braian 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (353) hide show
  1. package/README.md +31 -7
  2. package/bin/braian.mjs +337 -60
  3. package/bin/launch-target.mjs +15 -27
  4. package/bin/run-state.mjs +203 -0
  5. package/dist/app.module.js +2 -0
  6. package/dist/bootstrap.js +4 -1
  7. package/dist/http/api-controllers.js +6 -0
  8. package/dist/http/vault-http-error.js +4 -1
  9. package/dist/http/web-app-fallback.js +37 -0
  10. package/dist/logging/logging.middleware.js +3 -1
  11. package/dist/main.js +3 -0
  12. package/dist/mcp/mcp-path.js +12 -0
  13. package/dist/mcp/mcp-settings.controller.js +78 -0
  14. package/dist/mcp/mcp.controller.js +147 -0
  15. package/dist/mcp/mcp.dto.js +53 -0
  16. package/dist/mcp/mcp.module.js +20 -0
  17. package/dist/mcp/mcp.service.js +117 -0
  18. package/dist/providers/model-provider.service.js +3 -3
  19. package/dist/rss/rss-profiles.controller.js +167 -0
  20. package/dist/rss/rss-profiles.dto.js +511 -0
  21. package/dist/rss/rss-profiles.service.js +149 -0
  22. package/dist/rss/rss.module.js +5 -2
  23. package/dist/search/search.controller.js +1 -1
  24. package/dist/vaults/vault.controller.js +41 -0
  25. package/dist/vaults/vault.dto.js +80 -6
  26. package/dist/vaults/vaults.module.js +2 -1
  27. package/dist/vaults/vaults.service.js +30 -2
  28. package/dist/workspace/workspace-config.js +3 -3
  29. package/node_modules/@braian/ai-providers/dist/index.js +4 -1
  30. package/node_modules/@braian/ai-providers/dist/jev-routing.js +41 -13
  31. package/node_modules/@braian/graph-agent/dist/agent-profiles/tool-catalog.js +4 -4
  32. package/node_modules/@braian/graph-agent/dist/data-workspace.js +44 -0
  33. package/node_modules/@braian/graph-agent/dist/demo-vaults.js +348 -0
  34. package/node_modules/@braian/graph-agent/dist/feature-switch.js +1 -1
  35. package/node_modules/@braian/graph-agent/dist/graph-agent.js +40 -7
  36. package/node_modules/@braian/graph-agent/dist/index.js +24 -2
  37. package/node_modules/@braian/graph-agent/dist/mcp-tokens.js +62 -0
  38. package/node_modules/@braian/graph-agent/dist/rss/index.js +43 -1
  39. package/node_modules/@braian/graph-agent/dist/rss/rss-profile-model.js +378 -0
  40. package/node_modules/@braian/graph-agent/dist/rss/rss-profile-store.js +170 -0
  41. package/node_modules/@braian/graph-agent/dist/rss/rss-profile-test.js +120 -0
  42. package/node_modules/@braian/graph-agent/dist/rss/rss-profile-use-cases.js +74 -0
  43. package/node_modules/@braian/graph-agent/dist/vault-changes.js +3 -0
  44. package/node_modules/@braian/graph-agent/dist/vault-settings-operations.js +3 -1
  45. package/node_modules/@braian/graph-agent/dist/vault-settings-registry.js +1 -1
  46. package/node_modules/@braian/voice-transcription/dist/transcribe.js +1 -1
  47. package/package.json +3 -1
  48. package/public/assets/{agent-profiles-settings-I5Ux2GnH.js → agent-profiles-settings-yElCnMJo.js} +1 -1
  49. package/public/assets/{appearance-settings-module-CD3bJpfR.js → appearance-settings-module-BFDKE-mZ.js} +1 -1
  50. package/public/assets/{ar-SA-G6X2FPQ2-BPq1dwIU.js → ar-SA-G6X2FPQ2-R9ND2Rw0.js} +1 -1
  51. package/public/assets/{attachment-embed-BkP-B_Pa.js → attachment-embed-BX0XSPNZ.js} +1 -1
  52. package/public/assets/{attachments-settings-BeAekkzf.js → attachments-settings-CSEjOoFg.js} +1 -1
  53. package/public/assets/{az-AZ-76LH7QW2-nXEHcVXP.js → az-AZ-76LH7QW2-DpGlptKS.js} +1 -1
  54. package/public/assets/{bg-BG-XCXSNQG7-CpTkmSSX.js → bg-BG-XCXSNQG7-WKBfRf7q.js} +1 -1
  55. package/public/assets/{bn-BD-2XOGV67Q-BDMEyCuA.js → bn-BD-2XOGV67Q-BmT7jnvl.js} +1 -1
  56. package/public/assets/board-workspace-CmetKvXF.js +1 -0
  57. package/public/assets/{boards-settings-module-CCN_ZNks.js → boards-settings-module-Bh5dh9jG.js} +1 -1
  58. package/public/assets/{boards-view-B1B8wHHn.js → boards-view-3JR36W_w.js} +1 -1
  59. package/public/assets/{ca-ES-6MX7JW3Y-D0UEot-K.js → ca-ES-6MX7JW3Y-CBR9ytrG.js} +1 -1
  60. package/public/assets/{calendar-view-BlTCcAzD.js → calendar-view-Cr1VSpj0.js} +1 -1
  61. package/public/assets/calendar-workspace-B-2Himdy.js +1 -0
  62. package/public/assets/{calendars-settings-module-ActBZM9v.js → calendars-settings-module-BWI1k_YA.js} +1 -1
  63. package/public/assets/{card-fields-nzhTsBAW.js → card-fields-eo7dqj1P.js} +1 -1
  64. package/public/assets/{chat-composer-editor-CRtsZz3W.js → chat-composer-editor-DCmWVP16.js} +1 -1
  65. package/public/assets/chat-message-list-DPXjDBw1.js +1 -0
  66. package/public/assets/{chunk-EIO257PC-CGqfS2j0.js → chunk-EIO257PC-Bfdsn_q8.js} +1 -1
  67. package/public/assets/{code-editor-DnrGU9QQ.js → code-editor-CxLqzVwa.js} +1 -1
  68. package/public/assets/color-picker-DK8V_DI0.js +1 -0
  69. package/public/assets/{contents-view-C6RdJxE2.js → contents-view-DHRWEBwV.js} +1 -1
  70. package/public/assets/{conversation-debug-panel-DIjQShXO.js → conversation-debug-panel-zsrBEMxW.js} +1 -1
  71. package/public/assets/create-note-popup-C9IB_IZr.js +1 -0
  72. package/public/assets/{cs-CZ-2BRQDIVT-DvEBYfBD.js → cs-CZ-2BRQDIVT-fiabtlu1.js} +1 -1
  73. package/public/assets/{cypher-editor-Cdd9vqJj.js → cypher-editor-ef6RdDgm.js} +1 -1
  74. package/public/assets/{da-DK-5WZEPLOC-nBVf9B0e.js → da-DK-5WZEPLOC-C-5tRCvs.js} +1 -1
  75. package/public/assets/{daily-notes-settings-DG9RUcYk.js → daily-notes-settings-CCotd1Iq.js} +1 -1
  76. package/public/assets/{dashboard-grid-BvlcalWZ.js → dashboard-grid-DKMK4z_a.js} +1 -1
  77. package/public/assets/dashboard-workspace-4u-QaXby.js +4 -0
  78. package/public/assets/{dashboards-settings-module-CMkRnuLc.js → dashboards-settings-module-DmE0Krje.js} +1 -1
  79. package/public/assets/{dashboards-view-BB1CRB2G.js → dashboards-view-DxUAl6zg.js} +1 -1
  80. package/public/assets/{de-DE-XR44H4JA-wIoI5uHM.js → de-DE-XR44H4JA-4wneKMQi.js} +1 -1
  81. package/public/assets/{desktop-server-settings-j8RrUDQh.js → desktop-server-settings-DDd8PcxW.js} +1 -1
  82. package/public/assets/{directory-picker-columns-BDdL8yxc.js → directory-picker-columns-CqPZNMT8.js} +1 -1
  83. package/public/assets/{discovery-create-popup-DpDB1MTg.js → discovery-create-popup-BSOSYM4o.js} +1 -1
  84. package/public/assets/{discovery-import-popup-BsyONSTT.js → discovery-import-popup-NodFxSW1.js} +1 -1
  85. package/public/assets/{discovery-settings-module-CSz3wdqd.js → discovery-settings-module-DQMZismj.js} +1 -1
  86. package/public/assets/{discovery-view-DOb6HJff.js → discovery-view-PiwStXSa.js} +1 -1
  87. package/public/assets/discovery-workspace-BTrjBF19.js +2 -0
  88. package/public/assets/{dist-tLZONR8L.js → dist-B58c6eJE.js} +1 -1
  89. package/public/assets/drag-preview-D61OK7zr.js +1 -0
  90. package/public/assets/{drawing-note-BZkhWRBb.js → drawing-note-BytzAih9.js} +1 -1
  91. package/public/assets/{el-GR-BZB4AONW-BoxDB0UD.js → el-GR-BZB4AONW-BUDxOK9m.js} +1 -1
  92. package/public/assets/{en-B4ZKOASM-D3_h4H29.js → en-B4ZKOASM-jB7I34Md.js} +1 -1
  93. package/public/assets/{es-ES-U4NZUMDT-BTF8-J9f.js → es-ES-U4NZUMDT-gXLOOlpz.js} +1 -1
  94. package/public/assets/{esm-zhVSGSwY.js → esm-BSlSeh8A.js} +1 -1
  95. package/public/assets/{eu-ES-A7QVB2H4-PqSQa04Y.js → eu-ES-A7QVB2H4-4kiV_opo.js} +1 -1
  96. package/public/assets/{fa-IR-HGAKTJCU-B03HX6BC.js → fa-IR-HGAKTJCU-C7F0Dl4h.js} +1 -1
  97. package/public/assets/{feature-switch-section-CDTUV6B-.js → feature-switch-section-617S6UWP.js} +1 -1
  98. package/public/assets/{fi-FI-Z5N7JZ37-D5Rn9AGc.js → fi-FI-Z5N7JZ37-DEUSwc4a.js} +1 -1
  99. package/public/assets/{file-editor-DTm2a8_D.js → file-editor-DvP7rRI9.js} +3 -3
  100. package/public/assets/{file-language-C8bPT8Wh.js → file-language-DjeubQk3.js} +1 -1
  101. package/public/assets/{file-preview-Bp9k2YvK.js → file-preview-AkYowAab.js} +1 -1
  102. package/public/assets/{file-preview-media-CNZHdx05.js → file-preview-media-DL2hGeeZ.js} +1 -1
  103. package/public/assets/{file-references-api-CSyFnFFm.js → file-references-api-C2G0bSy9.js} +1 -1
  104. package/public/assets/{files-settings-module-D4HPlkbW.js → files-settings-module-DsylYhrR.js} +1 -1
  105. package/public/assets/files-view-B6_Mlm9V.css +1 -0
  106. package/public/assets/files-view-DPSrj_WW.js +3 -0
  107. package/public/assets/{folder-picker-dialog-D57Q15N4.js → folder-picker-dialog-D_VCqm_i.js} +1 -1
  108. package/public/assets/{format-panel-value-DYwL3ttM.js → format-panel-value-vueBm4DQ.js} +1 -1
  109. package/public/assets/{fr-FR-RHASNOE6-BoIuGpVa.js → fr-FR-RHASNOE6-BKLo10bn.js} +1 -1
  110. package/public/assets/{gl-ES-HMX3MZ6V-R9gfMkm_.js → gl-ES-HMX3MZ6V-D_nHnidC.js} +1 -1
  111. package/public/assets/{graph-explorer-DtYVExeD.js → graph-explorer-CHz-bFkx.js} +5 -5
  112. package/public/assets/{graph-settings-module-D--vzqKr.js → graph-settings-module-9hY9bkdT.js} +1 -1
  113. package/public/assets/{he-IL-6SHJWFNN-DLh6r8yJ.js → he-IL-6SHJWFNN-BXKK7JWx.js} +1 -1
  114. package/public/assets/{hi-IN-IWLTKZ5I-DsP1yUVR.js → hi-IN-IWLTKZ5I-D2utCBQM.js} +1 -1
  115. package/public/assets/{hu-HU-A5ZG7DT2-ttWV7_mJ.js → hu-HU-A5ZG7DT2-BENIngFF.js} +1 -1
  116. package/public/assets/{id-ID-SAP4L64H-DIFD1Rmb.js → id-ID-SAP4L64H-Bw77jJOj.js} +1 -1
  117. package/public/assets/{ide-settings-module-Dsg4tJV6.js → ide-settings-module-BbIX3okW.js} +1 -1
  118. package/public/assets/ide-view-0vK2duKI.js +2 -0
  119. package/public/assets/{image-GAAHSSAO-C38PUNrv.js → image-GAAHSSAO-D4NDL8F6.js} +1 -1
  120. package/public/assets/{imap-accounts-QVDGlYad.js → imap-accounts-BRbnITJv.js} +1 -1
  121. package/public/assets/index-BVDhmwI8.js +11 -0
  122. package/public/assets/index-DjUUY3gd.css +1 -0
  123. package/public/assets/{it-IT-JPQ66NNP-D9CIdJgS.js → it-IT-JPQ66NNP-DiG4G8vQ.js} +1 -1
  124. package/public/assets/{ja-JP-DBVTYXUO-CYn7dH3E.js → ja-JP-DBVTYXUO-CILN9NGs.js} +1 -1
  125. package/public/assets/{journal-create-popup-DnYgWgDU.js → journal-create-popup-39y9ieVG.js} +1 -1
  126. package/public/assets/{journal-day-route-DpsYGWU7.js → journal-day-route-CYlyL-u0.js} +1 -1
  127. package/public/assets/{journal-folder-field-DuvIgT6Y.js → journal-folder-field-BfO-_ied.js} +1 -1
  128. package/public/assets/{journal-page-BdQlNdyB.js → journal-page-TgyVFaPE.js} +2 -2
  129. package/public/assets/{journal-settings-Dq-9Conv.js → journal-settings-CfjXOXzF.js} +1 -1
  130. package/public/assets/{journal-typography-QR4z5v0X.js → journal-typography-D3O3AK2U.js} +1 -1
  131. package/public/assets/journal-writing-route-CYhXzipC.js +1 -0
  132. package/public/assets/journals-view-DNomC0nF.js +1 -0
  133. package/public/assets/{kaa-6HZHGXH3-DmZqyxcr.js → kaa-6HZHGXH3-BUua-YiR.js} +1 -1
  134. package/public/assets/{kab-KAB-ZGHBKWFO-BnEoO3f6.js → kab-KAB-ZGHBKWFO-yPJB-J7N.js} +1 -1
  135. package/public/assets/{kk-KZ-P5N5QNE5-DcYcuRxx.js → kk-KZ-P5N5QNE5-CAitSjw5.js} +1 -1
  136. package/public/assets/{km-KH-HSX4SM5Z-DO6DHT6h.js → km-KH-HSX4SM5Z-CSZjabru.js} +1 -1
  137. package/public/assets/{ko-KR-MTYHY66A-Ch6OwlXE.js → ko-KR-MTYHY66A-CGEXYXZz.js} +1 -1
  138. package/public/assets/{ku-TR-6OUDTVRD-C9KHFYbx.js → ku-TR-6OUDTVRD-DOfuZRKI.js} +1 -1
  139. package/public/assets/{link-file-browser-BvVwFMvC.js → link-file-browser-A_Mappx0.js} +1 -1
  140. package/public/assets/{link-kind-icon-r9mUfWOh.js → link-kind-icon-BMfHfR_C.js} +1 -1
  141. package/public/assets/{link-picker-C90irWTA.js → link-picker-BfwWXJZg.js} +2 -2
  142. package/public/assets/{locked-shares-prompt-CA0MuZ_G.js → locked-shares-prompt-BsM-ai_V.js} +1 -1
  143. package/public/assets/{logging-settings-contribution-C55dtngt.js → logging-settings-contribution-BLHCBnwO.js} +1 -1
  144. package/public/assets/logic-DtHJ5GlU.js +28 -0
  145. package/public/assets/{lt-LT-XHIRWOB4-CrK3hZ26.js → lt-LT-XHIRWOB4-CmbJTJAh.js} +1 -1
  146. package/public/assets/{lv-LV-5QDEKY6T-BOA9oRt-.js → lv-LV-5QDEKY6T-Br-VqxTs.js} +1 -1
  147. package/public/assets/{markdown-message-9f2rcF0-.js → markdown-message-BIo2pHhE.js} +2 -2
  148. package/public/assets/{markdown-task-toggle-DiIwYCgC.js → markdown-task-toggle-9k1EldDD.js} +3 -3
  149. package/public/assets/{matrices-settings-module-DPI1_WsY.js → matrices-settings-module-DKGdrCad.js} +1 -1
  150. package/public/assets/{matrices-view-CQlirOdv.js → matrices-view-DYF7e5ES.js} +1 -1
  151. package/public/assets/matrix-workspace-JZhH-HQ5.js +1 -0
  152. package/public/assets/{maximize-2-C6N1RKlt.js → maximize-2-DATMN9kx.js} +1 -1
  153. package/public/assets/{mermaid-diagram-CnzQOrTI.js → mermaid-diagram-gUL2-JyE.js} +1 -1
  154. package/public/assets/{mobile-file-text-B4j-_eP4.js → mobile-file-text-meniSeto.js} +1 -1
  155. package/public/assets/{mobile-note-content-editor-znLhIM9A.js → mobile-note-content-editor-C6TUyA4F.js} +2 -2
  156. package/public/assets/{mobile-panel-layer-C2OowtdM.js → mobile-panel-layer-2EcEm-JB.js} +1 -1
  157. package/public/assets/model-provider-settings-contribution-CfHiu3nS.js +1 -0
  158. package/public/assets/model-providers-cQOCMmwX.js +1 -0
  159. package/public/assets/{mr-IN-CRQNXWMA-GWTqYMNI.js → mr-IN-CRQNXWMA-DwF8SFQB.js} +1 -1
  160. package/public/assets/{my-MM-5M5IBNSE-DnqvLQeM.js → my-MM-5M5IBNSE-BEiMo9eJ.js} +1 -1
  161. package/public/assets/{nb-NO-T6EIAALU-DyrWt8fZ.js → nb-NO-T6EIAALU-BelWzTQs.js} +1 -1
  162. package/public/assets/{nl-NL-IS3SIHDZ-COWPkkr8.js → nl-NL-IS3SIHDZ-Ce06PPL4.js} +1 -1
  163. package/public/assets/{nn-NO-6E72VCQL-8aH2uP9Y.js → nn-NO-6E72VCQL-BbXlzJzR.js} +1 -1
  164. package/public/assets/note-collab-provider-B9DpnE58.js +1 -0
  165. package/public/assets/note-collab-transport-BHZ891IL.js +1 -0
  166. package/public/assets/{note-create-settings-module-CV4dWr8t.js → note-create-settings-module-rIZc1DjQ.js} +1 -1
  167. package/public/assets/{note-documents-DCd2HaSQ.js → note-documents-CcJDTkta.js} +2 -2
  168. package/public/assets/note-editor-container-DL3yLdYs.js +2 -0
  169. package/public/assets/{note-editor-settings-module-CbPu_40k.js → note-editor-settings-module-DI0jRyPy.js} +1 -1
  170. package/public/assets/{note-excalidraw-editor-RjnG4My9.js → note-excalidraw-editor-fDQ1JVBh.js} +11 -11
  171. package/public/assets/{note-export-api-2u0sbOpc.js → note-export-api-CwuXGV0y.js} +1 -1
  172. package/public/assets/{note-export-flow-B3wRdMj0.js → note-export-flow-DcBoI5Pp.js} +1 -1
  173. package/public/assets/{note-filter-rule-rows-BajgD2k3.js → note-filter-rule-rows-DFSWBwql.js} +1 -1
  174. package/public/assets/{note-folds-settings-module-DZju6Mum.js → note-folds-settings-module-CFfVg1Cp.js} +1 -1
  175. package/public/assets/{note-frontmatter-summary-BSKg__aS.js → note-frontmatter-summary-iubFPHA_.js} +1 -1
  176. package/public/assets/{note-link-list-DKU2PqtO.js → note-link-list-CI9-GM_3.js} +1 -1
  177. package/public/assets/{note-markdown-editor-CXelEHqr.js → note-markdown-editor-lG6gZT9i.js} +10 -10
  178. package/public/assets/{note-outline-CNoqBtUP.js → note-outline-BFidIp-8.js} +1 -1
  179. package/public/assets/note-page-content-8gzPBWMV.js +2 -0
  180. package/public/assets/{note-page-editor-rhBoxKYB.js → note-page-editor-DpVUxkCx.js} +4 -4
  181. package/public/assets/{note-path-breadcrumb-uTSXCQK4.js → note-path-breadcrumb-HmtWyYZP.js} +1 -1
  182. package/public/assets/{note-picker-BD8rmAOq.js → note-picker-B5i41l1u.js} +1 -1
  183. package/public/assets/{note-picker-popover-DI9Wc706.js → note-picker-popover-B9VTeHiM.js} +1 -1
  184. package/public/assets/{note-shares-popup-9sJOmL1-.js → note-shares-popup-aUO1SNLN.js} +1 -1
  185. package/public/assets/{note-source-editor-DWyDYMCj.js → note-source-editor-BXPR_-41.js} +1 -1
  186. package/public/assets/{note-type-grid-BFX3oTAC.js → note-type-grid-CRCfpYZy.js} +2 -2
  187. package/public/assets/{note-values-BqD4746M.js → note-values-6D6wWXPg.js} +1 -1
  188. package/public/assets/{notes-settings-module-C5IPmwKt.js → notes-settings-module-DcP9Hid-.js} +1 -1
  189. package/public/assets/{oc-FR-POXYY2M6-C_R_VP74.js → oc-FR-POXYY2M6-CyRgkETq.js} +1 -1
  190. package/public/assets/{open-journal-writing-Bd-CppeX.js → open-journal-writing-Bub8Zn13.js} +1 -1
  191. package/public/assets/{pa-IN-N4M65BXN-B21EEaul.js → pa-IN-N4M65BXN-A1_Q9748.js} +1 -1
  192. package/public/assets/page-content-B3fNjwr-.js +1 -0
  193. package/public/assets/{page-files-BMj9IzfB.js → page-files-CSqFupDZ.js} +1 -1
  194. package/public/assets/page-note-nmiinGCs.js +1 -0
  195. package/public/assets/{pane-keys-CTLoUZZR.js → pane-keys-osajBGnu.js} +1 -1
  196. package/public/assets/{panel-columns-fields-DPjV39xn.js → panel-columns-fields-ZlW6A4My.js} +1 -1
  197. package/public/assets/{pdf-view-Cm78nuSA.js → pdf-view-BATpBLO5.js} +1 -1
  198. package/public/assets/{pencil-DQ9fAqT6.js → pencil-xxFNyZzr.js} +1 -1
  199. package/public/assets/{percentages-BXMCSKIN-CUt8fyAS.js → percentages-BXMCSKIN-DzsiA6IB.js} +1 -1
  200. package/public/assets/{phone-numbers-CHQaYRah.js → phone-numbers-BQgyhfcH.js} +1 -1
  201. package/public/assets/{pl-PL-T2D74RX3-Bdo_j9QK.js → pl-PL-T2D74RX3-DaINIVjz.js} +1 -1
  202. package/public/assets/provider-configuration-CSnNV6ps.css +1 -0
  203. package/public/assets/provider-configuration-DaFovElx.js +8 -0
  204. package/public/assets/provider-use-select-D-lJiZ2W.js +1 -0
  205. package/public/assets/{pt-BR-5N22H2LF-C9DRQ7CW.js → pt-BR-5N22H2LF-ENVHjTz_.js} +1 -1
  206. package/public/assets/{pt-PT-UZXXM6DQ-ColydZPV.js → pt-PT-UZXXM6DQ-D5Uqv0Vz.js} +1 -1
  207. package/public/assets/{qr-code-Bm7I0KYt.js → qr-code-CDBCi1Cu.js} +2 -2
  208. package/public/assets/{qr-code-svg-D0RAuUIk.js → qr-code-svg-8ENstC8b.js} +1 -1
  209. package/public/assets/qr-defaults-settings-C_8ybA4R.js +1 -0
  210. package/public/assets/qr-settings-fields-C2-DGF6a.js +1 -0
  211. package/public/assets/qr-viewer-DAOzDI8d.js +1 -0
  212. package/public/assets/{reader-clock-22DkpiWR.js → reader-clock-7x7Yvzv1.js} +1 -1
  213. package/public/assets/{recording-bar-DOm-SEGc.js → recording-bar-BcuvYwhh.js} +2 -2
  214. package/public/assets/{recording-setup-CV3LE2_1.js → recording-setup-D_MgrYb7.js} +1 -1
  215. package/public/assets/{recordings-api-C-Bxpzgo.js → recordings-api-Ds77lFsk.js} +1 -1
  216. package/public/assets/resource-overview-card-BainFWKz.js +1 -0
  217. package/public/assets/{ro-RO-JPDTUUEW-iJAQDPe9.js → ro-RO-JPDTUUEW-Dq_ouOp1.js} +1 -1
  218. package/public/assets/{rss-preferences-Bx1Wa4ri.js → rss-preferences-BafuZ3Ku.js} +1 -1
  219. package/public/assets/{rss-settings-module-BmDISWDk.js → rss-settings-module-Df-YS9tr.js} +1 -1
  220. package/public/assets/rss-view-BORHnuIQ.js +3 -0
  221. package/public/assets/rss-view-DIPQBTLT.css +1 -0
  222. package/public/assets/{ru-RU-B4JR7IUQ-CX_CWbT7.js → ru-RU-B4JR7IUQ-CqqISqJC.js} +1 -1
  223. package/public/assets/{safe-block-copy-DygjvDD4.js → safe-block-copy-BOVhmncw.js} +1 -1
  224. package/public/assets/{safe-block-qr-button-Cn9WpEkl.js → safe-block-qr-button-CD7cJG3N.js} +1 -1
  225. package/public/assets/{safe-block-reader-CNfzTExh.js → safe-block-reader-BkilW4Hj.js} +1 -1
  226. package/public/assets/safe-folder-conversion-DWTRwvTH.js +1 -0
  227. package/public/assets/{safe-folders-DCf8IdrM.js → safe-folders-DmvM6dtV.js} +1 -1
  228. package/public/assets/{safe-move-leaving-tN-IMhDo.js → safe-move-leaving-BT5e1h3p.js} +1 -1
  229. package/public/assets/{safe-note-locked-B_lt0XcX.js → safe-note-locked-BDCeVwpK.js} +1 -1
  230. package/public/assets/{safe-notes-settings-module-CMvkyfNG.js → safe-notes-settings-module-BrZreYgf.js} +1 -1
  231. package/public/assets/search-settings-module-CPnculiI.js +1 -0
  232. package/public/assets/{secret-form-DSD348Om.js → secret-form-B-YAlbZf.js} +1 -1
  233. package/public/assets/{secret-popup-y9W7WIrZ.js → secret-popup-CoVpeLZV.js} +1 -1
  234. package/public/assets/{security-settings-contribution-B_Syg5ab.js → security-settings-contribution-BmcZq1hf.js} +1 -1
  235. package/public/assets/settings-CU8YR8di.js +1 -0
  236. package/public/assets/{settings-edit-dialog-B5emNjJi.js → settings-edit-dialog-C_AeTz9Y.js} +1 -1
  237. package/public/assets/settings-panel-Ds7lOtnD.js +1 -0
  238. package/public/assets/settings-view-BTz2XbnW.js +4 -0
  239. package/public/assets/{settings-view-6_hMxTXD.css → settings-view-Bd65kLGK.css} +1 -1
  240. package/public/assets/{setup-prompt-6JRbE0oa.js → setup-prompt-BbpHVdla.js} +1 -1
  241. package/public/assets/{share-access-control-C5mpELVT.js → share-access-control-CzAVEv6b.js} +1 -1
  242. package/public/assets/share-label-CbjQ9iMF.js +1 -0
  243. package/public/assets/{shared-board-lanes-UWl9klys.js → shared-board-lanes-CAbJAFk6.js} +1 -1
  244. package/public/assets/{shared-calendar-view-DcCO3mNo.js → shared-calendar-view-DTzDjSs0.js} +1 -1
  245. package/public/assets/shared-note-route-B_gfX0Nl.js +4 -0
  246. package/public/assets/{shared-note-text-BdCw7a9a.js → shared-note-text-DFBEyL8Z.js} +1 -1
  247. package/public/assets/{shares-settings-module-9oF4v70A.js → shares-settings-module-pIdBLmCq.js} +1 -1
  248. package/public/assets/{si-LK-N5RQ5JYF-DfLSaLm6.js → si-LK-N5RQ5JYF-DmhE8IT5.js} +1 -1
  249. package/public/assets/{sk-SK-C5VTKIMK-DrAaUVFC.js → sk-SK-C5VTKIMK-YiOZ-xKA.js} +1 -1
  250. package/public/assets/{sl-SI-NN7IZMDC-WxYLW2Uj.js → sl-SI-NN7IZMDC-BKb37Hlu.js} +1 -1
  251. package/public/assets/{spaces-settings-module-Dh_QfANj.js → spaces-settings-module-BLU1RsTS.js} +1 -1
  252. package/public/assets/spaces-view-BhWD3mAw.js +2 -0
  253. package/public/assets/{sqlite-browser-BfIrq_0x.js → sqlite-browser-C98PFoRG.js} +2 -2
  254. package/public/assets/{store-attachments-DNyH0asy.js → store-attachments-DbqF7LgE.js} +1 -1
  255. package/public/assets/{stored-color-picker-CYL7LYdQ.js → stored-color-picker-DLX-e5Nq.js} +1 -1
  256. package/public/assets/subset-shared.chunk-D8M638AI.js +1 -0
  257. package/public/assets/{subset-worker.chunk-BrbK91mW.js → subset-worker.chunk-B9ZhBm-P.js} +1 -1
  258. package/public/assets/{sv-SE-XGPEYMSR-DOB2jm3x.js → sv-SE-XGPEYMSR-VT0snW-T.js} +1 -1
  259. package/public/assets/{ta-IN-2NMHFXQM-DfC3wGVU.js → ta-IN-2NMHFXQM--MqIf2Jf.js} +1 -1
  260. package/public/assets/{text-diff-BzNG8nfy.js → text-diff-BmKfp7mY.js} +1 -1
  261. package/public/assets/{th-TH-HPSO5L25-BsqplWuv.js → th-TH-HPSO5L25-CTKAmQrO.js} +1 -1
  262. package/public/assets/{theme-colors-2LJ6VIeK.js → theme-colors-zbTaiYL0.js} +1 -1
  263. package/public/assets/{toolbar-items-DF7H0MSb.js → toolbar-items-DLi0bl0c.js} +1 -1
  264. package/public/assets/{topology-code-editor-B7zxDyT3.js → topology-code-editor-CNnSyUQ3.js} +1 -1
  265. package/public/assets/topology-designer-T54LYLYv.js +1 -0
  266. package/public/assets/topology-editor-aGtCktzA.js +8 -0
  267. package/public/assets/{topology-folder-migration-popup-Bj4nu8HE.js → topology-folder-migration-popup-C0Wc3ViK.js} +1 -1
  268. package/public/assets/{topology-settings-module-cWWujj9j.js → topology-settings-module-Dp-Sm37Z.js} +1 -1
  269. package/public/assets/{tr-TR-DEFEU3FU-DWO1lNTH.js → tr-TR-DEFEU3FU-BVLSiyVW.js} +1 -1
  270. package/public/assets/{transcription-settings-HrJHl14H.js → transcription-settings-BldPwHO7.js} +4 -4
  271. package/public/assets/{uk-UA-QMV73CPH-ZHBKj9kv.js → uk-UA-QMV73CPH-DQ4YsZml.js} +1 -1
  272. package/public/assets/{unlock-prompt-C1AEyIR_.js → unlock-prompt-CkkcVo9g.js} +1 -1
  273. package/public/assets/{use-candidate-notes-Du1V_uun.js → use-candidate-notes-jH4-EW29.js} +1 -1
  274. package/public/assets/{use-directory-listing-BaYgcuHI.js → use-directory-listing-Cn9t21ra.js} +1 -1
  275. package/public/assets/{use-folding-enabled-CyYip5Go.js → use-folding-enabled-DKvri2UA.js} +1 -1
  276. package/public/assets/{use-live-document-Ck_XPFVd.js → use-live-document-D4PkZrbU.js} +1 -1
  277. package/public/assets/{use-mobile-layer-navigation-CBRepW9w.js → use-mobile-layer-navigation-BIC7HlT_.js} +1 -1
  278. package/public/assets/{use-note-attachments-SPgAe-M0.js → use-note-attachments-Bew073Hl.js} +1 -1
  279. package/public/assets/{use-note-delete-Dvrzq6Pl.js → use-note-delete-fFNH1Glk.js} +1 -1
  280. package/public/assets/use-note-editor-session-R1wm0xDf.js +1 -0
  281. package/public/assets/{use-note-export-flow-0uAfXAwf.js → use-note-export-flow-Dm7yhW5s.js} +2 -2
  282. package/public/assets/use-provider-dialogs-CrxN9JCo.js +1 -0
  283. package/public/assets/{use-reflection-request-DV5-_c14.js → use-reflection-request-C1DxtaYX.js} +3 -3
  284. package/public/assets/{use-safe-folder-moves-0nw2jjTX.js → use-safe-folder-moves-DjQUnMvz.js} +1 -1
  285. package/public/assets/{use-safe-folders-apply-C9pni8YW.js → use-safe-folders-apply-B1V8l7WU.js} +1 -1
  286. package/public/assets/{use-screen-source-BllYITR6.js → use-screen-source-CF-48NnC.js} +1 -1
  287. package/public/assets/use-share-actions-kb7uFat_.js +1 -0
  288. package/public/assets/{use-vault-file-link-C0ZO_VPm.js → use-vault-file-link-B-ZRcKDu.js} +1 -1
  289. package/public/assets/{use-voice-questions-Bjgb45Dc.js → use-voice-questions-DGVQlAST.js} +1 -1
  290. package/public/assets/{vault-entries-api-DVVjgeZh.js → vault-entries-api-pFsJiGnJ.js} +1 -1
  291. package/public/assets/vault-manager-YKz_Ib18.js +1 -0
  292. package/public/assets/{vault-settings-module-DMjLQmKz.js → vault-settings-module-CCMMSy4B.js} +1 -1
  293. package/public/assets/{vault-shares-popup-CCPGkRmF.js → vault-shares-popup-CaGnEIJA.js} +1 -1
  294. package/public/assets/{versioning-preferences-dvxhrMo9.js → versioning-preferences-DrNq-y_0.js} +1 -1
  295. package/public/assets/{versioning-settings-module-CnDDngKG.js → versioning-settings-module-Ddug486c.js} +1 -1
  296. package/public/assets/versioning-view-PR4R4gks.js +2 -0
  297. package/public/assets/{vi-VN-M7AON7JQ-uUfHJEho.js → vi-VN-M7AON7JQ-B-fHV7o8.js} +1 -1
  298. package/public/assets/video-recording-dialog-CxRs1eLE.js +1 -0
  299. package/public/assets/{video-recording-settings-D6YT_FW3.js → video-recording-settings-B2iE6IdW.js} +1 -1
  300. package/public/assets/{widget-frame-CjlAZSUy.js → widget-frame-DiF4946k.js} +1 -1
  301. package/public/assets/{zh-CN-LNUGB5OW-COz3oRg3.js → zh-CN-LNUGB5OW-CUgxiiUV.js} +1 -1
  302. package/public/assets/{zh-HK-E62DVLB3-C8ICkLhf.js → zh-HK-E62DVLB3-D-87W8QH.js} +1 -1
  303. package/public/assets/{zh-TW-RAJ6MFWO-AYdVqmV8.js → zh-TW-RAJ6MFWO-BVaf47B6.js} +1 -1
  304. package/public/index.html +3 -3
  305. package/public/assets/board-workspace-DPSlmJ8w.js +0 -1
  306. package/public/assets/calendar-workspace-6t1kuFgj.js +0 -1
  307. package/public/assets/chat-message-list-ClUR56GV.js +0 -1
  308. package/public/assets/color-picker-ClAn42eA.js +0 -1
  309. package/public/assets/create-note-popup-CRi210cC.js +0 -1
  310. package/public/assets/dashboard-workspace-D45MA_Wf.js +0 -4
  311. package/public/assets/discovery-workspace-Cyc70gQ1.js +0 -2
  312. package/public/assets/drag-preview-Cb6aidku.js +0 -1
  313. package/public/assets/files-view-BIDZtZgg.js +0 -3
  314. package/public/assets/files-view-Bo1uBB_W.css +0 -1
  315. package/public/assets/ide-view-DCvwb5Bx.js +0 -2
  316. package/public/assets/index-B8xguO4f.css +0 -1
  317. package/public/assets/index-CCUyKE6q.js +0 -11
  318. package/public/assets/journal-writing-route-JP-jPBGZ.js +0 -1
  319. package/public/assets/journals-view-No5xQN8-.js +0 -1
  320. package/public/assets/logic-BNk_20eJ.js +0 -28
  321. package/public/assets/matrix-workspace-C3LhTNPX.js +0 -1
  322. package/public/assets/model-provider-settings-contribution-DYmNbsgA.js +0 -1
  323. package/public/assets/model-providers-7VKk3K9H.js +0 -8
  324. package/public/assets/model-providers-DgRkVmP5.css +0 -1
  325. package/public/assets/note-collab-provider-969Kgyu8.js +0 -1
  326. package/public/assets/note-collab-transport-CQDYt_Db.js +0 -1
  327. package/public/assets/note-editor-container-CTnEE-98.js +0 -2
  328. package/public/assets/note-page-content-DIqkiMvt.js +0 -2
  329. package/public/assets/page-content-C1jtzs7H.js +0 -1
  330. package/public/assets/page-note-Chw2UF0u.js +0 -1
  331. package/public/assets/provider-use-select-DCSwSrlz.js +0 -1
  332. package/public/assets/qr-defaults-settings-2_Yt9x4N.js +0 -1
  333. package/public/assets/qr-settings-fields-DDO4XgMl.js +0 -1
  334. package/public/assets/qr-viewer-CvEfRC2r.js +0 -1
  335. package/public/assets/resource-overview-card-Co8aU6jw.js +0 -1
  336. package/public/assets/rss-view-5aqCVOCs.css +0 -1
  337. package/public/assets/rss-view-BCEFsYtS.js +0 -1
  338. package/public/assets/safe-folder-conversion-BOLpnv8P.js +0 -1
  339. package/public/assets/search-settings-module-DmczYjcQ.js +0 -1
  340. package/public/assets/settings-ChT117Ke.js +0 -1
  341. package/public/assets/settings-panel-Cl5kUs9O.js +0 -1
  342. package/public/assets/settings-view-C_lfjngd.js +0 -3
  343. package/public/assets/share-label-BU3So3s7.js +0 -1
  344. package/public/assets/shared-note-route-DaI6hm83.js +0 -4
  345. package/public/assets/spaces-view-Dw2uxDxU.js +0 -2
  346. package/public/assets/subset-shared.chunk-D1nlqSEH.js +0 -1
  347. package/public/assets/topology-designer-CvJN6QTV.js +0 -1
  348. package/public/assets/topology-editor-RZ0_yLuO.js +0 -8
  349. package/public/assets/use-note-editor-session-CRC-natg.js +0 -1
  350. package/public/assets/use-share-actions-ujEMhCfl.js +0 -1
  351. package/public/assets/vault-manager-CMQaGDss.js +0 -1
  352. package/public/assets/versioning-view-BsIFugt4.js +0 -2
  353. package/public/assets/video-recording-dialog-7IGrQMwx.js +0 -1
@@ -0,0 +1 @@
1
+ import{$c as e,Bs as t,Jc as n,Kc as r,Qu as i,Rs as a,Ws as o,Xc as s,Yc as c,Zc as l,al as u,il as d,nl as f,qc as p,rl as m}from"./logic-DtHJ5GlU.js";import{a as h,c as g,d as _,f as v,i as y,o as b,p as ee,s as x,u as S}from"./yjs-DhdecF1t.js";var C=e=>new TextEncoder().encode(JSON.stringify([`braian-collab-v1`,e.vault,e.session,e.channel,e.epoch])),w=(e,t)=>new TextEncoder().encode(JSON.stringify([Array.from(C(e)),t.version,t.kind,t.sender,t.updateId]));async function te(e,t){if(e.length!==32||!Number.isSafeInteger(t.epoch)||t.epoch<1)throw Error(`Invalid collaboration key context.`);let n=s(t.salt);if(n.length!==32)throw Error(`Invalid collaboration salt.`);let r=await crypto.subtle.importKey(`raw`,new Uint8Array(e),`HKDF`,!1,[`deriveKey`]);return crypto.subtle.deriveKey({name:`HKDF`,hash:`SHA-256`,salt:n,info:C(t)},r,{name:`AES-GCM`,length:256},!1,[`encrypt`,`decrypt`])}async function T(t,n,r,i){let a={version:1,...r},o=l(12),s=await crypto.subtle.encrypt({name:`AES-GCM`,iv:o,additionalData:w(n,a)},t,new Uint8Array(i));return{...a,iv:e(o),ciphertext:e(new Uint8Array(s))}}async function E(e,t,n){if(n.version!==1||![`checkpoint`,`update`,`awareness`,`state-vector`].includes(n.kind)||!n.sender||!n.updateId)throw Error(`Invalid collaboration envelope.`);let r=s(n.iv);if(r.length!==12)throw Error(`Invalid collaboration nonce.`);return new Uint8Array(await crypto.subtle.decrypt({name:`AES-GCM`,iv:r,additionalData:w(t,n)},e,s(n.ciphertext)))}var D=[`Aspen`,`Birch`,`Cedar`,`Elm`,`Maple`,`Oak`,`Pine`,`Willow`],O=[`--accent`,`--violet`,`--ui-text-success`,`--ui-text-warning`],k=a({scope:`global`,name:`collabIdentity`,fallback:void 0,parse:e=>{let t=JSON.parse(e);return t&&typeof t.name==`string`&&D.some(e=>t.name.startsWith(e+` `))&&O.includes(t.token)?t:void 0},serialize:e=>JSON.stringify(e)});function A(e){let n=encodeURIComponent(e),r=t(k,{suffix:n});if(!r||!D.some(e=>r.name.startsWith(e+` `))||!O.includes(r.token)){let e=crypto.getRandomValues(new Uint8Array(3));r={name:`${D[e[0]%D.length]} ${e[1]+1}`,token:O[e[2]%O.length]},o(k,r,{suffix:n})}let i=getComputedStyle(document.documentElement).getPropertyValue(r.token).trim()||`currentColor`;return{name:r.name,color:i,colorLight:`color-mix(in srgb, ${i} 20%, transparent)`}}async function j(e,t,n,r,i,a,o){let s=t?.blocks.find(e=>e.id===n);return!e||!s?.version?!1:(await a({blockId:n,version:i??s.version,replacement:r}),await o(),!0)}function M(e,t,n,r){return!!(e&&t&&!n&&r)}function N(e,t){if(e===t)return null;let n=0,r=Math.min(e.length,t.length);for(;n<r&&e.charCodeAt(n)===t.charCodeAt(n);)n+=1;let i=e.length,a=t.length;for(;i>n&&a>n&&e.charCodeAt(i-1)===t.charCodeAt(a-1);)--i,--a;return{from:n,to:i,insert:t.slice(n,a)}}var P=Symbol(`remote-note-collab`);function F(e,t,n){let r=new g;return{id:n,doc:r,text:r.getText(`body`),awareness:new y(r),ready:n===`public`,context:{vault:e,session:t.session,epoch:t.epoch,channel:n,salt:t.salt}}}function I(e,t,n){let r=N(e.text.toString(),t);r&&e.doc.transact(()=>{e.text.delete(r.from,r.to-r.from),e.text.insert(r.from,r.insert)},n)}function L(e,t,n,r){let i=N(t,n);if(!i)return;if(e.persistedState){let n=new g;try{S(n,e.persistedState);let a=n.getText(`body`);if(a.toString()===t){let t=v(n);n.transact(()=>{a.delete(i.from,i.to-i.from),a.insert(i.from,i.insert)}),S(e.doc,_(n,t),r);return}}finally{n.destroy()}}let a=N(t,e.text.toString()),o=e=>!a||e<=a.from?e:e>=a.to?e+a.insert.length-(a.to-a.from):a.from+a.insert.length,s=Math.max(0,Math.min(e.text.length,o(i.from))),c=Math.max(s,Math.min(e.text.length,o(i.to)));e.doc.transact(()=>{e.text.delete(s,c-s),e.text.insert(s,i.insert)},r)}var R=e=>`<!--braian-collab:${e}-->`;function z(e,t){if(t.mode===`plain`)return e;if(t.mode===`whole`)return``;if(!m(e))return e.replace(/^\[safe block ([1-9][0-9]*)\]$/gm,(e,n)=>{let r=t.blocks[Number(n)-1];return r?R(r.id):e});let n=[...t.blocks],r=new Set;return u(e,e=>{let t=n.find(t=>!r.has(t.id)&&t.source===e.source)??n[e.index];if(!t||r.has(t.id))throw Error(`The safe block structure changed.`);return r.add(t.id),R(t.id)})}async function B(e,t,n,i=t.storedBody){if(t.mode===`whole`)return r(n,i);let a=t.blocks.find(t=>t.id===e)?.source,o=f(i),s=f(t.storedBody).findIndex(e=>e.source===a),c=i===t.storedBody&&a?f(a)[0]:o.find(e=>e.source===a)??o[s];if(!c)throw Error(`The encrypted block is missing.`);return p(n,c)}async function V(e,t,i){if(e.mode===`whole`){let a=t.get(`body`);return!i||!a?.ready||await r(i,e.storedBody)===a.text.toString()?e.storedBody:n(i,a.text.toString())}let a=t.get(`public`).text.toString(),o=new Map;for(let n of e.blocks){let e=n.source,r=t.get(n.id);if(i&&r?.ready&&n.editable){let[t]=f(e);await p(i,t)!==r.text.toString()&&(e=await c(i,r.text.toString(),{scope:`block`,display:t.header?.display,title:t.header?.title,kind:t.header?.kind}))}o.set(n.id,e)}return a.replace(/<!--braian-collab:([a-zA-Z0-9-]+)-->/g,(e,t)=>{let n=o.get(t);if(n===void 0)throw Error(`An encrypted block token is unknown.`);return n})}function H(e,t,n){let r=new g;try{r.getText(`body`),S(r,_(e.doc)),S(r,t);let i=r.getText(`body`);if([...r.share.keys()].some(e=>e!==`body`)||Object.keys(i.getAttributes()).length||i.toDelta().some(e=>typeof e.insert!=`string`||e.attributes))throw Error(`The live update contains an undeclared document type.`);S(e.doc,t,n)}finally{r.destroy()}}async function U(e,t,n,r){let i=[];for(let a of t.values())a.id!==`public`&&i.push({channel:a,base:await B(a.id,e,n),value:await B(a.id,e,n,r)});let a=t.has(`public`)?z(e.storedBody,e):void 0,o=t.has(`public`)?z(r,e):void 0;for(let e of i)L(e.channel,e.base,e.value,`outside-recovery`);a!==void 0&&o!==void 0&&L(t.get(`public`),a,o,`outside-recovery`)}async function W(e,t){let n={};for(let r of e.values())r.id!==`public`&&(n[r.id]=await T(r.key,r.context,{kind:`checkpoint`,sender:t,updateId:crypto.randomUUID()},_(r.doc)));return n}function G(e,t,n){if(e.mode===`blocks`){let r=new g;n&&S(r,s(n));let i=n?r.getText(`body`).toString():e.blocks.map(e=>`<!--braian-collab:${e.id}-->`).join(``);r.destroy();let a=[...i.matchAll(/<!--braian-collab:([a-zA-Z0-9-]+)-->/g)],o=f(t);e.blocks=a.map(t=>e.blocks.find(e=>e.id===t[1])).filter(Boolean);for(let[t,n]of a.entries()){let r=e.blocks.find(e=>e.id===n[1]);r&&o[t]&&(r.source=o[t].source)}}}async function K(e,t,r,i,a){return e.mode===`plain`&&d(i)&&r?n(r,t.get(`public`).text.toString()):e.mode===`whole`&&!m(i)?t.get(`body`).text.toString():a?V(e,t,r):i}async function q(e,t,n){let r=new Map;n.publicState&&r.set(`public`,s(n.publicState));for(let[e,i]of Object.entries(n.checkpoints??{})){let n=t.get(e);n?.key&&r.set(e,await E(n.key,n.context,i))}for(let[e,n]of r){let r=t.get(e);r&&(r.persistedState=n)}e.durableSequence=n.sequence,e.revision=n.revision,e.storedBody=n.storedBody??e.storedBody,n.blocks?e.blocks=n.blocks:G(e,e.storedBody,n.publicState)}async function J(e,t,n,r,i){let a=new Map;try{let o=[...e.mode===`whole`?[]:[`public`],...e.mode===`whole`?e.blocks.filter(e=>e.editable&&n).map(e=>e.id):[]];for(let c of o){let o=F(t,e,c);if(a.set(c,o),c===`public`)H(o,s(e.publicState),P),e.sequence===e.durableSequence&&(o.persistedState=s(e.publicState));else{o.key=await te(n.key,o.context);let t=e.checkpoints[c];t&&(o.persistedState=await E(o.key,o.context,t.envelope),H(o,o.persistedState,P),o.ready=!0);for(let t of e.relay.filter(e=>e.channel===c))H(o,await E(o.key,o.context,t.envelope),P),t.envelope.kind===`checkpoint`&&(o.ready=!0);if(!o.ready&&e.lease?.client===r){let t=await B(c,e,n);o.text.insert(0,t),o.ready=!0;let a=crypto.randomUUID();await i(`update`,{channel:c,updateId:a,envelope:await T(o.key,o.context,{kind:`checkpoint`,sender:r,updateId:a},_(o.doc))})}}}return a}catch(e){for(let e of a.values())e.awareness.destroy(),e.doc.destroy();throw e}}var Y=class{ports;id;running;constructor(e){this.ports=e}receive(e){this.id=e,this.ports.pause(!!e),e&&this.schedule()}schedule(){this.id&&!this.running&&(this.running=Promise.resolve().then(async()=>{await this.ports.drain(),this.id&&await this.ports.post(`conversion-ready`,{barrier:this.id,throughSequence:this.ports.through()})}).catch(e=>this.ports.failed(e)).finally(()=>{this.running=void 0}))}async prepare(){for(let e=0;e<40;e++){let e=await this.ports.post(`conversion-prepare`);if(this.id!==e.barrier&&this.receive(e.barrier),this.schedule(),e.ready)return e.barrier;await new Promise(e=>setTimeout(e,100))}throw Error(`Another editor could not finish its edits. Conversion was cancelled and the local draft is retained.`)}async cancel(){try{this.id&&await this.ports.post(`conversion-cancel`)}finally{this.receive()}}},X=class{peers=new Map;apply(e,t,n){let r=new g,i=new y(r);try{h(i,n,P);let r=this.peers.get(e)??new Map;r.set(t.id,[...i.getStates().keys()].filter(e=>e!==i.clientID)),this.peers.set(e,r),h(t.awareness,n,P)}finally{i.destroy(),r.destroy()}}leave(e,t){for(let[n,r]of this.peers.get(e)??[]){let e=t.get(n);e&&x(e.awareness,r,P)}this.peers.delete(e)}clear(){this.peers.clear()}};async function Z(e,t,n,r,i,a,o=!1){for(let[n,r]of t){let t=e.get(n);t?.ready&&S(t.doc,r,`local-recovery`)}if(n.mode!==`whole`&&!t.has(`public`)&&!o&&L(e.get(`public`),z(i,n),z(a,n),`local-recovery`),r)for(let o of e.values())o.id!==`public`&&o.ready&&!t.has(o.id)&&L(o,await B(o.id,n,r,i),await B(o.id,n,r,a),`local-recovery`)}function ne(e,t,n){e.doc.on(`update`,(t,r)=>{r!==P&&n.live()&&(e.id===`public`&&n.convertible(e.text.toString())?n.convert():n.update(t))}),e.awareness.setLocalStateField(`user`,t),e.awareness.on(`update`,({added:t,updated:r,removed:i},a)=>{a!==P&&n.awarenessLive()&&e.ready&&n.awareness(b(e.awareness,[...t,...r,...i]))})}var Q=class extends Error{code=`collab_capacity`;constructor(){super(`This change is too large for a live session.`)}};function re(e,t){if(e instanceof Q)return`fallback`;if(e instanceof i)return e.code===`share_reference_refused`||t&&e.code===`note_too_large`?`let-go`:e.code===`share_collab_unavailable`?`unavailable`:e.code===`collab_capacity`||e.code===`collab_invalid_update`||e.code===`note_too_large`||e.status===413||e.status===400&&!e.code?`fallback`:void 0}var $=e=>e===`whole`,ie=class{ports;client=crypto.randomUUID();barrier;channels=new Map;state;stream;active=!0;joining=!1;queue=Promise.resolve();unsubscribe;pending=[];unacknowledged=new Set;closing=()=>{this.flush().catch(()=>!1)};sending;disposing;batchTimer;timer;lease;lastRenew=0;checkpointing;failures=0;through=0;durableSequence=0;applied=new Map;buffered=[];lastKey;attachedKey;peerAwareness=new X;needsJoin=!1;renamePending=!1;replacing=!1;converting=!1;outsidePaused=!1;outsideDirty=!1;constructor(e){this.ports=e,this.barrier=new Y({post:(e,t)=>this.post(e,t),drain:()=>this.drain(),through:()=>this.through,pause:e=>this.ports.paused?.(e),failed:e=>this.failed(e)}),window.addEventListener(`beforeunload`,this.closing),window.addEventListener(`blur`,this.closing),this.unsubscribe=e.transport.subscribe((e,t)=>{this.active&&(t?this.joining?this.buffered.push(t):this.enqueue(()=>this.receive(t)):e?e!==this.stream&&(this.stream=e,this.enqueue(()=>this.join())):(this.stream=void 0,this.ports.status(!0,this.failures)))}),this.timer=setInterval(()=>this.enqueue(()=>this.maintain()),1e3)}get connected(){return!!(this.stream&&this.state)}markRenaming(e){this.renamePending=e,e||this.send()}enqueue(e){this.queue=this.queue.then(e).catch(e=>this.failed(e))}async join(){if(this.stream&&this.active){this.joining=!0;try{let e=this.ports.baseBody(),t=this.ports.key(),n=await this.ports.transport.post(`attach`,{id:this.ports.id,stream:this.stream,client:this.client,unlocked:!!t});if(this.attachedKey=t,!this.active)return;if(this.ports.alive?.()===!1){await this.dispose(!1);return}this.ports.id=n.id,await this.initialize(n,e)}finally{this.joining=!1;let e=this.buffered.splice(0);for(let t of e)await this.receive(t)}}}async initialize(e,t,n,r=!0){if(e.mode===`scene`!=!!this.ports.kind||this.ports.kind&&this.ports.kind.mode!==e.mode){await this.dispose(!1),this.ports.fallback?.(!1,new i(`This note opened another kind of live session.`,409,`collab_kind_mismatch`));return}if(this.ports.kind){this.reset(e),await this.ports.kind.bind(e,r),await this.ports.bound(this.channels,e),this.publishStatus(),await this.post(`acknowledge`,{throughSequence:this.through});return}let a=this.state?.session===e.session&&this.state?.epoch===e.epoch,o=this.ports.key();if(M(this.ports.recipient,!!this.state,a,!!(this.pending.length||this.unacknowledged.size)))throw this.outsidePaused=!0,this.ports.paused?.(!0),Error(`The editing session changed while edits were pending. Your text is retained; reload only after copying it.`);let s;try{s=await J(e,this.ports.vault,o,this.client,(t,n)=>this.ports.transport.post(t,{id:e.id,stream:this.stream,client:this.client,session:e.session,epoch:e.epoch,...n}))}catch(e){throw this.outsidePaused=!0,this.ports.remoteError?.(`The encrypted session could not be authenticated. The document and local draft are retained.`),e}if(this.ports.alive?.()===!1){for(let e of s.values())e.awareness.destroy(),e.doc.destroy();await this.dispose(!1);return}let c=new Map;if(a&&r)for(let e of this.channels.values())e.ready&&c.set(e.id,_(e.doc));this.reset(e),this.lastKey=o;for(let[e,t]of s)this.channels.set(e,t);for(let t of this.channels.values())ne(t,A(this.ports.identityScope),{live:()=>this.active&&!this.converting,awarenessLive:()=>this.active&&!this.replacing&&!!this.stream,convertible:t=>m(t)||e.blocks.some(e=>!t.includes(`<!--braian-collab:${e.id}-->`)),convert:()=>{this.converting=!0,this.storedBody().then(e=>this.convert(e)).catch(e=>this.failed(e)).finally(()=>{this.converting=!1})},update:e=>this.enqueueUpdate({channel:t.id,bytes:e,updateId:crypto.randomUUID()}),awareness:e=>void this.sendAwareness(t,e).catch(e=>this.failed(e))});await Z(this.channels,c,e,this.lastKey,t,n??await this.ports.localBody(),this.ports.recipient),await this.ports.bound(this.channels,e),this.barrier.receive(e.barrier),this.ports.changed(),this.publishStatus(),this.ready()&&await this.post(`acknowledge`,{throughSequence:this.through})}reset(e){this.replacing=!0,this.destroyChannels(),this.replacing=!1,this.pending.splice(0),this.unacknowledged.clear(),this.applied.clear(),this.needsJoin=!1,this.outsidePaused=!1,this.outsideDirty=!1,this.state=e,this.lease=e.lease,this.through=e.sequence,this.durableSequence=e.durableSequence}push(e){this.enqueueUpdate({channel:`public`,payload:e,updateId:crypto.randomUUID()})}enqueueUpdate(e){this.pending.push(e),this.ports.changed(),this.publishStatus(),this.batchTimer||=setTimeout(()=>{this.batchTimer=void 0,this.send()},100)}announce(e){return this.connected&&!this.renamePending?this.post(`awareness`,{channel:`public`,updateId:crypto.randomUUID(),awareness:e}):Promise.resolve()}get settled(){return!this.pending.length&&!this.unacknowledged.size}ready(){return!!(this.state&&this.state.blocks.filter(e=>$(this.state.mode)&&e.editable).every(e=>this.channels.get(e.id)?.ready))}async receive(e){if(this.state&&e.session===this.state.session&&(e.id===this.ports.id||e.kind===`renamed`&&e.previousId===this.ports.id)){if(e.kind===`epoch`)this.ports.paused?.(!0),await this.initialize(e.state,e.state.storedBody,e.state.storedBody),this.barrier.receive();else if(e.epoch===this.state.epoch){if(e.kind===`update`){if(e.sequence<=this.through)return;if(this.applied.size>=1024)throw this.needsJoin=!0,Error(`Live updates need to be resynchronized; the local draft is retained.`);for(this.applied.set(e.sequence,e);this.applied.has(this.through+1);){let e=this.applied.get(this.through+1);e.client===this.client&&this.unacknowledged.delete(e.updateId);let t=this.channels.get(e.channel);if(this.ports.kind)this.ports.kind.apply(e.update??``,e.client);else if(t){let n=e.channel===`public`?s(e.update):await this.openEnvelope(t,e.envelope);try{H(t,n,P)}catch(e){throw this.outsidePaused=!0,this.ports.remoteError?.(`An invalid live update was refused. The document and local draft are retained.`),e}e.envelope?.kind===`checkpoint`&&!t.ready&&(t.ready=!0,await this.ports.bound(this.channels,this.state))}this.applied.delete(++this.through)}this.ports.changed(),this.publishStatus(),this.barrier.schedule(),this.ready()&&!this.renamePending&&await this.post(`acknowledge`,{throughSequence:this.through})}else if(e.kind===`awareness`){if(this.ports.kind){e.awareness&&this.ports.kind.awareness(e.client,e.awareness);return}let t=this.channels.get(e.channel);if(!t)return;let n=e.channel===`public`?s(e.awareness):await E(t.key,t.context,e.envelope);this.peerAwareness.apply(e.client,t,n)}else e.kind===`durable`?(await q(this.state,this.channels,e),this.outsideDirty=!1,this.durableSequence=e.sequence,this.ports.durable(this.state.storedBody,e.revision),this.ports.changed(),this.failures=0,this.publishStatus()):e.kind===`left`?(this.peerAwareness.leave(e.client,this.channels),this.ports.kind?.leave(e.client)):e.kind===`barrier`?this.barrier.receive(e.barrier):e.kind===`lease`?this.lease=e.lease:e.kind===`outside`?await this.outside(e.storedBody,e.revision):e.kind===`renamed`?(this.ports.id=e.id,this.state.id=e.id,this.ports.ended(`renamed`),this.markRenaming(!1)):e.kind===`ended`?(this.ports.ended(e.reason),this.stream=void 0,this.dispose(!1)):e.kind===`error`&&this.failed(Error(e.message))}}}async openEnvelope(e,t){try{return await E(e.key,e.context,t)}catch(e){throw this.outsidePaused=!0,this.ports.remoteError?.(`An encrypted live update could not be authenticated. Saving is paused; the document and local draft are retained.`),e}}async outside(e,t){if(this.state&&this.lastKey&&this.lease?.client===this.client){try{await U(this.state,this.channels,this.lastKey,e)}catch{this.outsidePaused=!0,this.ports.remoteError?.(`The encrypted file changed but could not be decrypted. Live saving is paused; the file and local draft are retained.`);return}this.outsidePaused=!1,this.ports.remoteError?.(),this.outsideDirty=!0,this.state.revision=t,this.state.storedBody=e,this.ports.changed()}}async storedBody(){return this.state?V(this.state,this.channels,this.ports.key()):this.ports.localBody()}post(e,t={}){return!this.state||!this.stream?Promise.reject(Error(`Live editing is offline; the local draft is retained.`)):this.ports.transport.post(e,{id:this.ports.id,stream:this.stream,client:this.client,session:this.state.session,epoch:this.state.epoch,...t})}async send(){if(this.sending)return this.sending;if(this.stream&&this.state&&!this.renamePending&&!this.ports.hold?.())return this.sending=(async()=>{for(;this.pending.length&&this.active;){let t=this.pending[0],n=this.channels.get(t.channel),r=this.ports.kind;if(!t.request){let i=this.pending.filter(e=>e.channel===t.channel&&!e.request);for(let e of i.slice(1))this.pending.splice(this.pending.indexOf(e),1);r?t.request={channel:t.channel,updateId:t.updateId,update:r.encode(i.map(e=>e.payload))}:(t.bytes=ee(i.map(e=>e.bytes)),t.request={channel:t.channel,updateId:t.updateId,...t.channel===`public`?{update:e(t.bytes)}:{envelope:await T(n.key,n.context,{kind:`update`,sender:this.client,updateId:t.updateId},t.bytes)}})}if(String(t.request.update??``).length>1398104)throw new Q;this.unacknowledged.add(t.updateId),await this.post(`update`,t.request),this.pending.shift()}this.publishStatus()})().catch(async e=>{let t=re(e,!!this.ports.rejected);if(t&&this.pending.splice(0),t===`let-go`){let t=await this.ports.transport.post(`attach`,{id:this.ports.id,stream:this.stream,client:this.client,unlocked:!1});this.attachedKey=void 0,await this.initialize(t,t.storedBody,t.storedBody,!1),this.ports.rejected?.(e.code,e.message)}else t===`unavailable`?this.ports.ended(e.code):t===`fallback`?(this.unacknowledged.clear(),await this.dispose(!1),this.ports.fallback?.(!0)):this.failed(e)}).finally(()=>{this.sending=void 0}),this.sending}async sendAwareness(t,n){if(this.renamePending)return;let r=crypto.randomUUID();await this.post(`awareness`,{channel:t.id,updateId:r,...t.id===`public`?{awareness:e(n)}:{envelope:await T(t.key,t.context,{kind:`awareness`,sender:this.client,updateId:r},n)}})}async maintain(){this.active&&this.stream&&!this.renamePending&&(!this.state||this.needsJoin||this.lastKey!==this.ports.key()||this.attachedKey!==this.ports.key()?await this.join():(await this.send(),$(this.state.mode)&&this.ports.key()&&Date.now()-this.lastRenew>=5e3&&(this.lease=await this.post(`lease-renew`,{...this.lease?.client===this.client?{leaseGeneration:this.lease.generation}:{}}),this.lastRenew=Date.now()),this.lease?.client===this.client&&this.ready()&&(this.through>this.durableSequence||this.outsideDirty)&&await this.snapshot()))}snapshot(){return this.checkpointing||=(async()=>{if(this.ports.hold?.()||this.outsidePaused||!this.state||this.lease?.client!==this.client||!this.ready()||this.pending.length||this.unacknowledged.size)return!1;let e=this.through,t=this.state;await this.post(`acknowledge`,{throughSequence:e});let n=await W(this.channels,this.client),r=await this.storedBody();return e!==this.through||t!==this.state||this.pending.length||this.unacknowledged.size?!1:(await this.post(`checkpoint-save`,{leaseGeneration:this.lease.generation,throughSequence:e,expectedRevision:t.revision,storedBody:r,checkpoints:n}),!0)})().catch(e=>(this.failed(e),!1)).finally(()=>{this.checkpointing=void 0}),this.checkpointing}async drain(){await this.send(),await this.queue;for(let e=0;this.unacknowledged.size&&this.connected&&e<25;e++)await new Promise(e=>setTimeout(e,20)),await this.queue}async flush(){if(await this.drain(),!this.active||!this.connected||!this.state||this.pending.length||this.unacknowledged.size)return!1;if(!$(this.state.mode))await this.post(`flush`);else if((this.through>this.durableSequence||this.outsideDirty)&&!await this.snapshot())return!1;return await this.queue,this.pending.length===0&&this.durableSequence>=this.through}replaceBlock(e,t,n){return j(this.connected,this.state,e,t,n,e=>this.post(`block-replace`,e),()=>this.queue)}async convert(e){try{let t=await this.barrier.prepare();return await this.drain(),!this.connected||this.pending.length||this.unacknowledged.size||!this.ready()?!1:(await this.post(`acknowledge`,{throughSequence:this.through}),e=await K(this.state,this.channels,this.ports.key(),e,this.converting),await this.post(`convert`,{unlocked:!!this.ports.key(),barrier:t,throughSequence:this.through,expectedRevision:this.state.revision,storedBody:e}),!0)}catch(e){throw this.ports.remoteError?.(e instanceof Error?e.message:`Conversion was cancelled; the draft is retained.`),e}finally{await this.barrier.cancel().catch(()=>void 0)}}dispose(e=!0){return this.active?(this.disposing??=this.end(e),this.disposing):Promise.resolve()}async end(e){if(e){await this.flush().catch(()=>!1);for(let e of this.channels.values())e.awareness.setLocalState(null),this.connected&&e.ready&&await this.sendAwareness(e,b(e.awareness,[e.awareness.clientID])).catch(()=>void 0)}this.barrier.receive(),this.active=!1,window.removeEventListener(`beforeunload`,this.closing),window.removeEventListener(`blur`,this.closing),clearInterval(this.timer),this.batchTimer&&clearTimeout(this.batchTimer),this.connected&&this.post(`detach`).catch(()=>void 0),this.unsubscribe(),this.destroyChannels()}destroyChannels(){this.peerAwareness.clear();for(let e of this.channels.values())e.awareness.destroy(),e.doc.destroy();this.channels.clear()}publishStatus(){this.ports.status(!this.stream||this.pending.length>0||this.through>this.durableSequence,this.failures)}failed(e){this.active&&!this.replacing&&(this.state||this.ports.fallback?.(!1,e),e instanceof i&&e.code?.endsWith(`_expired`)&&(this.needsJoin=!0),e instanceof i&&e.code===`collab_stream_expired`?(this.stream=void 0,this.ports.transport.reconnect?.()):e instanceof i&&[`collab_incomplete_checkpoint`,`collab_incomplete_prefix`,`revision_conflict`,`collab_bootstrap_pending`].includes(e.code??``)||(e instanceof i&&e.code===`share_collab_unavailable`?this.ports.ended(e.code):(this.failures++,this.ports.status(!0,this.failures,e instanceof Error?e.message:`Live editing could not be reached.`))))}};export{N as a,I as i,z as n,A as o,P as r,ie as t};
@@ -0,0 +1 @@
1
+ import{Qu as e,od as t,sd as n}from"./logic-DtHJ5GlU.js";import{fn as r,un as i}from"./index-BVDhmwI8.js";function a(a){return{reconnect:()=>i(a),subscribe:e=>r(a,e),post:async(r,i)=>{let o=JSON.stringify(i),s=await n(t(a,`notes/collab/${r}`),{method:`POST`,headers:{"Content-Type":`application/json`},body:o,keepalive:o.length<6e4});if(!s.ok){let t=await s.json();throw new e(t.message??`Live editing could not be reached.`,s.status,t.code)}let c=await s.text();return c?JSON.parse(c):void 0}}}export{a as t};
@@ -1 +1 @@
1
- import{c as e}from"./settings-ChT117Ke.js";import{ar as t,jn as n,pr as r}from"./index-CCUyKE6q.js";import{t as i}from"./react-B3NTyEzE.js";var a=i();function o(){let{settings:i,ready:o,error:s,persist:c}=n();return(0,a.jsx)(e,{label:`Create note fast flow`,description:`Skip the title step: a new note opens in the editor and is named after its first title. One closed untouched is removed.`,persistence:`immediate`,layout:`control`,className:`note-create-setting`,children:(0,a.jsxs)(`div`,{children:[(0,a.jsx)(r,{checked:i.noteEditor.fastCreate===!0,disabled:!o,onCheckedChange:e=>void c({...i,noteEditor:{...i.noteEditor,fastCreate:e}}),children:(0,a.jsx)(`span`,{className:`visually-hidden`,children:`Create note fast flow`})}),s&&(0,a.jsxs)(t,{as:`small`,size:`caption`,tone:`danger`,className:`settings-inline-error`,role:`alert`,children:[`Unavailable: `,s]})]})})}var s={contributions:[{id:`note-create-fast-flow`,sectionId:`general`,priority:260,persistence:`immediate`,Component:o}]};export{s as noteCreateSettingsModule};
1
+ import{c as e}from"./settings-CU8YR8di.js";import{Nn as t,hr as n,sr as r}from"./index-BVDhmwI8.js";import{t as i}from"./react-B3NTyEzE.js";var a=i();function o(){let{settings:i,ready:o,error:s,persist:c}=t();return(0,a.jsx)(e,{label:`Create note fast flow`,description:`Skip the title step: a new note opens in the editor and is named after its first title. One closed untouched is removed.`,persistence:`immediate`,layout:`control`,className:`note-create-setting`,children:(0,a.jsxs)(`div`,{children:[(0,a.jsx)(n,{checked:i.noteEditor.fastCreate===!0,disabled:!o,onCheckedChange:e=>void c({...i,noteEditor:{...i.noteEditor,fastCreate:e}}),children:(0,a.jsx)(`span`,{className:`visually-hidden`,children:`Create note fast flow`})}),s&&(0,a.jsxs)(r,{as:`small`,size:`caption`,tone:`danger`,className:`settings-inline-error`,role:`alert`,children:[`Unavailable: `,s]})]})})}var s={contributions:[{id:`note-create-fast-flow`,sectionId:`general`,priority:260,persistence:`immediate`,Component:o}]};export{s as noteCreateSettingsModule};
@@ -1,2 +1,2 @@
1
- import{$u as e,Jc as t,Qs as n,Xc as r,al as i,el as a,ol as o,rc as s,td as c}from"./logic-BNk_20eJ.js";import{C as l,S as u,_ as d,b as f,g as p,h as m,nt as h,pn as g,tt as _,w as v,x as y,y as b}from"./index-CCUyKE6q.js";import{s as x}from"./note-values-BqD4746M.js";function S(e){return e.replace(/\r\n/g,`
2
- `).trimEnd()}function C(e,t,n){if(S(e.body)!==S(t.body))return!1;let r;try{r=x(e.frontmatterSource)}catch{return!1}let i={...t.frontmatter};for(let e of[n.typeKey,n.titleKey])Object.hasOwn(r,e)||delete i[e];return w(r,i)}function w(e,t){if(e===t)return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((e,n)=>w(e,t[n]));if(e instanceof Date||t instanceof Date)return e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime();if(typeof e!=`object`||typeof t!=`object`||e===null||t===null)return!1;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>Object.hasOwn(t,n)&&w(e[n],t[n]))}var T=class{notify;value={body:``,safe:!1,locked:!1,busy:!1};cipher=``;encryptedPlain=``;key;epoch=0;running;constructor(e){this.notify=e}get state(){return this.value}noteKey(){return this.key}stored(){return this.value.safe?this.cipher:this.value.body}async durable(e){if(!this.value.safe||!this.key||!o(e))return;let n=await t(this.key,e);!this.value.busy&&n===this.value.body&&(this.cipher=e,this.encryptedPlain=n,this.notify())}async open(e,n){let r=++this.epoch;if(!o(e)){this.value={body:e,safe:!1,locked:!1,busy:!1},this.notify();return}this.cipher=e;let i=a(e),s=this.key?.id===i?this.key:void 0;if(s||(this.value={body:``,safe:!0,locked:!0,busy:!1}),!s&&!n)this.notify();else{try{let a=s??(i?await n(i):void 0);if(r!==this.epoch)return;if(!a)throw Error(`This note's key is not in the vault.`);let o=await t(a,e);if(r!==this.epoch)return;this.key=a,this.encryptedPlain=o,this.value={body:o,safe:!0,locked:!1,busy:!1}}catch(e){if(r!==this.epoch)return;this.value={body:``,safe:!0,locked:!0,busy:!1,error:e instanceof Error?e.message:String(e)}}this.notify()}}change(e){this.value.locked||e===this.value.body||(this.value={...this.value,body:e,busy:this.value.safe,error:void 0},this.notify(),this.value.safe&&this.pump())}async encrypt(e){return!this.value.locked&&(++this.epoch,this.key=e,this.encryptedPlain=`\0`,this.value={...this.value,safe:!0,busy:!0,error:void 0},this.notify(),this.pump(),this.settle())}decrypt(){this.value.locked||(++this.epoch,this.value={...this.value,safe:!1,busy:!1,error:void 0},this.notify())}async unlock(e){this.key=void 0,await this.open(this.cipher,e)}async lock(){let e=this.value.safe&&!this.value.locked;return e&&await this.settle(),++this.epoch,this.key=void 0,this.encryptedPlain=``,this.value.safe?(this.value={body:``,safe:!0,locked:!0,busy:!1},this.notify(),e):!1}clear(){++this.epoch,this.key=void 0,this.cipher=this.encryptedPlain=``,this.value={body:``,safe:!1,locked:!1,busy:!1}}async settle(){for(;this.running;)await this.running;return!this.value.busy&&!this.value.error}pump(){this.running||=this.encryptLatest().finally(()=>{this.running=void 0,this.value.safe&&!this.value.locked&&!this.value.error&&this.encryptedPlain!==this.value.body&&this.pump()})}async encryptLatest(){let e=this.epoch;try{for(;this.value.safe&&this.key&&this.encryptedPlain!==this.value.body;){let e=this.epoch,t=this.value.body,n=await r(this.key,t);e===this.epoch&&(this.cipher=n,this.encryptedPlain=t)}this.value={...this.value,busy:!1}}catch(t){if(e!==this.epoch)return;this.value={...this.value,busy:!1,error:t instanceof Error?t.message:String(t)}}this.notify()}},E={resolve:async()=>void 0,forBody:async()=>void 0,mint:async()=>{throw Error(`Safe Notes is not available here.`)},drop:async()=>void 0},D=class{host;keys=E;generation=0;held;constructor(e){this.host=e}current(){return this.host.codec.noteKey()??this.held}forget(){this.held=void 0,this.generation++}resolver(e){return e?t=>this.keys.resolve(e,t):void 0}collabResolver(){let e=this.current();return e?async t=>t===e.id?e:void 0:void 0}async adoptMaster(e){let{codec:t}=this.host;if(this.host.disposed())return;if(!e){(this.held||t.state.safe&&!t.state.locked)&&await this.host.lock();return}let n=t.stored();if(t.state.safe){t.state.locked&&await this.host.unlock(e);return}if(!i(n))return;let r=await this.keys.forBody(e,n).catch(()=>void 0);this.host.disposed()||r===this.held||(this.held=r,this.generation++,this.host.publish())}async noteKeyWith(e){let t=this.current()??await this.keys.forBody(e,this.host.codec.stored())??await this.keys.mint(e);return t!==this.held&&!this.host.codec.noteKey()&&(this.held=t,this.generation++,this.host.publish()),t}dropAfterDecrypt(e,t){t&&e&&!i(this.host.codec.stored())&&this.keys.drop(e.id).catch(()=>void 0)}async dropIfPlain(){let e=this.current();!e||this.host.codec.state.safe||i(this.host.codec.stored())||await this.host.flush()&&!i(this.host.codec.stored())&&(this.held=void 0,this.generation++,this.host.publish(),await this.keys.drop(e.id).catch(()=>void 0))}},O=class{vault;ports;held=!1;disposed=!1;running;renaming;unsubscribe;constructor(e,t){this.vault=e,this.ports=t,this.unsubscribe=g(e,e=>{if(!t.loading()){if(e.type===`reset`)this.changed();else if(e.type===`changes`)for(let n of e.changes)n.kind===`note`&&n.id===t.id()&&(n.action===`deleted`?this.renaming||t.error(`This note was deleted elsewhere. Edits can no longer be saved.`):n.revision&&n.revision===t.revision()||this.changed())}})}markRenaming(e){this.renaming=e}saved(){this.held=!1}changed(){this.held=!0,this.check()}check(){!this.disposed&&this.held&&!this.running&&this.ports.idle()&&this.reload()}reload=()=>{if(this.running)return this.running;if(!this.ports.idle())return this.held=!0,Promise.resolve();this.held=!1;let e=this.ports.id(),t=this.ports.revision();return this.running=n(e,this.vault).then(async n=>{this.disposed||e!==this.ports.id()||t===this.ports.revision()&&(this.ports.idle()?n.revision!==this.ports.revision()&&await this.ports.adopt(n):this.held=!0)}).catch(e=>{this.disposed||this.ports.error(c(e))}).finally(()=>{this.running=void 0,this.check()}),this.running};dispose(){this.disposed=!0,this.unsubscribe()}},k=class{vaultId;noteId;ports;disposed=!1;parked=!1;park(e){this.parked=e,this.clearTimers()}ownWrites=new WeakSet;saveTimer;queued;interval;withdraw;unsubscribe;blur=()=>{this.flush()};visibility=()=>{document.visibilityState!==`visible`&&this.flush()};unload=()=>{if(!this.ports.dirty()||!this.ports.ready())return;let e=this.ports.payload();this.buffer(e),this.parked||d(this.vaultId,this.noteId,e)};constructor(e,t,n){this.vaultId=e,this.noteId=t,this.ports=n,this.unsubscribe=this.subscribe(),this.withdraw=b(e,()=>this.ports.flush?this.ports.flush():this.flush(),()=>this.ports.unsaved?.()??{noteId:this.noteId,reason:`its last write has not landed`}),this.interval=window.setInterval(()=>{this.flush()},1e4),window.addEventListener(`blur`,this.blur),window.addEventListener(`beforeunload`,this.unload),document.addEventListener(`visibilitychange`,this.visibility)}schedule(e=!1){this.clearTimers(),!this.disposed&&this.ports.ready()&&(this.ports.dirty()?(this.buffer(),(!this.parked||this.ports.pendingProperties?.())&&(e?this.send():this.saveTimer=window.setTimeout(()=>this.send(),1500))):u(this.vaultId,this.noteId))}revision(e){f(this.vaultId,this.noteId,e)}async flush(){return this.parked?this.parkedProperties():this.disposed||!await this.ports.settle()?!1:(this.enqueue(),p(this.vaultId,this.noteId))}async properties(e){let t={...this.ports.payload(),body:e.body,revision:e.revision,propertiesOnly:!0};return this.queued?.propertiesOnly&&this.queued.frontmatterSource===t.frontmatterSource||(this.ownWrites.add(t),this.queued=t,m(this.vaultId,this.noteId,t)),p(this.vaultId,this.noteId)}rename(e){this.clearTimers(),this.unsubscribe(),this.noteId=e,this.unsubscribe=this.subscribe()}dispose(){this.disposed=!0,this.withdraw(),this.clearTimers(),window.clearInterval(this.interval),this.unsubscribe(),window.removeEventListener(`blur`,this.blur),window.removeEventListener(`beforeunload`,this.unload),document.removeEventListener(`visibilitychange`,this.visibility)}subscribe(){return y(this.vaultId,this.noteId,(e,t,n)=>{this.ports.status(e),t&&(n===this.queued&&(this.queued=void 0),this.ports.saved(t,n&&this.ownWrites.has(n)?n:void 0))})}buffer(e=this.ports.payload()){!this.disposed&&this.ports.ready()&&v(this.vaultId,this.noteId,e)}send(){this.parked?this.parkedProperties():this.enqueue()}parkedProperties(){this.clearTimers();let e=this.disposed?void 0:this.ports.pendingProperties?.();return e?this.properties(e):Promise.resolve(!1)}enqueue(){if(this.clearTimers(),this.parked||!this.ports.ready()||!this.ports.dirty())return;let e=this.ports.payload();(this.queued?.body!==e.body||this.queued.frontmatterSource!==e.frontmatterSource)&&(this.queued=e,this.ownWrites.add(e),this.buffer(e),m(this.vaultId,this.noteId,e))}clearTimers(){this.saveTimer!==void 0&&window.clearTimeout(this.saveTimer),this.saveTimer=void 0}},A=class{ports;folderRule;serial=0;automatic=!1;declinedAt=0;constructor(e){this.ports=e}pending=()=>!!this.folderRule?.required()&&!this.ports.codec.state.safe;require(){this.automatic||!this.ports.edited()||!this.pending()||Date.now()-this.declinedAt<3e4||(this.automatic=!0,(async()=>{try{let e=await this.folderRule.key();e&&this.pending()&&await this.encrypt(e,!1)||(this.declinedAt=e?0:Date.now())}catch{this.declinedAt=Date.now()}finally{this.automatic=!1,this.ports.publish()}})())}async encrypt(e,t=!0){let{ports:n}=this,{codec:r}=n,i=++this.serial;if(t&&!await n.flush()||i!==this.serial)return!1;let a=await n.noteKeyWith(e);if(i!==this.serial)return!1;let o=r.stored();if(!await r.encrypt(a))return!1;let s=n.collaboration();if(s){try{if(await s.convert(r.stored()))return!0}catch(e){n.remoteError(e instanceof Error?e.message:`Encryption could not be committed.`)}return await n.restore(o),!1}return n.flush()}decrypt(){if(this.folderRule?.required())return;let{ports:e}=this,{codec:t}=e;++this.serial;let n=t.stored(),r=t.noteKey();t.decrypt();let i=t=>e.dropAfterDecrypt(r,t),a=e.collaboration();a?a.convert(t.stored()).then(t=>{if(!t)return e.restore(n);i(!0)}).catch(t=>(e.remoteError(t instanceof Error?t.message:`The conversion could not be committed.`),e.restore(n))):e.flush().then(i)}};function j({note:e,frontmatterSource:t,loading:n,codec:r,remoteError:i,collabPaused:a,bindingGeneration:o,noteKeyGeneration:s,queue:c,dirty:l}){return{note:e,body:r.body,frontmatterSource:t,loading:n,safe:r.safe,locked:r.locked,busy:r.busy,error:r.error,remoteError:i,collabPaused:a,bindingGeneration:o,noteKeyGeneration:s,saveStatus:c.status===`error`||r.error?`buffered`:c.status===`saving`||r.busy||l?`saving`:`idle`,saveError:c.error??r.error,saveFailures:c.failures??0,saveRetryable:c.retryable}}var M=new Map,N=0,P=(e,t)=>`${e}\u0000${t}`,F=class{vaultId;noteId;listeners=new Set;surfaces=new Map;codec=new T(()=>this.codecChanged());persistence;snapshot;note;frontmatter=``;saved={body:``,frontmatterSource:``};written={body:``,revision:``};loading=!0;initializing=!1;loadPromise;queue={status:`idle`};binding;collaboration;keyHolder=new D({codec:this.codec,disposed:()=>this.disposed,publish:()=>this.publish(),unlock:e=>this.unlock(e),lock:()=>this.lock(),flush:()=>this.flush()});conversion=new A({codec:this.codec,collaboration:()=>this.collaboration,flush:()=>this.flush(),noteKeyWith:e=>this.noteKeyWith(e),dropAfterDecrypt:(e,t)=>this.keyHolder.dropAfterDecrypt(e,t),restore:e=>this.collabStorage(e),remoteError:e=>this.collabRemoteError(e),edited:()=>!this.disposed&&!this.loading&&this.dirty(),publish:()=>this.publish()});liveClosed=!1;paused=!1;bindingGeneration=0;reloader;remoteError;disposed=!1;references=0;key=`note-document-${++N}`;formerIds=new Set;get folderRule(){return this.conversion.folderRule}set folderRule(e){this.conversion.folderRule=e}get keys(){return this.keyHolder.keys}set keys(e){this.keyHolder.keys=e}noteKeys=e;constructor(e,t,n){this.vaultId=e,this.noteId=t,this.snapshot=this.readSnapshot(),this.persistence=new k(e,t,{payload:()=>({frontmatterSource:this.frontmatter,body:this.codec.stored(),revision:this.note?.revision??``}),ready:()=>!!this.note&&!this.loading&&!this.codec.state.busy&&!this.codec.state.error&&!this.folderEncryptionPending(),dirty:()=>this.dirty(),settle:()=>this.codec.settle(),saved:(e,t)=>this.didSave(e,t),status:e=>{this.queue=e,this.publish()},flush:()=>this.flush(),pendingProperties:()=>this.pendingProperties(),unsaved:()=>({noteId:this.noteId,reason:this.queue.error??this.codec.state.error??(this.folderEncryptionPending()?`it is in an encrypted folder and waits for the vault key`:`its last write has not landed`)})}),this.reloader=new O(e,{id:()=>this.noteId,revision:()=>this.note?.revision,idle:()=>this.idle(),loading:()=>this.loading,adopt:e=>this.adopt(e),error:e=>{this.remoteError=e,this.publish()}}),n!==void 0&&this.codec.open(n)}getSnapshot=()=>this.snapshot;isDisposed=()=>this.disposed;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));collabKey=()=>this.keyHolder.current();adoptMaster(e){return this.keyHolder.adoptMaster(e)}noteKeyWith(e){return this.keyHolder.noteKeyWith(e)}dropKeyIfPlain(){return this.keyHolder.dropIfPlain()}collabBase=()=>this.saved.body;async collabStorage(e){this.initializing=!0,await this.codec.open(e,this.keyHolder.collabResolver()),this.initializing=!1,this.publish()}async collabOutside(e){this.codec.change(e);try{let t=await n(this.noteId,this.vaultId);await s(this.noteId,{vault:this.vaultId,frontmatterSource:this.frontmatter,body:e,revision:t.revision})}catch(e){this.collabRemoteError(e instanceof Error?e.message:`The source edit could not be saved; the local draft is retained.`)}}collabBody(e){this.codec.change(e),this.conversion.require()}collabPause(e){this.paused=e,this.publish()}collabRemoteError(e){this.remoteError=e,this.publish()}async collabRenamed(e){this.reloader.markRenaming(e),this.rename(e);let t=await n(e,this.vaultId),r=this.frontmatter!==this.saved.frontmatterSource;this.note=t,this.written={body:t.body,revision:t.revision},this.saved.frontmatterSource=t.frontmatterSource,r||(this.frontmatter=t.frontmatterSource),this.persistence.revision(t.revision),this.publish(),r&&this.persistence.schedule()}collabStatus(e,t,n){let r={status:t?`error`:e?`saving`:`idle`,failures:t,error:n},{queue:i}=this;(i.status!==r.status||i.failures!==r.failures||i.error!==r.error||i.retryable!==void 0)&&(this.queue=r,this.publish())}collabDurable(e,t,n=e){this.note&&(this.note={...this.note,body:e,revision:t},this.saved={...this.saved,body:e},n!==null&&(this.written={body:n,revision:t}),this.persistence.revision(t),this.codec.durable(e).then(()=>{this.dirty()||u(this.vaultId,this.noteId)}),this.dirty()||u(this.vaultId,this.noteId),this.publish(),this.codec.state.locked||_({vaultId:this.vaultId,noteId:this.noteId,revision:t,stored:n??e,key:this.collabKey()}))}collabClosed(){this.collaboration=void 0,this.liveClosed=!0,this.binding?.dispose(),this.binding=void 0,this.persistence.park(!0)}collabFallback(){this.collaboration=void 0,this.persistence.park(!1),this.persistence.schedule()}manageCollab(e){this.collaboration?.owner&&this.collaboration.owner!==e.owner&&this.collaboration.dispose(!1),this.collaboration=e,this.liveClosed=!1,this.persistence.park(!0)}storedBody=()=>this.codec.stored();settledBody=async()=>(await this.codec.settle(),this.codec.stored());attachSurface(e,t){return this.surfaces.set(e,t),()=>this.surfaces.delete(e)}idle(){return!this.loading&&!this.dirty()&&this.queue.status===`idle`}dirty(){return this.codec.state.busy||S(this.codec.stored())!==S(this.saved.body)||this.frontmatter!==this.saved.frontmatterSource}load(e,t){return this.loadPromise?!this.loading&&!this.dirty()&&t?.id===this.noteId&&t.revision!==this.note?.revision?this.adopt(structuredClone(t),e):this.loadPromise:(this.loadPromise=this.initialize(e,t?.id===this.noteId?t:void 0).catch(e=>{throw this.loadPromise=void 0,this.loading=!1,this.publish(),e}),this.loadPromise)}async initialize(e,t){let r=t?structuredClone(t):await n(this.noteId,this.vaultId);if(this.disposed)return;this.initializing=!0;let i=l(this.vaultId,this.noteId),a=!!(t&&i&&i.revision!==r.revision&&S(r.body).startsWith(S(i.body))),o=!(!i||a||i.frontmatterSource===r.frontmatterSource&&S(i.body)===S(r.body));this.note=r,this.written={body:r.body,revision:r.revision},this.saved={body:r.body,frontmatterSource:r.frontmatterSource},this.frontmatter=o?i.frontmatterSource:r.frontmatterSource,await this.codec.open(o?i.body:r.body,this.keyHolder.resolver(e)),this.loading=!1,this.initializing=!1,this.persistence.revision(r.revision),i&&!o&&u(this.vaultId,this.noteId),this.binding?.apply(this.codec.state.body,!1),this.announceHeld(),this.publish(),o&&!this.codec.state.locked&&this.persistence.schedule(!0),e&&this.adoptMaster(e)}setBody=e=>{this.codec.state.locked||e===this.codec.state.body||(!this.collaboration&&this.liveClosed&&(this.liveClosed=!1,this.persistence.park(!1)),this.collaboration?this.collaboration.apply(e,!0):this.binding?this.binding.apply(e,!0):this.textChanged(e))};textChanged(e){this.codec.change(e),this.conversion.require()}bind(e){this.binding?.dispose(),this.binding=e,this.bindingGeneration++,queueMicrotask(()=>this.publish())}setFrontmatter(e,t=!1){this.frontmatter=e,this.publish(),this.conversion.require(),t?this.flush():this.persistence.schedule()}folderEncryptionPending=()=>this.conversion.pending();encrypt(e){return this.conversion.encrypt(e)}decrypt(){this.conversion.decrypt()}async unlock(e){await this.codec.unlock(t=>this.keys.resolve(e,t)),this.binding?.apply(this.codec.state.body,!1),this.announceHeld(),this.publish(),this.dirty()&&this.persistence.schedule(!0)}announceHeld(){this.note&&this.codec.state.safe&&!this.codec.state.locked&&!this.codec.state.busy&&!this.dirty()&&h({vaultId:this.vaultId,noteId:this.noteId,revision:this.note.revision,body:this.codec.state.body,safe:!0})}async lock(){this.collaboration&&await this.collaboration.flush().catch(()=>!1),this.keyHolder.forget(),await this.codec.lock()&&!this.collaboration&&this.binding?.apply(``,!1),this.publish()}flush=async()=>{if(!this.collaboration){let e=this.pendingProperties();return this.liveClosed?e?this.persistence.properties(e):!this.dirty():this.persistence.flush()}let e=await this.collaboration.flush().catch(()=>!1),t=this.pendingProperties();return(!t||await this.persistence.properties(t))&&e};pendingProperties(){return this.frontmatter===this.saved.frontmatterSource?void 0:this.written}async adopt(e,t){let n=e.id!==this.noteId;n&&this.rename(e.id),e.revision===this.note?.revision&&!this.loading?n&&(this.note=e,this.written={body:e.body,revision:e.revision},this.reloader.markRenaming(),this.publish()):(this.initializing=!0,this.note=e,this.written={body:e.body,revision:e.revision},this.saved={body:e.body,frontmatterSource:e.frontmatterSource},this.frontmatter=e.frontmatterSource,this.collaboration||await this.codec.open(e.body,this.keyHolder.resolver(t)??this.keyHolder.collabResolver()),this.initializing=!1,this.loading=!1,this.collaboration||(this.remoteError=void 0),this.reloader.markRenaming(),this.collaboration||(this.binding?.apply(this.codec.state.body,!1),this.announceHeld()),this.persistence.revision(e.revision),this.publish(),t&&this.adoptMaster(t))}knownAs(e){return this.noteId===e||this.formerIds.has(e)}rename(e){this.formerIds.add(this.noteId),M.delete(P(this.vaultId,this.noteId)),u(this.vaultId,this.noteId),this.noteId=e,M.set(P(this.vaultId,e),this),this.persistence.rename(e)}reload=()=>this.reloader.reload();markRenaming(e){this.reloader.markRenaming(e),this.collaboration?.renaming?.(!!e)}didSave(e,t){if(t===void 0){this.reloader.changed();return}this.reloader.saved(),this.note=e,this.written={body:e.body,revision:e.revision},this.saved={body:t.propertiesOnly&&this.collaboration?this.saved.body:e.body,frontmatterSource:e.frontmatterSource},!t.propertiesOnly&&!this.codec.state.safe&&this.codec.stored()===t.body&&S(e.body)!==S(t.body)&&(this.binding?this.binding.apply(e.body,!1):this.codec.change(e.body));let n=t.propertiesOnly?e.body:this.codec.state.busy?void 0:this.codec.stored();n!==void 0&&C({body:n,frontmatterSource:this.frontmatter},e,this.noteKeys)&&(this.frontmatter=e.frontmatterSource),this.publish(),this.dirty()&&this.persistence.schedule(),!this.codec.state.locked&&!this.codec.state.busy&&S(this.codec.stored())===S(e.body)&&h({vaultId:this.vaultId,noteId:this.noteId,revision:e.revision,body:this.codec.state.body,safe:this.codec.state.safe})}codecChanged(){this.publish(),!this.initializing&&!this.loading&&this.persistence.schedule()}readSnapshot(){return j({note:this.note,frontmatterSource:this.frontmatter,loading:this.loading,codec:this.codec.state,remoteError:this.remoteError,collabPaused:this.paused,bindingGeneration:this.bindingGeneration,noteKeyGeneration:this.keyHolder.generation,queue:this.queue,dirty:this.dirty()})}publish(){if(!this.disposed){this.snapshot=this.readSnapshot();for(let e of this.listeners)e();this.reloader?.check()}}async dispose(){this.disposed||((this.note||this.codec.state.busy)&&await this.flush(),this.references||(await this.collaboration?.dispose(),this.collaboration=void 0,this.references||(this.discard(),M.get(P(this.vaultId,this.noteId))===this&&M.delete(P(this.vaultId,this.noteId)))))}discard(){this.disposed=!0,this.collaboration?.dispose(!1),this.collaboration=void 0,this.keyHolder.forget(),this.reloader.dispose(),this.persistence.dispose(),this.binding?.dispose(),this.binding=void 0,this.codec.clear(),this.listeners.clear(),this.surfaces.clear(),this.note=void 0,this.frontmatter=``,this.saved={body:``,frontmatterSource:``},this.snapshot=this.readSnapshot()}};function I(e,t,n){let r=P(e,t),i=M.get(r);i||(i=new F(e,t,n),M.set(r,i)),i.references+=1;let a=!1;return{document:i,release:()=>{a||(a=!0,--i.references,i.references||queueMicrotask(()=>{i.references||i.dispose()}))}}}export{C as n,S as r,I as t};
1
+ import{Jc as e,Kc as t,Qc as n,ac as r,ec as i,il as a,rd as o,rl as s,td as c}from"./logic-DtHJ5GlU.js";import{C as l,S as u,_ as d,b as f,dn as p,g as m,h,nt as g,tt as _,w as v,x as y,y as b}from"./index-BVDhmwI8.js";import{s as x}from"./note-values-6D6wWXPg.js";function S(e){return e.replace(/\r\n/g,`
2
+ `).trimEnd()}function C(e,t,n){if(S(e.body)!==S(t.body))return!1;let r;try{r=x(e.frontmatterSource)}catch{return!1}let i={...t.frontmatter};for(let e of[n.typeKey,n.titleKey])Object.hasOwn(r,e)||delete i[e];return w(r,i)}function w(e,t){if(e===t)return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((e,n)=>w(e,t[n]));if(e instanceof Date||t instanceof Date)return e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime();if(typeof e!=`object`||typeof t!=`object`||e===null||t===null)return!1;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>Object.hasOwn(t,n)&&w(e[n],t[n]))}var T=class{notify;value={body:``,safe:!1,locked:!1,busy:!1};cipher=``;encryptedPlain=``;key;epoch=0;running;constructor(e){this.notify=e}get state(){return this.value}noteKey(){return this.key}stored(){return this.value.safe?this.cipher:this.value.body}async durable(e){if(!this.value.safe||!this.key||!a(e))return;let n=await t(this.key,e);!this.value.busy&&n===this.value.body&&(this.cipher=e,this.encryptedPlain=n,this.notify())}async open(e,r){let i=++this.epoch;if(!a(e)){this.value={body:e,safe:!1,locked:!1,busy:!1},this.notify();return}this.cipher=e;let o=n(e),s=this.key?.id===o?this.key:void 0;if(s||(this.value={body:``,safe:!0,locked:!0,busy:!1}),!s&&!r)this.notify();else{try{let n=s??(o?await r(o):void 0);if(i!==this.epoch)return;if(!n)throw Error(`This note's key is not in the vault.`);let a=await t(n,e);if(i!==this.epoch)return;this.key=n,this.encryptedPlain=a,this.value={body:a,safe:!0,locked:!1,busy:!1}}catch(e){if(i!==this.epoch)return;this.value={body:``,safe:!0,locked:!0,busy:!1,error:e instanceof Error?e.message:String(e)}}this.notify()}}change(e){this.value.locked||e===this.value.body||(this.value={...this.value,body:e,busy:this.value.safe,error:void 0},this.notify(),this.value.safe&&this.pump())}async encrypt(e){return!this.value.locked&&(++this.epoch,this.key=e,this.encryptedPlain=`\0`,this.value={...this.value,safe:!0,busy:!0,error:void 0},this.notify(),this.pump(),this.settle())}decrypt(){this.value.locked||(++this.epoch,this.value={...this.value,safe:!1,busy:!1,error:void 0},this.notify())}async unlock(e){this.key=void 0,await this.open(this.cipher,e)}async lock(){let e=this.value.safe&&!this.value.locked;return e&&await this.settle(),++this.epoch,this.key=void 0,this.encryptedPlain=``,this.value.safe?(this.value={body:``,safe:!0,locked:!0,busy:!1},this.notify(),e):!1}clear(){++this.epoch,this.key=void 0,this.cipher=this.encryptedPlain=``,this.value={body:``,safe:!1,locked:!1,busy:!1}}async settle(){for(;this.running;)await this.running;return!this.value.busy&&!this.value.error}pump(){this.running||=this.encryptLatest().finally(()=>{this.running=void 0,this.value.safe&&!this.value.locked&&!this.value.error&&this.encryptedPlain!==this.value.body&&this.pump()})}async encryptLatest(){let t=this.epoch;try{for(;this.value.safe&&this.key&&this.encryptedPlain!==this.value.body;){let t=this.epoch,n=this.value.body,r=await e(this.key,n);t===this.epoch&&(this.cipher=r,this.encryptedPlain=n)}this.value={...this.value,busy:!1}}catch(e){if(t!==this.epoch)return;this.value={...this.value,busy:!1,error:e instanceof Error?e.message:String(e)}}this.notify()}},E={resolve:async()=>void 0,forBody:async()=>void 0,mint:async()=>{throw Error(`Safe Notes is not available here.`)},drop:async()=>void 0},D=class{host;keys=E;generation=0;held;constructor(e){this.host=e}current(){return this.host.codec.noteKey()??this.held}forget(){this.held=void 0,this.generation++}resolver(e){return e?t=>this.keys.resolve(e,t):void 0}collabResolver(){let e=this.current();return e?async t=>t===e.id?e:void 0:void 0}async adoptMaster(e){let{codec:t}=this.host;if(this.host.disposed())return;if(!e){(this.held||t.state.safe&&!t.state.locked)&&await this.host.lock();return}let n=t.stored();if(t.state.safe){t.state.locked&&await this.host.unlock(e);return}if(!s(n))return;let r=await this.keys.forBody(e,n).catch(()=>void 0);this.host.disposed()||r===this.held||(this.held=r,this.generation++,this.host.publish())}async noteKeyWith(e){let t=this.current()??await this.keys.forBody(e,this.host.codec.stored())??await this.keys.mint(e);return t!==this.held&&!this.host.codec.noteKey()&&(this.held=t,this.generation++,this.host.publish()),t}dropAfterDecrypt(e,t){t&&e&&!s(this.host.codec.stored())&&this.keys.drop(e.id).catch(()=>void 0)}async dropIfPlain(){let e=this.current();!e||this.host.codec.state.safe||s(this.host.codec.stored())||await this.host.flush()&&!s(this.host.codec.stored())&&(this.held=void 0,this.generation++,this.host.publish(),await this.keys.drop(e.id).catch(()=>void 0))}},O=class{vault;ports;held=!1;disposed=!1;running;renaming;unsubscribe;constructor(e,t){this.vault=e,this.ports=t,this.unsubscribe=p(e,e=>{if(!t.loading()){if(e.type===`reset`)this.changed();else if(e.type===`changes`)for(let n of e.changes)n.kind===`note`&&n.id===t.id()&&(n.action===`deleted`?this.renaming||t.error(`This note was deleted elsewhere. Edits can no longer be saved.`):n.revision&&n.revision===t.revision()||this.changed())}})}markRenaming(e){this.renaming=e}saved(){this.held=!1}changed(){this.held=!0,this.check()}check(){!this.disposed&&this.held&&!this.running&&this.ports.idle()&&this.reload()}reload=()=>{if(this.running)return this.running;if(!this.ports.idle())return this.held=!0,Promise.resolve();this.held=!1;let e=this.ports.id(),t=this.ports.revision();return this.running=i(e,this.vault).then(async n=>{this.disposed||e!==this.ports.id()||t===this.ports.revision()&&(this.ports.idle()?n.revision!==this.ports.revision()&&await this.ports.adopt(n):this.held=!0)}).catch(e=>{this.disposed||this.ports.error(o(e))}).finally(()=>{this.running=void 0,this.check()}),this.running};dispose(){this.disposed=!0,this.unsubscribe()}},k=class{vaultId;noteId;ports;disposed=!1;parked=!1;park(e){this.parked=e,this.clearTimers()}ownWrites=new WeakSet;saveTimer;queued;interval;withdraw;unsubscribe;blur=()=>{this.flush()};visibility=()=>{document.visibilityState!==`visible`&&this.flush()};unload=()=>{if(!this.ports.dirty()||!this.ports.ready())return;let e=this.ports.payload();this.buffer(e),this.parked||d(this.vaultId,this.noteId,e)};constructor(e,t,n){this.vaultId=e,this.noteId=t,this.ports=n,this.unsubscribe=this.subscribe(),this.withdraw=b(e,()=>this.ports.flush?this.ports.flush():this.flush(),()=>this.ports.unsaved?.()??{noteId:this.noteId,reason:`its last write has not landed`}),this.interval=window.setInterval(()=>{this.flush()},1e4),window.addEventListener(`blur`,this.blur),window.addEventListener(`beforeunload`,this.unload),document.addEventListener(`visibilitychange`,this.visibility)}schedule(e=!1){this.clearTimers(),!this.disposed&&this.ports.ready()&&(this.ports.dirty()?(this.buffer(),(!this.parked||this.ports.pendingProperties?.())&&(e?this.send():this.saveTimer=window.setTimeout(()=>this.send(),1500))):u(this.vaultId,this.noteId))}revision(e){f(this.vaultId,this.noteId,e)}async flush(){return this.parked?this.parkedProperties():this.disposed||!await this.ports.settle()?!1:(this.enqueue(),m(this.vaultId,this.noteId))}async properties(e){let t={...this.ports.payload(),body:e.body,revision:e.revision,propertiesOnly:!0};return this.queued?.propertiesOnly&&this.queued.frontmatterSource===t.frontmatterSource||(this.ownWrites.add(t),this.queued=t,h(this.vaultId,this.noteId,t)),m(this.vaultId,this.noteId)}rename(e){this.clearTimers(),this.unsubscribe(),this.noteId=e,this.unsubscribe=this.subscribe()}dispose(){this.disposed=!0,this.withdraw(),this.clearTimers(),window.clearInterval(this.interval),this.unsubscribe(),window.removeEventListener(`blur`,this.blur),window.removeEventListener(`beforeunload`,this.unload),document.removeEventListener(`visibilitychange`,this.visibility)}subscribe(){return y(this.vaultId,this.noteId,(e,t,n)=>{this.ports.status(e),t&&(n===this.queued&&(this.queued=void 0),this.ports.saved(t,n&&this.ownWrites.has(n)?n:void 0))})}buffer(e=this.ports.payload()){!this.disposed&&this.ports.ready()&&v(this.vaultId,this.noteId,e)}send(){this.parked?this.parkedProperties():this.enqueue()}parkedProperties(){this.clearTimers();let e=this.disposed?void 0:this.ports.pendingProperties?.();return e?this.properties(e):Promise.resolve(!1)}enqueue(){if(this.clearTimers(),this.parked||!this.ports.ready()||!this.ports.dirty())return;let e=this.ports.payload();(this.queued?.body!==e.body||this.queued.frontmatterSource!==e.frontmatterSource)&&(this.queued=e,this.ownWrites.add(e),this.buffer(e),h(this.vaultId,this.noteId,e))}clearTimers(){this.saveTimer!==void 0&&window.clearTimeout(this.saveTimer),this.saveTimer=void 0}},A=class{ports;folderRule;serial=0;automatic=!1;declinedAt=0;constructor(e){this.ports=e}pending=()=>!!this.folderRule?.required()&&!this.ports.codec.state.safe;require(){this.automatic||!this.ports.edited()||!this.pending()||Date.now()-this.declinedAt<3e4||(this.automatic=!0,(async()=>{try{let e=await this.folderRule.key();e&&this.pending()&&await this.encrypt(e,!1)||(this.declinedAt=e?0:Date.now())}catch{this.declinedAt=Date.now()}finally{this.automatic=!1,this.ports.publish()}})())}async encrypt(e,t=!0){let{ports:n}=this,{codec:r}=n,i=++this.serial;if(t&&!await n.flush()||i!==this.serial)return!1;let a=await n.noteKeyWith(e);if(i!==this.serial)return!1;let o=r.stored();if(!await r.encrypt(a))return!1;let s=n.collaboration();if(s){try{if(await s.convert(r.stored()))return!0}catch(e){n.remoteError(e instanceof Error?e.message:`Encryption could not be committed.`)}return await n.restore(o),!1}return n.flush()}decrypt(){if(this.folderRule?.required())return;let{ports:e}=this,{codec:t}=e;++this.serial;let n=t.stored(),r=t.noteKey();t.decrypt();let i=t=>e.dropAfterDecrypt(r,t),a=e.collaboration();a?a.convert(t.stored()).then(t=>{if(!t)return e.restore(n);i(!0)}).catch(t=>(e.remoteError(t instanceof Error?t.message:`The conversion could not be committed.`),e.restore(n))):e.flush().then(i)}};function j({note:e,frontmatterSource:t,loading:n,codec:r,remoteError:i,collabPaused:a,bindingGeneration:o,noteKeyGeneration:s,queue:c,dirty:l}){return{note:e,body:r.body,frontmatterSource:t,loading:n,safe:r.safe,locked:r.locked,busy:r.busy,error:r.error,remoteError:i,collabPaused:a,bindingGeneration:o,noteKeyGeneration:s,saveStatus:c.status===`error`||r.error?`buffered`:c.status===`saving`||r.busy||l?`saving`:`idle`,saveError:c.error??r.error,saveFailures:c.failures??0,saveRetryable:c.retryable}}var M=new Map,N=0,P=(e,t)=>`${e}\u0000${t}`,F=class{vaultId;noteId;listeners=new Set;surfaces=new Map;codec=new T(()=>this.codecChanged());persistence;snapshot;note;frontmatter=``;saved={body:``,frontmatterSource:``};written={body:``,revision:``};loading=!0;initializing=!1;loadPromise;queue={status:`idle`};binding;collaboration;keyHolder=new D({codec:this.codec,disposed:()=>this.disposed,publish:()=>this.publish(),unlock:e=>this.unlock(e),lock:()=>this.lock(),flush:()=>this.flush()});conversion=new A({codec:this.codec,collaboration:()=>this.collaboration,flush:()=>this.flush(),noteKeyWith:e=>this.noteKeyWith(e),dropAfterDecrypt:(e,t)=>this.keyHolder.dropAfterDecrypt(e,t),restore:e=>this.collabStorage(e),remoteError:e=>this.collabRemoteError(e),edited:()=>!this.disposed&&!this.loading&&this.dirty(),publish:()=>this.publish()});liveClosed=!1;paused=!1;bindingGeneration=0;reloader;remoteError;disposed=!1;references=0;key=`note-document-${++N}`;formerIds=new Set;get folderRule(){return this.conversion.folderRule}set folderRule(e){this.conversion.folderRule=e}get keys(){return this.keyHolder.keys}set keys(e){this.keyHolder.keys=e}noteKeys=c;constructor(e,t,n){this.vaultId=e,this.noteId=t,this.snapshot=this.readSnapshot(),this.persistence=new k(e,t,{payload:()=>({frontmatterSource:this.frontmatter,body:this.codec.stored(),revision:this.note?.revision??``}),ready:()=>!!this.note&&!this.loading&&!this.codec.state.busy&&!this.codec.state.error&&!this.folderEncryptionPending(),dirty:()=>this.dirty(),settle:()=>this.codec.settle(),saved:(e,t)=>this.didSave(e,t),status:e=>{this.queue=e,this.publish()},flush:()=>this.flush(),pendingProperties:()=>this.pendingProperties(),unsaved:()=>({noteId:this.noteId,reason:this.queue.error??this.codec.state.error??(this.folderEncryptionPending()?`it is in an encrypted folder and waits for the vault key`:`its last write has not landed`)})}),this.reloader=new O(e,{id:()=>this.noteId,revision:()=>this.note?.revision,idle:()=>this.idle(),loading:()=>this.loading,adopt:e=>this.adopt(e),error:e=>{this.remoteError=e,this.publish()}}),n!==void 0&&this.codec.open(n)}getSnapshot=()=>this.snapshot;isDisposed=()=>this.disposed;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));collabKey=()=>this.keyHolder.current();adoptMaster(e){return this.keyHolder.adoptMaster(e)}noteKeyWith(e){return this.keyHolder.noteKeyWith(e)}dropKeyIfPlain(){return this.keyHolder.dropIfPlain()}collabBase=()=>this.saved.body;async collabStorage(e){this.initializing=!0,await this.codec.open(e,this.keyHolder.collabResolver()),this.initializing=!1,this.publish()}async collabOutside(e){this.codec.change(e);try{let t=await i(this.noteId,this.vaultId);await r(this.noteId,{vault:this.vaultId,frontmatterSource:this.frontmatter,body:e,revision:t.revision})}catch(e){this.collabRemoteError(e instanceof Error?e.message:`The source edit could not be saved; the local draft is retained.`)}}collabBody(e){this.codec.change(e),this.conversion.require()}collabPause(e){this.paused=e,this.publish()}collabRemoteError(e){this.remoteError=e,this.publish()}async collabRenamed(e){this.reloader.markRenaming(e),this.rename(e);let t=await i(e,this.vaultId),n=this.frontmatter!==this.saved.frontmatterSource;this.note=t,this.written={body:t.body,revision:t.revision},this.saved.frontmatterSource=t.frontmatterSource,n||(this.frontmatter=t.frontmatterSource),this.persistence.revision(t.revision),this.publish(),n&&this.persistence.schedule()}collabStatus(e,t,n){let r={status:t?`error`:e?`saving`:`idle`,failures:t,error:n},{queue:i}=this;(i.status!==r.status||i.failures!==r.failures||i.error!==r.error||i.retryable!==void 0)&&(this.queue=r,this.publish())}collabDurable(e,t,n=e){this.note&&(this.note={...this.note,body:e,revision:t},this.saved={...this.saved,body:e},n!==null&&(this.written={body:n,revision:t}),this.persistence.revision(t),this.codec.durable(e).then(()=>{this.dirty()||u(this.vaultId,this.noteId)}),this.dirty()||u(this.vaultId,this.noteId),this.publish(),this.codec.state.locked||_({vaultId:this.vaultId,noteId:this.noteId,revision:t,stored:n??e,key:this.collabKey()}))}collabClosed(){this.collaboration=void 0,this.liveClosed=!0,this.binding?.dispose(),this.binding=void 0,this.persistence.park(!0)}collabFallback(){this.collaboration=void 0,this.persistence.park(!1),this.persistence.schedule()}manageCollab(e){this.collaboration?.owner&&this.collaboration.owner!==e.owner&&this.collaboration.dispose(!1),this.collaboration=e,this.liveClosed=!1,this.persistence.park(!0)}storedBody=()=>this.codec.stored();settledBody=async()=>(await this.codec.settle(),this.codec.stored());attachSurface(e,t){return this.surfaces.set(e,t),()=>this.surfaces.delete(e)}idle(){return!this.loading&&!this.dirty()&&this.queue.status===`idle`}dirty(){return this.codec.state.busy||S(this.codec.stored())!==S(this.saved.body)||this.frontmatter!==this.saved.frontmatterSource}load(e,t){return this.loadPromise?!this.loading&&!this.dirty()&&t?.id===this.noteId&&t.revision!==this.note?.revision?this.adopt(structuredClone(t),e):this.loadPromise:(this.loadPromise=this.initialize(e,t?.id===this.noteId?t:void 0).catch(e=>{throw this.loadPromise=void 0,this.loading=!1,this.publish(),e}),this.loadPromise)}async initialize(e,t){let n=t?structuredClone(t):await i(this.noteId,this.vaultId);if(this.disposed)return;this.initializing=!0;let r=l(this.vaultId,this.noteId),a=!!(t&&r&&r.revision!==n.revision&&S(n.body).startsWith(S(r.body))),o=!(!r||a||r.frontmatterSource===n.frontmatterSource&&S(r.body)===S(n.body));this.note=n,this.written={body:n.body,revision:n.revision},this.saved={body:n.body,frontmatterSource:n.frontmatterSource},this.frontmatter=o?r.frontmatterSource:n.frontmatterSource,await this.codec.open(o?r.body:n.body,this.keyHolder.resolver(e)),this.loading=!1,this.initializing=!1,this.persistence.revision(n.revision),r&&!o&&u(this.vaultId,this.noteId),this.binding?.apply(this.codec.state.body,!1),this.announceHeld(),this.publish(),o&&!this.codec.state.locked&&this.persistence.schedule(!0),e&&this.adoptMaster(e)}setBody=e=>{this.codec.state.locked||e===this.codec.state.body||(!this.collaboration&&this.liveClosed&&(this.liveClosed=!1,this.persistence.park(!1)),this.collaboration?this.collaboration.apply(e,!0):this.binding?this.binding.apply(e,!0):this.textChanged(e))};textChanged(e){this.codec.change(e),this.conversion.require()}bind(e){this.binding?.dispose(),this.binding=e,this.bindingGeneration++,queueMicrotask(()=>this.publish())}setFrontmatter(e,t=!1){this.frontmatter=e,this.publish(),this.conversion.require(),t?this.flush():this.persistence.schedule()}folderEncryptionPending=()=>this.conversion.pending();encrypt(e){return this.conversion.encrypt(e)}decrypt(){this.conversion.decrypt()}async unlock(e){await this.codec.unlock(t=>this.keys.resolve(e,t)),this.binding?.apply(this.codec.state.body,!1),this.announceHeld(),this.publish(),this.dirty()&&this.persistence.schedule(!0)}announceHeld(){this.note&&this.codec.state.safe&&!this.codec.state.locked&&!this.codec.state.busy&&!this.dirty()&&g({vaultId:this.vaultId,noteId:this.noteId,revision:this.note.revision,body:this.codec.state.body,safe:!0})}async lock(){this.collaboration&&await this.collaboration.flush().catch(()=>!1),this.keyHolder.forget(),await this.codec.lock()&&!this.collaboration&&this.binding?.apply(``,!1),this.publish()}flush=async()=>{if(!this.collaboration){let e=this.pendingProperties();return this.liveClosed?e?this.persistence.properties(e):!this.dirty():this.persistence.flush()}let e=await this.collaboration.flush().catch(()=>!1),t=this.pendingProperties();return(!t||await this.persistence.properties(t))&&e};pendingProperties(){return this.frontmatter===this.saved.frontmatterSource?void 0:this.written}async adopt(e,t){let n=e.id!==this.noteId;n&&this.rename(e.id),e.revision===this.note?.revision&&!this.loading?n&&(this.note=e,this.written={body:e.body,revision:e.revision},this.reloader.markRenaming(),this.publish()):(this.initializing=!0,this.note=e,this.written={body:e.body,revision:e.revision},this.saved={body:e.body,frontmatterSource:e.frontmatterSource},this.frontmatter=e.frontmatterSource,this.collaboration||await this.codec.open(e.body,this.keyHolder.resolver(t)??this.keyHolder.collabResolver()),this.initializing=!1,this.loading=!1,this.collaboration||(this.remoteError=void 0),this.reloader.markRenaming(),this.collaboration||(this.binding?.apply(this.codec.state.body,!1),this.announceHeld()),this.persistence.revision(e.revision),this.publish(),t&&this.adoptMaster(t))}knownAs(e){return this.noteId===e||this.formerIds.has(e)}rename(e){this.formerIds.add(this.noteId),M.delete(P(this.vaultId,this.noteId)),u(this.vaultId,this.noteId),this.noteId=e,M.set(P(this.vaultId,e),this),this.persistence.rename(e)}reload=()=>this.reloader.reload();markRenaming(e){this.reloader.markRenaming(e),this.collaboration?.renaming?.(!!e)}didSave(e,t){if(t===void 0){this.reloader.changed();return}this.reloader.saved(),this.note=e,this.written={body:e.body,revision:e.revision},this.saved={body:t.propertiesOnly&&this.collaboration?this.saved.body:e.body,frontmatterSource:e.frontmatterSource},!t.propertiesOnly&&!this.codec.state.safe&&this.codec.stored()===t.body&&S(e.body)!==S(t.body)&&(this.binding?this.binding.apply(e.body,!1):this.codec.change(e.body));let n=t.propertiesOnly?e.body:this.codec.state.busy?void 0:this.codec.stored();n!==void 0&&C({body:n,frontmatterSource:this.frontmatter},e,this.noteKeys)&&(this.frontmatter=e.frontmatterSource),this.publish(),this.dirty()&&this.persistence.schedule(),!this.codec.state.locked&&!this.codec.state.busy&&S(this.codec.stored())===S(e.body)&&g({vaultId:this.vaultId,noteId:this.noteId,revision:e.revision,body:this.codec.state.body,safe:this.codec.state.safe})}codecChanged(){this.publish(),!this.initializing&&!this.loading&&this.persistence.schedule()}readSnapshot(){return j({note:this.note,frontmatterSource:this.frontmatter,loading:this.loading,codec:this.codec.state,remoteError:this.remoteError,collabPaused:this.paused,bindingGeneration:this.bindingGeneration,noteKeyGeneration:this.keyHolder.generation,queue:this.queue,dirty:this.dirty()})}publish(){if(!this.disposed){this.snapshot=this.readSnapshot();for(let e of this.listeners)e();this.reloader?.check()}}async dispose(){this.disposed||((this.note||this.codec.state.busy)&&await this.flush(),this.references||(await this.collaboration?.dispose(),this.collaboration=void 0,this.references||(this.discard(),M.get(P(this.vaultId,this.noteId))===this&&M.delete(P(this.vaultId,this.noteId)))))}discard(){this.disposed=!0,this.collaboration?.dispose(!1),this.collaboration=void 0,this.keyHolder.forget(),this.reloader.dispose(),this.persistence.dispose(),this.binding?.dispose(),this.binding=void 0,this.codec.clear(),this.listeners.clear(),this.surfaces.clear(),this.note=void 0,this.frontmatter=``,this.saved={body:``,frontmatterSource:``},this.snapshot=this.readSnapshot()}};function I(e,t,n){let r=P(e,t),i=M.get(r);i||(i=new F(e,t,n),M.set(r,i)),i.references+=1;let a=!1;return{document:i,release:()=>{a||(a=!0,--i.references,i.references||queueMicrotask(()=>{i.references||i.dispose()}))}}}export{C as n,S as r,I as t};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/note-outline-BFidIp-8.js","assets/rolldown-runtime-COiEfhsA.js","assets/react-lcK3LgGH.js","assets/react-B3NTyEzE.js","assets/ArrowUp.es-DflnZKsA.js","assets/icons-CxH3_W-q.js","assets/ArrowDown.es-COHGTGu_.js","assets/ArrowLeft.es-Dvz_4AVp.js","assets/ArrowClockwise.es-DWqWLk15.js","assets/ArrowSquareOut.es-ssfQ7LE-.js","assets/index-BVDhmwI8.js","assets/state-9kAy-W2i.js","assets/logic-DtHJ5GlU.js","assets/interaction-BeNMN0Kn.js","assets/motion-DVTefdmR.js","assets/index-DjUUY3gd.css","assets/note-documents-CcJDTkta.js","assets/note-values-6D6wWXPg.js","assets/browser-DkgCZo02.js","assets/shared-note-text-DFBEyL8Z.js","assets/note-body-focus-BKKGEgBj.js","assets/note-collab-provider-B9DpnE58.js","assets/yjs-DhdecF1t.js","assets/codemirror-BqrpJAnL.js","assets/note-collab-transport-BHZ891IL.js","assets/drawing-note-BytzAih9.js","assets/page-note-nmiinGCs.js","assets/dist-CrehgOjo.js","assets/note-outline-CAyXKuOh.css","assets/note-source-editor-BXPR_-41.js","assets/code-editor-CxLqzVwa.js","assets/file-language-DjeubQk3.js","assets/dist-B58c6eJE.js","assets/code-editor-wFimHbMT.css","assets/schema-B0Kz-heR.js","assets/dist-CvpNNPIS.js","assets/language-service-extension-D0pqdeuF.js"])))=>i.map(i=>d[i]);
2
+ import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{t}from"./use-screen-source-CF-48NnC.js";import{m as n,p as r,t as i}from"./react-B3NTyEzE.js";import{Bt as a,Cr as o,G as s,Gn as c,Gt as l,Hn as u,In as d,Jn as f,Kn as p,Rt as m,S as h,Sr as g,Tr as _,Vn as v,Vt as y,Y as b,_r as x,at as S,fr as C,ft as w,gr as T,gt as E,ir as D,it as O,ot as k,pt as A,rr as j,sr as M,ut as N,vr as P}from"./index-BVDhmwI8.js";import{$s as F,Bi as I,Bs as L,Dl as R,Hs as z,Ls as B,Ma as ee,Ol as V,Rs as H,Ta as U,Us as W,Ws as te,Yn as ne,Zs as re,ad as ie,ea as ae,i as oe,md as se,oa as ce,od as le,rc as ue,rd as de,rl as fe,td as G,zt as pe}from"./logic-DtHJ5GlU.js";import{i as me,n as he,t as ge}from"./note-frontmatter-summary-iubFPHA_.js";import{n as _e,t as ve}from"./use-note-export-flow-Dm7yhW5s.js";import{t as ye}from"./LockSimple.es-DiQO6y_F.js";import{n as be}from"./page-note-nmiinGCs.js";import{i as xe,r as K}from"./drawing-note-BytzAih9.js";import{f as Se,l as q,s as Ce}from"./note-values-6D6wWXPg.js";import{n as we,r as Te,t as Ee}from"./mobile-note-content-editor-C6TUyA4F.js";import{a as De,i as Oe,n as ke,o as Ae,s as je,t as Me}from"./page-content-B3fNjwr-.js";import{d as Ne,k as Pe}from"./state-9kAy-W2i.js";import{t as Fe}from"./note-link-list-CI9-GM_3.js";import{N as Ie}from"./icons-CxH3_W-q.js";import{n as Le}from"./markdown-message-BIo2pHhE.js";import{n as Re,t as ze}from"./browser-DkgCZo02.js";import{c as Be,d as Ve,f as He,g as Ue,h as We,i as Ge,l as J,m as Ke,n as qe,p as Je,r as Ye,s as Xe,t as Ze}from"./note-type-grid-CRCfpYZy.js";import{t as Qe}from"./safe-note-locked-BDCeVwpK.js";import{r as $e,t as et}from"./note-documents-CcJDTkta.js";import{i as tt,n as nt,s as rt}from"./note-body-focus-BKKGEgBj.js";import{n as it,r as at,t as ot}from"./use-note-editor-session-R1wm0xDf.js";import{a as st,i as ct,n as lt,o as ut,r as dt,t as ft}from"./note-path-breadcrumb-HmtWyYZP.js";import{n as pt,r as mt,t as ht}from"./use-safe-folder-moves-DjQUnMvz.js";import{t as gt}from"./use-note-delete-fFNH1Glk.js";import{t as _t}from"./folder-picker-dialog-D_VCqm_i.js";import{i as vt}from"./use-directory-listing-Cn9t21ra.js";import{i as yt}from"./note-id-BmuLCV_i.js";import{r as bt}from"./safe-folders-DmvM6dtV.js";var Y=e(n(),1);function xt(e,t){(0,Y.useEffect)(()=>{let n=e.current?.closest(`.note-editor-panel`);if(n&&t)return E(n,t)},[e,t])}function St({vaultId:e,noteId:t,title:n,shareable:r}){let i=A(),a=i.enabled&&i.vaultId===e&&!!t&&r,o=w(e,a),{openNote:s}=i,c=(0,Y.useCallback)(()=>{t&&s(t,n)},[t,s,n]);return{onShare:a?c:void 0,activeLinks:a&&t?ee(o.data??[],t):0}}function Ct(e,t){(0,Y.useEffect)(()=>{let n=e.current?.closest(`.note-editor-panel`);if(n&&t)return U(n,t)},[e,t])}var X=i();function wt({locked:e}){let t=e?`Safe note: encrypted, locked on this device`:`Safe note: encrypted`;return(0,X.jsx)(`span`,{className:`safe-note-indicator`,role:`img`,"aria-label":t,title:t,children:(0,X.jsx)(ye,{"aria-hidden":`true`})})}function Tt({noteTitle:e,types:t,currentType:n,busy:r=!1,onChoose:i,onCancel:a}){return(0,X.jsxs)(c,{title:`Type of “${e}”`,description:`Choose what kind of note this is.`,size:`medium`,scrollableBody:!0,busy:r,onCancel:a,actions:(0,X.jsx)(p,{onClick:a,children:`Cancel`}),children:[(0,X.jsx)(Ze,{types:t,selectedId:n,onChoose:i}),(0,X.jsx)(Ge,{})]})}function Et({noteTitle:e,typeName:t,folder:n,busy:r=!1,onMove:i,onKeep:a,onCancel:o}){return(0,X.jsx)(c,{title:`Move “${e}” to ${n}?`,size:`small`,busy:r,onCancel:o,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(p,{onClick:o,children:`Cancel`}),(0,X.jsx)(f,{}),(0,X.jsx)(p,{onClick:a,disabled:r,children:`Don’t move note`}),(0,X.jsx)(p,{primary:!0,"data-popup-autofocus":`true`,onClick:i,disabled:r,children:r?`Moving…`:`Move note`})]}),children:(0,X.jsxs)(M,{as:`p`,tone:`muted`,children:[t,` notes are kept in `,n,`. Links to the note follow it.`]})})}async function Dt(e,t){try{return Ye((await ne(t,e)).definition.folder)}catch{return}}function Ot(e){let[t,n]=(0,Y.useState)(),r=(0,Y.useRef)(e);r.current=e;let i=(0,Y.useCallback)(()=>n({step:`choose`,busy:!1}),[]),a=(0,Y.useCallback)(()=>n(void 0),[]),o=(0,Y.useCallback)(async e=>{let{vaultId:t,noteId:i,types:o,currentType:s,onChangeType:c,onMoveToFolder:l}=r.current;if(e===s){a();return}if(!e||!l){c(e),a();return}n({step:`choose`,busy:!0});let u=await Dt(t,e);!u||qe(i,u)?(c(e),a()):n({step:`move`,typeId:e,typeName:o.find(t=>t.id===e)?.name??e,folder:u,busy:!1})},[a]),s=(0,Y.useCallback)(e=>{r.current.onChangeType(e),a()},[a]),c=(0,Y.useCallback)(async e=>{r.current.onChangeType(e.typeId),n({...e,busy:!0}),await r.current.onMoveToFolder?.(e.folder),a()},[a]),{noteTitle:l,types:u,currentType:d}=e;return{open:i,nodes:t?.step===`choose`?(0,X.jsx)(Tt,{noteTitle:l,types:u,currentType:d,busy:t.busy,onChoose:e=>void o(e),onCancel:a}):t?.step===`move`?(0,X.jsx)(Et,{noteTitle:l,typeName:t.typeName,folder:t.folder,busy:t.busy,onMove:()=>void c(t),onKeep:()=>s(t.typeId),onCancel:a}):null}}var kt=e(r(),1);function At({mode:e,templates:t=[],onApplyTemplate:n,onModeChange:r,onOpenInFileEditor:i,onShare:a,onExport:c,onRename:l,onMove:u,onEncrypt:d,onDecrypt:f,noteId:p,deleteDisabled:m,onDelete:h}){let[_,v]=(0,Y.useState)(!1),y=s(),b=e=>{v(!1),r(e)};return(0,X.jsx)(`div`,{className:`note-actions-menu`,children:(0,X.jsxs)(g,{open:_,onOpenChange:v,label:`Note actions menu`,trigger:(0,X.jsx)(P,{variant:`ghost`,size:`compact`,className:`note-actions-trigger`,"aria-label":`Note actions`,title:`Note actions`,children:`⋮`}),children:[(0,X.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===`visual`,onClick:()=>b(`visual`),children:[(0,X.jsx)(`span`,{children:`Visual`}),e===`visual`&&(0,X.jsx)(`span`,{"aria-hidden":`true`,children:`✓`})]}),(0,X.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===`source`,onClick:()=>b(`source`),children:[(0,X.jsx)(`span`,{children:`Source`}),e===`source`&&(0,X.jsx)(`span`,{"aria-hidden":`true`,children:`✓`})]}),i&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(D,{}),(0,X.jsx)(o,{onClick:()=>{v(!1),i()},children:`Open in File Editor`})]}),!!t.length&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(D,{}),(0,X.jsx)(j,{children:`Add template`}),(0,X.jsx)(me,{templates:t,onSelect:e=>{let r=t.find(({id:t})=>t===e);r&&n?.(r),v(!1)}})]}),(a||c)&&(0,X.jsx)(D,{}),a&&(0,X.jsx)(o,{onClick:()=>{v(!1),a()},children:`Share…`}),c&&(0,X.jsx)(_e,{onSelect:e=>{v(!1),c(e)}}),(d||f)&&(0,X.jsx)(D,{}),d&&(0,X.jsx)(o,{onClick:()=>{v(!1),d()},children:`Encrypt note…`}),f&&(0,X.jsx)(o,{onClick:()=>{v(!1),f()},children:`Decrypt note…`}),(l||u)&&(0,X.jsx)(D,{}),l&&(0,X.jsx)(o,{onClick:()=>{v(!1),l()},children:`Rename…`}),u&&(0,X.jsx)(o,{onClick:()=>{v(!1),u()},children:`Move to…`}),p&&y?.(p,()=>v(!1)),(0,X.jsx)(D,{}),(0,X.jsx)(o,{className:`danger`,disabled:m,onClick:()=>{v(!1),h()},children:`Delete note`})]})})}function jt({session:e,share:t,onExport:n,relocation:r,safety:i,onDelete:a,onOpenInFileEditor:o,beforeMenu:s}){let{state:c,commands:l}=e;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Mt,{state:c}),c.safe&&(0,X.jsx)(wt,{locked:c.locked}),t?.onShare&&(0,X.jsx)(N,{count:t.activeLinks,onOpen:t.onShare}),s,(0,X.jsx)(At,{mode:c.mode,templates:c.definition?.templates??[],onApplyTemplate:e=>void l.applyTemplate(e.id),onModeChange:l.changeMode,onOpenInFileEditor:o,onShare:t?.onShare,onExport:n,onRename:r?.onRename,onMove:r?.onMove,onEncrypt:i?.encrypt,onDecrypt:i?.decrypt,noteId:c.note?.revision?c.note.id:void 0,deleteDisabled:!c.note?.revision,onDelete:a})]})}function Mt({state:e}){return e.loading||e.saveFailures<3?null:(0,X.jsx)(M,{className:`note-save-status`,size:`caption`,tone:`danger`,"aria-live":`polite`,title:e.saveError,children:`Not saved to disk — retrying`})}function Nt(e,t,n){let r=t?.properties.map(e=>e.name)??[],i=new Set([n.typeKey,n.titleKey,...r]);return 1+r.length+Object.keys(e).filter(e=>!i.has(e)).length}function Pt(e){return[...(e?.panels??[]).map(e=>({value:`panel:${e.id}`,label:e.name})),{value:`panel:backlinks`,label:`Backlinks`}]}var Ft=[`content`,`properties`,`panel:backlinks`];function It(e,t,n){return e?e===`outline`?t.includes(`outline`)?`outline`:`content`:Ft.includes(e)||n&&t.includes(e)?e:`content`:`content`}function Lt(e,t){return[{value:`content`,label:`Content`},{value:`properties`,label:`Properties`},...Pt(e),...!be(t)&&!K(t)?[{value:`outline`,label:`Outline`}]:[]]}var Rt=/^[0-9a-f]{16}$/,zt=H({scope:`vault`,name:`readerProperties`,fallback:Object.freeze({}),parse:e=>{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t))return Object.fromEntries(Object.entries(t).filter(([e,t])=>Rt.test(e)&&Number.isFinite(t)))}});function Bt(e,t,{storage:n}={}){return B(t)in L(zt,{vaultId:e,storage:n})}function Vt(e,t,n,r,i=200){let a=B(t),{[a]:o,...s}=e;if(!n)return s;let c=Object.entries({...s,[a]:r});return c.length<=i?Object.fromEntries(c):Object.fromEntries(c.sort(([,e],[,t])=>t-e).slice(0,i))}function Ht(e,t,n,{storage:r,now:i=Date.now()}={}){let a=L(zt,{vaultId:e,storage:r});te(zt,Vt(a,t,n,i),{vaultId:e,storage:r})}function Ut(e,t){let n=`${e}\n${t}`,[r,i]=(0,Y.useState)(()=>({key:n,open:Bt(e,t)})),a=r.key===n?r.open:Bt(e,t);return[a,(0,Y.useCallback)(()=>{Ht(e,t,!a),i({key:n,open:!a})},[n,t,a,e])]}function Wt({vaultId:e,noteId:t,frontmatterSource:n,noteKeys:r,definition:i,types:a,allNotes:o,resolveNoteReference:s,onOpenNote:c}){let[l,u]=Ut(e,t),d=(0,Y.useMemo)(()=>{let e={};try{e=Ce(n)}catch{}let t=De(s,e=>o.find(t=>t.id===e)?.label);return Ae({frontmatter:e,noteKeys:r,definition:i,types:a,describeNote:t})},[o,i,n,r,s,a]);return d.length<=1?null:(0,X.jsx)(we,{className:`note-properties-reader`,open:l,onToggle:u,count:d.length,children:(0,X.jsx)(je,{className:`note-properties-reader-list`,entries:d,fileScope:{vaultId:e,noteId:t},onOpenNote:c})})}function Gt(e,t,n,r,i=fetch){return ie(le(e,`entity/panel`,{id:t,panel:n}),i,{headers:{Accept:`application/json`},signal:r})}function Kt({vaultId:e,noteId:t,panelId:n,onOpenNote:r,density:i=`full`}){let a=Ne({queryKey:[`note-panel`,e,t,n],queryFn:({signal:r})=>Gt(e,t,n,r)});if(a.isLoading)return(0,X.jsx)(l,{status:`loading`,density:i,children:`Loading related notes…`});if(a.isError)return(0,X.jsx)(l,{status:`error`,density:i,action:(0,X.jsx)(x,{size:`small`,onClick:()=>void a.refetch(),children:`Retry`}),children:a.error instanceof Error?a.error.message:`Could not load related notes.`});let o=a.data;return o?.items.length?(0,X.jsxs)(`div`,{className:`note-related-panel`,children:[o.columns?.length?(0,X.jsx)(Oe,{label:`${o.name} notes`,columns:o.columns,rows:o.items,onOpenNote:r}):(0,X.jsx)(qt,{result:o,onOpenNote:r}),o.truncated&&(0,X.jsx)(M,{as:`p`,className:`note-related-truncated`,children:`More matching notes were omitted by this panel’s limit.`})]}):(0,X.jsx)(l,{status:`empty`,density:i,children:`No related notes.`})}function qt({result:e,onOpenNote:t}){return(0,X.jsx)(Fe,{label:`${e.name} notes`,items:e.items.map(({note:e})=>({id:e.id,label:e.label,type:e.type})),onOpen:t})}var Jt=H({scope:`global`,name:`noteSidePanelWidth`,fallback:340,parse:Z,serialize:String}),Yt=H({scope:`global`,name:`graphNotePanelWidth`,fallback:520,parse:Z,serialize:String}),Xt=H({scope:`global`,name:`graphNoteSourceSplit`,fallback:230,parse:Z,serialize:String}),Zt=H({scope:`global`,name:`noteSourceSplit`,fallback:230,parse:Z,serialize:String});function Qt(e){return e===`floating`?Xt:Zt}function Z(e){let t=Number(e);return Number.isFinite(t)&&t>0?t:void 0}var $t=260,en=640;function tn({sections:e,expanded:t,onToggle:n,onHide:r}){let[i,a]=W(Jt,{min:$t,max:en}),o=(0,Y.useRef)(null),s=(0,Y.useId)();return(0,X.jsxs)(`aside`,{ref:o,className:`note-side-panel`,"aria-label":`Side panel`,style:{width:i},children:[(0,X.jsx)(y,{className:`note-side-panel-resize`,label:`Resize side panel`,value:i,min:$t,max:en,direction:-1,onPreview:e=>{o.current&&(o.current.style.width=`${e}px`)},onChange:a}),(0,X.jsx)(`div`,{className:`note-side-panel-sections`,children:e.map((e,i)=>{let a=t.includes(e.id),o=`${s}-${e.id}-header`,c=`${s}-${e.id}-body`;return(0,X.jsxs)(`section`,{className:`note-side-section${a?` open`:``}`,"aria-labelledby":o,children:[(0,X.jsxs)(`div`,{className:`note-side-section-heading`,children:[(0,X.jsxs)(x,{variant:`ghost`,className:`note-side-section-header`,id:o,"aria-expanded":a,"aria-controls":a?c:void 0,onClick:()=>n(e.id),children:[(0,X.jsx)(Ie,{"aria-hidden":`true`,weight:`bold`,className:`note-side-section-caret`}),(0,X.jsx)(`span`,{className:`note-side-section-title`,children:e.title}),e.count!==void 0&&(0,X.jsx)(`span`,{className:`note-side-section-count`,"aria-label":`${e.count} ${e.count===1?`item`:`items`}`,children:e.count})]}),i===0&&(0,X.jsx)(P,{variant:`ghost`,size:`compact`,className:`note-side-panel-hide`,"aria-label":`Hide side panel`,title:`Hide side panel`,onClick:r,children:(0,X.jsx)(Le,{"aria-hidden":`true`,mirrored:!0})})]}),a&&(0,X.jsx)(`div`,{className:`note-side-section-body`,id:c,children:e.render()})]},e.id)})})]})}function nn({main:e,side:t}){return(0,X.jsxs)(`div`,{className:`note-split-layout`,children:[(0,X.jsx)(`div`,{className:`note-split-main`,children:e}),t]})}function rn({open:e,onToggle:t}){let n=e?`Hide side panel`:`Show side panel`;return(0,X.jsx)(P,{variant:`ghost`,size:`compact`,className:`note-side-panel-toggle`,"aria-label":n,"aria-pressed":e,title:n,onClick:t,children:(0,X.jsx)(Le,{"aria-hidden":`true`,mirrored:!0,weight:e?`fill`:`regular`})})}function an(e,t){return ke(e,t)??Me(e,t)}function on(e,t){let{value:n,details:r={}}=e;if(e.code===`cardinality_mismatch`)return Array.isArray(n)?`Takes one ${Se(n)?`link`:`value`}, but this note has ${n.length}.`:`Takes a list, but this note has one value.`;if(e.code===`link_type_mismatch`&&typeof r.targetId==`string`&&typeof r.actualType==`string`){let e=Array.isArray(r.expectedTypes)?r.expectedTypes.map(e=>sn(e,t)):[],n=sn(r.actualType,t);return`Links to ${e.join(` or `)} notes, but ${cn(r.targetId)} is ${ln(n)} ${n} note.`}return e.code===`invalid_property_value`&&typeof r.type==`string`?`Takes ${ln(r.type)} ${r.type}, but this note has “${un(r.value??n)}”.`:e.code===`invalid_wikilink`?`Takes links, but this note has “${un(r.value??n)}”.`:e.message}function sn(e,t){return t.find(t=>t.id===e)?.name??String(e)}function cn(e){return e.replace(/^.*\//,``).replace(/\.md$/i,``)}function ln(e){return/^[aeiou]/i.test(e)?`an`:`a`}function un(e){return typeof e==`string`?e:JSON.stringify(e)}var dn=400,fn=[];function pn(e,t,n,r){let i=mn(n,dn),a=r&&!!e&&!!t,o=Ne({queryKey:[`note-property-issues`,e,t,i],queryFn:()=>re(t,{vault:e,frontmatterSource:i}),enabled:a,staleTime:0,gcTime:3e4,retry:!1,refetchOnWindowFocus:!1,placeholderData:Pe},R),s=a?o.data??fn:fn;return(0,Y.useMemo)(()=>{let e=new Map;for(let t of s)e.set(t.field,[...e.get(t.field)??[],t]);return e},[s])}function mn(e,t){let[n,r]=(0,Y.useState)(e);return(0,Y.useEffect)(()=>{let n=window.setTimeout(()=>r(e),t);return()=>window.clearTimeout(n)},[e,t]),n}function hn({vaultId:e,noteKeys:t=G,definition:n,types:r,noteId:i,frontmatterSource:a,body:o,allNotes:s,onOpenNote:c,resolveNoteReference:u,onFrontmatterChange:d,onBodyChange:f,error:p,focusOnMount:m=!0,focusAtEnd:h=!1,initialSection:g=`content`,section:_,onSectionChange:v,relatedPanels:y=[],renderRelatedPanel:S,content:w,editorKey:E,onMoveToFolder:D,only:O}){let[k,A]=(0,Y.useState)(g);(0,Y.useEffect)(()=>A(g),[g,i]);let j=_??k,M=v??A,N={};try{N=Ce(a)}catch{}let F=new Set([t.typeKey,t.titleKey,...n?.properties.map(e=>e.name)??[]]),I=Object.entries(N).filter(([e])=>!F.has(e)),L=(e,t)=>{let r=n?.properties.some(t=>t.name===e&&t.type!==`string`)&&(t===``||t==null||Array.isArray(t)&&!t.length),i={...N};r?delete i[e]:i[e]=t,d(q(i))},R=r.some(e=>e.id===N[t.typeKey])?String(N[t.typeKey]):``,z=u??(e=>s.some(t=>t.id===e.trim())?e.trim():void 0),B=e=>{let n={...N};e?n[t.typeKey]=e:delete n[t.typeKey],d(q(n))},ee=Nt(N,n,t),V=pn(e,i,a,!!n&&(O?O===`properties`:j===`properties`)),H=new Map([...V].map(([e,t])=>[e,t.map(e=>on(e,r))])),U=(0,X.jsx)(`section`,{className:`note-tab-panel note-content-tab`,"data-note-editor-content":`true`,children:w??(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(l,{status:`loading`,children:`Loading Markdown editor…`}),children:(0,X.jsx)(pe,{vaultId:e,noteId:i,value:o,onChange:f,resolveNoteReference:z,noteReferences:s,onOpenNote:c,focusOnMount:m,focusAtEnd:h},E??i)})}),W=(0,X.jsxs)(`section`,{className:`note-tab-panel note-fields-tab note-properties-table`,children:[(0,X.jsx)(gn,{vaultId:e,noteId:i,noteTitle:_n(N[t.titleKey],i),types:r,value:R,onChange:B,onMoveToFolder:D}),(0,X.jsx)(Ue,{definition:n,noteId:i,vaultId:e,frontmatter:N,allNotes:s,resolveNoteReference:z,onOpenNote:c,onChange:L,issues:H}),!!I.length&&(0,X.jsx)(`div`,{className:`frontmatter-subheading`,children:`Custom frontmatter`}),I.map(([e,t])=>{let n=Se(t);return(0,X.jsxs)(`div`,{className:n?`custom-field custom-link-field`:`custom-field`,children:[(0,X.jsx)(C,{"aria-label":`Custom field name`,defaultValue:e,onBlur:t=>yn(N,e,t.target.value,d)}),n?(0,X.jsx)(We,{name:e,noteId:i,multiple:n.multiple,types:[`*`],value:t,allNotes:s,resolveNoteReference:z,onOpenNote:c,allowCreate:!1,showLabel:!1,onChange:t=>L(e,t)}):(0,X.jsx)(T,{"aria-label":`${e} value`,rows:1,value:Re(t).trim(),onChange:t=>L(e,vn(t.target.value))}),(0,X.jsx)(P,{variant:`ghost`,size:`compact`,className:`custom-field-remove`,"aria-label":`Remove ${e}`,onClick:()=>bn(N,e,d),children:`×`})]},e)}),(0,X.jsx)(x,{className:`secondary-action`,onClick:()=>xn(N,d),children:`+ Add field`})]});return O?(0,X.jsxs)(`div`,{className:`note-visual-form note-visual-section`,children:[p&&(0,X.jsx)(`div`,{className:`topology-inline-error note-visual-error`,children:p}),O===`content`?U:W]}):(0,X.jsxs)(`div`,{className:`note-visual-form`,children:[p&&(0,X.jsx)(`div`,{className:`topology-inline-error note-visual-error`,children:p}),(0,X.jsxs)(b,{label:`Note sections`,options:[{value:`content`,label:`Content`},{value:`properties`,label:(0,X.jsxs)(X.Fragment,{children:[`Properties `,(0,X.jsx)(`small`,{children:ee})]})},...y.map(e=>({value:`panel:${e.id}`,label:e.name}))],value:j,onChange:M,children:[j===`content`&&U,j===`properties`&&W,j.startsWith(`panel:`)&&S?.(j.slice(6))]})]})}function gn({vaultId:e,noteId:t,noteTitle:n,types:r,value:i,onChange:a,onMoveToFolder:o}){let s=Ot({vaultId:e,noteId:t,noteTitle:n,types:r,currentType:i,onChangeType:a,onMoveToFolder:o}),c=r.find(e=>e.id===i);return(0,X.jsxs)(`div`,{className:`relation-value type-value`,children:[(0,X.jsx)(`span`,{className:`relation-value-name`,children:`Type`}),(0,X.jsx)(x,{variant:`ghost`,className:c?`relation-value-summary`:`relation-value-summary empty`,"aria-label":`Choose Type`,"aria-haspopup":`dialog`,onClick:s.open,children:c?.name??`Unknown`}),(0,X.jsx)(P,{variant:`ghost`,size:`compact`,className:`relation-edit`,"aria-label":`Edit Type`,"aria-haspopup":`dialog`,title:`Edit Type`,onClick:s.open,children:`✎`}),s.nodes]})}function _n(e,t){return typeof e==`string`&&e.trim()?e.trim():(t.split(`/`).pop()??t).replace(/\.md$/i,``)}function vn(e){try{return ze(e)}catch{return e}}function yn(e,t,n,r){if(!n||n===t)return;let i={...e};i[n]=i[t],delete i[t],r(q(i))}function bn(e,t,n){let r={...e};delete r[t],n(q(r))}function xn(e,t){let n=1;for(;`field${n}`in e;)n+=1;t(q({...e,[`field${n}`]:``}))}function Sn(e,t,n){(0,Y.useEffect)(()=>{if(!t)return;let n=et(e,t),r=rt(n.document);return()=>{r(),n.release()}},[e,t]);let r=(0,Y.useRef)({vault:e,id:t,opened:n});(r.current.id!==t||r.current.vault!==e)&&(r.current={vault:e,id:t,opened:n}),n&&(r.current.opened=!0);let i=r.current.opened,[a,o]=(0,Y.useState)(),[s,c]=(0,Y.useState)();return(0,Y.useEffect)(()=>{if(!i||!t)return;let n=!1,r;return V(()=>import(`./note-outline-BFidIp-8.js`).then(i=>{if(n)return;let a=i.openOutlineDocument(e,t);r=a.release,o({Component:i.NoteOutline,document:a.document,history:a.history,memory:{collapsed:new Set}})}),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28])).catch(()=>{n||c({vault:e,id:t,message:`The outline could not be loaded. Reload the app to try again.`})}),()=>{n=!0,r?.()}},[e,t,i]),{loaded:a?.document.vaultId===e&&t&&a.document.knownAs(t)?a:void 0,error:s?.vault===e&&s.id===t?s.message:void 0}}var Cn=(0,Y.lazy)(async()=>({default:(await V(async()=>{let{NoteSourceEditor:e}=await import(`./note-source-editor-BXPR_-41.js`);return{NoteSourceEditor:e}},__vite__mapDeps([29,1,3,10,11,5,12,13,14,15,30,23,31,32,33,34,35,36,20]))).NoteSourceEditor}));function wn({session:e,props:t,sourceSplit:n,onSourceSplitChange:r,onNavigateNote:i,mobile:a,onEditContent:o,tab:s,onMoveToFolder:c,layout:u,onClose:d}){let{state:f,commands:p}=e,m=(0,Y.useRef)(null),h=Lt(f.definition,f.frontmatterSource),g=s?.tab??f.section,_=h.some(e=>e.value===g)?g:`content`,v=e=>{s?.setTab(e),p.setSection(e)},y=!a&&!!(u?.wide&&u.side.open),{loaded:S,error:C}=Sn(t.vaultId,f.note?.id,_===`outline`||!!(y&&u?.side.expanded.includes(`outline`))),w=tt(m,f.note?.id,f.body,()=>v(`content`));if((0,Y.useEffect)(()=>{g!==_&&v(_)},[g,_]),f.loading)return f.quiet?null:(0,X.jsx)(l,{status:`loading`,children:`Loading note…`});if(!f.note)return(0,X.jsx)(l,{status:`error`,heading:`Note not found`,action:d&&(0,X.jsx)(x,{size:`small`,onClick:d,children:`Close`}),children:f.error??`Note not found.`});if(f.locked&&!a)return(0,X.jsx)(Qe,{error:f.lockError,onUnlock:()=>void p.unlock()});let T=f.note.id,E=t.noteKeys??G,D=t.resolveNoteReference??(e=>f.allNotes.some(t=>t.id===e)?e:void 0),O={vaultId:t.vaultId,noteKeys:E,definition:f.definition,types:f.types,noteId:T,frontmatterSource:f.frontmatterSource,body:f.body,allNotes:f.allNotes,onOpenNote:i,resolveNoteReference:t.resolveNoteReference,onFrontmatterChange:p.setFrontmatterSource,onBodyChange:p.setBody,onMoveToFolder:c},k=(0,X.jsx)(hn,{...O,focusOnMount:!1,only:`properties`}),A=f.locked?(0,X.jsx)(Qe,{error:f.lockError,onUnlock:()=>void p.unlock()}):f.mode===`source`?(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(l,{status:`loading`,children:`Loading source editors…`}),children:(0,X.jsx)(Cn,{documentId:`${t.vaultId}/${t.entityId}`,history:S?.history,singlePane:a,noteKeys:E,type:he(f.frontmatterSource,f.types,E),frontmatter:f.frontmatterSource,body:f.body,split:n,onSplitChange:r,onFrontmatterChange:p.setFrontmatterSource,onBodyChange:p.setBody})}):a?an(e,{vaultId:t.vaultId,noteKeys:E,resolveNoteReference:t.resolveNoteReference,onNavigateNote:i,viewOnly:!0})??(0,X.jsx)(Te,{header:(0,X.jsx)(Wt,{vaultId:t.vaultId,noteId:T,frontmatterSource:f.frontmatterSource,noteKeys:E,definition:f.definition,types:f.types,allNotes:f.allNotes,resolveNoteReference:D,onOpenNote:i}),body:f.body,onEdit:o,vaultId:t.vaultId,noteId:T,resolveNoteReference:D,onOpenNote:i,resolveAppReference:t.resolveAppReference,onOpenAppReference:t.onOpenAppReference,onTaskToggle:p.toggleTask,headingPositions:!0}):(0,Y.createElement)(hn,{...O,key:f.documentKey??T,editorKey:f.documentKey,only:`content`,focusOnMount:t.focusOnMount??t.active,focusAtEnd:t.focusCaret===`end`,content:an(e,{vaultId:t.vaultId,noteKeys:E,resolveNoteReference:t.resolveNoteReference,onNavigateNote:i,viewOnly:!1,focusOnMount:t.focusOnMount??t.active})}),j=(e,n=!1)=>e===`content`?A:e===`properties`?k:e===`outline`?f.locked?(0,X.jsx)(Qe,{error:f.lockError,onUnlock:()=>void p.unlock()}):S?(0,X.jsx)(S.Component,{document:S.document,memory:S.memory,onGo:w}):(0,X.jsx)(l,{status:C?`error`:`loading`,children:C??`Loading outline…`}):(0,X.jsx)(Kt,{vaultId:t.vaultId,noteId:T,panelId:e.slice(6),onOpenNote:i,density:n?`inline`:void 0}),N=y&&u?(0,X.jsx)(tn,{expanded:u.side.expanded,onToggle:u.side.toggleSection,onHide:()=>u.side.setOpen(!1),sections:h.filter(e=>e.value!==`content`).map(e=>({id:e.value,title:e.label,count:e.value===`properties`?Nt(En(f.frontmatterSource),f.definition,E):void 0,render:()=>j(e.value,!0)}))}):null;return(0,X.jsx)(`div`,{ref:m,className:`note-editor-sections`,children:y?(0,X.jsx)(nn,{main:A,side:N}):(0,X.jsxs)(`div`,{className:a?`mobile-note-sections`:`note-visual-form`,children:[(0,X.jsx)(Tn,{error:f.error}),(0,X.jsx)(b,{label:`Note sections`,options:h.map(e=>e.value===`properties`&&!a?{...e,label:(0,X.jsxs)(X.Fragment,{children:[`Properties `,(0,X.jsx)(M,{as:`small`,size:`caption`,children:Nt(En(f.frontmatterSource),f.definition,E)})]})}:e),value:_,onChange:v,children:j(_)})]})})}function Tn({error:e}){return e?(0,X.jsx)(`div`,{className:`mobile-note-editor-error`,role:`alert`,children:e}):null}function En(e){try{return Ce(e)}catch{return{}}}var Dn=e=>typeof e==`string`&&([`content`,`properties`,`outline`].includes(e)||/^panel:.+/.test(e)),On=H({scope:`global`,name:`noteActiveTab`,fallback:void 0,parse:e=>Dn(e)?e:void 0}),kn=H({scope:`global`,name:`noteSideSections`,fallback:void 0,parse(e){let t=JSON.parse(e);if(t&&typeof t==`object`&&`open`in t&&typeof t.open==`boolean`&&`sections`in t&&Array.isArray(t.sections)&&t.sections.every(Dn))return{open:t.open,sections:[...new Set(t.sections)]}}});function An(e,t){let n=e?.sections??t.slice(0,1);return{open:e?.open??!0,expanded:t.filter(e=>n.includes(e))}}function jn(e,t,n){let r=[...e?.sections??t.slice(0,1)];return r.includes(n)?r.filter(e=>e!==n):[...r,n]}function Mn({history:e,offered:t}){let[n,r]=z(kn);(0,Y.useEffect)(()=>{n===void 0&&e?.side&&r(e.side)},[e?.side,n,r]);let i=e?.onSideChange,a=n??e?.side,{open:o,expanded:s}=(0,Y.useMemo)(()=>An(a,t),[t,a]),c=(0,Y.useCallback)(e=>{r(e),i?.(e)},[i,r]),l=(0,Y.useCallback)(e=>c({open:e,sections:a?.sections??t.slice(0,1)}),[t,a,c]),u=(0,Y.useCallback)(e=>c({open:!0,sections:jn(a,t,e)}),[t,a,c]);return(0,Y.useMemo)(()=>({open:o,expanded:s,setOpen:l,toggleSection:u}),[s,o,l,u])}function Nn(e,t=880){let[n,r]=(0,Y.useState)(!1);return(0,Y.useLayoutEffect)(()=>{let n=e.current;if(!n||typeof ResizeObserver>`u`)return;let i=e=>r(e>=t);i(n.getBoundingClientRect().width);let a=new ResizeObserver(e=>{let t=e[e.length-1];t&&i(t.contentRect.width)});return a.observe(n),()=>a.disconnect()},[t,e]),n}async function Pn(e,{vaultId:t,fromId:n,toId:r,unsaved:i=`The note is not saved yet, so it stays where it is.`}){if(!await e().commands.flush())throw Error(i);e().commands.markRenaming(r);try{let i=await ue(t,n,r);return h(t,n),oe(t,n,i.id),await e().commands.adopt(i),i}catch(t){throw e().commands.markRenaming(void 0),t}}function Fn(e,t,n){return t.note?.id!==n||t.frontmatterSource===e.frontmatterSource&&$e(t.body)===$e(e.body)}function In(e,{vaultId:t,entityId:n,onRenamed:r,onDiscarded:i}){let a=(0,Y.useRef)(e);a.current=e;let o=(0,Y.useRef)({onRenamed:r,onDiscarded:i});o.current={onRenamed:r,onDiscarded:i};let s=(0,Y.useRef)(void 0);(0,Y.useEffect)(()=>(Je(t,n),()=>{He(t,n);let e=a.current.state;queueMicrotask(()=>{if(Ve(t,n)||!J(t,n))return;let r=Ke(t,n);r.discardUntouched&&Fn(r,e,n)&&F(n,{vault:t,revision:e.note?.id===n?e.note.revision:r.revision,force:!1}).then(async()=>{await R.invalidateQueries({queryKey:[`note-panel`,t]}),o.current.onDiscarded?.()}).catch(()=>void 0)})}),[n,t]);let c=(0,Y.useCallback)(async e=>{let{state:n,commands:r}=a.current;r.setTitle(e);let i=n.note?.id;if(!i||!J(t,i)||!o.current.onRenamed)return;Ke(t,i);let c=Be(i,e,new Set(n.allNotes.map(e=>e.id)));c&&(await Pn(()=>a.current,{vaultId:t,fromId:i,toId:c,unsaved:`The title is not saved yet, so the file keeps its name.`}),s.current=c,o.current.onRenamed?.(i,c))},[t]),l=(0,Y.useMemo)(()=>({...e,commands:{...e.commands,setTitle:c}}),[e,c]),u=J(t,n);return{session:l,fresh:!!u||s.current===n,titleFirst:!(!u||u.titled)}}var Ln=1e3;function Rn({vaultId:e,requestedId:t,noteKeys:n,shows:r}){let i=O(),a=(0,Y.useRef)(i);a.current=i;let o=(0,Y.useRef)(r);o.current=r;let s=(0,Y.useRef)(n);s.current=n;let[c,l]=(0,Y.useState)(()=>({shownId:t,display:`blank`})),u=(0,Y.useRef)(c);return u.current=c,(0,Y.useEffect)(()=>{let n=u.current;if(n.display===`note`&&(n.shownId===t||o.current(t))){n.shownId!==t&&l({shownId:t,display:`note`});return}let r=et(e,t),i=r.document;it(i,s.current,()=>a.current);let c=!1,d=!1,f=n.display===`loading`?n.loadingSince:void 0,p=[],m=()=>{c||l({shownId:t,display:`note`,preloaded:i})};return f===void 0?p.push(setTimeout(()=>{d||c||(f=Date.now(),l({shownId:t,display:`loading`,loadingSince:f}))},600)):l({shownId:t,display:`loading`,loadingSince:f}),i.load(a.current.currentKey()).then(()=>{let t=i.getSnapshot().note?.type;return t===void 0?void 0:at(e,t)}).catch(()=>void 0).then(()=>{c||(d=!0,f===void 0?m():p.push(setTimeout(m,Math.max(0,f+Ln-Date.now()))))}),()=>{c=!0;for(let e of p)clearTimeout(e);r.release()}},[t,e]),c}function zn(e,t){return t===`note`?e:{...e,state:{...e.state,note:void 0,frontmatterSource:``,loading:!0,quiet:t===`blank`}}}function Bn({noteId:e,initialSection:t,history:n,offered:r,definitionCurrent:i}){let[a,o]=z(On),s=n?.onTabChange,c=n?.tab??a,l=(0,Y.useCallback)(t=>{e&&(o(t),s?.(e,t))},[e,s,o]),[u,d]=(0,Y.useState)(()=>({noteId:e,initialSection:t,tab:t}));(u.noteId!==e||u.initialSection!==t)&&d({noteId:e,initialSection:t,tab:t});let f=u.tab??c,p=It(f,r,i),m=!s||n!==void 0&&n.entries[n.cursor]===e;return(0,Y.useEffect)(()=>{e&&i&&m&&f!==void 0&&((f!==`outline`||p!==`content`)&&(p!==c||s&&n?.tab===void 0||a===void 0&&n?.tab!==void 0)&&l(p),u.tab&&d(e=>({...e,tab:void 0})))},[u.tab,m,i,n?.tab,e,s,a,l,f,c,p]),{tab:p,setTab:(0,Y.useCallback)(e=>{d(e=>({...e,tab:void 0})),l(e)},[l])}}function Vn(e,t){let{state:n}=e,r=(0,Y.useMemo)(()=>Lt(n.definition,n.frontmatterSource).map(({value:e})=>e),[n.definition,n.frontmatterSource]);return{sections:r,tab:Bn({noteId:n.note?t.entityId:void 0,initialSection:t.initialSection,history:t.history,offered:r,definitionCurrent:n.definitionCurrent})}}function Hn(e,t){return t.find(t=>t.id===e)?.label||(e.split(`/`).pop()??e).replace(/\.md$/i,``)}function Un(e){return e.toLocaleLowerCase().endsWith(`.md`)?e:`${e}.md`}function Wn(e){return!e.loading&&!e.note&&!!e.error}function Gn(e,t,n,r,i=!0,a=!1){(0,Y.useEffect)(()=>{if(!i)return;let o=`note-editor:${e??`new`}:${Date.now()}`;window.history.pushState({...window.history.state,noteEditorMarker:o},``);let s=()=>{t.current?(window.history.pushState({...window.history.state,noteEditorMarker:o},``),n()):r.current()};return window.addEventListener(`popstate`,s),()=>{window.removeEventListener(`popstate`,s),window.history.state?.noteEditorMarker===o&&(a?window.history.back():window.history.replaceState({...window.history.state,noteEditorMarker:void 0},``))}},[r,t,i,n,e,a])}function Kn({vaultId:e,noteKeys:t,noteId:n,frontmatterSource:r,flush:i,onOpenVaultPath:a,session:o}){let s=O(),c=(0,Y.useCallback)(e=>a?.({kind:`file`,path:e}),[a]),l=o?.state,u=s.settings.plainExport,d=!!l?.safe||fe(l?.body??``),f=(0,Y.useCallback)(async()=>{if(!o||!d||!u)return;let e=await s.requestKey({reason:`The export is decrypted on this device and sent to the server to convert.`});return e?ce(t=>s.keyring.resolve(e,t),o.state.body):void 0},[d,u,s,o]),{startExport:p,exportFlow:m}=ve({vaultId:e,noteKeys:t,onOpenSavedFile:a?c:void 0,beforeExport:i,plainBodyOf:f}),h=(0,Y.useCallback)(e=>{n&&p(n,e)},[n,p]),g=!!l?.locked||!!l?.safe&&!u,_=!K(r)&&!be(r);return{onExport:n&&_&&!g?h:void 0,exportFlow:m}}var qn=`.excalidraw.md`;function Q(e,t=!1){return t||e.toLowerCase().endsWith(qn)?qn:`.md`}function $(e,t=Q(e)){let n=e.slice(e.lastIndexOf(`/`)+1);return n.toLowerCase().endsWith(t)?n.slice(0,-t.length):n.replace(/\.md$/i,``)}function Jn(e){return/\.md$/i.test(e)?e:`${e}.md`}function Yn(e,t){return/\.md$/i.test(e)?e:t===qn&&/\.excalidraw$/i.test(e)?`${e}.md`:`${e}${t}`}function Xn(e,t){return e?`${e}/${t}`:t}function Zn(e){let t=e.trim();if(!t||!Jn(t).replace(/\.md$/i,``).trim())return`A name is required.`;if(t.includes(`/`)||t.includes(`\\`))return`A name cannot contain a slash; use Move to… to change the folder.`;if(t.startsWith(`.`))return`A name cannot start with a dot, which hides the note from the vault.`}function Qn(e,t,n=Q(e)){if(Zn(t))return;let r=Xn(Xe(e),Yn(t.trim(),n));return r===e?void 0:r}function $n(e,t){let n=Xn(t,e.slice(e.lastIndexOf(`/`)+1));return n===e?void 0:n}function er(e,t,n){for(let r of n)if(r!==t&&r===e)return!0;return!1}function tr({vaultId:e,session:t,title:n,onRenamed:r,bodyRef:i}){let a=u(),o=d(),s=(0,Y.useRef)({session:t,title:n,onRenamed:r,bodyRef:i});s.current={session:t,title:n,onRenamed:r,bodyRef:i};let[c,l]=(0,Y.useState)(),f=ht(),p=(0,Y.useCallback)(async(t,n,r)=>{try{let i=await f.prepare([{sourcePath:t,destinationPath:n}],()=>!1);return i?(await Pn(()=>s.current.session,{vaultId:e,fromId:t,toId:n}),i.open&&await s.current.session.commands.convert(i.open.direction,i.open.key),await Promise.all([R.invalidateQueries({queryKey:[`note-panel`,e]}),R.invalidateQueries({queryKey:vt(e)})]),s.current.onRenamed?.(t,n),o.success(r),!0):!1}catch(e){return o.error(de(e)),!1}},[o,f,e]),m=(0,Y.useCallback)(async()=>{let{state:e}=s.current.session,t=e.note;if(!t?.revision)return;let n=e.allNotes.map(e=>e.id),r=Q(t.id,K(e.frontmatterSource)),i=yt(s.current.title),o=await a.prompt({title:`Rename “${s.current.title}”`,message:`Links to the note follow it. The title stays as it is.`,inputLabel:`File name`,initialValue:$(t.id,r),confirmLabel:`Rename`,suggestions:i?[{label:`Use note's title`,value:i}]:[],validate:e=>Zn(e)??(er(Qn(t.id,e,r)??``,t.id,n)?`Another note in this folder already has this name.`:void 0)}),c=o===null?void 0:Qn(t.id,o,r);c&&await p(t.id,c,`Renamed to ${$(c,r)}.`)&&nt(s.current.bodyRef,`start`)},[a,p]),h=(0,Y.useCallback)(async e=>{let{state:t}=s.current.session,n=t.note,r=n?Q(n.id,K(t.frontmatterSource)):void 0,i=n?.revision?Be(n.id,e,new Set(t.allNotes.map(e=>e.id)),r):void 0;n&&i&&await p(n.id,i,`Renamed to ${$(i,r)}.`)},[p]),g=(0,Y.useCallback)(()=>{let e=s.current.session.state.note?.revision?s.current.session.state.note.id:void 0;e&&l({fromId:e,folder:Xe(e),busy:!1})},[]),_=(0,Y.useCallback)(async()=>{if(!c)return;let e=$n(c.fromId,c.folder);if(!e){l(void 0);return}if(er(e,c.fromId,s.current.session.state.allNotes.map(e=>e.id))){o.error(`A note named ${$(e)} is already in that folder.`);return}l({...c,busy:!0});let t=await p(c.fromId,e,`Moved to ${c.folder||`the vault root`}.`);l(t?void 0:{...c,busy:!1})},[c,o,p]),v=(0,Y.useCallback)(async e=>{let t=s.current.session.state.note,n=t?.revision?$n(t.id,e):void 0;return!t||!n||n===t.id?!1:er(n,t.id,s.current.session.state.allNotes.map(e=>e.id))?(o.error(`A note named ${$(n)} is already in ${e}.`),!1):p(t.id,n,`Moved to ${e}.`)},[o,p]),y=!!(r&&t.state.note?.revision),b=(0,Y.useMemo)(()=>({onRename:()=>void m(),onMove:g,start:e=>{e===`rename`?m():g()},renameToTitle:h,moveToFolder:v}),[v,g,m,h]),x=c&&(0,X.jsx)(_t,{vaultId:e,title:`Move “${n}”`,description:`Choose the folder to move the note to. Links to it follow.`,confirmLabel:`Move here`,path:c.folder,busy:c.busy,isDisabled:e=>e===Xe(c.fromId),onPathChange:e=>l(t=>t&&{...t,folder:e}),onCancel:()=>l(void 0),onConfirm:()=>void _()});return{relocation:y?b:void 0,moveDialog:x}}function nr({vaultId:e,session:t,title:n,relocation:r,bodyRef:i}){let a=(0,Y.useRef)({session:t,title:n,relocation:r,bodyRef:i});a.current={session:t,title:n,relocation:r,bodyRef:i};let o=(0,Y.useRef)(void 0),s=(0,Y.useCallback)(()=>{let t=a.current.session.state.note?.id;return!!(t&&J(e,t))},[e]);return{onTitleChange:(0,Y.useCallback)(async(e,t)=>{let{session:n,title:r,relocation:i}=a.current,c=s();o.current=c,e!==r&&await n.commands.setTitle(e),t.mod&&!c&&await i?.renameToTitle(e)},[s]),onTitleEditEnd:(0,Y.useCallback)(e=>{let t=o.current??s();return o.current=void 0,!t&&e===`cancel`?!1:nt(a.current.bodyRef,`start`)},[s])}}function rr({session:e,fresh:t,title:n,sharedLinks:r}){let{state:i,commands:a}=e,o=O(),s=u(),c=!!i.note?.revision&&!i.loading&&!K(i.frontmatterSource),l=!!(i.note&&bt(i.note.id,o.settings.folders)),d=c&&o.enabled&&!l&&!!o.keyDocument?.keyFile&&!i.safe,f=c&&o.enabled&&!l&&!!i.safe&&!i.locked,p=n??i.note?.id??`this note`,m=o.settings.sharing===`copy`,h=(0,Y.useMemo)(()=>d||f?{...d?{encrypt:()=>void(async()=>{await s.confirm({title:`Encrypt this note?`,message:p,confirmLabel:`Encrypt`,detail:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{as:`p`,children:`The body is encrypted on this device; the title, type, properties and links stay readable, searchable and linked.`}),!t&&(0,X.jsxs)(M,{as:`p`,tone:`warning`,children:[`Earlier versions of this note stay readable in the vault's history. `,(0,X.jsx)(`a`,{href:`https://github.com/marcopeg/brian/blob/main/docs/SAFE_NOTES.md#purging-plaintext-from-history`,target:`_blank`,rel:`noreferrer`,children:`How to purge them`}),`.`]}),r>0&&m&&(0,X.jsx)(M,{as:`p`,tone:`muted`,children:`Its share links serve the decrypted copy this device sends, read-only: an edit link becomes read-only.`})]})})&&await a.encrypt()})()}:{},...f?{decrypt:()=>void(async()=>{await s.confirm({title:`Decrypt this note?`,message:p,confirmLabel:`Decrypt`,detail:`The body is written to the vault as plain text again, readable by search and the agent.`})&&await o.requestKey({confirm:!0,reason:`Decrypt ${p}: its body becomes plain text again.`})&&a.decrypt()})()}:{}}:void 0,[f,d,a,m,t,p,s,o,r]),g=i.note?.revision,_=fe(a.storedBody()),{syncSharedCopies:v}=o;return(0,Y.useEffect)(()=>{g&&!i.locked&&_&&v()},[_,g,i.locked,v]),h}var ir=(0,Y.forwardRef)(function(e,t){let n=se(),r=(0,Y.useRef)(()=>!1),i=(0,Y.useRef)(()=>!1),a=Rn({vaultId:e.vaultId,requestedId:e.entityId,noteKeys:e.noteKeys,shows:e=>i.current(e)}),o=a.shownId===e.entityId?e:{...e,entityId:a.shownId},s=ot({...o,preloaded:a.preloaded,isEditing:()=>r.current()});i.current=s.shows;let{session:c,fresh:l,titleFirst:u}=In(s,{vaultId:o.vaultId,entityId:o.entityId,onRenamed:o.onRenamed,onDiscarded:o.onSaved}),d=u,f=d?{...o,focusOnMount:!1,initialSection:o.initialSection??`content`}:l&&!o.focusCaret?{...o,focusCaret:`end`}:o,{state:p,commands:m}=c;(0,Y.useEffect)(()=>{I(f.vaultId,f.entityId)},[f.vaultId,f.entityId]);let[h,g]=W(Yt,{min:400,max:820}),[v,y]=W(Qt(f.placement),{min:120,max:520}),b=f.resize??(f.placement===`floating`?{label:`Resize ${f.entityId??`new note`} editor`,value:h,min:400,max:820,onChange:g}:void 0);(0,Y.useImperativeHandle)(t,()=>({save:m.save,flush:m.flush}),[m]);let{requestDelete:x,deleteDialog:S}=gt({vaultId:f.vaultId,note:p.note,onSaved:f.onSaved,onClose:f.onClose}),C=(0,Y.useCallback)((e,t)=>{e!==p.note?.id&&(m.flush(),f.onNavigateNote?.(e,t))},[m,f,p.note?.id]),w=(0,Y.useCallback)(async e=>{f.onOpenVaultPath&&(m.flush(),await lt(e,async()=>!0,f.onOpenVaultPath))},[m,f.onOpenVaultPath]),T=(0,Y.useCallback)(()=>{m.flush(),f.onClose()},[m,f]),E=f.history,D=(0,Y.useCallback)(()=>{E&&(m.flush(),E.onBack())},[m,E]),O=(0,Y.useCallback)(e=>{E&&(m.flush(),E.onJump(e))},[m,E]),k=E&&(0,X.jsx)(ut,{entries:E.entries.map(e=>({id:e,label:Hn(e,p.allNotes)})),cursor:E.cursor,onBack:D,onJump:O});(0,Y.useEffect)(()=>{if(!f.active)return;let e=e=>{e.defaultPrevented||e.repeat||e.isComposing||document.querySelector(`.mobile-note-active-editor-body`)||((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`s`&&(e.preventDefault(),m.flush()),(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&e.key===`[`&&E&&E.cursor>0&&!_(e.target)&&(e.preventDefault(),D()))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[m,D,E,f.active]);let{onExport:A,exportFlow:j}=Kn({vaultId:f.vaultId,noteKeys:f.noteKeys,noteId:p.note?.id,frontmatterSource:p.frontmatterSource,flush:m.flush,onOpenVaultPath:f.onOpenVaultPath,session:c}),M=p.note?ge(p.frontmatterSource,p.note.id,f.noteKeys??G):void 0,N=St({vaultId:f.vaultId,noteId:p.note?.id,title:M,shareable:!!p.note?.revision}),P=rr({session:c,fresh:l,title:M,sharedLinks:N.activeLinks??0}),F=(0,Y.useRef)(null),{relocation:L,moveDialog:R}=tr({vaultId:f.vaultId,session:c,title:M??f.entityId,onRenamed:f.onRenamed,bodyRef:n?void 0:F});if(n&&!f.active)return null;let z=n?(0,X.jsx)(or,{session:zn(c,a.display),props:f,titleFirst:d,editingProbe:r,leading:k,onClose:T,onNavigateNote:C,onNavigateVaultPath:w,share:N,onExport:A,relocation:L,safety:P,onDelete:x}):(0,X.jsx)(ar,{session:zn(c,a.display),props:f,titleFirst:d,bodyRef:F,editingProbe:r,leading:k,onClose:T,resize:b,sourceSplit:v,onSourceSplitChange:y,onNavigateNote:C,onNavigateVaultPath:w,share:N,onExport:A,relocation:L,safety:P,onDelete:x});return(0,X.jsxs)(X.Fragment,{children:[z,j,S,R]})});function ar({session:e,props:n,titleFirst:r,bodyRef:i,editingProbe:o,leading:s,onClose:c,resize:l,sourceSplit:u,onSourceSplitChange:d,onNavigateNote:f,onNavigateVaultPath:p,share:m,onExport:h,relocation:g,safety:_,onDelete:v}){let{state:y,commands:b}=e,x=st(pt(n.placement,n.maximize,n.vaultId,n.entityId),!!n.active,i);mt(n.vaultId,n.entityId,x),(0,Y.useEffect)(()=>(o.current=()=>!!i.current?.contains(document.activeElement),()=>{o.current=()=>!1}),[o]),xt(i,h),Ct(i,m?.onShare),k(i,g?.start),ae(i,_);let C=n.noteKeys??G,w=Wn(y),T=y.note?ge(y.frontmatterSource,y.note.id,C):y.loading?``:w?`Note not found`:n.entityId;t({vaultId:n.vaultId,id:y.note?.id,title:T,body:y.body,savedBody:y.note?.body??``,revision:y.note?.revision,safe:y.safe||y.locked,active:n.active!==!1},i);let E=sr(y,n),D=n.placement===`embedded`,O=nr({vaultId:n.vaultId,session:e,title:T,relocation:g,bodyRef:i}),{sections:A,tab:j}=Vn(e,n),M=(0,Y.useMemo)(()=>A.filter(e=>e!==`content`),[A]),N=Nn(i),P=Mn({history:n.history,offered:M});return S(i,N?P:void 0),(0,X.jsx)(a,{className:`note-editor-panel desktop-note-editor panel-note panel-note-${n.placement??`floating`}${n.placement===`floating`||!n.placement?` graph-note-editor-panel`:``}${ct(x)}`,leading:s,title:T,subtitle:(0,X.jsx)(ft,{path:E,onNavigate:n.onOpenVaultPath?p:void 0}),onTitleChange:O.onTitleChange,autoEditTitle:r&&!!y.frontmatterSource,onTitleEditEnd:O.onTitleEditEnd,actions:w?void 0:(0,X.jsx)(jt,{session:e,share:m,onExport:h,relocation:g,safety:_,onDelete:v,onOpenInFileEditor:n.onOpenInFileEditor,beforeMenu:(0,X.jsxs)(X.Fragment,{children:[N&&(0,X.jsx)(rn,{open:P.open,onToggle:()=>P.setOpen(!P.open)}),x&&(0,X.jsx)(dt,{maximize:x})]})}),bodyRef:i,bodyClassName:y.mode===`source`?`note-editor-body source-mode`:`note-editor-body`,headerShade:!1,bodyLabel:`Edit ${n.entityId}`,keyboardLayer:n.placement!==`stacked`&&!D,onClose:D?void 0:c,closeLabel:`Close ${n.entityId} editor`,resize:D||x?.maximized?void 0:l,onActivate:n.onActivate,children:(0,X.jsx)(wn,{session:e,props:n,onClose:D?void 0:c,sourceSplit:u,onSourceSplitChange:d,onNavigateNote:f,mobile:!1,tab:j,onMoveToFolder:g?.moveToFolder,layout:{wide:N,side:P}})})}function or({session:e,props:n,titleFirst:r,editingProbe:i,leading:o,onClose:s,onNavigateNote:c,onNavigateVaultPath:u,share:d,onExport:f,relocation:p,safety:h,onDelete:g}){let _=m(),{state:v,commands:y}=e,b=(0,Y.useRef)(null),{tab:x}=Vn(e,n),[S,C]=(0,Y.useState)(n.focusCaret===`end`),[w,T]=(0,Y.useState)(),E=(0,Y.useRef)(null),D=(0,Y.useRef)(S),O=(0,Y.useRef)(s),k=Wn(v),A=v.note?ge(v.frontmatterSource,v.note.id,n.noteKeys??G):v.loading?``:k?`Note not found`:n.entityId;t({vaultId:n.vaultId,id:v.note?.id,title:A,body:v.body,savedBody:v.note?.body??``,revision:v.note?.revision,safe:v.safe||v.locked,active:n.active!==!1},b);let j=A,M=sr(v,n),N=e=>(0,X.jsx)(ft,{path:M,onNavigate:n.onOpenVaultPath?e:void 0}),P=nr({vaultId:n.vaultId,session:e,title:A,relocation:p});(0,Y.useEffect)(()=>{let e=document.querySelector(`#root`);return E.current=e,e&&(e.inert=!0,e.setAttribute(`aria-hidden`,`true`)),()=>{e&&(e.inert=!1,e.removeAttribute(`aria-hidden`))}},[]);let F=(0,Y.useCallback)(()=>C(!1),[]),I=(0,Y.useCallback)(e=>{T(typeof e==`number`?e:void 0),C(!0)},[]),L=(0,Y.useCallback)((e,t)=>{C(!1),c(e,t)},[c]);return D.current=S,O.current=s,(0,Y.useEffect)(()=>(i.current=()=>D.current,()=>{i.current=()=>!1}),[i]),Gn(v.note?.id,D,F,O,!n.mobileBackManaged||S,n.mobileBackManaged),(0,Y.useEffect)(()=>{if(!S)return;let e=e=>{e.defaultPrevented||e.repeat||e.isComposing||document.querySelector(`[data-popup-root="true"]`)||(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`s`&&(e.preventDefault(),y.flush())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[y,S]),(0,kt.createPortal)((0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(a,{className:`note-editor-panel mobile-note-editor-panel`,leading:o,title:j,subtitle:N(e=>void u(e)),onTitleChange:P.onTitleChange,autoEditTitle:r&&!!v.frontmatterSource,onTitleEditEnd:P.onTitleEditEnd,actions:k?void 0:(0,X.jsx)(jt,{session:e,share:d,onExport:f,relocation:p,safety:h,onDelete:g,onOpenInFileEditor:n.onOpenInFileEditor}),fitMobileVisualViewport:!0,edgeSwipeDismiss:!0,swipeDismissFrom:xe(v)||x.tab===`outline`?`header`:`edge`,inert:S,keyboardLayer:!0,bodyRef:b,bodyClassName:`mobile-note-reader-body`,bodyLabel:`Read ${A}`,onClose:s,closeLabel:`Close ${A}`,children:(0,X.jsx)(wn,{session:e,props:n,onClose:s,sourceSplit:230,onSourceSplitChange:()=>void 0,onNavigateNote:c,mobile:!0,tab:x,onEditContent:I,onMoveToFolder:p?.moveToFolder})}),S&&(0,X.jsxs)(Ee,{title:A,save:{unsaved:v.saveStatus!==`idle`,failed:v.saveStatus===`buffered`&&v.saveFailures>=3,error:v.saveError},flush:y.flush,onClose:F,children:[(0,X.jsx)(Tn,{error:v.error}),(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(l,{status:`loading`,children:`Loading Markdown editor…`}),children:(0,X.jsx)(pe,{vaultId:n.vaultId,noteId:v.note?.id,value:v.body,onChange:y.setBody,resolveNoteReference:n.resolveNoteReference??(e=>v.allNotes.some(t=>t.id===e)?e:void 0),noteReferences:v.allNotes,onOpenNote:L,focusOnMount:!0,focusAtEnd:n.focusCaret===`end`&&w===void 0,focusAtPosition:w})})]})]}),_)}function sr(e,t){return Un(e.note?.id??t.entityId)}var cr=(0,Y.forwardRef)(function(e,t){return(0,X.jsx)(v,{children:(0,X.jsx)(ir,{ref:t,...e})})});export{cr as NoteEditorContainer};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{m as t,t as n}from"./react-B3NTyEzE.js";import{a as r,c as i,o as a,r as o,s,u as c}from"./settings-ChT117Ke.js";import{ar as l,jn as u,rr as d}from"./index-CCUyKE6q.js";import{F as f,P as p}from"./logic-BNk_20eJ.js";import{t as m,z as h}from"./icons-CxH3_W-q.js";import{t as g}from"./ArrowSquareOut.es-ssfQ7LE-.js";var _=e(t(),1),v=n();function y(){let{settings:e,ready:t,error:n,persist:c}=u(),d=e.noteEditor.dateTime,[m,h]=(0,_.useState)(d),[g,y]=(0,_.useState)({}),[b,x]=(0,_.useState)(!1),S=m.date!==d.date||m.time!==d.time||m.dateTime!==d.dateTime,C=new Date;(0,_.useEffect)(()=>{h(d),y({})},[d.date,d.dateTime,d.time]);function w(e,t){h(n=>({...n,[e]:t})),y(t=>({...t,[e]:void 0}))}async function T(t){t.preventDefault();let n={date:f(m.date),time:f(m.time),dateTime:f(m.dateTime)};if(y(n),!Object.values(n).some(Boolean)){x(!0);try{await c({...e,noteEditor:{...e.noteEditor,dateTime:m}})}finally{x(!1)}}}return(0,v.jsx)(i,{label:`Editor date and time`,description:`Customize the format of date and time values inserted into notes.`,persistence:`explicit`,className:`editor-date-time-setting`,help:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l,{as:`p`,children:`A format is made of these tokens:`}),(0,v.jsxs)(l,{as:`p`,children:[(0,v.jsx)(l,{as:`code`,monospace:!0,children:`yyyy`}),` `,(0,v.jsx)(l,{as:`code`,monospace:!0,children:`yy`}),` year · `,(0,v.jsx)(l,{as:`code`,monospace:!0,children:`MM`}),` `,(0,v.jsx)(l,{as:`code`,monospace:!0,children:`M`}),` month · `,(0,v.jsx)(l,{as:`code`,monospace:!0,children:`dd`}),` `,(0,v.jsx)(l,{as:`code`,monospace:!0,children:`d`}),` day`]}),(0,v.jsxs)(l,{as:`p`,children:[(0,v.jsx)(l,{as:`code`,monospace:!0,children:`HH`}),` `,(0,v.jsx)(l,{as:`code`,monospace:!0,children:`H`}),` hours (24h) · `,(0,v.jsx)(l,{as:`code`,monospace:!0,children:`hh`}),` `,(0,v.jsx)(l,{as:`code`,monospace:!0,children:`h`}),` hours (12h) · `,(0,v.jsx)(l,{as:`code`,monospace:!0,children:`a`}),` am/pm`]}),(0,v.jsxs)(l,{as:`p`,children:[(0,v.jsx)(l,{as:`code`,monospace:!0,children:`mm`}),` `,(0,v.jsx)(l,{as:`code`,monospace:!0,children:`m`}),` minutes · `,(0,v.jsx)(l,{as:`code`,monospace:!0,children:`ss`}),` `,(0,v.jsx)(l,{as:`code`,monospace:!0,children:`s`}),` seconds`]}),(0,v.jsxs)(l,{as:`p`,children:[`Wrap literal words in single quotes, as in `,(0,v.jsx)(l,{as:`code`,monospace:!0,children:`'at' HH:mm`}),`.`]})]}),helpLabel:`About date and time formats`,children:(0,v.jsxs)(r,{className:`editor-date-time-form`,onSubmit:e=>void T(e),children:[(0,v.jsxs)(`div`,{className:`editor-date-time-fields`,children:[(0,v.jsx)(o,{label:`Date`,description:`Preview: ${p(C,m.date)}`,error:g.date,children:(0,v.jsx)(s,{"aria-label":`Editor date format`,value:m.date,disabled:!t||b,onChange:e=>w(`date`,e.target.value)})}),(0,v.jsx)(o,{label:`Time`,description:`Preview: ${p(C,m.time)}`,error:g.time,children:(0,v.jsx)(s,{"aria-label":`Editor time format`,value:m.time,disabled:!t||b,onChange:e=>w(`time`,e.target.value)})}),(0,v.jsx)(o,{label:`Date and time`,description:`Preview: ${p(C,m.dateTime)}`,error:g.dateTime,children:(0,v.jsx)(s,{"aria-label":`Editor date and time format`,value:m.dateTime,disabled:!t||b,onChange:e=>w(`dateTime`,e.target.value)})})]}),n&&(0,v.jsxs)(l,{as:`small`,size:`caption`,tone:`danger`,className:`settings-inline-error`,role:`alert`,children:[`Unavailable: `,n]}),(0,v.jsx)(a,{dirty:S,busy:b,disabled:!t,onCancel:()=>{h(d),y({})}})]})})}var b=[12,14,16,18,20,22,24,28,32];function x(){let{settings:e,ready:t,error:n,persist:r}=u();function a(t){r({...e,noteEditor:t})}return(0,v.jsxs)(i,{label:`Font`,description:`Typography used while reading and editing notes.`,persistence:`immediate`,className:`note-font-setting`,children:[(0,v.jsxs)(`div`,{className:`note-font-fields`,children:[(0,v.jsx)(o,{label:`Family`,children:(0,v.jsxs)(c,{"aria-label":`Note font family`,value:e.noteEditor.fontFamily,disabled:!t,onChange:t=>a({...e.noteEditor,fontFamily:t.target.value}),children:[(0,v.jsx)(`option`,{value:`system`,children:`System sans`}),(0,v.jsx)(`option`,{value:`serif`,children:`Serif`}),(0,v.jsx)(`option`,{value:`monospace`,children:`Monospace`})]})}),(0,v.jsx)(o,{label:`Size`,children:(0,v.jsx)(c,{"aria-label":`Note font size`,value:e.noteEditor.fontSize,disabled:!t,onChange:t=>a({...e.noteEditor,fontSize:Number(t.target.value)}),children:b.map(e=>(0,v.jsxs)(`option`,{value:e,children:[e,`px`]},e))})})]}),n&&(0,v.jsxs)(l,{as:`small`,size:`caption`,tone:`danger`,className:`settings-inline-error`,role:`alert`,children:[`Unavailable: `,n]})]})}var S=new Map([[`bold`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M220,148v36c0,13.85-1.63,26.52-4.58,35.68a12,12,0,0,1-22.84-7.36c2.14-6.65,3.42-17.24,3.42-28.32V148a8,8,0,0,0-16,0v4a12,12,0,0,1-24,0V132a8,8,0,0,0-16,0v12a12,12,0,0,1-24,0V76a8,8,0,0,0-16,0V184a12,12,0,0,1-22.18,6.34l-18.68-30-.21-.34A8,8,0,0,0,45,167.92L70.27,209.8a12,12,0,0,1-20.56,12.39l-25.31-42-.12-.2A32,32,0,0,1,76,142.83V76a32,32,0,0,1,64,0v25a32,32,0,0,1,36.78,17A32,32,0,0,1,220,148ZM252.48,47.51l-32-32a12,12,0,0,0-17,17L215,44H172a12,12,0,0,0,0,24h43L203.51,79.51a12,12,0,1,0,17,17l32-32A12,12,0,0,0,252.48,47.51Z`}))],[`duotone`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M208,140v36c0,24-8,40-8,40H64L34.68,166a20,20,0,0,1,34.64-20L88,176V68a20,20,0,0,1,40,0v56a20,20,0,0,1,40,0v16a20,20,0,0,1,40,0Z`,opacity:`0.2`}),_.createElement(`path`,{d:`M216,140v36c0,25.59-8.49,42.85-8.85,43.58A8,8,0,0,1,200,224a7.9,7.9,0,0,1-3.57-.85,8,8,0,0,1-3.58-10.73c.06-.12,7.16-14.81,7.16-36.42V140a12,12,0,0,0-24,0v4a8,8,0,0,1-16,0V124a12,12,0,0,0-24,0v12a8,8,0,0,1-16,0V68a12,12,0,0,0-24,0V176a8,8,0,0,1-14.79,4.23l-18.68-30-.14-.23A12,12,0,1,0,41.6,162L70.89,212A8,8,0,1,1,57.08,220l-29.32-50a28,28,0,0,1,48.41-28.17L80,148V68a28,28,0,0,1,56,0V98.7a28,28,0,0,1,38.65,16.69A28,28,0,0,1,216,140Zm37.66-89.66-32-32a8,8,0,0,0-11.31,11.32L228.68,48H176a8,8,0,0,0,0,16h52.69L210.34,82.34a8,8,0,0,0,11.31,11.32l32-32A8,8,0,0,0,253.66,50.34Z`}))],[`fill`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M216,128v50.93c0,25.59-8.48,39.93-8.84,40.65A8,8,0,0,1,200,224H64a8,8,0,0,1-6.9-3.95L26.15,160a16,16,0,0,1,6.53-22.23c7.66-4,17.1-.84,21.4,6.62l21,36.44a6.09,6.09,0,0,0,6,3.09l.12,0A8.19,8.19,0,0,0,88,175.74V56a16,16,0,0,1,16.77-16c8.61.4,15.23,7.82,15.23,16.43V128a8,8,0,0,0,8.53,8,8.17,8.17,0,0,0,7.47-8.25V112a16,16,0,0,1,16.77-16c8.61.4,15.23,7.82,15.23,16.43V136a8,8,0,0,0,8.53,8,8.18,8.18,0,0,0,7.47-8.25v-7.28c0-8.61,6.62-16,15.23-16.43A16,16,0,0,1,216,128Zm37.66-77.66-32-32a8,8,0,0,0-11.32,11.32L228.69,48H176a8,8,0,0,0,0,16h52.69L210.34,82.34a8,8,0,0,0,11.32,11.32l32-32A8,8,0,0,0,253.66,50.34Z`}))],[`light`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M214,140v36c0,25.13-8.28,42-8.64,42.68A6,6,0,0,1,200,222a5.87,5.87,0,0,1-2.68-.64,6,6,0,0,1-2.68-8c.07-.14,7.37-15.19,7.37-37.32V140a14,14,0,0,0-28,0v4a6,6,0,0,1-12,0V124a14,14,0,0,0-28,0v12a6,6,0,0,1-12,0V68a14,14,0,0,0-28,0V176a6,6,0,0,1-11.09,3.17l-18.68-30a1,1,0,0,1-.1-.17,14,14,0,0,0-24.25,14l29.29,50A6,6,0,0,1,58.81,219L29.49,169a26,26,0,0,1,45-26.13L82,155V68a26,26,0,0,1,52,0v34.1a26,26,0,0,1,39.42,16.39A26,26,0,0,1,214,140Zm38.24-88.24-32-32a6,6,0,0,0-8.48,8.48L233.51,50H176a6,6,0,1,0,0,12h57.51L211.76,83.76a6,6,0,1,0,8.48,8.48l32-32A6,6,0,0,0,252.24,51.76Z`}))],[`regular`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M216,140v36c0,25.59-8.49,42.85-8.85,43.58A8,8,0,0,1,200,224a7.9,7.9,0,0,1-3.57-.85,8,8,0,0,1-3.58-10.73c.06-.12,7.16-14.81,7.16-36.42V140a12,12,0,0,0-24,0v4a8,8,0,0,1-16,0V124a12,12,0,0,0-24,0v12a8,8,0,0,1-16,0V68a12,12,0,0,0-24,0V176a8,8,0,0,1-14.79,4.23l-18.68-30-.14-.23A12,12,0,1,0,41.6,162L70.89,212A8,8,0,1,1,57.08,220l-29.32-50a28,28,0,0,1,48.41-28.17L80,148V68a28,28,0,0,1,56,0V98.7a28,28,0,0,1,38.65,16.69A28,28,0,0,1,216,140Zm37.66-89.66-32-32a8,8,0,0,0-11.31,11.32L228.68,48H176a8,8,0,0,0,0,16h52.69L210.34,82.34a8,8,0,0,0,11.31,11.32l32-32A8,8,0,0,0,253.66,50.34Z`}))],[`thin`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M212,140v36c0,24.66-8.08,41.1-8.42,41.79a4,4,0,1,1-7.16-3.58c.07-.15,7.58-15.55,7.58-38.21V140a16,16,0,0,0-32,0v4a4,4,0,0,1-8,0V124a16,16,0,0,0-32,0v12a4,4,0,0,1-8,0V68a16,16,0,0,0-32,0V176a4,4,0,0,1-7.39,2.11l-18.68-30a.75.75,0,0,1-.07-.12,16,16,0,0,0-27.72,16l29.31,50a4,4,0,0,1-6.9,4L31.22,168a24,24,0,0,1,41.52-24.09L84,162V68a24,24,0,0,1,48,0v38.13a24,24,0,0,1,39.94,16.06A24,24,0,0,1,212,140Zm38.83-86.83-32-32a4,4,0,0,0-5.66,5.66L238.34,52H176a4,4,0,0,0,0,8h62.34L213.17,85.17a4,4,0,0,0,5.66,5.66l32-32A4,4,0,0,0,250.83,53.17Z`}))]]),C=_.forwardRef((e,t)=>_.createElement(h,{ref:t,...e,weights:S}));C.displayName=`HandSwipeRightIcon`;var w=new Map([[`bold`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M228,156v36c0,13.85-1.63,26.52-4.58,35.68a12,12,0,1,1-22.84-7.36c2.14-6.65,3.42-17.24,3.42-28.32V156a8,8,0,0,0-16,0v4a12,12,0,0,1-24,0V140a8,8,0,0,0-16,0v12a12,12,0,0,1-24,0V84a8,8,0,0,0-16,0V192a12,12,0,0,1-22.18,6.34l-18.68-30-.21-.34A8,8,0,0,0,53,175.92L78.27,217.8a12,12,0,0,1-20.56,12.39l-25.31-42-.12-.2A32,32,0,0,1,84,150.83V84a32,32,0,0,1,64,0v25a32,32,0,0,1,36.78,17A32,32,0,0,1,228,156ZM56,96A12,12,0,0,0,68,84a48,48,0,0,1,96,0,12,12,0,0,0,24,0A72,72,0,0,0,44,84,12,12,0,0,0,56,96Z`}))],[`duotone`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M216,148v36c0,24-8,40-8,40H72L42.68,174a20,20,0,0,1,34.64-20L96,184V76a20,20,0,0,1,40,0v56a20,20,0,0,1,40,0v16a20,20,0,0,1,40,0Z`,opacity:`0.2`}),_.createElement(`path`,{d:`M56,76a60,60,0,0,1,120,0,8,8,0,0,1-16,0,44,44,0,0,0-88,0,8,8,0,1,1-16,0Zm140,44a27.9,27.9,0,0,0-13.36,3.39A28,28,0,0,0,144,106.7V76a28,28,0,0,0-56,0v80l-3.82-6.13a28,28,0,0,0-48.41,28.17l29.32,50A8,8,0,1,0,78.89,220L49.6,170a12,12,0,1,1,20.78-12l.14.23,18.68,30A8,8,0,0,0,104,184V76a12,12,0,0,1,24,0v68a8,8,0,1,0,16,0V132a12,12,0,0,1,24,0v20a8,8,0,0,0,16,0v-4a12,12,0,0,1,24,0v36c0,21.61-7.1,36.3-7.16,36.42a8,8,0,0,0,3.58,10.73A7.9,7.9,0,0,0,208,232a8,8,0,0,0,7.16-4.42c.37-.73,8.85-18,8.85-43.58V148A28,28,0,0,0,196,120Z`}))],[`fill`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M64,64a48,48,0,0,1,96,0,8,8,0,0,1-16,0,32,32,0,0,0-64,0,8,8,0,0,1-16,0Zm143.23,56c-8.61.4-15.23,7.82-15.23,16.43v7.28a8.17,8.17,0,0,1-7.47,8.25,8,8,0,0,1-8.53-8V120.45c0-8.61-6.62-16-15.23-16.43A16,16,0,0,0,144,120v15.73a8.17,8.17,0,0,1-7.47,8.25,8,8,0,0,1-8.53-8V64.45c0-8.61-6.62-16-15.23-16.43A16,16,0,0,0,96,64V183.74a8.19,8.19,0,0,1-6.72,8.16l-.12,0a6.09,6.09,0,0,1-6-3.09l-21-36.44c-4.3-7.46-13.74-10.57-21.4-6.62A16,16,0,0,0,34.15,168L65.1,228.05A8,8,0,0,0,72,232H208a8,8,0,0,0,7.16-4.42c.36-.72,8.84-15.06,8.84-40.65V136A16,16,0,0,0,207.23,120Z`}))],[`light`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M58,76a58,58,0,0,1,116,0,6,6,0,0,1-12,0,46,46,0,0,0-92,0,6,6,0,0,1-12,0Zm138,46a25.87,25.87,0,0,0-14.59,4.49A26,26,0,0,0,142,110.1V76a26,26,0,0,0-52,0v87l-7.53-12.1a26,26,0,0,0-45,26.13l29.32,50A6,6,0,0,0,77.16,221L47.87,171a14,14,0,0,1,24.25-14,1,1,0,0,0,.1.17l18.68,30A6,6,0,0,0,102,184V76a14,14,0,0,1,28,0v68a6,6,0,0,0,12,0V132a14,14,0,0,1,28,0v20a6,6,0,0,0,12,0v-4a14,14,0,0,1,28,0v36c0,22.13-7.3,37.18-7.37,37.32a6,6,0,0,0,2.69,8A5.83,5.83,0,0,0,208,230a6,6,0,0,0,5.38-3.32c.35-.7,8.63-17.55,8.63-42.68V148A26,26,0,0,0,196,122Z`}))],[`regular`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M56,76a60,60,0,0,1,120,0,8,8,0,0,1-16,0,44,44,0,0,0-88,0,8,8,0,1,1-16,0Zm140,44a27.9,27.9,0,0,0-13.36,3.39A28,28,0,0,0,144,106.7V76a28,28,0,0,0-56,0v80l-3.82-6.13a28,28,0,0,0-48.41,28.17l29.32,50A8,8,0,1,0,78.89,220L49.6,170a12,12,0,1,1,20.78-12l.14.23,18.68,30A8,8,0,0,0,104,184V76a12,12,0,0,1,24,0v68a8,8,0,1,0,16,0V132a12,12,0,0,1,24,0v20a8,8,0,0,0,16,0v-4a12,12,0,0,1,24,0v36c0,21.61-7.1,36.3-7.16,36.42a8,8,0,0,0,3.58,10.73A7.9,7.9,0,0,0,208,232a8,8,0,0,0,7.16-4.42c.37-.73,8.85-18,8.85-43.58V148A28,28,0,0,0,196,120Z`}))],[`thin`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M60,76a56,56,0,0,1,112,0,4,4,0,0,1-8,0,48,48,0,0,0-96,0,4,4,0,1,1-8,0Zm136,48a23.88,23.88,0,0,0-16.07,6.19A24,24,0,0,0,140,114.13V76a24,24,0,0,0-48,0v94L80.74,151.94A24,24,0,0,0,39.22,176l29.32,50a4,4,0,0,0,6.9-4L46.13,172a16,16,0,0,1,27.72-16l.07.12,18.68,30A4,4,0,0,0,100,184V76a16,16,0,0,1,32,0v68a4,4,0,0,0,8,0V132a16,16,0,0,1,32,0v20a4,4,0,0,0,8,0v-4a16,16,0,0,1,32,0v36c0,22.66-7.51,38.06-7.58,38.21a4,4,0,0,0,1.79,5.37A4.05,4.05,0,0,0,208,228a4,4,0,0,0,3.58-2.21c.34-.69,8.42-17.13,8.42-41.79V148A24,24,0,0,0,196,124Z`}))]]),T=_.forwardRef((e,t)=>_.createElement(h,{ref:t,...e,weights:w}));T.displayName=`HandTapIcon`;var E=[{value:`tap`,label:`Tap`,icon:(0,v.jsx)(T,{})},{value:`swipe`,label:`Swipe`,icon:(0,v.jsx)(C,{})}];function D(){let{settings:e,ready:t,error:n,persist:r}=u(),a=e.noteEditor.checklistSwipe===!0?`swipe`:`tap`;return(0,v.jsx)(i,{label:`Checklist behavior`,description:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(l,{as:`span`,className:`settings-description-row`,children:[(0,v.jsx)(l,{weight:`semibold`,children:`Tap`}),`: tap to check or uncheck, and use the arrow to fold.`]}),(0,v.jsxs)(l,{as:`span`,className:`settings-description-row`,children:[(0,v.jsx)(l,{weight:`semibold`,children:`Swipe`}),`: swipe right to check and left to uncheck; tap a row to fold it.`]})]}),persistence:`immediate`,layout:`control`,children:(0,v.jsxs)(`div`,{children:[(0,v.jsx)(d,{label:`Checklist behavior`,value:a,options:E,disabled:!t,onValueChange:t=>void r({...e,noteEditor:{...e.noteEditor,checklistSwipe:t===`swipe`}})}),n&&(0,v.jsxs)(l,{as:`small`,size:`caption`,tone:`danger`,className:`settings-inline-error`,role:`alert`,children:[`Unavailable: `,n]})]})})}var O=new Map([[`bold`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M144,180a16,16,0,1,1-16-16A16,16,0,0,1,144,180Zm92-52A108,108,0,1,1,128,20,108.12,108.12,0,0,1,236,128Zm-24,0a84,84,0,1,0-84,84A84.09,84.09,0,0,0,212,128ZM128,64c-24.26,0-44,17.94-44,40v4a12,12,0,0,0,24,0v-4c0-8.82,9-16,20-16s20,7.18,20,16-9,16-20,16a12,12,0,0,0-12,12v8a12,12,0,0,0,23.73,2.56C158.31,137.88,172,122.37,172,104,172,81.94,152.26,64,128,64Z`}))],[`duotone`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z`,opacity:`0.2`}),_.createElement(`path`,{d:`M140,180a12,12,0,1,1-12-12A12,12,0,0,1,140,180ZM128,72c-22.06,0-40,16.15-40,36v4a8,8,0,0,0,16,0v-4c0-11,10.77-20,24-20s24,9,24,20-10.77,20-24,20a8,8,0,0,0-8,8v8a8,8,0,0,0,16,0v-.72c18.24-3.35,32-17.9,32-35.28C168,88.15,150.06,72,128,72Zm104,56A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z`}))],[`fill`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,168a12,12,0,1,1,12-12A12,12,0,0,1,128,192Zm8-48.72V144a8,8,0,0,1-16,0v-8a8,8,0,0,1,8-8c13.23,0,24-9,24-20s-10.77-20-24-20-24,9-24,20v4a8,8,0,0,1-16,0v-4c0-19.85,17.94-36,40-36s40,16.15,40,36C168,125.38,154.24,139.93,136,143.28Z`}))],[`light`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M138,180a10,10,0,1,1-10-10A10,10,0,0,1,138,180ZM128,74c-21,0-38,15.25-38,34v4a6,6,0,0,0,12,0v-4c0-12.13,11.66-22,26-22s26,9.87,26,22-11.66,22-26,22a6,6,0,0,0-6,6v8a6,6,0,0,0,12,0v-2.42c18.11-2.58,32-16.66,32-33.58C166,89.25,149,74,128,74Zm102,54A102,102,0,1,1,128,26,102.12,102.12,0,0,1,230,128Zm-12,0a90,90,0,1,0-90,90A90.1,90.1,0,0,0,218,128Z`}))],[`regular`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M140,180a12,12,0,1,1-12-12A12,12,0,0,1,140,180ZM128,72c-22.06,0-40,16.15-40,36v4a8,8,0,0,0,16,0v-4c0-11,10.77-20,24-20s24,9,24,20-10.77,20-24,20a8,8,0,0,0-8,8v8a8,8,0,0,0,16,0v-.72c18.24-3.35,32-17.9,32-35.28C168,88.15,150.06,72,128,72Zm104,56A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z`}))],[`thin`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M136,180a8,8,0,1,1-8-8A8,8,0,0,1,136,180ZM128,76c-19.85,0-36,14.36-36,32v4a4,4,0,0,0,8,0v-4c0-13.23,12.56-24,28-24s28,10.77,28,24-12.56,24-28,24a4,4,0,0,0-4,4v8a4,4,0,0,0,8,0v-4.2c18-1.77,32-15.36,32-31.8C164,90.36,147.85,76,128,76Zm100,52A100,100,0,1,1,128,28,100.11,100.11,0,0,1,228,128Zm-8,0a92,92,0,1,0-92,92A92.1,92.1,0,0,0,220,128Z`}))]]),k=_.forwardRef((e,t)=>_.createElement(h,{ref:t,...e,weights:O}));k.displayName=`QuestionIcon`;var A=[{value:`off`,label:`Off`,icon:(0,v.jsx)(m,{})},{value:`on`,label:`On`,icon:(0,v.jsx)(g,{})},{value:`ask`,label:`Ask`,icon:(0,v.jsx)(k,{})}];function j(){let{settings:e,ready:t,error:n,persist:r}=u(),a=e.noteEditor.openLinksInNewTab??`ask`;return(0,v.jsx)(i,{label:`Open links in new tabs`,description:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(l,{as:`span`,className:`settings-description-row`,children:[(0,v.jsx)(l,{weight:`semibold`,children:`Off`}),`: open external links in this tab.`]}),(0,v.jsxs)(l,{as:`span`,className:`settings-description-row`,children:[(0,v.jsx)(l,{weight:`semibold`,children:`On`}),`: open external links in a new tab.`]}),(0,v.jsxs)(l,{as:`span`,className:`settings-description-row`,children:[(0,v.jsx)(l,{weight:`semibold`,children:`Ask`}),`: choose whether to open here, open in a new tab, or show a QR code.`]})]}),persistence:`immediate`,layout:`control`,children:(0,v.jsxs)(`div`,{children:[(0,v.jsx)(d,{label:`Open links in new tabs`,value:a,options:A,disabled:!t,onValueChange:t=>void r({...e,noteEditor:{...e.noteEditor,openLinksInNewTab:t}})}),n&&(0,v.jsxs)(l,{as:`small`,size:`caption`,tone:`danger`,className:`settings-inline-error`,role:`alert`,children:[`Unavailable: `,n]})]})})}var M={contributions:[{id:`note-appearance`,sectionId:`editor`,priority:200,persistence:`immediate`,Component:x},{id:`editor-date-time`,sectionId:`editor`,priority:250,persistence:`explicit`,Component:y},{id:`checklist-behavior`,sectionId:`editor`,priority:275,persistence:`immediate`,Component:D},{id:`external-links`,sectionId:`general`,priority:278,persistence:`immediate`,Component:j}]};export{M as noteEditorSettingsModule};
1
+ import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{m as t,t as n}from"./react-B3NTyEzE.js";import{a as r,c as i,o as a,r as o,s,u as c}from"./settings-CU8YR8di.js";import{Nn as l,ar as u,sr as d}from"./index-BVDhmwI8.js";import{F as f,P as p}from"./logic-DtHJ5GlU.js";import{t as m,z as h}from"./icons-CxH3_W-q.js";import{t as g}from"./ArrowSquareOut.es-ssfQ7LE-.js";var _=e(t(),1),v=n();function y(){let{settings:e,ready:t,error:n,persist:c}=l(),u=e.noteEditor.dateTime,[m,h]=(0,_.useState)(u),[g,y]=(0,_.useState)({}),[b,x]=(0,_.useState)(!1),S=m.date!==u.date||m.time!==u.time||m.dateTime!==u.dateTime,C=new Date;(0,_.useEffect)(()=>{h(u),y({})},[u.date,u.dateTime,u.time]);function w(e,t){h(n=>({...n,[e]:t})),y(t=>({...t,[e]:void 0}))}async function T(t){t.preventDefault();let n={date:f(m.date),time:f(m.time),dateTime:f(m.dateTime)};if(y(n),!Object.values(n).some(Boolean)){x(!0);try{await c({...e,noteEditor:{...e.noteEditor,dateTime:m}})}finally{x(!1)}}}return(0,v.jsx)(i,{label:`Editor date and time`,description:`Customize the format of date and time values inserted into notes.`,persistence:`explicit`,className:`editor-date-time-setting`,help:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(d,{as:`p`,children:`A format is made of these tokens:`}),(0,v.jsxs)(d,{as:`p`,children:[(0,v.jsx)(d,{as:`code`,monospace:!0,children:`yyyy`}),` `,(0,v.jsx)(d,{as:`code`,monospace:!0,children:`yy`}),` year · `,(0,v.jsx)(d,{as:`code`,monospace:!0,children:`MM`}),` `,(0,v.jsx)(d,{as:`code`,monospace:!0,children:`M`}),` month · `,(0,v.jsx)(d,{as:`code`,monospace:!0,children:`dd`}),` `,(0,v.jsx)(d,{as:`code`,monospace:!0,children:`d`}),` day`]}),(0,v.jsxs)(d,{as:`p`,children:[(0,v.jsx)(d,{as:`code`,monospace:!0,children:`HH`}),` `,(0,v.jsx)(d,{as:`code`,monospace:!0,children:`H`}),` hours (24h) · `,(0,v.jsx)(d,{as:`code`,monospace:!0,children:`hh`}),` `,(0,v.jsx)(d,{as:`code`,monospace:!0,children:`h`}),` hours (12h) · `,(0,v.jsx)(d,{as:`code`,monospace:!0,children:`a`}),` am/pm`]}),(0,v.jsxs)(d,{as:`p`,children:[(0,v.jsx)(d,{as:`code`,monospace:!0,children:`mm`}),` `,(0,v.jsx)(d,{as:`code`,monospace:!0,children:`m`}),` minutes · `,(0,v.jsx)(d,{as:`code`,monospace:!0,children:`ss`}),` `,(0,v.jsx)(d,{as:`code`,monospace:!0,children:`s`}),` seconds`]}),(0,v.jsxs)(d,{as:`p`,children:[`Wrap literal words in single quotes, as in `,(0,v.jsx)(d,{as:`code`,monospace:!0,children:`'at' HH:mm`}),`.`]})]}),helpLabel:`About date and time formats`,children:(0,v.jsxs)(r,{className:`editor-date-time-form`,onSubmit:e=>void T(e),children:[(0,v.jsxs)(`div`,{className:`editor-date-time-fields`,children:[(0,v.jsx)(o,{label:`Date`,description:`Preview: ${p(C,m.date)}`,error:g.date,children:(0,v.jsx)(s,{"aria-label":`Editor date format`,value:m.date,disabled:!t||b,onChange:e=>w(`date`,e.target.value)})}),(0,v.jsx)(o,{label:`Time`,description:`Preview: ${p(C,m.time)}`,error:g.time,children:(0,v.jsx)(s,{"aria-label":`Editor time format`,value:m.time,disabled:!t||b,onChange:e=>w(`time`,e.target.value)})}),(0,v.jsx)(o,{label:`Date and time`,description:`Preview: ${p(C,m.dateTime)}`,error:g.dateTime,children:(0,v.jsx)(s,{"aria-label":`Editor date and time format`,value:m.dateTime,disabled:!t||b,onChange:e=>w(`dateTime`,e.target.value)})})]}),n&&(0,v.jsxs)(d,{as:`small`,size:`caption`,tone:`danger`,className:`settings-inline-error`,role:`alert`,children:[`Unavailable: `,n]}),(0,v.jsx)(a,{dirty:S,busy:b,disabled:!t,onCancel:()=>{h(u),y({})}})]})})}var b=[12,14,16,18,20,22,24,28,32];function x(){let{settings:e,ready:t,error:n,persist:r}=l();function a(t){r({...e,noteEditor:t})}return(0,v.jsxs)(i,{label:`Font`,description:`Typography used while reading and editing notes.`,persistence:`immediate`,className:`note-font-setting`,children:[(0,v.jsxs)(`div`,{className:`note-font-fields`,children:[(0,v.jsx)(o,{label:`Family`,children:(0,v.jsxs)(c,{"aria-label":`Note font family`,value:e.noteEditor.fontFamily,disabled:!t,onChange:t=>a({...e.noteEditor,fontFamily:t.target.value}),children:[(0,v.jsx)(`option`,{value:`system`,children:`System sans`}),(0,v.jsx)(`option`,{value:`serif`,children:`Serif`}),(0,v.jsx)(`option`,{value:`monospace`,children:`Monospace`})]})}),(0,v.jsx)(o,{label:`Size`,children:(0,v.jsx)(c,{"aria-label":`Note font size`,value:e.noteEditor.fontSize,disabled:!t,onChange:t=>a({...e.noteEditor,fontSize:Number(t.target.value)}),children:b.map(e=>(0,v.jsxs)(`option`,{value:e,children:[e,`px`]},e))})})]}),n&&(0,v.jsxs)(d,{as:`small`,size:`caption`,tone:`danger`,className:`settings-inline-error`,role:`alert`,children:[`Unavailable: `,n]})]})}var S=new Map([[`bold`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M220,148v36c0,13.85-1.63,26.52-4.58,35.68a12,12,0,0,1-22.84-7.36c2.14-6.65,3.42-17.24,3.42-28.32V148a8,8,0,0,0-16,0v4a12,12,0,0,1-24,0V132a8,8,0,0,0-16,0v12a12,12,0,0,1-24,0V76a8,8,0,0,0-16,0V184a12,12,0,0,1-22.18,6.34l-18.68-30-.21-.34A8,8,0,0,0,45,167.92L70.27,209.8a12,12,0,0,1-20.56,12.39l-25.31-42-.12-.2A32,32,0,0,1,76,142.83V76a32,32,0,0,1,64,0v25a32,32,0,0,1,36.78,17A32,32,0,0,1,220,148ZM252.48,47.51l-32-32a12,12,0,0,0-17,17L215,44H172a12,12,0,0,0,0,24h43L203.51,79.51a12,12,0,1,0,17,17l32-32A12,12,0,0,0,252.48,47.51Z`}))],[`duotone`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M208,140v36c0,24-8,40-8,40H64L34.68,166a20,20,0,0,1,34.64-20L88,176V68a20,20,0,0,1,40,0v56a20,20,0,0,1,40,0v16a20,20,0,0,1,40,0Z`,opacity:`0.2`}),_.createElement(`path`,{d:`M216,140v36c0,25.59-8.49,42.85-8.85,43.58A8,8,0,0,1,200,224a7.9,7.9,0,0,1-3.57-.85,8,8,0,0,1-3.58-10.73c.06-.12,7.16-14.81,7.16-36.42V140a12,12,0,0,0-24,0v4a8,8,0,0,1-16,0V124a12,12,0,0,0-24,0v12a8,8,0,0,1-16,0V68a12,12,0,0,0-24,0V176a8,8,0,0,1-14.79,4.23l-18.68-30-.14-.23A12,12,0,1,0,41.6,162L70.89,212A8,8,0,1,1,57.08,220l-29.32-50a28,28,0,0,1,48.41-28.17L80,148V68a28,28,0,0,1,56,0V98.7a28,28,0,0,1,38.65,16.69A28,28,0,0,1,216,140Zm37.66-89.66-32-32a8,8,0,0,0-11.31,11.32L228.68,48H176a8,8,0,0,0,0,16h52.69L210.34,82.34a8,8,0,0,0,11.31,11.32l32-32A8,8,0,0,0,253.66,50.34Z`}))],[`fill`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M216,128v50.93c0,25.59-8.48,39.93-8.84,40.65A8,8,0,0,1,200,224H64a8,8,0,0,1-6.9-3.95L26.15,160a16,16,0,0,1,6.53-22.23c7.66-4,17.1-.84,21.4,6.62l21,36.44a6.09,6.09,0,0,0,6,3.09l.12,0A8.19,8.19,0,0,0,88,175.74V56a16,16,0,0,1,16.77-16c8.61.4,15.23,7.82,15.23,16.43V128a8,8,0,0,0,8.53,8,8.17,8.17,0,0,0,7.47-8.25V112a16,16,0,0,1,16.77-16c8.61.4,15.23,7.82,15.23,16.43V136a8,8,0,0,0,8.53,8,8.18,8.18,0,0,0,7.47-8.25v-7.28c0-8.61,6.62-16,15.23-16.43A16,16,0,0,1,216,128Zm37.66-77.66-32-32a8,8,0,0,0-11.32,11.32L228.69,48H176a8,8,0,0,0,0,16h52.69L210.34,82.34a8,8,0,0,0,11.32,11.32l32-32A8,8,0,0,0,253.66,50.34Z`}))],[`light`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M214,140v36c0,25.13-8.28,42-8.64,42.68A6,6,0,0,1,200,222a5.87,5.87,0,0,1-2.68-.64,6,6,0,0,1-2.68-8c.07-.14,7.37-15.19,7.37-37.32V140a14,14,0,0,0-28,0v4a6,6,0,0,1-12,0V124a14,14,0,0,0-28,0v12a6,6,0,0,1-12,0V68a14,14,0,0,0-28,0V176a6,6,0,0,1-11.09,3.17l-18.68-30a1,1,0,0,1-.1-.17,14,14,0,0,0-24.25,14l29.29,50A6,6,0,0,1,58.81,219L29.49,169a26,26,0,0,1,45-26.13L82,155V68a26,26,0,0,1,52,0v34.1a26,26,0,0,1,39.42,16.39A26,26,0,0,1,214,140Zm38.24-88.24-32-32a6,6,0,0,0-8.48,8.48L233.51,50H176a6,6,0,1,0,0,12h57.51L211.76,83.76a6,6,0,1,0,8.48,8.48l32-32A6,6,0,0,0,252.24,51.76Z`}))],[`regular`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M216,140v36c0,25.59-8.49,42.85-8.85,43.58A8,8,0,0,1,200,224a7.9,7.9,0,0,1-3.57-.85,8,8,0,0,1-3.58-10.73c.06-.12,7.16-14.81,7.16-36.42V140a12,12,0,0,0-24,0v4a8,8,0,0,1-16,0V124a12,12,0,0,0-24,0v12a8,8,0,0,1-16,0V68a12,12,0,0,0-24,0V176a8,8,0,0,1-14.79,4.23l-18.68-30-.14-.23A12,12,0,1,0,41.6,162L70.89,212A8,8,0,1,1,57.08,220l-29.32-50a28,28,0,0,1,48.41-28.17L80,148V68a28,28,0,0,1,56,0V98.7a28,28,0,0,1,38.65,16.69A28,28,0,0,1,216,140Zm37.66-89.66-32-32a8,8,0,0,0-11.31,11.32L228.68,48H176a8,8,0,0,0,0,16h52.69L210.34,82.34a8,8,0,0,0,11.31,11.32l32-32A8,8,0,0,0,253.66,50.34Z`}))],[`thin`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M212,140v36c0,24.66-8.08,41.1-8.42,41.79a4,4,0,1,1-7.16-3.58c.07-.15,7.58-15.55,7.58-38.21V140a16,16,0,0,0-32,0v4a4,4,0,0,1-8,0V124a16,16,0,0,0-32,0v12a4,4,0,0,1-8,0V68a16,16,0,0,0-32,0V176a4,4,0,0,1-7.39,2.11l-18.68-30a.75.75,0,0,1-.07-.12,16,16,0,0,0-27.72,16l29.31,50a4,4,0,0,1-6.9,4L31.22,168a24,24,0,0,1,41.52-24.09L84,162V68a24,24,0,0,1,48,0v38.13a24,24,0,0,1,39.94,16.06A24,24,0,0,1,212,140Zm38.83-86.83-32-32a4,4,0,0,0-5.66,5.66L238.34,52H176a4,4,0,0,0,0,8h62.34L213.17,85.17a4,4,0,0,0,5.66,5.66l32-32A4,4,0,0,0,250.83,53.17Z`}))]]),C=_.forwardRef((e,t)=>_.createElement(h,{ref:t,...e,weights:S}));C.displayName=`HandSwipeRightIcon`;var w=new Map([[`bold`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M228,156v36c0,13.85-1.63,26.52-4.58,35.68a12,12,0,1,1-22.84-7.36c2.14-6.65,3.42-17.24,3.42-28.32V156a8,8,0,0,0-16,0v4a12,12,0,0,1-24,0V140a8,8,0,0,0-16,0v12a12,12,0,0,1-24,0V84a8,8,0,0,0-16,0V192a12,12,0,0,1-22.18,6.34l-18.68-30-.21-.34A8,8,0,0,0,53,175.92L78.27,217.8a12,12,0,0,1-20.56,12.39l-25.31-42-.12-.2A32,32,0,0,1,84,150.83V84a32,32,0,0,1,64,0v25a32,32,0,0,1,36.78,17A32,32,0,0,1,228,156ZM56,96A12,12,0,0,0,68,84a48,48,0,0,1,96,0,12,12,0,0,0,24,0A72,72,0,0,0,44,84,12,12,0,0,0,56,96Z`}))],[`duotone`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M216,148v36c0,24-8,40-8,40H72L42.68,174a20,20,0,0,1,34.64-20L96,184V76a20,20,0,0,1,40,0v56a20,20,0,0,1,40,0v16a20,20,0,0,1,40,0Z`,opacity:`0.2`}),_.createElement(`path`,{d:`M56,76a60,60,0,0,1,120,0,8,8,0,0,1-16,0,44,44,0,0,0-88,0,8,8,0,1,1-16,0Zm140,44a27.9,27.9,0,0,0-13.36,3.39A28,28,0,0,0,144,106.7V76a28,28,0,0,0-56,0v80l-3.82-6.13a28,28,0,0,0-48.41,28.17l29.32,50A8,8,0,1,0,78.89,220L49.6,170a12,12,0,1,1,20.78-12l.14.23,18.68,30A8,8,0,0,0,104,184V76a12,12,0,0,1,24,0v68a8,8,0,1,0,16,0V132a12,12,0,0,1,24,0v20a8,8,0,0,0,16,0v-4a12,12,0,0,1,24,0v36c0,21.61-7.1,36.3-7.16,36.42a8,8,0,0,0,3.58,10.73A7.9,7.9,0,0,0,208,232a8,8,0,0,0,7.16-4.42c.37-.73,8.85-18,8.85-43.58V148A28,28,0,0,0,196,120Z`}))],[`fill`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M64,64a48,48,0,0,1,96,0,8,8,0,0,1-16,0,32,32,0,0,0-64,0,8,8,0,0,1-16,0Zm143.23,56c-8.61.4-15.23,7.82-15.23,16.43v7.28a8.17,8.17,0,0,1-7.47,8.25,8,8,0,0,1-8.53-8V120.45c0-8.61-6.62-16-15.23-16.43A16,16,0,0,0,144,120v15.73a8.17,8.17,0,0,1-7.47,8.25,8,8,0,0,1-8.53-8V64.45c0-8.61-6.62-16-15.23-16.43A16,16,0,0,0,96,64V183.74a8.19,8.19,0,0,1-6.72,8.16l-.12,0a6.09,6.09,0,0,1-6-3.09l-21-36.44c-4.3-7.46-13.74-10.57-21.4-6.62A16,16,0,0,0,34.15,168L65.1,228.05A8,8,0,0,0,72,232H208a8,8,0,0,0,7.16-4.42c.36-.72,8.84-15.06,8.84-40.65V136A16,16,0,0,0,207.23,120Z`}))],[`light`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M58,76a58,58,0,0,1,116,0,6,6,0,0,1-12,0,46,46,0,0,0-92,0,6,6,0,0,1-12,0Zm138,46a25.87,25.87,0,0,0-14.59,4.49A26,26,0,0,0,142,110.1V76a26,26,0,0,0-52,0v87l-7.53-12.1a26,26,0,0,0-45,26.13l29.32,50A6,6,0,0,0,77.16,221L47.87,171a14,14,0,0,1,24.25-14,1,1,0,0,0,.1.17l18.68,30A6,6,0,0,0,102,184V76a14,14,0,0,1,28,0v68a6,6,0,0,0,12,0V132a14,14,0,0,1,28,0v20a6,6,0,0,0,12,0v-4a14,14,0,0,1,28,0v36c0,22.13-7.3,37.18-7.37,37.32a6,6,0,0,0,2.69,8A5.83,5.83,0,0,0,208,230a6,6,0,0,0,5.38-3.32c.35-.7,8.63-17.55,8.63-42.68V148A26,26,0,0,0,196,122Z`}))],[`regular`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M56,76a60,60,0,0,1,120,0,8,8,0,0,1-16,0,44,44,0,0,0-88,0,8,8,0,1,1-16,0Zm140,44a27.9,27.9,0,0,0-13.36,3.39A28,28,0,0,0,144,106.7V76a28,28,0,0,0-56,0v80l-3.82-6.13a28,28,0,0,0-48.41,28.17l29.32,50A8,8,0,1,0,78.89,220L49.6,170a12,12,0,1,1,20.78-12l.14.23,18.68,30A8,8,0,0,0,104,184V76a12,12,0,0,1,24,0v68a8,8,0,1,0,16,0V132a12,12,0,0,1,24,0v20a8,8,0,0,0,16,0v-4a12,12,0,0,1,24,0v36c0,21.61-7.1,36.3-7.16,36.42a8,8,0,0,0,3.58,10.73A7.9,7.9,0,0,0,208,232a8,8,0,0,0,7.16-4.42c.37-.73,8.85-18,8.85-43.58V148A28,28,0,0,0,196,120Z`}))],[`thin`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M60,76a56,56,0,0,1,112,0,4,4,0,0,1-8,0,48,48,0,0,0-96,0,4,4,0,1,1-8,0Zm136,48a23.88,23.88,0,0,0-16.07,6.19A24,24,0,0,0,140,114.13V76a24,24,0,0,0-48,0v94L80.74,151.94A24,24,0,0,0,39.22,176l29.32,50a4,4,0,0,0,6.9-4L46.13,172a16,16,0,0,1,27.72-16l.07.12,18.68,30A4,4,0,0,0,100,184V76a16,16,0,0,1,32,0v68a4,4,0,0,0,8,0V132a16,16,0,0,1,32,0v20a4,4,0,0,0,8,0v-4a16,16,0,0,1,32,0v36c0,22.66-7.51,38.06-7.58,38.21a4,4,0,0,0,1.79,5.37A4.05,4.05,0,0,0,208,228a4,4,0,0,0,3.58-2.21c.34-.69,8.42-17.13,8.42-41.79V148A24,24,0,0,0,196,124Z`}))]]),T=_.forwardRef((e,t)=>_.createElement(h,{ref:t,...e,weights:w}));T.displayName=`HandTapIcon`;var E=[{value:`tap`,label:`Tap`,icon:(0,v.jsx)(T,{})},{value:`swipe`,label:`Swipe`,icon:(0,v.jsx)(C,{})}];function D(){let{settings:e,ready:t,error:n,persist:r}=l(),a=e.noteEditor.checklistSwipe===!0?`swipe`:`tap`;return(0,v.jsx)(i,{label:`Checklist behavior`,description:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(d,{as:`span`,className:`settings-description-row`,children:[(0,v.jsx)(d,{weight:`semibold`,children:`Tap`}),`: tap to check or uncheck, and use the arrow to fold.`]}),(0,v.jsxs)(d,{as:`span`,className:`settings-description-row`,children:[(0,v.jsx)(d,{weight:`semibold`,children:`Swipe`}),`: swipe right to check and left to uncheck; tap a row to fold it.`]})]}),persistence:`immediate`,layout:`control`,children:(0,v.jsxs)(`div`,{children:[(0,v.jsx)(u,{label:`Checklist behavior`,value:a,options:E,disabled:!t,onValueChange:t=>void r({...e,noteEditor:{...e.noteEditor,checklistSwipe:t===`swipe`}})}),n&&(0,v.jsxs)(d,{as:`small`,size:`caption`,tone:`danger`,className:`settings-inline-error`,role:`alert`,children:[`Unavailable: `,n]})]})})}var O=new Map([[`bold`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M144,180a16,16,0,1,1-16-16A16,16,0,0,1,144,180Zm92-52A108,108,0,1,1,128,20,108.12,108.12,0,0,1,236,128Zm-24,0a84,84,0,1,0-84,84A84.09,84.09,0,0,0,212,128ZM128,64c-24.26,0-44,17.94-44,40v4a12,12,0,0,0,24,0v-4c0-8.82,9-16,20-16s20,7.18,20,16-9,16-20,16a12,12,0,0,0-12,12v8a12,12,0,0,0,23.73,2.56C158.31,137.88,172,122.37,172,104,172,81.94,152.26,64,128,64Z`}))],[`duotone`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z`,opacity:`0.2`}),_.createElement(`path`,{d:`M140,180a12,12,0,1,1-12-12A12,12,0,0,1,140,180ZM128,72c-22.06,0-40,16.15-40,36v4a8,8,0,0,0,16,0v-4c0-11,10.77-20,24-20s24,9,24,20-10.77,20-24,20a8,8,0,0,0-8,8v8a8,8,0,0,0,16,0v-.72c18.24-3.35,32-17.9,32-35.28C168,88.15,150.06,72,128,72Zm104,56A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z`}))],[`fill`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,168a12,12,0,1,1,12-12A12,12,0,0,1,128,192Zm8-48.72V144a8,8,0,0,1-16,0v-8a8,8,0,0,1,8-8c13.23,0,24-9,24-20s-10.77-20-24-20-24,9-24,20v4a8,8,0,0,1-16,0v-4c0-19.85,17.94-36,40-36s40,16.15,40,36C168,125.38,154.24,139.93,136,143.28Z`}))],[`light`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M138,180a10,10,0,1,1-10-10A10,10,0,0,1,138,180ZM128,74c-21,0-38,15.25-38,34v4a6,6,0,0,0,12,0v-4c0-12.13,11.66-22,26-22s26,9.87,26,22-11.66,22-26,22a6,6,0,0,0-6,6v8a6,6,0,0,0,12,0v-2.42c18.11-2.58,32-16.66,32-33.58C166,89.25,149,74,128,74Zm102,54A102,102,0,1,1,128,26,102.12,102.12,0,0,1,230,128Zm-12,0a90,90,0,1,0-90,90A90.1,90.1,0,0,0,218,128Z`}))],[`regular`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M140,180a12,12,0,1,1-12-12A12,12,0,0,1,140,180ZM128,72c-22.06,0-40,16.15-40,36v4a8,8,0,0,0,16,0v-4c0-11,10.77-20,24-20s24,9,24,20-10.77,20-24,20a8,8,0,0,0-8,8v8a8,8,0,0,0,16,0v-.72c18.24-3.35,32-17.9,32-35.28C168,88.15,150.06,72,128,72Zm104,56A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z`}))],[`thin`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M136,180a8,8,0,1,1-8-8A8,8,0,0,1,136,180ZM128,76c-19.85,0-36,14.36-36,32v4a4,4,0,0,0,8,0v-4c0-13.23,12.56-24,28-24s28,10.77,28,24-12.56,24-28,24a4,4,0,0,0-4,4v8a4,4,0,0,0,8,0v-4.2c18-1.77,32-15.36,32-31.8C164,90.36,147.85,76,128,76Zm100,52A100,100,0,1,1,128,28,100.11,100.11,0,0,1,228,128Zm-8,0a92,92,0,1,0-92,92A92.1,92.1,0,0,0,220,128Z`}))]]),k=_.forwardRef((e,t)=>_.createElement(h,{ref:t,...e,weights:O}));k.displayName=`QuestionIcon`;var A=[{value:`off`,label:`Off`,icon:(0,v.jsx)(m,{})},{value:`on`,label:`On`,icon:(0,v.jsx)(g,{})},{value:`ask`,label:`Ask`,icon:(0,v.jsx)(k,{})}];function j(){let{settings:e,ready:t,error:n,persist:r}=l(),a=e.noteEditor.openLinksInNewTab??`ask`;return(0,v.jsx)(i,{label:`Open links in new tabs`,description:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(d,{as:`span`,className:`settings-description-row`,children:[(0,v.jsx)(d,{weight:`semibold`,children:`Off`}),`: open external links in this tab.`]}),(0,v.jsxs)(d,{as:`span`,className:`settings-description-row`,children:[(0,v.jsx)(d,{weight:`semibold`,children:`On`}),`: open external links in a new tab.`]}),(0,v.jsxs)(d,{as:`span`,className:`settings-description-row`,children:[(0,v.jsx)(d,{weight:`semibold`,children:`Ask`}),`: choose whether to open here, open in a new tab, or show a QR code.`]})]}),persistence:`immediate`,layout:`control`,children:(0,v.jsxs)(`div`,{children:[(0,v.jsx)(u,{label:`Open links in new tabs`,value:a,options:A,disabled:!t,onValueChange:t=>void r({...e,noteEditor:{...e.noteEditor,openLinksInNewTab:t}})}),n&&(0,v.jsxs)(d,{as:`small`,size:`caption`,tone:`danger`,className:`settings-inline-error`,role:`alert`,children:[`Unavailable: `,n]})]})})}var M={contributions:[{id:`note-appearance`,sectionId:`editor`,priority:200,persistence:`immediate`,Component:x},{id:`editor-date-time`,sectionId:`editor`,priority:250,persistence:`explicit`,Component:y},{id:`checklist-behavior`,sectionId:`editor`,priority:275,persistence:`immediate`,Component:D},{id:`external-links`,sectionId:`general`,priority:278,persistence:`immediate`,Component:j}]};export{M as noteEditorSettingsModule};