@forsion/unit 2.13.1 → 2.13.3

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 (187) hide show
  1. package/main.mjs +21 -3
  2. package/package.json +1 -1
  3. package/release.json +5 -5
  4. package/web/assets/{ArtificialView-XwHMLUFb.js → ArtificialView-DS97zlMg.js} +1 -1
  5. package/web/assets/{AutomationBuilder-hqs0QhMt.js → AutomationBuilder-BsJc8wuC.js} +1 -1
  6. package/web/assets/CalendarConfigView-BN8mraSo.js +1 -0
  7. package/web/assets/CalendarView-D55PA1vn.js +1 -0
  8. package/web/assets/{CapabilityMenu-SwVlZ06x.js → CapabilityMenu-BVrokPpT.js} +1 -1
  9. package/web/assets/{CheckboxInput-BC-5a_C9.js → CheckboxInput-BuJ3HPm_.js} +1 -1
  10. package/web/assets/{Chrome-HdfyYV3i.js → Chrome-amTcZNE4.js} +1 -1
  11. package/web/assets/{CodeView-CFL6yQ-6.js → CodeView-DRVh13k9.js} +3 -3
  12. package/web/assets/DashboardGridView-D9s9pez_.css +1 -0
  13. package/web/assets/DashboardGridView-DlFyYfUh.js +17 -0
  14. package/web/assets/{EventCard-B_ndpqH_.js → EventCard-DUrn2krw.js} +1 -1
  15. package/web/assets/ExcalidrawCanvas-TpbzBF-J.js +1 -0
  16. package/web/assets/{FloatingToc-Ce9GamvH.js → FloatingToc-B1d4-5EL.js} +1 -1
  17. package/web/assets/HomepageView-DnQ_5Obe.css +1 -0
  18. package/web/assets/HomepageView-nzKfbHM-.js +1 -0
  19. package/web/assets/ImageStudioPanels-B2PTq6Yb.js +3 -0
  20. package/web/assets/{ImageStudioView-UPv52acl.js → ImageStudioView-Cawr6pGW.js} +1 -1
  21. package/web/assets/InlineFiles-DKPH5JHz.js +1 -0
  22. package/web/assets/MarkdownBlock-BHpDy2qQ.js +58 -0
  23. package/web/assets/ModelPill-ChzAM3z1.js +2 -0
  24. package/web/assets/MuseLibraryView-DLuQ_jyV.js +2 -0
  25. package/web/assets/{MuseView-CC2A7MBs.js → MuseView-CDDwV6SR.js} +2 -2
  26. package/web/assets/{PageHistoryPanel-KhKT1DLy.js → PageHistoryPanel-BbdXpjJM.js} +2 -2
  27. package/web/assets/{PdfAnnotator-DUyrgY-t.js → PdfAnnotator-CW0wPWRB.js} +1 -1
  28. package/web/assets/PenRow-BY-MZLDQ.js +1 -0
  29. package/web/assets/{ProductView-CgsIYZqD.js → ProductView-0ieVL3rY.js} +1 -1
  30. package/web/assets/{RightPanel-BHDgqTFs.js → RightPanel-BRexwQ3W.js} +3 -3
  31. package/web/assets/RunLocationPicker-BrDfOu8-.css +1 -0
  32. package/web/assets/RunLocationPicker-CadYiE7C.js +43 -0
  33. package/web/assets/{SketchCard-BGYz-bXP.js → SketchCard-BcXCdBAs.js} +212 -8
  34. package/web/assets/{StudioGuestSurface-lt6znmkl.js → StudioGuestSurface-ZJFKnNYF.js} +1 -1
  35. package/web/assets/TodoListView-DuRdVFgB.js +1 -0
  36. package/web/assets/{Tooltip-ZxrDqN4p.js → Tooltip-DtDUL18W.js} +1 -1
  37. package/web/assets/UnifiedPage-D7JTfABH.js +68 -0
  38. package/web/assets/{amadeus-manual.en-DzRWr4BL.js → amadeus-manual.en-B8J-svqq.js} +1 -1
  39. package/web/assets/{amadeus-manual.zh-DW32DkL7.js → amadeus-manual.zh-CkCOFnrg.js} +1 -1
  40. package/web/assets/appStore-ClD7vq5L.css +1 -0
  41. package/web/assets/appStore-affnJoin.js +3292 -0
  42. package/web/assets/{arrow-up-right-DrCXuWS7.js → arrow-up-right-R4P9Mmxz.js} +1 -1
  43. package/web/assets/{astryxBridge-D-m4_kYt.js → astryxBridge-CT2wZJXs.js} +3 -3
  44. package/web/assets/{automationListSource-C8BNy6RY.js → automationListSource-JVBMsMbC.js} +1 -1
  45. package/web/assets/boardSurface-Ce0_vf9f.js +1 -0
  46. package/web/assets/{book-open-OLNm7OaB.js → book-open-CcXCToyx.js} +1 -1
  47. package/web/assets/{calendarNavStore-Cylfvv3s.js → calendarNavStore-tQJRVpum.js} +1 -1
  48. package/web/assets/{canvasPrefs-8taQ42Cz.js → canvasPrefs-CSuX9aLF.js} +1 -1
  49. package/web/assets/{chatBoxSurface-CIlzs45H.js → chatBoxSurface-IG6Vu4Dz.js} +1 -1
  50. package/web/assets/{circle-question-mark-XbAFplz1.js → circle-question-mark-O8AhUz35.js} +1 -1
  51. package/web/assets/{circle-x-fcReAZaE.js → circle-x-AV2ZWulM.js} +1 -1
  52. package/web/assets/{client-0MPbodA6.js → client-BqhpYbYL.js} +1 -1
  53. package/web/assets/{code-xml-Cuna8Kh4.js → code-xml-DdR58F83.js} +1 -1
  54. package/web/assets/{codeStudioStore-BBU62GTy.js → codeStudioStore-Dq5i8nbE.js} +1 -1
  55. package/web/assets/codingNavigation-CxdCK78-.js +53 -0
  56. package/web/assets/codingNavigation-_tOR0ell.css +1 -0
  57. package/web/assets/{create-BGtEfCcg.js → create-BgJN5qsj.js} +2 -2
  58. package/web/assets/dashboardSurface-BY-AFB-r.js +1 -0
  59. package/web/assets/{deskCapture-BiUCmqfc.js → deskCapture-BD2qD6NI.js} +1 -1
  60. package/web/assets/{diff2html-BNp2FTbk.js → diff2html-OoRdHZ_O.js} +1 -1
  61. package/web/assets/{docx-preview-CFznGVOU.js → docx-preview-B43XC8Cn.js} +1 -1
  62. package/web/assets/{emoji-6zl4yfOS.js → emoji-BPdA62d7.js} +1 -1
  63. package/web/assets/{floatingTocSurface-DreXPCa6.js → floatingTocSurface-BM2SYE_u.js} +1 -1
  64. package/web/assets/{foldActions-05QcQziQ.js → foldActions-BcyvNVBs.js} +1 -1
  65. package/web/assets/{folder-BpsfOHD4.js → folder-CCZqnwRc.js} +1 -1
  66. package/web/assets/{folder-plus-BeQHr4AZ.js → folder-plus-BJKT1Pqg.js} +1 -1
  67. package/web/assets/{gestures-DQBCcK4y.js → gestures-BwPbZDkU.js} +1 -1
  68. package/web/assets/{hand-Bko7ms15.js → hand-DRu7IJdU.js} +1 -1
  69. package/web/assets/{hard-drive-BpuI5ebj.js → hard-drive-CXNJUCXw.js} +1 -1
  70. package/web/assets/i18n-BMo19xaR.css +1 -0
  71. package/web/assets/i18n.generated-DvY59Zq3.js +15 -0
  72. package/web/assets/{imageStudio-BLVNKmEG.js → imageStudio-Axwmd4GW.js} +2 -2
  73. package/web/assets/imageStudio-DZ0qGU2s.css +1 -0
  74. package/web/assets/{index-C4L6vjd_.js → index-B1rE_NwA.js} +1 -1
  75. package/web/assets/{index-OD1gSX3h.js → index-BFTY79aq.js} +1 -1
  76. package/web/assets/{index-D6AycQIz.js → index-BGEkZBs2.js} +1 -1
  77. package/web/assets/{index-Cff42k7q.js → index-BO2XJc36.js} +1 -1
  78. package/web/assets/index-BYUntVIZ.js +297 -0
  79. package/web/assets/{index-C1doZp5H.js → index-C65u4fXd.js} +1 -1
  80. package/web/assets/{index-D7gVhvNY.js → index-C_Ohi-I3.js} +1 -1
  81. package/web/assets/{index-rggq2czF.js → index-CkMhazev.js} +1 -1
  82. package/web/assets/{index-D9UZQy42.js → index-CobUnTcv.js} +1 -1
  83. package/web/assets/{index-BgnNNv3e.js → index-D102FOuM.js} +1 -1
  84. package/web/assets/{index-DuBQ0j2g.js → index-D3CYvMpl.js} +1 -1
  85. package/web/assets/{index-BHm6K743.js → index-D78izbLA.js} +1 -1
  86. package/web/assets/{index-CwcOeZdT.js → index-DDMXVG0h.js} +1 -1
  87. package/web/assets/{index-Ck_O3Jdd.js → index-DY0M_dpd.js} +1 -1
  88. package/web/assets/{index-CLHoq1w-.js → index-DcbZwhpE.js} +1 -1
  89. package/web/assets/{index-CJeUgjPU.js → index-Dlkq7gkE.js} +1 -1
  90. package/web/assets/{index-o8cj0pRH.js → index-HqmJW2np.js} +1 -1
  91. package/web/assets/{index-sCXThwqZ.js → index-LxlyPm0_.js} +1 -1
  92. package/web/assets/{index-CD3yIkOA.js → index-Uq4J2aoW.js} +1 -1
  93. package/web/assets/{index-rHjhbwvm.js → index-WbVt2P8R.js} +1 -1
  94. package/web/assets/{index-CUZI62qU.js → index-XyjIhkPw.js} +1 -1
  95. package/web/assets/index-Y2kzYlZq.js +1 -0
  96. package/web/assets/{index-C0Gy2NQ6.js → index-mB0EQkyZ.js} +1 -1
  97. package/web/assets/{index-Uo5tswys.js → index-pJh7JN7_.js} +1 -1
  98. package/web/assets/{index-BF10xp_K.js → index-taRxNsbp.js} +1 -1
  99. package/web/assets/{invitePage-b0HGvMj6.js → invitePage-BW0BH8Ac.js} +1 -1
  100. package/web/assets/{ipc-CxAyeo8q.js → ipc-D7yENkjV.js} +1 -1
  101. package/web/assets/{jszip.min-B94KpE21.js → jszip.min-UE5d5vPJ.js} +1 -1
  102. package/web/assets/{layout-grid-BBVuEdWG.js → layout-grid-Hs3eDA07.js} +1 -1
  103. package/web/assets/linkFollow-Msu1XH9v.js +8 -0
  104. package/web/assets/{list-tree-4-0QDbLu.js → list-tree-DmuRb-p9.js} +1 -1
  105. package/web/assets/{listFold-DLuxXiIj.js → listFold-CKxjyY5_.js} +1 -1
  106. package/web/assets/{lock-CnbZm4vo.js → lock-kffGfeHt.js} +1 -1
  107. package/web/assets/{log-out-BEynWaHa.js → log-out-B5gEP0tF.js} +1 -1
  108. package/web/assets/main-DIyFlyfK.js +20 -0
  109. package/web/assets/markdownEditorSurface-Cx2rqFAY.js +3 -0
  110. package/web/assets/{message-square-plus-CpiKDvle.js → message-square-plus-DxBPIhPS.js} +1 -1
  111. package/web/assets/{messages-_jta1lSI.js → messages-4w1Khzm1.js} +1 -1
  112. package/web/assets/minus-CfoZ4oxr.js +1 -0
  113. package/web/assets/mobileEntry-B8JwR53-.js +13 -0
  114. package/web/assets/{nativeDownload-BYT082bY.js → nativeDownload-Udrv_tmU.js} +1 -1
  115. package/web/assets/{pageChrome-D3Niv1JM.js → pageChrome-D-9npbUE.js} +1 -1
  116. package/web/assets/pageChrome-eO9pb2fH.css +1 -0
  117. package/web/assets/{pageTree-CgfvpzIj.js → pageTree-CIXFRCLk.js} +4 -4
  118. package/web/assets/{pen-tool-BXEFnU2i.js → pen-tool-D_Y9We9x.js} +1 -1
  119. package/web/assets/{pencil-cqvCkekG.js → pencil-DGiTRzW1.js} +1 -1
  120. package/web/assets/phoneList-BQfCJwKF.css +1 -0
  121. package/web/assets/phoneList-DHUia6HT.js +9 -0
  122. package/web/assets/pluginChat-BXuJiMYi.js +2 -0
  123. package/web/assets/{redo-2-BO7wCDwy.js → redo-2-QgiKEg9T.js} +1 -1
  124. package/web/assets/{rotate-ccw-BvipPIjC.js → rotate-ccw-BLoH5er1.js} +1 -1
  125. package/web/assets/{sharePage-XbN50US7.js → sharePage-DYYN5usb.js} +2 -2
  126. package/web/assets/{shareViewer-BaYogetW.js → shareViewer-BzuSyJv_.js} +2 -2
  127. package/web/assets/{star-BQWMXnn7.js → star-BmywYD3u.js} +1 -1
  128. package/web/assets/tableSurface-21LDYY_G.js +1 -0
  129. package/web/assets/{terminal-l9k6RDrH.js → terminal-BlmA_Z1C.js} +1 -1
  130. package/web/assets/{terminalView-Cpnt5_0P.js → terminalView-SAxITnRW.js} +1 -1
  131. package/web/assets/{theme-C6D3tMGV.css → theme-Dgqst5S9.css} +1 -1
  132. package/web/assets/{type-CFoaj2eD.js → type-DmIL6FB-.js} +1 -1
  133. package/web/assets/{undo-2-DusxpdLa.js → undo-2-yMeXc8Wi.js} +1 -1
  134. package/web/assets/{unitAccount-DwutFPPw.js → unitAccount-BPYRAa3m.js} +1 -1
  135. package/web/assets/unitBridge-BNVzai6X.js +1 -0
  136. package/web/assets/{unitCloudTransport-vA7cLDts.js → unitCloudTransport-iFweA1xk.js} +1 -1
  137. package/web/assets/{unitOwnerAccess-LBlJ1YfA.js → unitOwnerAccess-Bggl7bDP.js} +1 -1
  138. package/web/assets/{unitShim-B_M9IrbC.js → unitShim-BP2nBO_k.js} +3 -3
  139. package/web/assets/{upload-ZrOj6tXA.js → upload-D20PZHXc.js} +1 -1
  140. package/web/assets/userSpaces-CrLrKklx.js +1 -0
  141. package/web/assets/viewportLock-DO1lzA2N.css +1 -0
  142. package/web/assets/viewportLock-tlT6H_Hc.js +629 -0
  143. package/web/assets/{workflow-DPoG4QE2.js → workflow-Bd6xBHiT.js} +1 -1
  144. package/web/assets/{zoom-in-lbTgzdQP.js → zoom-in-_TgFOpyv.js} +1 -1
  145. package/web/index.html +24 -27
  146. package/web/assets/CalendarConfigView-DKib8Oed.js +0 -1
  147. package/web/assets/CalendarView-DJ5iOzvu.js +0 -1
  148. package/web/assets/DashboardGridView-B9DCWYVb.js +0 -17
  149. package/web/assets/DashboardGridView-Ck3LKkOb.css +0 -1
  150. package/web/assets/ExcalidrawCanvas-BQ4KKLJP.js +0 -1
  151. package/web/assets/HomepageView-BNabJQfP.css +0 -1
  152. package/web/assets/HomepageView-RCOfcVbE.js +0 -1
  153. package/web/assets/ImageStudioPanels-lkS_y2uM.js +0 -3
  154. package/web/assets/InlineFiles-CQbQumkf.js +0 -1
  155. package/web/assets/MarkdownBlock-CkqiwPXa.js +0 -58
  156. package/web/assets/ModelPill-CY-rU1RU.js +0 -2
  157. package/web/assets/MuseLibraryView-CtTHlVnT.js +0 -2
  158. package/web/assets/RunLocationPicker-BE5mxnab.css +0 -1
  159. package/web/assets/RunLocationPicker-DBnXYV5B.js +0 -38
  160. package/web/assets/SidebarRow-BAJxbMcx.js +0 -9
  161. package/web/assets/SidebarRow-CsWEqPKX.css +0 -1
  162. package/web/assets/TodoListView-DPKhee6i.js +0 -1
  163. package/web/assets/UnifiedPage-BX6ZQL0h.js +0 -68
  164. package/web/assets/appStore-DWP8UET9.js +0 -3166
  165. package/web/assets/appStore-wtOILggO.css +0 -1
  166. package/web/assets/codingNavigation-CZB4v1ZW.css +0 -1
  167. package/web/assets/codingNavigation-DDlPpPk5.js +0 -47
  168. package/web/assets/dashboardSurface-BYM3C7WG.js +0 -1
  169. package/web/assets/i18n-ecQQxiMQ.css +0 -1
  170. package/web/assets/i18n.generated-BuLjnmY8.js +0 -15
  171. package/web/assets/imageStudio--KF9gwHA.css +0 -1
  172. package/web/assets/index-BM2o7PeV.js +0 -298
  173. package/web/assets/index-CuiYK18N.js +0 -1
  174. package/web/assets/linkFollow-B7ivDZMM.js +0 -8
  175. package/web/assets/main-sIq2N9Z5.js +0 -20
  176. package/web/assets/markdownEditorSurface-ZSJ3RHAv.js +0 -3
  177. package/web/assets/mdMarkStore-DQHDjG7s.js +0 -2
  178. package/web/assets/mdMarks-DbIcRa0O.js +0 -1
  179. package/web/assets/minus-C9ndHJ9O.js +0 -1
  180. package/web/assets/mobileEntry-CPmU_c4m.js +0 -13
  181. package/web/assets/pageChrome-CovzZPdb.css +0 -1
  182. package/web/assets/pluginChat-BbBukMuN.js +0 -2
  183. package/web/assets/tableSurface-BXqqidd1.js +0 -1
  184. package/web/assets/unitBridge-CcgQpkqV.js +0 -1
  185. package/web/assets/userSpaces-uJOnsedR.js +0 -1
  186. package/web/assets/viewportLock-D3SNkwS2.js +0 -631
  187. package/web/assets/viewportLock-IP1zaVkz.css +0 -1
@@ -1,17 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./PageHistoryPanel-KhKT1DLy.js","./index-BM2o7PeV.js","./appStore-DWP8UET9.js","./nativeDownload-BYT082bY.js","./ipc-CxAyeo8q.js","./client-0MPbodA6.js","./appStore-wtOILggO.css","./create-BGtEfCcg.js","./create-BgE3edmZ.css","./UnifiedPage-BX6ZQL0h.js","./MarkdownBlock-CkqiwPXa.js","./index-CuiYK18N.js","./linkFollow-B7ivDZMM.js","./mdMarks-DbIcRa0O.js","./emoji-6zl4yfOS.js","./listFold-DLuxXiIj.js","./book-open-OLNm7OaB.js","./MarkdownBlock--__nPQGh.css","./pageChrome-D3Niv1JM.js","./upload-ZrOj6tXA.js","./pageChrome-CovzZPdb.css","./SketchCard-BGYz-bXP.js","./arrow-up-right-DrCXuWS7.js","./Chrome-HdfyYV3i.js","./minus-C9ndHJ9O.js","./canvasPrefs-8taQ42Cz.js","./hand-Bko7ms15.js","./type-CFoaj2eD.js","./foldActions-05QcQziQ.js","./lock-CnbZm4vo.js","./undo-2-DusxpdLa.js","./code-xml-Cuna8Kh4.js","./message-square-plus-CpiKDvle.js","./UnifiedPage-CWXc_mo1.css","./FloatingToc-Ce9GamvH.js","./pageTree-CgfvpzIj.js","./pluginExt-Byb64tQO.js","./SidebarRow-BAJxbMcx.js","./SidebarRow-CsWEqPKX.css","./list-tree-4-0QDbLu.js","./pen-tool-BXEFnU2i.js","./pencil-cqvCkekG.js","./star-BQWMXnn7.js","./folder-plus-BeQHr4AZ.js","./redo-2-BO7wCDwy.js","./folder-BpsfOHD4.js","./layout-grid-BBVuEdWG.js","./PageHistoryPanel-DFjh0pWs.css"])))=>i.map(i=>d[i]);
2
- import{ce as va,cf as jn,r as ve,j as e,u as oe,d as c,cg as wa,bD as xi,ch as vi,m as wi,bO as ba,t as W,_ as bi,O as yi,c0 as ji,ar as ki,I as Ht,n as Ts,ad as Jn,ci as Zn,b_ as Si,b$ as Ni,aT as zi,aD as Ci,b4 as Pi,aI as Es,aL as Ti}from"./index-BM2o7PeV.js";import{F as rt,cr as It,Z as tn,ij as En,u as De,b as B,dl as Q,R as us,fL as Je,fs as Pe,f8 as Te,pG as ya,f9 as Ei,p as Re,ly as Di,pH as Ri,gc as Fi,cp as Mi,pI as $i,pJ as Ii,pK as Oi,pL as Li,aJ as ot,nR as Ai,f3 as ja,k$ as Bi,kj as hs,k9 as ka,pM as Vi,fW as Sa,g1 as ms,nT as Dn,pN as Na,fr as jt,pO as za,fE as Ca,k5 as Qn,k8 as Wi,pP as _i,fI as Pa,pQ as Ta,kb as Ea,pB as qi,ki as Da,pR as Ui,a4 as it,aE as ps,U as Ra,dZ as fs,bU as Rt,bJ as He,ah as vt,dB as Hi,hj as Ki,pS as Qt,iM as Fa,g7 as Yt,b1 as Gi,bn as gs,gl as Ma,fq as xs,pT as Yi,h as Xi,gb as Ji,cV as es,c5 as Ft,bs as $a,aq as bt,pU as Xt,cs as at,f7 as wn,aD as Ct,fc as $n,g6 as ut,fa as Ds,ic as Rs,fb as Fs,J as In,hw as On,nz as Ms,ag as Zi,ar as Ot,nA as Qi,Y as eo,f2 as un,ns as to,nr as no,ax as so,f_ as ao,fv as Mt,pV as io,f$ as Ia,cq as Ln,pW as $s,pX as Is,cK as Os,pY as oo,pZ as ro,fe as ft,p_ as hn,mc as lo,hx as An,gg as co,i9 as uo,id as ho,n5 as mo,cN as po,e_ as fo,ia as go,p$ as xo,q0 as vo,j as Oa,l0 as La,q1 as wo,q2 as bo,q3 as yo,q4 as jo,q5 as ko,b5 as So,nL as No,nM as zo,q6 as Co,q7 as Po,fn as $t,q8 as To,q9 as Eo,qa as Do,qb as Ro,qc as Fo,qd as Ls,jO as Aa,qe as As,fR as Ba,ir as Mo,is as $o,ay as Io,fQ as be,aB as Jt,ft as bn,qf as Bn,N as Oo,qg as Bs,qh as Vs,fu as Vn,fS as Wn,qi as Lo,qj as Ws,qk as Ao,ql as _s,qm as Bo,fT as _n,qn,qo as Vo,qp as Wo,bf as _o,ao as qs,qq as qo,fV as gt,qr as ts,qs as _t,qt,qu as Ue,gi as Uo,fG as Ho,qv as Ko,qw as Go,qx as Yo,qy as Xo,fD as Us,fP as Hs,qz as Jo,qA as Zo,qB as Qo,qC as er,qD as tr,qE as nr,qF as sr,kk as ar,fK as ir,qG as mn,qH as or,qI as rr,qJ as lr}from"./appStore-DWP8UET9.js";import"./client-0MPbodA6.js";import{e as Va,g as vs,h as cr,M as Wa,C as dr,S as ur,U as hr,A as mr,d as pr,i as fr}from"./UnifiedPage-BX6ZQL0h.js";import{F as gr}from"./FloatingToc-Ce9GamvH.js";import{ab as xr,ac as vr,a8 as _a,ad as wr,G as br}from"./MarkdownBlock-CkqiwPXa.js";import{u as yr,S as jr,r as kr,a as Sr,C as Nr,N as zr,U as Cr}from"./pageChrome-D3Niv1JM.js";import{m as Pr,b as Tr,r as Ks}from"./pageTree-CgfvpzIj.js";import{normalizePluginRename as Er}from"./pluginExt-Byb64tQO.js";import{c as ws,d as Dr,S as Kt,P as ns,t as Gs,a as Rr,f as Fr,b as Mr,e as $r,u as Ir,A as Ys,m as ss,C as qa}from"./SidebarRow-BAJxbMcx.js";import{c as At}from"./nativeDownload-BYT082bY.js";import{L as Or}from"./list-tree-4-0QDbLu.js";import{P as pn}from"./pen-tool-BXEFnU2i.js";import{P as yn}from"./pencil-cqvCkekG.js";import{S as as}from"./star-BQWMXnn7.js";import{B as Ua}from"./book-open-OLNm7OaB.js";import{F as Xs}from"./folder-plus-BeQHr4AZ.js";import{U as is}from"./upload-ZrOj6tXA.js";import{F as Lr,T as Ha}from"./type-CFoaj2eD.js";import{U as Ar}from"./undo-2-DusxpdLa.js";import{R as Br,F as fn}from"./redo-2-BO7wCDwy.js";import{C as Un}from"./code-xml-Cuna8Kh4.js";import{L as Js}from"./lock-CnbZm4vo.js";import{F as bs}from"./folder-BpsfOHD4.js";import{L as Pt}from"./layout-grid-BBVuEdWG.js";const Vr=[["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"}]],Ka=rt("a-large-small",Vr);const Wr=[["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"}]],_r=rt("book-marked",Wr);const qr=[["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"}]],os=rt("cloud-off",qr);const Ur=[["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"}]],Hr=rt("cloud-sun",Ur);const Kr=[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]],Gr=rt("heading",Kr);const Yr=[["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"}]],Hn=rt("layout-dashboard",Yr);const Xr=[["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"}]],Jr=rt("list-indent-decrease",Xr);const Zr=[["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"}]],Qr=rt("list-indent-increase",Zr);const el=[["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"}]],kn=rt("share-2",el);let Zs=0;const Ee=At(t=>({vaults:[],activeRoot:null,mirrorVaults:[],status:{},async refresh(){const n=++Zs,s=window.amadeusSync;if(s?.entrySyncGet)try{const a=await s.entrySyncGet();if(n!==Zs)return;t({vaults:a.vaults,activeRoot:a.activeRoot,mirrorVaults:a.mirrorVaults??[]})}catch{}}}));let Qs=!1;function Ga(){if(Qs)return;Qs=!0;const t=window.amadeusSync;Ee.getState().refresh(),t?.onEntrySyncChange?.(()=>{Ee.getState().refresh()}),t?.onStatus?.(n=>{const s=n.binding;s&&Ee.setState(a=>({status:{...a.status,[s]:n}}))})}function en(t,n){if(!t)return!1;const s=Ee.getState().vaults.find(a=>a.vaultRoot===t);return!!s&&va(s.entries,s.exclude,n)}function ys(t,n,s,a){if(!window.amadeusSync||s==="cloud")return jn(a);if(!n)return null;const l=t.find(o=>o.vaultRoot===n);return!l||!va(l.entries,l.exclude,a)?null:`${l.cloudName}/${jn(a)}`}function tl(t,n){const s=t?Ee.getState().vaults.find(l=>l.vaultRoot===t):null;if(!s?.exclude?.length)return!1;const a=jn(n);return s.exclude.some(l=>{const o=jn(l);return!!o&&(a===o||a.startsWith(`${o}/`)||a.startsWith(`${o.replace(/\.md$/i,"")}.fd/`))})}let Gt=null;function rs(){return Gt===null&&(Gt=!0,window.tangu?.getConfig?.().then(t=>{Gt=t?.notesUpgradeV4!==!1}).catch(()=>{})),Gt}function Cd(t){Gt=t}rs();ve({"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 ls=At(t=>({req:null,open:n=>t({req:n}),close:()=>t({req:null})}));function yt(t,n){ls.getState().open({path:t,kind:n})}const ea=t=>(t.split(/[\\/]/).pop()??t).replace(/\.md$/i,"");function Pd(){const t=ls(n=>n.req);return t?e.jsx("div",{className:"am-app tangu-lovable",style:{display:"contents"},children:e.jsx(nl,{req:t,onClose:()=>ls.getState().close()},`${t.kind}:${t.path}`)}):null}function nl({req:t,onClose:n}){const{t:s}=oe(),[a,l]=c.useState(null),[o,r]=c.useState(new Set),[u,x]=c.useState(new Set),[m,k]=c.useState(new Set),[p,j]=c.useState(!1),[f,b]=c.useState(null),[L,D]=c.useState("");c.useEffect(()=>{let P=!0;if(t.kind==="asset"){l({pages:[],files:[],subPages:[]});return}return window.amadeusSync?.entrySyncClosure?.(t.path,t.kind).then(I=>{if(!P)return;l({...I,subPages:I.subPages??[]}),r(new Set(I.pages)),x(new Set(I.files));const R=Ee.getState().activeRoot;k(new Set((I.subPages??[]).filter(U=>!tl(R,U))))}).catch(()=>P&&l({pages:[],files:[],subPages:[]})),()=>{P=!1}},[t.path,t.kind]);const H=async P=>{const I=window.amadeusSync;if(!I?.entrySyncEnable||p)return;j(!0);const R=[{path:t.path,kind:t.kind},...[...o].map(te=>({path:te,kind:"page"})),...[...u].map(te=>({path:te,kind:"asset"}))],U=a?.subPages??[],K=U.filter(te=>!m.has(te)),ae=U.filter(te=>m.has(te)),q=await I.entrySyncEnable({entries:R,exclude:K,include:ae,...P}).catch(te=>({error:String(te)}));if(j(!1),q?.conflict){b(q.conflict),D(`${q.conflict} 2`);return}if(q?.error||!q?.ok){De.getState().toast(q?.error||s("csd.failed"),!0);return}De.getState().toast(s("csd.enabled",{name:q.cloudName??""})),Ee.getState().refresh(),n()},S=P=>{const I=[];for(let R=P;;){const U=R.lastIndexOf(".fd/");if(U<0)return I;R=`${R.slice(0,U)}.md`,I.push(R)}},O=P=>k(I=>{const R=!I.has(P),U=a?.subPages??[],K=`${P.replace(/\.md$/i,"")}.fd/`,ae=new Set(I);for(const q of U)q!==P&&!q.startsWith(K)||(R?ae.add(q):ae.delete(q));if(R)for(const q of S(P))U.includes(q)&&ae.add(q);return ae}),F=(P,I)=>{const R=new Set(P);return R.has(I)?R.delete(I):R.add(I),R},N=(P,I,R,U,K,ae)=>R.length>0&&e.jsxs("div",{className:"amx-csd-group",children:[e.jsxs("div",{className:"amx-csd-head",children:[P,e.jsxs("span",{children:[I,"(",U.size,"/",R.length,")"]}),e.jsx("button",{className:"amx-csd-all",onClick:()=>ae(U.size<R.length),children:U.size<R.length?s("csd.selectAll"):s("csd.selectNone")})]}),e.jsx("div",{className:"amx-csd-list",children:R.map(q=>e.jsxs("label",{className:"amx-csd-item",title:q,children:[e.jsx("input",{type:"checkbox",checked:U.has(q),onChange:()=>K(q)}),e.jsx("span",{children:ea(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:P=>P.stopPropagation(),children:[e.jsxs("div",{className:"dialog-title",children:[e.jsx(It,{size:15,style:{verticalAlign:-2,marginRight:6}}),s("csd.title")]}),f?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"dialog-msg",children:s("csd.conflictMsg",{name:f})}),e.jsx("input",{className:"dialog-input",value:L,onChange:P=>D(P.target.value),placeholder:s("csd.newNamePlaceholder"),onKeyDown:P=>{P.key==="Enter"&&L.trim()&&H({cloudName:L.trim()}),P.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:p,onClick:()=>{H({cloudName:f,merge:!0})},children:s("csd.mergeInto",{name:f})}),e.jsx("button",{className:"dialog-btn","data-primary":!0,disabled:p||!L.trim(),onClick:()=>{H({cloudName:L.trim()})},children:s("csd.useNewName")})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"dialog-msg",children:s("csd.intro",{name:ea(t.path)})}),a===null?e.jsx("div",{className:"dialog-msg",children:s("csd.analyzing")}):e.jsxs(e.Fragment,{children:[N(e.jsx(Or,{size:12}),s("csd.groupSubPages"),a.subPages,m,O,P=>k(P?new Set(a.subPages):new Set)),N(e.jsx(tn,{size:12}),s("csd.groupLinkedPages"),a.pages,o,P=>r(I=>F(I,P)),P=>r(P?new Set(a.pages):new Set)),N(e.jsx(En,{size:12}),s("csd.groupAssets"),a.files,u,P=>x(I=>F(I,P)),P=>x(P?new Set(a.files):new Set)),!a.pages.length&&!a.files.length&&!a.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:p||a===null,onClick:()=>{H()},children:s(p?"csd.enabling":"csd.enable")})]})]})]})})}function ta(t,n){const s=o=>`${o.ghost?"g:":""}${o.path}`,a=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`${a.join("|")}::${l.join("|")}`}ve({"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 Sn=()=>B.getState(),cs=t=>(t.split(/[\\/]/).pop()??t).replace(/\.md$/i,""),Ya=At(t=>({seed:null,request:n=>t(s=>({seed:{q:n,n:(s.seed?.n??0)+1}}))}));function Td(){const{t}=oe(),n=B(m=>m.vaultRoot),[s,a]=c.useState(""),l=Ya(m=>m.seed);c.useEffect(()=>{l&&a(l.q)},[l]);const[o,r]=c.useState([]),u=c.useRef(0);c.useEffect(()=>{Sn().flushSave()},[]),c.useEffect(()=>{const m=s.trim();if(!m){r([]);return}const k=++u.current,p=setTimeout(()=>{Q.search(m).then(j=>{k===u.current&&r(j)})},120);return()=>clearTimeout(p)},[s]);const x=m=>{const k=s.trim().toLowerCase();Te(m.path).then(()=>{if(!k)return;const p=Object.values(Sn().blocks).find(j=>wa(j.content).toLowerCase().includes(k));requestAnimationFrame(()=>{const j=p?document.querySelector(`[data-block-id="${p.id}"]`):null;if(j){j.scrollIntoView({behavior:"smooth",block:"center"}),j.classList.add("amx-block-flash"),setTimeout(()=>j.classList.remove("amx-block-flash"),1300);return}const f=k.split(/[\s\-_/.]+/).filter(Boolean);ya(m.path,f.length>1?[k,...f]:[k])})})};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(us,{size:13,className:"t2s-dim"}),e.jsx("input",{autoFocus:!0,value:s,placeholder:t("amxpanel.searchPlaceholder"),onChange:m=>a(m.target.value)}),s.trim()&&e.jsx("button",{className:"amx-search-save",title:t("amxpanel.saveCollectionTip"),onClick:()=>{Je(t("amxpanel.saveCollection"),s.trim(),{label:t("amxpanel.saveCollectionHint")}).then(m=>{const k=m?.trim();k&&Pe.getState().saveCollection(k,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(m=>e.jsxs("button",{className:"amx-list-item",onClick:()=>x(m),title:m.path,children:[m.title,m.snippet&&e.jsx("span",{className:"amx-backlink-snippet amx-search-snippet",children:sl(m.snippet,s.trim())})]},m.path))}):e.jsx("div",{className:"amx-panel-empty",children:t("amxpanel.searchEmpty")}):e.jsx("div",{className:"amx-panel-empty",children:t("amxpanel.noVault")})]})}function sl(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 Xa=At(t=>({seed:null,request:n=>t(s=>({seed:{tag:n,n:(s.seed?.n??0)+1}}))}));function Ed(t){Xa.getState().request(t.replace(/^#/,""));const n=Re.getState();n.showSideView("left","amadeus-tags");const s=Re.getState(),a=s.api;s.leftVisible&&!a?.panels.some(l=>l.params?.__type==="amadeus-tags")&&n.openView("amadeus-tags",{},"left")}function Dd(){const{t}=oe(),n=B(p=>p.vaultRoot),s=B(p=>p.linkGraphVersion),[a,l]=c.useState([]),[o,r]=c.useState(null),[u,x]=c.useState([]),m=Xa(p=>p.seed);c.useEffect(()=>{m&&r(m.tag)},[m]);const k=o&&!a.some(p=>p.tag.toLowerCase()===o.toLowerCase())?[{tag:o,count:u.length},...a]:a;return c.useEffect(()=>{let p=!0;if(!n){l([]);return}return Q.listTags().then(j=>{p&&l(j)}),()=>{p=!1}},[n,s]),c.useEffect(()=>{let p=!0;if(!o){x([]);return}return Q.pagesByTag(o).then(j=>{p&&x(j)}),()=>{p=!1}},[o,s]),e.jsxs("div",{className:"amx-panel",children:[e.jsx("div",{className:"amx-panel-head",children:t("amxpanel.tagsHead",{n:a.length})}),n?k.length===0?e.jsx("div",{className:"amx-panel-empty",children:t("amxpanel.tagsEmpty")}):e.jsx("div",{className:"amx-list",children:k.map(p=>e.jsxs("div",{children:[e.jsxs("button",{className:`amx-list-item amx-tag${o===p.tag?" active":""}`,ref:o===p.tag&&m?j=>j?.scrollIntoView({block:"nearest"}):void 0,onClick:()=>r(j=>j===p.tag?null:p.tag),children:[e.jsxs("span",{className:"amx-tag-name",children:["#",p.tag]}),e.jsx("span",{className:"amx-tag-count",children:p.count})]}),o===p.tag&&u.map(j=>e.jsx("button",{className:"amx-list-item amx-tag-page",onClick:()=>{Te(j).then(()=>ya(j,[`#${p.tag}`],{tag:!0}))},title:j,children:cs(j)},j))]},p.tag))}):e.jsx("div",{className:"amx-panel-empty",children:t("amxpanel.noVault")})]})}const Et=320,Dt=280,Zt=(t,n,s)=>Math.min(s,Math.max(n,t));function al(t,n,s){const a=Et/2,l=Dt/2;for(let o=0;o<t.length;o++){const r=t[o];if(r.pinned)continue;let u=(a-r.x)*.005,x=(l-r.y)*.005;for(let m=0;m<t.length;m++){if(o===m)continue;const k=t[m],p=r.x-k.x,j=r.y-k.y,f=Math.max(64,p*p+j*j),b=1400/f;u+=p/Math.sqrt(f)*b,x+=j/Math.sqrt(f)*b}for(const m of n){if(m.a!==o&&m.b!==o)continue;const k=t[m.a===o?m.b:m.a],p=k.x-r.x,j=k.y-r.y,f=Math.max(1,Math.hypot(p,j)),b=(f-86)*.02;u+=p/f*b,x+=j/f*b}r.vx=(r.vx+u*s*2)*.82,r.vy=(r.vy+x*s*2)*.82,r.x=Zt(r.x+r.vx,16,Et-16),r.y=Zt(r.y+r.vy,16,Dt-16)}}function Rd(){const{t}=oe(),n=B(N=>N.activePage??N.activeNotePath),s=B(N=>N.linkGraphVersion),[a,l]=c.useState(null),[,o]=c.useState(0),[r,u]=c.useState(null),[x,m]=c.useState({x:0,y:0,k:1}),k=c.useRef(null),p=c.useRef(a);p.current=a;const j=c.useRef(x);j.current=x;const f=c.useRef({alpha:0,raf:0,dragging:!1}),b=c.useRef(!1),L=()=>{if(f.current.raf)return;const N=()=>{const P=p.current,I=f.current;if(!P){I.raf=0;return}al(P.nodes,P.edges,I.alpha),I.dragging||(I.alpha-=.006),o(R=>R+1),I.alpha>.02||I.dragging?I.raf=requestAnimationFrame(N):I.raf=0};f.current.raf=requestAnimationFrame(N)};c.useEffect(()=>()=>{f.current.raf&&cancelAnimationFrame(f.current.raf)},[]);const D=(N,P)=>{const I=k.current?.getScreenCTM();if(!I)return null;const R=new DOMPoint(N,P).matrixTransform(I.inverse());return{x:R.x,y:R.y}},H=(N,P)=>{const I=D(N,P);if(!I)return null;const R=j.current;return{x:(I.x-R.x)/R.k,y:(I.y-R.y)/R.k}};c.useEffect(()=>{let N=!0;if(!n){l(null),p.current=null;return}return p.current?.nodes[0]?.path!==n&&(p.current=null,l(null)),(async()=>{const P=await Q.backlinks(n).catch(()=>[]);if(!N)return;const I=Sn(),R=await Q.readTextFile(n).catch(()=>null);if(!N)return;const U=wa(xi(R??"")),K=[],ae=[],q=new Set;for(const se of vi(U)){const ne=wi(se,I.pages,n);ne?ne!==n&&!K.includes(ne)&&K.push(ne):q.has(se.toLowerCase())||(q.add(se.toLowerCase()),Ei(se,I.files,n)||ae.push(se))}const te=[...new Set([...K,...P.map(se=>se.path).filter(se=>se!==n)])],he=[...te,...ae],Se=[{path:n,label:cs(n),center:!0,x:Et/2,y:Dt/2,vx:0,vy:0,pinned:!0},...he.map((se,ne)=>{const me=ne/Math.max(1,he.length)*Math.PI*2,xe=ne>=te.length;return{path:se,label:xe?se:cs(se),center:!1,ghost:xe,x:Et/2+Math.cos(me)*90,y:Dt/2+Math.sin(me)*90,vx:0,vy:0,pinned:!1}})],ue=new Map(Se.slice(0,1+te.length).map((se,ne)=>[se.path,ne])),J=[],ce=new Set;for(const se of[...K,...P.map(ne=>ne.path)]){const ne=ue.get(se);ne===void 0||ce.has(se)||(ce.add(se),J.push({a:0,b:ne}))}for(let se=0;se<ae.length;se++)J.push({a:0,b:1+te.length+se});if(!N)return;const T={nodes:Se,edges:J},g=p.current;if(!(g&&ta(g.nodes,g.edges)===ta(T.nodes,T.edges))){if(g?.nodes[0]?.path===n){const se=new Map(g.nodes.map(ne=>[`${ne.ghost?"g:":""}${ne.path}`,ne]));for(const ne of T.nodes){const me=se.get(`${ne.ghost?"g:":""}${ne.path}`);me&&(ne.x=me.x,ne.y=me.y,ne.vx=me.vx,ne.vy=me.vy)}}p.current=T,l(T),u(null),f.current.alpha=g?.38:1,L()}})(),()=>{N=!1}},[n,s]);const S=N=>P=>{if(P.button!==0)return;P.stopPropagation();const I=p.current;if(!I)return;const R=I.nodes[N],U=R.pinned;R.pinned=!0,b.current=!1,f.current.dragging=!0,f.current.alpha=Math.max(f.current.alpha,.6),L();const K=q=>{const te=H(q.clientX,q.clientY);te&&(b.current=!0,R.x=Zt(te.x,16,Et-16),R.y=Zt(te.y,16,Dt-16),R.vx=0,R.vy=0,f.current.alpha=Math.max(f.current.alpha,.6))},ae=()=>{window.removeEventListener("pointermove",K),window.removeEventListener("pointerup",ae),R.pinned=U,f.current.dragging=!1,f.current.alpha=Math.max(f.current.alpha,.5),L()};window.addEventListener("pointermove",K),window.addEventListener("pointerup",ae)},O=N=>{if(N.button!==0||N.target!==N.currentTarget)return;const P=D(N.clientX,N.clientY);if(!P)return;const I=j.current,R=K=>{const ae=D(K.clientX,K.clientY);ae&&m({k:I.k,x:I.x+(ae.x-P.x),y:I.y+(ae.y-P.y)})},U=()=>{window.removeEventListener("pointermove",R),window.removeEventListener("pointerup",U)};window.addEventListener("pointermove",R),window.addEventListener("pointerup",U)},F=!!a&&a.nodes.length>1;return c.useEffect(()=>{const N=k.current;if(!N||!F)return;const P=I=>{I.preventDefault();const R=D(I.clientX,I.clientY);if(!R)return;const U=j.current,K=Zt(U.k*Math.exp(-I.deltaY*.0022),.4,3),ae=(R.x-U.x)/U.k,q=(R.y-U.y)/U.k;m({k:K,x:R.x-ae*K,y:R.y-q*K})};return N.addEventListener("wheel",P,{passive:!1}),()=>N.removeEventListener("wheel",P)},[F]),e.jsxs("div",{className:"amx-panel",children:[e.jsx("div",{className:"amx-panel-head",children:t("amxpanel.graphHead")}),n?!a||!F?e.jsx("div",{className:"amx-panel-empty",children:t("amxpanel.graphEmpty")}):e.jsx("svg",{ref:k,className:"amx-graph",viewBox:`0 0 ${Et} ${Dt}`,onPointerDown:O,onDoubleClick:()=>m({x:0,y:0,k:1}),children:e.jsxs("g",{transform:`translate(${x.x} ${x.y}) scale(${x.k})`,children:[a.edges.map((N,P)=>e.jsx("line",{x1:a.nodes[N.a].x,y1:a.nodes[N.a].y,x2:a.nodes[N.b].x,y2:a.nodes[N.b].y,className:`amx-graph-edge${r!==null?N.a===r||N.b===r?" hl":" dim":""}`},P)),a.nodes.map((N,P)=>{const I=r===null||P===r||a.edges.some(R=>R.a===r&&R.b===P||R.b===r&&R.a===P);return e.jsxs("g",{className:`amx-graph-node${N.center?" center":""}${N.ghost?" ghost":""}${r!==null?I?" hl":" dim":""}`,onPointerDown:S(P),onPointerEnter:()=>u(P),onPointerLeave:()=>u(null),onClick:()=>{b.current||N.center||(N.ghost?Sn().openWikiLink(N.path):Te(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 il=t=>/\.md$/i.test(t);function ol(t){const n=t.replace(/\.md$/i,""),s=n.split(/[\\/]/).pop()||n;return n===s?n:`${n}|${s}`}function rl(t){return Di(t).filter(n=>n.kind==="note").map(n=>il(n.path)?`[[${ol(n.path)}]]`:`![[${n.path}]]`)}ve({"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 js(t){try{await ba(t,!0)}catch(s){return{ok:!1,reason:W("unilock.failed.save",{err:Va(s)})}}const n=await Q.readTextFile(t).catch(()=>null);return n==null?{ok:!1,reason:W("unilock.failed.read")}:{ok:!0,raw:n}}const ll=t=>(t.split("/").pop()??t).replace(/\.md$/i,"");function Ja(t,n,s,a){vs({level:"error",dedupeKey:`amx-lock:${t}`,text:W(n?"unilock.failed.lock":"unilock.failed.unlock",{name:ll(t),reason:s}),action:{label:W("unilock.retry"),run:a}})}async function Za(t,n,s){const a=await js(n);return a.ok?(Ri(t,n,s),!0):(Ja(n,s,a.reason,()=>{Za(t,n,s)}),!1)}ve({"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 cl=t=>(t.split("/").pop()??t).replace(/\.md$/i,"");function gn(t,n,s){vs({level:"error",dedupeKey:`amx-hist-restore:${t}`,text:W("pghist.failed",{name:cl(t),reason:n}),...s?{action:{label:W("pghist.retry"),run:s}}:{}})}async function dl(t,n){const s=Q.restorePageHistory;if(!s)return!1;const a=()=>{dl(t,n)},l=await js(t);if(!l.ok)return gn(t,l.reason,a),!1;let o;try{o=await s(t,n.id,yi(l.raw))}catch(r){return gn(t,Va(r),a),!1}return o.ok?(ji(t,{}),vs({level:"success",text:W("pghist.done",{time:Mi(n.at)})}),!0):(o.current==null?gn(t,W("pghist.failed.gone")):gn(t,W("pghist.failed.conflict"),a),!1)}const ul=Fi(()=>bi(()=>import("./PageHistoryPanel-KhKT1DLy.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47]),import.meta.url));function hl({path:t,locked:n,onClose:s}){return e.jsx(c.Suspense,{fallback:null,children:e.jsx(ul,{path:t,locked:n,onClose:s})})}async function ml(t){await ba(t);const n=ki(t);if(n!=null)return n;const s=await Q.readTextFile(t).catch(()=>null);return s==null?null:cr(s).body}ve({"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 pl=["default","serif","mono"];function fl(t,n,s=W){return[{kind:"choice",id:"font",label:s("amxpage.font"),options:pl.map(a=>({id:a,label:s(`amxpage.font.${a}`),on:t.font===a,run:()=>n({font:a})}))},{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 gl(t,n){const[,s]=c.useState(0);return c.useEffect(()=>$i(()=>s(a=>a+1)),[]),n?Oi(t,n):Ii}function xl(t,n,s){Li(t,n,s)}function vl(t){return{...t.wide?{"data-page-wide":""}:{},...t.small?{"data-page-small":""}:{},...t.font!=="default"?{"data-page-font":t.font}:{}}}const wl={wide:Wa,small:Ka};function bl({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=wl[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(ot,{size:13,className:"amx-pagestyle-check"})]})}function jl({host:t,label:n,scanTrigger:s}){return e.jsx(gr,{scrollContainer:t,contentRoot:t,selector:".page-view h1, .page-view h2, .page-view h3",label:n,scanTrigger:s,placement:"sticky",topOffset:vr,topInset:xr})}ve({"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 Lt=(t,n)=>W("fileimport.withReason",{name:t,reason:n}),Ze=()=>B.getState(),Qe=t=>ja.getState().notify(t);function kl(){return window.amadeusSync?Ze().vaultSide==="cloud":!!window.amadeusCloudVaults}function Sl(t,n){const s=/[ ()<>]/.test(n)?`<${n}>`:n;return`[${t.replace(/[[\]]/g,"")}](${s})`}function Nl(t,n,s,a){return a&&!/[[\]|#]/.test(t)?`![[${t}]]`:Sl(n,s)}function Rn(t){const n=t instanceof Error?t.message:String(t);return/TOO_LARGE|\b413\b/.test(n)?W("fileimport.tooLargeCloud"):/VAULT_FULL/.test(n)?W("fileimport.vaultFull"):n||W("fileimport.unknownError")}async function zl(){const t=window.amadeusSync?(await window.amadeusSync.get().catch(()=>null))?.maxFileBytes:window.amadeusCloudMaxFileBytes;return typeof t=="number"&&t>0?t:null}const Cl=t=>`${+(t/1048576).toFixed(1)} MB`;async function ks(t){if(!kl())return null;const n=await zl();return n!==null&&t.size>n?Cl(n):null}async function Ss(){try{await Ze().refreshStructure?.()}catch{}}function Ns(t){let n=-1;return(s,a)=>{const l=a>0?Math.min(100,Math.floor(s/a*100)):0;l!==n&&(n=l,Qe(W("fileimport.uploading",{name:t,pct:l})))}}function Qa(t,n){const s=W("fileimport.placeholder",{name:n}),a=Ze().activePage===t?Ze().insertBlockAfter(null,void 0,s):null,l=()=>!!a&&Ze().activePage===t&&Ze().blocks[a]?.content===s;return{done:o=>l()?(Ze().setBlockContent(a,o),!0):!1,fail:()=>{l()&&Ze().setBlockContent(a,W("fileimport.placeholderFailed",{name:n}))}}}async function Nn(t,n){if(!t.length||!n)return;const{opts:s,preview:a}=await Ai();let l=0,o=0;const r=[];for(const u of t){const x=await ks(u);if(x){r.push(Lt(u.name,W("fileimport.overCloudLimit",{limit:x})));continue}const m=Qa(n,u.name);try{const k=new Uint8Array(await u.arrayBuffer()),{pageRel:p,base:j}=await Q.saveAttachment(n,u.name,k,s,Ns(u.name));m.done(Nl(j,u.name,p,a))||Ze().activePage===n?l++:o++}catch(k){m.fail(),r.push(Lt(u.name,Rn(k)))}}await Ss(),r.length?Qe(W(r.length===1?"fileimport.notImportedOne":"fileimport.notImportedMany",{n:r.length,first:r[0]})):o?Qe(W("fileimport.movedAway")):t.length>1?Qe(W(l===1?"fileimport.importedOne":"fileimport.importedMany",{n:l})):Qe(W("fileimport.uploadedOne",{name:t[0].name}))}async function na(t,n){if(!t.length)return;let s=0;const a=[];for(const o of t){const r=await ks(o);if(r){a.push(Lt(o.name,W("fileimport.overCloudLimit",{limit:r})));continue}try{const u=new Uint8Array(await o.arrayBuffer());await Q.saveAttachment("",o.name,u,{mode:"vault",folder:n},Ns(o.name)),s++}catch(u){a.push(Lt(o.name,Rn(u)))}}await Ss();const l=n?n.split("/").pop()||n:W("fileimport.vaultRoot");a.length?Qe(W(a.length===1?"fileimport.notImportedOne":"fileimport.notImportedMany",{n:a.length,first:a[0]})):Qe(W(s===1?"fileimport.importedToOne":"fileimport.importedToMany",{n:s,where:l}))}async function Pl(t){const n=window.tangu?.readHostFile;if(!n)return[];const s=[],a=[];for(const l of t){const o=l.split(/[\\/]/).pop()||l;try{const r=await n(l);if(!r||r.tooLarge){a.push(Lt(o,W(r?.tooLarge?"fileimport.over50mb":"fileimport.unreadable")));continue}s.push(new File([Bi(r.content)],o,{type:r.mimeType}))}catch(r){a.push(Lt(o,Rn(r)))}}return a.length&&Qe(W(a.length===1?"fileimport.unreadableOne":"fileimport.unreadableMany",{n:a.length,first:a[0]})),s}async function Tl(t,n){if(!t.length||!n)return;let s=0;const a=[];for(const l of t){const o=await ks(l);if(o){a.push(W("fileimport.imageOverCloudLimit",{limit:o}));continue}const r=(l.name||"pasted.png").replace(/\s+/g,"_"),u=Qa(n,r);try{const x=new Uint8Array(await l.arrayBuffer()),m=await Q.saveAsset(n,r,x,Ns(r));!u.done(`![](${m})`)&&Ze().activePage!==n&&s++}catch(x){u.fail(),a.push(Rn(x))}}await Ss(),a.length?Qe(W("fileimport.pasteFailed",{first:a[0]})):s&&Qe(W("fileimport.imageMovedAway"))}function sa(t,n,s=!1){return!!t&&!n&&!s}function El(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((a,l)=>{const o=s[l],r=document.createElement("h1");r.className="amx-title-input amx-title-static",r.textContent=o?.value||o?.placeholder||"",a.replaceWith(r)}),n}const aa="amx.sec.";function Dl(t,n){return t==="1"?!0:t==="0"?!1:n}function zn(t,n=!1){const[s,a]=c.useState(()=>{try{return Dl(localStorage.getItem(aa+t),n)}catch{return n}});return[s,()=>a(o=>{const r=!o;try{localStorage.setItem(aa+t,r?"1":"0")}catch{}return r})]}function ei(t,n){const s=n==="first",a=s?t.children[0]:t.children.at(-1),l=s?a?.columns[0]:a?.columns.at(-1);return(s?l?.children[0]:l?.children.at(-1))?.ref??null}const ti="amadeus.heading.fold";function Rl(t){const n=(t??"").split(`
3
- `,1)[0]??"",s=/^ {0,3}(#{1,6})\s/.exec(n);return s?s[1].length:0}function ia(t){const n=t??"";if(!n.includes("#"))return 0;let s=0,a=!1;for(const l of n.split(`
4
- `)){if(/^ {0,3}(```|~~~)/.test(l)){a=!a;continue}if(a)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 Fl=()=>{try{const t=JSON.parse(localStorage.getItem(ti)||"{}");return t&&typeof t=="object"?t:{}}catch{return{}}},oa=At(t=>({byPage:Fl(),toggle:(n,s)=>t(a=>{const l=a.byPage[n]??[],o=l.includes(s)?l.filter(u=>u!==s):[...l,s],r={...a.byPage};o.length?r[n]=o:delete r[n];try{localStorage.setItem(ti,JSON.stringify(r))}catch{}return{byPage:r}})}));function Ml(t,n){return new Set(t[n]??[])}function $l({col:t,gutterLead:n}){const s=B(r=>r.insertBlockAfter),{setNodeRef:a,isOver:l}=hs({id:`col:${t.id}`}),o=t.children.map(r=>r.ref);return e.jsxs("div",{ref:a,className:"column","data-col":t.id,"data-over":l||void 0,style:{flexGrow:t.width,flexBasis:0},children:[e.jsx(ka,{items:o,strategy:Vi,children:o.map((r,u)=>e.jsx(Sa,{blockId:r,gutterLead:u===0?n:void 0},r))}),e.jsx("button",{className:"col-add",onClick:()=>s(null,t.id),children:"+ 块"})]})}ve({"colresizer.dragHint":{zh:"拖动调整列宽",en:"Drag to resize columns"}});function Il({rowId:t,leftColId:n,rightColId:s}){const a=B(u=>u.resizeColumns),{t:l}=oe(),o=c.useRef(null),r=u=>{u.preventDefault();const x=o.current?.closest(".row-cols");if(!x)return;const m=p=>{const j=x.querySelector(`[data-col="${n}"]`),f=x.querySelector(`[data-col="${s}"]`);if(!j||!f)return;const b=j.getBoundingClientRect().left,L=f.getBoundingClientRect().right;L<=b||a(t,n,s,(p.clientX-b)/(L-b))},k=()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",k)};window.addEventListener("pointermove",m),window.addEventListener("pointerup",k)};return e.jsx("div",{ref:o,className:"col-resizer",onPointerDown:r,title:l("colresizer.dragHint")})}function Ol({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(ra,{rowId:t.id,side:"left"}),e.jsx("div",{className:"row-cols",children:t.columns.map((a,l)=>e.jsxs(c.Fragment,{children:[l>0&&e.jsx(Il,{rowId:t.id,leftColId:t.columns[l-1].id,rightColId:a.id}),e.jsx($l,{col:a,gutterLead:l===0?n:void 0})]},a.id))}),!s&&e.jsx(ra,{rowId:t.id,side:"right"})]})}function ra({rowId:t,side:n}){const{setNodeRef:s,isOver:a}=hs({id:`edge:${t}:${n}`});return e.jsx("div",{ref:s,className:"edge-zone","data-side":n,"data-over":a||void 0})}function Ll(){const t=B(u=>u.activePage),n=B(u=>u.linkGraphVersion),s=B(u=>u.loadPage),[a,l]=c.useState([]),[o,r]=c.useState(!1);return c.useEffect(()=>{let u=!0;if(!t){l([]);return}return Q.backlinks(t).then(x=>{u&&l(x)}),()=>{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?"▸":"▾"}),"链接到本页 · ",a.length]}),!o&&e.jsxs("div",{className:"backlinks-list",children:[a.length===0&&e.jsx("div",{className:"backlinks-empty",children:"还没有其它页面链接到这里"}),a.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}ve({"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 Al(t,n){return t==="saving"?n("amxpv.statusSaving"):t==="loading"?n("amxpv.statusLoading"):t==="ready"?n("amxpv.statusReady"):""}function Bl(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 la({index:t}){const{setNodeRef:n,isOver:s}=hs({id:`gap:${t}`});return e.jsx("div",{ref:n,className:"row-gap","data-over":s||void 0})}function Cn(t){const n=(t??ms(Dn())).getState(),s=n.manifest?ei(n.manifest.root,"first"):null;s?n.requestFocus(s,"start"):n.insertBlockAfter(null)}const Vl=t=>{const n=Da(t);return n.length?n:Ui(t)};function Wl(t){const n=t.getState(),s=n.manifest?ei(n.manifest.root,"last"):null;s&&!n.blocks[s]?.content?n.requestFocus(s,"end"):n.insertBlockAfter(null)}const Kn=24,_l=16,ql=typeof requestIdleCallback=="function"?t=>requestIdleCallback(t,{timeout:200}):t=>window.setTimeout(t,16),Ul=typeof cancelIdleCallback=="function"?cancelIdleCallback:clearTimeout;function Hl({bare:t=!1}={}){const{t:n}=oe(),s=B(E=>E.manifest),a=B(E=>E.blocks),l=B(E=>E.status),o=B(E=>E.activePage),r=B(E=>E.moveBlock),u=B(E=>E.addColumnWithBlock),x=B(E=>E.addRowWithBlock),m=B(E=>E.insertBlockAfter),k=B(E=>E.renamePage),p=B(E=>E.setDnd),j=Na(),f=jt();c.useEffect(()=>{const E=za(j);E&&f.getState().requestFocusAt(E.blockId,E.anchor)},[]);const[b,L]=c.useState([]),D=c.useRef([]),H=b[0]??null,[S,O]=c.useState(!1),[F,N]=c.useState(""),P=Ca(Qn(Wi,{activationConstraint:{distance:5}})),I=oa(E=>E.byPage);c.useEffect(()=>{const E=A=>{if(!(A.metaKey||A.ctrlKey))return;const _=A.key.toLowerCase();if(_!=="z"&&_!=="y")return;const M=A.target;if(M&&(M.tagName==="INPUT"||M.tagName==="TEXTAREA"||M.isContentEditable)||A.defaultPrevented||Dn()!==j)return;A.preventDefault();const de=f.getState();_==="y"||A.shiftKey?de.redo():de.undo()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[]);const R=s?.root.children.length??0,[U,K]=c.useState({page:o,n:Kn});U.page!==o&&K({page:o,n:Kn});const ae=U.page===o?U.n:Kn;if(c.useEffect(()=>{if(ae>=R)return;const E=ql(()=>K(A=>({...A,n:A.n+_l})));return()=>Ul(E)},[ae,R]),!s)return e.jsx("div",{className:"empty-state",children:n("amxpv.openVault")});const q=s.root,te=E=>{const A=(E??"").indexOf(`
6
- `);return A<0?"":(E??"").slice(A+1)},he=q.children.map(E=>{const A=E.columns[0]?.children[0]?.ref;let _=0,M=0;for(const de of E.columns)for(const pe of de.children){const Ke=a[pe.ref]?.content,Ne=ia(Ke);Ne&&(!_||Ne<_)&&(_=Ne);const ye=pe.ref===A?ia(te(Ke)):Ne;ye&&(!M||ye<M)&&(M=ye)}return{firstId:A,level:Rl(A?a[A]?.content:void 0),bound:_,self:M}}),Se=E=>{const A=he[E];if(!A.level||A.self&&A.self<=A.level)return 0;let _=0;for(let M=E+1;M<he.length&&!(he[M].bound&&he[M].bound<=A.level);M++)_++;return _},ue=Ml(I,o??""),J=new Set;if(!H)for(let E=0;E<he.length;E++){const A=he[E];if(!(!A.level||!A.firstId||!ue.has(A.firstId)))for(let _=E+1;_<=E+Se(E);_++)J.add(_)}const ce=s.title||o?.split("/").pop()||"",T=()=>{N(ce),O(!0)},g=async()=>{O(!1);const E=F.trim();E&&E!==ce&&await k(E)},se=E=>{for(const A of q.children)for(const _ of A.columns)if(_.children.some(M=>M.ref===E))return _.id;return null},ne=E=>{const A=String(E.active.id),_=qi.getState(),M=_.ids.has(A)?f.getState().flatOrder().filter(pe=>_.ids.has(pe)):[A];_.ids.has(A)||_.select(A);const de=M.length?M:[A];D.current=de,L(de),p(A,null)},me=E=>{const A=String(E.active.id),_=E.over?String(E.over.id):"",M=_&&!_.includes(":")&&_!==A?_:null;p(A,M)},xe=()=>{D.current=[],L([]),p(null,null)},Oe=E=>{const A=String(E.active.id),_=D.current.includes(A)?D.current:[A];if(D.current=[],L([]),p(null,null),!E.over)return;const M=String(E.over.id);if(M.startsWith("bedge:")){const[,de,pe]=M.split(":");f.getState().pairBlocks(_,de,pe==="left"?"left":"right")}else if(M.startsWith("edge:")){const[,de,pe]=M.split(":");u(de,_,pe==="left"?"left":"right")}else if(M.startsWith("gap:"))x(Number(M.slice(4)),_);else if(M.startsWith("col:"))r(_,M.slice(4),null);else if(M!==A){const de=se(M);de&&r(_,de,M)}};return e.jsxs("div",{className:"page-view","data-bare":t||void 0,children:[e.jsx(_i,{}),!t&&e.jsxs("header",{className:"page-header",children:[S?e.jsx("input",{className:"page-title-edit",autoFocus:!0,value:F,onChange:E=>N(E.target.value),onBlur:()=>{g()},onKeyDown:E=>{if(E.key==="Enter")E.preventDefault(),Cn(f),g();else if(E.key==="ArrowRight"||E.key==="ArrowDown"){const A=E.currentTarget;A.selectionStart===A.value.length&&A.selectionEnd===A.value.length&&(E.preventDefault(),Cn(f),g())}else E.key==="Escape"&&O(!1)}}):e.jsx("div",{className:"page-title",onClick:T,title:n("amxpv.renameTitle"),children:ce}),e.jsx("div",{className:"page-status","data-status":l,children:Al(l,n)})]}),e.jsxs(Pa,{sensors:P,collisionDetection:Vl,measuring:{droppable:{strategy:Ta.Always}},onDragStart:ne,onDragOver:me,onDragEnd:Oe,onDragCancel:xe,children:[e.jsxs("div",{className:"stack","data-dnd":H?"":void 0,children:[e.jsx(la,{index:-1}),q.children.map((E,A)=>{if(A>=ae||J.has(A))return null;const _=he[A],M=Se(A),de=!!(_.firstId&&ue.has(_.firstId));return e.jsxs(c.Fragment,{children:[e.jsxs("div",{className:`amx-hfold-wrap${M>0&&_.firstId?" has-fold":""}`,children:[de&&M>0&&e.jsx("span",{className:"amx-hfold-count",children:M}),e.jsx(Ol,{row:E,gutterLead:M>0&&_.firstId?e.jsx("button",{className:`amx-hfold${de?" folded":""}`,title:de?n("amxpv.expandSection",{n:M}):n("amxpv.foldSection"),onClick:pe=>{pe.stopPropagation(),oa.getState().toggle(o??"",_.firstId)},children:"›"}):void 0})]}),e.jsx(la,{index:A})]},E.id)})]}),e.jsx(Ea,{dropAnimation:null,children:H?e.jsxs("div",{className:"drag-overlay",children:[b.length>1?`${n("amxpv.dragBlocks",{n:b.length})} · `:"",Bl(a[H]?.content,n)]}):null})]}),t&&e.jsx("div",{className:"page-tail",onClick:()=>Wl(f)}),!t&&e.jsxs("div",{className:"page-footer",children:[e.jsx("button",{className:"add-block",onClick:()=>m(null),children:n("amxpv.addBlock")}),e.jsx("span",{className:"hint-inline",children:n("amxpv.dndHint")})]}),!t&&e.jsx(Ll,{})]})}ve({"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 Kl({onClose:t}){const{t:n}=oe(),s=window.amadeusCollab,a=(S,O=!1)=>De.getState().toast(S,O),[l,o]=c.useState([]),[r,u]=c.useState(""),[x,m]=c.useState([]),[k,p]=c.useState([]),[j,f]=c.useState(null),[b,L]=c.useState(null),D=()=>{s&&(s.listVaults().then(S=>o(S.map(O=>({id:O.id,name:O.name})))).catch(()=>{}),s.activeVaultId().then(u).catch(()=>{}),s.sharedWithMe().then(m).catch(()=>m([])),s.publishes().then(S=>{p(S.shares),f(S.quota)}).catch(()=>p([])))};if(c.useEffect(D,[]),!s)return null;const H=(S,O)=>{navigator.clipboard.writeText(S).then(()=>{L(O),setTimeout(()=>L(null),1200)})};return e.jsx("div",{className:"amxc-overlay",onClick:t,children:e.jsxs("div",{className:"amxc-panel",onClick:S=>S.stopPropagation(),children:[e.jsxs("div",{className:"amxc-head",children:[e.jsxs("span",{children:[e.jsx(it,{size:14})," ",n("cloudvault.title")]}),e.jsx("button",{className:"amxc-x",onClick:t,children:e.jsx(ps,{size:14})})]}),e.jsx("div",{className:"amxc-sec",children:n("cloudvault.myVaults")}),l.map(S=>e.jsxs("button",{className:`amxc-row${S.id===r?" on":""}`,onClick:()=>{S.id!==r&&s.switchVault(S.id)},children:[e.jsx("span",{className:"amxc-row-name",children:S.name}),S.id===r&&e.jsx(ot,{size:13})]},S.id)),e.jsxs("div",{className:"amxc-sec",children:[e.jsx(Ra,{size:12})," ",n("cloudvault.sharedWithMe",{n:x.length})]}),x.length===0&&e.jsx("div",{className:"amxc-hint",children:n("cloudvault.sharedEmpty")}),x.map(S=>e.jsxs("button",{className:"amxc-row",onClick:()=>{t(),S.vaultId===r?Te(S.path):s.switchVault(S.vaultId)},children:[e.jsx("span",{className:"amxc-row-name",children:S.title}),e.jsxs("span",{className:"amxc-tag",children:[S.role==="viewer"?n("cloudvault.roleViewer"):n("cloudvault.roleEditor"),S.ownerName?` · ${S.ownerName}`:""]})]},`${S.vaultId}:${S.path}`)),e.jsxs("div",{className:"amxc-sec",children:[e.jsx(fs,{size:12})," ",n("cloudvault.published",{n:k.length}),j&&Number.isFinite(j.publish)?` / ${j.publish}`:""]}),k.length===0&&e.jsx("div",{className:"amxc-hint",children:n("cloudvault.publishedEmpty")}),k.map(S=>e.jsxs("div",{className:"amxc-row static",children:[e.jsxs("span",{className:"amxc-row-name",title:S.path,children:[S.mode==="subtree"?"📁 ":"📄 ",S.path]}),e.jsx("button",{className:"amxc-ic",title:n("cloudvault.copyLink"),onClick:()=>H(s.publishUrl(S.token),S.token),children:b===S.token?e.jsx(ot,{size:12}):e.jsx(Rt,{size:12})}),e.jsx("button",{className:"amxc-ic",title:n("cloudvault.unpublish"),onClick:()=>{s.revokePublish(S.token).then(()=>{a(n("cloudvault.unpublished")),D()})},children:e.jsx(He,{size:12})})]},S.token))]})})}ve({"presencedots.viewing":{zh:"{name} 正在看 {page}",en:"{name} is viewing {page}"},"presencedots.online":{zh:"{name} 在线",en:"{name} is online"}});function Gl(){const{t}=oe(),n=window.amadeusCollab,s=B(m=>m.activePage??m.activeNotePath),a=B(m=>m.vaultSide),[l,o]=c.useState([]),r=!window.amadeusSync||a==="cloud";if(c.useEffect(()=>{if(!n||!r)return;const m=n.onPresence(o);return()=>{m(),n.stopHeartbeat()}},[n,r]),c.useEffect(()=>{r&&n?.heartbeat(s)},[n,s,r]),!n||!r)return null;const u=n.myUserId(),x=l.filter(m=>m.userId!==u);return x.length?e.jsxs("span",{className:"amxc-presence",title:x.map(m=>`${m.username}${m.page?` · ${m.page.replace(/\.md$/i,"")}`:""}`).join(`
7
- `),children:[x.slice(0,5).map(m=>e.jsx("span",{className:`amxc-dot${m.page&&m.page===s?" same":""}`,title:m.page?t("presencedots.viewing",{name:m.username,page:m.page.replace(/\.md$/i,"")}):t("presencedots.online",{name:m.username}),children:(m.username||"?").slice(0,1).toUpperCase()},m.userId)),x.length>5&&e.jsxs("span",{className:"amxc-dot more",children:["+",x.length-5]})]}):null}function Yl(t,n){return t.path===n?!0:t.mode==="subtree"?n.startsWith(`${t.path}/`):n.startsWith(`${t.path.replace(/\.md$/i,"")}.fd/`)}function ni(t,n){const s=n.find(l=>l.path===t);if(s)return{kind:"direct",token:s.token};const a=n.find(l=>Yl(l,t));return a?{kind:"inherited",via:a.path,viaMode:a.mode==="subtree"?"subtree":"page",token:a.token}:{kind:"none"}}ve({"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 ca=t=>Number.isFinite(t)?String(t):W("share.unlimited"),Xl=t=>(t.split("/").pop()??t).replace(/\.md$/i,"");function Jl({path:t,anchor:n,onClose:s}){const a=B(u=>u.vaultRoot),l=B(u=>u.vaultSide),o=Ee(u=>u.vaults),r=ys(o,a,l,t)??"";return e.jsx(Zl,{path:r,localPath:t,anchor:n,onClose:s},JSON.stringify([a,l,t,r]))}function Zl({path:t,localPath:n,anchor:s,onClose:a}){const l=window.amadeusCollab,{t:o}=oe(),r=(J,ce=!1)=>De.getState().toast(J,ce),u=c.useRef(!1),x=c.useRef(0),[m,k]=c.useState("share"),[p,j]=c.useState(null),[f,b]=c.useState(null),[L,D]=c.useState(null),[H,S]=c.useState({kind:"none"}),[O,F]=c.useState(0),[N,P]=c.useState(!1),[I,R]=c.useState(null),[U,K]=c.useState(""),[ae,q]=c.useState(!1),te=()=>{if(!u.current||!l||!t)return;const J=++x.current,ce=()=>u.current&&J===x.current;l.pageShare(t).then(T=>{ce()&&(j(T.share),b(T.quota),q(!1))}).catch(T=>{ce()&&T?.status===404&&q(!0)}),l.publishes().then(T=>{if(!ce())return;b(T.quota),F(T.shares.length);const g=T.shares.find(se=>se.path===t&&se.mode==="page");D(g?{token:g.token,url:l.publishUrl(g.token)}:null),S(ni(t,T.shares))}).catch(()=>{})};if(c.useEffect(()=>(u.current=!0,te(),()=>{u.current=!1,x.current++}),[l,t]),!l)return null;const he=(J,ce)=>{navigator.clipboard.writeText(J).then(()=>{u.current&&(R(ce),setTimeout(()=>{u.current&&R(null)},1200))})},Se=(J,ce)=>{const T=J;if(T?.status===404){r(o("share.notUploaded"),!0);return}r(T?.code==="QUOTA"?T.message||o("share.quotaReached"):ce,!0)},ue=(J,ce,T=o("share.opFailed"))=>{P(!0),J.then(()=>{u.current&&(ce&&r(ce),te())}).catch(g=>{u.current&&Se(g,T)}).finally(()=>{u.current&&P(!1)})};return e.jsx("div",{className:"amxc-cardwrap",onClick:a,children:e.jsxs(vt,{className:"amxc-card",x:s.x-340,y:s.y+6,onClick:J=>J.stopPropagation(),children:[e.jsxs("div",{className:"amxc-tabs",children:[e.jsx("button",{className:m==="share"?"on":"",onClick:()=>k("share"),children:o("share.tabShare")}),e.jsx("button",{className:m==="publish"?"on":"",onClick:()=>k("publish"),children:o("share.tabPublish")}),e.jsx("span",{className:"amxc-flex"}),e.jsx("button",{className:"amxc-x",onClick:a,children:e.jsx(ps,{size:14})})]}),t?ae?e.jsx("div",{className:"amxc-hint",style:{padding:"18px 8px"},children:o("share.ownerOnly")}):m==="share"?p?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(p.inviteToken)}),e.jsx("button",{className:"amxc-ic",title:o("share.copyInvite"),onClick:()=>he(l.inviteUrl(p.inviteToken),"inv"),children:I==="inv"?e.jsx(ot,{size:13}):e.jsx(Rt,{size:13})}),e.jsx("button",{className:"amxc-ic",title:o("share.rotate"),onClick:()=>ue(l.updatePageShare(p.id,{rotate:!0}),o("share.rotated")),children:e.jsx(Ki,{size:13})})]}),e.jsxs("div",{className:"amxc-frow",children:[e.jsx("span",{className:"amxc-lbl",children:o("share.linkRole")}),e.jsxs("select",{value:p.inviteRole,onChange:J=>ue(l.updatePageShare(p.id,{role:J.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:p.expiresAt===null?"forever":"7",onChange:J=>ue(l.updatePageShare(p.id,{expiresDays:J.target.value==="forever"?null:Number(J.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")}),p.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:()=>ue(l.updatePageShare(p.id,{password:null}),o("share.passwordCleared")),children:e.jsx(He,{size:12})})]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"amxc-input",placeholder:o("share.passwordOptional"),value:U,onChange:J=>K(J.target.value)}),e.jsx("button",{className:"amxc-ic",title:o("share.setPassword"),disabled:!U.trim(),onClick:()=>{const J=U.trim();K(""),ue(l.updatePageShare(p.id,{password:J}),o("share.passwordSaved"))},children:e.jsx(ot,{size:13})})]})]}),e.jsx("div",{className:"amxc-sec",children:o("share.participants",{n:p.participants.length})}),p.participants.length===0&&e.jsx("div",{className:"amxc-hint",children:o("share.noParticipants")}),p.participants.map(J=>e.jsxs("div",{className:"amxc-row static",children:[e.jsx("span",{className:"amxc-row-name",children:J.username??J.userId.slice(0,8)}),e.jsxs("select",{value:J.role,onChange:ce=>ue(l.setParticipantRole(p.id,J.userId,ce.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:()=>ue(l.removeParticipant(p.id,J.userId),o("share.removed")),children:e.jsx(He,{size:12})})]},J.userId)),e.jsx("button",{className:"amxc-danger",disabled:N,onClick:()=>ue(l.revokePageShare(p.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||(f?f.collab<=0:!1),onClick:()=>ue(l.createPageShare(t,{role:"editor",expiresDays:7}),o("share.enabled")),children:[e.jsx(Hi,{size:13})," ",o("share.enable")]}),f&&(f.collab<=0?e.jsx("div",{className:"amxc-hint",children:o("share.planNoCollab")}):e.jsx("div",{className:"amxc-hint",children:o("share.quotaCollab",{n:ca(f.collab)})}))]}):e.jsxs("div",{className:"amxc-body",children:[L?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"amxc-frow",children:[e.jsx("input",{className:"amxc-input",readOnly:!0,value:L.url}),e.jsx("button",{className:"amxc-ic",title:o("share.copyLink"),onClick:()=>he(L.url,"pub"),children:I==="pub"?e.jsx(ot,{size:13}):e.jsx(Rt,{size:13})})]}),e.jsxs("div",{className:"amxc-frow",children:[e.jsx("button",{className:"amxc-danger",disabled:N,onClick:()=>ue(l.revokePublish(L.token),o("share.unpublished")),children:o("share.unpublish")}),e.jsx("a",{className:"amxc-view",href:L.url,target:"_blank",rel:"noreferrer",children:o("share.viewPage")})]})]}):H.kind==="inherited"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"amxc-hint",children:o("share.inherited",{kind:H.viaMode==="subtree"?o("share.viaFolder"):o("share.viaPage"),name:Xl(H.via)})}),e.jsxs("div",{className:"amxc-frow",children:[e.jsx("input",{className:"amxc-input",readOnly:!0,value:`${l.publishUrl(H.token)}#${encodeURIComponent(t)}`}),e.jsx("button",{className:"amxc-ic",title:o("share.copyPageLink"),onClick:()=>he(`${l.publishUrl(H.token)}#${encodeURIComponent(t)}`,"pub"),children:I==="pub"?e.jsx(ot,{size:13}):e.jsx(Rt,{size:13})})]}),e.jsx("div",{className:"amxc-hint",children:o("share.inheritedStop",{kind:H.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:()=>ue(l.createPublish("page",t),o("share.published")),children:[e.jsx(fs,{size:13})," ",o("share.publish")]})]}),f&&e.jsx("div",{className:"amxc-hint",children:o("share.publishCount",{used:O,total:ca(f.publish)})})]}):e.jsx("div",{className:"amxc-hint",style:{padding:"18px 8px"},children:o("share.notInCloud")}),e.jsx(Ql,{path:n,onClose:a})]})})}function Ql({path:t,onClose:n}){const s=B(r=>r.vaultRoot),a=B(r=>r.vaultSide);Ee(r=>r.vaults);const{t:l}=oe();if(!window.amadeusSync?.entrySyncEnable||a!=="local")return null;const o=en(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(os,{size:13})," ",l("share.syncOff")]}):e.jsxs("button",{className:"amxc-primary",onClick:()=>{n(),yt(t,"page")},children:[e.jsx(It,{size:13})," ",l("share.syncOn")]})})}ve({"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 ec=t=>(t.split("/").pop()??t).replace(/\.md$/i,"");function tc({path:t,refreshKey:n,onOpen:s}){const a=B(u=>u.vaultRoot),l=B(u=>u.vaultSide),o=Ee(u=>u.vaults),r=ys(o,a,l,t);return e.jsx(nc,{path:r??"",refreshKey:n,onOpen:s},JSON.stringify([a,l,t,r]))}function nc({path:t,refreshKey:n,onOpen:s}){const a=window.amadeusCollab,[l,o]=c.useState(!1),[r,u]=c.useState({kind:"none"}),{t:x}=oe();if(c.useEffect(()=>{if(!a||!t){o(!1),u({kind:"none"});return}let p=!0;return a.pageShare(t).then(j=>p&&o(!!j.share)).catch(()=>p&&o(!1)),a.publishes().then(j=>p&&u(ni(t,j.shares))).catch(()=>p&&u({kind:"none"})),()=>{p=!1}},[a,t,n]),!a)return null;const m=r.kind!=="none";if(!l&&!m)return null;const k=p=>{p.stopPropagation();const j=p.currentTarget.getBoundingClientRect();s(j.right,j.bottom)};return e.jsxs("span",{className:"amx-sharestat",children:[l&&e.jsxs("button",{className:"amx-sharestat-chip is-collab",title:x("sharestatus.collabTitle"),onClick:k,children:[e.jsx(Ra,{size:12})," ",x("sharestatus.collab")]}),m&&e.jsxs("button",{className:"amx-sharestat-chip is-pub",title:r.kind==="inherited"?x("sharestatus.inheritedTitle",{name:ec(r.via)}):x("sharestatus.pubTitle"),onClick:k,children:[e.jsx(fs,{size:12})," ",r.kind==="inherited"?x("sharestatus.inherited"):x("sharestatus.published")]})]})}const xt=t=>{const n=t.split(/[\\/]/).filter(Boolean);return n.pop(),n.join("/")};function sc(t,n){return n?.mergedFd!=null?{folder:n.mergedFd}:/\.md$/i.test(t)&&!Ht(t)&&!Qt(t)&&!n?.pluginFile?{page:t}:{folder:xt(t)}}const Gn=t=>"page"in t?t.page:t.folder;function ac(t,n,s){return n&&t.includes(s.paths)&&!t.includes(s.ref)}ve({"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 ic=t=>(t.split(/[\\/]/).pop()??t).replace(/\.md$/i,"");function da(t,n,s){const a=ic(t),l=n.filter(r=>Ts(r)===Ts(t)).length<=1,o=l?a:t.replace(/\\/g,"/").replace(/\.md$/i,"");return s===a&&l?a:`${o}|${s}`}function oc({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 rc(){const{t}=oe(),n=B(f=>f.activePage??f.activeNotePath),s=B(f=>f.linkGraphVersion),a=B(f=>f.pages),[l,o]=c.useState([]),[r,u]=c.useState(!1),[x,m]=c.useState(null),[k,p]=c.useState(0);c.useEffect(()=>{let f=!0;if(!n){o([]);return}return Q.backlinks(n).then(b=>{f&&o(b)}),()=>{f=!1}},[n,s,k]),c.useEffect(()=>{let f=!0;if(!n||!r||!Q.unlinkedMentions){m(null);return}return Q.unlinkedMentions(n).then(b=>{f&&m(b)}).catch(()=>{f&&m([])}),()=>{f=!1}},[n,r,s,k]);const j=async(f,b)=>{if(!n||!Q.linkMention||b.raw===void 0||b.occ===void 0||b.col===void 0||!b.match)return;const L=da(n,a,b.match);await Q.linkMention(f,{raw:b.raw,occ:b.occ,col:b.col,match:b.match},L).catch(()=>!1)||window.dispatchEvent(new CustomEvent("amadeus:toast",{detail:{text:W("amxbl.linkFailed")}})),p(H=>H+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(f=>e.jsxs("div",{className:"amx-backlink-group",children:[e.jsx("button",{className:"amx-list-item amx-backlink-src",onClick:()=>{Te(f.path)},title:f.path,children:f.title}),(f.hits??(f.snippet?[{line:1,text:f.snippet}]:[])).map((b,L)=>e.jsxs("button",{className:"amx-list-item amx-backlink-hit",onClick:()=>{Te(f.path)},children:[b.line===0&&e.jsx("span",{className:"amx-backlink-prop",children:t("amxbl.prop")}),b.text]},`${b.line}:${L}`))]},f.path))}),Q.unlinkedMentions&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"amx-panel-head amx-backlink-toggle","aria-expanded":r,onClick:()=>u(f=>!f),children:[r?"▾ ":"▸ ",x&&r?t("amxbl.unlinkedCount",{n:x.length}):t("amxbl.unlinked")]}),r&&x&&(x.length===0?e.jsx("div",{className:"amx-panel-empty",children:t("amxbl.unlinkedEmpty")}):e.jsx("div",{className:"amx-list",children:x.map(f=>e.jsxs("div",{className:"amx-backlink-group",children:[e.jsx("button",{className:"amx-list-item amx-backlink-src",onClick:()=>{Te(f.path)},title:f.path,children:f.title}),f.hits.map((b,L)=>e.jsxs("div",{className:"amx-backlink-hit amx-mention",children:[e.jsx("button",{className:"amx-list-item amx-mention-text",onClick:()=>{Te(f.path)},children:e.jsx(oc,{h:b})}),Q.linkMention&&b.col!==void 0&&b.match&&e.jsx("button",{className:"amx-backlink-link",title:t("amxbl.linkTip",{inner:da(n,a,b.match)}),onClick:()=>{j(f.path,b)},children:t("amxbl.link")})]},`${b.line}:${L}`))]},f.path))}))]})]}):e.jsx("div",{className:"amx-panel-empty",children:t("amxv.backlinks.noNote")})]})}ve({"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.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.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 we=()=>B.getState(),ke=t=>t.split(/[\\/]/).pop().replace(/\.md$/,""),xn=t=>t.split("/").pop()||t,st=t=>{const n=[];let s="";for(const a of t.split(/[\\/]/).filter(Boolean))s=s?`${s}/${a}`:a,n.push(s);return n};function si(t,n){const s=Re.getState();for(const a of s.api?.panels??[]){const l=a.params??{};l.__type==="amadeus-editor"&&l.notePath===t&&s.navigateLeaf(a.id,"amadeus-editor",{...l,notePath:n})}}async function ua(t,n){try{await So();const s=await Q.renamePageFile(t,n);if(s!==t){Jn(t,"file",s),No(t,s,"file"),await zo(t,s),si(t,s);const a=we();a.activePage===s&&a.loadPage(s)}}catch(s){window.alert(W("amxv.renameFailed",{e:s instanceof Error?s.message:String(s)}))}await we().refreshStructure()}const lc=()=>!!Q.trashEntry;function cc(t){const n=ft(t),s=[...we().pages,...we().files].filter(a=>a.startsWith(`${n}/`)).length;return s>0?W("amxv.confirm.deleteNoteWithChildren",{name:ke(t),n:s}):W("amxv.confirm.deleteNote",{name:ke(t)})}async function Pn(t,n=we){if(!ds("note",t))return;const s=await Q.exclusiveAssets?.(t).catch(()=>[])??[];let a=s.length>0?pr():!1;if(s.length>0&&a===null){const l=await fr(ke(t),s);if(l===null)return;a=l==="with"}ws.getState().remove(`note:${t}`),await n().deletePage(t),a&&(await mo(s),await n().refreshStructure())}function ds(t,n){return lc()?!0:t==="note"?window.confirm(cc(n)):t==="file"?window.confirm(W("amxv.confirm.deleteFile",{name:n.split(/[\\/]/).pop()})):window.confirm(W("amxv.confirm.deleteFolder",{name:n.split(/[\\/]/).pop()}))}const ai=At(t=>({locate:null,requestLocate:n=>t(s=>({locate:{path:n,n:(s.locate?.n??0)+1}}))}));B.subscribe((t,n)=>{const s=t.activePage;if(!s||s===n.activePage||Qt(s)&&Gi()!=="mini")return;const a=Dn();queueMicrotask(()=>{const l=Re.getState().api,o=l?gs(l):null,r=o&&(o.params??{}).__type==="amadeus-editor"&&o.id===a?o.id:a;Ma(r,`amadeus:${s}`,()=>{const u=Re.getState(),x=r?u.leafById(r):null;x&&(x.type!=="amadeus-editor"&&u.navigateLeaf(r,"amadeus-editor",{notePath:s}),ms(r).getState().loadPage(s))})}),ws.getState().record({key:`note:${s}`,kind:"note",id:s,title:ke(s)})});function zs({path:t,hideLoneLeaf:n}={}){const s=B(p=>p.activePage),a=ai(p=>p.requestLocate),l=t??s;if(!l||n&&!l.includes("/"))return null;const o=l.replace(/(\.dashboard)?\.md$/i,"").split("/"),r=Fa(l),u=r?Yt(l,r.extensions):o[o.length-1],x=o.slice(0,-1).map((p,j)=>({seg:p,target:o.slice(0,j+1).join("/")})),m=x.length>3?[...x.slice(0,2),{seg:"…",target:null},x[x.length-1]]:x,k=m.length;return e.jsxs("div",{className:"amx-crumbs",children:[k>0&&e.jsx("span",{className:"amx-crumbs-parents",children:e.jsx("span",{className:"amx-crumbs-parents-in",children:m.map((p,j)=>e.jsxs("span",{className:"amx-crumb-seg",style:{"--d":`${(k-1-j)*25}ms`},children:[p.target?e.jsx("button",{className:"amx-crumb",title:p.target,onClick:()=>a(p.target),children:p.seg.replace(/\.fd$/i,"")}):e.jsx("span",{className:"amx-crumb amx-crumb-ellipsis",title:l,children:"…"}),e.jsx("span",{className:"amx-crumb-sep",children:"/"})]},`${p.target??"gap"}-${j}`))})}),e.jsx("button",{className:"amx-crumb amx-crumb-leaf",title:l,onClick:()=>a(l),children:u})]})}const wt=t=>/\.md$/i.test(t),Tt=t=>/\.db$/i.test(t),ha=t=>/\.pdf$/i.test(t),Yn=t=>/\.(png|jpe?g|gif|webp|svg|avif|bmp|ico)$/i.test(t),ma=t=>(t.split(/[\\/]/).pop()||t).replace(/\.db$/i,"");function dc(){const{t}=oe(),[n,s]=c.useState(null),[a,l]=c.useState(!1),o=!!Q.listTrash,r=()=>{Q.listTrash?.().then(s).catch(()=>{})};if(c.useEffect(()=>{o&&r()},[o]),c.useEffect(()=>{if(o)return Q.onStructureChange(()=>r())},[o]),!o)return null;const u=n?.length??0,x=m=>{const k=m.replace(/\\/g,"/").lastIndexOf("/");return k===-1?"/":m.slice(0,k)};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(He,{})}),e.jsxs("span",{className:"t2s-special-title",children:[t("amxv.trash.title"),u>0?` (${u})`:""]})]}),a&&e.jsx("div",{className:"amx-trash-wrap",onMouseDown:()=>l(!1),children:e.jsxs("div",{className:"amx-trash-pop",onMouseDown:m=>m.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"))&&Q.emptyTrash?.().then(r)},children:t("amxv.trash.emptyAction")})]}),e.jsxs("div",{className:"amx-trash-list",children:[(n??[]).map(m=>e.jsxs("div",{className:"amx-trash-row",children:[e.jsx("span",{className:"amx-trash-ic",children:m.dir?e.jsx(bs,{}):e.jsx(tn,{})}),e.jsxs("span",{className:"amx-trash-name",title:t("amxv.trash.origin",{path:m.original}),children:[m.name,e.jsx("span",{className:"amx-trash-orig",children:x(m.original)})]}),e.jsx("button",{className:"amx-trash-act",onClick:()=>{Q.restoreTrash?.(m.name).then(()=>{r(),we().refreshStructure()})},children:t("amxv.trash.restore")}),e.jsx("button",{className:"amx-trash-act amx-trash-danger",onClick:()=>{window.confirm(t("amxv.trash.confirmDelete",{name:m.name}))&&Q.deleteTrashEntry?.(m.name).then(r)},"aria-label":"delete forever",children:t("amxv.menu.delete")})]},m.name)),u===0&&e.jsx("div",{className:"t2s-hint",children:t("amxv.trash.emptyHint")})]})]})})]})}function uc({row:t,pages:n}){const{t:s}=oe(),a=Pe(j=>j.starred),l=Pe(j=>j.collections),[o,r]=zn("starred"),[u,x]=zn("collections"),m=new Set(n),k=a.filter(j=>m.has(j));if(!k.length&&!l.length)return null;const p=(j,f,b,L)=>f.length>0&&e.jsxs("div",{className:"amx-prefs-group",children:[e.jsx("button",{className:"t2s-group-toggle amx-sec-grab",onClick:L,children:e.jsxs("span",{className:"t2s-group-name amx-sec-head",children:[e.jsx("span",{className:"t2s-group-label",children:j}),e.jsx("span",{className:`t2s-chev${b?" open":""}`,children:e.jsx(Ft,{size:12})}),e.jsx("span",{className:"t2s-count",children:f.length})]})}),b&&e.jsx("div",{className:"t2s-group-sessions",children:f.map(D=>t(D))})]});return e.jsxs(e.Fragment,{children:[p(s("amxv.sec.starred"),k,o,r),l.length>0&&e.jsxs("div",{className:"amx-prefs-group",children:[e.jsx("button",{className:"t2s-group-toggle amx-sec-grab",onClick:x,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(Ft,{size:12})}),e.jsx("span",{className:"t2s-count",children:l.length})]})}),u&&e.jsx("div",{className:"t2s-group-sessions",children:l.map(j=>e.jsxs("div",{className:"t2s-srow amx-coll-row",role:"button",tabIndex:0,title:s("amxv.sec.searchTip",{q:j.query}),onClick:()=>{ko(),Ya.getState().request(j.query)},children:[e.jsx("span",{className:"amx-coll-ic",children:e.jsx(us,{})}),e.jsx("span",{className:"amx-coll-name",children:j.name}),e.jsx("button",{className:"amx-coll-del",title:s("amxv.sec.removeCollection"),"aria-label":"remove collection",onClick:f=>{f.stopPropagation(),Pe.getState().removeCollection(j.name)},children:"✕"})]},j.name))})]})]})}function hc(){const{t}=oe(),n=window.amadeusCollab,[s,a]=c.useState([]),[l,o]=c.useState("");return c.useEffect(()=>{n&&(n.sharedWithMe().then(a).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?Te(r.localPath):r.vaultId===l?Te(r.path):n.switchVault(r.vaultId)},children:[e.jsx("span",{className:"t2s-special-ic",children:e.jsx(kn,{})}),e.jsx("span",{className:"t2s-special-title",children:r.title})]},`${r.vaultId}:${r.path}`))]})}function Tn({id:t,defaultOpen:n,label:s,count:a,extra:l,dropProps:o,dropActive:r,children:u}){const[x,m]=zn(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:m,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${x?" open":""}`,children:e.jsx(Ft,{size:12})}),a!==void 0&&e.jsx("span",{className:"t2s-count",children:a}),l]})}),x&&e.jsx("div",{className:"t2s-group-sessions",children:u})]})}function mc({row:t,dragPath:n}){const{t:s}=oe(),a=Pe(k=>k.pins),l=B(k=>k.pages),o=B(k=>k.vaultRoot),[r,u]=c.useState(!1),x=c.useMemo(()=>l.filter(k=>a.includes(k)),[l,a]);if(!o||!x.length)return null;const m=!!n&&wt(n)&&!a.includes(n);return e.jsx(Tn,{id:"pinned",label:s("amxv.sec.pinned"),count:x.length,dropActive:r,dropProps:{onDragOver:k=>{m&&(k.preventDefault(),k.stopPropagation(),k.dataTransfer.dropEffect="move",r||u(!0))},onDragLeave:()=>u(!1),onDrop:k=>{m&&(k.preventDefault(),k.stopPropagation(),u(!1),Pe.getState().togglePin(n))}},children:x.map(k=>t(k))})}const pc=t=>t==="TOO_LARGE"?W("amxv.skip.tooLarge"):t==="ASSET_404"?W("amxv.skip.assetMissing"):t,ii=t=>e.jsx("div",{className:"t2s-hint amx-sec-hint amx-cs-warn",title:t.map(n=>`${n.path} — ${pc(n.reason)}`).join(`
8
- `),children:W("amxv.skip.summary",{n:t.length,extra:t.some(n=>n.reason==="TOO_LARGE")?W("amxv.skip.tooLargeNote"):""})});function fc(){oe();const[t,n]=c.useState(null);return c.useEffect(()=>{const s=window.amadeusSync;if(s)return s.get().then(n).catch(()=>{}),s.onStatus(a=>{a.binding||n(a)})},[]),!t?.enabled||!t.skipped.length?null:ii(t.skipped)}function gc({dragPath:t}){const{t:n}=oe(),s=B(F=>F.vaultRoot),a=B(F=>F.pages),l=B(F=>F.files),o=B(F=>F.folders),r=Ee(F=>F.vaults),u=Ee(F=>s?F.status[s]:void 0),[x,m]=c.useState(!1),k=r.find(F=>F.vaultRoot===s);if(!window.amadeusSync?.entrySyncEnable||!s)return null;const p=k?.entries??[];if(!p.length&&!u?.skipped.length)return null;const j=F=>F.replace(/\\/g,"/").normalize("NFC"),f=new Set(a.map(j)),b=new Set(l.map(j)),L=new Set(o.map(j)),D=F=>F.kind==="folder"?L.has(F.path):F.kind==="page"?f.has(F.path):b.has(F.path),H=u?.state==="error"||u?.state==="auth-required"?"err":u?.state==="offline"?"off":"ok",S=k?`${n("amxv.cloud.dotTitle",{name:k.cloudName})}${u?` · ${u.state}${u.skipped.length?` · ${n("amxv.cloud.skippedCount",{n:u.skipped.length})}`:""}`:""}`:n("amxv.cloud.notEnabled"),O=!!t&&!en(s,t);return e.jsxs(Tn,{id:"cloudsync",label:n("amxv.sec.cloudSync"),count:p.length,extra:k?e.jsx("span",{className:`amx-sync-dot ${H}`,title:S}):void 0,dropActive:x,dropProps:{onDragOver:F=>{O&&(F.preventDefault(),F.stopPropagation(),F.dataTransfer.dropEffect="move",x||m(!0))},onDragLeave:()=>m(!1),onDrop:F=>{O&&(F.preventDefault(),F.stopPropagation(),m(!1),yt(t,wt(t)?"page":"asset"))}},children:[!p.length&&e.jsx("div",{className:"t2s-hint amx-sec-hint",children:n("amxv.cloudsync.hint")}),!!u?.skipped.length&&ii(u.skipped),p.map(F=>{const N=D(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"?Te(F.path):F.kind==="asset"&&Tt(F.path)&&wn(F.path))},children:[e.jsx("span",{className:"amx-cs-ic",children:F.kind==="folder"?e.jsx(bs,{}):F.kind==="page"?e.jsx(tn,{}):e.jsx(En,{})}),e.jsx("span",{className:"t2s-srow-title",children:F.kind==="page"?ke(F.path):F.path.split(/[\\/]/).pop()}),e.jsx("button",{className:"amx-coll-del",title:n("amxv.cloud.disableTip"),onClick:P=>{P.stopPropagation(),window.amadeusSync?.entrySyncDisable?.(F.path)},children:"✕"})]},F.path)})]})}function xc(){const{t}=oe(),n=B(i=>i.pages),s=B(i=>i.folders),a=B(i=>i.files),l=B(i=>i.icons),o=B(i=>i.pendingPage??i.activePage??i.activeNotePath),r=B(i=>i.vaultRoot),u=B(i=>i.vaultSide),x=B(i=>i.vaultLoading),m=!!window.amadeusCloudVaults||u==="cloud",[k,p]=c.useState(""),[j,f]=c.useState(new Set),[b,L]=c.useState(!1),[D,H]=c.useState(null),[S,O]=c.useState(null),F=c.useRef(null),N=Dr(F),[P,I]=c.useState(()=>{try{const i=JSON.parse(localStorage.getItem("amx.sec.order")||"[]");return Array.isArray(i)?i.filter(y=>typeof y=="string"):[]}catch{return[]}}),[R,U]=c.useState(null),[K,ae]=c.useState(null),[q,te]=c.useState(null);c.useEffect(()=>{if(!R)return;const i=()=>U(null);return window.addEventListener("pointerup",i),window.addEventListener("pointercancel",i),()=>{window.removeEventListener("pointerup",i),window.removeEventListener("pointercancel",i)}},[R]);const he=["pinned","cloudsync","shared","prefs","tree"],Se=new Map(P.map((i,y)=>[i,y])),ue=P.length?[...he].sort((i,y)=>(Se.get(i)??P.length)-(Se.get(y)??P.length)):he,J=(i,y,w)=>{const $=ue.filter(ge=>ge!==i),le=$.indexOf(y);$.splice(le<0?$.length:w?le+1:le,0,i),I($);try{localStorage.setItem("amx.sec.order",JSON.stringify($))}catch{}},ce=(i,y)=>e.jsx("div",{className:`amx-sec-wrap${q===i&&K&&K!==i?" amx-sec-over":""}`,draggable:R===i,onPointerDown:w=>{w.pointerType!=="mouse"||w.button!==0||w.target.closest(".amx-sec-grab")&&U(i)},onDragStart:w=>{if(R===i){w.stopPropagation(),w.dataTransfer.effectAllowed="move";try{w.dataTransfer.setData("application/x-amx-section",i)}catch{}ae(i)}},onDragEnd:()=>{ae(null),te(null),U(null)},onDragOver:w=>{!K||K===i||(w.preventDefault(),w.stopPropagation(),w.dataTransfer.dropEffect="move",q!==i&&te(i))},onDragLeave:w=>{q===i&&!w.currentTarget.contains(w.relatedTarget)&&te(null)},onDrop:w=>{if(!K||K===i)return;w.preventDefault(),w.stopPropagation();const $=w.currentTarget.getBoundingClientRect();J(K,i,w.clientY>$.top+$.height/2),ae(null),te(null)},children:y},i),[T,g]=c.useState(null),[se,ne]=zn("vault",!0),[me,xe]=c.useState(null),[Oe,E]=c.useState(""),A=c.useRef(null),_=ai(i=>i.locate),[M,de]=c.useState(null),pe=c.useRef(null);c.useEffect(()=>{Xi()},[]),c.useEffect(()=>{Ga(),Ee.getState().refresh()},[r,n,s]);const Ke=Ee(i=>i.vaults),Ne=Ee(i=>i.mirrorVaults);c.useEffect(()=>{me&&A.current?.select()},[me]),c.useEffect(()=>{if(!T)return;const i=()=>g(null);return window.addEventListener("click",i),window.addEventListener("contextmenu",i),()=>{window.removeEventListener("click",i),window.removeEventListener("contextmenu",i)}},[T]),c.useEffect(()=>{if(!_)return;const i=s.includes(_.path)?_.path:xt(_.path);i&&f(w=>new Set([...w,...st(i)])),de(_.path);const y=setTimeout(()=>de(null),1200);return()=>clearTimeout(y)},[_?.n]),c.useEffect(()=>{M&&pe.current?.scrollIntoView({block:"nearest"})},[M]);const ye=k.trim().toLowerCase(),Ge=c.useMemo(()=>Pr(Tr([...n,...a],s)),[n,a,s]),kt=c.useMemo(()=>ye?[...n,...a].filter(i=>ke(i).toLowerCase().includes(ye)):[],[ye,n,a]),[St,je]=c.useState([]);c.useEffect(()=>{const i=window.amadeusCloudVaults;if(!i||window.amadeusSync)return;let y=!0;return i().then(w=>{y&&je(w)}).catch(()=>{}),()=>{y=!1}},[n,s]);const Ve=c.useMemo(()=>{const i=!!window.amadeusSync&&u==="cloud",y=!window.amadeusSync&&!!window.amadeusCloudVaults;if(!i&&!y)return null;const w=i?[...new Set([...Ke.map(h=>h.cloudName),...Ne])].sort():St,$=new Map(Ge.children.filter(h=>h.kind==="folder").map(h=>[h.path,h])),le=w.map(h=>({name:h,node:$.get(h)??null})),ge=new Set(w),d=Ge.children.filter(h=>!(h.kind==="folder"&&ge.has(h.path)));return{vaultSecs:le,rest:d}},[Ge,Ke,Ne,u,St]),et=Re(i=>i.mainTabs),Ye=c.useMemo(()=>{const i=Re.getState().api,y=i?gs(i):null,w=y?{id:y.id,type:String((y.params??{}).__type??"")}:et.find(ge=>ge.active),$=w&&Ji[w.type],le=$?Re.getState().leafById(w.id)?.params?.[$]:null;return typeof le=="string"?le:null},[et]),Me=es(i=>i.fileTypes),ee=es(i=>i.fileCreators),Fe=(i,y,w)=>{g(null),i&&f($=>new Set([...$,...st(i)])),Promise.resolve().then(()=>w(i)).catch($=>{console.error("[plugin] file creator failed",$),De.getState().toast(W("amxv.fileCreatorFailed",{label:y,e:$ instanceof Error?$.message:String($)}),!0)})},tt=i=>f(y=>{const w=new Set(y);return w.has(i)?w.delete(i):w.add(i),w}),Ce=i=>{const y=(D?N.batch(D):[]).filter($=>{if(xt($)===i)return!1;if(hn($)){const le=ft($);if(i===le||i.startsWith(`${le}/`))return!1}return!0});H(null),O(null);const w=ms(Dn());(async()=>{for(const $ of y)await w.getState().movePage($,i)})().catch($=>w.setState({error:String($)}))},Le=i=>Array.from(i.dataTransfer?.types??[]).includes("Files"),nt=i=>ac(Array.from(i.dataTransfer?.types??[]),!!r&&!!window.tangu?.copyHostFiles&&!(window.amadeusSync&&u==="cloud"),{paths:An,ref:La}),Ae=i=>{if(!nt(i))return[];try{const y=JSON.parse(i.dataTransfer?.getData(An)||"null");return Array.isArray(y)?y:[]}catch{return[]}},We=(i,y)=>{const w=Ae(i);return w.length?(i.preventDefault(),i.stopPropagation(),O(null),window.tangu.copyHostFiles(w,y?`${r}/${y}`:r).catch($=>ja.getState().notify(W("amxv.copyFailed",{e:$ instanceof Error?$.message:String($)}))).finally(()=>{we().refreshStructure()}),!0):!1},ht=(i,y)=>{const w=Ae(i);return w.length?(i.preventDefault(),i.stopPropagation(),O(null),Te(y).then(()=>Pl(w)).then($=>{$.length&&X($,y)}),!0):!1},v=(i,y)=>!Le(i)&&!nt(i)?!1:(i.preventDefault(),i.stopPropagation(),i.dataTransfer&&(i.dataTransfer.dropEffect="copy"),S!==y&&O(y),!0),V=(i,y)=>{if(We(i,y))return!0;const w=Array.from(i.dataTransfer?.files??[]);return w.length?(i.preventDefault(),i.stopPropagation(),O(null),na(w,y),!0):!1},G=(i,y)=>sc(i,{mergedFd:y,pluginFile:!!ut(Me,i)}),X=(i,y)=>{Zn(y,i)||Nn(i,y)},ze=(i,y,w)=>v(i,Gn(G(y,w))),Be=(i,y,w)=>{const $=G(y,w);if("page"in $?ht(i,$.page):We(i,$.folder))return!0;const le=Array.from(i.dataTransfer?.files??[]);if(!le.length)return!1;i.preventDefault(),i.stopPropagation(),O(null);const ge=G(y,w);return"page"in ge?Te(ge.page).then(()=>X(le,ge.page)):na(le,ge.folder),!0},_e=(i,y)=>!Le(i)&&!nt(i)?!1:(i.target.closest(y)||v(i,""),!0),nn=(i,y)=>!Le(i)&&!nt(i)?!1:(i.target.closest(y)||V(i,""),!0),sn=()=>{const i=me;xe(null);const y=Oe.trim();if(!i||!y)return;const w=ut(Me,i);if(w){const $=w.extensions.find(ge=>i.toLowerCase().endsWith(ge.toLowerCase()));if(!$||!/\.md$/i.test($))return;const le=Er(y,$);le!==Yt(i,w.extensions)+$.replace(/\.md$/i,"")&&ua(i,le);return}wt(i)?y!==ke(i)&&ua(i,y):Tt(i)&&y.replace(/\.db$/i,"")!==ma(i)&&jo(i,y).catch($=>window.alert(W("amxv.renameFailed",{e:$ instanceof Error?$.message:String($)})))},$e=i=>{const y=ut(Me,i);E(y?Yt(i,y.extensions):Tt(i)?ma(i):ke(i)),xe(i),g(null)},an=async i=>{const y=(await Je(i?W("amadeus.new.folderIn",{folder:xn(i)}):W("amadeus.new.folder"),W("amadeus.default.folder")))?.trim();y&&(we().createFolder(i,y),f(w=>new Set([...w,...st(i?`${i}/${y}`:y)]))),g(null)},Bt=async i=>{g(null);const y=(await Je(i?W("amadeus.new.databaseIn",{folder:xn(i)}):W("amadeus.new.database"),W("amadeus.default.database")))?.trim().replace(/[\\/]/g,"");if(!y)return;const w=i?`${i}/${y}.db`:`${y}.db`;if(we().files.some($=>$.replace(/\\/g,"/")===w)){window.alert(W("amadeus.exists",{name:`${y}.db`}));return}(async()=>{const $=new TextEncoder().encode(Si(Ni(y)));await Q.saveAttachment("",`${y}.db`,$,{mode:"vault",folder:i}),po("base.create"),fo("base.create",{f:w}),await we().refreshStructure(),i&&f(le=>new Set([...le,...st(i)])),wn(w)})().catch($=>window.alert(W("amxv.newBaseFailed",{e:$ instanceof Error?$.message:String($)})))},Vt=i=>{g(null),uo(i).then(y=>{y&&i&&f(w=>new Set([...w,...st(i)]))})},on=i=>{g(null),go(i).then(y=>{y&&i&&f(w=>new Set([...w,...st(i)]))})},Wt=(i,y,w)=>{if(!v(i,w)&&D&&(i.stopPropagation(),!(D===y||xt(D)===w))){if(hn(D)){const $=ft(D);if(w===$||w.startsWith(`${$}/`))return}i.preventDefault(),i.dataTransfer.dropEffect="move",S!==w&&O(w)}},Fn=i=>()=>r?$r(`${r}/${i}`,wt(i)?ke(i):i.split(/[\\/]/).pop()??i):null,rn=i=>{we().createChildNote(i,W("amadeus.default.note")).then(y=>{f(w=>new Set([...w,...st(ft(i))])),Te(y)},()=>{})},Nt=(i,y)=>{const w=Ht(i),$=!w&&Qt(i);(!w&&!$?ut(Me,i):void 0)?$n(i,y):$?ho(i,y):w?Fs(i,y):wt(i)?Te(i,y):Tt(i)?wn(i,y):ha(i)?Ds(i,void 0,y):Yn(i)?Rs(i,y):Q.openVaultFile(i).catch(()=>{})},mt=(i,y=0,w)=>{const $=Ht(i),le=!$&&Qt(i),ge=!$&&!le?ut(Me,i):void 0,d=!$&&!le&&!ge&&wt(i),h=d||le?"page":"asset",C=Tt(i)?In:$?pn:le?Hn:d?tn:Yn(i)?co:En;return e.jsxs(Mr,{as:"button",elRef:z=>{i===M&&(pe.current=z)},className:`${i===(Ye??o)?"active":""}${N.has(i)?" sel":""}${i===M?" amx-flash":""}${i===D?" dragging":""}${S===Gn(G(i,w?.fd))?" amx-drop-into":""}`.trim()||void 0,selId:i,depth:y,lead:e.jsxs(e.Fragment,{children:[l[i]?e.jsx("span",{className:"amx-page-emoji",children:l[i]}):ge?.icon?e.jsx("span",{className:"amx-page-emoji",children:On(ge.icon,e.jsx(C,{className:"t2s-lead-icon t2s-dim"}))}):e.jsx(C,{className:"t2s-lead-icon t2s-dim"}),w&&e.jsx("span",{className:`t2s-chev t2s-lead-chev${w.open?" open":""}`,onClick:z=>{z.stopPropagation(),tt(w.fd)},children:e.jsx(Ft,{size:12})})]}),onClick:z=>{const Y=N.click(i,z);Y.open!=="none"&&Nt(i,Y.open==="new"?{newTab:!0}:void 0)},onContextMenu:z=>{z.preventDefault(),z.stopPropagation();const Y=N.batch(i);Y.length===1&&N.only(i),g(Y.length>1?{kind:"multi",path:i,paths:Y,x:z.clientX,y:z.clientY}:{kind:h,path:i,x:z.clientX,y:z.clientY})},draggable:me!==i,onDragStart:z=>{const Y=z.currentTarget.getBoundingClientRect();z.dataTransfer.setDragImage(z.currentTarget,z.clientX-Y.left,z.clientY-Y.top),z.dataTransfer.effectAllowed="copyMove";const Z=N.batch(i);if(lo(z.dataTransfer,Z.map(ie=>({kind:"note",path:ie}))),r&&!(window.amadeusSync&&u==="cloud")){const ie=Z.flatMap(re=>{const fe=hn(re)?ft(re):"";return[`${r}/${re}`,...fe&&s.includes(fe)?[`${r}/${fe}`]:[]]});try{z.dataTransfer.setData(An,JSON.stringify(ie))}catch{}}H(i)},onDragEnd:()=>{H(null),O(null)},onDragOver:z=>{ze(z,i,w?.fd)||w&&Wt(z,i,w.fd)},onDragLeave:()=>{S===Gn(G(i,w?.fd))&&O(null)},onDrop:z=>{Be(z,i,w?.fd)||w&&(z.preventDefault(),z.stopPropagation(),Ce(w.fd))},...Gs(Fn(i)),children:[me===i?e.jsx("input",{ref:A,className:"t2s-rename",value:Oe,onChange:z=>E(z.target.value),onBlur:sn,onKeyDown:z=>{z.key==="Enter"&&sn(),z.key==="Escape"&&xe(null)},onClick:z=>z.stopPropagation()}):e.jsx("span",{className:"t2s-srow-title",children:ge?Yt(i,ge.extensions):d||$?ke(i):i.split(/[\\/]/).pop()}),e.jsx("span",{className:"t2s-srow-menu",onClick:z=>{z.stopPropagation(),g({kind:h,path:i,x:z.clientX,y:z.clientY})},children:e.jsx(Ot,{size:14})}),d&&e.jsx("span",{className:"t2s-srow-menu",title:t("amadeus.new.childNote"),onClick:z=>{z.stopPropagation(),rn(i)},children:e.jsx(bt,{size:14})})]},i)},lt=(i,y)=>{if(i.kind==="file"){if(!i.children.length)return mt(i.path,y);const h=ft(i.path),C=j.has(h);return e.jsxs("div",{children:[mt(i.path,y,{fd:h,open:C,count:i.children.filter(z=>z.kind==="file").length}),C&&e.jsx("div",{className:`t2s-group-sessions${S===h?" amx-drop-into":""}`,onDragOver:z=>Wt(z,i.path,h),onDragLeave:()=>{S===h&&O(null)},onDrop:z=>{V(z,h)||(z.preventDefault(),z.stopPropagation(),Ce(h))},children:i.children.map(z=>lt(z,y+1))})]},i.path)}const w=i.path,$=!j.has(w),le=i.children.filter(h=>h.kind==="file").length,ge=i.children.length-le,d=h=>{if(!v(h,w)&&D&&(h.stopPropagation(),xt(D)!==w)){if(hn(D)){const C=ft(D);if(w===C||w.startsWith(`${C}/`))return}h.preventDefault(),h.dataTransfer.dropEffect="move",S!==w&&O(w)}};return e.jsxs("div",{children:[e.jsxs("div",{ref:h=>{w===M&&(pe.current=h)},className:`t2s-group${w===M?" amx-flash":""}${S===w?" amx-drop-into":""}`,style:{paddingLeft:Fr(y)},...Gs(()=>[Rr("tip.folder",{files:le,folders:ge})]),onContextMenu:h=>{h.preventDefault(),h.stopPropagation(),g({kind:"folder",path:w,x:h.clientX,y:h.clientY})},onDragOver:d,onDragLeave:()=>{S===w&&O(null)},onDrop:h=>{V(h,w)||(h.preventDefault(),h.stopPropagation(),Ce(w))},children:[e.jsxs("button",{className:"t2s-group-toggle t2s-folder-row",onClick:()=>tt(w),children:[e.jsxs("span",{className:"t2s-lead",children:[$?e.jsx(bs,{className:"t2s-lead-icon"}):e.jsx(it,{className:"t2s-lead-icon"}),e.jsx("span",{className:`t2s-chev t2s-lead-chev${$?"":" open"}`,children:e.jsx(Ft,{size:12})})]}),e.jsx("span",{className:"t2s-group-label",children:xn(w)})]}),e.jsx("button",{className:"t2s-group-add",title:t("amxv.folder.actions"),onClick:h=>{h.stopPropagation(),g({kind:"folder",path:w,x:h.clientX,y:h.clientY})},children:e.jsx(Ot,{size:14})}),e.jsx("button",{className:"t2s-group-add",title:t("amxv.folder.newNoteHere"),onClick:()=>{f(h=>new Set([...h,...st(w)])),we().createPageInFolder(w)},children:e.jsx(bt,{size:14})})]}),!$&&e.jsx("div",{className:`t2s-group-sessions${S===w?" amx-drop-into":""}`,onDragOver:d,onDragLeave:()=>{S===w&&O(null)},onDrop:h=>{V(h,w)||(h.preventDefault(),h.stopPropagation(),Ce(w))},children:i.children.map(h=>lt(h,y+1))})]},w)},ln=Ve?e.jsxs(e.Fragment,{children:[e.jsx(fc,{}),e.jsx(Tn,{id:"cloud-ws",defaultOpen:!0,label:t("amxv.sec.cloudWorkspace"),children:Ve.rest.length?Ve.rest.map(i=>lt(i,0)):e.jsx("div",{className:"t2s-hint amx-sec-hint",children:t("amxv.empty")})}),Ve.vaultSecs.map(({name:i,node:y})=>e.jsx(Tn,{id:`vault:${i}`,defaultOpen:!0,label:i,children:y&&y.children.length?y.children.map(w=>lt(w,0)):e.jsx("div",{className:"t2s-hint amx-sec-hint",children:t(y?"amxv.empty":"amxv.syncNotArrived")})},i))]}):r?e.jsxs("div",{className:"amx-prefs-group",children:[e.jsx("button",{className:"t2s-group-toggle amx-sec-grab",onClick:ne,children:e.jsxs("span",{className:"t2s-group-name amx-sec-head",children:[e.jsx("span",{className:"t2s-group-label",children:ke(r)}),e.jsx("span",{className:`t2s-chev${se?" open":""}`,children:e.jsx(Ft,{size:12})})]})}),se&&e.jsx("div",{className:`t2s-group-sessions${S===""?" amx-drop-root":""}`,onDragOver:i=>{_e(i,".t2s-srow, .t2s-group")||!D||xt(D)===""||ye||i.target.closest(".t2s-srow, .t2s-group")||(i.preventDefault(),i.dataTransfer.dropEffect="move",S!==""&&O(""))},onDragLeave:()=>{S===""&&O(null)},onDrop:i=>{nn(i,".t2s-srow, .t2s-group")||i.target.closest(".t2s-srow, .t2s-group")||(i.preventDefault(),Ce(""))},children:Ge.children.map(i=>lt(i,0))})]}):e.jsx(e.Fragment,{children:Ge.children.map(i=>lt(i,0))});return e.jsxs("div",{style:{display:"flex",flex:1,minHeight:0,minWidth:0},children:[e.jsxs("aside",{className:"t2s-side amx-tree",children:[e.jsxs("div",{className:"t2s-search",children:[e.jsx(us,{size:13,className:"t2s-dim"}),e.jsx("input",{value:k,placeholder:t("amxv.searchNotes"),onChange:i=>p(i.target.value)})]}),e.jsx("div",{ref:F,className:`t2s-scroll${S===""?" amx-drop-root":""}`,onClick:i=>{i.target===i.currentTarget&&N.clear()},onContextMenu:i=>{i.target.closest(".t2s-srow, .t2s-group, .t2s-special-group")||r&&(i.preventDefault(),i.stopPropagation(),g({kind:"root",path:"",x:i.clientX,y:i.clientY}))},onDragOver:i=>{_e(i,".t2s-srow, .t2s-group, .t2s-group-sessions, .t2s-special-group")||!D||xt(D)===""||ye||i.target.closest(".t2s-srow, .t2s-group, .t2s-group-sessions, .t2s-special-group")||(i.preventDefault(),i.dataTransfer.dropEffect="move",S!==""&&O(""))},onDragLeave:()=>{S===""&&O(null)},onDrop:i=>{nn(i,".t2s-srow, .t2s-group, .t2s-group-sessions, .t2s-special-group")||i.target.closest(".t2s-srow, .t2s-group, .t2s-group-sessions, .t2s-special-group")||(i.preventDefault(),Ce(""))},children:ye?kt.length?kt.map(i=>mt(i)):e.jsx("div",{className:"t2s-hint",children:t("amxv.noMatches")}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"t2s-special-group",children:[e.jsxs("button",{className:"t2s-special",onClick:()=>{we().createPage()},children:[e.jsx("span",{className:"t2s-special-ic",children:e.jsx(Kt,{})}),e.jsx("span",{className:"t2s-special-title",children:t("amadeus.new.note")})]}),e.jsxs("button",{className:"t2s-special",onClick:()=>Vt(""),children:[e.jsx("span",{className:"t2s-special-ic",children:e.jsx(pn,{})}),e.jsx("span",{className:"t2s-special-title",children:t("amadeus.new.drawing")})]})]}),!r&&(x?e.jsx($a,{variant:"list"}):e.jsx("div",{className:"t2s-hint",children:t("amxv.openVaultHint")})),(()=>{const i={pinned:e.jsx(mc,{row:mt,dragPath:D}),cloudsync:u==="local"?e.jsx(gc,{dragPath:D}):null,shared:e.jsx(hc,{}),prefs:e.jsx(uc,{row:mt,pages:n}),tree:ln};return ue.map(y=>i[y]==null?null:ce(y,i[y]))})()]})}),e.jsxs("div",{className:"t2s-foot",children:[e.jsx(dc,{}),e.jsxs("button",{className:"t2s-special",onClick:()=>m?L(!0):void we().openVault(),title:m?t("amxv.cloudVaultTip"):r||void 0,children:[e.jsx("span",{className:"t2s-special-ic",children:e.jsx(it,{})}),e.jsx("span",{className:"t2s-special-title",children:m?t("amxv.cloudVault"):r?t("amxv.vaultNamed",{name:ke(r)}):t("amxv.openVault")})]})]})]}),T?.kind==="multi"&&e.jsxs(vt,{className:"ctx-menu",x:T.x,y:T.y,onClick:i=>i.stopPropagation(),children:[e.jsxs("button",{onClick:()=>{const i=T.paths??[];g(null);for(const y of i)Nt(y,{newTab:!0})},children:[e.jsx(bt,{size:13})," ",t("amxv.menu.openNInNewTabs",{n:T.paths?.length??0})]}),e.jsxs("button",{className:"danger",onClick:()=>{const i=T.paths??[];g(null),window.confirm(t("amxv.confirm.deleteSelected",{n:i.length}))&&(async()=>{for(const y of i)wt(y)&&!Ht(y)?await Pn(y):await we().deletePage(y);N.clear()})()},children:[e.jsx(He,{size:13})," ",t("amxv.menu.deleteN",{n:T.paths?.length??0})]})]}),T?.kind==="page"&&e.jsxs(vt,{className:"ctx-menu",x:T.x,y:T.y,onClick:i=>i.stopPropagation(),children:[e.jsxs("button",{onClick:()=>{Te(T.path,{newTab:!0}),g(null)},children:[e.jsx(bt,{size:13})," ",t("amxv.menu.openInNewTab")]}),e.jsxs("button",{onClick:()=>{const i=T.path;g(null),rn(i)},children:[e.jsx(Kt,{size:13})," ",t("amadeus.new.childNote")]}),e.jsxs("button",{onClick:()=>$e(T.path),children:[e.jsx(yn,{size:13})," ",t("amxv.menu.rename")]}),e.jsxs("button",{onClick:()=>{Pe.getState().toggleStar(T.path),g(null)},children:[e.jsx(as,{size:13})," ",Pe.getState().starred.includes(T.path)?t("amxv.menu.unstar"):t("amxv.menu.star")]}),window.amadeusSync?.entrySyncEnable&&u==="local"&&(en(r,T.path)?e.jsxs("button",{onClick:()=>{const i=T.path;g(null),window.amadeusSync.entrySyncDisable(i)},children:[e.jsx(os,{size:13})," ",t("amxv.menu.cloudSyncOff")]}):e.jsxs("button",{onClick:()=>{const i=T.path;g(null),yt(i,"page")},children:[e.jsx(It,{size:13})," ",t("amxv.menu.cloudSyncOn")]})),Xt()&&e.jsxs("button",{onClick:()=>{Q.revealInFileManager(T.path),g(null)},children:[e.jsx(it,{size:13})," ",t("amxv.menu.reveal")]}),e.jsxs("button",{className:"danger",onClick:()=>{const i=T.path;g(null),Pn(i)},children:[e.jsx(He,{size:13})," ",t("amxv.menu.delete")]})]}),T?.kind==="asset"&&e.jsxs(vt,{className:"ctx-menu",x:T.x,y:T.y,onClick:i=>i.stopPropagation(),children:[Tt(T.path)?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{wn(T.path),g(null)},children:[e.jsx(at,{size:13})," ",t("amxv.menu.open")]}),e.jsxs("button",{onClick:()=>$e(T.path),children:[e.jsx(yn,{size:13})," ",t("amxv.menu.rename")]}),e.jsxs("button",{onClick:()=>{Q.openVaultFile(T.path).catch(()=>{}),g(null)},children:[e.jsx(Ct,{size:13})," ",t("amxv.menu.openWithSystem")]})]}):ha(T.path)?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{$n(T.path),g(null)},children:[e.jsx(at,{size:13})," ",t("amxv.menu.open")]}),ut(Me,T.path)&&e.jsxs("button",{onClick:()=>{Ds(T.path),g(null)},children:[e.jsx(Ua,{size:13})," ",t("amxv.menu.openBuiltinReader")]}),e.jsxs("button",{onClick:()=>{Q.openVaultFile(T.path).catch(()=>{}),g(null)},children:[e.jsx(Ct,{size:13})," ",t("amxv.menu.openWithSystem")]})]}):Yn(T.path)?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{Rs(T.path),g(null)},children:[e.jsx(at,{size:13})," ",t("amxv.menu.open")]}),e.jsxs("button",{onClick:()=>{Q.openVaultFile(T.path).catch(()=>{}),g(null)},children:[e.jsx(Ct,{size:13})," ",t("amxv.menu.openWithSystem")]})]}):Ht(T.path)?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{Fs(T.path),g(null)},children:[e.jsx(at,{size:13})," ",t("amxv.menu.openDrawing")]}),e.jsxs("button",{onClick:()=>{Q.openVaultFile(T.path).catch(()=>{}),g(null)},children:[e.jsx(Ct,{size:13})," ",t("amxv.menu.openWithSystem")]})]}):ut(Me,T.path)?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{$n(T.path),g(null)},children:[e.jsx(at,{size:13})," ",t("amxv.menu.open")]}),e.jsxs("button",{onClick:()=>{Q.openVaultFile(T.path).catch(()=>{}),g(null)},children:[e.jsx(Ct,{size:13})," ",t("amxv.menu.openWithSystem")]})]}):e.jsxs("button",{onClick:()=>{Q.openVaultFile(T.path).catch(()=>{}),g(null)},children:[e.jsx(at,{size:13})," ",t("amxv.menu.open")]}),Xt()&&e.jsxs("button",{onClick:()=>{Q.revealInFileManager(T.path),g(null)},children:[e.jsx(it,{size:13})," ",t("amxv.menu.reveal")]}),e.jsxs("button",{className:"danger",onClick:()=>{const i=T.path;g(null),ds("file",i)&&we().deletePage(i)},children:[e.jsx(He,{size:13})," ",t("amxv.menu.delete")]})]}),T?.kind==="folder"&&e.jsxs(vt,{className:"ctx-menu",x:T.x,y:T.y,onClick:i=>i.stopPropagation(),children:[e.jsxs("button",{onClick:()=>{f(i=>new Set([...i,...st(T.path)])),we().createPageInFolder(T.path),g(null)},children:[e.jsx(Kt,{size:13})," ",t("amadeus.new.note")]}),e.jsxs("button",{onClick:()=>an(T.path),children:[e.jsx(Xs,{size:13})," ",t("amxv.menu.newSubfolder")]}),e.jsxs("button",{onClick:()=>Bt(T.path),children:[e.jsx(In,{size:13})," ",t("amadeus.new.database")]}),e.jsxs("button",{onClick:()=>Vt(T.path),children:[e.jsx(pn,{size:13})," ",t("amadeus.new.drawing")]}),e.jsxs("button",{onClick:()=>on(T.path),children:[e.jsx(Hn,{size:13})," ",t("amadeus.new.dashboard")]}),ee.map(i=>e.jsxs("button",{onClick:()=>Fe(T.path,i.item.label,i.item.run),children:[e.jsx("span",{style:{display:"inline-flex",width:13,justifyContent:"center",fontSize:13},children:On(i.item.icon,"📄")})," ",i.item.label]},i.item.id)),e.jsxs("button",{onClick:()=>{const i=T.path;g(null),Je(t("amxv.renameFolder"),xn(i)).then(y=>{const w=y?.trim();w&&we().renameFolder(i,w)})},children:[e.jsx(yn,{size:13})," ",t("amxv.menu.rename")]}),Xt()&&e.jsxs("button",{onClick:()=>{Q.revealInFileManager(T.path),g(null)},children:[e.jsx(it,{size:13})," ",t("amxv.menu.reveal")]}),window.amadeusSync?.entrySyncEnable&&u==="local"&&(en(r,T.path)?e.jsxs("button",{onClick:()=>{const i=T.path;g(null),window.amadeusSync.entrySyncDisable(i)},children:[e.jsx(os,{size:13})," ",t("amxv.menu.cloudSyncOff")]}):e.jsxs("button",{onClick:()=>{const i=T.path;g(null),yt(i,"folder")},children:[e.jsx(It,{size:13})," ",t("amxv.menu.cloudSyncOn")]})),window.amadeusCollab&&e.jsxs("button",{onClick:()=>{const i=T.path;g(null);const y=ys(Ke,r,u,i);if(!y){yt(i,"folder");return}window.amadeusCollab.createPublish("subtree",y).then(w=>navigator.clipboard.writeText(w.url).then(()=>De.getState().toast(t("amxv.publish.done")))).catch(w=>De.getState().toast(w?.code==="QUOTA"?w.message||t("amxv.publish.quota"):w?.status===404?t("amxv.publish.notUploaded"):t("amxv.publish.failed"),!0))},children:[e.jsx(kn,{size:13})," ",t("amxv.menu.publishFolder")]}),e.jsxs("button",{className:"danger",onClick:()=>{const i=T.path;g(null),ds("folder",i)&&we().deleteFolder(i)},children:[e.jsx(He,{size:13})," ",t("amxv.menu.delete")]})]}),T?.kind==="root"&&e.jsxs(vt,{className:"ctx-menu",x:T.x,y:T.y,onClick:i=>i.stopPropagation(),children:[e.jsxs("button",{onClick:()=>{we().createPage(),g(null)},children:[e.jsx(Kt,{size:13})," ",t("amadeus.new.note")]}),e.jsxs("button",{onClick:()=>an(""),children:[e.jsx(Xs,{size:13})," ",t("amadeus.new.folder")]}),e.jsxs("button",{onClick:()=>Bt(""),children:[e.jsx(In,{size:13})," ",t("amadeus.new.database")]}),e.jsxs("button",{onClick:()=>Vt(""),children:[e.jsx(pn,{size:13})," ",t("amadeus.new.drawing")]}),e.jsxs("button",{onClick:()=>on(""),children:[e.jsx(Hn,{size:13})," ",t("amadeus.new.dashboard")]}),ee.map(i=>e.jsxs("button",{onClick:()=>Fe("",i.item.label,i.item.run),children:[e.jsx("span",{style:{display:"inline-flex",width:13,justifyContent:"center",fontSize:13},children:On(i.item.icon,"📄")})," ",i.item.label]},i.item.id))]}),b&&e.jsx(Kl,{onClose:()=>L(!1)})]})}function oi(t){return t.map(n=>n.kind==="choice"?{id:`page-${n.id}`,icon:e.jsx(Ha,{size:16}),label:n.label,run:()=>{},choices:n.options}:{id:`page-${n.id}`,icon:n.id==="wide"?e.jsx(Wa,{size:16}):e.jsx(Ka,{size:16}),label:n.label,checked:n.on,run:n.run})}function vc(){const[t,n]=c.useState(0),s=c.useRef(0),a=c.useRef({w:0,h:0});return c.useEffect(()=>{const o=()=>{const r=a.current;r.w!==window.innerWidth?a.current={w:window.innerWidth,h:window.innerHeight}:window.innerHeight>r.h&&(r.h=window.innerHeight);const u=window.visualViewport,x=u?Math.max(0,window.innerHeight-u.height-u.offsetTop):0,m=Math.max(x,Math.max(0,a.current.h-window.innerHeight));m>120&&(s.current=m),n(x)};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 wc({height:t,onClose:n}){const s=wr(),a=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:a.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:()=>{_a()?.(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 ri({actions:t,onUpload:n,undo:s,redo:a,indent:l,sourceMode:o,onNeedFocus:r,canvas:u}){const{t:x}=oe(),{lift:m,kbHeight:k}=vc(),[p,j]=c.useState(!1),[f,b]=c.useState(0);Ms(p,()=>j(!1)),Ms(f>0,()=>b(0));const L=c.useRef(null),D=N=>N.preventDefault(),H=L.current?Zi(L.current):1,S=f?Math.round(f/H):0,O=S||Math.round(m/H),F=()=>{_a()||r();const N=k();document.activeElement?.blur?.(),b(N)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:L,className:"amx-mbar",style:O?{transform:`translateY(-${O}px)`}:void 0,children:[!o&&e.jsx("button",{onPointerDown:D,onClick:()=>f?b(0):F(),className:f?"on":void 0,title:x("amxv.mbar.insertBlock"),children:e.jsx(bt,{size:19})}),!o&&e.jsx("button",{onPointerDown:D,onClick:n,title:x("amxv.uploadToPage"),children:e.jsx(is,{size:19})}),!o&&u&&e.jsx("button",{onPointerDown:D,onClick:u.toggle,className:u.on?"on":void 0,title:u.on?x("amxv.mbar.toDocument"):x("amxv.mbar.toCanvas"),children:e.jsx(Lr,{size:19})}),!o&&l&&e.jsx("button",{onPointerDown:D,onClick:()=>l(-1),title:x("amxv.mbar.outdent"),children:e.jsx(Jr,{size:19})}),!o&&l&&e.jsx("button",{onPointerDown:D,onClick:()=>l(1),title:x("amxv.mbar.indent"),children:e.jsx(Qr,{size:19})}),!o&&e.jsx("button",{onPointerDown:D,onClick:s,title:x("amxv.mbar.undo"),children:e.jsx(Ar,{size:19})}),!o&&e.jsx("button",{onPointerDown:D,onClick:a,title:x("amxv.mbar.redo"),children:e.jsx(Br,{size:19})}),e.jsx("button",{onPointerDown:D,onClick:()=>j(!0),title:x("amxv.moreActions"),children:e.jsx(Ot,{size:19})}),e.jsx("button",{onClick:()=>{b(0),document.activeElement?.blur?.()},title:x("amxv.mbar.hideKeyboard"),children:e.jsx(dr,{size:19})})]}),S>0&&e.jsx(wc,{height:S,onClose:()=>b(0)}),p&&e.jsx("div",{className:"mb-sheet-scrim",onClick:()=>j(!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(P=>e.jsx("button",{type:"button",role:"radio","aria-checked":P.on,"data-font":P.id,className:P.on?"on":void 0,onClick:P.run,children:P.label},P.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&&j(!1),N.run()},children:[N.icon,e.jsx("span",{children:N.label}),N.checked&&e.jsx(ot,{size:16,className:"amx-sheet-check"})]},N.id))]})})]})}ve({"amxv.menu.lockPage":{zh:"锁定页面",en:"Lock page"},"amxv.menu.unlockPage":{zh:"解锁页面",en:"Unlock page"}});ve({"amxv.menu.copyMd":{zh:"复制为 Markdown",en:"Copy as Markdown"},"amxv.copyMd.done":{zh:"已复制 Markdown",en:"Markdown copied"}});function bc(t,n){const[,s]=c.useState(0);return c.useEffect(()=>xo(()=>s(a=>a+1)),[]),!!n&&vo(t,n)}function yc({children:t,dragging:n,rootRef:s,onDrop:a,onDragOver:l,onDragLeave:o,onClick:r,onPaste:u,pageAttrs:x}){const m=Oa(k=>k.mode);return e.jsx("div",{ref:k=>{s&&(s.current=k)},className:`am-app tangu-lovable amx-pane amx-editor${n?" amx-dragover":""}`,"data-mode":m,...x,onDrop:a,onDragOver:l,onDragLeave:o,onClick:r,onPaste:u,children:t})}function jc({params:t,size:n}){const s=typeof t.notePath=="string"?t.notePath:"",a=B(l=>s?l.icons[s]??null:null);return a?e.jsx("span",{className:"wb-tab-ic amx-tab-emoji",style:{fontSize:n},"aria-hidden":!0,children:a}):e.jsx(tn,{size:n,className:"wb-tab-ic"})}function li(){const{t}=oe(),n=jt(),s=()=>n.getState(),a=B(S=>S.activePage),l=B(S=>S.manifest),o=B(S=>a?S.icons[a]??null:null),r=a?Fa(a):void 0,u=r&&a?Yt(a,r.extensions):l?.title||(a?ke(a):""),x=Cr.test(u)?"":u,[m,k]=c.useState(x),[p,j]=c.useState(null),f=c.useRef(null);c.useEffect(()=>{k(x)},[a]),c.useEffect(()=>{if(!Qi(a))return;const S=f.current;if(!S)return;S.focus();const O=S.value.length;S.setSelectionRange(O,O)},[a]);const b=()=>{const S=m.trim();S&&S!==u?s().renamePage(S):k(x)},L=yr(),[D,H]=c.useState(null);return e.jsxs("div",{className:"amx-title-wrap",children:[o&&e.jsx("button",{className:"amx-title-bigicon",title:t("amxv.title.changeIcon"),onClick:S=>{const O=S.currentTarget.getBoundingClientRect();j({x:O.left,y:O.bottom+6})},children:o}),a&&(!o||!L)&&e.jsxs("div",{className:"amx-title-actions",children:[!o&&e.jsxs("button",{onClick:()=>{s().setPageIcon(a,kr())},children:[e.jsx(jr,{size:14,strokeWidth:1.7,"aria-hidden":"true"}),t("amxv.title.addIcon")]}),!L&&e.jsxs("button",{onClick:S=>{const O=S.currentTarget.getBoundingClientRect();H({x:O.right,y:O.bottom+6})},children:[e.jsx(eo,{size:14,strokeWidth:1.7,"aria-hidden":"true"}),t("amxv.title.addCover")]})]}),e.jsx("div",{className:"amx-title-row",children:e.jsx("input",{ref:f,className:"amx-title-input",value:m,placeholder:"New Page",onChange:S=>k(S.target.value),onBlur:b,onKeyDown:S=>{const O=S.currentTarget,F=O.selectionStart===O.value.length&&O.selectionEnd===O.value.length;(S.key==="Enter"||(S.key==="ArrowRight"||S.key==="ArrowDown")&&F)&&(S.preventDefault(),Cn(n),O.blur()),S.key==="Escape"&&(k(x),O.blur())}})}),p&&a&&e.jsx(Sr,{x:p.x,y:p.y,current:o,onPick:S=>{s().setPageIcon(a,S),j(null)},onClose:()=>j(null)}),D&&a&&e.jsx(Nr,{page:a,x:D.x,y:D.y,onClose:()=>H(null)})]})}function kc(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 Sc(){const t=jt(),n=Na(),s=()=>t.getState(),a=()=>{const p=s().manifest;if(!p)return"";const j={};for(const[f,b]of Object.entries(s().blocks))j[f]=b.content;return Ci(p,j)},[l,o]=c.useState(a),r=c.useRef(null),u=()=>{const p=r.current;p&&(p.style.height="auto",p.style.height=`${p.scrollHeight}px`)};c.useEffect(u,[l]);const x=c.useRef(l);x.current=l;const m=c.useRef(0);c.useEffect(()=>{const p=r.current,j=za(n);if(p&&j){const f=wo(x.current,j);if(f>=0){p.focus(),p.setSelectionRange(f,f),m.current=f;const b=x.current.slice(0,f).split(`
9
- `).length-1,L=parseFloat(getComputedStyle(p).lineHeight)||20,D=kc(p);D&&(D.scrollTop=Math.max(0,p.offsetTop+b*L-D.clientHeight/2))}}return()=>bo(yo(x.current,m.current),n)},[]);const k=()=>{const p=s().activePage;if(!p||l===a())return;const j=Pi(p,l,new Date().toISOString());s()._commit(j.manifest,j.blocks)};return e.jsx("textarea",{ref:r,className:"amx-source",value:l,spellCheck:!1,onChange:p=>{m.current=p.target.selectionStart,o(p.target.value)},onSelect:p=>{m.current=p.currentTarget.selectionStart},onBlur:k})}function Nc(t){return e.jsx(xs.Provider,{value:t.leaf.id,children:e.jsx(zc,{...t})})}function zc({leaf:t}){const{t:n}=oe(),s=jt(),a=()=>s.getState(),l=B(v=>v.activePage),o=B(v=>v.vaultRoot),r=B(v=>v.pendingPage),u=B(v=>v.error),x=es(v=>v.fileTypes),m=un(v=>to(v,t.id)),[k,p]=c.useState(!1);c.useEffect(()=>{if(!k)return;const v=()=>p(!1);return window.addEventListener("dragend",v),window.addEventListener("drop",v),()=>{window.removeEventListener("dragend",v),window.removeEventListener("drop",v)}},[k]);const[j,f]=c.useState(null),[b,L]=c.useState(null),[D,H]=c.useState(null),S=c.useRef(null),O=c.useRef(null),F=c.useRef(null),[N,P]=c.useState(null),[I,R]=c.useState(0),U=c.useRef(null),K=c.useRef(null),ae=Pe(v=>v.starred),q=Pe(v=>v.pins),te=B(v=>v.vaultSide);Ee(v=>v.vaults),c.useEffect(()=>{Ga()},[]);const he=!!window.amadeusSync?.entrySyncEnable&&te==="local";c.useEffect(()=>{if(!j)return;const v=()=>f(null);return window.addEventListener("click",v),window.addEventListener("contextmenu",v),()=>{window.removeEventListener("click",v),window.removeEventListener("contextmenu",v)}},[j]);const Se=async()=>{const v=a().activePage??ee,V=U.current;if(!v||!V)return;const G=document.createElement("div");G.id="amx-print-root";const X=El(V);X.setAttribute("data-mode","light"),G.appendChild(X),document.body.appendChild(G);try{const ze=await Q.exportPdf(ke(v));ze&&De.getState().toast(n("amxv.pdf.exported",{path:ze}))}catch(ze){De.getState().toast(n("amxv.pdf.exportFailed",{e:String(ze)}),!0)}finally{G.remove()}},ue=async()=>{if(ee)try{const v=await ml(ee);if(v==null)throw new Error(ee);await navigator.clipboard.writeText(v),De.getState().toast(n("amxv.copyMd.done"))}catch(v){De.getState().toast(n("amxv.copyFailed",{e:v instanceof Error?v.message:String(v)}),!0)}},J=Re(v=>v.mainTabs.find(V=>V.id===t.id)?.active??!1),ce=Re(v=>{if(!v.api)return!1;const V=gs(v.api),G=v.mainTabs.filter(X=>X.type==="amadeus-editor");return(G.find(X=>X.id===V?.id)??G.find(X=>X.front)??G[0])?.id===t.id}),T=no(),g=typeof t.params.notePath=="string"?t.params.notePath:null,se=c.useRef(!1),[ne,me]=c.useState(null),[xe,Oe]=c.useState(0),E=c.useRef(null),A=B(v=>g?v.pages.includes(g):!1);c.useEffect(()=>{if(!g){me(null);return}const v=E.current;if(v&&v.path===g&&(v.root===o||v.root===null))return;v&&v.path===g&&Jn(g);let V=!0;return(async()=>{let G=await Q.readTextFile(g).catch(()=>null);for(let ze=0;G==null&&!a().vaultRoot&&ze<30;ze++){if(await new Promise(Be=>setTimeout(Be,100)),!V)return;G=await Q.readTextFile(g).catch(()=>null)}if(!V)return;const X=Ks(g,G,rs(),new Date().toISOString());if(X.editor==="missing"&&a().pages.includes(g)){E.current=null,me({forPath:g,decision:X,root:a().vaultRoot,unreadable:!0});return}X.editor==="missing"?(Jn(g),E.current=null):E.current={path:g,root:a().vaultRoot},me({forPath:g,decision:X,root:a().vaultRoot})})(),()=>{V=!1}},[g,o,A,xe]);const _=ne&&ne.forPath===g?ne.decision:null,M=_?.editor==="unified"?_:null,de=!!g&&!!ne?.unreadable&&ne.forPath===g,pe=_?.editor==="missing"&&!!g&&!de,Ke=ne&&ne.forPath===g?ne.root??"":"",Ne=bc(o,g),[ye,Ge]=c.useState({path:g,on:Ne}),[kt,St]=c.useState(0),je=ye.path===g?ye.on:Ne;c.useEffect(()=>{if(ye.path!==g){Ge({path:g,on:Ne});return}if(ye.on===Ne||!g)return;let v=!0;return(async()=>{const V=await js(g);if(!v)return;if(!V.ok){Ja(g,Ne,V.reason,()=>St(X=>X+1));return}const G=Ks(g,V.raw,rs(),new Date().toISOString());G.editor==="unified"&&me(X=>X&&X.forPath===g?{...X,decision:G}:X),Ge({path:g,on:Ne})})(),()=>{v=!1}},[Ne,ye,g,kt]);const Ve=()=>{g&&Za(o,g,!je)},et=gl(o,M?g:null),Ye=M&&g?fl(et,v=>xl(o,g,v),n):[],Me=!M&&!pe&&!de&&(!!r&&r!==l||!!g&&!u&&g!==l),ee=l??(M&&g?g:null),Fe=!!ee&&ae.includes(ee),tt=!!ee&&q.includes(ee),Ce=he&&!!ee&&en(a().vaultRoot,ee);c.useEffect(()=>{if(!M||!g)return;const v=a().activePage;a().releasePage(v??g)},[M,g]),c.useEffect(()=>{g&&t.setTitle(ke(g))},[g]),c.useEffect(()=>{if(so!=="mobile"||g)return;const v=()=>{const G=a();if(!G.vaultRoot)return!1;let X=null;try{X=localStorage.getItem(`amx.lastNote:${G.vaultRoot}`)}catch{}return X&&G.pages.includes(X)&&t.setParams({...t.params,notePath:X}),!0};if(v())return;const V=s.subscribe(G=>{G.vaultRoot&&v()&&V()});return V},[g]),c.useEffect(()=>{a().setActiveNotePath(g)},[g]),c.useEffect(()=>{!M||!g||(Ma(t.id,`amadeus:${g}`,()=>{const v=Re.getState(),V=v.leafById(t.id);V&&v.navigateLeaf(t.id,"amadeus-editor",{...V.params,notePath:g})}),ws.getState().record({key:`note:${g}`,kind:"note",id:g,title:ke(g)}))},[M,g]),c.useEffect(()=>{if(g)return ao((v,V,G)=>{const X=_e=>V==="file"?_e===v:_e===v||_e.startsWith(`${v}/`);if(!X(g))return;if(G){t.setParams({...t.params,notePath:V==="file"?G:G+g.slice(v.length)});return}const ze=a(),Be=ze.activePage;t.setParams({...t.params,notePath:(Be&&!X(Be)?Be:ze.pages.find(_e=>!X(_e)))??void 0})})},[g]),c.useEffect(()=>{if(!g)return;const v=a().vaultRoot;if(v)try{localStorage.setItem(`amx.lastNote:${v}`,g)}catch{}},[g]),c.useEffect(()=>{g&&_?.editor==="block"&&g!==a().activePage&&a().loadPage(g)},[g,_]),c.useEffect(()=>{J&&Mt(t.id),se.current=J},[J,t.id]),c.useEffect(()=>{ce&&T===io&&o&&Mt(t.id)},[ce,T,o,t.id]),c.useEffect(()=>{!l||l===g||ut(x,l)||Qt(l)||(t.setParams({...t.params,notePath:l}),t.setTitle(ke(l)))},[l]),c.useEffect(()=>()=>Ia(t.id),[t.id]);const Le=async v=>{p(!1);const V=rl(v.dataTransfer);if(V.length){if(v.preventDefault(),M&&g){const Be=V.join(`
10
-
11
- `);if(F.current?F.current(Be):zi(g,Be,"cursor"))return}const ze=a();if(!ze.activePage)return;ze.insertBlocksAfter(null,V);return}const G=Array.from(v.dataTransfer?.files??[]);if(!G.length||(v.preventDefault(),M&&g&&(O.current?O.current(G):Zn(g,G))))return;const X=a().activePage;X&&await Nn(G,X)},nt=v=>{const V=Array.from(v.dataTransfer?.types??[]),G=V.includes(La);!V.includes("Files")&&!G||(v.preventDefault(),G&&v.dataTransfer&&(v.dataTransfer.dropEffect="copy"),k||p(!0))},Ae=v=>{v.currentTarget.contains(v.relatedTarget)||p(!1)},We=v=>{const V=v.target.closest("a");if(!V||V.classList.contains("wikilink"))return;const G=V.getAttribute("href")||"";if(!G||br(G)!=="file")return;v.preventDefault();const X=a().activePage??ee;X&&Q.openAttachment(X,G)},ht=v=>{if(v.defaultPrevented||v.target.closest("input, textarea, .t2s-rename"))return;const V=Array.from(v.clipboardData?.items??[]).filter(X=>X.kind==="file"&&X.type.startsWith("image/")).map(X=>X.getAsFile()).filter(X=>!!X);if(!V.length)return;v.preventDefault();const G=a().activePage;G&&Tl(V,G)};return e.jsxs(e.Fragment,{children:[e.jsxs(yc,{rootRef:U,pageAttrs:M?vl(et):void 0,dragging:k,onDrop:v=>{Le(v)},onDragOver:nt,onDragLeave:Ae,onClick:We,onPaste:ht,children:[ee&&m!=="source"&&!D?.on&&!t.params.miniSurface&&!Ln()&&e.jsx(jl,{host:U,label:n("amxv.floatingToc"),scanTrigger:ee}),e.jsx("input",{ref:K,type:"file",multiple:!0,style:{display:"none"},onChange:v=>{const V=Array.from(v.currentTarget.files??[]);if(v.currentTarget.value="",!V.length||M&&g&&(O.current?O.current(V):Zn(g,V)))return;const G=a().activePage;G&&Nn(V,G)}}),ee&&!Ln()&&!t.params.miniSurface&&e.jsxs("div",{className:"amx-toolbar",children:[e.jsx(zs,{path:ee,hideLoneLeaf:!!M}),e.jsx("span",{className:ur}),window.amadeusCollab&&e.jsx(tc,{path:ee,refreshKey:I,onOpen:(v,V)=>P({x:v,y:V})}),e.jsx("button",{className:`amx-mode-btn amx-pin-btn${tt?" amx-pin-on":""}`,title:n(tt?"amxv.unpin":"amxv.pin"),onClick:()=>Pe.getState().togglePin(ee),children:e.jsx(ns,{size:14})}),he&&e.jsx("button",{className:`amx-mode-btn amx-pin-btn${Ce?" amx-pin-on":""}`,title:n(Ce?"amxv.cloud.disableTip":"amxv.menu.cloudSyncOn"),onClick:()=>{Ce?window.amadeusSync?.entrySyncDisable?.(ee):yt(ee,"page")},children:e.jsx(It,{size:14})}),window.amadeusCollab&&e.jsx(Gl,{}),window.amadeusCollab&&e.jsx("button",{className:"amx-mode-btn",title:n("amxv.shareOrPublish"),onClick:v=>{v.stopPropagation();const V=v.currentTarget.getBoundingClientRect();P({x:V.right,y:V.bottom})},children:e.jsx(kn,{size:14})}),m==="source"&&e.jsx("button",{className:"amx-mode-btn",onClick:()=>un.getState().toggleEditorMode(t.id),title:n("amxv.toVisualLong"),children:e.jsx(at,{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();f({x:Math.max(8,Math.min(V.right-180,window.innerWidth-196)),y:V.bottom+4})},children:e.jsx(Ot,{size:14})})]}),j&&ee&&e.jsxs(vt,{className:"ctx-menu",x:j.x,y:j.y,onClick:v=>v.stopPropagation(),children:[Ye.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(bl,{entries:Ye}),e.jsx("div",{className:"ctx-separator"})]}),e.jsxs("button",{"data-note-mode":!0,onClick:()=>{f(null),un.getState().toggleEditorMode(t.id)},children:[m==="source"?e.jsx(at,{size:13}):e.jsx(Un,{size:13})," ",n(m==="source"?"amxv.toVisual":"amxv.toSource")]}),sa(ee,je,!!M&&m==="source")&&e.jsxs("button",{"data-note-upload":!0,onClick:()=>{f(null),K.current?.click()},children:[e.jsx(is,{size:13})," ",n("amxv.uploadToPage")]}),M&&e.jsxs("button",{onClick:()=>{f(null),ue()},children:[e.jsx(Rt,{size:13})," ",n("amxv.menu.copyMd")]}),$s()&&e.jsxs("button",{onClick:()=>{f(null),Se()},children:[e.jsx(fn,{size:13})," ",n("amxv.menu.exportPdf")]}),D?.on&&D.exportCanvas&&e.jsxs("button",{onClick:()=>{const v=D.exportCanvas;f(null),v?.()},children:[e.jsx(fn,{size:13})," ",n("amxv.menu.exportCanvas")]}),e.jsxs("button",{onClick:()=>{Pe.getState().toggleStar(ee),f(null)},children:[e.jsx(as,{size:13})," ",n(Fe?"amxv.menu.unstar":"amxv.menu.star")]}),Xt()&&e.jsxs("button",{onClick:()=>{Q.revealInFileManager(ee),f(null)},children:[e.jsx(it,{size:13})," ",n("amxv.menu.reveal")]}),M&&e.jsxs("button",{onClick:()=>{f(null),Ve()},children:[e.jsx(Js,{size:13})," ",n(je?"amxv.menu.unlockPage":"amxv.menu.lockPage")]}),M&&Is()&&e.jsxs("button",{"data-page-history":!0,onClick:()=>{f(null),L(ee)},children:[e.jsx(Os,{size:13})," ",n("pghist.menu")]}),e.jsxs("button",{className:"danger",onClick:()=>{const v=ee;f(null),Pn(v,a)},children:[e.jsx(He,{size:13})," ",n("amxv.menu.deleteNote")]})]}),b&&e.jsx(hl,{path:b,locked:b===g&&je,onClose:()=>L(null)}),N&&ee&&e.jsx(Jl,{path:ee,anchor:N,onClose:()=>{P(null),R(v=>v+1)}}),M&&g?e.jsx(hr,{compact:!!t.params.miniSurface,readOnly:je,onUnlock:je?Ve:void 0,path:g,initial:M.initial,diskRaw:M.diskRaw,onCanvasMode:H,historyRef:S,filesRef:O,mdRef:F,onRenamed:v=>{t.setParams({...t.params,notePath:v}),t.setTitle(ke(v)),si(g,v)}},`${Ke}\0${g}${je?"\0locked":""}`):de&&g?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:g}),e.jsx("div",{className:"amx-welcome-actions",children:e.jsx("button",{className:"amx-welcome-btn",onClick:()=>Oe(v=>v+1),children:n("amxv.retry")})})]}):pe&&g?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:g})}),e.jsx("div",{className:"amx-welcome-actions",children:e.jsx("button",{className:"amx-welcome-btn",onClick:()=>Re.getState().closeLeaf(t.id),children:n("amxv.missing.close")})})]}):Me?e.jsx($a,{variant:"document"}):l?m==="source"?e.jsx(Sc,{},l):e.jsxs(e.Fragment,{children:[e.jsx(zr,{}),e.jsxs("div",{className:"amx-doc",children:[e.jsx(li,{}),e.jsx(mr,{})]}),e.jsx(Hl,{bare:!0})]}):g&&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:()=>{g&&a().loadPage(g)},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:()=>{a().createPage()},children:[e.jsx(Kt,{size:16})," ",n("amadeus.new.note")]}),e.jsxs("button",{className:"amx-welcome-btn ghost",onClick:()=>{oo()},children:[e.jsx(Ua,{size:16})," ",n("amxv.welcome.tutorial")]}),e.jsxs("button",{className:"amx-welcome-btn ghost",onClick:()=>{ro()},children:[e.jsx(_r,{size:16})," ",n("amxv.welcome.manual")]})]}):e.jsxs("button",{className:"amx-welcome-btn",onClick:()=>{a().openVault()},children:[e.jsx(it,{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(En,{size:13})," ",n("amxv.welcome.tip2")]}),e.jsxs("li",{children:[e.jsx(Un,{size:13})," ",n("amxv.welcome.tip3")]})]})]})]}),Ln()&&ee&&!Me&&e.jsx(ri,{sourceMode:m==="source",canvas:D,onUpload:()=>K.current?.click(),undo:()=>{S.current?S.current.undo():l&&a().undo()},redo:()=>{S.current?S.current.redo():l&&a().redo()},indent:D?v=>{S.current?.indent?.(v)}:null,onNeedFocus:()=>{l&&Cn(s)},actions:[{id:"mode",icon:m==="source"?e.jsx(at,{size:16}):e.jsx(Un,{size:16}),label:n(m==="source"?"amxv.toVisual":"amxv.toSource"),run:()=>un.getState().toggleEditorMode(t.id)},...sa(ee,je,!!M&&m==="source")?[{id:"upload",icon:e.jsx(is,{size:16}),label:n("amxv.uploadToPage"),run:()=>K.current?.click()}]:[],...M?[{id:"lock",icon:e.jsx(Js,{size:16}),label:n(je?"amxv.menu.unlockPage":"amxv.menu.lockPage"),on:je,run:Ve}]:[],...M&&Is()?[{id:"history",icon:e.jsx(Os,{size:16}),label:n("pghist.menu"),run:()=>L(ee)}]:[],...oi(Ye),{id:"pin",icon:e.jsx(ns,{size:16}),label:n(tt?"amxv.unpin":"amxv.pin"),on:tt,run:()=>Pe.getState().togglePin(ee)},{id:"star",icon:e.jsx(as,{size:16}),label:n(Fe?"amxv.menu.unstar":"amxv.menu.star"),on:Fe,run:()=>Pe.getState().toggleStar(ee)},...he?[{id:"sync",icon:e.jsx(It,{size:16}),label:n(Ce?"amxv.cloud.disableTip":"amxv.menu.cloudSyncOn"),on:Ce,run:()=>{Ce?window.amadeusSync?.entrySyncDisable?.(ee):yt(ee,"page")}}]:[],...window.amadeusCollab?[{id:"share",icon:e.jsx(kn,{size:16}),label:n("amxv.shareOrPublish"),run:()=>P({x:window.innerWidth/2,y:window.innerHeight/2})}]:[],...M?[{id:"copymd",icon:e.jsx(Rt,{size:16}),label:n("amxv.menu.copyMd"),run:()=>{ue()}}]:[],...$s()?[{id:"pdf",icon:e.jsx(fn,{size:16}),label:n("amxv.menu.exportPdf"),run:()=>{Se()}}]:[],...D?.on&&D.exportCanvas?[{id:"canvas-export",icon:e.jsx(fn,{size:16}),label:n("amxv.menu.exportCanvas"),run:()=>D.exportCanvas?.()}]:[],...Xt()?[{id:"reveal",icon:e.jsx(it,{size:16}),label:n("amxv.menu.reveal"),run:()=>{Q.revealInFileManager(ee)}}]:[],{id:"delete",icon:e.jsx(He,{size:16}),label:n("amxv.menu.deleteNote"),danger:!0,run:()=>{Pn(ee,a)}}]})]})}function ci(){const{t}=oe(),n=Yi();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 Cc({path:t,scope:n}){return e.jsx(xs.Provider,{value:n,children:e.jsx(Pc,{path:t,scope:n})})}function Pc({path:t,scope:n}){const{t:s}=oe(),a=jt();return c.useEffect(()=>{t&&a.getState().activePage!==t&&a.getState().loadPage(t)},[t]),c.useEffect(()=>()=>Ia(n),[n]),t?e.jsx(ci,{}):e.jsx("div",{className:"amx-panel",children:e.jsx("div",{className:"amx-panel-empty",children:s("amxv.outline.noNote")})})}const Fd=Object.freeze(Object.defineProperty({__proto__:null,AmadeusBacklinksView:rc,AmadeusEditorView:Nc,AmadeusOutlineView:ci,AmadeusPagesView:xc,AmxMobileBar:ri,Breadcrumb:zs,NoteTabIcon:jc,NoteTitle:li,ScopedPageOutline:Cc,pageStyleSheetActions:oi},Symbol.toStringTag,{value:"Module"}));ve({"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 Ie=({children:t})=>e.jsx("div",{className:"dash-widget",children:e.jsx("div",{className:"dash-widget-note",children:t})});function di(t){const n=$t(s=>s.gen);return c.useEffect(()=>{t&&$t.getState().load(t,t)},[t,n]),$t(s=>t?s.entries[t]:void 0)}function ui(){const[t,n]=c.useState(Ls),[s,a]=c.useState(0);return c.useEffect(()=>{const l=new Date,o=new Date(l.getFullYear(),l.getMonth(),l.getDate()+1).getTime(),r=setTimeout(()=>{n(Ls()),a(u=>u+1)},Math.max(o-l.getTime()+1e3,1e3));return()=>clearTimeout(r)},[t,s]),t}function hi(t){const n=new Map(t.map(s=>[s.id,Aa(s.type)]));return s=>n.get(s)??null}function Tc({opts:t,filters:n}){const{t:s}=oe(),a=c.useMemo(()=>Co(t),[JSON.stringify(t)]),l=a.ok?a.spec.source:"",o=di(l);if(!a.ok)return e.jsx(Ie,{children:s("dashcards.statError",{err:a.error})});if(a.spec.literal!==null){const r=a.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(Ec,{spec:a.spec,entry:o,filters:n})}function Ec({spec:t,entry:n,filters:s}){const{t:a}=oe(),l=ui(),o=c.useMemo(()=>{if(!n?.data)return null;const u=hi(n.data.columns);return To(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(Ie,{children:a("dashcards.loading")});if(n.status==="missing")return e.jsx(Ie,{children:a("dashcards.missing",{source:t.source})});if(n.status==="corrupt")return e.jsx(Ie,{children:a("dashcards.corrupt",{source:t.source,err:n.message})});if(!o)return e.jsx(Ie,{children:a("dashcards.noData")});if(o.error)return e.jsx(Ie,{children:a("dashcards.statError",{err:o.error})});const r=t.label||(t.col?`${t.col} · ${t.stat}`:n.data?.name||a("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:a("dashcards.filteredRows",{n:o.rows})})]})}function Dc({opts:t,filters:n}){const{t:s}=oe(),a=c.useMemo(()=>Po(t),[JSON.stringify(t)]),l=a.ok?a.spec.source:"",o=di(l);return a.ok?e.jsx(Rc,{spec:a.spec,entry:o,filters:n}):e.jsx(Ie,{children:s("dashcards.chartError",{err:a.error})})}function Rc({spec:t,entry:n,filters:s}){const{t:a}=oe(),l=ui(),o=c.useMemo(()=>{if(!n?.data)return null;const x=hi(n.data.columns);return Eo(n.data.rows,n.data.columns,t,s,x,n.data.views)},[n?.data,t,s,l]);if(!n||n.status==="loading")return e.jsx(Ie,{children:a("dashcards.loading")});if(n.status==="missing")return e.jsx(Ie,{children:a("dashcards.missing",{source:t.source})});if(n.status==="corrupt")return e.jsx(Ie,{children:a("dashcards.corrupt",{source:t.source,err:n.message})});if(!o)return e.jsx(Ie,{children:a("dashcards.noData")});if(o.error)return e.jsx(Ie,{children:a("dashcards.chartError",{err:o.error})});if(!o.slices.length)return e.jsx(Ie,{children:a("dashcards.noMatch")});const r=t.agg==="count"?a("dashcards.aggCount"):a(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(Do,{slices:o.slices}):t.kind==="line"?e.jsx(Ro,{slices:o.slices}):e.jsx(Fo,{slices:o.slices})})]})}ve({"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 pa({widget:t,filters:n=[]}){return t.kind==="clock"?e.jsx(Mc,{opts:t.opts}):t.kind==="weather"?e.jsx(Lc,{opts:t.opts}):t.kind==="webview"?e.jsx(Ac,{opts:t.opts}):t.kind==="section"?e.jsx(Fc,{opts:t.opts}):t.kind==="stat"?e.jsx(Tc,{opts:t.opts,filters:n}):t.kind==="chart"?e.jsx(Dc,{opts:t.opts,filters:n}):null}function Fc({opts:t}){const{t:n}=oe();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 mi(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function Mc({opts:t}){const{t:n,locale:s}=oe(),[a,l]=c.useState(()=>new Date);c.useEffect(()=>{let m;const k=window.setTimeout(()=>{l(new Date),m=window.setInterval(()=>l(new Date),1e3)},1e3-Date.now()%1e3);return()=>{clearTimeout(k),m&&clearInterval(m)}},[]);const o=t.tz||mi();let r,u,x=!1;try{({time:r,date:u}=As(a,{locale:s,timeZone:o}))}catch{x=!0,{time:r,date:u}=As(a,{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()})]}),x&&e.jsx("div",{className:"dash-widget-note",children:n("dashwidget.clockBadTz",{tz:o})})]})}function $c(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 Ic(t,n){let s=Number(t.lat),a=Number(t.lon),l=t.label||t.city||"";if(!Number.isFinite(s)||!Number.isFinite(a)){const u=t.city||t.label;if(!u)throw new Error(W("dashwidget.weatherNoCity"));const k=(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(!k)throw new Error(W("dashwidget.weatherCityNotFound",{city:u}));s=k.latitude,a=k.longitude,l=l||k.name}const r=await(await fetch(`https://api.open-meteo.com/v1/forecast?latitude=${s}&longitude=${a}&current=temperature_2m,weather_code,wind_speed_10m`,{signal:n})).json();if(!r.current)throw new Error(W("dashwidget.weatherBadResponse"));return{temp:r.current.temperature_2m,code:r.current.weather_code,wind:r.current.wind_speed_10m,place:l}}const Oc=900*1e3;function Lc({opts:t}){const{t:n}=oe(),[s,a]=c.useState(null),[l,o]=c.useState(null),r=JSON.stringify(t);if(c.useEffect(()=>{const x=new AbortController,m=()=>{Ic(t,x.signal).then(p=>{a(p),o(null)}).catch(p=>{x.signal.aborted||o(p instanceof Error?p.message:String(p))})};m();const k=window.setInterval(m,Oc);return()=>{x.abort(),clearInterval(k)}},[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=$c(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 Ac({opts:t}){const{t:n}=oe(),s=t.url||"",a=c.useRef(null);return s?Ba(s)?window.tangu?e.jsx(Mo,{ref:a,src:s,partition:$o,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")})})}ve({"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 Bc({dashLeafId:t,dashPath:n,blockId:s,opts:a,size:l,onClose:o}){const r=jt(),{t:u}=oe(),x=a.type??"",[,m]=c.useState(0);c.useEffect(()=>Io(()=>m(H=>H+1)),[]);const k=c.useRef(o);k.current=o;const p=JSON.stringify(a),j=c.useMemo(()=>{const{type:H,...S}=JSON.parse(p);return S},[p]),f=c.useMemo(()=>({id:`${t}::${s}`,type:x,loc:"main",params:j,setTitle:()=>{},setParams:H=>{const S=r.getState();if(S.activePage!==n)return;const O={type:x};for(const[N,P]of Object.entries(H))N!=="type"&&(typeof P=="string"||typeof P=="number"||typeof P=="boolean")&&(O[N]=String(P));const F=be("view",O);(S.blocks[s]?.content??"").trim()!==F&&S.setBlockContent(s,F)},close:()=>k.current()}),[t,n,s,x,j,r]);if(!x)return e.jsx("div",{className:"dash-widget",children:e.jsx("div",{className:"dash-widget-note",children:u("viewcard.missingType")})});const b=Jt(x);if(!b)return e.jsx("div",{className:"dash-widget",children:e.jsx("div",{className:"dash-widget-note",children:u("viewcard.unavailable",{type:x})})});const L=l??b.dashboard?.defaultSize??"lg",D=b.dashboard?.factory?b.dashboard.factory({leaf:f,params:j},{size:L}):b.factory({leaf:f,params:j});return e.jsx("div",{className:`wb-view dash-viewcard${b.dashboard?.factory?" dash-viewcard--compact":" dash-viewcard--interactive"}`,"data-view-type":x,onPointerDownCapture:()=>{x==="amadeus-editor"&&Mt(f.id)},children:D})}const fa=new Set(["chat","browser","terminal","dashboard","amadeus-dashboard","sidebar-empty","home"]);function Vc(t,n){return t.type==="outline"?{param:"sourcePath",accept:(s,a)=>n(a)==="amadeus-editor"}:!t.idParam||!t.fileMatch?null:{param:t.idParam,accept:(s,a)=>n(a)===t.type}}async function Wc(t){const n=$t.getState();await n.load(t,t);const s=$t.getState().entries[t]?.data;if(!s)return null;const a=Es(s),l=a.find(x=>x.type==="chart");if(l)return l.name;const o=new Set(a.map(x=>x.name));let r="图表";for(let x=2;o.has(r);x++)r=`图表 ${x}`;const u={id:Ti(),name:r,type:"chart"};return n.mutate(t,x=>({...x,views:[...Es(x),u]})),r}function _c(t,n){const s=Object.entries(t).find(([l,o])=>l!=="type"&&/path$/i.test(l)&&o);if(!s)return n;const a=(s[1].split(/[\\/]/).pop()??s[1]).replace(/\.[^.]+$/,"");return a?`${n} · ${a}`:n}ve({"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 qc(){const t=$t(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 a of s.data.columns)n.has(a.name)||n.set(a.name,{name:a.name,kind:Aa(a.type),options:a.options??[]});return[...n.values()].sort((s,a)=>s.name.localeCompare(a.name))},[t])}function Uc({filters:t,editable:n,onChange:s}){const a=qc(),[l,o]=c.useState(!1),[r,u]=c.useState(null),x=bn(l),{t:m}=oe();if(!t.length&&!n)return null;const k=()=>{const b=a[0];b&&(u({prop:b.name,op:Bn[b.kind]?.[0]??"eq",value:""}),o(!0))},p=r?a.find(b=>b.name===r.prop):null,j=p?Bn[p.kind]??["eq"]:["eq"],f=()=>{if(!r)return;const b=Vs.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(Oo,{size:12,className:"dash-filterbar-label"}),e.jsx("span",{className:"dash-filterbar-label",children:m("dashfilter.label")}),t.map((b,L)=>e.jsxs("span",{className:"dash-filter-chip",children:[e.jsx("b",{children:b.prop}),e.jsx("span",{children:Bs[b.op]??b.op}),b.value!==void 0&&e.jsx("span",{children:b.value}),n&&e.jsx("button",{title:m("dashfilter.remove"),onClick:()=>s(t.filter((D,H)=>H!==L)),children:e.jsx(ps,{size:11})})]},`${b.prop}-${b.op}-${L}`)),n&&e.jsxs("span",{style:{position:"relative",display:"inline-flex"},children:[e.jsxs("button",{className:"dash-filter-add",onClick:k,disabled:!a.length,title:a.length?m("dashfilter.addTitle"):m("dashfilter.noCards"),children:[e.jsx(bt,{size:11})," ",m("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:x.ref,className:"dash-add-menu dash-filter-editor",style:x.style,children:[e.jsx("select",{value:r.prop,onChange:b=>{const L=a.find(D=>D.name===b.target.value);u({prop:b.target.value,op:(L&&Bn[L.kind]?.[0])??"eq",value:""})},children:a.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:j.map(b=>e.jsx("option",{value:b,children:Bs[b]??b},b))}),!Vs.has(r.op)&&(p?.options.length?e.jsxs("select",{value:r.value,onChange:b=>u({...r,value:b.target.value}),children:[e.jsx("option",{value:"",children:m("dashfilter.pickOne")}),p.options.map(b=>e.jsx("option",{value:b,children:b},b))]}):e.jsx("input",{value:r.value,placeholder:m("dashfilter.valuePlaceholder"),onChange:b=>u({...r,value:b.target.value}),onKeyDown:b=>{b.key==="Enter"&&f()},autoFocus:!0})),e.jsx("button",{className:"dash-filter-commit",onClick:f,children:m("dashfilter.commit")})]})]})]})]})}ve({"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 Hc=[{key:"section",labelKey:"dashgrid.add.section",icon:Gr},{key:"stat",labelKey:"dashgrid.add.stat",icon:Uo},{key:"chart",labelKey:"dashgrid.add.chart",icon:Ho},{key:"text",labelKey:"dashgrid.add.text",icon:Ha},{key:"clock",labelKey:"dashgrid.add.clock",icon:qa},{key:"weather",labelKey:"dashgrid.add.weather",icon:Hr},{key:"webview",labelKey:"dashgrid.add.webview",icon:Pt}],Kc={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"},Gc=[{key:"today",nameKey:"dashgrid.tpl.today.name",hintKey:"dashgrid.tpl.today.hint",cards:[{content:be("section",{title:W("dashgrid.tpl.today")}),w:12,h:1},{content:be("clock",{}),w:6,h:2},{content:be("weather",{city:"上海"}),w:6,h:2},{content:be("view",{type:"todo-list"}),w:6,h:5},{content:be("view",{type:"calendar"}),w:6,h:5}]},{key:"work",nameKey:"dashgrid.tpl.work.name",hintKey:"dashgrid.tpl.work.hint",cards:[{content:be("section",{title:W("dashgrid.tpl.doing")}),w:12,h:1},{content:be("view",{type:"inbox-list"}),w:6,h:5},{content:be("view",{type:"todo-list"}),w:6,h:5},{content:be("section",{title:W("dashgrid.tpl.recent")}),w:12,h:1},{content:be("view",{type:"activity-log"}),w:12,h:5}]},{key:"blank",nameKey:"dashgrid.tpl.blank.name",hintKey:"dashgrid.tpl.blank.hint",cards:[]}],Ut=t=>t==="section",Cs={w:4,h:3},pi={sizes:["lg","full"],defaultSize:"lg",surface:"workspace",min:Cs},ga={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:Cs},text:{sizes:["md","wide","lg","full"],defaultSize:"wide",surface:"note"}},Xn=t=>t.min??Yo(t.sizes);function zt(t){const n=gt(t);if(n?.kind==="view"){const s=Jt(n.opts.type??"")?.dashboard;return s?{sizes:s.sizes,defaultSize:s.defaultSize,surface:s.surface??"workspace",min:s.min??Cs}:pi}return ga[n?.kind??"text"]??ga.text}const vn=(t,n=0)=>{const s=ts(t);return{order:n,w:s.w,h:s.h}},Yc=()=>null;function Xc(t,n,s){const a=t.indexOf(n),l=t.indexOf(s);if(a<0||l<0||a===l)return t;const o=t.filter(r=>r!==n);return o.splice(a<l?o.indexOf(s)+1:o.indexOf(s),0,n),o}const Jc=(t,n)=>Xo(t,n)??n[0]??"lg",Zc=[],Qc={},xa=(t,n)=>{if(!t)return!1;const s=Object.keys(t);return s.length===Object.keys(n).length&&s.every(a=>n[a]&&t[a].row===n[a].row&&t[a].col===n[a].col)};function Md(t){return e.jsx(xs.Provider,{value:t.leaf.id,children:e.jsx(ed,{...t})})}function ed({leaf:t}){const{t:n}=oe(),s=jt(),a=typeof t.params.dashPath=="string"?t.params.dashPath:"",l=t.params.locked!==!1,o=Oa(d=>d.mode),r=B(d=>d.manifest),u=B(d=>d.blocks),x=B(d=>d.activePage),m=B(d=>d.manifest?.fmExtra??""),k=Pe(d=>!!a&&d.pins.includes(a)),p=Ir(),[j,f]=c.useState(!1),[b,L]=c.useState(null),[D,H]=c.useState(null),S=bn(j),O=bn(b?`${b.x},${b.y}`:""),F=bn(D?`${D.x},${D.y}`:""),[N,P]=c.useState(!1);c.useEffect(()=>{a&&t.setTitle(Vn(a))},[a]),c.useEffect(()=>{a&&a!==s.getState().activePage&&s.getState().loadPage(a)},[a]);const I=Re(d=>d.mainTabs.find(h=>h.id===t.id)?.active??!1);c.useEffect(()=>{I&&Mt(t.id)},[I,t.id]);const R=c.useMemo(()=>{if(!r)return[];const d=[];for(const h of r.root.children)for(const C of h.columns)for(const z of C.children)d.push(z.ref);return d},[r]),U=c.useMemo(()=>Wn(m),[m]),K=U.ok?U.layout:{},ae=U.ok&&Lo(K,R),q=c.useMemo(()=>Ws(m),[m]),te=q.ok?q.pins:Qc,he=c.useMemo(()=>Ao(m),[m]),Se=he.ok?he.filters:Zc,ue=()=>{const d=s.getState();return d.activePage===a?d.loadNonce:null},J=(d,h)=>{const C=s.getState();if(C.activePage!==a||h!==void 0&&(h===null||C.loadNonce!==h))return!1;const z=C.manifest?.fmExtra??"";return d===null||d===z?!1:(C.setFmExtra(d),!0)},ce=(d,h)=>J(_n(s.getState().manifest?.fmExtra??"",d),h),T=()=>{const d=Wn(s.getState().manifest?.fmExtra??"");return d.ok?d.layout:null};c.useEffect(()=>{if(!r||x!==a||!R.length||!U.ok||ae)return;const d=_s(K,R),h=q.ok?Bo(te,R):null;if(!d&&!h)return;let C=s.getState().manifest?.fmExtra??"";d&&(C=_n(C,d)??C),h&&(C=qn(C,h)??C),J(C)},[R,K,te,r,x,a,U.ok,q.ok,ae]);const g=c.useRef(null),se=c.useRef(null),[ne,me]=c.useState(0);c.useLayoutEffect(()=>{const d=se.current;if(!d)return;const h=new ResizeObserver(([z])=>me(z.contentRect.width));h.observe(d);const C=getComputedStyle(d);return me(d.clientWidth-parseFloat(C.paddingLeft||"0")-parseFloat(C.paddingRight||"0")),()=>h.disconnect()},[]);const xe=Vo(ne),Oe=xe>0?(ne-Ue*(xe-1))/xe:0,E=c.useMemo(()=>Wo(K,R),[K,R]),[A,_]=c.useState(null),M=c.useRef(new Map),de=c.useRef(null),pe=c.useRef(null),Ke=(d,h)=>{if(l||pe.current)return;d.preventDefault(),d.stopPropagation();const C=zt(u[h]?.content??""),z=Xn(C),Y=K[h]??vn(C.defaultSize),Z=M.current.get(h)??{...Y,w:Math.max(z.w,Y.w),h:Math.max(z.h,Y.h)};pe.current={id:h,pointerId:d.pointerId,nonce:ue(),x:d.clientX,y:d.clientY,w:Z.w,h:Z.h},de.current={id:h,w:Z.w,h:Z.h},_({id:h,w:Z.w,h:Z.h}),d.currentTarget.setPointerCapture(d.pointerId)},Ne=d=>{const h=pe.current;if(!h||h.pointerId!==d.pointerId||Oe<=0)return;const C=Zo(h.w,xe),z=C*Oe+(C-1)*Ue+(d.clientX-h.x),Y=Math.max(1,Math.min(xe,Math.round((z+Ue)/(Oe+Ue)))),Z=Math.max(1,Math.min(_t,Math.round(Y*_t/xe))),ie=h.h*qt+(h.h-1)*Ue+(d.clientY-h.y),re=Math.max(1,Math.min(or,Math.round((ie+Ue)/(qt+Ue)))),fe=zt(u[h.id]?.content??""),ct=Xn(fe),Xe={w:Math.max(ct.w,Z),h:Math.max(ct.h,re)};de.current={id:h.id,w:Xe.w,h:Xe.h},_(dt=>dt&&dt.w===Xe.w&&dt.h===Xe.h?dt:{id:h.id,w:Xe.w,h:Xe.h})},ye=d=>{const h=pe.current;if(h&&d&&h.pointerId!==d.pointerId)return;const C=de.current;if(pe.current=null,de.current=null,_(null),!h||!C||C.w===h.w&&C.h===h.h)return;const z=T();!z||!z[h.id]||ce({...z,[h.id]:{...z[h.id],w:C.w,h:C.h}},h.nonce)},Ge=d=>{const h=Ws(s.getState().manifest?.fmExtra??"");if(!h.ok||!h.pins[d])return;const C=h.pins[d].row,z={};for(const[Y,Z]of Object.entries(h.pins))Z.row!==C&&(z[Y]=Z);J(qn(s.getState().manifest?.fmExtra??"",z))},kt=(d,h,C)=>{const z=T();!z||!z[d]||ce({...z,[d]:{...z[d],w:h,h:C}})},St=Ca(Qn(sr,{activationConstraint:{distance:4}}),Qn(nr,{activationConstraint:{delay:150,tolerance:8}})),[je,Ve]=c.useState(null),[et,Ye]=c.useState(null);c.useLayoutEffect(()=>{l&&Ye(null)},[l]);const[Me,ee]=c.useState(null),Fe=c.useRef(null),[tt,Ce]=c.useState(null),Le=c.useRef(null),nt=c.useRef(0),Ae=c.useRef(null),We=c.useRef({bands:[],byId:new Map}),ht=c.useRef(null),v=c.useRef(null),V=c.useRef(1),G=d=>{v.current=ue(),Ye(null),ht.current=new Map(M.current);const h=se.current,C=h&&h.offsetWidth>0?h.getBoundingClientRect().width/h.offsetWidth:1;V.current=Math.abs(C-1)<.005?1:C,nt.current=tr(te),Ae.current=null,Le.current=null,Ve(String(d.active.id))},X=d=>{xa(Le.current,d)||(Le.current=d,Ce(d))},ze=d=>{const h=String(d.active.id),C=d.over?String(d.over.id):null;if(!C||C===h)return;Ae.current=null;const z={...te};delete z[h],X(z);const Y=Fe.current??E,Z=Xc(Y,h,C);Z.join(`
12
- `)!==Y.join(`
13
- `)&&(Fe.current=Z,ee(Z))},Be=d=>{const h=String(d.active.id);if(d.over&&String(d.over.id)!==h||Ut(gt(u[h]?.content??"")?.kind)||!q.ok)return;const C=d.active.rect.current.translated,z=se.current,Y=z?.getBoundingClientRect(),Z=We.current.byId.get(h);if(!C||!z||!Y||!Z||Oe<=0)return;const ie=getComputedStyle(z),re=V.current,fe=d.activatorEvent,ct=typeof fe?.clientY=="number"?fe.clientY:fe?.touches?.[0]?.clientY,Xe=typeof ct=="number"?ct+d.delta.y:C.top+C.height/2,dt=(C.left-Y.left)/re-parseFloat(ie.paddingLeft||"0"),pt=(Xe-Y.top)/re-parseFloat(ie.paddingTop||"0"),fi=qt+Ue,cn=We.current.bands.findIndex(qe=>pt>=qe.top&&pt<qe.top+qe.h*fi);if(cn<0)return;const gi=Math.round(dt/(Oe+Ue)),Mn=Math.max(0,Math.min(_t-Z.w,Math.round(gi*_t/xe)));if(Ae.current&&Ae.current.band===cn&&Ae.current.col===Mn)return;Ae.current={band:cn,col:Mn};const Ps=We.current.bands[cn].ids.filter(qe=>qe!==h);if(Ps.some(qe=>Ut(gt(u[qe]?.content??"")?.kind)))return;const dn=er(Fe.current??E,Le.current??te,[{id:h,col:Mn,w:Z.w},...Ps.map(qe=>({id:qe,col:We.current.byId.get(qe)?.col??0,w:We.current.byId.get(qe)?.w??1}))],nt.current);X(dn.pins),dn.ids.join(`
14
- `)!==(Fe.current??E).join(`
15
- `)&&(Fe.current=dn.ids,ee(dn.ids))},_e=()=>{const d={nonce:v.current,seq:Fe.current,pins:Le.current};return v.current=null,Fe.current=null,Le.current=null,ht.current=null,Ae.current=null,Ve(null),ee(null),Ce(null),d},nn=()=>{_e()},sn=()=>{const{nonce:d,seq:h,pins:C}=_e();if(!h&&!C)return;const z=T();if(!z)return;const Y=(h??E).filter(fe=>R.includes(fe));for(const fe of R)Y.includes(fe)||Y.push(fe);const Z=Y.join(`
16
- `)!==E.join(`
17
- `),ie=!!C&&q.ok&&!xa(C,te);if(!Z&&!ie)return;let re=s.getState().manifest?.fmExtra??"";Z&&(re=_n(re,Qo(z,Y))??re),ie&&(re=qn(re,C)??re),J(re,d)},$e=(d,h)=>{const C=s.getState();if(C.activePage!==a)return null;const z=R[R.length-1]??null,Y=C.insertBlockAfter(z,void 0,d);if(!Y)return null;const Z=Wn(s.getState().manifest?.fmExtra??"");if(Z.ok){const ie=Object.values(Z.layout).reduce((re,fe)=>Math.max(re,fe.order+1),0);ce({...Z.layout,[Y]:{order:ie,w:h.w,h:h.h}})}return Y},an=d=>{f(!1),(async()=>{if(d==="text"){$e("",rr);return}if(d==="section"){const C=await Je(n("dashgrid.add.section"),n("dashgrid.default.section"));if(!C?.trim())return;$e(be("section",{title:C.trim()}),{w:12,h:1});return}if(d==="clock"){$e(be("clock",{tz:mi()}),mn);return}if(d==="weather"){const C=await Je(n("dashgrid.prompt.weather"),"上海");if(!C?.trim())return;$e(be("weather",{city:C.trim()}),mn);return}if(d==="stat"){await Vt();return}if(d==="chart"){await on();return}const h=await Je(n("dashgrid.prompt.webview"),"https://");if(h?.trim()){if(!Ba(h.trim())){De.getState().toast(n("dashgrid.webviewRejected"),!0);return}$e(be("webview",{url:h.trim()}),lr)}})()},Bt=d=>new Promise(h=>{Hs.getState().openPicker({title:d,accept:(C,z)=>Us(z)==="amadeus-db",onPick:C=>h(C)})}),Vt=async()=>{const d=await Bt(n("dashgrid.pickDbStat"));if(!d)return;const h=(await Je(n("dashgrid.prompt.statCol"),""))?.trim()??"";if(!h){$e(be("stat",{source:d}),mn);return}const C=(await Je(n("dashgrid.prompt.statFn"),"sum"))?.trim();C&&$e(be("stat",{source:d,col:h,stat:C}),mn)},on=async()=>{const d=await Bt(n("dashgrid.pickDbChart"));if(!d)return;const h=await Wc(d);$e(be("view",{type:"amadeus-db",dbPath:d,...h?{view:h}:{}}),vn("lg"))},Wt=c.useMemo(()=>_o().filter(d=>d.embeddable&&!fa.has(d.type)).map(d=>({type:d.type,name:qs(d.displayName),Icon:d.icon??Pt,spec:Vc(d,Us)})).sort((d,h)=>d.name.localeCompare(h.name)),[j]),Fn=d=>{f(!1);const h=Jt(d.type),C=vn(h?.dashboard?.defaultSize??pi.defaultSize);if(!d.spec){$e(be("view",{type:d.type}),C);return}const{param:z,accept:Y}=d.spec;Hs.getState().openPicker({title:n("dashgrid.pickFileFor",{name:d.name}),accept:Y,onPick:Z=>{$e(be("view",{type:d.type,[z]:Z}),C)}})},rn=d=>{const h=s.getState();if(h.activePage!==a||!d.cards.length)return;const C=T();if(!C){De.getState().toast(n("dashgrid.layoutUnreadable"),!0);return}let z=R[R.length-1]??null;const Y={...C};let Z=Object.values(Y).reduce((ie,re)=>Math.max(ie,re.order+1),0);for(const ie of d.cards){const re=h.insertBlockAfter(z,void 0,ie.content);if(!re)break;Y[re]={order:Z++,w:ie.w,h:ie.h},z=re}ce(Y)},Nt=d=>{s.getState().activePage===a&&s.getState().deleteBlock(d)},mt=d=>{J(Jo(s.getState().manifest?.fmExtra??"",d))},lt=()=>{L(null),J(ir(s.getState().manifest?.fmExtra??"","canvas"))};if(!a)return e.jsx("div",{className:"amx-draw-state",children:n("dashgrid.noFile")});const ln=d=>{const h=gt(u[d]?.content??"");if(h?.kind!=="view")return{widget:h,title:null,Icon:null,openable:null};const C=h.opts.type??"",z=Jt(C);if(!z)return{widget:h,title:n("dashgrid.viewUnavailable",{type:C}),Icon:Pt,openable:null};const{type:Y,...Z}=h.opts;return{widget:h,title:_c(h.opts,qs(z.displayName)),Icon:z.icon??Pt,openable:()=>Re.getState().openView(C,Z,"main",{newTab:!0})}},i=(d,h)=>{const C=gt(u[d]?.content??"");if(C?.kind==="view"){const z=C.opts.type??"",Y=Jt(z);return!Y||fa.has(z)||!Y.embeddable?e.jsx("div",{className:"dash-widget",children:e.jsx("div",{className:"dash-widget-note",children:n("dashgrid.viewNotEmbeddable",{type:z})})}):e.jsx(Bc,{dashLeafId:t.id,dashPath:a,blockId:d,opts:C.opts,size:h,onClose:()=>Nt(d)})}return C?e.jsx(pa,{widget:C,filters:Se}):e.jsx(Sa,{blockId:d})},y=(()=>{if(!Me)return E;const d=Me.filter(h=>R.includes(h));for(const h of E)d.includes(h)||d.push(h);return d})(),w=tt??te,$=qo(y.map(d=>{const h=zt(u[d]?.content??""),C=K[d]??vn(h.defaultSize),z=ht.current?.get(d),Y=z?{...C,w:z.w,h:z.h}:C,Z=A?.id===d?{...Y,...A}:Y,ie=Ut(gt(u[d]?.content??"")?.kind),re=Xn(h),fe={key:Jc(Z,h.sizes),w:Math.max(re.w,Z.w),h:Math.max(re.h,Z.h)},ct=ts(h.defaultSize),Xe=!w[d]&&(!K[d]||K[d].w===ct.w&&K[d].h===ct.h),dt=A?.id===d||!Xe?[fe]:[fe,...h.sizes.map(pt=>ts(pt)).filter(pt=>pt.w!==fe.w||pt.h!==fe.h)];return{id:d,preferred:Z,choices:dt,chrome:ie}}),w,xe),le=[];{let d=1;const h=[],C=new Map;for(const z of $){let Y=1;const Z=[];for(const ie of z.items){const re=ie.start??Y;le.push({id:ie.id,rowStart:d,rowSpan:ie.h,colStart:re,colSpan:ie.span,size:ie.size,cell:ie.cell,chrome:ie.chrome}),Y=re+ie.span,Z.push(ie.id),C.set(ie.id,{col:Math.round((re-1)*_t/xe),w:ie.cell.w})}h.push({top:(d-1)*(qt+Ue),h:z.h,ids:Z}),d+=z.h}We.current={bands:h,byId:C}}M.current=new Map(le.map(d=>[d.id,d.cell]));const ge=(()=>{if(!je)return null;const d=gt(u[je]?.content??""),h=d?.kind??"text";if(d&&Ut(h))return e.jsx("div",{className:"dash3-card dash3-card--chrome dash3-card--lift",children:e.jsx("div",{className:"dash3-card-body",children:e.jsx(pa,{widget:d})})});const C=ln(je);return e.jsxs("div",{className:"dash3-card dash3-card--lift","data-kind":h,"data-surface":zt(u[je]?.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=>{Mt(t.id),et&&!d.target.closest?.(`.dash3-card[data-key="${CSS.escape(et)}"]`)&&Ye(null)},onDragOver:d=>{l||!Array.from(d.dataTransfer?.types??[]).includes("Files")||(d.preventDefault(),P(!0))},onDragLeave:d=>{d.currentTarget.contains(d.relatedTarget)||P(!1)},onDrop:d=>{P(!1);const h=Array.from(d.dataTransfer?.files??[]);l||!h.length||(d.preventDefault(),Mt(t.id),Nn(h,a))},children:[e.jsxs("div",{className:"amx-toolbar",children:[e.jsx(zs,{}),e.jsx("button",{className:`amx-mode-btn amx-pin-btn${k?" amx-pin-on":""}`,title:n(k?"dashgrid.unpin":"dashgrid.pin"),onClick:()=>Pe.getState().togglePin(a),children:e.jsx(ns,{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(yn,{size:13}):e.jsx(ot,{size:14}),e.jsx("span",{children:n(l?"dashgrid.editLayout":"dashgrid.done")})]}),e.jsx(Ys,{initial:!1,children:!l&&e.jsxs(ss.div,{className:"dash-add-wrap",initial:p?!1:{opacity:0,scale:.9,x:-4},animate:{opacity:1,scale:1,x:0},exit:p?{opacity:0}:{opacity:0,scale:.9,x:-4},transition:{duration:p?0:.18,ease:[.16,1,.3,1]},children:[e.jsx("button",{className:"amx-mode-btn",title:n("dashgrid.addCard"),onClick:d=>{d.stopPropagation(),f(h=>!h)},children:e.jsx(bt,{size:14})}),j&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"dash-menu-scrim",onClick:()=>f(!1)}),e.jsxs("div",{ref:S.ref,className:"dash-add-menu",style:S.style,children:[Hc.map(d=>e.jsxs("button",{onClick:()=>an(d.key),children:[e.jsx(d.icon,{size:13})," ",n(d.labelKey)]},d.key)),Wt.length>0&&e.jsx("div",{className:"dash-menu-sep",children:n("dashgrid.menuViews")}),Wt.map(d=>e.jsxs("button",{onClick:()=>Fn(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 h=d.currentTarget.getBoundingClientRect();L({x:Math.max(8,Math.min(h.right-180,window.innerWidth-196)),y:h.bottom+4})},children:e.jsx(Ot,{size:14})})]}),!U.ok&&e.jsx("div",{className:"dash-banner dash-banner-warn",children:n("dashgrid.fmBroken",{error:U.error})}),ae&&e.jsxs("div",{className:"dash-banner",children:[n("dashgrid.staleBanner"),e.jsx("button",{onClick:()=>ce(_s({},R)??{}),children:n("dashgrid.reflowNow")})]}),e.jsx(Uc,{filters:Se,editable:!l,onChange:mt}),e.jsx(Ko.Provider,{value:Se,children:e.jsxs(ss.div,{layoutScroll:!0,ref:g,className:"dash3-host","data-locked":l||void 0,onPointerMove:Ne,onPointerUp:ye,onPointerCancel:ye,children:[e.jsxs(Pa,{sensors:St,collisionDetection:Da,measuring:{droppable:{strategy:Ta.Always}},onDragStart:G,onDragMove:Be,onDragOver:ze,onDragEnd:sn,onDragCancel:nn,children:[e.jsx(ka,{items:y,strategy:Yc,children:e.jsx("div",{ref:se,className:"dash3-grid",style:{"--dash3-cols":xe,"--dash3-row":`${qt}px`,"--dash3-gap":`${Ue}px`},children:ne>0&&e.jsx(Ys,{initial:!1,mode:"popLayout",children:le.map(({id:d,rowStart:h,rowSpan:C,colStart:z,colSpan:Y,size:Z})=>{const ie=ln(d);return e.jsx(td,{id:d,rowStart:h,rowSpan:C,colStart:z,colSpan:Y,locked:l,chrome:Ut(ie.widget?.kind),kind:ie.widget?.kind??"text",surface:zt(u[d]?.content??"").surface,size:Z,dragging:je===d,sizing:A?.id===d,interact:et===d,reduceMotion:!!p,title:ie.title,Icon:ie.Icon,onOpen:ie.openable,onInteract:()=>Ye(d),onDelete:()=>Nt(d),onMenu:(re,fe)=>H({x:re,y:fe,id:d}),onGripDown:re=>Ke(re,d),children:i(d,Z)},d)})})})}),e.jsx(Ea,{zIndex:30,style:V.current!==1?{zoom:1/V.current}:void 0,dropAnimation:p?null:{duration:200,easing:"cubic-bezier(0.16, 1, 0.3, 1)"},children:ge})]}),!R.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(Pt,{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:Gc.filter(d=>d.cards.length).map(d=>{const h=d.key==="today"?qa:Pt;return e.jsxs("button",{type:"button",className:"dash3-template",onClick:()=>rn(d),children:[e.jsx("span",{className:"dash3-template-icon","aria-hidden":"true",children:e.jsx(h,{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)})})]})})]})}),D&&!l&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"dash-menu-scrim",onClick:()=>H(null)}),e.jsxs("div",{ref:F.ref,className:"dash-add-menu",style:{position:"fixed",left:D.x,top:D.y,...F.style},children:[e.jsx("div",{className:"dash-menu-sep",children:n("dashgrid.menuSize")}),Go.filter(d=>zt(u[D.id]?.content??"").sizes.includes(d.key)).map(d=>e.jsxs("button",{onClick:()=>{kt(D.id,d.w,d.h),H(null)},children:[n(Kc[d.key])," ",e.jsxs("span",{className:"dash3-size-dim",children:[d.w,"×",d.h]})]},d.key)),te[D.id]&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"dash-menu-sep"}),e.jsx("button",{onClick:()=>{Ge(D.id),H(null)},children:n("dashgrid.restoreAuto")})]}),e.jsx("div",{className:"dash-menu-sep"}),e.jsx("button",{className:"dash-danger",onClick:()=>{Nt(D.id),H(null)},children:n("dashgrid.deleteCard")})]})]}),b&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"dash-menu-scrim",onClick:()=>L(null)}),e.jsxs("div",{ref:O.ref,className:"dash-add-menu",style:{position:"fixed",left:b.x,top:b.y,...O.style},children:[e.jsx("button",{onClick:lt,children:n("dashgrid.switchToCanvas")}),e.jsx("button",{onClick:()=>{L(null),(async()=>{const d=(await Je(n("dashgrid.renameTitle"),Vn(a)))?.trim().replace(/[\\/]/g,"");if(!d)return;const h=await s.getState().renamePage(`${d}.dashboard`),C=s.getState().activePage;h&&C&&C!==a&&t.setParams({...t.params,dashPath:C})})()},children:n("dashgrid.rename")}),e.jsx("button",{className:"dash-danger",onClick:()=>{L(null),window.confirm(n("dashgrid.confirmDelete",{name:Vn(a)}))&&s.getState().deletePage(a).then(()=>{const d=s.getState().error;if(d){De.getState().toast(n("dashgrid.deleteFailed",{error:d}),!0);return}De.getState().toast(n("dashgrid.deleted")),Re.getState().closeLeaf(t.id)})},children:n("dashgrid.delete")})]})]})]})}function td({id:t,rowStart:n,rowSpan:s,colStart:a,colSpan:l,locked:o,chrome:r,kind:u,surface:x,size:m,dragging:k,sizing:p,interact:j,reduceMotion:f,title:b,Icon:L,children:D,onOpen:H,onInteract:S,onDelete:O,onMenu:F,onGripDown:N}){const{t:P}=oe(),{attributes:I,listeners:R,setNodeRef:U,isDragging:K}=ar({id:t,disabled:o,transition:null}),ae={gridRow:`${n} / span ${s}`,gridColumn:`${a} / span ${l}`};return e.jsx(ss.div,{ref:U,layout:!0,className:"dash3-card-slot",style:ae,initial:f?!1:{opacity:0,scale:.97,y:8},animate:{opacity:1,scale:1,y:0},exit:f?{opacity:0}:{opacity:0,scale:.96,y:-6},transition:{duration:f?0:p?.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":x,"data-size":m,"data-dragging":K||k||void 0,"data-sizing":p||void 0,"data-interact":j||void 0,children:[b&&!r&&e.jsxs("div",{className:"dash3-card-head",children:[L&&e.jsx(L,{size:13,className:"dash3-card-icon"}),e.jsx("span",{className:"dash3-card-title",children:b}),o&&H&&e.jsx("button",{type:"button",className:"dash3-card-open",title:P("dashgrid.openInTab"),"aria-label":P("dashgrid.openInTabAria",{title:b}),onClick:H,children:e.jsx(Ct,{size:12})})]}),e.jsx("div",{className:"dash3-card-body",children:D}),!o&&e.jsxs(e.Fragment,{children:[!j&&e.jsx("div",{className:"dash3-shield",...I,...R,onDoubleClick:r?void 0:S,title:P(r?"dashgrid.dragToReorder":"dashgrid.dragOrEnter")}),e.jsx("button",{type:"button",className:"dash3-card-btn dash3-card-more",title:P("dashgrid.sizeAndMore"),"aria-label":P("dashgrid.setCardSize"),onClick:q=>{q.stopPropagation();const te=q.currentTarget.getBoundingClientRect();F(Math.max(8,Math.min(te.left-60,window.innerWidth-196)),te.bottom+4)},children:e.jsx(Ot,{size:12})}),e.jsx("button",{type:"button",className:"dash3-card-btn dash3-card-del",title:P("dashgrid.deleteThisCard"),"aria-label":P("dashgrid.deleteThisCard"),onClick:q=>{q.stopPropagation(),O()},children:e.jsx(He,{size:12})}),!r&&e.jsx("div",{className:"dash3-grip",title:P("dashgrid.resize"),onPointerDown:N})]})]})})}export{Nc as A,zs as B,os as C,Md as D,fa as E,Hn as L,li as N,Hl as P,Cc as S,Bc as V,pa as W,Pd as a,Hr as b,Wc as c,jc as d,Ga as e,rc as f,Td as g,Dd as h,Nn as i,Rd as j,xc as k,mi as l,ci as m,Fd as n,Ed as o,Vc as p,dl as r,Cd as s,Ee as u};
@@ -1 +0,0 @@
1
- .dash-stat{gap:4px}.dash-stat-value{font-size:var(--ui-font-display, 20px);font-weight:620;line-height:1.02;color:var(--text);font-variant-numeric:tabular-nums;display:flex;align-items:baseline;gap:4px}.dash-stat-unit{font-size:.42em;font-weight:500;color:var(--text-muted)}.dash-stat-label{font-size:var(--ui-font-meta, 12px);color:var(--text-muted);max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dash-stat-sub{font-size:var(--ui-font-caption, 11px);color:var(--text-faint, var(--text-muted))}.dash-chart{height:100%;display:flex;flex-direction:column;min-height:0;padding:10px 12px;gap:8px}.dash-chart-title{flex:0 0 auto;font-size:var(--ui-font-meta, 12px);font-weight:550;color:var(--text-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dash-chart-body{flex:1 1 auto;min-height:0;display:flex}.dash-filterbar{flex:0 0 auto;display:flex;align-items:center;flex-wrap:wrap;gap:6px;padding:6px 12px;border-bottom:var(--border-width, 1px) solid var(--border);background:var(--bg-card, var(--bg));font-size:var(--ui-font-meta, 12px)}.dash-filterbar-label{color:var(--text-faint, var(--text-muted));margin-right:2px}.dash-filter-chip{display:inline-flex;align-items:center;gap:5px;padding:2px 6px 2px 8px;border:var(--border-width, 1px) solid color-mix(in srgb,var(--primary) 32%,var(--border));border-radius:var(--radius-pill, 999px);background:color-mix(in srgb,var(--primary) 8%,transparent);color:var(--text)}.dash-filter-chip b{font-weight:550}.dash-filter-chip button{border:none;background:transparent;cursor:pointer;padding:0;display:inline-flex;color:var(--text-faint, var(--text-muted))}.dash-filter-chip button:hover{color:var(--danger, #e5484d)}.dash-filter-add{display:inline-flex;align-items:center;gap:4px;padding:2px 8px;border-radius:var(--radius-pill, 999px);cursor:pointer;border:var(--border-width, 1px) dashed var(--border);background:transparent;color:var(--text-muted)}.dash-filter-add:hover{border-color:color-mix(in srgb,var(--primary) 45%,var(--border));color:var(--text)}.dash-filter-editor{display:flex;flex-direction:column;gap:6px;padding:8px;min-width:200px}.dash-filter-editor select,.dash-filter-editor input{width:100%;font:inherit;font-size:var(--ui-font-meta, 12px);padding:4px 6px;border:var(--border-width, 1px) solid var(--border);border-radius:var(--radius-sm, 6px);background:var(--bg);color:var(--text)}.dash-filter-editor select:focus-visible,.dash-filter-editor input:focus-visible{outline:var(--focus-ring) solid var(--primary);outline-offset:1px}.dash-filter-commit{border:none;border-radius:var(--radius-sm, 6px);cursor:pointer;padding:5px 8px;font-size:var(--ui-font-meta, 12px);font-weight:550;background:var(--primary);color:var(--bg)}.dash-router-page{display:flex;flex-direction:column;width:100%;height:100%;min-height:0}.dash-router-page>.dash2,.dash-router-page>.dash3{flex:1 1 auto;min-height:0}.dash3{--dash3-page-pad-block-start: 18px;--dash3-page-pad-block-end: 28px;display:flex;flex-direction:column;min-height:0}.dash3-mode-btn{padding-inline:8px;font-weight:550}.dash3-host{position:relative;flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;background:var(--bg-card, var(--bg));transition:background-color var(--dur-normal, .25s) var(--ease-apple, cubic-bezier(.25, .1, .25, 1))}.dash3-host:not([data-locked]){background:color-mix(in srgb,var(--primary) 2.5%,var(--bg-card, var(--bg)))}.dash3-grid{width:min(100%,1180px);margin-inline:auto;display:grid;grid-template-columns:repeat(var(--dash3-cols, 12),minmax(0,1fr));grid-auto-rows:var(--dash3-row, 72px);gap:var(--dash3-gap, 12px);padding-block-start:var(--dash3-page-pad-block-start);padding-block-end:var(--dash3-page-pad-block-end);padding-inline:var(--dash3-gap, 12px);align-content:start}.dash3-card-slot{position:relative;min-width:0;min-height:0}.dash3-card-slot:has(.dash3-card[data-dragging]),.dash3-card-slot:has(.dash3-card[data-sizing]){z-index:5}.dash3-card{position:relative;display:flex;flex-direction:column;min-width:0;min-height:0;overflow:hidden;border:var(--border-width, 1px) solid transparent;border-radius:var(--radius-md, 12px);background:var(--bg);box-shadow:var(--card-shadow);container-type:inline-size;width:100%;height:100%;transition:background-color var(--dur-normal, .25s) var(--ease-apple, cubic-bezier(.25, .1, .25, 1)),border-color var(--dur-fast, .18s) var(--ease-apple, cubic-bezier(.25, .1, .25, 1)),box-shadow var(--dur-normal, .25s) var(--ease-apple, cubic-bezier(.25, .1, .25, 1)),opacity var(--dur-fast, .18s) var(--ease-apple, cubic-bezier(.25, .1, .25, 1))}.dash3-card[data-surface=metric]{background:color-mix(in srgb,var(--primary) 6%,var(--bg));box-shadow:none}.dash3-card[data-surface=summary]{background:var(--bg);box-shadow:var(--card-shadow)}.dash3-card[data-surface=workspace]{background:var(--bg-card, var(--bg));box-shadow:none}.dash3-card[data-surface=note]{background:color-mix(in srgb,var(--bg) 82%,var(--bg-card));box-shadow:none}.dash3-card--chrome{border-color:transparent;background:transparent;box-shadow:none;overflow:visible;align-self:end}.dash3-card-head{flex:0 0 auto;display:flex;align-items:center;min-height:34px;gap:7px;padding-inline:12px 8px;border-bottom:var(--border-width, 1px) solid transparent;background:transparent;font-size:var(--ui-font-meta, 12px);font-weight:600;color:var(--text-muted);min-width:0}.dash3-card-icon{flex:0 0 auto;opacity:.72}.dash3-card-title{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dash3-card-open{flex:0 0 auto;width:24px;height:24px;border:var(--border-width, 1px) solid transparent;background:transparent;cursor:pointer;color:var(--text-faint, var(--text-muted));padding:0;border-radius:var(--radius-sm, 6px);display:inline-flex;align-items:center;justify-content:center;opacity:0;transition:opacity .12s ease,color .12s ease,background-color .12s ease}.dash3-card:hover .dash3-card-open{opacity:1}.dash3-card-open:hover{color:var(--text);background:var(--overlay-light)}.dash3-card-open:focus-visible{opacity:1;outline:var(--focus-ring) solid var(--primary);outline-offset:1px}.dash3-card-body{flex:1 1 auto;min-width:0;min-height:0;overflow:hidden}.dash3-card[data-surface=workspace]>.dash3-card-body{overflow:auto}.dash3-card[data-kind=view]>.dash3-card-body{overflow:hidden}.dash3-card[data-kind=text]>.dash3-card-body{padding:10px 12px}.dash3-card--chrome>.dash3-card-body{padding:0}.dash-widget.dash-section{display:flex;align-items:baseline;justify-content:flex-start;gap:8px;min-width:0;height:100%;padding:10px 2px 2px;text-align:left}.dash-section-title{color:var(--text);font-size:var(--ui-font-body, 13px);font-weight:650;letter-spacing:.02em}.dash-section-note{overflow:hidden;color:var(--text-muted);font-size:var(--ui-font-meta, 12px);text-overflow:ellipsis;white-space:nowrap}.dash-viewcard--compact{overflow:hidden}.dash-viewcard--interactive{width:100%;height:100%;min-height:0;overflow:hidden}.dash-viewcard--interactive>.am-app{width:100%;height:100%;min-height:0}.dash-compact{height:100%;min-height:0;display:flex;flex-direction:column;padding:0 12px 12px;color:var(--text)}.dash-compact-kpi{min-height:40px;display:flex;align-items:baseline;gap:6px;flex:0 0 auto}.dash-compact-kpi strong{font-size:var(--ui-font-display, 20px);line-height:1;font-weight:640;font-variant-numeric:tabular-nums}.dash-compact-kpi span{color:var(--text-muted);font-size:var(--ui-font-caption, 11px)}.dash-compact-kpi button{margin-left:auto;width:24px;height:24px;display:grid;place-items:center;border:var(--border-width, 1px) solid transparent;border-radius:var(--radius-sm, 6px);background:transparent;color:var(--text-muted);cursor:pointer}.dash-compact-kpi button:hover{background:var(--overlay-light);color:var(--text)}.dash-compact-rows{min-height:0;display:flex;flex:1 1 auto;flex-direction:column;overflow:hidden}.dash-compact-row{min-height:30px;display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:8px;padding:4px 0;border:0;border-bottom:var(--border-width, 1px) solid color-mix(in srgb,var(--border) 44%,transparent);background:transparent;color:var(--text);font:inherit;text-align:left}button.dash-compact-row{cursor:pointer}button.dash-compact-row{transition:color var(--dur-fast, .18s) var(--ease-apple, cubic-bezier(.25, .1, .25, 1)),opacity var(--dur-fast, .18s) var(--ease-apple, cubic-bezier(.25, .1, .25, 1)),background-color var(--dur-fast, .18s) var(--ease-apple, cubic-bezier(.25, .1, .25, 1))}button.dash-compact-row:hover{color:var(--primary);background:color-mix(in srgb,var(--primary) 4%,transparent)}.dash-compact-row>span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:var(--ui-font-meta, 12px)}.dash-compact-row>span b{display:block;overflow:hidden;color:var(--text-muted);font-size:var(--ui-font-caption, 11px);font-weight:550;line-height:1.2;text-overflow:ellipsis;white-space:nowrap}.dash-compact-row>span.is-done{color:var(--text-faint, var(--text-muted));text-decoration:line-through}.dash-compact-row>em{color:var(--text-faint, var(--text-muted));font-size:var(--ui-font-caption, 11px);font-style:normal;white-space:nowrap}.dash-compact-row>em.overdue{color:var(--danger)}.dash-compact-more{padding-top:6px;flex:0 0 auto;color:var(--text-faint, var(--text-muted));font-size:var(--ui-font-caption, 11px)}.dash-compact-empty{min-height:80px;display:flex;align-items:center;justify-content:center;gap:6px;color:var(--text-muted);font-size:var(--ui-font-meta, 12px)}.dash-agenda-row>i{width:7px;height:7px;border-radius:var(--radius-pill, 999px)}.dash-inbox-dot{width:6px;height:6px;border-radius:var(--radius-pill, 999px);background:color-mix(in srgb,var(--text-muted) 28%,transparent)}.dash-inbox-dot.is-unread{background:var(--primary)}.dash-activity-lines{min-height:0;overflow:hidden;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:var(--ui-font-caption, 11px);line-height:1.55}.dash-activity-lines>div{display:grid;grid-template-columns:3.4em minmax(3em,auto) minmax(0,1fr);gap:6px}.dash-activity-lines time{color:var(--text-faint, var(--text-muted))}.dash-activity-lines b{overflow:hidden;color:var(--primary);font-weight:600;text-overflow:ellipsis;white-space:nowrap}.dash-activity-lines span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dash3-shield{position:absolute;inset:0;z-index:2;cursor:grab;touch-action:none;background:transparent;border-radius:inherit;transition:background-color var(--dur-fast, .18s) var(--ease-apple, ease)}.dash3-shield:hover{background:color-mix(in srgb,var(--overlay-light, rgba(127, 127, 127, .06)) 50%,transparent)}.dash3-shield:focus-visible{outline:var(--focus-ring) solid var(--primary);outline-offset:-2px}.dash3-card[data-interact]{outline:1.5px solid var(--primary);outline-offset:1px}.dash3-card[data-dragging]{opacity:.35;outline:1.5px dashed color-mix(in srgb,var(--primary) 55%,transparent);outline-offset:-1.5px}.dash3-card[data-dragging] .dash3-shield{cursor:grabbing}.dash3-card[data-dragging] .dash3-card-btn,.dash3-card[data-dragging] .dash3-grip{opacity:0!important}.dash3-card--lift{cursor:grabbing;box-shadow:0 1px 2px #00000014,0 16px 40px #0000002e;transform:scale(1.02)}.dash3-overlay-ghost{background:linear-gradient(180deg,color-mix(in srgb,var(--primary) 4%,transparent),transparent 62%)}.dash3 .dash-add-menu{animation:dash3-menu-in var(--dur-fast, .18s) var(--ease-apple, cubic-bezier(.25, .1, .25, 1)) both}.dash3 .dash-menu-scrim{animation:dash3-scrim-in var(--dur-fast, .18s) ease both}@keyframes dash3-menu-in{0%{opacity:0;transform:translateY(-5px) scale(.98)}to{opacity:1;transform:none}}@keyframes dash3-scrim-in{0%{opacity:0}to{opacity:1}}.dash3-card-btn{position:absolute;z-index:4;top:6px;width:24px;height:24px;align-items:center;justify-content:center;border:var(--border-width, 1px) solid color-mix(in srgb,var(--border) 72%,transparent);background:var(--bg);color:var(--text-faint, var(--text-muted));cursor:pointer;padding:0;border-radius:var(--radius-sm, 6px);display:inline-flex;opacity:0;transition:opacity .12s ease,color .12s ease,background-color .12s ease}.dash3-card-more{right:36px}.dash3-card-del{right:6px}.dash3-card:hover .dash3-card-btn{opacity:1}.dash3-card-more:hover{color:var(--text);background:var(--overlay-light)}.dash3-card-del:hover{color:var(--danger);background:var(--overlay-light)}.dash3-card-btn:focus-visible{opacity:1;outline:var(--focus-ring) solid var(--primary);outline-offset:1px}.dash3-grip{position:absolute;right:0;bottom:0;width:22px;height:22px;z-index:4;cursor:nwse-resize;touch-action:none;opacity:0;border-radius:var(--radius-sm, 6px) 0 0 0;background:color-mix(in srgb,var(--bg) 76%,transparent);transition:opacity .12s ease,background-color .12s ease}.dash3-host:not([data-locked]) .dash3-grip{opacity:.5}.dash3-card:hover .dash3-grip{opacity:1}.dash3-grip:after{content:"";position:absolute;right:5px;bottom:5px;width:8px;height:8px;border-right:2px solid color-mix(in srgb,var(--primary) 72%,var(--text-muted));border-bottom:2px solid color-mix(in srgb,var(--primary) 72%,var(--text-muted));border-bottom-right-radius:3px}.dash3-card[data-sizing]{outline:1.5px solid var(--primary);outline-offset:1px}.dash3-card[data-sizing] .dash3-grip{opacity:1}@starting-style{.dash3-host:not([data-locked]) .dash3-grip{opacity:0}}.dash3-empty{width:min(100%,680px);min-height:clamp(360px,64vh,560px);margin-inline:auto;padding-block:44px;padding-inline:24px;display:grid;place-items:center}.dash3-empty-panel{width:min(100%,460px)}.dash3-empty-mark{width:42px;height:42px;display:grid;place-items:center;border:var(--border-width, 1px) solid color-mix(in srgb,var(--primary) 24%,var(--border));border-radius:var(--radius-md, 12px);background:color-mix(in srgb,var(--primary) 8%,var(--bg));color:var(--primary)}.dash3-empty-copy{margin-top:16px}.dash3-empty-title{font-size:var(--ui-font-heading, 14px);line-height:1.3;font-weight:650;color:var(--text)}.dash3-empty-sub{margin-top:6px;max-width:38ch;font-size:var(--ui-font-body, 13px);line-height:1.55;color:var(--text-muted)}.dash3-templates{margin-top:20px;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.dash3-template{min-width:0;min-height:76px;display:grid;grid-template-columns:32px minmax(0,1fr);gap:10px;align-items:center;padding-block:12px;padding-inline:12px;border:var(--border-width, 1px) solid transparent;border-radius:var(--radius-md, 12px);background:var(--bg);box-shadow:var(--card-shadow);cursor:pointer;text-align:left;transition:transform .14s ease,border-color .14s ease,background-color .14s ease}.dash3-template:hover{transform:translateY(-1px);border-color:color-mix(in srgb,var(--primary) 48%,var(--border));background:color-mix(in srgb,var(--primary) 3%,var(--bg))}.dash3-template:active{transform:translateY(0)}.dash3-template:focus-visible{outline:var(--focus-ring) solid var(--primary);outline-offset:2px}.dash3-template-icon{width:32px;height:32px;display:grid;place-items:center;border-radius:var(--radius-sm, 8px);background:color-mix(in srgb,var(--primary) 8%,var(--bg-card, var(--bg)));color:var(--primary)}.dash3-template-copy{min-width:0;display:flex;flex-direction:column;gap:3px}.dash3-template-name{font-size:var(--ui-font-body, 13px);line-height:1.25;font-weight:650;color:var(--text)}.dash3-template-hint{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:var(--ui-font-caption, 11px);color:var(--text-muted)}.dash3-size-dim{margin-left:auto;color:var(--text-faint, var(--text-muted));font-variant-numeric:tabular-nums}.dash3-card--chrome .dash-section{padding-inline:4px}.dash3-card--chrome .dash-section-title{font-size:var(--ui-font-body, 13px);line-height:1.35;font-weight:650;letter-spacing:0}@media(max-width:560px){.dash3-empty{padding-inline:16px}.dash3-templates{grid-template-columns:minmax(0,1fr)}}@media(prefers-reduced-motion:reduce){.dash3-host,.dash3-card,.dash-compact-row,.dash3-template,.dash3-card-open,.dash3-card-btn,.dash3-grip,.dash3-shield{transition-duration:.01ms}.dash3 .dash-add-menu,.dash3 .dash-menu-scrim{animation:none}}