@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
@@ -1,17 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./PageHistoryPanel-BMQC-V_l.js","./index-B5UW6SaE.js","./appStore-CidPWYa0.js","./nativeDownload-B3JGkABw.js","./ipc-CNlIRMtU.js","./client-CPUljePZ.js","./appStore-DeaC1U32.css","./create-C19zqt5N.js","./create-BgE3edmZ.css","./UnifiedPage-EJNWKzxN.js","./MarkdownBlock-wYEaBBOr.js","./index-BqGpbntz.js","./linkFollow-iP2zfbA3.js","./emoji-DczIG8SO.js","./listFold-Aea6I0Sa.js","./book-open-CBeNsIpo.js","./MarkdownBlock--__nPQGh.css","./pageChrome-DFi9zs6F.js","./upload-CrbEAW8C.js","./pageChrome-BDHHmRnt.css","./SketchCard-DAD0jR0i.js","./arrow-up-right-KPFbRA41.js","./Chrome-BvpbCvo1.js","./minus-BBdfT_sc.js","./canvasPrefs-CxfyDTMT.js","./hand-fuehbnkI.js","./type-C5J875vb.js","./foldActions-BGocXE-o.js","./lock-TSDKuCod.js","./undo-2-BOUt5qks.js","./code-xml-n9mgGgkv.js","./message-square-plus-3wFslIMY.js","./UnifiedPage-CWXc_mo1.css","./FloatingToc-ldOYWe2C.js","./pageTree-DZ7Eiro-.js","./pluginExt-Byb64tQO.js","./phoneList-DrxIwJxQ.js","./phoneList-DvpzD3zT.css","./list-tree-i07HsP3D.js","./pen-tool-ChGmX6g_.js","./pencil-CJsJD7M_.js","./star-C9KTji9N.js","./folder-plus-d5MwIMlf.js","./redo-2-CI57sDFr.js","./folder-CoOsfQ64.js","./layout-grid-DFmwM9NU.js","./PageHistoryPanel-DFjh0pWs.css"])))=>i.map(i=>d[i]);
2
- import{ch as Ea,ci as $n,r as Ne,j as e,u as he,d as c,cj as Da,bD as Ci,ck as Pi,m as Ti,bO as Fa,t as _,_ as Ei,P as Di,c2 as Fi,ar as Ri,J as Nt,n as As,ad as ln,cl as ds,c0 as Mi,c1 as $i,aT as Oi,aD as Ii,b4 as Li,aI as Bs,aL as Ai}from"./index-B5UW6SaE.js";import{G as ct,cs as Gt,_ as Yt,iG as fn,u as Ve,b as L,dm as te,T as js,fV as ot,fC as Pe,fi as Me,qn as Ra,fj as Bi,q as $e,m7 as Vi,qo as _i,gl as Wi,cq as qi,qp as Ui,qq as Hi,qr as Ki,qs as Gi,aK as vt,ow as Yi,fd as Ma,lA as Xi,kL as ks,kB as $a,qt as Ji,g3 as Oa,ga as Ss,oy as Wn,qu as Ia,fB as Ft,qv as La,fO as Aa,kx as us,kA as Zi,qw as Qi,fS as Ba,qx as Va,kD as _a,qi as eo,kK as Wa,qy as to,a5 as gt,aF as Ns,U as qa,e1 as zs,bV as Wt,bK as Ye,ai as Tt,dF as no,hx as so,qz as qt,j8 as Ua,gg as Bt,b2 as ao,bo as Cs,gu as Ha,fA as Ps,qA as io,hq as oo,m as ro,hF as lo,h as co,gk as uo,cW as hs,c6 as Ut,bt as Ka,ar as Et,qB as un,ct as xt,fh as Fn,aE as It,fm as Jn,gf as pt,fk as Vs,iA as _s,fl as Ws,K as jn,hP as Zn,oe as qs,ah as ho,as as Xt,of as mo,Z as po,fc as kn,o7 as fo,o6 as xo,ay as go,g7 as vo,fF as Ht,qC as wo,g8 as Ga,cr as Qn,qD as Us,qE as Hs,cL as Ks,qF as bo,qG as yo,fo as zt,qH as Sn,hH as jo,gp as Gs,mU as ko,hR as es,iy as So,iB as No,nM as zo,cO as Co,f8 as Po,iz as To,qI as Eo,qJ as Do,j as Ya,lB as Xa,qK as Fo,qL as Ro,qM as Mo,qN as $o,qO as Oo,b6 as Io,oq as Lo,or as Ao,p as ms,qP as Bo,qQ as Vo,fx as Kt,qR as _o,qS as Wo,qT as qo,qU as Uo,qV as Ho,qW as Ys,kd as Ja,qX as Xs,f_ as Za,iN as Ko,iO as Go,az as Yo,fZ as ze,aC as hn,fD as Rn,qY as ts,R as Xo,qZ as Js,q_ as Zs,fE as ns,f$ as ss,q$ as Jo,r0 as Qs,r1 as Zo,r2 as ea,r3 as Qo,g0 as as,r4 as is,r5 as er,r6 as tr,bg as nr,ap as ta,r7 as sr,g2 as Ct,r8 as ps,r9 as sn,ra as an,rb as st,gr as ar,fQ as ir,rc as or,rd as rr,re as lr,rf as cr,fN as na,rg as dr,rh as ur,ri as hr,rj as mr,rk as pr,rl as fr,rm as xr,kM as gr,fU as vr,rn as Nn,ro as wr,rp as br,rq as yr}from"./appStore-CidPWYa0.js";import"./client-CPUljePZ.js";import{e as Qa,g as Ts,h as jr,M as ei,C as kr,S as Sr,U as Nr,A as zr,d as Cr,i as Pr}from"./UnifiedPage-EJNWKzxN.js";import{F as Tr}from"./FloatingToc-ldOYWe2C.js";import{ab as Er,ac as Dr,a8 as ti,ad as Fr,h as Rr}from"./MarkdownBlock-wYEaBBOr.js";import{u as Mr,S as $r,r as Or,a as Ir,C as Lr,N as Ar,U as Br}from"./pageChrome-DFi9zs6F.js";import{m as Vr,b as _r,r as sa}from"./pageTree-DZ7Eiro-.js";import{normalizePluginRename as Wr}from"./pluginExt-Byb64tQO.js";import{h as qn,i as qr,l as Ur,a as Hr,b as Kr,p as Gr,q as Yr,c as Xr,w as Jr,v as Zr,S as Lt,L as Qr,d as el,P as fs,t as aa,f as tl,g as nl,x as sl,e as ia,j as al,s as il,u as ol,A as oa,m as xs,C as ni}from"./phoneList-DrxIwJxQ.js";import{c as Zt}from"./nativeDownload-B3JGkABw.js";import{L as rl}from"./list-tree-i07HsP3D.js";import{P as on}from"./pen-tool-ChGmX6g_.js";import{P as cn}from"./pencil-CJsJD7M_.js";import{S as On}from"./star-C9KTji9N.js";import{B as si}from"./book-open-CBeNsIpo.js";import{F as ra}from"./folder-plus-d5MwIMlf.js";import{U as gs}from"./upload-CrbEAW8C.js";import{F as ll,T as ai}from"./type-C5J875vb.js";import{U as cl}from"./undo-2-BOUt5qks.js";import{R as dl,F as zn}from"./redo-2-CI57sDFr.js";import{C as os}from"./code-xml-n9mgGgkv.js";import{L as la}from"./lock-TSDKuCod.js";import{F as Es}from"./folder-CoOsfQ64.js";import{L as At}from"./layout-grid-DFmwM9NU.js";const ul=[["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"}]],ii=ct("a-large-small",ul);const hl=[["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"}]],ml=ct("book-marked",hl);const pl=[["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"}]],vs=ct("cloud-off",pl);const fl=[["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"}]],xl=ct("cloud-sun",fl);const gl=[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]],vl=ct("heading",gl);const wl=[["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"}]],Cn=ct("layout-dashboard",wl);const bl=[["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"}]],yl=ct("list-indent-decrease",bl);const jl=[["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"}]],kl=ct("list-indent-increase",jl);const Sl=[["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=ct("share-2",Sl);const Nl=[["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"}]],zl=ct("star-off",Nl);let ca=0;const Oe=Zt(t=>({vaults:[],activeRoot:null,mirrorVaults:[],status:{},async refresh(){const n=++ca,s=window.amadeusSync;if(s?.entrySyncGet)try{const i=await s.entrySyncGet();if(n!==ca)return;t({vaults:i.vaults,activeRoot:i.activeRoot,mirrorVaults:i.mirrorVaults??[]})}catch{}}}));let da=!1;function oi(){if(da)return;da=!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&&Ea(s.entries,s.exclude,n)}function Ds(t,n,s,i){if(!window.amadeusSync||s==="cloud")return $n(i);if(!n)return null;const l=t.find(o=>o.vaultRoot===n);return!l||!Ea(l.entries,l.exclude,i)?null:`${l.cloudName}/${$n(i)}`}function Cl(t,n){const s=t?Oe.getState().vaults.find(l=>l.vaultRoot===t):null;if(!s?.exclude?.length)return!1;const i=$n(n);return s.exclude.some(l=>{const o=$n(l);return!!o&&(i===o||i.startsWith(`${o}/`)||i.startsWith(`${o.replace(/\.md$/i,"")}.fd/`))})}let dn=null;function ws(){return dn===null&&(dn=!0,window.tangu?.getConfig?.().then(t=>{dn=t?.notesUpgradeV4!==!1}).catch(()=>{})),dn}function nu(t){dn=t}ws();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 bs=Zt(t=>({req:null,open:n=>t({req:n}),close:()=>t({req:null})}));function Dt(t,n){bs.getState().open({path:t,kind:n})}const ua=t=>(t.split(/[\\/]/).pop()??t).replace(/\.md$/i,"");function su(){const t=bs(n=>n.req);return t?e.jsx("div",{className:"am-app tangu-lovable",style:{display:"contents"},children:e.jsx(Pl,{req:t,onClose:()=>bs.getState().close()},`${t.kind}:${t.path}`)}):null}function Pl({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,b]=c.useState(null),[O,E]=c.useState("");c.useEffect(()=>{let z=!0;if(t.kind==="asset"){l({pages:[],files:[],subPages:[]});return}return window.amadeusSync?.entrySyncClosure?.(t.path,t.kind).then(M=>{if(!z)return;l({...M,subPages:M.subPages??[]}),r(new Set(M.pages)),f(new Set(M.files));const D=Oe.getState().activeRoot;j(new Set((M.subPages??[]).filter(H=>!Cl(D,H))))}).catch(()=>z&&l({pages:[],files:[],subPages:[]})),()=>{z=!1}},[t.path,t.kind]);const G=async z=>{const M=window.amadeusSync;if(!M?.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"}))],H=i?.subPages??[],Z=H.filter(re=>!h.has(re)),ce=H.filter(re=>h.has(re)),q=await M.entrySyncEnable({entries:D,exclude:Z,include:ce,...z}).catch(re=>({error:String(re)}));if(y(!1),q?.conflict){b(q.conflict),E(`${q.conflict} 2`);return}if(q?.error||!q?.ok){Ve.getState().toast(q?.error||s("csd.failed"),!0);return}Ve.getState().toast(s("csd.enabled",{name:q.cloudName??""})),Oe.getState().refresh(),n()},k=z=>{const M=[];for(let D=z;;){const H=D.lastIndexOf(".fd/");if(H<0)return M;D=`${D.slice(0,H)}.md`,M.push(D)}},$=z=>j(M=>{const D=!M.has(z),H=i?.subPages??[],Z=`${z.replace(/\.md$/i,"")}.fd/`,ce=new Set(M);for(const q of H)q!==z&&!q.startsWith(Z)||(D?ce.add(q):ce.delete(q));if(D)for(const q of k(z))H.includes(q)&&ce.add(q);return ce}),F=(z,M)=>{const D=new Set(z);return D.has(M)?D.delete(M):D.add(M),D},N=(z,M,D,H,Z,ce)=>D.length>0&&e.jsxs("div",{className:"amx-csd-group",children:[e.jsxs("div",{className:"amx-csd-head",children:[z,e.jsxs("span",{children:[M,"(",H.size,"/",D.length,")"]}),e.jsx("button",{className:"amx-csd-all",onClick:()=>ce(H.size<D.length),children:H.size<D.length?s("csd.selectAll"):s("csd.selectNone")})]}),e.jsx("div",{className:"amx-csd-list",children:D.map(q=>e.jsxs("label",{className:"amx-csd-item",title:q,children:[e.jsx("input",{type:"checkbox",checked:H.has(q),onChange:()=>Z(q)}),e.jsx("span",{children:ua(q)}),e.jsx("span",{className:"amx-csd-path",children:q})]},q))})]});return e.jsx("div",{className:"dialog-overlay",onMouseDown:n,children:e.jsxs("div",{className:"dialog amx-csd",onMouseDown:z=>z.stopPropagation(),children:[e.jsxs("div",{className:"dialog-title",children:[e.jsx(Gt,{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:z=>E(z.target.value),placeholder:s("csd.newNamePlaceholder"),onKeyDown:z=>{z.key==="Enter"&&O.trim()&&G({cloudName:O.trim()}),z.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:ua(t.path)})}),i===null?e.jsx("div",{className:"dialog-msg",children:s("csd.analyzing")}):e.jsxs(e.Fragment,{children:[N(e.jsx(rl,{size:12}),s("csd.groupSubPages"),i.subPages,h,$,z=>j(z?new Set(i.subPages):new Set)),N(e.jsx(Yt,{size:12}),s("csd.groupLinkedPages"),i.pages,o,z=>r(M=>F(M,z)),z=>r(z?new Set(i.pages):new Set)),N(e.jsx(fn,{size:12}),s("csd.groupAssets"),i.files,u,z=>f(M=>F(M,z)),z=>f(z?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")})]})]})]})})}function ha(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 Ln=()=>L.getState(),ys=t=>(t.split(/[\\/]/).pop()??t).replace(/\.md$/i,""),ri=Zt(t=>({seed:null,request:n=>t(s=>({seed:{q:n,n:(s.seed?.n??0)+1}}))}));function au(){const{t}=he(),n=L(h=>h.vaultRoot),[s,i]=c.useState(""),l=ri(h=>h.seed);c.useEffect(()=>{l&&i(l.q)},[l]);const[o,r]=c.useState([]),u=c.useRef(0);c.useEffect(()=>{Ln().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=>{const j=s.trim().toLowerCase();Me(h.path).then(()=>{if(!j)return;const m=Object.values(Ln().blocks).find(y=>Da(y.content).toLowerCase().includes(j));requestAnimationFrame(()=>{const y=m?document.querySelector(`[data-block-id="${m.id}"]`):null;if(y){y.scrollIntoView({behavior:"smooth",block:"center"}),y.classList.add("amx-block-flash"),setTimeout(()=>y.classList.remove("amx-block-flash"),1300);return}const p=j.split(/[\s\-_/.]+/).filter(Boolean);Ra(h.path,p.length>1?[j,...p]:[j])})})};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(js,{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:()=>{ot(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:()=>f(h),title:h.path,children:[h.title,h.snippet&&e.jsx("span",{className:"amx-backlink-snippet amx-search-snippet",children:Tl(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 Tl(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 li=Zt(t=>({seed:null,request:n=>t(s=>({seed:{tag:n,n:(s.seed?.n??0)+1}}))}));function iu(t){li.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 ou(){const{t}=he(),n=L(m=>m.vaultRoot),s=L(m=>m.linkGraphVersion),[i,l]=c.useState([]),[o,r]=c.useState(null),[u,f]=c.useState([]),h=li(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:()=>{Me(y).then(()=>Ra(y,[`#${m.tag}`],{tag:!0}))},title:y,children:ys(y)},y))]},m.tag))}):e.jsx("div",{className:"amx-panel-empty",children:t("amxpanel.noVault")})]})}const Vt=320,_t=280,mn=(t,n,s)=>Math.min(s,Math.max(n,t));function El(t,n,s){const i=Vt/2,l=_t/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),b=1400/p;u+=m/Math.sqrt(p)*b,f+=y/Math.sqrt(p)*b}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)),b=(p-86)*.02;u+=m/p*b,f+=y/p*b}r.vx=(r.vx+u*s*2)*.82,r.vy=(r.vy+f*s*2)*.82,r.x=mn(r.x+r.vx,16,Vt-16),r.y=mn(r.y+r.vy,16,_t-16)}}function ru(){const{t}=he(),n=L(N=>N.activePage??N.activeNotePath),s=L(N=>N.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}),b=c.useRef(!1),O=()=>{if(p.current.raf)return;const N=()=>{const z=m.current,M=p.current;if(!z){M.raf=0;return}El(z.nodes,z.edges,M.alpha),M.dragging||(M.alpha-=.006),o(D=>D+1),M.alpha>.02||M.dragging?M.raf=requestAnimationFrame(N):M.raf=0};p.current.raf=requestAnimationFrame(N)};c.useEffect(()=>()=>{p.current.raf&&cancelAnimationFrame(p.current.raf)},[]);const E=(N,z)=>{const M=j.current?.getScreenCTM();if(!M)return null;const D=new DOMPoint(N,z).matrixTransform(M.inverse());return{x:D.x,y:D.y}},G=(N,z)=>{const M=E(N,z);if(!M)return null;const D=y.current;return{x:(M.x-D.x)/D.k,y:(M.y-D.y)/D.k}};c.useEffect(()=>{let N=!0;if(!n){l(null),m.current=null;return}return m.current?.nodes[0]?.path!==n&&(m.current=null,l(null)),(async()=>{const z=await te.backlinks(n).catch(()=>[]);if(!N)return;const M=Ln(),D=await te.readTextFile(n).catch(()=>null);if(!N)return;const H=Da(Ci(D??"")),Z=[],ce=[],q=new Set;for(const ie of Pi(H)){const ne=Ti(ie,M.pages,n);ne?ne!==n&&!Z.includes(ne)&&Z.push(ne):q.has(ie.toLowerCase())||(q.add(ie.toLowerCase()),Bi(ie,M.files,n)||ce.push(ie))}const re=[...new Set([...Z,...z.map(ie=>ie.path).filter(ie=>ie!==n)])],we=[...re,...ce],Re=[{path:n,label:ys(n),center:!0,x:Vt/2,y:_t/2,vx:0,vy:0,pinned:!0},...we.map((ie,ne)=>{const ge=ne/Math.max(1,we.length)*Math.PI*2,ke=ne>=re.length;return{path:ie,label:ke?ie:ys(ie),center:!1,ghost:ke,x:Vt/2+Math.cos(ge)*90,y:_t/2+Math.sin(ge)*90,vx:0,vy:0,pinned:!1}})],xe=new Map(Re.slice(0,1+re.length).map((ie,ne)=>[ie.path,ne])),X=[],pe=new Set;for(const ie of[...Z,...z.map(ne=>ne.path)]){const ne=xe.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(!N)return;const ue={nodes:Re,edges:X},S=m.current;if(!(S&&ha(S.nodes,S.edges)===ha(ue.nodes,ue.edges))){if(S?.nodes[0]?.path===n){const ie=new Map(S.nodes.map(ne=>[`${ne.ghost?"g:":""}${ne.path}`,ne]));for(const ne of ue.nodes){const ge=ie.get(`${ne.ghost?"g:":""}${ne.path}`);ge&&(ne.x=ge.x,ne.y=ge.y,ne.vx=ge.vx,ne.vy=ge.vy)}}m.current=ue,l(ue),u(null),p.current.alpha=S?.38:1,O()}})(),()=>{N=!1}},[n,s]);const k=N=>z=>{if(z.button!==0)return;z.stopPropagation();const M=m.current;if(!M)return;const D=M.nodes[N],H=D.pinned;D.pinned=!0,b.current=!1,p.current.dragging=!0,p.current.alpha=Math.max(p.current.alpha,.6),O();const Z=q=>{const re=G(q.clientX,q.clientY);re&&(b.current=!0,D.x=mn(re.x,16,Vt-16),D.y=mn(re.y,16,_t-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=H,p.current.dragging=!1,p.current.alpha=Math.max(p.current.alpha,.5),O()};window.addEventListener("pointermove",Z),window.addEventListener("pointerup",ce)},$=N=>{if(N.button!==0||N.target!==N.currentTarget)return;const z=E(N.clientX,N.clientY);if(!z)return;const M=y.current,D=Z=>{const ce=E(Z.clientX,Z.clientY);ce&&h({k:M.k,x:M.x+(ce.x-z.x),y:M.y+(ce.y-z.y)})},H=()=>{window.removeEventListener("pointermove",D),window.removeEventListener("pointerup",H)};window.addEventListener("pointermove",D),window.addEventListener("pointerup",H)},F=!!i&&i.nodes.length>1;return c.useEffect(()=>{const N=j.current;if(!N||!F)return;const z=M=>{M.preventDefault();const D=E(M.clientX,M.clientY);if(!D)return;const H=y.current,Z=mn(H.k*Math.exp(-M.deltaY*.0022),.4,3),ce=(D.x-H.x)/H.k,q=(D.y-H.y)/H.k;h({k:Z,x:D.x-ce*Z,y:D.y-q*Z})};return N.addEventListener("wheel",z,{passive:!1}),()=>N.removeEventListener("wheel",z)},[F]),e.jsxs("div",{className:"amx-panel",children:[e.jsx("div",{className:"amx-panel-head",children:t("amxpanel.graphHead")}),n?!i||!F?e.jsx("div",{className:"amx-panel-empty",children:t("amxpanel.graphEmpty")}):e.jsx("svg",{ref:j,className:"amx-graph",viewBox:`0 0 ${Vt} ${_t}`,onPointerDown:$,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((N,z)=>e.jsx("line",{x1:i.nodes[N.a].x,y1:i.nodes[N.a].y,x2:i.nodes[N.b].x,y2:i.nodes[N.b].y,className:`amx-graph-edge${r!==null?N.a===r||N.b===r?" hl":" dim":""}`},z)),i.nodes.map((N,z)=>{const M=r===null||z===r||i.edges.some(D=>D.a===r&&D.b===z||D.b===r&&D.a===z);return e.jsxs("g",{className:`amx-graph-node${N.center?" center":""}${N.ghost?" ghost":""}${r!==null?M?" hl":" dim":""}`,onPointerDown:k(z),onPointerEnter:()=>u(z),onPointerLeave:()=>u(null),onClick:()=>{b.current||N.center||(N.ghost?Ln().openWikiLink(N.path):Me(N.path))},children:[e.jsx("circle",{cx:N.x,cy:N.y,r:N.center?8:5.5}),e.jsx("text",{x:N.x,y:N.y+(N.center?20:16),textAnchor:"middle",children:N.label.length>12?`${N.label.slice(0,12)}…`:N.label})]},N.ghost?`g:${N.path}`:N.path)})]})}):e.jsx("div",{className:"amx-panel-empty",children:t("amxpanel.graphNoNote")})]})}const Dl=t=>/\.md$/i.test(t);function Fl(t){const n=t.replace(/\.md$/i,""),s=n.split(/[\\/]/).pop()||n;return n===s?n:`${n}|${s}`}function Rl(t){return Vi(t).filter(n=>n.kind==="note").map(n=>Dl(n.path)?`[[${Fl(n.path)}]]`:`![[${n.path}]]`)}const Ml=/[^./\\]\.[^./\\]+\.md$/;function $l(t,n){if(!t||!Ml.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:Qa(s)})}}const n=await te.readTextFile(t).catch(()=>null);return n==null?{ok:!1,reason:_("unilock.failed.read")}:{ok:!0,raw:n}}const Ol=t=>(t.split("/").pop()??t).replace(/\.md$/i,"");function ci(t,n,s,i){Ts({level:"error",dedupeKey:`amx-lock:${t}`,text:_(n?"unilock.failed.lock":"unilock.failed.unlock",{name:Ol(t),reason:s}),action:{label:_("unilock.retry"),run:i}})}async function di(t,n,s){const i=await Fs(n);return i.ok?(_i(t,n,s),!0):(ci(n,s,i.reason,()=>{di(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 Il=t=>(t.split("/").pop()??t).replace(/\.md$/i,"");function Pn(t,n,s){Ts({level:"error",dedupeKey:`amx-hist-restore:${t}`,text:_("pghist.failed",{name:Il(t),reason:n}),...s?{action:{label:_("pghist.retry"),run:s}}:{}})}async function Ll(t,n){const s=te.restorePageHistory;if(!s)return!1;const i=()=>{Ll(t,n)},l=await Fs(t);if(!l.ok)return Pn(t,l.reason,i),!1;let o;try{o=await s(t,n.id,Di(l.raw))}catch(r){return Pn(t,Qa(r),i),!1}return o.ok?(Fi(t,{}),Ts({level:"success",text:_("pghist.done",{time:qi(n.at)})}),!0):(o.current==null?Pn(t,_("pghist.failed.gone")):Pn(t,_("pghist.failed.conflict"),i),!1)}const Al=Wi(()=>Ei(()=>import("./PageHistoryPanel-BMQC-V_l.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]),import.meta.url));function Bl({path:t,locked:n,onClose:s}){return e.jsx(c.Suspense,{fallback:null,children:e.jsx(Al,{path:t,locked:n,onClose:s})})}async function Vl(t){await Fa(t);const n=Ri(t);if(n!=null)return n;const s=await te.readTextFile(t).catch(()=>null);return s==null?null:jr(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 _l=["default","serif","mono"];function Wl(t,n,s=_){return[{kind:"choice",id:"font",label:s("amxpage.font"),options:_l.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 ql(t,n){const[,s]=c.useState(0);return c.useEffect(()=>Ui(()=>s(i=>i+1)),[]),n?Ki(t,n):Hi}function Ul(t,n,s){Gi(t,n,s)}function Hl(t){return{...t.wide?{"data-page-wide":""}:{},...t.small?{"data-page-small":""}:{},...t.font!=="default"?{"data-page-font":t.font}:{}}}const Kl={wide:ei,small:ii};function Gl({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(Yl,{entry:n},n.id))})}function Yl({entry:t}){const n=Kl[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(vt,{size:13,className:"amx-pagestyle-check"})]})}function Xl({host:t,label:n,scanTrigger:s}){return e.jsx(Tr,{scrollContainer:t,contentRoot:t,selector:".page-view h1, .page-view h2, .page-view h3",label:n,scanTrigger:s,placement:"sticky",topOffset:Dr,topInset:Er})}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 Jt=(t,n)=>_("fileimport.withReason",{name:t,reason:n}),rt=()=>L.getState(),lt=t=>Ma.getState().notify(t);function Jl(){return window.amadeusSync?rt().vaultSide==="cloud":!!window.amadeusCloudVaults}function Zl(t,n){const s=/[ ()<>]/.test(n)?`<${n}>`:n;return`[${t.replace(/[[\]]/g,"")}](${s})`}function Ql(t,n,s,i){return i&&!/[[\]|#]/.test(t)?`![[${t}]]`:Zl(n,s)}function Un(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 ec(){const t=window.amadeusSync?(await window.amadeusSync.get().catch(()=>null))?.maxFileBytes:window.amadeusCloudMaxFileBytes;return typeof t=="number"&&t>0?t:null}const tc=t=>`${+(t/1048576).toFixed(1)} MB`;async function Rs(t){if(!Jl())return null;const n=await ec();return n!==null&&t.size>n?tc(n):null}async function Ms(){try{await rt().refreshStructure?.()}catch{}}function $s(t){let n=-1;return(s,i)=>{const l=i>0?Math.min(100,Math.floor(s/i*100)):0;l!==n&&(n=l,lt(_("fileimport.uploading",{name:t,pct:l})))}}function ui(t,n){const s=_("fileimport.placeholder",{name:n}),i=rt().activePage===t?rt().insertBlockAfter(null,void 0,s):null,l=()=>!!i&&rt().activePage===t&&rt().blocks[i]?.content===s;return{done:o=>l()?(rt().setBlockContent(i,o),!0):!1,fail:()=>{l()&&rt().setBlockContent(i,_("fileimport.placeholderFailed",{name:n}))}}}async function An(t,n){if(!t.length||!n)return;const{opts:s,preview:i}=await Yi();let l=0,o=0;const r=[];for(const u of t){const f=await Rs(u);if(f){r.push(Jt(u.name,_("fileimport.overCloudLimit",{limit:f})));continue}const h=ui(n,u.name);try{const j=new Uint8Array(await u.arrayBuffer()),{pageRel:m,base:y}=await te.saveAttachment(n,u.name,j,s,$s(u.name));h.done(Ql(y,u.name,m,i))||rt().activePage===n?l++:o++}catch(j){h.fail(),r.push(Jt(u.name,Un(j)))}}await Ms(),r.length?lt(_(r.length===1?"fileimport.notImportedOne":"fileimport.notImportedMany",{n:r.length,first:r[0]})):o?lt(_("fileimport.movedAway")):t.length>1?lt(_(l===1?"fileimport.importedOne":"fileimport.importedMany",{n:l})):lt(_("fileimport.uploadedOne",{name:t[0].name}))}async function ma(t,n){if(!t.length)return;let s=0;const i=[];for(const o of t){const r=await Rs(o);if(r){i.push(Jt(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},$s(o.name)),s++}catch(u){i.push(Jt(o.name,Un(u)))}}await Ms();const l=n?n.split("/").pop()||n:_("fileimport.vaultRoot");i.length?lt(_(i.length===1?"fileimport.notImportedOne":"fileimport.notImportedMany",{n:i.length,first:i[0]})):lt(_(s===1?"fileimport.importedToOne":"fileimport.importedToMany",{n:s,where:l}))}async function nc(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(Jt(o,_(r?.tooLarge?"fileimport.over50mb":"fileimport.unreadable")));continue}s.push(new File([Xi(r.content)],o,{type:r.mimeType}))}catch(r){i.push(Jt(o,Un(r)))}}return i.length&&lt(_(i.length===1?"fileimport.unreadableOne":"fileimport.unreadableMany",{n:i.length,first:i[0]})),s}async function sc(t,n){if(!t.length||!n)return;let s=0;const i=[];for(const l of t){const o=await Rs(l);if(o){i.push(_("fileimport.imageOverCloudLimit",{limit:o}));continue}const r=(l.name||"pasted.png").replace(/\s+/g,"_"),u=ui(n,r);try{const f=new Uint8Array(await l.arrayBuffer()),h=await te.saveAsset(n,r,f,$s(r));!u.done(`![](${h})`)&&rt().activePage!==n&&s++}catch(f){u.fail(),i.push(Un(f))}}await Ms(),i.length?lt(_("fileimport.pasteFailed",{first:i[0]})):s&&lt(_("fileimport.imageMovedAway"))}function pa(t,n,s=!1){return!!t&&!n&&!s}function ac(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 fa="amx.sec.";function ic(t,n){return t==="1"?!0:t==="0"?!1:n}function Bn(t,n=!1){const[s,i]=c.useState(()=>{try{return ic(localStorage.getItem(fa+t),n)}catch{return n}});return[s,()=>i(o=>{const r=!o;try{localStorage.setItem(fa+t,r?"1":"0")}catch{}return r})]}function hi(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 mi="amadeus.heading.fold";function oc(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 rc=()=>{try{const t=JSON.parse(localStorage.getItem(mi)||"{}");return t&&typeof t=="object"?t:{}}catch{return{}}},ga=Zt(t=>({byPage:rc(),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(mi,JSON.stringify(r))}catch{}return{byPage:r}})}));function lc(t,n){return new Set(t[n]??[])}function cc({col:t,gutterLead:n}){const s=L(r=>r.insertBlockAfter),{setNodeRef:i,isOver:l}=ks({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($a,{items:o,strategy:Ji,children:o.map((r,u)=>e.jsx(Oa,{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 dc({rowId:t,leftColId:n,rightColId:s}){const i=L(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 b=y.getBoundingClientRect().left,O=p.getBoundingClientRect().right;O<=b||i(t,n,s,(m.clientX-b)/(O-b))},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 uc({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(va,{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(dc,{rowId:t.id,leftColId:t.columns[l-1].id,rightColId:i.id}),e.jsx(cc,{col:i,gutterLead:l===0?n:void 0})]},i.id))}),!s&&e.jsx(va,{rowId:t.id,side:"right"})]})}function va({rowId:t,side:n}){const{setNodeRef:s,isOver:i}=ks({id:`edge:${t}:${n}`});return e.jsx("div",{ref:s,className:"edge-zone","data-side":n,"data-over":i||void 0})}function hc(){const t=L(u=>u.activePage),n=L(u=>u.linkGraphVersion),s=L(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 mc(t,n){return t==="saving"?n("amxpv.statusSaving"):t==="loading"?n("amxpv.statusLoading"):t==="ready"?n("amxpv.statusReady"):""}function pc(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 wa({index:t}){const{setNodeRef:n,isOver:s}=ks({id:`gap:${t}`});return e.jsx("div",{ref:n,className:"row-gap","data-over":s||void 0})}function Vn(t){const n=(t??Ss(Wn())).getState(),s=n.manifest?hi(n.manifest.root,"first"):null;s?n.requestFocus(s,"start"):n.insertBlockAfter(null)}const fc=t=>{const n=Wa(t);return n.length?n:to(t)};function xc(t){const n=t.getState(),s=n.manifest?hi(n.manifest.root,"last"):null;s&&!n.blocks[s]?.content?n.requestFocus(s,"end"):n.insertBlockAfter(null)}const rs=24,gc=16,vc=typeof requestIdleCallback=="function"?t=>requestIdleCallback(t,{timeout:200}):t=>window.setTimeout(t,16),wc=typeof cancelIdleCallback=="function"?cancelIdleCallback:clearTimeout;function bc({bare:t=!1}={}){const{t:n}=he(),s=L(P=>P.manifest),i=L(P=>P.blocks),l=L(P=>P.status),o=L(P=>P.activePage),r=L(P=>P.moveBlock),u=L(P=>P.addColumnWithBlock),f=L(P=>P.addRowWithBlock),h=L(P=>P.insertBlockAfter),j=L(P=>P.renamePage),m=L(P=>P.setDnd),y=Ia(),p=Ft();c.useEffect(()=>{const P=La(y);P&&p.getState().requestFocusAt(P.blockId,P.anchor)},[]);const[b,O]=c.useState([]),E=c.useRef([]),G=b[0]??null,[k,$]=c.useState(!1),[F,N]=c.useState(""),z=Aa(us(Zi,{activationConstraint:{distance:5}})),M=ga(P=>P.byPage);c.useEffect(()=>{const P=A=>{if(!(A.metaKey||A.ctrlKey))return;const U=A.key.toLowerCase();if(U!=="z"&&U!=="y")return;const Y=A.target;if(Y&&(Y.tagName==="INPUT"||Y.tagName==="TEXTAREA"||Y.isContentEditable)||A.defaultPrevented||Wn()!==y)return;A.preventDefault();const fe=p.getState();U==="y"||A.shiftKey?fe.redo():fe.undo()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[]);const D=s?.root.children.length??0,[H,Z]=c.useState({page:o,n:rs});H.page!==o&&Z({page:o,n:rs});const ce=H.page===o?H.n:rs;if(c.useEffect(()=>{if(ce>=D)return;const P=vc(()=>Z(A=>({...A,n:A.n+gc})));return()=>wc(P)},[ce,D]),!s)return e.jsx("div",{className:"empty-state",children:n("amxpv.openVault")});const q=s.root,re=P=>{const A=(P??"").indexOf(`
6
- `);return A<0?"":(P??"").slice(A+1)},we=q.children.map(P=>{const A=P.columns[0]?.children[0]?.ref;let U=0,Y=0;for(const fe of P.columns)for(const se of fe.children){const R=i[se.ref]?.content,W=xa(R);W&&(!U||W<U)&&(U=W);const Xe=se.ref===A?xa(re(R)):W;Xe&&(!Y||Xe<Y)&&(Y=Xe)}return{firstId:A,level:oc(A?i[A]?.content:void 0),bound:U,self:Y}}),Re=P=>{const A=we[P];if(!A.level||A.self&&A.self<=A.level)return 0;let U=0;for(let Y=P+1;Y<we.length&&!(we[Y].bound&&we[Y].bound<=A.level);Y++)U++;return U},xe=lc(M,o??""),X=new Set;if(!G)for(let P=0;P<we.length;P++){const A=we[P];if(!(!A.level||!A.firstId||!xe.has(A.firstId)))for(let U=P+1;U<=P+Re(P);U++)X.add(U)}const pe=s.title||o?.split("/").pop()||"",ue=()=>{N(pe),$(!0)},S=async()=>{$(!1);const P=F.trim();P&&P!==pe&&await j(P)},ie=P=>{for(const A of q.children)for(const U of A.columns)if(U.children.some(Y=>Y.ref===P))return U.id;return null},ne=P=>{const A=String(P.active.id),U=eo.getState(),Y=U.ids.has(A)?p.getState().flatOrder().filter(se=>U.ids.has(se)):[A];U.ids.has(A)||U.select(A);const fe=Y.length?Y:[A];E.current=fe,O(fe),m(A,null)},ge=P=>{const A=String(P.active.id),U=P.over?String(P.over.id):"",Y=U&&!U.includes(":")&&U!==A?U:null;m(A,Y)},ke=()=>{E.current=[],O([]),m(null,null)},qe=P=>{const A=String(P.active.id),U=E.current.includes(A)?E.current:[A];if(E.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(U,fe,se==="left"?"left":"right")}else if(Y.startsWith("edge:")){const[,fe,se]=Y.split(":");u(fe,U,se==="left"?"left":"right")}else if(Y.startsWith("gap:"))f(Number(Y.slice(4)),U);else if(Y.startsWith("col:"))r(U,Y.slice(4),null);else if(Y!==A){const fe=ie(Y);fe&&r(U,fe,Y)}};return e.jsxs("div",{className:"page-view","data-bare":t||void 0,children:[e.jsx(Qi,{}),!t&&e.jsxs("header",{className:"page-header",children:[k?e.jsx("input",{className:"page-title-edit",autoFocus:!0,value:F,onChange:P=>N(P.target.value),onBlur:()=>{S()},onKeyDown:P=>{if(P.key==="Enter")P.preventDefault(),Vn(p),S();else if(P.key==="ArrowRight"||P.key==="ArrowDown"){const A=P.currentTarget;A.selectionStart===A.value.length&&A.selectionEnd===A.value.length&&(P.preventDefault(),Vn(p),S())}else P.key==="Escape"&&$(!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:mc(l,n)})]}),e.jsxs(Ba,{sensors:z,collisionDetection:fc,measuring:{droppable:{strategy:Va.Always}},onDragStart:ne,onDragOver:ge,onDragEnd:qe,onDragCancel:ke,children:[e.jsxs("div",{className:"stack","data-dnd":G?"":void 0,children:[e.jsx(wa,{index:-1}),q.children.map((P,A)=>{if(A>=ce||X.has(A))return null;const U=we[A],Y=Re(A),fe=!!(U.firstId&&xe.has(U.firstId));return e.jsxs(c.Fragment,{children:[e.jsxs("div",{className:`amx-hfold-wrap${Y>0&&U.firstId?" has-fold":""}`,children:[fe&&Y>0&&e.jsx("span",{className:"amx-hfold-count",children:Y}),e.jsx(uc,{row:P,gutterLead:Y>0&&U.firstId?e.jsx("button",{className:`amx-hfold${fe?" folded":""}`,title:fe?n("amxpv.expandSection",{n:Y}):n("amxpv.foldSection"),onClick:se=>{se.stopPropagation(),ga.getState().toggle(o??"",U.firstId)},children:"›"}):void 0})]}),e.jsx(wa,{index:A})]},P.id)})]}),e.jsx(_a,{dropAnimation:null,children:G?e.jsxs("div",{className:"drag-overlay",children:[b.length>1?`${n("amxpv.dragBlocks",{n:b.length})} · `:"",pc(i[G]?.content,n)]}):null})]}),t&&e.jsx("div",{className:"page-tail",onClick:()=>xc(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(hc,{})]})}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 yc({onClose:t}){const{t:n}=he(),s=window.amadeusCollab,i=(k,$=!1)=>Ve.getState().toast(k,$),[l,o]=c.useState([]),[r,u]=c.useState(""),[f,h]=c.useState([]),[j,m]=c.useState([]),[y,p]=c.useState(null),[b,O]=c.useState(null),E=()=>{s&&(s.listVaults().then(k=>o(k.map($=>({id:$.id,name:$.name})))).catch(()=>{}),s.activeVaultId().then(u).catch(()=>{}),s.sharedWithMe().then(h).catch(()=>h([])),s.publishes().then(k=>{m(k.shares),p(k.quota)}).catch(()=>m([])))};if(c.useEffect(E,[]),!s)return null;const G=(k,$)=>{navigator.clipboard.writeText(k).then(()=>{O($),setTimeout(()=>O(null),1200)})};return e.jsx("div",{className:"amxc-overlay",onClick:t,children:e.jsxs("div",{className:"amxc-panel",onClick:k=>k.stopPropagation(),children:[e.jsxs("div",{className:"amxc-head",children:[e.jsxs("span",{children:[e.jsx(gt,{size:14})," ",n("cloudvault.title")]}),e.jsx("button",{className:"amxc-x",onClick:t,children:e.jsx(Ns,{size:14})})]}),e.jsx("div",{className:"amxc-sec",children:n("cloudvault.myVaults")}),l.map(k=>e.jsxs("button",{className:`amxc-row${k.id===r?" on":""}`,onClick:()=>{k.id!==r&&s.switchVault(k.id)},children:[e.jsx("span",{className:"amxc-row-name",children:k.name}),k.id===r&&e.jsx(vt,{size:13})]},k.id)),e.jsxs("div",{className:"amxc-sec",children:[e.jsx(qa,{size:12})," ",n("cloudvault.sharedWithMe",{n:f.length})]}),f.length===0&&e.jsx("div",{className:"amxc-hint",children:n("cloudvault.sharedEmpty")}),f.map(k=>e.jsxs("button",{className:"amxc-row",onClick:()=>{t(),k.vaultId===r?Me(k.path):s.switchVault(k.vaultId)},children:[e.jsx("span",{className:"amxc-row-name",children:k.title}),e.jsxs("span",{className:"amxc-tag",children:[k.role==="viewer"?n("cloudvault.roleViewer"):n("cloudvault.roleEditor"),k.ownerName?` · ${k.ownerName}`:""]})]},`${k.vaultId}:${k.path}`)),e.jsxs("div",{className:"amxc-sec",children:[e.jsx(zs,{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(k=>e.jsxs("div",{className:"amxc-row static",children:[e.jsxs("span",{className:"amxc-row-name",title:k.path,children:[k.mode==="subtree"?"📁 ":"📄 ",k.path]}),e.jsx("button",{className:"amxc-ic",title:n("cloudvault.copyLink"),onClick:()=>G(s.publishUrl(k.token),k.token),children:b===k.token?e.jsx(vt,{size:12}):e.jsx(Wt,{size:12})}),e.jsx("button",{className:"amxc-ic",title:n("cloudvault.unpublish"),onClick:()=>{s.revokePublish(k.token).then(()=>{i(n("cloudvault.unpublished")),E()})},children:e.jsx(Ye,{size:12})})]},k.token))]})})}Ne({"presencedots.viewing":{zh:"{name} 正在看 {page}",en:"{name} is viewing {page}"},"presencedots.online":{zh:"{name} 在线",en:"{name} is online"}});function jc(){const{t}=he(),n=window.amadeusCollab,s=L(h=>h.activePage??h.activeNotePath),i=L(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 kc(t,n){return t.path===n?!0:t.mode==="subtree"?n.startsWith(`${t.path}/`):n.startsWith(`${t.path.replace(/\.md$/i,"")}.fd/`)}function pi(t,n){const s=n.find(l=>l.path===t);if(s)return{kind:"direct",token:s.token};const i=n.find(l=>kc(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 ba=t=>Number.isFinite(t)?String(t):_("share.unlimited"),Sc=t=>(t.split("/").pop()??t).replace(/\.md$/i,"");function Nc({path:t,anchor:n,onClose:s}){const i=L(u=>u.vaultRoot),l=L(u=>u.vaultSide),o=Oe(u=>u.vaults),r=Ds(o,i,l,t)??"";return e.jsx(zc,{path:r,localPath:t,anchor:n,onClose:s},JSON.stringify([i,l,t,r]))}function zc({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,b]=c.useState(null),[O,E]=c.useState(null),[G,k]=c.useState({kind:"none"}),[$,F]=c.useState(0),[N,z]=c.useState(!1),[M,D]=c.useState(null),[H,Z]=c.useState(""),[ce,q]=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),b(ue.quota),q(!1))}).catch(ue=>{pe()&&ue?.status===404&&q(!0)}),l.publishes().then(ue=>{if(!pe())return;b(ue.quota),F(ue.shares.length);const S=ue.shares.find(ie=>ie.path===t&&ie.mode==="page");E(S?{token:S.token,url:l.publishUrl(S.token)}:null),k(pi(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))})},Re=(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)},xe=(X,pe,ue=o("share.opFailed"))=>{z(!0),X.then(()=>{u.current&&(pe&&r(pe),re())}).catch(S=>{u.current&&Re(S,ue)}).finally(()=>{u.current&&z(!1)})};return e.jsx("div",{className:"amxc-cardwrap",onClick:i,children:e.jsxs(Tt,{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(Ns,{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:M==="inv"?e.jsx(vt,{size:13}):e.jsx(Wt,{size:13})}),e.jsx("button",{className:"amxc-ic",title:o("share.rotate"),onClick:()=>xe(l.updatePageShare(m.id,{rotate:!0}),o("share.rotated")),children:e.jsx(so,{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=>xe(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=>xe(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:()=>xe(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:H,onChange:X=>Z(X.target.value)}),e.jsx("button",{className:"amxc-ic",title:o("share.setPassword"),disabled:!H.trim(),onClick:()=>{const X=H.trim();Z(""),xe(l.updatePageShare(m.id,{password:X}),o("share.passwordSaved"))},children:e.jsx(vt,{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=>xe(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:()=>xe(l.removeParticipant(m.id,X.userId),o("share.removed")),children:e.jsx(Ye,{size:12})})]},X.userId)),e.jsx("button",{className:"amxc-danger",disabled:N,onClick:()=>xe(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:N||(p?p.collab<=0:!1),onClick:()=>xe(l.createPageShare(t,{role:"editor",expiresDays:7}),o("share.enabled")),children:[e.jsx(no,{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:ba(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:M==="pub"?e.jsx(vt,{size:13}):e.jsx(Wt,{size:13})})]}),e.jsxs("div",{className:"amxc-frow",children:[e.jsx("button",{className:"amxc-danger",disabled:N,onClick:()=>xe(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:Sc(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:M==="pub"?e.jsx(vt,{size:13}):e.jsx(Wt,{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:N,onClick:()=>xe(l.createPublish("page",t),o("share.published")),children:[e.jsx(zs,{size:13})," ",o("share.publish")]})]}),p&&e.jsx("div",{className:"amxc-hint",children:o("share.publishCount",{used:$,total:ba(p.publish)})})]}):e.jsx("div",{className:"amxc-hint",style:{padding:"18px 8px"},children:o("share.notInCloud")}),e.jsx(Cc,{path:n,onClose:i})]})})}function Cc({path:t,onClose:n}){const s=L(r=>r.vaultRoot),i=L(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(vs,{size:13})," ",l("share.syncOff")]}):e.jsxs("button",{className:"amxc-primary",onClick:()=>{n(),Dt(t,"page")},children:[e.jsx(Gt,{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 Pc=t=>(t.split("/").pop()??t).replace(/\.md$/i,"");function Tc({path:t,refreshKey:n,onOpen:s}){const i=L(u=>u.vaultRoot),l=L(u=>u.vaultSide),o=Oe(u=>u.vaults),r=Ds(o,i,l,t);return e.jsx(Ec,{path:r??"",refreshKey:n,onOpen:s},JSON.stringify([i,l,t,r]))}function Ec({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(pi(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(qa,{size:12})," ",f("sharestatus.collab")]}),h&&e.jsxs("button",{className:"amx-sharestat-chip is-pub",title:r.kind==="inherited"?f("sharestatus.inheritedTitle",{name:Pc(r.via)}):f("sharestatus.pubTitle"),onClick:j,children:[e.jsx(zs,{size:12})," ",r.kind==="inherited"?f("sharestatus.inherited"):f("sharestatus.published")]})]})}const ft=t=>{const n=t.split(/[\\/]/).filter(Boolean);return n.pop(),n.join("/")};function Dc(t,n){return n?.mergedFd!=null?{folder:n.mergedFd}:/\.md$/i.test(t)&&!Nt(t)&&!qt(t)&&!n?.pluginFile?{page:t}:{folder:ft(t)}}const ls=t=>"page"in t?t.page:t.folder;function Fc(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 Rc=t=>(t.split(/[\\/]/).pop()??t).replace(/\.md$/i,"");function ya(t,n,s){const i=Rc(t),l=n.filter(r=>As(r)===As(t)).length<=1,o=l?i:t.replace(/\\/g,"/").replace(/\.md$/i,"");return s===i&&l?i:`${o}|${s}`}function Mc({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 $c(){const{t}=he(),n=L(p=>p.activePage??p.activeNotePath),s=L(p=>p.linkGraphVersion),i=L(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(b=>{p&&o(b)}),()=>{p=!1}},[n,s,j]),c.useEffect(()=>{let p=!0;if(!n||!r||!te.unlinkedMentions){h(null);return}return te.unlinkedMentions(n).then(b=>{p&&h(b)}).catch(()=>{p&&h([])}),()=>{p=!1}},[n,r,s,j]);const y=async(p,b)=>{if(!n||!te.linkMention||b.raw===void 0||b.occ===void 0||b.col===void 0||!b.match)return;const O=ya(n,i,b.match);await te.linkMention(p,{raw:b.raw,occ:b.occ,col:b.col,match:b.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:()=>{Me(p.path)},title:p.path,children:p.title}),(p.hits??(p.snippet?[{line:1,text:p.snippet}]:[])).map((b,O)=>e.jsxs("button",{className:"amx-list-item amx-backlink-hit",onClick:()=>{Me(p.path)},children:[b.line===0&&e.jsx("span",{className:"amx-backlink-prop",children:t("amxbl.prop")}),b.text]},`${b.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:()=>{Me(p.path)},title:p.path,children:p.title}),p.hits.map((b,O)=>e.jsxs("div",{className:"amx-backlink-hit amx-mention",children:[e.jsx("button",{className:"amx-list-item amx-mention-text",onClick:()=>{Me(p.path)},children:e.jsx(Mc,{h:b})}),te.linkMention&&b.col!==void 0&&b.match&&e.jsx("button",{className:"amx-backlink-link",title:t("amxbl.linkTip",{inner:ya(n,i,b.match)}),onClick:()=>{y(p.path,b)},children:t("amxbl.link")})]},`${b.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=()=>L.getState(),ye=t=>t.split(/[\\/]/).pop().replace(/\.md$/,""),Tn=t=>t.split("/").pop()||t,mt=t=>{const n=[];let s="";for(const i of t.split(/[\\/]/).filter(Boolean))s=s?`${s}/${i}`:i,n.push(s);return n};function fi(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 ja(t,n){try{await Io();const s=await te.renamePageFile(t,n);if(s!==t){ln(t,"file",s),Lo(t,s,"file"),await Ao(t,s),fi(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 Oc=()=>!!te.trashEntry;function Ic(t){const n=zt(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 pn(t,n=je){if(!Mn("note",t))return;const s=await te.exclusiveAssets?.(t).catch(()=>[])??[];let i=s.length>0?Cr():!1;if(s.length>0&&i===null){const l=await Pr(ye(t),s);if(l===null)return;i=l==="with"}qn.getState().remove(`note:${t}`),await n().deletePage(t),i&&(await zo(s),await n().refreshStructure())}function Mn(t,n){return Oc()?!0:t==="note"?window.confirm(Ic(n)):t==="file"?window.confirm(_("amxv.confirm.deleteFile",{name:n.split(/[\\/]/).pop()})):window.confirm(_("amxv.confirm.deleteFolder",{name:n.split(/[\\/]/).pop()}))}const xi=Zt(t=>({locate:null,requestLocate:n=>t(s=>({locate:{path:n,n:(s.locate?.n??0)+1}}))}));L.subscribe((t,n)=>{const s=t.activePage;if(!s||s===n.activePage||qt(s)&&ao()!=="mini")return;const i=Wn();queueMicrotask(()=>{const l=$e.getState().api,o=l?Cs(l):null,r=o&&(o.params??{}).__type==="amadeus-editor"&&o.id===i?o.id:i;Ha(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}),Ss(r).getState().loadPage(s))})}),qn.getState().record({key:`note:${s}`,kind:"note",id:s,title:ye(s)})});function Os({path:t,hideLoneLeaf:n}={}){const s=L(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=Ua(l),u=r?Bt(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 bt=t=>/\.md$/i.test(t),Pt=t=>/\.db$/i.test(t),ka=t=>/\.pdf$/i.test(t),En=t=>/\.(png|jpe?g|gif|webp|svg|avif|bmp|ico)$/i.test(t),Sa=t=>(t.split(/[\\/]/).pop()||t).replace(/\.db$/i,"");function Lc(){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(Es,{}):e.jsx(Yt,{})}),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 Ac({row:t,pages:n}){const{t:s}=he(),i=Pe(y=>y.starred),l=Pe(y=>y.collections),[o,r]=Bn("starred"),[u,f]=Bn("collections"),h=new Set(n),j=i.filter(y=>h.has(y));if(!j.length&&!l.length)return null;const m=(y,p,b,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${b?" open":""}`,children:e.jsx(Ut,{size:12})}),e.jsx("span",{className:"t2s-count",children:p.length})]})}),b&&e.jsx("div",{className:"t2s-group-sessions",children:p.map(E=>t(E))})]});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(Ut,{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:()=>{Oo(),ri.getState().request(y.query)},children:[e.jsx("span",{className:"amx-coll-ic",children:e.jsx(js,{})}),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 Bc(){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:()=>{r.localPath?Me(r.localPath):r.vaultId===l?Me(r.path):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 _n({id:t,defaultOpen:n,label:s,count:i,extra:l,dropProps:o,dropActive:r,children:u}){const[f,h]=Bn(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(Ut,{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 Vc({row:t,dragPath:n}){const{t:s}=he(),i=Pe(j=>j.pins),l=L(j=>j.pages),o=L(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&&bt(n)&&!i.includes(n);return e.jsx(_n,{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 _c=t=>t==="TOO_LARGE"?_("amxv.skip.tooLarge"):t==="ASSET_404"?_("amxv.skip.assetMissing"):t,gi=t=>e.jsx("div",{className:"t2s-hint amx-sec-hint amx-cs-warn",title:t.map(n=>`${n.path} — ${_c(n.reason)}`).join(`
8
- `),children:_("amxv.skip.summary",{n:t.length,extra:t.some(n=>n.reason==="TOO_LARGE")?_("amxv.skip.tooLargeNote"):""})});function Wc(){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:gi(t.skipped)}function qc({dragPath:t}){const{t:n}=he(),s=L(F=>F.vaultRoot),i=L(F=>F.pages),l=L(F=>F.files),o=L(F=>F.folders),r=Oe(F=>F.vaults),u=Oe(F=>s?F.status[s]:void 0),[f,h]=c.useState(!1),j=r.find(F=>F.vaultRoot===s);if(!window.amadeusSync?.entrySyncEnable||!s)return null;const m=j?.entries??[];if(!m.length&&!u?.skipped.length)return null;const y=F=>F.replace(/\\/g,"/").normalize("NFC"),p=new Set(i.map(y)),b=new Set(l.map(y)),O=new Set(o.map(y)),E=F=>F.kind==="folder"?O.has(F.path):F.kind==="page"?p.has(F.path):b.has(F.path),G=u?.state==="error"||u?.state==="auth-required"?"err":u?.state==="offline"?"off":"ok",k=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"),$=!!t&&!xn(s,t);return e.jsxs(_n,{id:"cloudsync",label:n("amxv.sec.cloudSync"),count:m.length,extra:j?e.jsx("span",{className:`amx-sync-dot ${G}`,title:k}):void 0,dropActive:f,dropProps:{onDragOver:F=>{$&&(F.preventDefault(),F.stopPropagation(),F.dataTransfer.dropEffect="move",f||h(!0))},onDragLeave:()=>h(!1),onDrop:F=>{$&&(F.preventDefault(),F.stopPropagation(),h(!1),Dt(t,bt(t)?"page":"asset"))}},children:[!m.length&&e.jsx("div",{className:"t2s-hint amx-sec-hint",children:n("amxv.cloudsync.hint")}),!!u?.skipped.length&&gi(u.skipped),m.map(F=>{const N=E(F);return e.jsxs("div",{className:`t2s-srow amx-cs-row${N?"":" amx-cs-ghost"}`,role:"button",tabIndex:0,title:N?F.path:n("amxv.cloud.missing",{path:F.path}),onClick:()=>{N&&(F.kind==="page"?Me(F.path):F.kind==="asset"&&Pt(F.path)&&Fn(F.path))},children:[e.jsx("span",{className:"amx-cs-ic",children:F.kind==="folder"?e.jsx(Es,{}):F.kind==="page"?e.jsx(Yt,{}):e.jsx(fn,{})}),e.jsx("span",{className:"t2s-srow-title",children:F.kind==="page"?ye(F.path):F.path.split(/[\\/]/).pop()}),e.jsx("button",{className:"amx-coll-del",title:n("amxv.cloud.disableTip"),onClick:z=>{z.stopPropagation(),window.amadeusSync?.entrySyncDisable?.(F.path)},children:"✕"})]},F.path)})]})}const Uc=[],Na=[];function Hc(){const{t}=he(),n=L(a=>a.pages),s=L(a=>a.folders),i=L(a=>a.files),l=L(a=>a.icons),o=L(a=>a.pendingPage??a.activePage??a.activeNotePath),r=L(a=>a.vaultRoot),u=L(a=>a.vaultSide),f=L(a=>a.vaultLoading),h=!!window.amadeusCloudVaults||u==="cloud",[j,m]=c.useState(""),[y,p]=c.useState(new Set),[b,O]=c.useState(!1),[E,G]=c.useState(null),[k,$]=c.useState(null),F=c.useRef(null),N=qr(F),z=oo(),[M,D]=c.useState(()=>{try{const a=localStorage.getItem("forsion_notes_phone_tab");return a==="recent"||a==="tree"||a==="boards"?a:null}catch{return null}}),H=qn(a=>z?a.items:Uc),Z=Pe(a=>z?a.recents:Na),ce=Pe(a=>z?a.starred:Na),q=c.useMemo(()=>{const a=new Set([...n,...i]),w=new Set,x=[];for(const T of H)(T.kind==="note"||T.kind==="file")&&a.has(T.id)&&!w.has(T.id)&&(w.add(T.id),x.push({path:T.id,at:T.ts}));for(const T of Z)a.has(T)&&!w.has(T)&&(w.add(T),x.push({path:T,at:0}));return x},[H,Z,n,i]),re=c.useMemo(()=>[...new Set([...i,...n])].filter(Nt).sort((a,w)=>ye(a).localeCompare(ye(w))),[n,i]),we=M??(q.length?"recent":"tree"),Re=a=>{D(a);try{localStorage.setItem("forsion_notes_phone_tab",a)}catch{}},xe=z&&!!r&&we!=="tree",X=()=>ms.getState().openPalette();Ur(F,z?X:void 0);const pe=ro(a=>a.items.find(w=>w.id==="rb-units-mobile"));lo(z?{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,S]=c.useState(()=>{try{const a=JSON.parse(localStorage.getItem("amx.sec.order")||"[]");return Array.isArray(a)?a.filter(w=>typeof w=="string"):[]}catch{return[]}}),[ie,ne]=c.useState(null),[ge,ke]=c.useState(null),[qe,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"],U=new Map(ue.map((a,w)=>[a,w])),Y=ue.length?[...A].sort((a,w)=>(U.get(a)??ue.length)-(U.get(w)??ue.length)):A,fe=(a,w,x)=>{const T=Y.filter(ve=>ve!==a),de=T.indexOf(w);T.splice(de<0?T.length:x?de+1:de,0,a),S(T);try{localStorage.setItem("amx.sec.order",JSON.stringify(T))}catch{}},se=(a,w)=>e.jsx("div",{className:`amx-sec-wrap${qe===a&&ge&&ge!==a?" amx-sec-over":""}`,draggable:ie===a,onPointerDown:x=>{x.pointerType!=="mouse"||x.button!==0||x.target.closest(".amx-sec-grab")&&ne(a)},onDragStart:x=>{if(ie===a){x.stopPropagation(),x.dataTransfer.effectAllowed="move";try{x.dataTransfer.setData("application/x-amx-section",a)}catch{}ke(a)}},onDragEnd:()=>{ke(null),P(null),ne(null)},onDragOver:x=>{!ge||ge===a||(x.preventDefault(),x.stopPropagation(),x.dataTransfer.dropEffect="move",qe!==a&&P(a))},onDragLeave:x=>{qe===a&&!x.currentTarget.contains(x.relatedTarget)&&P(null)},onDrop:x=>{if(!ge||ge===a)return;x.preventDefault(),x.stopPropagation();const T=x.currentTarget.getBoundingClientRect();fe(ge,a,x.clientY>T.top+T.height/2),ke(null),P(null)},children:w},a),[R,W]=c.useState(null),[Xe,Je]=Bn("vault",!0),[_e,dt]=c.useState(null),[Ze,wt]=c.useState(""),Te=c.useRef(null),Ie=xi(a=>a.locate),[He,at]=c.useState(null),We=c.useRef(null);c.useEffect(()=>{co()},[]),c.useEffect(()=>{oi(),Oe.getState().refresh()},[r,n,s]);const oe=Oe(a=>a.vaults),ut=Oe(a=>a.mirrorVaults);c.useEffect(()=>{_e&&Te.current?.select()},[_e]),c.useEffect(()=>{if(!R)return;const a=()=>W(null);return window.addEventListener("click",a),window.addEventListener("contextmenu",a),()=>{window.removeEventListener("click",a),window.removeEventListener("contextmenu",a)}},[R]),c.useEffect(()=>{if(!Ie)return;const a=s.includes(Ie.path)?Ie.path:ft(Ie.path);a&&p(x=>new Set([...x,...mt(a)])),at(Ie.path);const w=setTimeout(()=>at(null),1200);return()=>clearTimeout(w)},[Ie?.n]),c.useEffect(()=>{He&&We.current?.scrollIntoView({block:"nearest"})},[He]);const Ee=j.trim().toLowerCase(),Le=c.useMemo(()=>Vr(_r([...n,...i],s)),[n,i,s]),Ke=c.useMemo(()=>Ee?[...n,...i].filter(a=>ye(a).toLowerCase().includes(Ee)):[],[Ee,n,i]),[Qe,yt]=c.useState([]);c.useEffect(()=>{const a=window.amadeusCloudVaults;if(!a||window.amadeusSync)return;let w=!0;return a().then(x=>{w&&yt(x)}).catch(()=>{}),()=>{w=!1}},[n,s]);const it=c.useMemo(()=>{const a=!!window.amadeusSync&&u==="cloud",w=!window.amadeusSync&&!!window.amadeusCloudVaults;if(!a&&!w)return null;const x=a?[...new Set([...oe.map(I=>I.cloudName),...ut])].sort():Qe,T=new Map(Le.children.filter(I=>I.kind==="folder").map(I=>[I.path,I])),de=x.map(I=>({name:I,node:T.get(I)??null})),ve=new Set(x),De=Le.children.filter(I=>!(I.kind==="folder"&&ve.has(I.path)));return{vaultSecs:de,rest:De}},[Le,oe,ut,u,Qe]),ht=$e(a=>a.mainTabs),v=c.useMemo(()=>{const a=$e.getState().api,w=a?Cs(a):null,x=w?{id:w.id,type:String((w.params??{}).__type??"")}:ht.find(ve=>ve.active),T=x&&uo[x.type],de=T?$e.getState().leafById(x.id)?.params?.[T]:null;return typeof de=="string"?de:null},[ht]),V=hs(a=>a.fileTypes),J=hs(a=>a.fileCreators),Q=(a,w,x)=>{W(null),a&&p(T=>new Set([...T,...mt(a)])),Promise.resolve().then(()=>x(a)).catch(T=>{console.error("[plugin] file creator failed",T),Ve.getState().toast(_("amxv.fileCreatorFailed",{label:w,e:T instanceof Error?T.message:String(T)}),!0)})},Ce=a=>p(w=>{const x=new Set(w);return x.has(a)?x.delete(a):x.add(a),x}),Fe=a=>{const w=(E?N.batch(E):[]).filter(T=>{if(ft(T)===a)return!1;if(Sn(T)){const de=zt(T);if(a===de||a.startsWith(`${de}/`))return!1}return!0});G(null),$(null);const x=Ss(Wn());(async()=>{for(const T of w)await x.getState().movePage(T,a)})().catch(T=>x.setState({error:String(T)}))},et=a=>Array.from(a.dataTransfer?.types??[]).includes("Files"),Ae=a=>Fc(Array.from(a.dataTransfer?.types??[]),!!r&&!!window.tangu?.copyHostFiles&&!(window.amadeusSync&&u==="cloud"),{paths:es,ref:Xa}),gn=a=>{if(!Ae(a))return[];try{const w=JSON.parse(a.dataTransfer?.getData(es)||"null");return Array.isArray(w)?w:[]}catch{return[]}},Qt=(a,w)=>{const x=gn(a);return x.length?(a.preventDefault(),a.stopPropagation(),$(null),window.tangu.copyHostFiles(x,w?`${r}/${w}`:r).catch(T=>Ma.getState().notify(_("amxv.copyFailed",{e:T instanceof Error?T.message:String(T)}))).finally(()=>{je().refreshStructure()}),!0):!1},Hn=(a,w)=>{const x=gn(a);return x.length?(a.preventDefault(),a.stopPropagation(),$(null),Me(w).then(()=>nc(x)).then(T=>{T.length&&vn(T,w)}),!0):!1},Rt=(a,w)=>!et(a)&&!Ae(a)?!1:(a.preventDefault(),a.stopPropagation(),a.dataTransfer&&(a.dataTransfer.dropEffect="copy"),k!==w&&$(w),!0),jt=(a,w)=>{if(Qt(a,w))return!0;const x=Array.from(a.dataTransfer?.files??[]);return x.length?(a.preventDefault(),a.stopPropagation(),$(null),ma(x,w),!0):!1},kt=(a,w)=>Dc(a,{mergedFd:w,pluginFile:!!pt(V,a)}),vn=(a,w)=>{ds(w,a)||An(a,w)},en=(a,w,x)=>Rt(a,ls(kt(w,x))),Kn=(a,w,x)=>{const T=kt(w,x);if("page"in T?Hn(a,T.page):Qt(a,T.folder))return!0;const de=Array.from(a.dataTransfer?.files??[]);if(!de.length)return!1;a.preventDefault(),a.stopPropagation(),$(null);const ve=kt(w,x);return"page"in ve?Me(ve.page).then(()=>vn(de,ve.page)):ma(de,ve.folder),!0},wn=(a,w)=>!et(a)&&!Ae(a)?!1:(a.target.closest(w)||Rt(a,""),!0),tn=(a,w)=>!et(a)&&!Ae(a)?!1:(a.target.closest(w)||jt(a,""),!0),Mt=()=>{const a=_e;dt(null);const w=Ze.trim();if(!a||!w)return;const x=pt(V,a);if(x){const T=x.extensions.find(ve=>a.toLowerCase().endsWith(ve.toLowerCase()));if(!T||!/\.md$/i.test(T))return;const de=Wr(w,T);de!==Bt(a,x.extensions)+T.replace(/\.md$/i,"")&&ja(a,de);return}bt(a)?w!==ye(a)&&ja(a,w):Pt(a)&&w.replace(/\.db$/i,"")!==Sa(a)&&$o(a,w).catch(T=>window.alert(_("amxv.renameFailed",{e:T instanceof Error?T.message:String(T)})))},$t=a=>{const w=pt(V,a);wt(w?Bt(a,w.extensions):Pt(a)?Sa(a):ye(a)),dt(a),W(null)},nn=async a=>{const w=(await ot(a?_("amadeus.new.folderIn",{folder:Tn(a)}):_("amadeus.new.folder"),_("amadeus.default.folder")))?.trim();w&&(je().createFolder(a,w),p(x=>new Set([...x,...mt(a?`${a}/${w}`:w)]))),W(null)},bn=async a=>{W(null);const w=(await ot(a?_("amadeus.new.databaseIn",{folder:Tn(a)}):_("amadeus.new.database"),_("amadeus.default.database")))?.trim().replace(/[\\/]/g,"");if(!w)return;const x=a?`${a}/${w}.db`:`${w}.db`;if(je().files.some(T=>T.replace(/\\/g,"/")===x)){window.alert(_("amadeus.exists",{name:`${w}.db`}));return}(async()=>{const T=new TextEncoder().encode(Mi($i(w)));await te.saveAttachment("",`${w}.db`,T,{mode:"vault",folder:a}),Co("base.create"),Po("base.create",{f:x}),await je().refreshStructure(),a&&p(de=>new Set([...de,...mt(a)])),Fn(x)})().catch(T=>window.alert(_("amxv.newBaseFailed",{e:T instanceof Error?T.message:String(T)})))},St=a=>{W(null),So(a).then(w=>{w&&a&&p(x=>new Set([...x,...mt(a)]))})},yn=a=>{W(null),To(a).then(w=>{w&&a&&p(x=>new Set([...x,...mt(a)]))})},d=()=>[{id:"new-note",label:t("amadeus.new.note"),icon:e.jsx(Lt,{size:13}),run:()=>{je().createPage(),W(null)}},{id:"new-folder",label:t("amadeus.new.folder"),icon:e.jsx(ra,{size:13}),run:()=>{nn("")}},{id:"new-database",label:t("amadeus.new.database"),icon:e.jsx(jn,{size:13}),run:()=>{bn("")}},{id:"new-drawing",label:t("amadeus.new.drawing"),icon:e.jsx(on,{size:13}),run:()=>St("")},{id:"new-dashboard",label:t("amadeus.new.dashboard"),icon:e.jsx(Cn,{size:13}),run:()=>yn("")},...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:Zn(a.item.icon,"📄")}),run:()=>Q("",a.item.label,a.item.run)}))],g=R?.kind==="root"?R:null,C=Hr(g,()=>g&&{title:t("amxv.phone.new"),sections:[{items:d()}]},()=>W(null)),B=(a,w,x)=>{if(!Rt(a,x)&&E&&(a.stopPropagation(),!(E===w||ft(E)===x))){if(Sn(E)){const T=zt(E);if(x===T||x.startsWith(`${T}/`))return}a.preventDefault(),a.dataTransfer.dropEffect="move",k!==x&&$(x)}},ae=a=>()=>r?al(`${r}/${a}`,bt(a)?ye(a):a.split(/[\\/]/).pop()??a):null,ee=a=>{je().createChildNote(a,_("amadeus.default.note")).then(w=>{p(x=>new Set([...x,...mt(zt(a))])),Me(w)},()=>{})},le=(a,w)=>{const x=Nt(a),T=!x&&qt(a);(!x&&!T?pt(V,a):void 0)?Jn(a,w):T?No(a,w):x?Ws(a,w):bt(a)?Me(a,w):Pt(a)?Fn(a,w):ka(a)?Vs(a,void 0,w):En(a)?_s(a,w):te.openVaultFile(a).catch(()=>{})},me=(a,w)=>{const x=Nt(a),T=!x&&qt(a),de=!x&&!T?pt(V,a):void 0,ve=!x&&!T&&!de&&bt(a),De=ve||T,I=Pt(a)?jn:x?on:T?Cn:ve?Yt:En(a)?Gs:fn,nt=ce.includes(a),K=[...De?[{id:"star",label:t(nt?"amxv.menu.unstar":"amxv.menu.star"),icon:nt?e.jsx(zl,{}):e.jsx(On,{}),run:()=>Pe.getState().toggleStar(a)},{id:"rename",label:t("amxv.menu.rename"),icon:e.jsx(cn,{}),run:()=>$t(a)}]:[],{id:"delete",label:t("amxv.menu.delete"),icon:e.jsx(Ye,{}),tone:"danger",run:()=>{De?pn(a):Mn("file",a)&&je().deletePage(a)}}];return e.jsx(sl,{actions:K,children:e.jsx(ia,{as:"button",className:a===(v??o)?"active":void 0,style:{paddingLeft:void 0},lead:l[a]?e.jsx("span",{className:"amx-page-emoji",children:l[a]}):e.jsx(I,{className:"t2s-lead-icon t2s-dim"}),trailing:w?e.jsx("span",{className:"t2s-srow-time",children:jo(w)}):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:Ze,onChange:Se=>wt(Se.target.value),onBlur:Mt,onKeyDown:Se=>{Se.key==="Enter"&&Mt(),Se.key==="Escape"&&dt(null)},onClick:Se=>Se.stopPropagation()}):e.jsxs("span",{className:"t2s-srow-text",children:[e.jsx("span",{className:"t2s-srow-title",children:de?Bt(a,de.extensions):x?ye(a).replace(/\.excalidraw$/i,""):ve?ye(a):a.split(/[\\/]/).pop()}),ft(a)&&e.jsx("span",{className:"t2s-srow-sub",children:ft(a)})]})})},a)},be=(a,w=0,x)=>{const T=Nt(a),de=!T&&qt(a),ve=!T&&!de?pt(V,a):void 0,De=!T&&!de&&!ve&&bt(a),I=De||de?"page":"asset",nt=Pt(a)?jn:T?on:de?Cn:De?Yt:En(a)?Gs:fn;return e.jsxs(ia,{as:"button",elRef:K=>{a===He&&(We.current=K)},className:`${a===(v??o)?"active":""}${N.has(a)?" sel":""}${a===He?" amx-flash":""}${a===E?" dragging":""}${k===ls(kt(a,x?.fd))?" amx-drop-into":""}`.trim()||void 0,selId:a,depth:w,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:Zn(ve.icon,e.jsx(nt,{className:"t2s-lead-icon t2s-dim"}))}):e.jsx(nt,{className:"t2s-lead-icon t2s-dim"}),x&&e.jsx("span",{className:`t2s-chev t2s-lead-chev${x.open?" open":""}`,onClick:K=>{K.stopPropagation(),Ce(x.fd)},children:e.jsx(Ut,{size:12})})]}),onClick:K=>{const Se=N.click(a,K);Se.open!=="none"&&le(a,Se.open==="new"?{newTab:!0}:void 0)},onContextMenu:K=>{K.preventDefault(),K.stopPropagation();const Se=N.batch(a);Se.length===1&&N.only(a),W(Se.length>1?{kind:"multi",path:a,paths:Se,x:K.clientX,y:K.clientY}:{kind:I,path:a,x:K.clientX,y:K.clientY})},draggable:_e!==a,onDragStart:K=>{const Se=K.currentTarget.getBoundingClientRect();K.dataTransfer.setDragImage(K.currentTarget,K.clientX-Se.left,K.clientY-Se.top),K.dataTransfer.effectAllowed="copyMove";const Ls=N.batch(a);if(ko(K.dataTransfer,Ls.map(Gn=>({kind:"note",path:Gn}))),r&&!(window.amadeusSync&&u==="cloud")){const Gn=Ls.flatMap(Yn=>{const Xn=Sn(Yn)?zt(Yn):"";return[`${r}/${Yn}`,...Xn&&s.includes(Xn)?[`${r}/${Xn}`]:[]]});try{K.dataTransfer.setData(es,JSON.stringify(Gn))}catch{}}G(a)},onDragEnd:()=>{G(null),$(null)},onDragOver:K=>{en(K,a,x?.fd)||x&&B(K,a,x.fd)},onDragLeave:()=>{k===ls(kt(a,x?.fd))&&$(null)},onDrop:K=>{Kn(K,a,x?.fd)||x&&(K.preventDefault(),K.stopPropagation(),Fe(x.fd))},...aa(ae(a)),children:[_e===a?e.jsx("input",{ref:Te,className:"t2s-rename",value:Ze,onChange:K=>wt(K.target.value),onBlur:Mt,onKeyDown:K=>{K.key==="Enter"&&Mt(),K.key==="Escape"&&dt(null)},onClick:K=>K.stopPropagation()}):e.jsx("span",{className:"t2s-srow-title",children:ve?Bt(a,ve.extensions):De||T?ye(a):a.split(/[\\/]/).pop()}),e.jsx("span",{className:"t2s-srow-menu",onClick:K=>{K.stopPropagation(),W({kind:I,path:a,x:K.clientX,y:K.clientY})},children:e.jsx(Xt,{size:14})}),De&&e.jsx("span",{className:"t2s-srow-menu",title:t("amadeus.new.childNote"),onClick:K=>{K.stopPropagation(),ee(a)},children:e.jsx(Et,{size:14})})]},a)},Be=(a,w)=>{if(a.kind==="file"){if(!a.children.length)return be(a.path,w);const I=zt(a.path),nt=y.has(I);return e.jsxs("div",{children:[be(a.path,w,{fd:I,open:nt,count:a.children.filter(K=>K.kind==="file").length}),nt&&e.jsx("div",{className:`t2s-group-sessions${k===I?" amx-drop-into":""}`,onDragOver:K=>B(K,a.path,I),onDragLeave:()=>{k===I&&$(null)},onDrop:K=>{jt(K,I)||(K.preventDefault(),K.stopPropagation(),Fe(I))},children:a.children.map(K=>Be(K,w+1))})]},a.path)}const x=a.path,T=!y.has(x),de=a.children.filter(I=>I.kind==="file").length,ve=a.children.length-de,De=I=>{if(!Rt(I,x)&&E&&(I.stopPropagation(),ft(E)!==x)){if(Sn(E)){const nt=zt(E);if(x===nt||x.startsWith(`${nt}/`))return}I.preventDefault(),I.dataTransfer.dropEffect="move",k!==x&&$(x)}};return e.jsxs("div",{children:[e.jsxs("div",{ref:I=>{x===He&&(We.current=I)},className:`t2s-group${x===He?" amx-flash":""}${k===x?" amx-drop-into":""}`,style:{paddingLeft:nl(w)},...aa(()=>[tl("tip.folder",{files:de,folders:ve})]),onContextMenu:I=>{I.preventDefault(),I.stopPropagation(),W({kind:"folder",path:x,x:I.clientX,y:I.clientY})},onDragOver:De,onDragLeave:()=>{k===x&&$(null)},onDrop:I=>{jt(I,x)||(I.preventDefault(),I.stopPropagation(),Fe(x))},children:[e.jsxs("button",{className:"t2s-group-toggle t2s-folder-row",onClick:()=>Ce(x),children:[e.jsxs("span",{className:"t2s-lead",children:[T?e.jsx(Es,{className:"t2s-lead-icon"}):e.jsx(gt,{className:"t2s-lead-icon"}),e.jsx("span",{className:`t2s-chev t2s-lead-chev${T?"":" open"}`,children:e.jsx(Ut,{size:12})})]}),e.jsx("span",{className:"t2s-group-label",children:Tn(x)})]}),e.jsx("button",{className:"t2s-group-add",title:t("amxv.folder.actions"),onClick:I=>{I.stopPropagation(),W({kind:"folder",path:x,x:I.clientX,y:I.clientY})},children:e.jsx(Xt,{size:14})}),e.jsx("button",{className:"t2s-group-add",title:t("amxv.folder.newNoteHere"),onClick:()=>{p(I=>new Set([...I,...mt(x)])),je().createPageInFolder(x)},children:e.jsx(Et,{size:14})})]}),!T&&e.jsx("div",{className:`t2s-group-sessions${k===x?" amx-drop-into":""}`,onDragOver:De,onDragLeave:()=>{k===x&&$(null)},onDrop:I=>{jt(I,x)||(I.preventDefault(),I.stopPropagation(),Fe(x))},children:a.children.map(I=>Be(I,w+1))})]},x)},Ge=it?e.jsxs(e.Fragment,{children:[e.jsx(Wc,{}),e.jsx(_n,{id:"cloud-ws",defaultOpen:!0,label:t("amxv.sec.cloudWorkspace"),children:it.rest.length?it.rest.map(a=>Be(a,0)):e.jsx("div",{className:"t2s-hint amx-sec-hint",children:t("amxv.empty")})}),it.vaultSecs.map(({name:a,node:w})=>e.jsx(_n,{id:`vault:${a}`,defaultOpen:!0,label:a,children:w&&w.children.length?w.children.map(x=>Be(x,0)):e.jsx("div",{className:"t2s-hint amx-sec-hint",children:t(w?"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:Je,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${Xe?" open":""}`,children:e.jsx(Ut,{size:12})})]})}),Xe&&e.jsx("div",{className:`t2s-group-sessions${k===""?" amx-drop-root":""}`,onDragOver:a=>{wn(a,".t2s-srow, .t2s-group")||!E||ft(E)===""||Ee||a.target.closest(".t2s-srow, .t2s-group")||(a.preventDefault(),a.dataTransfer.dropEffect="move",k!==""&&$(""))},onDragLeave:()=>{k===""&&$(null)},onDrop:a=>{tn(a,".t2s-srow, .t2s-group")||a.target.closest(".t2s-srow, .t2s-group")||(a.preventDefault(),Fe(""))},children:Le.children.map(a=>Be(a,0))})]}):e.jsx(e.Fragment,{children:Le.children.map(a=>Be(a,0))}),tt=e.jsxs("div",{className:"t2s-foot",children:[e.jsx(Lc,{}),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(gt,{})}),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":xe?"":void 0,children:[z?!!r&&e.jsx(Kr,{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:Re}):e.jsxs("div",{className:"t2s-search",children:[e.jsx(js,{size:13,className:"t2s-dim"}),e.jsx("input",{value:j,placeholder:t("amxv.searchNotes"),onChange:a=>m(a.target.value)})]}),e.jsxs("div",{ref:F,className:`t2s-scroll${k===""?" amx-drop-root":""}`,"data-under-dock":z?"":void 0,onTouchStart:xe?Gr:void 0,onClick:a=>{a.target===a.currentTarget&&N.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=>{wn(a,".t2s-srow, .t2s-group, .t2s-group-sessions, .t2s-special-group")||!E||ft(E)===""||Ee||a.target.closest(".t2s-srow, .t2s-group, .t2s-group-sessions, .t2s-special-group")||(a.preventDefault(),a.dataTransfer.dropEffect="move",k!==""&&$(""))},onDragLeave:()=>{k===""&&$(null)},onDrop:a=>{tn(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(),Fe(""))},children:[z&&e.jsx(Yr,{}),xe&&e.jsx(Xr,{id:"notes",children:t("amxv.phone.hint")}),xe&&we==="recent"&&(q.length?Jr(q,a=>il(a.at)).map(a=>"section"in a?e.jsx(Zr,{bucket:a.section},`sec:${a.section}`):me(a.item.path,a.item.at)):e.jsx("div",{className:"t2s-hint",children:t("amxv.phone.noRecent")})),xe&&we==="boards"&&(re.length?re.map(a=>me(a,0)):e.jsx("div",{className:"t2s-hint",children:t("amxv.phone.noBoards")})),xe?null:Ee?Ke.length?Ke.map(a=>be(a)):e.jsx("div",{className:"t2s-hint",children:t("amxv.noMatches")}):e.jsxs(e.Fragment,{children:[!z&&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(Lt,{})}),e.jsx("span",{className:"t2s-special-title",children:t("amadeus.new.note")})]}),e.jsxs("button",{className:"t2s-special",onClick:()=>St(""),children:[e.jsx("span",{className:"t2s-special-ic",children:e.jsx(on,{})}),e.jsx("span",{className:"t2s-special-title",children:t("amadeus.new.drawing")})]})]}),!r&&(f?e.jsx(Ka,{variant:"list"}):e.jsx("div",{className:"t2s-hint",children:t("amxv.openVaultHint")})),(()=>{const a={pinned:e.jsx(Vc,{row:be,dragPath:E}),cloudsync:u==="local"?e.jsx(qc,{dragPath:E}):null,shared:e.jsx(Bc,{}),prefs:e.jsx(Ac,{row:be,pages:n}),tree:Ge};return Y.map(w=>a[w]==null?null:se(w,a[w]))})()]}),z&&tt]}),!z&&tt,z&&r&&e.jsx(Qr,{label:t("amadeus.new.note"),icon:e.jsx(Lt,{}),onClick:()=>{je().createPage()},onMenu:a=>W({kind:"root",path:"",x:a.x,y:a.y})})]}),R?.kind==="multi"&&e.jsxs(Tt,{className:"ctx-menu",x:R.x,y:R.y,onClick:a=>a.stopPropagation(),children:[e.jsxs("button",{onClick:()=>{const a=R.paths??[];W(null);for(const w of a)le(w,{newTab:!0})},children:[e.jsx(Et,{size:13})," ",t("amxv.menu.openNInNewTabs",{n:R.paths?.length??0})]}),e.jsxs("button",{className:"danger",onClick:()=>{const a=R.paths??[];W(null),window.confirm(t("amxv.confirm.deleteSelected",{n:a.length}))&&(async()=>{for(const w of a)bt(w)&&!Nt(w)?await pn(w):await je().deletePage(w);N.clear()})()},children:[e.jsx(Ye,{size:13})," ",t("amxv.menu.deleteN",{n:R.paths?.length??0})]})]}),R?.kind==="page"&&e.jsxs(Tt,{className:"ctx-menu",x:R.x,y:R.y,onClick:a=>a.stopPropagation(),children:[e.jsxs("button",{onClick:()=>{Me(R.path,{newTab:!0}),W(null)},children:[e.jsx(Et,{size:13})," ",t("amxv.menu.openInNewTab")]}),e.jsxs("button",{onClick:()=>{const a=R.path;W(null),ee(a)},children:[e.jsx(Lt,{size:13})," ",t("amadeus.new.childNote")]}),e.jsxs("button",{onClick:()=>$t(R.path),children:[e.jsx(cn,{size:13})," ",t("amxv.menu.rename")]}),e.jsxs("button",{onClick:()=>{Pe.getState().toggleStar(R.path),W(null)},children:[e.jsx(On,{size:13})," ",Pe.getState().starred.includes(R.path)?t("amxv.menu.unstar"):t("amxv.menu.star")]}),window.amadeusSync?.entrySyncEnable&&u==="local"&&(xn(r,R.path)?e.jsxs("button",{onClick:()=>{const a=R.path;W(null),window.amadeusSync.entrySyncDisable(a)},children:[e.jsx(vs,{size:13})," ",t("amxv.menu.cloudSyncOff")]}):e.jsxs("button",{onClick:()=>{const a=R.path;W(null),Dt(a,"page")},children:[e.jsx(Gt,{size:13})," ",t("amxv.menu.cloudSyncOn")]})),un()&&e.jsxs("button",{onClick:()=>{te.revealInFileManager(R.path),W(null)},children:[e.jsx(gt,{size:13})," ",t("amxv.menu.reveal")]}),e.jsxs("button",{className:"danger",onClick:()=>{const a=R.path;W(null),pn(a)},children:[e.jsx(Ye,{size:13})," ",t("amxv.menu.delete")]})]}),R?.kind==="asset"&&e.jsxs(Tt,{className:"ctx-menu",x:R.x,y:R.y,onClick:a=>a.stopPropagation(),children:[Pt(R.path)?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{Fn(R.path),W(null)},children:[e.jsx(xt,{size:13})," ",t("amxv.menu.open")]}),e.jsxs("button",{onClick:()=>$t(R.path),children:[e.jsx(cn,{size:13})," ",t("amxv.menu.rename")]}),e.jsxs("button",{onClick:()=>{te.openVaultFile(R.path).catch(()=>{}),W(null)},children:[e.jsx(It,{size:13})," ",t("amxv.menu.openWithSystem")]})]}):ka(R.path)?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{Jn(R.path),W(null)},children:[e.jsx(xt,{size:13})," ",t("amxv.menu.open")]}),pt(V,R.path)&&e.jsxs("button",{onClick:()=>{Vs(R.path),W(null)},children:[e.jsx(si,{size:13})," ",t("amxv.menu.openBuiltinReader")]}),e.jsxs("button",{onClick:()=>{te.openVaultFile(R.path).catch(()=>{}),W(null)},children:[e.jsx(It,{size:13})," ",t("amxv.menu.openWithSystem")]})]}):En(R.path)?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{_s(R.path),W(null)},children:[e.jsx(xt,{size:13})," ",t("amxv.menu.open")]}),e.jsxs("button",{onClick:()=>{te.openVaultFile(R.path).catch(()=>{}),W(null)},children:[e.jsx(It,{size:13})," ",t("amxv.menu.openWithSystem")]})]}):Nt(R.path)?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{Ws(R.path),W(null)},children:[e.jsx(xt,{size:13})," ",t("amxv.menu.openDrawing")]}),e.jsxs("button",{onClick:()=>{te.openVaultFile(R.path).catch(()=>{}),W(null)},children:[e.jsx(It,{size:13})," ",t("amxv.menu.openWithSystem")]})]}):pt(V,R.path)?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{Jn(R.path),W(null)},children:[e.jsx(xt,{size:13})," ",t("amxv.menu.open")]}),e.jsxs("button",{onClick:()=>{te.openVaultFile(R.path).catch(()=>{}),W(null)},children:[e.jsx(It,{size:13})," ",t("amxv.menu.openWithSystem")]})]}):e.jsxs("button",{onClick:()=>{te.openVaultFile(R.path).catch(()=>{}),W(null)},children:[e.jsx(xt,{size:13})," ",t("amxv.menu.open")]}),un()&&e.jsxs("button",{onClick:()=>{te.revealInFileManager(R.path),W(null)},children:[e.jsx(gt,{size:13})," ",t("amxv.menu.reveal")]}),e.jsxs("button",{className:"danger",onClick:()=>{const a=R.path;W(null),Mn("file",a)&&je().deletePage(a)},children:[e.jsx(Ye,{size:13})," ",t("amxv.menu.delete")]})]}),R?.kind==="folder"&&e.jsxs(Tt,{className:"ctx-menu",x:R.x,y:R.y,onClick:a=>a.stopPropagation(),children:[e.jsxs("button",{onClick:()=>{p(a=>new Set([...a,...mt(R.path)])),je().createPageInFolder(R.path),W(null)},children:[e.jsx(Lt,{size:13})," ",t("amadeus.new.note")]}),e.jsxs("button",{onClick:()=>nn(R.path),children:[e.jsx(ra,{size:13})," ",t("amxv.menu.newSubfolder")]}),e.jsxs("button",{onClick:()=>bn(R.path),children:[e.jsx(jn,{size:13})," ",t("amadeus.new.database")]}),e.jsxs("button",{onClick:()=>St(R.path),children:[e.jsx(on,{size:13})," ",t("amadeus.new.drawing")]}),e.jsxs("button",{onClick:()=>yn(R.path),children:[e.jsx(Cn,{size:13})," ",t("amadeus.new.dashboard")]}),J.map(a=>e.jsxs("button",{onClick:()=>Q(R.path,a.item.label,a.item.run),children:[e.jsx("span",{style:{display:"inline-flex",width:13,justifyContent:"center",fontSize:13},children:Zn(a.item.icon,"📄")})," ",a.item.label]},a.item.id)),e.jsxs("button",{onClick:()=>{const a=R.path;W(null),ot(t("amxv.renameFolder"),Tn(a)).then(w=>{const x=w?.trim();x&&je().renameFolder(a,x)})},children:[e.jsx(cn,{size:13})," ",t("amxv.menu.rename")]}),un()&&e.jsxs("button",{onClick:()=>{te.revealInFileManager(R.path),W(null)},children:[e.jsx(gt,{size:13})," ",t("amxv.menu.reveal")]}),window.amadeusSync?.entrySyncEnable&&u==="local"&&(xn(r,R.path)?e.jsxs("button",{onClick:()=>{const a=R.path;W(null),window.amadeusSync.entrySyncDisable(a)},children:[e.jsx(vs,{size:13})," ",t("amxv.menu.cloudSyncOff")]}):e.jsxs("button",{onClick:()=>{const a=R.path;W(null),Dt(a,"folder")},children:[e.jsx(Gt,{size:13})," ",t("amxv.menu.cloudSyncOn")]})),window.amadeusCollab&&e.jsxs("button",{onClick:()=>{const a=R.path;W(null);const w=Ds(oe,r,u,a);if(!w){Dt(a,"folder");return}window.amadeusCollab.createPublish("subtree",w).then(x=>navigator.clipboard.writeText(x.url).then(()=>Ve.getState().toast(t("amxv.publish.done")))).catch(x=>Ve.getState().toast(x?.code==="QUOTA"?x.message||t("amxv.publish.quota"):x?.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=R.path;W(null),Mn("folder",a)&&je().deleteFolder(a)},children:[e.jsx(Ye,{size:13})," ",t("amxv.menu.delete")]})]}),g&&C&&e.jsx(Tt,{className:"ctx-menu",x:g.x,y:g.y,onClick:a=>a.stopPropagation(),children:e.jsx(el,{items:d()})}),b&&e.jsx(yc,{onClose:()=>O(!1)})]})}function vi(t){return t.map(n=>n.kind==="choice"?{id:`page-${n.id}`,icon:e.jsx(ai,{size:16}),label:n.label,run:()=>{},choices:n.options}:{id:`page-${n.id}`,icon:n.id==="wide"?e.jsx(ei,{size:16}):e.jsx(ii,{size:16}),label:n.label,checked:n.on,run:n.run})}function Kc(){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 Gc({height:t,onClose:n}){const s=Fr(),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:()=>{ti()?.(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 wi({actions:t,onUpload:n,undo:s,redo:i,indent:l,sourceMode:o,onNeedFocus:r,canvas:u}){const{t:f}=he(),{lift:h,kbHeight:j}=Kc(),[m,y]=c.useState(!1),[p,b]=c.useState(0);qs(m,()=>y(!1)),qs(p>0,()=>b(0));const O=c.useRef(null),E=N=>N.preventDefault(),G=O.current?ho(O.current):1,k=p?Math.round(p/G):0,$=k||Math.round(h/G),F=()=>{ti()||r();const N=j();document.activeElement?.blur?.(),b(N)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:O,className:"amx-mbar",style:$?{transform:`translateY(-${$}px)`}:void 0,children:[!o&&e.jsx("button",{onPointerDown:E,onClick:()=>p?b(0):F(),className:p?"on":void 0,title:f("amxv.mbar.insertBlock"),children:e.jsx(Et,{size:19})}),!o&&e.jsx("button",{onPointerDown:E,onClick:n,title:f("amxv.uploadToPage"),children:e.jsx(gs,{size:19})}),!o&&u&&e.jsx("button",{onPointerDown:E,onClick:u.toggle,className:u.on?"on":void 0,title:u.on?f("amxv.mbar.toDocument"):f("amxv.mbar.toCanvas"),children:e.jsx(ll,{size:19})}),!o&&l&&e.jsx("button",{onPointerDown:E,onClick:()=>l(-1),title:f("amxv.mbar.outdent"),children:e.jsx(yl,{size:19})}),!o&&l&&e.jsx("button",{onPointerDown:E,onClick:()=>l(1),title:f("amxv.mbar.indent"),children:e.jsx(kl,{size:19})}),!o&&e.jsx("button",{onPointerDown:E,onClick:s,title:f("amxv.mbar.undo"),children:e.jsx(cl,{size:19})}),!o&&e.jsx("button",{onPointerDown:E,onClick:i,title:f("amxv.mbar.redo"),children:e.jsx(dl,{size:19})}),e.jsx("button",{onPointerDown:E,onClick:()=>y(!0),title:f("amxv.moreActions"),children:e.jsx(Xt,{size:19})}),e.jsx("button",{onClick:()=>{b(0),document.activeElement?.blur?.()},title:f("amxv.mbar.hideKeyboard"),children:e.jsx(kr,{size:19})})]}),k>0&&e.jsx(Gc,{height:k,onClose:()=>b(0)}),m&&e.jsx("div",{className:"mb-sheet-scrim",onClick:()=>y(!1),children:e.jsxs("div",{className:"mb-sheet",onClick:N=>N.stopPropagation(),style:{paddingBottom:"env(safe-area-inset-bottom)"},children:[e.jsx("div",{className:"mb-sheet-grip"}),t.map(N=>N.choices?e.jsxs("div",{className:"mb-sheet-row amx-sheet-choice",role:"group","aria-label":N.label,"data-action":N.id,children:[N.icon,e.jsx("span",{children:N.label}),e.jsx("span",{className:"amx-sheet-seg",children:N.choices.map(z=>e.jsx("button",{type:"button",role:"radio","aria-checked":z.on,"data-font":z.id,className:z.on?"on":void 0,onClick:z.run,children:z.label},z.id))})]},N.id):e.jsxs("button",{className:`mb-sheet-row${N.danger?" danger":""}${N.on?" on":""}`,role:N.checked!==void 0?"switch":void 0,"aria-checked":N.checked,"data-action":N.id,onClick:()=>{N.checked===void 0&&y(!1),N.run()},children:[N.icon,e.jsx("span",{children:N.label}),N.checked&&e.jsx(vt,{size:16,className:"amx-sheet-check"})]},N.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 Yc(t,n){const[,s]=c.useState(0);return c.useEffect(()=>Eo(()=>s(i=>i+1)),[]),!!n&&Do(t,n)}function Xc({children:t,dragging:n,rootRef:s,onDrop:i,onDragOver:l,onDragLeave:o,onClick:r,onPaste:u,pageAttrs:f}){const h=Ya(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 Jc({params:t,size:n}){const s=typeof t.notePath=="string"?t.notePath:"",i=L(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(Yt,{size:n,className:"wb-tab-ic"})}function bi(){const{t}=he(),n=Ft(),s=()=>n.getState(),i=L(k=>k.activePage),l=L(k=>k.manifest),o=L(k=>i?k.icons[i]??null:null),r=i?Ua(i):void 0,u=r&&i?Bt(i,r.extensions):l?.title||(i?ye(i):""),f=Br.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(!mo(i))return;const k=p.current;if(!k)return;k.focus();const $=k.value.length;k.setSelectionRange($,$)},[i]);const b=()=>{const k=h.trim();k&&k!==u?s().renamePage(k):j(f)},O=Mr(),[E,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:k=>{const $=k.currentTarget.getBoundingClientRect();y({x:$.left,y:$.bottom+6})},children:o}),i&&(!o||!O)&&e.jsxs("div",{className:"amx-title-actions",children:[!o&&e.jsxs("button",{onClick:()=>{s().setPageIcon(i,Or())},children:[e.jsx($r,{size:14,strokeWidth:1.7,"aria-hidden":"true"}),t("amxv.title.addIcon")]}),!O&&e.jsxs("button",{onClick:k=>{const $=k.currentTarget.getBoundingClientRect();G({x:$.right,y:$.bottom+6})},children:[e.jsx(po,{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:k=>j(k.target.value),onBlur:b,onKeyDown:k=>{const $=k.currentTarget,F=$.selectionStart===$.value.length&&$.selectionEnd===$.value.length;(k.key==="Enter"||(k.key==="ArrowRight"||k.key==="ArrowDown")&&F)&&(k.preventDefault(),Vn(n),$.blur()),k.key==="Escape"&&(j(f),$.blur())}})}),m&&i&&e.jsx(Ir,{x:m.x,y:m.y,current:o,onPick:k=>{s().setPageIcon(i,k),y(null)},onClose:()=>y(null)}),E&&i&&e.jsx(Lr,{page:i,x:E.x,y:E.y,onClose:()=>G(null)})]})}function Zc(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 Qc(){const t=Ft(),n=Ia(),s=()=>t.getState(),i=()=>{const m=s().manifest;if(!m)return"";const y={};for(const[p,b]of Object.entries(s().blocks))y[p]=b.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=La(n);if(m&&y){const p=Fo(f.current,y);if(p>=0){m.focus(),m.setSelectionRange(p,p),h.current=p;const b=f.current.slice(0,p).split(`
9
- `).length-1,O=parseFloat(getComputedStyle(m).lineHeight)||20,E=Zc(m);E&&(E.scrollTop=Math.max(0,m.offsetTop+b*O-E.clientHeight/2))}}return()=>Ro(Mo(f.current,h.current),n)},[]);const j=()=>{const m=s().activePage;if(!m||l===i())return;const y=Li(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 ed(t){return e.jsx(Ps.Provider,{value:t.leaf.id,children:e.jsx(td,{...t})})}function td({leaf:t}){const{t:n}=he(),s=Ft(),i=()=>s.getState(),l=L(v=>v.activePage),o=L(v=>v.vaultRoot),r=L(v=>v.pendingPage),u=L(v=>v.error),f=hs(v=>v.fileTypes),h=kn(v=>fo(v,t.id)),[j,m]=c.useState(!1);c.useEffect(()=>{if(!j)return;const v=()=>m(!1);return window.addEventListener("dragend",v),window.addEventListener("drop",v),()=>{window.removeEventListener("dragend",v),window.removeEventListener("drop",v)}},[j]);const[y,p]=c.useState(null),[b,O]=c.useState(null),[E,G]=c.useState(null),k=c.useRef(null),$=c.useRef(null),F=c.useRef(null),[N,z]=c.useState(null),[M,D]=c.useState(0),H=c.useRef(null),Z=c.useRef(null),ce=Pe(v=>v.starred),q=Pe(v=>v.pins),re=L(v=>v.vaultSide);Oe(v=>v.vaults),c.useEffect(()=>{oi()},[]);const we=!!window.amadeusSync?.entrySyncEnable&&re==="local";c.useEffect(()=>{if(!y)return;const v=()=>p(null);return window.addEventListener("click",v),window.addEventListener("contextmenu",v),()=>{window.removeEventListener("click",v),window.removeEventListener("contextmenu",v)}},[y]);const Re=async()=>{const v=i().activePage??oe,V=H.current;if(!v||!V)return;const J=document.createElement("div");J.id="amx-print-root";const Q=ac(V);Q.setAttribute("data-mode","light"),J.appendChild(Q),document.body.appendChild(J);try{const Ce=await te.exportPdf(ye(v));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()}},xe=async()=>{if(oe)try{const v=await Vl(oe);if(v==null)throw new Error(oe);await navigator.clipboard.writeText(v),Ve.getState().toast(n("amxv.copyMd.done"))}catch(v){Ve.getState().toast(n("amxv.copyFailed",{e:v instanceof Error?v.message:String(v)}),!0)}},X=$e(v=>v.mainTabs.find(V=>V.id===t.id)?.active??!1),pe=$e(v=>{if(!v.api)return!1;const V=Cs(v.api),J=v.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=xo(),S=typeof t.params.notePath=="string"?t.params.notePath:null,ie=c.useRef(!1),[ne,ge]=c.useState(null),[ke,qe]=c.useState(0),P=c.useRef(null),A=L(v=>S?v.pages.includes(S):!1),U=L(v=>$l(S,v)),Y=U==="plugin";c.useEffect(()=>{if(U!=="pending")return;const v=setInterval(()=>{L.getState().refreshStructure().catch(()=>{})},3e3);return()=>clearInterval(v)},[U]),c.useEffect(()=>{if(!S){ge(null);return}if(Y){ln(S),P.current=null,ge(null);return}const v=P.current;if(U==="pending"){v&&v.path===S&&ln(S),P.current=null,ge(null);return}if(v&&v.path===S&&(v.root===o||v.root===null))return;v&&v.path===S&&ln(S);let V=!0;return(async()=>{let J=await te.readTextFile(S).catch(()=>null);for(let Ce=0;J==null&&!i().vaultRoot&&Ce<30;Ce++){if(await new Promise(Fe=>setTimeout(Fe,100)),!V)return;J=await te.readTextFile(S).catch(()=>null)}if(!V)return;const Q=sa(S,J,ws(),new Date().toISOString());if(Q.editor==="missing"&&i().pages.includes(S)){P.current=null,ge({forPath:S,decision:Q,root:i().vaultRoot,unreadable:!0});return}Q.editor==="missing"?(ln(S),P.current=null):P.current={path:S,root:i().vaultRoot},ge({forPath:S,decision:Q,root:i().vaultRoot})})(),()=>{V=!1}},[S,o,A,ke,U]);const fe=U==="note"&&ne&&ne.forPath===S?ne.decision:null,se=fe?.editor==="unified"?fe:null,R=!!S&&!!ne?.unreadable&&ne.forPath===S,W=fe?.editor==="missing"&&!!S&&!R,Xe=ne&&ne.forPath===S?ne.root??"":"",Je=Yc(o,S),[_e,dt]=c.useState({path:S,on:Je}),[Ze,wt]=c.useState(0),Te=_e.path===S?_e.on:Je;c.useEffect(()=>{if(_e.path!==S){dt({path:S,on:Je});return}if(_e.on===Je||!S)return;let v=!0;return(async()=>{const V=await Fs(S);if(!v)return;if(!V.ok){ci(S,Je,V.reason,()=>wt(Q=>Q+1));return}const J=sa(S,V.raw,ws(),new Date().toISOString());J.editor==="unified"&&ge(Q=>Q&&Q.forPath===S?{...Q,decision:J}:Q),dt({path:S,on:Je})})(),()=>{v=!1}},[Je,_e,S,Ze]);const Ie=()=>{S&&di(o,S,!Te)},He=ql(o,se?S:null),at=se&&S?Wl(He,v=>Ul(o,S,v),n):[],We=!se&&!W&&!R&&!Y&&(!!r&&r!==l||!!S&&!u&&S!==l),oe=l??(se&&S?S:null),ut=!!oe&&ce.includes(oe),Ee=!!oe&&q.includes(oe),Le=we&&!!oe&&xn(i().vaultRoot,oe);c.useEffect(()=>{if(!se||!S)return;const v=i().activePage;i().releasePage(v??S)},[se,S]),c.useEffect(()=>{S&&t.setTitle(ye(S))},[S]),c.useEffect(()=>{if(go!=="mobile"||S)return;const v=()=>{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(v())return;const V=s.subscribe(J=>{J.vaultRoot&&v()&&V()});return V},[S]),c.useEffect(()=>{i().setActiveNotePath(S)},[S]),c.useEffect(()=>{!se||!S||(Ha(t.id,`amadeus:${S}`,()=>{const v=$e.getState(),V=v.leafById(t.id);V&&v.navigateLeaf(t.id,"amadeus-editor",{...V.params,notePath:S})}),qn.getState().record({key:`note:${S}`,kind:"note",id:S,title:ye(S)}))},[se,S]),c.useEffect(()=>{if(S)return vo((v,V,J)=>{const Q=et=>V==="file"?et===v:et===v||et.startsWith(`${v}/`);if(!Q(S))return;if(J){t.setParams({...t.params,notePath:V==="file"?J:J+S.slice(v.length)});return}const Ce=i(),Fe=Ce.activePage;t.setParams({...t.params,notePath:(Fe&&!Q(Fe)?Fe:Ce.pages.find(et=>!Q(et)))??void 0})})},[S]),c.useEffect(()=>{if(!S)return;const v=i().vaultRoot;if(v)try{localStorage.setItem(`amx.lastNote:${v}`,S)}catch{}},[S]),c.useEffect(()=>{S&&fe?.editor==="block"&&S!==i().activePage&&i().loadPage(S)},[S,fe]),c.useEffect(()=>{X&&Ht(t.id),ie.current=X},[X,t.id]),c.useEffect(()=>{pe&&ue===wo&&o&&Ht(t.id)},[pe,ue,o,t.id]),c.useEffect(()=>{!l||l===S||pt(f,l)||qt(l)||(t.setParams({...t.params,notePath:l}),t.setTitle(ye(l)))},[l]),c.useEffect(()=>()=>Ga(t.id),[t.id]);const Ke=async v=>{m(!1);const V=Rl(v.dataTransfer);if(V.length){if(v.preventDefault(),se&&S){const Fe=V.join(`
10
-
11
- `);if(F.current?F.current(Fe):Oi(S,Fe,"cursor"))return}const Ce=i();if(!Ce.activePage)return;Ce.insertBlocksAfter(null,V);return}const J=Array.from(v.dataTransfer?.files??[]);if(!J.length||(v.preventDefault(),se&&S&&($.current?$.current(J):ds(S,J))))return;const Q=i().activePage;Q&&await An(J,Q)},Qe=v=>{const V=Array.from(v.dataTransfer?.types??[]),J=V.includes(Xa);!V.includes("Files")&&!J||(v.preventDefault(),J&&v.dataTransfer&&(v.dataTransfer.dropEffect="copy"),j||m(!0))},yt=v=>{v.currentTarget.contains(v.relatedTarget)||m(!1)},it=v=>{const V=v.target.closest("a");if(!V||V.classList.contains("wikilink"))return;const J=V.getAttribute("href")||"";if(!J||Rr(J)!=="file")return;v.preventDefault();const Q=i().activePage??oe;Q&&te.openAttachment(Q,J)},ht=v=>{if(v.defaultPrevented||v.target.closest("input, textarea, .t2s-rename"))return;const V=Array.from(v.clipboardData?.items??[]).filter(Q=>Q.kind==="file"&&Q.type.startsWith("image/")).map(Q=>Q.getAsFile()).filter(Q=>!!Q);if(!V.length)return;v.preventDefault();const J=i().activePage;J&&sc(V,J)};return e.jsxs(e.Fragment,{children:[e.jsxs(Xc,{rootRef:H,pageAttrs:se?Hl(He):void 0,dragging:j,onDrop:v=>{Ke(v)},onDragOver:Qe,onDragLeave:yt,onClick:it,onPaste:ht,children:[oe&&h!=="source"&&!E?.on&&!t.params.miniSurface&&!Qn()&&e.jsx(Xl,{host:H,label:n("amxv.floatingToc"),scanTrigger:oe}),e.jsx("input",{ref:Z,type:"file",multiple:!0,style:{display:"none"},onChange:v=>{const V=Array.from(v.currentTarget.files??[]);if(v.currentTarget.value="",!V.length||se&&S&&($.current?$.current(V):ds(S,V)))return;const J=i().activePage;J&&An(V,J)}}),oe&&!Qn()&&!t.params.miniSurface&&e.jsxs("div",{className:"amx-toolbar",children:[e.jsx(Os,{path:oe,hideLoneLeaf:!!se}),e.jsx("span",{className:Sr}),window.amadeusCollab&&e.jsx(Tc,{path:oe,refreshKey:M,onOpen:(v,V)=>z({x:v,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(fs,{size:14})}),we&&e.jsx("button",{className:`amx-mode-btn amx-pin-btn${Le?" amx-pin-on":""}`,title:n(Le?"amxv.cloud.disableTip":"amxv.menu.cloudSyncOn"),onClick:()=>{Le?window.amadeusSync?.entrySyncDisable?.(oe):Dt(oe,"page")},children:e.jsx(Gt,{size:14})}),window.amadeusCollab&&e.jsx(jc,{}),window.amadeusCollab&&e.jsx("button",{className:"amx-mode-btn",title:n("amxv.shareOrPublish"),onClick:v=>{v.stopPropagation();const V=v.currentTarget.getBoundingClientRect();z({x:V.right,y:V.bottom})},children:e.jsx(In,{size:14})}),h==="source"&&e.jsx("button",{className:"amx-mode-btn",onClick:()=>kn.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:v=>{v.stopPropagation();const V=v.currentTarget.getBoundingClientRect();p({x:Math.max(8,Math.min(V.right-180,window.innerWidth-196)),y:V.bottom+4})},children:e.jsx(Xt,{size:14})})]}),y&&oe&&e.jsxs(Tt,{className:"ctx-menu",x:y.x,y:y.y,onClick:v=>v.stopPropagation(),children:[at.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Gl,{entries:at}),e.jsx("div",{className:"ctx-separator"})]}),e.jsxs("button",{"data-note-mode":!0,onClick:()=>{p(null),kn.getState().toggleEditorMode(t.id)},children:[h==="source"?e.jsx(xt,{size:13}):e.jsx(os,{size:13})," ",n(h==="source"?"amxv.toVisual":"amxv.toSource")]}),pa(oe,Te,!!se&&h==="source")&&e.jsxs("button",{"data-note-upload":!0,onClick:()=>{p(null),Z.current?.click()},children:[e.jsx(gs,{size:13})," ",n("amxv.uploadToPage")]}),se&&e.jsxs("button",{onClick:()=>{p(null),xe()},children:[e.jsx(Wt,{size:13})," ",n("amxv.menu.copyMd")]}),Us()&&e.jsxs("button",{onClick:()=>{p(null),Re()},children:[e.jsx(zn,{size:13})," ",n("amxv.menu.exportPdf")]}),E?.on&&E.exportCanvas&&e.jsxs("button",{onClick:()=>{const v=E.exportCanvas;p(null),v?.()},children:[e.jsx(zn,{size:13})," ",n("amxv.menu.exportCanvas")]}),e.jsxs("button",{onClick:()=>{Pe.getState().toggleStar(oe),p(null)},children:[e.jsx(On,{size:13})," ",n(ut?"amxv.menu.unstar":"amxv.menu.star")]}),un()&&e.jsxs("button",{onClick:()=>{te.revealInFileManager(oe),p(null)},children:[e.jsx(gt,{size:13})," ",n("amxv.menu.reveal")]}),se&&e.jsxs("button",{onClick:()=>{p(null),Ie()},children:[e.jsx(la,{size:13})," ",n(Te?"amxv.menu.unlockPage":"amxv.menu.lockPage")]}),se&&Hs()&&e.jsxs("button",{"data-page-history":!0,onClick:()=>{p(null),O(oe)},children:[e.jsx(Ks,{size:13})," ",n("pghist.menu")]}),e.jsxs("button",{className:"danger",onClick:()=>{const v=oe;p(null),pn(v,i)},children:[e.jsx(Ye,{size:13})," ",n("amxv.menu.deleteNote")]})]}),b&&e.jsx(Bl,{path:b,locked:b===S&&Te,onClose:()=>O(null)}),N&&oe&&e.jsx(Nc,{path:oe,anchor:N,onClose:()=>{z(null),D(v=>v+1)}}),Y&&S?e.jsxs("div",{className:"amx-welcome","data-plugin-owned-file":S,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:S})}),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&&S?e.jsx(Nr,{compact:!!t.params.miniSurface,readOnly:Te,onUnlock:Te?Ie:void 0,path:S,initial:se.initial,diskRaw:se.diskRaw,onCanvasMode:G,historyRef:k,filesRef:$,mdRef:F,onRenamed:v=>{t.setParams({...t.params,notePath:v}),t.setTitle(ye(v)),fi(S,v)}},`${Xe}\0${S}${Te?"\0locked":""}`):R&&S?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:S}),e.jsx("div",{className:"amx-welcome-actions",children:e.jsx("button",{className:"amx-welcome-btn",onClick:()=>qe(v=>v+1),children:n("amxv.retry")})})]}):W&&S?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:S})}),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(Ka,{variant:"document"}):l?h==="source"?e.jsx(Qc,{},l):e.jsxs(e.Fragment,{children:[e.jsx(Ar,{}),e.jsxs("div",{className:"amx-doc",children:[e.jsx(bi,{}),e.jsx(zr,{})]}),e.jsx(bc,{bare:!0})]}):S&&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:()=>{S&&i().loadPage(S)},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(Lt,{size:16})," ",n("amadeus.new.note")]}),e.jsxs("button",{className:"amx-welcome-btn ghost",onClick:()=>{bo()},children:[e.jsx(si,{size:16})," ",n("amxv.welcome.tutorial")]}),e.jsxs("button",{className:"amx-welcome-btn ghost",onClick:()=>{yo()},children:[e.jsx(ml,{size:16})," ",n("amxv.welcome.manual")]})]}):e.jsxs("button",{className:"amx-welcome-btn",onClick:()=>{i().openVault()},children:[e.jsx(gt,{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(fn,{size:13})," ",n("amxv.welcome.tip2")]}),e.jsxs("li",{children:[e.jsx(os,{size:13})," ",n("amxv.welcome.tip3")]})]})]})]}),Qn()&&oe&&!We&&e.jsx(wi,{sourceMode:h==="source",canvas:E,onUpload:()=>Z.current?.click(),undo:()=>{k.current?k.current.undo():l&&i().undo()},redo:()=>{k.current?k.current.redo():l&&i().redo()},indent:E?v=>{k.current?.indent?.(v)}:null,onNeedFocus:()=>{l&&Vn(s)},actions:[{id:"mode",icon:h==="source"?e.jsx(xt,{size:16}):e.jsx(os,{size:16}),label:n(h==="source"?"amxv.toVisual":"amxv.toSource"),run:()=>kn.getState().toggleEditorMode(t.id)},...pa(oe,Te,!!se&&h==="source")?[{id:"upload",icon:e.jsx(gs,{size:16}),label:n("amxv.uploadToPage"),run:()=>Z.current?.click()}]:[],...se?[{id:"lock",icon:e.jsx(la,{size:16}),label:n(Te?"amxv.menu.unlockPage":"amxv.menu.lockPage"),on:Te,run:Ie}]:[],...se&&Hs()?[{id:"history",icon:e.jsx(Ks,{size:16}),label:n("pghist.menu"),run:()=>O(oe)}]:[],...vi(at),{id:"pin",icon:e.jsx(fs,{size:16}),label:n(Ee?"amxv.unpin":"amxv.pin"),on:Ee,run:()=>Pe.getState().togglePin(oe)},{id:"star",icon:e.jsx(On,{size:16}),label:n(ut?"amxv.menu.unstar":"amxv.menu.star"),on:ut,run:()=>Pe.getState().toggleStar(oe)},...we?[{id:"sync",icon:e.jsx(Gt,{size:16}),label:n(Le?"amxv.cloud.disableTip":"amxv.menu.cloudSyncOn"),on:Le,run:()=>{Le?window.amadeusSync?.entrySyncDisable?.(oe):Dt(oe,"page")}}]:[],...window.amadeusCollab?[{id:"share",icon:e.jsx(In,{size:16}),label:n("amxv.shareOrPublish"),run:()=>z({x:window.innerWidth/2,y:window.innerHeight/2})}]:[],...se?[{id:"copymd",icon:e.jsx(Wt,{size:16}),label:n("amxv.menu.copyMd"),run:()=>{xe()}}]:[],...Us()?[{id:"pdf",icon:e.jsx(zn,{size:16}),label:n("amxv.menu.exportPdf"),run:()=>{Re()}}]:[],...E?.on&&E.exportCanvas?[{id:"canvas-export",icon:e.jsx(zn,{size:16}),label:n("amxv.menu.exportCanvas"),run:()=>E.exportCanvas?.()}]:[],...un()?[{id:"reveal",icon:e.jsx(gt,{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:()=>{pn(oe,i)}}]})]})}function yi(){const{t}=he(),n=io();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 nd({path:t,scope:n}){return e.jsx(Ps.Provider,{value:n,children:e.jsx(sd,{path:t,scope:n})})}function sd({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(()=>()=>Ga(n),[n]),t?e.jsx(yi,{}):e.jsx("div",{className:"amx-panel",children:e.jsx("div",{className:"amx-panel-empty",children:s("amxv.outline.noNote")})})}const lu=Object.freeze(Object.defineProperty({__proto__:null,AmadeusBacklinksView:$c,AmadeusEditorView:ed,AmadeusOutlineView:yi,AmadeusPagesView:Hc,AmxMobileBar:wi,Breadcrumb:Os,NoteTabIcon:Jc,NoteTitle:bi,ScopedPageOutline:nd,pageStyleSheetActions:vi},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 Ue=({children:t})=>e.jsx("div",{className:"dash-widget",children:e.jsx("div",{className:"dash-widget-note",children:t})});function ji(t){const n=Kt(s=>s.gen);return c.useEffect(()=>{t&&Kt.getState().load(t,t)},[t,n]),Kt(s=>t?s.entries[t]:void 0)}function ki(){const[t,n]=c.useState(Ys),[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(Ys()),i(u=>u+1)},Math.max(o-l.getTime()+1e3,1e3));return()=>clearTimeout(r)},[t,s]),t}function Si(t){const n=new Map(t.map(s=>[s.id,Ja(s.type)]));return s=>n.get(s)??null}function ad({opts:t,filters:n}){const{t:s}=he(),i=c.useMemo(()=>Bo(t),[JSON.stringify(t)]),l=i.ok?i.spec.source:"",o=ji(l);if(!i.ok)return e.jsx(Ue,{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(id,{spec:i.spec,entry:o,filters:n})}function id({spec:t,entry:n,filters:s}){const{t:i}=he(),l=ki(),o=c.useMemo(()=>{if(!n?.data)return null;const u=Si(n.data.columns);return _o(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(Ue,{children:i("dashcards.loading")});if(n.status==="missing")return e.jsx(Ue,{children:i("dashcards.missing",{source:t.source})});if(n.status==="corrupt")return e.jsx(Ue,{children:i("dashcards.corrupt",{source:t.source,err:n.message})});if(!o)return e.jsx(Ue,{children:i("dashcards.noData")});if(o.error)return e.jsx(Ue,{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 od({opts:t,filters:n}){const{t:s}=he(),i=c.useMemo(()=>Vo(t),[JSON.stringify(t)]),l=i.ok?i.spec.source:"",o=ji(l);return i.ok?e.jsx(rd,{spec:i.spec,entry:o,filters:n}):e.jsx(Ue,{children:s("dashcards.chartError",{err:i.error})})}function rd({spec:t,entry:n,filters:s}){const{t:i}=he(),l=ki(),o=c.useMemo(()=>{if(!n?.data)return null;const f=Si(n.data.columns);return Wo(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(Ue,{children:i("dashcards.loading")});if(n.status==="missing")return e.jsx(Ue,{children:i("dashcards.missing",{source:t.source})});if(n.status==="corrupt")return e.jsx(Ue,{children:i("dashcards.corrupt",{source:t.source,err:n.message})});if(!o)return e.jsx(Ue,{children:i("dashcards.noData")});if(o.error)return e.jsx(Ue,{children:i("dashcards.chartError",{err:o.error})});if(!o.slices.length)return e.jsx(Ue,{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(Uo,{slices:o.slices}):e.jsx(Ho,{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 za({widget:t,filters:n=[]}){return t.kind==="clock"?e.jsx(cd,{opts:t.opts}):t.kind==="weather"?e.jsx(md,{opts:t.opts}):t.kind==="webview"?e.jsx(pd,{opts:t.opts}):t.kind==="section"?e.jsx(ld,{opts:t.opts}):t.kind==="stat"?e.jsx(ad,{opts:t.opts,filters:n}):t.kind==="chart"?e.jsx(od,{opts:t.opts,filters:n}):null}function ld({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 Ni(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function cd({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||Ni();let r,u,f=!1;try{({time:r,date:u}=Xs(i,{locale:s,timeZone:o}))}catch{f=!0,{time:r,date:u}=Xs(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 dd(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 ud(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 hd=900*1e3;function md({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=()=>{ud(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,hd);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=dd(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 pd({opts:t}){const{t:n}=he(),s=t.url||"",i=c.useRef(null);return s?Za(s)?window.tangu?e.jsx(Ko,{ref:i,src:s,partition:Go,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 fd({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(()=>Yo(()=>h(G=>G+1)),[]);const j=c.useRef(o);j.current=o;const m=JSON.stringify(i),y=c.useMemo(()=>{const{type:G,...k}=JSON.parse(m);return k},[m]),p=c.useMemo(()=>({id:`${t}::${s}`,type:f,loc:"main",params:y,setTitle:()=>{},setParams:G=>{const k=r.getState();if(k.activePage!==n)return;const $={type:f};for(const[N,z]of Object.entries(G))N!=="type"&&(typeof z=="string"||typeof z=="number"||typeof z=="boolean")&&($[N]=String(z));const F=ze("view",$);(k.blocks[s]?.content??"").trim()!==F&&k.setBlockContent(s,F)},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 b=hn(f);if(!b)return e.jsx("div",{className:"dash-widget",children:e.jsx("div",{className:"dash-widget-note",children:u("viewcard.unavailable",{type:f})})});const O=l??b.dashboard?.defaultSize??"lg",E=b.dashboard?.factory?b.dashboard.factory({leaf:p,params:y},{size:O}):b.factory({leaf:p,params:y});return e.jsx("div",{className:`wb-view dash-viewcard${b.dashboard?.factory?" dash-viewcard--compact":" dash-viewcard--interactive"}`,"data-view-type":f,onPointerDownCapture:()=>{f==="amadeus-editor"&&Ht(p.id)},children:E})}const Ca=new Set(["chat","browser","terminal","dashboard","amadeus-dashboard","sidebar-empty","home"]);function xd(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 gd(t){const n=Kt.getState();await n.load(t,t);const s=Kt.getState().entries[t]?.data;if(!s)return null;const i=Bs(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:Ai(),name:r,type:"chart"};return n.mutate(t,f=>({...f,views:[...Bs(f),u]})),r}function vd(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 wd(){const t=Kt(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:Ja(i.type),options:i.options??[]});return[...n.values()].sort((s,i)=>s.name.localeCompare(i.name))},[t])}function bd({filters:t,editable:n,onChange:s}){const i=wd(),[l,o]=c.useState(!1),[r,u]=c.useState(null),f=Rn(l),{t:h}=he();if(!t.length&&!n)return null;const j=()=>{const b=i[0];b&&(u({prop:b.name,op:ts[b.kind]?.[0]??"eq",value:""}),o(!0))},m=r?i.find(b=>b.name===r.prop):null,y=m?ts[m.kind]??["eq"]:["eq"],p=()=>{if(!r)return;const b=Zs.has(r.op);!b&&!r.value.trim()||(s([...t,{prop:r.prop,op:r.op,...b?{}:{value:r.value.trim()}}]),u(null),o(!1))};return e.jsxs("div",{className:"dash-filterbar",children:[e.jsx(Xo,{size:12,className:"dash-filterbar-label"}),e.jsx("span",{className:"dash-filterbar-label",children:h("dashfilter.label")}),t.map((b,O)=>e.jsxs("span",{className:"dash-filter-chip",children:[e.jsx("b",{children:b.prop}),e.jsx("span",{children:Js[b.op]??b.op}),b.value!==void 0&&e.jsx("span",{children:b.value}),n&&e.jsx("button",{title:h("dashfilter.remove"),onClick:()=>s(t.filter((E,G)=>G!==O)),children:e.jsx(Ns,{size:11})})]},`${b.prop}-${b.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(Et,{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:b=>{const O=i.find(E=>E.name===b.target.value);u({prop:b.target.value,op:(O&&ts[O.kind]?.[0])??"eq",value:""})},children:i.map(b=>e.jsx("option",{value:b.name,children:b.name},b.name))}),e.jsx("select",{value:r.op,onChange:b=>u({...r,op:b.target.value}),children:y.map(b=>e.jsx("option",{value:b,children:Js[b]??b},b))}),!Zs.has(r.op)&&(m?.options.length?e.jsxs("select",{value:r.value,onChange:b=>u({...r,value:b.target.value}),children:[e.jsx("option",{value:"",children:h("dashfilter.pickOne")}),m.options.map(b=>e.jsx("option",{value:b,children:b},b))]}):e.jsx("input",{value:r.value,placeholder:h("dashfilter.valuePlaceholder"),onChange:b=>u({...r,value:b.target.value}),onKeyDown:b=>{b.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 yd=[{key:"section",labelKey:"dashgrid.add.section",icon:vl},{key:"stat",labelKey:"dashgrid.add.stat",icon:ar},{key:"chart",labelKey:"dashgrid.add.chart",icon:ir},{key:"text",labelKey:"dashgrid.add.text",icon:ai},{key:"clock",labelKey:"dashgrid.add.clock",icon:ni},{key:"weather",labelKey:"dashgrid.add.weather",icon:xl},{key:"webview",labelKey:"dashgrid.add.webview",icon:At}],jd={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"},kd=[{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:[]}],rn=t=>t==="section",Is={w:4,h:3},zi={sizes:["lg","full"],defaultSize:"lg",surface:"workspace",min:Is},Pa={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"}},cs=t=>t.min??lr(t.sizes);function Ot(t){const n=Ct(t);if(n?.kind==="view"){const s=hn(n.opts.type??"")?.dashboard;return s?{sizes:s.sizes,defaultSize:s.defaultSize,surface:s.surface??"workspace",min:s.min??Is}:zi}return Pa[n?.kind??"text"]??Pa.text}const Dn=(t,n=0)=>{const s=ps(t);return{order:n,w:s.w,h:s.h}},Sd=()=>null;function Nd(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 zd=(t,n)=>cr(t,n)??n[0]??"lg",Cd=[],Pd={},Ta=(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 cu(t){return e.jsx(Ps.Provider,{value:t.leaf.id,children:e.jsx(Td,{...t})})}function Td({leaf:t}){const{t:n}=he(),s=Ft(),i=typeof t.params.dashPath=="string"?t.params.dashPath:"",l=t.params.locked!==!1,o=Ya(d=>d.mode),r=L(d=>d.manifest),u=L(d=>d.blocks),f=L(d=>d.activePage),h=L(d=>d.manifest?.fmExtra??""),j=Pe(d=>!!i&&d.pins.includes(i)),m=ol(),[y,p]=c.useState(!1),[b,O]=c.useState(null),[E,G]=c.useState(null),k=Rn(y),$=Rn(b?`${b.x},${b.y}`:""),F=Rn(E?`${E.x},${E.y}`:""),[N,z]=c.useState(!1);c.useEffect(()=>{i&&t.setTitle(ns(i))},[i]),c.useEffect(()=>{i&&i!==s.getState().activePage&&s.getState().loadPage(i)},[i]);const M=$e(d=>d.mainTabs.find(g=>g.id===t.id)?.active??!1);c.useEffect(()=>{M&&Ht(t.id)},[M,t.id]);const D=c.useMemo(()=>{if(!r)return[];const d=[];for(const g of r.root.children)for(const C of g.columns)for(const B of C.children)d.push(B.ref);return d},[r]),H=c.useMemo(()=>ss(h),[h]),Z=H.ok?H.layout:{},ce=H.ok&&Jo(Z,D),q=c.useMemo(()=>Qs(h),[h]),re=q.ok?q.pins:Pd,we=c.useMemo(()=>Zo(h),[h]),Re=we.ok?we.filters:Cd,xe=()=>{const d=s.getState();return d.activePage===i?d.loadNonce:null},X=(d,g)=>{const C=s.getState();if(C.activePage!==i||g!==void 0&&(g===null||C.loadNonce!==g))return!1;const B=C.manifest?.fmExtra??"";return d===null||d===B?!1:(C.setFmExtra(d),!0)},pe=(d,g)=>X(as(s.getState().manifest?.fmExtra??"",d),g),ue=()=>{const d=ss(s.getState().manifest?.fmExtra??"");return d.ok?d.layout:null};c.useEffect(()=>{if(!r||f!==i||!D.length||!H.ok||ce)return;const d=ea(Z,D),g=q.ok?Qo(re,D):null;if(!d&&!g)return;let C=s.getState().manifest?.fmExtra??"";d&&(C=as(C,d)??C),g&&(C=is(C,g)??C),X(C)},[D,Z,re,r,f,i,H.ok,q.ok,ce]);const S=c.useRef(null),ie=c.useRef(null),[ne,ge]=c.useState(0);c.useLayoutEffect(()=>{const d=ie.current;if(!d)return;const g=new ResizeObserver(([B])=>ge(B.contentRect.width));g.observe(d);const C=getComputedStyle(d);return ge(d.clientWidth-parseFloat(C.paddingLeft||"0")-parseFloat(C.paddingRight||"0")),()=>g.disconnect()},[]);const ke=er(ne),qe=ke>0?(ne-st*(ke-1))/ke:0,P=c.useMemo(()=>tr(Z,D),[Z,D]),[A,U]=c.useState(null),Y=c.useRef(new Map),fe=c.useRef(null),se=c.useRef(null),R=(d,g)=>{if(l||se.current)return;d.preventDefault(),d.stopPropagation();const C=Ot(u[g]?.content??""),B=cs(C),ae=Z[g]??Dn(C.defaultSize),ee=Y.current.get(g)??{...ae,w:Math.max(B.w,ae.w),h:Math.max(B.h,ae.h)};se.current={id:g,pointerId:d.pointerId,nonce:xe(),x:d.clientX,y:d.clientY,w:ee.w,h:ee.h},fe.current={id:g,w:ee.w,h:ee.h},U({id:g,w:ee.w,h:ee.h}),d.currentTarget.setPointerCapture(d.pointerId)},W=d=>{const g=se.current;if(!g||g.pointerId!==d.pointerId||qe<=0)return;const C=ur(g.w,ke),B=C*qe+(C-1)*st+(d.clientX-g.x),ae=Math.max(1,Math.min(ke,Math.round((B+st)/(qe+st)))),ee=Math.max(1,Math.min(sn,Math.round(ae*sn/ke))),le=g.h*an+(g.h-1)*st+(d.clientY-g.y),me=Math.max(1,Math.min(wr,Math.round((le+st)/(an+st)))),be=Ot(u[g.id]?.content??""),Be=cs(be),Ge={w:Math.max(Be.w,ee),h:Math.max(Be.h,me)};fe.current={id:g.id,w:Ge.w,h:Ge.h},U(tt=>tt&&tt.w===Ge.w&&tt.h===Ge.h?tt:{id:g.id,w:Ge.w,h:Ge.h})},Xe=d=>{const g=se.current;if(g&&d&&g.pointerId!==d.pointerId)return;const C=fe.current;if(se.current=null,fe.current=null,U(null),!g||!C||C.w===g.w&&C.h===g.h)return;const B=ue();!B||!B[g.id]||pe({...B,[g.id]:{...B[g.id],w:C.w,h:C.h}},g.nonce)},Je=d=>{const g=Qs(s.getState().manifest?.fmExtra??"");if(!g.ok||!g.pins[d])return;const C=g.pins[d].row,B={};for(const[ae,ee]of Object.entries(g.pins))ee.row!==C&&(B[ae]=ee);X(is(s.getState().manifest?.fmExtra??"",B))},_e=(d,g,C)=>{const B=ue();!B||!B[d]||pe({...B,[d]:{...B[d],w:g,h:C}})},dt=Aa(us(xr,{activationConstraint:{distance:4}}),us(fr,{activationConstraint:{delay:150,tolerance:8}})),[Ze,wt]=c.useState(null),[Te,Ie]=c.useState(null);c.useLayoutEffect(()=>{l&&Ie(null)},[l]);const[He,at]=c.useState(null),We=c.useRef(null),[oe,ut]=c.useState(null),Ee=c.useRef(null),Le=c.useRef(0),Ke=c.useRef(null),Qe=c.useRef({bands:[],byId:new Map}),yt=c.useRef(null),it=c.useRef(null),ht=c.useRef(1),v=d=>{it.current=xe(),Ie(null),yt.current=new Map(Y.current);const g=ie.current,C=g&&g.offsetWidth>0?g.getBoundingClientRect().width/g.offsetWidth:1;ht.current=Math.abs(C-1)<.005?1:C,Le.current=pr(re),Ke.current=null,Ee.current=null,wt(String(d.active.id))},V=d=>{Ta(Ee.current,d)||(Ee.current=d,ut(d))},J=d=>{const g=String(d.active.id),C=d.over?String(d.over.id):null;if(!C||C===g)return;Ke.current=null;const B={...re};delete B[g],V(B);const ae=We.current??P,ee=Nd(ae,g,C);ee.join(`
12
- `)!==ae.join(`
13
- `)&&(We.current=ee,at(ee))},Q=d=>{const g=String(d.active.id);if(d.over&&String(d.over.id)!==g||rn(Ct(u[g]?.content??"")?.kind)||!q.ok)return;const C=d.active.rect.current.translated,B=ie.current,ae=B?.getBoundingClientRect(),ee=Qe.current.byId.get(g);if(!C||!B||!ae||!ee||qe<=0)return;const le=getComputedStyle(B),me=ht.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,tt=(C.left-ae.left)/me-parseFloat(le.paddingLeft||"0"),a=(Ge-ae.top)/me-parseFloat(le.paddingTop||"0"),w=an+st,x=Qe.current.bands.findIndex(I=>a>=I.top&&a<I.top+I.h*w);if(x<0)return;const T=Math.round(tt/(qe+st)),de=Math.max(0,Math.min(sn-ee.w,Math.round(T*sn/ke)));if(Ke.current&&Ke.current.band===x&&Ke.current.col===de)return;Ke.current={band:x,col:de};const ve=Qe.current.bands[x].ids.filter(I=>I!==g);if(ve.some(I=>rn(Ct(u[I]?.content??"")?.kind)))return;const De=mr(We.current??P,Ee.current??re,[{id:g,col:de,w:ee.w},...ve.map(I=>({id:I,col:Qe.current.byId.get(I)?.col??0,w:Qe.current.byId.get(I)?.w??1}))],Le.current);V(De.pins),De.ids.join(`
14
- `)!==(We.current??P).join(`
15
- `)&&(We.current=De.ids,at(De.ids))},Ce=()=>{const d={nonce:it.current,seq:We.current,pins:Ee.current};return it.current=null,We.current=null,Ee.current=null,yt.current=null,Ke.current=null,wt(null),at(null),ut(null),d},Fe=()=>{Ce()},et=()=>{const{nonce:d,seq:g,pins:C}=Ce();if(!g&&!C)return;const B=ue();if(!B)return;const ae=(g??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&&q.ok&&!Ta(C,re);if(!ee&&!le)return;let me=s.getState().manifest?.fmExtra??"";ee&&(me=as(me,hr(B,ae))??me),le&&(me=is(me,C)??me),X(me,d)},Ae=(d,g)=>{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=ss(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:g.w,h:g.h}})}return ae},gn=d=>{p(!1),(async()=>{if(d==="text"){Ae("",br);return}if(d==="section"){const C=await ot(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:Ni()}),Nn);return}if(d==="weather"){const C=await ot(n("dashgrid.prompt.weather"),"上海");if(!C?.trim())return;Ae(ze("weather",{city:C.trim()}),Nn);return}if(d==="stat"){await Hn();return}if(d==="chart"){await Rt();return}const g=await ot(n("dashgrid.prompt.webview"),"https://");if(g?.trim()){if(!Za(g.trim())){Ve.getState().toast(n("dashgrid.webviewRejected"),!0);return}Ae(ze("webview",{url:g.trim()}),yr)}})()},Qt=d=>new Promise(g=>{ms.getState().openPicker({title:d,accept:(C,B)=>na(B)==="amadeus-db",onPick:C=>g(C)})}),Hn=async()=>{const d=await Qt(n("dashgrid.pickDbStat"));if(!d)return;const g=(await ot(n("dashgrid.prompt.statCol"),""))?.trim()??"";if(!g){Ae(ze("stat",{source:d}),Nn);return}const C=(await ot(n("dashgrid.prompt.statFn"),"sum"))?.trim();C&&Ae(ze("stat",{source:d,col:g,stat:C}),Nn)},Rt=async()=>{const d=await Qt(n("dashgrid.pickDbChart"));if(!d)return;const g=await gd(d);Ae(ze("view",{type:"amadeus-db",dbPath:d,...g?{view:g}:{}}),Dn("lg"))},jt=c.useMemo(()=>nr().filter(d=>d.embeddable&&!Ca.has(d.type)).map(d=>({type:d.type,name:ta(d.displayName),Icon:d.icon??At,spec:xd(d,na)})).sort((d,g)=>d.name.localeCompare(g.name)),[y]),kt=d=>{p(!1);const g=hn(d.type),C=Dn(g?.dashboard?.defaultSize??zi.defaultSize);if(!d.spec){Ae(ze("view",{type:d.type}),C);return}const{param:B,accept:ae}=d.spec;ms.getState().openPicker({title:n("dashgrid.pickFileFor",{name:d.name}),accept:ae,onPick:ee=>{Ae(ze("view",{type:d.type,[B]:ee}),C)}})},vn=d=>{const g=s.getState();if(g.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=g.insertBlockAfter(B,void 0,le.content);if(!me)break;ae[me]={order:ee++,w:le.w,h:le.h},B=me}pe(ae)},en=d=>{s.getState().activePage===i&&s.getState().deleteBlock(d)},Kn=d=>{X(dr(s.getState().manifest?.fmExtra??"",d))},wn=()=>{O(null),X(vr(s.getState().manifest?.fmExtra??"","canvas"))};if(!i)return e.jsx("div",{className:"amx-draw-state",children:n("dashgrid.noFile")});const tn=d=>{const g=Ct(u[d]?.content??"");if(g?.kind!=="view")return{widget:g,title:null,Icon:null,openable:null};const C=g.opts.type??"",B=hn(C);if(!B)return{widget:g,title:n("dashgrid.viewUnavailable",{type:C}),Icon:At,openable:null};const{type:ae,...ee}=g.opts;return{widget:g,title:vd(g.opts,ta(B.displayName)),Icon:B.icon??At,openable:()=>$e.getState().openView(C,ee,"main",{newTab:!0})}},Mt=(d,g)=>{const C=Ct(u[d]?.content??"");if(C?.kind==="view"){const B=C.opts.type??"",ae=hn(B);return!ae||Ca.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(fd,{dashLeafId:t.id,dashPath:i,blockId:d,opts:C.opts,size:g,onClose:()=>en(d)})}return C?e.jsx(za,{widget:C,filters:Re}):e.jsx(Oa,{blockId:d})},$t=(()=>{if(!He)return P;const d=He.filter(g=>D.includes(g));for(const g of P)d.includes(g)||d.push(g);return d})(),nn=oe??re,bn=sr($t.map(d=>{const g=Ot(u[d]?.content??""),C=Z[d]??Dn(g.defaultSize),B=yt.current?.get(d),ae=B?{...C,w:B.w,h:B.h}:C,ee=A?.id===d?{...ae,...A}:ae,le=rn(Ct(u[d]?.content??"")?.kind),me=cs(g),be={key:zd(ee,g.sizes),w:Math.max(me.w,ee.w),h:Math.max(me.h,ee.h)},Be=ps(g.defaultSize),Ge=!nn[d]&&(!Z[d]||Z[d].w===Be.w&&Z[d].h===Be.h),tt=A?.id===d||!Ge?[be]:[be,...g.sizes.map(a=>ps(a)).filter(a=>a.w!==be.w||a.h!==be.h)];return{id:d,preferred:ee,choices:tt,chrome:le}}),nn,ke),St=[];{let d=1;const g=[],C=new Map;for(const B of bn){let ae=1;const ee=[];for(const le of B.items){const me=le.start??ae;St.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)*sn/ke),w:le.cell.w})}g.push({top:(d-1)*(an+st),h:B.h,ids:ee}),d+=B.h}Qe.current={bands:g,byId:C}}Y.current=new Map(St.map(d=>[d.id,d.cell]));const yn=(()=>{if(!Ze)return null;const d=Ct(u[Ze]?.content??""),g=d?.kind??"text";if(d&&rn(g))return e.jsx("div",{className:"dash3-card dash3-card--chrome dash3-card--lift",children:e.jsx("div",{className:"dash3-card-body",children:e.jsx(za,{widget:d})})});const C=tn(Ze);return e.jsxs("div",{className:"dash3-card dash3-card--lift","data-kind":g,"data-surface":Ot(u[Ze]?.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${N?" amx-dragover":""}`,"data-mode":o,onPointerDownCapture:d=>{Ht(t.id),Te&&!d.target.closest?.(`.dash3-card[data-key="${CSS.escape(Te)}"]`)&&Ie(null)},onDragOver:d=>{l||!Array.from(d.dataTransfer?.types??[]).includes("Files")||(d.preventDefault(),z(!0))},onDragLeave:d=>{d.currentTarget.contains(d.relatedTarget)||z(!1)},onDrop:d=>{z(!1);const g=Array.from(d.dataTransfer?.files??[]);l||!g.length||(d.preventDefault(),Ht(t.id),An(g,i))},children:[e.jsxs("div",{className:"amx-toolbar",children:[e.jsx(Os,{}),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(fs,{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(cn,{size:13}):e.jsx(vt,{size:14}),e.jsx("span",{children:n(l?"dashgrid.editLayout":"dashgrid.done")})]}),e.jsx(oa,{initial:!1,children:!l&&e.jsxs(xs.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(g=>!g)},children:e.jsx(Et,{size:14})}),y&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"dash-menu-scrim",onClick:()=>p(!1)}),e.jsxs("div",{ref:k.ref,className:"dash-add-menu",style:k.style,children:[yd.map(d=>e.jsxs("button",{onClick:()=>gn(d.key),children:[e.jsx(d.icon,{size:13})," ",n(d.labelKey)]},d.key)),jt.length>0&&e.jsx("div",{className:"dash-menu-sep",children:n("dashgrid.menuViews")}),jt.map(d=>e.jsxs("button",{onClick:()=>kt(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 g=d.currentTarget.getBoundingClientRect();O({x:Math.max(8,Math.min(g.right-180,window.innerWidth-196)),y:g.bottom+4})},children:e.jsx(Xt,{size:14})})]}),!H.ok&&e.jsx("div",{className:"dash-banner dash-banner-warn",children:n("dashgrid.fmBroken",{error:H.error})}),ce&&e.jsxs("div",{className:"dash-banner",children:[n("dashgrid.staleBanner"),e.jsx("button",{onClick:()=>pe(ea({},D)??{}),children:n("dashgrid.reflowNow")})]}),e.jsx(bd,{filters:Re,editable:!l,onChange:Kn}),e.jsx(or.Provider,{value:Re,children:e.jsxs(xs.div,{layoutScroll:!0,ref:S,className:"dash3-host","data-locked":l||void 0,onPointerMove:W,onPointerUp:Xe,onPointerCancel:Xe,children:[e.jsxs(Ba,{sensors:dt,collisionDetection:Wa,measuring:{droppable:{strategy:Va.Always}},onDragStart:v,onDragMove:Q,onDragOver:J,onDragEnd:et,onDragCancel:Fe,children:[e.jsx($a,{items:$t,strategy:Sd,children:e.jsx("div",{ref:ie,className:"dash3-grid",style:{"--dash3-cols":ke,"--dash3-row":`${an}px`,"--dash3-gap":`${st}px`},children:ne>0&&e.jsx(oa,{initial:!1,mode:"popLayout",children:St.map(({id:d,rowStart:g,rowSpan:C,colStart:B,colSpan:ae,size:ee})=>{const le=tn(d);return e.jsx(Ed,{id:d,rowStart:g,rowSpan:C,colStart:B,colSpan:ae,locked:l,chrome:rn(le.widget?.kind),kind:le.widget?.kind??"text",surface:Ot(u[d]?.content??"").surface,size:ee,dragging:Ze===d,sizing:A?.id===d,interact:Te===d,reduceMotion:!!m,title:le.title,Icon:le.Icon,onOpen:le.openable,onInteract:()=>Ie(d),onDelete:()=>en(d),onMenu:(me,be)=>G({x:me,y:be,id:d}),onGripDown:me=>R(me,d),children:Mt(d,ee)},d)})})})}),e.jsx(_a,{zIndex:30,style:ht.current!==1?{zoom:1/ht.current}:void 0,dropAnimation:m?null:{duration:200,easing:"cubic-bezier(0.16, 1, 0.3, 1)"},children:yn})]}),!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(At,{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:kd.filter(d=>d.cards.length).map(d=>{const g=d.key==="today"?ni:At;return e.jsxs("button",{type:"button",className:"dash3-template",onClick:()=>vn(d),children:[e.jsx("span",{className:"dash3-template-icon","aria-hidden":"true",children:e.jsx(g,{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)})})]})})]})}),E&&!l&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"dash-menu-scrim",onClick:()=>G(null)}),e.jsxs("div",{ref:F.ref,className:"dash-add-menu",style:{position:"fixed",left:E.x,top:E.y,...F.style},children:[e.jsx("div",{className:"dash-menu-sep",children:n("dashgrid.menuSize")}),rr.filter(d=>Ot(u[E.id]?.content??"").sizes.includes(d.key)).map(d=>e.jsxs("button",{onClick:()=>{_e(E.id,d.w,d.h),G(null)},children:[n(jd[d.key])," ",e.jsxs("span",{className:"dash3-size-dim",children:[d.w,"×",d.h]})]},d.key)),re[E.id]&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"dash-menu-sep"}),e.jsx("button",{onClick:()=>{Je(E.id),G(null)},children:n("dashgrid.restoreAuto")})]}),e.jsx("div",{className:"dash-menu-sep"}),e.jsx("button",{className:"dash-danger",onClick:()=>{en(E.id),G(null)},children:n("dashgrid.deleteCard")})]})]}),b&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"dash-menu-scrim",onClick:()=>O(null)}),e.jsxs("div",{ref:$.ref,className:"dash-add-menu",style:{position:"fixed",left:b.x,top:b.y,...$.style},children:[e.jsx("button",{onClick:wn,children:n("dashgrid.switchToCanvas")}),e.jsx("button",{onClick:()=>{O(null),(async()=>{const d=(await ot(n("dashgrid.renameTitle"),ns(i)))?.trim().replace(/[\\/]/g,"");if(!d)return;const g=await s.getState().renamePage(`${d}.dashboard`),C=s.getState().activePage;g&&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:ns(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 Ed({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:b,Icon:O,children:E,onOpen:G,onInteract:k,onDelete:$,onMenu:F,onGripDown:N}){const{t:z}=he(),{attributes:M,listeners:D,setNodeRef:H,isDragging:Z}=gr({id:t,disabled:o,transition:null}),ce={gridRow:`${n} / span ${s}`,gridColumn:`${i} / span ${l}`};return e.jsx(xs.div,{ref:H,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:[b&&!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:b}),o&&G&&e.jsx("button",{type:"button",className:"dash3-card-open",title:z("dashgrid.openInTab"),"aria-label":z("dashgrid.openInTabAria",{title:b}),onClick:G,children:e.jsx(It,{size:12})})]}),e.jsx("div",{className:"dash3-card-body",children:E}),!o&&e.jsxs(e.Fragment,{children:[!y&&e.jsx("div",{className:"dash3-shield",...M,...D,onDoubleClick:r?void 0:k,title:z(r?"dashgrid.dragToReorder":"dashgrid.dragOrEnter")}),e.jsx("button",{type:"button",className:"dash3-card-btn dash3-card-more",title:z("dashgrid.sizeAndMore"),"aria-label":z("dashgrid.setCardSize"),onClick:q=>{q.stopPropagation();const re=q.currentTarget.getBoundingClientRect();F(Math.max(8,Math.min(re.left-60,window.innerWidth-196)),re.bottom+4)},children:e.jsx(Xt,{size:12})}),e.jsx("button",{type:"button",className:"dash3-card-btn dash3-card-del",title:z("dashgrid.deleteThisCard"),"aria-label":z("dashgrid.deleteThisCard"),onClick:q=>{q.stopPropagation(),$()},children:e.jsx(Ye,{size:12})}),!r&&e.jsx("div",{className:"dash3-grip",title:z("dashgrid.resize"),onPointerDown:N})]})]})})}export{ed as A,Os as B,vs as C,cu as D,Ca as E,Cn as L,bi as N,bc as P,nd as S,fd as V,za as W,su as a,xl as b,gd as c,Jc as d,oi as e,$c as f,au as g,ou as h,An as i,ru as j,Hc as k,Ni as l,yi as m,lu as n,iu as o,xd as p,Ll as r,nu as s,Oe as u};