texlite 0.19.2 → 0.20.0
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/DESIGN.md +241 -7
- package/OPERATIONS.md +7 -4
- package/README.md +6 -1
- package/README.zh-CN.md +4 -1
- package/dist/client/assets/AdminUsers-BghRo_hC.js +1 -0
- package/dist/client/assets/AdminUsers-BghRo_hC.js.br +0 -0
- package/dist/client/assets/AdminUsers-BghRo_hC.js.gz +0 -0
- package/dist/client/assets/AgentIcon-DsoMeMA8.js +1 -0
- package/dist/client/assets/AgentIcon-DsoMeMA8.js.br +0 -0
- package/dist/client/assets/AgentIcon-DsoMeMA8.js.gz +0 -0
- package/dist/client/assets/AgentIcon-dCMgWJG-.css +1 -0
- package/dist/client/assets/AgentIcon-dCMgWJG-.css.br +0 -0
- package/dist/client/assets/AgentIcon-dCMgWJG-.css.gz +0 -0
- package/dist/client/assets/AgentManagement-rIYtm4Bo.js +1 -0
- package/dist/client/assets/AgentManagement-rIYtm4Bo.js.br +0 -0
- package/dist/client/assets/AgentManagement-rIYtm4Bo.js.gz +0 -0
- package/dist/client/assets/AgentTerminal-BEjiw51y.js +2 -0
- package/dist/client/assets/AgentTerminal-BEjiw51y.js.br +0 -0
- package/dist/client/assets/AgentTerminal-BEjiw51y.js.gz +0 -0
- package/dist/client/assets/{AgentTerminalSurface-C11baRxh.js → AgentTerminalSurface-B2rwONYs.js} +2 -2
- package/dist/client/assets/AgentTerminalSurface-B2rwONYs.js.br +0 -0
- package/dist/client/assets/AgentTerminalSurface-B2rwONYs.js.gz +0 -0
- package/dist/client/assets/AvatarSettingsDialog-DplRpiJJ.js +1 -0
- package/dist/client/assets/AvatarSettingsDialog-DplRpiJJ.js.br +0 -0
- package/dist/client/assets/AvatarSettingsDialog-DplRpiJJ.js.gz +0 -0
- package/dist/client/assets/CitationBibtexEditor-BnK6nZPi.js +1 -0
- package/dist/client/assets/CitationLibraryDialog-CZvJiTmT.js +3 -0
- package/dist/client/assets/CitationLibraryDialog-CZvJiTmT.js.br +0 -0
- package/dist/client/assets/CitationLibraryDialog-CZvJiTmT.js.gz +0 -0
- package/dist/client/assets/CitationNotesPreview-CiIzdjCa.js +36 -0
- package/dist/client/assets/CitationNotesPreview-CiIzdjCa.js.br +0 -0
- package/dist/client/assets/CitationNotesPreview-CiIzdjCa.js.gz +0 -0
- package/dist/client/assets/Dashboard-Dcl0Y_C3.js +5 -0
- package/dist/client/assets/Dashboard-Dcl0Y_C3.js.br +0 -0
- package/dist/client/assets/Dashboard-Dcl0Y_C3.js.gz +0 -0
- package/dist/client/assets/GitDialog-BeYvUCDv.js +3 -0
- package/dist/client/assets/GitDialog-BeYvUCDv.js.br +0 -0
- package/dist/client/assets/GitDialog-BeYvUCDv.js.gz +0 -0
- package/dist/client/assets/GitHubAccountDialog-BGKINOwJ.js +1 -0
- package/dist/client/assets/GitHubAccountDialog-BGKINOwJ.js.br +0 -0
- package/dist/client/assets/GitHubAccountDialog-BGKINOwJ.js.gz +0 -0
- package/dist/client/assets/GitHubIcon-CExJn0AV.js +1 -0
- package/dist/client/assets/HistoryDialog-B-C4Zaef.js +8 -0
- package/dist/client/assets/HistoryDialog-B-C4Zaef.js.br +0 -0
- package/dist/client/assets/HistoryDialog-B-C4Zaef.js.gz +0 -0
- package/dist/client/assets/InfoPopover-Dkz742vJ.js +1 -0
- package/dist/client/assets/LatexEditor-CohUJrGD.js +25 -0
- package/dist/client/assets/LatexEditor-CohUJrGD.js.br +0 -0
- package/dist/client/assets/LatexEditor-CohUJrGD.js.gz +0 -0
- package/dist/client/assets/PdfPreview-BvJxduy3.js +1 -0
- package/dist/client/assets/PdfPreview-BvJxduy3.js.br +0 -0
- package/dist/client/assets/PdfPreview-BvJxduy3.js.gz +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-B9_XvdIC.js +1 -0
- package/dist/client/assets/ProjectIconPickerDialog-B9_XvdIC.js.br +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-B9_XvdIC.js.gz +0 -0
- package/dist/client/assets/ProjectSettings-D8uH3PqQ.js +4 -0
- package/dist/client/assets/ProjectSettings-D8uH3PqQ.js.br +0 -0
- package/dist/client/assets/ProjectSettings-D8uH3PqQ.js.gz +0 -0
- package/dist/client/assets/ProjectWorkspace-BZj-CRZB.js +31 -0
- package/dist/client/assets/ProjectWorkspace-BZj-CRZB.js.br +0 -0
- package/dist/client/assets/ProjectWorkspace-BZj-CRZB.js.gz +0 -0
- package/dist/client/assets/QuickOpenDialog-B9bf5mnw.js +1 -0
- package/dist/client/assets/QuickOpenDialog-B9bf5mnw.js.br +0 -0
- package/dist/client/assets/QuickOpenDialog-B9bf5mnw.js.gz +0 -0
- package/dist/client/assets/ReadOnlySource-BZ7WYQO7.js +2 -0
- package/dist/client/assets/SaveButton-wiTpGLho.js +1 -0
- package/dist/client/assets/{SelectionHistoryDialog-cDxbuXmO.js → SelectionHistoryDialog-DYQb9hXp.js} +2 -2
- package/dist/client/assets/SelectionHistoryDialog-DYQb9hXp.js.br +0 -0
- package/dist/client/assets/SelectionHistoryDialog-DYQb9hXp.js.gz +0 -0
- package/dist/client/assets/SharedProjectPage-BOGGeyBG.css +1 -0
- package/dist/client/assets/SharedProjectPage-DJjR-D8d.js +2 -0
- package/dist/client/assets/SharedProjectPage-DJjR-D8d.js.br +0 -0
- package/dist/client/assets/SharedProjectPage-DJjR-D8d.js.gz +0 -0
- package/dist/client/assets/SystemMetricsDialog-BExTHWxg.js +1 -0
- package/dist/client/assets/SystemMetricsDialog-BExTHWxg.js.br +0 -0
- package/dist/client/assets/SystemMetricsDialog-BExTHWxg.js.gz +0 -0
- package/dist/client/assets/{TagColorSelect-D-zwdawC.js → TagColorSelect-CzPUDAny.js} +1 -1
- package/dist/client/assets/TagManagementDialog-BBOpD_62.js +1 -0
- package/dist/client/assets/TagManagementDialog-BBOpD_62.js.br +0 -0
- package/dist/client/assets/TagManagementDialog-BBOpD_62.js.gz +0 -0
- package/dist/client/assets/ThemeSwitcher-BTDUp7Wj.js +1 -0
- package/dist/client/assets/ThemeSwitcher-BTDUp7Wj.js.br +0 -0
- package/dist/client/assets/ThemeSwitcher-BTDUp7Wj.js.gz +0 -0
- package/dist/client/assets/WordCountDialog-CgDcnPdJ.js +1 -0
- package/dist/client/assets/WordCountDialog-CgDcnPdJ.js.br +0 -0
- package/dist/client/assets/WordCountDialog-CgDcnPdJ.js.gz +0 -0
- package/dist/client/assets/arrow-down-C_4f1E-E.js +1 -0
- package/dist/client/assets/check-Dw16EqG-.js +1 -0
- package/dist/client/assets/chevron-up-BHaMUEEA.js +1 -0
- package/dist/client/assets/{chktex-Dm6IIkcR.js → chktex-BeOSrdut.js} +1 -1
- package/dist/client/assets/circle-check-CunlnBPw.js +1 -0
- package/dist/client/assets/clipboard-CslquMx4.js +1 -0
- package/dist/client/assets/clock-3-DztJubz_.js +1 -0
- package/dist/client/assets/createLucideIcon-CDYIzuiB.js +1 -0
- package/dist/client/assets/createLucideIcon-CDYIzuiB.js.br +0 -0
- package/dist/client/assets/createLucideIcon-CDYIzuiB.js.gz +0 -0
- package/dist/client/assets/dist-B_WjsTVV.js +1 -0
- package/dist/client/assets/dist-B_WjsTVV.js.br +0 -0
- package/dist/client/assets/dist-B_WjsTVV.js.gz +0 -0
- package/dist/client/assets/dist-Bcdl4EAC.js +1 -0
- package/dist/client/assets/dist-Bcdl4EAC.js.br +0 -0
- package/dist/client/assets/dist-Bcdl4EAC.js.gz +0 -0
- package/dist/client/assets/dist-DdUqlCPw.js +1 -0
- package/dist/client/assets/dist-DdUqlCPw.js.br +0 -0
- package/dist/client/assets/dist-DdUqlCPw.js.gz +0 -0
- package/dist/client/assets/editor-JqCouYk8.js +14 -0
- package/dist/client/assets/editor-JqCouYk8.js.br +0 -0
- package/dist/client/assets/editor-JqCouYk8.js.gz +0 -0
- package/dist/client/assets/editor-languages-CRI2h3Fj.js +36 -0
- package/dist/client/assets/editor-languages-CRI2h3Fj.js.br +0 -0
- package/dist/client/assets/editor-languages-CRI2h3Fj.js.gz +0 -0
- package/dist/client/assets/editorThemeExtension-BNWs0sHh.js +1 -0
- package/dist/client/assets/editorThemeExtension-BNWs0sHh.js.br +0 -0
- package/dist/client/assets/editorThemeExtension-BNWs0sHh.js.gz +0 -0
- package/dist/client/assets/es2015-D2UDOM09.js +41 -0
- package/dist/client/assets/es2015-D2UDOM09.js.br +0 -0
- package/dist/client/assets/es2015-D2UDOM09.js.gz +0 -0
- package/dist/client/assets/eye-BnslGpqB.js +1 -0
- package/dist/client/assets/hard-drive-CXlummIE.js +1 -0
- package/dist/client/assets/i18n-Bv4wFb8D.js +13 -0
- package/dist/client/assets/i18n-Bv4wFb8D.js.br +0 -0
- package/dist/client/assets/i18n-Bv4wFb8D.js.gz +0 -0
- package/dist/client/assets/index-Bdb2ITID.js +2 -0
- package/dist/client/assets/index-Bdb2ITID.js.br +0 -0
- package/dist/client/assets/index-Bdb2ITID.js.gz +0 -0
- package/dist/client/assets/index-wqKiaXZr.css +1 -0
- package/dist/client/assets/index-wqKiaXZr.css.br +0 -0
- package/dist/client/assets/index-wqKiaXZr.css.gz +0 -0
- package/dist/client/assets/katex-CBRBI6nR.js +257 -0
- package/dist/client/assets/katex-CBRBI6nR.js.br +0 -0
- package/dist/client/assets/katex-CBRBI6nR.js.gz +0 -0
- package/dist/client/assets/katex-CvRo0776.css +1 -0
- package/dist/client/assets/katex-CvRo0776.css.br +0 -0
- package/dist/client/assets/{katex-DDK6mlKN.css.gz → katex-CvRo0776.css.gz} +0 -0
- package/dist/client/assets/library-big-B8e_Fiql.js +1 -0
- package/dist/client/assets/loader-circle-DKGyi5EK.js +1 -0
- package/dist/client/assets/lock-keyhole-aC_QjKDi.js +1 -0
- package/dist/client/assets/minimize-2-CkBmeGXp.js +1 -0
- package/dist/client/assets/minus-DrpwqY8Y.js +1 -0
- package/dist/client/assets/refresh-cw-IqExWG6S.js +1 -0
- package/dist/client/assets/relativeTime-DlKXhH_h.js +1 -0
- package/dist/client/assets/relativeTime-DlKXhH_h.js.br +0 -0
- package/dist/client/assets/relativeTime-DlKXhH_h.js.gz +0 -0
- package/dist/client/assets/search-DjOWqLig.js +1 -0
- package/dist/client/assets/sourceCursorStore-C7u-3Gbl.js +1 -0
- package/dist/client/assets/sourceCursorStore-C7u-3Gbl.js.br +0 -0
- package/dist/client/assets/sourceCursorStore-C7u-3Gbl.js.gz +0 -0
- package/dist/client/assets/{spellCheck-DiNvmZKv.js → spellCheck-P-fMO4iR.js} +1 -1
- package/dist/client/assets/spellCheck-P-fMO4iR.js.br +0 -0
- package/dist/client/assets/spellCheck-P-fMO4iR.js.gz +0 -0
- package/dist/client/assets/tags-GrE3ZIQN.js +1 -0
- package/dist/client/assets/terminal-DD9WJ56e.js +1 -0
- package/dist/client/assets/{textLanguageSupport-DIXngcZX.js → textLanguageSupport-BSIE7WPM.js} +1 -1
- package/dist/client/assets/textLanguages-DAJ1OXJA.js +78 -0
- package/dist/client/assets/textLanguages-DAJ1OXJA.js.br +0 -0
- package/dist/client/assets/textLanguages-DAJ1OXJA.js.gz +0 -0
- package/dist/client/assets/type-CKe1tHHo.js +1 -0
- package/dist/client/assets/useDeletionTransitions-TAZINdHX.js +1 -0
- package/dist/client/assets/useDeletionTransitions-TAZINdHX.js.br +0 -0
- package/dist/client/assets/useDeletionTransitions-TAZINdHX.js.gz +0 -0
- package/dist/client/assets/useTranslation-DwkoADSz.js +1 -0
- package/dist/client/assets/useTranslation-DwkoADSz.js.br +0 -0
- package/dist/client/assets/useTranslation-DwkoADSz.js.gz +0 -0
- package/dist/client/assets/user-plus-NNBQOWDP.js +1 -0
- package/dist/client/assets/{vimSupport-RdD-E-Eh.js → vimSupport-BwIAfLU0.js} +6 -6
- package/dist/client/assets/vimSupport-BwIAfLU0.js.br +0 -0
- package/dist/client/assets/vimSupport-BwIAfLU0.js.gz +0 -0
- package/dist/client/index.html +9 -4
- package/dist/server/app.js +7 -1
- package/dist/server/byteRange.js +19 -0
- package/dist/server/citationCollections.js +163 -0
- package/dist/server/citationFolderTransfer.js +74 -0
- package/dist/server/citationInput.js +34 -0
- package/dist/server/collaboration.js +47 -16
- package/dist/server/commentMentions.js +6 -1
- package/dist/server/commentSuggestions.js +143 -0
- package/dist/server/db.js +81 -0
- package/dist/server/i18n.js +9 -0
- package/dist/server/locales/zh-Hant.js +6 -0
- package/dist/server/projectPreview.js +133 -0
- package/dist/server/routes/citations.js +84 -55
- package/dist/server/routes/commentSuggestions.js +154 -0
- package/dist/server/routes/comments.js +17 -1
- package/dist/server/routes/compile.js +1 -19
- package/dist/server/routes/projectShared.js +3 -0
- package/dist/server/routes/projectViewLinks.js +238 -0
- package/dist/server/routes/projects.js +12 -3
- package/dist/server/viewLinkTokens.js +49 -0
- package/dist/server/viewLinks.js +25 -0
- package/dist/shared/citationCollections.js +29 -0
- package/dist/shared/citationContent.js +4 -0
- package/dist/shared/citationTransfer.js +7 -0
- package/dist/shared/comments.js +2 -1
- package/dist/shared/projectCatalog.js +1 -1
- package/dist/shared/projectViewLinks.js +20 -0
- package/dist/shared/suggestionMessages.js +41 -0
- package/dist/shared/updates.js +1 -1
- package/package.json +9 -1
- package/dist/client/assets/AdminUsers-D5vhK_Ae.js +0 -1
- package/dist/client/assets/AdminUsers-D5vhK_Ae.js.br +0 -0
- package/dist/client/assets/AdminUsers-D5vhK_Ae.js.gz +0 -0
- package/dist/client/assets/AgentIcon-C97W4Mt-.js +0 -1
- package/dist/client/assets/AgentIcon-C97W4Mt-.js.br +0 -0
- package/dist/client/assets/AgentIcon-C97W4Mt-.js.gz +0 -0
- package/dist/client/assets/AgentIcon-DxrC-zx_.css +0 -1
- package/dist/client/assets/AgentIcon-DxrC-zx_.css.br +0 -0
- package/dist/client/assets/AgentIcon-DxrC-zx_.css.gz +0 -0
- package/dist/client/assets/AgentManagement-D6I_GDL_.js +0 -1
- package/dist/client/assets/AgentManagement-D6I_GDL_.js.br +0 -0
- package/dist/client/assets/AgentManagement-D6I_GDL_.js.gz +0 -0
- package/dist/client/assets/AgentTerminal-fsHpIB_c.js +0 -2
- package/dist/client/assets/AgentTerminal-fsHpIB_c.js.br +0 -0
- package/dist/client/assets/AgentTerminal-fsHpIB_c.js.gz +0 -0
- package/dist/client/assets/AgentTerminalSurface-C11baRxh.js.br +0 -0
- package/dist/client/assets/AgentTerminalSurface-C11baRxh.js.gz +0 -0
- package/dist/client/assets/AvatarSettingsDialog-B80aSza0.js +0 -1
- package/dist/client/assets/AvatarSettingsDialog-B80aSza0.js.br +0 -0
- package/dist/client/assets/AvatarSettingsDialog-B80aSza0.js.gz +0 -0
- package/dist/client/assets/CitationLibraryDialog-DE7W81FW.js +0 -1
- package/dist/client/assets/CitationLibraryDialog-DE7W81FW.js.br +0 -0
- package/dist/client/assets/CitationLibraryDialog-DE7W81FW.js.gz +0 -0
- package/dist/client/assets/Dashboard-DAPwKNNH.js +0 -5
- package/dist/client/assets/Dashboard-DAPwKNNH.js.br +0 -0
- package/dist/client/assets/Dashboard-DAPwKNNH.js.gz +0 -0
- package/dist/client/assets/GitDialog-BzyA_IgU.js +0 -3
- package/dist/client/assets/GitDialog-BzyA_IgU.js.br +0 -0
- package/dist/client/assets/GitDialog-BzyA_IgU.js.gz +0 -0
- package/dist/client/assets/GitHubAccountDialog-tigrQQNz.js +0 -1
- package/dist/client/assets/GitHubAccountDialog-tigrQQNz.js.br +0 -0
- package/dist/client/assets/GitHubAccountDialog-tigrQQNz.js.gz +0 -0
- package/dist/client/assets/GitHubIcon-BqDow-CN.js +0 -1
- package/dist/client/assets/HistoryDialog-407q3Fe6.js +0 -8
- package/dist/client/assets/HistoryDialog-407q3Fe6.js.br +0 -0
- package/dist/client/assets/HistoryDialog-407q3Fe6.js.gz +0 -0
- package/dist/client/assets/LatexEditor-BYiVPD_b.js +0 -101
- package/dist/client/assets/LatexEditor-BYiVPD_b.js.br +0 -0
- package/dist/client/assets/LatexEditor-BYiVPD_b.js.gz +0 -0
- package/dist/client/assets/PdfPreview-Bbzop29j.js +0 -1
- package/dist/client/assets/PdfPreview-Bbzop29j.js.br +0 -0
- package/dist/client/assets/PdfPreview-Bbzop29j.js.gz +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-CsT5Pj4j.js +0 -1
- package/dist/client/assets/ProjectIconPickerDialog-CsT5Pj4j.js.br +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-CsT5Pj4j.js.gz +0 -0
- package/dist/client/assets/ProjectSettings-BfvAiyC6.js +0 -4
- package/dist/client/assets/ProjectSettings-BfvAiyC6.js.br +0 -0
- package/dist/client/assets/ProjectSettings-BfvAiyC6.js.gz +0 -0
- package/dist/client/assets/ProjectWorkspace-DHVcaXR0.js +0 -30
- package/dist/client/assets/ProjectWorkspace-DHVcaXR0.js.br +0 -0
- package/dist/client/assets/ProjectWorkspace-DHVcaXR0.js.gz +0 -0
- package/dist/client/assets/QuickOpenDialog-DKq9iNJ5.js +0 -1
- package/dist/client/assets/QuickOpenDialog-DKq9iNJ5.js.br +0 -0
- package/dist/client/assets/QuickOpenDialog-DKq9iNJ5.js.gz +0 -0
- package/dist/client/assets/SaveButton-C8W1DGzx.js +0 -1
- package/dist/client/assets/SelectionHistoryDialog-cDxbuXmO.js.br +0 -0
- package/dist/client/assets/SelectionHistoryDialog-cDxbuXmO.js.gz +0 -0
- package/dist/client/assets/SystemMetricsDialog-GZbYEHna.js +0 -1
- package/dist/client/assets/SystemMetricsDialog-GZbYEHna.js.br +0 -0
- package/dist/client/assets/SystemMetricsDialog-GZbYEHna.js.gz +0 -0
- package/dist/client/assets/TagManagementDialog-BN3tlXuW.js +0 -1
- package/dist/client/assets/TagManagementDialog-BN3tlXuW.js.br +0 -0
- package/dist/client/assets/TagManagementDialog-BN3tlXuW.js.gz +0 -0
- package/dist/client/assets/WordCountDialog-C4okQWS3.js +0 -1
- package/dist/client/assets/WordCountDialog-C4okQWS3.js.br +0 -0
- package/dist/client/assets/WordCountDialog-C4okQWS3.js.gz +0 -0
- package/dist/client/assets/arrow-down-BiIGj4-X.js +0 -1
- package/dist/client/assets/check-DfWHdQ1s.js +0 -1
- package/dist/client/assets/chevron-up-lyMKml7P.js +0 -1
- package/dist/client/assets/circle-check-DjXwnxuR.js +0 -1
- package/dist/client/assets/clock-3-D-XeFtkK.js +0 -1
- package/dist/client/assets/dist-ByqeNQqT.js +0 -1
- package/dist/client/assets/dist-ByqeNQqT.js.br +0 -0
- package/dist/client/assets/dist-ByqeNQqT.js.gz +0 -0
- package/dist/client/assets/dist-Dxkdrap6.js +0 -2
- package/dist/client/assets/dist-Dxkdrap6.js.br +0 -0
- package/dist/client/assets/dist-Dxkdrap6.js.gz +0 -0
- package/dist/client/assets/editor-languages-C6EDWlLD.js +0 -36
- package/dist/client/assets/editor-languages-C6EDWlLD.js.br +0 -0
- package/dist/client/assets/editor-languages-C6EDWlLD.js.gz +0 -0
- package/dist/client/assets/editor-oR9RlWUz.js +0 -14
- package/dist/client/assets/editor-oR9RlWUz.js.br +0 -0
- package/dist/client/assets/editor-oR9RlWUz.js.gz +0 -0
- package/dist/client/assets/eye-BvCLgqrq.js +0 -1
- package/dist/client/assets/hard-drive-Crh-l_oh.js +0 -1
- package/dist/client/assets/i18n-O9QnEo2t.js +0 -13
- package/dist/client/assets/i18n-O9QnEo2t.js.br +0 -0
- package/dist/client/assets/i18n-O9QnEo2t.js.gz +0 -0
- package/dist/client/assets/index-7d5TfVNx.css +0 -1
- package/dist/client/assets/index-7d5TfVNx.css.br +0 -0
- package/dist/client/assets/index-7d5TfVNx.css.gz +0 -0
- package/dist/client/assets/index-DFEpXxLs.js +0 -42
- package/dist/client/assets/index-DFEpXxLs.js.br +0 -0
- package/dist/client/assets/index-DFEpXxLs.js.gz +0 -0
- package/dist/client/assets/info-g1IBvVg6.js +0 -1
- package/dist/client/assets/katex-Bd0sKoun.js +0 -257
- package/dist/client/assets/katex-Bd0sKoun.js.br +0 -0
- package/dist/client/assets/katex-Bd0sKoun.js.gz +0 -0
- package/dist/client/assets/katex-DDK6mlKN.css +0 -1
- package/dist/client/assets/katex-DDK6mlKN.css.br +0 -0
- package/dist/client/assets/minimize-2-BHKmubQs.js +0 -1
- package/dist/client/assets/minus-BmWzkFwz.js +0 -1
- package/dist/client/assets/plus-CoYCCEFJ.js +0 -1
- package/dist/client/assets/refresh-cw-Di6Huxb4.js +0 -1
- package/dist/client/assets/relativeTime-CFNodf1I.js +0 -1
- package/dist/client/assets/relativeTime-CFNodf1I.js.br +0 -0
- package/dist/client/assets/relativeTime-CFNodf1I.js.gz +0 -0
- package/dist/client/assets/search-l36unLLS.js +0 -1
- package/dist/client/assets/spellCheck-DiNvmZKv.js.br +0 -0
- package/dist/client/assets/spellCheck-DiNvmZKv.js.gz +0 -0
- package/dist/client/assets/tags-yjr9KRc8.js +0 -1
- package/dist/client/assets/terminal-P09ZGT83.js +0 -1
- package/dist/client/assets/type-C7rzXWVU.js +0 -1
- package/dist/client/assets/user-plus-CqyV7OV4.js +0 -1
- package/dist/client/assets/vimSupport-RdD-E-Eh.js.br +0 -0
- package/dist/client/assets/vimSupport-RdD-E-Eh.js.gz +0 -0
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./spellCheck-DiNvmZKv.js","./index-DFEpXxLs.js","./rolldown-runtime-XKyaHtl9.js","./react-DUEFWlB7.js","./i18nInstance-CIMFwH0l.js","./i18n-O9QnEo2t.js","./basePath-B5-c90eh.js","./vite-runtime-CRzLMJPS.js","./index-7d5TfVNx.css","./chktex-Dm6IIkcR.js","./LatexEditor-BYiVPD_b.js","./relativeTime-CFNodf1I.js","./editor-oR9RlWUz.js","./CitationLibraryDialog-DE7W81FW.js","./check-DfWHdQ1s.js","./chevron-up-lyMKml7P.js","./tags-yjr9KRc8.js","./plus-CoYCCEFJ.js","./SaveButton-C8W1DGzx.js","./circle-check-DjXwnxuR.js","./search-l36unLLS.js","./dist-ByqeNQqT.js","./SuccessNotice-ubBtzzi_.js","./TagColorSelect-D-zwdawC.js","./citationLibrary-BzlqZiFU.js","./GitDialog-BzyA_IgU.js","./GitHubIcon-BqDow-CN.js","./eye-BvCLgqrq.js","./minus-BmWzkFwz.js","./minimize-2-BHKmubQs.js","./HistoryDialog-407q3Fe6.js","./clock-3-D-XeFtkK.js","./hard-drive-Crh-l_oh.js","./dist-Dxkdrap6.js","./SelectionHistoryDialog-cDxbuXmO.js","./QuickOpenDialog-DKq9iNJ5.js","./ProjectSettings-BfvAiyC6.js","./refresh-cw-Di6Huxb4.js","./terminal-P09ZGT83.js","./type-C7rzXWVU.js","./AgentTerminal-fsHpIB_c.js","./info-g1IBvVg6.js","./AgentIcon-C97W4Mt-.js","./AgentIcon-DxrC-zx_.css","./WordCountDialog-C4okQWS3.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{n as e,r as t}from"./rolldown-runtime-XKyaHtl9.js";import{i as n,r,t as i}from"./react-DUEFWlB7.js";import{a,r as o,s,t as c}from"./i18nInstance-CIMFwH0l.js";import{t as l}from"./i18n-O9QnEo2t.js";import{r as u,t as d}from"./basePath-B5-c90eh.js";import{t as f}from"./vite-runtime-CRzLMJPS.js";import{t as p}from"./arrow-down-BiIGj4-X.js";import{$ as m,B as h,C as g,D as _,E as v,F as y,G as b,H as x,I as S,J as C,K as w,L as T,O as E,P as D,Q as O,R as k,T as A,U as j,V as M,W as N,X as P,Y as F,Z as ee,_ as te,at as ne,b as re,et as ie,f as ae,i as oe,it as I,k as L,n as R,nt as se,o as z,ot as ce,q as B,r as le,rt as V,st as ue,t as de,tt as fe,v as pe,w as me,x as he,y as ge,z as _e}from"./relativeTime-CFNodf1I.js";import{t as ve}from"./check-DfWHdQ1s.js";import{t as H}from"./chevron-up-lyMKml7P.js";import{t as ye}from"./circle-check-DjXwnxuR.js";import{t as be}from"./refresh-cw-Di6Huxb4.js";import{t as U}from"./SaveButton-C8W1DGzx.js";import{t as xe}from"./user-plus-CqyV7OV4.js";import{A as Se,C as W,E as G,F as Ce,I as we,M as Te,N as Ee,O as De,P as Oe,S as ke,T as Ae,b as K,c as je,i as Me,j as Ne,k as Pe,o as Fe,s as Ie,w as Le,y as Re}from"./index-DFEpXxLs.js";import{a as ze,l as q,n as Be,r as Ve,t as He}from"./dist-ByqeNQqT.js";var Ue={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,"!doctype":!0,"!DOCTYPE":!0},We=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?("[^"]*"|'[^']*')/g;function Ge(e){let t={type:`tag`,name:``,voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(Ue[n[1]]||e.charAt(e.length-2)===`/`)&&(t.voidElement=!0),t.name.startsWith(`!--`))){let t=e.indexOf(`-->`);return{type:`comment`,comment:t===-1?``:e.slice(4,t)}}let r=new RegExp(We),i=null;for(;i=r.exec(e),i!==null;)if(i[0].trim()){if(i[1]){let e=i[1].trim(),n=[e,null],a=e.indexOf(`=`);a>-1&&(n=[e.slice(0,a),e.slice(a+1)]),t.attrs[n[0]]=n[1],r.lastIndex--}else i[2]&&(t.attrs[i[2]]=i[3].trim().substring(1,i[3].length-1))}return t}var Ke=/<!--[\s\S]*?-->|<[a-zA-Z0-9\-!/](?:"[^"]*"|'[^']*'|[^'">])*>/g,qe=/<\/?([^\s]+?)[/\s>]/,Je=/^\s*$/,Ye=/^(script|style)$/i,Xe=`\0`,Ze=Object.create(null);function Qe(e){e.forEach(function(e){if(e.type===`text`)e.content=e.content.split(Xe).join(`<`);else if(e.type===`comment`)e.comment=e.comment.split(Xe).join(`<`);else{for(let t in e.attrs){let n=e.attrs[t];typeof n==`string`&&n.indexOf(Xe)>-1&&(e.attrs[t]=n.split(Xe).join(`<`))}e.children.length&&Qe(e.children)}})}function $e(e,t){let n=t&&t.components||Ze,r=t&&t.allowedTags,i=!1;if(r){let t=typeof r==`function`?r:function(e){return r.indexOf(e)>-1},n=``,a=0;Ke.lastIndex=0;let o;for(;o=Ke.exec(e);){let r=o[0];n+=e.slice(a,o.index);let s=r.match(qe);r.startsWith(`<!--`)||s&&t(s[1])?(n+=r,a=o.index+r.length):(i=!0,n+=Xe,a=o.index+1,Ke.lastIndex=a)}e=n+e.slice(a)}let a=[],o=[],s,c=-1,l=!1,u=0,d;if(e.indexOf(`<`)!==0){let t=e.indexOf(`<`);a.push({type:`text`,content:t===-1?e:e.substring(0,t)})}let f=[],p;for(;p=Ke.exec(e);)f.push(p);return f.forEach(function(e,t){let n=e[0];if(!n||n.startsWith(`<!--`))return;let r=0,i=0,a=-1,o=null;for(let e=0;e<n.length;e++){let t=n.charAt(e);o?t===o&&(o=null):t===`"`||t===`'`?o=t:t===`<`?(r++,r===2&&(a=e)):t===`>`&&i++}let s=a>-1&&/[a-zA-Z0-9\-!/]/.test(n.charAt(a+1));if(r>i&&s){let e=n.substring(0,a),r=n.substring(e.length);f[t][0]=r,f[t].index+=e.length}}),f.forEach(function(t,r){let i=t[0];if(!i)return;let p=t.index;if(p<u)return;if(l){if(i!==`</`+s.name+`>`)return;l=!1}let m=i.charAt(1)!==`/`,h=i.startsWith(`<!--`),g=p+i.length,_=e.charAt(g),v=f[r+1],y;if(_===`<`&&v){let t=e.substring(g,v.index);y=t.split(`<`).length>t.split(`>`).length}let b;if(h){let t=Ge(i);if(c<0)return a.push(t),a;b=o[c],b.children.push(t);let n=e.slice(g,v?v.index:void 0);return n.length>0&&b.children.push({type:`text`,content:n}),a}if(m){c++,s=Ge(i),s.type===`tag`&&n[s.name]&&(s.type=`component`,l=!0);let t=!1;if(!l&&!s.voidElement&&Ye.test(s.name)){t=!0,d||=e.toLowerCase();let n=d.indexOf(`</`+s.name.toLowerCase()+`>`,g),r=n===-1?e.length:n,i=e.slice(g,r);i&&s.children.push({type:`text`,content:i}),u=r}!s.voidElement&&!l&&!t&&_&&_!==`<`&&s.children.push({type:`text`,content:e.slice(g,v?v.index:void 0)}),c===0&&a.push(s),b=o[c-1],b&&b.children.push(s),o[c]=s}if((!m||s.voidElement)&&(c>-1&&(s.voidElement||s.name===i.slice(2,-1))&&(c--,s=c===-1?a:o[c]),!l&&(_!==`<`||y)&&_)){b=c===-1?a:o[c].children;let t=v?v.index:-1,n=e.slice(g,t===-1?void 0:t);Je.test(n)&&(n=` `),(t>-1&&c+b.length>=0||n!==` `)&&b.push({type:`text`,content:n})}}),i&&Qe(a),a}function et(e){let t=[];for(let n in e)e[n]===null?t.push(n):t.push(n+`="`+String(e[n]).replace(/"/g,`"`)+`"`);return t.length?` `+t.join(` `):``}function tt(e,t){switch(t.type){case`text`:return e+t.content;case`tag`:{let n=t.voidElement&&t.name.toLowerCase()!==`!doctype`?`/>`:`>`;return e+=`<`+t.name+(t.attrs?et(t.attrs):``)+n,t.voidElement?e:e+t.children.reduce(tt,``)+`</`+t.name+`>`}case`comment`:return e+=`<!--`+t.comment+`-->`,e}}function nt(e){return e.reduce(function(e,t){return e+tt(``,t)},``)}var rt={parse:$e,stringify:nt},J=t(n()),it=(e,t)=>{if(!e)return!1;let n=e.props?.children??e.children;return t?n.length>0:!!n},at=e=>{if(!e)return[];let t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?st(t):t},ot=e=>st(e).every(J.isValidElement),st=e=>Array.isArray(e)?e:[e],ct=(e,t)=>{let n={...t};return n.props={...t.props,...e.props},n},lt=e=>{let t={};if(!e)return t;let n=e=>{st(e).forEach(e=>{Oe(e)||(it(e)?n(at(e)):Ee(e)&&!(0,J.isValidElement)(e)&&Object.assign(t,e))})};return n(e),t},ut=(e,t,n,r)=>{if(!e)return``;let i=``,a=st(e),o=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return a.forEach((e,a)=>{if(Oe(e))i+=`${e}`;else if((0,J.isValidElement)(e)){let{props:s,type:c}=e,l=Object.keys(s).length,u=o.indexOf(c)>-1,d=s.children;if(!d&&u&&!l){i+=`<${c}/>`;return}if(!d&&(!u||l)||s.i18nIsDynamicList){i+=`<${a}></${a}>`;return}if(u&&l<=1){let e=Oe(d)?d:ut(d,t,n,r);i+=`<${c}>${e}</${c}>`;return}let f=ut(d,t,n,r);i+=`<${a}>${f}</${a}>`}else if(e===null)Ce(n,`TRANS_NULL_VALUE`,`Passed in a null value as child`,{i18nKey:r});else if(Ee(e)){let{format:t,...a}=e,o=Object.keys(a);if(o.length===1){let e=t?`${o[0]}, ${t}`:o[0];i+=`{{${e}}}`;return}Ce(n,`TRANS_INVALID_OBJ`,`Invalid child - Object should only have keys {{ value, format }} (format is optional).`,{i18nKey:r,child:e})}else Ce(n,`TRANS_INVALID_VAR`,`Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`,{i18nKey:r,child:e})}),i},dt=(e,t,n,r,i,s,c)=>{if(n===``)return[];let l=i.transKeepBasicHtmlNodesFor||[],u=n&&new RegExp(l.map(e=>`<${e}`).join(`|`)).test(n);if(!e&&!t&&!u&&!c)return[n];let d=t??{},f=e=>{st(e).forEach(e=>{Oe(e)||(it(e)?f(at(e)):Ee(e)&&!(0,J.isValidElement)(e)&&Object.assign(d,e))})};f(e);let p=Object.keys(d),m=rt.parse(`<0>${n}</0>`,{allowedTags:e=>/^\d+$/.test(e)||l.indexOf(e)>-1||p.indexOf(e)>-1}),h={...d,...s},g=(e,t,n)=>{let r=at(e),i=v(r,t.children,n);return ot(r)&&i.length===0||e.props?.i18nIsDynamicList?r:i},_=(e,t,n,r,i)=>{e.dummy?(e.children=t,n.push((0,J.cloneElement)(e,{key:r},i?void 0:t))):n.push(...J.Children.map([e],e=>{if(e.type===J.Fragment||e.props?.i18nIsDynamicList!==void 0){let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t!==`children`&&t!==`i18nIsDynamicList`&&(n[t]=e.props[t])}),(0,J.createElement)(e.type,n,i?null:t)}let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t!==`ref`&&t!==`children`&&(n[t]=e.props[t])}),(0,J.cloneElement)(e,n,i?null:t)}))},v=(e,n,s)=>{let d=st(e),f=st(n),p={};return f.reduce((e,n,f)=>{let m=n.children?.[0]?.content&&r.services.interpolator.interpolate(n.children[0].content,h,r.language);if(n.type===`tag`){let o=d[parseInt(n.name,10)];!o&&t&&(o=t[n.name]),s.length===1&&!o&&(o=s[0][n.name]),o||={};let y={...n.attrs};c&&Object.keys(y).forEach(e=>{let t=y[e];Oe(t)&&(y[e]=a(t))});let b=Object.keys(y).length===0?o:ct({props:y},o),x=(0,J.isValidElement)(b),S=x&&it(n,!0)&&!n.voidElement,C=u&&Ee(b)&&b.dummy&&!x,w=Ee(t)&&Object.hasOwnProperty.call(t,n.name);if(Oe(b)){let t=r.services.interpolator.interpolate(b,h,r.language);e.push(t)}else if(it(b)||S){let t=g(b,n,s);_(b,t,e,f)}else if(C){let t=v(d,n.children,s);_(b,t,e,f)}else if(Number.isNaN(parseFloat(n.name))){if(w){let t=g(b,n,s);_(b,t,e,f,n.voidElement)}else if(i.transSupportBasicHtmlNodes&&l.indexOf(n.name)>-1){if(n.voidElement)e.push((0,J.createElement)(n.name,{key:`${n.name}-${f}`}));else{let t=p[n.name]||0;p[n.name]=t+1;let r,i=0;for(let e=0;e<d.length;e+=1){let a=d[e];if((0,J.isValidElement)(a)&&a.type===n.name){if(i===t){r=a;break}i+=1}}let a=r?st(at(r)):d,o=v(a,n.children,s);e.push((0,J.createElement)(n.name,{key:`${n.name}-${f}`},o))}}else if(n.voidElement)e.push(`<${n.name} />`);else{let t=v(d,n.children,s);e.push(`<${n.name}>${t}</${n.name}>`)}}else if(Ee(b)&&!x){let t=n.children[0]?m:null;t&&e.push(t)}else _(b,m,e,f,n.children.length!==1||!m)}else if(n.type===`text`){let t=i.transWrapTextNodes,a=typeof i.unescape==`function`?i.unescape:o().unescape,s=c?a(r.services.interpolator.interpolate(n.content,h,r.language)):r.services.interpolator.interpolate(n.content,h,r.language);t?e.push((0,J.createElement)(t,{key:`${n.name}-${f}`},s)):e.push(s)}return e},[])};return at(v([{dummy:!0,children:e||[]}],m,st(e||[]))[0])},ft=(e,t,n)=>{let r=e.key||t,i=(0,J.cloneElement)(e,{key:r});if(!i.props||!i.props.children||n.indexOf(`${t}/>`)<0&&n.indexOf(`${t} />`)<0)return i;function a(){return(0,J.createElement)(J.Fragment,null,i)}return(0,J.createElement)(a,{key:r})},pt=(e,t)=>e.map((e,n)=>ft(e,n,t)),mt=(e,t)=>{let n={};return Object.keys(e).forEach(r=>{Object.assign(n,{[r]:ft(e[r],r,t)})}),n},ht=(e,t,n,r)=>e?Array.isArray(e)?pt(e,t):Ee(e)?mt(e,t):(we(n,`TRANS_INVALID_COMPONENTS`,`<Trans /> "components" prop expects an object or array`,{i18nKey:r}),null):null,gt=e=>!Ee(e)||Array.isArray(e)?!1:Object.keys(e).reduce((e,t)=>e&&Number.isNaN(Number.parseFloat(t)),!0);function _t({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a={},values:l,defaults:u,components:d,ns:f,i18n:p,t:m,shouldUnescape:h,...g}){let _=p||c();if(!_)return we(_,`NO_I18NEXT_INSTANCE`,`Trans: You need to pass in an i18next instance using initReactI18next or by passing it via props or context. In monorepo setups, make sure there is only one instance of react-i18next.`,{i18nKey:r}),e;let v=m||_.t.bind(_)||(e=>e),y={...o(),..._.options?.react},b=f||(v.ns?void 0:_.options?.defaultNS||`translation`);Oe(b)&&(b=[b]);let{transDefaultProps:x}=y,S=x?.tOptions?{...x.tOptions,...a}:a,C=h??x?.shouldUnescape,w=x?.values?{...x.values,...l}:l,T=x?.components?{...x.components,...d}:d,E=ut(e,y,_,r),D=u||S?.defaultValue||E||y.transEmptyNodeValue||(typeof r==`function`?s(r):r),{hashTransKey:O}=y,k=r||(O?O(E||D):E||D);l=_.options?.interpolation?.defaultVariables?{..._.options.interpolation.defaultVariables,...w}:w;let A=lt(e);A&&typeof A.count==`number`&&t===void 0&&(t=A.count);let j=l||t!==void 0&&!_.options?.interpolation?.alwaysFormat||!e?S.interpolation:{interpolation:{...S.interpolation,prefix:`#$?`,suffix:`?$#`}},M={...S,context:i||S.context,count:t,...l,...j,defaultValue:D,ns:b},N=k?v(k,M):D;N===k&&D&&(N=D);let P=ht(T,N,_,r),F=P||e,ee=null;gt(P)&&(ee=P,F=e);let te=dt(F,ee,N,_,y,M,C),ne=n??y.defaultTransParent;return ne?(0,J.createElement)(ne,g,te):te}function vt({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a={},values:o,defaults:s,components:l,ns:u,i18n:d,t:f,shouldUnescape:p,...m}){let{i18n:h,defaultNS:g}=(0,J.useContext)(Te)||{},_=d||h||c(),v=f||_?.t.bind(_);return _t({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a,values:o,defaults:s,components:l,ns:u||(v?.ns?void 0:g||_?.options?.defaultNS),i18n:_,t:f,shouldUnescape:p,...m})}var yt={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};yt.node;var bt=K(yt),xt={name:`circle-question-mark`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`help-circle`,`circle-help`]};xt.node;var St=K(xt),Ct={name:`circle-x`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]],aliases:[`x-circle`]};Ct.node;var wt=K(Ct),Tt={name:`columns-2`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M12 3v18`,key:`108xh3`}]],aliases:[`columns`]};Tt.node;var Et=K(Tt),Dt={name:`eraser`,size:24,node:[[`path`,{d:`M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21`,key:`g5wo59`}],[`path`,{d:`m5.082 11.09 8.828 8.828`,key:`1wx5vj`}]]};Dt.node;var Y=K(Dt),Ot={name:`file-clock`,size:24,node:[[`path`,{d:`M16 22h2a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v2.85`,key:`ryk6xj`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 14v2.2l1.6 1`,key:`6m4bie`}],[`circle`,{cx:`8`,cy:`16`,r:`6`,key:`10v15b`}]]};Ot.node;var kt=K(Ot),At={name:`file-cog`,size:24,node:[[`path`,{d:`M15 8a1 1 0 0 1-1-1V2a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8z`,key:`1ckgky`}],[`path`,{d:`M20 8v12a2 2 0 0 1-2 2h-4.182`,key:`1726p0`}],[`path`,{d:`m3.305 19.53.923-.382`,key:`ao1pio`}],[`path`,{d:`M4 10.592V4a2 2 0 0 1 2-2h8`,key:`1foop0`}],[`path`,{d:`m4.228 16.852-.924-.383`,key:`1fv9zy`}],[`path`,{d:`m5.852 15.228-.383-.923`,key:`1a9hc2`}],[`path`,{d:`m5.852 20.772-.383.924`,key:`1sh9ke`}],[`path`,{d:`m8.148 15.228.383-.923`,key:`4yu6lf`}],[`path`,{d:`m8.53 21.696-.382-.924`,key:`18b0s9`}],[`path`,{d:`m9.773 16.852.922-.383`,key:`ti6xop`}],[`path`,{d:`m9.773 19.148.922.383`,key:`rws47d`}],[`circle`,{cx:`7`,cy:`18`,r:`3`,key:`lvkj7j`}]],aliases:[`file-cog-2`]};At.node;var jt=K(At),Mt={name:`file-headphone`,size:24,node:[[`path`,{d:`M4 6.835V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-.343`,key:`1vfytu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M2 19a2 2 0 0 1 4 0v1a2 2 0 0 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 0 1-4 0v-1a2 2 0 0 1 4 0`,key:`1etmh7`}]],aliases:[`file-audio`,`file-audio-2`]};Mt.node;var Nt=K(Mt),Pt={name:`file-image`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]};Pt.node;var Ft=K(Pt),It={name:`file-plus-corner`,size:24,node:[[`path`,{d:`M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35`,key:`17jvcc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 19h6`,key:`bvotb8`}],[`path`,{d:`M17 16v6`,key:`18yu1i`}]],aliases:[`file-plus-2`]};It.node;var Lt=K(It),Rt={name:`file-play`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M15.033 13.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56v-4.704a.645.645 0 0 1 .967-.56z`,key:`1tzo1f`}]],aliases:[`file-video`]};Rt.node;var zt=K(Rt),Bt={name:`file`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]};Bt.node;var Vt=K(Bt),Ht={name:`grip-vertical`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]};Ht.node;var Ut=K(Ht),Wt={name:`hash`,size:24,node:[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]};Wt.node;var Gt=K(Wt),Kt={name:`keyboard`,size:24,node:[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]};Kt.node;var qt=K(Kt),Jt={name:`library-big`,size:24,node:[[`rect`,{width:`8`,height:`18`,x:`3`,y:`3`,rx:`1`,key:`oynpb5`}],[`path`,{d:`M7 3v18`,key:`bbkbws`}],[`path`,{d:`M20.4 18.9c.2.5-.1 1.1-.6 1.3l-1.9.7c-.5.2-1.1-.1-1.3-.6L11.1 5.1c-.2-.5.1-1.1.6-1.3l1.9-.7c.5-.2 1.1.1 1.3.6Z`,key:`1qboyk`}]]};Jt.node;var Yt=K(Jt),Xt={name:`logs`,size:24,node:[[`path`,{d:`M3 5h1`,key:`1mv5vm`}],[`path`,{d:`M3 12h1`,key:`lp3yf2`}],[`path`,{d:`M3 19h1`,key:`w6f3n9`}],[`path`,{d:`M8 5h1`,key:`1nxr5w`}],[`path`,{d:`M8 12h1`,key:`1con00`}],[`path`,{d:`M8 19h1`,key:`k7p10e`}],[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}]]};Xt.node;var Zt=K(Xt),Qt={name:`messages-square`,size:24,node:[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]};Qt.node;var $t=K(Qt),en={name:`move`,size:24,node:[[`path`,{d:`M12 2v20`,key:`t6zp3m`}],[`path`,{d:`m15 19-3 3-3-3`,key:`11eu04`}],[`path`,{d:`m19 9 3 3-3 3`,key:`1mg7y2`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}],[`path`,{d:`m5 9-3 3 3 3`,key:`j64kie`}],[`path`,{d:`m9 5 3-3 3 3`,key:`l8vdw6`}]]};en.node;var tn=K(en),nn={name:`package-open`,size:24,node:[[`path`,{d:`M12 22v-9`,key:`x3hkom`}],[`path`,{d:`M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z`,key:`2ntwy6`}],[`path`,{d:`M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13`,key:`1pmm1c`}],[`path`,{d:`M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z`,key:`12ttoo`}]]};nn.node;var rn=K(nn),an={name:`panel-left-close`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]],aliases:[`sidebar-close`]};an.node;var on=K(an),sn={name:`panel-left-open`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]],aliases:[`sidebar-open`]};sn.node;var cn=K(sn),ln={name:`panel-left`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]],aliases:[`sidebar`]};ln.node;var un=K(ln),dn={name:`panel-right`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]};dn.node;var fn=K(dn),pn={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};pn.node;var mn=K(pn),hn={name:`rotate-ccw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]};hn.node;var gn=K(hn),_n={name:`send`,size:24,node:[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]};_n.node;var vn=K(_n),yn={name:`settings`,size:24,node:[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};yn.node;var bn=K(yn),xn={name:`wand-sparkles`,size:24,node:[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]],aliases:[`wand-2`]};xn.node;var Sn=K(xn),X=i(),Cn=new Set(`tex.latex.ltx.bib.bibtex.bst.sty.cls.dtx.ins.def.fd.aux.bbl.blg.log.toc.lof.lot.idx.ilg.ind.nav.snm.out.vrb.txt.text.dat.csv.tsv.md.markdown.mdown.mkdn.rst.ps.eps.json.jsonc.json5.jsonl.ipynb.yaml.yml.toml.ini.cfg.conf.cnf.env.properties.rc.lock.c.cc.cpp.cxx.h.hh.hpp.hxx.m.mm.cs.java.js.mjs.cjs.jsx.ts.mts.cts.tsx.py.pyw.pyi.r.rmd.qmd.jl.pl.pm.rb.go.rs.lua.php.sh.bash.zsh.ksh.fish.bashrc.zshrc.profile.awk.sed.ps1.psm1.bat.cmd.sql.html.htm.xhtml.css.scss.sass.less.xml.xsd.xsl.xslt.graphql.gql.proto.cmake.mk.diff.patch.srt.vtt.asc.pem`.split(`.`)),wn=new Set(`latexmkrc,.latexmkrc,readme,license,licence,copying,authors,changelog,makefile,gnumakefile,dockerfile,containerfile,pkgbuild,.gitignore,.gitattributes,.gitmodules,.dockerignore,.editorconfig,.npmrc,.yarnrc,.prettierrc,.eslintrc,.babelrc,.bashrc,.zshrc,.profile,.bash_profile,.zprofile`.split(`,`));function Tn(e){let t=e.split(`/`).at(-1)?.toLowerCase()??``,n=t.lastIndexOf(`.`),r=n>0?t.slice(n+1).toLowerCase():``;return r===`pdf`?`pdf`:/^(?:png|jpe?g|gif|webp|svg|bmp|ico|avif|tiff?)$/.test(r)?`image`:/^(?:zip|gz|bz2|xz|tar|rar|7z|zst|svgz|docx?|xlsx?|pptx?|od[tps]|mp[34]|wav|ogg|webm|mov|avi|flac|woff2?|ttf|otf|eot|pfb|pfa|tfm|vf|fmt|dvi|xdv|synctex|wasm|exe|bin|[ao]|so|dylib|dll|class|jar|sqlite3?|db|pyc|psd)$/.test(r)?`binary`:Cn.has(r)||wn.has(t)||t===`.env`||t.startsWith(`.env.`)||t.startsWith(`dockerfile.`)||t.startsWith(`containerfile.`)?`text`:`other`}function En(e,t){return!!e&&Tn(e)===`text`&&t!==!1}function Dn(e,t=!1){for(let t of e)if(t<32&&t!==9&&t!==10&&t!==12&&t!==13||t===127)return!1;try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(e,{stream:t}),!0}catch{return!1}}function On({size:e=16,...t}){return(0,X.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.75,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,...t,children:(0,X.jsx)(`path`,{d:`M2.5 17V7l5 5 5-5v10M19.5 7v10m-3-3 3 3 3-3`})})}function kn({size:e=16,variant:t=`document`,...n}){return(0,X.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.75,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,...n,children:t===`wordmark`?(0,X.jsx)(`path`,{d:`M2.5 17V7H5a2.5 2.5 0 0 1 0 5H2.5M9.5 7H11a5 5 0 0 1 0 10H9.5ZM21.5 7h-4v10m0-5H21`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`path`,{d:`M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9Z`}),(0,X.jsx)(`path`,{d:`M14 3v6h6`}),(0,X.jsx)(`path`,{transform:`translate(2.4 3.1) scale(.8)`,strokeWidth:1.5,d:`M5.5 18v-5H7a1.5 1.5 0 0 1 0 3H5.5M10 13h1a2.5 2.5 0 0 1 0 5h-1ZM18.5 13h-3v5m0-2.5H18`})]})})}function An({size:e=16,...t}){return(0,X.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,...t,children:(0,X.jsx)(`path`,{d:`M2 6.5h6m-3 0v10M14 9.5H9.5v10H14m-4.5-5h4M16 6.5l6 10m0-10-6 10`})})}var jn=new Set([`avif`,`bmp`,`gif`,`ico`,`jpeg`,`jpg`,`png`,`svg`,`webp`,`eps`]),Mn=new Set([`latex`,`ltx`,`tex`]),Nn=new Set(`aux.blg.bbl.bst.c.cc.cls.cpp.css.dtx.go.h.hpp.html.idx.ilg.ind.ins.java.js.json.jsx.lof.log.lot.lua.ltx.nav.out.php.py.r.rs.sh.snm.sql.sty.tex.toc.ts.tsx.vrb.xml.yaml.yml`.split(`.`)),Pn=new Set([`cfg`,`conf`,`dat`,`env`,`ini`,`text`,`toml`,`txt`]),Fn=new Set([`csv`,`ods`,`tsv`,`xls`,`xlsx`]),In=new Set([`7z`,`bz2`,`gz`,`rar`,`tar`,`xz`,`zip`]),Ln=new Set([`m4a`,`mp3`,`ogg`,`wav`]),Rn=new Set([`avi`,`mkv`,`mov`,`mp4`,`webm`]);function zn(e){let t=e.split(`/`).at(-1)?.toLocaleLowerCase()??``;if(t===`.latexmkrc`||t===`latexmkrc`)return`latexmkrc`;if(t===`makefile`||t===`dockerfile`)return`code`;if(t===`readme`)return`markdown`;let n=t.includes(`.`)?t.slice(t.lastIndexOf(`.`)+1):``;return n===`pdf`?`pdf`:jn.has(n)?`image`:n===`md`||n===`markdown`||n===`mdown`||n===`mkdn`?`markdown`:Mn.has(n)?`tex`:n===`bib`||n===`bibtex`?`bib`:Nn.has(n)?`code`:Pn.has(n)?`text`:Fn.has(n)?`spreadsheet`:In.has(n)?`archive`:Ln.has(n)?`audio`:Rn.has(n)?`video`:`file`}var Bn={bib:Yt,latexmkrc:jt,image:Ft,text:x,code:ee,spreadsheet:F,archive:O,audio:Nt,video:zt,file:Vt};function Vn({path:e,size:t=13}){let n=zn(e),r=`file-type-icon file-type-icon-${n}`;if(n===`pdf`)return(0,X.jsx)(kn,{className:r,size:t,variant:`wordmark`});if(n===`tex`)return(0,X.jsx)(An,{className:r,size:t});if(n===`markdown`)return(0,X.jsx)(On,{className:r,size:t});let i=Bn[n];return(0,X.jsx)(i,{className:r,size:t,"aria-hidden":`true`})}var Hn=()=>new Map,Un=e=>{let t=Hn();return e.forEach((e,n)=>{t.set(n,e)}),t},Wn=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},Gn=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},Kn=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},qn=()=>new Set,Jn=e=>e[e.length-1],Yn=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},Xn=Array.from,Zn=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},Qn=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},$n=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},er=Array.isArray,tr=class{constructor(){this._observers=Hn()}on(e,t){return Wn(this._observers,e,qn).add(t),t}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return Xn((this._observers.get(e)||Hn()).values()).forEach(e=>e(...t))}destroy(){this._observers=Hn()}},nr=class{constructor(){this._observers=Hn()}on(e,t){Wn(this._observers,e,qn).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return Xn((this._observers.get(e)||Hn()).values()).forEach(e=>e(...t))}destroy(){this._observers=Hn()}},rr=Math.floor,ir=Math.abs,ar=(e,t)=>e<t?e:t,or=(e,t)=>e>t?e:t;Number.isNaN;var sr=Math.pow,cr=e=>e===0?1/e<0:e<0,lr=1<<29,ur=2**53-1,dr=-(2**53-1),fr=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&rr(e)===e);Number.isNaN,Number.parseInt;var pr=String.fromCharCode;String.fromCodePoint,pr(65535);var mr=e=>e.toLowerCase(),hr=/^\s*/g,gr=e=>e.replace(hr,``),_r=/([A-Z])/g,vr=(e,t)=>gr(e.replace(_r,e=>`${t}${mr(e)}`)),yr=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},br=typeof TextEncoder<`u`?new TextEncoder:null,xr=br?e=>br.encode(e):yr,Sr=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});Sr&&Sr.decode(new Uint8Array).length===1&&(Sr=null);var Cr=(e,t)=>$n(t,()=>e).join(``),wr=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},Tr=()=>new wr,Er=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},Dr=e=>{let t=new Uint8Array(Er(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},Or=(e,t)=>{let n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(or(n,t)*2),e.cpos=0)},kr=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},Ar=kr,Z=(e,t)=>{for(;t>127;)kr(e,128|127&t),t=rr(t/128);kr(e,127&t)},jr=(e,t)=>{let n=cr(t);for(n&&(t=-t),kr(e,(t>63?128:0)|(n?64:0)|63&t),t=rr(t/64);t>0;)kr(e,(t>127?128:0)|127&t),t=rr(t/128)},Mr=new Uint8Array(3e4),Nr=Mr.length/3,Pr=br&&br.encodeInto?(e,t)=>{if(t.length<Nr){let n=br.encodeInto(t,Mr).written||0;Z(e,n);for(let t=0;t<n;t++)kr(e,Mr[t])}else Ir(e,xr(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;Z(e,r);for(let t=0;t<r;t++)kr(e,n.codePointAt(t))},Fr=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=ar(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(or(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},Ir=(e,t)=>{Z(e,t.byteLength),Fr(e,t)},Lr=(e,t)=>{Or(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},Rr=(e,t)=>Lr(e,4).setFloat32(0,t,!1),zr=(e,t)=>Lr(e,8).setFloat64(0,t,!1),Br=(e,t)=>Lr(e,8).setBigInt64(0,t,!1),Vr=new DataView(new ArrayBuffer(4)),Hr=e=>(Vr.setFloat32(0,e),Vr.getFloat32(0)===e),Ur=(e,t)=>{switch(typeof t){case`string`:kr(e,119),Pr(e,t);break;case`number`:fr(t)&&ir(t)<=2147483647?(kr(e,125),jr(e,t)):Hr(t)?(kr(e,124),Rr(e,t)):(kr(e,123),zr(e,t));break;case`bigint`:kr(e,122),Br(e,t);break;case`object`:if(t===null)kr(e,126);else if(er(t)){kr(e,117),Z(e,t.length);for(let n=0;n<t.length;n++)Ur(e,t[n])}else if(t instanceof Uint8Array)kr(e,116),Ir(e,t);else{kr(e,118);let n=Object.keys(t);Z(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];Pr(e,i),Ur(e,t[i])}}break;case`boolean`:kr(e,t?120:121);break;default:kr(e,127)}},Wr=class extends wr{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&Z(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},Gr=e=>{e.count>0&&(jr(e.encoder,e.count===1?e.s:-e.s),e.count>1&&Z(e.encoder,e.count-2))},Kr=class{constructor(){this.encoder=new wr,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Gr(this),this.count=1,this.s=e)}toUint8Array(){return Gr(this),Dr(this.encoder)}},qr=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);jr(e.encoder,t),e.count>1&&Z(e.encoder,e.count-2)}},Jr=class{constructor(){this.encoder=new wr,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(qr(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return qr(this),Dr(this.encoder)}},Yr=class{constructor(){this.sarr=[],this.s=``,this.lensE=new Kr}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=``),this.lensE.write(e.length)}toUint8Array(){let e=new wr;return this.sarr.push(this.s),this.s=``,Pr(e,this.sarr.join(``)),Fr(e,this.lensE.toUint8Array()),Dr(e)}},Xr=e=>Error(e),Zr=()=>{throw Xr(`Method unimplemented`)},Qr=()=>{throw Xr(`Unexpected case`)},$r=Xr(`Unexpected end of array`),ei=Xr(`Integer out of Range`),ti=class{constructor(e){this.arr=e,this.pos=0}},ni=e=>new ti(e),ri=e=>e.pos!==e.arr.length,ii=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},ai=e=>ii(e,Q(e)),oi=e=>e.arr[e.pos++],Q=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&127)*n,n*=128,r<128)return t;if(t>ur)throw ei}throw $r},si=e=>{let t=e.arr[e.pos++],n=t&63,r=64,i=(t&64)>0?-1:1;if(!(t&128))return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&127)*r,r*=128,t<128)return i*n;if(n>ur)throw ei}throw $r},ci=Sr?e=>Sr.decode(ai(e)):e=>{let t=Q(e);if(t===0)return``;{let n=String.fromCodePoint(oi(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(oi(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},li=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},ui=[e=>void 0,e=>null,si,e=>li(e,4).getFloat32(0,!1),e=>li(e,8).getFloat64(0,!1),e=>li(e,8).getBigInt64(0,!1),e=>!1,e=>!0,ci,e=>{let t=Q(e),n={};for(let r=0;r<t;r++){let t=ci(e);n[t]=di(e)}return n},e=>{let t=Q(e),n=[];for(let r=0;r<t;r++)n.push(di(e));return n},ai],di=e=>ui[127-oi(e)](e),fi=class extends ti{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),this.count=ri(this)?Q(this)+1:-1),this.count--,this.s}},pi=class extends ti{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=si(this);let e=cr(this.s);this.count=1,e&&(this.s=-this.s,this.count=Q(this)+2)}return this.count--,this.s}},mi=class extends ti{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=si(this),t=e&1;this.diff=rr(e/2),this.count=1,t&&(this.count=Q(this)+2)}return this.s+=this.diff,this.count--,this.s}},hi=class{constructor(e){this.decoder=new pi(e),this.str=ci(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}};crypto.subtle;var gi=crypto.getRandomValues.bind(crypto),_i=()=>gi(new Uint32Array(1))[0],vi=`10000000-1000-4000-8000-100000000000`,yi=()=>vi.replace(/[018]/g,e=>(e^_i()&15>>e/4).toString(16)),bi=Date.now,xi=e=>new Promise(e);Promise.all.bind(Promise);var Si=e=>e===void 0?null:e,Ci=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}},wi=!0;try{typeof localStorage<`u`&&localStorage&&(Ci=localStorage,wi=!1)}catch{}var Ti=Ci,Ei=e=>wi||addEventListener(`storage`,e),Di=e=>wi||removeEventListener(`storage`,e),Oi=Symbol(`Equality`),ki=(e,t)=>e===t||!!e?.[Oi]?.(t)||!1,Ai=e=>typeof e==`object`,ji=Object.assign,Mi=Object.keys,Ni=(e,t)=>{for(let n in e)t(e[n],n)},Pi=(e,t)=>{let n=[];for(let r in e)n.push(t(e[r],r));return n},Fi=e=>Mi(e).length,Ii=e=>{for(let t in e)return!1;return!0},Li=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},Ri=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),zi=(e,t)=>e===t||Fi(e)===Fi(t)&&Li(e,(e,n)=>(e!==void 0||Ri(t,n))&&ki(t[n],e)),Bi=Object.freeze,Vi=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&Vi(e[t])}return Bi(e)},Hi=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&Hi(e,t,n+1)}},Ui=e=>e,Wi=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[Oi]!=null)return e[Oi](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!Wi(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(Fi(e)!==Fi(t))return!1;for(let n in e)if(!Ri(e,n)||!Wi(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Wi(e[n],t[n]))return!1;break;default:return!1}return!0},Gi=(e,t)=>t.includes(e),Ki=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,qi=typeof window<`u`&&typeof document<`u`&&!Ki;typeof navigator<`u`&&/Mac/.test(navigator.platform);var Ji,Yi=[],Xi=()=>{if(Ji===void 0){if(Ki){Ji=Hn();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&Ji.set(t,``),t=r):t===null?Yi.push(r):(Ji.set(t,r),t=null)}t!==null&&Ji.set(t,``)}else typeof location==`object`?(Ji=Hn(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);Ji.set(`--${vr(t,`-`)}`,n),Ji.set(`-${vr(t,`-`)}`,n)}})):Ji=Hn()}return Ji},Zi=e=>Xi().has(e),Qi=e=>Si(Ki?{}[e.toUpperCase().replaceAll(`-`,`_`)]:Ti.getItem(e)),$i=e=>Zi(`--`+e)||Qi(e)!==null,ea=$i(`production`),ta=Ki&&Gi({}.FORCE_COLOR,[`true`,`1`,`2`])||!Zi(`--no-colors`)&&!$i(`no-color`)&&(!Ki||process.stdout.isTTY)&&(!Ki||Zi(`--color`)||Qi(`COLORTERM`)!==null||(Qi(`TERM`)||``).includes(`color`)),na=e=>new Uint8Array(e),ra=(e,t,n)=>new Uint8Array(e,t,n),ia=e=>new Uint8Array(e),aa=e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=pr(e[n]);return btoa(t)},oa=e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),sa=e=>{let t=atob(e),n=na(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n},ca=e=>{let t=Buffer.from(e,`base64`);return ra(t.buffer,t.byteOffset,t.byteLength)},la=qi?aa:oa,ua=qi?sa:ca,da=e=>{let t=na(e.byteLength);return t.set(e),t},fa=class{constructor(e,t){this.left=e,this.right=t}},pa=(e,t)=>new fa(e,t),ma=(e,t)=>e.forEach(e=>t(e.left,e.right)),ha=e=>e.next()>=.5,ga=(e,t,n)=>rr(e.next()*(n+1-t)+t),_a=(e,t,n)=>rr(e.next()*(n+1-t)+t),va=(e,t,n)=>_a(e,t,n),ya=e=>pr(va(e,97,122)),ba=(e,t=0,n=20)=>{let r=va(e,t,n),i=``;for(let t=0;t<r;t++)i+=ya(e);return i},xa=(e,t)=>t[va(e,0,t.length-1)],Sa=Symbol(`0schema`),Ca=class{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let n=this._rerrs[t];e.push(Cr(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
|
|
3
|
-
`)}},wa=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[Oi]?ki(e,t):er(e)?Zn(e,e=>Qn(t,t=>wa(e,t))):Ai(e)?Li(e,(e,n)=>wa(e,t[n])):!1,Ta=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),wa(t,n)}equals(e){return this.constructor===e.constructor&&Wi(this.shape,e.shape)}[Sa](){return!0}[Oi](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){Zr()}get nullable(){return io(this,bo)}get optional(){return new Ia(this)}cast(e){return wo(e,this),e}expect(e){return wo(e,this),e}},Ea=class extends Ta{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){let n=e?.constructor===this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor===this.shape?`Check failed`:`Constructor match failed`),n}},Da=(e,t=null)=>new Ea(e,t);Da(Ea);var Oa=class extends Ta{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape(e);return!n&&t?.extend(null,`custom prop`,e?.constructor.name,`failed to check custom prop`),n}},ka=e=>new Oa(e);Da(Oa);var Aa=class extends Ta{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape.some(t=>t===e);return!n&&t?.extend(null,this.shape.join(` | `),e.toString()),n}},ja=(...e)=>new Aa(e),Ma=Da(Aa),Na=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),Pa=e=>{if(ho.check(e))return[Na(e)];if(Ma.check(e))return e.shape.map(e=>e+``);if(mo.check(e))return[`[+-]?\\d+.?\\d*`];if(go.check(e))return[`.*`];if(ao.check(e))return e.shape.map(Pa).flat(1);Qr()};Da(class extends Ta{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(Pa).map(e=>`(${e.join(`|`)})`).join(``)+`$`)}check(e,t){let n=this._r.exec(e)!=null;return!n&&t?.extend(null,this._r.toString(),e.toString(),`String doesn't match string template.`),n}});var Fa=Symbol(`optional`),Ia=class extends Ta{constructor(e){super(),this.shape=e}check(e,t){let n=e===void 0||this.shape.check(e);return!n&&t?.extend(null,`undefined (optional)`,`()`),n}get[Fa](){return!0}},La=Da(Ia),Ra=class extends Ta{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new Ra,Da(Ra);var za=class e extends Ta{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new e(this.shape,!0)}check(e,t){return e==null?(t?.extend(null,`object`,`null`),!1):Li(this.shape,(n,r)=>{let i=this._isPartial&&!Ri(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},Ba=e=>new za(e),Va=Da(za),Ha=ka(e=>e!=null&&(e.constructor===Object||e.constructor==null)),Ua=class extends Ta{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&Li(e,(n,r)=>{let i=this.shape.keys.check(r,t);return!i&&t?.extend(r+``,`Record`,typeof e,i?`Key doesn't match schema`:`Value doesn't match value`),i&&this.shape.values.check(n,t)})}},Wa=(e,t)=>new Ua(e,t),Ga=Da(Ua),Ka=class extends Ta{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&Li(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},qa=(...e)=>new Ka(e);Da(Ka);var Ja=class extends Ta{constructor(e){super(),this.shape=e.length===1?e[0]:new ro(e)}check(e,t){let n=er(e)&&Zn(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},Ya=(...e)=>new Ja(e),Xa=Da(Ja),Za=ka(e=>er(e)),Qa=class extends Ta{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){let n=e instanceof this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name),n}},$a=(e,t=null)=>new Qa(e,t);Da(Qa);var eo=$a(Ta),to=Da(class extends Ta{constructor(e){super(),this.len=e.length-1,this.args=qa(...e.slice(-1)),this.res=e[this.len]}check(e,t){let n=e.constructor===Function&&e.length<=this.len;return!n&&t?.extend(null,`function`,typeof e),n}}),no=ka(e=>typeof e==`function`);Da(class extends Ta{constructor(e){super(),this.shape=e}check(e,t){let n=Zn(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var ro=class extends Ta{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=Qn(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},io=(...e)=>e.findIndex(e=>ao.check(e))>=0?io(...e.map(e=>Co(e)).map(e=>ao.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new ro(e),ao=Da(ro),oo=()=>!0,so=ka(oo),co=Da(Oa,e=>e.shape===oo),lo=ka(e=>typeof e==`bigint`),uo=ka(e=>e===lo),fo=ka(e=>typeof e==`symbol`);ka(e=>e===fo);var po=ka(e=>typeof e==`number`),mo=ka(e=>e===po),ho=ka(e=>typeof e==`string`),go=ka(e=>e===ho),_o=ka(e=>typeof e==`boolean`),vo=ka(e=>e===_o),yo=ja(void 0);Da(Aa,e=>e.shape.length===1&&e.shape[0]===void 0),ja(void 0);var bo=ja(null),xo=Da(Aa,e=>e.shape.length===1&&e.shape[0]===null);Da(Uint8Array),Da(Ea,e=>e.shape===Uint8Array);var So=io(po,ho,bo,yo,lo,_o,fo);(()=>{let e=Ya(so),t=Wa(ho,so),n=io(po,ho,bo,_o,e,t);return e.shape=n,t.shape.values=n,n})();var Co=e=>{if(eo.check(e))return e;if(Ha.check(e)){let t={};for(let n in e)t[n]=Co(e[n]);return Ba(t)}if(Za.check(e))return io(...e.map(Co));if(So.check(e))return ja(e);if(no.check(e))return Da(e);Qr()},wo=ea?()=>{}:(e,t)=>{let n=new Ca;if(!t.check(e,n))throw Xr(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},To=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:Co(e),h:t}),this}else(e){return this.if(so,e)}done(){return(e,t)=>{for(let n=0;n<this.patterns.length;n++){let r=this.patterns[n];if(r.if.check(e))return r.h(e,t)}throw Xr(`Unhandled pattern`)}}},Eo=(e=>new To(e))(so).if(mo,(e,t)=>ga(t,dr,ur)).if(go,(e,t)=>ba(t)).if(vo,(e,t)=>ha(t)).if(uo,(e,t)=>BigInt(ga(t,dr,ur))).if(ao,(e,t)=>Do(t,xa(t,e.shape))).if(Va,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(La.check(i)){if(ha(t))continue;i=i.shape}n[r]=Eo(i,t)}return n}).if(Xa,(e,t)=>{let n=[],r=_a(t,0,42);for(let i=0;i<r;i++)n.push(Do(t,e.shape));return n}).if(Ma,(e,t)=>xa(t,e.shape)).if(xo,(e,t)=>null).if(to,(e,t)=>{let n=Do(t,e.res);return()=>n}).if(co,(e,t)=>Do(t,xa(t,[po,ho,bo,yo,lo,_o,Ya(po),Wa(io(`a`,`b`,`c`),po)]))).if(Ga,(e,t)=>{let n={},r=ga(t,0,3);for(let i=0;i<r;i++){let r=Do(t,e.shape.keys);n[r]=Do(t,e.shape.values)}return n}).done(),Do=(e,t)=>Eo(Co(t),e),Oo=typeof document<`u`?document:{},ko=e=>Oo.createElement(e),Ao=()=>Oo.createDocumentFragment();ka(e=>e.nodeType===Ho);var jo=e=>Oo.createTextNode(e);typeof DOMParser<`u`&&new DOMParser;var Mo=(e,t)=>(ma(t,(t,n)=>{n===!1?e.removeAttribute(t):n===!0?e.setAttribute(t,``):e.setAttribute(t,n)}),e),No=e=>{let t=Ao();for(let n=0;n<e.length;n++)Ro(t,e[n]);return t},Po=(e,t)=>(Ro(e,No(t)),e),Fo=(e,t=[],n=[])=>Po(Mo(ko(e),t),n);ka(e=>e.nodeType===zo);var Io=jo;ka(e=>e.nodeType===Bo);var Lo=e=>Gn(e,(e,t)=>`${t}:${e};`).join(``),Ro=(e,t)=>e.appendChild(t),zo=Oo.ELEMENT_NODE,Bo=Oo.TEXT_NODE;Oo.CDATA_SECTION_NODE,Oo.COMMENT_NODE;var Vo=Oo.DOCUMENT_NODE;Oo.DOCUMENT_TYPE_NODE;var Ho=Oo.DOCUMENT_FRAGMENT_NODE;ka(e=>e.nodeType===Vo);var Uo=Symbol,Wo=Uo(),Go=Uo(),Ko=Uo(),qo=Uo(),Jo=Uo(),Yo=Uo(),Xo=Uo(),Zo=Uo(),Qo=Uo(),$o=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=0;for(;r<e.length;r++){let n=e[r];if(n===void 0)break;if(n.constructor===String||n.constructor===Number)t.push(n);else if(n.constructor===Object)break}for(r>0&&n.push(t.join(``));r<e.length;r++){let t=e[r];t instanceof Symbol||n.push(t)}return n};bi();var es={[Wo]:pa(`font-weight`,`bold`),[Go]:pa(`font-weight`,`normal`),[Ko]:pa(`color`,`blue`),[Jo]:pa(`color`,`green`),[qo]:pa(`color`,`grey`),[Yo]:pa(`color`,`red`),[Xo]:pa(`color`,`purple`),[Zo]:pa(`color`,`orange`),[Qo]:pa(`color`,`black`)},ts=ta?e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=Hn(),i=[],a=0;for(;a<e.length;a++){let i=e[a],o=es[i];if(o!==void 0)r.set(o.left,o.right);else{if(i===void 0)break;if(i.constructor===String||i.constructor===Number){let e=Lo(r);a>0||e.length>0?(t.push(`%c`+i),n.push(e)):t.push(i)}else break}}for(a>0&&(i=n,i.unshift(t.join(``)));a<e.length;a++){let t=e[a];t instanceof Symbol||i.push(t)}return i}:$o,ns=(...e)=>{console.log(...ts(e)),is.forEach(t=>t.print(e))},rs=(...e)=>{console.warn(...ts(e)),e.unshift(Zo),is.forEach(t=>t.print(e))},is=qn(),as=e=>({[Symbol.iterator](){return this},next:e}),os=(e,t)=>as(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),ss=(e,t)=>as(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),cs=class{constructor(e,t){this.clock=e,this.len=t}},ls=class{constructor(){this.clients=new Map}},us=(e,t,n)=>t.clients.forEach((t,r)=>{let i=e.doc.store.clients.get(r);if(i!=null){let r=i[i.length-1],a=r.id.clock+r.length;for(let r=0,o=t[r];r<t.length&&o.clock<a;o=t[++r])Ec(e,i,o.clock,o.len,n)}}),ds=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=rr((n+r)/2),a=e[i],o=a.clock;if(o<=t){if(t<o+a.len)return i;n=i+1}else r=i-1}return null},fs=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&ds(n,t.clock)!==null},ps=e=>{e.clients.forEach(e=>{e.sort((e,t)=>e.clock-t.clock);let t,n;for(t=1,n=1;t<e.length;t++){let r=e[n-1],i=e[t];r.clock+r.len>=i.clock?e[n-1]=new cs(r.clock,or(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},ms=e=>{let t=new ls;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,i)=>{if(!t.clients.has(i)){let a=r.slice();for(let t=n+1;t<e.length;t++)Yn(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return ps(t),t},hs=(e,t,n,r)=>{Wn(e.clients,t,()=>[]).push(new cs(n,r))},gs=()=>new ls,_s=e=>{let t=gs();return e.clients.forEach((e,n)=>{let r=[];for(let t=0;t<e.length;t++){let n=e[t];if(n.deleted){let i=n.id.clock,a=n.length;if(t+1<e.length)for(let n=e[t+1];t+1<e.length&&n.deleted;n=e[++t+1])a+=n.length;r.push(new cs(i,a))}}r.length>0&&t.clients.set(n,r)}),t},vs=(e,t)=>{Z(e.restEncoder,t.clients.size),Xn(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),Z(e.restEncoder,t);let r=n.length;Z(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},ys=e=>{let t=new ls,n=Q(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let n=Q(e.restDecoder),r=Q(e.restDecoder);if(r>0){let i=Wn(t.clients,n,()=>[]);for(let t=0;t<r;t++)i.push(new cs(e.readDsClock(),e.readDsLen()))}}return t},bs=(e,t,n)=>{let r=new ls,i=Q(e.restDecoder);for(let a=0;a<i;a++){e.resetDsCurVal();let i=Q(e.restDecoder),a=Q(e.restDecoder),o=n.clients.get(i)||[],s=vc(n,i);for(let n=0;n<a;n++){let n=e.readDsClock(),a=n+e.readDsLen();if(n<s){s<a&&hs(r,i,s,a-s);let e=bc(o,n),c=o[e];for(!c.deleted&&c.id.clock<n&&(o.splice(e+1,0,Hu(t,c,n-c.id.clock)),e++);e<o.length&&(c=o[e++],c.id.clock<a);)c.deleted||(a<c.id.clock+c.length&&o.splice(e,0,Hu(t,c,a-c.id.clock)),c.delete(t))}else hs(r,i,n,a-n)}}if(r.clients.size>0){let e=new As;return Z(e.restEncoder,0),vs(e,r),e.toUint8Array()}return null},xs=_i,Ss=class e extends tr{constructor({guid:e=yi(),collectionid:t=null,gc:n=!0,gcFilter:r=()=>!0,meta:i=null,autoLoad:a=!1,shouldLoad:o=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=xs(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new gc,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=a,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=xi(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>xi(e=>{let t=n=>{(n===void 0||n===!0)&&(this.off(`sync`,t),e())};this.on(`sync`,t)});this.on(`sync`,e=>{e===!1&&this.isSynced&&(this.whenSynced=s()),this.isSynced=e===void 0||e===!0,this.isSynced&&!this.isLoaded&&this.emit(`load`,[this])}),this.whenSynced=s()}load(){let e=this._item;e!==null&&!this.shouldLoad&&Pc(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Xn(this.subdocs).map(e=>e.guid))}transact(e,t=null){return Pc(this,e,t)}get(e,t=ul){let n=Wn(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==ul&&r!==t){if(r===ul){let r=new t;r._map=n._map,n._map.forEach(e=>{for(;e!==null;e=e.left)e.parent=r}),r._start=n._start;for(let e=r._start;e!==null;e=e.right)e.parent=r;return r._length=n._length,this.share.set(e,r),r._integrate(this,null),r}throw Error(`Type with the name ${e} has already been defined with a different constructor`)}return n}getArray(e=``){return this.get(e,Al)}getText(e=``){return this.get(e,Zl)}getMap(e=``){return this.get(e,Nl)}getXmlElement(e=``){return this.get(e,nu)}getXmlFragment(e=``){return this.get(e,eu)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,Xn(this.subdocs).forEach(e=>e.destroy());let t=this._item;if(t!==null){this._item=null;let n=t.content;n.doc=new e({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,Pc(t.parent.doc,e=>{let r=n.doc;t.deleted||e.subdocsAdded.add(r),e.subdocsRemoved.add(this)},null,!0)}this.emit(`destroyed`,[!0]),this.emit(`destroy`,[this]),super.destroy()}},Cs=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return Q(this.restDecoder)}readDsLen(){return Q(this.restDecoder)}},ws=class extends Cs{readLeftID(){return $(Q(this.restDecoder),Q(this.restDecoder))}readRightID(){return $(Q(this.restDecoder),Q(this.restDecoder))}readClient(){return Q(this.restDecoder)}readInfo(){return oi(this.restDecoder)}readString(){return ci(this.restDecoder)}readParentInfo(){return Q(this.restDecoder)===1}readTypeRef(){return Q(this.restDecoder)}readLen(){return Q(this.restDecoder)}readAny(){return di(this.restDecoder)}readBuf(){return da(ai(this.restDecoder))}readJSON(){return JSON.parse(ci(this.restDecoder))}readKey(){return ci(this.restDecoder)}},Ts=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Q(this.restDecoder),this.dsCurrVal}readDsLen(){let e=Q(this.restDecoder)+1;return this.dsCurrVal+=e,e}},Es=class extends Ts{constructor(e){super(e),this.keys=[],Q(e),this.keyClockDecoder=new mi(ai(e)),this.clientDecoder=new pi(ai(e)),this.leftClockDecoder=new mi(ai(e)),this.rightClockDecoder=new mi(ai(e)),this.infoDecoder=new fi(ai(e),oi),this.stringDecoder=new hi(ai(e)),this.parentInfoDecoder=new fi(ai(e),oi),this.typeRefDecoder=new pi(ai(e)),this.lenDecoder=new pi(ai(e))}readLeftID(){return new $s(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new $s(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return di(this.restDecoder)}readBuf(){return ai(this.restDecoder)}readJSON(){return di(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{let e=this.stringDecoder.read();return this.keys.push(e),e}}},Ds=class{constructor(){this.restEncoder=Tr()}toUint8Array(){return Dr(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){Z(this.restEncoder,e)}writeDsLen(e){Z(this.restEncoder,e)}},Os=class extends Ds{writeLeftID(e){Z(this.restEncoder,e.client),Z(this.restEncoder,e.clock)}writeRightID(e){Z(this.restEncoder,e.client),Z(this.restEncoder,e.clock)}writeClient(e){Z(this.restEncoder,e)}writeInfo(e){Ar(this.restEncoder,e)}writeString(e){Pr(this.restEncoder,e)}writeParentInfo(e){Z(this.restEncoder,+!!e)}writeTypeRef(e){Z(this.restEncoder,e)}writeLen(e){Z(this.restEncoder,e)}writeAny(e){Ur(this.restEncoder,e)}writeBuf(e){Ir(this.restEncoder,e)}writeJSON(e){Pr(this.restEncoder,JSON.stringify(e))}writeKey(e){Pr(this.restEncoder,e)}},ks=class{constructor(){this.restEncoder=Tr(),this.dsCurrVal=0}toUint8Array(){return Dr(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,Z(this.restEncoder,t)}writeDsLen(e){e===0&&Qr(),Z(this.restEncoder,e-1),this.dsCurrVal+=e}},As=class extends ks{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Jr,this.clientEncoder=new Kr,this.leftClockEncoder=new Jr,this.rightClockEncoder=new Jr,this.infoEncoder=new Wr(Ar),this.stringEncoder=new Yr,this.parentInfoEncoder=new Wr(Ar),this.typeRefEncoder=new Kr,this.lenEncoder=new Kr}toUint8Array(){let e=Tr();return Z(e,0),Ir(e,this.keyClockEncoder.toUint8Array()),Ir(e,this.clientEncoder.toUint8Array()),Ir(e,this.leftClockEncoder.toUint8Array()),Ir(e,this.rightClockEncoder.toUint8Array()),Ir(e,Dr(this.infoEncoder)),Ir(e,this.stringEncoder.toUint8Array()),Ir(e,Dr(this.parentInfoEncoder)),Ir(e,this.typeRefEncoder.toUint8Array()),Ir(e,this.lenEncoder.toUint8Array()),Fr(e,Dr(this.restEncoder)),Dr(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(+!!e)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){Ur(this.restEncoder,e)}writeBuf(e){Ir(this.restEncoder,e)}writeJSON(e){Ur(this.restEncoder,e)}writeKey(e){let t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}},js=(e,t,n,r)=>{r=or(r,t[0].id.clock);let i=bc(t,r);Z(e.restEncoder,t.length-i),e.writeClient(n),Z(e.restEncoder,r);let a=t[i];a.write(e,r-a.id.clock);for(let n=i+1;n<t.length;n++)t[n].write(e,0)},Ms=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{vc(t,n)>e&&r.set(n,e)}),_c(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),Z(e.restEncoder,r.size),Xn(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{js(e,t.clients.get(n),n,r)})},Ns=(e,t)=>{let n=Hn(),r=Q(e.restDecoder);for(let i=0;i<r;i++){let r=Q(e.restDecoder),i=Array(r),a=e.readClient(),o=Q(e.restDecoder);n.set(a,{i:0,refs:i});for(let n=0;n<r;n++){let r=e.readInfo();switch(31&r){case 0:{let t=e.readLen();i[n]=new du($(a,o),t),o+=t;break}case 10:{let t=Q(e.restDecoder);i[n]=new Yu($(a,o),t),o+=t;break}default:{let s=!(r&192),c=new Gu($(a,o),null,(r&128)==128?e.readLeftID():null,null,(r&64)==64?e.readRightID():null,s?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,s&&(r&32)==32?e.readString():null,Ku(e,r));i[n]=c,o+=c.length}}}}return n},Ps=(e,t,n)=>{let r=[],i=Xn(n.keys()).sort((e,t)=>e-t);if(i.length===0)return null;let a=()=>{if(i.length===0)return null;let e=n.get(i[i.length-1]);for(;e.refs.length===e.i;)if(i.pop(),i.length>0)e=n.get(i[i.length-1]);else return null;return e},o=a();if(o===null)return null;let s=new gc,c=new Map,l=(e,t)=>{let n=c.get(e);(n==null||n>t)&&c.set(e,t)},u=o.refs[o.i++],d=new Map,f=()=>{for(let e of r){let t=e.id.client,r=n.get(t);r?(r.i--,s.clients.set(t,r.refs.slice(r.i)),n.delete(t),r.i=0,r.refs=[]):s.clients.set(t,[e]),i=i.filter(e=>e!==t)}r.length=0};for(;;){if(u.constructor!==Yu){let i=Wn(d,u.id.client,()=>vc(t,u.id.client))-u.id.clock;if(i<0)r.push(u),l(u.id.client,u.id.clock-1),f();else{let a=u.getMissing(e,t);if(a!==null){r.push(u);let e=n.get(a)||{refs:[],i:0};if(e.refs.length===e.i)l(a,vc(t,a)),f();else{u=e.refs[e.i++];continue}}else(i===0||i<u.length)&&(u.integrate(e,i),d.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(o!==null&&o.i<o.refs.length)u=o.refs[o.i++];else{if(o=a(),o===null)break;u=o.refs[o.i++]}}if(s.clients.size>0){let e=new As;return Ms(e,s,new Map),Z(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},Fs=(e,t)=>Ms(e,t.doc.store,t.beforeState),Is=(e,t,n,r=new Es(e))=>Pc(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=Ps(e,i,Ns(r,n)),o=i.pendingStructs;if(o){for(let[e,n]of o.missing)if(n<vc(i,e)){t=!0;break}if(a){for(let[e,t]of a.missing){let n=o.missing.get(e);(n==null||n>t)&&o.missing.set(e,t)}o.update=Wc([o.update,a.update])}}else i.pendingStructs=a;let s=bs(r,e,i);if(i.pendingDs){let t=new Es(ni(i.pendingDs));Q(t.restDecoder);let n=bs(t,e,i);i.pendingDs=s&&n?Wc([s,n]):s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,Ls(e.doc,t)}},n,!1),Ls=(e,t,n,r=Es)=>{let i=ni(t);Is(i,e,n,new r(i))},Rs=(e,t,n)=>Ls(e,t,n,ws),zs=(e,t,n=new Map)=>{Ms(e,t.store,n),vs(e,_s(t.store))},Bs=(e,t=new Uint8Array([0]),n=new As)=>{zs(n,e,Us(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(Gc(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===Os)return Hc(r.map((e,t)=>t===0?e:Xc(e)));if(n.constructor===As)return Wc(r)}return r[0]},Vs=(e,t)=>Bs(e,t,new Os),Hs=e=>{let t=new Map,n=Q(e.restDecoder);for(let r=0;r<n;r++){let n=Q(e.restDecoder),r=Q(e.restDecoder);t.set(n,r)}return t},Us=e=>Hs(new Cs(ni(e))),Ws=(e,t)=>(Z(e.restEncoder,t.size),Xn(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{Z(e.restEncoder,t),Z(e.restEncoder,n)}),e),Gs=(e,t)=>Ws(e,_c(t.store)),Ks=(e,t=new ks)=>(e instanceof Map?Ws(t,e):Gs(t,e),t.toUint8Array()),qs=e=>Ks(e,new Ds),Js=class{constructor(){this.l=[]}},Ys=()=>new Js,Xs=(e,t)=>e.l.push(t),Zs=(e,t)=>{let n=e.l,r=n.length;e.l=n.filter(e=>t!==e),r===e.l.length&&console.error(`[yjs] Tried to remove event handler that doesn't exist.`)},Qs=(e,t,n)=>Hi(e.l,[t,n]),$s=class{constructor(e,t){this.client=e,this.clock=t}},ec=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,$=(e,t)=>new $s(e,t),tc=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw Qr()},nc=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},rc=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},ic=e=>{let t={};return e.type&&(t.type=e.type),e.tname&&(t.tname=e.tname),e.item&&(t.item=e.item),e.assoc!=null&&(t.assoc=e.assoc),t},ac=e=>new rc(e.type==null?null:$(e.type.client,e.type.clock),e.tname??null,e.item==null?null:$(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),oc=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},sc=(e,t,n=0)=>new oc(e,t,n),cc=(e,t,n)=>{let r=null,i=null;return e._item===null?i=tc(e):r=$(e._item.id.client,e._item.id.clock),new rc(r,i,t,n)},lc=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return cc(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return cc(e,$(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return cc(e,r.lastId,n);r=r.right}return cc(e,null,n)},uc=(e,t)=>{let n=xc(e,t);return{item:n,diff:t.clock-n.id.clock}},dc=(e,t,n=!0)=>{let r=t.store,i=e.item,a=e.type,o=e.tname,s=e.assoc,c=null,l=0;if(i!==null){if(vc(r,i.client)<=i.clock)return null;let e=n?Bu(r,i):uc(r,i),t=e.item;if(!(t instanceof Gu))return null;if(c=t.parent,c._item===null||!c._item.deleted){l=t.deleted||!t.countable?0:e.diff+(s>=0?0:1);let n=t.left;for(;n!==null;)!n.deleted&&n.countable&&(l+=n.length),n=n.left}}else{if(o!==null)c=t.get(o);else if(a!==null){if(vc(r,a.client)<=a.clock)return null;let{item:e}=n?Bu(r,a):{item:xc(r,a)};if(e instanceof Gu&&e.content instanceof Ru)c=e.content.type;else return null}else throw Qr();l=s>=0?c._length:0}return sc(c,l,e.assoc)},fc=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&ec(e.item,t.item)&&ec(e.type,t.type)&&e.assoc===t.assoc,pc=class{constructor(e,t){this.ds=e,this.sv=t}};((e,t)=>new pc(e,t))(gs(),new Map);var mc=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!fs(t.ds,e.id),hc=(e,t)=>{let n=Wn(e.meta,hc,qn),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<vc(r,n)&&Cc(e,$(n,t))}),us(e,t.ds,e=>{}),n.add(t))},gc=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},_c=e=>{let t=new Map;return e.clients.forEach((e,n)=>{let r=e[e.length-1];t.set(n,r.id.clock+r.length)}),t},vc=(e,t)=>{let n=e.clients.get(t);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},yc=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{let e=n[n.length-1];if(e.id.clock+e.length!==t.id.clock)throw Qr()}n.push(t)},bc=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=rr(t/(a+i.length-1)*r);for(;n<=r;){if(i=e[o],a=i.id.clock,a<=t){if(t<a+i.length)return o;n=o+1}else r=o-1;o=rr((n+r)/2)}throw Qr()},xc=(e,t)=>{let n=e.clients.get(t.client);return n[bc(n,t.clock)]},Sc=(e,t,n)=>{let r=bc(t,n),i=t[r];return i.id.clock<n&&i instanceof Gu?(t.splice(r+1,0,Hu(e,i,n-i.id.clock)),r+1):r},Cc=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[Sc(e,n,t.clock)]},wc=(e,t,n)=>{let r=t.clients.get(n.client),i=bc(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==du&&r.splice(i+1,0,Hu(e,a,n.clock-a.id.clock+1)),a},Tc=(e,t,n)=>{let r=e.clients.get(t.id.client);r[bc(r,t.id.clock)]=n},Ec=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=Sc(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&Sc(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)},Dc=class{constructor(e,t,n){this.doc=e,this.deleteSet=new ls,this.beforeState=_c(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},Oc=(e,t)=>t.deleteSet.clients.size===0&&!Kn(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(ps(t.deleteSet),Fs(e,t),vs(e,t.deleteSet),!0),kc=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&Wn(e.changed,t,qn).add(n)},Ac=(e,t)=>{let n=e[t],r=e[t-1],i=t;for(;i>0&&r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n);n=r,r=e[--i-1])n instanceof Gu&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);let a=t-i;return a&&e.splice(t+1-a,a),a},jc=(e,t,n)=>{for(let[r,i]of e.clients.entries()){let e=t.clients.get(r);for(let r=i.length-1;r>=0;r--){let a=i[r],o=a.clock+a.len;for(let r=bc(e,a.clock),i=e[r];r<e.length&&i.id.clock<o;i=e[++r]){let i=e[r];if(a.clock+a.len<=i.id.clock)break;i instanceof Gu&&i.deleted&&!i.keep&&n(i)&&i.gc(t,!1)}}}},Mc=(e,t)=>{e.clients.forEach((e,n)=>{let r=t.clients.get(n);for(let t=e.length-1;t>=0;t--){let n=e[t],i=ar(r.length-1,1+bc(r,n.clock+n.len-1));for(let e=i,t=r[e];e>0&&t.id.clock>=n.clock;t=r[e])e-=1+Ac(r,e)}})},Nc=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,o=n._mergeStructs;try{ps(a),n.afterState=_c(n.doc.store),r.emit(`beforeObserverCalls`,[n,r]);let e=[];n.changed.forEach((t,r)=>e.push(()=>{(r._item===null||!r._item.deleted)&&r._callObserver(n,t)})),e.push(()=>{n.changedParentTypes.forEach((t,r)=>{r._dEH.l.length>0&&(r._item===null||!r._item.deleted)&&(t=t.filter(e=>e.target._item===null||!e.target._item.deleted),t.forEach(e=>{e.currentTarget=r,e._path=null}),t.sort((e,t)=>e.path.length-t.path.length),e.push(()=>{Qs(r._dEH,t,n)}))}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&Jl(n)})}),Hi(e,[])}finally{r.gc&&jc(a,i,r.gcFilter),Mc(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=or(bc(e,r),1);for(let t=e.length-1;t>=n;)t-=1+Ac(e,t)}});for(let e=o.length-1;e>=0;e--){let{client:t,clock:n}=o[e].id,r=i.clients.get(t),a=bc(r,n);a+1<r.length&&Ac(r,a+1)>1||a>0&&Ac(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(ns(Zo,Wo,`[yjs] `,Go,Yo,`Changed the client-id because another client seems to be using it.`),r.clientID=xs()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new Os;Oc(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new As;Oc(e,n)&&r.emit(`updateV2`,[e.toUint8Array(),n.origin,r,n])}let{subdocsAdded:s,subdocsLoaded:c,subdocsRemoved:l}=n;(s.size>0||l.size>0||c.size>0)&&(s.forEach(e=>{e.clientID=r.clientID,e.collectionid??=r.collectionid,r.subdocs.add(e)}),l.forEach(e=>r.subdocs.delete(e)),r.emit(`subdocs`,[{loaded:c,added:s,removed:l},r,n]),l.forEach(e=>e.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit(`afterAllTransactions`,[r,e])):Nc(e,t+1)}}},Pc=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new Dc(e,n,r),i.push(e._transaction),i.length===1&&e.emit(`beforeAllTransactions`,[e]),e.emit(`beforeTransaction`,[e._transaction,e]));try{o=t(e._transaction)}finally{if(a){let t=e._transaction===i[0];e._transaction=null,t&&Nc(i,0)}}return o},Fc=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},Ic=(e,t,n)=>{us(e,n.deletions,n=>{n instanceof Gu&&t.scope.some(t=>t===e.doc||nc(t,n))&&Vu(n,!1)})},Lc=(e,t,n)=>{let r=null,i=e.doc,a=e.scope;Pc(i,n=>{for(;t.length>0&&e.currStackItem===null;){let r=i.store,o=t.pop(),s=new Set,c=[],l=!1;us(n,o.insertions,e=>{if(e instanceof Gu){if(e.redone!==null){let{item:t,diff:i}=Bu(r,e.id);i>0&&(t=Cc(n,$(t.id.client,t.id.clock+i))),e=t}!e.deleted&&a.some(t=>t===n.doc||nc(t,e))&&c.push(e)}}),us(n,o.deletions,e=>{e instanceof Gu&&a.some(t=>t===n.doc||nc(t,e))&&!fs(o.insertions,e.id)&&s.add(e)}),s.forEach(t=>{l=Wu(n,t,s,o.insertions,e.ignoreRemoteMapChanges,e)!==null||l});for(let t=c.length-1;t>=0;t--){let r=c[t];e.deleteFilter(r)&&(r.delete(n),l=!0)}e.currStackItem=l?o:null}n.changed.forEach((e,t)=>{e.has(null)&&t._searchMarker&&(t._searchMarker.length=0)}),r=n},e);let o=e.currStackItem;if(o!=null){let t=r.changedParentTypes;e.emit(`stack-item-popped`,[{stackItem:o,type:n,changedParentTypes:t,origin:e},e]),e.currStackItem=null}return o},Rc=class extends tr{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:o=er(e)?e[0].doc:e instanceof Ss?e:e.doc}={}){super(),this.scope=[],this.doc=o,this.addToScope(e),this.deleteFilter=r,i.add(this),this.trackedOrigins=i,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=a,this.captureTimeout=t,this.afterTransactionHandler=e=>{if(!this.captureTransaction(e)||!this.scope.some(t=>e.changedParentTypes.has(t)||t===this.doc)||!this.trackedOrigins.has(e.origin)&&(!e.origin||!this.trackedOrigins.has(e.origin.constructor)))return;let t=this.undoing,n=this.redoing,r=t?this.redoStack:this.undoStack;t?this.stopCapturing():n||this.clear(!1,!0);let i=new ls;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&hs(i,n,r,a)});let a=bi(),o=!1;if(this.lastChange>0&&a-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){let t=r[r.length-1];t.deletions=ms([t.deletions,e.deleteSet]),t.insertions=ms([t.insertions,i])}else r.push(new Fc(e.deleteSet,i)),o=!0;!t&&!n&&(this.lastChange=a),us(e,e.deleteSet,t=>{t instanceof Gu&&this.scope.some(n=>n===e.doc||nc(n,t))&&Vu(t,!0)});let s=[{stackItem:r[r.length-1],origin:e.origin,type:t?`redo`:`undo`,changedParentTypes:e.changedParentTypes},this];o?this.emit(`stack-item-added`,s):this.emit(`stack-item-updated`,s)},this.doc.on(`afterTransaction`,this.afterTransactionHandler),this.doc.on(`destroy`,()=>{this.destroy()})}addToScope(e){let t=new Set(this.scope);e=er(e)?e:[e],e.forEach(e=>{t.has(e)||(t.add(e),(e instanceof ul?e.doc!==this.doc:e!==this.doc)&&rs(`[yjs#509] Not same Y.Doc`),this.scope.push(e))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact(n=>{e&&(this.undoStack.forEach(e=>Ic(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>Ic(n,this,e)),this.redoStack=[]),this.emit(`stack-cleared`,[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=Lc(this,this.undoStack,`undo`)}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=Lc(this,this.redoStack,`redo`)}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off(`afterTransaction`,this.afterTransactionHandler),super.destroy()}};function*zc(e){let t=Q(e.restDecoder);for(let n=0;n<t;n++){let t=Q(e.restDecoder),n=e.readClient(),r=Q(e.restDecoder);for(let i=0;i<t;i++){let t=e.readInfo();if(t===10){let t=Q(e.restDecoder);yield new Yu($(n,r),t),r+=t}else if(31&t){let i=!(t&192),a=new Gu($(n,r),null,(t&128)==128?e.readLeftID():null,null,(t&64)==64?e.readRightID():null,i?e.readParentInfo()?e.readString():e.readLeftID():null,i&&(t&32)==32?e.readString():null,Ku(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new du($(n,r),t),r+=t}}}}var Bc=class{constructor(e,t){this.gen=zc(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===Yu);return this.curr}},Vc=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},Hc=e=>Wc(e,ws,Os),Uc=(e,t)=>{if(e.constructor===du){let{client:n,clock:r}=e.id;return new du($(n,r+t),e.length-t)}if(e.constructor===Yu){let{client:n,clock:r}=e.id;return new Yu($(n,r+t),e.length-t)}{let n=e,{client:r,clock:i}=n.id;return new Gu($(r,i+t),null,$(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},Wc=(e,t=Es,n=As)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(ni(e))),i=r.map(e=>new Bc(e,!0)),a=null,o=new n,s=new Vc(o);for(;i=i.filter(e=>e.curr!==null),i.sort((e,t)=>{if(e.curr.id.client===t.curr.id.client){let n=e.curr.id.clock-t.curr.id.clock;return n===0?e.curr.constructor===t.curr.constructor?0:e.curr.constructor===Yu?1:-1:n}return t.curr.id.client-e.curr.id.client}),i.length!==0;){let e=i[0],t=e.curr.id.client;if(a!==null){let n=e.curr,r=!1;for(;n!==null&&n.id.clock+n.length<=a.struct.id.clock+a.struct.length&&n.id.client>=a.struct.id.client;)n=e.next(),r=!0;if(n===null||n.id.client!==t||r&&n.id.clock>a.struct.id.clock+a.struct.length)continue;if(t!==a.struct.id.client)qc(s,a.struct,a.offset),a={struct:n,offset:0},e.next();else if(a.struct.id.clock+a.struct.length<n.id.clock){if(a.struct.constructor===Yu)a.struct.length=n.id.clock+n.length-a.struct.id.clock;else{qc(s,a.struct,a.offset);let e=n.id.clock-a.struct.id.clock-a.struct.length;a={struct:new Yu($(t,a.struct.id.clock+a.struct.length),e),offset:0}}}else{let t=a.struct.id.clock+a.struct.length-n.id.clock;t>0&&(a.struct.constructor===Yu?a.struct.length-=t:n=Uc(n,t)),a.struct.mergeWith(n)||(qc(s,a.struct,a.offset),a={struct:n,offset:0},e.next())}}else a={struct:e.curr,offset:0},e.next();for(let n=e.curr;n!==null&&n.id.client===t&&n.id.clock===a.struct.id.clock+a.struct.length&&n.constructor!==Yu;n=e.next())qc(s,a.struct,a.offset),a={struct:n,offset:0}}return a!==null&&(qc(s,a.struct,a.offset),a=null),Jc(s),vs(o,ms(r.map(e=>ys(e)))),o.toUint8Array()},Gc=(e,t,n=Es,r=As)=>{let i=Us(t),a=new r,o=new Vc(a),s=new n(ni(e)),c=new Bc(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===Yu)c.next();else if(e.id.clock+e.length>n)for(qc(o,e,or(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)qc(o,c.curr,0),c.next();else for(;c.curr&&c.curr.id.client===t&&c.curr.id.clock+c.curr.length<=n;)c.next()}return Jc(o),vs(a,ys(s)),a.toUint8Array()},Kc=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:Dr(e.encoder.restEncoder)}),e.encoder.restEncoder=Tr(),e.written=0)},qc=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&Kc(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),Z(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},Jc=e=>{Kc(e);let t=e.encoder.restEncoder;Z(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];Z(t,r.written),Fr(t,r.restEncoder)}},Yc=(e,t,n,r)=>{let i=new n(ni(e)),a=new Bc(i,!1),o=new r,s=new Vc(o);for(let e=a.curr;e!==null;e=a.next())qc(s,t(e),0);return Jc(s),vs(o,ys(i)),o.toUint8Array()},Xc=e=>Yc(e,Ui,Es,Os),Zc=`You must not compute changes after the event-handler fired.`,Qc=class{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||=$c(this.currentTarget,this.target)}deletes(e){return fs(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Xr(Zc);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach(n=>{if(n!==null){let r=t._map.get(n),i,a;if(this.adds(r)){let e=r.left;for(;e!==null&&this.adds(e);)e=e.left;if(this.deletes(r)){if(e!==null&&this.deletes(e))i=`delete`,a=Jn(e.content.getContent());else return}else e!==null&&this.deletes(e)?(i=`update`,a=Jn(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=Jn(r.content.getContent());else return;e.set(n,{action:i,oldValue:a})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw Xr(Zc);let t=this.target,n=qn(),r=qn(),i=[];if(e={added:n,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(t).has(null)){let e=null,a=()=>{e&&i.push(e)};for(let i=t._start;i!==null;i=i.right)i.deleted?this.deletes(i)&&!this.adds(i)&&((e===null||e.delete===void 0)&&(a(),e={delete:0}),e.delete+=i.length,r.add(i)):this.adds(i)?((e===null||e.insert===void 0)&&(a(),e={insert:[]}),e.insert=e.insert.concat(i.content.getContent()),n.add(i)):((e===null||e.retain===void 0)&&(a(),e={retain:0}),e.retain+=i.length);e!==null&&e.retain===void 0&&a()}this._changes=e}return e}},$c=(e,t)=>{let n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let e=0,r=t._item.parent._start;for(;r!==t._item&&r!==null;)!r.deleted&&r.countable&&(e+=r.length),r=r.right;n.unshift(e)}t=t._item.parent}return n},el=()=>{rs(`Invalid access: Add Yjs type to a document before reading data.`)},tl=80,nl=0,rl=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=nl++}},il=e=>{e.timestamp=nl++},al=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=nl++},ol=(e,t,n)=>{if(e.length>=tl){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return al(r,t,n),r}{let r=new rl(t,n);return e.push(r),r}},sl=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let n=e._searchMarker.length===0?null:e._searchMarker.reduce((e,n)=>ir(t-e.index)<ir(t-n.index)?e:n),r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,il(n));r.right!==null&&i<t;){if(!r.deleted&&r.countable){if(t<i+r.length)break;i+=r.length}r=r.right}for(;r.left!==null&&i>t;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return n!==null&&ir(n.index-i)<r.parent.length/tl?(al(n,r,i),n):ol(e._searchMarker,r,i)},cl=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){let i=e[r];if(n>0){let t=i.p;for(t.marker=!1;t&&(t.deleted||!t.countable);)t=t.left,t&&!t.deleted&&t.countable&&(i.index-=t.length);if(t===null||t.marker===!0){e.splice(r,1);continue}i.p=t,t.marker=!0}(t<i.index||n>0&&t===i.index)&&(i.index=or(t,i.index+n))}},ll=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;Wn(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;Qs(r._eH,n,t)},ul=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Ys(),this._dEH=Ys(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Zr()}clone(){throw Zr()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){Xs(this._eH,e)}observeDeep(e){Xs(this._dEH,e)}unobserve(e){Zs(this._eH,e)}unobserveDeep(e){Zs(this._dEH,e)}toJSON(){}},dl=(e,t,n)=>{e.doc??el(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t,i=[],a=e._start;for(;a!==null&&r>0;){if(a.countable&&!a.deleted){let e=a.content.getContent();if(e.length<=t)t-=e.length;else{for(let n=t;n<e.length&&r>0;n++)i.push(e[n]),r--;t=0}}a=a.right}return i},fl=e=>{e.doc??el();let t=[],n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){let e=n.content.getContent();for(let n=0;n<e.length;n++)t.push(e[n])}n=n.right}return t},pl=(e,t)=>{let n=0,r=e._start;for(e.doc??el();r!==null;){if(r.countable&&!r.deleted){let i=r.content.getContent();for(let r=0;r<i.length;r++)t(i[r],n++,e)}r=r.right}},ml=(e,t)=>{let n=[];return pl(e,(r,i)=>{n.push(t(r,i,e))}),n},hl=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}let e=n[r++];return n.length<=r&&(n=null),{done:!1,value:e}}}},gl=(e,t)=>{e.doc??el();let n=sl(e,t),r=e._start;for(n!==null&&(r=n.p,t-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},_l=(e,t,n,r)=>{let i=n,a=e.doc,o=a.clientID,s=a.store,c=n===null?t._start:n.right,l=[],u=()=>{l.length>0&&(i=new Gu($(o,vc(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Eu(l)),i.integrate(e,0),l=[])};r.forEach(n=>{if(n===null)l.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(n);break;default:switch(u(),n.constructor){case Uint8Array:case ArrayBuffer:i=new Gu($(o,vc(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new fu(new Uint8Array(n))),i.integrate(e,0);break;case Ss:i=new Gu($(o,vc(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new _u(n)),i.integrate(e,0);break;default:if(n instanceof ul)i=new Gu($(o,vc(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Ru(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},vl=()=>Xr(`Length exceeded!`),yl=(e,t,n,r)=>{if(n>t._length)throw vl();if(n===0)return t._searchMarker&&cl(t._searchMarker,n,r.length),_l(e,t,null,r);let i=n,a=sl(t,n),o=t._start;for(a!==null&&(o=a.p,n-=a.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&Cc(e,$(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&cl(t._searchMarker,i,r.length),_l(e,t,o,r)},bl=(e,t,n)=>{let r=(t._searchMarker||[]).reduce((e,t)=>t.index>e.index?t:e,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return _l(e,t,r,n)},xl=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=sl(t,n),s=t._start;for(o!==null&&(s=o.p,n-=o.index);s!==null&&n>0;s=s.right)!s.deleted&&s.countable&&(n<s.length&&Cc(e,$(s.id.client,s.id.clock+n)),n-=s.length);for(;r>0&&s!==null;)s.deleted||(r<s.length&&Cc(e,$(s.id.client,s.id.clock+r)),s.delete(e),r-=s.length),s=s.right;if(r>0)throw vl();t._searchMarker&&cl(t._searchMarker,i,-a+r)},Sl=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},Cl=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new Eu([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new Eu([r]);break;case Uint8Array:s=new fu(r);break;case Ss:s=new _u(r);break;default:if(r instanceof ul)s=new Ru(r);else throw Error(`Unexpected content type`)}new Gu($(o,vc(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},wl=(e,t)=>{e.doc??el();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Tl=e=>{let t={};return e.doc??el(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},El=(e,t)=>{e.doc??el();let n=e._map.get(t);return n!==void 0&&!n.deleted},Dl=(e,t)=>{let n={};return e._map.forEach((e,r)=>{let i=e;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&mc(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},Ol=e=>(e.doc??el(),os(e._map.entries(),e=>!e[1].deleted)),kl=class extends Qc{},Al=class e extends ul{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){let n=new e;return n.push(t),n}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof ul?e.clone():e)),t}get length(){return this.doc??el(),this._length}_callObserver(e,t){super._callObserver(e,t),ll(this,e,new kl(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):Pc(this.doc,n=>{yl(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):Pc(this.doc,t=>{bl(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):Pc(this.doc,n=>{xl(n,this,e,t)})}get(e){return gl(this,e)}toArray(){return fl(this)}slice(e=0,t=this.length){return dl(this,e,t)}toJSON(){return this.map(e=>e instanceof ul?e.toJSON():e)}map(e){return ml(this,e)}forEach(e){pl(this,e)}[Symbol.iterator](){return hl(this)}_write(e){e.writeTypeRef(ju)}},jl=e=>new Al,Ml=class extends Qc{constructor(e,t,n){super(e,t),this.keysChanged=n}},Nl=class e extends ul{constructor(e){super(),this._prelimContent=null,this._prelimContent=e===void 0?new Map:new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((e,t)=>{this.set(t,e)}),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return this.forEach((e,n)=>{t.set(n,e instanceof ul?e.clone():e)}),t}_callObserver(e,t){ll(this,e,new Ml(this,e,t))}toJSON(){this.doc??el();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof ul?r.toJSON():r}}),e}get size(){return[...Ol(this)].length}keys(){return ss(Ol(this),e=>e[0])}values(){return ss(Ol(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return ss(Ol(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??el(),this._map.forEach((t,n)=>{t.deleted||e(t.content.getContent()[t.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc===null?this._prelimContent.delete(e):Pc(this.doc,t=>{Sl(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):Pc(this.doc,n=>{Cl(n,this,e,t)}),t}get(e){return wl(this,e)}has(e){return El(this,e)}clear(){this.doc===null?this._prelimContent.clear():Pc(this.doc,e=>{this.forEach(function(t,n,r){Sl(e,r,n)})})}_write(e){e.writeTypeRef(Mu)}},Pl=e=>new Nl,Fl=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&zi(e,t),Il=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&Qr(),this.right.content.constructor){case xu:this.right.deleted||Bl(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length)}this.left=this.right,this.right=this.right.right}},Ll=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case xu:t.right.deleted||Bl(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&Cc(e,$(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length)}t.left=t.right,t.right=t.right.right}return t},Rl=(e,t,n,r)=>{let i=new Map,a=r?sl(t,n):null;return a?Ll(e,new Il(a.p.left,a.p,a.index,i),n-a.index):Ll(e,new Il(null,t._start,0,i),n)},zl=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===xu&&Fl(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let i=e.doc,a=i.clientID;r.forEach((r,o)=>{let s=n.left,c=n.right,l=new Gu($(a,vc(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new xu(o,r));l.integrate(e,0),n.right=l,n.forward()})},Bl=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},Vl=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===xu&&Fl(t[e.right.content.key]??null,e.right.content.value));)e.forward()},Hl=(e,t,n,r)=>{let i=e.doc,a=i.clientID,o=new Map;for(let s in r){let c=r[s],l=n.currentAttributes.get(s)??null;if(!Fl(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new Gu($(a,vc(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new xu(s,c)),n.right.integrate(e,0),n.forward()}}return o},Ul=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;Vl(n,i);let s=Hl(e,t,n,i),c=r.constructor===String?new Ou(r):r instanceof ul?new Ru(r):new yu(r),{left:l,right:u,index:d}=n;t._searchMarker&&cl(t._searchMarker,n.index,c.getLength()),u=new Gu($(o,vc(a.store,o)),l,l&&l.lastId,u,u&&u.id,t,null,c),u.integrate(e,0),n.right=u,n.index=d,n.forward(),zl(e,t,n,s)},Wl=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;Vl(n,i);let s=Hl(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===xu));){if(!n.right.deleted)switch(n.right.content.constructor){case xu:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(Fl(o,a))s.delete(t);else{if(r===0)break iterationLoop;s.set(t,a)}n.right.delete(e)}else n.currentAttributes.set(t,a);break}default:r<n.right.length&&Cc(e,$(n.right.id.client,n.right.id.clock+r)),r-=n.right.length}n.forward()}if(r>0){let i=``;for(;r>0;r--)i+=`
|
|
4
|
-
`;n.right=new Gu($(o,vc(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new Ou(i)),n.right.integrate(e,0),n.forward()}zl(e,t,n,s)},Gl=(e,t,n,r,i)=>{let a=t,o=Hn();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===xu){let e=a.content;o.set(e.key,e)}a=a.right}let s=0,c=!1;for(;t!==a;){if(n===t&&(c=!0),!t.deleted){let n=t.content;switch(n.constructor){case xu:{let{key:a,value:l}=n,u=r.get(a)??null;(o.get(a)!==n||u===l)&&(t.delete(e),s++,!c&&(i.get(a)??null)===l&&u!==l&&(u===null?i.delete(a):i.set(a,u))),!c&&!t.deleted&&Bl(i,n);break}}}t=t.right}return s},Kl=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;let n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===xu){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},ql=e=>{let t=0;return Pc(e.doc,n=>{let r=e._start,i=e._start,a=Hn(),o=Un(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case xu:Bl(o,i.content);break;default:t+=Gl(n,r,i,a,o),a=Un(o),r=i}i=i.right}}),t},Jl=e=>{let t=new Set,n=e.doc;for(let[r,i]of e.afterState.entries()){let a=e.beforeState.get(r)||0;i!==a&&Ec(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===xu&&e.constructor!==du&&t.add(e.parent)})}Pc(n,n=>{us(e,e.deleteSet,e=>{if(e instanceof du||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===xu?t.add(r):Kl(n,e)});for(let e of t)ql(e)})},Yl=(e,t,n)=>{let r=n,i=Un(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case Ru:case yu:case Ou:n<t.right.length&&Cc(e,$(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e)}t.forward()}a&&Gl(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&cl(o._searchMarker,t.index,-r+n),t},Xl=class extends Qc{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(e=>{e===null?this.childListChanged=!0:this.keysChanged.add(e)})}get changes(){if(this._changes===null){let e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){let e=this.target.doc,t=[];Pc(e,e=>{let n=new Map,r=new Map,i=this.target._start,a=null,o={},s=``,c=0,l=0,u=()=>{if(a!==null){let e=null;switch(a){case`delete`:l>0&&(e={delete:l}),l=0;break;case`insert`:(typeof s==`object`||s.length>0)&&(e={insert:s},n.size>0&&(e.attributes={},n.forEach((t,n)=>{t!==null&&(e.attributes[n]=t)}))),s=``;break;case`retain`:c>0&&(e={retain:c},Ii(o)||(e.attributes=ji({},o))),c=0}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case Ru:case yu:this.adds(i)?this.deletes(i)||(u(),a=`insert`,s=i.content.getContent()[0],u()):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=1):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=1);break;case Ou:this.adds(i)?this.deletes(i)||(a!==`insert`&&(u(),a=`insert`),s+=i.content.str):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=i.length):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=i.length);break;case xu:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(Fl(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),Fl(s,r.get(t)??null)?delete o[t]:o[t]=s));else if(this.deletes(i)){r.set(t,s);let e=n.get(t)??null;Fl(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(Fl(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),Bl(n,i.content));break}}i=i.right}for(u();t.length>0;){let e=t[t.length-1];if(e.retain!==void 0&&e.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}},Zl=class e extends ul{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??el(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(e=>e())}catch(e){console.error(e)}this._pending=null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}_callObserver(e,t){super._callObserver(e,t);let n=new Xl(this,e,t);ll(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??el();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===Ou&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc===null?this._pending.push(()=>this.applyDelta(e)):Pc(this.doc,n=>{let r=new Il(null,this._start,0,new Map);for(let i=0;i<e.length;i++){let a=e[i];if(a.insert!==void 0){let o=!t&&typeof a.insert==`string`&&i===e.length-1&&r.right===null&&a.insert.slice(-1)===`
|
|
5
|
-
`?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&Ul(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&Yl(n,r,a.delete):Wl(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??el();let r=[],i=new Map,a=this.doc,o=``,s=this._start;function c(){if(o.length>0){let e={},t=!1;i.forEach((n,r)=>{t=!0,e[r]=n});let n={insert:o};t&&(n.attributes=e),r.push(n),o=``}}let l=()=>{for(;s!==null;){if(mc(s,e)||t!==void 0&&mc(s,t))switch(s.content.constructor){case Ou:{let r=i.get(`ychange`);e!==void 0&&!mc(s,e)?(r===void 0||r.user!==s.id.client||r.type!==`removed`)&&(c(),i.set(`ychange`,n?n(`removed`,s.id):{type:`removed`})):t!==void 0&&!mc(s,t)?(r===void 0||r.user!==s.id.client||r.type!==`added`)&&(c(),i.set(`ychange`,n?n(`added`,s.id):{type:`added`})):r!==void 0&&(c(),i.delete(`ychange`)),o+=s.content.str;break}case Ru:case yu:{c();let e={insert:s.content.getContent()[0]};if(i.size>0){let t={};e.attributes=t,i.forEach((e,n)=>{t[n]=e})}r.push(e);break}case xu:mc(s,e)&&(c(),Bl(i,s.content))}s=s.right}c()};return e||t?Pc(a,n=>{e&&hc(n,e),t&&hc(n,t),l()},`cleanup`):l(),r}insert(e,t,n){if(t.length<=0)return;let r=this.doc;r===null?this._pending.push(()=>this.insert(e,t,n)):Pc(r,r=>{let i=Rl(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),Ul(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):Pc(r,r=>{let i=Rl(r,this,e,!n);Ul(r,this,i,t,n||{})})}delete(e,t){if(t===0)return;let n=this.doc;n===null?this._pending.push(()=>this.delete(e,t)):Pc(n,n=>{Yl(n,Rl(n,this,e,!0),t)})}format(e,t,n){if(t===0)return;let r=this.doc;r===null?this._pending.push(()=>this.format(e,t,n)):Pc(r,r=>{let i=Rl(r,this,e,!1);i.right!==null&&Wl(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):Pc(this.doc,t=>{Sl(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):Pc(this.doc,n=>{Cl(n,this,e,t)})}getAttribute(e){return wl(this,e)}getAttributes(){return Tl(this)}_write(e){e.writeTypeRef(Nu)}},Ql=e=>new Zl,$l=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??el()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===nu||t.constructor===eu)&&t._start!==null)e=t._start;else for(;e!==null;){let t=e.next;if(t!==null){e=t;break}e=e.parent===this._root?null:e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}},eu=class e extends ul{constructor(){super(),this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof ul?e.clone():e)),t}get length(){return this.doc??el(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new $l(this,e)}querySelector(e){e=e.toUpperCase();let t=new $l(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),Xn(new $l(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){ll(this,e,new iu(this,t,e))}toString(){return ml(this,e=>e.toString()).join(``)}toJSON(){return this.toString()}toDOM(e=document,t={},n){let r=e.createDocumentFragment();return n!==void 0&&n._createAssociation(r,this),pl(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):Pc(this.doc,n=>{yl(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)Pc(this.doc,n=>{let r=e&&e instanceof ul?e._item:e;_l(n,this,r,t)});else{let n=this._prelimContent,r=e===null?0:n.findIndex(t=>t===e)+1;if(r===0&&e!==null)throw Xr(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):Pc(this.doc,n=>{xl(n,this,e,t)})}toArray(){return fl(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return gl(this,e)}slice(e=0,t=this.length){return dl(this,e,t)}forEach(e){pl(this,e)}_write(e){e.writeTypeRef(Fu)}},tu=e=>new eu,nu=class e extends eu{constructor(e=`UNDEFINED`){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((e,t)=>{this.setAttribute(t,e)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){let t=new e(this.nodeName);return Ni(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof ul?e.clone():e)),t}toString(){let e=this.getAttributes(),t=[],n=[];for(let t in e)n.push(t);n.sort();let r=n.length;for(let i=0;i<r;i++){let r=n[i];t.push(r+`="`+e[r]+`"`)}let i=this.nodeName.toLocaleLowerCase();return`<${i}${t.length>0?` `+t.join(` `):``}>${super.toString()}</${i}>`}removeAttribute(e){this.doc===null?this._prelimAttrs.delete(e):Pc(this.doc,t=>{Sl(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):Pc(this.doc,n=>{Cl(n,this,e,t)})}getAttribute(e){return wl(this,e)}hasAttribute(e){return El(this,e)}getAttributes(e){return e?Dl(this,e):Tl(this)}toDOM(e=document,t={},n){let r=e.createElement(this.nodeName),i=this.getAttributes();for(let e in i){let t=i[e];typeof t==`string`&&r.setAttribute(e,t)}return pl(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(Pu),e.writeKey(this.nodeName)}},ru=e=>new nu(e.readKey()),iu=class extends Qc{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(e=>{e===null?this.childListChanged=!0:this.attributesChanged.add(e)})}},au=class e extends Nl{constructor(e){super(),this.hookName=e}_copy(){return new e(this.hookName)}clone(){let t=new e(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(e=document,t={},n){let r=t[this.hookName],i;return i=r===void 0?document.createElement(this.hookName):r.createDom(this),i.setAttribute(`data-yjs-hook`,this.hookName),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(Iu),e.writeKey(this.hookName)}},ou=e=>new au(e.readKey()),su=class e extends Zl{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}toDOM(e=document,t,n){let r=e.createTextNode(this.toString());return n!==void 0&&n._createAssociation(r,this),r}toString(){return this.toDelta().map(e=>{let t=[];for(let n in e.attributes){let r=[];for(let t in e.attributes[n])r.push({key:t,value:e.attributes[n][t]});r.sort((e,t)=>e.key<t.key?-1:1),t.push({nodeName:n,attrs:r})}t.sort((e,t)=>e.nodeName<t.nodeName?-1:1);let n=``;for(let e=0;e<t.length;e++){let r=t[e];n+=`<${r.nodeName}`;for(let e=0;e<r.attrs.length;e++){let t=r.attrs[e];n+=` ${t.key}="${t.value}"`}n+=`>`}n+=e.insert;for(let e=t.length-1;e>=0;e--)n+=`</${t[e].nodeName}>`;return n}).join(``)}toJSON(){return this.toString()}_write(e){e.writeTypeRef(Lu)}},cu=e=>new su,lu=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Zr()}mergeWith(e){return!1}write(e,t,n){throw Zr()}integrate(e,t){throw Zr()}},uu=0,du=class extends lu{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor&&(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),yc(e.doc.store,this)}write(e,t){e.writeInfo(uu),e.writeLen(this.length-t)}getMissing(e,t){return null}},fu=class e{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new e(this.content)}splice(e){throw Zr()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},pu=e=>new fu(e.readBuf()),mu=class e{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.len)}splice(t){let n=new e(this.len-t);return this.len=t,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){hs(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}},hu=e=>new mu(e.readLen()),gu=(e,t)=>new Ss({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),_u=class e{constructor(e){e._item&&console.error(`This document was already integrated as a sub-document. You should create a second instance instead with the same guid.`),this.doc=e;let t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new e(gu(this.doc.guid,this.opts))}splice(e){throw Zr()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}},vu=e=>new _u(gu(e.readString(),e.readAny())),yu=class e{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new e(this.embed)}splice(e){throw Zr()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},bu=e=>new yu(e.readJSON()),xu=class e{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.key,this.value)}splice(e){throw Zr()}mergeWith(e){return!1}integrate(e,t){let n=t.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}},Su=e=>new xu(e.readKey(),e.readJSON()),Cu=class e{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeString(t===void 0?`undefined`:JSON.stringify(t))}}getRef(){return 2}},wu=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++){let t=e.readString();t===`undefined`?n.push(void 0):n.push(JSON.parse(t))}return new Cu(n)},Tu=Qi(`node_env`)===`development`,Eu=class e{constructor(e){this.arr=e,Tu&&Vi(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeAny(t)}}getRef(){return 8}},Du=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new Eu(n)},Ou=class e{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split(``)}isCountable(){return!0}copy(){return new e(this.str)}splice(t){let n=new e(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+`�`,n.str=`�`+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}},ku=e=>new Ou(e.readString()),Au=[jl,Pl,Ql,ru,tu,ou,cu],ju=0,Mu=1,Nu=2,Pu=3,Fu=4,Iu=5,Lu=6,Ru=class e{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new e(this.type._copy())}splice(e){throw Zr()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(t=>{t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(t=>{for(;t!==null;)t.gc(e,!0),t=t.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}},zu=e=>new Ru(Au[e.readTypeRef()](e)),Bu=(e,t)=>{let n=t,r=0,i;do r>0&&(n=$(n.client,n.clock+r)),i=xc(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof Gu);return{item:i,diff:r}},Vu=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},Hu=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new Gu($(r,i+n),t,$(r,i+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&a.markDeleted(),t.keep&&(a.keep=!0),t.redone!==null&&(a.redone=$(t.redone.client,t.redone.clock+n)),t.right=a,a.right!==null&&(a.right.left=a),e._mergeStructs.push(a),a.parentSub!==null&&a.right===null&&a.parent._map.set(a.parentSub,a),t.length=n,a},Uu=(e,t)=>Qn(e,e=>fs(e.deletions,t)),Wu=(e,t,n,r,i,a)=>{let o=e.doc,s=o.store,c=o.clientID,l=t.redone;if(l!==null)return Cc(e,l);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||Wu(e,u,n,r,i,a)===null))return null;for(;u.redone!==null;)u=Cc(e,u.redone)}let p=u===null?t.parent:u.content.type;if(t.parentSub===null){for(d=t.left,f=t;d!==null;){let t=d;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:Cc(e,t.redone);if(t!==null&&t.parent._item===u){d=t;break}d=d.left}for(;f!==null;){let t=f;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:Cc(e,t.redone);if(t!==null&&t.parent._item===u){f=t;break}f=f.right}}else{if(f=null,t.right&&!i){for(d=t;d!==null&&d.right!==null&&(d.right.redone||fs(r,d.right.id)||Uu(a.undoStack,d.right.id)||Uu(a.redoStack,d.right.id));)for(d=d.right;d.redone;)d=Cc(e,d.redone);if(d&&d.right!==null)return null}else d=p._map.get(t.parentSub)||null;d!==null&&d.parent._item!==u&&(d=p._map.get(t.parentSub)||null)}let m=$(c,vc(s,c)),h=new Gu(m,d,d&&d.lastId,f,f&&f.id,p,t.parentSub,t.content.copy());return t.redone=m,Vu(h,!0),h.integrate(e,0),h},Gu=class e extends lu{constructor(e,t,n,r,i,a,o,s){super(e,s.getLength()),this.origin=n,this.left=t,this.right=r,this.rightOrigin=i,this.parent=a,this.parentSub=o,this.redone=null,this.content=s,this.info=this.content.isCountable()?2:0}set marker(e){(this.info&8)>0!==e&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=vc(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=vc(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===$s&&this.id.client!==this.parent.client&&this.parent.clock>=vc(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=wc(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=Cc(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===du||this.right&&this.right.constructor===du)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===e?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===e&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===$s){let e=xc(n,this.parent);this.parent=e.constructor===du?null:e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=wc(e,e.doc.store,$(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let t=this.left,n;if(t!==null)n=t.right;else if(this.parentSub!==null)for(n=this.parent._map.get(this.parentSub)||null;n!==null&&n.left!==null;)n=n.left;else n=this.parent._start;let r=new Set,i=new Set;for(;n!==null&&n!==this.right;){if(i.add(n),r.add(n),ec(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if(ec(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(xc(e.doc.store,n.origin)))r.has(xc(e.doc.store,n.origin))||(t=n,r.clear());else break;n=n.right}this.left=t}if(this.left!==null){let e=this.left.right;this.right=e,this.left.right=this}else{let e;if(this.parentSub!==null)for(e=this.parent._map.get(this.parentSub)||null;e!==null&&e.left!==null;)e=e.left;else e=this.parent._start,this.parent._start=this;this.right=e}this.right===null?this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)):this.right.left=this,this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),yc(e.doc.store,this),this.content.integrate(e,this),kc(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new du(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:$(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&ec(e.origin,this.lastId)&&this.right===e&&ec(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let t=this.parent._searchMarker;return t&&t.forEach(t=>{t.p===e&&(t.p=this,!this.deleted&&this.countable&&(t.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){let t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),hs(e.deleteSet,this.id.client,this.id.clock,this.length),kc(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw Qr();this.content.gc(e),t?Tc(e,this,new du(this.id,this.length)):this.content=new mu(this.length)}write(e,t){let n=t>0?$(this.id.client,this.id.clock+t-1):this.origin,r=this.rightOrigin,i=this.parentSub,a=this.content.getRef()&31|(n===null?0:128)|(r===null?0:64)|(i===null?0:32);if(e.writeInfo(a),n!==null&&e.writeLeftID(n),r!==null&&e.writeRightID(r),n===null&&r===null){let t=this.parent;if(t._item!==void 0){let n=t._item;if(n===null){let n=tc(t);e.writeParentInfo(!0),e.writeString(n)}else e.writeParentInfo(!1),e.writeLeftID(n.id)}else t.constructor===String?(e.writeParentInfo(!0),e.writeString(t)):t.constructor===$s?(e.writeParentInfo(!1),e.writeLeftID(t)):Qr();i!==null&&e.writeString(i)}this.content.write(e,t)}},Ku=(e,t)=>qu[t&31](e),qu=[()=>{Qr()},hu,wu,pu,ku,bu,Su,zu,Du,vu,()=>{Qr()}],Ju=10,Yu=class extends lu{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor&&(this.length+=e.length,!0)}integrate(e,t){Qr()}write(e,t){e.writeInfo(Ju),Z(e.restEncoder,this.length-t)}getMissing(e,t){return null}},Xu=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},Zu=`__ $YJS$ __`;Xu[Zu]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),Xu[Zu]=!0;var Qu=`verbatim.verbatim*.Verbatim.BVerbatim.LVerbatim.SaveVerbatim.VerbatimOut.bverbatim.bverbatim*.lverbatim.lverbatim*.saveverbatim.saveverbatim*.verbatimout.verbatimwrite.lstlisting.lstlisting*.minted.minted*.tcblisting.tcblisting*.pygmented.alltt.filecontents.filecontents*.luacode.luacodestar.comment`.split(`.`),$u=new Set(Qu);function ed(e){return $u.has(e)}function td(e,t,n){if(e[t]!==`[`)return t;let r=1;for(let i=t+1;i<n;i+=1)if(e[i]===`\\`)i+=1;else if(e[i]===`[`&&(r+=1),e[i]===`]`&&(--r,r===0))return i+1;return null}function nd(e,t,n){if(e[t]!==`{`)return null;let r=1;for(let i=t+1;i<n;i+=1)if(e[i]===`\\`)i+=1;else if(e[i]===`{`&&(r+=1),e[i]===`}`&&(--r,r===0))return i+1;return null}function rd(e,t,n=e.length){let r=e.indexOf(`
|
|
6
|
-
`,t);r>=0&&(n=Math.min(n,r));let i=/^\\(verb\*?|Verb\*?|lstinline\*?|mintinline\*?)(?![A-Za-z@])/.exec(e.slice(t,n));if(!i)return null;let a=i[1].replace(/\*$/,``),o=t+i[0].length;if(a!==`verb`){let t=td(e,o,n);if(t===null)return null;o=t}if(a===`mintinline`){let t=nd(e,o,n);if(t===null)return null;o=t}let s=e[o];if(!s||/\s/.test(s))return null;if(s===`{`&&a!==`verb`){let t=nd(e,o,n);return{end:t??n,closed:t!==null}}let c=e.indexOf(s,o+1);return c<0||c>=n?{end:n,closed:!1}:{end:c+1,closed:!0}}function id(e,t,n=e.length){return rd(e,t,n)?.end??null}function ad(e,t,n){let r=n.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),i=new RegExp(String.raw`\\end\s*\{\s*${r}\s*\}`,`g`);i.lastIndex=t;let a=i.exec(e);return a?{from:a.index,to:a.index+a[0].length}:null}function od(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function sd(e,t){let n=t+1;if(/[A-Za-z@]/.test(e[n]??``)){for(;/[A-Za-z@]/.test(e[n]??``);)n+=1;return e[n]===`*`&&(n+=1),n}return Math.min(e.length,n+1)}function cd(e,t){let n=/^\\begin\s*\{\s*([A-Za-z0-9@:_*.\-]+)\s*\}/.exec(e.slice(t));return!n||!ed(n[1])?null:{name:n[1],to:t+n[0].length}}function ld(e,t){let n=Math.max(0,Math.min(e.length,t));for(let t=0;t<n;){if(e[t]===`%`&&!od(e,t)){let r=e.indexOf(`
|
|
7
|
-
`,t),i=r<0?e.length:r;if(n<=i)return`comment`;t=i+1;continue}if(e[t]!==`\\`||od(e,t)){t+=1;continue}let r=rd(e,t);if(r!==null){if(n<r.end||!r.closed&&n<=r.end)return`literal`;t=r.end;continue}let i=cd(e,t);if(i){let r=ad(e,i.to,i.name),a=r?.to??e.length;if(n<a||!r&&n<=a)return`literal`;t=a}else t=sd(e,t)}return null}function ud(e,t,n){return e.slice(t,n).replace(/[^\r\n]/g,` `)}function dd(e){let t=e.split(``);for(let n=0;n<e.length;n+=1){if(e[n]!==`%`||od(e,n))continue;let r=e.indexOf(`
|
|
8
|
-
`,n),i=r<0?e.length:r;for(let e=n;e<i;e+=1)t[e]=` `;n=i}return t.join(``)}function fd(e){let t=``,n=0;for(;n<e.length;){if(e[n]===`%`&&!od(e,n)){let r=e.indexOf(`
|
|
9
|
-
`,n),i=r<0?e.length:r;t+=e.slice(n,i),n=i;continue}if(e[n]!==`\\`||od(e,n)){t+=e[n],n+=1;continue}let r=id(e,n);if(r!==null){t+=ud(e,n,r),n=r;continue}let i=cd(e,n);if(i){let r=ad(e,i.to,i.name)?.to??e.length;t+=ud(e,n,r),n=r}else t+=e[n],n+=1}return t}var pd=new Set(Qu);function md(e){return/[A-Za-z@0-9:_-]/.test(e)}function hd(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function gd(e,t){return e[t]===`%`&&!hd(e,t)}function _d(e,t){let n=e.indexOf(`
|
|
10
|
-
`,t);return n===-1?e.length:n}function vd(e,t){let n=t;for(;n<e.length;)if(/\s/.test(e[n]))n+=1;else if(gd(e,n))n=_d(e,n);else break;return n}function yd(e,t,n,r){if(e[t]!==n)return null;let i=0,a=0;for(let o=t;o<e.length;o+=1){let s=e[o];if(s===`\\`&&o+1<e.length)o+=1;else if(gd(e,o))o=_d(e,o)-1;else{if(n===`[`){if(s===`{`){a+=1;continue}if(s===`}`&&a>0){--a;continue}if(a>0)continue}if(s===n)i+=1;else if(s===r&&(--i,i===0))return{from:t,to:o+1,contentFrom:t+1,contentTo:o}}}return null}function bd(e,t,n){let r=[],i=t;for(;r.length<n;){for(i=vd(e,i);e[i]===`[`;){let t=yd(e,i,`[`,`]`);if(!t)return r;i=vd(e,t.to)}if(e[i]!==`{`)break;let t=yd(e,i,`{`,`}`);if(!t)break;r.push(t),i=t.to}return r}function xd(e,t,n){let r=[],i=t;for(;r.length<n&&(i=vd(e,i),e[i]===`[`);){let t=yd(e,i,`[`,`]`);if(!t)break;r.push(t),i=t.to}return r}function Sd(e,t){if(e[t]!==`\\`||t+1>=e.length)return null;let n=t+1;if(!/[A-Za-z@]/.test(e[n]))return{name:e[n],from:t,to:n+1};for(;n<e.length&&md(e[n]);)n+=1;let r=e.slice(t+1,n);return e[n]===`*`&&(n+=1),{name:r,from:t,to:n}}function Cd(e,t){if(t.name!==`begin`)return t.to;let n=bd(e,t.to,1)[0];if(!n)return t.to;let r=e.slice(n.contentFrom,n.contentTo).trim();return pd.has(r)?ad(e,n.to,r)?.to??e.length:t.to}function wd(e,t){let n=0;for(;n<e.length;){if(gd(e,n)){n=_d(e,n);continue}if(e[n]!==`\\`){n+=1;continue}let r=Sd(e,n);if(!r){n+=1;continue}let i=id(e,r.from);if(i!==null&&i>r.to){n=i;continue}let a=Cd(e,r);a>r.to?n=a:(t(r),n=r.to)}}function Td(e,t,n){let r=[],i=t.contentFrom,a=t.contentFrom;for(;a<=t.contentTo;){if(a<t.contentTo&&gd(e,a)){a=_d(e,a),e[a]===`
|
|
11
|
-
`&&(a+=1);continue}if(a!==t.contentTo&&(!n||e[a]!==`,`)){a+=1;continue}let o=Ed(e,i,a);o&&r.push(o),i=a+1,a+=1}return r}function Ed(e,t,n){let r=[],i=t;for(;i<n;)gd(e,i)?(i=_d(e,i),e[i]===`
|
|
12
|
-
`&&(i+=1)):(r.push({character:e[i],index:i}),i+=1);let a=0,o=r.length;for(;a<o&&/\s/.test(r[a].character);)a+=1;for(;o>a&&/\s/.test(r[o-1].character);)--o;return a===o?null:{path:r.slice(a,o).map(e=>e.character).join(``),command:``,from:r[a].index,to:r[o-1].index+1}}function Dd(e,t){let n=vd(e,t);if(n>=e.length||/[\\{}\[\]#~]/.test(e[n]))return null;let r=n;for(;r<e.length&&!/\s/.test(e[r])&&!gd(e,r)&&!/[\\{}\[\]#~]/.test(e[r]);)r+=1;return r===n?null:{path:e.slice(n,r),command:``,from:n,to:r}}function Od(e){let t=[];return wd(e,n=>{let r=n.name.toLowerCase();if(r===`input`||r===`include`||r===`subfile`){let i=bd(e,n.to,1)[0];if(i)for(let r of Td(e,i,!1))t.push({...r,command:n.name});else if(r===`input`){let r=Dd(e,n.to);r&&t.push({...r,command:n.name})}return}if(r!==`import`&&r!==`subimport`&&r!==`includefrom`&&r!==`inputfrom`&&r!==`subinputfrom`&&r!==`subincludefrom`)return;let i=bd(e,n.to,2);if(i.length!==2)return;let a=Td(e,i[0],!1)[0]?.path??``,o=Td(e,i[1],!1)[0];if(!o)return;let s=a&&!a.endsWith(`/`)?`/`:``;t.push({path:a+s+o.path,command:n.name,from:o.from,to:o.to,directory:a})}),t}var kd=(e,t)=>e>>>t|e<<32-t,Ad=e=>kd(e,2)^kd(e,13)^kd(e,22),jd=e=>kd(e,6)^kd(e,11)^kd(e,25),Md=e=>kd(e,7)^kd(e,18)^e>>>3,Nd=e=>kd(e,17)^kd(e,19)^e>>>10,Pd=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Fd=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Id=class{constructor(){let e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(Fd),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let e=16;e<64;e++)t[e]=Nd(t[e-2])+t[e-7]+Md(t[e-15])+t[e-16];let n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=e[6],l=e[7];for(let e=0,u,d;e<64;e++)u=l+jd(o)+(o&s^~o&c)+Pd[e]+t[e]>>>0,d=Ad(n)+(n&r^n&i^r&i)>>>0,l=c,c=s,s=o,o=a+u>>>0,a=i,i=r,r=n,n=u+d>>>0;e[0]+=n,e[1]+=r,e[2]+=i,e[3]+=a,e[4]+=o,e[5]+=s,e[6]+=c,e[7]+=l}digest(e){let t=0;for(;t+56<=e.length;){let n=0;for(;n<16&&t+3<e.length;n++)this._W[n]=e[t++]<<24|e[t++]<<16|e[t++]<<8|e[t++];if(t%64!=0){for(this._W.fill(0,n,16);t<e.length;)this._W[n]|=e[t]<<(3-t%4)*8,t++;this._W[n]|=128<<(3-t%4)*8}this._updateHash()}let n=t%64!=0;this._W.fill(0,0,16);let r=0;for(;t<e.length;r++)for(let n=3;n>=0&&t<e.length;n--)this._W[r]|=e[t++]<<n*8;n||(this._W[r-(t%4==0?0:1)]|=128<<(3-t%4)*8),this._W[14]=e.byteLength/lr,this._W[15]=e.byteLength*8,this._updateHash();let i=new Uint8Array(32);for(let e=0;e<this._H.length;e++)for(let t=0;t<4;t++)i[e*4+t]=this._H[e]>>>(3-t)*8;return i}},Ld=e=>new Id().digest(e);function Rd(e){return Array.from(Ld(new TextEncoder().encode(e)),e=>e.toString(16).padStart(2,`0`)).join(``)}function zd(e){for(let t=0;t<e.length;t+=1)e[t]=Math.floor(Math.random()*256);return e}function Bd(e){e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function Vd(e=globalThis.crypto){if(typeof e?.randomUUID==`function`)return e.randomUUID();let t=new Uint8Array(16);return Bd(typeof e?.getRandomValues==`function`?e.getRandomValues(t):zd(t))}function Hd(e){return/\.(?:tex|sty|cls|ltx|dtx|ins|txt|md|markdown|rst)$/i.test(e.trim())}function Ud(e){return/\.(?:tex|sty|cls)$/i.test(e.trim())}function Wd(e){return(typeof e==`number`||typeof e==`string`)&&e!==``}function Gd(e){let t=(0,J.useId)();return Wd(e)?`${e}`:t}var Kd=typeof window<`u`?J.useLayoutEffect:J.useEffect;function qd(e){let t=(0,J.useRef)(e);return Kd(()=>{t.current=e},[e]),(0,J.useCallback)((...e)=>t.current?.(...e),[t])}function Jd(...e){return qd(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t}})})}function Yd(e,t){let n=e?.[`data-testid`];return Wd(n)?`${n}`:Wd(t)?`${t}`:void 0}function Xd(e,t=`Assertion error`){if(!e)throw Error(t)}(0,J.createContext)(null);var Zd;function Qd(){return Zd===void 0&&(Zd=typeof matchMedia==`function`&&!!matchMedia(`(pointer:coarse)`).matches),Zd}function $d({expandHitTargets:e,axis:t,rect:n}){let r=e?Qd()?t.resizeTargetMinimumSize.coarse:t.resizeTargetMinimumSize.fine:0;if(n.width<r){let e=r-n.width;n=new DOMRect(n.x-e/2,n.y,n.width+e,n.height)}if(n.height<r){let e=r-n.height;n=new DOMRect(n.x,n.y-e/2,n.width,n.height+e)}return n}function ef(e){switch(typeof e){case`number`:return[e,`px`];case`string`:{let t=parseFloat(e);return e.endsWith(`%`)?[t,`%`]:e.endsWith(`px`)?[t,`px`]:e.endsWith(`rem`)?[t,`rem`]:e.endsWith(`em`)?[t,`em`]:e.endsWith(`vh`)?[t,`vh`]:e.endsWith(`vw`)?[t,`vw`]:[t,`%`]}}}var tf=class{#e={};addListener(e,t){let n=this.#e[e];return n===void 0?this.#e[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#e[e];if(n!==void 0){if(n.length===1){n[0].call(null,t);return}let e,r=Array.from(n);for(let n=0;n<r.length;n++){let i=r[n];try{i.call(null,t)}catch(t){e??={error:t}}}if(e)throw e.error}}removeAllListeners(){this.#e={}}removeListener(e,t){let n=this.#e[e];if(n!==void 0){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}},nf={cursorFlags:0,state:`inactive`},rf=new tf;function af(){return nf}function of(e){return rf.addListener(`change`,e)}function sf(e,t=[],n,r=!1){let i=nf,a={...nf};a.cursorFlags=e,a.state===`active`&&(a.didPointerMove||=r,a.previews=t,n&&(a.previewLayoutMap=n)),nf=a,rf.emit(`change`,{prev:i,next:a})}function cf(e){let t=nf;nf=e,t.state===`active`&&e.state!==`active`&&t.didPointerMove&&t.hitRegions.forEach(({separator:e})=>{e&&e.element.ownerDocument.activeElement===e.element&&e.element.blur()}),rf.emit(`change`,{prev:t,next:e})}function lf(e){nf.state!==`active`||!nf.previews.some(t=>t.separator===e)||cf({...nf,previews:nf.previews.map(t=>t.separator===e?{...t}:t)})}function uf(e){if(nf.state===`inactive`)return;let t=nf.hitRegions.filter(t=>t.axis!==e),n=nf.state===`active`&&nf.previews.some(t=>t.axis===e);if(t.length!==nf.hitRegions.length||n){if(t.length===0)cf({cursorFlags:0,state:`inactive`});else if(nf.state===`active`){let n=new Map(nf.initialLayoutMap),r=new Map(nf.previewLayoutMap);n.delete(e),r.delete(e),cf({...nf,cursorFlags:0,hitRegions:t,initialLayoutMap:n,previewLayoutMap:r,previews:nf.previews.filter(t=>t.axis!==e)})}else cf({...nf,hitRegions:t})}}var df=e=>e,ff=()=>{},pf=1,mf=2,hf=4,gf=8,_f=3,vf=12,yf;function bf(){return yf===void 0&&(yf=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(yf=!0)),yf}function xf({cursorFlags:e,axes:t,state:n}){let r=0,i=0;switch(n){case`active`:case`hover`:t.forEach(e=>{if(!e.mutableState.disableCursor)switch(e.orientation){case`horizontal`:r++;break;case`vertical`:i++}})}if(r!==0||i!==0){if(n===`active`&&e&&bf()){let t=(e&pf)!==0,n=(e&mf)!==0,r=(e&hf)!==0,i=(e&gf)!==0;if(t)return r?`se-resize`:i?`ne-resize`:`e-resize`;if(n)return r?`sw-resize`:i?`nw-resize`:`w-resize`;if(r)return`s-resize`;if(i)return`n-resize`}return bf()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var Sf=new WeakMap;function Cf(e){if(!e.defaultView||!e.adoptedStyleSheets)return;let{prevStyle:t,styleSheet:n}=Sf.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));let r=af();switch(r.state!==`inactive`&&r.ownerDocument!==e&&(r={cursorFlags:0,state:`inactive`}),r.state){case`active`:case`hover`:{let e=xf({cursorFlags:r.cursorFlags,axes:r.hitRegions.map(e=>e.axis),state:r.state}),i=`*, *:hover {cursor: ${e} !important; }`;if(t===i)return;t=i,e?n.cssRules.length===0?n.insertRule(i):n.replaceSync(i):n.cssRules.length===1&&n.deleteRule(0);break}case`inactive`:t=void 0,n.cssRules.length===1&&n.deleteRule(0)}Sf.set(e,{prevStyle:t,styleSheet:n})}function wf(e){return e.state===`inactive`?void 0:e.ownerDocument}function Tf({next:e,prev:t}){let n=wf(t),r=wf(e);n&&n!==r&&Cf(n),r&&Cf(r)}function Ef({axis:e}){let{layoutStrategy:t,orientation:n,items:r}=e;return t?t.calculateAvailableSize():r.reduce((e,t)=>(e+=n===`horizontal`?t.element.offsetWidth:t.element.offsetHeight,e),0)}function Df(e,t){let n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_DISCONNECTED?0:n&Node.DOCUMENT_POSITION_FOLLOWING?-1:n&Node.DOCUMENT_POSITION_PRECEDING?1:0}function Of(e,t){return Array.from(t).sort((t,n)=>{let r=e===`horizontal`?kf(t,n):Af(t,n);return r===0?Df(t.element,n.element):r})}function kf(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function Af(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function jf(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function Mf(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function Nf({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},i,a=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=Mf(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return Xd(i,`No rect found`),i}function Pf({expandHitTargets:e=!0,axis:t,includeDisabled:n=!1}){if(t.layoutStrategy)return t.layoutStrategy.calculateHitRegions({expandHitTargets:e,axis:t,includeDisabled:n});let{element:r,orientation:i,items:a,separators:o}=t,s=Of(i,Array.from(r.children).filter(jf).filter(e=>!e.hasAttribute(`data-resize-preview`)).map(e=>({element:e}))).map(({element:e})=>e),c=[],l=!1,u=!1,d=-1,f,p=-1,m=0,h,g=[];{let e=-1;for(let t of s)t.hasAttribute(`data-panel`)&&(e++,t.hasAttribute(`data-disabled`)||(m++,d===-1&&(d=e),p=e))}if(n||m>1){let r=-1;for(let m of s)if(m.hasAttribute(`data-panel`)){r++;let o=a.find(e=>e.element===m);if(o){if(h){let a=h.element.getBoundingClientRect(),s=m.getBoundingClientRect(),_;if(u){let e=i===`horizontal`?new DOMRect(a.right,a.top,0,a.height):new DOMRect(a.left,a.bottom,a.width,0),t=i===`horizontal`?new DOMRect(s.left,s.top,0,s.height):new DOMRect(s.left,s.top,s.width,0);switch(g.length){case 0:_=[e,t];break;case 1:{let n=g[0];_=[n,Nf({orientation:i,rects:[a,s],targetRect:n.element.getBoundingClientRect()})===a?t:e];break}default:_=g}}else _=g.length?g:[i===`horizontal`?new DOMRect(a.right,s.top,s.left-a.right,s.height):new DOMRect(s.left,a.bottom,s.width,s.top-a.bottom)];for(let i of _){let a=$d({expandHitTargets:e,axis:t,rect:`width`in i?i:i.element.getBoundingClientRect()});(n||!l&&!(r<=d||r>p))&&(f??=Ef({axis:t}),c.push({axis:t,axisSize:f,items:[h,o],separator:`width`in i?void 0:i,rect:a})),l=!1}}u=!1,h=o,g=[]}}else if(m.hasAttribute(`data-separator`)){m.ariaDisabled!==null&&(l=!0);let e=o.find(e=>e.element===m);e?g.push(e):(h=void 0,g=[])}else u=!0}return c}function Ff(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function If(e,t){let n=getComputedStyle(e.ownerDocument.documentElement);return t*parseFloat(n.fontSize)}function Lf(e){return e/100*window.innerHeight}function Rf(e){return e/100*window.innerWidth}function zf({axisSize:e,itemElement:t,styleProp:n}){let r,[i,a]=ef(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=If(t,i);break;case`em`:r=Ff(t,i);break;case`vh`:r=Lf(i);break;case`vw`:r=Rf(i)}return r}function Bf(e){return parseFloat(e.toFixed(3))}function Vf(e,t=Ef({axis:e})){let{items:n}=e;return t===0?n.map(e=>({groupResizeBehavior:e.constraintProps.groupResizeBehavior,collapsedSize:0,collapsible:e.constraintProps.collapsible===!0,defaultSize:void 0,disabled:e.constraintProps.disabled,minSize:0,maxSize:100,itemId:e.id})):n.map(e=>{let{element:n,constraintProps:r}=e,i=0;r.collapsedSize!==void 0&&(i=Bf(zf({axisSize:t,itemElement:n,styleProp:r.collapsedSize})/t*100));let a;r.collapsedThreshold!==void 0&&(a=Bf(zf({axisSize:t,itemElement:n,styleProp:r.collapsedThreshold})/t*100));let o;r.defaultSize!==void 0&&(o=Bf(zf({axisSize:t,itemElement:n,styleProp:r.defaultSize})/t*100));let s=0;r.minSize!==void 0&&(s=Bf(zf({axisSize:t,itemElement:n,styleProp:r.minSize})/t*100));let c=100;return r.maxSize!==void 0&&(c=Bf(zf({axisSize:t,itemElement:n,styleProp:r.maxSize})/t*100)),{groupResizeBehavior:r.groupResizeBehavior,collapsedSize:i,collapsedThreshold:a,collapsible:r.collapsible===!0,defaultSize:o,disabled:r.disabled,minSize:s,maxSize:c,itemId:e.id}})}var Hf=new Map,Uf=new tf,Wf=0,Gf=[],Kf;function qf(){Wf++}function Jf(){for(let e=0;e<Gf.length;e++)try{Uf.emit(`axisChange`,Gf[e])}catch(e){Kf??={error:e}}Gf.length=0}function Yf(){if(Wf===1&&Jf(),Wf--,Wf===0&&Kf){let{error:e}=Kf;throw Kf=void 0,e}}function Xf(e){Hf=new Map(Hf),Hf.delete(e)}function Zf(e,t){for(let[t]of Hf)if(t.id===e)return t}function Qf(e,t){for(let[t,n]of Hf)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function $f(){return Hf}function ep(e,t){return Uf.addListener(`axisChange`,n=>{n.axis.id===e&&t(n)})}function tp(e,t,n){let r=Hf.get(e);Hf=new Map(Hf),Hf.set(e,t);let i={axis:e,isUserInteraction:n?.isUserInteraction===!0,prev:r,next:t};Wf>0?Gf.push(i):Uf.emit(`axisChange`,i)}function np(e,{pointerId:t,pointerType:n}){return t===e.pointerId||n===`pen`&&e.pointerType===`pen`}function rp(e,t,n={}){return e.ownerDocument===t&&(n.pointerId===void 0||np(e,n))}function ip(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function ap(e,t,n=0){return Math.abs(Bf(e)-Bf(t))<=n}function op(e,t){return ap(e,t)?0:e>t?1:-1}function sp({overrideDisabledItems:e,itemConstraints:t,prevSize:n,size:r}){let{collapsedSize:i=0,collapsedThreshold:a,collapsible:o,disabled:s,maxSize:c=100,minSize:l=0}=t;if(s&&!e)return n;if(op(r,l)<0){if(o){let e=a??(l-i)/2,t=op(n,i)<=0,o=t?i+e:l-e,s=op(r,o);r=op(r,i)<=0||s<0||a!==void 0&&t&&s===0?i:l}else r=l}return r=Math.min(c,r),r=Bf(r),r}function cp({delta:e,initialLayout:t,itemConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(ap(e,0))return t;let o=a===`imperative-api`,s=n.map(({itemId:e})=>t[e]),c=n.map(({itemId:e})=>i[e]),l=[...s],[u,d]=r;Xd(u!=null,`Invalid first pivot index`),Xd(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];Xd(r,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(Xd(n!=null,`Previous layout not found for panel index ${t}`),ap(n,i)){let t=o-n;op(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];Xd(r,`No panel constraints found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(Xd(n!=null,`Previous layout not found for panel index ${t}`),ap(n,o)){let t=n-i;op(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];Xd(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsedSize:a,collapsedThreshold:o,collapsible:c,minSize:l}=r;if(c&&op(i,l)<0){let t=l-a,n=o??t/2;if(op(i+Math.abs(e),l)<0){let r=op(Math.abs(e),n);e=r>0||r===0&&o===void 0&&e<0?e<0?-t:t:0}}break}}{let t=e<0?1:-1,r=e<0?d:u,i=0;for(;;){let e=s[r];Xd(e!=null,`Previous layout not found for panel index ${r}`);let a=sp({overrideDisabledItems:o,itemConstraints:n[r],prevSize:e,size:100})-e;if(i+=a,r+=t,r<0||r>=n.length)break}let a=Math.min(Math.abs(e),Math.abs(i));e=e<0?0-a:a}{let t=e<0?u:d;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),i=s[t];Xd(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=sp({overrideDisabledItems:o,itemConstraints:n[t],prevSize:i,size:a});if(!ap(i,c)&&(f+=i-c,l[t]=c,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(ip(c,l))return i;{let t=e<0?d:u,r=s[t];Xd(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=sp({overrideDisabledItems:o,itemConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!ap(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];Xd(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=sp({overrideDisabledItems:o,itemConstraints:n[r],prevSize:i,size:a});if(ap(i,s)||(t-=s-i,l[r]=s),ap(t,0))break;e>0?r--:r++}}}return ap(Object.values(l).reduce((e,t)=>t+e,0),100,.1)?l.reduce((e,t,r)=>(e[n[r].itemId]=t,e),{}):i}function lp(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||op(e[n],t[n])!==0)return!1;return!0}function up(e){qf();try{dp(e)}finally{Yf()}}function dp({commit:e,event:t,hitRegions:n,initialLayoutMap:r,mountedAxes:i,pointerDownAtPoint:a,prevCursorFlags:o}){let s=0,c=af(),l=c.state===`active`?c.previews:[],u=new Map(c.state===`active`?c.previewLayoutMap:void 0);n.forEach(n=>{let{axis:o,axisSize:c}=n,{orientation:d,items:f}=o;if(e&&o.resizePreviewMode!==`separator`)return;let{disableCursor:p}=o.mutableState,m=0;m=a?d===`horizontal`?(t.clientX-a.x)/c*100:(t.clientY-a.y)/c*100:d===`horizontal`?t.clientX<0?-100:100:t.clientY<0?-100:100;let h=r.get(o),g=i.get(o);if(!h||!g)return;let{defaultLayoutDeferred:_,derivedItemConstraints:v,axisSize:y,layout:b,separatorToItems:x}=g;if(v&&b&&x){let t=o.resizePreviewMode===`separator`?u.get(o)??b:b,r=cp({delta:m,initialLayout:h,itemConstraints:v,pivotIndices:n.items.map(e=>f.indexOf(e)),prevLayout:t,trigger:`mouse-or-touch`});if(o.resizePreviewMode===`separator`&&!e&&!lp(r,t)){u.set(o,r);let e=0,t=f.map(t=>(e+=r[t.id]-h[t.id],c/100*e));l=l.map(e=>{if(e.axis!==o)return e;let n=t[e.itemIndex];return n===e.offset?e:{...e,offset:n}})}if(lp(r,t)&&m!==0&&!p)switch(d){case`horizontal`:s|=m<0?pf:mf;break;case`vertical`:s|=m<0?hf:gf}(o.resizePreviewMode!==`separator`||e)&&!lp(r,b)&&tp(n.axis,{defaultLayoutDeferred:_,derivedItemConstraints:v,axisSize:y,layout:r,requestedAxisSize:y,requestedLayout:r,separatorToItems:x})}});let d=0;t.movementX===0?d|=o&_f:d|=s&_f,t.movementY===0?d|=o&vf:d|=s&vf;let f=c.state===`active`&&(t.clientX!==c.pointerDownAtPoint.x||t.clientY!==c.pointerDownAtPoint.y);sf(d,l,u,f)}function fp(e,t){let n=af();if(n.state!==`active`||!rp(n,e,t))return;let r=$f();qf();try{up({commit:!0,event:t,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedAxes:r,pointerDownAtPoint:n.pointerDownAtPoint,prevCursorFlags:n.cursorFlags}),Jf(),cf({cursorFlags:0,state:`inactive`}),n.hitRegions.length>0&&(t.preventDefault?.(),n.hitRegions.forEach(e=>{if(!r.has(e.axis))return;let t=Qf(e.axis.id,!0);tp(e.axis,t,{isUserInteraction:!0})}))}finally{Yf()}}function pp(e){if(e.defaultPrevented)return;let{clientX:t,clientY:n,movementX:r,movementY:i}=e;fp(e.currentTarget,{clientX:t,clientY:n,movementX:r,movementY:i})}function mp(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=Mf(n,a.rect);switch(e){case`horizontal`:(t.x<i.x||t.x===i.x&&t.y<=i.y)&&(r=a,i=t);break;case`vertical`:(t.y<i.y||t.y===i.y&&t.x<=i.x)&&(r=a,i=t)}}return r?{distance:i,hitRegion:r}:void 0}function hp(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function gp(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:Sp(e),b:Sp(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();Xd(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:xp(bp(n.a)),b:xp(bp(n.b))};if(i.a===i.b){let e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let n=e[i];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(i.a-i.b)}var _p=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function vp(e){let t=getComputedStyle(Cp(e)??e).display;return t===`flex`||t===`inline-flex`}function yp(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||vp(e))||+t.opacity<1||`transform`in t&&t.transform!==`none`||`webkitTransform`in t&&t.webkitTransform!==`none`||`mixBlendMode`in t&&t.mixBlendMode!==`normal`||`filter`in t&&t.filter!==`none`||`webkitFilter`in t&&t.webkitFilter!==`none`||`isolation`in t&&t.isolation===`isolate`||_p.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function bp(e){let t=e.length;for(;t--;){let n=e[t];if(Xd(n,`Missing node`),yp(n))return n}return null}function xp(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Sp(e){let t=[];for(;e;)t.push(e),e=Cp(e);return t}function Cp(e){let{parentNode:t}=e;return hp(t)?t.host:t}function wp(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Tp(e){try{return e.matches(`:modal`)}catch{return!1}}function Ep({axisElement:e,hitRegion:t,pointerEventTarget:n}){if(jf(n)){let t=n.closest(`dialog`);if(t&&!t.contains(e)&&Tp(t))return!1}if(!jf(n)||n.contains(e)||e.contains(n)||!n.isConnected||!e.isConnected)return!0;if(gp(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(wp(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function Dp(e,t,n){let r=[];return t.forEach((t,i)=>{if(i.disabled||i.element.ownerDocument!==n)return;let a=Pf({axis:i}),o=mp(i.orientation,a,{x:e.clientX,y:e.clientY});o&&o.distance.x<=0&&o.distance.y<=0&&Ep({axisElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&r.push(o.hitRegion)}),r}function Op(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=Bf(i.defaultSize);n+=e,r[i.itemId]=e}else r[i.itemId]=void 0;let i=e.length-t;if(i!==0){let t=Bf((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.itemId]=t)}return r}function kp(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}function Ap({axis:e,itemConstraints:t}){let n=e.items.map(({id:e})=>e).join(`,`),r=e.mutableState.defaultLayout;return e.mutableState.layouts[n]??(r&&kp(e.items,r)?r:Op(t))}function jp(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function Mp(e,t){return e.length===t.length&&e.every((e,n)=>jp(e,t[n]))}function Np({layout:e,itemConstraints:t}){let n=t.map(({itemId:t})=>e[t]),r=[...n],i=r.reduce((e,t)=>e+t,0);if(Object.keys(e).length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${Object.values(e).map(e=>`${e}%`).join(`, `)}`);if(!ap(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];Xd(t!=null,`No layout data found for index ${e}`);let n=100/i*t;r[e]=n}let a=0;for(let e=0;e<t.length;e++){let i=n[e];Xd(i!=null,`No layout data found for index ${e}`);let o=r[e];Xd(o!=null,`No layout data found for index ${e}`);let s=sp({overrideDisabledItems:!0,itemConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!ap(a,0))for(let e=0;e<t.length;e++){let n=r[e];Xd(n!=null,`No layout data found for index ${e}`);let i=n+a,o=sp({overrideDisabledItems:!0,itemConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,ap(a,0)))break}return r.reduce((e,n,r)=>(e[t[r].itemId]=n,e),{})}function Pp({itemIds:e,layout:t}){return Np({layout:t,itemConstraints:e.map(e=>({collapsedSize:0,collapsible:!1,defaultSize:void 0,disabled:void 0,itemId:e,maxSize:100,minSize:0}))})}function Fp({axis:e,nextAxisSize:t,prevAxisSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,a=0,o=!1,s=new Map,c=[];for(let l of e.items){let e=r[l.id]??0;switch(l.constraintProps.groupResizeBehavior){case`preserve-pixel-size`:{o=!0;let r=Bf(e/100*n/t*100);s.set(l.id,r),i+=r;break}default:c.push(l.id),a+=e}}if(!o||c.length===0)return r;let l=100-i,u={...r};if(s.forEach((e,t)=>{u[t]=e}),a>0)for(let e of c)u[e]=Bf((r[e]??0)/a*l);else{let e=Bf(l/c.length);for(let t of c)u[t]=e}return u}function Ip({axis:e,axisState:t}){let n=Ef({axis:e});if(n===0)return;let r=Vf(e,n),i=t.requestedAxisSize,a=t.requestedLayout;t.defaultLayoutDeferred&&(i=n,a=Pp({itemIds:e.items.map(({id:e})=>e),layout:Ap({axis:e,itemConstraints:r})}));let o=Np({layout:Fp({axis:e,nextAxisSize:n,prevAxisSize:i,prevLayout:a}),itemConstraints:r});return{changed:t.defaultLayoutDeferred||!lp(t.layout,o)||!Mp(t.derivedItemConstraints,r)||t.axisSize!==n,state:{defaultLayoutDeferred:!1,derivedItemConstraints:r,axisSize:n,layout:o,requestedAxisSize:i,requestedLayout:a,separatorToItems:t.separatorToItems}}}function Lp({axisId:e,itemId:t}){let n=()=>{let t=$f();for(let[n,r]of t)if(n.id===e)return{axis:n,...r};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedItemConstraints.find(e=>e.itemId===t);if(e!==void 0)return e;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{let{axis:e,...r}=n(),i=Ip({axis:e,axisState:r}),a=i?.state??r,o=a.derivedItemConstraints.find(e=>e.itemId===t);if(o===void 0)throw Error(`Panel constraints not found for Panel ${t}`);let s=a.layout[t];if(s===void 0)throw Error(`Layout not found for Panel ${t}`);return{axis:e,changed:i?.changed===!0,itemConstraints:o,itemSize:s,state:a}},a=()=>{let e=n().axis.items.find(e=>e.id===t);if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},o=()=>{let e=n().layout[t];if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},s=({nextSize:e,items:n,prevLayout:r,derivedItemConstraints:i})=>{let a=r[t],o=n.findIndex(e=>e.id===t),s=o===0,c=o===n.length-1;if(c&&e<a&&(s||n.slice(0,o).every((e,t)=>{let n=i[t];return n?.collapsible&&ap(n.collapsedSize,r[n.itemId])}))){let e=n.slice(0,o).reduce((e,t)=>e+r[t.id],0);return{...r,[t]:Bf(100-e)}}return cp({delta:c?a-e:e-a,initialLayout:r,itemConstraints:i,pivotIndices:c?[o-1,o]:[o,o+1],prevLayout:r,trigger:`imperative-api`})},c=(e,{axis:t,changed:n,itemSize:r,state:i})=>{if(e===r)return;let{derivedItemConstraints:a,axisSize:o,layout:c}=i,l=Np({layout:s({nextSize:e,items:t.items,prevLayout:c,derivedItemConstraints:a}),itemConstraints:a});(n||!lp(c,l))&&tp(t,{...i,layout:l,requestedAxisSize:o,requestedLayout:l})};return{collapse:()=>{let e=i(),{collapsible:t,collapsedSize:n}=e.itemConstraints,{mutableValues:r}=a(),o=e.itemSize;t&&o!==n&&(r.expandToSize=o,c(n,e))},expand:()=>{let e=i(),{collapsible:t,collapsedSize:n,minSize:r}=e.itemConstraints,{mutableValues:o}=a(),s=e.itemSize;if(t&&s===n){let t=o.expandToSize??r;t===0&&(t=1),c(t,e)}},getSize:()=>{let{axis:e}=n(),r=o(),{element:i}=a();return{asPercentage:r,inPixels:e.layoutStrategy?e.layoutStrategy.getItemSizeInPixels(t):e.orientation===`horizontal`?i.offsetWidth:i.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=o();return e&&ap(t,n)},resize:e=>{let t=i(),{axisSize:n}=t.state,{element:r}=a(),o=Bf(zf({axisSize:n,itemElement:r,styleProp:e})/n*100);c(o,t)}}}function Rp(e){e.defaultPrevented||Dp(e,$f(),e.currentTarget).forEach(t=>{if(t.separator&&!t.separator.disableDoubleClick){let n=t.items.find(e=>e.constraintProps.defaultSize!==void 0);if(n){let r=n.constraintProps.defaultSize,i=Lp({axisId:t.axis.id,itemId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function zp(e){let t=$f();for(let[n]of t)if(n.separators.some(t=>t.element===e))return n;throw Error(`Could not find parent Group for separator element`)}function Bp({axisId:e}){let t=()=>{let t=$f();for(let[n,r]of t)if(n.id===e)return{axis:n,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{axis:n,...r}=t(),i=Ip({axis:n,axisState:r}),a=i?.state??r,{defaultLayoutDeferred:o,derivedItemConstraints:s,axisSize:c,layout:l}=a,u=Np({layout:e,itemConstraints:s});return o?l:((i?.changed||!lp(l,u))&&tp(n,{...a,layout:u,requestedAxisSize:c,requestedLayout:u}),u)}}}function Vp(e,t){let n=zp(e),r=Qf(n.id,!0),i=n.separators.find(t=>t.element===e);Xd(i,`Matching separator not found`);let a=r.separatorToItems.get(i);Xd(a,`Matching panels not found`);let o=a.map(e=>n.items.indexOf(e)),s=Bp({axisId:n.id}).getLayout(),c=Np({layout:cp({delta:t,initialLayout:s,itemConstraints:r.derivedItemConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),itemConstraints:r.derivedItemConstraints});lp(s,c)||tp(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedItemConstraints:r.derivedItemConstraints,axisSize:r.axisSize,layout:c,requestedAxisSize:r.axisSize,requestedLayout:c,separatorToItems:r.separatorToItems},{isUserInteraction:!0})}function Hp(e){return e.separators.filter(e=>!e.disabled)}function Up(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=zp(t);if(!(n.disabled||n.separators.find(e=>e.element===t)?.disabled))switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&Vp(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&Vp(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&Vp(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&Vp(t,-5);break;case`End`:e.preventDefault(),Vp(t,100);break;case`Enter`:{e.preventDefault();let{derivedItemConstraints:r,layout:i,separatorToItems:a}=Qf(n.id,!0),o=n.separators.find(e=>e.element===t);Xd(o,`Matching separator not found`);let s=a.get(o);Xd(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.itemId===c.id);if(Xd(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];Vp(t,(l.collapsedSize===e?n.mutableState.expandedItemSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let t=Hp(n).map(e=>e.element),r=t.findIndex(t=>t===e.currentTarget);Xd(r!==-1,`Index not found`),t[e.shiftKey?r>0?r-1:t.length-1:r+1<t.length?r+1:0].focus({preventScroll:!0});break}case`Home`:e.preventDefault(),Vp(t,-100)}}function Wp(e,t){let n=af();if(n.state!==`active`||!rp(n,e,t))return!1;let r=$f();qf();try{n.previewLayoutMap.forEach((e,t)=>{let n=r.get(t);t.resizePreviewMode===`separator`&&n&&!lp(e,n.layout)&&tp(t,{...n,layout:e,requestedAxisSize:n.axisSize,requestedLayout:e})}),Jf(),cf({cursorFlags:0,state:`inactive`}),n.hitRegions.forEach(e=>{if(!r.has(e.axis))return;let t=Qf(e.axis.id,!0);tp(e.axis,t,{isUserInteraction:!0})})}finally{Yf()}return!0}function Gp(e){let t=af();if(t.state!==`active`)return;let n=t.hitRegions.flatMap(({separator:e})=>e?[e.element]:[]);!n.some(t=>t===e.target)||n.some(t=>t.hasPointerCapture?.(e.pointerId))||Wp(e.currentTarget,e)}function Kp(e){Wp(e.currentTarget,e)}function qp(e,t){let{element:n,orientation:r,items:i}=e,a=n.getBoundingClientRect(),o=r===`horizontal`;return Pf({expandHitTargets:!1,axis:e,includeDisabled:!0}).map(({items:r,rect:s,separator:c},l)=>{let u=i.indexOf(r[0]),d=o?s.left+s.width/2:s.top+s.height/2;return{active:t.some(t=>{if(t.axis!==e||t.items[0]!==r[0])return!1;if(c||t.separator)return t.separator===c;let n=o?t.rect.left+t.rect.width/2:t.rect.top+t.rect.height/2;return ap(d,n)}),axis:e,key:c?`separator-${c.id}`:`panel-${r[0].id}-${l}`,offset:0,itemIndex:u,rect:new DOMRect((o&&!c?d:s.left)-a.left-n.clientLeft+n.scrollLeft,(!o&&!c?d:s.top)-a.top-n.clientTop+n.scrollTop,o&&!c?0:s.width,!o&&!c?0:s.height),separator:c}})}function Jp(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=af();if(t.state===`active`){np(t,e)&&Wp(t.ownerDocument,t);return}let n=$f(),r=Dp(e,n,e.currentTarget);if(r.length===0)return;let i=new Map,a=!1;r.forEach(e=>{e.separator&&(a||(a=!0,e.separator.element.focus({focusVisible:!1,preventScroll:!0})));let t=n.get(e.axis);t&&i.set(e.axis,t.layout)});let o=Array.from(i.keys()).flatMap(e=>e.resizePreviewMode===`separator`?qp(e,r):[]);cf({cursorFlags:0,didPointerMove:!1,hitRegions:r,initialLayoutMap:i,ownerDocument:e.currentTarget,pointerDownAtPoint:{x:e.clientX,y:e.clientY},pointerId:e.pointerId,pointerType:e.pointerType,previewLayoutMap:new Map(i),previews:o,state:`active`}),e.preventDefault()}function Yp(e){let t=e.currentTarget,n=$f(),r=af();if(r.state===`active`){if(!rp(r,t,e))return;up({commit:!1,event:e,hitRegions:r.hitRegions,initialLayoutMap:r.initialLayoutMap,mountedAxes:n,prevCursorFlags:r.cursorFlags})}}function Xp(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=af(),r=$f();switch(n.state){case`active`:if(!rp(n,t,e))return;if(e.buttons===0){Wp(t,e);return}for(let t of n.hitRegions)if(t.separator){let{element:n}=t.separator;n.isConnected&&!n.hasPointerCapture?.(e.pointerId)&&n.setPointerCapture?.(e.pointerId)}up({commit:!1,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedAxes:r,pointerDownAtPoint:n.pointerDownAtPoint,prevCursorFlags:n.cursorFlags});break;default:{let i=Dp(e,r,t);i.length===0?n.state!==`inactive`&&cf({cursorFlags:0,state:`inactive`}):cf({cursorFlags:0,hitRegions:i,ownerDocument:t,state:`hover`});break}}}function Zp(e){if(e.relatedTarget instanceof HTMLIFrameElement){let t=af();t.state===`hover`&&t.ownerDocument===e.currentTarget&&cf({cursorFlags:0,state:`inactive`})}}function Qp(e){e.defaultPrevented||e.pointerType===`mouse`&&e.button>0||fp(e.currentTarget,e)}function $p(e){e.target===e.currentTarget&&Wp(e.currentTarget.document)}function em(e){Wp(e.currentTarget.document)}function tm(e,t,n){if(!n[0])return;let r=e.items.find(e=>e.element===t);if(!r||!r.onResize)return;let i=Ef({axis:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:Bf(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}var nm=new Map,rm=!1;function im(e){let t=!0;Xd(e.element.ownerDocument.defaultView,`Cannot register an unmounted Group`);let n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,a=new n(n=>{let r;qf();try{for(let i of n){let{borderBoxSize:n,target:a}=i;if(a===e.element){if(t){let t=Qf(e.id);if(!t)break;let n=Ip({axis:e,axisState:t});if(!n)break;if(!n.changed)continue;tp(e,n.state)}}else try{tm(e,a,n)}catch(e){r??={error:e}}}}finally{Yf()}if(r)throw r.error});a.observe(e.element),e.items.forEach(e=>{Xd(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&a.observe(e.element)});let o=Ef({axis:e}),s=Vf(e,o),c=Ap({axis:e,itemConstraints:s}),l=Np({layout:c,itemConstraints:s}),u=e.element.ownerDocument,d=u.defaultView;nm.set(u,(nm.get(u)??0)+1);let f=new Map;return Pf({axis:e,includeDisabled:!0}).forEach(e=>{e.separator&&f.set(e.separator,e.items)}),tp(e,{defaultLayoutDeferred:o===0,derivedItemConstraints:s,axisSize:o,layout:l,requestedAxisSize:o,requestedLayout:Pp({itemIds:e.items.map(({id:e})=>e),layout:c}),separatorToItems:f}),e.separators.forEach(e=>{Xd(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener(`keydown`,Up)}),rm||(rm=!0,of(Tf)),nm.get(u)===1&&(u.addEventListener(`contextmenu`,pp,!0),u.addEventListener(`dblclick`,Rp,!0),u.addEventListener(`lostpointercapture`,Gp,!0),u.addEventListener(`pointercancel`,Kp,!0),u.addEventListener(`pointerdown`,Jp,!0),u.addEventListener(`pointerleave`,Yp),u.addEventListener(`pointermove`,Xp),u.addEventListener(`pointerout`,Zp),u.addEventListener(`pointerup`,Qp,!0),d?.addEventListener(`blur`,$p),d?.addEventListener(`pagehide`,em)),function(){t=!1,nm.set(u,Math.max(0,(nm.get(u)??0)-1)),Xf(e),uf(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,Up)}),nm.get(u)||(u.removeEventListener(`contextmenu`,pp,!0),u.removeEventListener(`dblclick`,Rp,!0),u.removeEventListener(`lostpointercapture`,Gp,!0),u.removeEventListener(`pointercancel`,Kp,!0),u.removeEventListener(`pointerdown`,Jp,!0),u.removeEventListener(`pointerleave`,Yp),u.removeEventListener(`pointermove`,Xp),u.removeEventListener(`pointerout`,Zp),u.removeEventListener(`pointerup`,Qp,!0),d?.removeEventListener(`blur`,$p),d?.removeEventListener(`pagehide`,em)),a.disconnect()}}function am({derivedItemConstraints:e,axis:t,layout:n,prevLayout:r,requestedLayout:i}){let a=t.items.map(({id:e})=>e).join(`,`);t.mutableState.layouts[a]=i,r&&e.forEach(e=>{if(e.collapsible){let i=ap(e.collapsedSize,n[e.itemId]),a=ap(e.collapsedSize,r[e.itemId]);i&&!a&&(t.mutableState.expandedItemSizes[e.itemId]=r[e.itemId])}})}function om(){let[e,t]=(0,J.useState)({});return[e,(0,J.useCallback)(()=>t({}),[])]}function sm(e){let t=(0,J.useRef)({...e});return Kd(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var cm=(0,J.createContext)(null);function lm({layout:e,itemConstraints:t,itemId:n,itemIndex:r}){let i,a,o=e[n],s=t.find(e=>e.itemId===n);if(s){let c=s.maxSize,l=s.collapsible?s.collapsedSize:s.minSize,u=[r,r+1];a=Np({layout:cp({delta:l-o,initialLayout:e,itemConstraints:t,pivotIndices:u,prevLayout:e}),itemConstraints:t})[n],i=Np({layout:cp({delta:c-o,initialLayout:e,itemConstraints:t,pivotIndices:u,prevLayout:e}),itemConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function um({attributes:e,axisId:t,axisOrientation:n,children:r,className:i,"data-testid":a,disableCursor:o,disabled:s,disableDoubleClick:c,elementRef:l,id:u,isSharedHitRegion:d,preview:f,registerSeparator:p,requiredStyle:m,style:h,styleDefaults:g,tabIndex:_=0,updateSeparatorProps:v}){let y=sm({disabled:s,disableDoubleClick:c,children:r,className:i,preview:f,style:h}),[b,x]=(0,J.useState)({}),[S,C]=(0,J.useState)(`inactive`),[w,T]=(0,J.useState)(!1),E=(0,J.useRef)(null),D=(0,J.useRef)(null),O=Jd(E,l),k=n===`horizontal`?`vertical`:`horizontal`;Kd(()=>{let e=E.current;if(e!==null){let n={disabled:y.disabled,disableDoubleClick:y.disableDoubleClick,element:e,id:u,get children(){return y.children},get className(){return y.className},get preview(){return y.preview},get style(){return y.style}};D.current=n;let r=p(n),i=of(e=>{C(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===n||(d?.(e)??!1))?e.next.state:`inactive`)}),a=ep(t,e=>{let{derivedItemConstraints:t,layout:r,separatorToItems:i}=e.next,a=i.get(n);if(a){let n=a[0],i=t.findIndex(e=>e.itemId===n.id),{layoutStrategy:o}=e.axis;x({...lm({layout:r,itemConstraints:t,itemId:n.id,itemIndex:i}),...o?.getItemAriaControls&&{valueControls:o.getItemAriaControls(n.id)}})}});return()=>{D.current=null,i(),a(),r()}}},[t,u,d,p,y]),Kd(()=>{let e=D.current;e&&lf(e)},[f]),(0,J.useEffect)(()=>{v(u,{disabled:s,disableDoubleClick:c})},[s,c,u,v]);let A;s&&!o&&(A=`not-allowed`);let j;if(s)j=`disabled`;else switch(S){case`active`:j=`active`;break;default:j=w?`focus`:S}return(0,X.jsx)(`div`,{...e,"aria-controls":b.valueControls,"aria-disabled":s||void 0,"aria-orientation":k,"aria-valuemax":b.valueMax,"aria-valuemin":b.valueMin,"aria-valuenow":b.valueNow,children:r,className:i,"data-separator":j,"data-testid":a,id:u,onBlur:()=>T(!1),onFocus:()=>T(!0),ref:O,role:`separator`,style:{...g,cursor:A,...h,...m,touchAction:`none`},tabIndex:s?void 0:_})}function dm(e){for(let t=1;t<e.length;t++)if(Df(e[t-1],e[t])>0)return!1;return!0}function fm({separator:e}){let{element:t}=e,n=(0,J.useRef)(null);return Kd(()=>{let e=t.cloneNode(!0),r=[t,...t.querySelectorAll(`*`)],i=[e,...e.querySelectorAll(`*`)],a=t.ownerDocument.defaultView;return r.forEach((e,t)=>{let n=i[t];if(n instanceof a.HTMLElement||n instanceof a.SVGElement){let t=a.getComputedStyle(e);for(let e=0;e<t.length;e++){let r=t.item(e);n.style.setProperty(r,t.getPropertyValue(r))}}n.removeAttribute(`data-testid`),n.removeAttribute(`id`)}),Object.assign(e.style,{boxSizing:`border-box`,height:`100%`,margin:`0`,position:`static`,transform:`none`,width:`100%`}),n.current.appendChild(e),()=>e.remove()},[t]),(0,X.jsx)(`div`,{ref:n,style:{height:`100%`,opacity:.65,pointerEvents:`none`,width:`100%`}})}function pm(){let e=(0,J.useContext)(cm);return Xd(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function mm(e){let{registerOverlay:t}=pm(),n=(0,J.useRef)(e);jp(n.current,e)||(n.current=e);let r=n.current;return Kd(()=>t(r),[t,r]),null}mm.displayName=`SeparatorOverlay`;function hm({active:e,orientation:t,style:n,...r}){let i;switch(t){case`horizontal`:i={height:`100%`,minWidth:`1px`};break;case`vertical`:i={minHeight:`1px`,width:`100%`}}return(0,X.jsx)(`div`,{...r,"data-separator-overlay":e?`active`:`inactive`,style:{...i,...n,flexShrink:0,pointerEvents:`none`}})}function gm({overlay:e,preview:t}){let{axis:n,offset:r,rect:i,separator:a}=t,o=n.orientation===`horizontal`,s=a?.preview,c=e;return(0,J.isValidElement)(s)&&s.type===mm&&(c=s.props,s=void 0),s??(c?s=(0,X.jsx)(hm,{...c,active:t.active,orientation:n.orientation}):a&&(s=(0,X.jsx)(fm,{separator:a}))),(0,X.jsx)(`div`,{"aria-hidden":`true`,"data-resize-preview":!0,inert:!0,style:{height:i.height,left:i.left,pointerEvents:`none`,position:`absolute`,top:i.top,transform:o?`translateX(${r}px)`:`translateY(${r}px)`,width:i.width},children:s})}function _m(e){return Array.from(e).sort(Df)}function vm(e,t){let n=(0,J.useRef)({getLayout:()=>({}),setLayout:df});(0,J.useImperativeHandle)(t,()=>n.current,[]),Kd(()=>{Object.assign(n.current,Bp({axisId:e}))})}function ym({groupId:e,resizePreviewMode:t}){let[n,r]=(0,J.useState)([]),i=(0,J.useRef)(n);return Kd(()=>{let n=n=>{let a=Zf(e),o=t===`separator`&&n.state===`active`?n.previews.filter(e=>e.axis===a&&(e.active||!ap(e.offset,0))):[],s=i.current;s.length===o.length&&o.every((e,t)=>e===s[t])||(i.current=o,r(o))};if(t!==`separator`){n(af());return}let a=of(({next:e})=>n(e));return n(af()),a},[e,t]),n}function bm({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:o,id:s,onLayoutChange:c,onLayoutChanged:l,orientation:u=`horizontal`,resizePreviewMode:d=`panel`,resizeTargetMinimumSize:f={coarse:20,fine:10},style:p,...m}){let h=(0,J.useRef)({onLayoutChange:{},onLayoutChanged:{}}),g=qd(e=>{lp(h.current.onLayoutChange,e)||(h.current.onLayoutChange=e,c?.(e))}),_=qd((e,t,n)=>{lp(h.current.onLayoutChanged,e)||(h.current.onLayoutChanged=e,l?.(e,{isUserInteraction:t,requestedLayout:n}))}),v=Gd(s),[y,b]=(0,J.useState)(),x=ym({groupId:v,resizePreviewMode:d}),S=(0,J.useRef)(null),[C,w]=om(),T=(0,J.useRef)([]),E=(0,J.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],separators:[]}),D=Jd(S,a);vm(v,o);let O=qd((e,t)=>{let r=Qf(e);if(r)return{flexGrow:r.layout[t]??1};if(n?.[t])return{flexGrow:n?.[t]}}),k=sm({defaultLayout:n,disableCursor:r,resizeTargetMinimumSize:f}),A=(0,J.useMemo)(()=>({get disableCursor(){return!!k.disableCursor},getPanelStyles:O,id:v,orientation:u,registerPanel:e=>{let t=E.current;return t.panels=Of(u,[...t.panels,e]),w(),()=>{t.panels=t.panels.filter(t=>t!==e),w()}},registerOverlay:e=>(b(e),()=>{b(void 0)}),registerSeparator:e=>{let t=E.current;return t.separators=Of(u,[...t.separators,e]),w(),()=>{t.separators=t.separators.filter(t=>t!==e),w()}},updatePanelProps:(e,{disabled:t})=>{let n=E.current.panels.find(t=>t.id===e);if(!n||n.constraintProps.disabled===t)return;n.constraintProps.disabled=t;let r=Zf(v),i=Qf(v);r&&i&&tp(r,{...i,derivedItemConstraints:Vf(r)})},updateSeparatorProps:(e,{disabled:t,disableDoubleClick:n})=>{let r=E.current.separators.find(t=>t.id===e);r&&(r.disabled=t,r.disableDoubleClick=n)}}),[O,v,w,u,k]),j=(0,J.useRef)(null);return Kd(()=>{let e=S.current;if(e===null)return;let t=E.current;t.panels=Of(u,t.panels),t.separators=Of(u,t.separators),T.current=_m([...t.panels.map(({element:e})=>e),...t.separators.map(({element:e})=>e)]);let n;if(k.defaultLayout!==void 0&&Object.keys(k.defaultLayout).length===t.panels.length){n={};for(let e of t.panels){let t=k.defaultLayout[e.id];t!==void 0&&(n[e.id]=t)}}let r={disabled:!!i,element:e,id:v,mutableState:{defaultLayout:n,disableCursor:!!k.disableCursor,expandedItemSizes:E.current.lastExpandedPanelSizes,layouts:E.current.layouts},orientation:u,items:t.panels,resizePreviewMode:d,get resizeTargetMinimumSize(){return k.resizeTargetMinimumSize},separators:t.separators};j.current=r;let a=im(r),{defaultLayoutDeferred:o,derivedItemConstraints:s,layout:c,requestedLayout:l}=Qf(r.id,!0);if(!o&&s.length>0)try{try{g(c)}finally{_(c,!1,l)}}catch(e){throw j.current=null,a(),e}let f=ep(v,e=>{let{defaultLayoutDeferred:t,derivedItemConstraints:n,layout:i,requestedLayout:a}=e.next;if(t||n.length===0)return;am({derivedItemConstraints:n,axis:r,layout:i,prevLayout:e.prev?.layout,requestedLayout:a});let o=af(),s=o.state!==`active`||!o.hitRegions.some(e=>e.axis===r);try{g(i)}finally{s&&_(i,e.isUserInteraction,a)}});return()=>{j.current=null,a(),f()}},[i,v,_,g,u,C,d,k]),Kd(()=>{dm(T.current)||w()}),(0,J.useEffect)(()=>{let e=j.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,X.jsx)(cm.Provider,{value:A,children:(0,X.jsxs)(`div`,{...m,className:t,"data-group":!0,"data-testid":Yd(m,s),id:v,ref:D,style:{height:`100%`,width:`100%`,overflow:`hidden`,position:d===`separator`?`relative`:void 0,...p,display:`flex`,flexDirection:u===`horizontal`?`row`:`column`,flexWrap:`nowrap`,touchAction:u===`horizontal`?`pan-y`:`pan-x`},children:[e,x.map(e=>(0,X.jsx)(gm,{overlay:y,preview:e},e.key))]})})}bm.displayName=`Group`;function xm(e,t){return`react-resizable-panels:${[e,...t].join(`:`)}`}function Sm({id:e,panelIds:t,storage:n}){let r=xm(e,[]),i=n.getItem(r);if(i)try{let e=JSON.parse(i);if(t){let n=e[t.join(`,`)];if(n&&Array.isArray(n.layout)&&t.length===n.layout.length){let e={};for(let r=0;r<t.length;r++)e[t[r]]=n.layout[r];return e}}else{let t=Object.keys(e);if(t.length===1){let n=e[t[0]];if(n&&Array.isArray(n.layout)){let e=t[0].split(`,`);if(e.length===n.layout.length){let t={};for(let r=0;r<e.length;r++)t[e[r]]=n.layout[r];return t}}}}}catch{}}function Cm({debounceSaveMs:e=100,onlySaveAfterUserInteractions:t,panelIds:n,storage:r=localStorage,...i}){let a=n!==void 0,o=`id`in i?i.id:i.groupId,s=xm(o,n??[]),c=(0,J.useSyncExternalStore)(wm,()=>r.getItem(s),()=>r.getItem(s)),l=(0,J.useMemo)(()=>{if(c){let e=JSON.parse(c),t=Object.values(e);if(Array.from(t).every(e=>typeof e==`number`))return e}},[c]),u=(0,J.useMemo)(()=>{if(!l)return Sm({id:o,panelIds:n,storage:r})},[l,o,n,r]),d=l??u,f=(0,J.useRef)(null),p=(0,J.useCallback)(()=>{let e=f.current;e&&(f.current=null,clearTimeout(e))},[]);(0,J.useLayoutEffect)(()=>()=>{p()},[p]);let m=(0,J.useCallback)((e,n)=>{if(t&&!n.isUserInteraction)return;p();let i=n.requestedLayout??e,s;s=a?xm(o,Object.keys(i)):xm(o,[]);try{r.setItem(s,JSON.stringify(i))}catch(e){console.error(e)}},[p,a,o,t,r]);return{defaultLayout:d,onLayoutChange:(0,J.useCallback)(t=>{p(),e===0?m(t,{isUserInteraction:!1}):f.current=setTimeout(()=>{m(t,{isUserInteraction:!1})},e)},[p,e,m]),onLayoutChanged:m}}function wm(){return function(){}}function Tm(e,t){let{id:n}=pm(),r=(0,J.useRef)({collapse:ff,expand:ff,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:ff});(0,J.useImperativeHandle)(t,()=>r.current,[]),Kd(()=>{Object.assign(r.current,Lp({axisId:n,itemId:e}))})}function Em({children:e,className:t,collapsedSize:n=`0%`,collapsedThreshold:r,collapsible:i=!1,defaultSize:a,disabled:o,elementRef:s,groupResizeBehavior:c=`preserve-relative-size`,id:l,maxSize:u=`100%`,minSize:d=`0%`,onResize:f,panelRef:p,style:m,...h}){let g=Wd(l),_=Gd(l),v=sm({disabled:o}),y=(0,J.useRef)(null),b=Jd(y,s),{getPanelStyles:x,id:S,orientation:C,registerPanel:w,updatePanelProps:T}=pm(),E=f!==null,D=qd((e,t,n)=>{f?.(e,l,n)});Kd(()=>{let e=y.current;if(e!==null){let t={element:e,id:_,idIsStable:g,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:E?D:void 0,constraintProps:{groupResizeBehavior:c,collapsedSize:n,collapsedThreshold:r,collapsible:i,defaultSize:a,disabled:v.disabled,maxSize:u,minSize:d}};return w(t)}},[c,n,r,i,a,E,_,g,u,d,D,w,v]),(0,J.useEffect)(()=>{T(_,{disabled:o})},[o,_,T]),Tm(_,p);let O=()=>{let e=x(S,_);if(e)return JSON.stringify(e)},k=(0,J.useSyncExternalStore)(e=>ep(S,e),O,O),A;return A=k?JSON.parse(k):a===void 0?{flexGrow:1}:{flexGrow:void 0,flexShrink:void 0,flexBasis:a},(0,X.jsx)(`div`,{...h,"data-disabled":o||void 0,"data-panel":!0,"data-testid":Yd(h,l),id:_,ref:b,style:{...Dm,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...A},children:(0,X.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...m,touchAction:C===`horizontal`?`pan-y`:`pan-x`},children:e})})}Em.displayName=`Panel`;var Dm={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function Om(){return(0,J.useRef)(null)}var km={flexBasis:`auto`},Am={flexGrow:0,flexShrink:0};function jm({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,preview:o,style:s,...c}){let l=Gd(a),{disableCursor:u,id:d,orientation:f,registerSeparator:p,updateSeparatorProps:m}=pm();return(0,X.jsx)(um,{attributes:c,axisId:d,axisOrientation:f,className:t,"data-testid":Yd(c,a),disableCursor:u,disabled:n,disableDoubleClick:r,elementRef:i,id:l,preview:o,registerSeparator:p,requiredStyle:Am,style:s,styleDefaults:km,updateSeparatorProps:m,children:e})}jm.displayName=`Separator`;function Mm(){let e={status:`loading`,error:``},t=new Set,n=(n,r=``)=>{if(e.status!==n||e.error!==r){e={status:n,error:r};for(let e of t)e()}};return{getSnapshot:()=>e,subscribe:e=>(t.add(e),()=>t.delete(e)),loading:()=>n(`loading`),working:()=>n(`working`),failed:e=>n(`error`,e instanceof Error?e.message:String(e))}}var Nm=Mm(),Pm=/\.(?:tex|bib|cls|sty)$/i,Fm=3e4,Im=null,Lm=!1,Rm=null,zm=1,Bm=new Map,Vm=[],Hm=null,Um=null,Wm=class extends Error{kind;constructor(e,t){super(t),this.kind=e,this.name=`TexFmtError`}};function Gm(e){return e instanceof Wm}function Km(e){Im?.terminate(),Im=null,Lm=!1,Rm!==null&&window.clearTimeout(Rm),Rm=null,Hm=null,Vm.length=0,Um=null,Nm.failed(e);for(let t of Bm.values())t.timeout!==null&&window.clearTimeout(t.timeout),t.reject(e);Bm.clear()}function qm(){if(Hm!==null||Vm.length===0)return;let e;try{e=Jm()}catch(e){Km(e instanceof Wm?e:new Wm(`load`,`The bundled tex-fmt formatter could not be loaded.`));return}if(!Lm)return;let t=Vm.shift();if(t===void 0)return;let n=Bm.get(t);if(!n)qm();else{Hm=t,n.timeout=window.setTimeout(()=>{Hm===t&&Km(new Wm(`result`,`The formatter did not respond within 30 seconds.`))},Fm);try{e.postMessage({...n.request,id:t})}catch{Km(new Wm(`load`,`The formatter worker could not receive the source.`))}}}function Jm(){if(Im)return Im;if(typeof Worker>`u`){let e=new Wm(`load`,`This browser does not support formatter workers.`);throw Nm.failed(e),e}Nm.loading();try{Im=new Worker(new URL(new URL(`latexFormatterWorker-BIDCSZPd.js`,import.meta.url).href,``+import.meta.url),{type:`module`,name:`texlite-latex-formatter`}),Rm=window.setTimeout(()=>{Lm||Km(new Wm(`load`,`The formatter did not finish loading within 30 seconds.`))},Fm)}catch{let e=new Wm(`load`,`The bundled tex-fmt formatter could not be loaded.`);throw Nm.failed(e),e}return Im.onmessage=e=>{let t=e.data;if(t&&`type`in t){t.type===`ready`&&(Lm=!0,Rm!==null&&window.clearTimeout(Rm),Rm=null,qm());return}if(!t||typeof t.id!=`number`){Km(new Wm(`result`,`The formatter worker returned an invalid response.`));return}let n=Bm.get(t.id);if(n){if(Bm.delete(t.id),n.timeout!==null&&window.clearTimeout(n.timeout),Hm===t.id&&(Hm=null),t.ok)Nm.working(),n.resolve(t.result),qm();else{let e=new Wm(t.kind,t.message);t.kind===`format`?(Nm.working(),n.reject(e),qm()):(n.reject(e),Km(e))}}},Im.onerror=()=>{Km(new Wm(`load`,`The bundled tex-fmt formatter could not be loaded.`))},Im.onmessageerror=()=>{Km(new Wm(`result`,`The formatter worker returned an unreadable response.`))},Im}function Ym(e){let t=zm++;return new Promise((n,r)=>{Bm.set(t,{request:e,resolve:n,reject:r,timeout:null}),Vm.push(t),qm()})}function Xm(e,t=``){return Ym({action:`format`,source:e,config:t})}async function Zm(){Im&&Nm.getSnapshot().status===`working`||(Um||=Ym({action:`probe`}).then(()=>void 0).finally(()=>{Um=null}),await Um)}async function Qm(){(Im||Bm.size)&&Km(new Wm(`load`,`The formatter runtime was reloaded.`)),Nm.loading(),await Zm()}function $m(e){return Pm.test(e)}function eh(e){return e.match(/(?:\r?\n)+$/)?.[0]??``}function th(e,t){let n=eh(e),r=(n?e.slice(0,-n.length):e).split(/\r?\n/).find(e=>e.trim())?.match(/^[\t ]*/)?.[0]??``,i=t.replace(/(?:\r?\n)+$/,``);return`${r?i.split(`
|
|
13
|
-
`).map(e=>e&&`${r}${e}`).join(`
|
|
14
|
-
`):i}${n}`}async function nh(e,t,n=0){return Ym({action:`diff`,source:e,formatted:t,baseOffset:n})}var rh=null,ih=1,ah=new Map,oh=class extends Error{kind;constructor(e){super(`BibTeX formatter: ${e}`),this.kind=e,this.name=`BibtexFormatterError`}};function sh(e){rh?.terminate(),rh=null;for(let t of ah.values())clearTimeout(t.timeout),t.reject(new oh(e));ah.clear()}function ch(){if(rh)return rh;let e=new Worker(new URL(new URL(`bibtexFormatterWorker-B_jvobIv.js`,import.meta.url).href,``+import.meta.url),{type:`module`,name:`texlite-bibtex-formatter`});return rh=e,e.onmessage=({data:t})=>{if(rh!==e)return;if(!t||typeof t.id!=`number`||typeof t.ok!=`boolean`){sh(`unavailable`);return}let n=ah.get(t.id);n&&(t.ok&&(t.action!==n.action||(t.action===`format`?typeof t.result!=`string`:!lh(t.result)))?sh(`unavailable`):(clearTimeout(n.timeout),ah.delete(t.id),t.ok?n.resolve(t.result):t.kind===`too-large`||t.kind===`invalid`?n.reject(new oh(t.kind)):(n.reject(new oh(`unavailable`)),sh(`unavailable`))))},e.onerror=e.onmessageerror=()=>{rh===e&&sh(`unavailable`)},e}function lh(e){if(!Array.isArray(e))return!1;let t=0;return e.every(e=>!e||!Number.isSafeInteger(e.from)||!Number.isSafeInteger(e.to)||e.from<t||e.to<e.from||typeof e.replacement!=`string`?!1:(t=e.to,!0))}function uh(e){return new Promise((t,n)=>{let r;try{r=ch()}catch{n(new oh(`unavailable`));return}let i=ih++,a=setTimeout(()=>sh(`timeout`),3e4);ah.set(i,{action:e.action,resolve:t,reject:n,timeout:a});try{r.postMessage({...e,id:i})}catch{sh(`unavailable`)}})}function dh(e,t){return uh({action:`format`,source:e,maxBytes:t})}function fh(e,t,n=0){return uh({action:`diff`,source:e,formatted:t,baseOffset:n})}function ph(e,t=null){let n=mh(e),r=t===`succeeded`||t===null&&_h(e)?[]:hh(n.filter(vh));return{warnings:hh(mh(gh(e)).filter(e=>!vh(e)&&yh(e))),errors:r}}function mh(e){return e.split(`
|
|
15
|
-
`).map(e=>e.trim()).filter(Boolean)}function hh(e){return[...new Set(e)]}function gh(e){let t=/^Running ['"][^\n]*(?:pdf|xe|lua)latex(?:\s|['"])[^\n]*$/gim,n=-1;for(let r of e.matchAll(t))n=r.index;return n>=0?e.slice(n):e}function _h(e){return/Latexmk: All targets .* are up-to-date/i.test(e)&&/Output written on .*\.pdf/i.test(e)}function vh(e){return/^!\s/.test(e)||/(?:^|:\s)(?:LaTeX|Package|Class|pdfTeX|XeTeX|LuaTeX)?\s*Error:/i.test(e)||/^Latexmk:.*(?:\bErrors?,|did not complete making targets|failure)/i.test(e)||/^Collected error summary/i.test(e)||/\b(?:fatal error|emergency stop|undefined control sequence|no output pdf|no pages of output)\b/i.test(e)||/\b(?:bibtex|biber) errors?:/i.test(e)||/^error, and then rerun latexmk/i.test(e)}function yh(e){return/\bwarnings?\b|overfull|underfull|badness/i.test(e)}var bh=Object.freeze({}),xh=class{threads=new Map;listeners=new Map;newComments=new Map;getThread(e){return this.threads.get(e)??bh}subscribe(e,t){let n=this.listeners.get(e)??new Set;return n.add(t),this.listeners.set(e,n),()=>{n.delete(t),n.size||this.listeners.delete(e)}}publish(e,t){Object.keys(t).length?this.threads.set(e,t):this.threads.delete(e);for(let t of this.listeners.get(e)??[])t()}isPending(e){return Object.values(this.getThread(e)).some(e=>e?.pending)}open(e,t,n=``){if(this.isPending(e))return;let r={...this.getThread(e)};if(t.startsWith(`edit-reply:`))for(let[e,t]of Object.entries(r))e.startsWith(`edit-reply:`)&&t?.open&&(r[e]={...t,open:!1});r[t]={content:n,pending:!1,error:``,...r[t],open:!0},this.publish(e,r)}change(e,t,n){let r=this.getThread(e)[t];r&&!this.isPending(e)&&this.publish(e,{...this.getThread(e),[t]:{...r,content:n}})}discard(e,t){let n={...this.getThread(e)};t===void 0?this.publish(e,bh):(delete n[t],this.publish(e,n))}async submit(e,t,n,r){let i=this.getThread(e)[t];if(!i||!i.content.trim()||this.isPending(e))return!1;let a={...i,pending:!0,error:``};this.publish(e,{...this.getThread(e),[t]:a});let o=r;try{if(await n(i.content))return this.getThread(e)[t]===a&&this.discard(e,t),!0}catch(e){o=W(e)}return this.getThread(e)[t]===a&&this.publish(e,{...this.getThread(e),[t]:{...i,pending:!1,error:o}}),!1}getNew(e){return this.newComments.get(e)}setNew(e){this.newComments.set(e.filePath,{...e,selection:{...e.selection}})}discardNew(e){this.newComments.delete(e)}},Sh=J.createContext(void 0),Ch=e=>{let t=J.useContext(Sh);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},wh=({client:e,children:t})=>(J.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,X.jsx)(Sh.Provider,{value:e,children:t})),Th={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Eh=new class{#e=Th;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function Dh(e){setTimeout(e,0)}var Oh=typeof window>`u`||`Deno`in globalThis;function kh(){}function Ah(e,t){return typeof e==`function`?e(t):e}function jh(e){return typeof e==`number`&&e>=0&&e!==1/0}function Mh(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Nh(e,t){return typeof e==`function`?e(t):e}function Ph(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Ih(o,t.options))return!1}else if(!Rh(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function Fh(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(Lh(t.options.mutationKey)!==Lh(a))return!1}else if(!Rh(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Ih(e,t){return(t?.queryKeyHashFn||Lh)(e)}function Lh(e){return JSON.stringify(e,(e,t)=>Uh(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Rh(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){if(t.length>e.length)return!1;for(let n=0;n<t.length;n++)if(!Rh(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!Rh(e[r],t[r]))return!1;return!0}return!1}var zh=Object.prototype.hasOwnProperty;function Bh(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=Hh(e)&&Hh(t);if(!r&&!(Uh(e)&&Uh(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:zh.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=Bh(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function Vh(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function Hh(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Uh(e){if(!Wh(e))return!1;let t=Object.getPrototypeOf(e),n=t?.constructor;if(n===void 0)return!0;if(typeof n!=`function`)return!1;let r=n.prototype;return!(!Wh(r)||!r.hasOwnProperty(`isPrototypeOf`)||t!==Object.prototype)}function Wh(e){return Object.prototype.toString.call(e)===`[object Object]`}function Gh(e){return new Promise(t=>{Eh.setTimeout(t,e)})}function Kh(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Bh(e,t)}function qh(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function Jh(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Yh=Symbol();function Xh(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Yh?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Zh(e,t){return typeof e==`function`?e(...t):!!e}function Qh(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r||(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0})),i)}),e}var $h=()=>Oh,eg=()=>$h(),tg=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},ng=new class extends tg{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},rg=Dh;function ig(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=rg,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var ag=ig(),og=new class extends tg{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function sg(e){return Math.min(1e3*2**e,3e4)}function cg(e){return(e??`online`)!==`online`||og.isOnline()}var lg=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function ug(e){let t=!1,n=0,r,i=`pending`,a,o,s=new Promise((e,t)=>{a=e,o=t});s.catch(kh);let c=()=>i!==`pending`,l=t=>{if(!c()){let n=new lg(t);h(n),e.onCancel?.(n)}},u=()=>{t=!0},d=()=>{t=!1},f=()=>ng.isFocused()&&(e.networkMode===`always`||og.isOnline())&&e.canRun(),p=()=>cg(e.networkMode)&&e.canRun(),m=e=>{c()||(r?.(),i=`resolved`,a(e))},h=e=>{c()||(r?.(),i=`rejected`,o(e))},g=t=>new Promise(n=>{r=e=>{(c()||t())&&n(e)},e.onPause?.()}).then(()=>{r=void 0,c()||e.onContinue?.()}),_=()=>{if(c())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(m).catch(r=>{if(c())return;let i=e.retry??(eg()?0:3),a=e.retryDelay??sg,o=typeof a==`function`?a(n,r):a,s=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);t||!s?h(r):(n++,e.onFail?.(n,r),Gh(o).then(()=>f()?void 0:g(f)).then(()=>{t?h(r):_()}))})};return{promise:s,status:()=>i,cancel:l,continue:()=>(r?.(),s),cancelRetry:u,continueRetry:d,canStart:p,start:()=>(p()?_():g(p).then(_),s)}}var dg=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),jh(this.gcTime)&&(this.#e=Eh.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(eg()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(Eh.clearTimeout(this.#e),this.#e=void 0)}};function fg(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{Qh(e,()=>t.signal,()=>n=!0)},u=Xh(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?Jh:qh;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?mg:pg,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]===void 0?r.initialPageParam:o[0]:pg(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function pg(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function mg(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var hg=class extends dg{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=vg(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=vg(this.options);e.data!==void 0&&(this.setState(_g(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=Kh(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#c({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(kh).catch(kh):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>Nh(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Yh||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>Nh(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!Mh(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){let t=this.observers.indexOf(e);t!==-1&&(this.observers.splice(t,1),this.observers.length||(this.#a&&(this.#s||this.state.fetchStatus===`paused`&&this.state.status===`pending`?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=Xh(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?fg(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta});let o=this.#a=ug({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof lg&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await o.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof lg){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.#a===o&&(this.#a=void 0),this.scheduleGc()}}#c(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...gg(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,..._g(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),ag.batch(()=>{this.observers.slice().forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function gg(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:cg(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function _g(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function vg(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var yg=class extends tg{#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=new Set;constructor(e,t){super(),this.options=t,this.#e=e,this.#o=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),xg(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Sg(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Sg(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof Nh(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!Vh(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Cg(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||Nh(this.options.enabled,this.#t)!==Nh(t.enabled,this.#t)||Nh(this.options.staleTime,this.#t)!==Nh(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||Nh(this.options.enabled,this.#t)!==Nh(t.enabled,this.#t)||i!==this.#f)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return Vh(this.getCurrentResult(),n)||(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),Reflect.get(e,n))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t),r=()=>{},i,a=new Promise(e=>{i=e,r=this.#e.getQueryCache().subscribe(i=>{i.type===`updated`&&i.query.queryHash===n.queryHash&&n.state.data!==void 0&&(r(),e(this.createResult(n,t)))})});return Promise.race([n.fetch(t).then(()=>{let e=this.createResult(n,t);return i?.(e),e}).finally(()=>{r()}),a])}fetch(e){return this.#m({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#m(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(kh)),t}#h(e){return!eg()&&Nh(this.options.enabled,this.#t)!==!1&&jh(e)}#g(){this.#b();let e=Nh(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=Mh(this.#r.dataUpdatedAt,e)+1;this.#u=Eh.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return Nh(this.options.refetchInterval,this.#t)??!1}#v(e){this.#x(),this.#f=e,this.#f!==0&&this.#h(this.#f)&&(this.#d=Eh.setInterval(()=>{(this.options.refetchIntervalInBackground||ng.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(Eh.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(Eh.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&xg(e,t),o=i&&Cg(e,n,t,r);(a||o)&&(l={...l,...gg(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#l?.state.data,this.#l):t.placeholderData,e!==void 0&&(m=`success`,d=Kh(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h){if(i&&d===a?.data&&t.select===this.#s)d=this.#c;else try{this.#s=t.select,d=t.select(d),d=Kh(i?.data,d,t),this.#c=d,this.#o=null}catch(e){this.#o=e}}else d===void 0&&(this.#o=null);this.#o&&(f=this.#o,d=this.#c,p=Date.now(),m=`error`,u=!1);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0;return{status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:wg(e,t),refetch:this.refetch,isEnabled:Nh(t.enabled,e)!==!1}}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#l=this.#t),Vh(t,e))return;this.#r=t;let n=(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#p.size)return!0;let r=new Set(n??this.#p);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})();ag.batch(()=>{n&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}};function bg(e,t){return Nh(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||Nh(t.retryOnMount,e)!==!1)}function xg(e,t){return bg(e,t)||e.state.data!==void 0&&Sg(e,t,t.refetchOnMount)}function Sg(e,t,n){if(Nh(t.enabled,e)!==!1&&Nh(t.staleTime,e)!==`static`){let r=Nh(n,e);return r===`always`||r!==!1&&wg(e,t)}return!1}function Cg(e,t,n,r){return(e!==t||Nh(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&wg(e,n)}function wg(e,t){return Nh(t.enabled,e)!==!1&&e.isStaleByTime(Nh(t.staleTime,e))}var Tg=class extends dg{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Eg(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??(this.state.status===`pending`?this.execute(this.state.variables):Promise.resolve())}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},r=this.#r=ug({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)}),i=this.state.status===`pending`,a=!r.canStart();try{if(i)t();else{this.#i({type:`pending`,variables:e,isPaused:a}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:a})}let o=await r.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:`success`,data:o}),o}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#r===r&&(this.#r=void 0),this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),ag.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Eg(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Dg=class extends tg{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){let r=new Tg({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Og(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Og(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Og(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=Og(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){ag.batch(()=>{let e=this.getAll();this.#e.clear(),this.#t.clear(),e.forEach(e=>{this.notify({type:`removed`,mutation:e})})})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Fh(t,e))}findAll(e={}){return this.getAll().filter(t=>Fh(e,t))}notify(e){ag.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return ag.batch(()=>Promise.all(e.map(e=>e.continue().catch(kh))))}};function Og(e){return e.options.scope?.id}var kg=class extends tg{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),Vh(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&Lh(t.mutationKey)!==Lh(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onSubscribe(){this.listeners.size===1&&this.#n&&(this.#n.addObserver(this),this.#i())}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Eg();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){ag.batch(()=>{let t=this.#r;if(t&&this.hasListeners()){let n=this.#t.variables,r=this.#t.context,i={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{t.onSuccess?.(e.data,n,r,i)}catch(e){Promise.reject(e)}try{t.onSettled?.(e.data,null,n,r,i)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{t.onError?.(e.error,n,r,i)}catch(e){Promise.reject(e)}try{t.onSettled?.(void 0,e.error,n,r,i)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},Ag=class extends tg{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??Ih(r,t),a=this.get(i);return a||(a=new hg({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){this.#e.get(e.queryHash)===e&&(e.destroy(),this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){ag.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Ph(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>Ph(e,t)):t}notify(e){ag.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){ag.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){ag.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},jg=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Ag,this.#t=e.mutationCache||new Dg,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=ng.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=og.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Nh(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=Ah(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return ag.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;ag.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return ag.batch(()=>{let r=n.findAll(e),i=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,predicate:e=>i.has(e)},t)})}cancelQueries(e,t={}){let n={revert:!0,...t},r=ag.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(kh).catch(kh)}invalidateQueries(e,t={}){return ag.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=ag.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(kh)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(kh)}async query(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t),r=n.isStaleByTime(Nh(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(Nh(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(kh).catch(kh)}infiniteQuery(e){return e._type=`infinite`,this.query(e)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(kh).catch(kh)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return og.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(Lh(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{Rh(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(Lh(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{Rh(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=Ih(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===Yh&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Mg=J.createContext(!1),Ng=()=>J.useContext(Mg);Mg.Provider;function Pg(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Fg=J.createContext(Pg()),Ig=()=>J.useContext(Fg),Lg=(e,t,n)=>{let r=n?.state.status===`error`&&typeof e.throwOnError==`function`?Zh(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},Rg=e=>{J.useEffect(()=>{e.clearReset()},[e])},zg=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Zh(n,[e.error,r])),Bg=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Vg=(e,t)=>e?.suspense&&t.isPending,Hg=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Ug(e,t,n){let r=Ng(),i=Ig(),a=Ch(n),o=a.defaultQueryOptions(e),s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,Bg(o),Lg(o,i,s),Rg(i);let[l]=J.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&c;if(J.useSyncExternalStore(J.useCallback(e=>{let t=d?l.subscribe(ag.batchCalls(e)):kh;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),J.useEffect(()=>{l.setOptions(o)},[o,l]),Vg(o,u))throw Hg(o,l,i);if(zg({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return o.notifyOnChangeProps?u:l.trackResult(u)}function Wg(e,t){return Ug(e,yg,t)}function Gg(e,t){let n=Ch(t),[r]=J.useState(()=>new kg(n,e));J.useEffect(()=>{r.setOptions(e)},[r,e]);let i=J.useSyncExternalStore(J.useCallback(e=>r.subscribe(ag.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=J.useCallback((...e)=>{r.mutate(e[0],e[1]).catch(kh)},[r]);if(i.error&&Zh(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}var Kg={lists:e=>[`discussion`,e,`comments`],file:(e,t)=>[`discussion`,e,`comments`,`file`,t],all:e=>[`discussion`,e,`comments`,`project`],summary:e=>[`discussion`,e,`summary`],mentions:e=>[`discussion`,e,`mentions`],candidates:e=>[`discussion`,e,`candidates`]},qg=[],Jg=[],Yg=e=>e instanceof Ae&&[401,403,404].includes(e.status);function Xg(){return new jg({defaultOptions:{queries:{staleTime:3e4,gcTime:3e5,retry:(e,t)=>!Yg(t)&&e<2&&(!(t instanceof Ae)||t.status===0||t.status>=500||t.code===`INVALID_RESPONSE`),retryDelay:e=>Math.min(500*2**e,2e3),refetchOnReconnect:`always`},mutations:{retry:!1}}})}var Zg=new WeakMap;function Qg(e){let t=Zg.get(e);return t||(t={next:0,summaries:new Map},Zg.set(e,t)),++t.next}function $g(e,t,n,r){let i=Zg.get(e);!n||!i||r<(i.summaries.get(t)??0)||(i.summaries.set(t,r),e.setQueryData(Kg.summary(t),n))}function e_(e,t){if(t.kind===`created`)return e.some(e=>e.id===t.comment.id)?e:[...e,t.comment];let n=t.kind===`edited`?t.comment.id:t.kind===`resolved`?t.resolution.id:t.commentId;return t.kind===`deleted`?e.filter(e=>e.id!==n):e.map(e=>{if(e.id!==n)return e;if(t.kind===`edited`)return{...e,...t.comment};if(t.kind===`resolved`)return{...e,...t.resolution};if(t.kind===`reply-deleted`)return{...e,replies:e.replies.filter(e=>e.id!==t.replyId)};let r=e.replies.some(e=>e.id===t.reply.id);return{...e,replies:r?e.replies.map(e=>e.id===t.reply.id?t.reply:e):[...e.replies,t.reply]}})}async function t_(e,t,n){await Promise.all([e.cancelQueries({queryKey:Kg.lists(t)}),e.cancelQueries({queryKey:Kg.mentions(t)})]);let r=n.change,i=r.kind===`created`||r.kind===`edited`?r.comment.filePath:r.kind===`resolved`?r.resolution.filePath:r.filePath;if(e.setQueriesData({queryKey:Kg.lists(t)},e=>{if(!e)return e;let t=e.comments;return r.kind===`created`?e:{...e,comments:e_(t,r),summary:n.summary}}),r.kind===`created`)for(let a of[Kg.file(t,i),Kg.all(t)])e.setQueryData(a,e=>e&&{...e,comments:e_(e.comments,r),summary:n.summary});$g(e,t,n.summary,Qg(e)),e.setQueryData(Kg.mentions(t),e=>e&&{mentions:e.mentions.filter(e=>r.kind===`deleted`?e.commentId!==r.commentId:r.kind===`resolved`&&r.resolution.resolved?e.commentId!==r.resolution.id:r.kind!==`reply-deleted`||e.replyId!==r.replyId)})}async function n_(e,t){await Promise.all([Kg.lists(t),Kg.mentions(t)].map(async t=>{await e.cancelQueries({queryKey:t}),await e.invalidateQueries({queryKey:t})}))}function r_(e,t,n,r,i){let a=Ch(),o=async(t,n)=>{let r=Qg(a),i=await G(t,{signal:n});return n.aborted||$g(a,e,i.summary,r),i},s=Wg({queryKey:Kg.file(e,t),enabled:!!t,queryFn:({signal:n})=>o(`/api/projects/${e}/comments?path=${encodeURIComponent(t)}`,n)}),c=Wg({queryKey:Kg.all(e),enabled:n===`project`,queryFn:({signal:t})=>o(`/api/projects/${e}/comments?scope=project`,t)}),l=Wg({queryKey:Kg.summary(e),enabled:!1}),u=(0,J.useRef)({projectId:e,revision:r,sourceOrderRevision:i});(0,J.useEffect)(()=>{let t=u.current;if(u.current={projectId:e,revision:r,sourceOrderRevision:i},t.projectId!==e)return;let n=t.revision===r?t.sourceOrderRevision===i?null:Kg.all(e):Kg.lists(e);n&&a.cancelQueries({queryKey:n}).then(()=>a.invalidateQueries({queryKey:n}))},[a,e,r,i]);let d=n===`project`?c:s,f=s.error?W(s.error):``;return{comments:Yg(s.error)?qg:s.data?.comments??qg,commentsFilePath:t&&(s.data||s.error)?t:``,commentsReady:!(!t||!s.data||s.isFetching||s.error),fileCommentsLoading:!!(t&&s.isFetching),fileCommentsError:f,reviewComments:Yg(d.error)?qg:d.data?.comments??qg,reviewCommentsLoading:!(n!==`project`&&!t||!d.isFetching),reviewCommentsError:d.error?W(d.error):``,projectCommentSummary:Yg(s.error)||Yg(c.error)?null:l.data??null,refreshComments:()=>n_(a,e)}}function i_(e){let t=Ch(),n=Gg({retry:!1,mutationFn:async({id:e,path:n,options:r})=>{let i=await G(`/api/projects/${e}/comments${n}`,r);return await t_(t,e,i),n_(t,e),i}});return(t,r)=>n.mutateAsync({id:e,path:t,options:r})}function a_({projectId:e,activeFile:t,content:n,permission:r,revision:i,sourceOrderRevision:a,selection:o,save:s,saveFailureMessage:c,onError:l,onAdded:u}){let d=(0,J.useMemo)(()=>new xh,[e]),f=(0,J.useMemo)(()=>({active:!1}),[e]);(0,J.useEffect)(()=>(f.active=!0,()=>{f.active=!1}),[f]);let[p,m]=(0,J.useState)(`file`),h=r_(e,t,p,i,a),g=i_(e),[_,v]=(0,J.useState)(null),[y,b]=(0,J.useState)(!1),[x,S]=(0,J.useState)(``),[C,w]=(0,J.useState)(null),[T,E]=(0,J.useState)(null),[D,O]=(0,J.useState)(!1),[k,A]=(0,J.useState)(!1),[j,M]=(0,J.useState)(``),N=(0,J.useRef)(!1),P=(0,J.useRef)(t),F=(0,J.useRef)(s),ee=(0,J.useRef)(l),te=(0,J.useRef)(u),ne=(0,J.useRef)(C),re=(0,J.useRef)(x);ne.current=C,re.current=x,P.current=t,F.current=s,ee.current=l,te.current=u,(0,J.useEffect)(()=>{v(null),m(`file`),b(!1),w(null),E(null),S(``),O(!1),M(``)},[e]),(0,J.useEffect)(()=>{b(!1),w(null),E(null),S(``),O(!1),M(``)},[t]);let ie=(e,r)=>{if(!t)return;M(``);let i={filePath:t,selection:{...e??o},sourceHash:Rd(r??n)},a=d.getNew(t);w(a??i),S(a?.content??``),E(i),O(!!a),b(!0)},ae=e=>{S(e),C&&(e?d.setNew({...C,content:e}):d.discardNew(C.filePath))},oe=()=>{N.current||(b(!1),M(``))},I=()=>{N.current||(C&&d.discardNew(C.filePath),S(``),w(null),E(null),O(!1),oe())},L=()=>{!N.current&&T&&T.filePath===P.current&&(w(T),x&&d.setNew({...T,content:x}),O(!1),M(``))},R=async()=>{let e=C,t=x;if(!x.trim()||!e||N.current)return;let n=()=>{let n=ne.current;return n?.filePath===e.filePath&&n.sourceHash===e.sourceHash&&n.selection.startOffset===e.selection.startOffset&&n.selection.endOffset===e.selection.endOffset&&re.current===t};N.current=!0,A(!0),M(``);try{if(r!==`read`&&!await F.current()){n()&&M(c);return}await g(``,{method:`POST`,body:JSON.stringify({path:e.filePath,content:t,...e.selection,sourceHash:e.sourceHash})});let i=d.getNew(e.filePath);if(i?.content===t&&i.sourceHash===e.sourceHash&&i.selection.startOffset===e.selection.startOffset&&i.selection.endOffset===e.selection.endOffset&&d.discardNew(e.filePath),!f.active)return;n()&&(b(!1),w(null),S(``),O(!1)),te.current()}catch(e){n()&&M(W(e))}finally{N.current=!1,A(!1)}},se=async e=>{try{await g(`/${e.id}`,{method:`PATCH`,body:JSON.stringify({resolved:!e.resolved})})}catch(e){f.active&&ee.current(W(e))}},z=async(e,t)=>(await g(`/${e.id}/replies`,{method:`POST`,body:JSON.stringify({content:t})}),!0),ce=async(e,t)=>(await g(`/${e.id}`,{method:`PATCH`,body:JSON.stringify({content:t})}),!0),B=async e=>(await g(`/${e.id}`,{method:`DELETE`}),f.active&&(v(t=>t?.id===e.id?null:t),d.discard(e.id)),!0),le=async(e,t,n)=>(await g(`/${e.id}/replies/${t}`,{method:`PATCH`,body:JSON.stringify({content:n})}),!0),V=async(e,t)=>(await g(`/${e.id}/replies/${t}`,{method:`DELETE`}),d.discard(e.id,`edit-reply:${t}`),!0);return{commentDraftStore:d,...h,retryFileComments:h.refreshComments,retryReviewComments:h.refreshComments,commentScope:p,setCommentScope:m,focusComment:_,setFocusComment:v,commentOpen:y,openComment:ie,closeComment:oe,cancelComment:I,commentDraftRestored:D,commentDraftCanRetarget:!(!C||!T||C.sourceHash===T.sourceHash&&C.selection.startOffset===T.selection.startOffset&&C.selection.endOffset===T.selection.endOffset),useCurrentCommentSelection:L,commentText:x,setCommentText:ae,commentSelection:C?.selection??o,commentSubmitting:k,commentError:j,addComment:R,toggleComment:se,replyToComment:z,editComment:ce,deleteComment:B,editCommentReply:le,deleteCommentReply:V}}function o_(e){let t=new Map;for(let n of e)for(let e of[n,...n.replies])t.has(e.authorId)||t.set(e.authorId,{authorId:e.authorId,authorUsername:e.authorUsername,authorDisplayName:e.authorDisplayName,authorAvatarStyle:e.authorAvatarStyle});return[...t.values()].sort((e,t)=>(e.authorDisplayName??e.authorUsername??``).localeCompare(t.authorDisplayName??t.authorUsername??``))}function s_(e,t){let n=t.participantIds;return!n?.size||n.has(e.authorId)||!t.topLevelOnly&&e.replies.some(e=>n.has(e.authorId))}function c_(e,t=`source`){return[...e].sort((e,n)=>{if(t===`time`)return Date.parse(n.createdAt)-Date.parse(e.createdAt);let r=e.sourceOrder??1/0,i=n.sourceOrder??1/0;return r===i?e.filePath.localeCompare(n.filePath,`en`,{numeric:!0})||e.startLine-n.startLine||e.startOffset-n.startOffset:r-i})}function l_(e,t){return t.scope===`project`||e.filePath===t.activeFile}function u_(e,t){return t===`unresolved`?!e.resolved:e.resolved}function d_(e,t){return t.some(t=>t.commentId===e.id&&t.readAt===null)}function f_(e,t){return e.filter(e=>l_(e,t)&&s_(e,t)&&u_(e,t.filter)&&(!t.unreadMentionsOnly||d_(e,t.unreadMentions)))}function p_(e,t,n=[]){let r=new Set(n.filter(e=>!!e));return c_(e.filter(e=>l_(e,t)?r.has(e.id)||s_(e,t)&&u_(e,t.filter)&&(!t.unreadMentionsOnly||d_(e,t.unreadMentions)):!1),t.sort)}function m_(e,t,n){let r=e.find(e=>e.id===t&&e.filePath===n&&!e.resolved);return r?[r]:[]}function h_(e,t){return e.filter(e=>e.filePath===t)}function g_(e,t,n){return!e||e.filePath!==t||n!==t?null:e}function __(e,t,n,r,i,a){return!e||e.filePath!==t||n!==t||r!==t||!i?null:a.find(n=>n.id===e.id&&n.filePath===t)??null}function v_(e,t){if(!t)return 0;let n=e.findIndex(e=>e.id===t);return n<0?0:n+1}function y_(e,t,n){if(!e.length)return null;let r=t?e.findIndex(e=>e.id===t):-1;if(r<0)return n===1?e[0]:null;let i=r+n;return i>=0&&i<e.length?e[i]:null}function b_(e,t,n,r){let i=Ch(),a=Kg.mentions(e),o=Wg({queryKey:a,queryFn:({signal:t})=>G(`/api/projects/${e}/mentions?unread=1&limit=100`,{signal:t})}),s=Yg(o.error)?Jg:o.data?.mentions??Jg,c=(0,J.useRef)({onError:n,onRead:r});c.current={onError:n,onRead:r};let l=(0,J.useMemo)(()=>({active:!1,pending:new Map}),[e]);(0,J.useEffect)(()=>(l.active=!0,()=>{l.active=!1}),[l]);let u=(0,J.useRef)({projectId:e,revision:t}),d=async(e=!1)=>{if(!l.active)return;await i.cancelQueries({queryKey:a});let t=await o.refetch();e&&t.error&&l.active&&c.current.onError(W(t.error))};(0,J.useEffect)(()=>{let n=u.current;u.current={projectId:e,revision:t},n.projectId===e&&n.revision!==t&&d()},[e,t]);let f=t=>{let n=t??`all`,r=l.pending.get(n);if(r)return r;let o=(async()=>{try{let n=await G(`/api/projects/${e}/mentions/${t?`${encodeURIComponent(t)}/read`:`read-all`}`,{method:`POST`});if(!l.active||(await i.cancelQueries({queryKey:a}),!l.active))return!1;i.setQueryData(a,e=>e&&{mentions:t?e.mentions.filter(e=>e.id!==t):[]});let r=Number(n.changed)||0;return(r||!t)&&c.current.onRead?.(r,!t),i.invalidateQueries({queryKey:a}),!0}catch(e){return l.active&&c.current.onError(W(e)),!1}finally{l.pending.delete(n)}})();return l.pending.set(n,o),o};return{unreadMentions:s,mentionsError:o.error?W(o.error):``,refresh:d,markMentionRead:e=>f(e),markAllMentionsRead:()=>f()}}function x_({children:e}){let[t]=(0,J.useState)(Xg);return(0,X.jsx)(wh,{client:t,children:e})}function S_(e){if(!e||typeof e!=`object`)return!1;let t=e;return(t.kind===`update`||t.kind===`move`||t.kind===`delete`)&&typeof t.revision==`string`}function C_(e,t,n,r){let[i,a]=(0,J.useState)(`connecting`),[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)([]),[u,d]=(0,J.useState)(null),[f,p]=(0,J.useState)(null),[m,h]=(0,J.useState)(``),[g,_]=(0,J.useState)(!1),[v,y]=(0,J.useState)(``),[b,x]=(0,J.useState)(``),[S,C]=(0,J.useState)([]),[w,T]=(0,J.useState)(!1),[E,D]=(0,J.useState)(n),[O,k]=(0,J.useState)(null),[A,j]=(0,J.useState)(!1),M=(0,J.useRef)(t),N=(0,J.useRef)(r);M.current=t,N.current=r,(0,J.useEffect)(()=>{let n=e.compileStates();d(n[t]??null)},[t,e]),(0,J.useEffect)(()=>{let t=()=>l(e.sessions()),n=()=>{s(!1),l([]),d(null),p(null),h(``),_(!1),y(``),x(``),C([])},r=({status:t})=>{a(t),t===`connected`?s(e.synced):n()},i=e=>{s(e),e&&(t(),c())},o=()=>{a(`disconnected`),n()},c=()=>{_(e.meta.get(`historyWarning`)===!0);let t=e.meta.get(`filesEvent`);S_(t)&&p(t);let n=e.meta.get(`commentsRevision`);typeof n==`string`&&h(n);let r=e.meta.get(`dictionaryRevision`);typeof r==`string`&&y(r);let i=e.meta.get(`chktexSettingsRevision`);typeof i==`string`&&x(i);let a=e.compileStates();d(a[M.current]??null)},u=()=>{let t=e.compileStates();d(t[M.current]??null)};e.awareness.on(`change`,t),e.provider.on(`status`,r),e.provider.on(`sync`,i),e.provider.on(`connection-close`,o),e.provider.on(`connection-error`,o),e.meta.observe(c);let f=e.onCompileStates(u),m=e.onProtocolUpgrade(()=>{j(!0),a(`disconnected`),n()}),g=e.onFormatLeaseState(()=>C(e.formatLeaseStates())),v=()=>{if(!N.current||e.currentPermission!==`read`)return;let t=e.hasWritableDraft,n=e.hasOtherWritableDraft;(t||n)&&k({previous:`edit`,localDraftReady:t,otherTabDraft:n})},b=e.onDraftReady(()=>{T(!0),v()}),S=e.onPermissionChanged((t,r)=>{t===`revoked`?(a(`disconnected`),n()):(D(t),t===`read`&&r!==`read`?k({previous:r,localDraftReady:e.hasWritableDraft,otherTabDraft:e.hasOtherWritableDraft}):t!==`read`&&k(null))});return t(),c(),a(e.connected?`connected`:`connecting`),s(e.synced),()=>{e.awareness.off(`change`,t),e.provider.off(`status`,r),e.provider.off(`sync`,i),e.provider.off(`connection-close`,o),e.provider.off(`connection-error`,o),e.meta.unobserve(c),f(),m(),g(),b(),S()}},[e]),(0,J.useEffect)(()=>{r&&e.connect()},[e,r]),(0,J.useEffect)(()=>{e.setPermission(n),D(n),r&&n===`read`&&(e.hasWritableDraft||e.hasOtherWritableDraft)?k({previous:`edit`,localDraftReady:e.hasWritableDraft,otherTabDraft:e.hasOtherWritableDraft}):n!==`read`&&k(null)},[e,n,r]);let P=O!==null;return(0,J.useEffect)(()=>{if(!P)return;let t=()=>{if(e.currentPermission!==`read`)return;let t=e.hasWritableDraft,n=e.hasOtherWritableDraft;k(e=>!e||e.localDraftReady===t&&e.otherTabDraft===n?e:{...e,localDraftReady:t,otherTabDraft:n})};t();let n=window.setInterval(t,2e3);return()=>window.clearInterval(n)},[e,P]),{collaboration:e,status:i===`connected`&&!o?`syncing`:i,synced:i===`connected`&&o,activeSessions:c,compileState:u,setCompileState:d,formatLeaseStates:S,filesEvent:f,commentsRevision:m,historyWarning:g,dictionaryRevision:v,chktexSettingsRevision:b,localDraftReady:w,permission:E,protocolUpgradeRequired:A,reconnect:()=>{A||(a(`connecting`),s(!1),l([]),d(null),C([]),e.reconnect())},permissionDowngrade:O,dismissPermissionDowngrade:()=>k(null),discardLocalDraft:async()=>await e.discardLocalDraft()?(k(null),window.location.reload(),!0):(k(e=>e&&{...e,otherTabDraft:!0}),!1)}}var w_=new Map,T_=class{constructor(e){this.room=e,this.onmessage=null,this._onChange=t=>t.key===e&&this.onmessage!==null&&this.onmessage({data:ua(t.newValue||``)}),Ei(this._onChange)}postMessage(e){Ti.setItem(this.room,la(ia(e)))}close(){Di(this._onChange)}},E_=typeof BroadcastChannel>`u`?T_:BroadcastChannel,D_=e=>Wn(w_,e,()=>{let t=qn(),n=new E_(e);return n.onmessage=e=>t.forEach(t=>t(e.data,`broadcastchannel`)),{bc:n,subs:t}}),O_=(e,t)=>(D_(e).subs.add(t),t),k_=(e,t)=>{let n=D_(e),r=n.subs.delete(t);return r&&n.subs.size===0&&(n.bc.close(),w_.delete(e)),r},A_=(e,t,n=null)=>{let r=D_(e);r.bc.postMessage(t),r.subs.forEach(e=>e(t,n))},j_=(e,t)=>{Z(e,0),Ir(e,qs(t))},M_=(e,t,n)=>{Z(e,1),Ir(e,Vs(t,n))},N_=(e,t,n)=>M_(t,n,ai(e)),P_=(e,t,n,r)=>{try{Rs(t,ai(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},F_=(e,t)=>{Z(e,2),Ir(e,t)},I_=P_,L_=(e,t,n,r,i)=>{let a=Q(e);switch(a){case 0:N_(e,t,n);break;case 1:P_(e,n,r,i);break;case 2:I_(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},R_=(e,t,n)=>{Q(e)===0&&n(t,ci(e))},z_=3e4,B_=class extends nr{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=bi();this.getLocalState()!==null&&15e3<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&3e4<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&V_(this,t,`timeout`)},rr(z_/10)),e.on(`destroy`,()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit(`destroy`,[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){let t=this.clientID,n=this.meta.get(t),r=n===void 0?0:n.clock+1,i=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:bi()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),Wi(i,e)||s.push(t)),(a.length>0||s.length>0||c.length>0)&&this.emit(`change`,[{added:a,updated:s,removed:c},`local`]),this.emit(`update`,[{added:a,updated:o,removed:c},`local`])}setLocalStateField(e,t){let n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}},V_=(e,t,n)=>{let r=[];for(let n=0;n<t.length;n++){let i=t[n];if(e.states.has(i)){if(e.states.delete(i),i===e.clientID){let t=e.meta.get(i);e.meta.set(i,{clock:t.clock+1,lastUpdated:bi()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},H_=(e,t,n=e.states)=>{let r=t.length,i=Tr();Z(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;Z(i,r),Z(i,s),Pr(i,JSON.stringify(o))}return Dr(i)},U_=(e,t,n)=>{let r=ni(t),i=bi(),a=[],o=[],s=[],c=[],l=Q(r);for(let t=0;t<l;t++){let t=Q(r),n=Q(r),l=JSON.parse(ci(r)),u=e.meta.get(t),d=e.states.get(t),f=u===void 0?0:u.clock;(f<n||f===n&&l===null&&e.states.has(t))&&(l===null?t===e.clientID&&e.getLocalState()!=null?n++:e.states.delete(t):e.states.set(t,l),e.meta.set(t,{clock:n,lastUpdated:i}),u===void 0&&l!==null?a.push(t):u!==void 0&&l===null?c.push(t):l!==null&&(Wi(l,d)||s.push(t),o.push(t)))}(a.length>0||s.length>0||c.length>0)&&e.emit(`change`,[{added:a,updated:s,removed:c},n]),(a.length>0||o.length>0||c.length>0)&&e.emit(`update`,[{added:a,updated:o,removed:c},n])},W_=e=>Pi(e,(e,t)=>`${encodeURIComponent(t)}=${encodeURIComponent(e)}`).join(`&`),G_=[];G_[0]=(e,t,n,r,i)=>{Z(e,0);let a=L_(t,e,n.doc,n);r&&a===1&&!n.synced&&(n.synced=!0)},G_[3]=(e,t,n,r,i)=>{Z(e,1),Ir(e,H_(n.awareness,Array.from(n.awareness.getStates().keys())))},G_[1]=(e,t,n,r,i)=>{U_(n.awareness,ai(t),n)},G_[2]=(e,t,n,r,i)=>{R_(t,n.doc,(e,t)=>q_(n,t))};var K_=3e4,q_=(e,t)=>console.warn(`Permission denied to access ${e.url}.\n${t}`),J_=(e,t,n)=>{let r=ni(t),i=Tr(),a=Q(r),o=e.messageHandlers[a];return o?o(i,r,e,n,a):console.error(`Unable to compute message`),i},Y_=(e,t,n)=>{t===e.ws&&(e.emit(`connection-close`,[n,e]),e.ws=null,t.close(),e.wsconnecting=!1,e.wsconnected?(e.wsconnected=!1,e.synced=!1,V_(e.awareness,Array.from(e.awareness.getStates().keys()).filter(t=>t!==e.doc.clientID),e),e.emit(`status`,[{status:`disconnected`}])):e.wsUnsuccessfulReconnects++,setTimeout(X_,ar(sr(2,e.wsUnsuccessfulReconnects)*100,e.maxBackoffTime),e))},X_=e=>{if(e.shouldConnect&&e.ws===null){let t=new e._WS(e.url,e.protocols);t.binaryType=`arraybuffer`,e.ws=t,e.wsconnecting=!0,e.wsconnected=!1,e.synced=!1,t.onmessage=n=>{e.wsLastMessageReceived=bi();let r=J_(e,new Uint8Array(n.data),!0);Er(r)>1&&t.send(Dr(r))},t.onerror=t=>{e.emit(`connection-error`,[t,e])},t.onclose=n=>{Y_(e,t,n)},t.onopen=()=>{e.wsLastMessageReceived=bi(),e.wsconnecting=!1,e.wsconnected=!0,e.wsUnsuccessfulReconnects=0,e.emit(`status`,[{status:`connected`}]);let n=Tr();if(Z(n,0),j_(n,e.doc),t.send(Dr(n)),e.awareness.getLocalState()!==null){let n=Tr();Z(n,1),Ir(n,H_(e.awareness,[e.doc.clientID])),t.send(Dr(n))}},e.emit(`status`,[{status:`connecting`}])}},Z_=(e,t)=>{let n=e.ws;e.wsconnected&&n&&n.readyState===n.OPEN&&n.send(t),e.bcconnected&&A_(e.bcChannel,t,e)},Q_=class extends tr{constructor(e,t,n,{connect:r=!0,awareness:i=new B_(n),params:a={},protocols:o=[],WebSocketPolyfill:s=WebSocket,resyncInterval:c=-1,maxBackoffTime:l=2500,disableBc:u=!1}={}){for(super();e[e.length-1]===`/`;)e=e.slice(0,e.length-1);this.serverUrl=e,this.bcChannel=e+`/`+t,this.maxBackoffTime=l,this.params=a,this.protocols=o,this.roomname=t,this.doc=n,this._WS=s,this.awareness=i,this.wsconnected=!1,this.wsconnecting=!1,this.bcconnected=!1,this.disableBc=u,this.wsUnsuccessfulReconnects=0,this.messageHandlers=G_.slice(),this._synced=!1,this.ws=null,this.wsLastMessageReceived=0,this.shouldConnect=r,this._resyncInterval=0,c>0&&(this._resyncInterval=setInterval(()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){let e=Tr();Z(e,0),j_(e,n),this.ws.send(Dr(e))}},c)),this._bcSubscriber=(e,t)=>{if(t!==this){let t=J_(this,new Uint8Array(e),!1);Er(t)>1&&A_(this.bcChannel,Dr(t),this)}},this._updateHandler=(e,t)=>{if(t!==this){let t=Tr();Z(t,0),F_(t,e),Z_(this,Dr(t))}},this.doc.on(`update`,this._updateHandler),this._awarenessUpdateHandler=({added:e,updated:t,removed:n},r)=>{let a=e.concat(t).concat(n),o=Tr();Z(o,1),Ir(o,H_(i,a)),Z_(this,Dr(o))},this._exitHandler=()=>{V_(this.awareness,[n.clientID],`app closed`)},Ki&&typeof process<`u`&&process.on(`exit`,this._exitHandler),i.on(`update`,this._awarenessUpdateHandler),this._checkInterval=setInterval(()=>{this.wsconnected&&K_<bi()-this.wsLastMessageReceived&&Y_(this,this.ws,null)},K_/10),r&&this.connect()}get url(){let e=W_(this.params);return this.serverUrl+`/`+this.roomname+(e.length===0?``:`?`+e)}get synced(){return this._synced}set synced(e){this._synced!==e&&(this._synced=e,this.emit(`synced`,[e]),this.emit(`sync`,[e]))}destroy(){this._resyncInterval!==0&&clearInterval(this._resyncInterval),clearInterval(this._checkInterval),this.disconnect(),Ki&&typeof process<`u`&&process.off(`exit`,this._exitHandler),this.awareness.off(`update`,this._awarenessUpdateHandler),this.doc.off(`update`,this._updateHandler),super.destroy()}connectBc(){if(this.disableBc)return;this.bcconnected||=(O_(this.bcChannel,this._bcSubscriber),!0);let e=Tr();Z(e,0),j_(e,this.doc),A_(this.bcChannel,Dr(e),this);let t=Tr();Z(t,0),M_(t,this.doc),A_(this.bcChannel,Dr(t),this);let n=Tr();Z(n,3),A_(this.bcChannel,Dr(n),this);let r=Tr();Z(r,1),Ir(r,H_(this.awareness,[this.doc.clientID])),A_(this.bcChannel,Dr(r),this)}disconnectBc(){let e=Tr();Z(e,1),Ir(e,H_(this.awareness,[this.doc.clientID],new Map)),Z_(this,Dr(e)),this.bcconnected&&=(k_(this.bcChannel,this._bcSubscriber),!1)}disconnect(){this.shouldConnect=!1,this.disconnectBc(),this.ws!==null&&Y_(this,this.ws,null)}connect(){this.shouldConnect=!0,!this.wsconnected&&this.ws===null&&(X_(this),this.connectBc())}},$_=e=>xi((t,n)=>{e.onerror=e=>n(Error(e.target.error)),e.onsuccess=e=>t(e.target.result)}),ev=(e,t)=>xi((n,r)=>{let i=indexedDB.open(e);i.onupgradeneeded=e=>t(e.target.result),i.onerror=e=>r(Xr(e.target.error)),i.onsuccess=e=>{let t=e.target.result;t.onversionchange=()=>{t.close()},n(t)}}),tv=e=>$_(indexedDB.deleteDatabase(e)),nv=(e,t)=>t.forEach(t=>e.createObjectStore.apply(e,t)),rv=(e,t,n=`readwrite`)=>{let r=e.transaction(t,n);return t.map(e=>mv(r,e))},iv=(e,t)=>$_(e.count(t)),av=(e,t)=>$_(e.get(t)),ov=(e,t)=>$_(e.delete(t)),sv=(e,t,n)=>$_(e.put(t,n)),cv=(e,t)=>$_(e.add(t)),lv=(e,t,n)=>$_(e.getAll(t,n)),uv=(e,t,n)=>{let r=null;return pv(e,t,e=>(r=e,!1),n).then(()=>r)},dv=(e,t=null)=>uv(e,t,`prev`),fv=(e,t)=>xi((n,r)=>{e.onerror=r,e.onsuccess=async e=>{let r=e.target.result;if(r===null||await t(r)===!1)return n();r.continue()}}),pv=(e,t,n,r=`next`)=>fv(e.openKeyCursor(t,r),e=>n(e.key)),mv=(e,t)=>e.objectStore(t),hv=(e,t)=>IDBKeyRange.upperBound(e,t),gv=(e,t)=>IDBKeyRange.lowerBound(e,t),_v=`custom`,vv=`updates`,yv=(e,t=()=>{},n=()=>{})=>{let[r]=rv(e.db,[vv]);return lv(r,gv(e._dbref,!1)).then(i=>{e._destroyed||(t(r),Pc(e.doc,()=>{i.forEach(t=>Rs(e.doc,t))},e,!1),n(r))}).then(()=>dv(r).then(t=>{e._dbref=t+1})).then(()=>iv(r).then(t=>{e._dbsize=t})).then(()=>r)},bv=(e,t=!0)=>yv(e).then(n=>{(t||e._dbsize>=500)&&cv(n,Vs(e.doc)).then(()=>ov(n,hv(e._dbref,!0))).then(()=>iv(n).then(t=>{e._dbsize=t}))}),xv=class extends nr{constructor(e,t){super(),this.doc=t,this.name=e,this._dbref=0,this._dbsize=0,this._destroyed=!1,this.db=null,this.synced=!1,this._db=ev(e,e=>nv(e,[[`updates`,{autoIncrement:!0}],[`custom`]])),this.whenSynced=xi(e=>this.on(`synced`,()=>e(this))),this._db.then(e=>{this.db=e,yv(this,e=>cv(e,Vs(t)),()=>{if(this._destroyed)return this;this.synced=!0,this.emit(`synced`,[this])})}),this._storeTimeout=1e3,this._storeTimeoutId=null,this._storeUpdate=(e,t)=>{if(this.db&&t!==this){let[t]=rv(this.db,[vv]);cv(t,e),++this._dbsize>=500&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{bv(this,!1),this._storeTimeoutId=null},this._storeTimeout))}},t.on(`update`,this._storeUpdate),this.destroy=this.destroy.bind(this),t.on(`destroy`,this.destroy)}destroy(){return this._storeTimeoutId&&clearTimeout(this._storeTimeoutId),this.doc.off(`update`,this._storeUpdate),this.doc.off(`destroy`,this.destroy),this._destroyed=!0,this._db.then(e=>{e.close()})}clearData(){return this.destroy().then(()=>{tv(this.name)})}get(e){return this._db.then(t=>{let[n]=rv(t,[_v],`readonly`);return av(n,e)})}set(e,t){return this._db.then(n=>{let[r]=rv(n,[_v]);return sv(r,t,e)})}del(e){return this._db.then(t=>{let[n]=rv(t,[_v]);return ov(n,e)})}},Sv={Sync:0,Awareness:1,QueryAwareness:3,Flush:4,Protocol:5,Maintenance:6,Permission:7,CompileStates:8,FormatLease:9},Cv=[`queued`,`running`,`succeeded`,`failed`,`cleaned`],wv=[`cache`,`artifacts`];function Tv(e){return typeof e==`string`&&Cv.includes(e)}function Ev(e){return typeof e==`string`&&wv.includes(e)}var Dv=[[`#1677c8`,`#1677c833`],[`#d65745`,`#d6574533`],[`#16866a`,`#16866a33`],[`#9a58b5`,`#9a58b533`],[`#d27b18`,`#d27b1833`],[`#3f7d20`,`#3f7d2033`],[`#be3e7b`,`#be3e7b33`],[`#4964c6`,`#4964c633`],[`#8a6a14`,`#8a6a1433`],[`#087f8c`,`#087f8c33`]],{Sync:Ov,Awareness:kv,Flush:Av,Protocol:jv,Maintenance:Mv,Permission:Nv,CompileStates:Pv,FormatLease:Fv}=Sv,Iv=6e4,Lv=2592e6,Rv=15e3,zv=3e5;function Bv(e){if(!e||typeof e!=`object`)return null;let t=e,n=t.requestedBy;return typeof t.mainFile!=`string`||typeof t.runId!=`string`||!Tv(t.status)||t.status===`cleaned`&&!Ev(t.cleanMode)||t.stale!==void 0&&typeof t.stale!=`boolean`||typeof t.updatedAt!=`string`||!n||typeof n.id!=`string`||typeof n.username!=`string`||typeof n.name!=`string`?null:t}function Vv(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e)){let e=Bv(r);e&&e.mainFile===n&&(t[n]=e)}return t}function Hv(e,t,n){return e<=n&&t<=n}function Uv(e,t,n){let r=e=>e>0&&n-e<=zv;return{recoverable:e.some(e=>e.tabId===t||!r(e.activeAt)),otherActive:e.some(e=>e.tabId!==t&&r(e.activeAt))}}var Wv=class{projectId;user;doc=new Ss;provider;awareness;persistence;permission=`read`;activeFile=``;epoch=null;destroyed=!1;localDraftReady=!1;draftListeners=new Set;permissionListeners=new Set;protocolUpgradeListeners=new Set;compileStateListeners=new Set;flushRequests=new Map;formatLeaseRequests=new Map;formatLeaseListeners=new Set;formatLeaseStatesByPath=new Map;formatLeaseExpiryTimers=new Map;draftTabId;draftGeneration=0;draftUpdatedAt=0;draftMarkerPresent=!1;draftHeartbeatTimer=null;markDraftTabInactive;markDraftTabActive;undoManagers=new Map;authoritativeCompileStates=null;metaObserver;localDraftTransactionObserver;constructor(e,t){this.projectId=e,this.user=t;let n=window.location.protocol===`https:`?`wss:`:`ws:`;this.draftTabId=Zv(u(`texlite:collaboration-tab:${t.id}:${e}`));let r=this.readOwnWritableDraftMarker();this.draftGeneration=r?.generation??0,this.draftUpdatedAt=r?.updatedAt??0,this.draftMarkerPresent=r!==null,this.markDraftTabInactive=()=>this.setOwnDraftActivity(!1),this.markDraftTabActive=()=>this.resumeOwnDraftActivity(),window.addEventListener(`pagehide`,this.markDraftTabInactive),window.addEventListener(`pageshow`,this.markDraftTabActive),r&&(this.setOwnDraftActivity(!0),this.startDraftHeartbeat()),this.persistence=new xv(u(`texlite:${t.id}:${e}`),this.doc),this.localDraftTransactionObserver=e=>{if(e.local){for(let[t,n]of this.doc.share)if(t.startsWith(`source:`)&&(e.changed.has(n)||e.changedParentTypes.has(n))){this.markWritableDraft();return}}},this.doc.on(`afterTransaction`,this.localDraftTransactionObserver),this.persistence.on(`synced`,()=>{this.localDraftReady=!0;for(let e of this.draftListeners)e()}),this.provider=new Q_(`${n}//${window.location.host}${d(`/api/collaboration`)}`,e,this.doc,{connect:!1,disableBc:!0,maxBackoffTime:2500}),this.awareness=this.provider.awareness;let i=this.doc.getMap(`texlite:meta`);this.metaObserver=(e,t)=>{t.origin===this.provider&&e.keysChanged.has(`compileStates`)&&(this.authoritativeCompileStates=null,this.notifyCompileStateListeners())},i.observe(this.metaObserver),this.provider.messageHandlers[Av]=(e,t)=>{let n=ci(t),r=this.flushRequests.get(n);if(!r)return;let i=Q(t)===1,a=Q(t),o=ci(t),s=Q(t),c=[];for(let e=0;e<s;e++)c.push(ci(t));if(window.clearTimeout(r.timer),this.flushRequests.delete(n),i)this.clearOwnWritableDraftMarker(r.draftGeneration),r.resolve({revision:a,persistedAt:o,ok:!0,failedPaths:[]});else{let e=Object.assign(Error(c.length?`保存失败:${c.join(`, `)}`:`源码保存到服务器磁盘失败`),{failedPaths:c});r.reject(e)}},this.provider.messageHandlers[jv]=(e,t)=>{let n=ci(t),r=this.epochStorageKey(),i=Gv(r),a=/^([0-9]+):/.exec(n)?.[1]??null,o=i?/^([0-9]+):/.exec(i)?.[1]??null:null,s=!this.epoch&&a===`3`&&o!==null&&o!==a;if((this.epoch&&this.epoch!==n||i&&i!==n)&&!s){this.provider.disconnect(),this.rejectFlushes(Error(`Collaboration state changed`));let e=n.endsWith(`:reload`)||a!==null&&a!==`3`,t=()=>{Kv(r,n.replace(/:reload$/,``)),window.location.reload()};if(e)for(let e of this.protocolUpgradeListeners)e();else this.persistence.clearData().then(()=>{this.clearWritableDraftMarkers(),t()});return}this.epoch=n,Kv(r,n);let c=this.provider.ws;if(!c||c.readyState!==WebSocket.OPEN)return;let l=Tr();Z(l,jv),Pr(l,n),Z(l,3),c.send(Dr(l));let u=Tr();Z(u,Ov),j_(u,this.doc),c.send(Dr(u));let d=Tr();Z(d,kv),Ir(d,H_(this.awareness,[this.doc.clientID])),c.send(Dr(d))},this.provider.messageHandlers[Nv]=(e,t)=>{let n=ci(t),r=ci(t);if(n!==this.user.id)return;if(r===`revoked`){this.rejectFlushes(Error(`Project access revoked`)),this.provider.disconnect();for(let e of this.permissionListeners)e(`revoked`,this.permission);return}if(r!==`read`&&r!==`edit`&&r!==`owner`)return;let i=this.permission;if(this.setPermission(r),i!==r){r===`read`&&this.rejectFlushes(Error(`Project permission changed to read-only`));for(let e of this.permissionListeners)e(r,i)}},this.provider.messageHandlers[Mv]=(e,t)=>{ci(t)},this.provider.messageHandlers[Pv]=(e,t)=>{let n={};try{n=Vv(JSON.parse(ci(t)))}catch{}this.authoritativeCompileStates=n,this.notifyCompileStateListeners()},this.provider.messageHandlers[Fv]=(e,t)=>{let n=ci(t),r=ci(t),i=ci(t),a=ci(t),o=ci(t),s=ci(t);if(n===`state`){let e=ri(t)?ci(t):``,n=ri(t)?ci(t):``,r=Number(o);if(!e||!Number.isFinite(r)||r<=Date.now())this.removeFormatLeaseState(i),this.notifyFormatLeaseListeners(null);else{let t={path:i,holderUserId:e,holderName:n,expiresAt:r};this.formatLeaseStatesByPath.set(i,t);let a=this.formatLeaseExpiryTimers.get(i);a!==void 0&&window.clearTimeout(a);let o=window.setTimeout(()=>{let e=this.formatLeaseStatesByPath.get(i);!e||e.expiresAt>Date.now()||(this.removeFormatLeaseState(i),this.notifyFormatLeaseListeners(null))},Math.max(0,r-Date.now())+25);this.formatLeaseExpiryTimers.set(i,o),this.notifyFormatLeaseListeners(t)}return}let c=this.formatLeaseRequests.get(r);c&&(window.clearTimeout(c.timer),this.formatLeaseRequests.delete(r),n===`denied`?c.reject(Error(s||`Format lease request was denied`)):c.resolve({status:n,filePath:i,token:a,expiresAt:Number(o)}))},this.provider.on(`status`,({status:e})=>{e===`disconnected`&&(this.authoritativeCompileStates=null,this.notifyCompileStateListeners(),this.rejectFlushes(Error(`Collaboration connection closed`)),this.rejectFormatLeaseRequests(Error(`Collaboration connection closed`)),this.clearFormatLeaseStates())}),this.updateLocalAwareness()}connect(){this.destroyed||(this.provider.connect(),this.updateLocalAwareness())}getText(e){return this.doc.getText(`source:${e}`)}getUndoManager(e){let t=this.undoManagers.get(e);if(t)return t;let n=new Rc(this.getText(e));return this.undoManagers.set(e,n),n}applyTextEdits(e,t){if(this.permission===`read`)throw Error(`Read-only collaborators cannot edit source files`);let n=this.getText(e),r=0;for(let e of t){if(!Number.isInteger(e.from)||!Number.isInteger(e.to)||e.from<r||e.to<e.from||e.to>n.length)throw RangeError(`Invalid collaborative text edits`);r=e.to}this.doc.transact(()=>{for(let e=t.length-1;e>=0;--e){let r=t[e];r.to>r.from&&n.delete(r.from,r.to-r.from),r.replacement&&n.insert(r.from,r.replacement)}})}get meta(){return this.doc.getMap(`texlite:meta`)}compileStates(){return this.authoritativeCompileStates??Vv(this.meta.get(`compileStates`))}onCompileStates(e){return this.compileStateListeners.add(e),()=>this.compileStateListeners.delete(e)}get synced(){return this.provider.synced}get connected(){return this.provider.wsconnected}get draftReady(){return this.localDraftReady}get currentPermission(){return this.permission}onDraftReady(e){return this.draftListeners.add(e),this.localDraftReady&&e(),()=>this.draftListeners.delete(e)}onPermissionChanged(e){return this.permissionListeners.add(e),()=>this.permissionListeners.delete(e)}onProtocolUpgrade(e){return this.protocolUpgradeListeners.add(e),()=>this.protocolUpgradeListeners.delete(e)}async discardLocalDraft(){return!this.hasOtherWritableDraft&&(await this.persistence.clearData(),this.localDraftReady=!1,this.clearWritableDraftMarkers(),!0)}get hasWritableDraft(){return Uv(this.readWritableDraftMarkers().map(({tabId:e,marker:t})=>({tabId:e,activeAt:t.activeAt})),this.draftTabId,Date.now()).recoverable}get hasOtherWritableDraft(){return Uv(this.readWritableDraftMarkers().map(({tabId:e,marker:t})=>({tabId:e,activeAt:t.activeAt})),this.draftTabId,Date.now()).otherActive}setPermission(e,t=!1){let n=this.permission;if(this.permission=e,e===`read`&&(n!==`read`&&this.rejectFlushes(Error(`Project permission changed to read-only`)),this.destroyUndoManagers(),this.clearFormatLeaseStates()),this.updateLocalAwareness(),t&&n!==e)for(let t of this.permissionListeners)t(e,n)}setActiveFile(e){this.activeFile!==e&&(this.activeFile=e,this.awareness.setLocalStateField(`cursor`,null),this.updateLocalAwareness())}sessions(){let e=[];return this.awareness.getStates().forEach((t,n)=>{let r=t?.user;r&&typeof r.id==`string`&&typeof r.name==`string`&&e.push({clientId:n,userId:r.id,username:typeof r.username==`string`?r.username:r.name,name:r.name,avatarStyle:g(r.avatarStyle)?r.avatarStyle:null,color:typeof r.color==`string`?r.color:`#1677c8`,colorLight:typeof r.colorLight==`string`?r.colorLight:`#1677c833`,permission:r.permission===`owner`||r.permission===`edit`?r.permission:`read`,filePath:typeof t.filePath==`string`?t.filePath:``,editing:!!t.cursor,local:n===this.doc.clientID})}),e.sort((e,t)=>Number(t.local)-Number(e.local)||e.name.localeCompare(t.name))}flush(){let e=this.provider.ws;if(!this.provider.synced||!e||e.readyState!==WebSocket.OPEN)return Promise.reject(Error(`Collaboration connection is unavailable`));let t=Vd(),n=this.draftGeneration,r=Tr();return Z(r,Av),Pr(r,t),new Promise((i,a)=>{let o=window.setTimeout(()=>{this.flushRequests.delete(t),a(Error(`Collaboration save timed out`))},5e3);this.flushRequests.set(t,{resolve:i,reject:a,timer:o,draftGeneration:n}),e.send(Dr(r))})}onFormatLeaseState(e){this.formatLeaseListeners.add(e);for(let t of this.formatLeaseStatesByPath.values())e(t);return()=>this.formatLeaseListeners.delete(e)}formatLeaseStates(){let e=Date.now();for(let[t,n]of this.formatLeaseStatesByPath)n.expiresAt<=e&&this.removeFormatLeaseState(t);return[...this.formatLeaseStatesByPath.values()]}async acquireFormatLease(e){if(this.permission===`read`)throw Error(`Formatting requires write permission`);let t=await this.requestFormatLease(`acquire`,e);if(t.status!==`grant`||!t.token||!Number.isFinite(t.expiresAt))throw Error(`Format lease was not granted`);let n=t.token,r=t.expiresAt,i=!1,a=async()=>{if(i)throw Error(`Format lease has already been released`);let t=await this.requestFormatLease(`renew`,e,n);if(t.status!==`renewed`||!Number.isFinite(t.expiresAt))throw Error(`Format lease renewal failed`);n=t.token||n,r=t.expiresAt};return{path:e,get token(){return n},get expiresAt(){return r},confirm:a,renew:a,release:async()=>{if(i)return;i=!0;let t=this.provider.ws;if(t&&t.readyState===WebSocket.OPEN)try{await this.requestFormatLease(`release`,e,n)}catch{}}}}reconnect(){this.destroyed||(this.rejectFlushes(Error(`Collaboration connection reset`)),this.provider.disconnect(),this.provider.connect(),this.updateLocalAwareness())}destroy(){this.destroyed=!0,this.setOwnDraftActivity(!1),this.stopDraftHeartbeat(),window.removeEventListener(`pagehide`,this.markDraftTabInactive),window.removeEventListener(`pageshow`,this.markDraftTabActive),this.rejectFlushes(Error(`Collaboration connection closed`)),this.provider.destroy(),this.persistence.destroy(),this.draftListeners.clear(),this.protocolUpgradeListeners.clear(),this.compileStateListeners.clear(),this.rejectFormatLeaseRequests(Error(`Collaboration connection closed`)),this.clearFormatLeaseStates(),this.formatLeaseListeners.clear(),this.meta.unobserve(this.metaObserver),this.doc.off(`afterTransaction`,this.localDraftTransactionObserver),this.destroyUndoManagers(),this.doc.destroy()}destroyUndoManagers(){for(let e of this.undoManagers.values())e.destroy();this.undoManagers.clear()}notifyCompileStateListeners(){for(let e of this.compileStateListeners)e()}rejectFlushes(e){for(let t of this.flushRequests.values())window.clearTimeout(t.timer),t.reject(e);this.flushRequests.clear()}requestFormatLease(e,t,n=``){let r=this.provider.ws;if(!this.provider.synced||!r||r.readyState!==WebSocket.OPEN)return Promise.reject(Error(`Collaboration connection is unavailable`));let i=Vd(),a=Tr();return Z(a,Fv),Pr(a,e),Pr(a,i),Pr(a,t),Pr(a,n),new Promise((n,o)=>{let s=window.setTimeout(()=>{if(this.formatLeaseRequests.delete(i),e===`acquire`){let e=this.provider.ws;if(e?.readyState===WebSocket.OPEN){let n=Tr();Z(n,Fv),Pr(n,`cancel`),Pr(n,i),Pr(n,t),Pr(n,``),e.send(Dr(n))}}o(Error(`Format lease request timed out`))},e===`acquire`?Iv:5e3);this.formatLeaseRequests.set(i,{resolve:n,reject:o,timer:s}),r.send(Dr(a))})}rejectFormatLeaseRequests(e){for(let t of this.formatLeaseRequests.values())window.clearTimeout(t.timer),t.reject(e);this.formatLeaseRequests.clear()}clearFormatLeaseStates(){for(let e of this.formatLeaseExpiryTimers.values())window.clearTimeout(e);this.formatLeaseExpiryTimers.clear(),this.formatLeaseStatesByPath.size&&(this.formatLeaseStatesByPath.clear(),this.notifyFormatLeaseListeners(null))}removeFormatLeaseState(e){let t=this.formatLeaseExpiryTimers.get(e);t!==void 0&&window.clearTimeout(t),this.formatLeaseExpiryTimers.delete(e),this.formatLeaseStatesByPath.delete(e)}notifyFormatLeaseListeners(e){for(let t of this.formatLeaseListeners)t(e)}updateLocalAwareness(){let[e,t]=Dv[Math.abs(this.doc.clientID)%Dv.length],n=this.awareness.getLocalState()?.user,r=n&&Object.hasOwn(n,`avatarStyle`)?n.avatarStyle:this.user.avatarStyle;this.awareness.setLocalStateField(`user`,{id:this.user.id,username:this.user.username,name:this.user.displayName,avatarStyle:g(r)?r:null,color:e,colorLight:t,permission:this.permission,sessionId:String(this.doc.clientID)}),this.awareness.setLocalStateField(`filePath`,this.activeFile)}epochStorageKey(){return u(`texlite:collaboration-epoch:${this.user.id}:${this.projectId}`)}writableDraftStoragePrefix(){return`${u(`texlite:collaboration-writable:${this.user.id}:${this.projectId}`)}:`}ownWritableDraftStorageKey(){return`${this.writableDraftStoragePrefix()}${this.draftTabId}`}markWritableDraft(){this.draftGeneration+=1,this.draftUpdatedAt=Date.now(),this.draftMarkerPresent||this.writeOwnWritableDraftMarker(!0),this.startDraftHeartbeat()}clearWritableDraftMarkers(){for(let{key:e}of this.readWritableDraftMarkers())qv(e);this.draftMarkerPresent=!1,this.stopDraftHeartbeat(),qv(this.writableDraftStoragePrefix().slice(0,-1))}clearOwnWritableDraftMarker(e){let t=this.readOwnWritableDraftMarker();t&&Hv(t.generation,this.draftGeneration,e)&&(qv(this.ownWritableDraftStorageKey()),this.draftMarkerPresent=!1,this.stopDraftHeartbeat())}readOwnWritableDraftMarker(){return this.readWritableDraftMarker(this.ownWritableDraftStorageKey())}readWritableDraftMarkers(){let e=this.writableDraftStoragePrefix(),t=[];for(let n of Jv()){if(!n.startsWith(e))continue;let r=this.readWritableDraftMarker(n);r&&t.push({key:n,tabId:n.slice(e.length),marker:r})}return t}readWritableDraftMarker(e){let t=Gv(e);if(!t)return null;try{let n=JSON.parse(t);if(!n||typeof n!=`object`||Array.isArray(n))return null;let r=n,i=Date.now();if(!Number.isInteger(r.generation)||(r.generation??0)<0||typeof r.updatedAt!=`number`||!Number.isFinite(r.updatedAt)||r.updatedAt<=0||i-r.updatedAt>Lv)return qv(e),null;let a=typeof r.activeAt==`number`&&Number.isFinite(r.activeAt)?Math.max(0,r.activeAt):0;return{generation:r.generation,updatedAt:r.updatedAt,activeAt:a}}catch{return qv(e),null}}writeOwnWritableDraftMarker(e){if(!this.draftMarkerPresent&&this.draftUpdatedAt<=0)return;let t={generation:this.draftGeneration,updatedAt:this.draftUpdatedAt||Date.now(),activeAt:e?Date.now():0};Kv(this.ownWritableDraftStorageKey(),JSON.stringify(t)),this.draftMarkerPresent=!0}setOwnDraftActivity(e){this.draftMarkerPresent&&(this.writeOwnWritableDraftMarker(e),e?this.startDraftHeartbeat():this.stopDraftHeartbeat())}resumeOwnDraftActivity(){let e=this.readOwnWritableDraftMarker();e?(this.draftGeneration=Math.max(this.draftGeneration,e.generation),this.draftUpdatedAt=e.updatedAt,this.draftMarkerPresent=!0,this.setOwnDraftActivity(!0)):(this.draftMarkerPresent=!1,this.stopDraftHeartbeat())}startDraftHeartbeat(){this.draftHeartbeatTimer===null&&this.draftMarkerPresent&&(this.draftHeartbeatTimer=window.setInterval(()=>{this.writeOwnWritableDraftMarker(!0)},Rv))}stopDraftHeartbeat(){this.draftHeartbeatTimer!==null&&(window.clearInterval(this.draftHeartbeatTimer),this.draftHeartbeatTimer=null)}};function Gv(e){try{return window.localStorage.getItem(e)}catch{return null}}function Kv(e,t){try{window.localStorage.setItem(e,t)}catch{}}function qv(e){try{window.localStorage.removeItem(e)}catch{}}function Jv(){try{let e=[];for(let t=0;t<window.localStorage.length;t+=1){let n=window.localStorage.key(t);n&&e.push(n)}return e}catch{return[]}}function Yv(e){try{return window.sessionStorage.getItem(e)}catch{return null}}function Xv(e,t){try{window.sessionStorage.setItem(e,t)}catch{}}function Zv(e){let t=Yv(e);if(t)return t;let n=Vd();return Xv(e,n),n}function Qv({projectId:e,user:t,children:n}){let{t:r}=Ne(),i=(0,J.useRef)(t);i.current=t;let[a,o]=(0,J.useState)(null),s=(0,J.useRef)(null),c=(0,J.useRef)(null),l=t.id;return(0,J.useEffect)(()=>{c.current=null;let t=s.current;return(!t||t.projectId!==e||t.userId!==l)&&(t?.collaboration.destroy(),t={projectId:e,userId:l,collaboration:new Wv(e,i.current)},s.current=t),o(t),()=>{let e={};c.current=e,queueMicrotask(()=>{c.current===e&&s.current===t&&(c.current=null,s.current=null,t.collaboration.destroy())})}},[e,l]),!a||a.projectId!==e||a.userId!==l?(0,X.jsx)(`div`,{className:`center-card`,role:`status`,children:r(`common.loading`)}):(0,X.jsx)(J.Fragment,{children:n(a.collaboration)},a.collaboration.doc.guid)}var $v=class{selection;restoreRetained;value;sharedAllowed;initialAllowed;constructor(e,t){this.selection=e,this.restoreRetained=t,this.value={selection:e,run:null,pdf:null},this.sharedAllowed=t,this.initialAllowed=t}get snapshot(){return this.value}get sharedCompletionAllowed(){return this.sharedAllowed}observeRunning(){this.sharedAllowed=!0}hasRun(e){return this.snapshot.run?.identity.runId===e&&this.snapshot.run.outcome!==null}beginCompile(){this.initialAllowed=!1,this.sharedAllowed=!0,this.value={...this.snapshot,run:null}}clean(e){this.initialAllowed=!1,e===`artifacts`&&(this.value={selection:this.selection,run:null,pdf:null})}receiveLatest(e,t){if(e.mainFile!==this.selection.mainFile||(t===`initial`?!this.initialAllowed:!this.sharedCompletionAllowed)||t===`shared`&&(!e.latestRun||this.hasRun(e.latestRun.id)))return null;let n=e.latestRun,r=n?.status===`succeeded`?`succeeded`:n?.log.includes(`Compilation was cancelled.`)?`cancelled`:n?.status===`failed`?`failed`:null;return this.receive(e,n?{identity:{...this.selection,runId:n.id},log:n.log,diagnostics:n.diagnostics,outcome:r}:null,t!==`initial`)}receiveLocal(e){return e.mainFile===this.selection.mainFile?this.receive(e,{identity:{...this.selection,runId:e.runId},log:e.log,diagnostics:e.diagnostics,outcome:e.cancelled?`cancelled`:e.ok?`succeeded`:`failed`},!0,e.skipped):null}receive(e,t,n,r=!1){let i=this.snapshot,a=t?this.hasRun(t.identity.runId):!1,o=i.pdf;if(e.pdfUrl){let t=new URL(e.pdfUrl,`https://texlite.invalid/`).searchParams.get(`run`);if(!t)throw Error(`PDF response is missing its compile run identity`);o={identity:{...this.selection,runId:t},url:e.pdfUrl,compiledAt:e.pdfCompiledAt,sizeBytes:e.pdfSizeBytes,loadingMode:e.pdfLoadingMode??`full`}}else n||(o=null);return this.initialAllowed=!1,this.value={selection:this.selection,run:t,pdf:o},{snapshot:this.snapshot,pdfChanged:i.pdf?.url!==o?.url,focusPdf:n&&t?.outcome===`succeeded`&&!!e.pdfUrl&&(r||!a)}}},ey=(e,t)=>`${e}\0${t}`,ty=e=>e instanceof Error&&e.name===`AbortError`;function ny(e,t){e.current&&(!t||e.current.owner===t)&&(e.current.controller.abort(),e.current=null)}function ry(e){return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof Element&&!!e.closest(`[role="dialog"], [role="alertdialog"], [data-agent-terminal]`)}function iy(e){let{projectId:t,project:n,mainFile:r,initialLatest:i,collaborationSynced:a,pdfVisible:o,sharedState:s}=e,{t:c}=Ne(),l=(0,J.useRef)({...e,t:c});l.current={...e,t:c};let u=(0,J.useRef)(!1),d=(0,J.useRef)(null),f=d.current;(!f||f.selection.projectId!==t||f.selection.mainFile!==r)&&(d.current=new $v({projectId:t,mainFile:r},!f||f.selection.projectId!==t||!f.selection.mainFile));let p=d.current,[m,h]=(0,J.useState)(p.snapshot),[g,_]=(0,J.useState)(null),[v,y]=(0,J.useState)(null),[b,x]=(0,J.useState)([]),[S,C]=(0,J.useState)(null),[w,T]=(0,J.useState)(!1),[E,D]=(0,J.useState)(null),[O,k]=(0,J.useState)(()=>new Set),[A,j]=(0,J.useState)(()=>new Set),[M,N]=(0,J.useState)(``),P=(0,J.useRef)(null),F=(0,J.useRef)(null),ee=(0,J.useRef)(null),te=(0,J.useRef)(null),ne=(0,J.useRef)(null),re=(0,J.useRef)(new Map),ie=(0,J.useRef)(new Map),ae=(0,J.useRef)(new Set),oe=(0,J.useRef)({projectId:t,promise:i});oe.current.projectId!==t&&(oe.current={projectId:t,promise:i});let I=(0,J.useRef)(null),L=(0,J.useRef)(null),R=(0,J.useRef)(()=>void 0),se=()=>l.current.getCurrentMainFile?.()||d.current.selection.mainFile,z=(e,t)=>u.current&&!t?.aborted&&d.current===e&&se()===e.selection.mainFile,ce=ey(t,r),B=m.selection===p.selection,le=O.has(ce),V=E===p,ue=e=>{for(let t of[P,F,ee,te])ny(t,e);for(let t of ae.current)t.owner===e&&(t.controller.abort(),ae.current.delete(t));_(t=>t?.owner===e?null:t),y(t=>t?.owner===e?null:t),T(!1)},de=()=>{L.current=null,I.current=null,x([]),C(null),T(!1),N(``),l.current.onPdfChanged()},fe=async(e,t)=>{if(!z(e))return;let n=t??{owner:e,controller:new AbortController};t||(ny(ee),ee.current=n);let r=e.snapshot.pdf?.url,i=()=>z(e,n.controller.signal)&&e.snapshot.pdf?.url===r;try{let t=await G(`/api/projects/${e.selection.projectId}/compile/artifacts?mainFile=${encodeURIComponent(e.selection.mainFile)}`,{signal:n.controller.signal});i()&&(x(t.artifacts),C(null))}catch(e){!ty(e)&&i()&&(x([]),C(null))}finally{ee.current===n&&(ee.current=null)}},pe=()=>{let e=L.current;e&&(L.current=null,z(e.owner)&&e.owner.snapshot.pdf?.url===e.url&&fe(e.owner))},me=e=>{let t=e.snapshot.pdf?.url;t&&(L.current={owner:e,url:t},(!l.current.pdfVisible||I.current?.owner===e&&I.current.url===t)&&pe())},he=e=>{z(p)&&p.snapshot.pdf?.url===e&&(I.current={owner:p,url:e},L.current?.owner===p&&L.current.url===e&&pe())},ge=(e,t)=>!t||!z(e)?!1:(h(t.snapshot),t.pdfChanged&&l.current.onPdfChanged(),t.focusPdf&&l.current.onCompileSuccess(),!0),_e=(e,t)=>{ue(e),L.current=null,e.clean(t),h(e.snapshot),t===`artifacts`&&(de(),l.current.onPreviewTab(`pdf`)),N(l.current.t(t===`cache`?`editor.cleanCacheComplete`:`editor.cleanArtifactsComplete`))};(0,J.useEffect)(()=>(u.current=!0,()=>{u.current=!1;for(let e of[P,F,ee,te,ne])ny(e);for(let e of[...ae.current,...ie.current.values(),...re.current.values()])e.controller.abort();ae.current.clear(),ie.current.clear(),re.current.clear()}),[]),(0,J.useEffect)(()=>{o||pe()},[o]),(0,J.useEffect)(()=>{h(p.snapshot),de();for(let e of[ie.current,re.current])for(let[n,r]of e)r.owner.selection.projectId!==t&&(r.controller.abort(),e.delete(n));let e=ey(t,``),n=t=>{let n=new Set([...t].filter(t=>t.startsWith(e)));return n.size===t.size?t:n};if(k(n),j(n),ne.current?.owner!==p&&ny(ne),!r)return;if(!p.restoreRetained){l.current.onPreviewTab(`pdf`);let e={owner:p,controller:new AbortController};return l.current.loadOutline(e.controller.signal,r).catch(()=>void 0),()=>{e.controller.abort(),ue(p)}}let i={owner:p,controller:new AbortController};P.current=i,_(i);let a=null,o,s=()=>(o=l.current.sharedState,G(`/api/projects/${t}/compile/latest?mainFile=${encodeURIComponent(r)}`,{signal:i.controller.signal})),c=oe.current.promise;return oe.current.promise=null,(c?c.then(e=>z(p,i.controller.signal)?e.mainFile===r?e:s():null,()=>z(p,i.controller.signal)?s():null):s()).then(e=>{if(e&&z(p,i.controller.signal)&&ge(p,p.receiveLatest(e,`initial`))){if(e.latestRun?.requestedBy&&(e.latestRun.status===`queued`||e.latestRun.status===`running`)){let t={mainFile:r,runId:e.latestRun.id,status:e.latestRun.status,requestedBy:e.latestRun.requestedBy,updatedAt:new Date().toISOString()};l.current.onSharedState(e=>!z(p,i.controller.signal)||e?.mainFile===r&&(e!==o||e.runId===t.runId&&(e.status!==`queued`||t.status===`queued`))?e:t)}e.pdfUrl&&l.current.onPreviewTab(`pdf`)}}).catch(e=>{!ty(e)&&z(p,i.controller.signal)&&l.current.onError(W(e))}).finally(()=>{P.current===i&&(P.current=null),_(e=>e===i?null:e),z(p,i.controller.signal)&&(ae.current.add(i),a=window.setTimeout(()=>{z(p,i.controller.signal)?Promise.all([fe(p,i),l.current.loadOutline(i.controller.signal,r).catch(()=>void 0)]).finally(()=>ae.current.delete(i)):ae.current.delete(i)},0))}),()=>{a!==null&&window.clearTimeout(a),i.controller.abort(),ue(p)}},[p]),(0,J.useEffect)(()=>{s&&s.mainFile===r&&s.status===`cleaned`&&s.cleanMode&&_e(p,s.cleanMode)},[p,s?.runId,s?.status,s?.cleanMode,s?.mainFile]),(0,J.useEffect)(()=>{s?.mainFile===r&&(s.status===`queued`||s.status===`running`)?p.observeRunning():j(e=>{if(!e.has(ce))return e;let t=new Set(e);return t.delete(ce),t})},[p,s?.mainFile,s?.status,s?.runId]),(0,J.useEffect)(()=>{if(!s||s.mainFile!==r||s.status!==`succeeded`&&s.status!==`failed`||P.current?.owner===p||ne.current?.owner===p||V||le||!p.sharedCompletionAllowed||p.hasRun(s.runId))return;let e={owner:p,controller:new AbortController};return ny(F),ny(te),T(!1),F.current=e,y(e),G(`/api/projects/${t}/compile/latest?mainFile=${encodeURIComponent(r)}`,{signal:e.controller.signal}).then(t=>{z(p,e.controller.signal)&&t.latestRun?.id===s.runId&&ge(p,p.receiveLatest(t,`shared`))&&(s.status===`succeeded`&&s.stale&&N(l.current.t(`editor.compileSnapshotStale`)),s.status===`succeeded`&&t.pdfUrl?(l.current.onPreviewTab(`pdf`),me(p)):s.status===`failed`&&l.current.onPreviewTab(t.latestRun.diagnostics.errors.length?`errors`:`log`))}).catch(t=>{!ty(t)&&z(p,e.controller.signal)&&l.current.onError(W(t))}).finally(()=>{F.current===e&&(F.current=null),y(t=>t===e?null:t)}),()=>{e.controller.abort(),F.current===e&&(F.current=null)}},[p,s?.runId,s?.status,s?.mainFile,s?.stale,le,g,V]);let ve=async()=>{if(!n||n.permission===`read`||!a)return;let e=l.current.resolveCompileMainFile?.()||se(),r=ey(t,e),i=l.current.sharedState;if(!e||ie.current.has(r)||i?.mainFile===e&&(i.status===`queued`||i.status===`running`))return;let o=d.current;o.selection.mainFile!==e&&(ue(o),o=new $v({projectId:t,mainFile:e},!1),d.current=o,de()),ue(o),N(``),l.current.onCompileStart(),l.current.onPreviewTab(o.snapshot.pdf?`pdf`:`log`);let s={owner:o,controller:new AbortController};ie.current.set(r,s),k(e=>new Set([...e,r]));try{if(!await l.current.save()||!z(o,s.controller.signal))return;o.beginCompile(),h(o.snapshot);let n=await G(`/api/projects/${t}/compile`,{method:`POST`,signal:s.controller.signal,body:JSON.stringify({mainFile:e})});if(!z(o,s.controller.signal)||!ge(o,o.receiveLocal(n)))return;n.cancelled&&N(l.current.t(`compileControls.cancelled`)),n.skipped&&N(l.current.t(`editor.upToDate`)),n.ok&&n.stale&&N(l.current.t(`editor.compileSnapshotStale`)),n.pdfUrl?(me(o),l.current.onPreviewTab(`pdf`)):l.current.onPreviewTab(n.diagnostics.errors.length?`errors`:`log`)}catch(e){!ty(e)&&z(o,s.controller.signal)&&l.current.onError(W(e))}finally{ie.current.get(r)===s&&(ie.current.delete(r),k(e=>{let t=new Set(e);return t.delete(r),t}),j(e=>{let t=new Set(e);return t.delete(r),t}))}},H=async()=>{if(!n||n.permission===`read`||!a||!z(p))return;let e=ey(t,r);if(!r||re.current.has(e))return;let i={owner:p,controller:new AbortController};re.current.set(e,i),j(t=>new Set([...t,e]));try{!(await G(`/api/projects/${t}/compile/cancel`,{method:`POST`,signal:i.controller.signal,body:JSON.stringify({mainFile:r})})).cancelled&&z(p,i.controller.signal)&&j(t=>{let n=new Set(t);return n.delete(e),n})}catch(t){z(p,i.controller.signal)&&(j(t=>{let n=new Set(t);return n.delete(e),n}),ty(t)||l.current.onError(W(t)))}finally{re.current.get(e)===i&&re.current.delete(e)}},ye=async e=>{if(!n||n.permission===`read`||!a||!z(p)||!r||ne.current||ie.current.has(ce)||s?.mainFile===r&&(s.status===`queued`||s.status===`running`))return;let i={owner:p,controller:new AbortController},o=l.current.sharedState;ne.current=i,D(p),ue(p);try{let n=await G(`/api/projects/${t}/compile/clean`,{method:`POST`,signal:i.controller.signal,body:JSON.stringify({mainFile:r,mode:e})});if(!z(p,i.controller.signal)||n.mainFile!==r)return;l.current.sharedState===o&&l.current.onSharedState(null),_e(p,e)}catch(e){!ty(e)&&z(p,i.controller.signal)&&l.current.onError(W(e))}finally{ne.current===i&&(ne.current=null),D(e=>e===p?null:e)}},be=async e=>{if(!e.viewable||!z(p))return;ny(te);let n={owner:p,controller:new AbortController},i=p.snapshot.pdf?.url;te.current=n,T(!0);try{let a=await G(`/api/projects/${t}/compile/artifacts?mainFile=${encodeURIComponent(r)}&path=${encodeURIComponent(e.path)}`,{signal:n.controller.signal});z(p,n.controller.signal)&&p.snapshot.pdf?.url===i&&C(a)}catch(e){!ty(e)&&z(p,n.controller.signal)&&p.snapshot.pdf?.url===i&&l.current.onError(W(e))}finally{te.current===n&&(te.current=null,T(!1))}};R.current=()=>void ve(),(0,J.useEffect)(()=>{if(!M)return;let e=window.setTimeout(()=>N(``),3e3);return()=>window.clearTimeout(e)},[M,p]),(0,J.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key.toLocaleLowerCase()===`s`&&(e.preventDefault(),!ry(e.target)&&(e.stopPropagation(),e.repeat||R.current()))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[]);let U=B?m:null;return{pdfUrl:U?.pdf?.url??``,pdfCompiledAt:U?.pdf?.compiledAt??null,pdfSizeBytes:U?.pdf?.sizeBytes??null,pdfLoadingMode:U?.pdf?.loadingMode??`full`,pdfLoading:g?.owner===p&&!g.controller.signal.aborted||v?.owner===p&&!v.controller.signal.aborted,compileLog:U?.run?.log??``,compileDiagnostics:U?.run?.diagnostics??null,compileOutcome:U?.run?.outcome??null,artifacts:B?b:[],artifactPreview:B?S:null,artifactLoading:B&&w,editorNotice:B?M:``,localCompiling:le,cancelling:A.has(ce),cleaning:V,pdfDisplayed:he,compile:ve,cancelCompile:H,cleanCompile:ye,viewArtifact:be}}var ay=10485760;function oy(e){return e instanceof Error&&e.name===`AbortError`}function sy(e){let t=e.split(`/`).filter(Boolean);return t.pop(),t.map((e,n)=>t.slice(0,n+1).join(`/`))}function cy(e,t){return!!(e&&t)&&(t===e||t.startsWith(`${e}/`))}function ly(e,t){let n=Tn(e);return n===`binary`||n===`other`||n===`text`&&t===!1?`unsupported`:n}function uy(e,t){let n=ly(e.path,e.textContent);return n===`unsupported`?n:(e.size??0)>10485760||n===`text`&&(e.size??0)>t?`large`:n===`text`?`editor`:n}function dy(e,t){return d(`/api/projects/${e}/file/raw?path=${encodeURIComponent(t)}`)}function fy({projectId:e,site:t,activeFile:n,dirty:r,save:i,onError:a,onProject:o,onActiveFile:s,onActiveMainFile:c}){let{t:l}=Ne(),[u,d]=(0,J.useState)([]),[f,p]=(0,J.useState)(!1),[m,h]=(0,J.useState)(``),[g,_]=(0,J.useState)(null),[v,y]=(0,J.useState)(!1),[b,x]=(0,J.useState)(!1),[S,C]=(0,J.useState)(``),[w,T]=(0,J.useState)(``),[E,D]=(0,J.useState)(null),[O,k]=(0,J.useState)(``),[A,j]=(0,J.useState)(new Set),[M,N]=(0,J.useState)(null),[P,F]=(0,J.useState)(``),[ee,te]=(0,J.useState)(``),[ne,re]=(0,J.useState)(null),[ie,ae]=(0,J.useState)(!1),[oe,I]=(0,J.useState)(null),[L,R]=(0,J.useState)(!1),[se,z]=(0,J.useState)(null),ce=(0,J.useRef)(!1),B=(0,J.useRef)(null),le=(0,J.useRef)(null),V=(0,J.useRef)(null),ue=async(t={})=>{le.current?.abort(),le.current=null;let n=t.signal?null:new AbortController;n&&(le.current=n);try{let r=await G(`/api/projects/${e}/files`,{signal:t.signal??n?.signal});return(!t.isCurrent||t.isCurrent())&&d(r.files),r.files}catch(e){if(!oy(e))throw e;return}finally{n&&le.current===n&&(le.current=null)}},de=async()=>{if(m.trim()&&!m.trim().endsWith(`/`)){T(``);try{await G(`/api/projects/${e}/file`,{method:`POST`,body:JSON.stringify({path:m,content:``})});let t=(await ue())?.find(e=>e.path===m);t&&await _e(t),D(null),j(e=>new Set([...e,...sy(m)])),p(!1),h(``)}catch(e){T(W(e))}}},fe=async()=>{if(!S.trim())return;T(``);let t=E?`${E}/${S.trim()}`:S.trim();try{let n=await G(`/api/projects/${e}/folders`,{method:`POST`,body:JSON.stringify({path:t})});await ue(),j(e=>new Set([...e,...sy(n.path),n.path])),D(n.path),x(!1),C(``)}catch(e){T(W(e))}},pe=async(n,r=new Set,i=E)=>{if(!n.length||ce.current)return;let a=t.maxUploadSizeMB;if(n.find(e=>e.size>a*1024*1024)){z({kind:`error`,message:l(`errors.fileTooLarge`,{size:a})});return}let o=i??``,s=n.map(e=>o?`${o}/${e.name}`:e.name),c=new Map;for(let e of s)c.set(e,(c.get(e)??0)+1);let d=[...c.entries()].filter(([,e])=>e>1).map(([e])=>e);if(d.length){z({kind:`error`,message:l(`errors.duplicateUploadNames`,{files:d.join(`, `)})});return}let f=new Set(u.map(e=>e.path)),p=[...new Set(s.filter(e=>f.has(e)&&!r.has(e)))];if(p.length){z(null),I({files:n,directory:o,collisions:p});return}I(null),B.current!==null&&window.clearTimeout(B.current),B.current=null,z(null),ce.current=!0,R(!0);let m=0;try{let i=new URLSearchParams;o&&i.set(`directory`,o);let a=``;for(let[t,c]of n.entries()){let l=s[t];i.delete(`overwrite`),r.has(l)&&i.set(`overwrite`,`1`);let u=i.toString()?`?${i.toString()}`:``,d=new FormData;d.append(`file`,c);try{z({kind:`uploading`,fileName:c.name,current:t+1,total:n.length});let r=await G(`/api/projects/${e}/upload${u}`,{method:`POST`,body:d});m+=1,typeof r.path==`string`&&En(r.path)&&(a=r.path)}catch(e){if(e instanceof Ae&&e.status===409&&!r.has(l)&&e.code===`FILE_EXISTS`){if(z(null),t>0)try{await ue()}catch{}I({files:n.slice(t),directory:o,collisions:[l]});return}throw e}}let c;try{c=(await ue())?.find(e=>e.path===a&&En(e.path,e.textContent)&&(e.size??0)<=t.maxCollaborativeFileSizeMB*1024*1024)}catch(e){z({kind:`error`,message:l(`editor.uploadSucceededRefreshFailed`,{message:W(e)})});return}c&&await _e(c),z({kind:`success`,count:m}),B.current=window.setTimeout(()=>{z(e=>e?.kind===`success`?null:e),B.current=null},3e3)}catch(e){try{await ue()}catch{}let t=m>0?l(`editor.uploadFailedPartial`,{count:n.length,uploaded:m,total:n.length,message:W(e)}):l(`editor.uploadFailed`,{message:W(e)});z({kind:`error`,message:t})}finally{ce.current=!1,R(!1)}},me=()=>{B.current!==null&&window.clearTimeout(B.current),B.current=null,z(null)},he=async e=>{await pe(Array.from(e.target.files??[])),e.target.value=``},ge=async n=>{V.current?.abort(),V.current=null,y(!1);let r=dy(e,n.path);if(uy(n,t.maxCollaborativeFileSizeMB*1024*1024)===`large`){let e=En(n.path,n.textContent)?Math.min(ay,t.maxCollaborativeFileSizeMB*1024*1024):ay;_({path:n.path,kind:`large`,size:n.size??0,url:r,limitBytes:e});return}let i=ly(n.path,n.textContent);if(i!==`text`){_({path:n.path,kind:i,size:n.size??0,url:r});return}_({path:n.path,kind:i,size:n.size??0,url:r,content:``}),y(!0);let o=new AbortController;V.current=o;try{let e;try{e=await fetch(r,{signal:o.signal})}catch(e){throw Pe(e)}let t=e.headers.get(`content-type`)??``;if(!e.ok){let n=null;try{n=t.includes(`application/json`)?await e.json():await e.text()}catch{}throw new Ae(De(n,e.status),e.status,Se(n))}let i=new Uint8Array(await e.arrayBuffer());if(!Dn(i)){_(e=>e?.path===n.path?{...e,kind:`unsupported`,content:void 0}:e);return}let a=new TextDecoder().decode(i);_(e=>e?.path===n.path?{...e,content:a}:e)}catch(e){oy(e)||(_(null),a(W(e)))}finally{V.current===o&&(V.current=null,y(!1))}},_e=async n=>{if(V.current?.abort(),V.current=null,y(!1),D(null),k(n.path),uy(n,t.maxCollaborativeFileSizeMB*1024*1024)!==`editor`){await ge(n);return}let r=new AbortController;V.current=r;try{if(await G(`/api/projects/${e}/file?path=${encodeURIComponent(n.path)}&validate=1`,{signal:r.signal}),r.signal.aborted||V.current!==r)return;s(n.path)}catch(t){if(r.signal.aborted||V.current!==r||oy(t))return;t instanceof Ae&&t.code===`FILE_CONTENT_INVALID`?(d(e=>e.map(e=>e.path===n.path?{...e,textContent:!1}:e)),_({path:n.path,kind:`unsupported`,size:n.size??0,url:dy(e,n.path)})):a(W(t))}finally{V.current===r&&(V.current=null)}},ve=async(t,n,r)=>{if(!await i())return null;let a=await G(`/api/projects/${e}/path`,{method:`PATCH`,body:JSON.stringify({source:t.path,destinationDirectory:n,destinationName:r})}),l=e=>e===t.path?a.path:e.startsWith(`${t.path}/`)?`${a.path}${e.slice(t.path.length)}`:e;s(e=>l(e)),c(e=>l(e)),D(e=>e&&l(e)),k(e=>e&&l(e));let[u,f]=await Promise.all([G(`/api/projects/${e}/files`),G(`/api/projects/${e}`)]);return d(u.files),o(f.project),j(e=>new Set([...e,...sy(a.path),n].filter(Boolean))),a.path};return(0,J.useEffect)(()=>()=>{le.current?.abort(),V.current?.abort(),B.current!==null&&window.clearTimeout(B.current)},[]),(0,J.useEffect)(()=>{V.current?.abort(),V.current=null,y(!1)},[n]),(0,J.useEffect)(()=>{E!==null&&(V.current?.abort(),V.current=null,y(!1))},[E]),(0,J.useEffect)(()=>{n&&k(n)},[n]),{files:u,setFiles:d,loadFiles:ue,newFileOpen:f,setNewFileOpen:p,newFilePath:m,setNewFilePath:h,resourcePreview:g,setResourcePreview:_,resourcePreviewLoading:v,setResourcePreviewLoading:y,newFolderOpen:b,setNewFolderOpen:x,newFolderName:S,setNewFolderName:C,fileDialogError:w,setFileDialogError:T,selectedFolder:E,setSelectedFolder:D,selectedFile:O,setSelectedFile:k,expandedFolders:A,setExpandedFolders:j,moveEntry:M,setMoveEntry:N,moveName:P,setMoveName:F,moveDestination:ee,setMoveDestination:te,deleteEntry:ne,setDeleteEntry:re,fileDragActive:ie,setFileDragActive:ae,uploadConflict:oe,setUploadConflict:I,uploadingFiles:L,uploadFeedback:se,dismissUploadFeedback:me,directoryEntries:u.filter(e=>e.type===`directory`),visibleEntries:u.filter(e=>sy(e.path).every(e=>A.has(e))),createFile:de,createFolder:fe,uploadFiles:pe,upload:he,openFile:_e,movePath:async()=>{if(!M)return;let e=P.trim();if(e){T(``);try{if(!await ve(M,ee,e))return;N(null),F(``),te(``)}catch(e){T(W(e))}}},movePathToFolder:async(e,t)=>{if(py(e.path)!==t&&(e.type!==`directory`||t!==e.path&&!t.startsWith(`${e.path}/`)))try{await ve(e,t,e.path.split(`/`).at(-1)??e.path)}catch(e){a(W(e))}},removePath:async()=>{if(ne){T(``);try{if(r&&!await i())return;await G(`/api/projects/${e}/file?path=${encodeURIComponent(ne.path)}`,{method:`DELETE`}),re(null)}catch(e){T(W(e))}}}}}function py(e){let t=e.lastIndexOf(`/`);return t<0?``:e.slice(0,t)}function my({active:e,harperEnabled:t=!0,projectId:n,activeFile:r,content:i,dictionaryWords:a,additionalIssues:o=[],additionalIssuesReady:s=!0}){let[c,l]=(0,J.useState)([]),[u,d]=(0,J.useState)(``),[p,m]=(0,J.useState)(``),[h,g]=(0,J.useState)(0),[_,v]=(0,J.useState)(null),[y,b]=(0,J.useState)(null),[x,S]=(0,J.useState)(!1),[C,w]=(0,J.useState)(0),T=(0,J.useRef)(0),E=(0,J.useRef)(!1),D=(0,J.useRef)(!1),O=(0,J.useRef)(i),k=(0,J.useRef)(r),A=(0,J.useRef)(0);O.current=i,k.current=r,D.current=x,(0,J.useEffect)(()=>{l([]),d(``),m(``),v(null),b(null),S(!1)},[r,a,t]),(0,J.useEffect)(()=>{b(null),S(!1)},[n]),(0,J.useEffect)(()=>{let o=++T.current;if(!e||!r){l([]),d(``),m(``),v(null);return}if(!t||y){l([]),d(``),m(``);return}let s=i,c=r,u=!1,p=window.setTimeout(()=>{b(null),(async()=>{try{let{lintLatex:e,isHarperLintSupersededError:t}=await f(async()=>{let{lintLatex:e,isHarperLintSupersededError:t}=await import(`./spellCheck-DiNvmZKv.js`);return{lintLatex:e,isHarperLintSupersededError:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]),import.meta.url);if(u||o!==T.current||O.current!==s||k.current!==c)return;let r;try{r=await e(n,c,s,a)}catch(e){if(t(e))return;throw e}if(u||o!==T.current||O.current!==s||k.current!==c)return;E.current=!1,S(!1),l(r),d(s),m(c),g(0),v(null)}catch(e){if(u||o!==T.current||O.current!==s||k.current!==c)return;l([]),d(``),m(``),b(e instanceof Error?e.message:String(e));let t=E.current;E.current=!1,S(t?D.current:!1)}})()},700);return()=>{u=!0,window.clearTimeout(p)}},[e,t,n,r,i,a,C,y]),(0,J.useEffect)(()=>{if(!y||!e||!t)return;let n=!1,r=()=>{n||(n=!0,E.current=!0,b(null),w(e=>e+1))},i=window.setTimeout(r,15e3);return window.addEventListener(`online`,r,{once:!0}),()=>{window.clearTimeout(i),window.removeEventListener(`online`,r)}},[y,e,t]);let j=t&&e&&p===r&&u===i,M=(0,J.useMemo)(()=>{if(!e)return[];let t=[...j?c:[],...o].sort((e,t)=>e.from-t.from||e.to-t.to),n=new Set;return t.filter(e=>{let t=`${e.from}:${e.to}:${e.kind}:${e.message}`;return!n.has(t)&&(n.add(t),!0)})},[e,o,j,c]),N=(0,J.useMemo)(()=>e&&(!t||j)&&s?{total:M.length,unique:new Set(M.map(e=>`${e.kind}:${e.word.toLocaleLowerCase(`en-US`)}`)).size}:null,[e,s,t,j,M]);return(0,J.useEffect)(()=>{g(e=>M.length?Math.min(e,M.length-1):0)},[M]),{issues:M,jump:e?_:null,index:h,summary:N,jumpToIssue:e=>{if(!M.length)return;let t=Math.max(0,Math.min(e,M.length-1)),n=M[t];g(t),v({from:n.from,to:n.to,nonce:++A.current})},error:e&&t&&!x?y:null,nativeFallback:e&&t&&!!y,retry:()=>{E.current=!1,b(null),S(!1),w(e=>e+1)},dismissError:()=>{E.current=!1,S(!0)}}}function hy({active:e,projectId:t,activeFile:n,content:r}){let[i,a]=(0,J.useState)([]),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)(null),[p,m]=(0,J.useState)(!1),[h,g]=(0,J.useState)(0),_=(0,J.useRef)(0),v=(0,J.useRef)(r),y=(0,J.useRef)(n);v.current=r,y.current=n,(0,J.useEffect)(()=>{a([]),s(``),l(``),d(null),m(!1)},[t,n]),(0,J.useEffect)(()=>{let i=++_.current;if(!e||!n){a([]),s(``),l(``);return}let o=r,c=n,u=!1,p=window.setTimeout(()=>{(async()=>{try{let{lintChktex:e,isChktexLintSupersededError:n}=await f(async()=>{let{lintChktex:e,isChktexLintSupersededError:t}=await import(`./chktex-Dm6IIkcR.js`);return{lintChktex:e,isChktexLintSupersededError:t}},__vite__mapDeps([9,1,2,3,4,5,6,7,8]),import.meta.url);if(u||i!==_.current||v.current!==o||y.current!==c)return;let r;try{r=await e(t,c,o)}catch(e){if(n(e))return;throw e}if(u||i!==_.current||v.current!==o||y.current!==c)return;a(r),s(o),l(c),d(null),m(!1)}catch(e){if(u||i!==_.current||v.current!==o||y.current!==c)return;a([]),s(``),l(``),d(e instanceof Error?e.message:String(e))}})()},2e3);return()=>{u=!0,window.clearTimeout(p)}},[e,t,n,r,h]);let b=e&&c===n&&o===r;return{issues:b?i:[],checked:b,error:e&&!p?u:null,retry:()=>{d(null),m(!1),g(e=>e+1)},dismissError:()=>m(!0)}}function gy(e){return e instanceof Error&&e.name===`AbortError`}function _y(e,t){return/\.tex$/i.test(e)&&/\.tex$/i.test(t)}function vy({projectId:e,mainFile:t,activeFile:n,onOpenSourceFile:r,onError:i,onShowPdf:a,onShowEditor:o}){let[s,c]=(0,J.useState)(null),[l,u]=(0,J.useState)(null),[d,f]=(0,J.useState)(null),p=(0,J.useRef)(null),m=(0,J.useRef)(0),h=(0,J.useRef)(n),g=(0,J.useRef)(r),_=(0,J.useRef)(i),v=(0,J.useRef)(a),y=(0,J.useRef)(o);h.current=n,g.current=r,_.current=i,v.current=a,y.current=o,(0,J.useEffect)(()=>(p.current?.abort(),p.current=null,c(null),u(null),f(null),()=>p.current?.abort()),[e,t]);let b=(e,t,n)=>{f({path:e,line:t,column:n,nonce:++m.current}),g.current(e)},x=async(n,r,i,a={})=>{if(!_y(n,t))return;p.current?.abort();let o=new AbortController;p.current=o;try{let a=await G(`/api/projects/${e}/sync/pdf?mainFile=${encodeURIComponent(t)}&path=${encodeURIComponent(n)}&line=${r}&column=${i}`,{signal:o.signal});if(p.current!==o||!a)return;c({...a,nonce:++m.current}),v.current()}catch(e){!gy(e)&&!a.silent&&_.current(W(e))}finally{p.current===o&&(p.current=null)}},S=async(n,r,i)=>{let a=h.current;p.current?.abort();let o=new AbortController;p.current=o;try{let s=await G(`/api/projects/${e}/sync/source?mainFile=${encodeURIComponent(t)}&page=${n}&x=${r}&y=${i}`,{signal:o.signal});if(p.current!==o||h.current!==a)return;y.current(),b(s.path,s.line,s.column)}catch(e){gy(e)||_.current(W(e))}finally{p.current===o&&(p.current=null)}};return{pdfTarget:s,pdfViewport:l,sourceJump:d,setPdfViewport:u,resetPdfViewport:()=>u(null),clearPdfViewport:()=>{p.current?.abort(),p.current=null,u(null),c(null)},jumpToSource:b,syncSourceToPdf:x,syncPdfToSource:S,syncVisiblePdfToSource:()=>{l&&S(l.page,l.x,l.y)}}}function yy(e,t){return u(`texlite.workspaceLayout:${encodeURIComponent(e)}:${encodeURIComponent(t)}`)}function by(e,t){try{let n=window.localStorage.getItem(yy(e,t));if(n===`editor-pdf`||n===`editor-only`||n===`pdf-only`)return n}catch{}return`editor-pdf`}function xy(e,t){let[n,r]=(0,J.useState)(()=>by(e,t));return(0,J.useEffect)(()=>{r(by(e,t))},[e,t]),{workspaceLayout:n,setWorkspaceLayout:n=>{r(n);try{window.localStorage.setItem(yy(e,t),n)}catch{}}}}function Sy(e,t){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let n=Object.entries(e);return n.length===t.length&&n.every(([e,n])=>t.includes(e)&&typeof n==`number`&&Number.isFinite(n)&&n>=0&&n<=100)&&Math.abs(n.reduce((e,[,t])=>e+t,0)-100)<.1}function Cy(e,t,n=()=>window.localStorage){let r=`react-resizable-panels:${e}:${t.join(`:`)}`;return{getItem(e){if(e!==r)return null;try{let e=n().getItem(r);return e&&Sy(JSON.parse(e),t)?e:null}catch{return null}},setItem(e,t){if(e===r)try{n().setItem(r,t)}catch{}}}}function wy(e,t,n){let r=(0,J.useMemo)(()=>[...e?[`files`,`source`]:[],...t?[`preview`]:[],...n?[`context`]:[]],[e,t,n]),i=u(`texlite-workspace-layout`);return Cm({id:i,panelIds:r,storage:(0,J.useMemo)(()=>Cy(i,r),[i,r])})}function Ty(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function Ey(e){let t=dd(fd(e));for(let e of t.matchAll(/\\documentclass(?![A-Za-z@])\s*(?:\[[^\]]*\]\s*)?\{/g))if(e.index!==void 0&&!Ty(t,e.index))return!0;return!1}function Dy({sessions:e,status:t}){let{t:n}=Ne(),[r,i]=(0,J.useState)(!1),a=Math.max(0,e.length-5),o=r&&a>0,s=o?e:e.slice(0,5);return(0,J.useEffect)(()=>{e.length<=5&&i(!1)},[e.length]),e.length<=1?null:(0,X.jsxs)(`div`,{className:`collaboration-presence collaboration-${t}`,children:[(0,X.jsx)(`span`,{className:`collaboration-status-dot`,"data-tooltip":n(`editor.collaboration.${t}`),"aria-label":n(`editor.collaboration.${t}`)}),(0,X.jsxs)(`div`,{className:`collaboration-avatars`,"aria-label":n(`editor.collaboration.activeSessions`,{count:e.length}),children:[s.map(e=>{let t=e.editing?n(`editor.collaboration.editing`):n(`editor.collaboration.viewing`),r=e.permission===`read`?n(`common.readOnly`):n(`common.readWrite`),i=n(`editor.collaboration.sessionTooltip`,{name:e.name,username:e.username,file:e.filePath||n(`editor.collaboration.joining`),activity:t,permission:r});return(0,X.jsxs)(`span`,{className:`collaboration-avatar${e.editing?` editing`:``}${e.local?` local`:``}`,style:{"--session-color":e.color},"aria-label":i,tabIndex:0,children:[(0,X.jsx)(he,{userId:e.userId,name:e.name,username:e.username,avatarStyle:e.avatarStyle,className:`collaboration-avatar-face`}),(0,X.jsxs)(`span`,{className:`collaboration-avatar-tooltip`,role:`tooltip`,children:[(0,X.jsx)(`strong`,{children:e.name}),(0,X.jsxs)(`span`,{children:[`@`,e.username]}),(0,X.jsxs)(`small`,{children:[e.filePath||n(`editor.collaboration.joining`),` · `,t,` · `,r]})]})]},e.clientId)}),a>0&&(0,X.jsx)(`button`,{type:`button`,className:`collaboration-avatar collaboration-avatar-overflow`,"aria-expanded":o,"aria-label":o?n(`editor.collaboration.showFewerSessions`):n(`editor.collaboration.showMoreSessions`,{count:a}),title:o?n(`editor.collaboration.showFewerSessions`):n(`editor.collaboration.showMoreSessions`,{count:a}),onClick:()=>i(e=>!e),children:o?`−`:`+${a}`})]})]})}function Oy({value:e,onChange:t}){let{t:n}=Ne(),[r,i]=(0,J.useState)(!1),a=(0,J.useRef)(null),o=[{value:`editor-pdf`,icon:Et},{value:`editor-only`,icon:un},{value:`pdf-only`,icon:fn}];return(0,J.useEffect)(()=>{if(!r)return;let e=e=>{a.current?.contains(e.target)||i(!1)},t=e=>{e.key===`Escape`&&i(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[r]),(0,X.jsxs)(`div`,{className:`layout-menu`,ref:a,children:[(0,X.jsxs)(`button`,{type:`button`,className:`layout-trigger${r?` active`:``}`,"aria-haspopup":`menu`,"aria-expanded":r,title:n(`editor.layout.current`,{layout:n(`editor.layout.${e}.name`)}),onClick:()=>i(e=>!e),children:[(0,X.jsx)(Et,{size:15}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`small`,{children:n(`editor.layout.label`)}),n(`editor.layout.${e}.name`)]}),(0,X.jsx)(V,{size:13})]}),r&&(0,X.jsxs)(`div`,{className:`layout-popover`,role:`menu`,"aria-label":n(`editor.layout.label`),children:[(0,X.jsx)(`div`,{className:`layout-popover-title`,children:n(`editor.layout.choose`)}),o.map(r=>{let a=r.icon,o=r.value===e;return(0,X.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":o,className:`layout-option${o?` selected`:``}`,onClick:()=>{t(r.value),i(!1)},children:[(0,X.jsx)(a,{size:19}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{children:n(`editor.layout.${r.value}.name`)}),(0,X.jsx)(`small`,{children:n(`editor.layout.${r.value}.description`)})]}),o&&(0,X.jsx)(ve,{size:16})]},r.value)})]})]})}function ky({name:e}){let t=(0,J.useRef)(null),n=(0,J.useRef)(null),[r,i]=(0,J.useState)(0);(0,J.useLayoutEffect)(()=>{let e=t.current,r=n.current,a=!1,o=()=>{a||i(Math.max(0,r.scrollWidth-e.clientWidth))};o();let s=new ResizeObserver(o);return s.observe(e),s.observe(r),document.fonts?.ready.then(o),()=>{a=!0,s.disconnect()}},[e]);let a=r>1;return(0,X.jsx)(`strong`,{ref:t,className:`workspace-project-title`,"data-overflow":a?`true`:void 0,tabIndex:a?0:void 0,style:{"--project-title-offset":`${-r}px`,"--project-title-duration":`${Math.max(4,r/32+1.5)}s`},children:(0,X.jsx)(`span`,{ref:n,children:e})})}function Ay({site:e,project:t,activeFile:n,saveStateLabel:r,editorPreferences:i,activeSessions:a,collaborationStatus:o,reconnectCollaboration:s,protocolUpgradeRequired:c,showEditor:l,filesCollapsed:u,toggleFilesPanel:f,workspaceLayout:p,changeWorkspaceLayout:m,onBack:h,onShare:g,showCitationLibrary:_,citationLibraryOpen:v,onCitationLibrary:x,onHistory:S,onGit:C,canManageGit:w,formatting:T,readOnly:E,collaborationSynced:O,onToggleComments:k,commentsOpen:A,unresolvedCommentCount:M,onToggleSettings:N,settingsOpen:P,compileBusy:F,sharedCompiling:ee,localCompiling:te,cancelling:re,onCompile:ie,onCancelCompile:oe,agentTerminal:I}){let{t:L}=Ne(),{showExecutionReminder:R}=ae();return(0,X.jsxs)(`header`,{className:`editor-topbar`,children:[(0,X.jsx)(`button`,{className:`back`,title:L(`editor.backToProjects`),"aria-label":L(`editor.backToProjects`),onClick:h,children:(0,X.jsx)(ue,{size:18})}),(0,X.jsx)(`a`,{className:`brand-link compact-brand-link`,href:d(`/`),"aria-label":e.siteName,onClick:e=>{e.preventDefault(),h()},children:(0,X.jsx)(ke,{siteName:e.siteName,compact:!0})}),(0,X.jsxs)(`div`,{className:`project-heading`,children:[(0,X.jsx)(ky,{name:t.name}),(0,X.jsxs)(`small`,{children:[n,` · `,r]})]}),i.vimMode&&(0,X.jsxs)(`span`,{className:`vim-status-badge`,title:L(`editor.vimOnHint`),children:[(0,X.jsx)(qt,{size:14}),L(`editor.vimOn`)]}),(0,X.jsx)(Dy,{sessions:a,status:o}),o===`disconnected`&&!c&&(0,X.jsxs)(`div`,{className:`collaboration-recovery`,role:`status`,children:[(0,X.jsx)(`span`,{children:L(`editor.collaboration.disconnected`)}),(0,X.jsx)(`button`,{type:`button`,onClick:s,children:L(`editor.collaboration.reconnect`)})]}),(0,X.jsxs)(`div`,{className:`editor-actions`,children:[l&&(0,X.jsxs)(`button`,{className:u?``:`active`,onClick:f,children:[u?(0,X.jsx)(cn,{size:15}):(0,X.jsx)(on,{size:15}),L(`common.files`)]}),(0,X.jsx)(Oy,{value:p,onChange:m}),(0,X.jsxs)(`button`,{type:`button`,className:`share-action`,"aria-label":t.sharedMemberCount?`${L(`projectSettings.share`)} (${t.sharedMemberCount})`:L(`projectSettings.share`),onClick:g,children:[(0,X.jsx)(y,{size:15}),(0,X.jsx)(`span`,{children:L(`projectSettings.share`)}),(t.sharedMemberCount??0)>0&&(0,X.jsx)(`sup`,{className:`share-action-count`,children:t.sharedMemberCount})]}),_&&(0,X.jsxs)(`button`,{className:v?`active`:``,onClick:x,children:[(0,X.jsx)(ne,{size:15}),L(`citationLibrary.title`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`snapshots-action`,title:L(`history.projectSnapshots`),onClick:S,children:[(0,X.jsx)(kt,{size:15}),L(`history.projectSnapshotsButton`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`comments-action${A?` active`:``}`,title:L(`editor.commentsAll`),"aria-label":M>0?`${L(`common.comments`)} (${M})`:L(`common.comments`),onClick:k,children:[(0,X.jsx)(j,{size:15}),(0,X.jsx)(`span`,{children:L(`common.comments`)}),M>0&&(0,X.jsx)(`sup`,{className:`comments-action-count`,children:M})]}),(0,X.jsxs)(`button`,{className:`git-action`,title:L(w?`git.title`:`git.ownerOnly`),disabled:!w,onClick:C,children:[(0,X.jsx)(b,{size:15}),`Git`]}),I&&(0,X.jsxs)(`button`,{type:`button`,className:I.open?`active`:``,"aria-expanded":I.open,"aria-label":R&&I.activeCount>0?`${L(`agents.terminal`)}: ${L(`agents.activeCount`,{count:I.activeCount})}`:L(`agents.terminal`),onClick:I.toggle,children:[(0,X.jsx)(_e,{size:15}),(0,X.jsx)(`span`,{children:L(`agents.terminal`)}),R&&I.activeCount>0&&(0,X.jsx)(`sup`,{className:`agent-active-count`,"aria-label":L(`agents.activeCount`,{count:I.activeCount}),children:I.activeCount})]}),(0,X.jsxs)(`button`,{className:P?`active`:``,onClick:N,children:[(0,X.jsx)(bn,{size:15}),L(`common.settings`)]}),ee||te?(0,X.jsxs)(`button`,{className:`compile cancel-compile`,title:L(`compileControls.cancel`),onClick:oe,disabled:re||T||E||!O,children:[re?(0,X.jsx)(Re,{className:`spin`,size:15}):(0,X.jsx)(D,{size:15}),L(re?`compileControls.cancelling`:`compileControls.cancel`)]}):(0,X.jsxs)(`button`,{className:`compile`,title:L(`editor.compileShortcut`),onClick:ie,disabled:F||T||E||!O,children:[F?(0,X.jsx)(Re,{className:`spin`,size:15}):(0,X.jsx)(mn,{size:15}),L(`editor.compile`,{engine:t.engine})]})]})]})}function jy(e,t,n){return e===`connected`?t:e===`disconnected`&&n?`editor.offlineDraft`:`editor.collaboration.${e}`}function My(e){return`${e.path}\u0000${e.line}`}function Ny(e){let t=[],n=[];for(let r of e){for(;n.length&&n.at(-1).level>=r.level;)n.pop();let e=n.at(-1);e&&(t[e.index].hasChildren=!0),t.push({item:r,key:My(r),ancestorKeys:n.map(({index:e})=>t[e].key),hasChildren:!1}),n.push({level:r.level,index:t.length-1})}return t}function Py(e,t){return e.filter(e=>!e.ancestorKeys.some(e=>t.has(e)))}var Fy=e=>e.path,Iy=(e,t)=>t===e||t.startsWith(`${e}/`),Ly=`application/x-texlite-project-path`,Ry=`texlite-path:`;function zy({project:e,filesPanel:t,visibleEntries:n,deletedPath:r=null,activeFile:i,activeMainFile:a,selectedFile:o,selectedFolder:s,expandedFolders:c,fileDragActive:l,uploadingFiles:u,uploadFeedback:f,readOnly:p,formatting:m,canFormat:h,activeFormatLease:g,collaborationSynced:_,editorFontSize:v,outline:y,sourceCursorStore:b,wordCountBusy:x,hasSelection:C,hasFormatSelection:E,uploadInput:O,setSelectedFolder:A,setExpandedFolders:j,setMoveEntry:M,setMoveName:N,setMoveDestination:F,setDeleteEntry:ee,setFileDialogError:te,setNewFolderName:ne,setNewFolderOpen:re,setNewFilePath:ae,setNewFileOpen:I,setQuickOpen:L,setFileDragActive:R,dismissUploadFeedback:se,setFilesCollapsed:z,uploadFiles:ce,upload:ue,openFile:de,movePathToFolder:pe,onError:me,onFormatFile:he,onFormatSelection:_e,jumpToSource:ve,syncSourceToPdf:H,onWordCount:be}){let{t:U}=Ne(),[xe,Se]=(0,J.useState)(!1),[W,G]=(0,J.useState)(null),[Ce,we]=(0,J.useState)(null),{entries:Te,finishExit:Ee}=oe(n,{scopeKey:JSON.stringify([e.id,[...c].sort()]),deletedKey:r,keyOf:Fy,contains:Iy,duration:180}),De=(0,J.useRef)(0),Oe=(e,t)=>Hy(e.path)!==t&&(e.type!==`directory`||t!==e.path&&!t.startsWith(`${e.path}/`)),ke=()=>{G(null),we(null)};return(0,X.jsx)(Em,{id:`files`,panelRef:t,defaultSize:`16%`,minSize:`12%`,maxSize:`30%`,collapsible:!0,collapsedSize:`0%`,onResize:e=>z(e.asPercentage===0),children:(0,X.jsxs)(`aside`,{className:`left-panel`,children:[(0,X.jsxs)(`section`,{className:`files-panel${l?` drop-active`:``}`,onDragEnter:e=>{Vy(e.dataTransfer)?e.preventDefault():e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),!p&&!u&&R(!0))},onDragOver:e=>{Vy(e.dataTransfer)?(e.preventDefault(),e.dataTransfer.dropEffect=`move`):e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=p||u?`none`:`copy`)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||R(!1)},onDrop:e=>{if(Vy(e.dataTransfer)){e.preventDefault(),e.stopPropagation();return}if(e.preventDefault(),R(!1),p||u)return;let t=Array.from(e.dataTransfer.files);By(e.dataTransfer)||t.length===0?me(U(`editor.dropFoldersUnsupported`)):ce(t)},children:[(0,X.jsxs)(`div`,{className:`panel-title`,children:[(0,X.jsx)(`button`,{className:`file-size-toggle`,type:`button`,"aria-pressed":xe,title:U(xe?`editor.hideFileSizes`:`editor.showFileSizes`),onClick:()=>Se(e=>!e),children:U(`common.files`)}),(0,X.jsxs)(`span`,{className:`file-tools`,children:[(0,X.jsx)(`button`,{type:`button`,"aria-label":U(`navigation.quickOpen`),title:`${U(`navigation.quickOpen`)} (Ctrl/Cmd+P)`,onClick:()=>L(!0),children:(0,X.jsx)(P,{size:15})}),!p&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,disabled:u,"aria-label":U(`editor.uploadAttachment`),title:U(`editor.uploadTo`,{folder:s||U(`editor.projectRoot`)}),onClick:()=>O.current?.click(),children:(0,X.jsx)(S,{size:15})}),(0,X.jsx)(`button`,{type:`button`,"aria-label":U(`editor.newFolder`),title:U(`editor.newFolder`),onClick:()=>{ne(``),re(!0)},children:(0,X.jsx)(w,{size:15})}),(0,X.jsx)(`button`,{type:`button`,"aria-label":U(`editor.newFile`),title:U(`editor.newFile`),onClick:()=>{ae(s?`${s}/`:``),I(!0)},children:(0,X.jsx)(Lt,{size:15})}),(0,X.jsx)(`input`,{ref:O,type:`file`,multiple:!0,hidden:!0,onChange:e=>void ue(e)})]})]})]}),f&&(0,X.jsxs)(`div`,{className:`file-upload-feedback ${f.kind}`,role:f.kind===`error`?`alert`:`status`,"aria-live":f.kind===`error`?`assertive`:`polite`,"aria-busy":f.kind===`uploading`,children:[f.kind===`uploading`?(0,X.jsx)(Re,{className:`spin`,size:14}):f.kind===`success`?(0,X.jsx)(ye,{size:14}):(0,X.jsx)(T,{size:14}),(0,X.jsxs)(`span`,{className:`file-upload-feedback-text`,children:[f.kind===`uploading`&&U(`editor.uploadingFile`,{file:f.fileName,current:f.current,total:f.total}),f.kind===`success`&&U(`editor.uploadSucceeded`,{count:f.count}),f.kind===`error`&&f.message]}),f.kind!==`uploading`&&(0,X.jsx)(`button`,{type:`button`,className:`file-upload-feedback-dismiss`,"aria-label":U(`common.close`),title:U(`common.close`),onClick:se,children:(0,X.jsx)(D,{size:13})})]}),l&&(0,X.jsxs)(`div`,{className:`file-drop-overlay`,children:[(0,X.jsx)(S,{size:24}),(0,X.jsx)(`strong`,{children:U(`editor.dropFiles`)}),(0,X.jsx)(`span`,{children:U(`editor.uploadTo`,{folder:s||U(`editor.projectRoot`)})})]}),(0,X.jsx)(`div`,{className:`file-list${s===null?``:` folder-selected`}${Ce===``?` root-drop-target`:``}`,style:{fontSize:`${v}px`},onDragOver:e=>{(W||Vy(e.dataTransfer))&&(e.preventDefault(),e.stopPropagation(),W&&(Oe(W,``)?(e.dataTransfer.dropEffect=`move`,we(``)):e.dataTransfer.dropEffect=`none`))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||we(e=>e===``?null:e)},onDrop:e=>{if(!W&&!Vy(e.dataTransfer)||(e.preventDefault(),e.stopPropagation(),!W))return;let t=W;ke(),Oe(t,``)&&pe(t,``)},children:Te.map(({item:t,removeAt:n})=>{let r=t.path.split(`/`).length-1,i=t.path.split(`/`).at(-1),a=c.has(t.path),l=e.mainFile===t.path,u=t.path!==e.mainFile&&!e.mainFile.startsWith(`${t.path}/`),f={ref:n===null?void 0:le,inert:n!==null||void 0,"aria-hidden":n!==null||void 0,"data-deletion-exit":n!==null||void 0,onAnimationEnd:e=>{e.target===e.currentTarget&&n!==null&&Ee(t.path)}};return t.type===`directory`?(0,J.createElement)(`div`,{...f,className:`file-entry folder-entry${s===t.path?` selected`:``}${Ce===t.path?` move-drop-target`:``}`,style:{paddingLeft:`${r*13+5}px`},key:t.path,onDragOver:e=>{(W||Vy(e.dataTransfer))&&(e.preventDefault(),e.stopPropagation(),W&&(Oe(W,t.path)?(e.dataTransfer.dropEffect=`move`,we(t.path)):e.dataTransfer.dropEffect=`none`))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||we(e=>e===t.path?null:e)},onDrop:e=>{if(!W&&!Vy(e.dataTransfer)||(e.preventDefault(),e.stopPropagation(),!W))return;let n=W;ke(),Oe(n,t.path)&&pe(n,t.path)}},(0,X.jsxs)(`button`,{type:`button`,className:`file-entry-main`,onClick:()=>{A(t.path),j(e=>{let n=new Set(e);return n.has(t.path)?n.delete(t.path):n.add(t.path),n})},children:[a?(0,X.jsx)(V,{size:13}):(0,X.jsx)(fe,{size:13}),(0,X.jsx)(B,{size:14}),(0,X.jsx)(`span`,{children:i})]}),!p&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,className:`file-entry-action`,title:U(`editor.move`),"aria-label":U(`editor.move`),onClick:()=>{M(t),N(i??``),F(``)},children:(0,X.jsx)(tn,{size:13})}),u&&(0,X.jsx)(`button`,{type:`button`,className:`file-entry-action danger-text`,title:U(`editor.deletePath`),"aria-label":U(`editor.deletePath`),onClick:()=>{ee(t),te(``)},children:(0,X.jsx)(k,{size:13})})]})):(0,J.createElement)(`div`,{...f,className:`file-entry${s===null&&o===t.path?` active`:``}${W?.path===t.path?` move-drag-source`:``}`,style:{paddingLeft:`${r*13+18}px`},key:t.path},(0,X.jsxs)(`button`,{type:`button`,className:`file-entry-main`,draggable:!p,onDragStart:e=>{De.current=Date.now()+500,Uy(e,t,G)},onDragEnd:ke,onClick:()=>{De.current>Date.now()?De.current=0:de(t)},children:[(0,X.jsx)(Vn,{path:t.path}),(0,X.jsx)(`span`,{children:i}),l&&(0,X.jsx)(`small`,{children:U(`editor.currentMainShort`)})]}),xe&&typeof t.size==`number`&&(0,X.jsx)(`span`,{className:`file-entry-size`,children:ge(t.size)}),!p&&(0,X.jsx)(`button`,{type:`button`,className:`file-entry-action`,title:U(`editor.move`),"aria-label":U(`editor.move`),onClick:()=>{M(t),N(i??``),F(``)},children:(0,X.jsx)(tn,{size:13})}),(0,X.jsx)(`a`,{className:`file-entry-action`,href:d(`/api/projects/${e.id}/file/raw?path=${encodeURIComponent(t.path)}&download=1`),download:i,draggable:!1,title:U(`editor.downloadResource`),"aria-label":U(`editor.downloadResource`),onClick:e=>e.stopPropagation(),children:(0,X.jsx)(ie,{size:13})}),!p&&u&&(0,X.jsx)(`button`,{type:`button`,className:`file-entry-action danger-text`,title:U(`editor.deletePath`),"aria-label":U(`editor.deletePath`),onClick:()=>{ee(t),te(``)},children:(0,X.jsx)(k,{size:13})}))})}),!p&&h&&(0,X.jsxs)(`div`,{className:`file-format-footer`,role:`group`,"aria-label":U(`editor.format`),"aria-busy":m,children:[(0,X.jsxs)(`div`,{className:`file-format-label`,children:[(0,X.jsx)(Sn,{size:13}),U(`editor.format`)]}),(0,X.jsxs)(`div`,{className:`file-format-actions`,children:[(0,X.jsx)(`button`,{className:E?``:`active`,type:`button`,title:U(`editor.formatFileHint`),onMouseDown:e=>e.preventDefault(),onClick:he,disabled:m||g||!_,children:U(`editor.formatFile`)}),(0,X.jsx)(`button`,{className:E?`active`:``,type:`button`,title:U(E?`editor.formatSelection`:`editor.formatSelectionHint`),onMouseDown:e=>e.preventDefault(),onClick:_e,disabled:m||g||!_||!E,children:U(`editor.formatSelected`)})]})]})]}),(0,X.jsx)(Wy,{outline:y,activeFile:i,activeMainFile:a,sourceCursorStore:b,wordCountBusy:x,hasSelection:C,jumpToSource:ve,syncSourceToPdf:H,onWordCount:be})]})})}function By(e){return Array.from(e.items).some(e=>e.webkitGetAsEntry?.()?.isDirectory===!0)}function Vy(e){return Array.from(e.types).includes(Ly)?!0:Array.from(e.types).includes(`text/plain`)&&e.getData(`text/plain`).startsWith(Ry)}function Hy(e){let t=e.lastIndexOf(`/`);return t<0?``:e.slice(0,t)}function Uy(e,t,n){e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(Ly,t.path),e.dataTransfer.setData(`text/plain`,`${Ry}${t.path}`),n(t)}function Wy({outline:e,activeFile:t,activeMainFile:n,sourceCursorStore:r,wordCountBusy:i,hasSelection:a,jumpToSource:o,syncSourceToPdf:s,onWordCount:c}){let{t:l}=Ne(),u=(0,J.useSyncExternalStore)(r.subscribe,r.getOutlineLine,r.getOutlineLine),d=(0,J.useMemo)(()=>Ny(e),[e]),f=(0,J.useMemo)(()=>d.filter(e=>e.hasChildren).map(e=>e.key),[d]),[p,m]=(0,J.useState)(()=>new Set);(0,J.useEffect)(()=>{let e=new Set(f);m(t=>{let n=new Set([...t].filter(t=>e.has(t)));return n.size===t.size?t:n})},[f]);let h=f.length>0&&f.every(e=>p.has(e)),g=(0,J.useMemo)(()=>Py(d,p),[d,p]),_=()=>m(e=>h?new Set([...e].filter(e=>!f.includes(e))):new Set([...e,...f])),v=e=>m(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,X.jsxs)(`section`,{className:`outline-panel`,children:[(0,X.jsxs)(`div`,{className:`panel-title`,children:[(0,X.jsxs)(`button`,{className:`outline-heading`,type:`button`,"aria-expanded":!h,title:l(h?`editor.expandOutline`:`editor.collapseOutline`),onClick:_,disabled:f.length===0,children:[(0,X.jsx)(N,{size:14}),l(`common.outline`)]}),(0,X.jsxs)(`span`,{className:`word-count-actions`,role:`group`,"aria-label":l(`editor.wordCountTitle`),children:[(0,X.jsxs)(`button`,{type:`button`,title:l(`editor.wordCountFullHint`),onClick:()=>c(`full`),disabled:i||!n,children:[i?(0,X.jsx)(Re,{className:`spin`,size:12}):(0,X.jsx)(Gt,{size:12}),l(`editor.wordCountFull`)]}),(0,X.jsxs)(`button`,{type:`button`,title:l(`editor.wordCountSelectionHint`),onClick:()=>c(`selection`),disabled:i||!a,children:[i?(0,X.jsx)(Re,{className:`spin`,size:12}):(0,X.jsx)(Gt,{size:12}),l(`editor.wordCountSelection`)]})]})]}),(0,X.jsxs)(`div`,{className:`outline`,children:[g.map(e=>{let{item:r}=e,i=p.has(e.key),a=t===r.path&&u===r.line,c=r.path===n||r.path===t;return(0,X.jsxs)(`div`,{className:`outline-row${a?` current`:``}`,children:[(0,X.jsx)(`span`,{className:`outline-guides`,"aria-hidden":!0,style:{width:`${r.level*12}px`}}),e.hasChildren?(0,X.jsx)(`button`,{className:`outline-toggle`,type:`button`,"aria-label":l(i?`editor.expandOutlineItem`:`editor.collapseOutlineItem`,{title:r.title}),"aria-expanded":!i,onClick:()=>v(e.key),children:i?(0,X.jsx)(fe,{size:13}):(0,X.jsx)(V,{size:13})}):(0,X.jsx)(`span`,{className:`outline-toggle-spacer`,"aria-hidden":!0}),(0,X.jsxs)(`button`,{className:`outline-item`,type:`button`,onClick:()=>{o(r.path,r.line,1),s(r.path,r.line,1)},children:[(0,X.jsx)(`small`,{children:c?r.line:r.path.split(`/`).at(-1)}),(0,X.jsx)(`span`,{className:`outline-title`,children:r.title})]})]},e.key)}),e.length===0&&(0,X.jsx)(`p`,{className:`muted padded`,children:l(`editor.noOutline`)})]})]})}function Gy({children:e,tabs:t,terminal:n}){let{t:r}=Ne(),i=Om(),[a,o]=(0,J.useState)(!1),s=!!n,c=(0,J.useRef)(s),l=s&&a;return(0,J.useLayoutEffect)(()=>{c.current&&!s&&i.current?.resize(`100%`),c.current=s},[i,s]),(0,X.jsx)(`main`,{className:`source-panel`,children:(0,X.jsxs)(bm,{orientation:`vertical`,className:`agent-editor-group`,children:[(0,X.jsx)(Em,{id:`source-editor`,panelRef:i,minSize:`20%`,collapsible:!!n,collapsedSize:`0%`,onResize:e=>o(e.asPercentage===0),children:(0,X.jsxs)(`div`,{className:`source-editor-pane`,inert:l,children:[t,e]})}),n&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(jm,{className:`agent-terminal-resizer`,"aria-label":r(`agents.resizeTerminal`)}),(0,X.jsx)(Em,{id:`agent-terminal`,defaultSize:`35%`,minSize:`20%`,children:n({maximized:l,toggleMaximized:()=>{let e=i.current;e?.isCollapsed()?e.expand():e?.collapse()}})})]})]})})}var Ky=(0,J.lazy)(()=>f(()=>import(`./LatexEditor-BYiVPD_b.js`).then(e=>({default:e.LatexEditor})),__vite__mapDeps([10,2,3,7,11,6,1,4,5,8,12]),import.meta.url));function qy({project:e,activeFile:t,openTabs:n,content:r,loadedFile:i,readOnly:a,comments:o,focusComment:s,editorPreferences:c,completionIndex:l,nativeSpellCheck:u,spellCheckIssues:d,spellCheckJump:f,sourceJump:p,collaborativeText:m,collaborationAwareness:h,undoManager:g,editorNotice:_,activateTab:v,closeTab:y,handleTabKeyDown:b,updateEditorContent:x,setSelection:S,onAddComment:w,onSelectionHistory:T,onCommentClick:E,onSpellCheckReplace:O,onReferenceNavigate:k,onCursor:A,terminal:j}){let{t:M}=Ne(),N=h_(o,t),P=g_(s,t,i);return(0,X.jsx)(Em,{id:`source`,minSize:`22%`,children:(0,X.jsx)(Gy,{terminal:j,tabs:c.openFilesInTabs&&n.length>0&&(0,X.jsx)(`div`,{className:`editor-tabs-bar`,role:`tablist`,"aria-label":M(`editor.openFiles`),children:(0,X.jsx)(`div`,{className:`editor-tabs-scroll`,children:n.map((n,r)=>{let i=n===t,a=n===e.mainFile,o=n.split(`/`).at(-1)||n;return(0,X.jsxs)(`div`,{className:`editor-tab-item${i?` active`:``}`,role:`presentation`,children:[(0,X.jsxs)(`button`,{id:`editor-tab-${encodeURIComponent(n)}`,type:`button`,role:`tab`,"aria-selected":i,"aria-controls":`editor-source-content`,tabIndex:i?0:-1,className:`editor-tab${i?` active`:``}${a?` main-tab`:``}`,onClick:()=>v(n),onKeyDown:e=>b(e,r),title:n,children:[(0,X.jsx)(`span`,{className:`editor-tab-icon`,children:a?(0,X.jsx)(I,{size:13}):(0,X.jsx)(C,{size:13})}),(0,X.jsx)(`span`,{className:`editor-tab-title`,children:o}),a&&(0,X.jsx)(`small`,{className:`editor-tab-badge`,children:M(`editor.currentMainShort`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`editor-tab-close`,title:M(`common.close`),"aria-label":`${M(`common.close`)} ${o}`,onClick:()=>y(n),children:(0,X.jsx)(D,{size:12})})]},n)})})}),children:(0,X.jsxs)(`div`,{id:`editor-source-content`,className:`editor-content-container`,children:[(0,X.jsx)(J.Suspense,{fallback:(0,X.jsxs)(`div`,{className:`preview-empty`,children:[(0,X.jsx)(Re,{className:`spin`,size:22}),(0,X.jsx)(`span`,{children:M(`common.loading`)})]}),children:(0,X.jsx)(Ky,{value:r,filePath:t,readOnly:a,comments:N,focusComment:P,preferences:c,nativeSpellCheck:u,completionIndex:l,spellCheckIssues:d,spellCheckJump:f,jumpTo:i===t&&p?.path===t?p:null,searchRequest:0,collaboration:m?{text:m,awareness:h,undoManager:a?void 0:g}:void 0,onChange:x,onSelection:S,onAddComment:w,onSelectionHistory:T,onCommentClick:E,onSpellCheckReplace:O,onReferenceNavigate:k,onCursor:A},t)}),_&&(0,X.jsx)(`div`,{className:`editor-centered-notice`,role:`status`,"aria-live":`polite`,children:_})]})})})}var Jy=t(r(),1);function Yy({children:e,showControls:t=!0}){let[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)(null);return(0,J.useLayoutEffect)(()=>{if(!n||!t)return;let e=()=>{let e=n.getBoundingClientRect(),t=e.left+e.width/2,r=e.top+e.height/2;a(e=>e?.left===t&&e.top===r?e:{left:t,top:r})},r=new ResizeObserver(e);r.observe(n);let i=n.parentElement;if(i){r.observe(i);for(let e of i.children)e.hasAttribute(`data-panel`)&&r.observe(e)}return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),e(),()=>{r.disconnect(),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[n,t]),(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(jm,{className:`resize-handle sync-resize-handle`,elementRef:r,children:(0,X.jsx)(Ut,{className:`resize-grip`,size:12})}),t&&i&&(0,Jy.createPortal)((0,X.jsx)(`span`,{className:`sync-direction-buttons`,style:{position:`fixed`,...i},children:e}),document.body)]})}function Xy({diagnostics:e,files:t,empty:n,tone:r,onJump:i}){let{t:a}=Ne(),o=r===`error`?wt:T;return e.length?(0,X.jsx)(`div`,{className:`compile-diagnostic-list compile-${r}`,children:e.map((e,n)=>{let r=eb(e.file,t),s=!!(r&&e.line);return(0,X.jsxs)(`button`,{type:`button`,disabled:!s,className:`compile-diagnostic-row`,onClick:()=>{r&&e.line&&i(r,e.line,e.column??1)},children:[(0,X.jsx)(o,{size:15}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{children:e.message}),(0,X.jsxs)(`small`,{children:[e.phase,r?` · ${r}${e.line?`:${e.line}`:``}`:e.line?` · ${a(`editor.lineNumber`,{line:e.line})}`:``]})]})]},`${e.phase}-${e.file??``}-${e.line??0}-${n}`)})}):(0,X.jsxs)(`div`,{className:`compile-empty compile-${r}`,children:[(0,X.jsx)(o,{size:26}),(0,X.jsx)(`span`,{children:n})]})}function Zy({lines:e,empty:t,tone:n=`log`}){let r=n===`error`?wt:n===`warning`?T:h;return e.length?(0,X.jsx)(`pre`,{className:`compile-output compile-${n}`,children:e.join(`
|
|
16
|
-
`)}):(0,X.jsxs)(`div`,{className:`compile-empty compile-${n}`,children:[(0,X.jsx)(r,{size:26}),(0,X.jsx)(`span`,{children:t})]})}function Qy({projectId:e,mainFile:t,artifacts:n,preview:r,loading:i,onView:a}){let{t:o}=Ne(),s=n=>d(`/api/projects/${e}/compile/artifacts?mainFile=${encodeURIComponent(t)}&path=${encodeURIComponent(n)}&download=1`);return n.length?(0,X.jsxs)(`div`,{className:`artifact-browser`,children:[(0,X.jsx)(`div`,{className:`artifact-list`,children:n.map(e=>(0,X.jsxs)(`div`,{className:`artifact-row${r?.path===e.path?` active`:``}`,children:[(0,X.jsxs)(`button`,{type:`button`,disabled:!e.viewable,title:e.viewable?o(`editor.viewArtifact`):o(`editor.downloadToView`),onClick:()=>a(e),children:[(0,X.jsx)(Vn,{path:e.path,size:14}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{children:e.path}),(0,X.jsx)(`small`,{children:ge(e.size,{maximumUnit:`MB`})})]})]}),(0,X.jsx)(`a`,{href:s(e.path),title:o(`editor.downloadArtifact`),"aria-label":o(`editor.downloadArtifact`),children:(0,X.jsx)(ie,{size:14})})]},e.path))}),(0,X.jsx)(`div`,{className:`artifact-preview`,children:i?(0,X.jsxs)(`div`,{className:`compile-empty`,children:[(0,X.jsx)(Re,{className:`spin`,size:24}),(0,X.jsx)(`span`,{children:o(`common.loading`)})]}):r?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`header`,{children:[(0,X.jsx)(`strong`,{children:r.path}),(0,X.jsxs)(`a`,{href:s(r.path),children:[(0,X.jsx)(ie,{size:13}),o(`projects.download`)]})]}),(0,X.jsx)(`pre`,{children:r.content})]}):(0,X.jsxs)(`div`,{className:`compile-empty`,children:[(0,X.jsx)(C,{size:24}),(0,X.jsx)(`span`,{children:o(`editor.selectArtifact`)})]})})]}):(0,X.jsxs)(`div`,{className:`compile-empty`,children:[(0,X.jsx)(rn,{size:26}),(0,X.jsx)(`span`,{children:o(`editor.noArtifacts`)})]})}function $y({mainFile:e,disabled:t,cleaning:n,onCleanCache:r,onCleanArtifacts:i}){let{t:a}=Ne();return(0,X.jsxs)(`div`,{className:`compile-clean-panel`,children:[(0,X.jsxs)(`div`,{className:`compile-clean-intro`,children:[(0,X.jsx)(T,{size:28}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`strong`,{children:a(`editor.cleanTitle`)}),(0,X.jsx)(`p`,{children:a(`editor.cleanDescription`,{file:e})})]})]}),(0,X.jsxs)(`div`,{className:`compile-clean-actions`,children:[(0,X.jsxs)(`article`,{children:[(0,X.jsx)(`div`,{className:`compile-clean-action-icon`,children:(0,X.jsx)(Y,{size:19})}),(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`compile-clean-action-heading`,children:[(0,X.jsx)(`strong`,{children:a(`editor.cleanCache`)}),(0,X.jsx)(`button`,{type:`button`,className:`compile-clean-help`,"aria-label":a(`editor.cleanCacheDescription`),"data-tooltip":a(`editor.cleanCacheDescription`),"data-texlite-tooltip-always":!0,children:(0,X.jsx)(St,{size:13,"aria-hidden":`true`})})]}),(0,X.jsxs)(`button`,{type:`button`,className:`compile-clean-operation`,disabled:t||n,onClick:r,children:[n?(0,X.jsx)(Re,{className:`spin`,size:14}):(0,X.jsx)(Y,{size:14}),a(`editor.cleanCache`)]})]})]}),(0,X.jsxs)(`article`,{className:`danger`,children:[(0,X.jsx)(`div`,{className:`compile-clean-action-icon`,children:(0,X.jsx)(k,{size:19})}),(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`compile-clean-action-heading`,children:[(0,X.jsx)(`strong`,{children:a(`editor.cleanArtifacts`)}),(0,X.jsx)(`button`,{type:`button`,className:`compile-clean-help`,"aria-label":a(`editor.cleanArtifactsDescription`),"data-tooltip":a(`editor.cleanArtifactsDescription`),"data-texlite-tooltip-always":!0,children:(0,X.jsx)(St,{size:13,"aria-hidden":`true`})})]}),(0,X.jsxs)(`button`,{type:`button`,className:`compile-clean-operation danger`,disabled:t||n,onClick:i,children:[n?(0,X.jsx)(Re,{className:`spin`,size:14}):(0,X.jsx)(k,{size:14}),a(`editor.cleanArtifacts`)]})]})]})]})]})}function eb(e,t){if(!e)return null;let n=t.filter(e=>e.type===`file`).map(e=>e.path),r=e.replaceAll(`\\`,`/`).replace(/^\.\//,``);if(n.includes(r))return r;let i=n.filter(e=>r.endsWith(`/${e}`));if(i.length===1)return i[0];let a=r.split(`/`).at(-1),o=n.filter(e=>e.split(`/`).at(-1)===a);return o.length===1?o[0]:null}var tb=(0,J.lazy)(()=>Le().then(e=>({default:e.PdfPreview})));function nb({commentsOpen:e=!1,onCommentsHost:t,projectId:n,activeMainFile:r,previewTab:i,diagnosticTab:a,pdfUrl:o,pdfLoadingMode:s,pdfLoading:c,pdfCompiledAt:u,pdfSizeBytes:d,pdfCompiledLabel:f,pdfTargetLabel:p,pdfDownloadUrl:m,pdfTarget:g,pdfViewport:_,activeFile:v,compileBusy:y,compileLog:b,compileDiagnostics:x,compileMessages:S,artifacts:C,artifactPreview:w,artifactLoading:E,cleaning:D,readOnly:O,collaborationSynced:k,workspaceLayout:A,showSyncResize:j,diagnosticCount:M,selectPreviewTab:N,changeWorkspaceLayout:P,onSetPdfViewport:F,onResetPdfViewport:ee,onPdfDisplayed:te,syncVisiblePdfToSource:ne,syncCurrentSourceToPdf:ae,syncPdfToSource:oe,canSyncWithPdf:I,canSyncPdfToSource:L,files:R,jumpToSource:se,onSetCleanMode:z,viewArtifact:ce}){let{t:B}=Ne(),[le,V]=(0,J.useState)(``),ue=(0,J.useRef)(``),de=e=>{ue.current!==e&&(ue.current=e,V(e),ee(),te(e))},fe=L&&!!o&&le===o,pe=[d==null?``:ge(d),f?B(`editor.pdfUpdatedAt`,{time:f}):``].filter(Boolean).join(` · `);return(0,X.jsxs)(X.Fragment,{children:[j&&(0,X.jsxs)(Yy,{showControls:!e,children:[(0,X.jsx)(`button`,{disabled:!o||!_||!fe,title:B(L?fe?`editor.showInSource`:`editor.syncTexWaitingForPdf`:`editor.syncTexOnlyForMain`),"aria-label":B(`editor.showInSource`),onClick:e=>{e.stopPropagation(),fe&&ne()},children:(0,X.jsx)(`span`,{"aria-hidden":!0,children:`←`})}),(0,X.jsx)(`button`,{disabled:!v||!o||!I,title:B(I?`editor.showInPdf`:`editor.syncTexOnlyForTex`),"aria-label":B(`editor.showInPdf`),onClick:e=>{e.stopPropagation(),v&&o&&I&&ae()},children:(0,X.jsx)(`span`,{"aria-hidden":!0,children:`→`})})]}),(0,X.jsx)(Em,{id:`preview`,minSize:`22%`,children:(0,X.jsx)(`div`,{className:`workspace-preview-region`,children:(0,X.jsxs)(`div`,{className:`workspace-output-layout${e?` has-comments`:``}`,children:[(0,X.jsx)(`div`,{ref:t,className:`workspace-comments-slot`,hidden:!e}),(0,X.jsxs)(`section`,{className:`preview-panel`,children:[(0,X.jsxs)(`div`,{className:`preview-tabs`,children:[(0,X.jsxs)(`div`,{className:`preview-tab-list`,role:`tablist`,"aria-label":B(`editor.outputTabs`),children:[(0,X.jsxs)(`button`,{role:`tab`,"aria-selected":i===`pdf`,className:`pdf-tab${i===`pdf`?` active`:``}`,onClick:()=>N(`pdf`),title:u?B(`editor.pdfCompiledAtFor`,{file:r,time:re(u,l.resolvedLanguage)}):B(`editor.currentMainDocument`,{path:r}),children:[(0,X.jsx)(kn,{className:`pdf-tab-icon`}),(0,X.jsxs)(`span`,{className:`pdf-tab-label`,children:[(0,X.jsxs)(`span`,{className:`pdf-tab-title`,children:[`PDF · `,p]}),pe&&(0,X.jsx)(`small`,{children:pe})]})]}),(0,X.jsxs)(`button`,{role:`tab`,"aria-selected":i===`diagnostics`,className:`diagnostics-tab${i===`diagnostics`?` active`:``}`,onClick:()=>N(`diagnostics`),children:[(0,X.jsx)(h,{size:14}),B(`editor.outputTabs`),(0,X.jsx)(`span`,{className:`diagnostic-count`,children:M})]})]}),m&&(0,X.jsxs)(`a`,{className:`pdf-download-top`,href:m,download:!0,title:B(`editor.downloadPdf`),"aria-label":B(`editor.downloadPdf`),children:[(0,X.jsx)(ie,{size:15}),(0,X.jsx)(`span`,{children:B(`editor.downloadPdf`)})]})]}),i===`diagnostics`&&(0,X.jsxs)(`div`,{className:`preview-subtabs`,role:`tablist`,"aria-label":B(`editor.outputTabs`),children:[(0,X.jsxs)(`button`,{role:`tab`,"aria-selected":a===`log`,className:a===`log`?`active`:``,onClick:()=>N(`log`),children:[(0,X.jsx)(Zt,{size:13}),B(`editor.log`)]}),(0,X.jsxs)(`button`,{role:`tab`,"aria-selected":a===`warnings`,className:a===`warnings`?`active`:``,onClick:()=>N(`warnings`),children:[(0,X.jsx)(T,{size:13}),B(`editor.warnings`),(0,X.jsx)(`span`,{children:S.warnings.length})]}),(0,X.jsxs)(`button`,{role:`tab`,"aria-selected":a===`errors`,className:a===`errors`?`active`:``,onClick:()=>N(`errors`),children:[(0,X.jsx)(wt,{size:13}),B(`editor.errors`),(0,X.jsx)(`span`,{children:S.errors.length})]}),(0,X.jsxs)(`button`,{role:`tab`,"aria-selected":a===`artifacts`,className:a===`artifacts`?`active`:``,onClick:()=>N(`artifacts`),children:[(0,X.jsx)(rn,{size:13}),B(`editor.artifacts`),(0,X.jsx)(`span`,{children:C.length})]}),(0,X.jsxs)(`button`,{role:`tab`,"aria-selected":a===`clean`,className:a===`clean`?`active`:``,onClick:()=>N(`clean`),children:[(0,X.jsx)(Y,{size:13}),B(`editor.clean`)]})]}),(0,X.jsxs)(`div`,{className:`preview-content preview-${i} ${i===`diagnostics`?`preview-${a}`:``}`,children:[i===`pdf`&&(o?(0,X.jsx)(J.Suspense,{fallback:(0,X.jsxs)(`div`,{className:`pdf-loading-state`,role:`status`,"aria-live":`polite`,children:[(0,X.jsx)(Re,{className:`spin`,size:24}),(0,X.jsx)(`span`,{children:B(`editor.loadingPdf`)})]}),children:(0,X.jsx)(tb,{url:o,loadingMode:s,target:g,compiling:y,onDisplayedUrlChange:de,onViewportLocation:(e,t,n)=>{ue.current===o&&F({page:e,x:t,y:n})},onDoubleClickLocation:(e,t,n)=>{ue.current===o&&fe&&(F({page:e,x:t,y:n}),oe(e,t,n))}})}):c?(0,X.jsxs)(`div`,{className:`pdf-loading-state`,role:`status`,"aria-live":`polite`,children:[(0,X.jsx)(Re,{className:`spin`,size:24}),(0,X.jsx)(`span`,{children:B(`editor.loadingPdf`)})]}):(0,X.jsxs)(`div`,{className:`preview-empty preview-empty-uncompiled`,role:`status`,"aria-live":`polite`,children:[(0,X.jsx)(`span`,{className:`preview-empty-icon`,"aria-hidden":`true`,children:y?(0,X.jsx)(Re,{className:`spin`,size:26}):(0,X.jsx)(kn,{size:32})}),(0,X.jsx)(`strong`,{children:B(y?`editor.compiling`:`editor.previewEmptyTitle`)}),(0,X.jsx)(`p`,{children:B(y?`editor.previewCompilingHint`:`editor.previewHint`)})]})),i===`diagnostics`&&a===`log`&&(0,X.jsx)(Zy,{lines:b?b.split(`
|
|
17
|
-
`):[],empty:B(y?`editor.compiling`:`editor.noLog`)}),i===`diagnostics`&&a===`warnings`&&(x?(0,X.jsx)(Xy,{tone:`warning`,diagnostics:x.warnings,files:R,empty:B(`editor.noWarnings`),onJump:(e,t,n)=>{A===`pdf-only`&&P(`editor-pdf`),se(e,t,n)}}):(0,X.jsx)(Zy,{tone:`warning`,lines:S.warnings,empty:B(`editor.noWarnings`)})),i===`diagnostics`&&a===`errors`&&(x?(0,X.jsx)(Xy,{tone:`error`,diagnostics:x.errors,files:R,empty:B(`editor.noErrors`),onJump:(e,t,n)=>{A===`pdf-only`&&P(`editor-pdf`),se(e,t,n)}}):(0,X.jsx)(Zy,{tone:`error`,lines:S.errors,empty:B(`editor.noErrors`)})),i===`diagnostics`&&a===`artifacts`&&(0,X.jsx)(Qy,{projectId:n,mainFile:r,artifacts:C,preview:w,loading:E,onView:e=>void ce(e)}),i===`diagnostics`&&a===`clean`&&(0,X.jsx)($y,{mainFile:r,disabled:O||!k||y,cleaning:D,onCleanCache:()=>z(`cache`),onCleanArtifacts:()=>z(`artifacts`)})]})]})]})})})]})}function rb({kind:e,onEdit:t,onDelete:n,disabled:r=!1}){let{t:i}=Ne(),a=(0,J.useRef)(!1);return(0,X.jsx)(`span`,{className:`comment-actions-menu`,onClick:e=>e.stopPropagation(),children:(0,X.jsxs)(He,{modal:!1,children:[(0,X.jsx)(q,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,disabled:r,className:`comment-actions-menu-trigger`,"aria-label":i(e===`comment`?`editor.commentActions`:`editor.replyActions`),children:(0,X.jsx)(m,{size:16,"aria-hidden":!0})})}),(0,X.jsx)(ze,{children:(0,X.jsxs)(Be,{className:`comment-actions-menu-content`,align:`end`,sideOffset:4,collisionPadding:8,onCloseAutoFocus:e=>{a.current&&e.preventDefault(),a.current=!1},children:[(0,X.jsxs)(Ve,{onSelect:()=>{a.current=!0,t()},children:[(0,X.jsx)(M,{size:13,"aria-hidden":!0}),i(e===`comment`?`editor.editComment`:`editor.editReply`)]}),(0,X.jsxs)(Ve,{className:`danger-text`,onSelect:()=>{a.current=!0,n()},children:[(0,X.jsx)(k,{size:13,"aria-hidden":!0}),i(e===`comment`?`editor.deleteComment`:`editor.deleteReply`)]})]})})]})})}function ib(e,t){let n=e.slice(0,t),r=/(^|[^\p{L}\p{N}_.-])@([\p{L}\p{N}_.-]*)$/u.exec(n);return r?{start:t-r[2].length-1,end:t,query:r[2]}:null}function ab({projectId:e,value:t,onChange:n,onKeyDown:r,onFocus:i,...a}){let{t:o}=Ne(),s=(0,J.useRef)(null),[c,l]=(0,J.useState)(null),u=Wg({queryKey:Kg.candidates(e),enabled:!!c,queryFn:({signal:t})=>G(`/api/projects/${e}/mention-candidates`,{signal:t})}),d=Yg(u.error)?void 0:u.data?.users,[f,p]=(0,J.useState)(0),m=(0,J.useMemo)(()=>{if(!c||!d)return[];let e=c.query.toLocaleLowerCase();return(e?d.filter(t=>t.username.toLocaleLowerCase().includes(e)||t.displayName.toLocaleLowerCase().includes(e)):d).slice(0,8)},[d,c]),h=!!(c&&m.length),g=(e,t)=>{let n=ib(e,t);l(n),p(0),n&&!u.isFetching&&(u.isError||u.isStale)&&u.refetch()},_=e=>{if(!c)return;let r=`@${e.username} `,i=`${t.slice(0,c.start)}${r}${t.slice(c.end)}`,a=c.start+r.length;n(i),l(null),p(0),window.requestAnimationFrame(()=>{s.current?.focus(),s.current?.setSelectionRange(a,a)})},v=e=>{if(!e.nativeEvent.isComposing&&h){if(e.key===`ArrowDown`){e.preventDefault(),p(e=>(e+1)%m.length);return}if(e.key===`ArrowUp`){e.preventDefault(),p(e=>(e-1+m.length)%m.length);return}if(e.key===`Enter`&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey){e.preventDefault(),_(m[f]??m[0]);return}if(e.key===`Escape`){l(null);return}}r?.(e)};return(0,X.jsxs)(`span`,{className:`mention-textarea`,children:[(0,X.jsx)(`textarea`,{...a,ref:s,value:t,onFocus:e=>{i?.(e),g(t,e.currentTarget.selectionStart??t.length)},onClick:e=>g(t,e.currentTarget.selectionStart??t.length),onChange:e=>{let t=e.currentTarget.value;n(t),g(t,e.currentTarget.selectionStart??t.length)},onKeyDown:v}),h&&(0,X.jsx)(`span`,{className:`mention-menu`,role:`listbox`,"aria-label":o(`editor.mentionUsers`),children:m.map((e,t)=>(0,X.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===f,className:t===f?`active`:``,onMouseDown:e=>e.preventDefault(),onClick:()=>_(e),children:[(0,X.jsx)(ce,{"aria-hidden":!0,size:13}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{children:e.displayName}),(0,X.jsxs)(`small`,{children:[`(`,e.username,`)`]})]})]},e.id))})]})}function ob({projectId:e,value:t,onChange:n,onSubmit:r,onCancel:i,pending:a=!1,error:o=``,label:s,editing:c=!1,disabled:l=!1,autoFocus:u=!0}){let{t:d}=Ne(),f=(0,J.useId)(),p=a||l,m=e=>{e?.preventDefault(),!p&&t.trim()&&r()};return(0,X.jsxs)(`form`,{className:`comment-reply-form${c?` comment-edit-form`:``}`,"aria-busy":a,onSubmit:e=>void m(e),onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(ab,{projectId:e,autoFocus:u,rows:c?4:3,value:t,onChange:n,disabled:p,"aria-label":s,"aria-invalid":!!o,"aria-describedby":o?f:void 0,placeholder:c?void 0:d(`editor.replyPlaceholder`),onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),e.stopPropagation(),m())}}),o&&(0,X.jsx)(`p`,{id:f,className:`comment-form-error`,role:`alert`,children:o}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`button`,{type:`button`,disabled:p,onClick:i,children:d(`common.cancel`)}),c?(0,X.jsx)(U,{type:`submit`,saving:a,disabled:l||!t.trim(),iconSize:13,children:d(a?`editor.commentSaving`:`editor.saveChanges`)}):(0,X.jsxs)(`button`,{className:`primary`,type:`submit`,disabled:p||!t.trim(),children:[a?(0,X.jsx)(Re,{className:`spin`,"aria-hidden":!0,size:13}):(0,X.jsx)(vn,{"aria-hidden":!0,size:13}),d(a?`editor.commentSending`:`editor.sendReply`)]})]})]})}function sb(e,t={}){let n=e.slice(0,Math.max(0,e.length-2)),r=!!(t.activeDraft||t.targetReplyId&&e.some(e=>e.id===t.targetReplyId)||n.some(e=>t.unreadReplyMentionIds?.has(e.id)||t.highlightReplyParticipants&&t.selectedParticipantIds?.has(e.authorId))),i=r||(t.expansion??!!t.current),a=i?0:n.length;return{replies:a?e.slice(-2):e,hiddenCount:a,expanded:i,canToggle:n.length>0&&!r}}var cb=1100;function lb(e){let t=()=>{};if(!e||window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches)return t;let n=e.closest(`.comments`)??e.parentElement,r=e.getBoundingClientRect(),i=e.closest(`.context-panel`)?.getBoundingClientRect(),a=Math.max(0,r.left,i?.left??0),o=Math.max(0,r.top,i?.top??0),s=Math.min(window.innerWidth,r.right,i?.right??window.innerWidth)-a,c=Math.min(180,Math.min(window.innerHeight,r.bottom,i?.bottom??window.innerHeight)-o);if(!n||s<=0||c<=0)return t;let l=!1;return()=>{if(l||!n.isConnected||window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches)return;l=!0;let e=document.createElement(`div`);e.className=`comment-paper-shred`,e.setAttribute(`aria-hidden`,`true`),e.inert=!0,Object.assign(e.style,{left:`${a}px`,top:`${o}px`,width:`${s}px`,height:`${c}px`}),e.style.setProperty(`--shred-duration`,`${cb}ms`),e.style.setProperty(`--shred-height`,`${c}px`);let t=Math.min(12,Math.max(8,Math.round(s/22))),r=c<96?1:2;for(let n=0;n<t*r;n++){let i=document.createElement(`span`),a=n%t,o=Math.floor(n/t),s=a/(t-1)*2-1,l=n*37;i.style.left=`${a/t*100}%`,i.style.top=`${o/r*100}%`,i.style.width=`${100/t}%`,i.style.height=`${c/r}px`,i.style.setProperty(`--shred-x`,`${s*14+l%7-3}px`),i.style.setProperty(`--shred-y`,`${48+o*16+l%31}px`),i.style.setProperty(`--shred-angle`,`${s*12+l%13-6}deg`),i.style.setProperty(`--shred-flip`,`${(n%2?1:-1)*(18+l%23)}deg`),i.style.setProperty(`--shred-line-offset`,`${-o*c/r}px`),i.style.animationDuration=`${780+l%4*25}ms`,i.style.animationDelay=`${80+a*7+o*35+l%3*9}ms`,e.append(i)}let i=()=>{window.clearTimeout(d),u.disconnect(),window.removeEventListener(`resize`,i),e.remove()},u=new MutationObserver(()=>{n.isConnected||i()}),d=window.setTimeout(i,1300);e.addEventListener(`animationend`,t=>{t.target===e&&!t.pseudoElement&&i()}),window.addEventListener(`resize`,i),u.observe(document.body,{childList:!0,subtree:!0}),document.body.append(e)}}var ub=e=>`${e.displayName?.trim()||e.username} (@${e.username})`;function db({users:e,value:t,onChange:n,disabled:r=!1}){let{t:i}=Ne(),a=(0,J.useId)(),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(0),f=(0,J.useRef)(null),p=(0,J.useRef)(null),m=(0,J.useRef)(null),h=e.find(e=>e.id===t),g=h?``:o.trim().replace(/^@/,``).toLowerCase(),y=g?e.filter(e=>e.username.toLowerCase().includes(g)||(e.displayName??``).toLowerCase().includes(g)):e,b=Math.min(u,Math.max(0,y.length-1)),x=c&&!r;(0,J.useEffect)(()=>{x&&m.current?.querySelector(`[data-index="${b}"]`)?.scrollIntoView?.({block:`nearest`})},[b,x,o]);let S=e=>{let t=y[e];t&&!r&&(n(t.id),s(``),l(!1))},C=()=>{d(Math.max(0,y.findIndex(e=>e.id===t))),l(!0)},w=`${a}-user`;return(0,X.jsxs)(`div`,{className:`share-user-picker`,children:[(0,X.jsx)(`label`,{htmlFor:w,children:i(`common.user`)}),(0,X.jsxs)(me,{open:x,onOpenChange:l,children:[(0,X.jsx)(A,{asChild:!0,children:(0,X.jsxs)(`div`,{className:`share-user-search`,ref:p,onClick:()=>{r||(f.current?.focus(),C())},children:[(0,X.jsx)(`input`,{id:w,ref:f,role:`combobox`,value:h?ub(h):o,disabled:r,placeholder:i(`projectSettings.searchUsersPlaceholder`),autoComplete:`off`,spellCheck:!1,"aria-autocomplete":`list`,"aria-expanded":x,"aria-controls":x?`${a}-list`:void 0,"aria-activedescendant":x&&y[b]?`${a}-user-${y[b].id}`:void 0,onClick:e=>{h&&e.currentTarget.select()},onFocus:e=>{C(),h&&e.currentTarget.select()},onChange:e=>{s(e.target.value),n(``),d(0),l(!0)},onKeyDown:e=>{if(!e.nativeEvent.isComposing){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),l(!0);let n=e.key===`ArrowDown`?1:-1;if(x)d(e=>y.length?(e+n+y.length)%y.length:0);else{let e=y.findIndex(e=>e.id===t);d(e>=0?e:n===1?0:Math.max(0,y.length-1))}}else e.key===`Enter`?(e.preventDefault(),x&&S(b)):e.key===`Escape`&&x&&(e.preventDefault(),e.stopPropagation(),l(!1))}}}),(0,X.jsx)(V,{className:`share-user-chevron`,size:14,"aria-hidden":!0})]})}),(0,X.jsx)(_,{container:f.current?.closest(`[role="dialog"]`),children:(0,X.jsxs)(v,{className:`share-user-popover`,"aria-label":i(`projectSettings.chooseUser`),align:`start`,side:`bottom`,sideOffset:5,collisionPadding:12,avoidCollisions:!1,collisionBoundary:f.current?.closest(`[role="dialog"]`)??void 0,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>{p.current?.contains(e.target)&&e.preventDefault()},onEscapeKeyDown:e=>{e.preventDefault(),e.stopPropagation(),l(!1)},children:[(0,X.jsx)(`div`,{id:`${a}-list`,ref:m,role:`listbox`,"aria-label":i(`projectSettings.chooseUser`),children:y.map((e,n)=>(0,X.jsxs)(`button`,{type:`button`,role:`option`,tabIndex:-1,id:`${a}-user-${e.id}`,"data-index":n,"data-active":n===b||void 0,"aria-selected":e.id===t,onMouseDown:e=>e.preventDefault(),onMouseMove:()=>d(n),onClick:()=>S(n),children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{children:e.displayName?.trim()||e.username}),(0,X.jsxs)(`small`,{children:[`@`,e.username]})]}),e.id===t&&(0,X.jsx)(ve,{size:14,"aria-hidden":!0})]},e.id))}),y.length===0&&(0,X.jsx)(`p`,{className:`share-user-no-results`,role:`status`,children:i(e.length?`projectSettings.noMatchingUsers`:`projectSettings.noAvailableUsers`)})]})})]})]})}function fb(e){let t=/(^|\s)(@[\p{L}\p{N}_.-]+)/gu,n=[],r=0;for(let i of e.matchAll(t)){let t=i.index??0,a=i[1],o=i[2],s=t+a.length;s>r&&n.push(e.slice(r,s)),n.push((0,X.jsx)(`span`,{className:`comment-inline-mention`,children:o},`${s}:${o}`)),r=s+o.length}return n.length?(r<e.length&&n.push(e.slice(r)),n):e}function pb({userId:e,avatarStyle:t,name:n,username:r,highlighted:i,children:a}){return(0,X.jsxs)(`span`,{className:`comment-identity`,children:[(0,X.jsx)(he,{userId:e,name:n,username:r,avatarStyle:t,className:`comment-avatar`}),(0,X.jsxs)(`span`,{className:`comment-author-details`,children:[(0,X.jsx)(`span`,{className:`comment-author${i?` participant-match`:``}`,children:(0,X.jsx)(`strong`,{"data-tooltip":r?`@${r}`:void 0,"data-texlite-tooltip-always":!0,children:n})}),a]})]})}function mb({projectId:e,comment:t,draftStore:n,currentUserId:r,unreadCommentMentionId:i,unreadReplyMentionIds:a,highlightedComment:o,highlightedReplyId:s,currentComment:c,showFilePath:l,onMarkMentionRead:u,onFocus:d,onActivate:f,onToggle:p,onReply:m,onEdit:h,onDelete:g,onEditReply:_,onDeleteReply:v,selectedParticipantIds:y,highlightReplyParticipants:b,replyExpansion:x,onReplyExpansionChange:S}){let{t:C,i18n:w}=Ne(),T=R(),[E,D]=(0,J.useState)(!1),O=(0,J.useCallback)(e=>n.subscribe(t.id,e),[n,t.id]),k=(0,J.useCallback)(()=>n.getThread(t.id),[n,t.id]),A=(0,J.useSyncExternalStore)(O,k,k),j=A.reply,M=A[`edit-comment`],N=(0,J.useId)(),P=sb(t.replies,{expansion:x,current:c,targetReplyId:s,unreadReplyMentionIds:a,selectedParticipantIds:y,highlightReplyParticipants:b,activeDraft:!!(j?.open||j?.pending||t.authorId===r&&M?.open||t.replies.some(e=>e.authorId===r&&A[`edit-reply:${e.id}`]?.open))}),F=n.isPending(t.id),[ee,te]=(0,J.useState)(null),[ne,ie]=(0,J.useState)(!1),[ae,oe]=(0,J.useState)(null),[I,L]=(0,J.useState)(``),se=(0,J.useRef)(null),z=(0,J.useRef)(!1),[B,le]=(0,J.useState)(!1),V=async e=>{if(z.current)return;z.current=!0,le(!0),L(``);let t=lb(e?se.current?.querySelector(`[data-comment-reply-id="${e}"]`)??null:se.current);try{if(!(e?await v(e):await g())){L(C(`editor.commentDeleteFailed`));return}e?oe(null):ie(!1),t()}catch(e){L(W(e))}finally{z.current=!1,le(!1)}},ue=(e,r=``)=>{f(),S(!0),te(e),n.open(t.id,e,r)},pe=(r,i,a)=>{let o=A[r];return o?.open?(0,X.jsx)(ob,{projectId:e,editing:r!==`reply`,label:i,value:o.content,pending:o.pending,error:o.error,disabled:F||E,autoFocus:ee===r,onChange:e=>n.change(t.id,r,e),onSubmit:()=>n.submit(t.id,r,a,C(`editor.commentSubmitFailed`)),onCancel:()=>n.discard(t.id,r)},r):null},me=t.authorUsername,he=e=>de(e,w.resolvedLanguage??`en`,T,(e,t)=>C(e,t)),ge=e=>re(e,w.resolvedLanguage,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}),_e=e=>(0,X.jsx)(`time`,{dateTime:e,"data-tooltip":ge(e),"data-texlite-tooltip-always":!0,children:he(e)}),be=(e,t)=>(0,X.jsxs)(`span`,{className:`comment-times`,children:[_e(e),t&&(0,X.jsx)(`small`,{"data-tooltip":C(`editor.editedAt`,{time:ge(t)}),"data-texlite-tooltip-always":!0,children:C(`editor.commentEdited`)})]}),U=async(e,t)=>{t.stopPropagation(),S(!0),await u(e)};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`article`,{ref:se,"data-comment-id":t.id,className:`comment-thread${t.resolved?` resolved`:``}${t.orphaned?` orphaned`:``}${o?` mention-target`:``}${c?` review-current`:``}`,onFocusCapture:f,onClick:()=>{window.getSelection()?.toString()||d()},children:[(0,X.jsxs)(`header`,{className:`comment-header`,children:[(0,X.jsx)(pb,{userId:t.authorId,avatarStyle:t.authorAvatarStyle,name:t.authorDisplayName??me??C(`editor.deletedUser`),username:me,highlighted:y?.has(t.authorId),children:be(t.createdAt,t.editedAt)}),(0,X.jsxs)(`span`,{className:`comment-header-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`resolve`,disabled:E||F,"aria-busy":E,"aria-label":C(t.resolved?`editor.reopen`:`editor.resolve`),"data-tooltip":C(t.resolved?`editor.reopen`:`editor.resolve`),"data-texlite-tooltip-always":!0,onClick:e=>{e.stopPropagation(),!E&&(D(!0),p().finally(()=>D(!1)))},children:E?(0,X.jsx)(Re,{className:`spin`,size:15,"aria-hidden":!0}):t.resolved?(0,X.jsx)(gn,{size:15,"aria-hidden":!0}):(0,X.jsx)(ve,{size:16,"aria-hidden":!0})}),t.authorId===r&&!M?.open&&(0,X.jsx)(rb,{kind:`comment`,disabled:F||E,onEdit:()=>ue(`edit-comment`,t.content),onDelete:()=>{L(``),ie(!0)}})]})]}),(0,X.jsx)(`div`,{className:`comment-location`,children:t.orphaned?C(`editor.orphaned`):l?C(`editor.commentLocation`,{path:t.filePath,line:t.startLine}):C(`editor.line`,{line:t.startLine})}),t.selectedText&&(0,X.jsx)(`blockquote`,{className:`comment-selected-text`,children:t.selectedText}),M?.open&&t.authorId===r?pe(`edit-comment`,C(`editor.editComment`),h):(0,X.jsx)(`p`,{className:`comment-content`,children:fb(t.content)}),i&&(0,X.jsxs)(`div`,{className:`comment-mention`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(ce,{"aria-hidden":!0,size:12}),C(`editor.mentionedYou`)]}),(0,X.jsx)(`button`,{type:`button`,onClick:e=>void U(i,e),children:C(`editor.markMentionRead`)})]}),t.replies.length>0&&(0,X.jsxs)(`div`,{className:`comment-replies`,children:[P.canToggle&&(0,X.jsxs)(`button`,{type:`button`,className:`comment-replies-toggle`,"aria-expanded":P.expanded,"aria-controls":N,onClick:e=>{e.stopPropagation(),S(!P.expanded)},children:[P.expanded?(0,X.jsx)(H,{size:12,"aria-hidden":!0}):(0,X.jsx)(fe,{size:12,"aria-hidden":!0}),P.expanded?C(`editor.hideEarlierReplies`):C(`editor.showEarlierReplies`,{count:P.hiddenCount})]}),(0,X.jsx)(`div`,{className:`comment-replies-list`,id:N,children:P.replies.map(e=>{let t=a?.get(e.id),n=`edit-reply:${e.id}`,i=A[n]?.open&&e.authorId===r;return(0,X.jsxs)(`div`,{"data-comment-reply-id":e.id,className:`comment-reply${s===e.id?` mention-target`:``}`,children:[(0,X.jsxs)(`header`,{children:[(0,X.jsx)(pb,{userId:e.authorId,avatarStyle:e.authorAvatarStyle,name:e.authorDisplayName??e.authorUsername??C(`editor.deletedUser`),username:e.authorUsername,highlighted:b&&y?.has(e.authorId),children:be(e.createdAt,e.editedAt)}),(0,X.jsx)(`span`,{className:`comment-header-actions`,children:e.authorId===r&&!i&&(0,X.jsx)(rb,{kind:`reply`,disabled:F||E,onEdit:()=>ue(n,e.content),onDelete:()=>{L(``),oe(e.id)}})})]}),i?pe(n,C(`editor.editReply`),t=>_(e.id,t)):(0,X.jsx)(`p`,{className:`comment-content`,children:fb(e.content)}),t&&(0,X.jsxs)(`div`,{className:`comment-mention`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(ce,{"aria-hidden":!0,size:12}),C(`editor.mentionedYou`)]}),(0,X.jsx)(`button`,{type:`button`,onClick:e=>void U(t,e),children:C(`editor.markMentionRead`)})]})]},e.id)})})]}),t.resolved&&t.resolvedAt&&(0,X.jsxs)(`div`,{className:`comment-resolution`,children:[(0,X.jsx)(ye,{size:12,"aria-hidden":!0}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(vt,{i18nKey:`editor.resolvedBy`,values:{user:t.resolvedByDisplayName??t.resolvedByUsername??C(`editor.deletedUser`)},components:{user:(0,X.jsx)(`strong`,{className:`comment-resolution-user`,"data-tooltip":t.resolvedByUsername?`@${t.resolvedByUsername}`:void 0,"data-texlite-tooltip-always":!0})}}),` · `,_e(t.resolvedAt)]})]}),!j?.open&&(0,X.jsx)(`button`,{type:`button`,className:`reply-action`,disabled:F||E,onClick:e=>{e.stopPropagation(),ue(`reply`)},children:C(`editor.replyPrompt`)}),pe(`reply`,C(`editor.reply`),m)]}),(0,X.jsx)(Ie,{open:ne,title:C(`editor.deleteCommentTitle`),description:C(`editor.deleteCommentDescription`),confirmLabel:C(`common.delete`),danger:!0,busy:B,error:I,onCancel:()=>ie(!1),onConfirm:()=>void V(null)}),(0,X.jsx)(Ie,{open:!!ae,title:C(`editor.deleteReplyTitle`),description:C(`editor.deleteReplyDescription`),confirmLabel:C(`common.delete`),danger:!0,busy:B,error:I,onCancel:()=>oe(null),onConfirm:()=>{ae&&V(ae)}})]})}function hb({open:e,onOpenChange:t,project:n,projectId:r,onMemberCountChange:i}){let{t:a}=Ne(),[o,s]=(0,J.useState)([]),[c,l]=(0,J.useState)([]),[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(`read`),[m,h]=(0,J.useState)(null),[g,_]=(0,J.useState)(``),[v,b]=(0,J.useState)(!1),[x,S]=(0,J.useState)(!1),C=(0,J.useRef)(null),w=(0,J.useRef)(null),T=(0,J.useRef)(null),E=n.permission===`owner`,D=(0,J.useCallback)(async e=>{let[t,a]=await Promise.all([G(`/api/projects/${r}/members`,{signal:e}),E?G(`/api/users`,{signal:e}):Promise.resolve({users:[]})]);if(e.aborted)return;let o=t.members.filter(e=>e.id!==n.ownerId);s(o),i?.(r,o.length),l(a.users.filter(e=>e.id!==n.ownerId))},[r,n.ownerId,E,i]);(0,J.useEffect)(()=>{if(!e)return;let t=new AbortController;return C.current=t,d(``),p(`read`),h(null),_(``),l([]),s([]),S(!1),b(!0),D(t.signal).catch(e=>{t.signal.aborted||_(W(e))}).finally(()=>{t.signal.aborted||b(!1)}),()=>{t.abort(),C.current===t&&(C.current=null)}},[e,D]);let O=async e=>{let t=C.current;if(E&&t&&!t.signal.aborted&&w.current!==t){w.current=t,S(!0),_(``);try{await e(t.signal),t.signal.aborted||await D(t.signal)}catch(e){t.signal.aborted||_(W(e))}finally{w.current===t&&(w.current=null),t.signal.aborted||S(!1)}}},A=c.filter(e=>!o.some(t=>t.id===e.id)),j=async()=>{A.some(e=>e.id===u)&&await O(async e=>{await G(`/api/projects/${r}/members/${u}`,{method:`PUT`,body:JSON.stringify({permission:f}),signal:e}),e.aborted||(d(``),p(`read`))})},M=async(e,t)=>{await O(n=>G(`/api/projects/${r}/members/${e.id}`,{method:`PUT`,body:JSON.stringify({permission:t}),signal:n}))},N=async()=>{m&&await O(async e=>{await G(`/api/projects/${r}/members/${m.id}`,{method:`DELETE`,signal:e}),e.aborted||h(null)})};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(je,{open:e,wide:!0,className:`share-dialog-modal`,title:a(`projectSettings.share`),description:a(`projectSettings.shareDescription`),onOpenChange:e=>{x||t(e)},onEscapeKeyDown:e=>{T.current?.querySelector(`[role="combobox"][aria-expanded="true"]`)&&e.preventDefault()},footer:(0,X.jsx)(`button`,{disabled:x,onClick:()=>t(!1),children:a(`common.close`)}),children:(0,X.jsxs)(`div`,{className:`share-dialog`,ref:T,"aria-busy":v||x,children:[g&&!m&&(0,X.jsx)(`p`,{className:`error`,role:`alert`,children:g}),(0,X.jsxs)(`div`,{className:`share-owner`,children:[(0,X.jsx)(y,{size:17}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`small`,{children:a(`projects.owner`)}),(0,X.jsx)(`strong`,{children:n.ownerDisplayName??n.ownerUsername})]})]}),E&&(0,X.jsxs)(`div`,{className:`share-add`,children:[(0,X.jsx)(db,{users:A,value:u,onChange:d,disabled:v||x},r),(0,X.jsxs)(`label`,{className:`form-field`,children:[a(`common.permission`),(0,X.jsxs)(`select`,{disabled:v||x,value:f,onChange:e=>p(e.target.value),children:[(0,X.jsx)(`option`,{value:`read`,children:a(`common.readOnly`)}),(0,X.jsx)(`option`,{value:`edit`,children:a(`common.readWrite`)})]})]}),(0,X.jsxs)(`button`,{className:`primary icon-button`,disabled:v||x||!A.some(e=>e.id===u),onClick:()=>void j(),children:[x?(0,X.jsx)(Re,{className:`spin`,size:15}):(0,X.jsx)(xe,{size:15}),a(`projectSettings.addMember`)]})]}),(0,X.jsxs)(`div`,{className:`shared-members-heading`,children:[(0,X.jsx)(`strong`,{children:a(`projectSettings.members`)}),(0,X.jsx)(`span`,{children:o.length})]}),(0,X.jsxs)(`div`,{className:`shared-members`,children:[o.map(e=>(0,X.jsxs)(`div`,{className:`shared-member`,children:[(0,X.jsxs)(`span`,{className:`member-identity`,children:[(0,X.jsx)(he,{userId:e.id,name:e.displayName,username:e.username,avatarStyle:e.avatarStyle,className:`member-avatar`}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{children:e.displayName??e.username}),(0,X.jsxs)(`small`,{children:[`@`,e.username]})]})]}),(0,X.jsxs)(`span`,{className:`member-controls`,children:[(0,X.jsxs)(`select`,{"aria-label":a(`common.permission`),disabled:!E||x,value:e.permission,onChange:t=>void M(e,t.target.value),children:[(0,X.jsx)(`option`,{value:`read`,children:a(`common.readOnly`)}),(0,X.jsx)(`option`,{value:`edit`,children:a(`common.readWrite`)})]}),E&&(0,X.jsx)(`button`,{disabled:x,className:`icon-only danger-text`,title:a(`common.remove`),"aria-label":a(`common.remove`),onClick:()=>{_(``),h(e)},children:(0,X.jsx)(k,{size:15})})]})]},e.id)),v?(0,X.jsxs)(`div`,{className:`share-empty`,role:`status`,children:[(0,X.jsx)(Re,{className:`spin`,size:20}),(0,X.jsx)(`span`,{children:a(`common.loading`)})]}):o.length===0&&(0,X.jsxs)(`div`,{className:`share-empty`,children:[(0,X.jsx)(y,{size:24}),(0,X.jsx)(`span`,{children:a(`projectSettings.noMembers`)})]})]})]})}),(0,X.jsx)(Ie,{open:!!m,title:a(`projectSettings.removeTitle`),description:a(`projectSettings.removeDescription`,{username:m?.username??``}),confirmLabel:a(`common.remove`),danger:!0,busy:x,error:g,onCancel:()=>{x||(h(null),_(``))},onConfirm:()=>void N()})]})}var gb=(0,J.lazy)(()=>f(()=>import(`./CitationLibraryDialog-DE7W81FW.js`).then(e=>({default:e.CitationLibraryDialog})),__vite__mapDeps([13,2,3,11,6,1,4,5,7,8,14,15,16,17,18,19,20,21,22,23,24]),import.meta.url)),_b=(0,J.lazy)(()=>f(()=>import(`./GitDialog-BzyA_IgU.js`).then(e=>({default:e.GitDialog})),__vite__mapDeps([25,2,3,11,6,1,4,5,7,8,26,27,28,29,17]),import.meta.url)),vb=(0,J.lazy)(()=>f(()=>import(`./HistoryDialog-407q3Fe6.js`).then(e=>({default:e.HistoryDialog})),__vite__mapDeps([30,2,3,11,6,1,4,5,7,8,19,31,32,28,29,17,18,20,22,33]),import.meta.url)),yb=(0,J.lazy)(()=>f(()=>import(`./SelectionHistoryDialog-cDxbuXmO.js`).then(e=>({default:e.SelectionHistoryDialog})),__vite__mapDeps([34,2,3,11,6,1,4,5,7,8,31,32,33]),import.meta.url)),bb=(0,J.lazy)(()=>f(()=>import(`./QuickOpenDialog-DKq9iNJ5.js`).then(e=>({default:e.QuickOpenDialog})),__vite__mapDeps([35,2,3,11,6,1,4,5,7,8,14,20]),import.meta.url));function xb({user:e,project:t,projectId:n,activeFile:r,content:i,maxCitationBibtexBytes:a,files:o,directoryEntries:s,readOnly:c,resourcePreview:l,resourcePreviewLoading:u,setResourcePreview:d,setResourcePreviewLoading:f,uploadConflict:p,setUploadConflict:m,dismissUploadFeedback:h,uploadFiles:g,cleanMode:_,setCleanMode:v,cleanCompile:y,newFileOpen:b,setNewFileOpen:x,newFilePath:S,setNewFilePath:C,newFolderOpen:w,setNewFolderOpen:E,newFolderName:D,setNewFolderName:A,selectedFolder:j,fileDialogError:M,setFileDialogError:N,createFile:P,createFolder:F,moveEntry:ee,setMoveEntry:te,moveName:ne,setMoveName:re,moveDestination:ae,setMoveDestination:oe,movePath:I,deleteEntry:L,setDeleteEntry:R,deleteActiveSessions:se,removePath:z,commentOpen:ce,closeComment:B,commentSelection:le,commentText:V,setCommentText:ue,commentSubmitting:de,commentError:fe,addComment:pe,cancelComment:me,commentDraftRestored:he,commentDraftCanRetarget:_e,useCurrentCommentSelection:ve,shareOpen:H,setShareOpen:ye,onSharedMemberCountChange:U,citationLibraryOpen:xe,setCitationLibraryOpen:Se,insertCitationAtCursor:W,quickOpen:G,setQuickOpen:Ce,openFile:we,selectionHistoryTarget:Te,closeSelectionHistory:Ee,historyOpen:De,setHistoryOpen:Oe,gitOpen:ke,setGitOpen:Ae,save:K,permissionDowngrade:Pe,permissionDowngradeBusy:Fe,dismissPermissionDowngrade:Le,discardPermissionDraft:ze}){let{t:q}=Ne();return(0,X.jsxs)(X.Fragment,{children:[Pe&&(0,X.jsx)(je,{open:!0,title:q(`editor.collaboration.permissionDowngradeTitle`),description:Pe.localDraftReady&&Pe.otherTabDraft?q(`editor.collaboration.permissionDowngradeMultipleDrafts`):Pe.otherTabDraft?q(`editor.collaboration.permissionDowngradeOtherTab`):Pe.localDraftReady?q(`editor.collaboration.permissionDowngradeDescription`,{previous:q(`common.readWrite`)}):q(`editor.collaboration.permissionDowngradeNoDraft`),onOpenChange:e=>{!e&&!Fe&&Le()},footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,disabled:Fe,onClick:Le,children:Pe.localDraftReady?q(`editor.collaboration.permissionDowngradeKeep`):q(`common.close`)}),!Pe.otherTabDraft&&(0,X.jsxs)(`button`,{type:`button`,className:`danger`,disabled:Fe,onClick:()=>void ze(),children:[Fe?(0,X.jsx)(Re,{className:`spin`,size:14}):Pe.localDraftReady?(0,X.jsx)(k,{size:14}):(0,X.jsx)(be,{size:14}),Pe.localDraftReady?q(`editor.collaboration.permissionDowngradeDiscard`):q(`editor.collaboration.permissionDowngradeReload`)]})]}),children:(0,X.jsx)(`div`,{})}),(0,X.jsxs)(je,{open:!!l,extraWide:l?.kind===`image`||l?.kind===`pdf`||l?.kind===`text`,title:l?.path??``,description:l?.kind===`large`?q(`editor.resourceTooLarge`,{size:ge(l.size,{maximumUnit:`MB`}),limit:ge(l.limitBytes??10485760,{maximumUnit:`MB`})}):q(`editor.resourcePreview.${l?.kind??`text`}`),onOpenChange:e=>{e||(d(null),f(!1))},footer:l&&(0,X.jsxs)(`a`,{className:`primary resource-download`,href:`${l.url}&download=1`,download:!0,children:[(0,X.jsx)(ie,{size:14}),q(`editor.downloadResource`)]}),children:[l?.kind===`large`&&(0,X.jsxs)(`div`,{className:`resource-preview-message`,children:[(0,X.jsx)(O,{size:34}),(0,X.jsx)(`strong`,{children:q(`editor.resourceTooLargeTitle`)}),(0,X.jsx)(`span`,{children:q(`editor.resourceTooLargeDescription`)})]}),l?.kind===`unsupported`&&(0,X.jsxs)(`div`,{className:`resource-preview-message`,children:[(0,X.jsx)(Vt,{size:34}),(0,X.jsx)(`strong`,{children:q(`editor.resourceUnsupportedTitle`)}),(0,X.jsx)(`span`,{children:q(`editor.resourceUnsupportedDescription`)})]}),l?.kind===`image`&&(0,X.jsx)(`div`,{className:`resource-image-wrap`,children:(0,X.jsx)(`img`,{className:`resource-image`,src:l.url,alt:l.path})}),l?.kind===`pdf`&&(0,X.jsx)(`iframe`,{className:`resource-pdf`,src:l.url,title:l.path}),l?.kind===`text`&&(u?(0,X.jsxs)(`div`,{className:`resource-preview-message`,children:[(0,X.jsx)(Re,{className:`spin`,size:24}),(0,X.jsx)(`span`,{children:q(`common.loading`)})]}):(0,X.jsx)(`pre`,{className:`resource-text`,children:l.content}))]}),(0,X.jsx)(Ie,{open:!!p,title:q(`editor.uploadOverwriteTitle`),description:q(`editor.uploadOverwriteDescription`,{count:p?.collisions.length??0,files:p?.collisions.join(`, `)??``}),confirmLabel:q(`editor.uploadOverwrite`),danger:!0,onCancel:()=>{m(null),h()},onConfirm:()=>{let e=p;m(null),e&&g(e.files,new Set(e.collisions),e.directory)}}),(0,X.jsx)(Ie,{open:!!_,title:q(_===`cache`?`editor.cleanCacheConfirmTitle`:`editor.cleanArtifactsConfirmTitle`),description:q(_===`cache`?`editor.cleanCacheConfirmDescription`:`editor.cleanArtifactsConfirmDescription`),confirmLabel:q(`editor.cleanConfirm`),danger:_===`artifacts`,onCancel:()=>v(null),onConfirm:()=>{let e=_;v(null),e&&y(e)}}),(0,X.jsx)(je,{open:b,title:q(`editor.newFile`),description:q(`editor.newFileDescription`),onOpenChange:e=>{x(e),e||N(``)},footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{onClick:()=>x(!1),children:q(`common.cancel`)}),(0,X.jsx)(`button`,{className:`primary`,onClick:()=>void P(),children:q(`common.create`)})]}),children:(0,X.jsxs)(X.Fragment,{children:[M&&(0,X.jsx)(`p`,{className:`error dialog-error`,children:M}),(0,X.jsxs)(`label`,{className:`form-field`,children:[q(`editor.filePath`),(0,X.jsx)(`input`,{autoFocus:!0,value:S,onChange:e=>C(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),P())}})]})]})}),(0,X.jsx)(je,{open:w,title:q(`editor.newFolder`),description:q(`editor.folderDestination`,{folder:j||q(`editor.projectRoot`)}),onOpenChange:e=>{E(e),e||N(``)},footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{onClick:()=>E(!1),children:q(`common.cancel`)}),(0,X.jsx)(`button`,{className:`primary`,onClick:()=>void F(),children:q(`common.create`)})]}),children:(0,X.jsxs)(X.Fragment,{children:[M&&(0,X.jsx)(`p`,{className:`error dialog-error`,children:M}),(0,X.jsxs)(`label`,{className:`form-field`,children:[q(`editor.folderName`),(0,X.jsx)(`input`,{autoFocus:!0,value:D,onChange:e=>A(e.target.value),onKeyDown:e=>{e.key===`Enter`&&F()}})]})]})}),(0,X.jsx)(je,{open:!!ee,title:q(`editor.moveTitle`,{name:ee?.path.split(`/`).at(-1)??``}),description:q(`editor.moveDescription`),onOpenChange:e=>{e||(te(null),re(``),N(``))},footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{onClick:()=>te(null),children:q(`common.cancel`)}),(0,X.jsx)(`button`,{className:`primary`,disabled:!ne.trim(),onClick:()=>void I(),children:q(`editor.moveApply`)})]}),children:(0,X.jsxs)(X.Fragment,{children:[M&&(0,X.jsx)(`p`,{className:`error dialog-error`,children:M}),(0,X.jsxs)(`label`,{className:`form-field`,children:[q(`editor.pathName`),(0,X.jsx)(`input`,{autoFocus:!0,value:ne,onChange:e=>re(e.target.value),onKeyDown:e=>{e.key===`Enter`&&I()}})]}),(0,X.jsxs)(`label`,{className:`form-field`,children:[q(`editor.destinationFolder`),(0,X.jsxs)(`select`,{value:ae,onChange:e=>oe(e.target.value),children:[(0,X.jsx)(`option`,{value:``,children:q(`editor.projectRoot`)}),s.filter(e=>ee?.type!==`directory`||e.path!==ee.path&&!e.path.startsWith(`${ee.path}/`)).map(e=>(0,X.jsx)(`option`,{value:e.path,children:e.path},e.path))]})]})]})}),(0,X.jsx)(je,{open:!!L,title:q(`editor.deletePathTitle`,{name:L?.path.split(`/`).at(-1)??``}),description:se.length?q(`editor.deletePathActiveDescription`,{count:se.length,path:L?.path??``,users:[...new Set(se.map(e=>e.name))].join(`, `)}):q(`editor.deletePathDescription`,{path:L?.path??``}),onOpenChange:e=>{e||(R(null),N(``))},footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{onClick:()=>R(null),children:q(`common.cancel`)}),(0,X.jsx)(`button`,{className:`danger`,onClick:()=>void z(),children:q(`common.delete`)})]}),children:(0,X.jsxs)(X.Fragment,{children:[M&&(0,X.jsx)(`p`,{className:`error dialog-error`,children:M}),se.length>0&&(0,X.jsxs)(`p`,{className:`warning`,children:[(0,X.jsx)(T,{size:15}),q(`editor.deletePathWillClose`)]})]})}),(0,X.jsxs)(je,{open:ce,draggable:!0,wide:!0,className:`comment-compose-modal`,title:q(`editor.addComment`),description:le.selectedText?q(`editor.commentDescription`,{count:le.endOffset-le.startOffset}):q(`editor.pointComment`),onOpenChange:e=>{e||B()},footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,disabled:de,onClick:me,children:q(`common.cancel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`primary`,"aria-busy":de,disabled:de||!V.trim(),onClick:()=>void pe(),children:[de&&(0,X.jsx)(Re,{className:`spin`,size:14}),q(de?`editor.commentSending`:`editor.addComment`)]})]}),children:[fe&&(0,X.jsx)(`p`,{className:`error dialog-error`,children:fe}),he&&(0,X.jsxs)(`p`,{className:`comment-draft-restored`,children:[(0,X.jsx)(`span`,{children:q(`editor.commentDraftRestored`)}),_e&&(0,X.jsx)(`button`,{type:`button`,disabled:de,onClick:ve,children:q(`editor.commentDraftUseSelection`)})]}),(0,X.jsxs)(`label`,{className:`form-field`,children:[q(`editor.commentContent`),(0,X.jsx)(ab,{projectId:n,autoFocus:!0,rows:5,disabled:de,value:V,placeholder:q(`editor.commentPlaceholder`),onChange:ue,onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),e.stopPropagation(),pe())}})]}),le.selectedText&&(0,X.jsx)(`blockquote`,{className:`selection-preview`,children:le.selectedText})]}),(0,X.jsx)(hb,{open:H,onOpenChange:ye,project:t,projectId:n,onMemberCountChange:U}),xe&&(0,X.jsx)(Me,{title:q(`citationLibrary.title`),onClose:()=>Se(!1),children:(0,X.jsx)(gb,{open:!0,onOpenChange:Se,currentFile:r,currentSource:i,readOnly:c,currentUserId:e.id,maxBibtexBytes:a,onInsert:W})}),G&&(0,X.jsx)(J.Suspense,{fallback:null,children:(0,X.jsx)(bb,{open:!0,files:o,onOpenChange:Ce,onOpenFile:e=>{let t=o.find(t=>t.path===e);t&&we(t)}})}),Te&&(0,X.jsx)(J.Suspense,{fallback:null,children:(0,X.jsx)(yb,{open:!0,onOpenChange:e=>{e||Ee()},project:t,filePath:Te.filePath,selection:Te.selection,currentSource:Te.source})}),De&&(0,X.jsx)(J.Suspense,{fallback:null,children:(0,X.jsx)(vb,{open:!0,onOpenChange:Oe,project:t,onBeforeMutation:t.permission===`read`?async()=>!0:K})}),t.ownerId===e.id&&ke&&(0,X.jsx)(J.Suspense,{fallback:null,children:(0,X.jsx)(_b,{open:!0,onOpenChange:Ae,project:t,onBeforeMutation:K})})]})}function Sb({participants:e,selectedIds:t,topLevelOnly:n,onToggle:r,onClear:i,onTopLevelOnlyChange:a}){let{t:o}=Ne(),[s,c]=(0,J.useState)(!1),l=(0,J.useRef)(null),u=t.size>0,d=e.find(e=>t.has(e.authorId)),f=e=>e.authorDisplayName??e.authorUsername??o(`editor.deletedUser`),p=u?d?t.size===1?f(d):o(`editor.commentParticipantsSelected`,{name:f(d),count:t.size-1}):o(`editor.commentParticipantsCount`,{count:t.size}):o(`editor.commentParticipantsAll`);return(0,X.jsx)(`div`,{className:`comment-participant-filter`,children:(0,X.jsxs)(`div`,{className:`comment-participants-trigger-group${u?` active`:``}`,children:[(0,X.jsxs)(me,{open:s,onOpenChange:c,children:[(0,X.jsx)(L,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,className:`comment-participants-toggle`,"aria-label":`${o(`editor.commentParticipants`)}: ${p}`,children:[(0,X.jsx)(y,{size:13,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`comment-participants-summary`,children:u&&d?f(d):p}),u&&d&&t.size>1&&(0,X.jsxs)(`span`,{className:`comment-participants-extra-count`,children:[`+`,t.size-1]}),(0,X.jsx)(V,{size:12,"aria-hidden":!0,className:s?`expanded`:``})]})}),(0,X.jsx)(_,{children:(0,X.jsxs)(v,{ref:l,className:`comment-participants-popover`,side:`bottom`,align:`end`,sideOffset:6,collisionPadding:10,"aria-label":o(`editor.commentParticipants`),onOpenAutoFocus:e=>{e.preventDefault();let t=l.current?.querySelector(`input[type="checkbox"]:not(:disabled)`);t?t.focus():l.current?.focus()},children:[(0,X.jsxs)(`div`,{className:`comment-participants-heading`,children:[(0,X.jsx)(E,{children:o(`editor.commentParticipants`)}),u&&(0,X.jsx)(`button`,{type:`button`,onClick:i,children:o(`editor.commentParticipantsClear`)})]}),(0,X.jsxs)(`div`,{className:`comment-participants-list`,children:[e.map(e=>{let n=f(e),i=t.has(e.authorId);return(0,X.jsxs)(`label`,{className:`comment-participant-option${i?` selected`:``}`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:i,onChange:()=>r(e.authorId)}),(0,X.jsx)(he,{userId:e.authorId,name:n,username:e.authorUsername,avatarStyle:e.authorAvatarStyle,className:`comment-participant-avatar`}),(0,X.jsxs)(`span`,{className:`comment-participant-identity`,children:[(0,X.jsx)(`strong`,{children:n}),e.authorUsername&&(0,X.jsxs)(`small`,{children:[`@`,e.authorUsername]})]})]},e.authorId??`deleted`)}),e.length===0&&(0,X.jsx)(`p`,{className:`comment-participants-empty`,children:o(`editor.commentNoParticipants`)})]}),(0,X.jsxs)(`label`,{className:`comment-participants-root-only`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:n,disabled:!u,onChange:e=>a(e.target.checked)}),o(`editor.commentTopLevelOnly`)]})]})})]}),u&&(0,X.jsx)(`button`,{type:`button`,className:`comment-participants-clear`,"aria-label":o(`editor.commentParticipantsClear`),onClick:i,children:(0,X.jsx)(D,{size:12,"aria-hidden":!0})})]})})}function Cb(e,t,n,r,i){let a=t.map(e=>({comment:e,exitAt:null})),o=new Set(t.map(e=>e.id)),s=new Map(n.map(e=>[e.id,e]));return e.forEach((e,t)=>{let n=s.get(e.comment.id);o.has(e.comment.id)||!n||u_(n,r)||a.splice(Math.min(t,a.length),0,{comment:n,exitAt:e.exitAt??i+280+50})}),a}function wb(e,t,n,r){let[i,a]=(0,J.useState)(()=>({contextKey:r,visible:e,comments:t,entries:e.map(e=>({comment:e,exitAt:null}))}));(i.contextKey!==r||i.visible!==e||i.comments!==t)&&a({contextKey:r,visible:e,comments:t,entries:i.contextKey===r?Cb(i.entries,e,t,n,Date.now()):e.map(e=>({comment:e,exitAt:null}))});let o=(0,J.useCallback)(e=>{a(t=>({...t,entries:t.entries.filter(t=>t.comment.id!==e||t.exitAt===null)}))},[]);return(0,J.useEffect)(()=>{let e=i.entries.flatMap(e=>e.exitAt===null?[]:[e.exitAt]);if(!e.length)return;let t=window.setTimeout(()=>{let e=Date.now();a(t=>({...t,entries:t.entries.filter(t=>t.exitAt===null||t.exitAt>e)}))},Math.max(0,Math.min(...e)-Date.now()));return()=>window.clearTimeout(t)},[i.entries]),{entries:i.entries,finishExit:o}}function Tb(e,t,n,r){let[i,a]=(0,J.useState)(()=>({contextKey:n,limit:50})),o=i.contextKey===n?i.limit:50;if(t)for(let t of r){if(!t)continue;let n=e.findIndex(e=>e.id===t)+1;o=Math.max(o,Math.ceil(n/50)*50)}(i.contextKey!==n||i.limit!==o)&&a({contextKey:n,limit:o});let s=(0,J.useMemo)(()=>t?e.slice(0,o):e,[e,t,o]),c=(0,J.useCallback)(()=>{a(e=>({contextKey:n,limit:(e.contextKey===n?e.limit:50)+50}))},[n]);return{shown:s,hasMore:s.length<e.length,loadMore:c}}var Eb=(0,J.lazy)(()=>f(()=>import(`./ProjectSettings-BfvAiyC6.js`).then(e=>({default:e.ProjectSettings})),__vite__mapDeps([36,2,3,11,6,1,4,5,7,8,19,27,37,18,38,39,22]),import.meta.url));function Db({commentsHost:e,sidePanel:t,onClose:n,project:r,projectId:i,site:a,files:o,currentUserId:s,comments:c,commentDraftStore:l,commentsLoading:u,commentsError:d,onRetryComments:f,unreadMentions:m,activeFile:h,singleCommentId:g,onShowAllComments:_,hasProjectCommentsScope:v,commentScope:y,onCommentScopeChange:b,focusedCommentId:x,commentFocusNonce:S,onMarkMentionRead:C,onMarkAllMentionsRead:w,onClearFocusComment:T,targetCommentId:E,targetReplyId:O,onFocusComment:k,onToggleComment:A,onReplyComment:j,onEditComment:M,onDeleteComment:N,onEditCommentReply:P,onDeleteCommentReply:F,dictionaryWords:ee,onDictionaryChange:te,editorPreferences:ne,onEditorPreferences:re,spellCheckCount:ie,spellCheckUniqueCount:ae,spellCheckIndex:oe,onSpellCheckNavigate:I,onProject:L}){let{t:R}=Ne(),z=!!g,[B,le]=(0,J.useState)(`unresolved`),[V,ue]=(0,J.useState)(!1),[de,pe]=(0,J.useState)(`source`),me=R(de===`time`?`editor.commentSortTime`:y===`project`?`editor.commentSortSourceProject`:`editor.commentSortSource`),[he,ge]=(0,J.useState)(()=>new Set),[_e,ve]=(0,J.useState)(!0),[H,ye]=(0,J.useState)(()=>new Map),[be,U]=(0,J.useState)(null),xe=(0,J.useRef)(new Map(c.map(e=>[e.id,e.resolved]))),Se=(0,J.useMemo)(()=>o_(c),[c]),W=(0,J.useMemo)(()=>{let e=c.filter(e=>l_(e,{activeFile:h,scope:y})),t=e.filter(e=>e.resolved).length;return{unresolved:e.length-t,resolved:t}},[h,y,c]),G=(0,J.useMemo)(()=>f_(c,{activeFile:h,scope:y,unreadMentions:m,participantIds:he,topLevelOnly:_e,filter:B,unreadMentionsOnly:!0}).length,[h,y,c,m,he,_e,B]),Ce=(0,J.useMemo)(()=>g?m_(c,g,h):p_(c,{activeFile:h,scope:y,filter:B,unreadMentions:m,sort:de,participantIds:he,topLevelOnly:_e,unreadMentionsOnly:V},[E,x]),[h,g,B,y,c,x,E,m,de,he,_e,V]),we=x&&Ce.some(e=>e.id===x)?x:E&&Ce.some(e=>e.id===E)?E:null,Te=z?Ce[0]?.id??null:be&&Ce.some(e=>e.id===be)?be:we;(0,J.useEffect)(()=>{U(null)},[x,S,E,O,h,y]),(0,J.useEffect)(()=>{be&&!Ce.some(e=>e.id===be)&&U(null)},[be,Ce]);let Ee=v_(Ce,Te),De=JSON.stringify([t,g,y,y===`file`?h:``,B,de,[...he].sort(),_e,V]),Oe=JSON.stringify([i,y,y===`file`?h:``,B,de,[...he].sort(),_e,V]),{shown:ke,hasMore:Ae,loadMore:K}=Tb(Ce,!z&&B===`resolved`,Oe,[E,x,be]),{entries:je,finishExit:Me}=wb(ke,c,z?`unresolved`:B,De);(0,J.useEffect)(()=>{let e=c.some(e=>(e.id===x||e.id===E)&&xe.current.has(e.id)&&xe.current.get(e.id)!==e.resolved);xe.current=new Map(c.map(e=>[e.id,e.resolved])),e&&T()},[c,x,E,T]),(0,J.useEffect)(()=>{if(t!==`comments`||be)return;let e=E&&O?`.comments [data-comment-reply-id="${O}"]`:E?`.comments .comment-thread[data-comment-id="${E}"]`:we?`.comments .comment-thread[data-comment-id="${we}"]`:``;if(!e)return;let n=document.querySelector(e);if(!n)return;let r=window.requestAnimationFrame(()=>n.scrollIntoView({block:E?`center`:`nearest`,behavior:`smooth`}));return()=>window.cancelAnimationFrame(r)},[t,be,we,S,E,O,Ce]);let Pe=e=>{U(null),k(e)},Ie=e=>{let t=y_(Ce,Te,e);t?Pe(t):T()},Le=async e=>{let t=await C(e);if(!t||z||!V)return t;let n=m.find(t=>t.id===e)?.commentId;return n&&(m.some(t=>t.id!==e&&t.commentId===n)||(x===n||E===n)&&T()),t},Re=async()=>{await w()&&V&&T()},ze=e=>{e!==y&&(U(null),T(),b(e))},q=e=>{e!==B&&(U(null),T(),le(e))},Be=()=>{U(null),T()},Ve=e=>{Be(),he.size===1&&he.has(e)&&ve(!0),ge(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};if(!t)return null;let He=(0,X.jsxs)(`aside`,{className:`context-panel`,"aria-label":R(t===`comments`?`editor.sourceComments`:`editor.projectSettings`),children:[t===`comments`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`drawer-title`,children:[(0,X.jsx)(`strong`,{children:R(z?`editor.currentComment`:`editor.sourceComments`)}),(0,X.jsxs)(`span`,{className:`drawer-title-actions`,children:[!z&&m.length>0&&(0,X.jsxs)(`button`,{className:`drawer-mention-read-all`,type:`button`,onClick:()=>void Re(),title:R(`editor.markAllMentionsRead`),children:[(0,X.jsx)(ce,{"aria-hidden":!0,size:13}),(0,X.jsx)(`span`,{children:R(`editor.markAllMentionsRead`)})]}),(0,X.jsx)(`button`,{"aria-label":R(`common.close`),onClick:n,children:(0,X.jsx)(D,{size:17})})]})]}),z?(0,X.jsx)(`div`,{className:`comment-current-controls`,children:(0,X.jsxs)(`button`,{type:`button`,onClick:_,children:[(0,X.jsx)($t,{size:14,"aria-hidden":!0}),R(`editor.viewAllComments`)]})}):(0,X.jsxs)(`div`,{className:`comment-review-controls`,children:[(0,X.jsxs)(`div`,{className:`comment-review-queue-row`,children:[v&&(0,X.jsxs)(`div`,{className:`comment-review-group`,role:`group`,"aria-label":R(`editor.commentScope`),children:[(0,X.jsx)(`button`,{type:`button`,className:y===`file`?`active`:``,"aria-pressed":y===`file`,onClick:()=>ze(`file`),children:R(`editor.commentScopeFile`)}),(0,X.jsx)(`button`,{type:`button`,className:y===`project`?`active`:``,"aria-pressed":y===`project`,onClick:()=>ze(`project`),children:R(`editor.commentScopeProject`)})]}),(0,X.jsxs)(`div`,{className:`comment-review-group`,role:`group`,"aria-label":R(`editor.commentFilter`),children:[(0,X.jsx)(`button`,{type:`button`,className:B===`unresolved`?`active`:``,"aria-pressed":B===`unresolved`,onClick:()=>q(`unresolved`),children:R(`editor.commentFilterUnresolved`,{count:W.unresolved})}),(0,X.jsx)(`button`,{type:`button`,className:B===`resolved`?`active`:``,"aria-pressed":B===`resolved`,onClick:()=>q(`resolved`),children:R(`editor.commentFilterResolved`,{count:W.resolved})})]}),(0,X.jsxs)(`div`,{className:`comment-review-navigation`,children:[(0,X.jsx)(`button`,{type:`button`,disabled:Ee<=1,"aria-label":R(`editor.commentPrevious`),title:R(`editor.commentPrevious`),onClick:()=>Ie(-1),children:(0,X.jsx)(se,{size:14})}),(0,X.jsx)(`output`,{"aria-live":`polite`,children:R(`editor.commentPosition`,{current:Ee,total:Ce.length})}),(0,X.jsx)(`button`,{type:`button`,disabled:Ce.length===0||Ee>0&&Ee>=Ce.length,"aria-label":R(`editor.commentNext`),title:R(`editor.commentNext`),onClick:()=>Ie(1),children:(0,X.jsx)(fe,{size:14})})]})]}),(0,X.jsxs)(`div`,{className:`comment-review-sort-row`,children:[(0,X.jsx)(Sb,{participants:Se,selectedIds:he,topLevelOnly:_e,onToggle:Ve,onClear:()=>{Be(),ge(new Set),ve(!0)},onTopLevelOnlyChange:e=>{Be(),ve(e)}},`${y}:${y===`file`?h:`project`}`),(0,X.jsxs)(`button`,{type:`button`,className:`comment-unread-toggle${V?` active`:``}`,"aria-pressed":V,"aria-label":R(`editor.commentUnreadMentionsHint`),title:R(`editor.commentUnreadMentionsHint`),onClick:()=>{Be(),ue(e=>!e)},children:[(0,X.jsx)(ce,{size:12,"aria-hidden":!0}),R(`editor.commentUnreadMentionsOnly`),(0,X.jsx)(`span`,{children:G})]}),(0,X.jsxs)(`label`,{className:`comment-review-sort`,"data-texlite-tooltip-always":!0,"data-tooltip":me,children:[(0,X.jsx)(`span`,{className:`sr-only`,children:R(`editor.commentSort`)}),de===`source`?(0,X.jsx)(p,{size:12,"aria-hidden":!0}):(0,X.jsx)(bt,{size:12,"aria-hidden":!0}),(0,X.jsxs)(`select`,{value:de,"aria-label":`${R(`editor.commentSort`)}: ${me}`,onChange:e=>{Be(),pe(e.target.value)},children:[(0,X.jsx)(`option`,{value:`source`,children:R(`editor.commentSortSourceShort`)}),(0,X.jsx)(`option`,{value:`time`,children:R(`editor.commentSortTimeShort`)})]})]})]})]}),d&&(0,X.jsxs)(`div`,{className:`comment-review-error`,role:`alert`,children:[(0,X.jsx)(`span`,{children:d}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void f(),children:R(`common.retry`)})]}),u&&(0,X.jsx)(`div`,{className:`comment-review-loading`,role:`status`,children:R(`common.loading`)}),(0,X.jsxs)(`div`,{className:`comments`,children:[je.map(({comment:e,exitAt:t})=>{let n=m.find(t=>t.commentId===e.id&&!t.replyId)?.id,r=new Map(m.filter(t=>t.commentId===e.id&&t.replyId).map(e=>[e.replyId,e.id]));return(0,X.jsx)(`div`,{className:`comment-thread-slot${t===null?``:` is-exiting`}`,inert:t!==null||void 0,"aria-hidden":t!==null||void 0,style:{"--comment-exit-duration":`280ms`},onAnimationEnd:n=>{n.target===n.currentTarget&&t!==null&&Me(e.id)},children:(0,X.jsx)(`div`,{className:`comment-thread-slot-content`,children:(0,X.jsx)(mb,{projectId:i,comment:e,draftStore:l,currentUserId:s,unreadCommentMentionId:n,unreadReplyMentionIds:r,highlightedComment:E===e.id&&!O,highlightedReplyId:E===e.id?O:null,currentComment:Te===e.id,showFilePath:!z&&y===`project`&&v,replyExpansion:H.get(e.id),onReplyExpansionChange:t=>{ye(n=>n.get(e.id)===t?n:new Map(n).set(e.id,t))},selectedParticipantIds:z?void 0:he,highlightReplyParticipants:!z&&!_e,onMarkMentionRead:Le,onFocus:()=>Pe(e),onActivate:()=>U(e.id),onToggle:()=>A(e),onReply:t=>j(e,t),onEdit:t=>M(e,t),onDelete:()=>N(e),onEditReply:(t,n)=>P(e,t,n),onDeleteReply:t=>F(e,t)})})},e.id)}),je.length===0&&!u&&!d&&(0,X.jsxs)(`div`,{className:`comment-review-empty`,role:`status`,children:[(0,X.jsx)(`span`,{className:`comment-review-empty-icon`,"aria-hidden":`true`,children:(0,X.jsx)($t,{size:23,strokeWidth:1.5})}),(0,X.jsx)(`p`,{children:z?R(c.some(e=>e.id===g&&e.resolved)?`editor.currentCommentResolved`:`editor.currentCommentUnavailable`):W.unresolved+W.resolved>0?R(`editor.commentNoMatches`):R(`editor.noComments`)})]}),!z&&B===`resolved`&&Ae&&(0,X.jsx)(`div`,{className:`comment-review-pagination`,children:(0,X.jsx)(`button`,{type:`button`,onClick:K,children:R(`editor.commentLoadMore`)})})]})]}),t===`settings`&&(0,X.jsx)(Fe,{onClose:n,children:(0,X.jsx)(Eb,{onClose:n,project:r,projectId:i,site:a,files:o,dictionaryWords:ee,onDictionaryChange:te,editorPreferences:ne,onEditorPreferences:re,spellCheckCount:ie,spellCheckUniqueCount:ae,spellCheckIndex:oe,onSpellCheckNavigate:I,onProject:L},i)})]});return t===`comments`&&e!==void 0?e?(0,Jy.createPortal)(He,e):null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(jm,{className:`resize-handle`}),(0,X.jsx)(Em,{id:`context`,defaultSize:`20%`,minSize:`15%`,maxSize:`38%`,children:He})]})}function Ob(e){if(typeof globalThis.requestAnimationFrame==`function`){let t=globalThis.requestAnimationFrame(e);return()=>globalThis.cancelAnimationFrame(t)}let t=globalThis.setTimeout(e,0);return()=>globalThis.clearTimeout(t)}function kb(){let e={line:1,column:1,offset:0},t=e.line,n=null,r=null,i=new Set,a=()=>{for(let e of i)e()},o=()=>{r=null;let e=n;n=null,e!==null&&e!==t&&(t=e,a())},s=e=>{n=e,r===null&&(r=Ob(o))};return{getCursor:()=>e,getOutlineLine:()=>t,subscribe:e=>(i.add(e),()=>i.delete(e)),update:(n,i,a)=>{(e.line!==n||e.column!==i||e.offset!==a)&&(e={line:n,column:i,offset:a},(n!==t||r!==null)&&s(n))},reset:()=>{r?.(),r=null,n=null,e={line:1,column:1,offset:0},t!==1&&(t=1,a())},dispose:()=>{r?.(),r=null,n=null}}}function Ab(e,t,n){return e.mainFile===t?e.items:!t||n.filePath!==t?[]:jb(n.content).map(e=>({...e,path:t}))}function jb(e){let t=[],n=/^\s*\\(part|chapter|section|subsection|subsubsection)\*?(?:\[[^\]]*\])?\{([^}]*)\}/,r={part:0,chapter:0,section:1,subsection:2,subsubsection:3};return e.split(`
|
|
18
|
-
`).forEach((e,i)=>{let a=e.match(n);a&&t.push({level:r[a[1]],title:a[2],line:i+1})}),t}var Mb=e({ProjectWorkspace:()=>zb}),Nb=(0,J.lazy)(()=>f(()=>import(`./AgentTerminal-fsHpIB_c.js`).then(e=>({default:e.AgentTerminal})),__vite__mapDeps([40,2,3,7,11,6,1,4,5,8,14,15,41,17,18,19,42,43,21]),import.meta.url)),Pb=(0,J.lazy)(()=>f(()=>import(`./WordCountDialog-C4okQWS3.js`).then(e=>({default:e.WordCountDialog})),__vite__mapDeps([44,3,2,11,6,1,4,5,7,8,39]),import.meta.url)),Fb=null;function Ib(){return Fb||=f(()=>import(`./citationLibrary-BzlqZiFU.js`),__vite__mapDeps([24,2]),import.meta.url).catch(e=>{throw Fb=null,e}),Fb}function Lb(e){return e instanceof Error&&e.name===`AbortError`}var Rb=300;function zb(e){return(0,X.jsx)(x_,{children:(0,X.jsx)(Qv,{projectId:e.projectId,user:e.user,children:t=>(0,X.jsx)(Bb,{...e,collaboration:t})})},`${e.user.id}:${e.projectId}`)}function Bb({site:e,user:t,projectId:n,preload:r,mentionId:i=null,onMentionTargeted:a,onMentionsRead:o,onBack:s,collaboration:c}){let{t:u}=Ne(),d=(0,J.useRef)(n),f=z(t.id,n),[p,m]=(0,J.useState)(!1);d.current=n;let[h,g]=(0,J.useState)(null),_=(0,J.useCallback)((e,t)=>{g(n=>n?.id===e&&n.sharedMemberCount!==t?{...n,sharedMemberCount:t}:n)},[]);(0,J.useEffect)(()=>(document.title=h?.name?`${e.siteName} | ${h.name}`:e.siteName,()=>{document.title=e.siteName}),[h?.name,e.siteName]);let[v,y]=(0,J.useState)(!1),[b,x]=(0,J.useState)([]),[S,C]=(0,J.useState)(null),[w,E]=(0,J.useState)({mainFile:``,items:[]}),[O,k]=(0,J.useState)(``),[A,j]=(0,J.useState)(``),[M,N]=(0,J.useState)(``),[P,F]=(0,J.useState)({filePath:``,content:``}),[ee,ne]=(0,J.useState)({path:``,hasIncludes:!1}),[ie,ae]=(0,J.useState)(``),[oe,I]=(0,J.useState)(!1),[L,R]=(0,J.useState)(`editor.saved`),[se,ce]=(0,J.useState)(null),B=(0,J.useRef)(se);B.current=se;let le=(0,J.useRef)(null);le.current||=kb();let V=le.current,[ue,de]=(0,J.useState)(`pdf`),[fe,me]=(0,J.useState)(`log`),he=e=>{e===`pdf`?de(`pdf`):(e===`diagnostics`||me(e),de(`diagnostics`))},{workspaceLayout:ge,setWorkspaceLayout:_e}=xy(t.id,n),[ve,H]=(0,J.useState)(``),[ye,be]=(0,J.useState)(``),[U,xe]=(0,J.useState)({selectedText:``,startOffset:0,endOffset:0}),Se=(0,J.useRef)({selectedText:``,startOffset:0,endOffset:0}),Ce=e=>{let t=Se.current;(t.selectedText!==e.selectedText||t.startOffset!==e.startOffset||t.endOffset!==e.endOffset)&&(Se.current=e,xe(e))},[we,Te]=(0,J.useState)(null),[Ee,De]=(0,J.useState)(null),[Oe,ke]=(0,J.useState)(null),[K,je]=(0,J.useState)(null),[Pe,Fe]=(0,J.useState)(null),[Ie,ze]=(0,J.useState)(null),[q,Be]=(0,J.useState)(!1),[Ve,He]=(0,J.useState)(!1),[Ue,We]=(0,J.useState)(!1),[Ge,Ke]=(0,J.useState)(!1),[qe,Je]=(0,J.useState)(null),[Ye,Xe]=(0,J.useState)(!1),[Ze,Qe]=(0,J.useState)(null),[$e,et]=(0,J.useState)(!1),[tt,nt]=(0,J.useState)(!1),[rt,it]=(0,J.useState)(`full`),[at,ot]=(0,J.useState)(``),[st,ct]=(0,J.useState)(!1),[lt,ut]=(0,J.useState)(``),[dt,ft]=(0,J.useState)(null),[pt,mt]=(0,J.useState)(!1),[ht,gt]=(0,J.useState)(null),[_t,vt]=(0,J.useState)(!1),[yt,bt]=(0,J.useState)(()=>te(t.id,n));(0,J.useEffect)(()=>{let e=document.documentElement,t=yt.showTooltips?`on`:`off`;return e.setAttribute(`data-texlite-tooltips`,t),()=>{e.getAttribute(`data-texlite-tooltips`)===t&&e.removeAttribute(`data-texlite-tooltips`)}},[yt.showTooltips]);let[xt,St]=(0,J.useState)([]),Ct=(0,J.useRef)([]);Ct.current=xt;let wt=(0,J.useRef)(null),Tt=(0,J.useRef)(null),Et=(0,J.useRef)(0),Dt=(0,J.useRef)(0),Y=(0,J.useRef)(``),Ot=(0,J.useRef)(``),kt=(0,J.useRef)(()=>void 0),At=(0,J.useRef)(ge),jt=(0,J.useRef)(0),Mt=(0,J.useRef)(null),Nt=(0,J.useRef)(null),Pt=(0,J.useRef)(null),Ft=(0,J.useRef)(null),It=(0,J.useRef)(null),Lt=(0,J.useRef)(null),Rt=(0,J.useRef)(null),zt=(0,J.useRef)(null),Bt=(0,J.useRef)(null),Vt=(0,J.useRef)(!1),Ht=(0,J.useRef)(null),Wt=(0,J.useRef)(s),Gt=(0,J.useRef)(a),Kt=(0,J.useRef)(o);Wt.current=s,Gt.current=a,Kt.current=o,Y.current=O,Ot.current=A,At.current=ge,(0,J.useEffect)(()=>{if(!ye)return;let e=window.setTimeout(()=>be(``),3e3);return()=>window.clearTimeout(e)},[ye]);let qt=(0,J.useCallback)((e,t,n=0)=>{V.update(e,t,n)},[V]);(0,J.useEffect)(()=>()=>V.dispose(),[V]),(0,J.useEffect)(()=>()=>{zt.current?.abort(),zt.current=null},[]);let Jt=e=>{let t=Ct.current,n=e(t);n!==t&&(Ct.current=n,St(n))};(0,J.useEffect)(()=>{Ct.current=[],St([]),gt(null),Je(null),Lt.current?.abort(),Lt.current=null,Rt.current?.abort(),Rt.current=null,zt.current?.abort(),zt.current=null,Bt.current=null,je(null),Fe(null),ze(null),nt(!1),ct(!1),ut(``),ft(null)},[n]);let Yt=e=>{let t=Ct.current,n=t.indexOf(e);if(n<0)return;let r=t.filter(t=>t!==e);if(Ct.current=r,St(r),Y.current!==e)return;let i=r.length>0?r[Math.min(n,r.length-1)]:h?.mainFile??``;k(i)},{status:Xt,synced:Zt,activeSessions:Qt,formatLeaseStates:$t,compileState:en,setCompileState:tn,filesEvent:nn,commentsRevision:rn,historyWarning:an,dictionaryRevision:on,chktexSettingsRevision:sn,localDraftReady:cn,permission:ln,reconnect:un,protocolUpgradeRequired:dn,permissionDowngrade:fn,dismissPermissionDowngrade:pn,discardLocalDraft:mn}=C_(c,A,h?.permission??`read`,v),{unreadMentions:hn,mentionsError:gn,markMentionRead:_n,markAllMentionsRead:vn}=b_(n,rn,H,(e,t)=>Kt.current?.(e,t)),{pdfTarget:yn,pdfViewport:bn,sourceJump:xn,setPdfViewport:Sn,resetPdfViewport:Cn,clearPdfViewport:wn,jumpToSource:Tn,syncSourceToPdf:Dn,syncPdfToSource:On,syncVisiblePdfToSource:kn}=vy({projectId:n,mainFile:A,activeFile:O,onOpenSourceFile:e=>kt.current(e),onError:H,onShowPdf:()=>he(`pdf`),onShowEditor:()=>{At.current===`pdf-only`&&_e(`editor-pdf`)}}),An=!!(h&&h.chktexEnabled&&O&&Zt&&Ud(O)),jn=hy({active:An,projectId:n,activeFile:O,content:M}),Mn=my({active:!!(h&&O&&Zt&&Hd(O)&&(yt.spellCheck||h.chktexEnabled&&Ud(O))),harperEnabled:yt.spellCheck,projectId:n,activeFile:O,content:M,dictionaryWords:b,additionalIssues:jn.issues,additionalIssuesReady:!An||jn.checked});(0,J.useEffect)(()=>{bt(te(t.id,n))},[t.id,n]);let Nn=e=>{N(e)};(0,J.useEffect)(()=>{if(!O||ie!==O){F(e=>e.filePath||e.content?{filePath:``,content:``}:e);return}let e=O,t=M,n=window.setTimeout(()=>{F(n=>n.filePath===e&&n.content===t?n:{filePath:e,content:t})},Rb);return()=>window.clearTimeout(n)},[O,ie,M]),(0,J.useEffect)(()=>{Y.current=O,V.reset(),Ce({selectedText:``,startOffset:0,endOffset:0}),yt.openFilesInTabs?O&&Jt(e=>e.includes(O)?e:[...e,O]):Ct.current.length>0&&(Ct.current=[],St([]))},[O,yt.openFilesInTabs,n,V]),(0,J.useEffect)(()=>{if(!oe)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[oe]),(0,J.useEffect)(()=>{if(Xt!==`disconnected`)return;let e=new AbortController;return G(`/api/projects/${n}`,{signal:e.signal}).then(({project:t})=>{e.signal.aborted||(g(t),H(``))}).catch(e=>{Lb(e)||(e instanceof Ae&&[401,403,404].includes(e.status)?(H(W(e)),Wt.current()):H(u(`errors.collaborationUnavailable`)))}),()=>e.abort()},[Xt,n,u]);let Pn=async(e={},t=Ot.current)=>{Mt.current?.abort(),Mt.current=null;let r=e.signal?null:new AbortController;r&&(Mt.current=r);try{let i=t?`?mainFile=${encodeURIComponent(t)}`:``,a=await G(`/api/projects/${n}/completions${i}`,{signal:e.signal??r?.signal});(!e.isCurrent||e.isCurrent())&&C(a.index)}catch(t){if(Lb(t))return;(!e.isCurrent||e.isCurrent())&&C(null)}finally{r&&Mt.current===r&&(Mt.current=null)}},Fn=async(e={},t=Ot.current)=>{Pt.current?.abort(),Pt.current=null;let r=e.signal?null:new AbortController;r&&(Pt.current=r);try{let i=t?`?mainFile=${encodeURIComponent(t)}`:``,a=await G(`/api/projects/${n}/outline${i}`,{signal:e.signal??r?.signal});(!e.isCurrent||e.isCurrent())&&Ot.current===t&&E({mainFile:t,items:a.outline})}catch(e){if(Lb(e))return}finally{r&&Pt.current===r&&(Pt.current=null)}},In=async(e={})=>{Ft.current?.abort(),Ft.current=null;let t=e.signal?null:new AbortController;t&&(Ft.current=t);try{let r=await G(`/api/projects/${n}/dictionary`,{signal:e.signal??t?.signal});(!e.isCurrent||e.isCurrent())&&x(r.words)}catch(t){if(Lb(t))return;(!e.isCurrent||e.isCurrent())&&x([])}finally{t&&Ft.current===t&&(Ft.current=null)}};(0,J.useEffect)(()=>{let e=!1,t=++jt.current,i=new AbortController,a=()=>!e&&jt.current===t,o=!1,s=``;g(null),Jn([]),E({mainFile:``,items:[]}),k(``),j(``),ne({path:``,hasIncludes:!1}),N(``),ae(``),tn(null),wn(),C(null),x([]),Le();let c=(r?.projectId===n?r.project:G(`/api/projects/${n}`,{signal:i.signal})).then(e=>{a()&&(o=!0,s=e.project.mainFile,g(e.project),k(e.project.mainFile),Ot.current=e.project.mainFile,j(e.project.mainFile),hr(new Set(sy(e.project.mainFile))))}).catch(e=>{a()&&H(W(e))}),l=G(`/api/projects/${n}/files`,{signal:i.signal}).then(e=>{a()&&Jn(e.files)}).catch(e=>{a()&&H(W(e))}),u=null;return Promise.allSettled([c,l]).then(()=>{a()&&o&&(u=window.setTimeout(()=>{a()&&Promise.all([Pn({signal:i.signal,isCurrent:a},Ot.current||s),In({signal:i.signal,isCurrent:a})])},0))}),()=>{e=!0,u!==null&&window.clearTimeout(u),i.abort(),Mt.current?.abort(),Mt.current=null,Pt.current?.abort(),Pt.current=null,Ft.current?.abort(),Ft.current=null,It.current?.abort(),It.current=null}},[n,r]),(0,J.useEffect)(()=>{h&&A&&(Nt.current===n?Pn({},A):Nt.current=n)},[A,h?.id,n]),(0,J.useEffect)(()=>{if(!i||!h)return;Rt.current?.abort();let e=new AbortController;return Rt.current=e,G(`/api/projects/${n}/mentions/${encodeURIComponent(i)}`,{signal:e.signal}).then(({mention:t})=>{e.signal.aborted||(je(t),ke(null),Te(`comments`),k(t.filePath),Gt.current?.(t.id))}).catch(t=>{Lb(t)||e.signal.aborted||(H(W(t)),Gt.current?.(i))}).finally(()=>{Rt.current===e&&(Rt.current=null)}),()=>e.abort()},[i,h?.id,n]),(0,J.useEffect)(()=>{on&&In()},[on,n]),(0,J.useEffect)(()=>{if(!sn)return;let e=new AbortController;return G(`/api/projects/${n}`,{signal:e.signal}).then(({project:t})=>{e.signal.aborted||g(e=>e?{...e,chktexEnabled:t.chktexEnabled}:t)}).catch(e=>{Lb(e)||H(W(e))}),()=>e.abort()},[sn,n]),(0,J.useEffect)(()=>{h&&Xt===`connected`&&ln!==h.permission&&g(e=>e&&{...e,permission:ln})},[ln,h?.permission]),(0,J.useEffect)(()=>{if(!nn)return;let t=nn.kind===`delete`&&!!nn.path&&cy(nn.path,Y.current),r=nn.kind===`delete`&&!!nn.path&&cy(nn.path,Ot.current);if(nn.kind===`move`&&nn.source&&nn.destination){let e=nn.source,t=nn.destination,n=n=>n===e?t:n.startsWith(`${e}/`)?`${t}${n.slice(e.length)}`:n;k(e=>n(e)),j(e=>n(e)),dr(e=>e&&n(e)),pr(e=>e&&n(e)),Jt(e=>e.map(n))}t&&(k(``),ae(``),Nn(``),be(u(`editor.fileDeletedByCollaborator`,{path:nn.path}))),nn.kind===`delete`&&nn.path&&(dr(e=>e&&cy(nn.path,e)?null:e),pr(e=>cy(nn.path,e)?``:e),tr(e=>e&&cy(nn.path,e.path)?null:e),Jt(e=>e.filter(e=>!cy(nn.path,e)))),It.current?.abort();let i=new AbortController;It.current=i,Promise.all([Yn({signal:i.signal}),G(`/api/projects/${n}`,{signal:i.signal})]).then(([n,a])=>{if(g(a.project),r&&j(a.project.mainFile),t&&n){let t=n.find(e=>e.type===`file`&&e.path===a.project.mainFile)??n.find(t=>t.type===`file`&&En(t.path,t.textContent)&&(t.size??0)<=e.maxCollaborativeFileSizeMB*1024*1024);k(t?.path??``)}Pn({signal:i.signal}),Fn({signal:i.signal},r?a.project.mainFile:Ot.current)}).catch(e=>{Lb(e)}).finally(()=>{It.current===i&&(It.current=null)})},[nn?.revision]),(0,J.useEffect)(()=>{if(c.setActiveFile(O),!O)return;ae(``),R(`editor.loading`);let e=c.getText(O),t=(t,n)=>{Nn(e.toString()),ae(O),n?.local&&h?.permission!==`read`?(Et.current+=1,I(!0),R(`editor.pending`)):Et.current<=Dt.current&&R(B.current?`editor.savedAt`:`editor.saved`)};return e.observe(t),(Zt||cn)&&t(),()=>{e.unobserve(t)}},[O,c,Zt,cn,h?.permission]);let Ln=async()=>{if(!Zt)throw Error(`Collaboration is not synchronized`);let e=Et.current,t=await c.flush();return Dt.current=Math.max(Dt.current,e),ce(t.persistedAt),/\.tex$/i.test(Y.current)&&Fn(),Et.current===e?(I(!1),R(`editor.savedAt`)):R(`editor.pending`),t};(0,J.useEffect)(()=>{if(!oe||!O||!Zt)return;R(`editor.pending`);let e=window.setTimeout(()=>{R(`editor.saving`),Ln().catch(()=>{R(`editor.saveFailed`)})},750);return()=>window.clearTimeout(e)},[M,oe,O,Zt]);let Rn=async()=>{if(!h||h.permission===`read`||!Zt||!O)return!1;R(`editor.saving`);try{return await Ln(),Pn(),!0}catch(e){return R(`editor.saveFailed`),H(W(e)||u(`errors.collaborationUnavailable`)),!1}},zn=async e=>{if(!h||st)return;let t=e===`full`?Ot.current||h.mainFile:Y.current,r=e===`selection`?Se.current.selectedText:``;if(!t)return;if(e===`selection`&&(!r.trim()||!/\.(?:tex|sty|cls)$/i.test(t))){be(u(`editor.wordCountSelectionEmpty`));return}Lt.current?.abort();let i=new AbortController;Lt.current=i,it(e),ot(t),ft(null),ut(``),nt(!0),ct(!0);try{if(e===`full`&&oe&&h.permission!==`read`&&!await Rn())throw Error(u(`editor.wordCountSaveRequired`));let a=e===`selection`?{mode:e,path:t,source:r}:{mode:e,mainFile:t},o=await G(`/api/projects/${n}/word-count`,{method:`POST`,body:JSON.stringify(a),signal:i.signal});if(i.signal.aborted)return;ft(o)}catch(e){if(Lb(e))return;i.signal.aborted||ut(W(e))}finally{Lt.current===i&&(Lt.current=null,ct(!1))}},Bn=async(t,n,r=yt.texFmtConfig)=>{if(/\.bib$/i.test(t))try{return{formatted:await dh(n,e.maxCitationBibtexBytes)}}catch(t){throw t instanceof oh?t.kind===`too-large`?Error(u(`citationLibrary.fileTooLarge`,{size:`${Math.round(e.maxCitationBibtexBytes/1024)} KB`})):t.kind===`invalid`?Error(u(`citationLibrary.fileInvalid`)):Error(u(t.kind===`timeout`?`editor.bibtexFormatterTimeout`:`editor.bibtexFormatterUnavailable`)):t}return{formatted:(await Xm(n,r)).output}},Vn=async(e,t,n,r=0)=>{if(!/\.bib$/i.test(e))return nh(t,n,r);try{return await fh(t,n,r)}catch(e){throw e instanceof oh?Error(u(e.kind===`timeout`?`editor.bibtexFormatterTimeout`:`editor.bibtexFormatterUnavailable`)):e}},Hn=async e=>{if(!h||h.permission===`read`||!Zt||Vt.current||!$m(Y.current))return;let t=Y.current,n=c.getText(t);Vt.current=!0,mt(!0);let r=()=>{},i=new Promise(e=>{r=e});Ht.current=i;let a=null;try{a=await c.acquireFormatLease(t);let r=n.toString(),{formatted:i}=await Bn(t,r,e);if(Y.current!==t||n.toString()!==r){H(u(`editor.formatSourceChanged`));return}await a.confirm();let o=await Vn(t,r,i);if(Y.current!==t||n.toString()!==r||(await a.confirm(),Y.current!==t||n.toString()!==r)){H(u(`editor.formatSourceChanged`));return}o.length&&c.applyTextEdits(t,o),o.length&&await Ln(),gt(null),H(``),be(u(`editor.formatFileComplete`))}catch(e){Gm(e)?(gt({action:`file`,kind:e.kind,detail:e.message}),H(``)):H(u(`editor.formatFileFailed`,{message:W(e)}))}finally{a&&await a.release(),Vt.current=!1,mt(!1),r(),Ht.current===i&&(Ht.current=null)}},Un=async()=>{if(!yt.formatOnCompile||!h||h.permission===`read`||!Zt||!$m(Y.current)||Vt.current)return;let e=Y.current,t=c.getText(e);Vt.current=!0,mt(!0);let n=null;try{n=await c.acquireFormatLease(e);let r=t.toString(),{formatted:i}=await Bn(e,r);await n.confirm();let a=await Vn(e,r,i);if(Y.current!==e||t.toString()!==r||(await n.confirm(),Y.current!==e||t.toString()!==r))throw Error(u(`editor.formatSourceChanged`));a.length&&c.applyTextEdits(e,a),a.length&&await c.flush(),gt(null)}catch(e){Gm(e)?(gt({action:`file`,kind:e.kind,detail:e.message}),H(``)):H(u(`editor.formatFailedContinue`,{message:W(e)}))}finally{n&&await n.release(),Vt.current=!1,mt(!1)}},Wn=async()=>(Ht.current&&await Ht.current,await Un(),Rn()),Gn=async e=>{if(!h||h.permission===`read`||!Zt||Vt.current||!$m(Y.current))return;let t=Se.current;if(!t.selectedText.trim()){be(u(`editor.formatSelectionRequired`));return}let n=Y.current,{startOffset:r,endOffset:i,selectedText:a}=t,o=c.getText(n);if(o.toString().slice(r,i)!==a){H(u(`editor.formatSelectionChanged`));return}Vt.current=!0,mt(!0);let s=()=>{},l=new Promise(e=>{s=e});Ht.current=l;let d=null;try{if(d=await c.acquireFormatLease(n),o.toString().slice(r,i)!==a){H(u(`editor.formatSelectionChanged`));return}let t=th(a,(await Bn(n,a,e)).formatted);await d.confirm();let s=await Vn(n,a,t,r);if(Y.current!==n||o.toString().slice(r,i)!==a||(await d.confirm(),Y.current!==n||o.toString().slice(r,i)!==a)){H(u(`editor.formatSelectionChanged`));return}s.length&&c.applyTextEdits(n,s),s.length&&await Ln(),gt(null),H(``),be(u(`editor.formatSelectionComplete`))}catch(e){Gm(e)?(gt({action:`selection`,kind:e.kind,detail:e.message}),H(``)):H(u(`editor.formatFailed`,{message:W(e)}))}finally{d&&await d.release(),Vt.current=!1,mt(!1),s(),Ht.current===l&&(Ht.current=null)}},Kn=async t=>{let n=Y.current;if(!/\.bib$/i.test(n)||h?.permission===`read`||!Zt)return be(u(`citationLibrary.importRequiresWrite`)),!1;let r=c.getText(n),i;try{i=await Ib()}catch(e){return H(W(e)),!1}if(Y.current!==n||!Zt)return!1;let a=r.toString(),o=i.parseBibEntriesResult(a,e.maxCitationBibtexBytes);if(o.status===`too-large`)return be(u(`citationLibrary.fileTooLarge`,{size:i.citationBibtexLimitLabel(e.maxCitationBibtexBytes)})),!1;if(o.status===`invalid`)return be(u(`citationLibrary.fileInvalid`)),!1;if(o.entries.some(e=>e.citationKey.toLowerCase()===t.citationKey.toLowerCase()))return be(u(`citationErrors.alreadyInFile`,{key:t.citationKey})),!1;let s=Math.max(0,Math.min(a.length,V.getCursor().offset)),l=a.slice(0,s),d=a.slice(s),f=l?l.endsWith(`
|
|
19
|
-
|
|
20
|
-
`)?``:l.endsWith(`
|
|
21
|
-
`)?`
|
|
22
|
-
`:`
|
|
23
|
-
|
|
24
|
-
`:``,p=d?d.startsWith(`
|
|
25
|
-
|
|
26
|
-
`)?``:d.startsWith(`
|
|
27
|
-
`)?`
|
|
28
|
-
`:`
|
|
29
|
-
|
|
30
|
-
`:``;return c.applyTextEdits(n,[{from:s,to:s,replacement:`${f}${t.bibtex.trim()}${p}`}]),be(u(`citationLibrary.imported`,{key:t.citationKey})),!0},{files:qn,setFiles:Jn,loadFiles:Yn,newFileOpen:Xn,setNewFileOpen:Zn,newFilePath:Qn,setNewFilePath:$n,resourcePreview:er,setResourcePreview:tr,resourcePreviewLoading:nr,setResourcePreviewLoading:rr,newFolderOpen:ir,setNewFolderOpen:ar,newFolderName:or,setNewFolderName:sr,fileDialogError:cr,setFileDialogError:lr,selectedFolder:ur,setSelectedFolder:dr,selectedFile:fr,setSelectedFile:pr,expandedFolders:mr,setExpandedFolders:hr,moveEntry:gr,setMoveEntry:_r,moveName:vr,setMoveName:yr,moveDestination:br,setMoveDestination:xr,deleteEntry:Sr,setDeleteEntry:Cr,fileDragActive:wr,setFileDragActive:Tr,uploadConflict:Er,setUploadConflict:Dr,uploadingFiles:Or,uploadFeedback:kr,dismissUploadFeedback:Ar,directoryEntries:Z,visibleEntries:jr,createFile:Mr,createFolder:Nr,uploadFiles:Pr,upload:Fr,openFile:Ir,movePath:Lr,movePathToFolder:Rr,removePath:zr}=fy({projectId:n,site:e,activeFile:O,dirty:oe,save:Rn,onError:H,onProject:g,onActiveFile:k,onActiveMainFile:j});kt.current=e=>{dr(null),pr(e),hr(t=>new Set([...t,...sy(e)])),k(e)};let Br=e=>{if(e.id!==d.current)return;let t=e.mainFile!==h?.mainFile;g(e),t&&(Ot.current=e.mainFile,Y.current=e.mainFile,j(e.mainFile),k(e.mainFile),dr(null),pr(e.mainFile),hr(t=>new Set([...t,...sy(e.mainFile)])))},Vr=()=>Ot.current||h?.mainFile||``,Hr=()=>{let e=Vr(),t=Y.current;if(!t||!/\.tex$/i.test(t))return e;let n=qn.filter(e=>e.type===`file`&&/\.tex$/i.test(e.path)).length;return Ey(c.getText(t).toString())||n===1?(e!==t&&(Ot.current=t,j(t)),t):e===t&&h?.mainFile&&h.mainFile!==t?(Ot.current=h.mainFile,j(h.mainFile),h.mainFile):e};(0,J.useEffect)(()=>{O&&O===A&&ie===O&&P.filePath===O&&O.toLocaleLowerCase().endsWith(`.tex`)&&qn.filter(e=>e.type===`file`&&/\.tex$/i.test(e.path)).length!==0&&O!==h?.mainFile&&!Ey(P.content)&&h?.mainFile&&(Ot.current=h.mainFile,j(h.mainFile))},[O,A,ie,P,qn,h?.mainFile]),(0,J.useEffect)(()=>{if(!yt.openFilesInTabs||qn.length===0)return;let t=new Set(qn.filter(t=>t.type===`file`&&En(t.path,t.textContent)&&(t.size??0)<=e.maxCollaborativeFileSizeMB*1024*1024).map(e=>e.path));Jt(e=>{let n=e.filter(e=>t.has(e));return n.length===e.length?e:n})},[qn,yt.openFilesInTabs]);let{comments:Ur,projectCommentSummary:Wr,commentsFilePath:Gr,commentsReady:Kr,fileCommentsLoading:qr,fileCommentsError:Jr,retryFileComments:Yr,reviewComments:Xr,reviewCommentsLoading:Zr,reviewCommentsError:Qr,retryReviewComments:$r,commentScope:ei,setCommentScope:ti,focusComment:ni,setFocusComment:ri,commentOpen:ii,openComment:ai,closeComment:oi,commentText:Q,setCommentText:si,commentSelection:ci,commentSubmitting:li,commentError:ui,addComment:di,toggleComment:fi,replyToComment:pi,editComment:mi,deleteComment:hi,editCommentReply:gi,deleteCommentReply:_i,commentDraftStore:vi,cancelComment:yi,commentDraftRestored:bi,commentDraftCanRetarget:xi,useCurrentCommentSelection:Si}=a_({projectId:n,activeFile:O,content:M,permission:h?.permission,revision:rn,sourceOrderRevision:`${h?.mainFile??``}\0${nn?.revision??``}`,selection:U,save:Rn,saveFailureMessage:u(`errors.collaborationUnavailable`),onError:H,onAdded:()=>{ke(null),Te(`comments`)}});(0,J.useEffect)(()=>{if(!A||P.filePath!==A)return;let e=Od(P.content).length>0;ne(t=>t.path===A&&t.hasIncludes===e?t:{path:A,hasIncludes:e})},[A,P]),(0,J.useEffect)(()=>{if(!A||!Zt||O===A)return;let e=c.getText(A),t=null,n=()=>{let t=Od(e.toString()).length>0;ne(e=>e.path===A&&e.hasIncludes===t?e:{path:A,hasIncludes:t})},r=()=>{t!==null&&window.clearTimeout(t),t=window.setTimeout(()=>{t=null,n()},Rb)};return n(),e.observe(r),()=>{t!==null&&window.clearTimeout(t),e.unobserve(r)}},[O,A,c,Zt]);let Ci=(0,J.useMemo)(()=>ee.path===A&&ee.hasIncludes||!!Wr?.filePaths.some(e=>e!==O),[A,ee,Wr,O]),wi=e=>{ze(null),Te(`comments`),ri(null),Fe(e),Y.current!==e.filePath&&Tn(e.filePath,e.startLine,1)},Ti=(e,t=!1)=>{let n=Ur.find(t=>t.id===e&&t.filePath===O);!n||n.resolved||n.orphaned||(Fe(null),ri(null),je(null),t&&we===`comments`&&Oe===n.id?(ke(null),ze(null),Te(null)):(ke(n.id),ze(e=>({id:n.id,filePath:n.filePath,nonce:(e?.nonce??0)+1})),Te(`comments`)))};(0,J.useEffect)(()=>{ze(null),ke(null)},[O]),(0,J.useEffect)(()=>{if(!Pe)return;let e=__(Pe,O,ie,Gr,Kr,Ur);e?(ri({...e}),Fe(null)):Pe.filePath===O&&ie===O&&Gr===O&&Kr&&Fe(null)},[O,Ur,Gr,Kr,ie,Pe,ri]),(0,J.useEffect)(()=>{if(!K||O!==K.filePath||we!==`comments`)return;let e=Ur.find(e=>e.id===K.commentId);if(!e||K.replyId&&!e.replies.some(e=>e.id===K.replyId)||Bt.current===K.id)return;Bt.current=K.id,wi(e);let t=window.setTimeout(()=>je(e=>e?.id===K.id?null:e),3e3);return()=>window.clearTimeout(t)},[O,Ur,we,K]);let{pdfUrl:Ei,pdfCompiledAt:Di,pdfSizeBytes:Oi,pdfLoadingMode:ki,pdfLoading:Ai,compileLog:ji,compileDiagnostics:Mi,compileOutcome:Ni,artifacts:Pi,artifactPreview:Fi,artifactLoading:Ii,editorNotice:Li,localCompiling:Ri,cancelling:zi,cleaning:Bi,compile:Vi,cancelCompile:Hi,cleanCompile:Ui,viewArtifact:Wi,pdfDisplayed:Gi}=iy({projectId:n,project:h,mainFile:A,resolveCompileMainFile:Hr,getCurrentMainFile:Vr,initialLatest:r?.projectId===n?r.latestCompile:null,collaborationSynced:Zt,pdfVisible:ue===`pdf`&&ge!==`editor-only`,sharedState:en,onSharedState:tn,save:Wn,loadOutline:(e,t)=>Fn({signal:e},t),onPreviewTab:he,onError:H,onCompileStart:()=>{H(``),be(``)},onCompileSuccess:()=>{let e=Y.current;if(e){let t=V.getCursor();Dn(e,t.line,t.column,{silent:!0})}},onPdfChanged:wn});(0,J.useEffect)(()=>{if(!h||!A||!Ei&&Ai)return;let e=window.setTimeout(()=>y(!0),Ei?150:0);return()=>window.clearTimeout(e)},[h,Ai,Ei]),(0,J.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&!e.shiftKey&&e.key.toLocaleLowerCase()===`p`&&(e.preventDefault(),et(!0))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[]);let Ki=e=>{pe(t.id,n,e),bt(e)},qi=(e=!1)=>{let t=ht;if(!t)return;gt(null),H(``),e&&Ki({...yt,texFmtConfig:``});let n=e?``:void 0;t.action===`selection`?Gn(n):Hn(n)},Ji=async()=>{vt(!0);try{await mn()||(H(u(`editor.collaboration.permissionDowngradeOtherTabBlocked`)),vt(!1))}catch(e){H(W(e)),vt(!1)}},Yi=()=>{Tt.current?.isCollapsed()?Tt.current.expand():Tt.current?.collapse()},Xi=(0,J.useMemo)(()=>Ab(w,A,P),[w,A,P]),Zi=(0,J.useMemo)(()=>ph(ji,Ni),[ji,Ni]),Qi=ge!==`pdf-only`,$i=ge!==`editor-only`,ea=wy(Qi,$i,we===`settings`||we===`comments`&&!$i),ta=e=>{_e(e),e===`pdf-only`&&he(`pdf`)},na=(0,J.useCallback)(e=>{zt.current?.abort();let t=new AbortController;zt.current=t;let r=Y.current,i=Ot.current,a=new URLSearchParams({kind:e.kind,key:e.key,...r?{path:r}:{},...i?{mainFile:i}:{}});G(`/api/projects/${n}/references/resolve?${a}`,{signal:t.signal}).then(({target:n})=>{t.signal.aborted||Y.current!==r||Ot.current!==i||(n?(At.current===`pdf-only`&&ta(`editor-pdf`),Tn(n.path,n.line,n.column)):H(u(e.kind===`citation`?`editor.citationTargetNotFound`:`editor.labelTargetNotFound`,{key:e.key})))}).catch(e=>{!t.signal.aborted&&!Lb(e)&&H(W(e))}).finally(()=>{zt.current===t&&(zt.current=null)})},[Tn,n,u]),ra=Sr?Qt.filter(e=>e.filePath&&cy(Sr.path,e.filePath)):[];if(!h)return(0,X.jsxs)(`div`,{className:`center-card`,children:[(0,X.jsx)(`p`,{children:ve||u(`common.loading`)}),ve&&(0,X.jsx)(`button`,{className:`primary`,onClick:s,children:u(`editor.backToProjects`)})]});let ia=h.permission===`read`||!Zt,aa=$t.find(e=>e.path===O),oa=aa&&!pt?aa:null,sa=(e,t)=>{if(ia)return;let n=Y.current;if(n){if(c.getText(n).toString().slice(e.from,e.to)!==e.word)H(u(`editor.spellCheckSourceChanged`));else try{c.applyTextEdits(n,[{from:e.from,to:e.to,replacement:t}])}catch(e){H(W(e))}}},ca=en?.mainFile===A&&(en.status===`queued`||en.status===`running`),la=Ri||ca||Bi,ua=O?c.getText(O):null,da=Di?re(Di,l.resolvedLanguage,{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`}):``,fa=A.split(`/`).at(-1)??A,pa=Zi.warnings.length+Zi.errors.length+Pi.length,ma=Ei?`${Ei}${Ei.includes(`?`)?`&`:`?`}download=1`:``,ha=A||h.mainFile,ga=_y(O,ha),_a=!!(ha&&/\.tex$/i.test(ha)),va=e=>{let t=qn.find(t=>t.path===e);t&&En(t.path,t.textContent)?Ir(t):Yt(e)},ya=e=>{document.getElementById(`editor-tab-${encodeURIComponent(e)}`)?.focus()},ba=(e,t)=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;e.preventDefault();let n=e.key===`Home`?0:e.key===`End`?xt.length-1:(t+(e.key===`ArrowLeft`?-1:1)+xt.length)%xt.length,r=xt[n];r&&(va(r),window.requestAnimationFrame(()=>ya(r)))},xa=la?ca?en?.status===`queued`?u(`editor.compileQueued`):u(`editor.compilingBy`,{name:en?.requestedBy.name??u(`common.user`)}):u(`editor.compiling`):Ni===`failed`?Ei&&Di?u(`editor.compileFailedRetained`,{time:re(Di,l.resolvedLanguage)}):u(`editor.compileFailedNoPdf`):Ni===`cancelled`?u(`compileControls.cancelled`):``,Sa=jy(Xt,L,Xt===`disconnected`&&(oe||c.hasWritableDraft)),Ca=Sa===`editor.savedAt`&&se?u(`editor.savedAt`,{time:re(se,l.resolvedLanguage,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}):u(Sa);return(0,X.jsxs)(`div`,{className:`workspace`,"data-texlite-tooltips":yt.showTooltips?`on`:`off`,children:[(0,X.jsx)(Ay,{agentTerminal:Qi&&f.visible&&h.permission!==`read`?{open:p,activeCount:f.activeCount,toggle:()=>m(e=>!e)}:void 0,site:e,project:h,activeFile:O,saveStateLabel:Ca,editorPreferences:yt,activeSessions:Qt,collaborationStatus:Xt,reconnectCollaboration:un,protocolUpgradeRequired:dn,showEditor:Qi,filesCollapsed:q,toggleFilesPanel:Yi,workspaceLayout:ge,changeWorkspaceLayout:ta,onBack:s,onShare:()=>He(!0),showCitationLibrary:Qi&&/\.bib$/i.test(O),citationLibraryOpen:Ye,onCitationLibrary:()=>Xe(!0),onHistory:()=>Ke(!0),onGit:()=>We(!0),canManageGit:h.ownerId===t.id,formatting:pt,readOnly:ia,collaborationSynced:Zt,onToggleComments:()=>{let e=we!==`comments`||!!Oe;ke(null),e&&ti(`project`),Te(e?`comments`:null)},commentsOpen:we===`comments`,unresolvedCommentCount:Wr?.unresolvedCount??h.unresolvedCommentCount??0,onToggleSettings:()=>Te(we===`settings`?null:`settings`),settingsOpen:we===`settings`,compileBusy:la,sharedCompiling:ca,localCompiling:Ri,cancelling:zi,onCompile:Vi,onCancelCompile:()=>void Hi()}),dn&&(0,X.jsxs)(`div`,{className:`workspace-update-banner`,role:`alert`,children:[(0,X.jsx)(T,{size:15}),(0,X.jsx)(`span`,{children:u(`workspaceUpdates.protocolUpgrade`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),children:u(`common.reload`)})]}),xa&&(0,X.jsxs)(`div`,{className:`compile-status-strip${Ni===`failed`?` failed`:``}`,role:`status`,"aria-live":`polite`,children:[(0,X.jsx)(Re,{className:la?`spin`:``,size:14}),(0,X.jsx)(`span`,{children:xa})]}),(Mn.error||jn.error||ht||oa)&&(0,X.jsxs)(`div`,{className:`client-tool-recoveries`,children:[Mn.error&&(0,X.jsxs)(`div`,{className:`client-tool-recovery`,role:`alert`,title:Mn.error,children:[(0,X.jsx)(T,{size:15}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{children:u(`editor.harperRecoveryTitle`)}),u(`editor.harperFallbackHint`)]}),(0,X.jsx)(`div`,{className:`client-tool-recovery-actions`,children:(0,X.jsx)(`button`,{type:`button`,onClick:Mn.retry,children:u(`common.retry`)})}),(0,X.jsx)(`button`,{type:`button`,className:`formatter-diagnostics-dismiss`,title:u(`common.close`),"aria-label":u(`common.close`),onClick:Mn.dismissError,children:(0,X.jsx)(D,{size:13})})]}),jn.error&&(0,X.jsxs)(`div`,{className:`client-tool-recovery`,role:`alert`,title:jn.error,children:[(0,X.jsx)(T,{size:15}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{children:u(`chktex.recoveryTitle`)}),u(`chktex.recoveryHint`)]}),(0,X.jsx)(`div`,{className:`client-tool-recovery-actions`,children:(0,X.jsx)(`button`,{type:`button`,onClick:jn.retry,children:u(`common.retry`)})}),(0,X.jsx)(`button`,{type:`button`,className:`formatter-diagnostics-dismiss`,title:u(`common.close`),"aria-label":u(`common.close`),onClick:jn.dismissError,children:(0,X.jsx)(D,{size:13})})]}),ht&&(0,X.jsxs)(`div`,{className:`client-tool-recovery`,role:`alert`,title:ht.detail,children:[(0,X.jsx)(T,{size:15}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{children:u(ht.kind===`format`?`editor.texFmtOptionsRecoveryTitle`:ht.kind===`load`?`editor.texFmtRecoveryTitle`:`editor.texFmtRuntimeRecoveryTitle`)}),u(`editor.clientToolRecoveryHint`)]}),(0,X.jsxs)(`div`,{className:`client-tool-recovery-actions`,children:[(0,X.jsx)(`button`,{type:`button`,disabled:pt||ia,onClick:()=>qi(),children:u(`common.retry`)}),ht.kind===`format`&&yt.texFmtConfig.trim()&&(0,X.jsx)(`button`,{type:`button`,disabled:pt||ia,onClick:()=>qi(!0),children:u(`editor.resetFormatterOptions`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),children:u(`common.reload`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`formatter-diagnostics-dismiss`,title:u(`common.close`),"aria-label":u(`common.close`),onClick:()=>gt(null),children:(0,X.jsx)(D,{size:13})})]}),oa&&(0,X.jsxs)(`div`,{className:`client-tool-recovery format-lease-status`,role:`status`,children:[(0,X.jsx)(Re,{className:`spin`,size:15}),(0,X.jsx)(`span`,{children:u(`editor.formattingBy`,{name:oa.holderName})})]})]}),an&&(0,X.jsxs)(`div`,{className:`client-tool-recovery`,role:`status`,children:[(0,X.jsx)(T,{size:15}),(0,X.jsx)(`span`,{children:u(`history.saveWarning`)})]}),ve&&(0,X.jsx)(`div`,{className:`toast`,onClick:()=>H(``),children:ve}),ye&&(0,X.jsx)(`div`,{className:`toast success`,onClick:()=>be(``),children:ye}),(0,X.jsxs)(bm,{orientation:`horizontal`,className:`work-grid`,...ea,children:[Qi&&(0,X.jsx)(zy,{project:h,filesPanel:Tt,visibleEntries:jr,deletedPath:nn?.kind===`delete`?nn.path:null,activeFile:O,activeMainFile:A,selectedFile:fr,selectedFolder:ur,expandedFolders:mr,fileDragActive:wr,uploadingFiles:Or,uploadFeedback:kr,readOnly:ia,formatting:pt,canFormat:$m(O),activeFormatLease:!!aa,collaborationSynced:Zt,editorFontSize:yt.fontSize,outline:Xi,sourceCursorStore:V,wordCountBusy:st,hasSelection:!!U.selectedText.trim()&&/\.(?:tex|sty|cls)$/i.test(O),hasFormatSelection:!!U.selectedText.trim(),uploadInput:wt,setSelectedFolder:dr,setExpandedFolders:hr,setMoveEntry:_r,setMoveName:yr,setMoveDestination:xr,setDeleteEntry:Cr,setFileDialogError:lr,setNewFolderName:sr,setNewFolderOpen:ar,setNewFilePath:$n,setNewFileOpen:Zn,setQuickOpen:et,setFileDragActive:Tr,dismissUploadFeedback:Ar,setFilesCollapsed:Be,onError:H,uploadFiles:Pr,upload:Fr,openFile:Ir,movePathToFolder:Rr,onFormatFile:()=>void Hn(),onFormatSelection:()=>void Gn(),jumpToSource:Tn,syncSourceToPdf:Dn,onWordCount:e=>void zn(e)}),Qi&&(0,X.jsx)(jm,{className:`resize-handle`,children:(0,X.jsx)(Ut,{size:12})}),Qi&&(0,X.jsx)(qy,{terminal:p?({maximized:e,toggleMaximized:t})=>(0,X.jsx)(J.Suspense,{fallback:(0,X.jsx)(`div`,{className:`agent-task-empty`,children:(0,X.jsx)(Re,{className:`spin`,size:18})}),children:(0,X.jsx)(Nb,{projectId:n,readOnly:ia,onHide:()=>m(!1),maximized:e,onToggleMaximized:t})}):null,project:h,activeFile:O,openTabs:xt,content:M,loadedFile:ie,readOnly:ia,comments:Ur,focusComment:ni,editorPreferences:yt,completionIndex:S,nativeSpellCheck:Mn.nativeFallback,spellCheckIssues:Mn.issues,spellCheckJump:Mn.jump,sourceJump:xn,collaborativeText:ua,collaborationAwareness:c.awareness,undoManager:O?c.getUndoManager(O):void 0,editorNotice:Li,activateTab:va,closeTab:Yt,handleTabKeyDown:ba,updateEditorContent:Nn,setSelection:(e,t,n)=>Ce({selectedText:e,startOffset:t,endOffset:n}),onAddComment:(e,t,n,r)=>ai({selectedText:e,startOffset:t,endOffset:n},r),onSelectionHistory:(e,t,n,r)=>{Je({filePath:O,selection:{selectedText:e,startOffset:t,endOffset:n},source:r})},onCommentClick:Ti,onSpellCheckReplace:sa,onReferenceNavigate:na,onCursor:qt}),$i&&(0,X.jsx)(nb,{commentsOpen:we===`comments`,onCommentsHost:De,projectId:n,activeMainFile:A,previewTab:ue,diagnosticTab:fe,pdfUrl:Ei,pdfLoadingMode:ki,pdfLoading:Ai,pdfCompiledAt:Di,pdfSizeBytes:Oi,pdfCompiledLabel:da,pdfTargetLabel:fa,pdfDownloadUrl:ma,pdfTarget:yn,pdfViewport:bn,activeFile:O,compileBusy:la,compileLog:ji,compileDiagnostics:Mi,compileMessages:Zi,artifacts:Pi,artifactPreview:Fi,artifactLoading:Ii,cleaning:Bi,readOnly:ia,collaborationSynced:Zt,workspaceLayout:ge,showSyncResize:Qi&&$i,diagnosticCount:pa,selectPreviewTab:he,changeWorkspaceLayout:ta,onSetPdfViewport:Sn,onResetPdfViewport:Cn,onPdfDisplayed:Gi,syncVisiblePdfToSource:kn,syncCurrentSourceToPdf:()=>{let e=Y.current;if(!e)return Promise.resolve();let t=V.getCursor();return Dn(e,t.line,t.column)},syncPdfToSource:On,canSyncWithPdf:ga,canSyncPdfToSource:_a,files:qn,jumpToSource:Tn,onSetCleanMode:Qe,viewArtifact:Wi}),(0,X.jsx)(Db,{commentsHost:$i?Ee:void 0,sidePanel:we,onClose:()=>Te(null),project:h,projectId:n,site:e,files:qn,currentUserId:t.id,comments:Oe?Ur:Xr,commentDraftStore:vi,commentsLoading:Oe?qr:Zr,commentsError:(Oe?Jr:Qr)||gn,onRetryComments:Oe?Yr:$r,activeFile:O,singleCommentId:Oe,onShowAllComments:()=>{ke(null),ti(`project`)},hasProjectCommentsScope:Ci,commentScope:ei,onCommentScopeChange:ti,focusedCommentId:Ie?.filePath===O?Ie.id:ni?.id,commentFocusNonce:Ie?.nonce,onClearFocusComment:()=>{ze(null),ri(null),je(null)},unreadMentions:hn,onMarkMentionRead:_n,onMarkAllMentionsRead:vn,targetCommentId:K?.commentId,targetReplyId:K?.replyId,onFocusComment:wi,onToggleComment:fi,onReplyComment:pi,onEditComment:mi,onDeleteComment:hi,onEditCommentReply:gi,onDeleteCommentReply:_i,dictionaryWords:b,onDictionaryChange:x,editorPreferences:yt,onEditorPreferences:Ki,spellCheckCount:Mn.summary?.total??null,spellCheckUniqueCount:Mn.summary?.unique??null,spellCheckIndex:Mn.summary?Mn.index:-1,onSpellCheckNavigate:Mn.jumpToIssue,onProject:Br},n)]}),tt&&(0,X.jsx)(Me,{title:u(`editor.wordCountTitle`),onClose:()=>nt(!1),children:(0,X.jsx)(Pb,{open:!0,mode:rt,path:at,busy:st,error:lt,result:dt,onOpenChange:nt})}),(0,X.jsx)(xb,{user:t,project:h,projectId:n,activeFile:O,content:M,maxCitationBibtexBytes:e.maxCitationBibtexBytes,files:qn,directoryEntries:Z,readOnly:ia,resourcePreview:er,resourcePreviewLoading:nr,setResourcePreview:tr,setResourcePreviewLoading:rr,uploadConflict:Er,setUploadConflict:Dr,dismissUploadFeedback:Ar,uploadFiles:Pr,cleanMode:Ze,setCleanMode:Qe,cleanCompile:Ui,newFileOpen:Xn,setNewFileOpen:Zn,newFilePath:Qn,setNewFilePath:$n,newFolderOpen:ir,setNewFolderOpen:ar,newFolderName:or,setNewFolderName:sr,selectedFolder:ur,fileDialogError:cr,setFileDialogError:lr,createFile:Mr,createFolder:Nr,moveEntry:gr,setMoveEntry:_r,moveName:vr,setMoveName:yr,moveDestination:br,setMoveDestination:xr,movePath:Lr,deleteEntry:Sr,setDeleteEntry:Cr,deleteActiveSessions:ra,removePath:zr,commentOpen:ii,closeComment:oi,commentSelection:ci,commentText:Q,setCommentText:si,commentSubmitting:li,cancelComment:yi,commentDraftRestored:bi,commentDraftCanRetarget:xi,useCurrentCommentSelection:Si,commentError:ui,addComment:di,shareOpen:Ve,setShareOpen:He,onSharedMemberCountChange:_,citationLibraryOpen:Ye,setCitationLibraryOpen:Xe,insertCitationAtCursor:Kn,quickOpen:$e,setQuickOpen:et,openFile:Ir,selectionHistoryTarget:qe,closeSelectionHistory:()=>Je(null),historyOpen:Ge,setHistoryOpen:Ke,gitOpen:Ue,setGitOpen:We,save:Rn,permissionDowngrade:fn,permissionDowngradeBusy:_t,dismissPermissionDowngrade:pn,discardPermissionDraft:Ji})]})}export{Io as A,kt as B,Rc as C,lc as D,ac as E,Tn as F,bn as I,gn as L,or as M,ar as N,ic as O,Vn as P,zb as ProjectWorkspace,mn as R,fd as S,dc as T,id as _,Ud as a,ad as b,Rd as c,hd as d,yd as f,vd as g,_d as h,Nm as i,pa as j,Fo as k,wd as l,xd as m,Zm as n,Hd as o,bd as p,Qm as r,Vd as s,Mb as t,gd as u,ed as v,fc as w,dd as x,ld as y,Gt as z};
|