@forsion/unit 2.13.2 → 2.13.4

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 (207) hide show
  1. package/main.mjs +25 -3
  2. package/package.json +1 -1
  3. package/release.json +5 -5
  4. package/web/assets/ArtificialView-DLh75dAI.js +1 -0
  5. package/web/assets/AutomationBuilder-DNWWGnFr.js +1 -0
  6. package/web/assets/CalendarConfigView-G7je7k9-.js +1 -0
  7. package/web/assets/{CalendarView-D7ZUE_dr.js → CalendarView-B2MtaOJk.js} +1 -1
  8. package/web/assets/{CapabilityMenu-CrsaTtDe.js → CapabilityMenu-DJaZ_Cyt.js} +1 -1
  9. package/web/assets/{CheckboxInput-DVO2-1J7.js → CheckboxInput-FYXLaZke.js} +1 -1
  10. package/web/assets/{Chrome-BvpbCvo1.js → Chrome-CFonajM4.js} +1 -1
  11. package/web/assets/{CodeView-CB4kG7Y6.js → CodeView-GZ0BAgoW.js} +3 -3
  12. package/web/assets/DashboardGridView-D9s9pez_.css +1 -0
  13. package/web/assets/DashboardGridView-Xgw4wa0_.js +17 -0
  14. package/web/assets/{EventCard-c6s4uGBu.js → EventCard-_39F_I5M.js} +1 -1
  15. package/web/assets/ExcalidrawCanvas-rXujil36.js +1 -0
  16. package/web/assets/{FloatingToc-ldOYWe2C.js → FloatingToc-DNqAkkI0.js} +1 -1
  17. package/web/assets/GitCloneDialog-Bj9G3o-n.css +1 -0
  18. package/web/assets/GitCloneDialog-CQx-O4j1.js +1 -0
  19. package/web/assets/HomepageView-DcWmTPQO.css +1 -0
  20. package/web/assets/HomepageView-MYEk3RCs.js +3 -0
  21. package/web/assets/{ImageStudioPanels-DgMYAsHj.js → ImageStudioPanels-4wnb2XF4.js} +2 -2
  22. package/web/assets/ImageStudioView-qrmW8pfx.js +1 -0
  23. package/web/assets/InlineAiPanel-B3kd1ob2.js +1 -0
  24. package/web/assets/InlineAiPanel-DZZijfif.css +1 -0
  25. package/web/assets/InlineFiles-Clnqh9jD.js +1 -0
  26. package/web/assets/MarkdownBlock-DQTuoen3.css +1 -0
  27. package/web/assets/MarkdownBlock-DT_wsaja.js +58 -0
  28. package/web/assets/ModelPill-JaIH3ffZ.js +2 -0
  29. package/web/assets/MuseLibraryView-16p1zsxz.css +1 -0
  30. package/web/assets/MuseLibraryView-DOJVVeU6.js +2 -0
  31. package/web/assets/{MuseView-3GL4Ltoj.js → MuseView-uxTmjVQa.js} +2 -2
  32. package/web/assets/{PageHistoryPanel-BMQC-V_l.js → PageHistoryPanel-Bn4-XmdK.js} +2 -2
  33. package/web/assets/{PdfAnnotator-CyAw8sgq.js → PdfAnnotator-Cq8cklTz.js} +1 -1
  34. package/web/assets/PenRow-COOYAaxx.js +1 -0
  35. package/web/assets/ProductView-DPTveulg.js +1 -0
  36. package/web/assets/RightPanel-BJUacrsf.js +4 -0
  37. package/web/assets/RightPanel-D0zk1g3I.css +1 -0
  38. package/web/assets/{SketchCard-DAD0jR0i.js → SketchCard-B_UU5sxV.js} +3 -3
  39. package/web/assets/{StudioGuestSurface-DlUKXBXv.js → StudioGuestSurface-yBa4QKfX.js} +1 -1
  40. package/web/assets/TargetHealthNotice-BLzDB-Xl.css +1 -0
  41. package/web/assets/TargetHealthNotice-CgkdTdhB.js +47 -0
  42. package/web/assets/{TodoListView-_yFkPUrw.js → TodoListView-CricdCfW.js} +1 -1
  43. package/web/assets/{Tooltip-DXuy9-1_.js → Tooltip-o8ZqIb3L.js} +1 -1
  44. package/web/assets/UnifiedPage-BWAyqj65.js +69 -0
  45. package/web/assets/ViewSelectionBar-35x8TiLA.js +2 -0
  46. package/web/assets/{amadeus-manual.en-DzRWr4BL.js → amadeus-manual.en-B8J-svqq.js} +1 -1
  47. package/web/assets/{amadeus-manual.zh-DW32DkL7.js → amadeus-manual.zh-CkCOFnrg.js} +1 -1
  48. package/web/assets/appStore-CI1_L5OS.js +3357 -0
  49. package/web/assets/appStore-DQc2marq.css +1 -0
  50. package/web/assets/{arrow-up-right-KPFbRA41.js → arrow-up-right-BDsMFoNQ.js} +1 -1
  51. package/web/assets/{astryxBridge-Bupzouso.js → astryxBridge-CH_c5xjo.js} +3 -3
  52. package/web/assets/automationListSource-CB6AWkL_.js +1 -0
  53. package/web/assets/{boardSurface-BHuMoQN-.js → boardSurface-CLvEUjbF.js} +1 -1
  54. package/web/assets/{book-open-CBeNsIpo.js → book-open-BLzEdGfu.js} +1 -1
  55. package/web/assets/{calendarNavStore-Duyhbmm_.js → calendarNavStore-BHUNxDx8.js} +1 -1
  56. package/web/assets/{canvasPrefs-CxfyDTMT.js → canvasPrefs-CvE7mgyq.js} +1 -1
  57. package/web/assets/{chatBoxSurface-OBzO1Z5E.js → chatBoxSurface-CuuHLzs5.js} +1 -1
  58. package/web/assets/{circle-question-mark-M8QUJJYk.js → circle-question-mark-BM4ZRxQS.js} +1 -1
  59. package/web/assets/{circle-x-Szwop5L_.js → circle-x-DTcNGZDT.js} +1 -1
  60. package/web/assets/{client-CPUljePZ.js → client-CaivGZFR.js} +5 -5
  61. package/web/assets/{code-xml-n9mgGgkv.js → code-xml-AE3mT4T5.js} +1 -1
  62. package/web/assets/{codeStudioStore-DXMQwRzG.js → codeStudioStore-DhyMazGT.js} +1 -1
  63. package/web/assets/codingNavigation-B0kVsy4x.js +53 -0
  64. package/web/assets/codingNavigation-DHCidM4N.css +1 -0
  65. package/web/assets/{create-C19zqt5N.js → create-1JI2I47p.js} +2 -2
  66. package/web/assets/dashboardSurface-CIE5HybN.js +1 -0
  67. package/web/assets/{deskCapture-B_LKZSPt.js → deskCapture-COW7aG5Y.js} +1 -1
  68. package/web/assets/{diff2html-DrCCWvpR.js → diff2html-Daje9Kkm.js} +1 -1
  69. package/web/assets/{docx-preview-Bi7wekSM.js → docx-preview-CABR7n30.js} +1 -1
  70. package/web/assets/emoji-DZ9CA_3l.css +1 -0
  71. package/web/assets/emoji-DphwSxPx.js +1 -0
  72. package/web/assets/{floatingTocSurface-rc1ZC7-I.js → floatingTocSurface-BOm2QYBK.js} +1 -1
  73. package/web/assets/{foldActions-BGocXE-o.js → foldActions-DNbJPlPl.js} +1 -1
  74. package/web/assets/{folder-CoOsfQ64.js → folder-DotgUhYD.js} +1 -1
  75. package/web/assets/{folder-plus-d5MwIMlf.js → folder-plus-aJgL9NeP.js} +1 -1
  76. package/web/assets/gestures-dqncPOwo.js +1 -0
  77. package/web/assets/git-branch-CwR2qic6.js +1 -0
  78. package/web/assets/{hand-fuehbnkI.js → hand-XNkzNiW2.js} +1 -1
  79. package/web/assets/{hard-drive-Bh1DmZg0.js → hard-drive-CfWKRoAE.js} +1 -1
  80. package/web/assets/i18n-CykmULlm.css +1 -0
  81. package/web/assets/i18n.generated-BwynSSMk.js +15 -0
  82. package/web/assets/{imageStudio-Dgl1wZNB.js → imageStudio-CWgLpC_d.js} +2 -2
  83. package/web/assets/imageStudio-DZ0qGU2s.css +1 -0
  84. package/web/assets/{index-2tD0kijW.js → index-B65ULikK.js} +1 -1
  85. package/web/assets/{index-BPqoEOV_.js → index-BGfvNj7R.js} +1 -1
  86. package/web/assets/{index-38xsQSS9.js → index-BIIeiIap.js} +1 -1
  87. package/web/assets/{index-B5UW6SaE.js → index-BOzsniE1.js} +89 -89
  88. package/web/assets/{index-YRWOePBS.js → index-BfrjVzia.js} +1 -1
  89. package/web/assets/{index-CnDAYLti.js → index-Bi9UtjVz.js} +1 -1
  90. package/web/assets/{index-fViJsYjM.js → index-C1uilc9i.js} +1 -1
  91. package/web/assets/{index-CPLtf9Vc.js → index-C3Dc3Ivz.js} +1 -1
  92. package/web/assets/{index-B8Co6KG3.js → index-CJF_Ld1Y.js} +1 -1
  93. package/web/assets/{index-lfow5R3O.js → index-CMARP4oV.js} +1 -1
  94. package/web/assets/{index-Dx9aIoyo.js → index-C_RsQVNm.js} +1 -1
  95. package/web/assets/{index-D4CSH-v1.js → index-ChyxZMm8.js} +1 -1
  96. package/web/assets/{index-7kdR1oL8.js → index-CoKcOaZg.js} +1 -1
  97. package/web/assets/{index-Ce1sNSS8.js → index-CuviSCbk.js} +1 -1
  98. package/web/assets/{index-Ch0FIsJX.js → index-Cw43kua8.js} +1 -1
  99. package/web/assets/{index-DvOrTnw2.js → index-D1fu6XQN.js} +1 -1
  100. package/web/assets/{index-QjVOA7QM.js → index-DG-hXb63.js} +1 -1
  101. package/web/assets/index-DjnTfJpN.js +1 -0
  102. package/web/assets/{index-DcRyQ3eU.js → index-Dtw0abst.js} +1 -1
  103. package/web/assets/{index-Dy07SBfH.js → index-O05r2Ty6.js} +1 -1
  104. package/web/assets/{index-BCG8Wnc4.js → index-W3ErfZiX.js} +1 -1
  105. package/web/assets/{index-e-MxdHFO.js → index-Yc56b3XX.js} +1 -1
  106. package/web/assets/{index-Dff-DL1v.js → index-d4jCdYJH.js} +1 -1
  107. package/web/assets/{index-Dc8iMctf.js → index-gt5JBIFf.js} +1 -1
  108. package/web/assets/{index-Df9jregv.js → index-siHtlYTM.js} +1 -1
  109. package/web/assets/{invitePage-Dgl3-c_m.js → invitePage-Bgveo6Hj.js} +1 -1
  110. package/web/assets/{ipc-CNlIRMtU.js → ipc-B6hkgxQL.js} +1 -1
  111. package/web/assets/{jszip.min-tyV0GaJg.js → jszip.min-eU-k-vEy.js} +1 -1
  112. package/web/assets/{layout-grid-DFmwM9NU.js → layout-grid-CraV7nhh.js} +1 -1
  113. package/web/assets/linkFollow-BpvDWzUx.js +8 -0
  114. package/web/assets/{list-tree-i07HsP3D.js → list-tree-cLJw-jYQ.js} +1 -1
  115. package/web/assets/{listFold-Aea6I0Sa.js → listFold-M8s5JYEC.js} +1 -1
  116. package/web/assets/{lock-TSDKuCod.js → lock-DBkXXwaI.js} +1 -1
  117. package/web/assets/lock-open-C-9-AWct.js +1 -0
  118. package/web/assets/{log-out-DK84lW5n.js → log-out-C8bDXj9P.js} +1 -1
  119. package/web/assets/main-CMk6twzA.js +20 -0
  120. package/web/assets/markdownEditorSurface-DgQ0TUWH.js +3 -0
  121. package/web/assets/{message-square-plus-3wFslIMY.js → message-square-plus-8pfimvem.js} +1 -1
  122. package/web/assets/{messages-DEAGRsC3.js → messages-CKtabOqy.js} +1 -1
  123. package/web/assets/minus-CfA9fAN3.js +1 -0
  124. package/web/assets/mobileEntry-NcMcK0LV.js +13 -0
  125. package/web/assets/{nativeDownload-B3JGkABw.js → nativeDownload-CNtwSCy0.js} +1 -1
  126. package/web/assets/pageChrome-BR4cfIaA.js +1 -0
  127. package/web/assets/pageChrome-BbUhILy0.css +1 -0
  128. package/web/assets/{pageTree-DZ7Eiro-.js → pageTree-BYYPgZm_.js} +4 -4
  129. package/web/assets/{pen-tool-ChGmX6g_.js → pen-tool-C5ftHCnm.js} +1 -1
  130. package/web/assets/{pencil-CJsJD7M_.js → pencil-ehhM9_9k.js} +1 -1
  131. package/web/assets/phoneList-B6gwUJZF.js +9 -0
  132. package/web/assets/phoneList-iRdfiKA8.css +1 -0
  133. package/web/assets/pluginChat-DTTWWiUS.js +2 -0
  134. package/web/assets/{redo-2-CI57sDFr.js → redo-2-DCEAgQlN.js} +1 -1
  135. package/web/assets/{rotate-ccw-xgT_0UN9.js → rotate-ccw-DdkrbRAB.js} +1 -1
  136. package/web/assets/selectionActions-BQD2kox1.js +2 -0
  137. package/web/assets/selectionBarSurface-CzUZmJDJ.js +1 -0
  138. package/web/assets/server-Ddu9f1k3.js +1 -0
  139. package/web/assets/sharePage-CNrm2xTC.js +2 -0
  140. package/web/assets/{shareViewer-DKPWhTJv.js → shareViewer-BiMqIBxP.js} +2 -2
  141. package/web/assets/{star-C9KTji9N.js → star-Dxv7XANS.js} +1 -1
  142. package/web/assets/tableSurface-Bly1iCXc.js +1 -0
  143. package/web/assets/{terminal-DPZazOQ2.js → terminal-CAmmC9cV.js} +1 -1
  144. package/web/assets/{terminalView-CsJmxE_m.js → terminalView-lbcBgG0c.js} +1 -1
  145. package/web/assets/theme-CUWFlazV.css +1 -0
  146. package/web/assets/{type-C5J875vb.js → type-Dz6rnTvG.js} +1 -1
  147. package/web/assets/{undo-2-BOUt5qks.js → undo-2-B7izWNb_.js} +1 -1
  148. package/web/assets/{unitAccount-BIAIxKNp.js → unitAccount-DGwGsmC3.js} +1 -1
  149. package/web/assets/{unitBridge-b2C6zb3a.js → unitBridge-CE2yAvm0.js} +1 -1
  150. package/web/assets/{unitCloudTransport-NGtDDKWo.js → unitCloudTransport-BGFwkaDM.js} +1 -1
  151. package/web/assets/{unitOwnerAccess-CwH9ApZT.js → unitOwnerAccess-D4nKS6Gg.js} +1 -1
  152. package/web/assets/{unitShim-CY8EVkKD.js → unitShim-2_2hhGxS.js} +3 -3
  153. package/web/assets/{upload-CrbEAW8C.js → upload-DqpRRAhG.js} +1 -1
  154. package/web/assets/userSpaces-VFu4s05v.js +1 -0
  155. package/web/assets/viewportLock-3AOdDmwi.js +631 -0
  156. package/web/assets/viewportLock-djvL8fUQ.css +1 -0
  157. package/web/assets/{zoom-in-BcuPvIYd.js → zoom-in-Bf-eKTnH.js} +1 -1
  158. package/web/index.html +2 -2
  159. package/web/assets/ArtificialView-Bs_6B211.js +0 -1
  160. package/web/assets/AutomationBuilder-C-IFaaBp.js +0 -1
  161. package/web/assets/CalendarConfigView-DEsNvVkD.js +0 -1
  162. package/web/assets/DashboardGridView-hpRmBr9B.css +0 -1
  163. package/web/assets/DashboardGridView-tgaj9-SM.js +0 -17
  164. package/web/assets/ExcalidrawCanvas-NdV86AR3.js +0 -1
  165. package/web/assets/HomepageView-4joJWYlg.js +0 -1
  166. package/web/assets/HomepageView-Cxf3AWBu.css +0 -1
  167. package/web/assets/ImageStudioView-_CYHoOoG.js +0 -1
  168. package/web/assets/InlineFiles-BIfsx3R-.js +0 -1
  169. package/web/assets/MarkdownBlock--__nPQGh.css +0 -1
  170. package/web/assets/MarkdownBlock-wYEaBBOr.js +0 -58
  171. package/web/assets/ModelPill-DveHcLqq.js +0 -2
  172. package/web/assets/MuseLibraryView-Do9RnKiq.js +0 -2
  173. package/web/assets/PenRow-BSB-h5Pb.js +0 -1
  174. package/web/assets/ProductView-B96OeHOP.js +0 -1
  175. package/web/assets/RightPanel-BgSeCLnw.js +0 -4
  176. package/web/assets/RunLocationPicker-CEmFio4n.css +0 -1
  177. package/web/assets/RunLocationPicker-M1UoJyjf.js +0 -38
  178. package/web/assets/UnifiedPage-EJNWKzxN.js +0 -68
  179. package/web/assets/appStore-CidPWYa0.js +0 -3254
  180. package/web/assets/appStore-DeaC1U32.css +0 -1
  181. package/web/assets/automationListSource-1aOVKBLw.js +0 -1
  182. package/web/assets/codingNavigation-CCjs1kon.js +0 -53
  183. package/web/assets/codingNavigation-yp19w6uu.css +0 -1
  184. package/web/assets/dashboardSurface-BwcH16Qc.js +0 -1
  185. package/web/assets/emoji-DczIG8SO.js +0 -1
  186. package/web/assets/gestures-CXFaEydn.js +0 -1
  187. package/web/assets/i18n-DjziAw8r.css +0 -1
  188. package/web/assets/i18n.generated-BiQFRL2U.js +0 -15
  189. package/web/assets/imageStudio--KF9gwHA.css +0 -1
  190. package/web/assets/index-BqGpbntz.js +0 -1
  191. package/web/assets/linkFollow-iP2zfbA3.js +0 -8
  192. package/web/assets/main-D7CEGndC.js +0 -20
  193. package/web/assets/markdownEditorSurface-DISu_twy.js +0 -3
  194. package/web/assets/minus-BBdfT_sc.js +0 -1
  195. package/web/assets/mobileEntry-5UaAITwY.js +0 -13
  196. package/web/assets/pageChrome-BDHHmRnt.css +0 -1
  197. package/web/assets/pageChrome-DFi9zs6F.js +0 -1
  198. package/web/assets/phoneList-DrxIwJxQ.js +0 -9
  199. package/web/assets/phoneList-DvpzD3zT.css +0 -1
  200. package/web/assets/pluginChat-0QI9a8Q1.js +0 -2
  201. package/web/assets/sharePage-C2Yqx0NQ.js +0 -2
  202. package/web/assets/tableSurface-cYs6dX6B.js +0 -1
  203. package/web/assets/theme-Dgqst5S9.css +0 -1
  204. package/web/assets/userSpaces-B_Njvel_.js +0 -1
  205. package/web/assets/viewportLock-Bi3orrUs.css +0 -1
  206. package/web/assets/viewportLock-DZ927PNz.js +0 -629
  207. package/web/assets/workflow-DY2Cnaei.js +0 -1
@@ -0,0 +1,17 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./PageHistoryPanel-Bn4-XmdK.js","./index-BOzsniE1.js","./appStore-CI1_L5OS.js","./nativeDownload-CNtwSCy0.js","./ipc-B6hkgxQL.js","./client-CaivGZFR.js","./appStore-DQc2marq.css","./create-1JI2I47p.js","./create-BgE3edmZ.css","./UnifiedPage-BWAyqj65.js","./MarkdownBlock-DT_wsaja.js","./index-DjnTfJpN.js","./linkFollow-BpvDWzUx.js","./selectionActions-BQD2kox1.js","./emoji-DphwSxPx.js","./emoji-DZ9CA_3l.css","./listFold-M8s5JYEC.js","./book-open-BLzEdGfu.js","./MarkdownBlock-DQTuoen3.css","./pageChrome-BR4cfIaA.js","./upload-DqpRRAhG.js","./pageChrome-BbUhILy0.css","./SketchCard-B_UU5sxV.js","./arrow-up-right-BDsMFoNQ.js","./Chrome-CFonajM4.js","./minus-CfA9fAN3.js","./canvasPrefs-CvE7mgyq.js","./hand-XNkzNiW2.js","./type-Dz6rnTvG.js","./InlineAiPanel-B3kd1ob2.js","./InlineAiPanel-DZZijfif.css","./foldActions-DNbJPlPl.js","./lock-DBkXXwaI.js","./undo-2-B7izWNb_.js","./code-xml-AE3mT4T5.js","./message-square-plus-8pfimvem.js","./UnifiedPage-CWXc_mo1.css","./FloatingToc-DNqAkkI0.js","./pageTree-BYYPgZm_.js","./pluginExt-Byb64tQO.js","./phoneList-B6gwUJZF.js","./phoneList-iRdfiKA8.css","./list-tree-cLJw-jYQ.js","./pen-tool-C5ftHCnm.js","./pencil-ehhM9_9k.js","./star-Dxv7XANS.js","./folder-plus-aJgL9NeP.js","./redo-2-DCEAgQlN.js","./folder-DotgUhYD.js","./layout-grid-CraV7nhh.js","./PageHistoryPanel-DFjh0pWs.css"])))=>i.map(i=>d[i]);
2
+ import{cj as Da,ck as On,r as Ne,j as e,u as he,d as c,cl as Pi,cm as Ra,bF as Ti,n as Ei,bQ as Fa,t as _,_ as Di,W as Ri,c4 as Fi,au as Mi,m as zt,x as Bs,aj as cn,cn as us,c2 as $i,c3 as Oi,aW as Li,aG as Ii,b7 as Ai,aL as Vs,aO as Bi}from"./index-BOzsniE1.js";import{J as dt,ch as Yt,a1 as Xt,j9 as gn,u as Ve,b as I,dd as te,V as ks,ge as rt,fW as Pe,mf as Xe,fv as Me,rD as Ma,pg as Vi,t as $e,mB as _i,rE as Wi,gG as Ui,cf as Hi,rF as qi,rG as Ki,rH as Gi,rI as Yi,aR as wt,pi as Xi,fz as $a,m9 as Ji,lg as Ss,l6 as Oa,rJ as Zi,go as La,gv as Ns,pl as Un,rK as Ia,fV as Ft,rL as Aa,g7 as Ba,l2 as hs,l5 as Qi,rM as eo,gb as Va,rN as _a,l8 as Wa,ry as to,lf as Ua,rO as no,a9 as vt,aM as zs,W as Ha,e4 as Cs,bK as Ut,bw as Ye,aq as Et,dw as so,hS as ao,rP as Ht,jC as qa,gB as Vt,ba as io,dz as Ps,gR as Ka,fU as Ts,rQ as oo,m4 as ro,hL as lo,m as co,h$ as uo,h as ho,gF as mo,cM as ms,bX as qt,fe as Ga,aA as Dt,fu as hn,ci as xt,fD as Fn,aL as It,fE as Zn,gA as ft,rR as _s,j3 as Ws,fF as Us,N as kn,ie as Qn,o$ as Hs,am as po,aB as Jt,p0 as fo,a0 as go,fy as Sn,oU as xo,oT as vo,aH as wo,gs as bo,fZ as Kt,rS as yo,gt as Ya,cg as es,rT as qs,rU as Ks,cA as Gs,rV as jo,rW as ko,fH as Ct,fp as Nn,i1 as So,gK as Ys,nu as No,ii as ts,i$ as zo,j4 as Co,ow as Po,cD as To,fj as Eo,j0 as Do,rX as Ro,rY as Fo,j as Xa,ma as Ja,rZ as Mo,r_ as $o,r$ as Oo,s0 as Lo,s1 as Io,be as Ao,pb as Bo,pc as Vo,s as ps,s2 as _o,s3 as Wo,fR as Gt,s4 as Uo,s5 as Ho,s6 as qo,s7 as Ko,s8 as Go,s9 as Xs,kK as Za,sa as Js,gj as Qa,je as Yo,jf as Xo,ad as Jo,gi as ze,ae as mn,fX as Mn,sb as ns,U as Zo,sc as Zs,sd as Qs,fY as ss,gk as as,se as Qo,sf as ea,sg as er,sh as ta,si as tr,gl as is,sj as os,sk as nr,sl as sr,g5 as ar,ax as na,sm as ir,gn as Pt,sn as fs,so as an,sp as on,sq as at,b4 as gs,gM as or,g9 as rr,sr as lr,ss as cr,st as dr,su as ur,g6 as sa,sv as hr,sw as mr,sx as pr,sy as fr,sz as gr,sA as xr,sB as vr,lh as wr,gd as br,sC as zn,sD as yr,sE as jr,sF as kr}from"./appStore-CI1_L5OS.js";import"./client-CaivGZFR.js";import{e as ei,g as Es,h as Sr,M as ti,C as Nr,S as zr,U as Cr,A as Pr,d as Tr,i as Er}from"./UnifiedPage-BWAyqj65.js";import{F as Dr}from"./FloatingToc-DNqAkkI0.js";import{ab as Rr,ac as Fr,a8 as ni,ad as Mr,h as $r}from"./MarkdownBlock-DT_wsaja.js";import{u as Or,S as Lr,r as Ir,I as Ar,C as Br,N as Vr,U as _r}from"./pageChrome-BR4cfIaA.js";import{m as Wr,b as Ur,r as aa}from"./pageTree-BYYPgZm_.js";import{normalizePluginRename as Hr}from"./pluginExt-Byb64tQO.js";import{c as Qt}from"./nativeDownload-CNtwSCy0.js";import{m as Hn,h as qr,b as Kr,c as Gr,i as Yr,j as Xr,d as Jr,w as Zr,x as Qr,S as At,L as el,e as tl,P as xs,t as ia,g as nl,k as sl,l as al,f as oa,s as il,o as ol,v as rl,u as ll,A as ra,C as si}from"./phoneList-B6gwUJZF.js";import{L as cl}from"./list-tree-cLJw-jYQ.js";import{P as rn}from"./pen-tool-C5ftHCnm.js";import{P as dn}from"./pencil-ehhM9_9k.js";import{S as Ln}from"./star-Dxv7XANS.js";import{B as ai}from"./book-open-BLzEdGfu.js";import{F as la}from"./folder-plus-aJgL9NeP.js";import{U as vs}from"./upload-DqpRRAhG.js";import{F as dl,T as ii}from"./type-Dz6rnTvG.js";import{U as ul}from"./undo-2-B7izWNb_.js";import{R as hl,F as Cn}from"./redo-2-DCEAgQlN.js";import{C as rs}from"./code-xml-AE3mT4T5.js";import{L as ca}from"./lock-DBkXXwaI.js";import{F as Ds}from"./folder-DotgUhYD.js";import{L as Bt}from"./layout-grid-CraV7nhh.js";const ml=[["path",{d:"m15 16 2.536-7.328a1.02 1.02 1 0 1 1.928 0L22 16",key:"xik6mr"}],["path",{d:"M15.697 14h5.606",key:"1stdlc"}],["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}]],oi=dt("a-large-small",ml);const pl=[["path",{d:"M10 2v8l3-3 3 3V2",key:"sqw3rj"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]],fl=dt("book-marked",pl);const gl=[["path",{d:"M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057",key:"1uxyv8"}],["path",{d:"M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78",key:"99tcn7"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],ws=dt("cloud-off",gl);const xl=[["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}],["path",{d:"M15.947 12.65a4 4 0 0 0-5.925-4.128",key:"dpwdj0"}],["path",{d:"M13 22H7a5 5 0 1 1 4.9-6H13a3 3 0 0 1 0 6Z",key:"s09mg5"}]],vl=dt("cloud-sun",xl);const wl=[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]],bl=dt("heading",wl);const yl=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],Pn=dt("layout-dashboard",yl);const jl=[["path",{d:"M21 5H11",key:"us1j55"}],["path",{d:"M21 12H11",key:"wd7e0v"}],["path",{d:"M21 19H11",key:"saa85w"}],["path",{d:"m7 8-4 4 4 4",key:"o5hrat"}]],kl=dt("list-indent-decrease",jl);const Sl=[["path",{d:"M21 5H11",key:"us1j55"}],["path",{d:"M21 12H11",key:"wd7e0v"}],["path",{d:"M21 19H11",key:"saa85w"}],["path",{d:"m3 8 4 4-4 4",key:"1a3j6y"}]],Nl=dt("list-indent-increase",Sl);const zl=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],In=dt("share-2",zl);const Cl=[["path",{d:"m10.344 4.688 1.181-2.393a.53.53 0 0 1 .95 0l2.31 4.679a2.12 2.12 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.237 3.152",key:"19ctli"}],["path",{d:"m17.945 17.945.43 2.505a.53.53 0 0 1-.771.56l-4.618-2.428a2.12 2.12 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.12 2.12 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a8 8 0 0 0 .4-.099",key:"ptqqvy"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Pl=dt("star-off",Cl);let da=0;const Oe=Qt(t=>({vaults:[],activeRoot:null,mirrorVaults:[],status:{},async refresh(){const n=++da,s=window.amadeusSync;if(s?.entrySyncGet)try{const i=await s.entrySyncGet();if(n!==da)return;t({vaults:i.vaults,activeRoot:i.activeRoot,mirrorVaults:i.mirrorVaults??[]})}catch{}}}));let ua=!1;function ri(){if(ua)return;ua=!0;const t=window.amadeusSync;Oe.getState().refresh(),t?.onEntrySyncChange?.(()=>{Oe.getState().refresh()}),t?.onStatus?.(n=>{const s=n.binding;s&&Oe.setState(i=>({status:{...i.status,[s]:n}}))})}function xn(t,n){if(!t)return!1;const s=Oe.getState().vaults.find(i=>i.vaultRoot===t);return!!s&&Da(s.entries,s.exclude,n)}function Rs(t,n,s,i){if(!window.amadeusSync||s==="cloud")return On(i);if(!n)return null;const l=t.find(o=>o.vaultRoot===n);return!l||!Da(l.entries,l.exclude,i)?null:`${l.cloudName}/${On(i)}`}function Tl(t,n){const s=t?Oe.getState().vaults.find(l=>l.vaultRoot===t):null;if(!s?.exclude?.length)return!1;const i=On(n);return s.exclude.some(l=>{const o=On(l);return!!o&&(i===o||i.startsWith(`${o}/`)||i.startsWith(`${o.replace(/\.md$/i,"")}.fd/`))})}let un=null;function bs(){return un===null&&(un=!0,window.tangu?.getConfig?.().then(t=>{un=t?.notesUpgradeV4!==!1}).catch(()=>{})),un}function iu(t){un=t}bs();Ne({"csd.title":{zh:"开启云同步",en:"Turn on cloud sync"},"csd.failed":{zh:"开启云同步失败",en:"Could not turn on cloud sync"},"csd.enabled":{zh:"已开启云同步:云端「{name}」",en:"Cloud sync is on — cloud folder “{name}”"},"csd.selectAll":{zh:"全选",en:"Select all"},"csd.selectNone":{zh:"全不选",en:"Deselect all"},"csd.conflictMsg":{zh:"云端智库根目录已有「{name}」。可以换一个云端文件夹名,或把本智库的同步内容合并进现有文件夹(换机后重新开启同步时选「合并」)。",en:"The cloud workspace root already has a folder called “{name}”. Pick a different name for the cloud folder, or merge this vault’s synced content into the existing one (choose Merge when you turn sync back on after switching machines)."},"csd.newNamePlaceholder":{zh:"新的云端文件夹名",en:"New cloud folder name"},"csd.cancel":{zh:"取消",en:"Cancel"},"csd.mergeInto":{zh:"合并进「{name}」",en:"Merge into “{name}”"},"csd.useNewName":{zh:"用新名字开启",en:"Use new name"},"csd.intro":{zh:"「{name}」将带完整相对路径同步到云端智库(双向)。子页面与库内关联默认一并纳入,保留智库里的相对位置;取消勾选即不同步:",en:"“{name}” will sync to the cloud workspace with its full relative path (two-way). Subpages and in-vault links are included by default and keep their position in the vault; uncheck anything you do not want synced:"},"csd.analyzing":{zh:"正在分析关联…",en:"Analyzing links…"},"csd.groupSubPages":{zh:"子页面",en:"Subpages"},"csd.groupLinkedPages":{zh:"关联笔记",en:"Linked notes"},"csd.groupAssets":{zh:"附件",en:"Attachments"},"csd.nothingElse":{zh:"没有子页面与库内关联,仅同步此条目。",en:"No subpages or in-vault links — only this item will sync."},"csd.enabling":{zh:"开启中…",en:"Turning on…"},"csd.enable":{zh:"开启同步",en:"Turn on sync"}});const ys=Qt(t=>({req:null,open:n=>t({req:n}),close:()=>t({req:null})}));function Rt(t,n){ys.getState().open({path:t,kind:n})}const ha=t=>(t.split(/[\\/]/).pop()??t).replace(/\.md$/i,"");function ou(){const t=ys(n=>n.req);return t?e.jsx("div",{className:"am-app tangu-lovable",style:{display:"contents"},children:e.jsx(El,{req:t,onClose:()=>ys.getState().close()},`${t.kind}:${t.path}`)}):null}function El({req:t,onClose:n}){const{t:s}=he(),[i,l]=c.useState(null),[o,r]=c.useState(new Set),[u,f]=c.useState(new Set),[h,j]=c.useState(new Set),[m,y]=c.useState(!1),[p,x]=c.useState(null),[O,T]=c.useState("");c.useEffect(()=>{let k=!0;if(t.kind==="asset"){l({pages:[],files:[],subPages:[]});return}return window.amadeusSync?.entrySyncClosure?.(t.path,t.kind).then($=>{if(!k)return;l({...$,subPages:$.subPages??[]}),r(new Set($.pages)),f(new Set($.files));const D=Oe.getState().activeRoot;j(new Set(($.subPages??[]).filter(K=>!Tl(D,K))))}).catch(()=>k&&l({pages:[],files:[],subPages:[]})),()=>{k=!1}},[t.path,t.kind]);const G=async k=>{const $=window.amadeusSync;if(!$?.entrySyncEnable||m)return;y(!0);const D=[{path:t.path,kind:t.kind},...[...o].map(re=>({path:re,kind:"page"})),...[...u].map(re=>({path:re,kind:"asset"}))],K=i?.subPages??[],Z=K.filter(re=>!h.has(re)),ce=K.filter(re=>h.has(re)),U=await $.entrySyncEnable({entries:D,exclude:Z,include:ce,...k}).catch(re=>({error:String(re)}));if(y(!1),U?.conflict){x(U.conflict),T(`${U.conflict} 2`);return}if(U?.error||!U?.ok){Ve.getState().toast(U?.error||s("csd.failed"),!0);return}Ve.getState().toast(s("csd.enabled",{name:U.cloudName??""})),Oe.getState().refresh(),n()},S=k=>{const $=[];for(let D=k;;){const K=D.lastIndexOf(".fd/");if(K<0)return $;D=`${D.slice(0,K)}.md`,$.push(D)}},M=k=>j($=>{const D=!$.has(k),K=i?.subPages??[],Z=`${k.replace(/\.md$/i,"")}.fd/`,ce=new Set($);for(const U of K)U!==k&&!U.startsWith(Z)||(D?ce.add(U):ce.delete(U));if(D)for(const U of S(k))K.includes(U)&&ce.add(U);return ce}),R=(k,$)=>{const D=new Set(k);return D.has($)?D.delete($):D.add($),D},z=(k,$,D,K,Z,ce)=>D.length>0&&e.jsxs("div",{className:"amx-csd-group",children:[e.jsxs("div",{className:"amx-csd-head",children:[k,e.jsxs("span",{children:[$,"(",K.size,"/",D.length,")"]}),e.jsx("button",{className:"amx-csd-all",onClick:()=>ce(K.size<D.length),children:K.size<D.length?s("csd.selectAll"):s("csd.selectNone")})]}),e.jsx("div",{className:"amx-csd-list",children:D.map(U=>e.jsxs("label",{className:"amx-csd-item",title:U,children:[e.jsx("input",{type:"checkbox",checked:K.has(U),onChange:()=>Z(U)}),e.jsx("span",{children:ha(U)}),e.jsx("span",{className:"amx-csd-path",children:U})]},U))})]});return e.jsx("div",{className:"dialog-overlay",onMouseDown:n,children:e.jsxs("div",{className:"dialog amx-csd",onMouseDown:k=>k.stopPropagation(),children:[e.jsxs("div",{className:"dialog-title",children:[e.jsx(Yt,{size:15,style:{verticalAlign:-2,marginRight:6}}),s("csd.title")]}),p?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"dialog-msg",children:s("csd.conflictMsg",{name:p})}),e.jsx("input",{className:"dialog-input",value:O,onChange:k=>T(k.target.value),placeholder:s("csd.newNamePlaceholder"),onKeyDown:k=>{k.key==="Enter"&&O.trim()&&G({cloudName:O.trim()}),k.key==="Escape"&&n()}}),e.jsxs("div",{className:"dialog-actions",children:[e.jsx("button",{className:"dialog-btn",onClick:n,children:s("csd.cancel")}),e.jsx("button",{className:"dialog-btn",disabled:m,onClick:()=>{G({cloudName:p,merge:!0})},children:s("csd.mergeInto",{name:p})}),e.jsx("button",{className:"dialog-btn","data-primary":!0,disabled:m||!O.trim(),onClick:()=>{G({cloudName:O.trim()})},children:s("csd.useNewName")})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"dialog-msg",children:s("csd.intro",{name:ha(t.path)})}),i===null?e.jsx("div",{className:"dialog-msg",children:s("csd.analyzing")}):e.jsxs(e.Fragment,{children:[z(e.jsx(cl,{size:12}),s("csd.groupSubPages"),i.subPages,h,M,k=>j(k?new Set(i.subPages):new Set)),z(e.jsx(Xt,{size:12}),s("csd.groupLinkedPages"),i.pages,o,k=>r($=>R($,k)),k=>r(k?new Set(i.pages):new Set)),z(e.jsx(gn,{size:12}),s("csd.groupAssets"),i.files,u,k=>f($=>R($,k)),k=>f(k?new Set(i.files):new Set)),!i.pages.length&&!i.files.length&&!i.subPages.length&&e.jsx("div",{className:"dialog-msg",style:{opacity:.6},children:s("csd.nothingElse")})]}),e.jsxs("div",{className:"dialog-actions",children:[e.jsx("button",{className:"dialog-btn",onClick:n,children:s("csd.cancel")}),e.jsx("button",{className:"dialog-btn","data-primary":!0,disabled:m||i===null,onClick:()=>{G()},children:s(m?"csd.enabling":"csd.enable")})]})]})]})})}const Dl=t=>Pi(t).filter(n=>!/^(?:app|window):\/\//i.test(n));function ma(t,n){const s=o=>`${o.ghost?"g:":""}${o.path}`,i=t.map(s).sort(),l=n.map(o=>{const r=s(t[o.a]),u=s(t[o.b]);return r<u?`${r}>${u}`:`${u}>${r}`}).sort();return`${i.join("|")}::${l.join("|")}`}Ne({"amxpanel.searchHead":{zh:"全文搜索",en:"Full-text search"},"amxpanel.searchPlaceholder":{zh:"搜索全部笔记…",en:"Search all notes…"},"amxpanel.saveCollection":{zh:"存为集合",en:"Save as collection"},"amxpanel.saveCollectionTip":{zh:"存为集合(左栏可一键回放这次搜索)",en:"Save as a collection (replay this search from the sidebar in one click)"},"amxpanel.saveCollectionHint":{zh:"集合会出现在左栏,点击即重放这次搜索。",en:"The collection shows up in the sidebar — click it to replay this search."},"amxpanel.noVault":{zh:"先打开一个智库。",en:"Open a vault first."},"amxpanel.searchEmpty":{zh:"输入关键词,搜遍全部笔记内容。",en:"Type a keyword to search the contents of every note."},"amxpanel.noResults":{zh:"无结果",en:"No results"},"amxpanel.tagsHead":{zh:"标签 · {n}",en:"Tags · {n}"},"amxpanel.tagsEmpty":{zh:"还没有 #标签。在笔记里写 #灵感 这样的行内标签即可出现在这里。",en:"No #tags yet. Write an inline tag like #idea in a note and it will show up here."},"amxpanel.graphHead":{zh:"关系图 · 当前笔记",en:"Graph · current note"},"amxpanel.graphNoNote":{zh:"未打开笔记",en:"No note open"},"amxpanel.graphEmpty":{zh:"这篇笔记还没有链接(出链 [[…]] 或反链)。",en:"This note has no links yet — no outgoing [[…]] links and no backlinks."}});const An=()=>I.getState(),js=t=>(t.split(/[\\/]/).pop()??t).replace(/\.md$/i,""),li=Qt(t=>({seed:null,request:n=>t(s=>({seed:{q:n,n:(s.seed?.n??0)+1}}))}));function ru(){const{t}=he(),n=I(h=>h.vaultRoot),[s,i]=c.useState(""),l=li(h=>h.seed);c.useEffect(()=>{l&&i(l.q)},[l]);const[o,r]=c.useState([]),u=c.useRef(0);c.useEffect(()=>{An().flushSave()},[]),c.useEffect(()=>{const h=s.trim();if(!h){r([]);return}const j=++u.current,m=setTimeout(()=>{te.search(h).then(y=>{j===u.current&&r(y)})},120);return()=>clearTimeout(m)},[s]);const f=(h,j)=>{const m=s.trim().toLowerCase();Me(h.path,j).then(()=>{if(!m)return;const y=Object.values(An().blocks).find(p=>Ra(p.content).toLowerCase().includes(m));requestAnimationFrame(()=>{const p=y?document.querySelector(`[data-block-id="${y.id}"]`):null;if(p){p.scrollIntoView({behavior:"smooth",block:"center"}),p.classList.add("amx-block-flash"),setTimeout(()=>p.classList.remove("amx-block-flash"),1300);return}const x=m.split(/[\s\-_/.]+/).filter(Boolean);Ma(h.path,x.length>1?[m,...x]:[m])})})};return e.jsxs("div",{className:"amx-panel",children:[e.jsx("div",{className:"amx-panel-head",children:t("amxpanel.searchHead")}),e.jsxs("div",{className:"t2s-search amx-search-box",children:[e.jsx(ks,{size:13,className:"t2s-dim"}),e.jsx("input",{autoFocus:!0,value:s,placeholder:t("amxpanel.searchPlaceholder"),onChange:h=>i(h.target.value)}),s.trim()&&e.jsx("button",{className:"amx-search-save",title:t("amxpanel.saveCollectionTip"),onClick:()=>{rt(t("amxpanel.saveCollection"),s.trim(),{label:t("amxpanel.saveCollectionHint")}).then(h=>{const j=h?.trim();j&&Pe.getState().saveCollection(j,s.trim())})},children:t("amxpanel.saveCollection")})]}),n?s.trim()?o.length===0?e.jsx("div",{className:"amx-panel-empty",children:t("amxpanel.noResults")}):e.jsx("div",{className:"amx-list",children:o.map(h=>e.jsxs("button",{className:"amx-list-item",onClick:j=>f(h,Xe(j)),title:h.path,children:[h.title,h.snippet&&e.jsx("span",{className:"amx-backlink-snippet amx-search-snippet",children:Rl(h.snippet,s.trim())})]},h.path))}):e.jsx("div",{className:"amx-panel-empty",children:t("amxpanel.searchEmpty")}):e.jsx("div",{className:"amx-panel-empty",children:t("amxpanel.noVault")})]})}function Rl(t,n){if(!n)return t;const s=t.toLowerCase().indexOf(n.toLowerCase());return s<0?t:e.jsxs(e.Fragment,{children:[t.slice(0,s),e.jsx("mark",{children:t.slice(s,s+n.length)}),t.slice(s+n.length)]})}const ci=Qt(t=>({seed:null,request:n=>t(s=>({seed:{tag:n,n:(s.seed?.n??0)+1}}))}));function lu(t){ci.getState().request(t.replace(/^#/,""));const n=$e.getState();n.showSideView("left","amadeus-tags");const s=$e.getState(),i=s.api;s.leftVisible&&!i?.panels.some(l=>l.params?.__type==="amadeus-tags")&&n.openView("amadeus-tags",{},"left")}function cu(){const{t}=he(),n=I(m=>m.vaultRoot),s=I(m=>m.linkGraphVersion),[i,l]=c.useState([]),[o,r]=c.useState(null),[u,f]=c.useState([]),h=ci(m=>m.seed);c.useEffect(()=>{h&&r(h.tag)},[h]);const j=o&&!i.some(m=>m.tag.toLowerCase()===o.toLowerCase())?[{tag:o,count:u.length},...i]:i;return c.useEffect(()=>{let m=!0;if(!n){l([]);return}return te.listTags().then(y=>{m&&l(y)}),()=>{m=!1}},[n,s]),c.useEffect(()=>{let m=!0;if(!o){f([]);return}return te.pagesByTag(o).then(y=>{m&&f(y)}),()=>{m=!1}},[o,s]),e.jsxs("div",{className:"amx-panel",children:[e.jsx("div",{className:"amx-panel-head",children:t("amxpanel.tagsHead",{n:i.length})}),n?j.length===0?e.jsx("div",{className:"amx-panel-empty",children:t("amxpanel.tagsEmpty")}):e.jsx("div",{className:"amx-list",children:j.map(m=>e.jsxs("div",{children:[e.jsxs("button",{className:`amx-list-item amx-tag${o===m.tag?" active":""}`,ref:o===m.tag&&h?y=>y?.scrollIntoView({block:"nearest"}):void 0,onClick:()=>r(y=>y===m.tag?null:m.tag),children:[e.jsxs("span",{className:"amx-tag-name",children:["#",m.tag]}),e.jsx("span",{className:"amx-tag-count",children:m.count})]}),o===m.tag&&u.map(y=>e.jsx("button",{className:"amx-list-item amx-tag-page",onClick:p=>{Me(y,Xe(p)).then(()=>Ma(y,[`#${m.tag}`],{tag:!0}))},title:y,children:js(y)},y))]},m.tag))}):e.jsx("div",{className:"amx-panel-empty",children:t("amxpanel.noVault")})]})}const _t=320,Wt=280,pn=(t,n,s)=>Math.min(s,Math.max(n,t));function Fl(t,n,s){const i=_t/2,l=Wt/2;for(let o=0;o<t.length;o++){const r=t[o];if(r.pinned)continue;let u=(i-r.x)*.005,f=(l-r.y)*.005;for(let h=0;h<t.length;h++){if(o===h)continue;const j=t[h],m=r.x-j.x,y=r.y-j.y,p=Math.max(64,m*m+y*y),x=1400/p;u+=m/Math.sqrt(p)*x,f+=y/Math.sqrt(p)*x}for(const h of n){if(h.a!==o&&h.b!==o)continue;const j=t[h.a===o?h.b:h.a],m=j.x-r.x,y=j.y-r.y,p=Math.max(1,Math.hypot(m,y)),x=(p-86)*.02;u+=m/p*x,f+=y/p*x}r.vx=(r.vx+u*s*2)*.82,r.vy=(r.vy+f*s*2)*.82,r.x=pn(r.x+r.vx,16,_t-16),r.y=pn(r.y+r.vy,16,Wt-16)}}function du(){const{t}=he(),n=I(z=>z.activePage??z.activeNotePath),s=I(z=>z.linkGraphVersion),[i,l]=c.useState(null),[,o]=c.useState(0),[r,u]=c.useState(null),[f,h]=c.useState({x:0,y:0,k:1}),j=c.useRef(null),m=c.useRef(i);m.current=i;const y=c.useRef(f);y.current=f;const p=c.useRef({alpha:0,raf:0,dragging:!1}),x=c.useRef(!1),O=()=>{if(p.current.raf)return;const z=()=>{const k=m.current,$=p.current;if(!k){$.raf=0;return}Fl(k.nodes,k.edges,$.alpha),$.dragging||($.alpha-=.006),o(D=>D+1),$.alpha>.02||$.dragging?$.raf=requestAnimationFrame(z):$.raf=0};p.current.raf=requestAnimationFrame(z)};c.useEffect(()=>()=>{p.current.raf&&cancelAnimationFrame(p.current.raf)},[]);const T=(z,k)=>{const $=j.current?.getScreenCTM();if(!$)return null;const D=new DOMPoint(z,k).matrixTransform($.inverse());return{x:D.x,y:D.y}},G=(z,k)=>{const $=T(z,k);if(!$)return null;const D=y.current;return{x:($.x-D.x)/D.k,y:($.y-D.y)/D.k}};c.useEffect(()=>{let z=!0;if(!n){l(null),m.current=null;return}return m.current?.nodes[0]?.path!==n&&(m.current=null,l(null)),(async()=>{const k=await te.backlinks(n).catch(()=>[]);if(!z)return;const $=An(),D=await te.readTextFile(n).catch(()=>null);if(!z)return;const K=Ra(Ti(D??"")),Z=[],ce=[],U=new Set;for(const ie of Dl(K)){const ne=Ei(ie,$.pages,n);ne?ne!==n&&!Z.includes(ne)&&Z.push(ne):U.has(ie.toLowerCase())||(U.add(ie.toLowerCase()),Vi(ie,$.files,n)||ce.push(ie))}const re=[...new Set([...Z,...k.map(ie=>ie.path).filter(ie=>ie!==n)])],we=[...re,...ce],Fe=[{path:n,label:js(n),center:!0,x:_t/2,y:Wt/2,vx:0,vy:0,pinned:!0},...we.map((ie,ne)=>{const xe=ne/Math.max(1,we.length)*Math.PI*2,ke=ne>=re.length;return{path:ie,label:ke?ie:js(ie),center:!1,ghost:ke,x:_t/2+Math.cos(xe)*90,y:Wt/2+Math.sin(xe)*90,vx:0,vy:0,pinned:!1}})],ge=new Map(Fe.slice(0,1+re.length).map((ie,ne)=>[ie.path,ne])),X=[],pe=new Set;for(const ie of[...Z,...k.map(ne=>ne.path)]){const ne=ge.get(ie);ne===void 0||pe.has(ie)||(pe.add(ie),X.push({a:0,b:ne}))}for(let ie=0;ie<ce.length;ie++)X.push({a:0,b:1+re.length+ie});if(!z)return;const ue={nodes:Fe,edges:X},N=m.current;if(!(N&&ma(N.nodes,N.edges)===ma(ue.nodes,ue.edges))){if(N?.nodes[0]?.path===n){const ie=new Map(N.nodes.map(ne=>[`${ne.ghost?"g:":""}${ne.path}`,ne]));for(const ne of ue.nodes){const xe=ie.get(`${ne.ghost?"g:":""}${ne.path}`);xe&&(ne.x=xe.x,ne.y=xe.y,ne.vx=xe.vx,ne.vy=xe.vy)}}m.current=ue,l(ue),u(null),p.current.alpha=N?.38:1,O()}})(),()=>{z=!1}},[n,s]);const S=z=>k=>{if(k.button!==0)return;k.stopPropagation();const $=m.current;if(!$)return;const D=$.nodes[z],K=D.pinned;D.pinned=!0,x.current=!1,p.current.dragging=!0,p.current.alpha=Math.max(p.current.alpha,.6),O();const Z=U=>{const re=G(U.clientX,U.clientY);re&&(x.current=!0,D.x=pn(re.x,16,_t-16),D.y=pn(re.y,16,Wt-16),D.vx=0,D.vy=0,p.current.alpha=Math.max(p.current.alpha,.6))},ce=()=>{window.removeEventListener("pointermove",Z),window.removeEventListener("pointerup",ce),D.pinned=K,p.current.dragging=!1,p.current.alpha=Math.max(p.current.alpha,.5),O()};window.addEventListener("pointermove",Z),window.addEventListener("pointerup",ce)},M=z=>{if(z.button!==0||z.target!==z.currentTarget)return;const k=T(z.clientX,z.clientY);if(!k)return;const $=y.current,D=Z=>{const ce=T(Z.clientX,Z.clientY);ce&&h({k:$.k,x:$.x+(ce.x-k.x),y:$.y+(ce.y-k.y)})},K=()=>{window.removeEventListener("pointermove",D),window.removeEventListener("pointerup",K)};window.addEventListener("pointermove",D),window.addEventListener("pointerup",K)},R=!!i&&i.nodes.length>1;return c.useEffect(()=>{const z=j.current;if(!z||!R)return;const k=$=>{$.preventDefault();const D=T($.clientX,$.clientY);if(!D)return;const K=y.current,Z=pn(K.k*Math.exp(-$.deltaY*.0022),.4,3),ce=(D.x-K.x)/K.k,U=(D.y-K.y)/K.k;h({k:Z,x:D.x-ce*Z,y:D.y-U*Z})};return z.addEventListener("wheel",k,{passive:!1}),()=>z.removeEventListener("wheel",k)},[R]),e.jsxs("div",{className:"amx-panel",children:[e.jsx("div",{className:"amx-panel-head",children:t("amxpanel.graphHead")}),n?!i||!R?e.jsx("div",{className:"amx-panel-empty",children:t("amxpanel.graphEmpty")}):e.jsx("svg",{ref:j,className:"amx-graph",viewBox:`0 0 ${_t} ${Wt}`,onPointerDown:M,onDoubleClick:()=>h({x:0,y:0,k:1}),children:e.jsxs("g",{transform:`translate(${f.x} ${f.y}) scale(${f.k})`,children:[i.edges.map((z,k)=>e.jsx("line",{x1:i.nodes[z.a].x,y1:i.nodes[z.a].y,x2:i.nodes[z.b].x,y2:i.nodes[z.b].y,className:`amx-graph-edge${r!==null?z.a===r||z.b===r?" hl":" dim":""}`},k)),i.nodes.map((z,k)=>{const $=r===null||k===r||i.edges.some(D=>D.a===r&&D.b===k||D.b===r&&D.a===k);return e.jsxs("g",{className:`amx-graph-node${z.center?" center":""}${z.ghost?" ghost":""}${r!==null?$?" hl":" dim":""}`,onPointerDown:S(k),onPointerEnter:()=>u(k),onPointerLeave:()=>u(null),onClick:D=>{x.current||z.center||(z.ghost?An().openWikiLink(z.path):Me(z.path,Xe(D)))},children:[e.jsx("circle",{cx:z.x,cy:z.y,r:z.center?8:5.5}),e.jsx("text",{x:z.x,y:z.y+(z.center?20:16),textAnchor:"middle",children:z.label.length>12?`${z.label.slice(0,12)}…`:z.label})]},z.ghost?`g:${z.path}`:z.path)})]})}):e.jsx("div",{className:"amx-panel-empty",children:t("amxpanel.graphNoNote")})]})}const Ml=t=>/\.md$/i.test(t);function $l(t){const n=t.replace(/\.md$/i,""),s=n.split(/[\\/]/).pop()||n;return n===s?n:`${n}|${s}`}function Ol(t){return _i(t).filter(n=>n.kind==="note").map(n=>Ml(n.path)?`[[${$l(n.path)}]]`:`![[${n.path}]]`)}const Ll=/[^./\\]\.[^./\\]+\.md$/;function Il(t,n){if(!t||!Ll.test(t)||n.pages.includes(t))return"note";if(n.filesPendingFor!=null&&n.filesPendingFor===n.vaultRoot)return"pending";const s=t.replace(/\\/g,"/");return n.files.some(i=>i.replace(/\\/g,"/")===s)?"plugin":"note"}Ne({"unilock.failed.lock":{zh:"没能锁定「{name}」:{reason}。页面保持原样,内容没有丢。",en:'Couldn’t lock "{name}": {reason}. The page is unchanged and nothing was lost.'},"unilock.failed.unlock":{zh:"没能解锁「{name}」:{reason}。页面保持锁定。",en:'Couldn’t unlock "{name}": {reason}. The page stays locked.'},"unilock.failed.save":{zh:"还有改动没保存下来({err})",en:"some changes couldn’t be saved ({err})"},"unilock.failed.read":{zh:"读不到这篇笔记的最新内容",en:"the latest version of the note couldn’t be read"},"unilock.retry":{zh:"重试",en:"Retry"}});async function Fs(t){try{await Fa(t,!0)}catch(s){return{ok:!1,reason:_("unilock.failed.save",{err:ei(s)})}}const n=await te.readTextFile(t).catch(()=>null);return n==null?{ok:!1,reason:_("unilock.failed.read")}:{ok:!0,raw:n}}const Al=t=>(t.split("/").pop()??t).replace(/\.md$/i,"");function di(t,n,s,i){Es({level:"error",dedupeKey:`amx-lock:${t}`,text:_(n?"unilock.failed.lock":"unilock.failed.unlock",{name:Al(t),reason:s}),action:{label:_("unilock.retry"),run:i}})}async function ui(t,n,s){const i=await Fs(n);return i.ok?(Wi(t,n,s),!0):(di(n,s,i.reason,()=>{ui(t,n,s)}),!1)}Ne({"pghist.menu":{zh:"版本历史",en:"Version history"},"pghist.close":{zh:"关闭",en:"Close"},"pghist.listLabel":{zh:"历史版本",en:"Saved versions"},"pghist.loading":{zh:"正在读取…",en:"Loading…"},"pghist.loadFailed":{zh:"读不到版本历史:{reason}",en:"Couldn’t load version history: {reason}"},"pghist.empty":{zh:"还没有历史版本。编辑这篇笔记后,大约每 5 分钟会自动留一份。",en:"No saved versions yet. While you edit this note, a version is kept about every 5 minutes."},"pghist.tab.content":{zh:"内容",en:"Content"},"pghist.tab.diff":{zh:"与当前对比",en:"Compare with current"},"pghist.diff.current":{zh:"当前",en:"Current"},"pghist.diff.version":{zh:"此版本",en:"This version"},"pghist.same":{zh:"与当前内容相同。",en:"Same as the current content."},"pghist.tooLarge":{zh:"内容太大,无法对比。",en:"Too large to compare."},"pghist.previewFailed":{zh:"读不到这个版本。",en:"This version couldn’t be read."},"pghist.restore":{zh:"恢复此版本",en:"Restore this version"},"pghist.restoreHint":{zh:"恢复前会先把当前内容存进版本历史。",en:"The current content is saved to version history before restoring."},"pghist.lockedHint":{zh:"页面已锁定,解锁后才能恢复。",en:"This page is locked. Unlock it to restore a version."},"pghist.confirm.title":{zh:"恢复到 {time} 的版本?",en:"Restore the version from {time}?"},"pghist.confirm.msg":{zh:"笔记会换成这个版本的内容。当前内容会先存进版本历史,之后还能恢复回来。",en:"The note will be replaced with this version. The current content is saved to version history first, so you can switch back later."},"pghist.confirm.ok":{zh:"恢复",en:"Restore"},"pghist.done":{zh:"已恢复到 {time} 的版本",en:"Restored the version from {time}"},"pghist.failed":{zh:"没能恢复「{name}」:{reason}。笔记保持原样。",en:'Couldn’t restore "{name}": {reason}. The note is unchanged.'},"pghist.failed.conflict":{zh:"这篇笔记刚被别处改动了",en:"the note was just changed elsewhere"},"pghist.failed.gone":{zh:"这篇笔记已经不在了",en:"the note no longer exists"},"pghist.retry":{zh:"重试",en:"Retry"}});const Bl=t=>(t.split("/").pop()??t).replace(/\.md$/i,"");function Tn(t,n,s){Es({level:"error",dedupeKey:`amx-hist-restore:${t}`,text:_("pghist.failed",{name:Bl(t),reason:n}),...s?{action:{label:_("pghist.retry"),run:s}}:{}})}async function Vl(t,n){const s=te.restorePageHistory;if(!s)return!1;const i=()=>{Vl(t,n)},l=await Fs(t);if(!l.ok)return Tn(t,l.reason,i),!1;let o;try{o=await s(t,n.id,Ri(l.raw))}catch(r){return Tn(t,ei(r),i),!1}return o.ok?(Fi(t,{}),Es({level:"success",text:_("pghist.done",{time:Hi(n.at)})}),!0):(o.current==null?Tn(t,_("pghist.failed.gone")):Tn(t,_("pghist.failed.conflict"),i),!1)}const _l=Ui(()=>Di(()=>import("./PageHistoryPanel-Bn4-XmdK.js"),__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,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50]),import.meta.url));function Wl({path:t,locked:n,onClose:s}){return e.jsx(c.Suspense,{fallback:null,children:e.jsx(_l,{path:t,locked:n,onClose:s})})}async function Ul(t){await Fa(t);const n=Mi(t);if(n!=null)return n;const s=await te.readTextFile(t).catch(()=>null);return s==null?null:Sr(s).body}Ne({"amxpage.font":{zh:"页面字体",en:"Page font"},"amxpage.font.default":{zh:"默认",en:"Default"},"amxpage.font.serif":{zh:"衬线",en:"Serif"},"amxpage.font.mono":{zh:"等宽",en:"Mono"},"amxpage.wide":{zh:"全宽",en:"Full width"},"amxpage.small":{zh:"小字号",en:"Small text"}});const Hl=["default","serif","mono"];function ql(t,n,s=_){return[{kind:"choice",id:"font",label:s("amxpage.font"),options:Hl.map(i=>({id:i,label:s(`amxpage.font.${i}`),on:t.font===i,run:()=>n({font:i})}))},{kind:"toggle",id:"wide",label:s("amxpage.wide"),on:t.wide,run:()=>n({wide:!t.wide})},{kind:"toggle",id:"small",label:s("amxpage.small"),on:t.small,run:()=>n({small:!t.small})}]}function Kl(t,n){const[,s]=c.useState(0);return c.useEffect(()=>qi(()=>s(i=>i+1)),[]),n?Gi(t,n):Ki}function Gl(t,n,s){Yi(t,n,s)}function Yl(t){return{...t.wide?{"data-page-wide":""}:{},...t.small?{"data-page-small":""}:{},...t.font!=="default"?{"data-page-font":t.font}:{}}}const Xl={wide:ti,small:oi};function Jl({entries:t}){return e.jsx("div",{className:"amx-pagestyle","data-pagestyle-menu":"",children:t.map(n=>n.kind==="choice"?e.jsxs("div",{className:"amx-pagefont",role:"group","aria-label":n.label,children:[e.jsx("div",{className:"ctx-head",children:n.label}),e.jsx("div",{className:"amx-pagefont-row",children:n.options.map(s=>e.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":s.on,className:`amx-pagefont-opt${s.on?" on":""}`,"data-font":s.id,onClick:s.run,children:[e.jsx("span",{className:"amx-pagefont-aa","aria-hidden":!0,children:"Aa"}),e.jsx("span",{className:"amx-pagefont-name",children:s.label})]},s.id))})]},n.id):e.jsx(Zl,{entry:n},n.id))})}function Zl({entry:t}){const n=Xl[t.id];return e.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":t.on,"data-pagestyle":t.id,onClick:t.run,children:[e.jsx(n,{size:13}),e.jsx("span",{className:"amx-pagestyle-label",children:t.label}),t.on&&e.jsx(wt,{size:13,className:"amx-pagestyle-check"})]})}function Ql({host:t,label:n,scanTrigger:s}){return e.jsx(Dr,{scrollContainer:t,contentRoot:t,selector:".page-view h1, .page-view h2, .page-view h3",label:n,scanTrigger:s,placement:"sticky",topOffset:Fr,topInset:Rr})}Ne({"fileimport.tooLargeCloud":{zh:"超过云端单文件上限",en:"Over the cloud file size limit"},"fileimport.vaultFull":{zh:"云端智库容量已满",en:"The cloud vault is full"},"fileimport.unknownError":{zh:"未知错误",en:"Unknown error"},"fileimport.overCloudLimit":{zh:"超过云端单文件上限 {limit}",en:"over the {limit} cloud file limit"},"fileimport.over50mb":{zh:"超 50MB",en:"over 50 MB"},"fileimport.unreadable":{zh:"读不到",en:"unreadable"},"fileimport.withReason":{zh:"{name}({reason})",en:"{name} ({reason})"},"fileimport.uploading":{zh:"正在上传 {name}… {pct}%",en:"Uploading {name}… {pct}%"},"fileimport.placeholder":{zh:"⏳ 正在上传 {name}…",en:"⏳ Uploading {name}…"},"fileimport.placeholderFailed":{zh:"⚠️ 上传失败:{name}",en:"⚠️ Upload failed: {name}"},"fileimport.notImportedOne":{zh:"{n} 个文件未导入:{first}",en:"{n} file was not imported: {first}"},"fileimport.notImportedMany":{zh:"{n} 个文件未导入:{first}",en:"{n} files were not imported: {first}"},"fileimport.movedAway":{zh:"文件已存入原笔记(已切换页,占位行未替换)",en:"The file was saved to the original note (you switched pages, so the placeholder line was left as is)"},"fileimport.imageMovedAway":{zh:"图片已存入原笔记(已切换页,占位行未替换)",en:"The image was saved to the original note (you switched pages, so the placeholder line was left as is)"},"fileimport.importedOne":{zh:"已导入 {n} 个文件",en:"Imported {n} file"},"fileimport.importedMany":{zh:"已导入 {n} 个文件",en:"Imported {n} files"},"fileimport.uploadedOne":{zh:"已上传 {name}",en:"Uploaded {name}"},"fileimport.vaultRoot":{zh:"库根目录",en:"Vault root"},"fileimport.importedToOne":{zh:"已导入 {n} 个文件到「{where}」",en:"Imported {n} file to “{where}”"},"fileimport.importedToMany":{zh:"已导入 {n} 个文件到「{where}」",en:"Imported {n} files to “{where}”"},"fileimport.unreadableOne":{zh:"{n} 个文件读不了:{first}",en:"Could not read {n} file: {first}"},"fileimport.unreadableMany":{zh:"{n} 个文件读不了:{first}",en:"Could not read {n} files: {first}"},"fileimport.imageOverCloudLimit":{zh:"图片超过云端单文件上限 {limit}",en:"Image is over the {limit} cloud file limit"},"fileimport.pasteFailed":{zh:"粘贴图片:{first}",en:"Could not paste image: {first}"}});const Zt=(t,n)=>_("fileimport.withReason",{name:t,reason:n}),lt=()=>I.getState(),ct=t=>$a.getState().notify(t);function ec(){return window.amadeusSync?lt().vaultSide==="cloud":!!window.amadeusCloudVaults}function tc(t,n){const s=/[ ()<>]/.test(n)?`<${n}>`:n;return`[${t.replace(/[[\]]/g,"")}](${s})`}function nc(t,n,s,i){return i&&!/[[\]|#]/.test(t)?`![[${t}]]`:tc(n,s)}function qn(t){const n=t instanceof Error?t.message:String(t);return/TOO_LARGE|\b413\b/.test(n)?_("fileimport.tooLargeCloud"):/VAULT_FULL/.test(n)?_("fileimport.vaultFull"):n||_("fileimport.unknownError")}async function sc(){const t=window.amadeusSync?(await window.amadeusSync.get().catch(()=>null))?.maxFileBytes:window.amadeusCloudMaxFileBytes;return typeof t=="number"&&t>0?t:null}const ac=t=>`${+(t/1048576).toFixed(1)} MB`;async function Ms(t){if(!ec())return null;const n=await sc();return n!==null&&t.size>n?ac(n):null}async function $s(){try{await lt().refreshStructure?.()}catch{}}function Os(t){let n=-1;return(s,i)=>{const l=i>0?Math.min(100,Math.floor(s/i*100)):0;l!==n&&(n=l,ct(_("fileimport.uploading",{name:t,pct:l})))}}function hi(t,n){const s=_("fileimport.placeholder",{name:n}),i=lt().activePage===t?lt().insertBlockAfter(null,void 0,s):null,l=()=>!!i&&lt().activePage===t&&lt().blocks[i]?.content===s;return{done:o=>l()?(lt().setBlockContent(i,o),!0):!1,fail:()=>{l()&&lt().setBlockContent(i,_("fileimport.placeholderFailed",{name:n}))}}}async function Bn(t,n){if(!t.length||!n)return;const{opts:s,preview:i}=await Xi();let l=0,o=0;const r=[];for(const u of t){const f=await Ms(u);if(f){r.push(Zt(u.name,_("fileimport.overCloudLimit",{limit:f})));continue}const h=hi(n,u.name);try{const j=new Uint8Array(await u.arrayBuffer()),{pageRel:m,base:y}=await te.saveAttachment(n,u.name,j,s,Os(u.name));h.done(nc(y,u.name,m,i))||lt().activePage===n?l++:o++}catch(j){h.fail(),r.push(Zt(u.name,qn(j)))}}await $s(),r.length?ct(_(r.length===1?"fileimport.notImportedOne":"fileimport.notImportedMany",{n:r.length,first:r[0]})):o?ct(_("fileimport.movedAway")):t.length>1?ct(_(l===1?"fileimport.importedOne":"fileimport.importedMany",{n:l})):ct(_("fileimport.uploadedOne",{name:t[0].name}))}async function pa(t,n){if(!t.length)return;let s=0;const i=[];for(const o of t){const r=await Ms(o);if(r){i.push(Zt(o.name,_("fileimport.overCloudLimit",{limit:r})));continue}try{const u=new Uint8Array(await o.arrayBuffer());await te.saveAttachment("",o.name,u,{mode:"vault",folder:n},Os(o.name)),s++}catch(u){i.push(Zt(o.name,qn(u)))}}await $s();const l=n?n.split("/").pop()||n:_("fileimport.vaultRoot");i.length?ct(_(i.length===1?"fileimport.notImportedOne":"fileimport.notImportedMany",{n:i.length,first:i[0]})):ct(_(s===1?"fileimport.importedToOne":"fileimport.importedToMany",{n:s,where:l}))}async function ic(t){const n=window.tangu?.readHostFile;if(!n)return[];const s=[],i=[];for(const l of t){const o=l.split(/[\\/]/).pop()||l;try{const r=await n(l);if(!r||r.tooLarge){i.push(Zt(o,_(r?.tooLarge?"fileimport.over50mb":"fileimport.unreadable")));continue}s.push(new File([Ji(r.content)],o,{type:r.mimeType}))}catch(r){i.push(Zt(o,qn(r)))}}return i.length&&ct(_(i.length===1?"fileimport.unreadableOne":"fileimport.unreadableMany",{n:i.length,first:i[0]})),s}async function oc(t,n){if(!t.length||!n)return;let s=0;const i=[];for(const l of t){const o=await Ms(l);if(o){i.push(_("fileimport.imageOverCloudLimit",{limit:o}));continue}const r=(l.name||"pasted.png").replace(/\s+/g,"_"),u=hi(n,r);try{const f=new Uint8Array(await l.arrayBuffer()),h=await te.saveAsset(n,r,f,Os(r));!u.done(`![](${h})`)&&lt().activePage!==n&&s++}catch(f){u.fail(),i.push(qn(f))}}await $s(),i.length?ct(_("fileimport.pasteFailed",{first:i[0]})):s&&ct(_("fileimport.imageMovedAway"))}function fa(t,n,s=!1){return!!t&&!n&&!s}function rc(t){const n=t.cloneNode(!0),s=[...t.querySelectorAll("input.amx-title-input, textarea.amx-title-input")];return n.querySelectorAll("input.amx-title-input, textarea.amx-title-input").forEach((i,l)=>{const o=s[l],r=document.createElement("h1");r.className="amx-title-input amx-title-static",r.textContent=o?.value||o?.placeholder||"",i.replaceWith(r)}),n}const ga="amx.sec.";function lc(t,n){return t==="1"?!0:t==="0"?!1:n}function Vn(t,n=!1){const[s,i]=c.useState(()=>{try{return lc(localStorage.getItem(ga+t),n)}catch{return n}});return[s,()=>i(o=>{const r=!o;try{localStorage.setItem(ga+t,r?"1":"0")}catch{}return r})]}function mi(t,n){const s=n==="first",i=s?t.children[0]:t.children.at(-1),l=s?i?.columns[0]:i?.columns.at(-1);return(s?l?.children[0]:l?.children.at(-1))?.ref??null}const pi="amadeus.heading.fold";function cc(t){const n=(t??"").split(`
3
+ `,1)[0]??"",s=/^ {0,3}(#{1,6})\s/.exec(n);return s?s[1].length:0}function xa(t){const n=t??"";if(!n.includes("#"))return 0;let s=0,i=!1;for(const l of n.split(`
4
+ `)){if(/^ {0,3}(```|~~~)/.test(l)){i=!i;continue}if(i)continue;const o=/^ {0,3}(#{1,6})\s/.exec(l);if(o&&((!s||o[1].length<s)&&(s=o[1].length),s===1))break}return s}const dc=()=>{try{const t=JSON.parse(localStorage.getItem(pi)||"{}");return t&&typeof t=="object"?t:{}}catch{return{}}},va=Qt(t=>({byPage:dc(),toggle:(n,s)=>t(i=>{const l=i.byPage[n]??[],o=l.includes(s)?l.filter(u=>u!==s):[...l,s],r={...i.byPage};o.length?r[n]=o:delete r[n];try{localStorage.setItem(pi,JSON.stringify(r))}catch{}return{byPage:r}})}));function uc(t,n){return new Set(t[n]??[])}function hc({col:t,gutterLead:n}){const s=I(r=>r.insertBlockAfter),{setNodeRef:i,isOver:l}=Ss({id:`col:${t.id}`}),o=t.children.map(r=>r.ref);return e.jsxs("div",{ref:i,className:"column","data-col":t.id,"data-over":l||void 0,style:{flexGrow:t.width,flexBasis:0},children:[e.jsx(Oa,{items:o,strategy:Zi,children:o.map((r,u)=>e.jsx(La,{blockId:r,gutterLead:u===0?n:void 0},r))}),e.jsx("button",{className:"col-add",onClick:()=>s(null,t.id),children:"+ 块"})]})}Ne({"colresizer.dragHint":{zh:"拖动调整列宽",en:"Drag to resize columns"}});function mc({rowId:t,leftColId:n,rightColId:s}){const i=I(u=>u.resizeColumns),{t:l}=he(),o=c.useRef(null),r=u=>{u.preventDefault();const f=o.current?.closest(".row-cols");if(!f)return;const h=m=>{const y=f.querySelector(`[data-col="${n}"]`),p=f.querySelector(`[data-col="${s}"]`);if(!y||!p)return;const x=y.getBoundingClientRect().left,O=p.getBoundingClientRect().right;O<=x||i(t,n,s,(m.clientX-x)/(O-x))},j=()=>{window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",j)};window.addEventListener("pointermove",h),window.addEventListener("pointerup",j)};return e.jsx("div",{ref:o,className:"col-resizer",onPointerDown:r,title:l("colresizer.dragHint")})}function pc({row:t,gutterLead:n}){const s=t.columns.length===1&&t.columns[0].children.length>1;return e.jsxs("div",{className:"row",children:[!s&&e.jsx(wa,{rowId:t.id,side:"left"}),e.jsx("div",{className:"row-cols",children:t.columns.map((i,l)=>e.jsxs(c.Fragment,{children:[l>0&&e.jsx(mc,{rowId:t.id,leftColId:t.columns[l-1].id,rightColId:i.id}),e.jsx(hc,{col:i,gutterLead:l===0?n:void 0})]},i.id))}),!s&&e.jsx(wa,{rowId:t.id,side:"right"})]})}function wa({rowId:t,side:n}){const{setNodeRef:s,isOver:i}=Ss({id:`edge:${t}:${n}`});return e.jsx("div",{ref:s,className:"edge-zone","data-side":n,"data-over":i||void 0})}function fc(){const t=I(u=>u.activePage),n=I(u=>u.linkGraphVersion),s=I(u=>u.loadPage),[i,l]=c.useState([]),[o,r]=c.useState(!1);return c.useEffect(()=>{let u=!0;if(!t){l([]);return}return te.backlinks(t).then(f=>{u&&l(f)}),()=>{u=!1}},[t,n]),t?e.jsxs("section",{className:"backlinks",children:[e.jsxs("button",{className:"backlinks-head",onClick:()=>r(u=>!u),children:[e.jsx("span",{className:"backlinks-chevron",children:o?"▸":"▾"}),"链接到本页 · ",i.length]}),!o&&e.jsxs("div",{className:"backlinks-list",children:[i.length===0&&e.jsx("div",{className:"backlinks-empty",children:"还没有其它页面链接到这里"}),i.map(u=>e.jsxs("button",{className:"page-item backlink-item",onClick:()=>{s(u.path)},title:u.path,children:[e.jsx("span",{className:"backlink-title",children:u.title}),u.snippet&&e.jsx("span",{className:"backlink-snippet",children:u.snippet})]},u.path))]})]}):null}Ne({"amxpv.statusSaving":{zh:"保存中…",en:"Saving…"},"amxpv.statusLoading":{zh:"加载中…",en:"Loading…"},"amxpv.statusReady":{zh:"已保存",en:"Saved"},"amxpv.emptyBlock":{zh:"空块",en:"Empty block"},"amxpv.openVault":{zh:"打开一个智库,或新建页面开始。",en:"Open a vault, or create a page to get started."},"amxpv.renameTitle":{zh:"点击重命名页面",en:"Click to rename the page"},"amxpv.expandSection":{zh:"展开小节({n} 行)",en:"Expand section ({n} rows)"},"amxpv.foldSection":{zh:"折叠小节",en:"Collapse section"},"amxpv.addBlock":{zh:"+ 新块",en:"+ New block"},"amxpv.dndHint":{zh:"拖动 ⠿ 到列边缘可分栏 · 拖到行间可新建行",en:"Drag ⠿ to a column edge to split into columns · drop between rows to add a row"},"amxpv.dragBlocks":{zh:"{n} 个块",en:"{n} blocks"}});function gc(t,n){return t==="saving"?n("amxpv.statusSaving"):t==="loading"?n("amxpv.statusLoading"):t==="ready"?n("amxpv.statusReady"):""}function xc(t,n){if(!t)return n("amxpv.emptyBlock");const s=t.replace(/[#>*_`\-[\]]/g,"").trim().split(`
5
+ `)[0];return s.length>48?s.slice(0,48)+"…":s||n("amxpv.emptyBlock")}function ba({index:t}){const{setNodeRef:n,isOver:s}=Ss({id:`gap:${t}`});return e.jsx("div",{ref:n,className:"row-gap","data-over":s||void 0})}function _n(t){const n=(t??Ns(Un())).getState(),s=n.manifest?mi(n.manifest.root,"first"):null;s?n.requestFocus(s,"start"):n.insertBlockAfter(null)}const vc=t=>{const n=Ua(t);return n.length?n:no(t)};function wc(t){const n=t.getState(),s=n.manifest?mi(n.manifest.root,"last"):null;s&&!n.blocks[s]?.content?n.requestFocus(s,"end"):n.insertBlockAfter(null)}const ls=24,bc=16,yc=typeof requestIdleCallback=="function"?t=>requestIdleCallback(t,{timeout:200}):t=>window.setTimeout(t,16),jc=typeof cancelIdleCallback=="function"?cancelIdleCallback:clearTimeout;function kc({bare:t=!1}={}){const{t:n}=he(),s=I(P=>P.manifest),i=I(P=>P.blocks),l=I(P=>P.status),o=I(P=>P.activePage),r=I(P=>P.moveBlock),u=I(P=>P.addColumnWithBlock),f=I(P=>P.addRowWithBlock),h=I(P=>P.insertBlockAfter),j=I(P=>P.renamePage),m=I(P=>P.setDnd),y=Ia(),p=Ft();c.useEffect(()=>{const P=Aa(y);P&&p.getState().requestFocusAt(P.blockId,P.anchor)},[]);const[x,O]=c.useState([]),T=c.useRef([]),G=x[0]??null,[S,M]=c.useState(!1),[R,z]=c.useState(""),k=Ba(hs(Qi,{activationConstraint:{distance:5}})),$=va(P=>P.byPage);c.useEffect(()=>{const P=A=>{if(!(A.metaKey||A.ctrlKey))return;const H=A.key.toLowerCase();if(H!=="z"&&H!=="y")return;const Y=A.target;if(Y&&(Y.tagName==="INPUT"||Y.tagName==="TEXTAREA"||Y.isContentEditable)||A.defaultPrevented||Un()!==y)return;A.preventDefault();const fe=p.getState();H==="y"||A.shiftKey?fe.redo():fe.undo()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[]);const D=s?.root.children.length??0,[K,Z]=c.useState({page:o,n:ls});K.page!==o&&Z({page:o,n:ls});const ce=K.page===o?K.n:ls;if(c.useEffect(()=>{if(ce>=D)return;const P=yc(()=>Z(A=>({...A,n:A.n+bc})));return()=>jc(P)},[ce,D]),!s)return e.jsx("div",{className:"empty-state",children:n("amxpv.openVault")});const U=s.root,re=P=>{const A=(P??"").indexOf(`
6
+ `);return A<0?"":(P??"").slice(A+1)},we=U.children.map(P=>{const A=P.columns[0]?.children[0]?.ref;let H=0,Y=0;for(const fe of P.columns)for(const se of fe.children){const F=i[se.ref]?.content,W=xa(F);W&&(!H||W<H)&&(H=W);const Je=se.ref===A?xa(re(F)):W;Je&&(!Y||Je<Y)&&(Y=Je)}return{firstId:A,level:cc(A?i[A]?.content:void 0),bound:H,self:Y}}),Fe=P=>{const A=we[P];if(!A.level||A.self&&A.self<=A.level)return 0;let H=0;for(let Y=P+1;Y<we.length&&!(we[Y].bound&&we[Y].bound<=A.level);Y++)H++;return H},ge=uc($,o??""),X=new Set;if(!G)for(let P=0;P<we.length;P++){const A=we[P];if(!(!A.level||!A.firstId||!ge.has(A.firstId)))for(let H=P+1;H<=P+Fe(P);H++)X.add(H)}const pe=s.title||o?.split("/").pop()||"",ue=()=>{z(pe),M(!0)},N=async()=>{M(!1);const P=R.trim();P&&P!==pe&&await j(P)},ie=P=>{for(const A of U.children)for(const H of A.columns)if(H.children.some(Y=>Y.ref===P))return H.id;return null},ne=P=>{const A=String(P.active.id),H=to.getState(),Y=H.ids.has(A)?p.getState().flatOrder().filter(se=>H.ids.has(se)):[A];H.ids.has(A)||H.select(A);const fe=Y.length?Y:[A];T.current=fe,O(fe),m(A,null)},xe=P=>{const A=String(P.active.id),H=P.over?String(P.over.id):"",Y=H&&!H.includes(":")&&H!==A?H:null;m(A,Y)},ke=()=>{T.current=[],O([]),m(null,null)},Ue=P=>{const A=String(P.active.id),H=T.current.includes(A)?T.current:[A];if(T.current=[],O([]),m(null,null),!P.over)return;const Y=String(P.over.id);if(Y.startsWith("bedge:")){const[,fe,se]=Y.split(":");p.getState().pairBlocks(H,fe,se==="left"?"left":"right")}else if(Y.startsWith("edge:")){const[,fe,se]=Y.split(":");u(fe,H,se==="left"?"left":"right")}else if(Y.startsWith("gap:"))f(Number(Y.slice(4)),H);else if(Y.startsWith("col:"))r(H,Y.slice(4),null);else if(Y!==A){const fe=ie(Y);fe&&r(H,fe,Y)}};return e.jsxs("div",{className:"page-view","data-bare":t||void 0,children:[e.jsx(eo,{}),!t&&e.jsxs("header",{className:"page-header",children:[S?e.jsx("input",{className:"page-title-edit",autoFocus:!0,value:R,onChange:P=>z(P.target.value),onBlur:()=>{N()},onKeyDown:P=>{if(P.key==="Enter")P.preventDefault(),_n(p),N();else if(P.key==="ArrowRight"||P.key==="ArrowDown"){const A=P.currentTarget;A.selectionStart===A.value.length&&A.selectionEnd===A.value.length&&(P.preventDefault(),_n(p),N())}else P.key==="Escape"&&M(!1)}}):e.jsx("div",{className:"page-title",onClick:ue,title:n("amxpv.renameTitle"),children:pe}),e.jsx("div",{className:"page-status","data-status":l,children:gc(l,n)})]}),e.jsxs(Va,{sensors:k,collisionDetection:vc,measuring:{droppable:{strategy:_a.Always}},onDragStart:ne,onDragOver:xe,onDragEnd:Ue,onDragCancel:ke,children:[e.jsxs("div",{className:"stack","data-dnd":G?"":void 0,children:[e.jsx(ba,{index:-1}),U.children.map((P,A)=>{if(A>=ce||X.has(A))return null;const H=we[A],Y=Fe(A),fe=!!(H.firstId&&ge.has(H.firstId));return e.jsxs(c.Fragment,{children:[e.jsxs("div",{className:`amx-hfold-wrap${Y>0&&H.firstId?" has-fold":""}`,children:[fe&&Y>0&&e.jsx("span",{className:"amx-hfold-count",children:Y}),e.jsx(pc,{row:P,gutterLead:Y>0&&H.firstId?e.jsx("button",{className:`amx-hfold${fe?" folded":""}`,title:fe?n("amxpv.expandSection",{n:Y}):n("amxpv.foldSection"),onClick:se=>{se.stopPropagation(),va.getState().toggle(o??"",H.firstId)},children:"›"}):void 0})]}),e.jsx(ba,{index:A})]},P.id)})]}),e.jsx(Wa,{dropAnimation:null,children:G?e.jsxs("div",{className:"drag-overlay",children:[x.length>1?`${n("amxpv.dragBlocks",{n:x.length})} · `:"",xc(i[G]?.content,n)]}):null})]}),t&&e.jsx("div",{className:"page-tail",onClick:()=>wc(p)}),!t&&e.jsxs("div",{className:"page-footer",children:[e.jsx("button",{className:"add-block",onClick:()=>h(null),children:n("amxpv.addBlock")}),e.jsx("span",{className:"hint-inline",children:n("amxpv.dndHint")})]}),!t&&e.jsx(fc,{})]})}Ne({"cloudvault.title":{zh:"云端智库",en:"Cloud vaults"},"cloudvault.myVaults":{zh:"我的库",en:"My vaults"},"cloudvault.sharedWithMe":{zh:"与我共享 · {n}",en:"Shared with me · {n}"},"cloudvault.sharedEmpty":{zh:"别人共享给你的页面会出现在这里(打开对方发的邀请链接并同意)。",en:"Pages other people share with you show up here — open their invite link and accept it."},"cloudvault.roleViewer":{zh:"只读",en:"Read-only"},"cloudvault.roleEditor":{zh:"可编辑",en:"Can edit"},"cloudvault.published":{zh:"已发布 · {n}",en:"Published · {n}"},"cloudvault.publishedEmpty":{zh:"在笔记的「分享 → 发布」里生成公开链接,链接会列在这里。",en:"Create a public link from a note under Share → Publish, and it will be listed here."},"cloudvault.copyLink":{zh:"复制链接",en:"Copy link"},"cloudvault.unpublish":{zh:"取消发布",en:"Unpublish"},"cloudvault.unpublished":{zh:"已取消发布,链接立即失效",en:"Unpublished — the link stopped working immediately"}});function Sc({onClose:t}){const{t:n}=he(),s=window.amadeusCollab,i=(S,M=!1)=>Ve.getState().toast(S,M),[l,o]=c.useState([]),[r,u]=c.useState(""),[f,h]=c.useState([]),[j,m]=c.useState([]),[y,p]=c.useState(null),[x,O]=c.useState(null),T=()=>{s&&(s.listVaults().then(S=>o(S.map(M=>({id:M.id,name:M.name})))).catch(()=>{}),s.activeVaultId().then(u).catch(()=>{}),s.sharedWithMe().then(h).catch(()=>h([])),s.publishes().then(S=>{m(S.shares),p(S.quota)}).catch(()=>m([])))};if(c.useEffect(T,[]),!s)return null;const G=(S,M)=>{navigator.clipboard.writeText(S).then(()=>{O(M),setTimeout(()=>O(null),1200)})};return e.jsx("div",{className:"amxc-overlay",onClick:t,children:e.jsxs("div",{className:"amxc-panel",onClick:S=>S.stopPropagation(),children:[e.jsxs("div",{className:"amxc-head",children:[e.jsxs("span",{children:[e.jsx(vt,{size:14})," ",n("cloudvault.title")]}),e.jsx("button",{className:"amxc-x",onClick:t,children:e.jsx(zs,{size:14})})]}),e.jsx("div",{className:"amxc-sec",children:n("cloudvault.myVaults")}),l.map(S=>e.jsxs("button",{className:`amxc-row${S.id===r?" on":""}`,onClick:()=>{S.id!==r&&s.switchVault(S.id)},children:[e.jsx("span",{className:"amxc-row-name",children:S.name}),S.id===r&&e.jsx(wt,{size:13})]},S.id)),e.jsxs("div",{className:"amxc-sec",children:[e.jsx(Ha,{size:12})," ",n("cloudvault.sharedWithMe",{n:f.length})]}),f.length===0&&e.jsx("div",{className:"amxc-hint",children:n("cloudvault.sharedEmpty")}),f.map(S=>e.jsxs("button",{className:"amxc-row",onClick:M=>{t(),S.vaultId===r?Me(S.path,Xe(M)):s.switchVault(S.vaultId)},children:[e.jsx("span",{className:"amxc-row-name",children:S.title}),e.jsxs("span",{className:"amxc-tag",children:[S.role==="viewer"?n("cloudvault.roleViewer"):n("cloudvault.roleEditor"),S.ownerName?` · ${S.ownerName}`:""]})]},`${S.vaultId}:${S.path}`)),e.jsxs("div",{className:"amxc-sec",children:[e.jsx(Cs,{size:12})," ",n("cloudvault.published",{n:j.length}),y&&Number.isFinite(y.publish)?` / ${y.publish}`:""]}),j.length===0&&e.jsx("div",{className:"amxc-hint",children:n("cloudvault.publishedEmpty")}),j.map(S=>e.jsxs("div",{className:"amxc-row static",children:[e.jsxs("span",{className:"amxc-row-name",title:S.path,children:[S.mode==="subtree"?"📁 ":"📄 ",S.path]}),e.jsx("button",{className:"amxc-ic",title:n("cloudvault.copyLink"),onClick:()=>G(s.publishUrl(S.token),S.token),children:x===S.token?e.jsx(wt,{size:12}):e.jsx(Ut,{size:12})}),e.jsx("button",{className:"amxc-ic",title:n("cloudvault.unpublish"),onClick:()=>{s.revokePublish(S.token).then(()=>{i(n("cloudvault.unpublished")),T()})},children:e.jsx(Ye,{size:12})})]},S.token))]})})}Ne({"presencedots.viewing":{zh:"{name} 正在看 {page}",en:"{name} is viewing {page}"},"presencedots.online":{zh:"{name} 在线",en:"{name} is online"}});function Nc(){const{t}=he(),n=window.amadeusCollab,s=I(h=>h.activePage??h.activeNotePath),i=I(h=>h.vaultSide),[l,o]=c.useState([]),r=!window.amadeusSync||i==="cloud";if(c.useEffect(()=>{if(!n||!r)return;const h=n.onPresence(o);return()=>{h(),n.stopHeartbeat()}},[n,r]),c.useEffect(()=>{r&&n?.heartbeat(s)},[n,s,r]),!n||!r)return null;const u=n.myUserId(),f=l.filter(h=>h.userId!==u);return f.length?e.jsxs("span",{className:"amxc-presence",title:f.map(h=>`${h.username}${h.page?` · ${h.page.replace(/\.md$/i,"")}`:""}`).join(`
7
+ `),children:[f.slice(0,5).map(h=>e.jsx("span",{className:`amxc-dot${h.page&&h.page===s?" same":""}`,title:h.page?t("presencedots.viewing",{name:h.username,page:h.page.replace(/\.md$/i,"")}):t("presencedots.online",{name:h.username}),children:(h.username||"?").slice(0,1).toUpperCase()},h.userId)),f.length>5&&e.jsxs("span",{className:"amxc-dot more",children:["+",f.length-5]})]}):null}function zc(t,n){return t.path===n?!0:t.mode==="subtree"?n.startsWith(`${t.path}/`):n.startsWith(`${t.path.replace(/\.md$/i,"")}.fd/`)}function fi(t,n){const s=n.find(l=>l.path===t);if(s)return{kind:"direct",token:s.token};const i=n.find(l=>zc(l,t));return i?{kind:"inherited",via:i.path,viaMode:i.mode==="subtree"?"subtree":"page",token:i.token}:{kind:"none"}}Ne({"share.unlimited":{zh:"无限制",en:"unlimited"},"share.tabShare":{zh:"共享",en:"Share"},"share.tabPublish":{zh:"发布",en:"Publish"},"share.ownerOnly":{zh:"只有库所有者可以管理共享与发布。",en:"Only the vault owner can manage sharing and publishing."},"share.intro":{zh:"邀请他人参与这一页(含子页面)。对方需登录 Forsion 账号并同意邀请;权限可为只读或可编辑,默认开放 7 天。",en:"Invite others to this page and its subpages. They need to sign in to a Forsion account and accept the invite; access can be read-only or editable, and stays open for 7 days by default."},"share.enable":{zh:"开启同步共享",en:"Turn on live sharing"},"share.enabled":{zh:"已开启共享",en:"Sharing is on"},"share.planNoCollab":{zh:"当前套餐不支持同步共享,升级 Plus/Pro 解锁。",en:"Your plan does not include live sharing — upgrade to Plus or Pro to unlock it."},"share.quotaCollab":{zh:"套餐可共享 {n} 页。",en:"Your plan can share {n} pages."},"share.copyInvite":{zh:"复制邀请链接",en:"Copy invite link"},"share.rotate":{zh:"更换链接(旧链接失效)",en:"Replace link (the old one stops working)"},"share.rotated":{zh:"已更换邀请链接",en:"Invite link replaced"},"share.linkRole":{zh:"链接权限",en:"Link access"},"share.roleEditor":{zh:"可编辑",en:"Can edit"},"share.roleViewer":{zh:"只读",en:"Read-only"},"share.openFor":{zh:"开放时间",en:"Open for"},"share.days7":{zh:"7 天",en:"7 days"},"share.days30":{zh:"30 天",en:"30 days"},"share.forever":{zh:"永久",en:"Forever"},"share.password":{zh:"查看密码",en:"Password"},"share.passwordSet":{zh:"已设置",en:"Set"},"share.clearPassword":{zh:"清除密码",en:"Clear password"},"share.passwordCleared":{zh:"已清除密码",en:"Password cleared"},"share.passwordOptional":{zh:"可选",en:"Optional"},"share.setPassword":{zh:"设置",en:"Set password"},"share.passwordSaved":{zh:"已设置密码",en:"Password set"},"share.participants":{zh:"参与者 · {n}",en:"Participants · {n}"},"share.noParticipants":{zh:"还没有人加入。把邀请链接发给对方,登录并同意后出现在这里。",en:"Nobody has joined yet. Send someone the invite link — they appear here once they sign in and accept."},"share.removeParticipant":{zh:"移除",en:"Remove"},"share.removed":{zh:"已移除",en:"Removed"},"share.stop":{zh:"停止共享",en:"Stop sharing"},"share.stopped":{zh:"已停止共享,参与者立即失去访问",en:"Sharing stopped — participants lost access immediately"},"share.copyLink":{zh:"复制链接",en:"Copy link"},"share.copyPageLink":{zh:"复制本页链接",en:"Copy link to this page"},"share.unpublish":{zh:"取消发布",en:"Unpublish"},"share.unpublished":{zh:"已取消发布,链接立即失效",en:"Unpublished — the link stopped working immediately"},"share.viewPage":{zh:"查看页面",en:"View page"},"share.viaFolder":{zh:"文件夹",en:"folder"},"share.viaPage":{zh:"页面",en:"page"},"share.inherited":{zh:"本页已通过上级{kind}《{name}》整体发布 —— 拿到链接的人都能只读查看本页,无需单独发布。",en:'This page is already published as part of the parent {kind} "{name}" — anyone with that link can view it read-only, so nothing needs publishing here.'},"share.inheritedStop":{zh:"要停止公开,请到该{kind}取消发布。",en:"To make it private again, unpublish that {kind}."},"share.publishIntro":{zh:"发布后,任何拿到链接的人**无需账号**即可只读查看这一页(含子页面)。",en:"Once published, anyone with the link can read this page and its subpages with **no account needed**."},"share.publish":{zh:"发布到公开链接",en:"Publish to a public link"},"share.published":{zh:"已发布,链接已生成",en:"Published — link ready"},"share.publishCount":{zh:"已发布 {used} / {total} 页。",en:"Published {used} / {total} pages."},"share.quotaReached":{zh:"已达套餐上限",en:"Plan limit reached"},"share.opFailed":{zh:"操作失败",en:"Something went wrong"},"share.syncOff":{zh:"关闭云同步(云端副本保留)",en:"Turn off cloud sync (the cloud copy is kept)"},"share.syncOn":{zh:"开启云同步(同步到云端工作区)",en:"Turn on cloud sync (sync to your cloud vault)"},"share.notUploaded":{zh:"云端还没有这一页(同步尚未完成或失败),稍后再试",en:"This page is not in the cloud yet (sync pending or failed). Try again later."},"share.notInCloud":{zh:"这一页还没有同步到云端 —— 共享和发布的都是云端副本,先在下方开启云同步,再回来生成链接。",en:"This page is not synced to the cloud yet. Sharing and publishing work on the cloud copy, so turn on cloud sync below first, then come back for a link."}});const ya=t=>Number.isFinite(t)?String(t):_("share.unlimited"),Cc=t=>(t.split("/").pop()??t).replace(/\.md$/i,"");function Pc({path:t,anchor:n,onClose:s}){const i=I(u=>u.vaultRoot),l=I(u=>u.vaultSide),o=Oe(u=>u.vaults),r=Rs(o,i,l,t)??"";return e.jsx(Tc,{path:r,localPath:t,anchor:n,onClose:s},JSON.stringify([i,l,t,r]))}function Tc({path:t,localPath:n,anchor:s,onClose:i}){const l=window.amadeusCollab,{t:o}=he(),r=(X,pe=!1)=>Ve.getState().toast(X,pe),u=c.useRef(!1),f=c.useRef(0),[h,j]=c.useState("share"),[m,y]=c.useState(null),[p,x]=c.useState(null),[O,T]=c.useState(null),[G,S]=c.useState({kind:"none"}),[M,R]=c.useState(0),[z,k]=c.useState(!1),[$,D]=c.useState(null),[K,Z]=c.useState(""),[ce,U]=c.useState(!1),re=()=>{if(!u.current||!l||!t)return;const X=++f.current,pe=()=>u.current&&X===f.current;l.pageShare(t).then(ue=>{pe()&&(y(ue.share),x(ue.quota),U(!1))}).catch(ue=>{pe()&&ue?.status===404&&U(!0)}),l.publishes().then(ue=>{if(!pe())return;x(ue.quota),R(ue.shares.length);const N=ue.shares.find(ie=>ie.path===t&&ie.mode==="page");T(N?{token:N.token,url:l.publishUrl(N.token)}:null),S(fi(t,ue.shares))}).catch(()=>{})};if(c.useEffect(()=>(u.current=!0,re(),()=>{u.current=!1,f.current++}),[l,t]),!l)return null;const we=(X,pe)=>{navigator.clipboard.writeText(X).then(()=>{u.current&&(D(pe),setTimeout(()=>{u.current&&D(null)},1200))})},Fe=(X,pe)=>{const ue=X;if(ue?.status===404){r(o("share.notUploaded"),!0);return}r(ue?.code==="QUOTA"?ue.message||o("share.quotaReached"):pe,!0)},ge=(X,pe,ue=o("share.opFailed"))=>{k(!0),X.then(()=>{u.current&&(pe&&r(pe),re())}).catch(N=>{u.current&&Fe(N,ue)}).finally(()=>{u.current&&k(!1)})};return e.jsx("div",{className:"amxc-cardwrap",onClick:i,children:e.jsxs(Et,{className:"amxc-card",x:s.x-340,y:s.y+6,onClick:X=>X.stopPropagation(),children:[e.jsxs("div",{className:"amxc-tabs",children:[e.jsx("button",{className:h==="share"?"on":"",onClick:()=>j("share"),children:o("share.tabShare")}),e.jsx("button",{className:h==="publish"?"on":"",onClick:()=>j("publish"),children:o("share.tabPublish")}),e.jsx("span",{className:"amxc-flex"}),e.jsx("button",{className:"amxc-x",onClick:i,children:e.jsx(zs,{size:14})})]}),t?ce?e.jsx("div",{className:"amxc-hint",style:{padding:"18px 8px"},children:o("share.ownerOnly")}):h==="share"?m?e.jsxs("div",{className:"amxc-body",children:[e.jsxs("div",{className:"amxc-frow",children:[e.jsx("input",{className:"amxc-input",readOnly:!0,value:l.inviteUrl(m.inviteToken)}),e.jsx("button",{className:"amxc-ic",title:o("share.copyInvite"),onClick:()=>we(l.inviteUrl(m.inviteToken),"inv"),children:$==="inv"?e.jsx(wt,{size:13}):e.jsx(Ut,{size:13})}),e.jsx("button",{className:"amxc-ic",title:o("share.rotate"),onClick:()=>ge(l.updatePageShare(m.id,{rotate:!0}),o("share.rotated")),children:e.jsx(ao,{size:13})})]}),e.jsxs("div",{className:"amxc-frow",children:[e.jsx("span",{className:"amxc-lbl",children:o("share.linkRole")}),e.jsxs("select",{value:m.inviteRole,onChange:X=>ge(l.updatePageShare(m.id,{role:X.target.value})),children:[e.jsx("option",{value:"editor",children:o("share.roleEditor")}),e.jsx("option",{value:"viewer",children:o("share.roleViewer")})]}),e.jsx("span",{className:"amxc-lbl",children:o("share.openFor")}),e.jsxs("select",{value:m.expiresAt===null?"forever":"7",onChange:X=>ge(l.updatePageShare(m.id,{expiresDays:X.target.value==="forever"?null:Number(X.target.value)})),children:[e.jsx("option",{value:"7",children:o("share.days7")}),e.jsx("option",{value:"30",children:o("share.days30")}),e.jsx("option",{value:"forever",children:o("share.forever")})]})]}),e.jsxs("div",{className:"amxc-frow",children:[e.jsx("span",{className:"amxc-lbl",children:o("share.password")}),m.hasPassword?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"amxc-tag",children:o("share.passwordSet")}),e.jsx("button",{className:"amxc-ic",title:o("share.clearPassword"),onClick:()=>ge(l.updatePageShare(m.id,{password:null}),o("share.passwordCleared")),children:e.jsx(Ye,{size:12})})]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"amxc-input",placeholder:o("share.passwordOptional"),value:K,onChange:X=>Z(X.target.value)}),e.jsx("button",{className:"amxc-ic",title:o("share.setPassword"),disabled:!K.trim(),onClick:()=>{const X=K.trim();Z(""),ge(l.updatePageShare(m.id,{password:X}),o("share.passwordSaved"))},children:e.jsx(wt,{size:13})})]})]}),e.jsx("div",{className:"amxc-sec",children:o("share.participants",{n:m.participants.length})}),m.participants.length===0&&e.jsx("div",{className:"amxc-hint",children:o("share.noParticipants")}),m.participants.map(X=>e.jsxs("div",{className:"amxc-row static",children:[e.jsx("span",{className:"amxc-row-name",children:X.username??X.userId.slice(0,8)}),e.jsxs("select",{value:X.role,onChange:pe=>ge(l.setParticipantRole(m.id,X.userId,pe.target.value)),children:[e.jsx("option",{value:"editor",children:o("share.roleEditor")}),e.jsx("option",{value:"viewer",children:o("share.roleViewer")})]}),e.jsx("button",{className:"amxc-ic",title:o("share.removeParticipant"),onClick:()=>ge(l.removeParticipant(m.id,X.userId),o("share.removed")),children:e.jsx(Ye,{size:12})})]},X.userId)),e.jsx("button",{className:"amxc-danger",disabled:z,onClick:()=>ge(l.revokePageShare(m.id),o("share.stopped")),children:o("share.stop")})]}):e.jsxs("div",{className:"amxc-body",children:[e.jsx("div",{className:"amxc-hint",children:o("share.intro")}),e.jsxs("button",{className:"amxc-primary",disabled:z||(p?p.collab<=0:!1),onClick:()=>ge(l.createPageShare(t,{role:"editor",expiresDays:7}),o("share.enabled")),children:[e.jsx(so,{size:13})," ",o("share.enable")]}),p&&(p.collab<=0?e.jsx("div",{className:"amxc-hint",children:o("share.planNoCollab")}):e.jsx("div",{className:"amxc-hint",children:o("share.quotaCollab",{n:ya(p.collab)})}))]}):e.jsxs("div",{className:"amxc-body",children:[O?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"amxc-frow",children:[e.jsx("input",{className:"amxc-input",readOnly:!0,value:O.url}),e.jsx("button",{className:"amxc-ic",title:o("share.copyLink"),onClick:()=>we(O.url,"pub"),children:$==="pub"?e.jsx(wt,{size:13}):e.jsx(Ut,{size:13})})]}),e.jsxs("div",{className:"amxc-frow",children:[e.jsx("button",{className:"amxc-danger",disabled:z,onClick:()=>ge(l.revokePublish(O.token),o("share.unpublished")),children:o("share.unpublish")}),e.jsx("a",{className:"amxc-view",href:O.url,target:"_blank",rel:"noreferrer",children:o("share.viewPage")})]})]}):G.kind==="inherited"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"amxc-hint",children:o("share.inherited",{kind:G.viaMode==="subtree"?o("share.viaFolder"):o("share.viaPage"),name:Cc(G.via)})}),e.jsxs("div",{className:"amxc-frow",children:[e.jsx("input",{className:"amxc-input",readOnly:!0,value:`${l.publishUrl(G.token)}#${encodeURIComponent(t)}`}),e.jsx("button",{className:"amxc-ic",title:o("share.copyPageLink"),onClick:()=>we(`${l.publishUrl(G.token)}#${encodeURIComponent(t)}`,"pub"),children:$==="pub"?e.jsx(wt,{size:13}):e.jsx(Ut,{size:13})})]}),e.jsx("div",{className:"amxc-hint",children:o("share.inheritedStop",{kind:G.viaMode==="subtree"?o("share.viaFolder"):o("share.viaPage")})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"amxc-hint",children:o("share.publishIntro")}),e.jsxs("button",{className:"amxc-primary",disabled:z,onClick:()=>ge(l.createPublish("page",t),o("share.published")),children:[e.jsx(Cs,{size:13})," ",o("share.publish")]})]}),p&&e.jsx("div",{className:"amxc-hint",children:o("share.publishCount",{used:M,total:ya(p.publish)})})]}):e.jsx("div",{className:"amxc-hint",style:{padding:"18px 8px"},children:o("share.notInCloud")}),e.jsx(Ec,{path:n,onClose:i})]})})}function Ec({path:t,onClose:n}){const s=I(r=>r.vaultRoot),i=I(r=>r.vaultSide);Oe(r=>r.vaults);const{t:l}=he();if(!window.amadeusSync?.entrySyncEnable||i!=="local")return null;const o=xn(s,t);return e.jsx("div",{className:"amxc-body",style:{borderTop:"1px solid var(--border, rgba(128,128,128,.25))",marginTop:4,paddingTop:8},children:o?e.jsxs("button",{className:"amxc-primary",onClick:()=>{window.amadeusSync.entrySyncDisable(t)},children:[e.jsx(ws,{size:13})," ",l("share.syncOff")]}):e.jsxs("button",{className:"amxc-primary",onClick:()=>{n(),Rt(t,"page")},children:[e.jsx(Yt,{size:13})," ",l("share.syncOn")]})})}Ne({"sharestatus.collabTitle":{zh:"本页正在协作共享 · 点击管理",en:"This page is being shared for collaboration — click to manage"},"sharestatus.collab":{zh:"协作中",en:"Collaborating"},"sharestatus.inheritedTitle":{zh:"已通过上级《{name}》发布 · 点击查看",en:'Published via the parent "{name}" — click to view'},"sharestatus.pubTitle":{zh:"本页已公开发布 · 点击管理",en:"This page is published publicly — click to manage"},"sharestatus.inherited":{zh:"已随文件夹发布",en:"Published via folder"},"sharestatus.published":{zh:"已发布",en:"Published"}});const Dc=t=>(t.split("/").pop()??t).replace(/\.md$/i,"");function Rc({path:t,refreshKey:n,onOpen:s}){const i=I(u=>u.vaultRoot),l=I(u=>u.vaultSide),o=Oe(u=>u.vaults),r=Rs(o,i,l,t);return e.jsx(Fc,{path:r??"",refreshKey:n,onOpen:s},JSON.stringify([i,l,t,r]))}function Fc({path:t,refreshKey:n,onOpen:s}){const i=window.amadeusCollab,[l,o]=c.useState(!1),[r,u]=c.useState({kind:"none"}),{t:f}=he();if(c.useEffect(()=>{if(!i||!t){o(!1),u({kind:"none"});return}let m=!0;return i.pageShare(t).then(y=>m&&o(!!y.share)).catch(()=>m&&o(!1)),i.publishes().then(y=>m&&u(fi(t,y.shares))).catch(()=>m&&u({kind:"none"})),()=>{m=!1}},[i,t,n]),!i)return null;const h=r.kind!=="none";if(!l&&!h)return null;const j=m=>{m.stopPropagation();const y=m.currentTarget.getBoundingClientRect();s(y.right,y.bottom)};return e.jsxs("span",{className:"amx-sharestat",children:[l&&e.jsxs("button",{className:"amx-sharestat-chip is-collab",title:f("sharestatus.collabTitle"),onClick:j,children:[e.jsx(Ha,{size:12})," ",f("sharestatus.collab")]}),h&&e.jsxs("button",{className:"amx-sharestat-chip is-pub",title:r.kind==="inherited"?f("sharestatus.inheritedTitle",{name:Dc(r.via)}):f("sharestatus.pubTitle"),onClick:j,children:[e.jsx(Cs,{size:12})," ",r.kind==="inherited"?f("sharestatus.inherited"):f("sharestatus.published")]})]})}const gt=t=>{const n=t.split(/[\\/]/).filter(Boolean);return n.pop(),n.join("/")};function Mc(t,n){return n?.mergedFd!=null?{folder:n.mergedFd}:/\.md$/i.test(t)&&!zt(t)&&!Ht(t)&&!n?.pluginFile?{page:t}:{folder:gt(t)}}const cs=t=>"page"in t?t.page:t.folder;function $c(t,n,s){return n&&t.includes(s.paths)&&!t.includes(s.ref)}Ne({"amxbl.prop":{zh:"属性",en:"Property"},"amxbl.unlinked":{zh:"未链接提及",en:"Unlinked mentions"},"amxbl.unlinkedCount":{zh:"未链接提及 · {n}",en:"Unlinked mentions · {n}"},"amxbl.unlinkedEmpty":{zh:"没有未链接的提及。",en:"No unlinked mentions."},"amxbl.link":{zh:"链接",en:"Link"},"amxbl.linkTip":{zh:"改写成 [[{inner}]]",en:"Turn into [[{inner}]]"},"amxbl.linkFailed":{zh:"这处提及在列出之后已被改动,没有改写。",en:"That mention changed after it was listed, so nothing was rewritten."}});const Oc=t=>(t.split(/[\\/]/).pop()??t).replace(/\.md$/i,"");function ja(t,n,s){const i=Oc(t),l=n.filter(r=>Bs(r)===Bs(t)).length<=1,o=l?i:t.replace(/\\/g,"/").replace(/\.md$/i,"");return s===i&&l?i:`${o}|${s}`}function Lc({h:t}){if(!t.match)return e.jsx(e.Fragment,{children:t.text});const n=t.text.toLowerCase().indexOf(t.match.toLowerCase());return n<0?e.jsx(e.Fragment,{children:t.text}):e.jsxs(e.Fragment,{children:[t.text.slice(0,n),e.jsx("mark",{children:t.text.slice(n,n+t.match.length)}),t.text.slice(n+t.match.length)]})}function Ic(){const{t}=he(),n=I(p=>p.activePage??p.activeNotePath),s=I(p=>p.linkGraphVersion),i=I(p=>p.pages),[l,o]=c.useState([]),[r,u]=c.useState(!1),[f,h]=c.useState(null),[j,m]=c.useState(0);c.useEffect(()=>{let p=!0;if(!n){o([]);return}return te.backlinks(n).then(x=>{p&&o(x)}),()=>{p=!1}},[n,s,j]),c.useEffect(()=>{let p=!0;if(!n||!r||!te.unlinkedMentions){h(null);return}return te.unlinkedMentions(n).then(x=>{p&&h(x)}).catch(()=>{p&&h([])}),()=>{p=!1}},[n,r,s,j]);const y=async(p,x)=>{if(!n||!te.linkMention||x.raw===void 0||x.occ===void 0||x.col===void 0||!x.match)return;const O=ja(n,i,x.match);await te.linkMention(p,{raw:x.raw,occ:x.occ,col:x.col,match:x.match},O).catch(()=>!1)||window.dispatchEvent(new CustomEvent("amadeus:toast",{detail:{text:_("amxbl.linkFailed")}})),m(G=>G+1)};return e.jsxs("div",{className:"amx-panel",children:[e.jsxs("div",{className:"amx-panel-head",children:[t("amadeus.backlinks")," · ",l.length]}),n?e.jsxs(e.Fragment,{children:[l.length===0?e.jsx("div",{className:"amx-panel-empty",children:t("amxv.backlinks.empty")}):e.jsx("div",{className:"amx-list",children:l.map(p=>e.jsxs("div",{className:"amx-backlink-group",children:[e.jsx("button",{className:"amx-list-item amx-backlink-src",onClick:x=>{Me(p.path,Xe(x))},title:p.path,children:p.title}),(p.hits??(p.snippet?[{line:1,text:p.snippet}]:[])).map((x,O)=>e.jsxs("button",{className:"amx-list-item amx-backlink-hit",onClick:T=>{Me(p.path,Xe(T))},children:[x.line===0&&e.jsx("span",{className:"amx-backlink-prop",children:t("amxbl.prop")}),x.text]},`${x.line}:${O}`))]},p.path))}),te.unlinkedMentions&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"amx-panel-head amx-backlink-toggle","aria-expanded":r,onClick:()=>u(p=>!p),children:[r?"▾ ":"▸ ",f&&r?t("amxbl.unlinkedCount",{n:f.length}):t("amxbl.unlinked")]}),r&&f&&(f.length===0?e.jsx("div",{className:"amx-panel-empty",children:t("amxbl.unlinkedEmpty")}):e.jsx("div",{className:"amx-list",children:f.map(p=>e.jsxs("div",{className:"amx-backlink-group",children:[e.jsx("button",{className:"amx-list-item amx-backlink-src",onClick:x=>{Me(p.path,Xe(x))},title:p.path,children:p.title}),p.hits.map((x,O)=>e.jsxs("div",{className:"amx-backlink-hit amx-mention",children:[e.jsx("button",{className:"amx-list-item amx-mention-text",onClick:T=>{Me(p.path,Xe(T))},children:e.jsx(Lc,{h:x})}),te.linkMention&&x.col!==void 0&&x.match&&e.jsx("button",{className:"amx-backlink-link",title:t("amxbl.linkTip",{inner:ja(n,i,x.match)}),onClick:()=>{y(p.path,x)},children:t("amxbl.link")})]},`${x.line}:${O}`))]},p.path))}))]})]}):e.jsx("div",{className:"amx-panel-empty",children:t("amxv.backlinks.noNote")})]})}Ne({"amxv.renameFailed":{zh:"重命名失败:{e}",en:"Rename failed: {e}"},"amxv.newBaseFailed":{zh:"新建 Base 失败:{e}",en:"Could not create the base: {e}"},"amxv.copyFailed":{zh:"复制失败:{e}",en:"Copy failed: {e}"},"amxv.fileCreatorFailed":{zh:"「{label}」失败:{e}",en:"“{label}” failed: {e}"},"amxv.confirm.deleteNote":{zh:"删除笔记「{name}」?此操作不可撤销。",en:"Delete the note “{name}”? This cannot be undone."},"amxv.confirm.deleteNoteWithChildren":{zh:"删除笔记「{name}」?其中包含 {n} 个子文件,将一并删除。此操作不可撤销。",en:"Delete the note “{name}”? It contains {n} sub-file(s) that will be deleted with it. This cannot be undone."},"amxv.confirm.deleteFile":{zh:"删除文件「{name}」?此操作不可撤销。",en:"Delete the file “{name}”? This cannot be undone."},"amxv.confirm.deleteFolder":{zh:"删除文件夹「{name}」及其全部内容?不可撤销。",en:"Delete the folder “{name}” and everything in it? This cannot be undone."},"amxv.confirm.deleteSelected":{zh:"删除选中的 {n} 项?",en:"Delete the {n} selected items?"},"amxv.trash.title":{zh:"回收站",en:"Trash"},"amxv.trash.entryTip":{zh:"查看回收站(删除的笔记/文件可恢复)",en:"Open the trash (deleted notes and files can be restored)"},"amxv.trash.confirmEmpty":{zh:"清空回收站?其中内容将永久删除。",en:"Empty the trash? Everything in it is deleted permanently."},"amxv.trash.emptyAction":{zh:"清空",en:"Empty"},"amxv.trash.origin":{zh:"原位置:{path}",en:"Original location: {path}"},"amxv.trash.restore":{zh:"恢复",en:"Restore"},"amxv.trash.confirmDelete":{zh:"彻底删除「{name}」?不可恢复。",en:"Permanently delete “{name}”? This cannot be undone."},"amxv.trash.emptyHint":{zh:"回收站是空的。",en:"The trash is empty."},"amxv.missing.title":{zh:"当前库里没有这篇笔记",en:"This note is not in the current vault"},"amxv.missing.sub":{zh:"「{path}」在这一侧不存在 —— 它可能属于另一侧(本地/云端)、已改名或已删除。这里不会替你新建同名空文件。",en:"“{path}” does not exist on this side. It may belong to the other side (local/cloud), or it was renamed or deleted. No empty file is created in its place."},"amxv.missing.close":{zh:"关闭标签页",en:"Close tab"},"amxv.pluginFile.title":{zh:"这个文件归插件管理",en:"This file belongs to a plugin"},"amxv.pluginFile.sub":{zh:"「{path}」是某个插件的专属格式,而那个插件没有安装或没有启用。当成笔记来编辑会改坏它的格式,所以这里不打开;启用对应的插件后再打开它。",en:"“{path}” is in a plugin’s own format, and that plugin is not installed or not enabled. Editing it as a note would break the format, so it is not opened here. Enable the plugin, then open the file again."},"amxv.sec.starred":{zh:"收藏",en:"Starred"},"amxv.sec.collections":{zh:"集合",en:"Collections"},"amxv.sec.searchTip":{zh:"搜索:{q}",en:"Search: {q}"},"amxv.sec.removeCollection":{zh:"移除集合",en:"Remove collection"},"amxv.sec.sharedWithMe":{zh:"与我共享",en:"Shared with me"},"amxv.sec.pinned":{zh:"置顶",en:"Pinned"},"amxv.sec.cloudSync":{zh:"云同步",en:"Cloud sync"},"amxv.sec.cloudWorkspace":{zh:"Cloud工作区",en:"Cloud vault"},"amxv.role.viewer":{zh:"只读",en:"Read-only"},"amxv.role.editor":{zh:"可编辑",en:"Can edit"},"amxv.cloudsync.hint":{zh:"拖入笔记/文件,或右键条目「开启云同步」",en:"Drag notes or files here, or right-click an item and choose “Turn on cloud sync”"},"amxv.skip.tooLarge":{zh:"超过云端单文件上限,云端不收",en:"Over the cloud file size limit — the cloud will not accept it"},"amxv.skip.assetMissing":{zh:"云端缺失",en:"Missing in the cloud"},"amxv.skip.summary":{zh:"⚠ {n} 项未同步{extra},悬停看明细",en:"⚠ {n} item(s) not synced{extra} — hover for details"},"amxv.skip.tooLargeNote":{zh:"(有文件超过云端单文件上限:笔记 5MB,附件随会员档位)",en:" (some files are over the per-file cloud limit: 5 MB for notes, plan-based for attachments)"},"amxv.cloud.dotTitle":{zh:"云端「{name}」",en:"Cloud “{name}”"},"amxv.cloud.skippedCount":{zh:"{n} 项跳过",en:"{n} skipped"},"amxv.cloud.notEnabled":{zh:"尚未开启云同步",en:"Cloud sync is not on yet"},"amxv.cloud.missing":{zh:"{path}(已不存在)",en:"{path} (no longer exists)"},"amxv.cloud.disableTip":{zh:"关闭云同步(云端副本保留)",en:"Turn off cloud sync (the cloud copy is kept)"},"amxv.empty":{zh:"空",en:"Empty"},"amxv.syncNotArrived":{zh:"同步内容尚未到达",en:"Synced content has not arrived yet"},"amxv.searchNotes":{zh:"搜索笔记",en:"Search notes"},"amxv.phone.tabs":{zh:"笔记分类",en:"Note lists"},"amxv.phone.tab.recent":{zh:"最近",en:"Recent"},"amxv.phone.tab.tree":{zh:"文件夹",en:"Folders"},"amxv.phone.tab.boards":{zh:"白板",en:"Whiteboards"},"amxv.phone.noRecent":{zh:"还没有最近打开的笔记",en:"No recently opened notes yet"},"amxv.phone.noBoards":{zh:"还没有白板",en:"No whiteboards yet"},"amxv.phone.new":{zh:"新建",en:"New"},"amxv.phone.hint":{zh:"向左滑动一行:收藏、重命名、删除。长按右下角的按钮:新建白板、文件夹等。",en:"Swipe a row left to star, rename or delete it. Press and hold the button at the bottom right for a new whiteboard, folder and more."},"amxv.noMatches":{zh:"没有匹配的笔记",en:"No matching notes"},"amxv.openVaultHint":{zh:"打开一个智库文件夹开始。",en:"Open a vault folder to get started."},"amxv.cloudVault":{zh:"云端智库",en:"Cloud vault"},"amxv.cloudVaultTip":{zh:"云端智库(切换 / 成员 / 分享)",en:"Cloud vault (switch / members / sharing)"},"amxv.vaultNamed":{zh:"智库:{name}",en:"Vault: {name}"},"amxv.openVault":{zh:"打开智库",en:"Open vault"},"amxv.folder.actions":{zh:"文件夹操作",en:"Folder actions"},"amxv.folder.newNoteHere":{zh:"在此文件夹新建笔记",en:"New note in this folder"},"amxv.renameFolder":{zh:"重命名文件夹",en:"Rename folder"},"amxv.menu.openInNewTab":{zh:"在新标签页打开",en:"Open in new tab"},"amxv.menu.openNInNewTabs":{zh:"在新标签页打开 {n} 项",en:"Open {n} items in new tabs"},"amxv.menu.deleteN":{zh:"删除 {n} 项",en:"Delete {n} items"},"amxv.menu.rename":{zh:"重命名",en:"Rename"},"amxv.menu.star":{zh:"收藏",en:"Star"},"amxv.menu.unstar":{zh:"取消收藏",en:"Unstar"},"amxv.menu.cloudSyncOff":{zh:"关闭云同步",en:"Turn off cloud sync"},"amxv.menu.cloudSyncOn":{zh:"开启云同步",en:"Turn on cloud sync"},"amxv.menu.reveal":{zh:"在文件管理器中显示",en:"Show in file manager"},"amxv.menu.delete":{zh:"删除",en:"Delete"},"amxv.menu.open":{zh:"打开",en:"Open"},"amxv.menu.openWithSystem":{zh:"用系统程序打开",en:"Open with the system app"},"amxv.menu.openBuiltinReader":{zh:"用内置阅读器打开",en:"Open with the built-in reader"},"amxv.menu.openDrawing":{zh:"打开白板",en:"Open whiteboard"},"amxv.menu.newSubfolder":{zh:"新建子文件夹",en:"New subfolder"},"amxv.menu.publishFolder":{zh:"发布此文件夹(公开链接)",en:"Publish this folder (public link)"},"amxv.menu.exportPdf":{zh:"导出为 PDF",en:"Export as PDF"},"amxv.menu.exportCanvas":{zh:"导出为 JSON Canvas",en:"Export as JSON Canvas"},"amxv.menu.deleteNote":{zh:"删除笔记",en:"Delete note"},"amxv.publish.done":{zh:"文件夹已发布,公开链接已复制(任何人可只读浏览)",en:"Folder published — the public link is copied (anyone can read it)"},"amxv.publish.quota":{zh:"发布页数已达套餐上限",en:"You have reached your plan limit for published pages"},"amxv.publish.ownerOnly":{zh:"只有库所有者能发布",en:"Only the vault owner can publish"},"amxv.publish.notUploaded":{zh:"云端尚未找到此文件夹,请等待同步完成后重试",en:"This folder is not in the cloud yet. Wait for sync to finish and try again."},"amxv.publish.failed":{zh:"发布失败",en:"Publishing failed"},"amxv.mbar.insertBlock":{zh:"插入块",en:"Insert block"},"amxv.uploadToPage":{zh:"上传文件到本页",en:"Upload files to this note"},"amxv.mbar.toDocument":{zh:"切换到文档",en:"Switch to document"},"amxv.mbar.toCanvas":{zh:"切换到画布",en:"Switch to canvas"},"amxv.mbar.undo":{zh:"撤销",en:"Undo"},"amxv.mbar.redo":{zh:"重做",en:"Redo"},"amxv.mbar.outdent":{zh:"减少缩进",en:"Outdent"},"amxv.mbar.indent":{zh:"增加缩进",en:"Indent"},"amxv.moreActions":{zh:"更多操作",en:"More actions"},"amxv.mbar.hideKeyboard":{zh:"收起键盘",en:"Hide keyboard"},"amxv.title.changeIcon":{zh:"更换/移除页面图标",en:"Change or remove the page icon"},"amxv.title.addIcon":{zh:"添加图标",en:"Add icon"},"amxv.title.addCover":{zh:"添加封面",en:"Add cover"},"amxv.pdf.exported":{zh:"已导出 PDF:{path}",en:"PDF exported: {path}"},"amxv.pdf.exportFailed":{zh:"导出 PDF 失败:{e}",en:"PDF export failed: {e}"},"amxv.pin":{zh:"置顶",en:"Pin"},"amxv.unpin":{zh:"取消置顶",en:"Unpin"},"amxv.shareOrPublish":{zh:"共享 / 发布",en:"Share / publish"},"amxv.toVisualLong":{zh:"切换到可视编辑(所见即所得)",en:"Switch to visual editing (WYSIWYG)"},"amxv.toVisual":{zh:"切换到可视编辑",en:"Switch to visual editing"},"amxv.toSource":{zh:"切换到源码 Markdown",en:"Switch to Markdown source"},"amxv.retry":{zh:"重试",en:"Retry"},"amxv.welcome.loadFailed":{zh:"📓 笔记加载失败",en:"📓 Could not load the note"},"amxv.welcome.title":{zh:"📓 笔记",en:"📓 Notes"},"amxv.welcome.pickNote":{zh:"从左栏选一篇笔记开始,或新建一篇。",en:"Pick a note in the sidebar to get started, or create a new one."},"amxv.welcome.noVault":{zh:"把任意文件夹选作你的智库就能开写 —— 所见即所得,像 Obsidian 一样用双链把想法连起来。",en:"Choose any folder as your vault and start writing — WYSIWYG editing, with Obsidian-style wikilinks to connect your ideas."},"amxv.welcome.tutorial":{zh:"使用教程",en:"Tutorial"},"amxv.welcome.manual":{zh:"使用手册",en:"User manual"},"amxv.welcome.openVaultFolder":{zh:"打开智库文件夹",en:"Open a vault folder"},"amxv.welcome.tip1":{zh:"引用其它笔记,自动生成反向链接",en:"links to another note, and backlinks are generated automatically"},"amxv.welcome.tip2":{zh:"拖入图片 / 文件直接插入;支持多维表块、LaTeX、代码高亮",en:"Drop in images or files to insert them; database blocks, LaTeX and syntax highlighting are all supported"},"amxv.welcome.tip3":{zh:"顶栏切「可视 / 源码」,右上角 ⋮ 可导出 PDF",en:"Toggle visual / source mode in the top bar; export to PDF from the ⋮ menu"},"amxv.floatingToc":{zh:"笔记目录",en:"Note table of contents"},"amxv.outline.empty":{zh:"没有标题",en:"No headings"},"amxv.outline.noNote":{zh:"未指定笔记",en:"No note specified"},"amxv.backlinks.noNote":{zh:"未打开笔记",en:"No note open"},"amxv.backlinks.empty":{zh:"还没有其它笔记链接到这里",en:"No other notes link here yet"}});const je=()=>I.getState(),ye=t=>t.split(/[\\/]/).pop().replace(/\.md$/,""),En=t=>t.split("/").pop()||t,pt=t=>{const n=[];let s="";for(const i of t.split(/[\\/]/).filter(Boolean))s=s?`${s}/${i}`:i,n.push(s);return n};function gi(t,n){const s=$e.getState();for(const i of s.api?.panels??[]){const l=i.params??{};l.__type==="amadeus-editor"&&l.notePath===t&&s.navigateLeaf(i.id,"amadeus-editor",{...l,notePath:n})}}async function ka(t,n){try{await Ao();const s=await te.renamePageFile(t,n);if(s!==t){cn(t,"file",s),Bo(t,s,"file"),await Vo(t,s),gi(t,s);const i=je();i.activePage===s&&i.loadPage(s)}}catch(s){window.alert(_("amxv.renameFailed",{e:s instanceof Error?s.message:String(s)}))}await je().refreshStructure()}const Ac=()=>!!te.trashEntry;function Bc(t){const n=Ct(t),s=[...je().pages,...je().files].filter(i=>i.startsWith(`${n}/`)).length;return s>0?_("amxv.confirm.deleteNoteWithChildren",{name:ye(t),n:s}):_("amxv.confirm.deleteNote",{name:ye(t)})}async function fn(t,n=je){if(!$n("note",t))return;const s=await te.exclusiveAssets?.(t).catch(()=>[])??[];let i=s.length>0?Tr():!1;if(s.length>0&&i===null){const l=await Er(ye(t),s);if(l===null)return;i=l==="with"}Hn.getState().remove(`note:${t}`),await n().deletePage(t),i&&(await Po(s),await n().refreshStructure())}function $n(t,n){return Ac()?!0:t==="note"?window.confirm(Bc(n)):t==="file"?window.confirm(_("amxv.confirm.deleteFile",{name:n.split(/[\\/]/).pop()})):window.confirm(_("amxv.confirm.deleteFolder",{name:n.split(/[\\/]/).pop()}))}const xi=Qt(t=>({locate:null,requestLocate:n=>t(s=>({locate:{path:n,n:(s.locate?.n??0)+1}}))}));I.subscribe((t,n)=>{const s=t.activePage;if(!s||s===n.activePage||Ht(s)&&io()!=="mini")return;const i=Un();queueMicrotask(()=>{const l=$e.getState().api,o=l?Ps(l):null,r=o&&(o.params??{}).__type==="amadeus-editor"&&o.id===i?o.id:i;Ka(r,`amadeus:${s}`,()=>{const u=$e.getState(),f=r?u.leafById(r):null;f&&(f.type!=="amadeus-editor"&&u.navigateLeaf(r,"amadeus-editor",{notePath:s}),Ns(r).getState().loadPage(s))})}),Hn.getState().record({key:`note:${s}`,kind:"note",id:s,title:ye(s)})});function Ls({path:t,hideLoneLeaf:n}={}){const s=I(m=>m.activePage),i=xi(m=>m.requestLocate),l=t??s;if(!l||n&&!l.includes("/"))return null;const o=l.replace(/(\.dashboard)?\.md$/i,"").split("/"),r=qa(l),u=r?Vt(l,r.extensions):o[o.length-1],f=o.slice(0,-1).map((m,y)=>({seg:m,target:o.slice(0,y+1).join("/")})),h=f.length>3?[...f.slice(0,2),{seg:"…",target:null},f[f.length-1]]:f,j=h.length;return e.jsxs("div",{className:"amx-crumbs",children:[j>0&&e.jsx("span",{className:"amx-crumbs-parents",children:e.jsx("span",{className:"amx-crumbs-parents-in",children:h.map((m,y)=>e.jsxs("span",{className:"amx-crumb-seg",style:{"--d":`${(j-1-y)*25}ms`},children:[m.target?e.jsx("button",{className:"amx-crumb",title:m.target,onClick:()=>i(m.target),children:m.seg.replace(/\.fd$/i,"")}):e.jsx("span",{className:"amx-crumb amx-crumb-ellipsis",title:l,children:"…"}),e.jsx("span",{className:"amx-crumb-sep",children:"/"})]},`${m.target??"gap"}-${y}`))})}),e.jsx("button",{className:"amx-crumb amx-crumb-leaf",title:l,onClick:()=>i(l),children:u})]})}const yt=t=>/\.md$/i.test(t),Tt=t=>/\.db$/i.test(t),Sa=t=>/\.pdf$/i.test(t),Dn=t=>/\.(png|jpe?g|gif|webp|svg|avif|bmp|ico)$/i.test(t),Na=t=>(t.split(/[\\/]/).pop()||t).replace(/\.db$/i,"");function Vc(){const{t}=he(),[n,s]=c.useState(null),[i,l]=c.useState(!1),o=!!te.listTrash,r=()=>{te.listTrash?.().then(s).catch(()=>{})};if(c.useEffect(()=>{o&&r()},[o]),c.useEffect(()=>{if(o)return te.onStructureChange(()=>r())},[o]),!o)return null;const u=n?.length??0,f=h=>{const j=h.replace(/\\/g,"/").lastIndexOf("/");return j===-1?"/":h.slice(0,j)};return e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"t2s-special amx-trash-entry",onClick:()=>{r(),l(!0)},title:t("amxv.trash.entryTip"),children:[e.jsx("span",{className:"t2s-special-ic",children:e.jsx(Ye,{})}),e.jsxs("span",{className:"t2s-special-title",children:[t("amxv.trash.title"),u>0?` (${u})`:""]})]}),i&&e.jsx("div",{className:"amx-trash-wrap",onMouseDown:()=>l(!1),children:e.jsxs("div",{className:"amx-trash-pop",onMouseDown:h=>h.stopPropagation(),children:[e.jsxs("div",{className:"amx-trash-head",children:[e.jsx("span",{children:t("amxv.trash.title")}),u>0&&e.jsx("button",{className:"amx-trash-clear",onClick:()=>{window.confirm(t("amxv.trash.confirmEmpty"))&&te.emptyTrash?.().then(r)},children:t("amxv.trash.emptyAction")})]}),e.jsxs("div",{className:"amx-trash-list",children:[(n??[]).map(h=>e.jsxs("div",{className:"amx-trash-row",children:[e.jsx("span",{className:"amx-trash-ic",children:h.dir?e.jsx(Ds,{}):e.jsx(Xt,{})}),e.jsxs("span",{className:"amx-trash-name",title:t("amxv.trash.origin",{path:h.original}),children:[h.name,e.jsx("span",{className:"amx-trash-orig",children:f(h.original)})]}),e.jsx("button",{className:"amx-trash-act",onClick:()=>{te.restoreTrash?.(h.name).then(()=>{r(),je().refreshStructure()})},children:t("amxv.trash.restore")}),e.jsx("button",{className:"amx-trash-act amx-trash-danger",onClick:()=>{window.confirm(t("amxv.trash.confirmDelete",{name:h.name}))&&te.deleteTrashEntry?.(h.name).then(r)},"aria-label":"delete forever",children:t("amxv.menu.delete")})]},h.name)),u===0&&e.jsx("div",{className:"t2s-hint",children:t("amxv.trash.emptyHint")})]})]})})]})}function _c({row:t,pages:n}){const{t:s}=he(),i=Pe(y=>y.starred),l=Pe(y=>y.collections),[o,r]=Vn("starred"),[u,f]=Vn("collections"),h=new Set(n),j=i.filter(y=>h.has(y));if(!j.length&&!l.length)return null;const m=(y,p,x,O)=>p.length>0&&e.jsxs("div",{className:"amx-prefs-group",children:[e.jsx("button",{className:"t2s-group-toggle amx-sec-grab",onClick:O,children:e.jsxs("span",{className:"t2s-group-name amx-sec-head",children:[e.jsx("span",{className:"t2s-group-label",children:y}),e.jsx("span",{className:`t2s-chev${x?" open":""}`,children:e.jsx(qt,{size:12})}),e.jsx("span",{className:"t2s-count",children:p.length})]})}),x&&e.jsx("div",{className:"t2s-group-sessions",children:p.map(T=>t(T))})]});return e.jsxs(e.Fragment,{children:[m(s("amxv.sec.starred"),j,o,r),l.length>0&&e.jsxs("div",{className:"amx-prefs-group",children:[e.jsx("button",{className:"t2s-group-toggle amx-sec-grab",onClick:f,children:e.jsxs("span",{className:"t2s-group-name amx-sec-head",children:[e.jsx("span",{className:"t2s-group-label",children:s("amxv.sec.collections")}),e.jsx("span",{className:`t2s-chev${u?" open":""}`,children:e.jsx(qt,{size:12})}),e.jsx("span",{className:"t2s-count",children:l.length})]})}),u&&e.jsx("div",{className:"t2s-group-sessions",children:l.map(y=>e.jsxs("div",{className:"t2s-srow amx-coll-row",role:"button",tabIndex:0,title:s("amxv.sec.searchTip",{q:y.query}),onClick:()=>{Io(),li.getState().request(y.query)},children:[e.jsx("span",{className:"amx-coll-ic",children:e.jsx(ks,{})}),e.jsx("span",{className:"amx-coll-name",children:y.name}),e.jsx("button",{className:"amx-coll-del",title:s("amxv.sec.removeCollection"),"aria-label":"remove collection",onClick:p=>{p.stopPropagation(),Pe.getState().removeCollection(y.name)},children:"✕"})]},y.name))})]})]})}function Wc(){const{t}=he(),n=window.amadeusCollab,[s,i]=c.useState([]),[l,o]=c.useState("");return c.useEffect(()=>{n&&(n.sharedWithMe().then(i).catch(()=>{}),n.activeVaultId().then(o).catch(()=>{}))},[n]),!n||s.length===0?null:e.jsxs("div",{className:"t2s-special-group",style:{marginTop:6},children:[e.jsx("div",{className:"t2s-hint amx-sec-grab",style:{padding:"2px 10px 2px",fontSize:"var(--ui-font-caption, 11px)"},children:t("amxv.sec.sharedWithMe")}),s.map(r=>e.jsxs("button",{className:"t2s-special",title:`${r.ownerName??""} · ${r.role==="viewer"?t("amxv.role.viewer"):t("amxv.role.editor")}`,onClick:u=>{r.localPath?Me(r.localPath,Xe(u)):r.vaultId===l?Me(r.path,Xe(u)):n.switchVault(r.vaultId)},children:[e.jsx("span",{className:"t2s-special-ic",children:e.jsx(In,{})}),e.jsx("span",{className:"t2s-special-title",children:r.title})]},`${r.vaultId}:${r.path}`))]})}function Wn({id:t,defaultOpen:n,label:s,count:i,extra:l,dropProps:o,dropActive:r,children:u}){const[f,h]=Vn(t,n);return e.jsxs("div",{className:`amx-prefs-group${r?" amx-drop-into":""}`,...o,children:[e.jsx("button",{className:"t2s-group-toggle amx-sec-grab",onClick:h,children:e.jsxs("span",{className:"t2s-group-name amx-sec-head",children:[e.jsx("span",{className:"t2s-group-label",children:s}),e.jsx("span",{className:`t2s-chev${f?" open":""}`,children:e.jsx(qt,{size:12})}),i!==void 0&&e.jsx("span",{className:"t2s-count",children:i}),l]})}),f&&e.jsx("div",{className:"t2s-group-sessions",children:u})]})}function Uc({row:t,dragPath:n}){const{t:s}=he(),i=Pe(j=>j.pins),l=I(j=>j.pages),o=I(j=>j.vaultRoot),[r,u]=c.useState(!1),f=c.useMemo(()=>l.filter(j=>i.includes(j)),[l,i]);if(!o||!f.length)return null;const h=!!n&&yt(n)&&!i.includes(n);return e.jsx(Wn,{id:"pinned",label:s("amxv.sec.pinned"),count:f.length,dropActive:r,dropProps:{onDragOver:j=>{h&&(j.preventDefault(),j.stopPropagation(),j.dataTransfer.dropEffect="move",r||u(!0))},onDragLeave:()=>u(!1),onDrop:j=>{h&&(j.preventDefault(),j.stopPropagation(),u(!1),Pe.getState().togglePin(n))}},children:f.map(j=>t(j))})}const Hc=t=>t==="TOO_LARGE"?_("amxv.skip.tooLarge"):t==="ASSET_404"?_("amxv.skip.assetMissing"):t,vi=t=>e.jsx("div",{className:"t2s-hint amx-sec-hint amx-cs-warn",title:t.map(n=>`${n.path} — ${Hc(n.reason)}`).join(`
8
+ `),children:_("amxv.skip.summary",{n:t.length,extra:t.some(n=>n.reason==="TOO_LARGE")?_("amxv.skip.tooLargeNote"):""})});function qc(){he();const[t,n]=c.useState(null);return c.useEffect(()=>{const s=window.amadeusSync;if(s)return s.get().then(n).catch(()=>{}),s.onStatus(i=>{i.binding||n(i)})},[]),!t?.enabled||!t.skipped.length?null:vi(t.skipped)}function Kc({dragPath:t}){const{t:n}=he(),s=I(R=>R.vaultRoot),i=I(R=>R.pages),l=I(R=>R.files),o=I(R=>R.folders),r=Oe(R=>R.vaults),u=Oe(R=>s?R.status[s]:void 0),[f,h]=c.useState(!1),j=r.find(R=>R.vaultRoot===s);if(!window.amadeusSync?.entrySyncEnable||!s)return null;const m=j?.entries??[];if(!m.length&&!u?.skipped.length)return null;const y=R=>R.replace(/\\/g,"/").normalize("NFC"),p=new Set(i.map(y)),x=new Set(l.map(y)),O=new Set(o.map(y)),T=R=>R.kind==="folder"?O.has(R.path):R.kind==="page"?p.has(R.path):x.has(R.path),G=u?.state==="error"||u?.state==="auth-required"?"err":u?.state==="offline"?"off":"ok",S=j?`${n("amxv.cloud.dotTitle",{name:j.cloudName})}${u?` · ${u.state}${u.skipped.length?` · ${n("amxv.cloud.skippedCount",{n:u.skipped.length})}`:""}`:""}`:n("amxv.cloud.notEnabled"),M=!!t&&!xn(s,t);return e.jsxs(Wn,{id:"cloudsync",label:n("amxv.sec.cloudSync"),count:m.length,extra:j?e.jsx("span",{className:`amx-sync-dot ${G}`,title:S}):void 0,dropActive:f,dropProps:{onDragOver:R=>{M&&(R.preventDefault(),R.stopPropagation(),R.dataTransfer.dropEffect="move",f||h(!0))},onDragLeave:()=>h(!1),onDrop:R=>{M&&(R.preventDefault(),R.stopPropagation(),h(!1),Rt(t,yt(t)?"page":"asset"))}},children:[!m.length&&e.jsx("div",{className:"t2s-hint amx-sec-hint",children:n("amxv.cloudsync.hint")}),!!u?.skipped.length&&vi(u.skipped),m.map(R=>{const z=T(R);return e.jsxs("div",{className:`t2s-srow amx-cs-row${z?"":" amx-cs-ghost"}`,role:"button",tabIndex:0,title:z?R.path:n("amxv.cloud.missing",{path:R.path}),onClick:k=>{z&&(R.kind==="page"?Me(R.path,Xe(k)):R.kind==="asset"&&Tt(R.path)&&Fn(R.path,Xe(k)))},children:[e.jsx("span",{className:"amx-cs-ic",children:R.kind==="folder"?e.jsx(Ds,{}):R.kind==="page"?e.jsx(Xt,{}):e.jsx(gn,{})}),e.jsx("span",{className:"t2s-srow-title",children:R.kind==="page"?ye(R.path):R.path.split(/[\\/]/).pop()}),e.jsx("button",{className:"amx-coll-del",title:n("amxv.cloud.disableTip"),onClick:k=>{k.stopPropagation(),window.amadeusSync?.entrySyncDisable?.(R.path)},children:"✕"})]},R.path)})]})}const Gc=[],za=[];function Yc(){const{t}=he(),n=I(a=>a.pages),s=I(a=>a.folders),i=I(a=>a.files),l=I(a=>a.icons),o=I(a=>a.pendingPage??a.activePage??a.activeNotePath),r=I(a=>a.vaultRoot),u=I(a=>a.vaultSide),f=I(a=>a.vaultLoading),h=!!window.amadeusCloudVaults||u==="cloud",[j,m]=c.useState(""),[y,p]=c.useState(new Set),[x,O]=c.useState(!1),[T,G]=c.useState(null),[S,M]=c.useState(null),R=c.useRef(null),z=ro(R),k=lo(),[$,D]=c.useState(()=>{try{const a=localStorage.getItem("forsion_notes_phone_tab");return a==="recent"||a==="tree"||a==="boards"?a:null}catch{return null}}),K=Hn(a=>k?a.items:Gc),Z=Pe(a=>k?a.recents:za),ce=Pe(a=>k?a.starred:za),U=c.useMemo(()=>{const a=new Set([...n,...i]),b=new Set,g=[];for(const E of K)(E.kind==="note"||E.kind==="file")&&a.has(E.id)&&!b.has(E.id)&&(b.add(E.id),g.push({path:E.id,at:E.ts}));for(const E of Z)a.has(E)&&!b.has(E)&&(b.add(E),g.push({path:E,at:0}));return g},[K,Z,n,i]),re=c.useMemo(()=>[...new Set([...i,...n])].filter(zt).sort((a,b)=>ye(a).localeCompare(ye(b))),[n,i]),we=$??(U.length?"recent":"tree"),Fe=a=>{D(a);try{localStorage.setItem("forsion_notes_phone_tab",a)}catch{}},ge=k&&!!r&&we!=="tree",X=()=>ps.getState().openPalette();qr(R,k?X:void 0);const pe=co(a=>a.items.find(b=>b.id==="rb-units-mobile"));uo(k?{where:"list",search:{label:t("amxv.searchNotes"),run:X},...r?{title:{sub:u==="cloud"?t("amxv.cloudVault"):ye(r),run:pe?.onClick}}:{}}:null);const[ue,N]=c.useState(()=>{try{const a=JSON.parse(localStorage.getItem("amx.sec.order")||"[]");return Array.isArray(a)?a.filter(b=>typeof b=="string"):[]}catch{return[]}}),[ie,ne]=c.useState(null),[xe,ke]=c.useState(null),[Ue,P]=c.useState(null);c.useEffect(()=>{if(!ie)return;const a=()=>ne(null);return window.addEventListener("pointerup",a),window.addEventListener("pointercancel",a),()=>{window.removeEventListener("pointerup",a),window.removeEventListener("pointercancel",a)}},[ie]);const A=["pinned","cloudsync","shared","prefs","tree"],H=new Map(ue.map((a,b)=>[a,b])),Y=ue.length?[...A].sort((a,b)=>(H.get(a)??ue.length)-(H.get(b)??ue.length)):A,fe=(a,b,g)=>{const E=Y.filter(ve=>ve!==a),de=E.indexOf(b);E.splice(de<0?E.length:g?de+1:de,0,a),N(E);try{localStorage.setItem("amx.sec.order",JSON.stringify(E))}catch{}},se=(a,b)=>e.jsx("div",{className:`amx-sec-wrap${Ue===a&&xe&&xe!==a?" amx-sec-over":""}`,draggable:ie===a,onPointerDown:g=>{g.pointerType!=="mouse"||g.button!==0||g.target.closest(".amx-sec-grab")&&ne(a)},onDragStart:g=>{if(ie===a){g.stopPropagation(),g.dataTransfer.effectAllowed="move";try{g.dataTransfer.setData("application/x-amx-section",a)}catch{}ke(a)}},onDragEnd:()=>{ke(null),P(null),ne(null)},onDragOver:g=>{!xe||xe===a||(g.preventDefault(),g.stopPropagation(),g.dataTransfer.dropEffect="move",Ue!==a&&P(a))},onDragLeave:g=>{Ue===a&&!g.currentTarget.contains(g.relatedTarget)&&P(null)},onDrop:g=>{if(!xe||xe===a)return;g.preventDefault(),g.stopPropagation();const E=g.currentTarget.getBoundingClientRect();fe(xe,a,g.clientY>E.top+E.height/2),ke(null),P(null)},children:b},a),[F,W]=c.useState(null),[Je,Ze]=Vn("vault",!0),[_e,ut]=c.useState(null),[Qe,bt]=c.useState(""),Te=c.useRef(null),Le=xi(a=>a.locate),[qe,it]=c.useState(null),We=c.useRef(null);c.useEffect(()=>{ho()},[]),c.useEffect(()=>{ri(),Oe.getState().refresh()},[r,n,s]);const oe=Oe(a=>a.vaults),ht=Oe(a=>a.mirrorVaults);c.useEffect(()=>{_e&&Te.current?.select()},[_e]),c.useEffect(()=>{if(!F)return;const a=()=>W(null);return window.addEventListener("click",a),window.addEventListener("contextmenu",a),()=>{window.removeEventListener("click",a),window.removeEventListener("contextmenu",a)}},[F]),c.useEffect(()=>{if(!Le)return;const a=s.includes(Le.path)?Le.path:gt(Le.path);a&&p(g=>new Set([...g,...pt(a)])),it(Le.path);const b=setTimeout(()=>it(null),1200);return()=>clearTimeout(b)},[Le?.n]),c.useEffect(()=>{qe&&We.current?.scrollIntoView({block:"nearest"})},[qe]);const Ee=j.trim().toLowerCase(),Ie=c.useMemo(()=>Wr(Ur([...n,...i],s)),[n,i,s]),Ke=c.useMemo(()=>Ee?[...n,...i].filter(a=>ye(a).toLowerCase().includes(Ee)):[],[Ee,n,i]),[et,jt]=c.useState([]);c.useEffect(()=>{const a=window.amadeusCloudVaults;if(!a||window.amadeusSync)return;let b=!0;return a().then(g=>{b&&jt(g)}).catch(()=>{}),()=>{b=!1}},[n,s]);const ot=c.useMemo(()=>{const a=!!window.amadeusSync&&u==="cloud",b=!window.amadeusSync&&!!window.amadeusCloudVaults;if(!a&&!b)return null;const g=a?[...new Set([...oe.map(L=>L.cloudName),...ht])].sort():et,E=new Map(Ie.children.filter(L=>L.kind==="folder").map(L=>[L.path,L])),de=g.map(L=>({name:L,node:E.get(L)??null})),ve=new Set(g),De=Ie.children.filter(L=>!(L.kind==="folder"&&ve.has(L.path)));return{vaultSecs:de,rest:De}},[Ie,oe,ht,u,et]),mt=$e(a=>a.mainTabs),w=c.useMemo(()=>{const a=$e.getState().api,b=a?Ps(a):null,g=b?{id:b.id,type:String((b.params??{}).__type??"")}:mt.find(ve=>ve.active),E=g&&mo[g.type],de=E?$e.getState().leafById(g.id)?.params?.[E]:null;return typeof de=="string"?de:null},[mt]),V=ms(a=>a.fileTypes),J=ms(a=>a.fileCreators),Q=(a,b,g)=>{W(null),a&&p(E=>new Set([...E,...pt(a)])),Promise.resolve().then(()=>g(a)).catch(E=>{console.error("[plugin] file creator failed",E),Ve.getState().toast(_("amxv.fileCreatorFailed",{label:b,e:E instanceof Error?E.message:String(E)}),!0)})},Ce=a=>p(b=>{const g=new Set(b);return g.has(a)?g.delete(a):g.add(a),g}),Re=a=>{const b=(T?z.batch(T):[]).filter(E=>{if(gt(E)===a)return!1;if(Nn(E)){const de=Ct(E);if(a===de||a.startsWith(`${de}/`))return!1}return!0});G(null),M(null);const g=Ns(Un());(async()=>{for(const E of b)await g.getState().movePage(E,a)})().catch(E=>g.setState({error:String(E)}))},tt=a=>Array.from(a.dataTransfer?.types??[]).includes("Files"),Ae=a=>$c(Array.from(a.dataTransfer?.types??[]),!!r&&!!window.tangu?.copyHostFiles&&!(window.amadeusSync&&u==="cloud"),{paths:ts,ref:Ja}),vn=a=>{if(!Ae(a))return[];try{const b=JSON.parse(a.dataTransfer?.getData(ts)||"null");return Array.isArray(b)?b:[]}catch{return[]}},en=(a,b)=>{const g=vn(a);return g.length?(a.preventDefault(),a.stopPropagation(),M(null),window.tangu.copyHostFiles(g,b?`${r}/${b}`:r).catch(E=>$a.getState().notify(_("amxv.copyFailed",{e:E instanceof Error?E.message:String(E)}))).finally(()=>{je().refreshStructure()}),!0):!1},Kn=(a,b)=>{const g=vn(a);return g.length?(a.preventDefault(),a.stopPropagation(),M(null),Me(b).then(()=>ic(g)).then(E=>{E.length&&wn(E,b)}),!0):!1},Mt=(a,b)=>!tt(a)&&!Ae(a)?!1:(a.preventDefault(),a.stopPropagation(),a.dataTransfer&&(a.dataTransfer.dropEffect="copy"),S!==b&&M(b),!0),kt=(a,b)=>{if(en(a,b))return!0;const g=Array.from(a.dataTransfer?.files??[]);return g.length?(a.preventDefault(),a.stopPropagation(),M(null),pa(g,b),!0):!1},St=(a,b)=>Mc(a,{mergedFd:b,pluginFile:!!ft(V,a)}),wn=(a,b)=>{us(b,a)||Bn(a,b)},tn=(a,b,g)=>Mt(a,cs(St(b,g))),Gn=(a,b,g)=>{const E=St(b,g);if("page"in E?Kn(a,E.page):en(a,E.folder))return!0;const de=Array.from(a.dataTransfer?.files??[]);if(!de.length)return!1;a.preventDefault(),a.stopPropagation(),M(null);const ve=St(b,g);return"page"in ve?Me(ve.page).then(()=>wn(de,ve.page)):pa(de,ve.folder),!0},bn=(a,b)=>!tt(a)&&!Ae(a)?!1:(a.target.closest(b)||Mt(a,""),!0),nn=(a,b)=>!tt(a)&&!Ae(a)?!1:(a.target.closest(b)||kt(a,""),!0),$t=()=>{const a=_e;ut(null);const b=Qe.trim();if(!a||!b)return;const g=ft(V,a);if(g){const E=g.extensions.find(ve=>a.toLowerCase().endsWith(ve.toLowerCase()));if(!E||!/\.md$/i.test(E))return;const de=Hr(b,E);de!==Vt(a,g.extensions)+E.replace(/\.md$/i,"")&&ka(a,de);return}yt(a)?b!==ye(a)&&ka(a,b):Tt(a)&&b.replace(/\.db$/i,"")!==Na(a)&&Lo(a,b).catch(E=>window.alert(_("amxv.renameFailed",{e:E instanceof Error?E.message:String(E)})))},Ot=a=>{const b=ft(V,a);bt(b?Vt(a,b.extensions):Tt(a)?Na(a):ye(a)),ut(a),W(null)},sn=async a=>{const b=(await rt(a?_("amadeus.new.folderIn",{folder:En(a)}):_("amadeus.new.folder"),_("amadeus.default.folder")))?.trim();b&&(je().createFolder(a,b),p(g=>new Set([...g,...pt(a?`${a}/${b}`:b)]))),W(null)},yn=async a=>{W(null);const b=(await rt(a?_("amadeus.new.databaseIn",{folder:En(a)}):_("amadeus.new.database"),_("amadeus.default.database")))?.trim().replace(/[\\/]/g,"");if(!b)return;const g=a?`${a}/${b}.db`:`${b}.db`;if(je().files.some(E=>E.replace(/\\/g,"/")===g)){window.alert(_("amadeus.exists",{name:`${b}.db`}));return}(async()=>{const E=new TextEncoder().encode($i(Oi(b)));await te.saveAttachment("",`${b}.db`,E,{mode:"vault",folder:a}),To("base.create"),Eo("base.create",{f:g}),await je().refreshStructure(),a&&p(de=>new Set([...de,...pt(a)])),Fn(g)})().catch(E=>window.alert(_("amxv.newBaseFailed",{e:E instanceof Error?E.message:String(E)})))},Nt=a=>{W(null),zo(a).then(b=>{b&&a&&p(g=>new Set([...g,...pt(a)]))})},jn=a=>{W(null),Do(a).then(b=>{b&&a&&p(g=>new Set([...g,...pt(a)]))})},d=()=>[{id:"new-note",label:t("amadeus.new.note"),icon:e.jsx(At,{size:13}),run:()=>{je().createPage(),W(null)}},{id:"new-folder",label:t("amadeus.new.folder"),icon:e.jsx(la,{size:13}),run:()=>{sn("")}},{id:"new-database",label:t("amadeus.new.database"),icon:e.jsx(kn,{size:13}),run:()=>{yn("")}},{id:"new-drawing",label:t("amadeus.new.drawing"),icon:e.jsx(rn,{size:13}),run:()=>Nt("")},{id:"new-dashboard",label:t("amadeus.new.dashboard"),icon:e.jsx(Pn,{size:13}),run:()=>jn("")},...J.map(a=>({id:`creator:${a.item.id}`,label:a.item.label,icon:e.jsx("span",{style:{display:"inline-flex",width:13,justifyContent:"center",fontSize:13},children:Qn(a.item.icon,"📄")}),run:()=>Q("",a.item.label,a.item.run)}))],v=F?.kind==="root"?F:null,C=Kr(v,()=>v&&{title:t("amxv.phone.new"),sections:[{items:d()}]},()=>W(null)),B=(a,b,g)=>{if(!Mt(a,g)&&T&&(a.stopPropagation(),!(T===b||gt(T)===g))){if(Nn(T)){const E=Ct(T);if(g===E||g.startsWith(`${E}/`))return}a.preventDefault(),a.dataTransfer.dropEffect="move",S!==g&&M(g)}},ae=a=>()=>r?ol(`${r}/${a}`,yt(a)?ye(a):a.split(/[\\/]/).pop()??a):null,ee=a=>{je().createChildNote(a,_("amadeus.default.note")).then(b=>{p(g=>new Set([...g,...pt(Ct(a))])),Me(b)},()=>{})},le=(a,b)=>{const g=zt(a),E=!g&&Ht(a);(!g&&!E?ft(V,a):void 0)?Zn(a,b):E?Co(a,b):g?Us(a,b):yt(a)?Me(a,b):Tt(a)?Fn(a,b):Sa(a)?_s(a,void 0,b):Dn(a)?Ws(a,b):te.openVaultFile(a).catch(()=>{})},me=(a,b)=>{const g=zt(a),E=!g&&Ht(a),de=!g&&!E?ft(V,a):void 0,ve=!g&&!E&&!de&&yt(a),De=ve||E,L=Tt(a)?kn:g?rn:E?Pn:ve?Xt:Dn(a)?Ys:gn,st=ce.includes(a),q=[...De?[{id:"star",label:t(st?"amxv.menu.unstar":"amxv.menu.star"),icon:st?e.jsx(Pl,{}):e.jsx(Ln,{}),run:()=>Pe.getState().toggleStar(a)},{id:"rename",label:t("amxv.menu.rename"),icon:e.jsx(dn,{}),run:()=>Ot(a)}]:[],{id:"delete",label:t("amxv.menu.delete"),icon:e.jsx(Ye,{}),tone:"danger",run:()=>{De?fn(a):$n("file",a)&&je().deletePage(a)}}];return e.jsx(al,{actions:q,children:e.jsx(oa,{as:"button",className:a===(w??o)?"active":void 0,style:{paddingLeft:void 0},lead:l[a]?e.jsx("span",{className:"amx-page-emoji",children:l[a]}):e.jsx(L,{className:"t2s-lead-icon t2s-dim"}),trailing:b?e.jsx("span",{className:"t2s-srow-time",children:So(b)}):void 0,onClick:()=>le(a),onContextMenu:Se=>{Se.preventDefault(),Se.stopPropagation(),W({kind:De?"page":"asset",path:a,x:Se.clientX,y:Se.clientY})},children:_e===a?e.jsx("input",{ref:Te,className:"t2s-rename",value:Qe,onChange:Se=>bt(Se.target.value),onBlur:$t,onKeyDown:Se=>{Se.key==="Enter"&&$t(),Se.key==="Escape"&&ut(null)},onClick:Se=>Se.stopPropagation()}):e.jsxs("span",{className:"t2s-srow-text",children:[e.jsx("span",{className:"t2s-srow-title",children:de?Vt(a,de.extensions):g?ye(a).replace(/\.excalidraw$/i,""):ve?ye(a):a.split(/[\\/]/).pop()}),gt(a)&&e.jsx("span",{className:"t2s-srow-sub",children:gt(a)})]})})},a)},be=(a,b=0,g)=>{const E=zt(a),de=!E&&Ht(a),ve=!E&&!de?ft(V,a):void 0,De=!E&&!de&&!ve&&yt(a),L=De||de?"page":"asset",st=Tt(a)?kn:E?rn:de?Pn:De?Xt:Dn(a)?Ys:gn;return e.jsxs(oa,{as:"button",elRef:q=>{a===qe&&(We.current=q)},className:`${a===(w??o)?"active":""}${z.has(a)?" sel":""}${a===qe?" amx-flash":""}${a===T?" dragging":""}${S===cs(St(a,g?.fd))?" amx-drop-into":""}`.trim()||void 0,selId:a,depth:b,lead:e.jsxs(e.Fragment,{children:[l[a]?e.jsx("span",{className:"amx-page-emoji",children:l[a]}):ve?.icon?e.jsx("span",{className:"amx-page-emoji",children:Qn(ve.icon,e.jsx(st,{className:"t2s-lead-icon t2s-dim"}))}):e.jsx(st,{className:"t2s-lead-icon t2s-dim"}),g&&e.jsx("span",{className:`t2s-chev t2s-lead-chev${g.open?" open":""}`,onClick:q=>{q.stopPropagation(),Ce(g.fd)},children:e.jsx(qt,{size:12})})]}),onClick:q=>{const Se=z.click(a,q);Se.open!=="none"&&le(a,Se.open==="new"?{newTab:!0}:void 0)},onContextMenu:q=>{q.preventDefault(),q.stopPropagation();const Se=z.batch(a);Se.length===1&&z.only(a),W(Se.length>1?{kind:"multi",path:a,paths:Se,x:q.clientX,y:q.clientY}:{kind:L,path:a,x:q.clientX,y:q.clientY})},draggable:_e!==a,onDragStart:q=>{const Se=q.currentTarget.getBoundingClientRect();q.dataTransfer.setDragImage(q.currentTarget,q.clientX-Se.left,q.clientY-Se.top),q.dataTransfer.effectAllowed="copyMove";const As=z.batch(a);if(No(q.dataTransfer,As.map(Yn=>({kind:"note",path:Yn}))),r&&!(window.amadeusSync&&u==="cloud")){const Yn=As.flatMap(Xn=>{const Jn=Nn(Xn)?Ct(Xn):"";return[`${r}/${Xn}`,...Jn&&s.includes(Jn)?[`${r}/${Jn}`]:[]]});try{q.dataTransfer.setData(ts,JSON.stringify(Yn))}catch{}}il(q.dataTransfer,{open:()=>le(a)}),G(a)},onDragEnd:()=>{G(null),M(null)},onDragOver:q=>{tn(q,a,g?.fd)||g&&B(q,a,g.fd)},onDragLeave:()=>{S===cs(St(a,g?.fd))&&M(null)},onDrop:q=>{Gn(q,a,g?.fd)||g&&(q.preventDefault(),q.stopPropagation(),Re(g.fd))},...ia(ae(a)),children:[_e===a?e.jsx("input",{ref:Te,className:"t2s-rename",value:Qe,onChange:q=>bt(q.target.value),onBlur:$t,onKeyDown:q=>{q.key==="Enter"&&$t(),q.key==="Escape"&&ut(null)},onClick:q=>q.stopPropagation()}):e.jsx("span",{className:"t2s-srow-title",children:ve?Vt(a,ve.extensions):De||E?ye(a):a.split(/[\\/]/).pop()}),e.jsx("span",{className:"t2s-srow-menu",onClick:q=>{q.stopPropagation(),W({kind:L,path:a,x:q.clientX,y:q.clientY})},children:e.jsx(Jt,{size:14})}),De&&e.jsx("span",{className:"t2s-srow-menu",title:t("amadeus.new.childNote"),onClick:q=>{q.stopPropagation(),ee(a)},children:e.jsx(Dt,{size:14})})]},a)},Be=(a,b)=>{if(a.kind==="file"){if(!a.children.length)return be(a.path,b);const L=Ct(a.path),st=y.has(L);return e.jsxs("div",{children:[be(a.path,b,{fd:L,open:st,count:a.children.filter(q=>q.kind==="file").length}),st&&e.jsx("div",{className:`t2s-group-sessions${S===L?" amx-drop-into":""}`,onDragOver:q=>B(q,a.path,L),onDragLeave:()=>{S===L&&M(null)},onDrop:q=>{kt(q,L)||(q.preventDefault(),q.stopPropagation(),Re(L))},children:a.children.map(q=>Be(q,b+1))})]},a.path)}const g=a.path,E=!y.has(g),de=a.children.filter(L=>L.kind==="file").length,ve=a.children.length-de,De=L=>{if(!Mt(L,g)&&T&&(L.stopPropagation(),gt(T)!==g)){if(Nn(T)){const st=Ct(T);if(g===st||g.startsWith(`${st}/`))return}L.preventDefault(),L.dataTransfer.dropEffect="move",S!==g&&M(g)}};return e.jsxs("div",{children:[e.jsxs("div",{ref:L=>{g===qe&&(We.current=L)},className:`t2s-group${g===qe?" amx-flash":""}${S===g?" amx-drop-into":""}`,style:{paddingLeft:sl(b)},...ia(()=>[nl("tip.folder",{files:de,folders:ve})]),onContextMenu:L=>{L.preventDefault(),L.stopPropagation(),W({kind:"folder",path:g,x:L.clientX,y:L.clientY})},onDragOver:De,onDragLeave:()=>{S===g&&M(null)},onDrop:L=>{kt(L,g)||(L.preventDefault(),L.stopPropagation(),Re(g))},children:[e.jsxs("button",{className:"t2s-group-toggle t2s-folder-row",onClick:()=>Ce(g),children:[e.jsxs("span",{className:"t2s-lead",children:[E?e.jsx(Ds,{className:"t2s-lead-icon"}):e.jsx(vt,{className:"t2s-lead-icon"}),e.jsx("span",{className:`t2s-chev t2s-lead-chev${E?"":" open"}`,children:e.jsx(qt,{size:12})})]}),e.jsx("span",{className:"t2s-group-label",children:En(g)})]}),e.jsx("button",{className:"t2s-group-add",title:t("amxv.folder.actions"),onClick:L=>{L.stopPropagation(),W({kind:"folder",path:g,x:L.clientX,y:L.clientY})},children:e.jsx(Jt,{size:14})}),e.jsx("button",{className:"t2s-group-add",title:t("amxv.folder.newNoteHere"),onClick:()=>{p(L=>new Set([...L,...pt(g)])),je().createPageInFolder(g)},children:e.jsx(Dt,{size:14})})]}),!E&&e.jsx("div",{className:`t2s-group-sessions${S===g?" amx-drop-into":""}`,onDragOver:De,onDragLeave:()=>{S===g&&M(null)},onDrop:L=>{kt(L,g)||(L.preventDefault(),L.stopPropagation(),Re(g))},children:a.children.map(L=>Be(L,b+1))})]},g)},Ge=ot?e.jsxs(e.Fragment,{children:[e.jsx(qc,{}),e.jsx(Wn,{id:"cloud-ws",defaultOpen:!0,label:t("amxv.sec.cloudWorkspace"),children:ot.rest.length?ot.rest.map(a=>Be(a,0)):e.jsx("div",{className:"t2s-hint amx-sec-hint",children:t("amxv.empty")})}),ot.vaultSecs.map(({name:a,node:b})=>e.jsx(Wn,{id:`vault:${a}`,defaultOpen:!0,label:a,children:b&&b.children.length?b.children.map(g=>Be(g,0)):e.jsx("div",{className:"t2s-hint amx-sec-hint",children:t(b?"amxv.empty":"amxv.syncNotArrived")})},a))]}):r?e.jsxs("div",{className:"amx-prefs-group",children:[e.jsx("button",{className:"t2s-group-toggle amx-sec-grab",onClick:Ze,children:e.jsxs("span",{className:"t2s-group-name amx-sec-head",children:[e.jsx("span",{className:"t2s-group-label",children:ye(r)}),e.jsx("span",{className:`t2s-chev${Je?" open":""}`,children:e.jsx(qt,{size:12})})]})}),Je&&e.jsx("div",{className:`t2s-group-sessions${S===""?" amx-drop-root":""}`,onDragOver:a=>{bn(a,".t2s-srow, .t2s-group")||!T||gt(T)===""||Ee||a.target.closest(".t2s-srow, .t2s-group")||(a.preventDefault(),a.dataTransfer.dropEffect="move",S!==""&&M(""))},onDragLeave:()=>{S===""&&M(null)},onDrop:a=>{nn(a,".t2s-srow, .t2s-group")||a.target.closest(".t2s-srow, .t2s-group")||(a.preventDefault(),Re(""))},children:Ie.children.map(a=>Be(a,0))})]}):e.jsx(e.Fragment,{children:Ie.children.map(a=>Be(a,0))}),nt=e.jsxs("div",{className:"t2s-foot",children:[e.jsx(Vc,{}),e.jsxs("button",{className:"t2s-special",onClick:()=>h?O(!0):void je().openVault(),title:h?t("amxv.cloudVaultTip"):r||void 0,children:[e.jsx("span",{className:"t2s-special-ic",children:e.jsx(vt,{})}),e.jsx("span",{className:"t2s-special-title",children:h?t("amxv.cloudVault"):r?t("amxv.vaultNamed",{name:ye(r)}):t("amxv.openVault")})]})]});return e.jsxs("div",{style:{display:"flex",flex:1,minHeight:0,minWidth:0},children:[e.jsxs("aside",{className:"t2s-side amx-tree","data-timeline":ge?"":void 0,children:[k?!!r&&e.jsx(Gr,{label:t("amxv.phone.tabs"),items:[{id:"recent",label:t("amxv.phone.tab.recent")},{id:"tree",label:t("amxv.phone.tab.tree")},{id:"boards",label:t("amxv.phone.tab.boards")}],value:we,onChange:Fe}):e.jsxs("div",{className:"t2s-search",children:[e.jsx(ks,{size:13,className:"t2s-dim"}),e.jsx("input",{value:j,placeholder:t("amxv.searchNotes"),onChange:a=>m(a.target.value)})]}),e.jsxs("div",{ref:R,className:`t2s-scroll${S===""?" amx-drop-root":""}`,"data-under-dock":k?"":void 0,onTouchStart:ge?Yr:void 0,onClick:a=>{a.target===a.currentTarget&&z.clear()},onContextMenu:a=>{a.target.closest(".t2s-srow, .t2s-group, .t2s-special-group")||r&&(a.preventDefault(),a.stopPropagation(),W({kind:"root",path:"",x:a.clientX,y:a.clientY}))},onDragOver:a=>{bn(a,".t2s-srow, .t2s-group, .t2s-group-sessions, .t2s-special-group")||!T||gt(T)===""||Ee||a.target.closest(".t2s-srow, .t2s-group, .t2s-group-sessions, .t2s-special-group")||(a.preventDefault(),a.dataTransfer.dropEffect="move",S!==""&&M(""))},onDragLeave:()=>{S===""&&M(null)},onDrop:a=>{nn(a,".t2s-srow, .t2s-group, .t2s-group-sessions, .t2s-special-group")||a.target.closest(".t2s-srow, .t2s-group, .t2s-group-sessions, .t2s-special-group")||(a.preventDefault(),Re(""))},children:[k&&e.jsx(Xr,{}),ge&&e.jsx(Jr,{id:"notes",children:t("amxv.phone.hint")}),ge&&we==="recent"&&(U.length?Zr(U,a=>rl(a.at)).map(a=>"section"in a?e.jsx(Qr,{bucket:a.section},`sec:${a.section}`):me(a.item.path,a.item.at)):e.jsx("div",{className:"t2s-hint",children:t("amxv.phone.noRecent")})),ge&&we==="boards"&&(re.length?re.map(a=>me(a,0)):e.jsx("div",{className:"t2s-hint",children:t("amxv.phone.noBoards")})),ge?null:Ee?Ke.length?Ke.map(a=>be(a)):e.jsx("div",{className:"t2s-hint",children:t("amxv.noMatches")}):e.jsxs(e.Fragment,{children:[!k&&e.jsxs("div",{className:"t2s-special-group",children:[e.jsxs("button",{className:"t2s-special",onClick:()=>{je().createPage()},children:[e.jsx("span",{className:"t2s-special-ic",children:e.jsx(At,{})}),e.jsx("span",{className:"t2s-special-title",children:t("amadeus.new.note")})]}),e.jsxs("button",{className:"t2s-special",onClick:()=>Nt(""),children:[e.jsx("span",{className:"t2s-special-ic",children:e.jsx(rn,{})}),e.jsx("span",{className:"t2s-special-title",children:t("amadeus.new.drawing")})]})]}),!r&&(f?e.jsx(Ga,{variant:"list"}):e.jsx("div",{className:"t2s-hint",children:t("amxv.openVaultHint")})),(()=>{const a={pinned:e.jsx(Uc,{row:be,dragPath:T}),cloudsync:u==="local"?e.jsx(Kc,{dragPath:T}):null,shared:e.jsx(Wc,{}),prefs:e.jsx(_c,{row:be,pages:n}),tree:Ge};return Y.map(b=>a[b]==null?null:se(b,a[b]))})()]}),k&&nt]}),!k&&nt,k&&r&&e.jsx(el,{label:t("amadeus.new.note"),icon:e.jsx(At,{}),onClick:()=>{je().createPage()},onMenu:a=>W({kind:"root",path:"",x:a.x,y:a.y})})]}),F?.kind==="multi"&&e.jsxs(Et,{className:"ctx-menu",x:F.x,y:F.y,onClick:a=>a.stopPropagation(),children:[e.jsxs("button",{onClick:()=>{const a=F.paths??[];W(null);for(const b of a)le(b,{newTab:!0})},children:[e.jsx(Dt,{size:13})," ",t("amxv.menu.openNInNewTabs",{n:F.paths?.length??0})]}),e.jsxs("button",{className:"danger",onClick:()=>{const a=F.paths??[];W(null),window.confirm(t("amxv.confirm.deleteSelected",{n:a.length}))&&(async()=>{for(const b of a)yt(b)&&!zt(b)?await fn(b):await je().deletePage(b);z.clear()})()},children:[e.jsx(Ye,{size:13})," ",t("amxv.menu.deleteN",{n:F.paths?.length??0})]})]}),F?.kind==="page"&&e.jsxs(Et,{className:"ctx-menu",x:F.x,y:F.y,onClick:a=>a.stopPropagation(),children:[e.jsxs("button",{onClick:()=>{Me(F.path,{newTab:!0}),W(null)},children:[e.jsx(Dt,{size:13})," ",t("amxv.menu.openInNewTab")]}),e.jsxs("button",{onClick:()=>{const a=F.path;W(null),ee(a)},children:[e.jsx(At,{size:13})," ",t("amadeus.new.childNote")]}),e.jsxs("button",{onClick:()=>Ot(F.path),children:[e.jsx(dn,{size:13})," ",t("amxv.menu.rename")]}),e.jsxs("button",{onClick:()=>{Pe.getState().toggleStar(F.path),W(null)},children:[e.jsx(Ln,{size:13})," ",Pe.getState().starred.includes(F.path)?t("amxv.menu.unstar"):t("amxv.menu.star")]}),window.amadeusSync?.entrySyncEnable&&u==="local"&&(xn(r,F.path)?e.jsxs("button",{onClick:()=>{const a=F.path;W(null),window.amadeusSync.entrySyncDisable(a)},children:[e.jsx(ws,{size:13})," ",t("amxv.menu.cloudSyncOff")]}):e.jsxs("button",{onClick:()=>{const a=F.path;W(null),Rt(a,"page")},children:[e.jsx(Yt,{size:13})," ",t("amxv.menu.cloudSyncOn")]})),hn()&&e.jsxs("button",{onClick:()=>{te.revealInFileManager(F.path),W(null)},children:[e.jsx(vt,{size:13})," ",t("amxv.menu.reveal")]}),e.jsxs("button",{className:"danger",onClick:()=>{const a=F.path;W(null),fn(a)},children:[e.jsx(Ye,{size:13})," ",t("amxv.menu.delete")]})]}),F?.kind==="asset"&&e.jsxs(Et,{className:"ctx-menu",x:F.x,y:F.y,onClick:a=>a.stopPropagation(),children:[Tt(F.path)?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{Fn(F.path),W(null)},children:[e.jsx(xt,{size:13})," ",t("amxv.menu.open")]}),e.jsxs("button",{onClick:()=>Ot(F.path),children:[e.jsx(dn,{size:13})," ",t("amxv.menu.rename")]}),e.jsxs("button",{onClick:()=>{te.openVaultFile(F.path).catch(()=>{}),W(null)},children:[e.jsx(It,{size:13})," ",t("amxv.menu.openWithSystem")]})]}):Sa(F.path)?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{Zn(F.path),W(null)},children:[e.jsx(xt,{size:13})," ",t("amxv.menu.open")]}),ft(V,F.path)&&e.jsxs("button",{onClick:()=>{_s(F.path),W(null)},children:[e.jsx(ai,{size:13})," ",t("amxv.menu.openBuiltinReader")]}),e.jsxs("button",{onClick:()=>{te.openVaultFile(F.path).catch(()=>{}),W(null)},children:[e.jsx(It,{size:13})," ",t("amxv.menu.openWithSystem")]})]}):Dn(F.path)?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{Ws(F.path),W(null)},children:[e.jsx(xt,{size:13})," ",t("amxv.menu.open")]}),e.jsxs("button",{onClick:()=>{te.openVaultFile(F.path).catch(()=>{}),W(null)},children:[e.jsx(It,{size:13})," ",t("amxv.menu.openWithSystem")]})]}):zt(F.path)?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{Us(F.path),W(null)},children:[e.jsx(xt,{size:13})," ",t("amxv.menu.openDrawing")]}),e.jsxs("button",{onClick:()=>{te.openVaultFile(F.path).catch(()=>{}),W(null)},children:[e.jsx(It,{size:13})," ",t("amxv.menu.openWithSystem")]})]}):ft(V,F.path)?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{Zn(F.path),W(null)},children:[e.jsx(xt,{size:13})," ",t("amxv.menu.open")]}),e.jsxs("button",{onClick:()=>{te.openVaultFile(F.path).catch(()=>{}),W(null)},children:[e.jsx(It,{size:13})," ",t("amxv.menu.openWithSystem")]})]}):e.jsxs("button",{onClick:()=>{te.openVaultFile(F.path).catch(()=>{}),W(null)},children:[e.jsx(xt,{size:13})," ",t("amxv.menu.open")]}),hn()&&e.jsxs("button",{onClick:()=>{te.revealInFileManager(F.path),W(null)},children:[e.jsx(vt,{size:13})," ",t("amxv.menu.reveal")]}),e.jsxs("button",{className:"danger",onClick:()=>{const a=F.path;W(null),$n("file",a)&&je().deletePage(a)},children:[e.jsx(Ye,{size:13})," ",t("amxv.menu.delete")]})]}),F?.kind==="folder"&&e.jsxs(Et,{className:"ctx-menu",x:F.x,y:F.y,onClick:a=>a.stopPropagation(),children:[e.jsxs("button",{onClick:()=>{p(a=>new Set([...a,...pt(F.path)])),je().createPageInFolder(F.path),W(null)},children:[e.jsx(At,{size:13})," ",t("amadeus.new.note")]}),e.jsxs("button",{onClick:()=>sn(F.path),children:[e.jsx(la,{size:13})," ",t("amxv.menu.newSubfolder")]}),e.jsxs("button",{onClick:()=>yn(F.path),children:[e.jsx(kn,{size:13})," ",t("amadeus.new.database")]}),e.jsxs("button",{onClick:()=>Nt(F.path),children:[e.jsx(rn,{size:13})," ",t("amadeus.new.drawing")]}),e.jsxs("button",{onClick:()=>jn(F.path),children:[e.jsx(Pn,{size:13})," ",t("amadeus.new.dashboard")]}),J.map(a=>e.jsxs("button",{onClick:()=>Q(F.path,a.item.label,a.item.run),children:[e.jsx("span",{style:{display:"inline-flex",width:13,justifyContent:"center",fontSize:13},children:Qn(a.item.icon,"📄")})," ",a.item.label]},a.item.id)),e.jsxs("button",{onClick:()=>{const a=F.path;W(null),rt(t("amxv.renameFolder"),En(a)).then(b=>{const g=b?.trim();g&&je().renameFolder(a,g)})},children:[e.jsx(dn,{size:13})," ",t("amxv.menu.rename")]}),hn()&&e.jsxs("button",{onClick:()=>{te.revealInFileManager(F.path),W(null)},children:[e.jsx(vt,{size:13})," ",t("amxv.menu.reveal")]}),window.amadeusSync?.entrySyncEnable&&u==="local"&&(xn(r,F.path)?e.jsxs("button",{onClick:()=>{const a=F.path;W(null),window.amadeusSync.entrySyncDisable(a)},children:[e.jsx(ws,{size:13})," ",t("amxv.menu.cloudSyncOff")]}):e.jsxs("button",{onClick:()=>{const a=F.path;W(null),Rt(a,"folder")},children:[e.jsx(Yt,{size:13})," ",t("amxv.menu.cloudSyncOn")]})),window.amadeusCollab&&e.jsxs("button",{onClick:()=>{const a=F.path;W(null);const b=Rs(oe,r,u,a);if(!b){Rt(a,"folder");return}window.amadeusCollab.createPublish("subtree",b).then(g=>navigator.clipboard.writeText(g.url).then(()=>Ve.getState().toast(t("amxv.publish.done")))).catch(g=>Ve.getState().toast(g?.code==="QUOTA"?g.message||t("amxv.publish.quota"):g?.status===404?t("amxv.publish.notUploaded"):t("amxv.publish.failed"),!0))},children:[e.jsx(In,{size:13})," ",t("amxv.menu.publishFolder")]}),e.jsxs("button",{className:"danger",onClick:()=>{const a=F.path;W(null),$n("folder",a)&&je().deleteFolder(a)},children:[e.jsx(Ye,{size:13})," ",t("amxv.menu.delete")]})]}),v&&C&&e.jsx(Et,{className:"ctx-menu",x:v.x,y:v.y,onClick:a=>a.stopPropagation(),children:e.jsx(tl,{items:d()})}),x&&e.jsx(Sc,{onClose:()=>O(!1)})]})}function wi(t){return t.map(n=>n.kind==="choice"?{id:`page-${n.id}`,icon:e.jsx(ii,{size:16}),label:n.label,run:()=>{},choices:n.options}:{id:`page-${n.id}`,icon:n.id==="wide"?e.jsx(ti,{size:16}):e.jsx(oi,{size:16}),label:n.label,checked:n.on,run:n.run})}function Xc(){const[t,n]=c.useState(0),s=c.useRef(0),i=c.useRef({w:0,h:0});return c.useEffect(()=>{const o=()=>{const r=i.current;r.w!==window.innerWidth?i.current={w:window.innerWidth,h:window.innerHeight}:window.innerHeight>r.h&&(r.h=window.innerHeight);const u=window.visualViewport,f=u?Math.max(0,window.innerHeight-u.height-u.offsetTop):0,h=Math.max(f,Math.max(0,i.current.h-window.innerHeight));h>120&&(s.current=h),n(f)};return o(),window.visualViewport?.addEventListener("resize",o),window.visualViewport?.addEventListener("scroll",o),window.addEventListener("resize",o),()=>{window.visualViewport?.removeEventListener("resize",o),window.visualViewport?.removeEventListener("scroll",o),window.removeEventListener("resize",o)}},[]),{lift:t,kbHeight:()=>s.current||Math.min(380,Math.max(240,Math.round(window.innerHeight*.42)))}}function Jc({height:t,onClose:n}){const s=Mr(),i=c.useMemo(()=>{const l=new Map;for(const o of s)(l.get(o.group)??l.set(o.group,[]).get(o.group)).push(o);return[...l]},[s]);return e.jsx("div",{className:"amx-bpick",style:{height:t},children:e.jsx("div",{className:"amx-bpick-scroll",children:i.map(([l,o])=>e.jsxs(c.Fragment,{children:[e.jsx("div",{className:"amx-bpick-label",children:l}),e.jsx("div",{className:"amx-bpick-grid",children:o.map(r=>e.jsxs("button",{className:"amx-bpick-item",onClick:()=>{ni()?.(r),n()},children:[e.jsx("span",{className:"amx-bpick-icon",children:r.icon}),e.jsx("span",{className:"amx-bpick-name",children:r.label})]},r.key))})]},l))})})}function bi({actions:t,onUpload:n,undo:s,redo:i,indent:l,sourceMode:o,onNeedFocus:r,canvas:u}){const{t:f}=he(),{lift:h,kbHeight:j}=Xc(),[m,y]=c.useState(!1),[p,x]=c.useState(0);Hs(m,()=>y(!1)),Hs(p>0,()=>x(0));const O=c.useRef(null),T=z=>z.preventDefault(),G=O.current?po(O.current):1,S=p?Math.round(p/G):0,M=S||Math.round(h/G),R=()=>{ni()||r();const z=j();document.activeElement?.blur?.(),x(z)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:O,className:"amx-mbar","data-kb-rise":!0,style:M?{transform:`translateY(-${M}px)`}:void 0,children:[!o&&e.jsx("button",{onPointerDown:T,onClick:()=>p?x(0):R(),className:p?"on":void 0,title:f("amxv.mbar.insertBlock"),children:e.jsx(Dt,{size:19})}),!o&&e.jsx("button",{onPointerDown:T,onClick:n,title:f("amxv.uploadToPage"),children:e.jsx(vs,{size:19})}),!o&&u&&e.jsx("button",{onPointerDown:T,onClick:u.toggle,className:u.on?"on":void 0,title:u.on?f("amxv.mbar.toDocument"):f("amxv.mbar.toCanvas"),children:e.jsx(dl,{size:19})}),!o&&l&&e.jsx("button",{onPointerDown:T,onClick:()=>l(-1),title:f("amxv.mbar.outdent"),children:e.jsx(kl,{size:19})}),!o&&l&&e.jsx("button",{onPointerDown:T,onClick:()=>l(1),title:f("amxv.mbar.indent"),children:e.jsx(Nl,{size:19})}),!o&&e.jsx("button",{onPointerDown:T,onClick:s,title:f("amxv.mbar.undo"),children:e.jsx(ul,{size:19})}),!o&&e.jsx("button",{onPointerDown:T,onClick:i,title:f("amxv.mbar.redo"),children:e.jsx(hl,{size:19})}),e.jsx("button",{onPointerDown:T,onClick:()=>y(!0),title:f("amxv.moreActions"),children:e.jsx(Jt,{size:19})}),e.jsx("button",{onClick:()=>{x(0),document.activeElement?.blur?.()},title:f("amxv.mbar.hideKeyboard"),children:e.jsx(Nr,{size:19})})]}),S>0&&e.jsx(Jc,{height:S,onClose:()=>x(0)}),m&&e.jsx("div",{className:"mb-sheet-scrim",onClick:()=>y(!1),children:e.jsxs("div",{className:"mb-sheet",onClick:z=>z.stopPropagation(),style:{paddingBottom:"env(safe-area-inset-bottom)"},children:[e.jsx("div",{className:"mb-sheet-grip"}),t.map(z=>z.choices?e.jsxs("div",{className:"mb-sheet-row amx-sheet-choice",role:"group","aria-label":z.label,"data-action":z.id,children:[z.icon,e.jsx("span",{children:z.label}),e.jsx("span",{className:"amx-sheet-seg",children:z.choices.map(k=>e.jsx("button",{type:"button",role:"radio","aria-checked":k.on,"data-font":k.id,className:k.on?"on":void 0,onClick:k.run,children:k.label},k.id))})]},z.id):e.jsxs("button",{className:`mb-sheet-row${z.danger?" danger":""}${z.on?" on":""}`,role:z.checked!==void 0?"switch":void 0,"aria-checked":z.checked,"data-action":z.id,onClick:()=>{z.checked===void 0&&y(!1),z.run()},children:[z.icon,e.jsx("span",{children:z.label}),z.checked&&e.jsx(wt,{size:16,className:"amx-sheet-check"})]},z.id))]})})]})}Ne({"amxv.menu.lockPage":{zh:"锁定页面",en:"Lock page"},"amxv.menu.unlockPage":{zh:"解锁页面",en:"Unlock page"}});Ne({"amxv.menu.copyMd":{zh:"复制为 Markdown",en:"Copy as Markdown"},"amxv.copyMd.done":{zh:"已复制 Markdown",en:"Markdown copied"}});function Zc(t,n){const[,s]=c.useState(0);return c.useEffect(()=>Ro(()=>s(i=>i+1)),[]),!!n&&Fo(t,n)}function Qc({children:t,dragging:n,rootRef:s,onDrop:i,onDragOver:l,onDragLeave:o,onClick:r,onPaste:u,pageAttrs:f}){const h=Xa(j=>j.mode);return e.jsx("div",{ref:j=>{s&&(s.current=j)},className:`am-app tangu-lovable amx-pane amx-editor${n?" amx-dragover":""}`,"data-mode":h,...f,onDrop:i,onDragOver:l,onDragLeave:o,onClick:r,onPaste:u,children:t})}function ed({params:t,size:n}){const s=typeof t.notePath=="string"?t.notePath:"",i=I(l=>s?l.icons[s]??null:null);return i?e.jsx("span",{className:"wb-tab-ic amx-tab-emoji",style:{fontSize:n},"aria-hidden":!0,children:i}):e.jsx(Xt,{size:n,className:"wb-tab-ic"})}function yi(){const{t}=he(),n=Ft(),s=()=>n.getState(),i=I(S=>S.activePage),l=I(S=>S.manifest),o=I(S=>i?S.icons[i]??null:null),r=i?qa(i):void 0,u=r&&i?Vt(i,r.extensions):l?.title||(i?ye(i):""),f=_r.test(u)?"":u,[h,j]=c.useState(f),[m,y]=c.useState(null),p=c.useRef(null);c.useEffect(()=>{j(f)},[i]),c.useEffect(()=>{if(!fo(i))return;const S=p.current;if(!S)return;S.focus();const M=S.value.length;S.setSelectionRange(M,M)},[i]);const x=()=>{const S=h.trim();S&&S!==u?s().renamePage(S):j(f)},O=Or(),[T,G]=c.useState(null);return e.jsxs("div",{className:"amx-title-wrap",children:[o&&e.jsx("button",{className:"amx-title-bigicon",title:t("amxv.title.changeIcon"),onClick:S=>{const M=S.currentTarget.getBoundingClientRect();y({x:M.left,y:M.bottom+6})},children:o}),i&&(!o||!O)&&e.jsxs("div",{className:"amx-title-actions",children:[!o&&e.jsxs("button",{onClick:()=>{s().setPageIcon(i,Ir())},children:[e.jsx(Lr,{size:14,strokeWidth:1.7,"aria-hidden":"true"}),t("amxv.title.addIcon")]}),!O&&e.jsxs("button",{onClick:S=>{const M=S.currentTarget.getBoundingClientRect();G({x:M.right,y:M.bottom+6})},children:[e.jsx(go,{size:14,strokeWidth:1.7,"aria-hidden":"true"}),t("amxv.title.addCover")]})]}),e.jsx("div",{className:"amx-title-row",children:e.jsx("input",{ref:p,className:"amx-title-input",value:h,placeholder:"New Page",onChange:S=>j(S.target.value),onBlur:x,onKeyDown:S=>{const M=S.currentTarget,R=M.selectionStart===M.value.length&&M.selectionEnd===M.value.length;(S.key==="Enter"||(S.key==="ArrowRight"||S.key==="ArrowDown")&&R)&&(S.preventDefault(),_n(n),M.blur()),S.key==="Escape"&&(j(f),M.blur())}})}),m&&i&&e.jsx(Ar,{x:m.x,y:m.y,current:o,onPick:S=>{s().setPageIcon(i,S),y(null)},onClose:()=>y(null)}),T&&i&&e.jsx(Br,{page:i,x:T.x,y:T.y,onClose:()=>G(null)})]})}function td(t){for(let n=t.parentElement;n;n=n.parentElement)if(/(auto|scroll)/.test(getComputedStyle(n).overflowY)&&n.scrollHeight>n.clientHeight)return n;return null}function nd(){const t=Ft(),n=Ia(),s=()=>t.getState(),i=()=>{const m=s().manifest;if(!m)return"";const y={};for(const[p,x]of Object.entries(s().blocks))y[p]=x.content;return Ii(m,y)},[l,o]=c.useState(i),r=c.useRef(null),u=()=>{const m=r.current;m&&(m.style.height="auto",m.style.height=`${m.scrollHeight}px`)};c.useEffect(u,[l]);const f=c.useRef(l);f.current=l;const h=c.useRef(0);c.useEffect(()=>{const m=r.current,y=Aa(n);if(m&&y){const p=Mo(f.current,y);if(p>=0){m.focus(),m.setSelectionRange(p,p),h.current=p;const x=f.current.slice(0,p).split(`
9
+ `).length-1,O=parseFloat(getComputedStyle(m).lineHeight)||20,T=td(m);T&&(T.scrollTop=Math.max(0,m.offsetTop+x*O-T.clientHeight/2))}}return()=>$o(Oo(f.current,h.current),n)},[]);const j=()=>{const m=s().activePage;if(!m||l===i())return;const y=Ai(m,l,new Date().toISOString());s()._commit(y.manifest,y.blocks)};return e.jsx("textarea",{ref:r,className:"amx-source",value:l,spellCheck:!1,onChange:m=>{h.current=m.target.selectionStart,o(m.target.value)},onSelect:m=>{h.current=m.currentTarget.selectionStart},onBlur:j})}function sd(t){return e.jsx(Ts.Provider,{value:t.leaf.id,children:e.jsx(ad,{...t})})}function ad({leaf:t}){const{t:n}=he(),s=Ft(),i=()=>s.getState(),l=I(w=>w.activePage),o=I(w=>w.vaultRoot),r=I(w=>w.pendingPage),u=I(w=>w.error),f=ms(w=>w.fileTypes),h=Sn(w=>xo(w,t.id)),[j,m]=c.useState(!1);c.useEffect(()=>{if(!j)return;const w=()=>m(!1);return window.addEventListener("dragend",w),window.addEventListener("drop",w),()=>{window.removeEventListener("dragend",w),window.removeEventListener("drop",w)}},[j]);const[y,p]=c.useState(null),[x,O]=c.useState(null),[T,G]=c.useState(null),S=c.useRef(null),M=c.useRef(null),R=c.useRef(null),[z,k]=c.useState(null),[$,D]=c.useState(0),K=c.useRef(null),Z=c.useRef(null),ce=Pe(w=>w.starred),U=Pe(w=>w.pins),re=I(w=>w.vaultSide);Oe(w=>w.vaults),c.useEffect(()=>{ri()},[]);const we=!!window.amadeusSync?.entrySyncEnable&&re==="local";c.useEffect(()=>{if(!y)return;const w=()=>p(null);return window.addEventListener("click",w),window.addEventListener("contextmenu",w),()=>{window.removeEventListener("click",w),window.removeEventListener("contextmenu",w)}},[y]);const Fe=async()=>{const w=i().activePage??oe,V=K.current;if(!w||!V)return;const J=document.createElement("div");J.id="amx-print-root";const Q=rc(V);Q.setAttribute("data-mode","light"),J.appendChild(Q),document.body.appendChild(J);try{const Ce=await te.exportPdf(ye(w));Ce&&Ve.getState().toast(n("amxv.pdf.exported",{path:Ce}))}catch(Ce){Ve.getState().toast(n("amxv.pdf.exportFailed",{e:String(Ce)}),!0)}finally{J.remove()}},ge=async()=>{if(oe)try{const w=await Ul(oe);if(w==null)throw new Error(oe);await navigator.clipboard.writeText(w),Ve.getState().toast(n("amxv.copyMd.done"))}catch(w){Ve.getState().toast(n("amxv.copyFailed",{e:w instanceof Error?w.message:String(w)}),!0)}},X=$e(w=>w.mainTabs.find(V=>V.id===t.id)?.active??!1),pe=$e(w=>{if(!w.api)return!1;const V=Ps(w.api),J=w.mainTabs.filter(Q=>Q.type==="amadeus-editor");return(J.find(Q=>Q.id===V?.id)??J.find(Q=>Q.front)??J[0])?.id===t.id}),ue=vo(),N=typeof t.params.notePath=="string"?t.params.notePath:null,ie=c.useRef(!1),[ne,xe]=c.useState(null),[ke,Ue]=c.useState(0),P=c.useRef(null),A=I(w=>N?w.pages.includes(N):!1),H=I(w=>Il(N,w)),Y=H==="plugin";c.useEffect(()=>{if(H!=="pending")return;const w=setInterval(()=>{I.getState().refreshStructure().catch(()=>{})},3e3);return()=>clearInterval(w)},[H]),c.useEffect(()=>{if(!N){xe(null);return}if(Y){cn(N),P.current=null,xe(null);return}const w=P.current;if(H==="pending"){w&&w.path===N&&cn(N),P.current=null,xe(null);return}if(w&&w.path===N&&(w.root===o||w.root===null))return;w&&w.path===N&&cn(N);let V=!0;return(async()=>{let J=await te.readTextFile(N).catch(()=>null);for(let Ce=0;J==null&&!i().vaultRoot&&Ce<30;Ce++){if(await new Promise(Re=>setTimeout(Re,100)),!V)return;J=await te.readTextFile(N).catch(()=>null)}if(!V)return;const Q=aa(N,J,bs(),new Date().toISOString());if(Q.editor==="missing"&&i().pages.includes(N)){P.current=null,xe({forPath:N,decision:Q,root:i().vaultRoot,unreadable:!0});return}Q.editor==="missing"?(cn(N),P.current=null):P.current={path:N,root:i().vaultRoot},xe({forPath:N,decision:Q,root:i().vaultRoot})})(),()=>{V=!1}},[N,o,A,ke,H]);const fe=H==="note"&&ne&&ne.forPath===N?ne.decision:null,se=fe?.editor==="unified"?fe:null,F=!!N&&!!ne?.unreadable&&ne.forPath===N,W=fe?.editor==="missing"&&!!N&&!F,Je=ne&&ne.forPath===N?ne.root??"":"",Ze=Zc(o,N),[_e,ut]=c.useState({path:N,on:Ze}),[Qe,bt]=c.useState(0),Te=_e.path===N?_e.on:Ze;c.useEffect(()=>{if(_e.path!==N){ut({path:N,on:Ze});return}if(_e.on===Ze||!N)return;let w=!0;return(async()=>{const V=await Fs(N);if(!w)return;if(!V.ok){di(N,Ze,V.reason,()=>bt(Q=>Q+1));return}const J=aa(N,V.raw,bs(),new Date().toISOString());J.editor==="unified"&&xe(Q=>Q&&Q.forPath===N?{...Q,decision:J}:Q),ut({path:N,on:Ze})})(),()=>{w=!1}},[Ze,_e,N,Qe]);const Le=()=>{N&&ui(o,N,!Te)},qe=Kl(o,se?N:null),it=se&&N?ql(qe,w=>Gl(o,N,w),n):[],We=!se&&!W&&!F&&!Y&&(!!r&&r!==l||!!N&&!u&&N!==l),oe=l??(se&&N?N:null),ht=!!oe&&ce.includes(oe),Ee=!!oe&&U.includes(oe),Ie=we&&!!oe&&xn(i().vaultRoot,oe);c.useEffect(()=>{if(!se||!N)return;const w=i().activePage;i().releasePage(w??N)},[se,N]),c.useEffect(()=>{N&&t.setTitle(ye(N))},[N]),c.useEffect(()=>{if(wo!=="mobile"||N)return;const w=()=>{const J=i();if(!J.vaultRoot)return!1;let Q=null;try{Q=localStorage.getItem(`amx.lastNote:${J.vaultRoot}`)}catch{}return Q&&J.pages.includes(Q)&&t.setParams({...t.params,notePath:Q}),!0};if(w())return;const V=s.subscribe(J=>{J.vaultRoot&&w()&&V()});return V},[N]),c.useEffect(()=>{i().setActiveNotePath(N)},[N]),c.useEffect(()=>{!se||!N||(Ka(t.id,`amadeus:${N}`,()=>{const w=$e.getState(),V=w.leafById(t.id);V&&w.navigateLeaf(t.id,"amadeus-editor",{...V.params,notePath:N})}),Hn.getState().record({key:`note:${N}`,kind:"note",id:N,title:ye(N)}))},[se,N]),c.useEffect(()=>{if(N)return bo((w,V,J)=>{const Q=tt=>V==="file"?tt===w:tt===w||tt.startsWith(`${w}/`);if(!Q(N))return;if(J){t.setParams({...t.params,notePath:V==="file"?J:J+N.slice(w.length)});return}const Ce=i(),Re=Ce.activePage;t.setParams({...t.params,notePath:(Re&&!Q(Re)?Re:Ce.pages.find(tt=>!Q(tt)))??void 0})})},[N]),c.useEffect(()=>{if(!N)return;const w=i().vaultRoot;if(w)try{localStorage.setItem(`amx.lastNote:${w}`,N)}catch{}},[N]),c.useEffect(()=>{N&&fe?.editor==="block"&&N!==i().activePage&&i().loadPage(N)},[N,fe]),c.useEffect(()=>{X&&Kt(t.id),ie.current=X},[X,t.id]),c.useEffect(()=>{pe&&ue===yo&&o&&Kt(t.id)},[pe,ue,o,t.id]),c.useEffect(()=>{!l||l===N||ft(f,l)||Ht(l)||(t.setParams({...t.params,notePath:l}),t.setTitle(ye(l)))},[l]),c.useEffect(()=>()=>Ya(t.id),[t.id]);const Ke=async w=>{m(!1);const V=Ol(w.dataTransfer);if(V.length){if(w.preventDefault(),se&&N){const Re=V.join(`
10
+
11
+ `);if(R.current?R.current(Re):Li(N,Re,"cursor"))return}const Ce=i();if(!Ce.activePage)return;Ce.insertBlocksAfter(null,V);return}const J=Array.from(w.dataTransfer?.files??[]);if(!J.length||(w.preventDefault(),se&&N&&(M.current?M.current(J):us(N,J))))return;const Q=i().activePage;Q&&await Bn(J,Q)},et=w=>{const V=Array.from(w.dataTransfer?.types??[]),J=V.includes(Ja);!V.includes("Files")&&!J||(w.preventDefault(),J&&w.dataTransfer&&(w.dataTransfer.dropEffect="copy"),j||m(!0))},jt=w=>{w.currentTarget.contains(w.relatedTarget)||m(!1)},ot=w=>{const V=w.target.closest("a");if(!V||V.classList.contains("wikilink"))return;const J=V.getAttribute("href")||"";if(!J||$r(J)!=="file")return;w.preventDefault();const Q=i().activePage??oe;Q&&te.openAttachment(Q,J)},mt=w=>{if(w.defaultPrevented||w.target.closest("input, textarea, .t2s-rename"))return;const V=Array.from(w.clipboardData?.items??[]).filter(Q=>Q.kind==="file"&&Q.type.startsWith("image/")).map(Q=>Q.getAsFile()).filter(Q=>!!Q);if(!V.length)return;w.preventDefault();const J=i().activePage;J&&oc(V,J)};return e.jsxs(e.Fragment,{children:[e.jsxs(Qc,{rootRef:K,pageAttrs:se?Yl(qe):void 0,dragging:j,onDrop:w=>{Ke(w)},onDragOver:et,onDragLeave:jt,onClick:ot,onPaste:mt,children:[oe&&h!=="source"&&!T?.on&&!t.params.miniSurface&&!es()&&e.jsx(Ql,{host:K,label:n("amxv.floatingToc"),scanTrigger:oe}),e.jsx("input",{ref:Z,type:"file",multiple:!0,style:{display:"none"},onChange:w=>{const V=Array.from(w.currentTarget.files??[]);if(w.currentTarget.value="",!V.length||se&&N&&(M.current?M.current(V):us(N,V)))return;const J=i().activePage;J&&Bn(V,J)}}),oe&&!es()&&!t.params.miniSurface&&e.jsxs("div",{className:"amx-toolbar",children:[e.jsx(Ls,{path:oe,hideLoneLeaf:!!se}),e.jsx("span",{className:zr}),window.amadeusCollab&&e.jsx(Rc,{path:oe,refreshKey:$,onOpen:(w,V)=>k({x:w,y:V})}),e.jsx("button",{className:`amx-mode-btn amx-pin-btn${Ee?" amx-pin-on":""}`,title:n(Ee?"amxv.unpin":"amxv.pin"),onClick:()=>Pe.getState().togglePin(oe),children:e.jsx(xs,{size:14})}),we&&e.jsx("button",{className:`amx-mode-btn amx-pin-btn${Ie?" amx-pin-on":""}`,title:n(Ie?"amxv.cloud.disableTip":"amxv.menu.cloudSyncOn"),onClick:()=>{Ie?window.amadeusSync?.entrySyncDisable?.(oe):Rt(oe,"page")},children:e.jsx(Yt,{size:14})}),window.amadeusCollab&&e.jsx(Nc,{}),window.amadeusCollab&&e.jsx("button",{className:"amx-mode-btn",title:n("amxv.shareOrPublish"),onClick:w=>{w.stopPropagation();const V=w.currentTarget.getBoundingClientRect();k({x:V.right,y:V.bottom})},children:e.jsx(In,{size:14})}),h==="source"&&e.jsx("button",{className:"amx-mode-btn",onClick:()=>Sn.getState().toggleEditorMode(t.id),title:n("amxv.toVisualLong"),children:e.jsx(xt,{size:14})}),e.jsx("button",{className:"amx-mode-btn amx-more-btn",title:n("amxv.moreActions"),onClick:w=>{w.stopPropagation();const V=w.currentTarget.getBoundingClientRect();p({x:Math.max(8,Math.min(V.right-180,window.innerWidth-196)),y:V.bottom+4})},children:e.jsx(Jt,{size:14})})]}),y&&oe&&e.jsxs(Et,{className:"ctx-menu",x:y.x,y:y.y,onClick:w=>w.stopPropagation(),children:[it.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Jl,{entries:it}),e.jsx("div",{className:"ctx-separator"})]}),e.jsxs("button",{"data-note-mode":!0,onClick:()=>{p(null),Sn.getState().toggleEditorMode(t.id)},children:[h==="source"?e.jsx(xt,{size:13}):e.jsx(rs,{size:13})," ",n(h==="source"?"amxv.toVisual":"amxv.toSource")]}),fa(oe,Te,!!se&&h==="source")&&e.jsxs("button",{"data-note-upload":!0,onClick:()=>{p(null),Z.current?.click()},children:[e.jsx(vs,{size:13})," ",n("amxv.uploadToPage")]}),se&&e.jsxs("button",{onClick:()=>{p(null),ge()},children:[e.jsx(Ut,{size:13})," ",n("amxv.menu.copyMd")]}),qs()&&e.jsxs("button",{onClick:()=>{p(null),Fe()},children:[e.jsx(Cn,{size:13})," ",n("amxv.menu.exportPdf")]}),T?.on&&T.exportCanvas&&e.jsxs("button",{onClick:()=>{const w=T.exportCanvas;p(null),w?.()},children:[e.jsx(Cn,{size:13})," ",n("amxv.menu.exportCanvas")]}),e.jsxs("button",{onClick:()=>{Pe.getState().toggleStar(oe),p(null)},children:[e.jsx(Ln,{size:13})," ",n(ht?"amxv.menu.unstar":"amxv.menu.star")]}),hn()&&e.jsxs("button",{onClick:()=>{te.revealInFileManager(oe),p(null)},children:[e.jsx(vt,{size:13})," ",n("amxv.menu.reveal")]}),se&&e.jsxs("button",{onClick:()=>{p(null),Le()},children:[e.jsx(ca,{size:13})," ",n(Te?"amxv.menu.unlockPage":"amxv.menu.lockPage")]}),se&&Ks()&&e.jsxs("button",{"data-page-history":!0,onClick:()=>{p(null),O(oe)},children:[e.jsx(Gs,{size:13})," ",n("pghist.menu")]}),e.jsxs("button",{className:"danger",onClick:()=>{const w=oe;p(null),fn(w,i)},children:[e.jsx(Ye,{size:13})," ",n("amxv.menu.deleteNote")]})]}),x&&e.jsx(Wl,{path:x,locked:x===N&&Te,onClose:()=>O(null)}),z&&oe&&e.jsx(Pc,{path:oe,anchor:z,onClose:()=>{k(null),D(w=>w+1)}}),Y&&N?e.jsxs("div",{className:"amx-welcome","data-plugin-owned-file":N,children:[e.jsx("div",{className:"amx-welcome-title",children:n("amxv.pluginFile.title")}),e.jsx("p",{className:"amx-welcome-sub",children:n("amxv.pluginFile.sub",{path:N})}),e.jsx("div",{className:"amx-welcome-actions",children:e.jsx("button",{className:"amx-welcome-btn",onClick:()=>$e.getState().closeLeaf(t.id),children:n("amxv.missing.close")})})]}):se&&N?e.jsx(Cr,{compact:!!t.params.miniSurface,readOnly:Te,onUnlock:Te?Le:void 0,path:N,initial:se.initial,diskRaw:se.diskRaw,onCanvasMode:G,historyRef:S,filesRef:M,mdRef:R,onRenamed:w=>{t.setParams({...t.params,notePath:w}),t.setTitle(ye(w)),gi(N,w)}},`${Je}\0${N}${Te?"\0locked":""}`):F&&N?e.jsxs("div",{className:"amx-welcome",children:[e.jsx("div",{className:"amx-welcome-title",children:n("amxv.welcome.loadFailed")}),e.jsx("p",{className:"amx-welcome-sub",children:N}),e.jsx("div",{className:"amx-welcome-actions",children:e.jsx("button",{className:"amx-welcome-btn",onClick:()=>Ue(w=>w+1),children:n("amxv.retry")})})]}):W&&N?e.jsxs("div",{className:"amx-welcome",children:[e.jsx("div",{className:"amx-welcome-title",children:n("amxv.missing.title")}),e.jsx("p",{className:"amx-welcome-sub",children:n("amxv.missing.sub",{path:N})}),e.jsx("div",{className:"amx-welcome-actions",children:e.jsx("button",{className:"amx-welcome-btn",onClick:()=>$e.getState().closeLeaf(t.id),children:n("amxv.missing.close")})})]}):We?e.jsx(Ga,{variant:"document"}):l?h==="source"?e.jsx(nd,{},l):e.jsxs(e.Fragment,{children:[e.jsx(Vr,{}),e.jsxs("div",{className:"amx-doc",children:[e.jsx(yi,{}),e.jsx(Pr,{})]}),e.jsx(kc,{bare:!0})]}):N&&u?e.jsxs("div",{className:"amx-welcome",children:[e.jsx("div",{className:"amx-welcome-title",children:n("amxv.welcome.loadFailed")}),e.jsx("p",{className:"amx-welcome-sub",children:u}),e.jsx("div",{className:"amx-welcome-actions",children:e.jsx("button",{className:"amx-welcome-btn",onClick:()=>{N&&i().loadPage(N)},children:n("amxv.retry")})})]}):e.jsxs("div",{className:"amx-welcome",children:[e.jsx("div",{className:"amx-welcome-title",children:n("amxv.welcome.title")}),e.jsx("p",{className:"amx-welcome-sub",children:n(o?"amxv.welcome.pickNote":"amxv.welcome.noVault")}),e.jsx("div",{className:"amx-welcome-actions",children:o?e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"amx-welcome-btn",onClick:()=>{i().createPage()},children:[e.jsx(At,{size:16})," ",n("amadeus.new.note")]}),e.jsxs("button",{className:"amx-welcome-btn ghost",onClick:()=>{jo()},children:[e.jsx(ai,{size:16})," ",n("amxv.welcome.tutorial")]}),e.jsxs("button",{className:"amx-welcome-btn ghost",onClick:()=>{ko()},children:[e.jsx(fl,{size:16})," ",n("amxv.welcome.manual")]})]}):e.jsxs("button",{className:"amx-welcome-btn",onClick:()=>{i().openVault()},children:[e.jsx(vt,{size:16})," ",n("amxv.welcome.openVaultFolder")]})}),e.jsxs("ul",{className:"amx-welcome-tips",children:[e.jsxs("li",{children:[e.jsx("span",{className:"amx-kbd",children:"[["})," ",n("amxv.welcome.tip1")]}),e.jsxs("li",{children:[e.jsx(gn,{size:13})," ",n("amxv.welcome.tip2")]}),e.jsxs("li",{children:[e.jsx(rs,{size:13})," ",n("amxv.welcome.tip3")]})]})]})]}),es()&&oe&&!We&&e.jsx(bi,{sourceMode:h==="source",canvas:T,onUpload:()=>Z.current?.click(),undo:()=>{S.current?S.current.undo():l&&i().undo()},redo:()=>{S.current?S.current.redo():l&&i().redo()},indent:T?w=>{S.current?.indent?.(w)}:null,onNeedFocus:()=>{l&&_n(s)},actions:[{id:"mode",icon:h==="source"?e.jsx(xt,{size:16}):e.jsx(rs,{size:16}),label:n(h==="source"?"amxv.toVisual":"amxv.toSource"),run:()=>Sn.getState().toggleEditorMode(t.id)},...fa(oe,Te,!!se&&h==="source")?[{id:"upload",icon:e.jsx(vs,{size:16}),label:n("amxv.uploadToPage"),run:()=>Z.current?.click()}]:[],...se?[{id:"lock",icon:e.jsx(ca,{size:16}),label:n(Te?"amxv.menu.unlockPage":"amxv.menu.lockPage"),on:Te,run:Le}]:[],...se&&Ks()?[{id:"history",icon:e.jsx(Gs,{size:16}),label:n("pghist.menu"),run:()=>O(oe)}]:[],...wi(it),{id:"pin",icon:e.jsx(xs,{size:16}),label:n(Ee?"amxv.unpin":"amxv.pin"),on:Ee,run:()=>Pe.getState().togglePin(oe)},{id:"star",icon:e.jsx(Ln,{size:16}),label:n(ht?"amxv.menu.unstar":"amxv.menu.star"),on:ht,run:()=>Pe.getState().toggleStar(oe)},...we?[{id:"sync",icon:e.jsx(Yt,{size:16}),label:n(Ie?"amxv.cloud.disableTip":"amxv.menu.cloudSyncOn"),on:Ie,run:()=>{Ie?window.amadeusSync?.entrySyncDisable?.(oe):Rt(oe,"page")}}]:[],...window.amadeusCollab?[{id:"share",icon:e.jsx(In,{size:16}),label:n("amxv.shareOrPublish"),run:()=>k({x:window.innerWidth/2,y:window.innerHeight/2})}]:[],...se?[{id:"copymd",icon:e.jsx(Ut,{size:16}),label:n("amxv.menu.copyMd"),run:()=>{ge()}}]:[],...qs()?[{id:"pdf",icon:e.jsx(Cn,{size:16}),label:n("amxv.menu.exportPdf"),run:()=>{Fe()}}]:[],...T?.on&&T.exportCanvas?[{id:"canvas-export",icon:e.jsx(Cn,{size:16}),label:n("amxv.menu.exportCanvas"),run:()=>T.exportCanvas?.()}]:[],...hn()?[{id:"reveal",icon:e.jsx(vt,{size:16}),label:n("amxv.menu.reveal"),run:()=>{te.revealInFileManager(oe)}}]:[],{id:"delete",icon:e.jsx(Ye,{size:16}),label:n("amxv.menu.deleteNote"),danger:!0,run:()=>{fn(oe,i)}}]})]})}function ji(){const{t}=he(),n=oo();return e.jsxs("div",{className:"amx-panel",children:[e.jsx("div",{className:"amx-panel-head",children:t("amadeus.outline")}),n.length===0?e.jsx("div",{className:"amx-panel-empty",children:t("amxv.outline.empty")}):e.jsx("div",{className:"amx-list",children:n.map(s=>e.jsx("button",{className:"amx-list-item",style:{paddingLeft:10+(s.level-1)*12},onClick:s.go,title:s.text,children:s.text},s.key))})]})}function id({path:t,scope:n}){return e.jsx(Ts.Provider,{value:n,children:e.jsx(od,{path:t,scope:n})})}function od({path:t,scope:n}){const{t:s}=he(),i=Ft();return c.useEffect(()=>{t&&i.getState().activePage!==t&&i.getState().loadPage(t)},[t]),c.useEffect(()=>()=>Ya(n),[n]),t?e.jsx(ji,{}):e.jsx("div",{className:"amx-panel",children:e.jsx("div",{className:"amx-panel-empty",children:s("amxv.outline.noNote")})})}const uu=Object.freeze(Object.defineProperty({__proto__:null,AmadeusBacklinksView:Ic,AmadeusEditorView:sd,AmadeusOutlineView:ji,AmadeusPagesView:Yc,AmxMobileBar:bi,Breadcrumb:Ls,NoteTabIcon:ed,NoteTitle:yi,ScopedPageOutline:id,pageStyleSheetActions:wi},Symbol.toStringTag,{value:"Module"}));Ne({"dashcards.statError":{zh:"数字卡:{err}",en:"Stat card: {err}"},"dashcards.chartError":{zh:"图表卡:{err}",en:"Chart card: {err}"},"dashcards.loading":{zh:"加载中…",en:"Loading…"},"dashcards.missing":{zh:"找不到「{source}」",en:"Can’t find “{source}”"},"dashcards.corrupt":{zh:"「{source}」读不出来:{err}",en:"Can’t read “{source}”: {err}"},"dashcards.noData":{zh:"无数据",en:"No data"},"dashcards.noMatch":{zh:"没有符合条件的数据",en:"No data matches the filters"},"dashcards.rowCount":{zh:"行数",en:"Row count"},"dashcards.filteredRows":{zh:"共 {n} 行(已按页面筛选)",en:"{n} rows (page filters applied)"},"dashcards.aggCount":{zh:"计数",en:"Count"},"dashcards.aggSum":{zh:"{col} 求和",en:"Sum of {col}"},"dashcards.aggAvg":{zh:"{col} 平均",en:"Average of {col}"}});const He=({children:t})=>e.jsx("div",{className:"dash-widget",children:e.jsx("div",{className:"dash-widget-note",children:t})});function ki(t){const n=Gt(s=>s.gen);return c.useEffect(()=>{t&&Gt.getState().load(t,t)},[t,n]),Gt(s=>t?s.entries[t]:void 0)}function Si(){const[t,n]=c.useState(Xs),[s,i]=c.useState(0);return c.useEffect(()=>{const l=new Date,o=new Date(l.getFullYear(),l.getMonth(),l.getDate()+1).getTime(),r=setTimeout(()=>{n(Xs()),i(u=>u+1)},Math.max(o-l.getTime()+1e3,1e3));return()=>clearTimeout(r)},[t,s]),t}function Ni(t){const n=new Map(t.map(s=>[s.id,Za(s.type)]));return s=>n.get(s)??null}function rd({opts:t,filters:n}){const{t:s}=he(),i=c.useMemo(()=>_o(t),[JSON.stringify(t)]),l=i.ok?i.spec.source:"",o=ki(l);if(!i.ok)return e.jsx(He,{children:s("dashcards.statError",{err:i.error})});if(i.spec.literal!==null){const r=i.spec;return e.jsxs("div",{className:"dash-widget dash-stat",children:[e.jsxs("div",{className:"dash-stat-value",children:[r.literal,r.unit&&e.jsx("span",{className:"dash-stat-unit",children:r.unit})]}),e.jsx("div",{className:"dash-stat-label",children:r.label||"—"})]})}return e.jsx(ld,{spec:i.spec,entry:o,filters:n})}function ld({spec:t,entry:n,filters:s}){const{t:i}=he(),l=Si(),o=c.useMemo(()=>{if(!n?.data)return null;const u=Ni(n.data.columns);return Uo(n.data.rows,n.data.columns,t,s,u,n.data.views)},[n?.data,t,s,l]);if(!n||n.status==="loading")return e.jsx(He,{children:i("dashcards.loading")});if(n.status==="missing")return e.jsx(He,{children:i("dashcards.missing",{source:t.source})});if(n.status==="corrupt")return e.jsx(He,{children:i("dashcards.corrupt",{source:t.source,err:n.message})});if(!o)return e.jsx(He,{children:i("dashcards.noData")});if(o.error)return e.jsx(He,{children:i("dashcards.statError",{err:o.error})});const r=t.label||(t.col?`${t.col} · ${t.stat}`:n.data?.name||i("dashcards.rowCount"));return e.jsxs("div",{className:"dash-widget dash-stat",children:[e.jsxs("div",{className:"dash-stat-value",children:[o.text,t.unit&&e.jsx("span",{className:"dash-stat-unit",children:t.unit})]}),e.jsx("div",{className:"dash-stat-label",children:r}),!!s.length&&e.jsx("div",{className:"dash-stat-sub",children:i("dashcards.filteredRows",{n:o.rows})})]})}function cd({opts:t,filters:n}){const{t:s}=he(),i=c.useMemo(()=>Wo(t),[JSON.stringify(t)]),l=i.ok?i.spec.source:"",o=ki(l);return i.ok?e.jsx(dd,{spec:i.spec,entry:o,filters:n}):e.jsx(He,{children:s("dashcards.chartError",{err:i.error})})}function dd({spec:t,entry:n,filters:s}){const{t:i}=he(),l=Si(),o=c.useMemo(()=>{if(!n?.data)return null;const f=Ni(n.data.columns);return Ho(n.data.rows,n.data.columns,t,s,f,n.data.views)},[n?.data,t,s,l]);if(!n||n.status==="loading")return e.jsx(He,{children:i("dashcards.loading")});if(n.status==="missing")return e.jsx(He,{children:i("dashcards.missing",{source:t.source})});if(n.status==="corrupt")return e.jsx(He,{children:i("dashcards.corrupt",{source:t.source,err:n.message})});if(!o)return e.jsx(He,{children:i("dashcards.noData")});if(o.error)return e.jsx(He,{children:i("dashcards.chartError",{err:o.error})});if(!o.slices.length)return e.jsx(He,{children:i("dashcards.noMatch")});const r=t.agg==="count"?i("dashcards.aggCount"):i(t.agg==="sum"?"dashcards.aggSum":"dashcards.aggAvg",{col:t.value}),u=t.label||`${t.group} · ${r}`;return e.jsxs("div",{className:"dash-chart",children:[e.jsx("div",{className:"dash-chart-title",children:u}),e.jsx("div",{className:"dash-chart-body",children:t.kind==="donut"?e.jsx(qo,{slices:o.slices}):t.kind==="line"?e.jsx(Ko,{slices:o.slices}):e.jsx(Go,{slices:o.slices})})]})}Ne({"dashwidget.sectionUntitled":{zh:"未命名分区",en:"Untitled section"},"dashwidget.clockBadTz":{zh:"时区「{tz}」无效,已按本机时间显示",en:'Time zone "{tz}" is invalid, showing local time instead'},"dashwidget.wmoClear":{zh:"晴",en:"Clear"},"dashwidget.wmoPartly":{zh:"多云",en:"Partly cloudy"},"dashwidget.wmoOvercast":{zh:"阴",en:"Overcast"},"dashwidget.wmoFog":{zh:"雾",en:"Fog"},"dashwidget.wmoDrizzle":{zh:"毛毛雨",en:"Drizzle"},"dashwidget.wmoRain":{zh:"雨",en:"Rain"},"dashwidget.wmoSnow":{zh:"雪",en:"Snow"},"dashwidget.wmoShowers":{zh:"阵雨",en:"Showers"},"dashwidget.wmoSnowShowers":{zh:"阵雪",en:"Snow showers"},"dashwidget.wmoThunder":{zh:"雷暴",en:"Thunderstorm"},"dashwidget.weatherNoCity":{zh:"未指定城市",en:"No city specified"},"dashwidget.weatherCityNotFound":{zh:"找不到「{city}」",en:'Could not find "{city}"'},"dashwidget.weatherBadResponse":{zh:"返回数据异常",en:"Unexpected response from the weather service"},"dashwidget.weatherError":{zh:"天气不可用:{msg}",en:"Weather unavailable: {msg}"},"dashwidget.weatherWind":{zh:"风 {n} km/h",en:"Wind {n} km/h"},"dashwidget.loading":{zh:"加载中…",en:"Loading…"},"dashwidget.webviewNoUrl":{zh:"未指定 url",en:"No url specified"},"dashwidget.webviewBlocked":{zh:"已拦截:网页卡片只允许公网 http(s) 地址(拒绝 file/data/javascript、localhost 与内网)。",en:"Blocked: web cards only allow public http(s) addresses (file, data and javascript URLs, localhost and private networks are rejected)."},"dashwidget.webviewUnsupported":{zh:"此端不支持内嵌网页",en:"Embedded web pages are not supported on this platform"}});function Ca({widget:t,filters:n=[]}){return t.kind==="clock"?e.jsx(hd,{opts:t.opts}):t.kind==="weather"?e.jsx(gd,{opts:t.opts}):t.kind==="webview"?e.jsx(xd,{opts:t.opts}):t.kind==="section"?e.jsx(ud,{opts:t.opts}):t.kind==="stat"?e.jsx(rd,{opts:t.opts,filters:n}):t.kind==="chart"?e.jsx(cd,{opts:t.opts,filters:n}):null}function ud({opts:t}){const{t:n}=he();return e.jsxs("div",{className:"dash-widget dash-section",children:[e.jsx("span",{className:"dash-section-title",children:t.title||n("dashwidget.sectionUntitled")}),t.note&&e.jsx("span",{className:"dash-section-note",children:t.note})]})}function zi(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function hd({opts:t}){const{t:n,locale:s}=he(),[i,l]=c.useState(()=>new Date);c.useEffect(()=>{let h;const j=window.setTimeout(()=>{l(new Date),h=window.setInterval(()=>l(new Date),1e3)},1e3-Date.now()%1e3);return()=>{clearTimeout(j),h&&clearInterval(h)}},[]);const o=t.tz||zi();let r,u,f=!1;try{({time:r,date:u}=Js(i,{locale:s,timeZone:o}))}catch{f=!0,{time:r,date:u}=Js(i,{locale:s})}return e.jsxs("div",{className:"dash-widget dash-clock",children:[e.jsx("div",{className:"dash-clock-time",children:r}),e.jsxs("div",{className:"dash-clock-sub",children:[u,(t.label||o)&&e.jsx("span",{className:"dash-clock-tz",children:t.label||o.split("/").pop()})]}),f&&e.jsx("div",{className:"dash-widget-note",children:n("dashwidget.clockBadTz",{tz:o})})]})}function md(t){return t===0?{icon:"☀️",key:"dashwidget.wmoClear"}:t<=2?{icon:"🌤️",key:"dashwidget.wmoPartly"}:t===3?{icon:"☁️",key:"dashwidget.wmoOvercast"}:t<=49?{icon:"🌫️",key:"dashwidget.wmoFog"}:t<=59?{icon:"🌦️",key:"dashwidget.wmoDrizzle"}:t<=69?{icon:"🌧️",key:"dashwidget.wmoRain"}:t<=79?{icon:"🌨️",key:"dashwidget.wmoSnow"}:t<=84?{icon:"🌧️",key:"dashwidget.wmoShowers"}:t<=94?{icon:"🌨️",key:"dashwidget.wmoSnowShowers"}:{icon:"⛈️",key:"dashwidget.wmoThunder"}}async function pd(t,n){let s=Number(t.lat),i=Number(t.lon),l=t.label||t.city||"";if(!Number.isFinite(s)||!Number.isFinite(i)){const u=t.city||t.label;if(!u)throw new Error(_("dashwidget.weatherNoCity"));const j=(await(await fetch(`https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(u)}&count=1&language=zh&format=json`,{signal:n})).json()).results?.[0];if(!j)throw new Error(_("dashwidget.weatherCityNotFound",{city:u}));s=j.latitude,i=j.longitude,l=l||j.name}const r=await(await fetch(`https://api.open-meteo.com/v1/forecast?latitude=${s}&longitude=${i}&current=temperature_2m,weather_code,wind_speed_10m`,{signal:n})).json();if(!r.current)throw new Error(_("dashwidget.weatherBadResponse"));return{temp:r.current.temperature_2m,code:r.current.weather_code,wind:r.current.wind_speed_10m,place:l}}const fd=900*1e3;function gd({opts:t}){const{t:n}=he(),[s,i]=c.useState(null),[l,o]=c.useState(null),r=JSON.stringify(t);if(c.useEffect(()=>{const f=new AbortController,h=()=>{pd(t,f.signal).then(m=>{i(m),o(null)}).catch(m=>{f.signal.aborted||o(m instanceof Error?m.message:String(m))})};h();const j=window.setInterval(h,fd);return()=>{f.abort(),clearInterval(j)}},[r]),l)return e.jsx("div",{className:"dash-widget dash-weather",children:e.jsx("div",{className:"dash-widget-note",children:n("dashwidget.weatherError",{msg:l})})});if(!s)return e.jsx("div",{className:"dash-widget dash-weather",children:e.jsx("div",{className:"dash-widget-note",children:n("dashwidget.loading")})});const u=md(s.code);return e.jsxs("div",{className:"dash-widget dash-weather",children:[e.jsxs("div",{className:"dash-weather-main",children:[e.jsx("span",{className:"dash-weather-icon",children:u.icon}),e.jsxs("span",{className:"dash-weather-temp",children:[Math.round(s.temp),"°"]})]}),e.jsxs("div",{className:"dash-clock-sub",children:[n(u.key)," · ",n("dashwidget.weatherWind",{n:Math.round(s.wind)}),s.place&&e.jsx("span",{className:"dash-clock-tz",children:s.place})]})]})}function xd({opts:t}){const{t:n}=he(),s=t.url||"",i=c.useRef(null);return s?Qa(s)?window.tangu?e.jsx(Yo,{ref:i,src:s,partition:Xo,className:"dash-webview"}):e.jsx("div",{className:"dash-widget",children:e.jsxs("div",{className:"dash-widget-note",children:[n("dashwidget.webviewUnsupported")," · ",e.jsx("a",{href:s,target:"_blank",rel:"noreferrer",children:s})]})}):e.jsx("div",{className:"dash-widget",children:e.jsxs("div",{className:"dash-widget-note",children:[n("dashwidget.webviewBlocked"),e.jsx("br",{}),e.jsx("code",{children:s.slice(0,120)})]})}):e.jsx("div",{className:"dash-widget",children:e.jsx("div",{className:"dash-widget-note",children:n("dashwidget.webviewNoUrl")})})}Ne({"viewcard.missingType":{zh:"卡片源码里缺 `type:`(视图注册键)",en:"The card source is missing `type:` (the view registration key)"},"viewcard.unavailable":{zh:"视图「{type}」不可用 —— 可能来自未启用的插件",en:'View "{type}" is unavailable — it may come from a plugin that is not enabled'}});function vd({dashLeafId:t,dashPath:n,blockId:s,opts:i,size:l,onClose:o}){const r=Ft(),{t:u}=he(),f=i.type??"",[,h]=c.useState(0);c.useEffect(()=>Jo(()=>h(G=>G+1)),[]);const j=c.useRef(o);j.current=o;const m=JSON.stringify(i),y=c.useMemo(()=>{const{type:G,...S}=JSON.parse(m);return S},[m]),p=c.useMemo(()=>({id:`${t}::${s}`,type:f,loc:"main",params:y,setTitle:()=>{},setParams:G=>{const S=r.getState();if(S.activePage!==n)return;const M={type:f};for(const[z,k]of Object.entries(G))z!=="type"&&(typeof k=="string"||typeof k=="number"||typeof k=="boolean")&&(M[z]=String(k));const R=ze("view",M);(S.blocks[s]?.content??"").trim()!==R&&S.setBlockContent(s,R)},close:()=>j.current()}),[t,n,s,f,y,r]);if(!f)return e.jsx("div",{className:"dash-widget",children:e.jsx("div",{className:"dash-widget-note",children:u("viewcard.missingType")})});const x=mn(f);if(!x)return e.jsx("div",{className:"dash-widget",children:e.jsx("div",{className:"dash-widget-note",children:u("viewcard.unavailable",{type:f})})});const O=l??x.dashboard?.defaultSize??"lg",T=x.dashboard?.factory?x.dashboard.factory({leaf:p,params:y},{size:O}):x.factory({leaf:p,params:y});return e.jsx("div",{className:`wb-view dash-viewcard${x.dashboard?.factory?" dash-viewcard--compact":" dash-viewcard--interactive"}`,"data-view-type":f,onPointerDownCapture:()=>{f==="amadeus-editor"&&Kt(p.id)},children:T})}const Pa=new Set(["chat","browser","terminal","dashboard","amadeus-dashboard","sidebar-empty","home"]);function wd(t,n){return t.type==="outline"?{param:"sourcePath",accept:(s,i)=>n(i)==="amadeus-editor"}:!t.idParam||!t.fileMatch?null:{param:t.idParam,accept:(s,i)=>n(i)===t.type}}async function bd(t){const n=Gt.getState();await n.load(t,t);const s=Gt.getState().entries[t]?.data;if(!s)return null;const i=Vs(s),l=i.find(f=>f.type==="chart");if(l)return l.name;const o=new Set(i.map(f=>f.name));let r="图表";for(let f=2;o.has(r);f++)r=`图表 ${f}`;const u={id:Bi(),name:r,type:"chart"};return n.mutate(t,f=>({...f,views:[...Vs(f),u]})),r}function yd(t,n){const s=Object.entries(t).find(([l,o])=>l!=="type"&&/path$/i.test(l)&&o);if(!s)return n;const i=(s[1].split(/[\\/]/).pop()??s[1]).replace(/\.[^.]+$/,"");return i?`${n} · ${i}`:n}Ne({"dashfilter.label":{zh:"筛选",en:"Filter"},"dashfilter.remove":{zh:"去掉这条",en:"Remove this filter"},"dashfilter.addTitle":{zh:"加一条筛选",en:"Add a filter"},"dashfilter.noCards":{zh:"这一页还没有可筛的数据卡",en:"No filterable data cards on this page yet"},"dashfilter.add":{zh:"加筛选",en:"Add filter"},"dashfilter.pickOne":{zh:"选一个…",en:"Pick one…"},"dashfilter.valuePlaceholder":{zh:"值",en:"Value"},"dashfilter.commit":{zh:"加上",en:"Add"}});function jd(){const t=Gt(n=>n.entries);return c.useMemo(()=>{const n=new Map;for(const s of Object.values(t))if(!(s.status!=="ok"||!s.data))for(const i of s.data.columns)n.has(i.name)||n.set(i.name,{name:i.name,kind:Za(i.type),options:i.options??[]});return[...n.values()].sort((s,i)=>s.name.localeCompare(i.name))},[t])}function kd({filters:t,editable:n,onChange:s}){const i=jd(),[l,o]=c.useState(!1),[r,u]=c.useState(null),f=Mn(l),{t:h}=he();if(!t.length&&!n)return null;const j=()=>{const x=i[0];x&&(u({prop:x.name,op:ns[x.kind]?.[0]??"eq",value:""}),o(!0))},m=r?i.find(x=>x.name===r.prop):null,y=m?ns[m.kind]??["eq"]:["eq"],p=()=>{if(!r)return;const x=Qs.has(r.op);!x&&!r.value.trim()||(s([...t,{prop:r.prop,op:r.op,...x?{}:{value:r.value.trim()}}]),u(null),o(!1))};return e.jsxs("div",{className:"dash-filterbar",children:[e.jsx(Zo,{size:12,className:"dash-filterbar-label"}),e.jsx("span",{className:"dash-filterbar-label",children:h("dashfilter.label")}),t.map((x,O)=>e.jsxs("span",{className:"dash-filter-chip",children:[e.jsx("b",{children:x.prop}),e.jsx("span",{children:Zs[x.op]??x.op}),x.value!==void 0&&e.jsx("span",{children:x.value}),n&&e.jsx("button",{title:h("dashfilter.remove"),onClick:()=>s(t.filter((T,G)=>G!==O)),children:e.jsx(zs,{size:11})})]},`${x.prop}-${x.op}-${O}`)),n&&e.jsxs("span",{style:{position:"relative",display:"inline-flex"},children:[e.jsxs("button",{className:"dash-filter-add",onClick:j,disabled:!i.length,title:i.length?h("dashfilter.addTitle"):h("dashfilter.noCards"),children:[e.jsx(Dt,{size:11})," ",h("dashfilter.add")]}),l&&r&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"dash-menu-scrim",onClick:()=>{o(!1),u(null)}}),e.jsxs("div",{ref:f.ref,className:"dash-add-menu dash-filter-editor",style:f.style,children:[e.jsx("select",{value:r.prop,onChange:x=>{const O=i.find(T=>T.name===x.target.value);u({prop:x.target.value,op:(O&&ns[O.kind]?.[0])??"eq",value:""})},children:i.map(x=>e.jsx("option",{value:x.name,children:x.name},x.name))}),e.jsx("select",{value:r.op,onChange:x=>u({...r,op:x.target.value}),children:y.map(x=>e.jsx("option",{value:x,children:Zs[x]??x},x))}),!Qs.has(r.op)&&(m?.options.length?e.jsxs("select",{value:r.value,onChange:x=>u({...r,value:x.target.value}),children:[e.jsx("option",{value:"",children:h("dashfilter.pickOne")}),m.options.map(x=>e.jsx("option",{value:x,children:x},x))]}):e.jsx("input",{value:r.value,placeholder:h("dashfilter.valuePlaceholder"),onChange:x=>u({...r,value:x.target.value}),onKeyDown:x=>{x.key==="Enter"&&p()},autoFocus:!0})),e.jsx("button",{className:"dash-filter-commit",onClick:p,children:h("dashfilter.commit")})]})]})]})]})}Ne({"dashgrid.add.section":{zh:"分区标题",en:"Section heading"},"dashgrid.default.section":{zh:"新分区",en:"New section"},"dashgrid.tpl.today":{zh:"今天",en:"Today"},"dashgrid.tpl.doing":{zh:"在办",en:"In progress"},"dashgrid.tpl.recent":{zh:"最近",en:"Recent"},"dashgrid.add.stat":{zh:"数字卡…",en:"Stat card…"},"dashgrid.add.chart":{zh:"图表(多维表)…",en:"Chart (database)…"},"dashgrid.add.text":{zh:"文本块",en:"Text block"},"dashgrid.add.clock":{zh:"时钟",en:"Clock"},"dashgrid.add.weather":{zh:"天气",en:"Weather"},"dashgrid.add.webview":{zh:"网页",en:"Web page"},"dashgrid.tpl.today.name":{zh:"今日",en:"Today"},"dashgrid.tpl.today.hint":{zh:"时钟 · 天气 · 待办 · 日历",en:"Clock · Weather · To-dos · Calendar"},"dashgrid.tpl.work.name":{zh:"工作台",en:"Workbench"},"dashgrid.tpl.work.hint":{zh:"收件箱 · 待办 · 活动日志",en:"Inbox · To-dos · Activity log"},"dashgrid.tpl.blank.name":{zh:"空白",en:"Blank"},"dashgrid.tpl.blank.hint":{zh:"自己拼",en:"Build your own"},"dashgrid.size.sm":{zh:"小",en:"Small"},"dashgrid.size.md":{zh:"中",en:"Medium"},"dashgrid.size.wide":{zh:"宽",en:"Wide"},"dashgrid.size.tall":{zh:"高",en:"Tall"},"dashgrid.size.lg":{zh:"大",en:"Large"},"dashgrid.size.full":{zh:"整行",en:"Full row"},"dashgrid.size.workspace":{zh:"工作区",en:"Workspace"},"dashgrid.pin":{zh:"置顶",en:"Pin"},"dashgrid.unpin":{zh:"取消置顶",en:"Unpin"},"dashgrid.editLayout":{zh:"编辑布局",en:"Edit layout"},"dashgrid.editLayoutTip":{zh:"编辑布局(拖动排序 / 改大小 / 增删卡片)",en:"Edit layout (drag to reorder, resize, add or remove cards)"},"dashgrid.done":{zh:"完成",en:"Done"},"dashgrid.addCard":{zh:"添加卡片",en:"Add card"},"dashgrid.menuViews":{zh:"视图",en:"Views"},"dashgrid.more":{zh:"更多操作",en:"More actions"},"dashgrid.noFile":{zh:"未指定仪表盘文件。",en:"No dashboard file specified."},"dashgrid.fmBroken":{zh:"这份笔记的 frontmatter 无法解析({error}),布局已冻结、不会自动改写。请先修好 YAML。",en:"Could not parse this note's frontmatter ({error}). The layout is frozen and will not be rewritten — please fix the YAML first."},"dashgrid.staleBanner":{zh:"布局记录的块 id 与当前块对不上(笔记可能被重编号过),已停止自动重排以免丢失布局。",en:"The block ids in the saved layout do not match the current blocks (the note may have been renumbered), so automatic reflow is off to avoid losing the layout."},"dashgrid.reflowNow":{zh:"按当前顺序重排",en:"Reflow in current order"},"dashgrid.emptyTitle":{zh:"从模板开始",en:"Start from a template"},"dashgrid.emptySub":{zh:"先放下常用组合,再拖动排序、按格调整大小。",en:"Drop in a common combination first, then drag to reorder and resize by the grid."},"dashgrid.templatesLabel":{zh:"仪表盘模板",en:"Dashboard templates"},"dashgrid.prompt.weather":{zh:"天气卡片 — 城市",en:"Weather card — city"},"dashgrid.prompt.webview":{zh:"网页卡片 — 地址",en:"Web card — address"},"dashgrid.webviewRejected":{zh:"只允许公网 http(s) 地址(拒绝 file/data、localhost 与内网)",en:"Only public http(s) addresses are allowed — file/data, localhost and private networks are rejected"},"dashgrid.pickDbStat":{zh:"数字卡 — 选一份多维表(.db)…",en:"Stat card — pick a database (.db)…"},"dashgrid.prompt.statCol":{zh:"统计哪一列?(留空 = 数行数)",en:"Which column to measure? (leave empty to count rows)"},"dashgrid.prompt.statFn":{zh:"统计方式(count/sum/avg/min/max)",en:"Aggregation (count/sum/avg/min/max)"},"dashgrid.pickDbChart":{zh:"图表 — 选一份多维表(.db)…",en:"Chart — pick a database (.db)…"},"dashgrid.pickFileFor":{zh:"选择要放进「{name}」卡片的文件…",en:'Pick a file for the "{name}" card…'},"dashgrid.layoutUnreadable":{zh:"这份笔记的布局读不出来,已停手 —— 请先修好 frontmatter",en:"Could not read this note's layout, so nothing was changed — please fix the frontmatter first"},"dashgrid.menuSize":{zh:"大小",en:"Size"},"dashgrid.restoreAuto":{zh:"恢复自动排版",en:"Restore automatic layout"},"dashgrid.deleteCard":{zh:"删除卡片",en:"Delete card"},"dashgrid.switchToCanvas":{zh:"切换到自由摆位(高级)",en:"Switch to free-form canvas (advanced)"},"dashgrid.renameTitle":{zh:"重命名仪表盘",en:"Rename dashboard"},"dashgrid.rename":{zh:"重命名",en:"Rename"},"dashgrid.delete":{zh:"删除",en:"Delete"},"dashgrid.confirmDelete":{zh:"删除仪表盘「{name}」?",en:'Delete the dashboard "{name}"?'},"dashgrid.deleteFailed":{zh:"删除失败:{error}",en:"Delete failed: {error}"},"dashgrid.deleted":{zh:"已删除",en:"Deleted"},"dashgrid.viewUnavailable":{zh:"视图「{type}」不可用",en:'View "{type}" is unavailable'},"dashgrid.viewNotEmbeddable":{zh:"视图「{type}」不支持嵌入卡片",en:'View "{type}" cannot be embedded in a card'},"dashgrid.openInTab":{zh:"在标签页里打开",en:"Open in a tab"},"dashgrid.openInTabAria":{zh:"在标签页里打开{title}",en:"Open {title} in a tab"},"dashgrid.dragToReorder":{zh:"拖动排序",en:"Drag to reorder"},"dashgrid.dragOrEnter":{zh:"拖动排序;双击进入卡片",en:"Drag to reorder; double-click to enter the card"},"dashgrid.sizeAndMore":{zh:"大小与更多",en:"Size and more"},"dashgrid.setCardSize":{zh:"设置卡片大小",en:"Set card size"},"dashgrid.deleteThisCard":{zh:"删除这张卡片",en:"Delete this card"},"dashgrid.resize":{zh:"调整大小",en:"Resize"}});const Sd=[{key:"section",labelKey:"dashgrid.add.section",icon:bl},{key:"stat",labelKey:"dashgrid.add.stat",icon:or},{key:"chart",labelKey:"dashgrid.add.chart",icon:rr},{key:"text",labelKey:"dashgrid.add.text",icon:ii},{key:"clock",labelKey:"dashgrid.add.clock",icon:si},{key:"weather",labelKey:"dashgrid.add.weather",icon:vl},{key:"webview",labelKey:"dashgrid.add.webview",icon:Bt}],Nd={sm:"dashgrid.size.sm",md:"dashgrid.size.md",wide:"dashgrid.size.wide",tall:"dashgrid.size.tall",lg:"dashgrid.size.lg",full:"dashgrid.size.full",workspace:"dashgrid.size.workspace"},zd=[{key:"today",nameKey:"dashgrid.tpl.today.name",hintKey:"dashgrid.tpl.today.hint",cards:[{content:ze("section",{title:_("dashgrid.tpl.today")}),w:12,h:1},{content:ze("clock",{}),w:6,h:2},{content:ze("weather",{city:"上海"}),w:6,h:2},{content:ze("view",{type:"todo-list"}),w:6,h:5},{content:ze("view",{type:"calendar"}),w:6,h:5}]},{key:"work",nameKey:"dashgrid.tpl.work.name",hintKey:"dashgrid.tpl.work.hint",cards:[{content:ze("section",{title:_("dashgrid.tpl.doing")}),w:12,h:1},{content:ze("view",{type:"inbox-list"}),w:6,h:5},{content:ze("view",{type:"todo-list"}),w:6,h:5},{content:ze("section",{title:_("dashgrid.tpl.recent")}),w:12,h:1},{content:ze("view",{type:"activity-log"}),w:12,h:5}]},{key:"blank",nameKey:"dashgrid.tpl.blank.name",hintKey:"dashgrid.tpl.blank.hint",cards:[]}],ln=t=>t==="section",Is={w:4,h:3},Ci={sizes:["lg","full"],defaultSize:"lg",surface:"workspace",min:Is},Ta={section:{sizes:["full"],defaultSize:"full",surface:"chrome"},clock:{sizes:["sm","wide"],defaultSize:"sm",surface:"metric"},weather:{sizes:["sm","wide"],defaultSize:"sm",surface:"metric"},stat:{sizes:["sm","md","wide"],defaultSize:"sm",surface:"metric"},chart:{sizes:["wide","lg","full"],defaultSize:"wide",surface:"summary",min:{w:4,h:2}},webview:{sizes:["lg","full"],defaultSize:"lg",surface:"workspace",min:Is},text:{sizes:["md","wide","lg","full"],defaultSize:"wide",surface:"note"}},ds=t=>t.min??dr(t.sizes);function Lt(t){const n=Pt(t);if(n?.kind==="view"){const s=mn(n.opts.type??"")?.dashboard;return s?{sizes:s.sizes,defaultSize:s.defaultSize,surface:s.surface??"workspace",min:s.min??Is}:Ci}return Ta[n?.kind??"text"]??Ta.text}const Rn=(t,n=0)=>{const s=fs(t);return{order:n,w:s.w,h:s.h}},Cd=()=>null;function Pd(t,n,s){const i=t.indexOf(n),l=t.indexOf(s);if(i<0||l<0||i===l)return t;const o=t.filter(r=>r!==n);return o.splice(i<l?o.indexOf(s)+1:o.indexOf(s),0,n),o}const Td=(t,n)=>ur(t,n)??n[0]??"lg",Ed=[],Dd={},Ea=(t,n)=>{if(!t)return!1;const s=Object.keys(t);return s.length===Object.keys(n).length&&s.every(i=>n[i]&&t[i].row===n[i].row&&t[i].col===n[i].col)};function hu(t){return e.jsx(Ts.Provider,{value:t.leaf.id,children:e.jsx(Rd,{...t})})}function Rd({leaf:t}){const{t:n}=he(),s=Ft(),i=typeof t.params.dashPath=="string"?t.params.dashPath:"",l=t.params.locked!==!1,o=Xa(d=>d.mode),r=I(d=>d.manifest),u=I(d=>d.blocks),f=I(d=>d.activePage),h=I(d=>d.manifest?.fmExtra??""),j=Pe(d=>!!i&&d.pins.includes(i)),m=ll(),[y,p]=c.useState(!1),[x,O]=c.useState(null),[T,G]=c.useState(null),S=Mn(y),M=Mn(x?`${x.x},${x.y}`:""),R=Mn(T?`${T.x},${T.y}`:""),[z,k]=c.useState(!1);c.useEffect(()=>{i&&t.setTitle(ss(i))},[i]),c.useEffect(()=>{i&&i!==s.getState().activePage&&s.getState().loadPage(i)},[i]);const $=$e(d=>d.mainTabs.find(v=>v.id===t.id)?.active??!1);c.useEffect(()=>{$&&Kt(t.id)},[$,t.id]);const D=c.useMemo(()=>{if(!r)return[];const d=[];for(const v of r.root.children)for(const C of v.columns)for(const B of C.children)d.push(B.ref);return d},[r]),K=c.useMemo(()=>as(h),[h]),Z=K.ok?K.layout:{},ce=K.ok&&Qo(Z,D),U=c.useMemo(()=>ea(h),[h]),re=U.ok?U.pins:Dd,we=c.useMemo(()=>er(h),[h]),Fe=we.ok?we.filters:Ed,ge=()=>{const d=s.getState();return d.activePage===i?d.loadNonce:null},X=(d,v)=>{const C=s.getState();if(C.activePage!==i||v!==void 0&&(v===null||C.loadNonce!==v))return!1;const B=C.manifest?.fmExtra??"";return d===null||d===B?!1:(C.setFmExtra(d),!0)},pe=(d,v)=>X(is(s.getState().manifest?.fmExtra??"",d),v),ue=()=>{const d=as(s.getState().manifest?.fmExtra??"");return d.ok?d.layout:null};c.useEffect(()=>{if(!r||f!==i||!D.length||!K.ok||ce)return;const d=ta(Z,D),v=U.ok?tr(re,D):null;if(!d&&!v)return;let C=s.getState().manifest?.fmExtra??"";d&&(C=is(C,d)??C),v&&(C=os(C,v)??C),X(C)},[D,Z,re,r,f,i,K.ok,U.ok,ce]);const N=c.useRef(null),ie=c.useRef(null),[ne,xe]=c.useState(0);c.useLayoutEffect(()=>{const d=ie.current;if(!d)return;const v=new ResizeObserver(([B])=>xe(B.contentRect.width));v.observe(d);const C=getComputedStyle(d);return xe(d.clientWidth-parseFloat(C.paddingLeft||"0")-parseFloat(C.paddingRight||"0")),()=>v.disconnect()},[]);const ke=nr(ne),Ue=ke>0?(ne-at*(ke-1))/ke:0,P=c.useMemo(()=>sr(Z,D),[Z,D]),[A,H]=c.useState(null),Y=c.useRef(new Map),fe=c.useRef(null),se=c.useRef(null),F=(d,v)=>{if(l||se.current)return;d.preventDefault(),d.stopPropagation();const C=Lt(u[v]?.content??""),B=ds(C),ae=Z[v]??Rn(C.defaultSize),ee=Y.current.get(v)??{...ae,w:Math.max(B.w,ae.w),h:Math.max(B.h,ae.h)};se.current={id:v,pointerId:d.pointerId,nonce:ge(),x:d.clientX,y:d.clientY,w:ee.w,h:ee.h},fe.current={id:v,w:ee.w,h:ee.h},H({id:v,w:ee.w,h:ee.h}),d.currentTarget.setPointerCapture(d.pointerId)},W=d=>{const v=se.current;if(!v||v.pointerId!==d.pointerId||Ue<=0)return;const C=mr(v.w,ke),B=C*Ue+(C-1)*at+(d.clientX-v.x),ae=Math.max(1,Math.min(ke,Math.round((B+at)/(Ue+at)))),ee=Math.max(1,Math.min(an,Math.round(ae*an/ke))),le=v.h*on+(v.h-1)*at+(d.clientY-v.y),me=Math.max(1,Math.min(yr,Math.round((le+at)/(on+at)))),be=Lt(u[v.id]?.content??""),Be=ds(be),Ge={w:Math.max(Be.w,ee),h:Math.max(Be.h,me)};fe.current={id:v.id,w:Ge.w,h:Ge.h},H(nt=>nt&&nt.w===Ge.w&&nt.h===Ge.h?nt:{id:v.id,w:Ge.w,h:Ge.h})},Je=d=>{const v=se.current;if(v&&d&&v.pointerId!==d.pointerId)return;const C=fe.current;if(se.current=null,fe.current=null,H(null),!v||!C||C.w===v.w&&C.h===v.h)return;const B=ue();!B||!B[v.id]||pe({...B,[v.id]:{...B[v.id],w:C.w,h:C.h}},v.nonce)},Ze=d=>{const v=ea(s.getState().manifest?.fmExtra??"");if(!v.ok||!v.pins[d])return;const C=v.pins[d].row,B={};for(const[ae,ee]of Object.entries(v.pins))ee.row!==C&&(B[ae]=ee);X(os(s.getState().manifest?.fmExtra??"",B))},_e=(d,v,C)=>{const B=ue();!B||!B[d]||pe({...B,[d]:{...B[d],w:v,h:C}})},ut=Ba(hs(vr,{activationConstraint:{distance:4}}),hs(xr,{activationConstraint:{delay:150,tolerance:8}})),[Qe,bt]=c.useState(null),[Te,Le]=c.useState(null);c.useLayoutEffect(()=>{l&&Le(null)},[l]);const[qe,it]=c.useState(null),We=c.useRef(null),[oe,ht]=c.useState(null),Ee=c.useRef(null),Ie=c.useRef(0),Ke=c.useRef(null),et=c.useRef({bands:[],byId:new Map}),jt=c.useRef(null),ot=c.useRef(null),mt=c.useRef(1),w=d=>{ot.current=ge(),Le(null),jt.current=new Map(Y.current);const v=ie.current,C=v&&v.offsetWidth>0?v.getBoundingClientRect().width/v.offsetWidth:1;mt.current=Math.abs(C-1)<.005?1:C,Ie.current=gr(re),Ke.current=null,Ee.current=null,bt(String(d.active.id))},V=d=>{Ea(Ee.current,d)||(Ee.current=d,ht(d))},J=d=>{const v=String(d.active.id),C=d.over?String(d.over.id):null;if(!C||C===v)return;Ke.current=null;const B={...re};delete B[v],V(B);const ae=We.current??P,ee=Pd(ae,v,C);ee.join(`
12
+ `)!==ae.join(`
13
+ `)&&(We.current=ee,it(ee))},Q=d=>{const v=String(d.active.id);if(d.over&&String(d.over.id)!==v||ln(Pt(u[v]?.content??"")?.kind)||!U.ok)return;const C=d.active.rect.current.translated,B=ie.current,ae=B?.getBoundingClientRect(),ee=et.current.byId.get(v);if(!C||!B||!ae||!ee||Ue<=0)return;const le=getComputedStyle(B),me=mt.current,be=d.activatorEvent,Be=typeof be?.clientY=="number"?be.clientY:be?.touches?.[0]?.clientY,Ge=typeof Be=="number"?Be+d.delta.y:C.top+C.height/2,nt=(C.left-ae.left)/me-parseFloat(le.paddingLeft||"0"),a=(Ge-ae.top)/me-parseFloat(le.paddingTop||"0"),b=on+at,g=et.current.bands.findIndex(L=>a>=L.top&&a<L.top+L.h*b);if(g<0)return;const E=Math.round(nt/(Ue+at)),de=Math.max(0,Math.min(an-ee.w,Math.round(E*an/ke)));if(Ke.current&&Ke.current.band===g&&Ke.current.col===de)return;Ke.current={band:g,col:de};const ve=et.current.bands[g].ids.filter(L=>L!==v);if(ve.some(L=>ln(Pt(u[L]?.content??"")?.kind)))return;const De=fr(We.current??P,Ee.current??re,[{id:v,col:de,w:ee.w},...ve.map(L=>({id:L,col:et.current.byId.get(L)?.col??0,w:et.current.byId.get(L)?.w??1}))],Ie.current);V(De.pins),De.ids.join(`
14
+ `)!==(We.current??P).join(`
15
+ `)&&(We.current=De.ids,it(De.ids))},Ce=()=>{const d={nonce:ot.current,seq:We.current,pins:Ee.current};return ot.current=null,We.current=null,Ee.current=null,jt.current=null,Ke.current=null,bt(null),it(null),ht(null),d},Re=()=>{Ce()},tt=()=>{const{nonce:d,seq:v,pins:C}=Ce();if(!v&&!C)return;const B=ue();if(!B)return;const ae=(v??P).filter(be=>D.includes(be));for(const be of D)ae.includes(be)||ae.push(be);const ee=ae.join(`
16
+ `)!==P.join(`
17
+ `),le=!!C&&U.ok&&!Ea(C,re);if(!ee&&!le)return;let me=s.getState().manifest?.fmExtra??"";ee&&(me=is(me,pr(B,ae))??me),le&&(me=os(me,C)??me),X(me,d)},Ae=(d,v)=>{const C=s.getState();if(C.activePage!==i)return null;const B=D[D.length-1]??null,ae=C.insertBlockAfter(B,void 0,d);if(!ae)return null;const ee=as(s.getState().manifest?.fmExtra??"");if(ee.ok){const le=Object.values(ee.layout).reduce((me,be)=>Math.max(me,be.order+1),0);pe({...ee.layout,[ae]:{order:le,w:v.w,h:v.h}})}return ae},vn=d=>{p(!1),(async()=>{if(d==="text"){Ae("",jr);return}if(d==="section"){const C=await rt(n("dashgrid.add.section"),n("dashgrid.default.section"));if(!C?.trim())return;Ae(ze("section",{title:C.trim()}),{w:12,h:1});return}if(d==="clock"){Ae(ze("clock",{tz:zi()}),zn);return}if(d==="weather"){const C=await rt(n("dashgrid.prompt.weather"),"上海");if(!C?.trim())return;Ae(ze("weather",{city:C.trim()}),zn);return}if(d==="stat"){await Kn();return}if(d==="chart"){await Mt();return}const v=await rt(n("dashgrid.prompt.webview"),"https://");if(v?.trim()){if(!Qa(v.trim())){Ve.getState().toast(n("dashgrid.webviewRejected"),!0);return}Ae(ze("webview",{url:v.trim()}),kr)}})()},en=d=>new Promise(v=>{ps.getState().openPicker({title:d,accept:(C,B)=>sa(B)==="amadeus-db",onPick:C=>v(C)})}),Kn=async()=>{const d=await en(n("dashgrid.pickDbStat"));if(!d)return;const v=(await rt(n("dashgrid.prompt.statCol"),""))?.trim()??"";if(!v){Ae(ze("stat",{source:d}),zn);return}const C=(await rt(n("dashgrid.prompt.statFn"),"sum"))?.trim();C&&Ae(ze("stat",{source:d,col:v,stat:C}),zn)},Mt=async()=>{const d=await en(n("dashgrid.pickDbChart"));if(!d)return;const v=await bd(d);Ae(ze("view",{type:"amadeus-db",dbPath:d,...v?{view:v}:{}}),Rn("lg"))},kt=c.useMemo(()=>ar().filter(d=>d.embeddable&&!Pa.has(d.type)).map(d=>({type:d.type,name:na(d.displayName),Icon:d.icon??Bt,spec:wd(d,sa)})).sort((d,v)=>d.name.localeCompare(v.name)),[y]),St=d=>{p(!1);const v=mn(d.type),C=Rn(v?.dashboard?.defaultSize??Ci.defaultSize);if(!d.spec){Ae(ze("view",{type:d.type}),C);return}const{param:B,accept:ae}=d.spec;ps.getState().openPicker({title:n("dashgrid.pickFileFor",{name:d.name}),accept:ae,onPick:ee=>{Ae(ze("view",{type:d.type,[B]:ee}),C)}})},wn=d=>{const v=s.getState();if(v.activePage!==i||!d.cards.length)return;const C=ue();if(!C){Ve.getState().toast(n("dashgrid.layoutUnreadable"),!0);return}let B=D[D.length-1]??null;const ae={...C};let ee=Object.values(ae).reduce((le,me)=>Math.max(le,me.order+1),0);for(const le of d.cards){const me=v.insertBlockAfter(B,void 0,le.content);if(!me)break;ae[me]={order:ee++,w:le.w,h:le.h},B=me}pe(ae)},tn=d=>{s.getState().activePage===i&&s.getState().deleteBlock(d)},Gn=d=>{X(hr(s.getState().manifest?.fmExtra??"",d))},bn=()=>{O(null),X(br(s.getState().manifest?.fmExtra??"","canvas"))};if(!i)return e.jsx("div",{className:"amx-draw-state",children:n("dashgrid.noFile")});const nn=d=>{const v=Pt(u[d]?.content??"");if(v?.kind!=="view")return{widget:v,title:null,Icon:null,openable:null};const C=v.opts.type??"",B=mn(C);if(!B)return{widget:v,title:n("dashgrid.viewUnavailable",{type:C}),Icon:Bt,openable:null};const{type:ae,...ee}=v.opts;return{widget:v,title:yd(v.opts,na(B.displayName)),Icon:B.icon??Bt,openable:()=>$e.getState().openView(C,ee,"main",{newTab:!0})}},$t=(d,v)=>{const C=Pt(u[d]?.content??"");if(C?.kind==="view"){const B=C.opts.type??"",ae=mn(B);return!ae||Pa.has(B)||!ae.embeddable?e.jsx("div",{className:"dash-widget",children:e.jsx("div",{className:"dash-widget-note",children:n("dashgrid.viewNotEmbeddable",{type:B})})}):e.jsx(vd,{dashLeafId:t.id,dashPath:i,blockId:d,opts:C.opts,size:v,onClose:()=>tn(d)})}return C?e.jsx(Ca,{widget:C,filters:Fe}):e.jsx(La,{blockId:d})},Ot=(()=>{if(!qe)return P;const d=qe.filter(v=>D.includes(v));for(const v of P)d.includes(v)||d.push(v);return d})(),sn=oe??re,yn=ir(Ot.map(d=>{const v=Lt(u[d]?.content??""),C=Z[d]??Rn(v.defaultSize),B=jt.current?.get(d),ae=B?{...C,w:B.w,h:B.h}:C,ee=A?.id===d?{...ae,...A}:ae,le=ln(Pt(u[d]?.content??"")?.kind),me=ds(v),be={key:Td(ee,v.sizes),w:Math.max(me.w,ee.w),h:Math.max(me.h,ee.h)},Be=fs(v.defaultSize),Ge=!sn[d]&&(!Z[d]||Z[d].w===Be.w&&Z[d].h===Be.h),nt=A?.id===d||!Ge?[be]:[be,...v.sizes.map(a=>fs(a)).filter(a=>a.w!==be.w||a.h!==be.h)];return{id:d,preferred:ee,choices:nt,chrome:le}}),sn,ke),Nt=[];{let d=1;const v=[],C=new Map;for(const B of yn){let ae=1;const ee=[];for(const le of B.items){const me=le.start??ae;Nt.push({id:le.id,rowStart:d,rowSpan:le.h,colStart:me,colSpan:le.span,size:le.size,cell:le.cell,chrome:le.chrome}),ae=me+le.span,ee.push(le.id),C.set(le.id,{col:Math.round((me-1)*an/ke),w:le.cell.w})}v.push({top:(d-1)*(on+at),h:B.h,ids:ee}),d+=B.h}et.current={bands:v,byId:C}}Y.current=new Map(Nt.map(d=>[d.id,d.cell]));const jn=(()=>{if(!Qe)return null;const d=Pt(u[Qe]?.content??""),v=d?.kind??"text";if(d&&ln(v))return e.jsx("div",{className:"dash3-card dash3-card--chrome dash3-card--lift",children:e.jsx("div",{className:"dash3-card-body",children:e.jsx(Ca,{widget:d})})});const C=nn(Qe);return e.jsxs("div",{className:"dash3-card dash3-card--lift","data-kind":v,"data-surface":Lt(u[Qe]?.content??"").surface,children:[C.title&&e.jsxs("div",{className:"dash3-card-head",children:[C.Icon&&e.jsx(C.Icon,{size:13,className:"dash3-card-icon"}),e.jsx("span",{className:"dash3-card-title",children:C.title})]}),e.jsx("div",{className:"dash3-card-body dash3-overlay-ghost"})]})})();return e.jsxs("div",{className:`am-app tangu-lovable amx-pane amx-editor dash3${z?" amx-dragover":""}`,"data-mode":o,onPointerDownCapture:d=>{Kt(t.id),Te&&!d.target.closest?.(`.dash3-card[data-key="${CSS.escape(Te)}"]`)&&Le(null)},onDragOver:d=>{l||!Array.from(d.dataTransfer?.types??[]).includes("Files")||(d.preventDefault(),k(!0))},onDragLeave:d=>{d.currentTarget.contains(d.relatedTarget)||k(!1)},onDrop:d=>{k(!1);const v=Array.from(d.dataTransfer?.files??[]);l||!v.length||(d.preventDefault(),Kt(t.id),Bn(v,i))},children:[e.jsxs("div",{className:"amx-toolbar",children:[e.jsx(Ls,{}),e.jsx("button",{className:`amx-mode-btn amx-pin-btn${j?" amx-pin-on":""}`,title:n(j?"dashgrid.unpin":"dashgrid.pin"),onClick:()=>Pe.getState().togglePin(i),children:e.jsx(xs,{size:14})}),e.jsxs("button",{className:`amx-mode-btn dash3-mode-btn${l?"":" amx-pin-on"}`,title:n(l?"dashgrid.editLayoutTip":"dashgrid.done"),onClick:()=>t.setParams({...t.params,locked:!l}),children:[l?e.jsx(dn,{size:13}):e.jsx(wt,{size:14}),e.jsx("span",{children:n(l?"dashgrid.editLayout":"dashgrid.done")})]}),e.jsx(ra,{initial:!1,children:!l&&e.jsxs(gs.div,{className:"dash-add-wrap",initial:m?!1:{opacity:0,scale:.9,x:-4},animate:{opacity:1,scale:1,x:0},exit:m?{opacity:0}:{opacity:0,scale:.9,x:-4},transition:{duration:m?0:.18,ease:[.16,1,.3,1]},children:[e.jsx("button",{className:"amx-mode-btn",title:n("dashgrid.addCard"),onClick:d=>{d.stopPropagation(),p(v=>!v)},children:e.jsx(Dt,{size:14})}),y&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"dash-menu-scrim",onClick:()=>p(!1)}),e.jsxs("div",{ref:S.ref,className:"dash-add-menu",style:S.style,children:[Sd.map(d=>e.jsxs("button",{onClick:()=>vn(d.key),children:[e.jsx(d.icon,{size:13})," ",n(d.labelKey)]},d.key)),kt.length>0&&e.jsx("div",{className:"dash-menu-sep",children:n("dashgrid.menuViews")}),kt.map(d=>e.jsxs("button",{onClick:()=>St(d),title:d.type,children:[e.jsx(d.Icon,{size:13})," ",d.name,d.spec?"…":""]},d.type))]})]})]})}),e.jsx("button",{className:"amx-mode-btn amx-more-btn",title:n("dashgrid.more"),onClick:d=>{d.stopPropagation();const v=d.currentTarget.getBoundingClientRect();O({x:Math.max(8,Math.min(v.right-180,window.innerWidth-196)),y:v.bottom+4})},children:e.jsx(Jt,{size:14})})]}),!K.ok&&e.jsx("div",{className:"dash-banner dash-banner-warn",children:n("dashgrid.fmBroken",{error:K.error})}),ce&&e.jsxs("div",{className:"dash-banner",children:[n("dashgrid.staleBanner"),e.jsx("button",{onClick:()=>pe(ta({},D)??{}),children:n("dashgrid.reflowNow")})]}),e.jsx(kd,{filters:Fe,editable:!l,onChange:Gn}),e.jsx(lr.Provider,{value:Fe,children:e.jsxs(gs.div,{layoutScroll:!0,ref:N,className:"dash3-host","data-locked":l||void 0,onPointerMove:W,onPointerUp:Je,onPointerCancel:Je,children:[e.jsxs(Va,{sensors:ut,collisionDetection:Ua,measuring:{droppable:{strategy:_a.Always}},onDragStart:w,onDragMove:Q,onDragOver:J,onDragEnd:tt,onDragCancel:Re,children:[e.jsx(Oa,{items:Ot,strategy:Cd,children:e.jsx("div",{ref:ie,className:"dash3-grid",style:{"--dash3-cols":ke,"--dash3-row":`${on}px`,"--dash3-gap":`${at}px`},children:ne>0&&e.jsx(ra,{initial:!1,mode:"popLayout",children:Nt.map(({id:d,rowStart:v,rowSpan:C,colStart:B,colSpan:ae,size:ee})=>{const le=nn(d);return e.jsx(Fd,{id:d,rowStart:v,rowSpan:C,colStart:B,colSpan:ae,locked:l,chrome:ln(le.widget?.kind),kind:le.widget?.kind??"text",surface:Lt(u[d]?.content??"").surface,size:ee,dragging:Qe===d,sizing:A?.id===d,interact:Te===d,reduceMotion:!!m,title:le.title,Icon:le.Icon,onOpen:le.openable,onInteract:()=>Le(d),onDelete:()=>tn(d),onMenu:(me,be)=>G({x:me,y:be,id:d}),onGripDown:me=>F(me,d),children:$t(d,ee)},d)})})})}),e.jsx(Wa,{zIndex:30,style:mt.current!==1?{zoom:1/mt.current}:void 0,dropAnimation:m?null:{duration:200,easing:"cubic-bezier(0.16, 1, 0.3, 1)"},children:jn})]}),!D.length&&e.jsx("div",{className:"dash3-empty",children:e.jsxs("div",{className:"dash3-empty-panel",children:[e.jsx("div",{className:"dash3-empty-mark","aria-hidden":"true",children:e.jsx(Bt,{size:18})}),e.jsxs("div",{className:"dash3-empty-copy",children:[e.jsx("div",{className:"dash3-empty-title",children:n("dashgrid.emptyTitle")}),e.jsx("div",{className:"dash3-empty-sub",children:n("dashgrid.emptySub")})]}),e.jsx("div",{className:"dash3-templates","aria-label":n("dashgrid.templatesLabel"),children:zd.filter(d=>d.cards.length).map(d=>{const v=d.key==="today"?si:Bt;return e.jsxs("button",{type:"button",className:"dash3-template",onClick:()=>wn(d),children:[e.jsx("span",{className:"dash3-template-icon","aria-hidden":"true",children:e.jsx(v,{size:16})}),e.jsxs("span",{className:"dash3-template-copy",children:[e.jsx("span",{className:"dash3-template-name",children:n(d.nameKey)}),e.jsx("span",{className:"dash3-template-hint",children:n(d.hintKey)})]})]},d.key)})})]})})]})}),T&&!l&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"dash-menu-scrim",onClick:()=>G(null)}),e.jsxs("div",{ref:R.ref,className:"dash-add-menu",style:{position:"fixed",left:T.x,top:T.y,...R.style},children:[e.jsx("div",{className:"dash-menu-sep",children:n("dashgrid.menuSize")}),cr.filter(d=>Lt(u[T.id]?.content??"").sizes.includes(d.key)).map(d=>e.jsxs("button",{onClick:()=>{_e(T.id,d.w,d.h),G(null)},children:[n(Nd[d.key])," ",e.jsxs("span",{className:"dash3-size-dim",children:[d.w,"×",d.h]})]},d.key)),re[T.id]&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"dash-menu-sep"}),e.jsx("button",{onClick:()=>{Ze(T.id),G(null)},children:n("dashgrid.restoreAuto")})]}),e.jsx("div",{className:"dash-menu-sep"}),e.jsx("button",{className:"dash-danger",onClick:()=>{tn(T.id),G(null)},children:n("dashgrid.deleteCard")})]})]}),x&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"dash-menu-scrim",onClick:()=>O(null)}),e.jsxs("div",{ref:M.ref,className:"dash-add-menu",style:{position:"fixed",left:x.x,top:x.y,...M.style},children:[e.jsx("button",{onClick:bn,children:n("dashgrid.switchToCanvas")}),e.jsx("button",{onClick:()=>{O(null),(async()=>{const d=(await rt(n("dashgrid.renameTitle"),ss(i)))?.trim().replace(/[\\/]/g,"");if(!d)return;const v=await s.getState().renamePage(`${d}.dashboard`),C=s.getState().activePage;v&&C&&C!==i&&t.setParams({...t.params,dashPath:C})})()},children:n("dashgrid.rename")}),e.jsx("button",{className:"dash-danger",onClick:()=>{O(null),window.confirm(n("dashgrid.confirmDelete",{name:ss(i)}))&&s.getState().deletePage(i).then(()=>{const d=s.getState().error;if(d){Ve.getState().toast(n("dashgrid.deleteFailed",{error:d}),!0);return}Ve.getState().toast(n("dashgrid.deleted")),$e.getState().closeLeaf(t.id)})},children:n("dashgrid.delete")})]})]})]})}function Fd({id:t,rowStart:n,rowSpan:s,colStart:i,colSpan:l,locked:o,chrome:r,kind:u,surface:f,size:h,dragging:j,sizing:m,interact:y,reduceMotion:p,title:x,Icon:O,children:T,onOpen:G,onInteract:S,onDelete:M,onMenu:R,onGripDown:z}){const{t:k}=he(),{attributes:$,listeners:D,setNodeRef:K,isDragging:Z}=wr({id:t,disabled:o,transition:null}),ce={gridRow:`${n} / span ${s}`,gridColumn:`${i} / span ${l}`};return e.jsx(gs.div,{ref:K,layout:!0,className:"dash3-card-slot",style:ce,initial:p?!1:{opacity:0,scale:.97,y:8},animate:{opacity:1,scale:1,y:0},exit:p?{opacity:0}:{opacity:0,scale:.96,y:-6},transition:{duration:p?0:m?.16:.28,ease:[.16,1,.3,1]},children:e.jsxs("div",{className:`dash3-card${r?" dash3-card--chrome":""}`,"data-key":t,"data-kind":u,"data-surface":f,"data-size":h,"data-dragging":Z||j||void 0,"data-sizing":m||void 0,"data-interact":y||void 0,children:[x&&!r&&e.jsxs("div",{className:"dash3-card-head",children:[O&&e.jsx(O,{size:13,className:"dash3-card-icon"}),e.jsx("span",{className:"dash3-card-title",children:x}),o&&G&&e.jsx("button",{type:"button",className:"dash3-card-open",title:k("dashgrid.openInTab"),"aria-label":k("dashgrid.openInTabAria",{title:x}),onClick:G,children:e.jsx(It,{size:12})})]}),e.jsx("div",{className:"dash3-card-body",children:T}),!o&&e.jsxs(e.Fragment,{children:[!y&&e.jsx("div",{className:"dash3-shield",...$,...D,onDoubleClick:r?void 0:S,title:k(r?"dashgrid.dragToReorder":"dashgrid.dragOrEnter")}),e.jsx("button",{type:"button",className:"dash3-card-btn dash3-card-more",title:k("dashgrid.sizeAndMore"),"aria-label":k("dashgrid.setCardSize"),onClick:U=>{U.stopPropagation();const re=U.currentTarget.getBoundingClientRect();R(Math.max(8,Math.min(re.left-60,window.innerWidth-196)),re.bottom+4)},children:e.jsx(Jt,{size:12})}),e.jsx("button",{type:"button",className:"dash3-card-btn dash3-card-del",title:k("dashgrid.deleteThisCard"),"aria-label":k("dashgrid.deleteThisCard"),onClick:U=>{U.stopPropagation(),M()},children:e.jsx(Ye,{size:12})}),!r&&e.jsx("div",{className:"dash3-grip",title:k("dashgrid.resize"),onPointerDown:z})]})]})})}export{sd as A,Ls as B,ws as C,hu as D,Pa as E,Pn as L,yi as N,kc as P,id as S,vd as V,Ca as W,ou as a,vl as b,bd as c,ed as d,ri as e,Ic as f,ru as g,cu as h,Bn as i,du as j,Yc as k,zi as l,ji as m,uu as n,lu as o,wd as p,Vl as r,iu as s,Oe as u};