@forsion/unit 2.13.4 → 2.13.6

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 (307) hide show
  1. package/README.md +2 -2
  2. package/main.mjs +129 -10
  3. package/package.json +1 -1
  4. package/release.json +6 -5
  5. package/web/assets/ArtificialView-DHqb9CTL.js +1 -0
  6. package/web/assets/AutomationBuilder-CzBKmOiw.js +1 -0
  7. package/web/assets/CalendarConfigView-Blw47NCs.js +1 -0
  8. package/web/assets/CalendarSide-CFSzme3H.js +1 -0
  9. package/web/assets/CalendarView-B8sQfgZt.js +3 -0
  10. package/web/assets/CalendarView-t91KpUG7.css +1 -0
  11. package/web/assets/CapabilityMenu-Dzn6RbB1.js +1 -0
  12. package/web/assets/Chrome-owLewFu4.js +1 -0
  13. package/web/assets/{CodeView-GZ0BAgoW.js → CodeView-E18NDilX.js} +3 -3
  14. package/web/assets/CtxMenuButtons-CAiwQkOK.js +1 -0
  15. package/web/assets/DashboardGridView-CBbYKcCo.js +25 -0
  16. package/web/assets/DashboardGridView-RoVFSkNO.css +1 -0
  17. package/web/assets/EventCard-D9uQe7g4.js +1 -0
  18. package/web/assets/ExcalidrawCanvas-BSOERegJ.js +1 -0
  19. package/web/assets/ExcalidrawCanvas-BgcFPMpU.css +1 -0
  20. package/web/assets/FloatingToc-iK08Qpjc.js +1 -0
  21. package/web/assets/{GitCloneDialog-Bj9G3o-n.css → GitCloneDialog-DOxZk2K0.css} +1 -1
  22. package/web/assets/GitCloneDialog-DfY0kqhP.js +1 -0
  23. package/web/assets/HomepageView-BCqFe1Ym.js +4 -0
  24. package/web/assets/HomepageView-Bx8FbWlY.css +1 -0
  25. package/web/assets/ImageStudioPanels-DdwihAkT.js +3 -0
  26. package/web/assets/ImageStudioView-gJSYrmu1.js +1 -0
  27. package/web/assets/InlineAiPanel-CjYOW0_0.js +1 -0
  28. package/web/assets/InlineFiles-3g2jMUeA.js +1 -0
  29. package/web/assets/{MarkdownBlock-DQTuoen3.css → MarkdownBlock-Cqfk5DhC.css} +1 -1
  30. package/web/assets/MarkdownBlock-DjsGkPZ_.js +58 -0
  31. package/web/assets/{ModelPill-CzdNh7Mt.css → ModelPill-BiUsuhy3.css} +1 -1
  32. package/web/assets/ModelPill-DgyXBsL9.js +2 -0
  33. package/web/assets/MuseLibraryView-D_HBijmU.js +2 -0
  34. package/web/assets/MuseView-BVDlmM6i.js +7 -0
  35. package/web/assets/{PageHistoryPanel-Bn4-XmdK.js → PageHistoryPanel-B1EAPZeX.js} +2 -2
  36. package/web/assets/{PdfAnnotator-Cq8cklTz.js → PdfAnnotator-bdB9evsY.js} +3 -3
  37. package/web/assets/PenRow-DCOIGlfY.js +1 -0
  38. package/web/assets/PluginToolCard-BXE5vA1h.js +2 -0
  39. package/web/assets/PluginToolCard-BmTRr5JT.css +1 -0
  40. package/web/assets/ProductView-l5Q7uBy6.js +1 -0
  41. package/web/assets/SettingsPage-fjxfS_Mt.js +3 -0
  42. package/web/assets/StudioGuestSurface-360CWUwf.js +1 -0
  43. package/web/assets/TodoListView-BsPt2GUU.js +1 -0
  44. package/web/assets/Tooltip-CuXpWtdJ.js +1 -0
  45. package/web/assets/UnifiedPage-6xbFLtXT.js +712 -0
  46. package/web/assets/UnifiedPage-CTmQpf2T.css +1 -0
  47. package/web/assets/{ViewSelectionBar-35x8TiLA.js → ViewSelectionBar-C5FDh7fO.js} +2 -2
  48. package/web/assets/appStore-BskcSDl6.js +455 -0
  49. package/web/assets/appStore-iy8_Tmac.css +1 -0
  50. package/web/assets/arrow-up-right-DEykpgsH.js +1 -0
  51. package/web/assets/{artificial-BzLFkChP.css → artificial-BubVxExB.css} +1 -1
  52. package/web/assets/astryxBridge-B2IZdPvo.js +69 -0
  53. package/web/assets/astryxBridge-djzCiy4v.css +1 -0
  54. package/web/assets/automationListSource-Cm09JKkK.js +1 -0
  55. package/web/assets/boardSurface-Dv-aVaUJ.js +1 -0
  56. package/web/assets/calendarNavStore-FKStA7Hh.js +1 -0
  57. package/web/assets/canvasPrefs-CMulOS0k.js +1 -0
  58. package/web/assets/chatBoxSurface-BR_G6cxG.js +1 -0
  59. package/web/assets/chevron-up-C_EDOZzI.js +1 -0
  60. package/web/assets/{client-CaivGZFR.js → client-DD5czSuF.js} +5 -5
  61. package/web/assets/code-xml-vTB4LtTf.js +1 -0
  62. package/web/assets/{codeStudioStore-DhyMazGT.js → codeStudioStore-OswE1_s0.js} +8 -8
  63. package/web/assets/codingNavigation-BrkLENBZ.css +1 -0
  64. package/web/assets/contextMenuSurface-DqdYEGuH.js +1 -0
  65. package/web/assets/copy-plus-CVHqDNny.js +1 -0
  66. package/web/assets/create-DZWy4zBR.js +14 -0
  67. package/web/assets/dashboardSurface-Co4byEQm.js +1 -0
  68. package/web/assets/dbStore-Bc2lC8ZI.js +2 -0
  69. package/web/assets/deskCapture-BfTzH2aO.js +1 -0
  70. package/web/assets/{diff2html-Daje9Kkm.js → diff2html-0MkNy2ws.js} +2 -2
  71. package/web/assets/{docx-preview-CABR7n30.js → docx-preview-CwNWZegI.js} +1 -1
  72. package/web/assets/draft-DTzuTatQ.js +2 -0
  73. package/web/assets/drawingStore-BD5m2eqn.js +7 -0
  74. package/web/assets/file-down-Cjo_T6By.js +1 -0
  75. package/web/assets/floatingTocSurface-D3IIVNnq.js +1 -0
  76. package/web/assets/foldActions-utwZpRrA.js +1 -0
  77. package/web/assets/folder-DiaFWdCg.js +1 -0
  78. package/web/assets/folder-minus-DUEOcs12.js +1 -0
  79. package/web/assets/folder-plus-Cmhq0GcR.js +1 -0
  80. package/web/assets/gestures-Bx9M0le5.js +1 -0
  81. package/web/assets/git-branch-DzGWffyD.js +1 -0
  82. package/web/assets/homeCardStatus-NAk4A77P.js +1 -0
  83. package/web/assets/i18n-CAf4PT1o.css +1 -0
  84. package/web/assets/i18n.generated-D4-Wu9Wh.js +15 -0
  85. package/web/assets/imageStudio-CwG21Bat.css +1 -0
  86. package/web/assets/imageStudio-D67oElIb.js +4 -0
  87. package/web/assets/index-3VWZ1rsL.js +13 -0
  88. package/web/assets/index-58wBjkHy.js +3 -0
  89. package/web/assets/index-B9_zH7f5.js +1 -0
  90. package/web/assets/index-BQrMYjou.js +1 -0
  91. package/web/assets/index-BWrWMYua.js +1 -0
  92. package/web/assets/index-BdLJBf4-.js +1 -0
  93. package/web/assets/index-Bf3W92Hb.js +1 -0
  94. package/web/assets/index-BjmPaLFA.js +1 -0
  95. package/web/assets/index-Bv-vJTzF.js +7 -0
  96. package/web/assets/index-C7yb62gg.js +1 -0
  97. package/web/assets/index-C9gBBMYv.js +1 -0
  98. package/web/assets/index-CiQ59Kib.js +1 -0
  99. package/web/assets/{index-gt5JBIFf.js → index-CzTUjEMt.js} +2 -2
  100. package/web/assets/index-D4Qx6o3E.js +1 -0
  101. package/web/assets/index-DDBcn3UD.js +1 -0
  102. package/web/assets/index-DEADY94l.js +1 -0
  103. package/web/assets/index-DGTKsPAQ.js +1 -0
  104. package/web/assets/index-DRwDqvjf.js +1 -0
  105. package/web/assets/{index-BGfvNj7R.js → index-DexVkoxH.js} +2 -2
  106. package/web/assets/{index-O05r2Ty6.js → index-IMOhRWY8.js} +1 -1
  107. package/web/assets/index-XjvpYHIo.js +1 -0
  108. package/web/assets/index-YuejkHoJ.js +3412 -0
  109. package/web/assets/index-pH0266gX.js +1 -0
  110. package/web/assets/index-sQl_bGM_.js +1 -0
  111. package/web/assets/index-vbNFy5lS.js +1 -0
  112. package/web/assets/{invitePage-Bgveo6Hj.js → invitePage-BT_rFfab.js} +1 -1
  113. package/web/assets/{ipc-B6hkgxQL.js → ipc-8cxXGSZK.js} +1 -1
  114. package/web/assets/{jszip.min-eU-k-vEy.js → jszip.min-By4OI3XR.js} +1 -1
  115. package/web/assets/launchpad-BX4jQyF4.js +2 -0
  116. package/web/assets/launchpad-C9U9hpWJ.css +1 -0
  117. package/web/assets/layout-grid-CzxXbCDa.js +1 -0
  118. package/web/assets/linkFollow-J2c0wSgB.js +8 -0
  119. package/web/assets/{listFold-M8s5JYEC.js → listFold-B_2Xqxn_.js} +1 -1
  120. package/web/assets/lock-open-DVWCLSZm.js +1 -0
  121. package/web/assets/log-out-CdKTS7HC.js +1 -0
  122. package/web/assets/magnet-BmVcZ9U4.js +1 -0
  123. package/web/assets/main-BlVApHpj.css +1 -0
  124. package/web/assets/main-CForzSFD.js +15 -0
  125. package/web/assets/markdownEditorSurface-BiDH0__r.css +1 -0
  126. package/web/assets/markdownEditorSurface-Bs8FJNHu.js +3 -0
  127. package/web/assets/mediaPlayer-O9pVRl_k.js +1 -0
  128. package/web/assets/message-square-plus-CspBv9iG.js +1 -0
  129. package/web/assets/{messages-CKtabOqy.js → messages-CG7ywZ-K.js} +1 -1
  130. package/web/assets/minimize-2-Bq4vUin-.js +1 -0
  131. package/web/assets/mobileEntry-6u7TYC4s.css +1 -0
  132. package/web/assets/mobileEntry-CptXQ4Ov.js +13 -0
  133. package/web/assets/modelPickerSurface-C0SkjaPL.js +1 -0
  134. package/web/assets/nativeDownload-DlnT8U-y.js +1 -0
  135. package/web/assets/nativeSheetMenu-CVC51DzC.js +1 -0
  136. package/web/assets/pageStore-BC6Z18n7.css +1 -0
  137. package/web/assets/pageStore-D_fKLv-o.js +13 -0
  138. package/web/assets/{pageTree-BYYPgZm_.js → pageTree-DtDKozTg.js} +3 -3
  139. package/web/assets/pen-line-ho1GgAe2.js +1 -0
  140. package/web/assets/pen-tool-CV-FKFEZ.js +1 -0
  141. package/web/assets/pencil-BgF4Kiqp.js +1 -0
  142. package/web/assets/phoneList-BLVdQcXY.js +1 -0
  143. package/web/assets/phoneList-BpLxxdq6.css +1 -0
  144. package/web/assets/pluginChat-C6t6DWhY.js +2 -0
  145. package/web/assets/react-DOzedx9n.js +1 -0
  146. package/web/assets/recordSurface-C9SRNjy4.js +1 -0
  147. package/web/assets/redo-2-DWZTaEz-.js +1 -0
  148. package/web/assets/rotate-ccw-CyZpL7MX.js +1 -0
  149. package/web/assets/selectionActions-C2a8ImJm.js +2 -0
  150. package/web/assets/selectionBarSurface-DaXlyy1s.js +1 -0
  151. package/web/assets/sessionTitle-BtZ1BteL.js +1 -0
  152. package/web/assets/settingsPageSurface-Cg8FNZq3.js +1 -0
  153. package/web/assets/sharePage-vnghra3Q.js +2 -0
  154. package/web/assets/{shareViewer-BiMqIBxP.js → shareViewer-CWJQHiV-.js} +2 -2
  155. package/web/assets/star-ZEpUQwnX.js +1 -0
  156. package/web/assets/tableSurface-DfEdzVDn.js +1 -0
  157. package/web/assets/tanguProbe-BboOas-a.js +6 -0
  158. package/web/assets/{terminalView-lbcBgG0c.js → terminalView-xp8ARBLi.js} +3 -3
  159. package/web/assets/type-CMyP4cKt.js +1 -0
  160. package/web/assets/undo-2-C4ZCsMsx.js +1 -0
  161. package/web/assets/{unitAccount-DGwGsmC3.js → unitAccount-DNxfGo3c.js} +1 -1
  162. package/web/assets/{unitBridge-CE2yAvm0.js → unitBridge-Bq0n1ZM6.js} +1 -1
  163. package/web/assets/{unitCloudTransport-BGFwkaDM.js → unitCloudTransport-CErylgEO.js} +1 -1
  164. package/web/assets/unitOwnerAccess-7s-3dfNM.js +1 -0
  165. package/web/assets/unitShim-BfheyIG8.js +5 -0
  166. package/web/assets/upload-VtCrluEO.js +1 -0
  167. package/web/assets/userSpaces-BpeYjLni.js +1 -0
  168. package/web/assets/viewportLock-B0l1GU_k.css +1 -0
  169. package/web/assets/viewportLock-cVUalJAI.js +738 -0
  170. package/web/assets/zoom-in-C7R8s9x-.js +1 -0
  171. package/web/excalidraw/excalidraw.js +4 -2
  172. package/web/index.html +12 -13
  173. package/web/assets/ArtificialView-DLh75dAI.js +0 -1
  174. package/web/assets/AutomationBuilder-DNWWGnFr.js +0 -1
  175. package/web/assets/CalendarConfigView-G7je7k9-.js +0 -1
  176. package/web/assets/CalendarView-B2MtaOJk.js +0 -1
  177. package/web/assets/CapabilityMenu-DJaZ_Cyt.js +0 -1
  178. package/web/assets/CheckboxInput-FYXLaZke.js +0 -1
  179. package/web/assets/Chrome-CFonajM4.js +0 -1
  180. package/web/assets/DashboardGridView-D9s9pez_.css +0 -1
  181. package/web/assets/DashboardGridView-Xgw4wa0_.js +0 -17
  182. package/web/assets/EventCard-_39F_I5M.js +0 -1
  183. package/web/assets/ExcalidrawCanvas-4uYrLYin.css +0 -1
  184. package/web/assets/ExcalidrawCanvas-rXujil36.js +0 -1
  185. package/web/assets/FloatingToc-DNqAkkI0.js +0 -1
  186. package/web/assets/GitCloneDialog-CQx-O4j1.js +0 -1
  187. package/web/assets/HomepageView-DcWmTPQO.css +0 -1
  188. package/web/assets/HomepageView-MYEk3RCs.js +0 -3
  189. package/web/assets/ImageStudioPanels-4wnb2XF4.js +0 -3
  190. package/web/assets/ImageStudioView-qrmW8pfx.js +0 -1
  191. package/web/assets/InlineAiPanel-B3kd1ob2.js +0 -1
  192. package/web/assets/InlineFiles-Clnqh9jD.js +0 -1
  193. package/web/assets/MarkdownBlock-DT_wsaja.js +0 -58
  194. package/web/assets/ModelPill-JaIH3ffZ.js +0 -2
  195. package/web/assets/MuseLibraryView-DOJVVeU6.js +0 -2
  196. package/web/assets/MuseView-uxTmjVQa.js +0 -6
  197. package/web/assets/PenRow-COOYAaxx.js +0 -1
  198. package/web/assets/ProductView-DPTveulg.js +0 -1
  199. package/web/assets/RightPanel-BJUacrsf.js +0 -4
  200. package/web/assets/RightPanel-D0zk1g3I.css +0 -1
  201. package/web/assets/SketchCard-B_UU5sxV.js +0 -641
  202. package/web/assets/StudioGuestSurface-yBa4QKfX.js +0 -1
  203. package/web/assets/TargetHealthNotice-BLzDB-Xl.css +0 -1
  204. package/web/assets/TargetHealthNotice-CgkdTdhB.js +0 -47
  205. package/web/assets/TodoListView-CricdCfW.js +0 -1
  206. package/web/assets/Tooltip-o8ZqIb3L.js +0 -1
  207. package/web/assets/UnifiedPage-BWAyqj65.js +0 -69
  208. package/web/assets/UnifiedPage-CWXc_mo1.css +0 -1
  209. package/web/assets/appStore-CI1_L5OS.js +0 -3357
  210. package/web/assets/appStore-DQc2marq.css +0 -1
  211. package/web/assets/approvalText-Cy2UAUAQ.js +0 -2
  212. package/web/assets/arrow-up-right-BDsMFoNQ.js +0 -1
  213. package/web/assets/astryxBridge-CF_hpqC2.css +0 -1
  214. package/web/assets/astryxBridge-CH_c5xjo.js +0 -70
  215. package/web/assets/automationListSource-CB6AWkL_.js +0 -1
  216. package/web/assets/boardSurface-CLvEUjbF.js +0 -1
  217. package/web/assets/book-open-BLzEdGfu.js +0 -1
  218. package/web/assets/calendarNavStore-BHUNxDx8.js +0 -1
  219. package/web/assets/canvasPrefs-CvE7mgyq.js +0 -1
  220. package/web/assets/chatBoxSurface-CuuHLzs5.js +0 -1
  221. package/web/assets/circle-question-mark-BM4ZRxQS.js +0 -1
  222. package/web/assets/circle-x-DTcNGZDT.js +0 -1
  223. package/web/assets/code-xml-AE3mT4T5.js +0 -1
  224. package/web/assets/codingNavigation-B0kVsy4x.js +0 -53
  225. package/web/assets/codingNavigation-DHCidM4N.css +0 -1
  226. package/web/assets/create-1JI2I47p.js +0 -14
  227. package/web/assets/dashboardSurface-CIE5HybN.js +0 -1
  228. package/web/assets/deskCapture-COW7aG5Y.js +0 -1
  229. package/web/assets/emoji-DZ9CA_3l.css +0 -1
  230. package/web/assets/emoji-DphwSxPx.js +0 -1
  231. package/web/assets/floatingTocSurface-BOm2QYBK.js +0 -1
  232. package/web/assets/foldActions-DNbJPlPl.js +0 -1
  233. package/web/assets/folder-DotgUhYD.js +0 -1
  234. package/web/assets/folder-plus-aJgL9NeP.js +0 -1
  235. package/web/assets/gestures-dqncPOwo.js +0 -1
  236. package/web/assets/git-branch-CwR2qic6.js +0 -1
  237. package/web/assets/hack2gate-dark-Dx2RtDRI.jpg +0 -0
  238. package/web/assets/hack2gate-light-DRKq9tyS.jpg +0 -0
  239. package/web/assets/hand-XNkzNiW2.js +0 -1
  240. package/web/assets/hard-drive-CfWKRoAE.js +0 -1
  241. package/web/assets/i18n-CykmULlm.css +0 -1
  242. package/web/assets/i18n.generated-BwynSSMk.js +0 -15
  243. package/web/assets/imageStudio-CWgLpC_d.js +0 -2
  244. package/web/assets/imageStudio-DZ0qGU2s.css +0 -1
  245. package/web/assets/index-B65ULikK.js +0 -1
  246. package/web/assets/index-BIIeiIap.js +0 -1
  247. package/web/assets/index-BOzsniE1.js +0 -297
  248. package/web/assets/index-BfrjVzia.js +0 -13
  249. package/web/assets/index-Bi9UtjVz.js +0 -1
  250. package/web/assets/index-C1uilc9i.js +0 -1
  251. package/web/assets/index-C3Dc3Ivz.js +0 -1
  252. package/web/assets/index-CJF_Ld1Y.js +0 -1
  253. package/web/assets/index-CMARP4oV.js +0 -1
  254. package/web/assets/index-C_RsQVNm.js +0 -7
  255. package/web/assets/index-ChyxZMm8.js +0 -1
  256. package/web/assets/index-CoKcOaZg.js +0 -1
  257. package/web/assets/index-CuviSCbk.js +0 -1
  258. package/web/assets/index-Cw43kua8.js +0 -1
  259. package/web/assets/index-D1fu6XQN.js +0 -3
  260. package/web/assets/index-DG-hXb63.js +0 -1
  261. package/web/assets/index-DjnTfJpN.js +0 -1
  262. package/web/assets/index-Dtw0abst.js +0 -1
  263. package/web/assets/index-W3ErfZiX.js +0 -1
  264. package/web/assets/index-Yc56b3XX.js +0 -1
  265. package/web/assets/index-d4jCdYJH.js +0 -1
  266. package/web/assets/index-siHtlYTM.js +0 -1
  267. package/web/assets/launchpad-C2c1MSVX.css +0 -1
  268. package/web/assets/layout-grid-CraV7nhh.js +0 -1
  269. package/web/assets/linkFollow-BpvDWzUx.js +0 -8
  270. package/web/assets/list-tree-cLJw-jYQ.js +0 -1
  271. package/web/assets/lock-DBkXXwaI.js +0 -1
  272. package/web/assets/lock-open-C-9-AWct.js +0 -1
  273. package/web/assets/log-out-C8bDXj9P.js +0 -1
  274. package/web/assets/main-BiS_5wrB.css +0 -1
  275. package/web/assets/main-CMk6twzA.js +0 -20
  276. package/web/assets/markdownEditorSurface-Bql20IAf.css +0 -1
  277. package/web/assets/markdownEditorSurface-DgQ0TUWH.js +0 -3
  278. package/web/assets/message-square-plus-8pfimvem.js +0 -1
  279. package/web/assets/minus-CfA9fAN3.js +0 -1
  280. package/web/assets/mobileEntry-DS1vohuL.css +0 -1
  281. package/web/assets/mobileEntry-NcMcK0LV.js +0 -13
  282. package/web/assets/nativeDownload-CNtwSCy0.js +0 -1
  283. package/web/assets/pageChrome-BR4cfIaA.js +0 -1
  284. package/web/assets/pageChrome-BbUhILy0.css +0 -1
  285. package/web/assets/pen-tool-C5ftHCnm.js +0 -1
  286. package/web/assets/pencil-ehhM9_9k.js +0 -1
  287. package/web/assets/phoneList-B6gwUJZF.js +0 -9
  288. package/web/assets/phoneList-iRdfiKA8.css +0 -1
  289. package/web/assets/pluginChat-DTTWWiUS.js +0 -2
  290. package/web/assets/redo-2-DCEAgQlN.js +0 -1
  291. package/web/assets/rotate-ccw-DdkrbRAB.js +0 -1
  292. package/web/assets/selectionActions-BQD2kox1.js +0 -2
  293. package/web/assets/selectionBarSurface-CzUZmJDJ.js +0 -1
  294. package/web/assets/server-Ddu9f1k3.js +0 -1
  295. package/web/assets/sharePage-CNrm2xTC.js +0 -2
  296. package/web/assets/star-Dxv7XANS.js +0 -1
  297. package/web/assets/tableSurface-Bly1iCXc.js +0 -1
  298. package/web/assets/terminal-CAmmC9cV.js +0 -1
  299. package/web/assets/type-Dz6rnTvG.js +0 -1
  300. package/web/assets/undo-2-B7izWNb_.js +0 -1
  301. package/web/assets/unitOwnerAccess-D4nKS6Gg.js +0 -1
  302. package/web/assets/unitShim-2_2hhGxS.js +0 -5
  303. package/web/assets/upload-DqpRRAhG.js +0 -1
  304. package/web/assets/userSpaces-VFu4s05v.js +0 -1
  305. package/web/assets/viewportLock-3AOdDmwi.js +0 -631
  306. package/web/assets/viewportLock-djvL8fUQ.css +0 -1
  307. package/web/assets/zoom-in-Bf-eKTnH.js +0 -1
@@ -0,0 +1,25 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./PageHistoryPanel-B1EAPZeX.js","./index-YuejkHoJ.js","./pageStore-D_fKLv-o.js","./react-DOzedx9n.js","./client-DD5czSuF.js","./pageStore-BC6Z18n7.css","./create-DZWy4zBR.js","./appStore-BskcSDl6.js","./dbStore-Bc2lC8ZI.js","./ipc-8cxXGSZK.js","./nativeDownload-DlnT8U-y.js","./drawingStore-BD5m2eqn.js","./appStore-iy8_Tmac.css","./create-BgE3edmZ.css","./UnifiedPage-6xbFLtXT.js","./MarkdownBlock-DjsGkPZ_.js","./index-CiQ59Kib.js","./linkFollow-J2c0wSgB.js","./selectionActions-C2a8ImJm.js","./listFold-B_2Xqxn_.js","./FloatingToc-iK08Qpjc.js","./MarkdownBlock-Cqfk5DhC.css","./type-CMyP4cKt.js","./upload-VtCrluEO.js","./arrow-up-right-DEykpgsH.js","./Chrome-owLewFu4.js","./magnet-BmVcZ9U4.js","./canvasPrefs-CMulOS0k.js","./InlineAiPanel-CjYOW0_0.js","./InlineAiPanel-DZZijfif.css","./foldActions-utwZpRrA.js","./undo-2-C4ZCsMsx.js","./code-xml-vTB4LtTf.js","./message-square-plus-CspBv9iG.js","./UnifiedPage-CTmQpf2T.css","./pageTree-DtDKozTg.js","./pluginExt-Byb64tQO.js","./nativeSheetMenu-CVC51DzC.js","./star-ZEpUQwnX.js","./CtxMenuButtons-CAiwQkOK.js","./phoneList-BLVdQcXY.js","./phoneList-BpLxxdq6.css","./pen-tool-CV-FKFEZ.js","./pencil-BgF4Kiqp.js","./folder-plus-Cmhq0GcR.js","./folder-minus-DUEOcs12.js","./redo-2-DWZTaEz-.js","./file-down-Cjo_T6By.js","./folder-DiaFWdCg.js","./layout-grid-CzxXbCDa.js","./PageHistoryPanel-DFjh0pWs.css"])))=>i.map(i=>d[i]);
2
+ import{R as ne,r as _,j as a,a2 as Er,a3 as rs,a as Ve,u as Ce,a4 as Pd,a5 as Gr,X as kd,f as zd,a6 as Ir,t as Q,_ as Td,v as Ed,a7 as Gd,a8 as Id,i as _i,m as Qo,a9 as pn,n as Ad,aa as Ys,ab as Nd,ac as jd,ad as Od,a1 as Md,ae as Ld,af as ea,ag as Rd}from"./index-YuejkHoJ.js";import{p as Je,bR as Vd,bS as ze,y as ws,x as Ar,w as Fd,z as Nr,b8 as jr,bT as Wd,aa as $d,ab as Hd,a3 as Xs,bF as Bd,bU as Ud,bV as Yd,bW as ta,bX as Xd,A as yi,o as gn,am as Kd,bE as qd,a6 as ui,al as Jd,aH as bs,bY as Zd,bZ as Qd,ah as Cn,T as ec,X as Jt,ay as tc,b_ as ic,ai as nc,b$ as sc,aO as So,c0 as oc,c1 as ac,c2 as rc,R as Ks,c3 as Or,W as lc,c4 as dc,c5 as cc,c6 as hc,F as Yi,u as K,aE as me,c7 as uc,l as Xe,c8 as Mr,c9 as Po,ca as pc,cb as mc,cc as vc,cd as gc,ce as fc,aj as ei,aU as Lr,be as ko,cf as xs,cg as Rr,b4 as Si,r as Vr,ch as _c,by as Fr,b3 as zo,bz as wc,k as bc,bA as xc,aA as Fi,D as Ln,bw as yc,a7 as Xi,ci as Dc,I as Cc,cj as Sc,ad as Pc,bc as kc,b6 as Wi,ck as zc,bd as Wr,aV as wi,aT as Rn,cl as Tc,as as Ec,aQ as Gc,cm as Ic,cn as Ac,av as Nc,co as jc,cp as Oc,b5 as ns}from"./pageStore-D_fKLv-o.js";import"./client-DD5czSuF.js";import{ee as Mc,aj as ia,J as ls,kI as Lc,kJ as Es,kK as $r,kL as Hr,kM as Rc,kN as Vc,kO as Fc,kP as Wc,kQ as $c,kR as Hc,a4 as Ki,fD as Sn,u as Ke,S as To,e_ as Ot,eL as Be,hz as ft,er as qe,kS as Br,i5 as Bc,fl as Uc,bv as Ur,kT as Yc,hr as Xc,kU as Eo,kV as Yr,kW as Kc,f7 as Xr,kX as Kr,eU as qr,kY as qs,kZ as qc,k_ as Jc,eY as Jr,k$ as Zr,l0 as Qr,l1 as Zc,l2 as el,l3 as Qc,E as Qt,d8 as Go,b4 as $i,aQ as gt,cE as eh,jb as th,l4 as Hi,k4 as tl,fg as Mi,X as ih,l5 as nh,gb as sh,g as oh,fk as ah,bV as Js,eq as fn,aN as Zt,ex as ss,K as Ai,ey as Gs,ff as Kt,bG as il,l6 as na,jJ as sa,ez as oa,gS as Is,l7 as aa,eu as Vn,l8 as rh,aA as As,l9 as ra,df as la,la as da,bQ as ca,lb as lh,lc as dh,j as Zs,eg as ch,gj as hh,fo as ha,gi as uh,hs as Ns,jH as ph,jK as mh,jI as vh,i as nl,ht as sl,ld as gh,le as fh,lf as _h,lg as wh,lh as bh,li as xh,lj as yh,lk as Dh,ll as Ch,lm as Sh,ln as Ph,lo as kh,lp as ua,lq as ol,lr as pa,f2 as al,gp as zh,gq as Th,f1 as Fe,ls as js,F as Eh,lt as ma,lu as va,eM as Os,f3 as Ms,lv as Gh,lw as ga,lx as Ih,ly as fa,lz as Ah,f4 as Ls,lA as Rs,lB as Nh,lC as jh,lD as Oh,f6 as bi,lE as Qs,lF as on,lG as an,lH as zt,ag as eo,fq as Mh,eW as Lh,C as rl,lI as Rh,lJ as Vh,lK as Fh,lL as Wh,eT as _a,lM as $h,lN as Hh,lO as Bh,lP as Uh,lQ as Yh,lR as Xh,lS as Kh,lT as qh,eZ as Jh,lU as Fn,lV as Zh,lW as Qh,lX as eu}from"./appStore-BskcSDl6.js";import{j as tu,k as ll,C as iu,u as nu,S as su,r as ou,I as au,l as ru,m as lu,U as du,N as cu,A as hu,d as uu,n as pu,p as mu}from"./UnifiedPage-6xbFLtXT.js";import{F as vu}from"./FloatingToc-iK08Qpjc.js";import{d as gu,R as fu,g as dl,e as _u,h as wu}from"./MarkdownBlock-DjsGkPZ_.js";import{m as bu,b as xu,r as wa}from"./pageTree-DtDKozTg.js";import{normalizePluginRename as yu}from"./pluginExt-Byb64tQO.js";import{c as mi}from"./react-DOzedx9n.js";import{u as Du}from"./nativeSheetMenu-CVC51DzC.js";import{L as Cu,S as ds}from"./star-ZEpUQwnX.js";import{C as Su}from"./CtxMenuButtons-CAiwQkOK.js";import{u as Pu,b as ku,c as zu,P as Tu,e as Eu,w as Gu,L as Iu,a as Au,S as Nu,d as ju}from"./phoneList-BLVdQcXY.js";import{P as rn}from"./pen-tool-CV-FKFEZ.js";import{P as mn}from"./pencil-BgF4Kiqp.js";import{F as ba}from"./folder-plus-Cmhq0GcR.js";import{F as Ou}from"./folder-minus-DUEOcs12.js";import{U as to}from"./upload-VtCrluEO.js";import{F as Mu,T as cl}from"./type-CMyP4cKt.js";import{U as Lu}from"./undo-2-C4ZCsMsx.js";import{R as Ru}from"./redo-2-DWZTaEz-.js";import{C as Vs}from"./code-xml-vTB4LtTf.js";import{F as Wn}from"./file-down-Cjo_T6By.js";import{F as Io}from"./folder-DiaFWdCg.js";import{u as Bi}from"./dbStore-Bc2lC8ZI.js";import{L as Ni}from"./layout-grid-CzxXbCDa.js";const Vu=[["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"}]],hl=Je("a-large-small",Vu);const Fu=[["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"}]],Wu=Je("book-marked",Fu);const $u=[["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"}]],io=Je("cloud-off",$u);const Hu=[["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"}]],Bu=Je("cloud-sun",Hu);const Uu=[["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v.5",key:"1dkoa9"}],["path",{d:"M12 10v4h4",key:"1czhmt"}],["path",{d:"m12 14 1.535-1.605a5 5 0 0 1 8 1.5",key:"lvuxfi"}],["path",{d:"M22 22v-4h-4",key:"1ewp4q"}],["path",{d:"m22 18-1.535 1.605a5 5 0 0 1-8-1.5",key:"14ync0"}]],Yu=Je("folder-sync",Uu);const Xu=[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]],Ku=Je("heading",Xu);const qu=[["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"}]],$n=Je("layout-dashboard",qu);const Ju=[["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"}]],Zu=Je("list-indent-decrease",Ju);const Qu=[["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"}]],ep=Je("list-indent-increase",Qu);const tp=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}]],ip=Je("panel-bottom",tp);const np=[["path",{d:"M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4",key:"daa4of"}],["rect",{width:"10",height:"7",x:"12",y:"13",rx:"2",key:"1nb8gs"}]],sp=Je("picture-in-picture-2",np);const op=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],no=Je("pin",op);const ap=[["path",{d:"M20 9V7a2 2 0 0 0-2-2h-6",key:"19z8uc"}],["path",{d:"m15 2-3 3 3 3",key:"177bxs"}],["path",{d:"M20 13v5a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h2",key:"d36hnl"}]],rp=Je("rotate-ccw-square",ap);const lp=[["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"}]],cs=Je("share-2",lp);const dp=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],ji=Je("square-pen",dp);const cp=[["path",{d:"m10.344 4.688 1.181-2.393a.53.53 0 0 1 .95 0l2.31 4.679a2.12 2.12 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.237 3.152",key:"19ctli"}],["path",{d:"m17.945 17.945.43 2.505a.53.53 0 0 1-.771.56l-4.618-2.428a2.12 2.12 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.12 2.12 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a8 8 0 0 0 .4-.099",key:"ptqqvy"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],hp=Je("star-off",cp);var up={};class ul{}class _t extends ul{constructor(e,t,i,s){super(),this.viewId=e,this.groupId=t,this.panelId=i,this.tabGroupId=s}}class _n extends ul{constructor(e,t){super(),this.viewId=e,this.paneId=t}}class Gt{constructor(){}static getInstance(){return Gt.INSTANCE}hasData(e){return e&&e===this.proto}clearData(e){this.hasData(e)&&(this.proto=void 0,this.data=void 0)}getData(e){if(this.hasData(e))return this.data}setData(e,t){t&&(this.data=e,this.proto=t)}}Gt.INSTANCE=new Gt;function Ae(){const n=Gt.getInstance();if(n.hasData(_t.prototype))return n.getData(_t.prototype)[0]}function ln(){const n=Gt.getInstance();if(n.hasData(_n.prototype))return n.getData(_n.prototype)[0]}var ke;(function(n){n.NONE={dispose:()=>{}};function e(t){return{dispose:()=>{t()}}}n.from=e})(ke||(ke={}));class X{get isDisposed(){return this._isDisposed}constructor(...e){this._isDisposed=!1,this._disposables=new Set(e)}addDisposables(...e){e.forEach(t=>this._disposables.add(t))}removeDisposable(e){this._disposables.delete(e)}dispose(){this._isDisposed||(this._isDisposed=!0,this._disposables.forEach(e=>e.dispose()),this._disposables.clear())}}class $e{constructor(){this._disposable=ke.NONE}set value(e){this._disposable&&this._disposable.dispose(),this._disposable=e}dispose(){this._disposable&&(this._disposable.dispose(),this._disposable=ke.NONE)}}var wt;(function(n){n.any=(...e)=>t=>{const i=e.map(s=>s(t));return{dispose:()=>{i.forEach(s=>{s.dispose()})}}}})(wt||(wt={}));class Ao{constructor(){this._defaultPrevented=!1}get defaultPrevented(){return this._defaultPrevented}preventDefault(){this._defaultPrevented=!0}}class pl{constructor(){this._isAccepted=!1}get isAccepted(){return this._isAccepted}accept(){this._isAccepted=!0}}class pp{constructor(){this.events=new Map}get size(){return this.events.size}add(e,t){this.events.set(e,t)}delete(e){this.events.delete(e)}clear(){this.events.clear()}}class hs{static create(){var e;return new hs((e=new Error().stack)!==null&&e!==void 0?e:"")}constructor(e){this.value=e}print(){console.warn("dockview: stacktrace",this.value)}}class mp{constructor(e,t){this.callback=e,this.stacktrace=t}}class z{static setLeakageMonitorEnabled(e){e!==z.ENABLE_TRACKING&&z.MEMORY_LEAK_WATCHER.clear(),z.ENABLE_TRACKING=e}get value(){return this._last}constructor(e){this.options=e,this._listeners=[],this._disposed=!1,this._pauseTokens=new Set}get event(){return this._event||(this._event=e=>{var t;!((t=this.options)===null||t===void 0)&&t.replay&&this._last!==void 0&&e(this._last);const i=new mp(e,z.ENABLE_TRACKING?hs.create():void 0);return this._listeners.push(i),{dispose:()=>{const s=this._listeners.indexOf(i);s>-1&&this._listeners.splice(s,1)}}},z.ENABLE_TRACKING&&z.MEMORY_LEAK_WATCHER.add(this._event,hs.create())),this._event}fire(e){var t;if(!(this._pauseTokens.size>0)){!((t=this.options)===null||t===void 0)&&t.replay&&(this._last=e);for(const i of this._listeners)i.callback(e)}}pause(){const e={};return this._pauseTokens.add(e),ke.from(()=>this._pauseTokens.delete(e))}dispose(){this._disposed||(this._disposed=!0,this._listeners.length>0&&(z.ENABLE_TRACKING&&queueMicrotask(()=>{var e;for(const t of this._listeners)console.warn("dockview: stacktrace",(e=t.stacktrace)===null||e===void 0?void 0:e.print())}),this._listeners=[]),z.ENABLE_TRACKING&&this._event&&z.MEMORY_LEAK_WATCHER.delete(this._event))}}z.ENABLE_TRACKING=!1;z.MEMORY_LEAK_WATCHER=new pp;function U(n,e,t,i){return n.addEventListener(e,t,i),{dispose:()=>{n.removeEventListener(e,t,i)}}}class xa{constructor(){this._onFired=new z,this._currentFireCount=0,this._queued=!1,this.onEvent=e=>{const t=this._currentFireCount;return this._onFired.event(()=>{this._currentFireCount>t&&e()})}}fire(){this._currentFireCount++,!this._queued&&(this._queued=!0,queueMicrotask(()=>{this._queued=!1,this._onFired.fire()}))}dispose(){this._onFired.dispose()}}class vp extends X{constructor(e){super(),this._onDidChange=new z,this.onDidChange=this._onDidChange.event,this._value=null,this.addDisposables(this._onDidChange,Gn(e,t=>{const i=t.target.scrollWidth>t.target.clientWidth,s=t.target.scrollHeight>t.target.clientHeight;this._value={hasScrollX:i,hasScrollY:s},this._onDidChange.fire(this._value)}))}}function Gn(n,e){const t=new ResizeObserver(i=>{requestAnimationFrame(()=>{const s=i[0];e(s)})});return t.observe(n),{dispose:()=>{t.unobserve(n),t.disconnect()}}}const It=(n,...e)=>{for(const t of e)n.classList.contains(t)&&n.classList.remove(t)},At=(n,...e)=>{for(const t of e)n.classList.contains(t)||n.classList.add(t)},W=(n,e,t)=>{const i=n.classList.contains(e);t&&!i&&n.classList.add(e),!t&&i&&n.classList.remove(e)};function so(n,e){for(;n;){if(n===e)return!0;n=n.parentNode}return!1}function ml(n){return new gp(n)}class gp extends X{constructor(e){super(),this._onDidFocus=new z,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new z,this.onDidBlur=this._onDidBlur.event,this.addDisposables(this._onDidFocus,this._onDidBlur);let t=so(document.activeElement,e),i=!1;const s=()=>{i=!1,t||(t=!0,this._onDidFocus.fire())},o=()=>{t&&(i=!0,window.setTimeout(()=>{i&&(i=!1,t=!1,this._onDidBlur.fire())},0))};this._refreshStateHandler=()=>{so(document.activeElement,e)!==t&&(t?o():s())},this.addDisposables(U(e,"focus",s,!0)),this.addDisposables(U(e,"blur",o,!0))}refreshState(){this._refreshStateHandler()}}const vl="dv-quasiPreventDefault";function gl(n){n[vl]=!0}function ya(n){return n[vl]}function fp(n,e,t={}){const i=Array.from(e),{nonce:s}=t,o=typeof s=="function"?s(n):s;for(const r of i){if(r.href){const c=n.createElement("link");c.href=r.href,c.type=r.type,c.rel="stylesheet",n.head.appendChild(c);continue}let l=[];try{r.cssRules&&(l=Array.from(r.cssRules).map(c=>c.cssText))}catch(c){console.warn("dockview: failed to access stylesheet rules due to security restrictions",c)}const d=n.createDocumentFragment();for(const c of l){const h=n.createElement("style");o&&h.setAttribute("nonce",o),h.appendChild(n.createTextNode(c)),d.appendChild(h)}n.head.appendChild(d)}}function oo(n){const{left:e,top:t,width:i,height:s}=n.getBoundingClientRect();return{left:e+window.scrollX,top:t+window.scrollY,width:i,height:s}}function _p(n){let e=n;for(;e?.parentNode;){if(e.parentNode===document)return!0;e.parentNode instanceof DocumentFragment?e=e.parentNode.host:e=e.parentNode}return!1}function wp(n,e){n.setAttribute("data-testid",e)}function bp(n,e){const t=[];function i(o){if(o.nodeType===Node.ELEMENT_NODE){n.includes(o.tagName)&&t.push(o),o.shadowRoot&&i(o.shadowRoot);for(const r of o.children)i(r)}}const s=e instanceof Document?e.documentElement:e;return i(s),t}function Pn(n=document){const e=bp(["IFRAME","WEBVIEW"],n),t=new WeakMap;for(const i of e)t.set(i,i.style.pointerEvents),i.style.pointerEvents="none";return{release:()=>{var i;for(const s of e)s.style.pointerEvents=(i=t.get(s))!==null&&i!==void 0?i:"auto";e.splice(0,e.length)}}}function xp(n){function e(s){const o=[];for(let r=0;r<s.classList.length;r++)o.push(s.classList.item(r));return o}let t,i=n;for(;i!==null&&(t=e(i).find(s=>s.startsWith("dockview-theme-")),typeof t!="string");)i=i.parentElement;return t}class ys{constructor(e){this.element=e,this._classNames=[]}setClassNames(e){for(const t of this._classNames)W(this.element,t,!1);this._classNames=e.split(" ").filter(t=>t.trim().length>0);for(const t of this._classNames)W(this.element,t,!0)}}const fl=100;function Da(n,e){const t=oo(n),i=oo(e);return!(t.left<i.left||t.left+t.width>i.left+i.width||t.top<i.top||t.top+t.height>i.top+i.height)}function yp(n){const e=new z;let t=n.screenX,i=n.screenY,s;const o=()=>{if(n.closed)return;const r=n.screenX,l=n.screenY;(r!==t||l!==i)&&(clearTimeout(s),s=setTimeout(()=>{e.fire()},fl),t=r,i=l),requestAnimationFrame(o)};return o(),e}function Dp(n,e){let t;return new X(U(n,"resize",()=>{clearTimeout(t),t=setTimeout(()=>{e()},fl)}))}function Cp(n,e,t={buffer:10}){const i=t.buffer,s=n.getBoundingClientRect(),o=e.getBoundingClientRect();let r=0,l=0;const d=s.left-o.left,c=s.top-o.top,h=s.bottom-o.bottom,u=s.right-o.right;d<i?r=i-d:u>i&&(r=-i-u),c<i?l=i-c:h>i&&(l=-h-i),(r!==0||l!==0)&&(n.style.transform=`translate(${r}px, ${l}px)`)}function _l(n){let e=n;for(;e&&(e.style.zIndex==="auto"||e.style.zIndex==="");)e=e.parentElement;return e}function ti(n){if(n.length===0)throw new Error("Invalid tail call");return[n.slice(0,n.length-1),n[n.length-1]]}function wl(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;return!0}function Fs(n,e){const t=n.indexOf(e);t>-1&&(n.splice(t,1),n.unshift(e))}function Hn(n,e){const t=n.indexOf(e);t>-1&&(n.splice(t,1),n.push(e))}function Sp(n,e){for(let t=0;t<n.length;t++){const i=n[t];if(e(i))return t}return-1}function bl(n,e){const t=n.findIndex(i=>i===e);return t>-1?(n.splice(t,1),!0):!1}const Ee=(n,e,t)=>e>t?e:Math.min(t,Math.max(n,e)),No=()=>{let n=1;return{next:()=>(n++).toString()}},Tt=(n,e)=>{const t=[];if(typeof e!="number"&&(e=n,n=0),n<=e)for(let i=n;i<e;i++)t.push(i);else for(let i=n;i>e;i--)t.push(i);return t};class Pp{set size(e){this._size=e}get size(){return this._size}get cachedVisibleSize(){return this._cachedVisibleSize}get visible(){return typeof this._cachedVisibleSize>"u"}get minimumSize(){return this.visible?this.view.minimumSize:0}get viewMinimumSize(){return this.view.minimumSize}get maximumSize(){return this.visible?this.view.maximumSize:0}get viewMaximumSize(){return this.view.maximumSize}get priority(){return this.view.priority}get snap(){return!!this.view.snap}set enabled(e){this.container.style.pointerEvents=e?"":"none"}constructor(e,t,i,s){this.container=e,this.view=t,this.disposable=s,this._cachedVisibleSize=void 0,typeof i=="number"?(this._size=i,this._cachedVisibleSize=void 0,e.classList.add("visible")):(this._size=0,this._cachedVisibleSize=i.cachedVisibleSize)}setVisible(e,t){var i;e!==this.visible&&(e?(this.size=Ee((i=this._cachedVisibleSize)!==null&&i!==void 0?i:0,this.viewMinimumSize,this.viewMaximumSize),this._cachedVisibleSize=void 0):(this._cachedVisibleSize=typeof t=="number"?t:this.size,this.size=0),this.container.classList.toggle("visible",e),this.view.setVisible&&this.view.setVisible(e))}dispose(){return this.disposable.dispose(),this.view}}var ee;(function(n){n.HORIZONTAL="HORIZONTAL",n.VERTICAL="VERTICAL"})(ee||(ee={}));var mt;(function(n){n[n.MAXIMUM=0]="MAXIMUM",n[n.MINIMUM=1]="MINIMUM",n[n.DISABLED=2]="DISABLED",n[n.ENABLED=3]="ENABLED"})(mt||(mt={}));var Le;(function(n){n.Low="low",n.High="high",n.Normal="normal"})(Le||(Le={}));var nt;(function(n){n.Distribute={type:"distribute"};function e(i){return{type:"split",index:i}}n.Split=e;function t(i){return{type:"invisible",cachedVisibleSize:i}}n.Invisible=t})(nt||(nt={}));class Ci{get contentSize(){return this._contentSize}get size(){return this._size}set size(e){this._size=e}get orthogonalSize(){return this._orthogonalSize}set orthogonalSize(e){this._orthogonalSize=e}get length(){return this.viewItems.length}get proportions(){return this._proportions?[...this._proportions]:void 0}get orientation(){return this._orientation}set orientation(e){this._orientation=e;const t=this.size;this.size=this.orthogonalSize,this.orthogonalSize=t,It(this.element,"dv-horizontal","dv-vertical"),this.element.classList.add(this.orientation==ee.HORIZONTAL?"dv-horizontal":"dv-vertical")}get minimumSize(){return this.viewItems.reduce((e,t)=>e+t.minimumSize,0)}get maximumSize(){return this.length===0?Number.POSITIVE_INFINITY:this.viewItems.reduce((e,t)=>e+t.maximumSize,0)}get startSnappingEnabled(){return this._startSnappingEnabled}set startSnappingEnabled(e){this._startSnappingEnabled!==e&&(this._startSnappingEnabled=e,this.updateSashEnablement())}get endSnappingEnabled(){return this._endSnappingEnabled}set endSnappingEnabled(e){this._endSnappingEnabled!==e&&(this._endSnappingEnabled=e,this.updateSashEnablement())}get disabled(){return this._disabled}set disabled(e){this._disabled=e,W(this.element,"dv-splitview-disabled",e)}get margin(){return this._margin}set margin(e){this._margin=e,W(this.element,"dv-splitview-has-margin",e!==0)}constructor(e,t){var i,s;this.container=e,this.viewItems=[],this.sashes=[],this._size=0,this._orthogonalSize=0,this._contentSize=0,this._proportions=void 0,this._startSnappingEnabled=!0,this._endSnappingEnabled=!0,this._disabled=!1,this._margin=0,this._onDidSashEnd=new z,this.onDidSashEnd=this._onDidSashEnd.event,this._onDidAddView=new z,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new z,this.onDidRemoveView=this._onDidRemoveView.event,this.resize=(o,r,l=this.viewItems.map(p=>p.size),d,c,h=Number.NEGATIVE_INFINITY,u=Number.POSITIVE_INFINITY,m,g)=>{if(o<0||o>this.viewItems.length)return 0;const p=Tt(o,-1),f=Tt(o+1,this.viewItems.length);if(c)for(const V of c)Fs(p,V),Fs(f,V);if(d)for(const V of d)Hn(p,V),Hn(f,V);const w=p.map(V=>this.viewItems[V]),C=p.map(V=>l[V]),b=f.map(V=>this.viewItems[V]),D=f.map(V=>l[V]),k=p.reduce((V,B)=>V+this.viewItems[B].minimumSize-l[B],0),P=p.reduce((V,B)=>V+this.viewItems[B].maximumSize-l[B],0),y=f.length===0?Number.POSITIVE_INFINITY:f.reduce((V,B)=>V+l[B]-this.viewItems[B].minimumSize,0),T=f.length===0?Number.NEGATIVE_INFINITY:f.reduce((V,B)=>V+l[B]-this.viewItems[B].maximumSize,0),S=Math.max(k,T),N=Math.min(y,P);let O=!1;if(m){const V=this.viewItems[m.index],B=r>=m.limitDelta;O=B!==V.visible,V.setVisible(B,m.size)}if(!O&&g){const V=this.viewItems[g.index],B=r<g.limitDelta;O=B!==V.visible,V.setVisible(B,g.size)}if(O)return this.resize(o,r,l,d,c,h,u);const $=Ee(r,S,N);let F=0,q=$;for(let V=0;V<w.length;V++){const B=w[V],te=Ee(C[V]+q,B.minimumSize,B.maximumSize),we=te-C[V];F+=we,q-=we,B.size=te}let re=F;for(let V=0;V<b.length;V++){const B=b[V],te=Ee(D[V]-re,B.minimumSize,B.maximumSize),we=te-D[V];re+=we,B.size=te}return r},this._orientation=(i=t.orientation)!==null&&i!==void 0?i:ee.VERTICAL,this.element=this.createContainer(),this.margin=(s=t.margin)!==null&&s!==void 0?s:0,this.proportionalLayout=t.proportionalLayout===void 0?!0:!!t.proportionalLayout,this.viewContainer=this.createViewContainer(),this.sashContainer=this.createSashContainer(),this.element.appendChild(this.sashContainer),this.element.appendChild(this.viewContainer),this.container.appendChild(this.element),this.style(t.styles),t.descriptor&&(this._size=t.descriptor.size,t.descriptor.views.forEach((o,r)=>{const l=o.visible===void 0||o.visible?o.size:{type:"invisible",cachedVisibleSize:o.size},d=o.view;this.addView(d,l,r,!0)}),this._contentSize=this.viewItems.reduce((o,r)=>o+r.size,0),this.saveProportions())}style(e){e?.separatorBorder==="transparent"?(It(this.element,"dv-separator-border"),this.element.style.removeProperty("--dv-separator-border")):(At(this.element,"dv-separator-border"),e?.separatorBorder&&this.element.style.setProperty("--dv-separator-border",e.separatorBorder))}isViewVisible(e){if(e<0||e>=this.viewItems.length)throw new Error("Index out of bounds");return this.viewItems[e].visible}setViewVisible(e,t){if(e<0||e>=this.viewItems.length)throw new Error("Index out of bounds");const i=this.viewItems[e];i.setVisible(t,i.size),this.distributeEmptySpace(e),this.layoutViews(),this.saveProportions()}getViewSize(e){return e<0||e>=this.viewItems.length?-1:this.viewItems[e].size}resizeView(e,t){if(e<0||e>=this.viewItems.length)return;const i=Tt(this.viewItems.length).filter(l=>l!==e),s=[...i.filter(l=>this.viewItems[l].priority===Le.Low),e],o=i.filter(l=>this.viewItems[l].priority===Le.High),r=this.viewItems[e];t=Math.round(t),t=Ee(t,r.minimumSize,Math.min(r.maximumSize,this._size)),r.size=t,this.relayout(s,o)}getViews(){return this.viewItems.map(e=>e.view)}onDidChange(e,t){const i=this.viewItems.indexOf(e);if(i<0||i>=this.viewItems.length)return;t=typeof t=="number"?t:e.size,t=Ee(t,e.minimumSize,e.maximumSize),e.size=t;const s=Tt(this.viewItems.length).filter(l=>l!==i),o=[...s.filter(l=>this.viewItems[l].priority===Le.Low),i],r=s.filter(l=>this.viewItems[l].priority===Le.High);this.relayout([...o,i],r)}addView(e,t={type:"distribute"},i=this.viewItems.length,s){const o=document.createElement("div");o.className="dv-view",o.appendChild(e.element);let r;typeof t=="number"?r=t:t.type==="split"?r=this.getViewSize(t.index)/2:t.type==="invisible"?r={cachedVisibleSize:t.cachedVisibleSize}:r=e.minimumSize;const l=e.onDidChange(c=>this.onDidChange(d,c.size)),d=new Pp(o,e,r,{dispose:()=>{l.dispose(),this.viewContainer.removeChild(o)}});if(i===this.viewItems.length?this.viewContainer.appendChild(o):this.viewContainer.insertBefore(o,this.viewContainer.children.item(i)),this.viewItems.splice(i,0,d),this.viewItems.length>1){const c=document.createElement("div");c.className="dv-sash";const h=m=>{for(const V of this.viewItems)V.enabled=!1;const g=Pn(),p=this._orientation===ee.HORIZONTAL?m.clientX:m.clientY,f=Sp(this.sashes,V=>V.container===c),w=this.viewItems.map(V=>V.size);let C,b;const D=Tt(f,-1),k=Tt(f+1,this.viewItems.length),P=D.reduce((V,B)=>V+(this.viewItems[B].minimumSize-w[B]),0),y=D.reduce((V,B)=>V+(this.viewItems[B].viewMaximumSize-w[B]),0),T=k.length===0?Number.POSITIVE_INFINITY:k.reduce((V,B)=>V+(w[B]-this.viewItems[B].minimumSize),0),S=k.length===0?Number.NEGATIVE_INFINITY:k.reduce((V,B)=>V+(w[B]-this.viewItems[B].viewMaximumSize),0),N=Math.max(P,S),O=Math.min(T,y),$=this.findFirstSnapIndex(D),F=this.findFirstSnapIndex(k);if(typeof $=="number"){const V=this.viewItems[$],B=Math.floor(V.viewMinimumSize/2);C={index:$,limitDelta:V.visible?N-B:N+B,size:V.size}}if(typeof F=="number"){const V=this.viewItems[F],B=Math.floor(V.viewMinimumSize/2);b={index:F,limitDelta:V.visible?O+B:O-B,size:V.size}}const q=V=>{const te=(this._orientation===ee.HORIZONTAL?V.clientX:V.clientY)-p;this.resize(f,te,w,void 0,void 0,N,O,C,b),this.distributeEmptySpace(),this.layoutViews()},re=()=>{for(const V of this.viewItems)V.enabled=!0;g.release(),this.saveProportions(),document.removeEventListener("pointermove",q),document.removeEventListener("pointerup",re),document.removeEventListener("pointercancel",re),document.removeEventListener("contextmenu",re),this._onDidSashEnd.fire(void 0)};document.addEventListener("pointermove",q),document.addEventListener("pointerup",re),document.addEventListener("pointercancel",re),document.addEventListener("contextmenu",re)};c.addEventListener("pointerdown",h);const u={container:c,disposable:()=>{c.removeEventListener("pointerdown",h),this.sashContainer.removeChild(c)}};this.sashContainer.appendChild(c),this.sashes.push(u)}s||this.relayout([i]),!s&&typeof t!="number"&&t.type==="distribute"&&this.distributeViewSizes(),this._onDidAddView.fire(e)}distributeViewSizes(){const e=[];let t=0;for(const l of this.viewItems)l.maximumSize-l.minimumSize>0&&(e.push(l),t+=l.size);const i=Math.floor(t/e.length);for(const l of e)l.size=Ee(i,l.minimumSize,l.maximumSize);const s=Tt(this.viewItems.length),o=s.filter(l=>this.viewItems[l].priority===Le.Low),r=s.filter(l=>this.viewItems[l].priority===Le.High);this.relayout(o,r)}removeView(e,t,i=!1){const s=this.viewItems.splice(e,1)[0];if(s.dispose(),this.viewItems.length>=1){const o=Math.max(e-1,0);this.sashes.splice(o,1)[0].disposable()}return i||this.relayout(),t&&t.type==="distribute"&&this.distributeViewSizes(),this._onDidRemoveView.fire(s.view),s.view}getViewCachedVisibleSize(e){if(e<0||e>=this.viewItems.length)throw new Error("Index out of bounds");return this.viewItems[e].cachedVisibleSize}moveView(e,t){const i=this.getViewCachedVisibleSize(e),s=typeof i>"u"?this.getViewSize(e):nt.Invisible(i),o=this.removeView(e,void 0,!0);this.addView(o,s,t)}layout(e,t){const i=Math.max(this.size,this._contentSize);if(this.size=e,this.orthogonalSize=t,this.proportions){let s=0;for(let o=0;o<this.viewItems.length;o++){const r=this.viewItems[o],l=this.proportions[o];typeof l=="number"?s+=l:e-=r.size}for(let o=0;o<this.viewItems.length;o++){const r=this.viewItems[o],l=this.proportions[o];typeof l=="number"&&s>0&&(r.size=Ee(Math.round(l*e/s),r.minimumSize,r.maximumSize))}}else{const s=Tt(this.viewItems.length),o=s.filter(l=>this.viewItems[l].priority===Le.Low),r=s.filter(l=>this.viewItems[l].priority===Le.High);this.resize(this.viewItems.length-1,e-i,void 0,o,r)}this.distributeEmptySpace(),this.layoutViews()}relayout(e,t){const i=this.viewItems.reduce((s,o)=>s+o.size,0);this.resize(this.viewItems.length-1,this._size-i,void 0,e,t),this.distributeEmptySpace(),this.layoutViews(),this.saveProportions()}distributeEmptySpace(e){const t=this.viewItems.reduce((l,d)=>l+d.size,0);let i=this.size-t;const s=Tt(this.viewItems.length-1,-1),o=s.filter(l=>this.viewItems[l].priority===Le.Low),r=s.filter(l=>this.viewItems[l].priority===Le.High);for(const l of r)Fs(s,l);for(const l of o)Hn(s,l);typeof e=="number"&&Hn(s,e);for(let l=0;i!==0&&l<s.length;l++){const d=this.viewItems[s[l]],c=Ee(d.size+i,d.minimumSize,d.maximumSize),h=c-d.size;i-=h,d.size=c}}saveProportions(){this.proportionalLayout&&this._contentSize>0&&(this._proportions=this.viewItems.map(e=>e.visible?e.size/this._contentSize:void 0))}layoutViews(){if(this._contentSize=this.viewItems.reduce((d,c)=>d+c.size,0),this.updateSashEnablement(),this.viewItems.length===0)return;const e=this.viewItems.filter(d=>d.visible),t=Math.max(0,e.length-1),i=this.margin*t/Math.max(1,e.length);let s=0;const o=[],r=4,l=this.viewItems.reduce((d,c,h)=>{const u=c.visible?1:0;return h===0?d.push(u):d.push(d[h-1]+u),d},[]);this.viewItems.forEach((d,c)=>{s+=this.viewItems[c].size,o.push(s);const h=d.visible?d.size-i:0,u=Math.max(0,l[c]-1),m=c===0||u===0?0:o[c-1]+u/t*i;if(c<this.viewItems.length-1){const g=d.visible?m+h-r/2+this.margin/2:m;this._orientation===ee.HORIZONTAL&&(this.sashes[c].container.style.left=`${g}px`,this.sashes[c].container.style.top="0px"),this._orientation===ee.VERTICAL&&(this.sashes[c].container.style.left="0px",this.sashes[c].container.style.top=`${g}px`)}this._orientation===ee.HORIZONTAL&&(d.container.style.width=`${h}px`,d.container.style.left=`${m}px`,d.container.style.top="",d.container.style.height=""),this._orientation===ee.VERTICAL&&(d.container.style.height=`${h}px`,d.container.style.top=`${m}px`,d.container.style.width="",d.container.style.left=""),d.view.layout(d.size-i,this._orthogonalSize)})}findFirstSnapIndex(e){for(const t of e){const i=this.viewItems[t];if(i.visible&&i.snap)return t}for(const t of e){const i=this.viewItems[t];if(i.visible&&i.maximumSize-i.minimumSize>0)return;if(!i.visible&&i.snap)return t}}updateSashEnablement(){let e=!1;const t=this.viewItems.map(d=>e=d.size-d.minimumSize>0||e);e=!1;const i=this.viewItems.map(d=>e=d.maximumSize-d.size>0||e),s=[...this.viewItems].reverse();e=!1;const o=s.map(d=>e=d.size-d.minimumSize>0||e).reverse();e=!1;const r=s.map(d=>e=d.maximumSize-d.size>0||e).reverse();let l=0;for(let d=0;d<this.sashes.length;d++){const c=this.sashes[d],h=this.viewItems[d];l+=h.size;const u=!(t[d]&&r[d+1]),m=!(i[d]&&o[d+1]);if(u&&m){const g=Tt(d,-1),p=Tt(d+1,this.viewItems.length),f=this.findFirstSnapIndex(g),w=this.findFirstSnapIndex(p),C=typeof f=="number"&&!this.viewItems[f].visible,b=typeof w=="number"&&!this.viewItems[w].visible;C&&o[d]&&(l>0||this.startSnappingEnabled)?this.updateSash(c,mt.MINIMUM):b&&t[d]&&(l<this._contentSize||this.endSnappingEnabled)?this.updateSash(c,mt.MAXIMUM):this.updateSash(c,mt.DISABLED)}else u&&!m?this.updateSash(c,mt.MINIMUM):!u&&m?this.updateSash(c,mt.MAXIMUM):this.updateSash(c,mt.ENABLED)}}updateSash(e,t){W(e.container,"dv-disabled",t===mt.DISABLED),W(e.container,"dv-enabled",t===mt.ENABLED),W(e.container,"dv-maximum",t===mt.MAXIMUM),W(e.container,"dv-minimum",t===mt.MINIMUM)}createViewContainer(){const e=document.createElement("div");return e.className="dv-view-container",e}createSashContainer(){const e=document.createElement("div");return e.className="dv-sash-container",e}createContainer(){const e=document.createElement("div"),t=this._orientation===ee.HORIZONTAL?"dv-horizontal":"dv-vertical";return e.className=`dv-split-view-container ${t}`,e}dispose(){this._onDidSashEnd.dispose(),this._onDidAddView.dispose(),this._onDidRemoveView.dispose();for(let e=0;e<this.element.children.length;e++)if(this.element.children.item(e)===this.element){this.element.removeChild(this.element);break}for(const e of this.viewItems)e.dispose();this.element.remove()}}const ao=Object.keys({orientation:void 0,descriptor:void 0,proportionalLayout:void 0,styles:void 0,margin:void 0,disableAutoResizing:void 0,className:void 0});class Ca extends X{get onDidAddView(){return this.splitview.onDidAddView}get onDidRemoveView(){return this.splitview.onDidRemoveView}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get orientation(){return this.splitview.orientation}get size(){return this.splitview.size}get orthogonalSize(){return this.splitview.orthogonalSize}constructor(e,t){var i;super(),this.paneItems=[],this.skipAnimation=!1,this._onDidChange=new z,this.onDidChange=this._onDidChange.event,this._orientation=(i=t.orientation)!==null&&i!==void 0?i:ee.VERTICAL,this.element=document.createElement("div"),this.element.className="dv-pane-container",e.appendChild(this.element),this.splitview=new Ci(this.element,{orientation:this._orientation,proportionalLayout:!1,descriptor:t.descriptor}),this.getPanes().forEach(s=>{const o=new X(s.onDidChangeExpansionState(()=>{this.setupAnimation(),this._onDidChange.fire(void 0)})),r={pane:s,disposable:{dispose:()=>{o.dispose()}}};this.paneItems.push(r),s.orthogonalSize=this.splitview.orthogonalSize}),this.addDisposables(this._onDidChange,this.splitview.onDidSashEnd(()=>{this._onDidChange.fire(void 0)}),this.splitview.onDidAddView(()=>{this._onDidChange.fire()}),this.splitview.onDidRemoveView(()=>{this._onDidChange.fire()}))}setViewVisible(e,t){this.splitview.setViewVisible(e,t)}addPane(e,t,i=this.splitview.length,s=!1){const o=e.onDidChangeExpansionState(()=>{this.setupAnimation(),this._onDidChange.fire(void 0)}),r={pane:e,disposable:{dispose:()=>{o.dispose()}}};this.paneItems.splice(i,0,r),e.orthogonalSize=this.splitview.orthogonalSize,this.splitview.addView(e,t,i,s)}getViewSize(e){return this.splitview.getViewSize(e)}getPanes(){return this.splitview.getViews()}removePane(e,t={skipDispose:!1}){const i=this.paneItems.splice(e,1)[0];return this.splitview.removeView(e),t.skipDispose||(i.disposable.dispose(),i.pane.dispose()),i}moveView(e,t){if(e===t)return;const i=this.removePane(e,{skipDispose:!0});this.skipAnimation=!0;try{this.addPane(i.pane,i.pane.size,t,!1)}finally{this.skipAnimation=!1}}layout(e,t){this.splitview.layout(e,t)}setupAnimation(){this.skipAnimation||(this.animationTimer&&(clearTimeout(this.animationTimer),this.animationTimer=void 0),At(this.element,"dv-animated"),this.animationTimer=setTimeout(()=>{this.animationTimer=void 0,It(this.element,"dv-animated")},200))}dispose(){super.dispose(),this.animationTimer&&(clearTimeout(this.animationTimer),this.animationTimer=void 0),this.paneItems.forEach(e=>{e.disposable.dispose(),e.pane.dispose()}),this.paneItems=[],this.splitview.dispose(),this.element.remove()}}class Ye{get minimumWidth(){return this.view.minimumWidth}get maximumWidth(){return this.view.maximumWidth}get minimumHeight(){return this.view.minimumHeight}get maximumHeight(){return this.view.maximumHeight}get priority(){return this.view.priority}get snap(){return this.view.snap}get minimumSize(){return this.orientation===ee.HORIZONTAL?this.minimumHeight:this.minimumWidth}get maximumSize(){return this.orientation===ee.HORIZONTAL?this.maximumHeight:this.maximumWidth}get minimumOrthogonalSize(){return this.orientation===ee.HORIZONTAL?this.minimumWidth:this.minimumHeight}get maximumOrthogonalSize(){return this.orientation===ee.HORIZONTAL?this.maximumWidth:this.maximumHeight}get orthogonalSize(){return this._orthogonalSize}get size(){return this._size}get element(){return this.view.element}get width(){return this.orientation===ee.HORIZONTAL?this.orthogonalSize:this.size}get height(){return this.orientation===ee.HORIZONTAL?this.size:this.orthogonalSize}constructor(e,t,i,s=0){this.view=e,this.orientation=t,this._onDidChange=new z,this.onDidChange=this._onDidChange.event,this._orthogonalSize=i,this._size=s,this._disposable=this.view.onDidChange(o=>{o?this._onDidChange.fire({size:this.orientation===ee.VERTICAL?o.width:o.height,orthogonalSize:this.orientation===ee.VERTICAL?o.height:o.width}):this._onDidChange.fire({})})}setVisible(e){this.view.setVisible&&this.view.setVisible(e)}layout(e,t){this._size=e,this._orthogonalSize=t,this.view.layout(this.width,this.height)}dispose(){this._onDidChange.dispose(),this._disposable.dispose()}}class Me extends X{get width(){return this.orientation===ee.HORIZONTAL?this.size:this.orthogonalSize}get height(){return this.orientation===ee.HORIZONTAL?this.orthogonalSize:this.size}get minimumSize(){return this.children.length===0?0:Math.max(...this.children.map((e,t)=>this.splitview.isViewVisible(t)?e.minimumOrthogonalSize:0))}get maximumSize(){return Math.min(...this.children.map((e,t)=>this.splitview.isViewVisible(t)?e.maximumOrthogonalSize:Number.POSITIVE_INFINITY))}get minimumOrthogonalSize(){return this.splitview.minimumSize}get maximumOrthogonalSize(){return this.splitview.maximumSize}get orthogonalSize(){return this._orthogonalSize}get size(){return this._size}get minimumWidth(){return this.orientation===ee.HORIZONTAL?this.minimumOrthogonalSize:this.minimumSize}get minimumHeight(){return this.orientation===ee.HORIZONTAL?this.minimumSize:this.minimumOrthogonalSize}get maximumWidth(){return this.orientation===ee.HORIZONTAL?this.maximumOrthogonalSize:this.maximumSize}get maximumHeight(){return this.orientation===ee.HORIZONTAL?this.maximumSize:this.maximumOrthogonalSize}get priority(){if(this.children.length===0)return Le.Normal;const e=this.children.map(t=>typeof t.priority>"u"?Le.Normal:t.priority);return e.some(t=>t===Le.High)?Le.High:e.some(t=>t===Le.Low)?Le.Low:Le.Normal}get disabled(){return this.splitview.disabled}set disabled(e){this.splitview.disabled=e}get margin(){return this.splitview.margin}set margin(e){this.splitview.margin=e,this.children.forEach(t=>{t instanceof Me&&(t.margin=e)})}constructor(e,t,i,s,o,r,l,d){if(super(),this.orientation=e,this.proportionalLayout=t,this.styles=i,this._childrenDisposable=ke.NONE,this.children=[],this._onDidChange=new z,this.onDidChange=this._onDidChange.event,this._onDidVisibilityChange=new z,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._orthogonalSize=o,this._size=s,this.element=document.createElement("div"),this.element.className="dv-branch-node",!d)this.splitview=new Ci(this.element,{orientation:this.orientation,proportionalLayout:t,styles:i,margin:l}),this.splitview.layout(this.size,this.orthogonalSize);else{const c={views:d.map(h=>({view:h.node,size:h.node.size,visible:h.node instanceof Ye&&h.visible!==void 0?h.visible:!0})),size:this.orthogonalSize};this.children=d.map(h=>h.node),this.splitview=new Ci(this.element,{orientation:this.orientation,descriptor:c,proportionalLayout:t,styles:i,margin:l})}this.disabled=r,this.addDisposables(this._onDidChange,this._onDidVisibilityChange,this.splitview.onDidSashEnd(()=>{this._onDidChange.fire({})})),this.setupChildrenEvents()}setVisible(e){}isChildVisible(e){if(e<0||e>=this.children.length)throw new Error("Invalid index");return this.splitview.isViewVisible(e)}setChildVisible(e,t){if(e<0||e>=this.children.length)throw new Error("Invalid index");if(this.splitview.isViewVisible(e)===t)return;const i=this.splitview.contentSize===0;this.splitview.setViewVisible(e,t);const s=this.splitview.contentSize===0;(t&&i||!t&&s)&&this._onDidVisibilityChange.fire({visible:t})}moveChild(e,t){if(e===t)return;if(e<0||e>=this.children.length)throw new Error("Invalid from index");e<t&&t--,this.splitview.moveView(e,t);const i=this._removeChild(e);this._addChild(i,t)}getChildSize(e){if(e<0||e>=this.children.length)throw new Error("Invalid index");return this.splitview.getViewSize(e)}resizeChild(e,t){if(e<0||e>=this.children.length)throw new Error("Invalid index");this.splitview.resizeView(e,t)}layout(e,t){this._size=t,this._orthogonalSize=e,this.splitview.layout(t,e)}addChild(e,t,i,s){if(i<0||i>this.children.length)throw new Error("Invalid index");this.splitview.addView(e,t,i,s),this._addChild(e,i)}getChildCachedVisibleSize(e){if(e<0||e>=this.children.length)throw new Error("Invalid index");return this.splitview.getViewCachedVisibleSize(e)}removeChild(e,t){if(e<0||e>=this.children.length)throw new Error("Invalid index");return this.splitview.removeView(e,t),this._removeChild(e)}_addChild(e,t){this.children.splice(t,0,e),this.setupChildrenEvents()}_removeChild(e){const[t]=this.children.splice(e,1);return this.setupChildrenEvents(),t}setupChildrenEvents(){this._childrenDisposable.dispose(),this._childrenDisposable=new X(wt.any(...this.children.map(e=>e.onDidChange))(e=>{this._onDidChange.fire({size:e.orthogonalSize})}),...this.children.map((e,t)=>e instanceof Me?e.onDidVisibilityChange(({visible:i})=>{this.setChildVisible(t,i)}):ke.NONE))}dispose(){this._childrenDisposable.dispose(),this.splitview.dispose(),this.children.forEach(e=>e.dispose()),super.dispose()}}function ro(n,e){if(n instanceof Ye)return n;if(n instanceof Me)return ro(n.children[e?n.children.length-1:0],e);throw new Error("invalid node")}function xl(n,e,t){if(n instanceof Me){const i=new Me(n.orientation,n.proportionalLayout,n.styles,e,t,n.disabled,n.margin);for(let s=n.children.length-1;s>=0;s--){const o=n.children[s];i.addChild(xl(o,o.size,o.orthogonalSize),o.size,0,!0)}return i}else return new Ye(n.view,n.orientation,t)}function lo(n,e,t){if(n instanceof Me){const i=new Me(Rt(n.orientation),n.proportionalLayout,n.styles,e,t,n.disabled,n.margin);let s=0;for(let o=n.children.length-1;o>=0;o--){const r=n.children[o],l=r instanceof Me?r.orthogonalSize:r.size;let d=n.size===0?0:Math.round(e*l/n.size);s+=d,o===0&&(d+=e-s),i.addChild(lo(r,t,d),d,0,!0)}return i}else return new Ye(n.view,Rt(n.orientation),t)}function kp(n){const e=n.parentElement;if(!e)throw new Error("Invalid grid element");let t=e.firstElementChild,i=0;for(;t!==n&&t!==e.lastElementChild&&t;)t=t.nextElementSibling,i++;return i}function Te(n){const e=n.parentElement;if(!e)throw new Error("Invalid grid element");if(/\bdv-grid-view\b/.test(e.className))return[];const t=kp(e),i=e.parentElement.parentElement.parentElement;return[...Te(i),t]}function vt(n,e,t){const i=Tp(n,e),s=zp(t);if(i===s){const[o,r]=ti(e);let l=r;return(t==="right"||t==="bottom")&&(l+=1),[...o,l]}else{const o=t==="right"||t==="bottom"?1:0;return[...e,o]}}function zp(n){return n==="top"||n==="bottom"?ee.VERTICAL:ee.HORIZONTAL}function Tp(n,e){return e.length%2===0?Rt(n):n}const Rt=n=>n===ee.HORIZONTAL?ee.VERTICAL:ee.HORIZONTAL;function Ep(n){return!!n.children}const co=(n,e)=>{const t=e===ee.VERTICAL?n.box.width:n.box.height;return Ep(n)?{type:"branch",data:n.children.map(i=>co(i,Rt(e))),size:t}:typeof n.cachedVisibleSize=="number"?{type:"leaf",data:n.view.toJSON(),size:n.cachedVisibleSize,visible:!1}:{type:"leaf",data:n.view.toJSON(),size:t}};class yl{get length(){return this._root?this._root.children.length:0}get orientation(){return this.root.orientation}set orientation(e){if(this.root.orientation===e)return;const{size:t,orthogonalSize:i}=this.root;this.root=lo(this.root,i,t),this.root.layout(t,i)}get width(){return this.root.width}get height(){return this.root.height}get minimumWidth(){return this.root.minimumWidth}get minimumHeight(){return this.root.minimumHeight}get maximumWidth(){return this.root.maximumHeight}get maximumHeight(){return this.root.maximumHeight}get locked(){return this._locked}set locked(e){this._locked=e;const t=[this.root];for(;t.length>0;){const i=t.pop();i instanceof Me&&(i.disabled=e,t.push(...i.children))}}get margin(){return this._margin}set margin(e){this._margin=e,this.root.margin=e}maximizedView(){var e;return(e=this._maximizedNode)===null||e===void 0?void 0:e.leaf.view}hasMaximizedView(){return this._maximizedNode!==void 0}maximizeView(e){var t;const i=Te(e.element),[s,o]=this.getNode(i);if(!(o instanceof Ye)||((t=this._maximizedNode)===null||t===void 0?void 0:t.leaf)===o)return;this.hasMaximizedView()&&this.exitMaximizedView(),co(this.getView(),this.orientation);const r=[];function l(d,c){for(let h=0;h<d.children.length;h++){const u=d.children[h];u instanceof Ye?u!==c&&(d.isChildVisible(h)?d.setChildVisible(h,!1):r.push(u)):l(u,c)}}l(this.root,o),this._maximizedNode={leaf:o,hiddenOnMaximize:r},this._onDidMaximizedNodeChange.fire({view:o.view,isMaximized:!0})}exitMaximizedView(){if(!this._maximizedNode)return;const e=this._maximizedNode.hiddenOnMaximize;function t(s){for(let o=s.children.length-1;o>=0;o--){const r=s.children[o];r instanceof Ye?e.includes(r)||s.setChildVisible(o,!0):t(r)}}t(this.root);const i=this._maximizedNode.leaf;this._maximizedNode=void 0,this._onDidMaximizedNodeChange.fire({view:i.view,isMaximized:!1})}serialize(){const e=this.maximizedView();let t;e&&(t=Te(e.element));const i=this._onDidMaximizedNodeChange.pause();try{this.hasMaximizedView()&&this.exitMaximizedView();const o={root:co(this.getView(),this.orientation),width:this.width,height:this.height,orientation:this.orientation};return t&&(o.maximizedNode={location:t}),e&&this.maximizeView(e),o}finally{i.dispose()}}dispose(){this.disposable.dispose(),this._onDidChange.dispose(),this._onDidMaximizedNodeChange.dispose(),this._onDidViewVisibilityChange.dispose(),this.root.dispose(),this._maximizedNode=void 0,this.element.remove()}clear(){const e=this.root.orientation;this.root=new Me(e,this.proportionalLayout,this.styles,this.root.size,this.root.orthogonalSize,this.locked,this.margin)}deserialize(e,t){const i=e.orientation,s=i===ee.VERTICAL?e.height:e.width;if(this._deserialize(e.root,i,t,s),this.layout(e.width,e.height),e.maximizedNode){const o=e.maximizedNode.location,[r,l]=this.getNode(o);if(!(l instanceof Ye))return;this.maximizeView(l.view)}}_deserialize(e,t,i,s){this.root=this._deserializeNode(e,t,i,s)}_deserializeNode(e,t,i,s){var o;let r;if(e.type==="branch"){const d=e.data.map(c=>({node:this._deserializeNode(c,Rt(t),i,e.size),visible:c.visible}));r=new Me(t,this.proportionalLayout,this.styles,e.size,s,this.locked,this.margin,d)}else{const l=i.fromJSON(e);typeof e.visible=="boolean"&&((o=l.setVisible)===null||o===void 0||o.call(l,e.visible)),r=new Ye(l,t,s,e.size)}return r}get root(){return this._root}set root(e){const t=this._root;t&&(t.dispose(),this._maximizedNode=void 0,this.element.removeChild(t.element)),this._root=e,this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(i=>{this._onDidChange.fire(i)})}normalize(){if(!this._root||this._root.children.length!==1)return;const e=this.root,t=e.children[0];if(t instanceof Ye)return;e.element.remove();const i=e.removeChild(0);e.dispose(),i.dispose(),this._root=xl(t,t.size,t.orthogonalSize),this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(s=>{this._onDidChange.fire(s)})}insertOrthogonalSplitviewAtRoot(){if(!this._root)return;const e=this.root;if(e.element.remove(),this._root=new Me(Rt(e.orientation),this.proportionalLayout,this.styles,this.root.orthogonalSize,this.root.size,this.locked,this.margin),e.children.length!==0)if(e.children.length===1){const t=e.children[0];e.removeChild(0).dispose(),e.dispose(),this._root.addChild(lo(t,t.orthogonalSize,t.size),nt.Distribute,0)}else this._root.addChild(e,nt.Distribute,0);this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(t=>{this._onDidChange.fire(t)})}next(e){return this.progmaticSelect(e)}previous(e){return this.progmaticSelect(e,!0)}getView(e){const t=e?this.getNode(e)[1]:this.root;return this._getViews(t,this.orientation)}_getViews(e,t,i){const s={height:e.height,width:e.width};if(e instanceof Ye)return{box:s,view:e.view,cachedVisibleSize:i};const o=[];for(let r=0;r<e.children.length;r++){const l=e.children[r],d=e.getChildCachedVisibleSize(r);o.push(this._getViews(l,Rt(t),d))}return{box:s,children:o}}progmaticSelect(e,t=!1){const[i,s]=this.getNode(e);if(!(s instanceof Ye))throw new Error("invalid location");for(let o=i.length-1;o>-1;o--){const r=i[o],l=e[o]||0;if(t?l-1>-1:l+1<r.children.length)return ro(r.children[t?l-1:l+1],t)}return ro(this.root,t)}constructor(e,t,i,s,o){this.proportionalLayout=e,this.styles=t,this._locked=!1,this._margin=0,this._maximizedNode=void 0,this.disposable=new $e,this._onDidChange=new z,this.onDidChange=this._onDidChange.event,this._onDidViewVisibilityChange=new z,this.onDidViewVisibilityChange=this._onDidViewVisibilityChange.event,this._onDidMaximizedNodeChange=new z,this.onDidMaximizedNodeChange=this._onDidMaximizedNodeChange.event,this.element=document.createElement("div"),this.element.className="dv-grid-view",this._locked=s??!1,this._margin=o??0,this.root=new Me(i,e,t,0,0,this.locked,this.margin)}isViewVisible(e){const[t,i]=ti(e),[,s]=this.getNode(t);if(!(s instanceof Me))throw new Error("Invalid from location");return s.isChildVisible(i)}setViewVisible(e,t){this.hasMaximizedView()&&this.exitMaximizedView();const[i,s]=ti(e),[,o]=this.getNode(i);if(!(o instanceof Me))throw new Error("Invalid from location");this._onDidViewVisibilityChange.fire(),o.setChildVisible(s,t)}moveView(e,t,i){this.hasMaximizedView()&&this.exitMaximizedView();const[,s]=this.getNode(e);if(!(s instanceof Me))throw new Error("Invalid location");s.moveChild(t,i)}addView(e,t,i){this.hasMaximizedView()&&this.exitMaximizedView();const[s,o]=ti(i),[r,l]=this.getNode(s);if(l instanceof Me){const d=new Ye(e,Rt(l.orientation),l.orthogonalSize);l.addChild(d,t,o)}else{const[d,...c]=[...r].reverse(),[h,...u]=[...s].reverse();let m=0;const g=d.getChildCachedVisibleSize(h);typeof g=="number"&&(m=nt.Invisible(g)),d.removeChild(h).dispose();const f=new Me(l.orientation,this.proportionalLayout,this.styles,l.size,l.orthogonalSize,this.locked,this.margin);d.addChild(f,l.size,h);const w=new Ye(l.view,d.orientation,l.size);f.addChild(w,m,0),typeof t!="number"&&t.type==="split"&&(t={type:"split",index:0});const C=new Ye(e,d.orientation,l.size);f.addChild(C,t,o)}}remove(e,t){const i=Te(e.element);return this.removeView(i,t)}removeView(e,t){this.hasMaximizedView()&&this.exitMaximizedView();const[i,s]=ti(e),[o,r]=this.getNode(i);if(!(r instanceof Me))throw new Error("Invalid location");const l=r.children[s];if(!(l instanceof Ye))throw new Error("Invalid location");if(r.removeChild(s,t),l.dispose(),r.children.length!==1)return l.view;const d=r.children[0];if(o.length===0)return d instanceof Ye||(r.removeChild(0,t),this.root=d),l.view;const[c,...h]=[...o].reverse(),[u,...m]=[...i].reverse(),g=r.isChildVisible(0);r.removeChild(0,t);const p=c.children.map((f,w)=>c.getChildSize(w));if(c.removeChild(u,t).dispose(),d instanceof Me){p.splice(u,1,...d.children.map(f=>f.size));for(let f=0;f<d.children.length;f++){const w=d.children[f];c.addChild(w,w.size,u+f)}for(;d.children.length>0;)d.removeChild(0)}else{const f=new Ye(d.view,Rt(d.orientation),d.size),w=g?d.orthogonalSize:nt.Invisible(d.orthogonalSize);c.addChild(f,w,u)}d.dispose();for(let f=0;f<p.length;f++)c.resizeChild(f,p[f]);return l.view}layout(e,t){const[i,s]=this.root.orientation===ee.HORIZONTAL?[t,e]:[e,t];this.root.layout(i,s)}getNode(e,t=this.root,i=[]){if(e.length===0)return[i,t];if(!(t instanceof Me))throw new Error("Invalid location");const[s,...o]=e;if(s<0||s>=t.children.length)throw new Error("Invalid location");const r=t.children[s];return i.push(t),this.getNode(o,r,i)}}const ho=Object.keys({disableAutoResizing:void 0,proportionalLayout:void 0,orientation:void 0,hideBorders:void 0,className:void 0});class jo extends X{get element(){return this._element}get disableResizing(){return this._disableResizing}set disableResizing(e){this._disableResizing=e}constructor(e,t=!1){super(),this._lastWidth=-1,this._lastHeight=-1,this._disableResizing=t,this._element=e,this.addDisposables(Gn(this._element,i=>{if(this.isDisposed||this.disableResizing||!this._element.offsetParent||!_p(this._element))return;const s=Math.round(i.contentRect.width),o=Math.round(i.contentRect.height);s===this._lastWidth&&o===this._lastHeight||(this._lastWidth=s,this._lastHeight=o,this.layout(s,o))}))}}const Gp=No();function us(n){switch(n){case"left":return"left";case"right":return"right";case"above":return"top";case"below":return"bottom";default:return"center"}}class Dl extends jo{get id(){return this._id}get size(){return this._groups.size}get groups(){return Array.from(this._groups.values()).map(e=>e.value)}get width(){return this.gridview.width}get height(){return this.gridview.height}get minimumHeight(){return this.gridview.minimumHeight}get maximumHeight(){return this.gridview.maximumHeight}get minimumWidth(){return this.gridview.minimumWidth}get maximumWidth(){return this.gridview.maximumWidth}get activeGroup(){return this._activeGroup}get locked(){return this.gridview.locked}set locked(e){this.gridview.locked=e}constructor(e,t){var i;super(document.createElement("div"),t.disableAutoResizing),this._id=Gp.next(),this._groups=new Map,this._onDidRemove=new z,this.onDidRemove=this._onDidRemove.event,this._onDidAdd=new z,this.onDidAdd=this._onDidAdd.event,this._onDidMaximizedChange=new z,this.onDidMaximizedChange=this._onDidMaximizedChange.event,this._onDidActiveChange=new z,this.onDidActiveChange=this._onDidActiveChange.event,this._bufferOnDidLayoutChange=new xa,this.onDidLayoutChange=this._bufferOnDidLayoutChange.onEvent,this._onDidViewVisibilityChangeMicroTaskQueue=new xa,this.onDidViewVisibilityChangeMicroTaskQueue=this._onDidViewVisibilityChangeMicroTaskQueue.onEvent,this.element.style.height="100%",this.element.style.width="100%",this._classNames=new ys(this.element),this._classNames.setClassNames((i=t.className)!==null&&i!==void 0?i:""),e.appendChild(this.element),this.gridview=new yl(!!t.proportionalLayout,t.styles,t.orientation,t.locked,t.margin),this.gridview.locked=!!t.locked,this.element.appendChild(this.gridview.element),this.layout(0,0,!0),this.addDisposables(this.gridview.onDidMaximizedNodeChange(s=>{this._onDidMaximizedChange.fire({panel:s.view,isMaximized:s.isMaximized})}),this.gridview.onDidViewVisibilityChange(()=>this._onDidViewVisibilityChangeMicroTaskQueue.fire()),this.onDidViewVisibilityChangeMicroTaskQueue(()=>{this.forceRelayout()}),ke.from(()=>{var s;(s=this.element.parentElement)===null||s===void 0||s.removeChild(this.element)}),this.gridview.onDidChange(()=>{this._bufferOnDidLayoutChange.fire()}),wt.any(this.onDidAdd,this.onDidRemove,this.onDidActiveChange)(()=>{this._bufferOnDidLayoutChange.fire()}),this._onDidMaximizedChange,this._onDidViewVisibilityChangeMicroTaskQueue,this._bufferOnDidLayoutChange)}setVisible(e,t){this.gridview.setViewVisible(Te(e.element),t),this._bufferOnDidLayoutChange.fire()}isVisible(e){return this.gridview.isViewVisible(Te(e.element))}updateOptions(e){var t,i,s,o;e.proportionalLayout,e.orientation&&(this.gridview.orientation=e.orientation),"disableResizing"in e&&(this.disableResizing=(t=e.disableAutoResizing)!==null&&t!==void 0?t:!1),"locked"in e&&(this.locked=(i=e.locked)!==null&&i!==void 0?i:!1),"margin"in e&&(this.gridview.margin=(s=e.margin)!==null&&s!==void 0?s:0),"className"in e&&this._classNames.setClassNames((o=e.className)!==null&&o!==void 0?o:"")}maximizeGroup(e){this.gridview.maximizeView(e),this.doSetGroupActive(e)}isMaximizedGroup(e){return this.gridview.maximizedView()===e}exitMaximizedGroup(){this.gridview.exitMaximizedView()}hasMaximizedGroup(){return this.gridview.hasMaximizedView()}doAddGroup(e,t=[0],i,s=this.gridview){s.addView(e,i??nt.Distribute,t),this._onDidAdd.fire(e)}doRemoveGroup(e,t){if(!this._groups.has(e.id))throw new Error("invalid operation");const i=this._groups.get(e.id),s=this.gridview.remove(e,nt.Distribute);if(i&&!t?.skipDispose&&(i.disposable.dispose(),i.value.dispose(),this._groups.delete(e.id),this._onDidRemove.fire(e)),!t?.skipActive&&this._activeGroup===e){const o=Array.from(this._groups.values());this.doSetGroupActive(o.length>0?o[0].value:void 0)}return s}getPanel(e){var t;return(t=this._groups.get(e))===null||t===void 0?void 0:t.value}doSetGroupActive(e){this._activeGroup!==e&&(this._activeGroup&&this._activeGroup.setActive(!1),e&&e.setActive(!0),this._activeGroup=e,this._onDidActiveChange.fire(e))}removeGroup(e){this.doRemoveGroup(e)}moveToNext(e){var t;if(e||(e={}),!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}const i=Te(e.group.element),s=(t=this.gridview.next(i))===null||t===void 0?void 0:t.view;this.doSetGroupActive(s)}moveToPrevious(e){var t;if(e||(e={}),!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}const i=Te(e.group.element),s=(t=this.gridview.previous(i))===null||t===void 0?void 0:t.view;this.doSetGroupActive(s)}forceRelayout(){this.layout(this.width,this.height,!0)}layout(e,t,i){(i||e!==this.width||t!==this.height)&&(this.gridview.element.style.height=`${t}px`,this.gridview.element.style.width=`${e}px`,this.gridview.layout(e,t))}dispose(){this._onDidActiveChange.dispose(),this._onDidAdd.dispose(),this._onDidRemove.dispose();for(const e of this.groups)e.dispose();this.gridview.dispose(),super.dispose()}}class Cl{get minimumSize(){return this.component.minimumSize}get maximumSize(){return this.component.maximumSize}get width(){return this.component.width}get height(){return this.component.height}get length(){return this.component.length}get orientation(){return this.component.orientation}get panels(){return this.component.panels}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidAddView(){return this.component.onDidAddView}get onDidRemoveView(){return this.component.onDidRemoveView}constructor(e){this.component=e}removePanel(e,t){this.component.removePanel(e,t)}focus(){this.component.focus()}getPanel(e){return this.component.getPanel(e)}layout(e,t){return this.component.layout(e,t)}addPanel(e){return this.component.addPanel(e)}movePanel(e,t){this.component.movePanel(e,t)}fromJSON(e){this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}}class kn{get minimumSize(){return this.component.minimumSize}get maximumSize(){return this.component.maximumSize}get width(){return this.component.width}get height(){return this.component.height}get panels(){return this.component.panels}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidAddView(){return this.component.onDidAddView}get onDidRemoveView(){return this.component.onDidRemoveView}get onDidDrop(){return this.component.onDidDrop}get onUnhandledDragOver(){return this.component.onUnhandledDragOver}constructor(e){this.component=e}removePanel(e){this.component.removePanel(e)}getPanel(e){return this.component.getPanel(e)}movePanel(e,t){this.component.movePanel(e,t)}focus(){this.component.focus()}layout(e,t){this.component.layout(e,t)}addPanel(e){return this.component.addPanel(e)}fromJSON(e){this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}}class Sl{get width(){return this.component.width}get height(){return this.component.height}get minimumHeight(){return this.component.minimumHeight}get maximumHeight(){return this.component.maximumHeight}get minimumWidth(){return this.component.minimumWidth}get maximumWidth(){return this.component.maximumWidth}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidAddPanel(){return this.component.onDidAddGroup}get onDidRemovePanel(){return this.component.onDidRemoveGroup}get onDidActivePanelChange(){return this.component.onDidActiveGroupChange}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get panels(){return this.component.groups}get orientation(){return this.component.orientation}set orientation(e){this.component.updateOptions({orientation:e})}constructor(e){this.component=e}focus(){this.component.focus()}layout(e,t,i=!1){this.component.layout(e,t,i)}addPanel(e){return this.component.addPanel(e)}removePanel(e,t){this.component.removePanel(e,t)}movePanel(e,t){this.component.movePanel(e,t)}getPanel(e){return this.component.getPanel(e)}fromJSON(e){return this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}}class Oo{get id(){return this.component.id}get width(){return this.component.width}get height(){return this.component.height}get minimumHeight(){return this.component.minimumHeight}get maximumHeight(){return this.component.maximumHeight}get minimumWidth(){return this.component.minimumWidth}get maximumWidth(){return this.component.maximumWidth}get size(){return this.component.size}get tabGroupColors(){return this.component.tabGroupColorPalette.entries()}get totalPanels(){return this.component.totalPanels}get onDidActiveGroupChange(){return this.component.onDidActiveGroupChange}get onDidAddGroup(){return this.component.onDidAddGroup}get onDidRemoveGroup(){return this.component.onDidRemoveGroup}get onDidActivePanelChange(){return this.component.onDidActivePanelChange}get onDidAddPanel(){return this.component.onDidAddPanel}get onDidRemovePanel(){return this.component.onDidRemovePanel}get onDidMovePanel(){return this.component.onDidMovePanel}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidDrop(){return this.component.onDidDrop}get onWillDrop(){return this.component.onWillDrop}get onWillMutateLayout(){return this.component.onWillMutateLayout}get onDidMutateLayout(){return this.component.onDidMutateLayout}get onWillShowOverlay(){return this.component.onWillShowOverlay}get onWillDragGroup(){return this.component.onWillDragGroup}get onWillDragPanel(){return this.component.onWillDragPanel}get onUnhandledDragOver(){return this.component.onUnhandledDragOver}get onDidPopoutGroupSizeChange(){return this.component.onDidPopoutGroupSizeChange}get onDidPopoutGroupPositionChange(){return this.component.onDidPopoutGroupPositionChange}get onDidAddPopoutGroup(){return this.component.onDidAddPopoutGroup}get onDidRemovePopoutGroup(){return this.component.onDidRemovePopoutGroup}get onDidOpenPopoutWindowFail(){return this.component.onDidOpenPopoutWindowFail}getPopouts(){return this.component.getPopouts()}get onDidCreateTabGroup(){return this.component.onDidCreateTabGroup}get onDidDestroyTabGroup(){return this.component.onDidDestroyTabGroup}get onDidAddPanelToTabGroup(){return this.component.onDidAddPanelToTabGroup}get onDidRemovePanelFromTabGroup(){return this.component.onDidRemovePanelFromTabGroup}get onDidTabGroupChange(){return this.component.onDidTabGroupChange}get onDidTabGroupCollapsedChange(){return this.component.onDidTabGroupCollapsedChange}get panels(){return this.component.panels}get groups(){return this.component.groups}adjacentGroupInDirection(e,t){return this.component.adjacentGroupInDirection(e,t)}get activePanel(){return this.component.activePanel}get activeGroup(){return this.component.activeGroup}constructor(e){this.component=e}focus(){this.component.focus()}getPanel(e){return this.component.getGroupPanel(e)}layout(e,t,i=!1){this.component.layout(e,t,i)}addPanel(e){return this.component.withOrigin("api",()=>this.component.addPanel(e))}removePanel(e){this.component.withOrigin("api",()=>this.component.removePanel(e))}addGroup(e){return this.component.addGroup(e)}closeAllGroups(){return this.component.withOrigin("api",()=>this.component.closeAllGroups())}removeGroup(e){this.component.withOrigin("api",()=>this.component.removeGroup(e))}getGroup(e){return this.component.getPanel(e)}addFloatingGroup(e,t){return this.component.withOrigin("api",()=>this.component.addFloatingGroup(e,t))}fromJSON(e,t){this.component.withOrigin("api",()=>this.component.fromJSON(e,t))}toJSON(){return this.component.toJSON()}clear(){this.component.withOrigin("api",()=>this.component.clear())}moveToNext(e){this.component.moveToNext(e)}moveToPrevious(e){this.component.moveToPrevious(e)}maximizeGroup(e){this.component.maximizeGroup(e.group)}hasMaximizedGroup(){return this.component.hasMaximizedGroup()}exitMaximizedGroup(){this.component.exitMaximizedGroup()}get onDidMaximizedGroupChange(){return this.component.onDidMaximizedGroupChange}addPopoutGroup(e,t){return this.component.withOrigin("api",()=>this.component.addPopoutGroup(e,t))}addEdgeGroup(e,t){return this.component.addEdgeGroup(e,t)}getEdgeGroup(e){return this.component.getEdgeGroup(e)}setEdgeGroupVisible(e,t){this.component.setEdgeGroupVisible(e,t)}isEdgeGroupVisible(e){return this.component.isEdgeGroupVisible(e)}removeEdgeGroup(e){this.component.removeEdgeGroup(e)}updateOptions(e){this.component.updateOptions(e)}_getGroupModel(e){const t=this.component.getPanel(e);if(!t)throw new Error(`dockview: group '${e}' not found`);return t.model}createTabGroup(e){const t=this._getGroupModel(e.groupId);return this.component.withOrigin("api",()=>t.createTabGroup({label:e.label,color:e.color,componentParams:e.componentParams}))}dissolveTabGroup(e){const t=this._getGroupModel(e.groupId);this.component.withOrigin("api",()=>t.dissolveTabGroup(e.tabGroupId))}addPanelToTabGroup(e){const t=this._getGroupModel(e.groupId);this.component.withOrigin("api",()=>t.addPanelToTabGroup(e.tabGroupId,e.panelId,e.index))}removePanelFromTabGroup(e){const t=this._getGroupModel(e.groupId);this.component.withOrigin("api",()=>t.removePanelFromTabGroup(e.panelId))}getTabGroups(e){return this._getGroupModel(e.groupId).getTabGroups()}getTabGroupForPanel(e){return this._getGroupModel(e.groupId).getTabGroupForPanel(e.panelId)}moveTabGroup(e){this._getGroupModel(e.groupId).moveTabGroup(e.tabGroupId,e.index)}dispose(){this.component.dispose()}}class Pl extends X{constructor(e,t){super(),this.element=e,this.callbacks=t,this.target=null,this.registerListeners()}onDragEnter(e){this.target=e.target,this.callbacks.onDragEnter(e)}onDragOver(e){e.preventDefault(),this.callbacks.onDragOver&&this.callbacks.onDragOver(e)}onDragLeave(e){this.target===e.target&&(this.target=null,this.callbacks.onDragLeave(e))}onDragEnd(e){this.target=null,this.callbacks.onDragEnd(e)}onDrop(e){this.callbacks.onDrop(e)}registerListeners(){this.addDisposables(U(this.element,"dragenter",e=>{this.onDragEnter(e)},!0)),this.addDisposables(U(this.element,"dragover",e=>{this.onDragOver(e)},!0)),this.addDisposables(U(this.element,"dragleave",e=>{this.onDragLeave(e)})),this.addDisposables(U(this.element,"dragend",e=>{this.onDragEnd(e)})),this.addDisposables(U(this.element,"drop",e=>{this.onDrop(e)}))}}const Ip={value:50,type:"percentage"},Ap=100,Np=100;function uo(){const n=document.createElement("div");n.className="dv-drop-target-dropzone";const e=document.createElement("div");return e.className="dv-drop-target-selection",n.appendChild(e),{dropzone:n,selection:e}}function kl(n,e,t,i){var s,o,r;const l=(s=i?.smallWidthBoundary)!==null&&s!==void 0?s:Ap,d=(o=i?.smallHeightBoundary)!==null&&o!==void 0?o:Np,c=e<l,h=t<d,u=n==="left",m=n==="right",g=n==="top",p=n==="bottom",f=!c&&m,w=!c&&u,C=!h&&g,b=!h&&p;let D=1;const k=(r=i?.size)!==null&&r!==void 0?r:Ip;return k.type==="percentage"?D=Ee(k.value,0,100)/100:((f||w)&&(D=Ee(0,k.value,e)/e),(C||b)&&(D=Ee(0,k.value,t)/t)),{isSmallX:c,isSmallY:h,isLeft:u,isRight:m,isTop:g,isBottom:p,rightClass:f,leftClass:w,topClass:C,bottomClass:b,size:D}}function zl(n,e,t,i,s){const o=kl(e,t,i,s),{rightClass:r,leftClass:l,topClass:d,bottomClass:c,size:h}=o,u={top:"0px",left:"0px",width:"100%",height:"100%"};r?(u.left=`${100*(1-h)}%`,u.width=`${100*h}%`):l?u.width=`${100*h}%`:d?u.height=`${100*h}%`:c&&(u.top=`${100*(1-h)}%`,u.height=`${100*h}%`),o.isSmallX&&o.isLeft&&(u.width="4px"),o.isSmallX&&o.isRight&&(u.left=`${t-4}px`,u.width="4px"),o.isSmallY&&o.isTop&&(u.height="4px"),o.isSmallY&&o.isBottom&&(u.top=`${i-4}px`,u.height="4px"),n.style.top=u.top,n.style.left=u.left,n.style.width=u.width,n.style.height=u.height,n.style.visibility="visible",(!n.style.transform||n.style.transform==="")&&(n.style.transform="translate3d(0, 0, 0)");const m=o.isSmallX&&(o.isLeft||o.isRight)||o.isSmallY&&(o.isTop||o.isBottom);W(n,"dv-drop-target-small-vertical",o.isSmallY),W(n,"dv-drop-target-small-horizontal",o.isSmallX),W(n,"dv-drop-target-selection-line",m),W(n,"dv-drop-target-left",o.isLeft),W(n,"dv-drop-target-right",o.isRight),W(n,"dv-drop-target-top",o.isTop),W(n,"dv-drop-target-bottom",o.isBottom),W(n,"dv-drop-target-center",e==="center")}function jp(n,e){const t=`${Math.round(e.top)}px`,i=`${Math.round(e.left)}px`,s=`${Math.round(e.width)}px`,o=`${Math.round(e.height)}px`;return n.style.top!==t||n.style.left!==i||n.style.width!==s||n.style.height!==o}function Op(n,e){n.style.top=`${Math.round(e.top)}px`,n.style.left=`${Math.round(e.left)}px`,n.style.width=`${Math.round(e.width)}px`,n.style.height=`${Math.round(e.height)}px`,n.style.visibility="visible",(!n.style.transform||n.style.transform==="")&&(n.style.transform="translate3d(0, 0, 0)")}function Tl(n){const e=kl(n.quadrant,n.width,n.height,n.overlayModel),{rightClass:t,leftClass:i,topClass:s,bottomClass:o,size:r}=e,l=n.outlineElement.getBoundingClientRect(),d=n.targetModel.getElements(void 0,n.outlineElement),c=d.root,h=d.overlay,u=c.getBoundingClientRect(),m=l.top-u.top,g=l.left-u.left,p={top:m,left:g,width:n.width,height:n.height};return t?(p.left=g+n.width*(1-r),p.width=n.width*r):i?p.width=n.width*r:s?p.height=n.height*r:o&&(p.top=m+n.height*(1-r),p.height=n.height*r),e.isSmallX&&e.isLeft&&(p.width=4),e.isSmallX&&e.isRight&&(p.left=g+n.width-4,p.width=4),e.isSmallY&&e.isTop&&(p.height=4),e.isSmallY&&e.isBottom&&(p.top=m+n.height-4,p.height=4),jp(h,p)?(Op(h,p),h.className=`dv-drop-target-anchor${n.className?` ${n.className}`:""}`,W(h,"dv-drop-target-left",e.isLeft),W(h,"dv-drop-target-right",e.isRight),W(h,"dv-drop-target-top",e.isTop),W(h,"dv-drop-target-bottom",e.isBottom),W(h,"dv-drop-target-anchor-line",e.isSmallX&&(e.isLeft||e.isRight)||e.isSmallY&&(e.isTop||e.isBottom)),W(h,"dv-drop-target-center",n.quadrant==="center"),d.changed&&(W(h,"dv-drop-target-anchor-container-changed",!0),setTimeout(()=>{W(h,"dv-drop-target-anchor-container-changed",!1)},10)),{boundsChanged:!0,targetChanged:d.changed}):{boundsChanged:!1,targetChanged:d.changed}}class El extends Ao{get nativeEvent(){return this.options.nativeEvent}get position(){return this.options.position}constructor(e){super(),this.options=e}}function Sa(n){switch(n){case"above":return"top";case"below":return"bottom";case"left":return"left";case"right":return"right";case"within":return"center";default:throw new Error(`invalid direction '${n}'`)}}function Mp(n){switch(n){case"top":return"above";case"bottom":return"below";case"left":return"left";case"right":return"right";case"center":return"within";default:throw new Error(`invalid position '${n}'`)}}const Lp={value:20,type:"percentage"};class ii extends X{get disabled(){return this._disabled}set disabled(e){this._disabled=e}get state(){return this._state}constructor(e,t){super(),this.element=e,this.options=t,this._onDrop=new z,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new z,this.onWillShowOverlay=this._onWillShowOverlay.event,this._disabled=!1,this._acceptedTargetZonesSet=new Set(this.options.acceptedTargetZones),this.dnd=new Pl(this.element,{onDragEnter:()=>{var i,s,o;(o=(s=(i=this.options).getOverrideTarget)===null||s===void 0?void 0:s.call(i))===null||o===void 0||o.getElements()},onDragOver:i=>{var s,o,r,l,d,c,h;ii.ACTUAL_TARGET=this;const u=(o=(s=this.options).getOverrideTarget)===null||o===void 0?void 0:o.call(s);if(this._acceptedTargetZonesSet.size===0){if(u)return;this.removeDropTarget();return}const m=(d=(l=(r=this.options).getOverlayOutline)===null||l===void 0?void 0:l.call(r))!==null&&d!==void 0?d:this.element,g=m.offsetWidth,p=m.offsetHeight;if(g===0||p===0)return;const f=i.currentTarget.getBoundingClientRect(),w=((c=i.clientX)!==null&&c!==void 0?c:0)-f.left,C=((h=i.clientY)!==null&&h!==void 0?h:0)-f.top,b=this.calculateQuadrant(this._acceptedTargetZonesSet,w,C,g,p);if(this.isAlreadyUsed(i)||b===null){this.removeDropTarget();return}if(!this.options.canDisplayOverlay(i,b)){if(u)return;this.removeDropTarget();return}const D=new El({nativeEvent:i,position:b});if(this._onWillShowOverlay.fire(D),D.defaultPrevented){this.removeDropTarget();return}if(this.markAsUsed(i),!u){if(!this.targetElement){const k=uo();this.targetElement=k.dropzone,this.overlayElement=k.selection,this._state="center",m.classList.add("dv-drop-target"),m.append(this.targetElement)}}this.toggleClasses(b,g,p),this._state=b},onDragLeave:()=>{var i,s;!((s=(i=this.options).getOverrideTarget)===null||s===void 0)&&s.call(i)||this.removeDropTarget()},onDragEnd:i=>{var s,o;const r=(o=(s=this.options).getOverrideTarget)===null||o===void 0?void 0:o.call(s);r&&ii.ACTUAL_TARGET===this&&this._state&&(i.stopPropagation(),this._onDrop.fire({position:this._state,nativeEvent:i})),this.removeDropTarget(),r?.clear()},onDrop:i=>{var s,o,r;i.preventDefault();const l=this._state;this.removeDropTarget(),(r=(o=(s=this.options).getOverrideTarget)===null||o===void 0?void 0:o.call(s))===null||r===void 0||r.clear(),l&&(i.stopPropagation(),this._onDrop.fire({position:l,nativeEvent:i}))}}),this.addDisposables(this._onDrop,this._onWillShowOverlay,this.dnd)}setTargetZones(e){this._acceptedTargetZonesSet=new Set(e)}setOverlayModel(e){this.options.overlayModel=e}dispose(){this.removeDropTarget(),super.dispose()}markAsUsed(e){e[ii.USED_EVENT_ID]=!0}isAlreadyUsed(e){const t=e[ii.USED_EVENT_ID];return typeof t=="boolean"&&t}toggleClasses(e,t,i){var s,o,r,l,d;const c=(o=(s=this.options).getOverrideTarget)===null||o===void 0?void 0:o.call(s);if(c){const h=(d=(l=(r=this.options).getOverlayOutline)===null||l===void 0?void 0:l.call(r))!==null&&d!==void 0?d:this.element;Tl({outlineElement:h,targetModel:c,quadrant:e,width:t,height:i,overlayModel:this.options.overlayModel,className:this.options.className});return}this.overlayElement&&zl(this.overlayElement,e,t,i,this.options.overlayModel)}calculateQuadrant(e,t,i,s,o){var r,l;const d=(l=(r=this.options.overlayModel)===null||r===void 0?void 0:r.activationSize)!==null&&l!==void 0?l:Lp;return d.type==="percentage"?Gl(e,t,i,s,o,d.value):Il(e,t,i,s,o,d.value)}removeDropTarget(){var e;this.targetElement&&(this._state=void 0,(e=this.targetElement.parentElement)===null||e===void 0||e.classList.remove("dv-drop-target"),this.targetElement.remove(),this.targetElement=void 0,this.overlayElement=void 0)}showOverlay(e){var t,i,s,o,r;const l=(i=(t=this.options).getOverrideTarget)===null||i===void 0?void 0:i.call(t),d=(r=(o=(s=this.options).getOverlayOutline)===null||o===void 0?void 0:o.call(s))!==null&&r!==void 0?r:this.element,c=d.offsetWidth,h=d.offsetHeight;if(!l&&!this.targetElement){const u=uo();this.targetElement=u.dropzone,this.overlayElement=u.selection,d.classList.add("dv-drop-target"),d.append(this.targetElement)}this.toggleClasses(e,c,h),this._state=e}clearOverlay(){var e,t,i;this.removeDropTarget(),(i=(t=(e=this.options).getOverrideTarget)===null||t===void 0?void 0:t.call(e))===null||i===void 0||i.clear(),this._state=void 0}}ii.USED_EVENT_ID="__dockview_droptarget_event_is_used__";function Gl(n,e,t,i,s,o){const r=100*e/i,l=100*t/s;return n.has("left")&&r<o?"left":n.has("right")&&r>100-o?"right":n.has("top")&&l<o?"top":n.has("bottom")&&l>100-o?"bottom":n.has("center")?"center":null}function Il(n,e,t,i,s,o){return n.has("left")&&e<o?"left":n.has("right")&&e>i-o?"right":n.has("top")&&t<o?"top":n.has("bottom")&&t>s-o?"bottom":n.has("center")?"center":null}function Rp(n,e,t){var i,s;At(e,"dv-dragged"),e.style.top="-9999px",document.body.appendChild(e),n.setDragImage(e,(i=t?.x)!==null&&i!==void 0?i:0,(s=t?.y)!==null&&s!==void 0?s:0),setTimeout(()=>{It(e,"dv-dragged"),e.remove()},0)}class ni extends X{static getInstance(){return ni._instance||(ni._instance=new ni),ni._instance}constructor(){super(),this._targets=new Set,this._targetByElement=new Map,this._onDragStart=new z,this.onDragStart=this._onDragStart.event,this._onDragMove=new z,this.onDragMove=this._onDragMove.event,this._onDragEnd=new z,this.onDragEnd=this._onDragEnd.event,this.addDisposables(this._onDragStart,this._onDragMove,this._onDragEnd)}get active(){return this._active}registerTarget(e){return this._targets.add(e),this._targetByElement.set(e.element,e),{dispose:()=>{this._targets.delete(e),this._targetByElement.get(e.element)===e&&this._targetByElement.delete(e.element),this._currentTarget===e&&(this._currentTarget=void 0)}}}beginDrag(e){var t,i,s;this._active&&this.cancel();const{pointerEvent:o,source:r}=e,l=e.getData();this._active={pointerId:o.pointerId,startX:o.clientX,startY:o.clientY,source:r},this._onDragMoveCallback=e.onDragMove,this._onDragEndCallback=e.onDragEnd,this._dataDisposable=l,this._ghost=e.ghost,this._iframeShield=Pn((t=r.ownerDocument)!==null&&t!==void 0?t:document);const d={clientX:o.clientX,clientY:o.clientY,pointerEvent:o};this._onDragStart.fire(d);const c=(s=(i=r.ownerDocument)===null||i===void 0?void 0:i.defaultView)!==null&&s!==void 0?s:window;this._moveListener=U(c,"pointermove",h=>{!this._active||h.pointerId!==this._active.pointerId||this._handleMove(h)}),this._upListener=U(c,"pointerup",h=>{!this._active||h.pointerId!==this._active.pointerId||this._handleEnd(h,!0)}),this._cancelListener=U(c,"pointercancel",h=>{!this._active||h.pointerId!==this._active.pointerId||this._handleEnd(h,!1)})}cancel(){var e,t;this._active&&((e=this._currentTarget)===null||e===void 0||e.handleDragLeave(),this._teardown(),(t=this._dataDisposable)===null||t===void 0||t.dispose(),this._dataDisposable=void 0)}_findTargetUnder(e,t){var i,s;const r=((s=(i=this._active)===null||i===void 0?void 0:i.source.ownerDocument)!==null&&s!==void 0?s:document).elementsFromPoint(e,t);for(const l of r){let d=l;for(;d;){const c=this._targetByElement.get(d);if(c)return c;d=d.parentElement}}}_handleMove(e){var t,i,s;(t=this._ghost)===null||t===void 0||t.update(e.clientX,e.clientY);const o={clientX:e.clientX,clientY:e.clientY,pointerEvent:e},r=this._findTargetUnder(e.clientX,e.clientY);r!==this._currentTarget&&((i=this._currentTarget)===null||i===void 0||i.handleDragLeave(),this._currentTarget=r),r&&r.handleDragOver(o),(s=this._onDragMoveCallback)===null||s===void 0||s.call(this,o),this._onDragMove.fire(o)}_handleEnd(e,t){var i;const s={clientX:e.clientX,clientY:e.clientY,pointerEvent:e};t&&this._currentTarget?this._currentTarget.handleDrop(s):(i=this._currentTarget)===null||i===void 0||i.handleDragLeave();const o=this._onDragEndCallback,r=this._dataDisposable;this._teardown(),this._dataDisposable=void 0,setTimeout(()=>r?.dispose(),0),o?.(s,t),this._onDragEnd.fire(s)}_teardown(){var e,t,i,s,o;this._currentTarget=void 0,this._active=void 0,this._onDragMoveCallback=void 0,this._onDragEndCallback=void 0,(e=this._ghost)===null||e===void 0||e.dispose(),this._ghost=void 0,(t=this._iframeShield)===null||t===void 0||t.release(),this._iframeShield=void 0,(i=this._moveListener)===null||i===void 0||i.dispose(),(s=this._upListener)===null||s===void 0||s.dispose(),(o=this._cancelListener)===null||o===void 0||o.dispose(),this._moveListener=void 0,this._upListener=void 0,this._cancelListener=void 0}}const Vp={value:20,type:"percentage"};class Fp extends X{get disabled(){return this._disabled}set disabled(e){this._disabled=e,e&&this._removeOverlay()}get state(){return this._state}constructor(e,t){super(),this.element=e,this.options=t,this._onDrop=new z,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new z,this.onWillShowOverlay=this._onWillShowOverlay.event,this._disabled=!1,this._acceptedTargetZonesSet=new Set(t.acceptedTargetZones);const i={element:this.element,handleDragOver:s=>this._onDragOver(s),handleDragLeave:()=>this._onDragLeave(),handleDrop:s=>this._onDropEvent(s)};this.addDisposables(this._onDrop,this._onWillShowOverlay,ni.getInstance().registerTarget(i))}setTargetZones(e){this._acceptedTargetZonesSet=new Set(e)}setOverlayModel(e){this.options.overlayModel=e}dispose(){this._removeOverlay(),super.dispose()}_onDragOver(e){var t,i,s,o,r;if(this._disabled){this._removeOverlay();return}const l=(i=(t=this.options).getOverrideTarget)===null||i===void 0?void 0:i.call(t);if(this._acceptedTargetZonesSet.size===0){if(l)return;this._removeOverlay();return}const d=(r=(o=(s=this.options).getOverlayOutline)===null||o===void 0?void 0:o.call(s))!==null&&r!==void 0?r:this.element,c=d.offsetWidth,h=d.offsetHeight;if(c===0||h===0)return;const u=d.getBoundingClientRect(),m=e.clientX-u.left,g=e.clientY-u.top,p=this._calculateQuadrant(m,g,c,h);if(p===null){this._removeOverlay();return}if(!this.options.canDisplayOverlay(e.pointerEvent,p)){if(l)return;this._removeOverlay();return}const f=new El({nativeEvent:e.pointerEvent,position:p});if(this._onWillShowOverlay.fire(f),f.defaultPrevented){this._removeOverlay();return}if(l){Tl({outlineElement:d,targetModel:l,quadrant:p,width:c,height:h,overlayModel:this.options.overlayModel,className:this.options.className}),this._state=p;return}if(!this._targetElement){const w=uo();this._targetElement=w.dropzone,this._overlayElement=w.selection,this._state="center",this.element.classList.add("dv-drop-target"),this.element.append(this._targetElement)}this._overlayElement&&zl(this._overlayElement,p,c,h,this.options.overlayModel),this._state=p}_onDragLeave(){var e,t;const i=(t=(e=this.options).getOverrideTarget)===null||t===void 0?void 0:t.call(e);if(i){this._state=void 0,i.clear();return}this._removeOverlay()}_onDropEvent(e){var t,i;const s=this._state,o=(i=(t=this.options).getOverrideTarget)===null||i===void 0?void 0:i.call(t);this._removeOverlay(),o?.clear(),s&&this._onDrop.fire({position:s,nativeEvent:e.pointerEvent})}_calculateQuadrant(e,t,i,s){var o,r;const l=(r=(o=this.options.overlayModel)===null||o===void 0?void 0:o.activationSize)!==null&&r!==void 0?r:Vp;return l.type==="percentage"?Gl(this._acceptedTargetZonesSet,e,t,i,s,l.value):Il(this._acceptedTargetZonesSet,e,t,i,s,l.value)}_removeOverlay(){var e;this._targetElement?(this._state=void 0,(e=this._targetElement.parentElement)===null||e===void 0||e.classList.remove("dv-drop-target"),this._targetElement.remove(),this._targetElement=void 0,this._overlayElement=void 0):this._state=void 0}}const Wp=5,$p=250,Hp=8;class Bp extends X{constructor(e,t){var i;super(),this.element=e,this.options=t,this._disabled=!1,this._armed=!1,this._startX=0,this._startY=0,this._touchOnly=(i=t.touchOnly)!==null&&i!==void 0?i:!0,this.addDisposables(U(this.element,"pointerdown",s=>{this._onPointerDown(s)}))}setDisabled(e){this._disabled=e,e&&this._cancelPending()}setTouchOnly(e){this._touchOnly!==e&&(this._touchOnly=e,e&&this._cancelPending())}_shouldHandle(e){var t,i;return!(this._disabled||this._touchOnly&&e.pointerType!=="touch"&&e.pointerType!=="pen"||!((i=(t=this.options).isCancelled)===null||i===void 0)&&i.call(t,e))}_onPointerDown(e){var t,i,s,o,r;if(!this._shouldHandle(e))return;this._cancelPending(),this._pendingPointerId=e.pointerId,this._startX=e.clientX,this._startY=e.clientY,this._startEvent=e;const l=e.pointerType==="touch"||e.pointerType==="pen",d=this.options.touchInitiationDelay,c=(t=typeof d=="function"?d():d)!==null&&t!==void 0?t:$p;this._armed=!l||c<=0,l&&c>0&&isFinite(c)&&(this._armTimer=setTimeout(()=>{this._armTimer=void 0,this._armed=!0},c));const h=(i=this.options.threshold)!==null&&i!==void 0?i:Wp,u=this.options.pressTolerance,m=(s=typeof u=="function"?u():u)!==null&&s!==void 0?s:Hp,g=(r=(o=this.element.ownerDocument)===null||o===void 0?void 0:o.defaultView)!==null&&r!==void 0?r:window;this._pendingMoveListener=U(g,"pointermove",p=>{if(p.pointerId!==this._pendingPointerId)return;const f=p.clientX-this._startX,w=p.clientY-this._startY,C=Math.hypot(f,w);if(this._armed){C>=h&&this._beginDrag(p);return}C>m&&this._beginDrag(p)}),this._pendingUpListener=U(g,"pointerup",p=>{p.pointerId===this._pendingPointerId&&this._cancelPending()}),this._pendingCancelListener=U(g,"pointercancel",p=>{p.pointerId===this._pendingPointerId&&this._cancelPending()})}cancelPending(){this._cancelPending()}_cancelPending(){var e,t,i;this._pendingPointerId=void 0,this._armTimer!==void 0&&(clearTimeout(this._armTimer),this._armTimer=void 0),this._armed=!1,(e=this._pendingMoveListener)===null||e===void 0||e.dispose(),(t=this._pendingUpListener)===null||t===void 0||t.dispose(),(i=this._pendingCancelListener)===null||i===void 0||i.dispose(),this._pendingMoveListener=void 0,this._pendingUpListener=void 0,this._pendingCancelListener=void 0,this._startEvent=void 0}_beginDrag(e){var t,i,s,o,r;const l=(t=this._startEvent)!==null&&t!==void 0?t:e;this._cancelPending(),(s=(i=this.options).onDragStart)===null||s===void 0||s.call(i,l);const d=(r=(o=this.options).createGhost)===null||r===void 0?void 0:r.call(o,l);ni.getInstance().beginDrag({pointerEvent:e,source:this.element,getData:()=>this.options.getData(l),ghost:d,onDragMove:this.options.onDragMove,onDragEnd:this.options.onDragEnd})}dispose(){this._cancelPending(),super.dispose()}}class Up{constructor(e){var t,i,s,o,r;this._disposed=!1,this.element=e.element,this.offsetX=(t=e.offsetX)!==null&&t!==void 0?t:0,this.offsetY=(i=e.offsetY)!==null&&i!==void 0?i:0,this.element.style.position="fixed",this.element.style.left="0px",this.element.style.top="0px",this.element.style.pointerEvents="none",this.element.style.zIndex="99999",this.element.style.opacity=String((s=e.opacity)!==null&&s!==void 0?s:.8),this.element.style.willChange="transform",this.element.style.transform=`translate3d(${e.initialX-this.offsetX}px, ${e.initialY-this.offsetY}px, 0)`,((r=(o=e.owner)===null||o===void 0?void 0:o.ownerDocument)!==null&&r!==void 0?r:document).body.appendChild(this.element)}update(e,t){this._disposed||(this.element.style.transform=`translate3d(${e-this.offsetX}px, ${t-this.offsetY}px, 0)`)}dispose(){this._disposed||(this._disposed=!0,this.element.remove())}}class Yp extends X{constructor(e,t){super(),this.el=e,this.opts=t,this._dataDisposable=new $e,this._pointerEventsDisposable=new $e,this._disabled=!!t.disabled,this.addDisposables(this._dataDisposable,this._pointerEventsDisposable,U(this.el,"dragstart",i=>{var s,o,r,l,d,c,h,u,m;if(i.defaultPrevented||this._disabled||!((o=(s=this.opts).isCancelled)===null||o===void 0)&&o.call(s,i)){i.preventDefault();return}const g=Pn((r=this.el.ownerDocument)!==null&&r!==void 0?r:document);this._pointerEventsDisposable.value={dispose:()=>g.release()},this.el.classList.add("dv-dragged"),setTimeout(()=>this.el.classList.remove("dv-dragged"),0),this._dataDisposable.value=this.opts.getData(i);const p=(d=(l=this.opts).createGhost)===null||d===void 0?void 0:d.call(l,i);if(p&&i.dataTransfer&&(Rp(i.dataTransfer,p.element,{x:(c=p.offsetX)!==null&&c!==void 0?c:0,y:(h=p.offsetY)!==null&&h!==void 0?h:0}),p.dispose)){const f=p.dispose;setTimeout(()=>f(),0)}i.dataTransfer&&(i.dataTransfer.effectAllowed="move",i.dataTransfer.items.length===0&&i.dataTransfer.setData("text/plain","")),(m=(u=this.opts).onDragStart)===null||m===void 0||m.call(u,i)}),U(this.el,"dragend",i=>{var s,o;this._pointerEventsDisposable.dispose(),setTimeout(()=>this._dataDisposable.dispose(),0),(o=(s=this.opts).onDragEnd)===null||o===void 0||o.call(s,i)}))}setDisabled(e){this._disabled=e}setTouchOnly(e){}cancelPending(){}}class Xp{constructor(){this.kind="html5"}createDropTarget(e,t){return new ii(e,t)}createDragSource(e,t){return new Yp(e,t)}}class Kp{constructor(){this.kind="pointer"}createDropTarget(e,t){return new Fp(e,t)}createDragSource(e,t){const i=t.createGhost?o=>{const r=t.createGhost(o);if(!r)return;const l=new Up({element:r.element,initialX:o.clientX,initialY:o.clientY,offsetX:r.offsetX,offsetY:r.offsetY,owner:e});if(r.dispose){const d=l.dispose.bind(l),c=r.dispose;l.dispose=()=>{d(),c()}}return l}:void 0,s=new Bp(e,{getData:t.getData,isCancelled:t.isCancelled,onDragStart:t.onDragStart,onDragEnd:t.onDragEnd?o=>t.onDragEnd(o.pointerEvent):void 0,createGhost:i,touchOnly:t.touchOnly,touchInitiationDelay:t.touchInitiationDelay,pressTolerance:t.pressTolerance,threshold:t.threshold});return t.disabled&&s.setDisabled(!0),s}}const pi=new Xp,si=new Kp,po=Object.keys({disableAutoResizing:void 0,disableDnd:void 0,className:void 0});class qp extends pl{constructor(e,t,i,s){super(),this.nativeEvent=e,this.position=t,this.getData=i,this.panel=s}}class Al extends Ao{constructor(){super()}}class Nl extends X{get isFocused(){return this._isFocused}get isActive(){return this._isActive}get isVisible(){return this._isVisible}get width(){return this._width}get height(){return this._height}constructor(e,t){super(),this.id=e,this.component=t,this._isFocused=!1,this._isActive=!1,this._isVisible=!0,this._width=0,this._height=0,this._parameters={},this.panelUpdatesDisposable=new $e,this._onDidDimensionChange=new z,this.onDidDimensionsChange=this._onDidDimensionChange.event,this._onDidChangeFocus=new z,this.onDidFocusChange=this._onDidChangeFocus.event,this._onWillFocus=new z,this.onWillFocus=this._onWillFocus.event,this._onDidVisibilityChange=new z,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._onWillVisibilityChange=new z,this.onWillVisibilityChange=this._onWillVisibilityChange.event,this._onDidActiveChange=new z,this.onDidActiveChange=this._onDidActiveChange.event,this._onActiveChange=new z,this.onActiveChange=this._onActiveChange.event,this._onDidParametersChange=new z,this.onDidParametersChange=this._onDidParametersChange.event,this.addDisposables(this.onDidFocusChange(i=>{this._isFocused=i.isFocused}),this.onDidActiveChange(i=>{this._isActive=i.isActive}),this.onDidVisibilityChange(i=>{this._isVisible=i.isVisible}),this.onDidDimensionsChange(i=>{this._width=i.width,this._height=i.height}),this.panelUpdatesDisposable,this._onDidDimensionChange,this._onDidChangeFocus,this._onDidVisibilityChange,this._onDidActiveChange,this._onWillFocus,this._onActiveChange,this._onWillFocus,this._onWillVisibilityChange,this._onDidParametersChange)}getParameters(){return this._parameters}initialize(e){this.panelUpdatesDisposable.value=this._onDidParametersChange.event(t=>{this._parameters=t,e.update({params:t})})}setVisible(e){this._onWillVisibilityChange.fire({isVisible:e})}setActive(){this._onActiveChange.fire()}updateParameters(e){this._onDidParametersChange.fire(e)}}class jl extends Nl{constructor(e,t){super(e,t),this._onDidConstraintsChangeInternal=new z,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new z({replay:!0}),this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new z,this.onDidSizeChange=this._onDidSizeChange.event,this.addDisposables(this._onDidConstraintsChangeInternal,this._onDidConstraintsChange,this._onDidSizeChange)}setConstraints(e){this._onDidConstraintsChangeInternal.fire(e)}setSize(e){this._onDidSizeChange.fire(e)}}class Jp extends jl{set pane(e){this._pane=e}constructor(e,t){super(e,t),this._onDidExpansionChange=new z({replay:!0}),this.onDidExpansionChange=this._onDidExpansionChange.event,this._onMouseEnter=new z({}),this.onMouseEnter=this._onMouseEnter.event,this._onMouseLeave=new z({}),this.onMouseLeave=this._onMouseLeave.event,this.addDisposables(this._onDidExpansionChange,this._onMouseEnter,this._onMouseLeave)}setExpanded(e){var t;(t=this._pane)===null||t===void 0||t.setExpanded(e)}get isExpanded(){var e;return!!(!((e=this._pane)===null||e===void 0)&&e.isExpanded())}}class Mo extends X{get element(){return this._element}get width(){return this._width}get height(){return this._height}get params(){var e;return(e=this._params)===null||e===void 0?void 0:e.params}constructor(e,t,i){super(),this.id=e,this.component=t,this.api=i,this._height=0,this._width=0,this._element=document.createElement("div"),this._element.tabIndex=-1,this._element.style.outline="none",this._element.style.height="100%",this._element.style.width="100%",this._element.style.overflow="hidden";const s=ml(this._element);this.addDisposables(this.api,s.onDidFocus(()=>{this.api._onDidChangeFocus.fire({isFocused:!0})}),s.onDidBlur(()=>{this.api._onDidChangeFocus.fire({isFocused:!1})}),s)}focus(){const e=new Al;this.api._onWillFocus.fire(e),!e.defaultPrevented&&this._element.focus()}layout(e,t){this._width=e,this._height=t,this.api._onDidDimensionChange.fire({width:e,height:t}),this.part&&this._params&&this.part.update(this._params.params)}init(e){this._params=e,this.part=this.getComponent()}update(e){var t,i;this._params=Object.assign(Object.assign({},this._params),{params:Object.assign(Object.assign({},(t=this._params)===null||t===void 0?void 0:t.params),e.params)});for(const s of Object.keys(e.params))e.params[s]===void 0&&delete this._params.params[s];(i=this.part)===null||i===void 0||i.update({params:this._params.params})}toJSON(){var e,t;const i=(t=(e=this._params)===null||e===void 0?void 0:e.params)!==null&&t!==void 0?t:{};return{id:this.id,component:this.component,params:Object.keys(i).length>0?i:void 0}}dispose(){var e;this.api.dispose(),(e=this.part)===null||e===void 0||e.dispose(),super.dispose()}}class Zp extends Mo{set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){const e=this.headerSize,i=this.isExpanded()?this._minimumBodySize:0;return e+i}get maximumSize(){const e=this.headerSize,i=this.isExpanded()?this._maximumBodySize:0;return e+i}get size(){return this._size}get orthogonalSize(){return this._orthogonalSize}set orthogonalSize(e){this._orthogonalSize=e}get minimumBodySize(){return this._minimumBodySize}set minimumBodySize(e){this._minimumBodySize=typeof e=="number"?e:0}get maximumBodySize(){return this._maximumBodySize}set maximumBodySize(e){this._maximumBodySize=typeof e=="number"?e:Number.POSITIVE_INFINITY}get headerVisible(){return this._headerVisible}set headerVisible(e){this._headerVisible=e,this.header.style.display=e?"":"none"}constructor(e){super(e.id,e.component,new Jp(e.id,e.component)),this._onDidChangeExpansionState=new z({replay:!0}),this.onDidChangeExpansionState=this._onDidChangeExpansionState.event,this._onDidChange=new z,this.onDidChange=this._onDidChange.event,this._orthogonalSize=0,this._size=0,this._isExpanded=!1,this.api.pane=this,this.api.initialize(this),this.headerSize=e.headerSize,this.headerComponent=e.headerComponent,this._minimumBodySize=e.minimumBodySize,this._maximumBodySize=e.maximumBodySize,this._isExpanded=e.isExpanded,this._headerVisible=e.isHeaderVisible,this._onDidChangeExpansionState.fire(this.isExpanded()),this._orientation=e.orientation,this.element.classList.add("dv-pane"),this.addDisposables(this.api.onWillVisibilityChange(t=>{const{isVisible:i}=t,{accessor:s}=this._params;s.setVisible(this,i)}),this.api.onDidSizeChange(t=>{this._onDidChange.fire({size:t.size})}),U(this.element,"mouseenter",t=>{this.api._onMouseEnter.fire(t)}),U(this.element,"mouseleave",t=>{this.api._onMouseLeave.fire(t)})),this.addDisposables(this._onDidChangeExpansionState,this.onDidChangeExpansionState(t=>{this.api._onDidExpansionChange.fire({isExpanded:t})}),this.api.onDidFocusChange(t=>{this.header&&(t.isFocused?At(this.header,"focused"):It(this.header,"focused"))})),this.renderOnce()}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}isExpanded(){return this._isExpanded}setExpanded(e){this._isExpanded!==e&&(this._isExpanded=e,e?(this.animationTimer&&clearTimeout(this.animationTimer),this.body&&this.element.appendChild(this.body)):this.animationTimer=setTimeout(()=>{var t;(t=this.body)===null||t===void 0||t.remove()},200),this._onDidChange.fire(e?{size:this.width}:{}),this._onDidChangeExpansionState.fire(e))}layout(e,t){this._size=e,this._orthogonalSize=t;const[i,s]=this.orientation===ee.HORIZONTAL?[e,t]:[t,e];super.layout(i,s)}init(e){var t,i;super.init(e),typeof e.minimumBodySize=="number"&&(this.minimumBodySize=e.minimumBodySize),typeof e.maximumBodySize=="number"&&(this.maximumBodySize=e.maximumBodySize),this.bodyPart=this.getBodyComponent(),this.headerPart=this.getHeaderComponent(),this.bodyPart.init(Object.assign(Object.assign({},e),{api:this.api})),this.headerPart.init(Object.assign(Object.assign({},e),{api:this.api})),(t=this.body)===null||t===void 0||t.append(this.bodyPart.element),(i=this.header)===null||i===void 0||i.append(this.headerPart.element),typeof e.isExpanded=="boolean"&&this.setExpanded(e.isExpanded)}toJSON(){const e=this._params;return Object.assign(Object.assign({},super.toJSON()),{headerComponent:this.headerComponent,title:e.title})}renderOnce(){this.header=document.createElement("div"),this.header.tabIndex=0,this.header.className="dv-pane-header",this.header.style.height=`${this.headerSize}px`,this.header.style.lineHeight=`${this.headerSize}px`,this.header.style.minHeight=`${this.headerSize}px`,this.header.style.maxHeight=`${this.headerSize}px`,this.element.appendChild(this.header),this.body=document.createElement("div"),this.body.className="dv-pane-body",this.element.appendChild(this.body)}getComponent(){return{update:e=>{var t,i;(t=this.bodyPart)===null||t===void 0||t.update({params:e}),(i=this.headerPart)===null||i===void 0||i.update({params:e})},dispose:()=>{var e,t;(e=this.bodyPart)===null||e===void 0||e.dispose(),(t=this.headerPart)===null||t===void 0||t.dispose()}}}}class Qp extends Zp{constructor(e){super({id:e.id,component:e.component,headerComponent:e.headerComponent,orientation:e.orientation,isExpanded:e.isExpanded,isHeaderVisible:!0,headerSize:e.headerSize,minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize}),this._onDidDrop=new z,this.onDidDrop=this._onDidDrop.event,this._onUnhandledDragOver=new z,this.onUnhandledDragOver=this._onUnhandledDragOver.event,this.accessor=e.accessor,this.addDisposables(this._onDidDrop,this._onUnhandledDragOver),e.disableDnd||this.initDragFeatures()}initDragFeatures(){if(!this.header)return;const e=this.id,t=this.accessor.id;this.header.draggable=!0;const i={getData:()=>(Gt.getInstance().setData([new _n(t,e)],_n.prototype),{dispose:()=>{Gt.getInstance().clearData(_n.prototype)}})};this.html5DragSource=pi.createDragSource(this.header,i),this.pointerDragSource=si.createDragSource(this.header,i);const o={acceptedTargetZones:["top","bottom"],overlayModel:{activationSize:{type:"percentage",value:50}},canDisplayOverlay:(r,l)=>{const d=ln();if(d&&d.paneId!==this.id&&d.viewId===this.accessor.id)return!0;const c=new qp(r,l,ln,this);return this._onUnhandledDragOver.fire(c),c.isAccepted}};this.target=pi.createDropTarget(this.element,o),this.pointerTarget=si.createDropTarget(this.element,o),this.addDisposables(this._onDidDrop,this.html5DragSource,this.pointerDragSource,this.target,this.pointerTarget,this.target.onDrop(r=>{this.onDrop(r)}),this.pointerTarget.onDrop(r=>{this.onDrop(r)}))}onDrop(e){const t=ln();if(!t||t.viewId!==this.accessor.id){this._onDidDrop.fire(Object.assign(Object.assign({},e),{panel:this,api:new kn(this.accessor),getData:ln}));return}const i=this._params.containerApi,s=t.paneId,o=i.getPanel(s);if(!o){this._onDidDrop.fire(Object.assign(Object.assign({},e),{panel:this,getData:ln,api:new kn(this.accessor)}));return}const r=i.panels,l=r.indexOf(o);let d=i.panels.indexOf(this);(e.position==="left"||e.position==="top")&&(d=Math.max(0,d-1)),(e.position==="right"||e.position==="bottom")&&(l>d&&d++,d=Math.min(r.length-1,d)),i.movePanel(l,d)}}let em=0;const tm=()=>`dv-tabpanel-${em++}`;class im extends X{get element(){return this._element}constructor(e,t){var i,s,o,r,l,d,c;super(),this.accessor=e,this.group=t,this.disposable=new $e,this._onDidFocus=new z,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new z,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement("div"),this._element.className="dv-content-container",this._element.tabIndex=-1,this._element.id=tm(),this._element.setAttribute("role","tabpanel"),this.addDisposables(this._onDidFocus,this._onDidBlur);const h=()=>{var m;return(m=t.dropTargetContainer)===null||m===void 0?void 0:m.model},u=(m,g)=>{if(this.group.locked==="no-drop-target"||this.group.locked&&g==="center")return!1;const p=Ae();return!p&&m.shiftKey&&this.group.location.type!=="floating"?!1:p&&p.viewId===this.accessor.id?!0:this.group.canDisplayOverlay(m,g,"content")};this.dropTarget=new ii(this.element,{getOverlayOutline:()=>{var m;return((m=e.options.theme)===null||m===void 0?void 0:m.dndPanelOverlay)==="group"?this.element.parentElement:null},className:"dv-drop-target-content",acceptedTargetZones:["top","bottom","left","right","center"],canDisplayOverlay:u,getOverrideTarget:h,overlayModel:(s=(i=this.accessor).resolveDropOverlayModel)===null||s===void 0?void 0:s.call(i,"content")}),this.pointerDropTarget=si.createDropTarget(this.element,{acceptedTargetZones:["top","bottom","left","right","center"],canDisplayOverlay:u,getOverlayOutline:()=>{var m;return((m=e.options.theme)===null||m===void 0?void 0:m.dndPanelOverlay)==="group"?this.element.parentElement:null},className:"dv-drop-target-content",getOverrideTarget:h,overlayModel:(r=(o=this.accessor).resolveDropOverlayModel)===null||r===void 0?void 0:r.call(o,"content")}),this.addDisposables(this.dropTarget,this.pointerDropTarget,(c=(d=(l=this.accessor).onDidOptionsChange)===null||d===void 0?void 0:d.call(l,()=>{var m,g,p;const f=(p=(g=(m=this.accessor).resolveDropOverlayModel)===null||g===void 0?void 0:g.call(m,"content"))!==null&&p!==void 0?p:{};this.dropTarget.setOverlayModel(f),this.pointerDropTarget.setOverlayModel(f)}))!==null&&c!==void 0?c:ke.NONE)}show(){this.element.style.display=""}hide(){this.element.style.display="none"}setLabelledBy(e){e?this._element.setAttribute("aria-labelledby",e):this._element.removeAttribute("aria-labelledby")}renderPanel(e,t={asActive:!0}){var i,s,o,r;const l=t.asActive||this.panel&&this.group.isPanelActive(this.panel);this.panel&&this.panel.view.content.element.parentElement===this._element&&(this._element.removeChild(this.panel.view.content.element),(s=(i=this.panel.view.content).onHide)===null||s===void 0||s.call(i)),this.panel=e;let d;switch(e.api.renderer){case"onlyWhenVisible":this.group.renderContainer.detatch(e),this.panel&&l&&(this._element.appendChild(this.panel.view.content.element),(r=(o=this.panel.view.content).onShow)===null||r===void 0||r.call(o)),d=this._element;break;case"always":e.view.content.element.parentElement===this._element&&this._element.removeChild(e.view.content.element),d=this.group.renderContainer.attach({panel:e,referenceContainer:this});break;default:throw new Error(`dockview: invalid renderer type '${e.api.renderer}'`)}if(l){const c=ml(d);this.focusTracker=c;const h=new X;h.addDisposables(c,c.onDidFocus(()=>this._onDidFocus.fire()),c.onDidBlur(()=>this._onDidBlur.fire())),this.disposable.value=h}}openPanel(e){this.panel!==e&&this.renderPanel(e)}layout(e,t){}closePanel(){var e,t,i;this.panel&&this.panel.api.renderer==="onlyWhenVisible"&&((e=this.panel.view.content.element.parentElement)===null||e===void 0||e.removeChild(this.panel.view.content.element),(i=(t=this.panel.view.content).onHide)===null||i===void 0||i.call(t)),this.panel=void 0}dispose(){this.disposable.dispose(),super.dispose()}refreshFocusState(){var e;!((e=this.focusTracker)===null||e===void 0)&&e.refreshState&&this.focusTracker.refreshState()}}const nm=500,sm=8;class Lo extends X{constructor(e,t){super(),this.element=e,this.options=t,this._startX=0,this._startY=0,this.addDisposables(U(this.element,"pointerdown",i=>{this._onPointerDown(i)}))}_onPointerDown(e){var t,i,s,o,r;if(((t=this.options.touchOnly)!==null&&t!==void 0?t:!0)&&e.pointerType!=="touch"&&e.pointerType!=="pen")return;this._cancelPending(),this._pointerId=e.pointerId,this._startX=e.clientX,this._startY=e.clientY;const d=(i=this.options.delay)!==null&&i!==void 0?i:nm,c=(s=this.options.tolerance)!==null&&s!==void 0?s:sm,h=(r=(o=this.element.ownerDocument)===null||o===void 0?void 0:o.defaultView)!==null&&r!==void 0?r:window;this._timer=setTimeout(()=>{this._timer=void 0,this._cancelPending(),this._installContextMenuGuard(h),this._installClickGuard(h),this.options.onLongPress(e)},d),this._moveListener=U(h,"pointermove",u=>{if(u.pointerId!==this._pointerId)return;const m=u.clientX-this._startX,g=u.clientY-this._startY;Math.hypot(m,g)>c&&this._cancelPending()}),this._upListener=U(h,"pointerup",u=>{u.pointerId===this._pointerId&&this._cancelPending()}),this._cancelListener=U(h,"pointercancel",u=>{u.pointerId===this._pointerId&&this._cancelPending()})}_installContextMenuGuard(e){let t;const i=setTimeout(()=>t?.dispose(),500);t=U(e,"contextmenu",s=>{s.preventDefault(),clearTimeout(i),t?.dispose()},{capture:!0})}_installClickGuard(e){let t;const i=setTimeout(()=>t?.dispose(),500);t=U(e,"click",s=>{const o=s.target;o&&this.element.contains(o)&&(s.preventDefault(),s.stopPropagation()),clearTimeout(i),t?.dispose()},{capture:!0})}_cancelPending(){var e,t,i;this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0),this._pointerId=void 0,(e=this._moveListener)===null||e===void 0||e.dispose(),(t=this._upListener)===null||t===void 0||t.dispose(),(i=this._cancelListener)===null||i===void 0||i.dispose(),this._moveListener=void 0,this._upListener=void 0,this._cancelListener=void 0}dispose(){this._cancelPending(),super.dispose()}}function Ft(n){if(n.disableDnd)return{html5:!1,pointer:!1,pointerHandlesMouse:!1};switch(n.dndStrategy){case"pointer":return{html5:!1,pointer:!0,pointerHandlesMouse:!0};case"html5":return{html5:!0,pointer:!1,pointerHandlesMouse:!1};default:return om()?{html5:!1,pointer:!0,pointerHandlesMouse:!0}:{html5:!0,pointer:!0,pointerHandlesMouse:!1}}}function om(){if(typeof window>"u"||!window.matchMedia)return!1;const n=window.matchMedia("(pointer: coarse)").matches,e=window.matchMedia("(pointer: fine)").matches;return n&&!e}let am=0;const rm=()=>`dv-tab-${am++}`;class lm extends X{get element(){return this._element}constructor(e,t,i){var s,o;super(),this.panel=e,this.accessor=t,this.group=i,this.content=void 0,this.panelTransfer=Gt.getInstance(),this._direction="horizontal",this._onPointDown=new z,this.onPointerDown=this._onPointDown.event,this._onTabClick=new z,this.onTabClick=this._onTabClick.event,this._onDropped=new z,this.onDrop=this._onDropped.event,this._onDragStart=new z,this.onDragStart=this._onDragStart.event,this._onDragEnd=new z,this.onDragEnd=this._onDragEnd.event;const r=Ft(this.accessor.options);this._element=document.createElement("div"),this._element.className="dv-tab",this._element.tabIndex=-1,this._element.draggable=r.html5,this._element.id=rm(),this._element.setAttribute("role","tab"),this._element.setAttribute("aria-selected","false");const l=(o=(s=this.group)===null||s===void 0?void 0:s.model)===null||o===void 0?void 0:o.contentContainerId;l&&this._element.setAttribute("aria-controls",l),W(this.element,"dv-inactive-tab",!0);const d=(h,u)=>{var m;if(this.group.locked)return!1;const g=Ae();return g&&this.accessor.id===g.viewId?((m=this.accessor.options.theme)===null||m===void 0?void 0:m.tabAnimation)!=="smooth":this.group.model.canDisplayOverlay(h,u,"tab")};this.dropTarget=pi.createDropTarget(this._element,{acceptedTargetZones:["left","right"],overlayModel:this._buildOverlayModel(),canDisplayOverlay:d,getOverrideTarget:()=>{var h;return(h=i.model.dropTargetContainer)===null||h===void 0?void 0:h.model}}),this.pointerDropTarget=si.createDropTarget(this._element,{acceptedTargetZones:["left","right"],overlayModel:this._buildOverlayModel(),canDisplayOverlay:d,getOverrideTarget:()=>{var h;return(h=i.model.dropTargetContainer)===null||h===void 0?void 0:h.model}});const c={getData:()=>(this.panelTransfer.setData([new _t(this.accessor.id,this.group.id,this.panel.id)],_t.prototype),{dispose:()=>{this.panelTransfer.clearData(_t.prototype)}}),createGhost:()=>({element:this._buildGhostElement(),offsetX:30,offsetY:-10}),onDragStart:h=>{var u;this._onDragStart.fire(h),!(h instanceof PointerEvent)&&((u=this.accessor.options.theme)===null||u===void 0?void 0:u.tabAnimation)==="smooth"&&requestAnimationFrame(()=>{W(this.element,"dv-tab--dragging",!0)})},onDragEnd:h=>{this._onDragEnd.fire(h)}};this.html5DragSource=pi.createDragSource(this._element,Object.assign(Object.assign({},c),{disabled:!r.html5})),this.pointerDragSource=si.createDragSource(this._element,Object.assign(Object.assign({},c),{disabled:!r.pointer,touchOnly:!r.pointerHandlesMouse,isCancelled:()=>!Ft(this.accessor.options).pointer})),this.onWillShowOverlay=wt.any(this.dropTarget.onWillShowOverlay,this.pointerDropTarget.onWillShowOverlay),this.addDisposables(this._onPointDown,this._onTabClick,this._onDropped,this._onDragStart,this._onDragEnd,this.accessor.onDidOptionsChange(()=>{const h=this._buildOverlayModel();this.dropTarget.setOverlayModel(h),this.pointerDropTarget.setOverlayModel(h)}),U(this._element,"dragend",()=>{W(this.element,"dv-tab--dragging",!1)}),this.html5DragSource,U(this._element,"pointerdown",h=>{this._onPointDown.fire(h)}),U(this._element,"click",h=>{this._onTabClick.fire(h)}),U(this._element,"contextmenu",h=>{var u;(u=this.accessor.contextMenuService)===null||u===void 0||u.show(this.panel,this.group,h)}),new Lo(this._element,{onLongPress:h=>{var u;this.pointerDragSource.cancelPending(),(u=this.accessor.contextMenuService)===null||u===void 0||u.show(this.panel,this.group,h)}}),this.dropTarget.onDrop(h=>{this._onDropped.fire(h)}),this.pointerDropTarget.onDrop(h=>{this._onDropped.fire(h)}),this.dropTarget,this.pointerDropTarget,this.pointerDragSource)}setActive(e){W(this.element,"dv-active-tab",e),W(this.element,"dv-inactive-tab",!e),this._element.setAttribute("aria-selected",e?"true":"false"),this._element.tabIndex=e?0:-1}setContent(e){this.content&&this._element.removeChild(this.content.element),this.content=e,this._element.appendChild(this.content.element)}_buildOverlayModel(){var e,t,i;const s=(t=(e=this.accessor).resolveDropOverlayModel)===null||t===void 0?void 0:t.call(e,"tab",this.group);if(s)return s;const o=((i=this.accessor.options.theme)===null||i===void 0?void 0:i.dndTabIndicator)==="line"?Number.POSITIVE_INFINITY:0;return{activationSize:{value:50,type:"percentage"},smallWidthBoundary:o,smallHeightBoundary:o}}setDirection(e){this._direction=e;const t=e==="vertical"?["top","bottom"]:["left","right"];this.dropTarget.setTargetZones(t),this.pointerDropTarget.setTargetZones(t)}updateDragAndDropState(){const e=Ft(this.accessor.options);this._element.draggable=e.html5,this.html5DragSource.setDisabled(!e.html5),this.pointerDragSource.setDisabled(!e.pointer),this.pointerDragSource.setTouchOnly(!e.pointerHandlesMouse)}_buildGhostElement(){const e=getComputedStyle(this.element),t=this.element.cloneNode(!0),i=this._direction==="vertical",s=new Set(["writing-mode","inline-size","block-size","min-inline-size","min-block-size","max-inline-size","max-block-size","margin-inline","margin-inline-start","margin-inline-end","margin-block","margin-block-start","margin-block-end","padding-inline","padding-inline-start","padding-inline-end","padding-block","padding-block-start","padding-block-end"]);return Array.from(e).forEach(o=>{i&&s.has(o)||t.style.setProperty(o,e.getPropertyValue(o),e.getPropertyPriority(o))}),i&&(t.style.setProperty("writing-mode","horizontal-tb"),t.style.setProperty("width",e.height),t.style.setProperty("height",e.width)),t.style.position="absolute",t.classList.add("dv-tab-ghost-drag"),t}}class zn{get kind(){return this.options.kind}get nativeEvent(){return this.event.nativeEvent}get position(){return this.event.position}get defaultPrevented(){return this.event.defaultPrevented}get panel(){return this.options.panel}get api(){return this.options.api}get group(){return this.options.group}preventDefault(){this.event.preventDefault()}getData(){return this.options.getData()}constructor(e,t){this.event=e,this.options=t}}const dm=500;class Ol extends X{get group(){return this.groupAccessor()}constructor(e){var t,i,s;super(),this.panelTransfer=Gt.getInstance(),this._onDragStart=new z,this.onDragStart=this._onDragStart.event,this._element=e.element,this.accessor=e.accessor;const o=e.group;this.groupAccessor=typeof o=="function"?o:()=>o,this.isFloatingMoveHandle=(t=e.isFloatingMoveHandle)!==null&&t!==void 0?t:(()=>!0);const r=Ft(this.accessor.options);this._element.draggable=r.html5,W(this._element,"dv-draggable",r.html5||r.pointer),this.addDisposables(this._onDragStart);const l=()=>{const p=document.createElement("div"),f=window.getComputedStyle(this._element),w=f.getPropertyValue("--dv-activegroup-visiblepanel-tab-background-color"),C=f.getPropertyValue("--dv-activegroup-visiblepanel-tab-color");return p.style.backgroundColor=w,p.style.color=C,p.style.padding="2px 8px",p.style.height="24px",p.style.fontSize="11px",p.style.lineHeight="20px",p.style.borderRadius="12px",p.style.whiteSpace="nowrap",p.style.boxSizing="border-box",p.style.display="inline-block",p.textContent=`Multiple Panels (${this.group.size})`,p},c={getData:()=>(this.panelTransfer.setData([new _t(this.accessor.id,this.group.id,null)],_t.prototype),{dispose:()=>{this.panelTransfer.clearData(_t.prototype)}}),createGhost:()=>{var p,f;const w=(f=(p=this.accessor).buildGroupDragGhost)===null||f===void 0?void 0:f.call(p,this.group);return w||{element:l(),offsetX:30,offsetY:-10}},onDragStart:p=>{this._onDragStart.fire(p)}};this.html5DragSource=pi.createDragSource(this._element,Object.assign(Object.assign({},c),{disabled:!r.html5,isCancelled:p=>!!(this.group.api.location.type==="floating"&&this.isFloatingMoveHandle()&&!p.shiftKey||this.group.api.location.type==="edge"&&this.group.size===0)}));const h=()=>{var p,f,w;return((w=(f=(p=this.group)===null||p===void 0?void 0:p.api)===null||f===void 0?void 0:f.location)===null||w===void 0?void 0:w.type)==="floating"&&this.isFloatingMoveHandle()};this.pointerDragSource=si.createDragSource(this._element,Object.assign(Object.assign({},c),{disabled:!r.pointer,touchOnly:!r.pointerHandlesMouse,touchInitiationDelay:()=>h()?dm:250,pressTolerance:()=>h()?1/0:8,isCancelled:()=>!Ft(this.accessor.options).pointer||this.group.api.location.type==="edge"&&this.group.size===0,onDragStart:p=>{var f;(f=this.getFloatingOverlay())===null||f===void 0||f.cancelPendingDrag(),this._onDragStart.fire(p)}}));const u=new $e,m=()=>{const p=this.getFloatingOverlay();u.value=p?p.onDidStartMoving(()=>{this.pointerDragSource.cancelPending()}):ke.NONE};m(),this.addDisposables(u);const g=(s=(i=this.group)===null||i===void 0?void 0:i.api)===null||s===void 0?void 0:s.onDidLocationChange;g&&this.addDisposables(g(m)),this.addDisposables(this.html5DragSource,this.pointerDragSource)}updateDragAndDropState(){const e=Ft(this.accessor.options);this._element.draggable=e.html5,W(this._element,"dv-draggable",e.html5||e.pointer),this.html5DragSource.setDisabled(!e.html5),this.pointerDragSource.setDisabled(!e.pointer),this.pointerDragSource.setTouchOnly(!e.pointerHandlesMouse)}getFloatingOverlay(){var e,t;if(this.group)return(t=(e=this.accessor.floatingGroups)===null||e===void 0?void 0:e.find(i=>i.group===this.group))===null||t===void 0?void 0:t.overlay}}class cm extends X{get element(){return this._element}constructor(e,t){var i,s,o,r,l,d,c;super(),this.accessor=e,this.group=t,this._onDrop=new z,this.onDrop=this._onDrop.event,this._onDragStart=new z,this.onDragStart=this._onDragStart.event,this._element=document.createElement("div"),this._element.className="dv-void-container",this.addDisposables(this._onDrop,this._onDragStart,U(this._element,"pointerdown",()=>{this.accessor.doSetGroupActive(this.group)}),U(this._element,"pointerdown",u=>{u.shiftKey&&gl(u)},!0)),this.dragSource=new Ol({element:this._element,accessor:this.accessor,group:this.group,isFloatingMoveHandle:()=>!this._element.closest(".dv-resize-container-with-titlebar")});const h=(u,m)=>{if(this.group.api.locked)return!1;const g=Ae();return g&&this.accessor.id===g.viewId?!0:t.model.canDisplayOverlay(u,m,"header_space")};this.dropTarget=pi.createDropTarget(this._element,{acceptedTargetZones:["center"],canDisplayOverlay:h,getOverrideTarget:()=>{var u;return(u=t.model.dropTargetContainer)===null||u===void 0?void 0:u.model},overlayModel:(s=(i=this.accessor).resolveDropOverlayModel)===null||s===void 0?void 0:s.call(i,"header_space",this.group)}),this.pointerDropTarget=si.createDropTarget(this._element,{acceptedTargetZones:["center"],canDisplayOverlay:h,getOverrideTarget:()=>{var u;return(u=t.model.dropTargetContainer)===null||u===void 0?void 0:u.model},overlayModel:(r=(o=this.accessor).resolveDropOverlayModel)===null||r===void 0?void 0:r.call(o,"header_space",this.group)}),this.onWillShowOverlay=wt.any(this.dropTarget.onWillShowOverlay,this.pointerDropTarget.onWillShowOverlay),this.addDisposables(this.dragSource,this.dragSource.onDragStart(u=>{this._onDragStart.fire(u)}),this.dropTarget.onDrop(u=>{this._onDrop.fire(u)}),this.pointerDropTarget.onDrop(u=>{this._onDrop.fire(u)}),this.dropTarget,this.pointerDropTarget,(c=(d=(l=this.accessor).onDidOptionsChange)===null||d===void 0?void 0:d.call(l,()=>{var u,m,g;const p=(g=(m=(u=this.accessor).resolveDropOverlayModel)===null||m===void 0?void 0:m.call(u,"header_space",this.group))!==null&&g!==void 0?g:{};this.dropTarget.setOverlayModel(p),this.pointerDropTarget.setOverlayModel(p)}))!==null&&c!==void 0?c:ke.NONE)}updateDragAndDropState(){this.dragSource.updateDragAndDropState()}}class Ds extends X{get element(){return this._element}get orientation(){return this._orientation}set orientation(e){this._orientation!==e&&(this._scrollOffset=0,this._orientation=e,It(this._scrollbar,"dv-scrollbar-vertical","dv-scrollbar-horizontal"),e==="vertical"?At(this._scrollbar,"dv-scrollbar-vertical"):At(this._scrollbar,"dv-scrollbar-horizontal"))}constructor(e){super(),this.scrollableElement=e,this._scrollOffset=0,this._orientation="horizontal",this._element=document.createElement("div"),this._element.className="dv-scrollable",this._scrollbar=document.createElement("div"),this._scrollbar.className="dv-scrollbar dv-scrollbar-horizontal",this.element.appendChild(e),this.element.appendChild(this._scrollbar),this.addDisposables(U(this.element,"wheel",t=>{this._scrollOffset+=t.deltaY*Ds.MouseWheelSpeed,this.calculateScrollbarStyles()}),U(this._scrollbar,"pointerdown",t=>{t.preventDefault(),W(this.element,"dv-scrollable-scrolling",!0);const i=this._orientation==="horizontal"?t.clientX:t.clientY,s=this._scrollOffset,o=l=>{const d=this._orientation==="horizontal"?l.clientX-i:l.clientY-i,c=this._orientation==="horizontal"?this.element.clientWidth:this.element.clientHeight,h=this._orientation==="horizontal"?this.scrollableElement.scrollWidth:this.scrollableElement.scrollHeight,u=c/h;this._scrollOffset=s+d/u,this.calculateScrollbarStyles()},r=()=>{W(this.element,"dv-scrollable-scrolling",!1),document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",r),document.removeEventListener("pointercancel",r)};document.addEventListener("pointermove",o),document.addEventListener("pointerup",r),document.addEventListener("pointercancel",r)}),U(this.element,"scroll",()=>{this.calculateScrollbarStyles()}),U(this.scrollableElement,"scroll",()=>{this._scrollOffset=this._orientation==="horizontal"?this.scrollableElement.scrollLeft:this.scrollableElement.scrollTop,this.calculateScrollbarStyles()}),Gn(this.element,()=>{W(this.element,"dv-scrollable-resizing",!0),this._animationTimer&&clearTimeout(this._animationTimer),this._animationTimer=setTimeout(()=>{clearTimeout(this._animationTimer),W(this.element,"dv-scrollable-resizing",!1)},500),this.calculateScrollbarStyles()}))}calculateScrollbarStyles(){const e=this._orientation==="horizontal"?this.element.clientWidth:this.element.clientHeight,t=this._orientation==="horizontal"?this.scrollableElement.scrollWidth:this.scrollableElement.scrollHeight;if(t>e){const s=e*(e/t);this._orientation==="horizontal"?(this._scrollbar.style.width=`${s}px`,this._scrollbar.style.height=""):(this._scrollbar.style.height=`${s}px`,this._scrollbar.style.width=""),this._scrollOffset=Ee(this._scrollOffset,0,t-e),this._orientation==="horizontal"?this.scrollableElement.scrollLeft=this._scrollOffset:this.scrollableElement.scrollTop=this._scrollOffset;const o=this._scrollOffset/(t-e);this._orientation==="horizontal"?(this._scrollbar.style.left=`${(e-s)*o}px`,this._scrollbar.style.top=""):(this._scrollbar.style.top=`${(e-s)*o}px`,this._scrollbar.style.left="")}else this._orientation==="horizontal"?(this._scrollbar.style.width="0px",this._scrollbar.style.left="0px"):(this._scrollbar.style.height="0px",this._scrollbar.style.top="0px"),this._scrollOffset=0}}Ds.MouseWheelSpeed=1;const Ro=[{id:"grey",value:"var(--dv-tab-group-color-grey)",label:"Grey"},{id:"blue",value:"var(--dv-tab-group-color-blue)",label:"Blue"},{id:"red",value:"var(--dv-tab-group-color-red)",label:"Red"},{id:"yellow",value:"var(--dv-tab-group-color-yellow)",label:"Yellow"},{id:"green",value:"var(--dv-tab-group-color-green)",label:"Green"},{id:"pink",value:"var(--dv-tab-group-color-pink)",label:"Pink"},{id:"purple",value:"var(--dv-tab-group-color-purple)",label:"Purple"},{id:"cyan",value:"var(--dv-tab-group-color-cyan)",label:"Cyan"},{id:"orange",value:"var(--dv-tab-group-color-orange)",label:"Orange"}];class Ml{constructor(e,t=!0){this._entries=e.slice(),this._byId=new Map(e.map(i=>[i.id,i])),this._enabled=t}get enabled(){return this._enabled}set enabled(e){this._enabled=e}setEntries(e){this._entries=e.slice(),this._byId=new Map(e.map(t=>[t.id,t]))}entries(){return this._entries}has(e){return this._byId.has(e)}get(e){return this._byId.get(e)}defaultId(){var e;return(e=this._entries[0])===null||e===void 0?void 0:e.id}resolveValue(e){if(!this._enabled||!e)return;const t=this._byId.get(e);return t?t.value:e}}let Ws;function Ll(){return Ws||(Ws=new Ml(Ro,!0)),Ws}function Vo(n,e,t){const i=(t??Ll()).resolveValue(e);i===void 0?n.style.removeProperty("--dv-tab-group-color"):n.style.setProperty("--dv-tab-group-color",i)}function Rl(n,e){return(e??Ll()).resolveValue(n)}class Pa extends X{get element(){return this._element}constructor(e){super(),this._palette=e,this._onClick=new z,this.onClick=this._onClick.event,this._onContextMenu=new z,this.onContextMenu=this._onContextMenu.event,this._element=document.createElement("div"),this._element.className="dv-tab-group-chip",this._element.tabIndex=0,this._label=document.createElement("span"),this._label.className="dv-tab-group-chip-label",this._element.appendChild(this._label),this.addDisposables(this._onClick,this._onContextMenu,new Lo(this._element,{onLongPress:t=>{this._onContextMenu.fire(t)}}),U(this._element,"click",t=>{this._onClick.fire(t)}),U(this._element,"contextmenu",t=>{this._onContextMenu.fire(t)}))}init(e){this._tabGroup=e.tabGroup,this.updateColor(e.tabGroup.color),this.updateLabel(e.tabGroup.label),this.updateCollapsed(e.tabGroup.collapsed),this.addDisposables(e.tabGroup.onDidChange(()=>{this._tabGroup&&(this.updateColor(this._tabGroup.color),this.updateLabel(this._tabGroup.label))}),e.tabGroup.onDidCollapseChange(t=>{this.updateCollapsed(t)}),this._onClick.event(()=>{var t;(t=this._tabGroup)===null||t===void 0||t.toggle()}))}update(e){this._tabGroup=e.tabGroup,this.updateColor(e.tabGroup.color),this.updateLabel(e.tabGroup.label),this.updateCollapsed(e.tabGroup.collapsed)}updateColor(e){var t;Vo(this._element,e,this._palette),W(this._element,"dv-tab-group-chip--accent-off",((t=this._palette)===null||t===void 0?void 0:t.enabled)===!1)}updateLabel(e){this._label.textContent=e,W(this._label,"dv-tab-group-chip-label--empty",!e)}updateCollapsed(e){W(this._element,"dv-tab-group-chip--collapsed",e)}}class Vl{get underlines(){return this._underlines}constructor(e){this._ctx=e,this._underlines=new Map,this._rafId=null}positionUnderlines(){requestAnimationFrame(()=>{this._positionUnderlinesSync()})}trackUnderlines(){this._rafId!==null&&cancelAnimationFrame(this._rafId);const e=performance.now(),t=250,i=()=>{this._positionUnderlinesSync(),performance.now()-e<t?this._rafId=requestAnimationFrame(i):this._rafId=null};this._rafId=requestAnimationFrame(i)}syncUnderlineElements(e){for(const t of e)if(!this._underlines.has(t)){const i=document.createElement("div");i.className="dv-tab-group-underline",this._ctx.tabsList.appendChild(i),this._underlines.set(t,i)}for(const[t,i]of this._underlines)e.has(t)||(i.remove(),this._underlines.delete(t))}getUnderline(e){return this._underlines.get(e)}dispose(){this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null);for(const[,e]of this._underlines)e.remove();this._underlines.clear()}_positionUnderlinesSync(){const e=this._ctx.tabsList.getBoundingClientRect(),t=this._ctx.getTabGroups(),i=this._ctx.getDirection()==="vertical",s=i?e.width:e.height,o=this._ctx.getActivePanelId(),r=this._ctx.getTabMap();for(const l of t){const d=this._underlines.get(l.id);if(!d)continue;const c=l.panelIds;if(c.length===0){d.style.display="none";continue}d.style.display="";const h=this._ctx.getChipElement(l.id);let u;if(h){const b=h.getBoundingClientRect(),D=getComputedStyle(h),k=i?Number.parseFloat(D.marginTop)||0:Number.parseFloat(D.marginLeft)||0;u=i?b.top-e.top-k:b.left-e.left-k}else{const b=c[0],D=r.get(b);if(D){const k=D.value.element.getBoundingClientRect();u=i?k.top-e.top:k.left-e.left}else u=0}const m=c[c.length-1],g=r.get(m);if(!g){i?(d.style.top=`${u}px`,d.style.height="0px",d.style.left="",d.style.width=""):(d.style.left=`${u}px`,d.style.width="0px",d.style.top="",d.style.height="");continue}const p=g.value.element.getBoundingClientRect();let f=i?p.bottom-e.top:p.right-e.left,w=f-u;if((l.collapsed||l.panelIds.some(b=>{const D=r.get(b);return D&&D.value.element.classList.contains("dv-tab--group-expanding")}))&&h){const b=h.getBoundingClientRect(),D=i?b.top+b.height/2-e.top:b.left+b.width/2-e.left;let k=0,P=0;for(const T of l.panelIds){const S=r.get(T);if(!S)continue;const N=S.value.element;i?(k+=N.getBoundingClientRect().height,P+=N.scrollHeight):(k+=N.getBoundingClientRect().width,P+=N.scrollWidth)}const y=P>0?Math.min(1,k/P):0;u=D+(u-D)*y,f=D+(f-D)*y,w=Math.max(0,f-u)}i?(d.style.top=`${u}px`,d.style.height=`${Math.max(0,w)}px`,d.style.left="",d.style.width=""):(d.style.left=`${u}px`,d.style.width=`${Math.max(0,w)}px`,d.style.top="",d.style.height=""),this.applyShape(d,l,u,w,s,o,e,i)}}}class hm extends Vl{_applyStraightLine(e,t,i,s,o,r){r?(e.setAttribute("width",String(s)),e.setAttribute("height",String(o)),i.style.width=`${s}px`,i.style.height=`${o}px`,t.setAttribute("d",`M ${s/2},0 L ${s/2},${o}`)):(e.setAttribute("width",String(o)),e.setAttribute("height",String(s)),i.style.width=`${o}px`,i.style.height=`${s}px`,t.setAttribute("d",`M 0,${s/2} L ${o},${s/2}`))}applyShape(e,t,i,s,o,r,l,d){const h=o,u=s,m=Rl(t.color,this._ctx.getColorPalette());if(u<=0||h<=0||m===void 0){e.style.display="none";return}e.style.display="";let g;r&&t.panelIds.includes(r)&&(g=this._ctx.getTabMap().get(r));let p=e.firstElementChild,f;if(!p||p.tagName!=="svg"?(e.replaceChildren(),p=document.createElementNS("http://www.w3.org/2000/svg","svg"),p.style.display="block",f=document.createElementNS("http://www.w3.org/2000/svg","path"),f.setAttribute("fill","none"),p.appendChild(f),e.appendChild(p)):f=p.firstElementChild,f.setAttribute("stroke",m),f.setAttribute("stroke-width",String(2)),!g){this._applyStraightLine(p,f,e,2,u,d);return}const w=g.value.element.getBoundingClientRect();let C,b;if(d?(C=Math.max(0,w.top-l.top-i),b=Math.min(u,w.bottom-l.top-i)):(C=Math.max(0,w.left-l.left-i),b=Math.min(u,w.right-l.left-i)),b<=C){this._applyStraightLine(p,f,e,2,u,d);return}const D=6,k=2/2,P=this._ctx.getHeaderPosition();if(d){const y=h,T=u;p.setAttribute("width",String(y)),p.setAttribute("height",String(T)),e.style.width=`${y}px`,e.style.height=`${T}px`;const S=P==="right",N=S?y-k:k,O=S?k:y-k,$=S?-1:1,F=[`M ${N},0`,`L ${N},${C-D}`,`Q ${N},${C} ${N+$*D},${C}`,`L ${O-$*D},${C}`,`Q ${O},${C} ${O},${C+D}`,`L ${O},${b-D}`,`Q ${O},${b} ${O-$*D},${b}`,`L ${N+$*D},${b}`,`Q ${N},${b} ${N},${b+D}`,`L ${N},${T}`].join(" ");f.setAttribute("d",F)}else{const y=u,T=h;p.setAttribute("width",String(y)),p.setAttribute("height",String(T)),e.style.width=`${y}px`,e.style.height=`${T}px`;const S=P==="bottom",N=S?k:T-k,O=S?T-k:k,$=S?1:-1,F=[`M 0,${N}`,`L ${C-D},${N}`,`Q ${C},${N} ${C},${N+$*D}`,`L ${C},${O-$*D}`,`Q ${C},${O} ${C+D},${O}`,`L ${b-D},${O}`,`Q ${b},${O} ${b},${O-$*D}`,`L ${b},${N+$*D}`,`Q ${b},${N} ${b+D},${N}`,`L ${y},${N}`].join(" ");f.setAttribute("d",F)}}}class um extends Vl{applyShape(e,t,i,s,o,r,l,d){const h=Rl(t.color,this._ctx.getColorPalette());if(s<=0||h===void 0){e.style.display="none";return}e.style.display="",e.firstElementChild&&e.replaceChildren(),e.style.backgroundColor=h,d?(e.style.width="2px",e.style.height=`${s}px`):(e.style.width=`${s}px`,e.style.height="2px")}}const pm=new Map;class mm{get chipRenderers(){return this._chipRenderers}get groupUnderlines(){var e,t;return(t=(e=this._indicator)===null||e===void 0?void 0:e.underlines)!==null&&t!==void 0?t:pm}get skipNextCollapseAnimation(){return this._skipNextCollapseAnimation}set skipNextCollapseAnimation(e){this._skipNextCollapseAnimation=e}constructor(e,t){this._ctx=e,this._callbacks=t,this._chipRenderers=new Map,this._indicator=null,this._skipNextCollapseAnimation=!1,this._pendingTransitionCleanups=new Map}update(){const t=this._ctx.group.model.getTabGroups(),i=new Set;for(const s of t)i.add(s.id),this._ensureChipForGroup(s),this._positionChipForGroup(s);for(const[s,o]of this._chipRenderers)i.has(s)||(o.chip.element.remove(),o.chip.dispose(),o.disposable.dispose(),this._chipRenderers.delete(s));this._updateTabGroupClasses()}refreshAccents(){var e,t;for(const i of this._ctx.group.model.getTabGroups()){const s=this._chipRenderers.get(i.id);(t=s==null?void 0:(e=s.chip).update)===null||t===void 0||t.call(e,{tabGroup:i})}this._updateTabGroupClasses()}positionAllChips(){if(this._chipRenderers.size!==0)for(const e of this._ctx.group.model.getTabGroups())this._positionChipForGroup(e)}updateDirection(){const e=this._ctx.getDirection()==="vertical";for(const[,t]of this._chipRenderers)t.dropTarget.setTargetZones(e?["top"]:["left"])}snapshotChipWidths(){const e=new Map;for(const[t,i]of this._chipRenderers)e.set(t,i.chip.element.getBoundingClientRect().width);return e}positionUnderlines(){var e;(e=this._indicator)===null||e===void 0||e.positionUnderlines()}trackUnderlines(){var e;(e=this._indicator)===null||e===void 0||e.trackUnderlines()}setGroupDragImage(e,t,i){if(!e.dataTransfer)return;const s=this._ctx.getDirection()==="vertical",o=this._ctx.tabsList.cloneNode(!0);s?(o.classList.remove("dv-tabs-container-vertical","dv-vertical"),o.classList.add("dv-horizontal"),o.style.writingMode="horizontal-tb",o.style.height=`${this._ctx.tabsList.offsetWidth}px`):o.style.height=`${this._ctx.tabsList.offsetHeight}px`,o.style.width="auto",o.style.overflow="visible",o.style.pointerEvents="none";const r=Array.from(o.children),l=Array.from(this._ctx.tabsList.children);for(let p=r.length-1;p>=0;p--)l[p]!==i&&r[p].remove();const d=document.createElement("div");d.className="dv-groupview dv-active-group",d.style.position="fixed",d.style.top="-10000px",d.style.left="0px",d.style.height="auto",d.style.width="auto",d.style.pointerEvents="none";const c=document.createElement("div");c.className="dv-tabs-and-actions-container",c.style.height="auto",c.style.width="auto",d.appendChild(c),c.appendChild(o),this._ctx.accessor.element.appendChild(d);const h=o.querySelector(".dv-tab-group-chip"),u=i.getBoundingClientRect(),m=e.clientX-u.left,g=e.clientY-u.top;if(h){const p=h.getBoundingClientRect(),f=d.getBoundingClientRect(),w=p.left-f.left+m,C=p.top-f.top+g;e.dataTransfer.setDragImage(d,w,C)}else e.dataTransfer.setDragImage(d,m,g);requestAnimationFrame(()=>{d.remove()})}cleanupTransition(e){var t;(t=this._pendingTransitionCleanups.get(e))===null||t===void 0||t(),this._pendingTransitionCleanups.delete(e)}updateDragAndDropState(){const e=Ft(this._ctx.accessor.options);for(const t of this._chipRenderers.values())t.chip.element.draggable=e.html5,t.html5DragSource.setDisabled(!e.html5),t.pointerDragSource.setDisabled(!e.pointer),t.pointerDragSource.setTouchOnly(!e.pointerHandlesMouse)}disposeChipDrag(e){var t,i;const s=this._chipRenderers.get(e);s&&((t=s.html5DragSource)===null||t===void 0||t.dispose(),(i=s.pointerDragSource)===null||i===void 0||i.dispose())}_buildChipGhostElement(e){const t=getComputedStyle(e),i=e.cloneNode(!0);return Array.from(t).forEach(s=>{i.style.setProperty(s,t.getPropertyValue(s),t.getPropertyPriority(s))}),i.style.position="absolute",i}disposeAll(){var e;(e=this._indicator)===null||e===void 0||e.dispose(),this._indicator=null;for(const[,t]of this._pendingTransitionCleanups)t();this._pendingTransitionCleanups.clear();for(const[,t]of this._chipRenderers)t.chip.element.remove(),t.chip.dispose(),t.disposable.dispose();this._chipRenderers.clear()}_ensureIndicator(){var e,t;const s=((t=(e=this._ctx.accessor.options.theme)===null||e===void 0?void 0:e.tabGroupIndicator)!==null&&t!==void 0?t:"wrap")==="none"?um:hm;this._indicator&&!(this._indicator instanceof s)&&(this._indicator.dispose(),this._indicator=null),this._indicator||(this._indicator=new s({tabsList:this._ctx.tabsList,getTabGroups:()=>this._ctx.group.model.getTabGroups(),getActivePanelId:()=>{var o;return(o=this._ctx.group.activePanel)===null||o===void 0?void 0:o.id},getTabMap:()=>this._ctx.getTabMap(),getChipElement:o=>{var r;return(r=this._chipRenderers.get(o))===null||r===void 0?void 0:r.chip.element},getDirection:()=>this._ctx.getDirection(),getHeaderPosition:()=>this._ctx.group.model.headerPosition,getColorPalette:()=>this._ctx.accessor.tabGroupColorPalette}))}_ensureChipForGroup(e){if(this._chipRenderers.has(e.id))return;const t=this._ctx.accessor.options.createTabGroupChipComponent,i=t?t(e):new Pa(this._ctx.accessor.tabGroupColorPalette);i.init({tabGroup:e,api:this._ctx.accessor.api});const s=Ft(this._ctx.accessor.options);i.element.draggable=s.html5;const o=Gt.getInstance(),r=()=>(o.setData([new _t(this._ctx.accessor.id,this._ctx.group.id,null,e.id)],_t.prototype),{dispose:()=>{o.clearData(_t.prototype)}}),l=pi.createDragSource(i.element,{getData:r,disabled:!s.html5,isCancelled:()=>!Ft(this._ctx.accessor.options).html5,onDragStart:p=>{"dataTransfer"in p&&p.dataTransfer&&this.setGroupDragImage(p,e,i.element),this._callbacks.onChipDragStart(e,i,p)},onDragEnd:p=>{var f,w;(w=(f=this._callbacks).onChipDragEnd)===null||w===void 0||w.call(f,e,i,p)}});i.element.addEventListener("dragend",()=>{o.clearData(_t.prototype)},{once:!0});const d=si.createDragSource(i.element,{getData:r,disabled:!s.pointer,touchOnly:!s.pointerHandlesMouse,isCancelled:()=>!Ft(this._ctx.accessor.options).pointer,createGhost:()=>({element:this._buildChipGhostElement(i.element),offsetX:8,offsetY:8}),onDragStart:p=>{this._callbacks.onChipDragStart(e,i,p)}}),c=[e.onDidChange(()=>{var p;(p=i.update)===null||p===void 0||p.call(i,{tabGroup:e}),this._updateTabGroupClasses()}),e.onDidPanelChange(()=>{this._positionChipForGroup(e),this._updateTabGroupClasses()}),e.onDidCollapseChange(()=>{this._updateTabGroupClasses()}),l,d],h=p=>{d.cancelPending(),this._callbacks.onChipContextMenu(e,p)};i instanceof Pa?c.push(i.onContextMenu(h)):c.push(new Lo(i.element,{onLongPress:h}),U(i.element,"contextmenu",h));const u=this._ctx.getDirection()==="vertical",m=new ii(i.element,{acceptedTargetZones:u?["top"]:["left"],overlayModel:{activationSize:{value:100,type:"percentage"}},canDisplayOverlay:(p,f)=>{var w;if(this._ctx.group.locked||this._ctx.accessor.options.disableDnd)return!1;const C=Ae();return C&&this._ctx.accessor.id===C.viewId?((w=this._ctx.accessor.options.theme)===null||w===void 0?void 0:w.tabAnimation)!=="smooth":this._ctx.group.model.canDisplayOverlay(p,f,"tab")}});c.push(m,m.onDrop(p=>{this._callbacks.onChipDrop(e,p)}));const g=new X(...c);this._chipRenderers.set(e.id,{chip:i,html5DragSource:l,pointerDragSource:d,disposable:g,dropTarget:m}),e.collapsed&&(this._skipNextCollapseAnimation=!0)}_positionChipForGroup(e){const t=this._chipRenderers.get(e.id);if(!t)return;const i=t.chip.element,s=e.panelIds;if(s.length===0){i.remove();return}const o=s[0],r=this._ctx.getTabMap().get(o);if(!r){i.remove();return}const l=r.value.element;i.nextSibling!==l&&this._ctx.tabsList.insertBefore(i,l)}_updateTabGroupClasses(){var e;const i=this._ctx.group.model.getTabGroups(),s=this._ctx.getTabs(),o=this._ctx.getTabMap();let r=!1;const l=new Map;for(const c of i)for(const h of c.panelIds)l.set(h,c);for(const c of s){const h=c.value,u=h.panel.id,m=l.get(u),g=!!m;if(W(h.element,"dv-tab--grouped",g),m){const p=m.panelIds,f=p[0]===u,w=p[p.length-1]===u;W(h.element,"dv-tab--group-first",f),W(h.element,"dv-tab--group-last",w),Vo(h.element,m.color,this._ctx.accessor.tabGroupColorPalette);const C=h.element.classList.contains("dv-tab--group-collapsed");if(!m.collapsed&&C){r=!0,h.element.classList.remove("dv-tab--group-collapsed"),h.element.classList.add("dv-tab--group-expanding"),(e=this._pendingTransitionCleanups.get(u))===null||e===void 0||e();const b=()=>{h.element.classList.remove("dv-tab--group-expanding"),h.element.style.removeProperty("width"),h.element.removeEventListener("transitionend",b),clearTimeout(D),this._pendingTransitionCleanups.delete(u)},D=setTimeout(b,300);this._pendingTransitionCleanups.set(u,b),h.element.addEventListener("transitionend",b)}}else W(h.element,"dv-tab--group-first",!1),W(h.element,"dv-tab--group-last",!1),h.element.classList.remove("dv-tab--group-collapsed","dv-tab--group-expanding"),h.element.style.removeProperty("width"),h.element.style.removeProperty("--dv-tab-group-color")}const d=new Set;for(const c of i)if(d.add(c.id),c.collapsed&&c.panelIds.some(u=>{const m=o.get(u);return m&&!m.value.element.classList.contains("dv-tab--group-collapsed")}))if(this._skipNextCollapseAnimation){const u=[];for(const m of c.panelIds){const g=o.get(m);g&&(g.value.element.style.transition="none",g.value.element.classList.add("dv-tab--group-collapsed"),u.push(g.value.element))}if(u.length>0){u[0].offsetHeight;for(const m of u)m.style.removeProperty("transition")}}else{r=!0;const u=this._ctx.getDirection()==="vertical";for(const m of c.panelIds){const g=o.get(m);if(g&&!g.value.element.classList.contains("dv-tab--group-collapsed")){const p=g.value.element.getBoundingClientRect();u?g.value.element.style.height=`${p.height}px`:g.value.element.style.width=`${p.width}px`,g.value.element.offsetHeight,g.value.element.classList.add("dv-tab--group-collapsed")}}}this._skipNextCollapseAnimation=!1,this._ensureIndicator(),this._indicator&&(this._indicator.syncUnderlineElements(d),r?this._indicator.trackUnderlines():this._indicator.positionUnderlines())}}class vm extends X{get showTabsOverflowControl(){return this._showTabsOverflowControl}set showTabsOverflowControl(e){if(this._showTabsOverflowControl!=e&&(this._showTabsOverflowControl=e,e)){const t=new vp(this._tabsList);this._observerDisposable.value=new X(t,t.onDidChange(i=>{const s=i.hasScrollX||i.hasScrollY;this.toggleDropdown({reset:!s}),this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}),U(this._tabsList,"scroll",()=>{this.toggleDropdown({reset:!1}),this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}))}}get element(){return this._element}set voidContainer(e){var t;(t=this._voidContainerListeners)===null||t===void 0||t.dispose(),this._voidContainerListeners=null,this._voidContainer=e,e&&(this._voidContainerListeners=new X(U(e,"dragover",i=>{this._animState&&i.preventDefault()}),U(e,"drop",i=>{var s;!((s=this._animState)===null||s===void 0)&&s.sourceTabGroupId&&this._animState.currentInsertionIndex!==null&&(i.preventDefault(),i.stopPropagation(),this.handleVoidDrop())})))}handleVoidDrop(){var e,t;if(!(!((e=this._animState)===null||e===void 0)&&e.sourceTabGroupId))return!1;const i=this._animState.sourceTabGroupId,s=(t=this._animState.currentInsertionIndex)!==null&&t!==void 0?t:this._tabs.length;return this._animState=null,this._commitGroupMove(i,s),!0}get panels(){return this._tabs.map(e=>e.value.panel.id)}get size(){return this._tabs.length}get tabs(){return this._tabs.map(e=>e.value)}get direction(){return this._direction}set direction(e){if(this._direction!==e){this._direction=e,this._tabsList.setAttribute("aria-orientation",e==="vertical"?"vertical":"horizontal"),this._scrollbar&&(this._scrollbar.orientation=e),It(this._tabsList,"dv-horizontal","dv-vertical"),e==="vertical"?At(this._tabsList,"dv-tabs-container-vertical","dv-vertical"):(It(this._tabsList,"dv-tabs-container-vertical"),At(this._tabsList,"dv-horizontal"));for(const t of this._tabs)t.value.setDirection(e);this._tabGroupManager.updateDirection()}}constructor(e,t,i){super(),this.group=e,this.accessor=t,this._observerDisposable=new $e,this._scrollbar=null,this._tabs=[],this._tabMap=new Map,this.selectedIndex=-1,this._showTabsOverflowControl=!1,this._direction="horizontal",this._animState=null,this._pendingMarginCleanups=new Map,this._pendingCollapse=!1,this._flipTransitionCleanup=null,this._voidContainer=null,this._voidContainerListeners=null,this._extendedDropZone=null,this._pointerInsideTabsList=!1,this._onTabDragStart=new z,this.onTabDragStart=this._onTabDragStart.event,this._onDrop=new z,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new z,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onOverflowTabsChange=new z,this.onOverflowTabsChange=this._onOverflowTabsChange.event,this._tabsList=document.createElement("div"),this._tabsList.className="dv-tabs-container",this._tabsList.setAttribute("role","tablist"),this._tabsList.setAttribute("aria-orientation",this._direction==="vertical"?"vertical":"horizontal"),this.showTabsOverflowControl=i.showTabsOverflowControl,t.options.scrollbars==="native"?this._element=this._tabsList:(this._scrollbar=new Ds(this._tabsList),this._scrollbar.orientation=this.direction,this._element=this._scrollbar.element,this.addDisposables(this._scrollbar)),this._tabGroupManager=new mm({group:this.group,accessor:this.accessor,tabsList:this._tabsList,getTabs:()=>this._tabs,getTabMap:()=>this._tabMap,getDirection:()=>this._direction},{onChipContextMenu:(s,o)=>{var r;(r=this.accessor.contextMenuService)===null||r===void 0||r.showForChip(s,this.group,o)},onChipDragStart:(s,o,r)=>{this._handleChipDragStart(s,o,r)},onChipDragEnd:()=>{this.resetDragAnimation()},onChipDrop:(s,o)=>{this._handleChipDrop(s,o)}}),this.addDisposables(this._onOverflowTabsChange,this._observerDisposable,this._onWillShowOverlay,this._onDrop,this._onTabDragStart,{dispose:()=>{var s;(s=this._flipTransitionCleanup)===null||s===void 0||s.call(this)}},ni.getInstance().onDragEnd(()=>{this._pointerInsideTabsList=!1,this.resetDragAnimation()}),ni.getInstance().onDragMove(s=>{this._handlePointerDragMove(s.clientX,s.clientY)}),U(this.element,"pointerdown",s=>{if(s.defaultPrevented)return;s.button===0&&this.accessor.doSetGroupActive(this.group)}),U(this._tabsList,"wheel",s=>{const o=this._direction==="vertical",r=o?s.deltaY||s.deltaX:s.deltaX||s.deltaY;if(r===0)return;const l=o?this._tabsList.scrollHeight-this._tabsList.clientHeight:this._tabsList.scrollWidth-this._tabsList.clientWidth;if(l<=0)return;const d=o?this._tabsList.scrollTop:this._tabsList.scrollLeft;r<0&&d<=0||r>0&&d>=l||(s.preventDefault(),s.stopPropagation(),o?this._tabsList.scrollTop=d+r:this._tabsList.scrollLeft=d+r)},{passive:!1}),U(this._tabsList,"keydown",s=>{this._onKeyDown(s)}),U(this._tabsList,"dragover",s=>{this._processDragOver(s.clientX)&&s.preventDefault()},!0),U(this._tabsList,"dragleave",s=>{this._processDragLeave(s.relatedTarget)},!0),U(this._tabsList,"dragend",()=>{this.resetDragAnimation()}),U(this._tabsList,"drop",s=>{var o,r,l;if(!this._animState||this._animState.currentInsertionIndex===null||((o=this.accessor.options.theme)===null||o===void 0?void 0:o.tabAnimation)!=="smooth"&&!this._animState.sourceTabGroupId)return;s.stopPropagation(),s.preventDefault(),(l=(r=this.group.model.dropTargetContainer)===null||r===void 0?void 0:r.model)===null||l===void 0||l.clear();const d=this._animState;if(this._animState=null,this._pendingCollapse=!1,d.sourceTabGroupId){this._commitGroupMove(d.sourceTabGroupId,d.currentInsertionIndex);return}const c=d.currentInsertionIndex,h=d.sourceIndex,u=c-(h!==-1&&h<c?1:0),m=this.group.model.getTabGroupForPanel(d.sourceTabId);if(u===h&&!d.targetTabGroupId&&!m){this._uncollapsSourceTab(d.sourceTabId),this.resetTabTransforms();return}this._uncollapsSourceTab(d.sourceTabId);const g=this.snapshotTabPositions();this.resetTabTransforms(),this._onDrop.fire({event:s,index:u,targetTabGroupId:d.targetTabGroupId}),this.runFlipAnimation(g,d.sourceTabId,d.sourceIndex===-1,{from:Math.min(h,u),to:Math.max(h,u)})},!0),ke.from(()=>{var s;(s=this._voidContainerListeners)===null||s===void 0||s.dispose(),this.resetDragAnimation(),this._tabGroupManager.disposeAll();for(const{value:o,disposable:r}of this._tabs)r.dispose(),o.dispose();this._tabs=[],this._tabMap.clear()}))}indexOf(e){return this._tabs.findIndex(t=>t.value.panel.id===e)}getTabId(e){var t;return(t=this._tabMap.get(e))===null||t===void 0?void 0:t.value.element.id}isActive(e){return this.selectedIndex>-1&&this._tabs[this.selectedIndex].value===e}_onKeyDown(e){const t=this._tabs.findIndex(l=>l.value.element===e.target);if(t===-1)return;const i=this._direction==="vertical",s=i?"ArrowDown":"ArrowRight",o=i?"ArrowUp":"ArrowLeft",r=this._tabs.length-1;switch(e.key){case s:e.preventDefault(),this._focusTab(Math.min(t+1,r));break;case o:e.preventDefault(),this._focusTab(Math.max(t-1,0));break;case"Home":e.preventDefault(),this._focusTab(0);break;case"End":e.preventDefault(),this._focusTab(r);break;case"Enter":case" ":e.preventDefault(),this.accessor.withOrigin("user",()=>this._tabs[t].value.panel.api.setActive());break;case"Delete":case"Backspace":e.preventDefault(),this._closeTab(t);break}}_closeTab(e){var t,i,s,o,r;const l=(t=this._tabs[e])===null||t===void 0?void 0:t.value;if(!l)return;const d=(r=(s=(i=this._tabs[e+1])===null||i===void 0?void 0:i.value)!==null&&s!==void 0?s:(o=this._tabs[e-1])===null||o===void 0?void 0:o.value)===null||r===void 0?void 0:r.panel.id;if(l.panel.api.close(),d!==void 0){const c=this._tabs.findIndex(h=>h.value.panel.id===d);c>-1&&this._focusTab(c)}}_focusTab(e){for(let t=0;t<this._tabs.length;t++)this._tabs[t].value.element.tabIndex=t===e?0:-1;this._tabs[e].value.element.focus()}focusActiveTab(){var e;if(this._tabs.length===0)return;const t=(e=this.group.activePanel)===null||e===void 0?void 0:e.id,i=t?this._tabs.findIndex(s=>s.value.panel.id===t):-1;this._focusTab(i>-1?i:0)}setActivePanel(e){const t=this._direction==="vertical";let i=0;for(const s of this._tabs){const o=e.id===s.value.panel.id;if(s.value.setActive(o),o){const r=s.value.element,l=r.parentElement;t?(i<l.scrollTop||i+r.clientHeight>l.scrollTop+l.clientHeight)&&(l.scrollTop=i):(i<l.scrollLeft||i+r.clientWidth>l.scrollLeft+l.clientWidth)&&(l.scrollLeft=i)}i+=t?s.value.element.clientHeight:s.value.element.clientWidth}this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}openPanel(e,t=this._tabs.length){if(this._tabMap.has(e.id))return;const i=new lm(e,this.accessor,this.group);i.setContent(e.view.tab),this._direction!=="horizontal"&&i.setDirection(this._direction);const s=new X(i.onDragStart(r=>{var l;if(this._onTabDragStart.fire({nativeEvent:r,panel:e}),((l=this.accessor.options.theme)===null||l===void 0?void 0:l.tabAnimation)==="smooth"){const d=i.element.getBoundingClientRect().width,c=this._tabs.findIndex(h=>h.value===i);this._animState={sourceTabId:e.id,sourceIndex:c,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:null,sourceGroupPanelIds:null,sourceChipWidth:0,cursorOffsetFromDragLeft:d/2,sourceGapWidth:d,containerLeft:this._tabsList.getBoundingClientRect().left},this._pendingCollapse=!0,requestAnimationFrame(()=>{var h,u;this._pendingCollapse=!1,this._animState&&(i.element.style.transition="none",W(i.element,"dv-tab--dragging",!0),i.element.offsetHeight,(h=(u=this._animState).currentInsertionIndex)!==null&&h!==void 0||(u.currentInsertionIndex=c),this.applyDragOverTransforms(!0),i.element.style.removeProperty("transition"))})}}),i.onTabClick(r=>{r.defaultPrevented||this.group.api.location.type==="edge"&&(this.group.activePanel===e?this.group.api.isCollapsed()?this.group.api.expand():this.group.api.collapse():(this.group.model.openPanel(e),this.group.api.isCollapsed()&&this.group.api.expand()))}),i.onPointerDown(r=>{if(r.defaultPrevented)return;const l=!this.accessor.options.disableFloatingGroups,d=this.group.api.location.type==="floating"&&this.size===1;if(l&&!d&&r.shiftKey){r.preventDefault();const c=this.accessor.getGroupPanel(i.panel.id),{top:h,left:u}=i.element.getBoundingClientRect(),{top:m,left:g}=this.accessor.element.getBoundingClientRect();this.accessor.addFloatingGroup(c,{x:u-g,y:h-m,inDragMode:!0});return}r.button===0&&(this.group.api.location.type==="edge"||this.group.activePanel!==e&&this.group.model.openPanel(e))}),i.onDrop(r=>{var l,d,c,h;const u=this._animState;this._animState=null,this._pendingCollapse=!1;const m=this._tabs.findIndex(g=>g.value===i);if(u){const g=r.position==="right"?m+1:m;if(u.sourceTabGroupId){this._commitGroupMove(u.sourceTabGroupId,(l=u.currentInsertionIndex)!==null&&l!==void 0?l:g);return}this._uncollapsSourceTab(u.sourceTabId);const p=this.snapshotTabPositions();this.resetTabTransforms(),this._onDrop.fire({event:r.nativeEvent,index:g,targetTabGroupId:u.targetTabGroupId}),((d=this.accessor.options.theme)===null||d===void 0?void 0:d.tabAnimation)==="smooth"&&this.runFlipAnimation(p,u.sourceTabId,u.sourceIndex===-1,u.sourceIndex!==-1?{from:Math.min(u.sourceIndex,g),to:Math.max(u.sourceIndex,g)}:void 0)}else{const g=this._direction==="vertical"?"bottom":"right",p=r.position===g?m+1:m,f=Ae(),w=f?this._tabs.findIndex(D=>D.value.panel.id===f.panelId):-1,C=p-(w!==-1&&w<p?1:0),b=(h=(c=this.group.model.getTabGroupForPanel(i.panel.id))===null||c===void 0?void 0:c.id)!==null&&h!==void 0?h:null;this._onDrop.fire({event:r.nativeEvent,index:C,targetTabGroupId:b})}}),i.onWillShowOverlay(r=>{this._onWillShowOverlay.fire(new zn(r,{kind:"tab",panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:Ae}))})),o={value:i,disposable:s};this.addTab(o,t),this._tabGroupManager.positionAllChips(),this._animState&&(this._animState.tabPositions=this.snapshotTabPositions(),this._animState.chipPositions=this._tabGroupManager.snapshotChipWidths(),this.applyDragOverTransforms())}delete(e){var t;((t=this._animState)===null||t===void 0?void 0:t.sourceTabId)===e&&(this.resetTabTransforms(),this._animState=null),this._tabGroupManager.cleanupTransition(e);const i=this.indexOf(e),s=this._tabs.splice(i,1)[0];if(this._tabMap.delete(e),s){const{value:o,disposable:r}=s;r.dispose(),o.dispose(),o.element.remove()}this._animState&&(this._animState.tabPositions=this.snapshotTabPositions(),this._animState.chipPositions=this._tabGroupManager.snapshotChipWidths(),this.applyDragOverTransforms())}addTab(e,t=this._tabs.length){if(t<0||t>this._tabs.length)throw new Error("invalid location");const i=t<this._tabs.length?this._tabs[t].value.element:null;this._tabsList.insertBefore(e.value.element,i),this._tabs=[...this._tabs.slice(0,t),e,...this._tabs.slice(t)],this._tabMap.set(e.value.panel.id,e),this.selectedIndex<0&&(this.selectedIndex=t)}toggleDropdown(e){if(e.reset){this._onOverflowTabsChange.fire({tabs:[],tabGroups:[],reset:!0});return}const t=this._tabs.filter(o=>!Da(o.value.element,this._tabsList)).map(o=>o.value.panel.id),i=new Set(t),s=[];for(const o of this.group.model.getTabGroups()){const r=this._tabGroupManager.chipRenderers.get(o.id),l=r&&!Da(r.chip.element,this._tabsList),d=o.panelIds.length>0&&o.panelIds.every(c=>i.has(c));if((l||d)&&(s.push(o.id),o.collapsed))for(const c of o.panelIds)i.has(c)||(i.add(c),t.push(c))}this._onOverflowTabsChange.fire({tabs:t,tabGroups:s,reset:!1})}updateDragAndDropState(){for(const e of this._tabs)e.value.updateDragAndDropState();this._tabGroupManager.updateDragAndDropState()}updateTabGroups(){this._tabGroupManager.update()}refreshTabGroupAccent(){this._tabGroupManager.refreshAccents()}_handleChipDragStart(e,t,i){var s;const o=e.panelIds[0],r=o?this._tabs.findIndex(h=>h.value.panel.id===o):-1,l=t.element.getBoundingClientRect();let d=l.width;for(const h of e.panelIds){const u=this._tabMap.get(h);u&&(d+=u.value.element.getBoundingClientRect().width)}if(this._animState={sourceTabId:"",sourceIndex:r,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:e.id,sourceGroupPanelIds:new Set(e.panelIds),sourceChipWidth:l.width,cursorOffsetFromDragLeft:i.clientX-l.left,sourceGapWidth:d,containerLeft:this._tabsList.getBoundingClientRect().left},((s=this.accessor.options.theme)===null||s===void 0?void 0:s.tabAnimation)!=="smooth")return;const c=new Set(e.panelIds);this._pendingCollapse=!0,requestAnimationFrame(()=>{var h,u;if(this._pendingCollapse=!1,!this._animState)return;for(const p of this._tabs)c.has(p.value.panel.id)&&(p.value.element.style.transition="none",W(p.value.element,"dv-tab--dragging",!0));const m=this._tabGroupManager.chipRenderers.get(e.id);m&&(m.chip.element.style.transition="none",W(m.chip.element,"dv-tab-group-chip--dragging",!0)),this._tabsList.offsetHeight;const g=this._tabGroupManager.groupUnderlines.get(e.id);g&&(g.style.display="none"),(h=(u=this._animState).currentInsertionIndex)!==null&&h!==void 0||(u.currentInsertionIndex=r),this.applyDragOverTransforms(!0);for(const p of this._tabs)c.has(p.value.panel.id)&&p.value.element.style.removeProperty("transition");m&&m.chip.element.style.removeProperty("transition")})}_handleChipDrop(e,t){const i=e.panelIds[0];if(!i)return;const s=this._tabs.findIndex(d=>d.value.panel.id===i);if(s===-1)return;const o=Ae(),r=o&&o.groupId===this.group.id&&o.panelId?this._tabs.findIndex(d=>d.value.panel.id===o.panelId):-1,l=s-(r!==-1&&r<s?1:0);this._onDrop.fire({event:t.nativeEvent,index:l,targetTabGroupId:null})}setExtendedDropZone(e){this._extendedDropZone=e}setExternalInsertionIndex(e){this._animState&&e!==this._animState.currentInsertionIndex&&(this._animState.currentInsertionIndex=e,this.applyDragOverTransforms())}clearExternalAnimState(){this._animState&&(this.resetTabTransforms(),this._animState.sourceIndex===-1?this._animState=null:this._animState.currentInsertionIndex=null)}snapshotTabPositions(){const e=new Map;for(const t of this._tabs)e.set(t.value.panel.id,t.value.element.getBoundingClientRect());return e}getAverageTabWidth(){if(this._tabs.length===0)return 0;const e=this._direction==="vertical";let t=0;for(const i of this._tabs){const s=i.value.element.getBoundingClientRect();t+=e?s.height:s.width}return t/this._tabs.length}_handlePointerDragMove(e,t){var i;const o=((i=this._tabsList.ownerDocument)!==null&&i!==void 0?i:document).elementFromPoint(e,t);if(!(!!o&&(this._tabsList.contains(o)||!!this._extendedDropZone&&this._extendedDropZone.contains(o)))){this._pointerInsideTabsList&&(this._pointerInsideTabsList=!1,this._processDragLeave(o));return}this._pointerInsideTabsList=!0,this._processDragOver(e)}_processDragOver(e){var t,i,s,o;if(this.accessor.options.disableDnd)return!1;if(this._animState){const r=Ae();r?.tabGroupId&&r.groupId!==this.group.id&&this._animState.sourceTabGroupId!==r.tabGroupId&&(this._animState=null)}if(!this._animState){const r=Ae();if(((t=this.accessor.options.theme)===null||t===void 0?void 0:t.tabAnimation)==="default"&&!r?.tabGroupId)return!1;if(r&&(r.panelId||r.tabGroupId)&&r.groupId!==this.group.id){const l=this.getAverageTabWidth();if(r.tabGroupId){const d=this.accessor.getPanel(r.groupId),c=d?.model.getTabGroups().find(m=>m.id===r.tabGroupId),h=(i=c?.panelIds.length)!==null&&i!==void 0?i:1,u=l*h+l;this._animState={sourceTabId:"",sourceIndex:-1,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:r.tabGroupId,sourceGroupPanelIds:c?new Set(c.panelIds):new Set,sourceChipWidth:l,cursorOffsetFromDragLeft:u/2,sourceGapWidth:u,containerLeft:this._tabsList.getBoundingClientRect().left}}else this._animState={sourceTabId:r.panelId,sourceIndex:-1,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:null,sourceGroupPanelIds:null,sourceChipWidth:0,cursorOffsetFromDragLeft:l/2,sourceGapWidth:l,containerLeft:this._tabsList.getBoundingClientRect().left}}else return!1}return this._animState.sourceIndex!==-1&&((o=(s=this.group.model.dropTargetContainer)===null||s===void 0?void 0:s.model)===null||o===void 0||o.clear()),this.handleDragOver({clientX:e}),!0}_processDragLeave(e){var t,i,s;if(!this._animState||e&&this._tabsList.contains(e))return;if(e&&(!((t=this._extendedDropZone)===null||t===void 0)&&t.contains(e))){this.resetTabTransforms(),this._animState.currentInsertionIndex=null;return}this._voidContainer&&e&&(e===this._voidContainer||this._voidContainer.contains(e))||(this.resetTabTransforms(),this._animState.sourceIndex===-1?((s=(i=this.group.model.dropTargetContainer)===null||i===void 0?void 0:i.model)===null||s===void 0||s.clear(),this._animState=null):this._animState.currentInsertionIndex=null)}handleDragOver(e){var t,i,s,o,r;if(!this._animState)return;const l=e.clientX;let d=null,c=null;const h=this._animState.sourceGroupPanelIds,m=l-this._animState.cursorOffsetFromDragLeft-this._animState.containerLeft;let g=0;const p=new Map;if(this._tabGroupManager.chipRenderers.size>0){const f=this.group.model.getTabGroups();for(const w of f)w.id!==this._animState.sourceTabGroupId&&w.panelIds.length>0&&p.set(w.panelIds[0],w.id)}for(let f=0;f<this._tabs.length;f++){const w=this._tabs[f].value;if(w.panel.id===this._animState.sourceTabId||h?.has(w.panel.id))continue;const C=p.get(w.panel.id);if(C){const k=(t=this._animState.chipPositions.get(C))!==null&&t!==void 0?t:0;if(g+k>m){d??(d=f);break}g+=k}const b=this._animState.tabPositions.get(w.panel.id),D=b?b.width:w.element.getBoundingClientRect().width;if(g+D/2<=m)g+=D,d=f+1;else{d??(d=f);break}}if(d!==null&&this._tabGroupManager.chipRenderers.size>0){const f=!!this._animState.sourceTabGroupId,w=this.group.model.getTabGroups();let C=0;for(let b=0;b<this._tabs.length;b++){const D=this._tabs[b].value;if(D.panel.id===this._animState.sourceTabId||h?.has(D.panel.id))continue;if(b>=d)break;const k=p.get(D.panel.id);k&&(C+=(i=this._animState.chipPositions.get(k))!==null&&i!==void 0?i:0);const P=this._animState.tabPositions.get(D.panel.id);C+=P?P.width:D.element.getBoundingClientRect().width}for(const b of w){const D=b.panelIds.filter(S=>S!==this._animState.sourceTabId&&!h?.has(S));if(D.length===0)continue;const k=this._tabs.findIndex(S=>S.value.panel.id===D[0]),P=this._tabs.findIndex(S=>S.value.panel.id===D[D.length-1]);if(k===-1||P===-1)continue;const y=d>=k&&d<=P,T=!y&&d===k-1;if(!(!y&&!T)){if(f&&y){const S=(k+P+1)/2;d<S?d=k:d=P+1;break}if(f&&T)break;if(T){let S=!0;for(let $=d;$<k;$++){const F=this._tabs[$].value.panel.id;if(F!==this._animState.sourceTabId&&!h?.has(F)){S=!1;break}}if(!S)continue;const N=(s=this._animState.chipPositions.get(b.id))!==null&&s!==void 0?s:0,O=b.collapsed?this._animState.containerLeft+C+N/2:this._animState.containerLeft+C+N;l>=O&&(d=k,c=b.id);break}if(y){const S=(o=this._animState.chipPositions.get(b.id))!==null&&o!==void 0?o:0,N=this._animState.containerLeft+C+S;d===k?l>=N&&(c=b.id):c=b.id;break}}}}d===this._animState.currentInsertionIndex&&c===this._animState.targetTabGroupId||(this._animState.currentInsertionIndex=d,this._animState.targetTabGroupId=c,((r=this.accessor.options.theme)===null||r===void 0?void 0:r.tabAnimation)==="smooth"&&this.applyDragOverTransforms())}_removeClassInstantlyBatch(e,t){const i=[];for(const s of e)s.classList.contains(t)&&(s.style.transition="none",W(s,t,!1),i.push(s));if(i.length>0){i[0].offsetHeight;for(const s of i)s.style.removeProperty("transition")}}_uncollapsSourceTab(e){const t=this._tabMap.get(e);t&&this._removeClassInstantlyBatch([t.value.element],"dv-tab--dragging")}applyDragOverTransforms(e=!1){if(!this._animState||this._animState.currentInsertionIndex===null){this.resetTabTransforms();return}if(this._pendingCollapse)return;const t=this._animState.currentInsertionIndex;let i;const s=this._animState.sourceGroupPanelIds;if(this._animState.sourceTabGroupId&&s)i=this._animState.sourceGapWidth;else{const h=this._animState.tabPositions.get(this._animState.sourceTabId);i=h?h.width:this.getAverageTabWidth()}let o=null;if(this._tabGroupManager.chipRenderers.size>0){const h=this.group.model.getTabGroups();for(const u of h){if(u.id===this._animState.sourceTabGroupId||u.panelIds.includes(this._animState.sourceTabId))continue;const m=u.panelIds.filter(f=>f!==this._animState.sourceTabId&&!s?.has(f));if(m.length===0)continue;const g=this._tabs.findIndex(f=>f.value.panel.id===m[0]);if((!this._animState.targetTabGroupId||this._animState.targetTabGroupId===u.id&&u.collapsed)&&g>=t){let f=!1;for(let w=t;w<g;w++){const C=this._tabs[w].value.panel.id;if(C!==this._animState.sourceTabId&&!s?.has(C)){f=!0;break}}if(!f){const w=this._tabGroupManager.chipRenderers.get(u.id);w&&(o=w.chip.element)}break}}}const r=h=>h.classList.contains("dv-tab-group-chip")?"dv-tab-group-chip--shifting":"dv-tab--shifting",l=(h,u)=>{e?(h.style.transition="none",h.style.marginLeft=u,h.offsetHeight,h.style.removeProperty("transition")):h.style.marginLeft=u,W(h,r(h),!0)},d=h=>{const u=r(h),m=this._pendingMarginCleanups.get(h);if(m&&m(),e||!h.style.marginLeft)h.style.removeProperty("margin-left"),W(h,u,!1);else{h.style.marginLeft="0px",W(h,u,!0);const g=()=>{h.style.removeProperty("margin-left"),W(h,u,!1),h.removeEventListener("transitionend",g),clearTimeout(p),this._pendingMarginCleanups.delete(h)},p=setTimeout(g,300);this._pendingMarginCleanups.set(h,g),h.addEventListener("transitionend",g)}};let c=!1;for(const[h,u]of this._tabGroupManager.chipRenderers)h!==this._animState.sourceTabGroupId&&d(u.chip.element);o&&(l(o,`${i}px`),c=!0);for(let h=0;h<this._tabs.length;h++){const u=this._tabs[h].value;u.panel.id!==this._animState.sourceTabId&&(s?.has(u.panel.id)||(!c&&h>=t?(l(u.element,`${i}px`),c=!0):d(u.element)))}this._tabGroupManager.trackUnderlines()}resetTabTransforms(){for(const[,e]of this._pendingMarginCleanups)e();this._pendingMarginCleanups.clear();for(const e of this._tabs)e.value.element.style.removeProperty("margin-left"),e.value.element.style.removeProperty("margin-right"),e.value.element.style.removeProperty("margin-top"),e.value.element.style.removeProperty("margin-bottom"),e.value.element.style.removeProperty("transform"),W(e.value.element,"dv-tab--shifting",!1);for(const[,e]of this._tabGroupManager.chipRenderers)e.chip.element.style.removeProperty("margin-left"),W(e.chip.element,"dv-tab-group-chip--shifting",!1);this._tabGroupManager.positionUnderlines()}_commitGroupMove(e,t){var i,s;const o=Ae();if(this._tabGroupManager.disposeChipDrag(e),this.group.model.getTabGroups().some(l=>l.id===e))if(((i=this.accessor.options.theme)===null||i===void 0?void 0:i.tabAnimation)==="smooth"){this._clearGroupDragClasses(e);const l=this.snapshotTabPositions();this.resetTabTransforms(),this.group.model.moveTabGroup(e,t),this.runFlipAnimation(l,"",!1)}else this._tabGroupManager.skipNextCollapseAnimation=!0,this.group.model.moveTabGroup(e,t);else o&&(this.resetTabTransforms(),this.accessor.moveGroupOrPanel({from:{groupId:o.groupId,tabGroupId:(s=o.tabGroupId)!==null&&s!==void 0?s:e},to:{group:this.group,position:"center",index:t}}))}_clearGroupDragClasses(e){const t=this._tabGroupManager.chipRenderers.get(e);t&&this._removeClassInstantlyBatch([t.chip.element],"dv-tab-group-chip--dragging"),this._removeClassInstantlyBatch(this._tabs.map(s=>s.value.element),"dv-tab--dragging");const i=this._tabGroupManager.groupUnderlines.get(e);i&&i.style.removeProperty("display"),this._tabGroupManager.skipNextCollapseAnimation=!0}resetDragAnimation(){if(this._pendingCollapse=!1,this._animState){this.resetTabTransforms(),this._animState.sourceTabGroupId?this._clearGroupDragClasses(this._animState.sourceTabGroupId):this._removeClassInstantlyBatch(this._tabs.map(e=>e.value.element),"dv-tab--dragging"),this._animState=null;for(const[,e]of this._tabGroupManager.groupUnderlines)e.style.removeProperty("display")}}runFlipAnimation(e,t,i=!1,s){const o=this._direction==="vertical";let r=!1;for(let l=0;l<this._tabs.length;l++){const d=this._tabs[l],c=d.value.panel.id;if(c===t){if(i){const g=d.value.element.getBoundingClientRect();d.value.element.style.transform=o?`translateY(${g.height}px)`:`translateX(${g.width}px)`,W(d.value.element,"dv-tab--shifting",!0),r=!0}continue}if(s!==void 0&&(l<s.from||l>s.to))continue;const h=e.get(c);if(!h)continue;const u=d.value.element.getBoundingClientRect(),m=o?h.top-u.top:h.left-u.left;Math.abs(m)<1||(d.value.element.style.transform=o?`translateY(${m}px)`:`translateX(${m}px)`,W(d.value.element,"dv-tab--shifting",!0),r=!0)}r&&requestAnimationFrame(()=>{var l;for(const h of this._tabs)h.value.element.style.transform&&(h.value.element.style.transform="");this._tabGroupManager.trackUnderlines(),(l=this._flipTransitionCleanup)===null||l===void 0||l.call(this);const d=h=>{if(h.propertyName==="transform"){c();for(const u of this._tabs)W(u.value.element,"dv-tab--shifting",!1);this._tabGroupManager.positionUnderlines()}},c=()=>{this._tabsList.removeEventListener("transitionend",d),this._flipTransitionCleanup=null};this._flipTransitionCleanup=c,this._tabsList.addEventListener("transitionend",d)})}}const Fo=n=>{const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttributeNS(null,"height",n.height),e.setAttributeNS(null,"width",n.width),e.setAttributeNS(null,"viewBox",n.viewbox),e.setAttributeNS(null,"aria-hidden","false"),e.setAttributeNS(null,"focusable","false"),e.classList.add("dv-svg");const t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttributeNS(null,"d",n.path),e.appendChild(t),e},gm=()=>Fo({width:"11",height:"11",viewbox:"0 0 28 28",path:"M2.1 27.3L0 25.2L11.55 13.65L0 2.1L2.1 0L13.65 11.55L25.2 0L27.3 2.1L15.75 13.65L27.3 25.2L25.2 27.3L13.65 15.75L2.1 27.3Z"}),fm=()=>Fo({width:"11",height:"11",viewbox:"0 0 24 15",path:"M12 14.15L0 2.15L2.15 0L12 9.9L21.85 0.0499992L24 2.2L12 14.15Z"}),Fl=()=>Fo({width:"11",height:"11",viewbox:"0 0 15 25",path:"M2.15 24.1L0 21.95L9.9 12.05L0 2.15L2.15 0L14.2 12.05L2.15 24.1Z"});function _m(){const n=document.createElement("div");n.className="dv-tabs-overflow-dropdown-default";const e=document.createElement("span");e.textContent="";const t=Fl();return n.appendChild(t),n.appendChild(e),{element:n,update:i=>{e.textContent=`${i.tabs}`}}}class wm extends X{get onTabDragStart(){return this.tabs.onTabDragStart}get panels(){return this.tabs.panels}get size(){return this.tabs.size}get hidden(){return this._hidden}set hidden(e){this._hidden=e,this.element.style.display=e?"none":""}get direction(){return this._direction}set direction(e){this._direction=e,e==="vertical"?(At(this._element,"dv-groupview-header-vertical"),At(this.rightActionsContainer,"dv-right-actions-container-vertical"),this.tabs.direction=e):(It(this._element,"dv-groupview-header-vertical"),It(this.rightActionsContainer,"dv-right-actions-container-vertical"),this.tabs.direction=e)}get element(){return this._element}constructor(e,t){super(),this.accessor=e,this.group=t,this._hidden=!1,this._direction="horizontal",this.dropdownPart=null,this._overflowTabs=[],this._overflowTabGroups=[],this._dropdownDisposable=new $e,this._onDrop=new z,this.onDrop=this._onDrop.event,this._onGroupDragStart=new z,this.onGroupDragStart=this._onGroupDragStart.event,this._onWillShowOverlay=new z,this.onWillShowOverlay=this._onWillShowOverlay.event,this._element=document.createElement("div"),this._element.className="dv-tabs-and-actions-container",W(this._element,"dv-full-width-single-tab",this.accessor.options.singleTabMode==="fullwidth"),this.rightActionsContainer=document.createElement("div"),this.rightActionsContainer.className="dv-right-actions-container",this.leftActionsContainer=document.createElement("div"),this.leftActionsContainer.className="dv-left-actions-container",this.preActionsContainer=document.createElement("div"),this.preActionsContainer.className="dv-pre-actions-container",this.tabs=new vm(t,e,{showTabsOverflowControl:!e.options.disableTabsOverflowList}),this.voidContainer=new cm(this.accessor,this.group),this.tabs.voidContainer=this.voidContainer.element,this._element.appendChild(this.preActionsContainer),this._element.appendChild(this.tabs.element),this._element.appendChild(this.leftActionsContainer),this._element.appendChild(this.voidContainer.element),this._element.appendChild(this.rightActionsContainer),this.tabs.setExtendedDropZone(this._element),this.addDisposables(this.tabs.onDrop(i=>this._onDrop.fire(i)),this.tabs.onWillShowOverlay(i=>this._onWillShowOverlay.fire(i)),e.onDidOptionsChange(()=>{this.tabs.showTabsOverflowControl=!e.options.disableTabsOverflowList}),this.tabs.onOverflowTabsChange(i=>{this.toggleDropdown(i)}),this.tabs,this._onWillShowOverlay,this._onDrop,this._onGroupDragStart,this.voidContainer,this.voidContainer.onDragStart(i=>{this._onGroupDragStart.fire({nativeEvent:i,group:this.group})}),this.voidContainer.onDrop(i=>{this.tabs.handleVoidDrop()||this._onDrop.fire({event:i.nativeEvent,index:this.tabs.size})}),this.voidContainer.onWillShowOverlay(i=>{this._onWillShowOverlay.fire(new zn(i,{kind:"header_space",panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:Ae}))}),U(this.leftActionsContainer,"dragleave",i=>{const s=i.relatedTarget;!this.leftActionsContainer.contains(s)&&!this._element.contains(s)&&this.tabs.clearExternalAnimState()}),U(this.voidContainer.element,"dragleave",i=>{const s=i.relatedTarget;this.voidContainer.element.contains(s)||(this._element.contains(s)?this.tabs.setExternalInsertionIndex(null):this.tabs.clearExternalAnimState())}),U(this.voidContainer.element,"pointerdown",i=>{if(i.defaultPrevented)return;if(!this.accessor.options.disableFloatingGroups&&i.shiftKey&&this.group.api.location.type!=="floating"&&this.group.api.location.type!=="edge"){i.preventDefault();const{top:o,left:r}=this.element.getBoundingClientRect(),{top:l,left:d}=this.accessor.element.getBoundingClientRect();this.accessor.addFloatingGroup(this.group,{x:r-d+20,y:o-l+20,inDragMode:!0})}}))}show(){this.hidden||(this.element.style.display="")}hide(){this._element.style.display="none"}setRightActionsElement(e){this.rightActions!==e&&(this.rightActions&&(this.rightActions.remove(),this.rightActions=void 0),e&&(this.rightActionsContainer.appendChild(e),this.rightActions=e))}setLeftActionsElement(e){this.leftActions!==e&&(this.leftActions&&(this.leftActions.remove(),this.leftActions=void 0),e&&(this.leftActionsContainer.appendChild(e),this.leftActions=e))}setPrefixActionsElement(e){this.preActions!==e&&(this.preActions&&(this.preActions.remove(),this.preActions=void 0),e&&(this.preActionsContainer.appendChild(e),this.preActions=e))}isActive(e){return this.tabs.isActive(e)}indexOf(e){return this.tabs.indexOf(e)}getTabId(e){return this.tabs.getTabId(e)}setActive(e){}delete(e){this.tabs.delete(e),this.updateClassnames()}setActivePanel(e){this.tabs.setActivePanel(e)}focusActiveTab(){this.tabs.focusActiveTab()}openPanel(e,t=this.tabs.size){this.tabs.openPanel(e,t),this.updateClassnames()}closePanel(e){this.delete(e.id)}updateClassnames(){W(this._element,"dv-single-tab",this.size===1)}toggleDropdown(e){const t=e.reset?[]:e.tabs,i=e.reset?[]:e.tabGroups;this._overflowTabs=t,this._overflowTabGroups=i;const s=this._overflowTabs.length;if(s>0&&this.dropdownPart){this.dropdownPart.update({tabs:s});return}if(s===0){this._dropdownDisposable.dispose();return}const o=document.createElement("div");o.className="dv-tabs-overflow-dropdown-root";const r=_m();r.update({tabs:s}),this.dropdownPart=r,o.appendChild(r.element),this.rightActionsContainer.prepend(o),this._dropdownDisposable.value=new X(ke.from(()=>{var l,d;o.remove(),(d=(l=this.dropdownPart)===null||l===void 0?void 0:l.dispose)===null||d===void 0||d.call(l),this.dropdownPart=null}),U(o,"pointerdown",l=>{l.preventDefault()},{capture:!0}),U(o,"click",l=>{const d=document.createElement("div");d.style.overflow="auto",d.className="dv-tabs-overflow-container";const c=new Set(this._overflowTabGroups),h=this.group.model.getTabGroups(),u=new Map;for(const p of h)if(c.has(p.id))for(const f of p.panelIds)u.set(f,p);const m=new Set;for(const p of this.tabs.tabs.filter(f=>this._overflowTabs.includes(f.panel.id))){const f=u.get(p.panel.id);if(f&&!m.has(f.id)){m.add(f.id);const k=document.createElement("div");k.className="dv-tabs-overflow-group-header";const P=document.createElement("span");P.className="dv-tabs-overflow-group-color",Vo(P,f.color,this.accessor.tabGroupColorPalette),k.appendChild(P);const y=document.createElement("span");if(y.className="dv-tabs-overflow-group-label",y.textContent=f.label||f.id,k.appendChild(y),f.collapsed){const T=document.createElement("span");T.className="dv-tabs-overflow-group-collapsed-badge",T.textContent=`${f.panelIds.length}`,k.appendChild(T)}k.addEventListener("click",()=>{this.accessor.getPopupServiceForGroup(this.group).close(),f.collapsed&&f.expand();const T=f.panelIds[0];if(T){const S=this.group.panels.find(N=>N.id===T);this.accessor.withOrigin("user",()=>S?.api.setActive())}}),d.appendChild(k)}const w=this.group.panels.find(k=>k===p.panel),b=w.view.createTabRenderer("headerOverflow").element,D=document.createElement("div");W(D,"dv-tab",!0),W(D,"dv-active-tab",w.api.isActive),W(D,"dv-inactive-tab",!w.api.isActive),f&&W(D,"dv-tab--grouped",!0),D.addEventListener("click",k=>{this.accessor.getPopupServiceForGroup(this.group).close(),!k.defaultPrevented&&(f?.collapsed&&f.expand(),p.element.scrollIntoView(),this.accessor.withOrigin("user",()=>p.panel.api.setActive()))}),D.appendChild(b),d.appendChild(D)}const g=_l(o);this.accessor.getPopupServiceForGroup(this.group).openPopover(d,{x:l.clientX,y:l.clientY,zIndex:g?.style.zIndex?`calc(${g.style.zIndex} * 2)`:void 0})}))}updateDragAndDropState(){this.tabs.updateDragAndDropState(),this.voidContainer.updateDragAndDropState()}updateTabGroups(){this.tabs.updateTabGroups()}refreshTabGroupAccent(){this.tabs.refreshTabGroupAccent()}}class Wl extends pl{constructor(e,t,i,s,o){super(),this.nativeEvent=e,this.target=t,this.position=i,this.getData=s,this.group=o}}const mo=Object.keys({disableAutoResizing:void 0,hideBorders:void 0,singleTabMode:void 0,disableFloatingGroups:void 0,floatingGroupBounds:void 0,transformFloatingGroupDrag:void 0,floatingGroupDragHandle:void 0,popoutUrl:void 0,nonce:void 0,defaultRenderer:void 0,defaultHeaderPosition:void 0,debug:void 0,locked:void 0,disableDnd:void 0,dndStrategy:void 0,className:void 0,noPanelsOverlay:void 0,dndEdges:void 0,theme:void 0,disableTabsOverflowList:void 0,scrollbars:void 0,getTabContextMenuItems:void 0,getTabGroupChipContextMenuItems:void 0,createTabGroupChipComponent:void 0,createGroupDragGhostComponent:void 0,dropOverlayModel:void 0,announcements:void 0,getAnnouncement:void 0,announcer:void 0,messages:void 0,keyboardNavigation:void 0,tabGroupColors:void 0,tabGroupAccent:void 0});function bm(n){return!!n.referencePanel}function xm(n){return!!n.referenceGroup}function ym(n){return!!n.referencePanel}function Dm(n){return!!n.referenceGroup}class Cm extends X{get label(){return this._label}get color(){return this._color}get componentParams(){return this._componentParams}setLabel(e){this.isDisposed||this._label===e||(this._label=e,this._onDidChange.fire())}setColor(e){if(this.isDisposed)return;const t=e===""?void 0:e;this._color!==t&&(this._color=t,this._onDidChange.fire())}setComponentParams(e){this.isDisposed||(this._componentParams=e,this._onDidChange.fire())}get collapsed(){return this._collapsed}get panelIds(){return this._panelIds}get size(){return this._panelIds.length}get isEmpty(){return this._panelIds.length===0}constructor(e,t){var i,s;super(),this.id=e,this._collapsed=!1,this._panelIds=[],this._onDidChange=new z,this.onDidChange=this._onDidChange.event,this._onDidPanelChange=new z,this.onDidPanelChange=this._onDidPanelChange.event,this._onDidCollapseChange=new z,this.onDidCollapseChange=this._onDidCollapseChange.event,this._onDidDestroy=new z,this.onDidDestroy=this._onDidDestroy.event,this._label=(i=t?.label)!==null&&i!==void 0?i:"",this._color=t?.color===""?void 0:t?.color,this._collapsed=(s=t?.collapsed)!==null&&s!==void 0?s:!1,this._componentParams=t?.componentParams,this.addDisposables(this._onDidChange,this._onDidPanelChange,this._onDidCollapseChange,this._onDidDestroy)}addPanel(e,t){if(this.isDisposed||this._panelIds.includes(e))return;const i=t!==void 0?Math.max(0,Math.min(t,this._panelIds.length)):this._panelIds.length;this._panelIds.splice(i,0,e),this._onDidPanelChange.fire({panelId:e,type:"add"})}removePanel(e){if(this.isDisposed)return!1;const t=this._panelIds.indexOf(e);return t===-1?!1:(this._panelIds.splice(t,1),this._onDidPanelChange.fire({panelId:e,type:"remove"}),!0)}indexOfPanel(e){return this._panelIds.indexOf(e)}containsPanel(e){return this._panelIds.includes(e)}collapse(){this.isDisposed||this._collapsed||(this._collapsed=!0,this._onDidCollapseChange.fire(!0))}expand(){this.isDisposed||!this._collapsed||(this._collapsed=!1,this._onDidCollapseChange.fire(!1))}toggle(){this._collapsed?this.expand():this.collapse()}toJSON(){const e={id:this.id,collapsed:this._collapsed,panelIds:[...this._panelIds]};return this._label&&(e.label=this._label),this._color!==void 0&&(e.color=this._color),this._componentParams!==void 0&&(e.componentParams=this._componentParams),e}dispose(){this._onDidDestroy.fire(),super.dispose()}}class Wo extends Ao{get nativeEvent(){return this.options.nativeEvent}get position(){return this.options.position}get panel(){return this.options.panel}get group(){return this.options.group}get api(){return this.options.api}constructor(e){super(),this.options=e}getData(){return this.options.getData()}}class $l extends Wo{get kind(){return this._kind}constructor(e){super(e),this._kind=e.kind}}class Sm extends X{get tabGroups(){return this._tabGroups}get element(){throw new Error("dockview: not supported")}get activePanel(){return this._activePanel}get contentContainerId(){return this.contentContainer.element.id}get contentDropTarget(){return this.contentContainer.dropTarget}get locked(){return this._locked}set locked(e){this._locked=e,W(this.container,"dv-locked-groupview",e==="no-drop-target"||e)}get isActive(){return this._isGroupActive}get panels(){return this._panels}get size(){return this._panels.length}get isEmpty(){return this._panels.length===0}get hasWatermark(){return!!(this.watermark&&this.container.contains(this.watermark.element))}get header(){return this.tabsContainer}get isContentFocused(){return document.activeElement?so(document.activeElement,this.contentContainer.element):!1}get headerPosition(){var e;return(e=this._headerPosition)!==null&&e!==void 0?e:"top"}set headerPosition(e){var t;this._headerPosition=e,It(this.container,"dv-groupview-header-top","dv-groupview-header-bottom","dv-groupview-header-left","dv-groupview-header-right"),At(this.container,`dv-groupview-header-${e}`);const i=e==="top"||e==="bottom"?"horizontal":"vertical";this.tabsContainer.direction=i,this.header.direction=i,!((t=this._activePanel)===null||t===void 0)&&t.layout&&this._activePanel.layout(this._width,this._height),this.updateHeaderActions()}get location(){return this._location}set location(e){this._location=e,W(this.container,"dv-groupview-floating",!1),W(this.container,"dv-groupview-popout",!1),W(this.container,"dv-groupview-edge",!1);const t=i=>{this.contentContainer.dropTarget.setTargetZones(i),this.contentContainer.pointerDropTarget.setTargetZones(i)};switch(e.type){case"grid":t(["top","bottom","left","right","center"]);break;case"floating":t(["top","bottom","left","right","center"]),W(this.container,"dv-groupview-floating",!0);break;case"popout":t(["top","bottom","left","right","center"]),W(this.container,"dv-groupview-popout",!0);break;case"edge":t(["center"]),W(this.container,"dv-groupview-edge",!0);break}this.groupPanel.api._onDidLocationChange.fire({location:this.location})}constructor(e,t,i,s,o){var r,l;super(),this.container=e,this.accessor=t,this.id=i,this.options=s,this.groupPanel=o,this._isGroupActive=!1,this._locked=!1,this._location={type:"grid"},this.mostRecentlyUsed=[],this._overwriteRenderContainer=null,this._overwriteDropTargetContainer=null,this._onDidChange=new z,this.onDidChange=this._onDidChange.event,this._width=0,this._height=0,this._panels=[],this._panelDisposables=new Map,this._tabGroupDisposables=new Map,this._pendingMicrotaskDisposables=new Set,this._onMove=new z,this.onMove=this._onMove.event,this._onDidDrop=new z,this.onDidDrop=this._onDidDrop.event,this._onWillDrop=new z,this.onWillDrop=this._onWillDrop.event,this._onWillShowOverlay=new z,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onTabDragStart=new z,this.onTabDragStart=this._onTabDragStart.event,this._onGroupDragStart=new z,this.onGroupDragStart=this._onGroupDragStart.event,this._onDidAddPanel=new z,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidPanelTitleChange=new z,this.onDidPanelTitleChange=this._onDidPanelTitleChange.event,this._onDidPanelParametersChange=new z,this.onDidPanelParametersChange=this._onDidPanelParametersChange.event,this._onDidRemovePanel=new z,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidActivePanelChange=new z,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onUnhandledDragOver=new z,this.onUnhandledDragOver=this._onUnhandledDragOver.event,this._tabGroups=[],this._tabGroupMap=new Map,this._panelToTabGroup=new Map,this._tabGroupIdCounter=0,this._pendingTabGroupUpdate=!1,this._onDidCreateTabGroup=new z,this.onDidCreateTabGroup=this._onDidCreateTabGroup.event,this._onDidDestroyTabGroup=new z,this.onDidDestroyTabGroup=this._onDidDestroyTabGroup.event,this._onDidAddPanelToTabGroup=new z,this.onDidAddPanelToTabGroup=this._onDidAddPanelToTabGroup.event,this._onDidRemovePanelFromTabGroup=new z,this.onDidRemovePanelFromTabGroup=this._onDidRemovePanelFromTabGroup.event,this._onDidTabGroupChange=new z,this.onDidTabGroupChange=this._onDidTabGroupChange.event,this._onDidTabGroupCollapsedChange=new z,this.onDidTabGroupCollapsedChange=this._onDidTabGroupCollapsedChange.event,W(this.container,"dv-groupview",!0),this.container.setAttribute("role","region"),this._api=new Oo(this.accessor),this.tabsContainer=new wm(this.accessor,this.groupPanel),this.contentContainer=new im(this.accessor,this),e.append(this.tabsContainer.element,this.contentContainer.element),this.header.hidden=!!s.hideHeader,this.locked=(r=s.locked)!==null&&r!==void 0?r:!1,this.headerPosition=(l=s.headerPosition)!==null&&l!==void 0?l:t.defaultHeaderPosition,this.addDisposables(this._onDidPanelTitleChange.event(()=>this.updateAccessibleLabel()),this._onTabDragStart,this._onGroupDragStart,this._onWillShowOverlay,this.tabsContainer.onTabDragStart(d=>{this._onTabDragStart.fire(d)}),this.tabsContainer.onGroupDragStart(d=>{this._onGroupDragStart.fire(d)}),this.tabsContainer.onDrop(d=>{var c;const h=Ae(),u=(c=h?.panelId)!==null&&c!==void 0?c:null;if(this.handleDropEvent("header",d.event,"center",d.index),u&&d.targetTabGroupId){const m=this._tabGroupMap.get(d.targetTabGroupId);let g;if(m){const p=this._panels.findIndex(f=>f.id===u);if(p!==-1){g=0;for(const f of m.panelIds)this._panels.findIndex(C=>C.id===f)<p&&g++}}this.addPanelToTabGroup(d.targetTabGroupId,u,g)}else u&&d.targetTabGroupId===null&&this.removePanelFromTabGroup(u)}),this.contentContainer.onDidFocus(()=>{this.accessor.doSetGroupActive(this.groupPanel)}),this.contentContainer.onDidBlur(()=>{}),this.contentContainer.dropTarget.onDrop(d=>{this.handleDropEvent("content",d.nativeEvent,d.position)}),this.contentContainer.pointerDropTarget.onDrop(d=>{this.handleDropEvent("content",d.nativeEvent,d.position)}),this.tabsContainer.onWillShowOverlay(d=>{this._onWillShowOverlay.fire(d)}),this.contentContainer.dropTarget.onWillShowOverlay(d=>{this._onWillShowOverlay.fire(new zn(d,{kind:"content",panel:this.activePanel,api:this._api,group:this.groupPanel,getData:Ae}))}),this.contentContainer.pointerDropTarget.onWillShowOverlay(d=>{this._onWillShowOverlay.fire(new zn(d,{kind:"content",panel:this.activePanel,api:this._api,group:this.groupPanel,getData:Ae}))}),this._onMove,this._onDidChange,this._onDidDrop,this._onWillDrop,this._onDidAddPanel,this._onDidRemovePanel,this._onDidActivePanelChange,this._onUnhandledDragOver,this._onDidPanelTitleChange,this._onDidPanelParametersChange,this._onDidCreateTabGroup,this._onDidDestroyTabGroup,this._onDidAddPanelToTabGroup,this._onDidRemovePanelFromTabGroup,this._onDidTabGroupChange,this._onDidTabGroupCollapsedChange,this._onDidCreateTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidDestroyTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidAddPanelToTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidRemovePanelFromTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidTabGroupChange.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidTabGroupCollapsedChange.event(()=>{this._scheduleTabGroupUpdate()}))}_scheduleTabGroupUpdate(){this._pendingTabGroupUpdate||(this._pendingTabGroupUpdate=!0,queueMicrotask(()=>{this._pendingTabGroupUpdate=!1,this.isDisposed||this.tabsContainer.updateTabGroups()}))}_bracketTabGroupMutation(e){return this.accessor.mutation?this.accessor.mutation("tab-group",e):e()}createTabGroup(e){return this._bracketTabGroupMutation(()=>this._doCreateTabGroup(e))}_doCreateTabGroup(e){var t;const i=(t=e?.id)!==null&&t!==void 0?t:`tg-${this.id}-${this._tabGroupIdCounter++}`,s=new Cm(i,{label:e?.label,color:e?.color,collapsed:e?.collapsed,componentParams:e?.componentParams});return this._tabGroups.push(s),this._tabGroupMap.set(i,s),this._tabGroupDisposables.set(i,new X(s.onDidChange(()=>{this._onDidTabGroupChange.fire({tabGroup:s})}),s.onDidCollapseChange(o=>{o?this._handleGroupCollapse(s):this._handleGroupExpand(s),this._onDidTabGroupCollapsedChange.fire({tabGroup:s})}),s.onDidDestroy(()=>{this._removeTabGroupInternal(s)}))),this._onDidCreateTabGroup.fire({tabGroup:s}),s}dissolveTabGroup(e){const t=this._tabGroupMap.get(e);t&&this._bracketTabGroupMutation(()=>{const i=[...t.panelIds];for(const s of i)t.removePanel(s),this._panelToTabGroup.delete(s),this._onDidRemovePanelFromTabGroup.fire({tabGroup:t,panelId:s});t.dispose()})}addPanelToTabGroup(e,t,i){const s=this._tabGroupMap.get(e);if(!s||!this._panels.some(r=>r.id===t))return;const o=this.getTabGroupForPanel(t);o&&o.id===e||this._bracketTabGroupMutation(()=>{o&&this.removePanelFromTabGroup(t),s.addPanel(t,i),this._panelToTabGroup.set(t,s),this._enforceContiguity(s,t),this._onDidAddPanelToTabGroup.fire({tabGroup:s,panelId:t})})}movePanelWithinGroup(e,t,i){const s=this._tabGroupMap.get(e);!s||!s.containsPanel(t)||(s.removePanel(t),s.addPanel(t,i),this._enforceContiguity(s,t),this.tabsContainer.updateTabGroups())}movePanelBetweenGroups(e,t,i){const s=this._findTabGroupForPanel(e),o=this._tabGroupMap.get(t);o&&(s&&(s.removePanel(e),this._panelToTabGroup.delete(e),this._onDidRemovePanelFromTabGroup.fire({tabGroup:s,panelId:e}),s.isEmpty&&s.dispose()),o.addPanel(e,i),this._panelToTabGroup.set(e,o),this._enforceContiguity(o,e),this._onDidAddPanelToTabGroup.fire({tabGroup:o,panelId:e}))}moveTabGroup(e,t){const i=this._tabGroupMap.get(e);if(!i||i.panelIds.length===0)return;const s=new Set(i.panelIds),o=i.panelIds.map(c=>this._panels.find(h=>h.id===c)).filter(c=>c!==void 0);if(o.length===0)return;let r=0;for(let c=0;c<Math.min(t,this._panels.length);c++)s.has(this._panels[c].id)&&r++;for(const c of o){const h=this._panels.indexOf(c);h!==-1&&this._panels.splice(h,1)}const l=t-r,d=Math.max(0,Math.min(l,this._panels.length));this._panels.splice(d,0,...o);for(const c of this._panels)this.tabsContainer.delete(c.id);for(let c=0;c<this._panels.length;c++)this.tabsContainer.openPanel(this._panels[c],c);this.tabsContainer.updateTabGroups()}_enforceContiguity(e,t){const i=this._panels.find(d=>d.id===t);if(!i)return;const s=e.indexOfPanel(t),o=this._computeGlobalIndex(e,s),r=this._panels.indexOf(i);if(r===o)return;this._panels.splice(r,1);const l=o>r?o-1:o;this._panels.splice(l,0,i),this.tabsContainer.delete(t),this.tabsContainer.openPanel(i,l)}_computeGlobalIndex(e,t){const i=e.panelIds;if(i.length<=1){const s=this._panels.find(o=>o.id===i[0]);return s?this._panels.indexOf(s):this._panels.length}for(let s=0;s<i.length;s++){if(s===t)continue;const o=this._panels.find(r=>r.id===i[s]);if(o){const r=this._panels.indexOf(o);return Math.max(0,r+(t-s))}}return this._panels.length}removePanelFromTabGroup(e){const t=this._findTabGroupForPanel(e);t&&this._bracketTabGroupMutation(()=>{t.removePanel(e),this._panelToTabGroup.delete(e),this._onDidRemovePanelFromTabGroup.fire({tabGroup:t,panelId:e}),t.isEmpty&&t.dispose()})}getTabGroups(){return this._tabGroups}updateTabGroups(){this.tabsContainer.updateTabGroups()}refreshTabGroupAccent(){this.tabsContainer.refreshTabGroupAccent()}refreshWatermark(){var e,t;this.watermark&&(this.watermark.element.remove(),(t=(e=this.watermark).dispose)===null||t===void 0||t.call(e),this.watermark=void 0),this.updateContainer()}getTabGroupForPanel(e){return this._findTabGroupForPanel(e)}_findTabGroupForPanel(e){return this._panelToTabGroup.get(e)}_removeTabGroupInternal(e){const t=this._tabGroups.indexOf(e);if(t!==-1){this._tabGroups.splice(t,1),this._tabGroupMap.delete(e.id);for(const s of e.panelIds)this._panelToTabGroup.delete(s);this._onDidDestroyTabGroup.fire({tabGroup:e});const i=this._tabGroupDisposables.get(e.id);this._tabGroupDisposables.delete(e.id),i&&(this._pendingMicrotaskDisposables.add(i),queueMicrotask(()=>{this._pendingMicrotaskDisposables.delete(i),i.dispose()}))}}_handleGroupCollapse(e){if(!this._activePanel||!e.containsPanel(this._activePanel.id))return;const t=this._panels.indexOf(this._activePanel);for(let i=t+1;i<this._panels.length;i++){const s=this._panels[i],o=this._findTabGroupForPanel(s.id);if(!o||!o.collapsed){this.doSetActivePanel(s),this.updateContainer();return}}for(let i=t-1;i>=0;i--){const s=this._panels[i],o=this._findTabGroupForPanel(s.id);if(!o||!o.collapsed){this.doSetActivePanel(s),this.updateContainer();return}}this.contentContainer.closePanel(),this.doSetActivePanel(void 0),this.updateContainer()}_handleGroupExpand(e){if(this._activePanel)return;const t=e.panelIds[0];if(t){const i=this._panels.find(s=>s.id===t);i&&(this.doSetActivePanel(i),this.updateContainer())}}restoreTabGroups(e){for(const t of e){const i=t.id.match(/-(\d+)$/);if(i){const s=parseInt(i[1],10)+1;s>this._tabGroupIdCounter&&(this._tabGroupIdCounter=s)}}for(const t of e){const i=this.createTabGroup({id:t.id,label:t.label,color:t.color,componentParams:t.componentParams}),s=this._tabGroupMap.get(i.id);for(const o of t.panelIds)this._panels.some(r=>r.id===o)&&(i.addPanel(o),this._panelToTabGroup.set(o,s),this._enforceContiguity(s,o));t.collapsed&&i.collapse(),i.isEmpty&&i.dispose()}}focusContent(){this.contentContainer.element.focus()}focusActiveTab(){this.tabsContainer.focusActiveTab()}set renderContainer(e){this.panels.forEach(t=>{this.renderContainer.detatch(t)}),this._overwriteRenderContainer=e,this.panels.forEach(t=>{this.rerender(t)})}get renderContainer(){var e;return(e=this._overwriteRenderContainer)!==null&&e!==void 0?e:this.accessor.overlayRenderContainer}set dropTargetContainer(e){this._overwriteDropTargetContainer=e}get dropTargetContainer(){var e;return(e=this._overwriteDropTargetContainer)!==null&&e!==void 0?e:this.accessor.rootDropTargetContainer}initialize(){this.options.panels&&this.options.panels.forEach(e=>{this.doAddPanel(e)}),this.options.activePanel&&this.openPanel(this.options.activePanel),this.setActive(this.isActive,!0),this.updateContainer(),this.updateHeaderActions()}updateHeaderActions(){var e;(e=this.accessor.headerActionsService)===null||e===void 0||e.refresh(this.groupPanel)}attachHeaderAction(e,t){switch(e){case"left":this.tabsContainer.setLeftActionsElement(t);break;case"right":this.tabsContainer.setRightActionsElement(t);break;case"prefix":this.tabsContainer.setPrefixActionsElement(t);break}}rerender(e){this.contentContainer.renderPanel(e,{asActive:!1})}indexOf(e){return this.tabsContainer.indexOf(e.id)}toJSON(){var e;const t={views:this.tabsContainer.panels,activeView:(e=this._activePanel)===null||e===void 0?void 0:e.id,id:this.id};return this.locked!==!1&&(t.locked=this.locked),this.header.hidden&&(t.hideHeader=!0),this.headerPosition!=="top"&&(t.headerPosition=this.headerPosition),this._tabGroups.length>0&&(t.tabGroups=this._tabGroups.map(i=>i.toJSON())),t}moveToNext(e){e||(e={}),e.panel||(e.panel=this.activePanel);const t=e.panel?this.panels.indexOf(e.panel):-1;let i;if(t<this.panels.length-1)i=t+1;else if(!e.suppressRoll)i=0;else return;this.openPanel(this.panels[i])}moveToPrevious(e){if(e||(e={}),e.panel||(e.panel=this.activePanel),!e.panel)return;const t=this.panels.indexOf(e.panel);let i;if(t>0)i=t-1;else if(!e.suppressRoll)i=this.panels.length-1;else return;this.openPanel(this.panels[i])}containsPanel(e){return this.panels.includes(e)}init(e){}update(e){}focus(){var e;(e=this._activePanel)===null||e===void 0||e.focus()}openPanel(e,t={}){(typeof t.index!="number"||t.index>this.panels.length)&&(t.index=this.panels.length);const i=!!t.skipSetActive;if(e.updateParentGroup(this.groupPanel,{skipSetActive:t.skipSetActive}),this.doAddPanel(e,t.index,{skipSetActive:i}),this._activePanel===e){this.contentContainer.renderPanel(e,{asActive:!0});return}i||this.doSetActivePanel(e),t.skipSetGroupActive||this.accessor.doSetGroupActive(this.groupPanel),t.skipSetActive||this.updateContainer()}removePanel(e,t={skipSetActive:!1}){const i=typeof e=="string"?e:e.id,s=this._panels.find(o=>o.id===i);if(!s)throw new Error("invalid operation");return this._removePanel(s,t)}closeAllPanels(){if(this.panels.length>0){const e=[...this.panels];for(const t of e)this.doClose(t)}else this.accessor.removeGroup(this.groupPanel)}closePanel(e){this.doClose(e)}doClose(e){const t=this.panels.length===1&&this.accessor.groups.length===1;this.accessor.removePanel(e,t&&this.accessor.options.noPanelsOverlay==="emptyGroup"?{removeEmptyGroup:!1}:void 0)}isPanelActive(e){return this._activePanel===e}updateActions(e){this.tabsContainer.setRightActionsElement(e)}setActive(e,t=!1){if(!(!t&&this.isActive===e)){if(this._isGroupActive=e,W(this.container,"dv-active-group",e),W(this.container,"dv-inactive-group",!e),this.tabsContainer.setActive(this.isActive),!this._activePanel&&this.panels.length>0){const i=this._panels.find(s=>{const o=this._findTabGroupForPanel(s.id);return!o||!o.collapsed});i&&this.doSetActivePanel(i)}this.updateContainer()}}layout(e,t){var i;this._width=e,this._height=t,this.contentContainer.layout(this._width,this._height),!((i=this._activePanel)===null||i===void 0)&&i.layout&&this._activePanel.layout(this._width,this._height)}_removePanel(e,t){const i=this._activePanel===e;if(this.doRemovePanel(e),i&&this.panels.length>0){const s=this.mostRecentlyUsed[0];this.openPanel(s,{skipSetActive:t.skipSetActive,skipSetGroupActive:t.skipSetActiveGroup})}return this._activePanel&&this.panels.length===0&&this.doSetActivePanel(void 0),t.skipSetActive||this.updateContainer(),e}doRemovePanel(e){const t=this.panels.indexOf(e);if(this._activePanel===e&&this.contentContainer.closePanel(),this.tabsContainer.delete(e.id),this._panels.splice(t,1),this.mostRecentlyUsed.includes(e)){const s=this.mostRecentlyUsed.indexOf(e);this.mostRecentlyUsed.splice(s,1)}const i=this._panelDisposables.get(e.id);i&&(i.dispose(),this._panelDisposables.delete(e.id)),this.removePanelFromTabGroup(e.id),this._onDidRemovePanel.fire({panel:e})}doAddPanel(e,t=this.panels.length,i={skipSetActive:!1}){const o=this._panels.indexOf(e)>-1;this.tabsContainer.show(),this.contentContainer.show(),this.tabsContainer.openPanel(e,t),i.skipSetActive?e.api.renderer==="always"&&this.contentContainer.renderPanel(e,{asActive:!1}):this.contentContainer.openPanel(e),!o&&(this.updateMru(e),this.panels.splice(t,0,e),this._panelDisposables.set(e.id,new X(e.api.onDidTitleChange(r=>this._onDidPanelTitleChange.fire(r)),e.api.onDidParametersChange(r=>this._onDidPanelParametersChange.fire(r)))),this._onDidAddPanel.fire({panel:e}))}doSetActivePanel(e){var t,i,s;this._activePanel!==e&&(this._activePanel=e,e&&(this.tabsContainer.setActivePanel(e),this.contentContainer.setLabelledBy(this.tabsContainer.getTabId(e.id)),this.contentContainer.openPanel(e),e.layout(this._width,this._height),this.updateMru(e),this.contentContainer.refreshFocusState(),this._onDidActivePanelChange.fire({panel:e,origin:(s=(i=(t=this.accessor).currentOrigin)===null||i===void 0?void 0:i.call(t))!==null&&s!==void 0?s:"user"})),this.updateAccessibleLabel())}updateAccessibleLabel(){var e;const t=(e=this._activePanel)===null||e===void 0?void 0:e.title;t?this.container.setAttribute("aria-label",t):this.container.removeAttribute("aria-label")}updateMru(e){this.mostRecentlyUsed.includes(e)&&this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(e),1),this.mostRecentlyUsed=[e,...this.mostRecentlyUsed]}updateContainer(){var e,t;this.panels.forEach(s=>s.runEvents());const i=this.isEmpty||!this._activePanel;if(i&&!this.watermark){const s=this.accessor.createWatermarkComponent();s.init({containerApi:this._api,group:this.groupPanel}),this.watermark=s,U(this.watermark.element,"pointerdown",()=>{this.isActive||this.accessor.doSetGroupActive(this.groupPanel)}),this.contentContainer.element.appendChild(this.watermark.element)}!i&&this.watermark&&(this.watermark.element.remove(),(t=(e=this.watermark).dispose)===null||t===void 0||t.call(e),this.watermark=void 0)}canDisplayOverlay(e,t,i){const s=new Wl(e,i,t,Ae,this.accessor.getPanel(this.id));return this._onUnhandledDragOver.fire(s),s.isAccepted}handleDropEvent(e,t,i,s){if(this.locked==="no-drop-target")return;function o(){switch(e){case"header":return typeof s=="number"?"tab":"header_space";case"content":return"content"}}const r=typeof s=="number"?this.panels[s]:void 0,l=new $l({nativeEvent:t,position:i,panel:r,getData:()=>Ae(),kind:o(),group:this.groupPanel,api:this._api});if(this._onWillDrop.fire(l),l.defaultPrevented)return;const d=Ae();if(d&&d.viewId===this.accessor.id){if(e==="content"&&d.groupId===this.id&&(i==="center"||d.panelId===null&&!d.tabGroupId)||e==="header"&&d.groupId===this.id&&d.panelId===null&&!d.tabGroupId)return;if(d.panelId===null){const{groupId:g}=d;this._onMove.fire({target:i,groupId:g,index:s,tabGroupId:d.tabGroupId});return}if(this.tabsContainer.indexOf(d.panelId)!==-1&&this.tabsContainer.size===1)return;const{groupId:h,panelId:u}=d;if(this.id===h&&!i&&this.tabsContainer.indexOf(u)===s)return;this._onMove.fire({target:i,groupId:d.groupId,itemId:d.panelId,index:s})}else this._onDidDrop.fire(new Wo({nativeEvent:t,position:i,panel:r,getData:()=>Ae(),group:this.groupPanel,api:this._api}))}updateDragAndDropState(){this.tabsContainer.updateDragAndDropState()}dispose(){var e,t,i;super.dispose(),(e=this.watermark)===null||e===void 0||e.element.remove(),(i=(t=this.watermark)===null||t===void 0?void 0:t.dispose)===null||i===void 0||i.call(t),this.watermark=void 0;for(const s of[...this._tabGroups])s.dispose();for(const s of this._tabGroupDisposables.values())s.dispose();this._tabGroupDisposables.clear();for(const s of this._pendingMicrotaskDisposables)s.dispose();this._pendingMicrotaskDisposables.clear();for(const s of this.panels)s.dispose();this.tabsContainer.dispose(),this.contentContainer.dispose()}}class $o extends Nl{constructor(e,t,i){super(e,t),this._onDidConstraintsChangeInternal=new z,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new z,this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new z,this.onDidSizeChange=this._onDidSizeChange.event,this.addDisposables(this._onDidConstraintsChangeInternal,this._onDidConstraintsChange,this._onDidSizeChange),i&&this.initialize(i)}setConstraints(e){this._onDidConstraintsChangeInternal.fire(e)}setSize(e){this._onDidSizeChange.fire(e)}}class Hl extends Mo{get priority(){return this._priority}get snap(){return this._snap}get minimumWidth(){return this.__minimumWidth()}get minimumHeight(){return this.__minimumHeight()}get maximumHeight(){return this.__maximumHeight()}get maximumWidth(){return this.__maximumWidth()}__minimumWidth(){const e=typeof this._minimumWidth=="function"?this._minimumWidth():this._minimumWidth;return e!==this._evaluatedMinimumWidth&&(this._evaluatedMinimumWidth=e,this.updateConstraints()),e}__maximumWidth(){const e=typeof this._maximumWidth=="function"?this._maximumWidth():this._maximumWidth;return e!==this._evaluatedMaximumWidth&&(this._evaluatedMaximumWidth=e,this.updateConstraints()),e}__minimumHeight(){const e=typeof this._minimumHeight=="function"?this._minimumHeight():this._minimumHeight;return e!==this._evaluatedMinimumHeight&&(this._evaluatedMinimumHeight=e,this.updateConstraints()),e}__maximumHeight(){const e=typeof this._maximumHeight=="function"?this._maximumHeight():this._maximumHeight;return e!==this._evaluatedMaximumHeight&&(this._evaluatedMaximumHeight=e,this.updateConstraints()),e}get isActive(){return this.api.isActive}get isVisible(){return this.api.isVisible}constructor(e,t,i,s){super(e,t,s??new $o(e,t)),this._evaluatedMinimumWidth=0,this._evaluatedMaximumWidth=Number.MAX_SAFE_INTEGER,this._evaluatedMinimumHeight=0,this._evaluatedMaximumHeight=Number.MAX_SAFE_INTEGER,this._minimumWidth=0,this._minimumHeight=0,this._maximumWidth=Number.MAX_SAFE_INTEGER,this._maximumHeight=Number.MAX_SAFE_INTEGER,this._snap=!1,this._onDidChange=new z,this.onDidChange=this._onDidChange.event,typeof i?.minimumWidth=="number"&&(this._minimumWidth=i.minimumWidth),typeof i?.maximumWidth=="number"&&(this._maximumWidth=i.maximumWidth),typeof i?.minimumHeight=="number"&&(this._minimumHeight=i.minimumHeight),typeof i?.maximumHeight=="number"&&(this._maximumHeight=i.maximumHeight),this.api.initialize(this),this.addDisposables(this.api.onWillVisibilityChange(o=>{const{isVisible:r}=o,{accessor:l}=this._params;l.setVisible(this,r)}),this.api.onActiveChange(()=>{const{accessor:o}=this._params;o.doSetGroupActive(this)}),this.api.onDidConstraintsChangeInternal(o=>{(typeof o.minimumWidth=="number"||typeof o.minimumWidth=="function")&&(this._minimumWidth=o.minimumWidth),(typeof o.minimumHeight=="number"||typeof o.minimumHeight=="function")&&(this._minimumHeight=o.minimumHeight),(typeof o.maximumWidth=="number"||typeof o.maximumWidth=="function")&&(this._maximumWidth=o.maximumWidth),(typeof o.maximumHeight=="number"||typeof o.maximumHeight=="function")&&(this._maximumHeight=o.maximumHeight)}),this.api.onDidSizeChange(o=>{this._onDidChange.fire({height:o.height,width:o.width})}),this._onDidChange)}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}init(e){e.maximumHeight&&(this._maximumHeight=e.maximumHeight),e.minimumHeight&&(this._minimumHeight=e.minimumHeight),e.maximumWidth&&(this._maximumWidth=e.maximumWidth),e.minimumWidth&&(this._minimumWidth=e.minimumWidth),this._priority=e.priority,this._snap=!!e.snap,super.init(e),typeof e.isVisible=="boolean"&&this.setVisible(e.isVisible)}updateConstraints(){this.api._onDidConstraintsChange.fire({minimumWidth:this._evaluatedMinimumWidth,maximumWidth:this._evaluatedMaximumWidth,minimumHeight:this._evaluatedMinimumHeight,maximumHeight:this._evaluatedMaximumHeight})}toJSON(){const e=super.toJSON(),t=s=>s===Number.MAX_SAFE_INTEGER?void 0:s,i=s=>s<=0?void 0:s;return Object.assign(Object.assign({},e),{minimumHeight:i(this.minimumHeight),maximumHeight:t(this.maximumHeight),minimumWidth:i(this.minimumWidth),maximumWidth:t(this.maximumWidth),snap:this.snap,priority:this.priority})}}const Yt="dockview: DockviewGroupPanelApiImpl not initialized";class Pm extends $o{get location(){if(!this._group)throw new Error(Yt);return this._group.model.location}get boundingBox(){if(!this._group||this._group.model.location.type==="popout")return;const e=this.accessor.element.getBoundingClientRect(),t=this._group.element.getBoundingClientRect();return{left:t.left-e.left,top:t.top-e.top,width:t.width,height:t.height}}get locked(){if(!this._group)throw new Error(Yt);return this._group.locked}set locked(e){if(!this._group)throw new Error(Yt);this._group.locked=e}constructor(e,t){super(e,"__dockviewgroup__"),this.accessor=t,this._onDidLocationChange=new z,this.onDidLocationChange=this._onDidLocationChange.event,this._onDidActivePanelChange=new z,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onDidCollapsedChange=new z,this.onDidCollapsedChange=this._onDidCollapsedChange.event,this.addDisposables(this._onDidLocationChange,this._onDidActivePanelChange,this._onDidCollapsedChange,this._onDidVisibilityChange.event(i=>{i.isVisible&&this._pendingSize&&(super.setSize(this._pendingSize),this._pendingSize=void 0)}))}setSize(e){this._pendingSize=Object.assign({},e),super.setSize(e)}close(){if(this._group)return this.accessor.removeGroup(this._group)}getWindow(){return this.location.type==="popout"?this.location.getWindow():window}setHeaderPosition(e){if(!this._group)throw new Error(Yt);this._group.model.headerPosition=e}getHeaderPosition(){if(!this._group)throw new Error(Yt);return this._group.model.headerPosition}moveTo(e){var t,i,s,o;if(!this._group)throw new Error(Yt);const r=(t=e.group)!==null&&t!==void 0?t:this.accessor.addGroup({direction:Mp((i=e.position)!==null&&i!==void 0?i:"right"),skipSetActive:(s=e.skipSetActive)!==null&&s!==void 0?s:!1});this.accessor.moveGroupOrPanel({from:{groupId:this._group.id},to:{group:r,position:e.group&&(o=e.position)!==null&&o!==void 0?o:"center",index:e.index},skipSetActive:e.skipSetActive})}maximize(){if(!this._group)throw new Error(Yt);this.location.type==="grid"&&this.accessor.maximizeGroup(this._group)}isMaximized(){if(!this._group)throw new Error(Yt);return this.accessor.isMaximizedGroup(this._group)}exitMaximized(){if(!this._group)throw new Error(Yt);this.isMaximized()&&this.accessor.exitMaximizedGroup()}collapse(){this._group&&this.accessor.setEdgeGroupCollapsed(this._group,!0)}expand(){this._group&&this.accessor.setEdgeGroupCollapsed(this._group,!1)}isCollapsed(){return this._group?this.accessor.isEdgeGroupCollapsed(this._group):!1}initialize(e){this._group=e}}const km=100,zm=100;class Bn extends Hl{get minimumWidth(){var e;if(typeof this._explicitConstraints.minimumWidth=="number")return this._explicitConstraints.minimumWidth;const t=(e=this.activePanel)===null||e===void 0?void 0:e.minimumWidth;return typeof t=="number"?t:super.__minimumWidth()}get minimumHeight(){var e;if(typeof this._explicitConstraints.minimumHeight=="number")return this._explicitConstraints.minimumHeight;const t=(e=this.activePanel)===null||e===void 0?void 0:e.minimumHeight;return typeof t=="number"?t:super.__minimumHeight()}get maximumWidth(){var e;if(typeof this._explicitConstraints.maximumWidth=="number")return this._explicitConstraints.maximumWidth;const t=(e=this.activePanel)===null||e===void 0?void 0:e.maximumWidth;return typeof t=="number"?t:super.__maximumWidth()}get maximumHeight(){var e;if(typeof this._explicitConstraints.maximumHeight=="number")return this._explicitConstraints.maximumHeight;const t=(e=this.activePanel)===null||e===void 0?void 0:e.maximumHeight;return typeof t=="number"?t:super.__maximumHeight()}get panels(){return this._model.panels}get activePanel(){return this._model.activePanel}get size(){return this._model.size}get model(){return this._model}get locked(){return this._model.locked}set locked(e){this._model.locked=e}get header(){return this._model.header}constructor(e,t,i){var s,o,r,l,d,c;super(t,"groupview_default",{minimumHeight:(o=(s=i.constraints)===null||s===void 0?void 0:s.minimumHeight)!==null&&o!==void 0?o:zm,minimumWidth:(l=(r=i.constraints)===null||r===void 0?void 0:r.minimumWidth)!==null&&l!==void 0?l:km,maximumHeight:(d=i.constraints)===null||d===void 0?void 0:d.maximumHeight,maximumWidth:(c=i.constraints)===null||c===void 0?void 0:c.maximumWidth},new Pm(t,e)),this._explicitConstraints={},this.api.initialize(this),this._model=new Sm(this.element,e,t,i,this),this.addDisposables(this.model.onDidActivePanelChange(h=>{this.api._onDidActivePanelChange.fire(h)}),this.api.onDidConstraintsChangeInternal(h=>{h.minimumWidth!==void 0&&(this._explicitConstraints.minimumWidth=typeof h.minimumWidth=="function"?h.minimumWidth():h.minimumWidth),h.minimumHeight!==void 0&&(this._explicitConstraints.minimumHeight=typeof h.minimumHeight=="function"?h.minimumHeight():h.minimumHeight),h.maximumWidth!==void 0&&(this._explicitConstraints.maximumWidth=typeof h.maximumWidth=="function"?h.maximumWidth():h.maximumWidth),h.maximumHeight!==void 0&&(this._explicitConstraints.maximumHeight=typeof h.maximumHeight=="function"?h.maximumHeight():h.maximumHeight)}))}focus(){this.api.isActive||this.api.setActive(),super.focus()}initialize(){this._model.initialize()}setActive(e){super.setActive(e),this.model.setActive(e)}layout(e,t){super.layout(e,t),this.model.layout(e,t)}getComponent(){return this._model}toJSON(){return this.model.toJSON()}}const Tm={className:"dockview-theme-abyss",tabGroupIndicator:"none"};class Em extends $o{get location(){return this.group.api.location}get title(){return this.panel.title}get isGroupActive(){return this.group.isActive}get renderer(){return this.panel.renderer}set group(e){const t=this._group;this._group!==e&&(this._group=e,this._onDidGroupChange.fire({}),this.setupGroupEventListeners(t),this._onDidLocationChange.fire({location:this.group.api.location}))}get group(){return this._group}get tabComponent(){return this._tabComponent}constructor(e,t,i,s,o){super(e.id,s),this.panel=e,this.accessor=i,this._onDidTitleChange=new z,this.onDidTitleChange=this._onDidTitleChange.event,this._onDidActiveGroupChange=new z,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._onDidGroupChange=new z,this.onDidGroupChange=this._onDidGroupChange.event,this._onDidRendererChange=new z,this.onDidRendererChange=this._onDidRendererChange.event,this._onDidLocationChange=new z,this.onDidLocationChange=this._onDidLocationChange.event,this.groupEventsDisposable=new $e,this._tabComponent=o,this.initialize(e),this._group=t,this.setupGroupEventListeners(),this.addDisposables(this.groupEventsDisposable,this._onDidRendererChange,this._onDidTitleChange,this._onDidGroupChange,this._onDidActiveGroupChange,this._onDidLocationChange)}getWindow(){return this.group.api.getWindow()}setActive(){this.accessor.withOrigin("api",()=>super.setActive())}moveTo(e){var t,i;this.accessor.moveGroupOrPanel({from:{groupId:this._group.id,panelId:this.panel.id},to:{group:(t=e.group)!==null&&t!==void 0?t:this._group,position:e.group&&(i=e.position)!==null&&i!==void 0?i:"center",index:e.index},skipSetActive:e.skipSetActive})}setTitle(e){this.panel.setTitle(e)}setRenderer(e){this.panel.setRenderer(e)}close(){this.group.model.closePanel(this.panel)}maximize(){this.group.api.maximize()}isMaximized(){return this.group.api.isMaximized()}exitMaximized(){this.group.api.exitMaximized()}setupGroupEventListeners(e){var t;let i=(t=e?.isActive)!==null&&t!==void 0?t:!1;this.groupEventsDisposable.value=new X(this.group.api.onDidVisibilityChange(s=>{const o=!s.isVisible&&this.isVisible,r=s.isVisible&&!this.isVisible,l=this.group.model.isPanelActive(this.panel);(o||r&&l)&&this._onDidVisibilityChange.fire(s)}),this.group.api.onDidLocationChange(s=>{this.group===this.panel.group&&this._onDidLocationChange.fire(s)}),this.group.api.onDidActiveChange(()=>{this.group===this.panel.group&&i!==this.isGroupActive&&(i=this.isGroupActive,this._onDidActiveGroupChange.fire({isActive:this.isGroupActive}))}))}}class Oi extends X{get params(){return this._params}get title(){return this._title}get group(){return this._group}get renderer(){var e;return(e=this._renderer)!==null&&e!==void 0?e:this.accessor.renderer}get minimumWidth(){return this._minimumWidth}get minimumHeight(){return this._minimumHeight}get maximumWidth(){return this._maximumWidth}get maximumHeight(){return this._maximumHeight}constructor(e,t,i,s,o,r,l,d){super(),this.id=e,this.accessor=s,this.containerApi=o,this.view=l,this._renderer=d.renderer,this._group=r,this._minimumWidth=d.minimumWidth,this._minimumHeight=d.minimumHeight,this._maximumWidth=d.maximumWidth,this._maximumHeight=d.maximumHeight,this.api=new Em(this,this._group,s,t,i),this.addDisposables(this.api.onActiveChange(()=>{s.setActivePanel(this)}),this.api.onDidSizeChange(c=>{this.group.api.setSize(c)}),this.api.onDidRendererChange(()=>{this.group.model.rerender(this)}))}init(e){this._params=e.params,this.view.init(Object.assign(Object.assign({},e),{api:this.api,containerApi:this.containerApi})),this.setTitle(e.title)}focus(){const e=new Al;this.api._onWillFocus.fire(e),!e.defaultPrevented&&(this.api.isActive||this.api.setActive())}toJSON(){return{id:this.id,contentComponent:this.view.contentComponent,tabComponent:this.view.tabComponent,params:Object.keys(this._params||{}).length>0?this._params:void 0,title:this.title,renderer:this._renderer,minimumHeight:this._minimumHeight,maximumHeight:this._maximumHeight,minimumWidth:this._minimumWidth,maximumWidth:this._maximumWidth}}setTitle(e){e!==this.title&&(this._title=e,this.view.setTitle(e),this.api._onDidTitleChange.fire({title:e}))}setRenderer(e){e!==this.renderer&&(this._renderer=e,this.api._onDidRendererChange.fire({renderer:e}))}update(e){var t;this._params=Object.assign(Object.assign({},(t=this._params)!==null&&t!==void 0?t:{}),e.params);for(const i of Object.keys(e.params))e.params[i]===void 0&&delete this._params[i];this.view.update({params:this._params})}updateFromStateModel(e){var t,i,s;this._maximumHeight=e.maximumHeight,this._minimumHeight=e.minimumHeight,this._maximumWidth=e.maximumWidth,this._minimumWidth=e.minimumWidth,this.update({params:(t=e.params)!==null&&t!==void 0?t:{}}),this.setTitle((i=e.title)!==null&&i!==void 0?i:this.id),this.setRenderer((s=e.renderer)!==null&&s!==void 0?s:this.accessor.renderer)}updateParentGroup(e,t){this._group=e,this.api.group=this._group;const i=this._group.model.isPanelActive(this),s=this.group.api.isActive&&i;t?.skipSetActive||this.api.isActive!==s&&this.api._onDidActiveChange.fire({isActive:this.group.api.isActive&&i}),this.api.isVisible!==i&&this.api._onDidVisibilityChange.fire({isVisible:i})}runEvents(){const e=this._group.model.isPanelActive(this),t=this.group.api.isActive&&e;this.api.isActive!==t&&this.api._onDidActiveChange.fire({isActive:this.group.api.isActive&&e}),this.api.isVisible!==e&&this.api._onDidVisibilityChange.fire({isVisible:e})}layout(e,t){this.api._onDidDimensionChange.fire({width:e,height:t}),this.view.layout(e,t)}dispose(){this.api.dispose(),this.view.dispose()}}class ka extends X{get element(){return this._element}constructor(){super(),this._element=document.createElement("div"),this._element.className="dv-default-tab",this._content=document.createElement("div"),this._content.className="dv-default-tab-content",this.action=document.createElement("div"),this.action.className="dv-default-tab-action",this.action.appendChild(gm()),this._element.appendChild(this._content),this._element.appendChild(this.action),this.render()}init(e){this._title=e.title,this.addDisposables(e.api.onDidTitleChange(t=>{this._title=t.title,this.render()}),U(this.action,"pointerdown",t=>{t.preventDefault()}),U(this.action,"click",t=>{t.defaultPrevented||(t.preventDefault(),e.api.close())})),this.render()}render(){var e;this._content.textContent!==this._title&&(this._content.textContent=(e=this._title)!==null&&e!==void 0?e:"")}}class Bl{get content(){return this._content}get tab(){return this._tab}constructor(e,t,i,s){this.accessor=e,this.id=t,this.contentComponent=i,this.tabComponent=s,this._content=this.createContentComponent(this.id,i),this._tab=this.createTabComponent(this.id,s)}createTabRenderer(e){var t;const i=this.createTabComponent(this.id,this.tabComponent);return this._params&&i.init(Object.assign(Object.assign({},this._params),{tabLocation:e})),this._updateEvent&&((t=i.update)===null||t===void 0||t.call(i,this._updateEvent)),i}init(e){this._params=e,this.content.init(e),this.tab.init(Object.assign(Object.assign({},e),{tabLocation:"header"}))}setTitle(e){this._params&&(this._params.title=e)}layout(e,t){var i,s;(s=(i=this.content).layout)===null||s===void 0||s.call(i,e,t)}update(e){var t,i,s,o;this._updateEvent=e,(i=(t=this.content).update)===null||i===void 0||i.call(t,e),(o=(s=this.tab).update)===null||o===void 0||o.call(s,e)}dispose(){var e,t,i,s;(t=(e=this.content).dispose)===null||t===void 0||t.call(e),(s=(i=this.tab).dispose)===null||s===void 0||s.call(i)}createContentComponent(e,t){return this.accessor.options.createComponent({id:e,name:t})}createTabComponent(e,t){const i=t??this.accessor.options.defaultTabComponent;if(i){if(this.accessor.options.createTabComponent){const s=this.accessor.options.createTabComponent({id:e,name:i});return s||new ka}console.warn(`dockview: tabComponent '${t}' was not found. falling back to the default tab.`)}return new ka}}class Gm{constructor(e){this.accessor=e}fromJSON(e,t){var i,s;const o=e.id,r=e.params,l=e.title,d=e.view,c=d?d.content.id:(i=e.contentComponent)!==null&&i!==void 0?i:"unknown",h=d?(s=d.tab)===null||s===void 0?void 0:s.id:e.tabComponent,u=new Bl(this.accessor,o,c,h),m=new Oi(o,c,h,this.accessor,new Oo(this.accessor),t,u,{renderer:e.renderer,minimumWidth:e.minimumWidth,minimumHeight:e.minimumHeight,maximumWidth:e.maximumWidth,maximumHeight:e.maximumHeight});return m.init({title:l??o,params:r??{}}),m}}class Im extends X{get element(){return this._element}constructor(){super(),this._element=document.createElement("div"),this._element.className="dv-watermark"}init(e){}}class Am{constructor(){this._orderedList=[]}push(e){this._orderedList=[...this._orderedList.filter(t=>t!==e),e],this.update()}destroy(e){this._orderedList=this._orderedList.filter(t=>t!==e),this.update()}update(){for(let e=0;e<this._orderedList.length;e++)this._orderedList[e].setAttribute("aria-level",`${e}`),this._orderedList[e].style.zIndex=`calc(var(--dv-overlay-z-index, 999) + ${e*2})`}}const Un=new Am;class Mt extends X{set minimumInViewportWidth(e){this.options.minimumInViewportWidth=e}set minimumInViewportHeight(e){this.options.minimumInViewportHeight=e}get element(){return this._element}get isVisible(){return this._isVisible}get headerHeight(){var e,t;return(t=(e=this.options.header)===null||e===void 0?void 0:e.offsetHeight)!==null&&t!==void 0?t:0}constructor(e){super(),this.options=e,this._element=document.createElement("div"),this._onDidChange=new z,this.onDidChange=this._onDidChange.event,this._onDidChangeEnd=new z,this.onDidChangeEnd=this._onDidChangeEnd.event,this._onDidStartMoving=new z,this.onDidStartMoving=this._onDidStartMoving.event,this._dragMove=new $e,this._dragCancelled=!1,this.addDisposables(this._onDidChange,this._onDidChangeEnd,this._onDidStartMoving,this._dragMove),this._element.className="dv-resize-container",this._element.setAttribute("role","dialog"),this._element.setAttribute("aria-modal","false"),this._isVisible=!0,this.setupResize("top"),this.setupResize("bottom"),this.setupResize("left"),this.setupResize("right"),this.setupResize("topleft"),this.setupResize("topright"),this.setupResize("bottomleft"),this.setupResize("bottomright"),this.options.header&&(W(this._element,"dv-resize-container-with-titlebar",!0),this._element.appendChild(this.options.header)),this._element.appendChild(this.options.content),this.options.container.appendChild(this._element),this.setBounds(Object.assign(Object.assign(Object.assign(Object.assign({height:this.options.height,width:this.options.width},"top"in this.options&&{top:this.options.top}),"bottom"in this.options&&{bottom:this.options.bottom}),"left"in this.options&&{left:this.options.left}),"right"in this.options&&{right:this.options.right})),Un.push(this._element)}setVisible(e){e!==this.isVisible&&(this._isVisible=e,W(this.element,"dv-hidden",!this.isVisible))}bringToFront(){Un.push(this._element)}setBounds(e={}){typeof e.height=="number"&&(this._element.style.height=`${e.height}px`),typeof e.width=="number"&&(this._element.style.width=`${e.width}px`),"top"in e&&typeof e.top=="number"&&(this._element.style.top=`${e.top}px`,this._element.style.bottom="auto",this.verticalAlignment="top"),"bottom"in e&&typeof e.bottom=="number"&&(this._element.style.bottom=`${e.bottom}px`,this._element.style.top="auto",this.verticalAlignment="bottom"),"left"in e&&typeof e.left=="number"&&(this._element.style.left=`${e.left}px`,this._element.style.right="auto",this.horiziontalAlignment="left"),"right"in e&&typeof e.right=="number"&&(this._element.style.right=`${e.right}px`,this._element.style.left="auto",this.horiziontalAlignment="right");const t=this.options.container.getBoundingClientRect(),i=this._element.getBoundingClientRect(),s=Math.max(0,this.getMinimumWidth(i.width)),o=Math.max(0,this.getMinimumHeight(i.height));if(this.verticalAlignment==="top"){const r=Ee(i.top-t.top,-o,Math.max(0,t.height-i.height+o));this._element.style.top=`${r}px`,this._element.style.bottom="auto"}if(this.verticalAlignment==="bottom"){const r=Ee(t.bottom-i.bottom,-o,Math.max(0,t.height-i.height+o));this._element.style.bottom=`${r}px`,this._element.style.top="auto"}if(this.horiziontalAlignment==="left"){const r=Ee(i.left-t.left,-s,Math.max(0,t.width-i.width+s));this._element.style.left=`${r}px`,this._element.style.right="auto"}if(this.horiziontalAlignment==="right"){const r=Ee(t.right-i.right,-s,Math.max(0,t.width-i.width+s));this._element.style.right=`${r}px`,this._element.style.left="auto"}this._onDidChange.fire()}toJSON(){const e=this.options.container.getBoundingClientRect(),t=this._element.getBoundingClientRect(),i={};return this.verticalAlignment==="top"?i.top=parseFloat(this._element.style.top):this.verticalAlignment==="bottom"?i.bottom=parseFloat(this._element.style.bottom):i.top=t.top-e.top,this.horiziontalAlignment==="left"?i.left=parseFloat(this._element.style.left):this.horiziontalAlignment==="right"?i.right=parseFloat(this._element.style.right):i.left=t.left-e.left,i.width=t.width,i.height=t.height,i}cancelPendingDrag(){this._dragMove.value&&(this._dragCancelled=!0,W(this._element,"dv-resize-container-dragging",!1),this._dragMove.value=ke.NONE)}setupDrag(e,t={inDragMode:!1}){const i=(s,o)=>{var r,l,d;let c=null,h=!1;this._dragCancelled=!1;const u=this.options.transformDragPosition?(d=(l=(r=this.options).getSiblingBoxes)===null||l===void 0?void 0:l.call(r))!==null&&d!==void 0?d:[]:[],m=Pn();if(s&&typeof o=="number"&&typeof s.setPointerCapture=="function")try{s.setPointerCapture(o)}catch{}const g=()=>{W(this._element,"dv-resize-container-dragging",!1),this._dragMove.value=ke.NONE,this._onDidChangeEnd.fire()};this._dragMove.value=new X({dispose:()=>{if(m.release(),s&&typeof o=="number"&&typeof s.releasePointerCapture=="function")try{s.releasePointerCapture(o)}catch{}}},U(window,"pointermove",p=>{if(this._dragCancelled)return;const f=this.options.container.getBoundingClientRect(),w=p.clientX-f.left,C=p.clientY-f.top;W(this._element,"dv-resize-container-dragging",!0);const b=this._element.getBoundingClientRect();c===null&&(c={x:p.clientX-b.left,y:p.clientY-b.top});const D=Math.max(0,this.getMinimumWidth(b.width)),k=Math.max(0,this.getMinimumHeight(b.height));let P=C-c.y,y=w-c.x;if(this.options.transformDragPosition){const re=this.options.transformDragPosition({proposed:{top:P,left:y,width:b.width,height:b.height},container:{width:f.width,height:f.height},others:u});re&&(P=re.top,y=re.left)}const T=Math.max(0,f.height-b.height+k),S=Math.max(0,f.width-b.width+D),N=Ee(P,-k,T),O=Ee(f.height-b.height-P,-k,T),$=Ee(y,-D,S),F=Ee(f.width-b.width-y,-D,S),q={};N<=O?q.top=N:q.bottom=O,$<=F?q.left=$:q.right=F,this.setBounds(q),h||(h=!0,this._onDidStartMoving.fire())}),U(window,"pointerup",g),U(window,"pointercancel",g))};this.addDisposables(U(e,"pointerdown",s=>{if(s.defaultPrevented){s.preventDefault();return}ya(s)||i(e,s.pointerId)}),U(this.options.content,"pointerdown",s=>{s.defaultPrevented||ya(s)||s.shiftKey&&i(this.options.content,s.pointerId)}),U(this.options.content,"pointerdown",()=>{Un.push(this._element)},!0)),t.inDragMode&&i()}setupResize(e){const t=document.createElement("div");t.className=`dv-resize-handle-${e}`,this._element.appendChild(t);const i=new $e;this.addDisposables(i,U(t,"pointerdown",s=>{s.preventDefault();let o=null;const r=Pn(),l=s.pointerId;if(typeof t.setPointerCapture=="function")try{t.setPointerCapture(l)}catch{}const d=()=>{i.dispose(),this._onDidChangeEnd.fire()};i.value=new X(U(window,"pointermove",c=>{const h=this.options.container.getBoundingClientRect(),u=this._element.getBoundingClientRect(),m=c.clientY-h.top,g=c.clientX-h.left;o===null&&(o={originalY:m,originalHeight:u.height,originalX:g,originalWidth:u.width});let p,f,w,C,b,D;const k=()=>{const N=o.originalY+o.originalHeight>h.height?Math.max(0,h.height-Mt.MINIMUM_HEIGHT):Math.max(0,o.originalY+o.originalHeight-Mt.MINIMUM_HEIGHT);p=Ee(m,0,N),w=o.originalY+o.originalHeight-p,f=h.height-p-w},P=()=>{p=o.originalY-o.originalHeight;const N=p<0&&typeof this.options.minimumInViewportHeight=="number"?-p+this.options.minimumInViewportHeight:Mt.MINIMUM_HEIGHT,O=h.height-Math.max(0,p);w=Ee(m-p,N,O),f=h.height-p-w},y=()=>{const N=o.originalX+o.originalWidth>h.width?Math.max(0,h.width-Mt.MINIMUM_WIDTH):Math.max(0,o.originalX+o.originalWidth-Mt.MINIMUM_WIDTH);C=Ee(g,0,N),D=o.originalX+o.originalWidth-C,b=h.width-C-D},T=()=>{C=o.originalX-o.originalWidth;const N=C<0&&typeof this.options.minimumInViewportWidth=="number"?-C+this.options.minimumInViewportWidth:Mt.MINIMUM_WIDTH,O=h.width-Math.max(0,C);D=Ee(g-C,N,O),b=h.width-C-D};switch(e){case"top":k();break;case"bottom":P();break;case"left":y();break;case"right":T();break;case"topleft":k(),y();break;case"topright":k(),T();break;case"bottomleft":P(),y();break;case"bottomright":P(),T();break}const S={};p<=f?S.top=p:S.bottom=f,C<=b?S.left=C:S.right=b,S.height=w,S.width=D,this.setBounds(S)}),{dispose:()=>{if(r.release(),typeof t.releasePointerCapture=="function")try{t.releasePointerCapture(l)}catch{}}},U(window,"pointerup",d),U(window,"pointercancel",d))}))}getMinimumWidth(e){return typeof this.options.minimumInViewportWidth=="number"?e-this.options.minimumInViewportWidth:0}getMinimumHeight(e){return typeof this.options.minimumInViewportHeight=="number"?e-this.options.minimumInViewportHeight:0}dispose(){Un.destroy(this._element),this._element.remove(),super.dispose()}}Mt.MINIMUM_HEIGHT=20;Mt.MINIMUM_WIDTH=20;class Nm extends X{get element(){return this._element}get group(){return this._group}setGroup(e){this._group=e}constructor(e,t){super(),this.accessor=e,this._onDragStart=new z,this.onDragStart=this._onDragStart.event,this._group=t,this._element=document.createElement("div"),this._element.className="dv-floating-titlebar",this.addDisposables(this._onDragStart,U(this._element,"pointerdown",()=>{this.accessor.doSetGroupActive(this._group)}),U(this._element,"pointerdown",i=>{i.shiftKey&&gl(i)},!0)),this.dragSource=new Ol({element:this._element,accessor:this.accessor,group:()=>this._group}),this.addDisposables(this.dragSource,this.dragSource.onDragStart(i=>{this._onDragStart.fire(i)}))}updateDragAndDropState(){this.dragSource.updateDragAndDropState()}}function bt(n){return{moduleName:n.name,services:{[n.serviceKey]:n.create},init:n.init?(e,t)=>n.init(e,t[n.serviceKey]):void 0,dependsOn:n.dependsOn}}const za=new Set;function fi(n,e,t){if(n!==void 0)return n;const i=`${e}|${t??""}`;if(za.has(i))return;za.add(i);const s=t?` for ${t}`:"";console.error(`dockview: module "${e}" is not registered${s}.`)}class jm{constructor(){this._modules=new Map,this._services={},this._initDisposables=[]}get services(){return this._services}register(e){if(!this._modules.has(e.moduleName)){if(e.dependsOn)for(const t of e.dependsOn)this.register(t);this._modules.set(e.moduleName,e)}}initialize(e){for(const t of this._modules.values())if(t.services)for(const[i,s]of Object.entries(t.services))this._services[i]=s(e)}postConstruct(e){for(const t of this._modules.values())t.init&&this._initDisposables.push(t.init(e,this._services))}has(e){return this._modules.has(e)}dispose(){for(const e of this._initDisposables)e.dispose();this._initDisposables.length=0;for(const e of Object.values(this._services))e!==void 0&&typeof e.dispose=="function"&&e.dispose()}}const vo=[];function Om(n){for(const e of n)vo.some(t=>t.moduleName===e.moduleName)||vo.push(e)}function Mm(){return[...vo]}let Ul=!1;function Lm(){Ul=!0}function Rm(){return Ul}const ps=100,di={left:100,top:100,width:300,height:300},Vm=100;class Fm extends X{get group(){return this._group}setTitleBar(e){this._titleBar=e}setAnchorGroup(e){var t;this._group=e,(t=this._titleBar)===null||t===void 0||t.setGroup(e)}constructor(e,t,i){super(),this.overlay=t,this.gridview=i,this._group=e,this.addDisposables(t,{dispose:()=>this.gridview.dispose()})}position(e){this.overlay.setBounds(e)}}class Wm{get floatingGroups(){return this._floatingGroups}constructor(e){this._floatingGroups=[],this._host=e}add(e,t,i){const s=new Fm(e,t,i),o=new X(e.api.onDidActiveChange(l=>{l.isActive&&t.bringToFront()}),(()=>{let l=-1,d=-1;return Gn(i.element,c=>{const h=Math.round(c.contentRect.width),u=Math.round(c.contentRect.height);h===l&&u===d||(l=h,d=u,i.layout(h,u))})})()),r=()=>{var l;const d=(l=e.activePanel)===null||l===void 0?void 0:l.title;d?t.element.setAttribute("aria-label",d):t.element.removeAttribute("aria-label")};return r(),s.addDisposables(e.api.onDidActivePanelChange(()=>r()),t.onDidChange(()=>{i.layout(i.width,i.height)}),t.onDidChangeEnd(()=>{this._host.fireLayoutChange()}),e.onDidChange(l=>{t.setBounds({height:typeof l?.height=="number"?l.height+t.headerHeight:l?.height,width:l?.width})}),{dispose:()=>{o.dispose(),bl(this._floatingGroups,s),e.model.location={type:"grid"}}}),this._floatingGroups.push(s),s}findByGroup(e){return this._floatingGroups.find(t=>t.group===e||t.gridview.element.contains(e.element))}serialize(){return this._floatingGroups.map(e=>{const t=e.gridview.serialize(),i=e.overlay.toJSON(),s=t.root;return s.type==="branch"&&s.data.length===1&&s.data[0].type==="leaf"?{data:s.data[0].data,position:i}:{grid:t,position:i}})}constrainBounds(){for(const e of this._floatingGroups)e.overlay.setBounds()}updateBounds(e){var t,i;if("floatingGroupBounds"in e)for(const s of this._floatingGroups){switch(e.floatingGroupBounds){case"boundedWithinViewport":s.overlay.minimumInViewportHeight=void 0,s.overlay.minimumInViewportWidth=void 0;break;case void 0:s.overlay.minimumInViewportHeight=ps,s.overlay.minimumInViewportWidth=ps;break;default:s.overlay.minimumInViewportHeight=(t=e.floatingGroupBounds)===null||t===void 0?void 0:t.minimumHeightWithinViewport,s.overlay.minimumInViewportWidth=(i=e.floatingGroupBounds)===null||i===void 0?void 0:i.minimumWidthWithinViewport}s.overlay.setBounds()}}disposeAll(){for(const e of[...this._floatingGroups])e.dispose()}dispose(){this.disposeAll()}}const $m=bt({name:"FloatingGroup",serviceKey:"floatingGroupService",create:n=>new Wm(n)});class Hm{constructor(e){this._entries=[],this._popupServices=new Map,this._restorationCleanups=new Set,this._restorationPromise=Promise.resolve(),this._onDidRemove=new z,this.onDidRemove=this._onDidRemove.event,this._host=e}get entries(){return this._entries}get restorationPromise(){return this._restorationPromise}add(e){this._entries.push(e)}remove(e){bl(this._entries,e)&&!this._host.isDisposed&&this._onDidRemove.fire(e)}findByGroup(e){return this._entries.find(t=>t.popoutGroup===e||t.gridview.element.contains(e.element))}findReferenceGroupId(e){var t;return(t=this._entries.find(i=>i.popoutGroup===e))===null||t===void 0?void 0:t.referenceGroup}observeGridviewSize(e,t,i){var s;const o=(s=e.window)===null||s===void 0?void 0:s.ResizeObserver;if(!o)return;let r=-1,l=-1;const d=()=>{const h=e.window;if(this._host.isDisposed||!h||h.closed)return;const u=Math.round(t.element.clientWidth),m=Math.round(t.element.clientHeight);u===r&&m===l||(r=u,l=m,u>0&&m>0&&t.layout(u,m),i.updateAllPositions())},c=new o(()=>{var h;const u=(h=e.window)===null||h===void 0?void 0:h.requestAnimationFrame;u?u.call(e.window,d):d()});return c.observe(t.element),{dispose:()=>c.disconnect()}}getPopupService(e){return this._popupServices.get(e)}setPopupService(e,t){this._popupServices.set(e,t)}deletePopupService(e){this._popupServices.delete(e)}scheduleRestoration(e,t,i){return new Promise(s=>{const o=()=>{this._restorationCleanups.delete(o),clearTimeout(r),i?.(),s()},r=setTimeout(()=>{if(this._restorationCleanups.delete(o),this._host.isDisposed){s();return}t(),s()},e);this._restorationCleanups.add(o)})}finishRestoration(e){this._restorationPromise=Promise.all(e).then(()=>{})}cancelPendingRestorations(){for(const e of[...this._restorationCleanups])e();this._restorationCleanups.clear()}serialize(){return this._entries.map(e=>{const t=e.gridview.serialize(),i=t.root,s=e.popoutGroup.api.location.type==="popout"?e.popoutGroup.api.location.popoutUrl:void 0,o={gridReferenceGroup:e.referenceGroup,position:e.window.dimensions(),url:s};return i.type==="branch"&&i.data.length===1&&i.data[0].type==="leaf"?Object.assign(Object.assign({},o),{data:i.data[0].data}):Object.assign(Object.assign({},o),{grid:t})})}disposeAll(){for(const e of[...this._entries])e.disposable.dispose()}dispose(){this.cancelPendingRestorations(),this.disposeAll(),this._onDidRemove.dispose()}}const Bm=bt({name:"PopoutWindow",serviceKey:"popoutWindowService",create:n=>new Hm(n)});class Um{constructor(e){this._watermark=null,this._host=e}update(){if(this._host.hasVisibleGridGroup()){this._unmount();return}if(this._watermark)return;this._watermark=this._host.createWatermarkComponent(),this._watermark.init({containerApi:this._host.api});const e=document.createElement("div");e.className="dv-watermark-container",wp(e,"watermark-component"),e.appendChild(this._watermark.element),this._host.mountElement.appendChild(e)}refresh(){this._unmount(),this.update()}_unmount(){var e,t;this._watermark&&(this._watermark.element.parentElement.remove(),(t=(e=this._watermark).dispose)===null||t===void 0||t.call(e),this._watermark=null)}dispose(){this._unmount()}}const Ym=bt({name:"Watermark",serviceKey:"watermarkService",create:n=>new Um(n),init:(n,e)=>(e.update(),new X(wt.any(n.onDidAdd,n.onDidRemove)(()=>{e.update()}),n.onDidViewVisibilityChangeMicroTaskQueue(()=>{e.update()})))});class Xm{constructor(){this._edgeGroups=new Map,this._edgeGroupDisposables=new Map}add(e,t,i){this._edgeGroups.set(e,t),this._edgeGroupDisposables.set(e,i)}remove(e){var t;(t=this._edgeGroupDisposables.get(e))===null||t===void 0||t.dispose(),this._edgeGroupDisposables.delete(e),this._edgeGroups.delete(e)}get(e){return this._edgeGroups.get(e)}has(e){return this._edgeGroups.has(e)}hasAny(){return this._edgeGroups.size>0}entries(){return this._edgeGroups.entries()}includes(e){for(const t of this._edgeGroups.values())if(t===e)return!0;return!1}findPositionOf(e){for(const[t,i]of this._edgeGroups)if(i===e)return t}disposeAll(){for(const e of this._edgeGroupDisposables.values())e.dispose();this._edgeGroupDisposables.clear(),this._edgeGroups.clear()}dispose(){this.disposeAll()}}const Km=bt({name:"EdgeGroup",serviceKey:"edgeGroupService",create:()=>new Xm}),$s={activationSize:{type:"pixels",value:10},size:{type:"pixels",value:20}};class qm{constructor(e){const t=(s,o)=>{const r=Ae();return r?r.viewId!==e.id?!1:o==="center"?e.isGridEmpty():!0:o==="center"&&!e.isGridEmpty()?!1:e.dispatchUnhandledDragOver(s,o)},i=typeof e.options.dndEdges=="object"&&e.options.dndEdges!==null?e.options.dndEdges:$s;this._html5Target=pi.createDropTarget(e.element,{className:"dv-drop-target-edge",canDisplayOverlay:t,acceptedTargetZones:["top","bottom","left","right","center"],overlayModel:i,getOverrideTarget:()=>e.rootDropTargetOverrideTarget()}),this._pointerTarget=si.createDropTarget(e.element,{className:"dv-drop-target-edge",canDisplayOverlay:t,acceptedTargetZones:["top","bottom","left","right","center"],overlayModel:i,getOverrideTarget:()=>e.rootDropTargetOverrideTarget()}),this.onWillShowOverlay=wt.any(this._html5Target.onWillShowOverlay,this._pointerTarget.onWillShowOverlay),this.onDrop=wt.any(this._html5Target.onDrop,this._pointerTarget.onDrop),this.setOptions(e.options)}setOptions(e){if("dndEdges"in e){const t=typeof e.dndEdges=="boolean"&&e.dndEdges===!1;this._html5Target.disabled=t,this._pointerTarget.disabled=t,typeof e.dndEdges=="object"&&e.dndEdges!==null?(this._html5Target.setOverlayModel(e.dndEdges),this._pointerTarget.setOverlayModel(e.dndEdges)):(this._html5Target.setOverlayModel($s),this._pointerTarget.setOverlayModel($s))}}dispose(){this._html5Target.dispose(),this._pointerTarget.dispose()}}const Jm=bt({name:"RootDropTarget",serviceKey:"rootDropTargetService",create:n=>new qm(n)}),Zm={left:"createLeftHeaderActionComponent",right:"createRightHeaderActionComponent",prefix:"createPrefixHeaderActionComponent"};class Qm{constructor(e){this._perGroup=new Map,this._host=e}refresh(e){if(!e?.model)return;const t=this._ensureState(e);this._refreshSlot("left",e,t.left),this._refreshSlot("right",e,t.right),this._refreshSlot("prefix",e,t.prefix)}refreshAll(){for(const e of this._host.groups)this.refresh(e)}disposeGroup(e){const t=this._perGroup.get(e);t&&(t.left.dispose(),t.right.dispose(),t.prefix.dispose(),this._perGroup.delete(e))}dispose(){for(const e of[...this._perGroup.keys()])this.disposeGroup(e)}_ensureState(e){let t=this._perGroup.get(e);return t||(t={left:new $e,right:new $e,prefix:new $e},this._perGroup.set(e,t)),t}_refreshSlot(e,t,i){const s=this._host.options[Zm[e]];if(s){const o=s(t);i.value=o,o.init({containerApi:this._host.api,api:t.api,group:t}),t.model.attachHeaderAction(e,o.element)}else i.dispose(),t.model.attachHeaderAction(e,void 0)}}const ev=bt({name:"HeaderActions",serviceKey:"headerActionsService",create:n=>new Qm(n),init:(n,e)=>new X(n.onDidRemoveGroup(t=>{e.disposeGroup(t)}))});function tv(n,e){return n==="center"?`Tab into ${e}`:`Split ${n} of ${e}`}function iv(n,e){return n==="center"?`docked into ${e}`:`split ${n} of ${e}`}const Ta={panelOpened:n=>`${n} opened`,panelClosed:n=>`${n} closed`,groupMaximized:n=>`${n} maximized`,groupRestored:n=>`${n} restored`,groupFloated:n=>`${n} floated`,groupDocked:n=>`${n} docked`,groupPoppedOut:n=>`${n} opened in a new window`,movePickTarget:(n,e,t,i)=>`Moving ${n}. Target ${e}, ${t} of ${i}. Enter to choose where, Escape to cancel.`,movePickEdge:(n,e)=>`${tv(n,e)}. Arrows to change, Enter to confirm, Escape to go back.`,moveCommitted:(n,e,t)=>`${n} ${iv(t,e)}.`,moveCancelled:()=>"Move cancelled.",moveNotAllowed:()=>"That move is not allowed."};function Yl(n){return n?Object.assign(Object.assign({},Ta),n):Ta}const Ea=n=>n==="load"||n==="clear";function Ga(n){const e=document.createElement("div");return e.className=n==="assertive"?"dv-live-region-assertive":"dv-live-region",e.setAttribute("role",n==="assertive"?"alert":"status"),e.setAttribute("aria-live",n),e.setAttribute("aria-atomic","true"),Object.assign(e.style,{position:"absolute",width:"1px",height:"1px",margin:"-1px",padding:"0",overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:"0"}),e}class nv extends X{constructor(e){super(),this._suppressDepth=0,this._locationSubs=new Map,this._host=e,this._polite=Ga("polite"),this._assertive=Ga("assertive"),e.element.appendChild(this._polite),e.element.appendChild(this._assertive),this.addDisposables({dispose:()=>this._polite.remove()},{dispose:()=>this._assertive.remove()},e.onDidAddPanel(t=>this._announce(t,"open")),e.onDidRemovePanel(t=>this._announce(t,"close")),e.onWillMutateLayout(t=>{Ea(t.kind)&&this._suppressDepth++}),e.onDidMutateLayout(t=>{Ea(t.kind)&&(this._suppressDepth=Math.max(0,this._suppressDepth-1))}),e.onDidMaximizedGroupChange(t=>{const i=t.group.activePanel;i&&this._announce(i,t.isMaximized?"maximize":"restore")}),e.onDidAddGroup(t=>this._trackLocation(t)),e.onDidRemoveGroup(t=>{var i;(i=this._locationSubs.get(t.id))===null||i===void 0||i.dispose(),this._locationSubs.delete(t.id)}),{dispose:()=>{this._locationSubs.forEach(t=>t.dispose()),this._locationSubs.clear()}})}_trackLocation(e){let t=e.api.location.type;const i=e.api.onDidLocationChange(s=>{const o=s.location.type;if(o===t)return;t=o;const r=e.activePanel;if(!r)return;const l=o==="floating"?"float":o==="popout"?"popout":"dock";this._announce(r,l)});this._locationSubs.set(e.id,i)}announce(e,t="polite"){if(this._host.options.announcements===!1||this._suppressDepth>0||!e)return;const i=this._host.options.announcer;if(i){i({message:e,politeness:t});return}const s=t==="assertive"?this._assertive:this._polite;s.textContent="",s.textContent=e}_announce(e,t){var i,s;const o=(s=(i=this._host.options).getAnnouncement)===null||s===void 0?void 0:s.call(i,{kind:t,panel:e});o===null||o===""||this.announce(o??this._defaultMessage(e,t))}_defaultMessage(e,t){var i;const s=Yl(this._host.options.messages),o=(i=e.title)!==null&&i!==void 0?i:e.id;switch(t){case"open":return s.panelOpened(o);case"close":return s.panelClosed(o);case"maximize":return s.groupMaximized(o);case"restore":return s.groupRestored(o);case"float":return s.groupFloated(o);case"dock":return s.groupDocked(o);case"popout":return s.groupPoppedOut(o)}}}const Xl=bt({name:"LiveRegion",serviceKey:"liveRegionService",create:n=>new nv(n)}),sv=[$m,Bm,Ym,Km,Jm,ev,Xl];class ov{constructor(){this.cache=new Map,this.currentFrameId=0,this.rafId=null}getPosition(e){const t=this.cache.get(e);if(t&&t.frameId===this.currentFrameId)return t.rect;this.scheduleFrameUpdate();const i=oo(e);return this.cache.set(e,{rect:i,frameId:this.currentFrameId}),i}invalidate(){this.currentFrameId++}scheduleFrameUpdate(){this.rafId||(this.rafId=requestAnimationFrame(()=>{this.currentFrameId++,this.rafId=null}))}}function av(){const n=document.createElement("div");return n.tabIndex=-1,n}class Ia extends X{constructor(e,t){super(),this.element=e,this.accessor=t,this.map={},this._disposed=!1,this.positionCache=new ov,this.pendingUpdates=new Set,this.addDisposables(ke.from(()=>{for(const i of Object.values(this.map))i.disposable.dispose(),i.destroy.dispose();this._disposed=!0}))}updateAllPositions(){if(!this._disposed){this.positionCache.invalidate();for(const e of Object.values(this.map))e.panel.api.isVisible&&e.resize&&e.resize()}}detatch(e){if(this.map[e.api.id]){const{disposable:t,destroy:i}=this.map[e.api.id];return t.dispose(),i.dispose(),delete this.map[e.api.id],!0}return!1}attach(e){const{panel:t,referenceContainer:i}=e;if(!this.map[t.api.id]){const u=av();u.className="dv-render-overlay",u.style.visibility="hidden",this.map[t.api.id]={panel:t,disposable:ke.NONE,destroy:ke.NONE,element:u}}const s=this.map[t.api.id].element,o=t.view.content.element;o.parentElement!==s&&s.appendChild(o),s.parentElement!==this.element&&this.element.appendChild(s);const r=()=>{const u=t.api.id;this.pendingUpdates.has(u)||(this.pendingUpdates.add(u),requestAnimationFrame(()=>{if(this.pendingUpdates.delete(u),this.isDisposed||!this.map[u])return;const m=this.positionCache.getPosition(i.element),g=this.positionCache.getPosition(this.element),p=m.left-g.left,f=m.top-g.top,w=m.width,C=m.height;s.style.left=`${p}px`,s.style.top=`${f}px`,s.style.width=`${w}px`,s.style.height=`${C}px`,t.api.isVisible?(s.style.visibility="",s.style.pointerEvents=""):(s.style.visibility="hidden",s.style.pointerEvents="none"),W(s,"dv-render-overlay-float",t.group.api.location.type==="floating")}))},l=()=>{t.api.isVisible?(this.positionCache.invalidate(),r(),s.style.pointerEvents=""):(s.style.visibility="hidden",s.style.pointerEvents="none")},d=new $e,c=()=>{t.api.location.type==="floating"?queueMicrotask(()=>{const u=this.accessor.floatingGroups.find(f=>f.group===t.api.group);if(!u)return;const m=u.overlay.element,g=()=>{const f=Number(m.getAttribute("aria-level"));s.style.zIndex=`calc(var(--dv-overlay-z-index, 999) + ${f*2+1})`},p=new MutationObserver(()=>{g()});d.value=ke.from(()=>p.disconnect()),p.observe(m,{attributeFilter:["aria-level"],attributes:!0}),g()}):s.style.zIndex=""},h=new X(d,new Pl(s,{onDragEnd:u=>{i.dropTarget.dnd.onDragEnd(u)},onDragEnter:u=>{i.dropTarget.dnd.onDragEnter(u)},onDragLeave:u=>{i.dropTarget.dnd.onDragLeave(u)},onDrop:u=>{i.dropTarget.dnd.onDrop(u)},onDragOver:u=>{i.dropTarget.dnd.onDragOver(u)}}),t.api.onDidVisibilityChange(()=>{l()}),t.api.onDidDimensionsChange(()=>{t.api.isVisible&&r()}),t.api.onDidLocationChange(()=>{c()}));return this.map[t.api.id].destroy=ke.from(()=>{var u;o.parentElement===s&&s.removeChild(o),(u=s.parentElement)===null||u===void 0||u.removeChild(s)}),c(),queueMicrotask(()=>{this.isDisposed||l()}),this.map[t.api.id].disposable.dispose(),this.map[t.api.id].disposable=h,this.map[t.api.id].resize=r,s}}function rv(n,e,t,i){function s(o){return o instanceof t?o:new t(function(r){r(o)})}return new(t||(t=Promise))(function(o,r){function l(h){try{c(i.next(h))}catch(u){r(u)}}function d(h){try{c(i.throw(h))}catch(u){r(u)}}function c(h){h.done?o(h.value):s(h.value).then(l,d)}c((i=i.apply(n,[])).next())})}function lv(n){let e;try{e=new URL(n,window.location.href)}catch{throw new Error(`dockview: invalid popout URL: ${n}`)}if(!(e.protocol==="http:"||e.protocol==="https:")||e.origin!==window.location.origin)throw new Error(`dockview: popout URL must be same-origin http(s); got: ${n}`)}class dv extends X{get window(){var e,t;return(t=(e=this._window)===null||e===void 0?void 0:e.value)!==null&&t!==void 0?t:null}constructor(e,t,i){super(),this.target=e,this.className=t,this.options=i,this._onWillClose=new z,this.onWillClose=this._onWillClose.event,this._onDidClose=new z,this.onDidClose=this._onDidClose.event,this._window=null,this.addDisposables(this._onWillClose,this._onDidClose,{dispose:()=>{this.close()}})}dimensions(){if(!this._window)return null;const e=this._window.value.screenX,t=this._window.value.screenY,i=this._window.value.innerWidth,s=this._window.value.innerHeight;return{top:t,left:e,width:i,height:s}}close(){var e,t;this._window&&(this._onWillClose.fire(),(t=(e=this.options).onWillClose)===null||t===void 0||t.call(e,{id:this.target,window:this._window.value}),this._window.disposable.dispose(),this._window=null,this._onDidClose.fire())}open(){return rv(this,void 0,void 0,function*(){var e,t;if(this._window)throw new Error("instance of popout window is already open");const i=`${this.options.url}`;lv(i);const s=Object.entries({top:this.options.top,left:this.options.left,width:this.options.width,height:this.options.height}).map(([d,c])=>`${d}=${c}`).join(","),o=window.open(i,this.target,s);if(!o)return null;const r=new X;this._window={value:o,disposable:r},r.addDisposables(ke.from(()=>{o.close()}),U(window,"beforeunload",()=>{this.close()}));const l=this.createPopoutWindowContainer();return this.className&&l.classList.add(this.className),(t=(e=this.options).onDidOpen)===null||t===void 0||t.call(e,{id:this.target,window:o}),new Promise((d,c)=>{o.addEventListener("unload",h=>{}),o.addEventListener("load",()=>{try{const h=o.document;h.title=document.title,h.body.appendChild(l),fp(h,window.document.styleSheets,{nonce:this.options.nonce}),U(o,"beforeunload",()=>{this.close()}),d(l)}catch(h){c(h)}})})})}createPopoutWindowContainer(){const e=document.createElement("div");return e.classList.add("dv-popout-window"),e.id="dv-popout-window",e.style.position="absolute",e.style.width="100%",e.style.height="100%",e.style.top="0px",e.style.left="0px",e}}class cv extends X{constructor(e){super(),this.accessor=e,this.init()}init(){const e=new Set,t=new Set;this.addDisposables(this.accessor.onDidAddPanel(i=>{if(e.has(i.api.id))throw new Error(`dockview: Invalid event sequence. [onDidAddPanel] called for panel ${i.api.id} but panel already exists`);e.add(i.api.id)}),this.accessor.onDidRemovePanel(i=>{if(e.has(i.api.id))e.delete(i.api.id);else throw new Error(`dockview: Invalid event sequence. [onDidRemovePanel] called for panel ${i.api.id} but panel does not exists`)}),this.accessor.onDidAddGroup(i=>{if(t.has(i.api.id))throw new Error(`dockview: Invalid event sequence. [onDidAddGroup] called for group ${i.api.id} but group already exists`);t.add(i.api.id)}),this.accessor.onDidRemoveGroup(i=>{if(t.has(i.api.id))t.delete(i.api.id);else throw new Error(`dockview: Invalid event sequence. [onDidRemoveGroup] called for group ${i.api.id} but group does not exists`)}))}}function hv(n){if(!n.matchMedia)return!1;const e=n.matchMedia("(pointer: coarse)").matches,t=n.matchMedia("(pointer: fine)").matches;return e&&!t}class Aa extends X{constructor(e,t=window){super(),this._active=null,this._activeDisposable=new $e,this._root=e,this._window=t,this._element=t.document.createElement("div"),this._element.className="dv-popover-anchor",this._element.style.position="relative",this._root.prepend(this._element),this.addDisposables(ke.from(()=>{this.close()}),this._activeDisposable)}updateRoot(e){e.prepend(this._element),this._root=e}openPopover(e,t){var i;this.close();const s=this._window.document.createElement("div");s.style.position="absolute",s.style.zIndex=(i=t.zIndex)!==null&&i!==void 0?i:"var(--dv-overlay-z-index)",s.appendChild(e);const o=this._element.getBoundingClientRect(),r=o.left,l=o.top;s.style.top=`${t.y-l}px`,s.style.left=`${t.x-r}px`,this._element.appendChild(s),this._active=s;const d=Date.now(),c=200;this._activeDisposable.value=new X(U(this._window,"pointerdown",h=>{var u;if(Date.now()-d<c)return;const m=h.target;if(!(m instanceof HTMLElement))return;let g=m;for(;g&&g!==s;)g=(u=g?.parentElement)!==null&&u!==void 0?u:null;g||this.close()}),U(this._window,"keydown",h=>{(h.key==="Escape"||h.key==="Enter")&&this.close()}),U(this._window,"resize",()=>{hv(this._window)||this.close()})),this._window.requestAnimationFrame(()=>{Cp(s,this._root)})}close(){this._active&&(this._active.remove(),this._activeDisposable.dispose(),this._active=null)}}class Na extends X{get disabled(){return this._disabled}set disabled(e){var t;this.disabled!==e&&(this._disabled=e,e&&((t=this.model)===null||t===void 0||t.clear()))}get model(){if(!this.disabled)return{clear:()=>{var e;this._model&&((e=this._model.root.parentElement)===null||e===void 0||e.removeChild(this._model.root)),this._model=void 0},exists:()=>!!this._model,getElements:(e,t)=>{const i=this._outline!==t;if(this._outline=t,this._model)return this._model.changed=i,this._model;const s=this.createContainer(),o=this.createAnchor();if(this._model={root:s,overlay:o,changed:i},s.appendChild(o),this.element.appendChild(s),e?.target instanceof HTMLElement){const r=e.target.getBoundingClientRect(),l=this.element.getBoundingClientRect();o.style.left=`${r.left-l.left}px`,o.style.top=`${r.top-l.top}px`}return this._model}}}constructor(e,t){super(),this.element=e,this._disabled=!1,this._disabled=t.disabled,this.addDisposables(ke.from(()=>{var i;(i=this.model)===null||i===void 0||i.clear()}))}createContainer(){const e=document.createElement("div");return e.className="dv-drop-target-container",e}createAnchor(){const e=document.createElement("div");return e.className="dv-drop-target-anchor",e.style.visibility="hidden",e}}class uv{get minimumSize(){return this._isCollapsed?this._collapsedSize:this._expandedMinimumSize}get maximumSize(){return this._isCollapsed?this._collapsedSize:this._expandedMaximumSize}get element(){return this._group.element}get isCollapsed(){return this._isCollapsed}get lastExpandedSize(){return this._lastExpandedSize}get collapsedSize(){return this._collapsedSize}constructor(e,t,i){var s,o,r;this._onDidChange=new z,this.onDidChange=this._onDidChange.event,this.snap=!1,this.priority=Le.Low,this._isCollapsed=!1,this._group=t,this._orientation=i,t.element.classList.add("dv-edge-group"),t.element.dataset.testid=`dv-edge-group-${e.id}`,this._collapsedSize=(s=e.collapsedSize)!==null&&s!==void 0?s:35,this._expandedMaximumSize=(o=e.maximumSize)!==null&&o!==void 0?o:Number.POSITIVE_INFINITY,this._expandedMinimumSize=e.minimumSize!==void 0?e.minimumSize:this._collapsedSize+50,this._lastExpandedSize=(r=e.initialSize)!==null&&r!==void 0?r:200,e.collapsed&&(this._isCollapsed=!0,t.element.classList.add("dv-edge-collapsed"))}layout(e,t){this._isCollapsed||(this._lastExpandedSize=e),this._orientation==="horizontal"?this._group.layout(e,t):this._group.layout(t,e)}setCollapsed(e){this._isCollapsed!==e&&(this._isCollapsed=e,this._group.element.classList.toggle("dv-edge-collapsed",e))}setVisible(e){}restoreExpandedSize(e){this._lastExpandedSize=e}updateCollapsedSize(e,t){this._collapsedSize=e,this._expandedMinimumSize=t}dispose(){this._onDidChange.dispose()}}class pv{get element(){return this._dockviewElement}constructor(e,t){this._dockviewElement=e,this._layoutDockview=t,this.priority=Le.High,this.minimumSize=100,this.maximumSize=Number.POSITIVE_INFINITY,this._onDidChange=new z,this.onDidChange=this._onDidChange.event}layout(e,t){this._layoutDockview(t,e)}setVisible(e){}dispose(){this._onDidChange.dispose()}}class mv{get element(){return this._element}constructor(e,t=0){this._onDidChange=new z,this.onDidChange=this._onDidChange.event,this.minimumSize=100,this.maximumSize=Number.POSITIVE_INFINITY,this.priority=Le.High,this._element=document.createElement("div"),this._element.className="dv-shell-middle-column",this._element.style.height="100%",this._element.style.width="100%",this._splitview=new Ci(this._element,{orientation:ee.VERTICAL,proportionalLayout:!1,margin:t}),this._centerIndex=0,this._splitview.addView(e,{type:"distribute"},0)}addTopView(e,t){this._splitview.addView(e,t,0),this._topIndex=0,this._centerIndex+=1,this._bottomIndex!==void 0&&(this._bottomIndex+=1)}addBottomView(e,t){const i=this._splitview.length;this._splitview.addView(e,t,i),this._bottomIndex=i}removeView(e){const t=e==="top"?this._topIndex:this._bottomIndex;t!==void 0&&(this._splitview.removeView(t),e==="top"?(this._topIndex=void 0,this._centerIndex-=1,this._bottomIndex!==void 0&&(this._bottomIndex-=1)):this._bottomIndex=void 0)}layout(e,t){this._splitview.layout(t,e)}setVisible(e){}setViewVisible(e,t){const i=e==="top"?this._topIndex:this._bottomIndex;i!==void 0&&this._splitview.setViewVisible(i,t)}isViewVisible(e){const t=e==="top"?this._topIndex:this._bottomIndex;return t!==void 0?this._splitview.isViewVisible(t):!1}getViewSize(e){const t=e==="top"?this._topIndex:this._bottomIndex;return t!==void 0?this._splitview.getViewSize(t):0}resizeView(e,t){const i=e==="top"?this._topIndex:this._bottomIndex;i!==void 0&&this._splitview.resizeView(i,t)}updateMargin(e){this._splitview.margin=e}dispose(){this._onDidChange.dispose(),this._splitview.dispose()}}function vv(n,e,t){var i;const s=((i=n.collapsedSize)!==null&&i!==void 0?i:e)+t,o=Object.assign(Object.assign({},n),{collapsedSize:s});return n.minimumSize!==void 0&&(o.minimumSize=n.minimumSize+t),o}class gv{constructor(e,t,i,s=0,o=35){this._disposables=new X,this._viewConfigs=new Map,this._currentWidth=0,this._currentHeight=0,this._gap=s,this._defaultCollapsedSize=o,this._shellElement=document.createElement("div"),this._shellElement.className="dv-shell",this._shellElement.style.height="100%",this._shellElement.style.width="100%",this._shellElement.style.position="relative",e.appendChild(this._shellElement);const r=new pv(t,i);this._middleColumn=new mv(r,s),this._outerSplitview=new Ci(this._shellElement,{orientation:ee.HORIZONTAL,proportionalLayout:!1,margin:s}),this._middleIndex=0,this._outerSplitview.addView(this._middleColumn,{type:"distribute"},0),this._disposables.addDisposables(Gn(this._shellElement,l=>{const d=Math.round(l.contentRect.width),c=Math.round(l.contentRect.height);d===this._currentWidth&&c===this._currentHeight||(this._currentWidth=d,this._currentHeight=c,this.layout(d,c))}),this._outerSplitview,this._middleColumn,r)}get element(){return this._shellElement}addEdgeView(e,t,i){if(this.hasEdgeGroup(e))throw new Error(`dockview: edge group already registered at position '${e}'`);this._viewConfigs.set(e,t);const s=1+(this._viewConfigs.has("left")?1:0)+(this._viewConfigs.has("right")?1:0),o=1+(this._viewConfigs.has("top")?1:0)+(this._viewConfigs.has("bottom")?1:0),r=s>1?this._gap*(s-1)/s:0,l=o>1?this._gap*(o-1)/o:0,d=e==="left"||e==="right",c=d?r:l,h=d?"horizontal":"vertical",u=new uv(vv(Object.assign({collapsedSize:this._defaultCollapsedSize},t),this._defaultCollapsedSize,c),i,h),m=u.isCollapsed?u.collapsedSize:u.lastExpandedSize;switch(e){case"left":this._outerSplitview.addView(u,m,0),this._leftIndex=0,this._middleIndex+=1,this._rightIndex!==void 0&&(this._rightIndex+=1),this._leftView=u;break;case"right":{const g=this._outerSplitview.length;this._outerSplitview.addView(u,m,g),this._rightIndex=g,this._rightView=u}break;case"top":this._middleColumn.addTopView(u,m),this._topView=u;break;case"bottom":this._middleColumn.addBottomView(u,m),this._bottomView=u;break}return this._disposables.addDisposables(u),this.updateTheme(this._gap,this._defaultCollapsedSize),u}layout(e,t){this._outerSplitview.layout(e,t)}updateTheme(e,t){var i,s,o,r;this._gap=e,this._defaultCollapsedSize=t;const l=1+(this._viewConfigs.has("left")?1:0)+(this._viewConfigs.has("right")?1:0),d=1+(this._viewConfigs.has("top")?1:0)+(this._viewConfigs.has("bottom")?1:0),c=l>1?e*(l-1)/l:0,h=d>1?e*(d-1)/d:0;this._outerSplitview.margin=e,this._middleColumn.updateMargin(e);const u=(w,C,b)=>{var D;const P=((D=C.collapsedSize)!==null&&D!==void 0?D:t)+b,y=C.minimumSize,T=y!==void 0?y+b:P+50;w.updateCollapsedSize(P,T)},m=this._viewConfigs.get("top");this._topView&&m&&u(this._topView,m,h);const g=this._viewConfigs.get("bottom");this._bottomView&&g&&u(this._bottomView,g,h);const p=this._viewConfigs.get("left");this._leftView&&p&&u(this._leftView,p,c);const f=this._viewConfigs.get("right");this._rightView&&f&&u(this._rightView,f,c),!((i=this._leftView)===null||i===void 0)&&i.isCollapsed&&this._leftIndex!==void 0&&this._outerSplitview.resizeView(this._leftIndex,this._leftView.collapsedSize),!((s=this._rightView)===null||s===void 0)&&s.isCollapsed&&this._rightIndex!==void 0&&this._outerSplitview.resizeView(this._rightIndex,this._rightView.collapsedSize),!((o=this._topView)===null||o===void 0)&&o.isCollapsed&&this._middleColumn.resizeView("top",this._topView.collapsedSize),!((r=this._bottomView)===null||r===void 0)&&r.isCollapsed&&this._middleColumn.resizeView("bottom",this._bottomView.collapsedSize),this._currentWidth>0&&this._currentHeight>0&&this.layout(this._currentWidth,this._currentHeight)}removeEdgeView(e){const t=this._getView(e);if(t){switch(e){case"left":this._outerSplitview.removeView(this._leftIndex),this._leftIndex=void 0,this._leftView=void 0,this._middleIndex-=1,this._rightIndex!==void 0&&(this._rightIndex-=1);break;case"right":this._outerSplitview.removeView(this._rightIndex),this._rightIndex=void 0,this._rightView=void 0;break;case"top":this._middleColumn.removeView("top"),this._topView=void 0;break;case"bottom":this._middleColumn.removeView("bottom"),this._bottomView=void 0;break}this._disposables.removeDisposable(t),t.dispose(),this._viewConfigs.delete(e),this.updateTheme(this._gap,this._defaultCollapsedSize)}}hasEdgeGroup(e){switch(e){case"top":return this._topView!==void 0;case"bottom":return this._bottomView!==void 0;case"left":return this._leftView!==void 0;case"right":return this._rightView!==void 0}}setEdgeGroupVisible(e,t){switch(e){case"left":this._leftIndex!==void 0&&this._outerSplitview.setViewVisible(this._leftIndex,t);break;case"right":this._rightIndex!==void 0&&this._outerSplitview.setViewVisible(this._rightIndex,t);break;case"top":case"bottom":this._middleColumn.setViewVisible(e,t);break}}isEdgeGroupVisible(e){switch(e){case"left":return this._leftIndex!==void 0?this._outerSplitview.isViewVisible(this._leftIndex):!1;case"right":return this._rightIndex!==void 0?this._outerSplitview.isViewVisible(this._rightIndex):!1;case"top":case"bottom":return this._middleColumn.isViewVisible(e)}}setEdgeGroupCollapsed(e,t){const i=this._getView(e);if(!i)return;i.setCollapsed(t);const s=t?i.collapsedSize:i.lastExpandedSize;switch(e){case"left":this._leftIndex!==void 0&&this._outerSplitview.resizeView(this._leftIndex,s);break;case"right":this._rightIndex!==void 0&&this._outerSplitview.resizeView(this._rightIndex,s);break;case"top":case"bottom":this._middleColumn.resizeView(e,s);break}}isEdgeGroupCollapsed(e){var t,i;return(i=(t=this._getView(e))===null||t===void 0?void 0:t.isCollapsed)!==null&&i!==void 0?i:!1}_getView(e){switch(e){case"top":return this._topView;case"bottom":return this._bottomView;case"left":return this._leftView;case"right":return this._rightView}}toJSON(){const e={};return this._leftView&&this._leftIndex!==void 0&&(e.left={size:this._leftView.isCollapsed?this._leftView.lastExpandedSize:this._outerSplitview.getViewSize(this._leftIndex),visible:this._outerSplitview.isViewVisible(this._leftIndex),collapsed:this._leftView.isCollapsed||void 0}),this._rightView&&this._rightIndex!==void 0&&(e.right={size:this._rightView.isCollapsed?this._rightView.lastExpandedSize:this._outerSplitview.getViewSize(this._rightIndex),visible:this._outerSplitview.isViewVisible(this._rightIndex),collapsed:this._rightView.isCollapsed||void 0}),this._topView&&(e.top={size:this._topView.isCollapsed?this._topView.lastExpandedSize:this._middleColumn.getViewSize("top"),visible:this._middleColumn.isViewVisible("top"),collapsed:this._topView.isCollapsed||void 0}),this._bottomView&&(e.bottom={size:this._bottomView.isCollapsed?this._bottomView.lastExpandedSize:this._middleColumn.getViewSize("bottom"),visible:this._middleColumn.isViewVisible("bottom"),collapsed:this._bottomView.isCollapsed||void 0}),e}fromJSON(e){var t,i,s,o,r,l,d,c,h,u,m,g,p,f,w,C,b,D,k,P;e.left&&this._leftIndex!==void 0&&((t=this._leftView)===null||t===void 0||t.restoreExpandedSize(e.left.size),(i=this._leftView)===null||i===void 0||i.setCollapsed((s=e.left.collapsed)!==null&&s!==void 0?s:!1),this._outerSplitview.resizeView(this._leftIndex,e.left.collapsed&&(r=(o=this._leftView)===null||o===void 0?void 0:o.collapsedSize)!==null&&r!==void 0?r:e.left.size),e.left.visible||this._outerSplitview.setViewVisible(this._leftIndex,!1)),e.right&&this._rightIndex!==void 0&&((l=this._rightView)===null||l===void 0||l.restoreExpandedSize(e.right.size),(d=this._rightView)===null||d===void 0||d.setCollapsed((c=e.right.collapsed)!==null&&c!==void 0?c:!1),this._outerSplitview.resizeView(this._rightIndex,e.right.collapsed&&(u=(h=this._rightView)===null||h===void 0?void 0:h.collapsedSize)!==null&&u!==void 0?u:e.right.size),e.right.visible||this._outerSplitview.setViewVisible(this._rightIndex,!1)),e.top&&((m=this._topView)===null||m===void 0||m.restoreExpandedSize(e.top.size),(g=this._topView)===null||g===void 0||g.setCollapsed((p=e.top.collapsed)!==null&&p!==void 0?p:!1),this._middleColumn.resizeView("top",e.top.collapsed&&(w=(f=this._topView)===null||f===void 0?void 0:f.collapsedSize)!==null&&w!==void 0?w:e.top.size),e.top.visible||this._middleColumn.setViewVisible("top",!1)),e.bottom&&((C=this._bottomView)===null||C===void 0||C.restoreExpandedSize(e.bottom.size),(b=this._bottomView)===null||b===void 0||b.setCollapsed((D=e.bottom.collapsed)!==null&&D!==void 0?D:!1),this._middleColumn.resizeView("bottom",e.bottom.collapsed&&(P=(k=this._bottomView)===null||k===void 0?void 0:k.collapsedSize)!==null&&P!==void 0?P:e.bottom.size),e.bottom.visible||this._middleColumn.setViewVisible("bottom",!1))}dispose(){var e;this._disposables.dispose(),(e=this._shellElement.parentElement)===null||e===void 0||e.removeChild(this._shellElement)}}function fv(n){var e;const t=(e=n.tabGroupColors)!==null&&e!==void 0?e:Ro,i=n.tabGroupAccent!=="off";return new Ml(t,i)}function Yn(n){const e=n.from.activePanel;[...n.from.panels].map(i=>{const s=n.from.model.removePanel(i);return n.from.model.renderContainer.detatch(i),s}).forEach(i=>{n.to.model.openPanel(i,{skipSetActive:e!==i,skipSetGroupActive:!0})})}let ja=!1;function _v(){typeof process<"u"&&up||ja||Rm()||(ja=!0,console.warn('dockview: do not use "dockview-core" directly — it is an internal package. Use the "dockview" package, the JavaScript version of dockview, instead. This notice is shown once.'))}class wv extends Dl{fireDidCreateTabGroup(e){this._onDidCreateTabGroup.fire(e)}fireDidDestroyTabGroup(e){this._onDidDestroyTabGroup.fire(e)}fireDidAddPanelToTabGroup(e){this._onDidAddPanelToTabGroup.fire(e)}fireDidRemovePanelFromTabGroup(e){this._onDidRemovePanelFromTabGroup.fire(e)}fireDidTabGroupChange(e){this._onDidTabGroupChange.fire(e)}fireDidTabGroupCollapsedChange(e){this._onDidTabGroupCollapsedChange.fire(e)}get orientation(){return this.gridview.orientation}get totalPanels(){return this.panels.length}get panels(){return this.groups.flatMap(e=>e.panels)}get options(){return this._options}get tabGroupColorPalette(){return this._tabGroupColorPalette}get activePanel(){const e=this.activeGroup;if(e)return e.activePanel}get renderer(){var e;return(e=this.options.defaultRenderer)!==null&&e!==void 0?e:"onlyWhenVisible"}get defaultHeaderPosition(){var e;return(e=this.options.defaultHeaderPosition)!==null&&e!==void 0?e:"top"}get api(){return this._api}get floatingGroups(){var e,t,i;return(i=(t=(e=this._moduleRegistry)===null||e===void 0?void 0:e.services.floatingGroupService)===null||t===void 0?void 0:t.floatingGroups)!==null&&i!==void 0?i:[]}_gatherFloatingGroupBoxes(e){var t;const s=((t=this._floatingOverlayHost)!==null&&t!==void 0?t:this.gridview.element).getBoundingClientRect();return this.floatingGroups.filter(o=>o.group!==e).map(o=>{const r=o.overlay.element.getBoundingClientRect();return{left:r.left-s.left,top:r.top-s.top,width:r.width,height:r.height}})}get _floatingGroupService(){return this._moduleRegistry.services.floatingGroupService}get _popoutWindowService(){return this._moduleRegistry.services.popoutWindowService}get _watermarkService(){return this._moduleRegistry.services.watermarkService}get _edgeGroupService(){return this._moduleRegistry.services.edgeGroupService}get _rootDropTargetService(){return this._moduleRegistry.services.rootDropTargetService}get _advancedDnDService(){return this._moduleRegistry.services.advancedDnDService}get headerActionsService(){return this._moduleRegistry.services.headerActionsService}isGridEmpty(){return this.gridview.length===0}rootDropTargetOverrideTarget(){var e;return(e=this.rootDropTargetContainer)===null||e===void 0?void 0:e.model}dispatchUnhandledDragOver(e,t){const i=new Wl(e,"edge",t,Ae);return this._onUnhandledDragOver.fire(i),i.isAccepted}fireWillDragPanel(e){this._onWillDragPanel.fire(e)}fireWillDragGroup(e){this._onWillDragGroup.fire(e)}fireWillDrop(e){this._onWillDrop.fire(e)}fireWillShowOverlay(e){this._onWillShowOverlay.fire(e)}buildGroupDragGhost(e){var t;return(t=this._advancedDnDService)===null||t===void 0?void 0:t.buildGroupDragGhost(e)}resolveDropOverlayModel(e,t){var i;return(i=this._advancedDnDService)===null||i===void 0?void 0:i.resolveOverlayModel(e,t)}get rootElement(){var e,t;return(t=(e=this._shellManager)===null||e===void 0?void 0:e.element)!==null&&t!==void 0?t:this.element}adjacentGroup(e,t){var i;if(e.api.location.type!=="grid")return;const s=Te(e.element);return(i=t?this.gridview.previous(s):this.gridview.next(s))===null||i===void 0?void 0:i.view}adjacentGroupInDirection(e,t){if(e.api.location.type!=="grid")return;const i=e.element.getBoundingClientRect(),s=i.left+i.width/2,o=i.top+i.height/2;let r,l=Number.POSITIVE_INFINITY;for(const d of this.groups){if(d===e||d.api.location.type!=="grid")continue;const c=d.element.getBoundingClientRect(),h=c.left+c.width/2-s,u=c.top+c.height/2-o;if(!(t==="left"?h<0&&Math.abs(h)>=Math.abs(u):t==="right"?h>0&&Math.abs(h)>=Math.abs(u):t==="up"?u<0&&Math.abs(u)>=Math.abs(h):u>0&&Math.abs(u)>=Math.abs(h)))continue;const g=h*h+u*u;g<l&&(l=g,r=d)}return r}showDropPreview(e,t){var i,s;return(s=(i=this._advancedDnDService)===null||i===void 0?void 0:i.showPreviewOverlay(e,t))!==null&&s!==void 0?s:ke.NONE}announce(e){var t;(t=this._moduleRegistry.services.liveRegionService)===null||t===void 0||t.announce(e)}dockPanel(e,t,i){this.moveGroupOrPanel({from:{groupId:e.group.id,panelId:e.id},to:{group:t,position:i}})}get contextMenuService(){return this._moduleRegistry.services.contextMenuService}get mountElement(){return this.gridview.element}hasVisibleGridGroup(){return this.groups.some(e=>e.api.location.type==="grid"&&e.api.isVisible)}fireLayoutChange(){this._bufferOnDidLayoutChange.fire()}get popoutRestorationPromise(){var e,t;return(t=(e=this._popoutWindowService)===null||e===void 0?void 0:e.restorationPromise)!==null&&t!==void 0?t:Promise.resolve()}constructor(e,t){var i,s,o,r,l;super(e,{proportionalLayout:!0,orientation:ee.HORIZONTAL,styles:t.hideBorders?{separatorBorder:"transparent"}:void 0,disableAutoResizing:t.disableAutoResizing,locked:t.locked,margin:(s=(i=t.theme)===null||i===void 0?void 0:i.gap)!==null&&s!==void 0?s:0,className:t.className}),this.nextGroupId=No(),this._deserializer=new Gm(this),this._moduleRegistry=new jm,this._onWillDragPanel=new z,this.onWillDragPanel=this._onWillDragPanel.event,this._onWillDragGroup=new z,this.onWillDragGroup=this._onWillDragGroup.event,this._onDidDrop=new z,this.onDidDrop=this._onDidDrop.event,this._onWillDrop=new z,this.onWillDrop=this._onWillDrop.event,this._mutationDepth=0,this._origin="user",this._originDepth=0,this._onWillMutateLayout=new z,this.onWillMutateLayout=this._onWillMutateLayout.event,this._onDidMutateLayout=new z,this.onDidMutateLayout=this._onDidMutateLayout.event,this._onWillShowOverlay=new z,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onUnhandledDragOver=new z,this.onUnhandledDragOver=this._onUnhandledDragOver.event,this._onDidRemovePanel=new z,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidAddPanel=new z,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidPopoutGroupSizeChange=new z,this.onDidPopoutGroupSizeChange=this._onDidPopoutGroupSizeChange.event,this._onDidPopoutGroupPositionChange=new z,this.onDidPopoutGroupPositionChange=this._onDidPopoutGroupPositionChange.event,this._onDidAddPopoutGroup=new z,this.onDidAddPopoutGroup=this._onDidAddPopoutGroup.event,this._onDidRemovePopoutGroup=new z,this.onDidRemovePopoutGroup=this._onDidRemovePopoutGroup.event,this._onDidOpenPopoutWindowFail=new z,this.onDidOpenPopoutWindowFail=this._onDidOpenPopoutWindowFail.event,this._onDidLayoutFromJSON=new z,this.onDidLayoutFromJSON=this._onDidLayoutFromJSON.event,this._onDidActivePanelChange=new z({replay:!0}),this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onDidMovePanel=new z,this.onDidMovePanel=this._onDidMovePanel.event,this._onDidCreateTabGroup=new z,this.onDidCreateTabGroup=this._onDidCreateTabGroup.event,this._onDidDestroyTabGroup=new z,this.onDidDestroyTabGroup=this._onDidDestroyTabGroup.event,this._onDidAddPanelToTabGroup=new z,this.onDidAddPanelToTabGroup=this._onDidAddPanelToTabGroup.event,this._onDidRemovePanelFromTabGroup=new z,this.onDidRemovePanelFromTabGroup=this._onDidRemovePanelFromTabGroup.event,this._onDidTabGroupChange=new z,this.onDidTabGroupChange=this._onDidTabGroupChange.event,this._onDidTabGroupCollapsedChange=new z,this.onDidTabGroupCollapsedChange=this._onDidTabGroupCollapsedChange.event,this._onDidMaximizedGroupChange=new z,this.onDidMaximizedGroupChange=this._onDidMaximizedGroupChange.event,this._inShellLayout=!1,this._onDidRemoveGroup=new z,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new z,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidOptionsChange=new z,this.onDidOptionsChange=this._onDidOptionsChange.event,this._onDidActiveGroupChange=new z,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._moving=!1,this._options=t,this._tabGroupColorPalette=fv(t);const d=t.modules,c=d??[...sv,...Mm()];for(const m of c)this._moduleRegistry.register(m);this._moduleRegistry.initialize(this);const h=this._popoutWindowService;h&&this.addDisposables(h.onDidRemove(m=>{this._onDidRemovePopoutGroup.fire({id:m.popoutGroup.id,group:m.popoutGroup,window:m.getWindow()})})),_v(),this.popupService=new Aa(this.element),this._api=new Oo(this),this.disableResizing=!0,e.removeChild(this.element),this._shellManager=new gv(e,this.element,(m,g)=>this._layoutFromShell(m,g),(r=(o=t.theme)===null||o===void 0?void 0:o.gap)!==null&&r!==void 0?r:0,(l=t.theme)===null||l===void 0?void 0:l.edgeGroupCollapsedSize),this.popupService.updateRoot(this._shellManager.element),this._shellThemeClassnames=new ys(this._shellManager.element),this.rootDropTargetContainer=new Na(this._shellManager.element,{disabled:!0}),this.overlayRenderContainer=new Ia(this._shellManager.element,this),this._floatingOverlayHost=document.createElement("div"),this._floatingOverlayHost.className="dv-floating-overlay-host",this._shellManager.element.appendChild(this._floatingOverlayHost),W(this.gridview.element,"dv-dockview",!0),W(this.element,"dv-debug",!!t.debug),this.updateTheme(),t.debug&&this.addDisposables(new cv(this)),this.addDisposables(this.rootDropTargetContainer,this.overlayRenderContainer,this._onWillDragPanel,this._onWillDragGroup,this._onWillShowOverlay,this._onDidActivePanelChange,this._onDidAddPanel,this._onDidRemovePanel,this._onDidLayoutFromJSON,this._onDidDrop,this._onWillDrop,this._onWillMutateLayout,this._onDidMutateLayout,this._onDidMovePanel,this._onDidMovePanel.event(()=>{this.debouncedUpdateAllPositions()}),this._onDidAddGroup,this._onDidRemoveGroup,this._onDidActiveGroupChange,this._onUnhandledDragOver,this._onDidMaximizedGroupChange,this._onDidPopoutGroupSizeChange,this._onDidPopoutGroupPositionChange,this._onDidAddPopoutGroup,this._onDidRemovePopoutGroup,this._onDidOpenPopoutWindowFail,this._onDidCreateTabGroup,this._onDidDestroyTabGroup,this._onDidAddPanelToTabGroup,this._onDidRemovePanelFromTabGroup,this._onDidTabGroupChange,this._onDidTabGroupCollapsedChange,wt.any(this.onDidPopoutGroupSizeChange,this.onDidPopoutGroupPositionChange,this.onDidCreateTabGroup,this.onDidDestroyTabGroup,this.onDidAddPanelToTabGroup,this.onDidRemovePanelFromTabGroup,this.onDidTabGroupChange,this.onDidTabGroupCollapsedChange)(()=>{this.fireLayoutChange()}),this._onDidOptionsChange,this.onDidAdd(m=>{this._moving||this._onDidAddGroup.fire(m)}),this.onDidRemove(m=>{this._moving||this._onDidRemoveGroup.fire(m)}),this.onDidActiveChange(m=>{this._moving||this._onDidActiveGroupChange.fire(m)}),this.onDidMaximizedChange(m=>{this._onDidMaximizedGroupChange.fire({group:m.panel,isMaximized:m.isMaximized})}),wt.any(this.onDidAddPanel,this.onDidRemovePanel,this.onDidAddGroup,this.onDidRemove,this.onDidRemoveGroup,this.onDidMovePanel,this.onDidActivePanelChange)(()=>{this._bufferOnDidLayoutChange.fire()}),ke.from(()=>{var m;this._moduleRegistry.dispose(),(m=this._shellManager)===null||m===void 0||m.dispose()}));const u=this._rootDropTargetService;u&&this.addDisposables(u.onWillShowOverlay(m=>{this.gridview.length>0&&m.position==="center"||this._onWillShowOverlay.fire(new zn(m,{kind:"edge",panel:void 0,api:this._api,group:void 0,getData:Ae}))}),u.onDrop(m=>{var g;const p=new $l({nativeEvent:m.nativeEvent,position:m.position,panel:void 0,api:this._api,group:void 0,getData:Ae,kind:"edge"});if(this._onWillDrop.fire(p),p.defaultPrevented)return;const f=Ae();f?this.moveGroupOrPanel({from:{groupId:f.groupId,panelId:(g=f.panelId)!==null&&g!==void 0?g:void 0},to:{group:this.orthogonalize(m.position),position:"center"}}):this._onDidDrop.fire(new Wo({nativeEvent:m.nativeEvent,position:m.position,panel:void 0,api:this._api,group:void 0,getData:Ae}))})),this._moduleRegistry.postConstruct(this)}setVisible(e,t){switch(e.api.location.type){case"grid":super.setVisible(e,t);break;case"floating":{const i=this.floatingGroups.find(s=>s.group===e);i&&(i.overlay.setVisible(t),e.api._onDidVisibilityChange.fire({isVisible:t}));break}case"popout":console.warn("dockview: You cannot hide a group that is in a popout window");break}}getPopupServiceForGroup(e){var t,i;return(i=(t=this._popoutWindowService)===null||t===void 0?void 0:t.getPopupService(e.id))!==null&&i!==void 0?i:this.popupService}addPopoutGroup(e,t){return this.mutation("popout",()=>this._doAddPopoutGroup(e,t))}getPopouts(){var e,t;return(t=(e=this._popoutWindowService)===null||e===void 0?void 0:e.entries.map(i=>({id:i.popoutGroup.id,group:i.popoutGroup,window:i.getWindow()})))!==null&&t!==void 0?t:[]}_doAddPopoutGroup(e,t){var i,s,o,r,l;const d=fi(this._popoutWindowService,"PopoutWindow","api.addPopoutGroup");if(!d||e instanceof Bn&&e.model.location.type==="edge")return Promise.resolve(!1);if(e instanceof Oi&&e.group.size===1)return this.addPopoutGroup(e.group,t);const c=xp(this.gridview.element),h=this.element;function u(){return t?.position?t.position:e instanceof Bn?e.element.getBoundingClientRect():e.group?e.group.element.getBoundingClientRect():h.getBoundingClientRect()}const m=u(),g=(s=(i=t?.overridePopoutGroup)===null||i===void 0?void 0:i.id)!==null&&s!==void 0?s:this.getNextGroupId(),p=(o=t?.popoutUrl)!==null&&o!==void 0?o:(r=this.options)===null||r===void 0?void 0:r.popoutUrl,f=new dv(`${this.id}-${g}`,c??"",{url:p??"/popout.html",left:window.screenX+m.left,top:window.screenY+m.top,width:m.width,height:m.height,onDidOpen:t?.onDidOpen,onWillClose:t?.onWillClose,nonce:(l=this.options)===null||l===void 0?void 0:l.nonce}),w=new X(f,f.onDidClose(()=>{w.dispose()}));return f.open().then(C=>{var b,D,k;if(f.isDisposed)return!1;const P=t?.referenceGroup?t.referenceGroup:e instanceof Oi?e.group:e,y=e.api.location.type,T=P.element.parentElement!==null;let S;if(t?.overridePopoutGridview?S=(b=t.overridePopoutGroup)!==null&&b!==void 0?b:P:T?t?.overridePopoutGroup?S=t.overridePopoutGroup:(S=this.createGroup({id:g}),C&&this._onDidAddGroup.fire(S)):S=P,C===null)return this.handleBlockedPopout({group:S,referenceGroup:P,options:t,popoutWindowDisposable:w}),!1;const N=document.createElement("div");N.className="dv-overlay-render-container";const O=new Ia(N,this);S.model.renderContainer=O;const $=(D=t?.overridePopoutGridview)!==null&&D!==void 0?D:this.createNestedGridview();t?.overridePopoutGridview||$.addView(S,nt.Distribute,[0]),$.element.style.width="100%",$.element.style.height="100%",$.layout(f.window.innerWidth,f.window.innerHeight);let F=!1;const q=()=>{F||(F=!0,$.dispose())};let re;if(!t?.overridePopoutGroup&&!t?.overridePopoutGridview&&T)if(e instanceof Oi)this.movingLock(()=>{const be=P.model.removePanel(e);S.model.openPanel(be)});else switch(this.movingLock(()=>Yn({from:P,to:S})),y){case"grid":P.api.setVisible(!1);break;case"floating":case"popout":re=(k=this.floatingGroups.find(be=>be.group.api.id===e.api.id))===null||k===void 0?void 0:k.overlay.toJSON(),this.removeGroup(P);break}C.classList.add("dv-dockview"),C.style.overflow="hidden",C.appendChild(N),C.appendChild($.element);const V=document.createElement("div"),B=new Na(V,{disabled:this.rootDropTargetContainer.disabled});C.appendChild(V),S.model.dropTargetContainer=B;const te=new Aa(C,f.window);if(d.setPopupService(S.id,te),w.addDisposables(te,ke.from(()=>{d.deletePopupService(S.id)})),S.model.location={type:"popout",getWindow:()=>f.window,popoutUrl:p},t?.overridePopoutGridview){const be=this.groups.filter(Se=>$.element.contains(Se.element));for(const Se of be)Se.model.renderContainer=O,Se.model.dropTargetContainer=B,Se.model.location={type:"popout",getWindow:()=>f.window,popoutUrl:p}}T&&e.api.location.type==="grid"&&e.api.setVisible(!1),this.doSetGroupAndPanelActive(S);const we=d.observeGridviewSize(f,$,O);we&&w.addDisposables(we),w.addDisposables(S.api.onDidActiveChange(be=>{var Se;be.isActive&&((Se=f.window)===null||Se===void 0||Se.focus())}),S.api.onWillFocus(()=>{var be;(be=f.window)===null||be===void 0||be.focus()}));const xe={},j=T&&P&&this.getPanel(P.id),de={window:f,popoutGroup:S,gridview:$,overlayRenderContainer:O,dropTargetContainer:B,getWindow:()=>f.window,popoutUrl:p,referenceGroup:j?P.id:void 0,disposable:{dispose:()=>(w.dispose(),xe.returnedGroup)}},ce=yp(f.window);return w.addDisposables(ce,Dp(f.window,()=>{this._onDidPopoutGroupSizeChange.fire({width:f.window.innerWidth,height:f.window.innerHeight,group:S})}),ce.event(()=>{this._onDidPopoutGroupPositionChange.fire({screenX:f.window.screenX,screenY:f.window.screenX,group:S})}),U(f.window,"resize",()=>{$.layout(f.window.innerWidth,f.window.innerHeight)}),O,ke.from(()=>this.disposePopoutWindow({group:S,referenceGroup:P,popoutGridview:$,isGroupAddedToDom:T,floatingBox:re,disposePopoutGridview:q,closeResult:xe}))),d.add(de),this._onDidAddPopoutGroup.fire({id:de.popoutGroup.id,group:de.popoutGroup,window:de.getWindow()}),!0}).catch(C=>(console.error("dockview: failed to create popout.",C),!1))}handleBlockedPopout(e){const{group:t,referenceGroup:i,options:s,popoutWindowDisposable:o}=e;if(console.error("dockview: failed to create popout. perhaps you need to allow pop-ups for this website"),o.dispose(),this._onDidOpenPopoutWindowFail.fire(),s?.overridePopoutGridview){const r=s.overridePopoutGridview,l=this.groups.filter(d=>r.element.contains(d.element));for(const d of l)this.movingLock(()=>{r.remove(d),this.redockGroupToMainGrid(d)});r.dispose(),i&&!i.api.isVisible&&i.api.setVisible(!0);return}t===i?this.gridview.element.contains(t.element)||(this.movingLock(()=>this.doAddGroup(t,[0])),t.model.location={type:"grid"}):(this.movingLock(()=>Yn({from:t,to:i})),t.model.size===0&&this._groups.has(t.id)&&(t.dispose(),this._groups.delete(t.id),this._onDidRemoveGroup.fire(t))),i.api.isVisible||i.api.setVisible(!0)}redockGroupToMainGrid(e){e.model.renderContainer=this.overlayRenderContainer,e.model.dropTargetContainer=this.rootDropTargetContainer,e.model.location={type:"grid"},this.doAddGroup(e,[0])}disposePopoutWindow(e){var t;const{group:i,referenceGroup:s,popoutGridview:o,isGroupAddedToDom:r,floatingBox:l,disposePopoutGridview:d,closeResult:c}=e;if(this.isDisposed){d();return}const h=!!(!((t=this._popoutWindowService)===null||t===void 0)&&t.entries.find(p=>p.gridview===o)),u=this.groups.filter(p=>o.element.contains(p.element)),m=u.includes(i),g=m&&u.length===1;if(h)for(const p of u)p!==i&&this.movingLock(()=>{this.doRemoveGroup(p,{skipDispose:!0,skipActive:!0,skipPopoutReturn:!0}),this.redockGroupToMainGrid(p)});if(m&&r&&this.getPanel(s.id))this.movingLock(()=>Yn({from:i,to:s})),s.api.isVisible||s.api.setVisible(!0),this.getPanel(i.id)&&this.doRemoveGroup(i,{skipPopoutAssociated:!0});else if(m&&this.getPanel(i.id)){if(i.model.renderContainer=this.overlayRenderContainer,i.model.dropTargetContainer=this.rootDropTargetContainer,c.returnedGroup=i,!h){d();return}l&&g?this.addFloatingGroup(i,{height:l.height,width:l.width,position:l}):(this.doRemoveGroup(i,{skipDispose:!0,skipActive:!0,skipPopoutReturn:!0}),i.model.location={type:"grid"},this.movingLock(()=>{this.doAddGroup(i,[0])})),this.doSetGroupAndPanelActive(i)}d()}addFloatingGroup(e,t){this.mutation("float",()=>this._doAddFloatingGroup(e,t))}_doAddFloatingGroup(e,t){var i;if(!fi(this._floatingGroupService,"FloatingGroup","api.addFloatingGroup")||e instanceof Bn&&e.model.location.type==="edge")return;let o;if(e instanceof Oi)o=this.createGroup(),this._onDidAddGroup.fire(o),this.movingLock(()=>this.removePanel(e,{removeEmptyGroup:!0,skipDispose:!0,skipSetActiveGroup:!0})),this.movingLock(()=>o.model.openPanel(e,{skipSetGroupActive:!0}));else{o=e;const c=(i=this._popoutWindowService)===null||i===void 0?void 0:i.findReferenceGroupId(o),h=c?this.getPanel(c):void 0;typeof t?.skipRemoveGroup=="boolean"&&t.skipRemoveGroup||(h?(this.movingLock(()=>Yn({from:e,to:h})),this.doRemoveGroup(e,{skipPopoutReturn:!0,skipPopoutAssociated:!0}),this.doRemoveGroup(h,{skipDispose:!0}),o=h):this.doRemoveGroup(e,{skipDispose:!0,skipPopoutReturn:!0,skipPopoutAssociated:!1}))}function r(){if(t?.position){const c={};return"left"in t.position?c.left=Math.max(t.position.left,0):"right"in t.position?c.right=Math.max(t.position.right,0):c.left=di.left,"top"in t.position?c.top=Math.max(t.position.top,0):"bottom"in t.position?c.bottom=Math.max(t.position.bottom,0):c.top=di.top,typeof t.width=="number"?c.width=Math.max(t.width,0):c.width=di.width,typeof t.height=="number"?c.height=Math.max(t.height,0):c.height=di.height,c}return{left:typeof t?.x=="number"?Math.max(t.x,0):di.left,top:typeof t?.y=="number"?Math.max(t.y,0):di.top,width:typeof t?.width=="number"?Math.max(t.width,0):di.width,height:typeof t?.height=="number"?Math.max(t.height,0):di.height}}const l=r(),d=this.createNestedGridview();d.addView(o,nt.Distribute,[0]),this.mountFloatingWindow(d,o,[o],l,{dragHandle:t?.dragHandle,inDragMode:t?.inDragMode,skipActiveGroup:t?.skipActiveGroup})}createNestedGridview(e=ee.HORIZONTAL){var t,i;return new yl(!0,this.options.hideBorders?{separatorBorder:"transparent"}:void 0,e,!1,(i=(t=this.options.theme)===null||t===void 0?void 0:t.gap)!==null&&i!==void 0?i:0)}mountFloatingWindow(e,t,i,s,o){var r,l,d,c,h,u,m,g;const p=fi(this._floatingGroupService,"FloatingGroup","api.addFloatingGroup");if(!p)return;const w=((l=(r=o?.dragHandle)!==null&&r!==void 0?r:this.options.floatingGroupDragHandle)!==null&&l!==void 0?l:"titlebar")==="titlebar"?new Nm(this,t):void 0,C=new Mt(Object.assign(Object.assign({container:(d=this._floatingOverlayHost)!==null&&d!==void 0?d:this.gridview.element,content:e.element,header:w?.element},s),{minimumInViewportWidth:this.options.floatingGroupBounds==="boundedWithinViewport"?void 0:(h=(c=this.options.floatingGroupBounds)===null||c===void 0?void 0:c.minimumWidthWithinViewport)!==null&&h!==void 0?h:ps,minimumInViewportHeight:this.options.floatingGroupBounds==="boundedWithinViewport"?void 0:(m=(u=this.options.floatingGroupBounds)===null||u===void 0?void 0:u.minimumHeightWithinViewport)!==null&&m!==void 0?m:ps,transformDragPosition:this.options.transformFloatingGroupDrag?k=>this.options.transformFloatingGroupDrag({group:t,proposed:k.proposed,container:k.container,others:k.others}):void 0,getSiblingBoxes:()=>this._gatherFloatingGroupBoxes(t)})),b=(g=w?.element)!==null&&g!==void 0?g:t.element.querySelector(".dv-void-container");if(!b)throw new Error("dockview: failed to find drag handle");C.setupDrag(b,{inDragMode:typeof o?.inDragMode=="boolean"?o.inDragMode:!1});const D=p.add(t,C,e);w&&(D.setTitleBar(w),D.addDisposables(w,ke.from(()=>D.setTitleBar(void 0)),w.onDragStart(k=>{this._onWillDragGroup.fire({nativeEvent:k,group:D.group})})));for(const k of i)k.model.location={type:"floating"};o?.skipActiveGroup||this.doSetGroupAndPanelActive(t)}orthogonalize(e,t){switch(this.gridview.normalize(),e){case"top":case"bottom":this.gridview.orientation===ee.HORIZONTAL&&this.gridview.insertOrthogonalSplitviewAtRoot();break;case"left":case"right":this.gridview.orientation===ee.VERTICAL&&this.gridview.insertOrthogonalSplitviewAtRoot();break}switch(e){case"top":case"left":case"center":return this.createGroupAtLocation([0],void 0,t);case"bottom":case"right":return this.createGroupAtLocation([this.gridview.length],void 0,t);default:throw new Error(`dockview: unsupported position ${e}`)}}updateOptions(e){var t,i,s,o,r;super.updateOptions(e),(t=this._floatingGroupService)===null||t===void 0||t.updateBounds(e),(i=this._rootDropTargetService)===null||i===void 0||i.setOptions(e);const l=this.options.disableDnd,d=this.options.dndStrategy;this._options=Object.assign(Object.assign({},this.options),e);const c=this.options.disableDnd,h=this.options.dndStrategy;if((l!==c||d!==h)&&this.updateDragAndDropState(),"theme"in e&&this.updateTheme(),("createRightHeaderActionComponent"in e||"createLeftHeaderActionComponent"in e||"createPrefixHeaderActionComponent"in e)&&((s=this.headerActionsService)===null||s===void 0||s.refreshAll()),"createWatermarkComponent"in e){(o=this._watermarkService)===null||o===void 0||o.refresh();for(const u of this.groups)u.model.refreshWatermark()}if("tabGroupColors"in e||"tabGroupAccent"in e){this._tabGroupColorPalette.setEntries((r=this._options.tabGroupColors)!==null&&r!==void 0?r:Ro),this._tabGroupColorPalette.enabled=this._options.tabGroupAccent!=="off";for(const u of this.groups)u.model.refreshTabGroupAccent()}this._onDidOptionsChange.fire(),this._layoutFromShell(this.gridview.width,this.gridview.height)}layout(e,t,i){var s,o;this._shellManager&&!this._inShellLayout?this._shellManager.layout(e,t):super.layout(e,t,i),this._syncFloatingOverlayHost(),(o=(s=this._moduleRegistry)===null||s===void 0?void 0:s.services.floatingGroupService)===null||o===void 0||o.constrainBounds()}_syncFloatingOverlayHost(){if(!this._floatingOverlayHost||!this._shellManager)return;const e=this._shellManager.element.getBoundingClientRect(),t=this.element.getBoundingClientRect(),i=this._floatingOverlayHost;i.style.left=`${t.left-e.left}px`,i.style.top=`${t.top-e.top}px`,i.style.width=`${t.width}px`,i.style.height=`${t.height}px`}_layoutFromShell(e,t){this._inShellLayout=!0,this.layout(e,t,!0),this._inShellLayout=!1}forceRelayout(){this._shellManager?this._layoutFromShell(this.width,this.height):super.forceRelayout()}addEdgeGroup(e,t){const i=fi(this._edgeGroupService,"EdgeGroup","api.addEdgeGroup");if(!i)throw new Error("dockview: EdgeGroup module is not registered");if(i.has(e))throw new Error(`dockview: edge group already exists at position '${e}'`);return this.mutation("add",()=>{const s=this.createGroup({id:t.id});s.model.location={type:"edge",position:e},s.model.headerPosition=e;const o=s.model.onDidRemovePanel(()=>{s.model.isEmpty&&this.setEdgeGroupCollapsed(s,!0)});return i.add(e,s,o),this._onDidAddGroup.fire(s),this._shellManager.addEdgeView(e,t,s),s.api})}getEdgeGroup(e){var t,i;return(i=(t=this._edgeGroupService)===null||t===void 0?void 0:t.get(e))===null||i===void 0?void 0:i.api}setEdgeGroupVisible(e,t){this._shellManager.setEdgeGroupVisible(e,t)}isEdgeGroupVisible(e){return this._shellManager.isEdgeGroupVisible(e)}removeEdgeGroup(e){const t=fi(this._edgeGroupService,"EdgeGroup","api.removeEdgeGroup");if(!t)return;const i=t.get(e);if(!i)throw new Error(`dockview: no edge group exists at position '${e}'`);this.mutation("remove",()=>{for(const s of[...i.panels])this.removePanel(s,{removeEmptyGroup:!1,skipDispose:!1});this._shellManager.removeEdgeView(e),t.remove(e),i.dispose(),this._groups.delete(i.id),this._onDidRemoveGroup.fire(i)})}setEdgeGroupCollapsed(e,t){var i;const s=(i=this._edgeGroupService)===null||i===void 0?void 0:i.findPositionOf(e);s&&this._shellManager.isEdgeGroupCollapsed(s)!==t&&(this._shellManager.setEdgeGroupCollapsed(s,t),e.api._onDidCollapsedChange.fire({isCollapsed:t}))}isEdgeGroupCollapsed(e){var t;const i=(t=this._edgeGroupService)===null||t===void 0?void 0:t.findPositionOf(e);return i?this._shellManager.isEdgeGroupCollapsed(i):!1}updateDragAndDropState(){for(const e of this.groups)e.model.updateDragAndDropState()}focus(){var e;(e=this.activeGroup)===null||e===void 0||e.focus()}getGroupPanel(e){return this.panels.find(t=>t.id===e)}setActivePanel(e){e.group.model.openPanel(e),this.doSetGroupAndPanelActive(e.group)}moveToNext(e={}){var t;if(!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}if(e.includePanel&&e.group&&e.group.activePanel!==e.group.panels[e.group.panels.length-1]){e.group.model.moveToNext({suppressRoll:!0});return}const i=Te(e.group.element),s=(t=this.gridview.next(i))===null||t===void 0?void 0:t.view;this.doSetGroupAndPanelActive(s)}moveToPrevious(e={}){var t;if(!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}if(e.includePanel&&e.group&&e.group.activePanel!==e.group.panels[0]){e.group.model.moveToPrevious({suppressRoll:!0});return}const i=Te(e.group.element),s=(t=this.gridview.previous(i))===null||t===void 0?void 0:t.view;s&&this.doSetGroupAndPanelActive(s)}toJSON(){var e,t,i,s,o,r,l,d;const c=this.gridview.serialize(),h=this.panels.reduce((f,w)=>(f[w.id]=w.toJSON(),f),{}),u=(t=(e=this._floatingGroupService)===null||e===void 0?void 0:e.serialize())!==null&&t!==void 0?t:[],m=(s=(i=this._popoutWindowService)===null||i===void 0?void 0:i.serialize())!==null&&s!==void 0?s:[],g={grid:c,panels:h,activeGroup:(o=this.activeGroup)===null||o===void 0?void 0:o.id};u.length>0&&(g.floatingGroups=u),m.length>0&&(g.popoutGroups=m);const p=(l=(r=this._edgeGroupService)===null||r===void 0?void 0:r.entries())!==null&&l!==void 0?l:[];if(!((d=this._edgeGroupService)===null||d===void 0)&&d.hasAny()){const f=this._shellManager.toJSON();for(const[w,C]of p){const b=f[w];b&&(b.group=C.toJSON())}g.edgeGroups=f}return g}fromJSON(e,t){this.mutation("load",()=>this._doFromJSON(e,t))}_doFromJSON(e,t){var i,s,o,r,l,d,c;(i=this._popoutWindowService)===null||i===void 0||i.cancelPendingRestorations();const h=new Map;let u;if(t?.reuseExistingPanels){u=this.createGroup(),this._groups.delete(u.api.id);const f=Object.keys(e.panels);for(const w of this.panels)f.includes(w.api.id)&&h.set(w.api.id,w);this.movingLock(()=>{Array.from(h.values()).forEach(w=>{this.moveGroupOrPanel({from:{groupId:w.api.group.api.id,panelId:w.api.id},to:{group:u,position:"center"},keepEmptyGroups:!0})})})}if(this.clear(),typeof e!="object"||e===null)throw new Error("dockview: serialized layout must be a non-null object");const{grid:m,panels:g,activeGroup:p}=e;if(m.root.type!=="branch"||!Array.isArray(m.root.data))throw new Error("dockview: root must be of type branch");try{const f=this.width,w=this.height,C=D=>{const{id:k,locked:P,hideHeader:y,headerPosition:T,views:S,activeView:N}=D;if(typeof k!="string")throw new Error("dockview: group id must be of type string");const O=this.createGroup({id:k,locked:!!P,hideHeader:!!y,headerPosition:T});this._onDidAddGroup.fire(O);const $=[];for(const F of S){const q=h.get(F);if(u&&q)this.movingLock(()=>{u.model.removePanel(q)}),$.push(q),q.updateFromStateModel(g[F]);else{const re=this._deserializer.fromJSON(g[F],O);$.push(re)}}for(let F=0;F<S.length;F++){const q=$[F],re=typeof N=="string"&&N===q.id;h.has(q.api.id)?this.movingLock(()=>{O.model.openPanel(q,{skipSetActive:!re,skipSetGroupActive:!0})}):O.model.openPanel(q,{skipSetActive:!re,skipSetGroupActive:!0})}return D.tabGroups&&D.tabGroups.length>0&&O.model.restoreTabGroups(D.tabGroups),!O.activePanel&&O.panels.length>0&&O.model.openPanel(O.panels[O.panels.length-1],{skipSetGroupActive:!0}),O};this.gridview.deserialize(m,{fromJSON:D=>C(D.data)}),this._layoutFromShell(f,w),e.edgeGroups&&this.deserializeEdgeGroups(e.edgeGroups,g),this.deserializeFloatingWindows((s=e.floatingGroups)!==null&&s!==void 0?s:[],C);const b=this.deserializePopoutWindows((o=e.popoutGroups)!==null&&o!==void 0?o:[],C);if((r=this._popoutWindowService)===null||r===void 0||r.finishRestoration(b),(l=this._floatingGroupService)===null||l===void 0||l.constrainBounds(),typeof p=="string"){const D=this.getPanel(p);D&&this.doSetGroupAndPanelActive(D)}(d=this._watermarkService)===null||d===void 0||d.update()}catch(f){console.error("dockview: failed to deserialize layout. Reverting changes",f);for(const w of this.groups)for(const C of w.panels)this.removePanel(C,{removeEmptyGroup:!1,skipDispose:!1});for(const w of this.groups)w.dispose(),this._groups.delete(w.id),this._onDidRemoveGroup.fire(w);throw(c=this._floatingGroupService)===null||c===void 0||c.disposeAll(),this.clear(),f}this.debouncedUpdateAllPositions(),this._onDidLayoutFromJSON.fire()}deserializeNestedGridview(e,t){const i=this.createNestedGridview(e.orientation),s=[];return i.deserialize(e,{fromJSON:o=>{const r=t(o.data);return s.push(r),r}}),{gridview:i,members:s}}deserializeEdgeGroups(e,t){var i;const s=fi(this._edgeGroupService,"EdgeGroup","fromJSON edge restoration");if(s){for(const o of["top","bottom","left","right"]){const r=e[o];if(r&&!s.has(o)){const l=r.group,d=(i=l?.id)!==null&&i!==void 0?i:`${o}-group`;this.addEdgeGroup(o,{id:d})}}for(const[o,r]of s.entries()){const l=e[o],d=l?.group;if(d){const{views:c,activeView:h}=d,u=[];for(const m of c)if(t[m]){const g=this._deserializer.fromJSON(t[m],r);u.push(g)}for(let m=0;m<u.length;m++){const g=u[m],p=h===g.id;r.model.openPanel(g,{skipSetActive:!p,skipSetGroupActive:!0})}d.tabGroups&&d.tabGroups.length>0&&r.model.restoreTabGroups(d.tabGroups),!r.activePanel&&r.panels.length>0&&r.model.openPanel(r.panels[r.panels.length-1],{skipSetGroupActive:!0})}}this._shellManager.fromJSON(e)}}deserializeFloatingWindows(e,t){for(const i of e){const{data:s,grid:o,position:r}=i;if(o){const{gridview:l,members:d}=this.deserializeNestedGridview(o,t);if(d.length===0)continue;this.mountFloatingWindow(l,d[0],d,r,{inDragMode:!1})}else if(s){const l=t(s);this.addFloatingGroup(l,{position:r,width:r.width,height:r.height,skipRemoveGroup:!0,inDragMode:!1})}}}deserializePopoutWindows(e,t){const i=e.length>0?fi(this._popoutWindowService,"PopoutWindow","fromJSON popout restoration"):this._popoutWindowService;return i?e.flatMap((s,o)=>{const{data:r,grid:l,position:d,gridReferenceGroup:c,url:h}=s;let u,m=[];if(l){const p=this.deserializeNestedGridview(l,t);if(u=p.gridview,m=p.members,m.length===0)return u.dispose(),[]}const g=l?m[0]:t(r);return i.scheduleRestoration(o*Vm,()=>{this.addPopoutGroup(g,{position:d??void 0,overridePopoutGroup:c?g:void 0,overridePopoutGridview:u,referenceGroup:c?this.getPanel(c):void 0,popoutUrl:h})},()=>{for(const p of m.length>0?m:[g])if(!this.isDisposed&&this._groups.has(p.id)&&p.element.parentElement===null){for(const f of[...p.panels])this.removePanel(f,{removeEmptyGroup:!1});p.dispose(),this._groups.delete(p.id),this._onDidRemoveGroup.fire(p)}})}):[]}clear(){this.mutation("clear",()=>this._doClear())}_doClear(){var e;const t=Array.from(this._groups.values()).map(s=>s.value),i=!!this.activeGroup;for(const s of t){if(!((e=this._edgeGroupService)===null||e===void 0)&&e.includes(s)){const o=[...s.panels];for(const r of o)this.removePanel(r,{removeEmptyGroup:!1});continue}this.removeGroup(s,{skipActive:!0})}i&&this.doSetGroupAndPanelActive(void 0),this.gridview.clear()}closeAllGroups(){this.mutation("remove",()=>{for(const e of this._groups.entries()){const[t,i]=e;i.value.model.closeAllPanels()}})}addPanel(e){return this.mutation("add",()=>this._doAddPanel(e))}_doAddPanel(e){var t,i;if(this.panels.find(d=>d.id===e.id))throw new Error(`dockview: panel with id ${e.id} already exists`);let s;if(e.position&&e.floating)throw new Error("dockview: you can only provide one of: position, floating as arguments to .addPanel(...)");const o={width:e.initialWidth,height:e.initialHeight};let r;if(e.position)if(bm(e.position)){const d=typeof e.position.referencePanel=="string"?this.getGroupPanel(e.position.referencePanel):e.position.referencePanel;if(r=e.position.index,!d)throw new Error(`dockview: referencePanel '${e.position.referencePanel}' does not exist`);s=this.findGroup(d)}else if(xm(e.position)){if(s=typeof e.position.referenceGroup=="string"?(t=this._groups.get(e.position.referenceGroup))===null||t===void 0?void 0:t.value:e.position.referenceGroup,r=e.position.index,!s)throw new Error(`dockview: referenceGroup '${e.position.referenceGroup}' does not exist`)}else{const d=this.orthogonalize(Sa(e.position.direction)),c=this.createPanel(e,d);return d.model.openPanel(c,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:r}),e.inactive||this.doSetGroupAndPanelActive(d),d.api.setSize({height:o?.height,width:o?.width}),c}else s=this.activeGroup;let l;if(s){const d=us(((i=e.position)===null||i===void 0?void 0:i.direction)||"within");if(e.floating){const c=this.createGroup();this._onDidAddGroup.fire(c);const h=typeof e.floating=="object"&&e.floating!==null?e.floating:{};this.addFloatingGroup(c,Object.assign(Object.assign({},h),{inDragMode:!1,skipRemoveGroup:!0,skipActiveGroup:!0})),l=this.createPanel(e,c),c.model.openPanel(l,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:r})}else if(s.api.location.type==="floating"||s.api.location.type==="edge"||d==="center")l=this.createPanel(e,s),s.model.openPanel(l,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:r}),s.api.setSize({width:o?.width,height:o?.height}),e.inactive||this.doSetGroupAndPanelActive(s);else{const c=Te(s.element),h=vt(this.gridview.orientation,c,d),u=this.createGroupAtLocation(h,this.orientationAtLocation(h)===ee.VERTICAL?o?.height:o?.width);l=this.createPanel(e,u),u.model.openPanel(l,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:r}),e.inactive||this.doSetGroupAndPanelActive(u)}}else if(e.floating){const d=this.createGroup();this._onDidAddGroup.fire(d);const c=typeof e.floating=="object"&&e.floating!==null?e.floating:{};this.addFloatingGroup(d,Object.assign(Object.assign({},c),{inDragMode:!1,skipRemoveGroup:!0,skipActiveGroup:!0})),l=this.createPanel(e,d),d.model.openPanel(l,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:r})}else{const d=this.createGroupAtLocation([0],this.gridview.orientation===ee.VERTICAL?o?.height:o?.width);l=this.createPanel(e,d),d.model.openPanel(l,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:r}),e.inactive||this.doSetGroupAndPanelActive(d)}return l}removePanel(e,t={removeEmptyGroup:!0}){this.mutation("remove",()=>this._doRemovePanel(e,t))}_doRemovePanel(e,t={removeEmptyGroup:!0}){const i=e.group;if(!i)throw new Error(`dockview: cannot remove panel ${e.id}. it's missing a group.`);i.model.removePanel(e,{skipSetActiveGroup:t.skipSetActiveGroup}),t.skipDispose||(e.group.model.renderContainer.detatch(e),e.dispose()),i.size===0&&t.removeEmptyGroup&&this.removeGroup(i,{skipActive:t.skipSetActiveGroup})}createWatermarkComponent(){return this.options.createWatermarkComponent?this.options.createWatermarkComponent():new Im}addGroup(e){return this.mutation("add",()=>this._doAddGroup(e))}_doAddGroup(e){var t;if(e){let i;if(ym(e)){const c=typeof e.referencePanel=="string"?this.panels.find(h=>h.id===e.referencePanel):e.referencePanel;if(!c)throw new Error(`dockview: reference panel ${e.referencePanel} does not exist`);if(i=this.findGroup(c),!i)throw new Error(`dockview: reference group for reference panel ${e.referencePanel} does not exist`)}else if(Dm(e)){if(i=typeof e.referenceGroup=="string"?(t=this._groups.get(e.referenceGroup))===null||t===void 0?void 0:t.value:e.referenceGroup,!i)throw new Error(`dockview: reference group ${e.referenceGroup} does not exist`)}else{const c=this.orthogonalize(Sa(e.direction),e);return e.skipSetActive||this.doSetGroupAndPanelActive(c),c}const s=us(e.direction||"within"),o=Te(i.element),r=vt(this.gridview.orientation,o,s),l=this.createGroup(e),d=this.getLocationOrientation(r)===ee.VERTICAL?e.initialHeight:e.initialWidth;return this.doAddGroup(l,r,d),e.skipSetActive||this.doSetGroupAndPanelActive(l),l}else{const i=this.createGroup(e);return this.doAddGroup(i),this.doSetGroupAndPanelActive(i),i}}getLocationOrientation(e){return e.length%2==0&&this.gridview.orientation===ee.HORIZONTAL?ee.HORIZONTAL:ee.VERTICAL}removeGroup(e,t){this.mutation("remove",()=>this.doRemoveGroup(e,t))}detachFromNestedWindow(e){var t,i;const s=(t=this._floatingGroupService)===null||t===void 0?void 0:t.findByGroup(e);if(s){const r=this.nestedWindowMembers(e);return r.length<=1?!1:(s.gridview.remove(e),s.group===e&&s.setAnchorGroup(r.find(l=>l!==e)),!0)}const o=(i=this._popoutWindowService)===null||i===void 0?void 0:i.findByGroup(e);if(o){const r=this.nestedWindowMembers(e);return r.length<=1?!1:(o.gridview.remove(e),o.popoutGroup===e&&(o.popoutGroup=r.find(l=>l!==e)),!0)}return!1}disposeGroupRecord(e){e.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e)}activateFallbackGroupIfRemoved(e,t){if(!t&&this._activeGroup===e){const i=Array.from(this._groups.values());this.doSetGroupAndPanelActive(i.length>0?i[0].value:void 0)}}doRemoveGroup(e,t){var i,s,o,r,l;if(!((i=this._edgeGroupService)===null||i===void 0)&&i.includes(e))return e;const d=[...e.panels];if(!t?.skipDispose)for(const u of d)this.removePanel(u,{removeEmptyGroup:!1,skipDispose:(s=t?.skipDispose)!==null&&s!==void 0?s:!1});const c=this.activePanel;if(e.api.location.type==="floating"){const u=(o=this._floatingGroupService)===null||o===void 0?void 0:o.findByGroup(e);if(!u)throw new Error("dockview: failed to find floating group");return this.detachFromNestedWindow(e)?(t?.skipDispose?e.model.location={type:"grid"}:this.disposeGroupRecord(e),this.activateFallbackGroupIfRemoved(e,t?.skipActive),e):(t?.skipDispose||this.disposeGroupRecord(e),u.dispose(),this.activateFallbackGroupIfRemoved(e,t?.skipActive),e)}if(e.api.location.type==="popout"){const u=(r=this._popoutWindowService)===null||r===void 0?void 0:r.findByGroup(e);if(!u)throw new Error("dockview: failed to find popout group");if(this.detachFromNestedWindow(e))return t?.skipDispose?e.model.location={type:"grid"}:this.disposeGroupRecord(e),this.activateFallbackGroupIfRemoved(e,t?.skipActive),e;if(!t?.skipDispose){if(!t?.skipPopoutAssociated){const g=u.referenceGroup?this.getPanel(u.referenceGroup):void 0;g&&g.panels.length===0&&this.removeGroup(g)}u.popoutGroup.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e)}(l=this._popoutWindowService)===null||l===void 0||l.remove(u);const m=u.disposable.dispose();return!t?.skipPopoutReturn&&m&&(this.doAddGroup(m,[0]),this.doSetGroupAndPanelActive(m)),this.activateFallbackGroupIfRemoved(e,t?.skipActive),u.popoutGroup}if(!this.gridview.element.contains(e.element)){if(!t?.skipDispose){const u=this._groups.get(e.id);u?.disposable.dispose(),this.disposeGroupRecord(e)}return this.activateFallbackGroupIfRemoved(e,t?.skipActive),e}const h=super.doRemoveGroup(e,t);return t?.skipActive||this.activePanel!==c&&this.fireActivePanelChange(this.activePanel),h}debouncedUpdateAllPositions(){this._updatePositionsFrameId!==void 0&&cancelAnimationFrame(this._updatePositionsFrameId),this._updatePositionsFrameId=requestAnimationFrame(()=>{var e,t;this._updatePositionsFrameId=void 0,this.overlayRenderContainer.updateAllPositions();for(const i of(t=(e=this._popoutWindowService)===null||e===void 0?void 0:e.entries)!==null&&t!==void 0?t:[])i.overlayRenderContainer.updateAllPositions()})}movingLock(e){const t=this._moving;try{return this._moving=!0,e()}finally{this._moving=t}}mutation(e,t){const i=this._mutationDepth===0,s=this._origin;i&&this._onWillMutateLayout.fire({kind:e,origin:s}),this._mutationDepth++;try{return t()}finally{this._mutationDepth--,i&&this._onDidMutateLayout.fire({kind:e,origin:s})}}currentOrigin(){return this._origin}withOrigin(e,t){if(this._originDepth>0||this._mutationDepth>0)return t();const i=this._origin;this._origin=e,this._originDepth++;try{return t()}finally{this._originDepth--,this._origin=i}}fireActivePanelChange(e){this._onDidActivePanelChange.fire({panel:e,origin:this._origin})}moveGroupOrPanel(e){this.mutation("move",()=>this._doMoveGroupOrPanel(e))}_doMoveGroupOrPanel(e){var t,i;const s=e.to.group,o=e.from.groupId,r=e.from.panelId,l=e.to.position,d=e.to.index,c=o?(t=this._groups.get(o))===null||t===void 0?void 0:t.value:void 0;if(!c)throw new Error(`dockview: Failed to find group id ${o}`);if(r===void 0){e.from.tabGroupId?this.moveTabGroupToGroup({sourceGroup:c,tabGroupId:e.from.tabGroupId,destinationGroup:s,destinationTarget:l,destinationIndex:d,skipSetActive:e.skipSetActive,keepEmptyGroups:e.keepEmptyGroups}):this.moveGroup({from:{group:c},to:{group:s,position:l},skipSetActive:e.skipSetActive});return}if(!l||l==="center"){const h=this.movingLock(()=>c.model.removePanel(r,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!h)throw new Error(`dockview: No panel with id ${r}`);!e.keepEmptyGroups&&c.model.size===0&&this.doRemoveGroup(c,{skipActive:!0});const u=s.model.size===0;this.movingLock(()=>{var m;return s.model.openPanel(h,{index:d,skipSetActive:((m=e.skipSetActive)!==null&&m!==void 0?m:!1)&&!u,skipSetGroupActive:!0})}),e.skipSetActive||this.doSetGroupAndPanelActive(s),this._onDidMovePanel.fire({panel:h,from:c})}else{const h=this.getGridviewForGroup(s),u=Te(s.element),m=vt(h.orientation,u,l);if(c.size<2){const[g,p]=ti(m);if(c.api.location.type==="grid"&&h===this.gridview){const b=Te(c.element),[D,k]=ti(b);if(wl(D,g)){this.gridview.moveView(D,k,p),this._onDidMovePanel.fire({panel:this.getGroupPanel(r),from:c});return}}if(c.api.location.type==="popout"&&this.nestedWindowMembers(c).length<=1){const b=(i=this._popoutWindowService)===null||i===void 0?void 0:i.findByGroup(c);if(!b)return;const D=this.movingLock(()=>b.popoutGroup.model.removePanel(b.popoutGroup.panels[0],{skipSetActive:!0,skipSetActiveGroup:!0}));this.doRemoveGroup(c,{skipActive:!0});const k=vt(h.orientation,Te(s.element),l),P=this.createGroupAtLocation(k,void 0,void 0,h);this.movingLock(()=>P.model.openPanel(D,{skipSetActive:!0})),this.doSetGroupAndPanelActive(P),this._onDidMovePanel.fire({panel:this.getGroupPanel(r),from:c});return}if(c.api.location.type==="edge"){const b=this.movingLock(()=>c.model.removePanel(r,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!b)throw new Error(`dockview: No panel with id ${r}`);const D=this.createGroupAtLocation(m,void 0,void 0,h);this.movingLock(()=>D.model.openPanel(b,{skipSetGroupActive:!0})),this.doSetGroupAndPanelActive(D),this._onDidMovePanel.fire({panel:b,from:c});return}const f=this.movingLock(()=>this.doRemoveGroup(c,{skipActive:!0,skipDispose:!0})),w=Te(s.element),C=vt(h.orientation,w,l);this.movingLock(()=>this.doAddGroup(f,C,void 0,h)),this.setGroupLocationForRoot(f,h),this.doSetGroupAndPanelActive(f),this._onDidMovePanel.fire({panel:this.getGroupPanel(r),from:c})}else{const g=this.movingLock(()=>c.model.removePanel(r,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!g)throw new Error(`dockview: No panel with id ${r}`);const p=vt(h.orientation,u,l),f=this.createGroupAtLocation(p,void 0,void 0,h);this.movingLock(()=>f.model.openPanel(g,{skipSetGroupActive:!0})),this.doSetGroupAndPanelActive(f),this._onDidMovePanel.fire({panel:g,from:c})}}}moveTabGroupToGroup(e){const{sourceGroup:t,tabGroupId:i,destinationGroup:s,destinationTarget:o,destinationIndex:r}=e,l=t.model.getTabGroups().find(C=>C.id===i);if(!l||l.panelIds.length===0)return;const d=l.label,c=l.color,h=l.collapsed,u=l.componentParams,m=[...l.panelIds],g=o&&o!=="center"?Te(s.element):void 0,p=this.movingLock(()=>m.map(C=>t.model.removePanel(C,{skipSetActive:!1,skipSetActiveGroup:!0})).filter(C=>C!==void 0));if(p.length===0)return;const f=C=>{this.movingLock(()=>{for(const D of p)C.model.openPanel(D,{index:r,skipSetActive:!0,skipSetGroupActive:!0})});const b=C.model.createTabGroup({label:d,color:c,collapsed:h,componentParams:u});for(const D of p)C.model.addPanelToTabGroup(b.id,D.id);e.skipSetActive||this.doSetGroupAndPanelActive(C);for(const D of p)this._onDidMovePanel.fire({panel:D,from:t})};let w;if(!o||o==="center"||!g)w=s;else{const C=vt(this.gridview.orientation,g,o);w=this.createGroupAtLocation(C)}!e.keepEmptyGroups&&t.model.size===0&&t!==w&&this.doRemoveGroup(t,{skipActive:!0}),f(w)}moveGroup(e){this.mutation("move",()=>this._doMoveGroup(e))}maximizeGroup(e){this.mutation("maximize",()=>super.maximizeGroup(e))}exitMaximizedGroup(){this.mutation("maximize",()=>super.exitMaximizedGroup())}_doMoveGroup(e){var t,i,s;const o=e.from.group,r=e.to.group,l=e.to.position;let d=o;if(l==="center"){const c=o.activePanel,h=o.model.getTabGroups().map(m=>({label:m.label,color:m.color,collapsed:m.collapsed,componentParams:m.componentParams,panelIds:[...m.panelIds]})),u=this.movingLock(()=>[...o.panels].map(m=>o.model.removePanel(m.id,{skipSetActive:!0})));o?.model.size===0&&this.doRemoveGroup(o,{skipActive:!0}),this.movingLock(()=>{for(const m of u)r.model.openPanel(m,{skipSetActive:m!==c,skipSetGroupActive:!0})});for(const m of h){const g=r.model.createTabGroup({label:m.label,color:m.color,collapsed:m.collapsed,componentParams:m.componentParams});for(const p of m.panelIds)r.model.addPanelToTabGroup(g.id,p)}e.skipSetActive!==!0?this.doSetGroupAndPanelActive(r):this.activePanel||this.doSetGroupAndPanelActive(r)}else{if(o.api.location.type==="edge"){const c=o.activePanel,h=o.model.getTabGroups().map(m=>({label:m.label,color:m.color,collapsed:m.collapsed,componentParams:m.componentParams,panelIds:[...m.panelIds]})),u=this.movingLock(()=>[...o.panels].map(m=>o.model.removePanel(m.id,{skipSetActive:!0})));d=this.createGroup(),this._onDidAddGroup.fire(d),this.movingLock(()=>{for(const m of u)d.model.openPanel(m,{skipSetActive:m!==c,skipSetGroupActive:!0})});for(const m of h){const g=d.model.createTabGroup({label:m.label,color:m.color,collapsed:m.collapsed,componentParams:m.componentParams});for(const p of m.panelIds)d.model.addPanelToTabGroup(g.id,p)}}else switch(o.api.location.type){case"grid":this.gridview.removeView(Te(o.element));break;case"floating":{const c=(t=this._floatingGroupService)===null||t===void 0?void 0:t.findByGroup(o);if(!c)throw new Error("dockview: failed to find floating group");this.detachFromNestedWindow(o)||c.dispose();break}case"popout":{const c=(i=this._popoutWindowService)===null||i===void 0?void 0:i.findByGroup(o);if(!c)throw new Error("dockview: failed to find popout group");if(this.detachFromNestedWindow(o))break;if((s=this._popoutWindowService)===null||s===void 0||s.remove(c),c.referenceGroup){const h=this.getPanel(c.referenceGroup);h&&!h.api.isVisible&&this.doRemoveGroup(h,{skipActive:!0})}c.window.dispose();break}}if(r.api.location.type==="grid"||r.api.location.type==="floating"||r.api.location.type==="popout"){const c=this.getGridviewForGroup(r),h=Te(r.element),u=vt(c.orientation,h,l);let m;switch(c.orientation){case ee.VERTICAL:m=h.length%2==0?o.api.width:o.api.height;break;case ee.HORIZONTAL:m=h.length%2==0?o.api.height:o.api.width;break}c.addView(d,m,u),this.setGroupLocationForRoot(d,c)}}if(d.panels.forEach(c=>{this._onDidMovePanel.fire({panel:c,from:o})}),this.debouncedUpdateAllPositions(),e.skipSetActive===!1){const c=r??o;this.doSetGroupAndPanelActive(c)}else d!==o&&e.skipSetActive!==!0&&this.doSetGroupAndPanelActive(d)}doSetGroupActive(e){var t;super.doSetGroupActive(e);const i=this.activePanel;!this._moving&&i!==((t=this._onDidActivePanelChange.value)===null||t===void 0?void 0:t.panel)&&this.fireActivePanelChange(i)}doSetGroupAndPanelActive(e){var t;super.doSetGroupActive(e);const i=this.activePanel;e&&this.hasMaximizedGroup()&&!this.isMaximizedGroup(e)&&this.exitMaximizedGroup(),!this._moving&&i!==((t=this._onDidActivePanelChange.value)===null||t===void 0?void 0:t.panel)&&this.fireActivePanelChange(i)}getNextGroupId(){let e=this.nextGroupId.next();for(;this._groups.has(e);)e=this.nextGroupId.next();return e}createGroup(e){e||(e={});let t=e?.id;if(t&&this._groups.has(e.id)&&(console.warn(`dockview: Duplicate group id ${e?.id}. reassigning group id to avoid errors`),t=void 0),!t)for(t=this.nextGroupId.next();this._groups.has(t);)t=this.nextGroupId.next();const i=new Bn(this,t,e);if(i.init({params:{},accessor:this}),!this._groups.has(i.id)){const s=new X(i.model.onTabDragStart(o=>{var r;(r=this._advancedDnDService)===null||r===void 0||r.dispatchWillDragPanel(o)}),i.model.onGroupDragStart(o=>{var r;(r=this._advancedDnDService)===null||r===void 0||r.dispatchWillDragGroup(o)}),i.model.onMove(o=>{const{groupId:r,itemId:l,target:d,index:c,tabGroupId:h}=o;this.moveGroupOrPanel({from:{groupId:r,panelId:l,tabGroupId:h},to:{group:i,position:d,index:c}})}),i.model.onDidDrop(o=>{this._onDidDrop.fire(o)}),i.model.onWillDrop(o=>{var r;(r=this._advancedDnDService)===null||r===void 0||r.dispatchWillDrop(o)}),i.model.onWillShowOverlay(o=>{var r;if(this.options.disableDnd){o.preventDefault();return}(r=this._advancedDnDService)===null||r===void 0||r.dispatchWillShowOverlay(o)}),i.model.onUnhandledDragOver(o=>{this._onUnhandledDragOver.fire(o)}),i.model.onDidAddPanel(o=>{this._moving||this._onDidAddPanel.fire(o.panel)}),i.model.onDidRemovePanel(o=>{this._moving||this._onDidRemovePanel.fire(o.panel)}),i.model.onDidActivePanelChange(o=>{var r;this._moving||o.panel===this.activePanel&&((r=this._onDidActivePanelChange.value)===null||r===void 0?void 0:r.panel)!==o.panel&&this.fireActivePanelChange(o.panel)}),wt.any(i.model.onDidPanelTitleChange,i.model.onDidPanelParametersChange)(()=>{this._bufferOnDidLayoutChange.fire()}));this._groups.set(i.id,{value:i,disposable:s})}return i.initialize(),i}createPanel(e,t){var i,s,o;const r=e.component,l=(i=e.tabComponent)!==null&&i!==void 0?i:this.options.defaultTabComponent,d=new Bl(this,e.id,r,l),c=new Oi(e.id,r,l,this,this._api,t,d,{renderer:e.renderer,minimumWidth:e.minimumWidth,minimumHeight:e.minimumHeight,maximumWidth:e.maximumWidth,maximumHeight:e.maximumHeight});return c.init({title:(s=e.title)!==null&&s!==void 0?s:e.id,params:(o=e?.params)!==null&&o!==void 0?o:{}}),c}createGroupAtLocation(e,t,i,s=this.gridview){const o=this.createGroup(i);return this.doAddGroup(o,e,t,s),this.setGroupLocationForRoot(o,s),o}setGroupLocationForRoot(e,t){var i;const s=(i=this._popoutWindowService)===null||i===void 0?void 0:i.entries.find(o=>o.gridview===t);if(s){e.model.renderContainer!==s.overlayRenderContainer&&(e.model.renderContainer=s.overlayRenderContainer),e.model.dropTargetContainer=s.dropTargetContainer,e.model.location={type:"popout",getWindow:s.getWindow,popoutUrl:s.popoutUrl};return}e.model.renderContainer!==this.overlayRenderContainer&&(e.model.renderContainer=this.overlayRenderContainer),e.model.dropTargetContainer=this.rootDropTargetContainer,e.model.location=t===this.gridview?{type:"grid"}:{type:"floating"}}getGridviewForGroup(e){var t,i;const s=(t=this._floatingGroupService)===null||t===void 0?void 0:t.findByGroup(e);if(s)return s.gridview;const o=(i=this._popoutWindowService)===null||i===void 0?void 0:i.findByGroup(e);return o?o.gridview:this.gridview}nestedWindowMembers(e){const t=this.getGridviewForGroup(e);return t===this.gridview?[]:this.groups.filter(i=>t.element.contains(i.element))}findGroup(e){var t;return(t=Array.from(this._groups.values()).find(i=>i.value.model.containsPanel(e)))===null||t===void 0?void 0:t.value}orientationAtLocation(e){const t=this.gridview.orientation;return e.length%2==1?t:Rt(t)}updateTheme(){var e,t,i,s,o,r,l,d,c,h;const u=(e=this._options.theme)!==null&&e!==void 0?e:Tm;(t=this._shellThemeClassnames)===null||t===void 0||t.setClassNames(u.className);const m=(i=u.gap)!==null&&i!==void 0?i:0;this.gridview.margin=m;for(const p of this.floatingGroups)p.gridview.margin=m;for(const p of(o=(s=this._popoutWindowService)===null||s===void 0?void 0:s.entries)!==null&&o!==void 0?o:[])p.gridview.margin=m;(r=this._shellManager)===null||r===void 0||r.updateTheme(m,(l=u.edgeGroupCollapsedSize)!==null&&l!==void 0?l:35),u.dndOverlayBorder!==void 0?(this.element.style.setProperty("--dv-drag-over-border",u.dndOverlayBorder),(d=this._shellManager)===null||d===void 0||d.element.style.setProperty("--dv-drag-over-border",u.dndOverlayBorder)):(this.element.style.removeProperty("--dv-drag-over-border"),(c=this._shellManager)===null||c===void 0||c.element.style.removeProperty("--dv-drag-over-border")),u.dndOverlayMounting==="absolute"?this.rootDropTargetContainer.disabled=!1:this.rootDropTargetContainer.disabled=!0;const g=((h=u.tabGroupIndicator)!==null&&h!==void 0?h:"wrap")==="none";W(this.element,"dv-tab-group-indicator-none",g),this._shellManager&&W(this._shellManager.element,"dv-tab-group-indicator-none",g);for(const p of this.groups)p.model.updateTabGroups()}}class bv extends Dl{get orientation(){return this.gridview.orientation}set orientation(e){this.gridview.orientation=e}get options(){return this._options}get deserializer(){return this._deserializer}set deserializer(e){this._deserializer=e}constructor(e,t){var i;super(e,{proportionalLayout:(i=t.proportionalLayout)!==null&&i!==void 0?i:!0,orientation:t.orientation,styles:t.hideBorders?{separatorBorder:"transparent"}:void 0,disableAutoResizing:t.disableAutoResizing,className:t.className}),this._onDidLayoutfromJSON=new z,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidRemoveGroup=new z,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new z,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidActiveGroupChange=new z,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._options=t,this.addDisposables(this._onDidAddGroup,this._onDidRemoveGroup,this._onDidActiveGroupChange,this.onDidAdd(s=>{this._onDidAddGroup.fire(s)}),this.onDidRemove(s=>{this._onDidRemoveGroup.fire(s)}),this.onDidActiveChange(s=>{this._onDidActiveGroupChange.fire(s)}))}updateOptions(e){super.updateOptions(e);const t=typeof e.orientation=="string"&&this.gridview.orientation!==e.orientation;this._options=Object.assign(Object.assign({},this.options),e),t&&(this.gridview.orientation=e.orientation),this.layout(this.gridview.width,this.gridview.height,!0)}removePanel(e){this.removeGroup(e)}toJSON(){var e;return{grid:this.gridview.serialize(),activePanel:(e=this.activeGroup)===null||e===void 0?void 0:e.id}}setVisible(e,t){this.gridview.setViewVisible(Te(e.element),t)}setActive(e){this._groups.forEach((t,i)=>{t.value.setActive(e===t.value)})}focus(){var e;(e=this.activeGroup)===null||e===void 0||e.focus()}fromJSON(e){this.clear();const{grid:t,activePanel:i}=e;try{const s=[],o=this.width,r=this.height;if(this.gridview.deserialize(t,{fromJSON:l=>{const{data:d}=l,c=this.options.createComponent({id:d.id,name:d.component});return s.push(()=>c.init({params:d.params,minimumWidth:d.minimumWidth,maximumWidth:d.maximumWidth,minimumHeight:d.minimumHeight,maximumHeight:d.maximumHeight,priority:d.priority,snap:!!d.snap,accessor:this,isVisible:l.visible})),this._onDidAddGroup.fire(c),this.registerPanel(c),c}}),this.layout(o,r,!0),s.forEach(l=>l()),typeof i=="string"){const l=this.getPanel(i);l&&this.doSetGroupActive(l)}}catch(s){for(const o of this.groups)o.dispose(),this._groups.delete(o.id),this._onDidRemoveGroup.fire(o);throw this.clear(),s}this._onDidLayoutfromJSON.fire()}clear(){const e=this.activeGroup,t=Array.from(this._groups.values());for(const i of t)i.disposable.dispose(),this.doRemoveGroup(i.value,{skipActive:!0});e&&this.doSetGroupActive(void 0),this.gridview.clear()}movePanel(e,t){var i;let s;const o=this.gridview.remove(e),r=(i=this._groups.get(t.reference))===null||i===void 0?void 0:i.value;if(!r)throw new Error(`reference group ${t.reference} does not exist`);const l=us(t.direction);if(l==="center")throw new Error(`${l} not supported as an option`);{const d=Te(r.element);s=vt(this.gridview.orientation,d,l)}this.doAddGroup(o,s,t.size)}addPanel(e){var t,i,s,o;let r=(t=e.location)!==null&&t!==void 0?t:[0];if(!((i=e.position)===null||i===void 0)&&i.referencePanel){const d=(s=this._groups.get(e.position.referencePanel))===null||s===void 0?void 0:s.value;if(!d)throw new Error(`reference group ${e.position.referencePanel} does not exist`);const c=us(e.position.direction);if(c==="center")throw new Error(`${c} not supported as an option`);{const h=Te(d.element);r=vt(this.gridview.orientation,h,c)}}const l=this.options.createComponent({id:e.id,name:e.component});return l.init({params:(o=e.params)!==null&&o!==void 0?o:{},minimumWidth:e.minimumWidth,maximumWidth:e.maximumWidth,minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight,priority:e.priority,snap:!!e.snap,accessor:this,isVisible:!0}),this.doAddGroup(l,r,e.size),this.registerPanel(l),this.doSetGroupActive(l),l}registerPanel(e){const t=new X(e.api.onDidFocusChange(i=>{i.isFocused&&this._groups.forEach(s=>{const o=s.value;o!==e?o.setActive(!1):o.setActive(!0)})}));this._groups.set(e.id,{value:e,disposable:t})}moveGroup(e,t,i){const s=this.getPanel(t);if(!s)throw new Error("invalid operation");const o=Te(e.element),r=vt(this.gridview.orientation,o,i),[l,d]=ti(r),c=Te(s.element),[h,u]=ti(c);if(wl(h,l)){this.gridview.moveView(h,u,d);return}const m=this.doRemoveGroup(s,{skipActive:!0,skipDispose:!0}),g=Te(e.element),p=vt(this.gridview.orientation,g,i);this.doAddGroup(m,p)}removeGroup(e){super.removeGroup(e)}dispose(){super.dispose(),this._onDidLayoutfromJSON.dispose()}}class xv extends jo{get panels(){return this.splitview.getViews()}get options(){return this._options}get length(){return this._panels.size}get orientation(){return this.splitview.orientation}get splitview(){return this._splitview}set splitview(e){this._splitview&&this._splitview.dispose(),this._splitview=e,this._splitviewChangeDisposable.value=new X(this._splitview.onDidSashEnd(()=>{this._onDidLayoutChange.fire(void 0)}),this._splitview.onDidAddView(t=>this._onDidAddView.fire(t)),this._splitview.onDidRemoveView(t=>this._onDidRemoveView.fire(t)))}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get height(){return this.splitview.orientation===ee.HORIZONTAL?this.splitview.orthogonalSize:this.splitview.size}get width(){return this.splitview.orientation===ee.HORIZONTAL?this.splitview.size:this.splitview.orthogonalSize}constructor(e,t){var i;super(document.createElement("div"),t.disableAutoResizing),this._splitviewChangeDisposable=new $e,this._panels=new Map,this._onDidLayoutfromJSON=new z,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidAddView=new z,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new z,this.onDidRemoveView=this._onDidRemoveView.event,this._onDidLayoutChange=new z,this.onDidLayoutChange=this._onDidLayoutChange.event,this.element.style.height="100%",this.element.style.width="100%",this._classNames=new ys(this.element),this._classNames.setClassNames((i=t.className)!==null&&i!==void 0?i:""),e.appendChild(this.element),this._options=t,this.splitview=new Ci(this.element,t),this.addDisposables(this._onDidAddView,this._onDidLayoutfromJSON,this._onDidRemoveView,this._onDidLayoutChange)}updateOptions(e){var t,i;"className"in e&&this._classNames.setClassNames((t=e.className)!==null&&t!==void 0?t:""),"disableResizing"in e&&(this.disableResizing=(i=e.disableAutoResizing)!==null&&i!==void 0?i:!1),typeof e.orientation=="string"&&(this.splitview.orientation=e.orientation),this._options=Object.assign(Object.assign({},this.options),e),this.splitview.layout(this.splitview.size,this.splitview.orthogonalSize)}focus(){var e;(e=this._activePanel)===null||e===void 0||e.focus()}movePanel(e,t){this.splitview.moveView(e,t)}setVisible(e,t){const i=this.panels.indexOf(e);this.splitview.setViewVisible(i,t)}setActive(e,t){this._activePanel=e,this.panels.filter(i=>i!==e).forEach(i=>{i.api._onDidActiveChange.fire({isActive:!1}),t||i.focus()}),e.api._onDidActiveChange.fire({isActive:!0}),t||e.focus()}removePanel(e,t){const i=this._panels.get(e.id);if(!i)throw new Error(`unknown splitview panel ${e.id}`);i.dispose(),this._panels.delete(e.id);const s=this.panels.findIndex(l=>l===e);this.splitview.removeView(s,t).dispose();const r=this.panels;r.length>0&&this.setActive(r[r.length-1])}getPanel(e){return this.panels.find(t=>t.id===e)}addPanel(e){var t;if(this._panels.has(e.id))throw new Error(`panel ${e.id} already exists`);const i=this.options.createComponent({id:e.id,name:e.component});i.orientation=this.splitview.orientation,i.init({params:(t=e.params)!==null&&t!==void 0?t:{},minimumSize:e.minimumSize,maximumSize:e.maximumSize,snap:e.snap,priority:e.priority,accessor:this});const s=typeof e.size=="number"?e.size:nt.Distribute,o=typeof e.index=="number"?e.index:void 0;return this.splitview.addView(i,s,o),this.doAddView(i),this.setActive(i),i}layout(e,t){const[i,s]=this.splitview.orientation===ee.HORIZONTAL?[e,t]:[t,e];this.splitview.layout(i,s)}doAddView(e){const t=e.api.onDidFocusChange(i=>{i.isFocused&&this.setActive(e,!0)});this._panels.set(e.id,t)}toJSON(){var e;return{views:this.splitview.getViews().map((i,s)=>({size:this.splitview.getViewSize(s),data:i.toJSON(),snap:!!i.snap,priority:i.priority})),activeView:(e=this._activePanel)===null||e===void 0?void 0:e.id,size:this.splitview.size,orientation:this.splitview.orientation}}fromJSON(e){this.clear();const{views:t,orientation:i,size:s,activeView:o}=e,r=[],l=this.width,d=this.height;if(this.splitview=new Ci(this.element,{orientation:i,proportionalLayout:this.options.proportionalLayout,descriptor:{size:s,views:t.map(c=>{const h=c.data;if(this._panels.has(h.id))throw new Error(`panel ${h.id} already exists`);const u=this.options.createComponent({id:h.id,name:h.component});return r.push(()=>{var m;u.init({params:(m=h.params)!==null&&m!==void 0?m:{},minimumSize:h.minimumSize,maximumSize:h.maximumSize,snap:c.snap,priority:c.priority,accessor:this})}),u.orientation=i,this.doAddView(u),setTimeout(()=>{this._onDidAddView.fire(u)},0),{size:c.size,view:u}})}}),this.layout(l,d),r.forEach(c=>c()),typeof o=="string"){const c=this.getPanel(o);c&&this.setActive(c)}this._onDidLayoutfromJSON.fire()}clear(){for(const e of this._panels.values())e.dispose();for(this._panels.clear();this.splitview.length>0;)this.splitview.removeView(0,nt.Distribute,!0).dispose()}dispose(){for(const t of this._panels.values())t.dispose();this._panels.clear();const e=this.splitview.getViews();this._splitviewChangeDisposable.dispose(),this.splitview.dispose();for(const t of e)t.dispose();this.element.remove(),super.dispose()}}class Oa extends X{get element(){return this._element}constructor(){super(),this._expandedIcon=fm(),this._collapsedIcon=Fl(),this.disposable=new $e,this.apiRef={api:null},this._element=document.createElement("div"),this.element.className="dv-default-header",this._content=document.createElement("span"),this._expander=document.createElement("div"),this._expander.className="dv-pane-header-icon",this.element.appendChild(this._expander),this.element.appendChild(this._content),this.addDisposables(U(this._element,"click",()=>{var e;(e=this.apiRef.api)===null||e===void 0||e.setExpanded(!this.apiRef.api.isExpanded)}))}init(e){this.apiRef.api=e.api,this._content.textContent=e.title,this.updateIcon(),this.disposable.value=e.api.onDidExpansionChange(()=>{this.updateIcon()})}updateIcon(){var e;const t=!!(!((e=this.apiRef.api)===null||e===void 0)&&e.isExpanded);W(this._expander,"collapsed",!t),t?(this._expander.contains(this._collapsedIcon)&&this._collapsedIcon.remove(),this._expander.contains(this._expandedIcon)||this._expander.appendChild(this._expandedIcon)):(this._expander.contains(this._expandedIcon)&&this._expandedIcon.remove(),this._expander.contains(this._collapsedIcon)||this._expander.appendChild(this._collapsedIcon))}update(e){}dispose(){this.disposable.dispose(),super.dispose()}}const yv=No(),Ma=22,La=0,Ra=Number.MAX_SAFE_INTEGER;class Va extends Qp{constructor(e){super({accessor:e.accessor,id:e.id,component:e.component,headerComponent:e.headerComponent,orientation:e.orientation,isExpanded:e.isExpanded,disableDnd:e.disableDnd,headerSize:e.headerSize,minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize}),this.options=e}getBodyComponent(){return this.options.body}getHeaderComponent(){return this.options.header}}class Dv extends jo{get id(){return this._id}get panels(){return this.paneview.getPanes()}set paneview(e){this._paneview=e,this._disposable.value=new X(this._paneview.onDidChange(()=>{this._onDidLayoutChange.fire(void 0)}),this._paneview.onDidAddView(t=>this._onDidAddView.fire(t)),this._paneview.onDidRemoveView(t=>this._onDidRemoveView.fire(t)))}get paneview(){return this._paneview}get minimumSize(){return this.paneview.minimumSize}get maximumSize(){return this.paneview.maximumSize}get height(){return this.paneview.orientation===ee.HORIZONTAL?this.paneview.orthogonalSize:this.paneview.size}get width(){return this.paneview.orientation===ee.HORIZONTAL?this.paneview.size:this.paneview.orthogonalSize}get options(){return this._options}constructor(e,t){var i;super(document.createElement("div"),t.disableAutoResizing),this._id=yv.next(),this._disposable=new $e,this._viewDisposables=new Map,this._onDidLayoutfromJSON=new z,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidLayoutChange=new z,this.onDidLayoutChange=this._onDidLayoutChange.event,this._onDidDrop=new z,this.onDidDrop=this._onDidDrop.event,this._onDidAddView=new z,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new z,this.onDidRemoveView=this._onDidRemoveView.event,this._onUnhandledDragOver=new z,this.onUnhandledDragOver=this._onUnhandledDragOver.event,this.element.style.height="100%",this.element.style.width="100%",this.addDisposables(this._onDidLayoutChange,this._onDidLayoutfromJSON,this._onDidDrop,this._onDidAddView,this._onDidRemoveView,this._onUnhandledDragOver),this._classNames=new ys(this.element),this._classNames.setClassNames((i=t.className)!==null&&i!==void 0?i:""),e.appendChild(this.element),this._options=t,this.paneview=new Ca(this.element,{orientation:ee.VERTICAL}),this.addDisposables(this._disposable)}setVisible(e,t){const i=this.panels.indexOf(e);this.paneview.setViewVisible(i,t)}focus(){}updateOptions(e){var t,i;"className"in e&&this._classNames.setClassNames((t=e.className)!==null&&t!==void 0?t:""),"disableResizing"in e&&(this.disableResizing=(i=e.disableAutoResizing)!==null&&i!==void 0?i:!1),this._options=Object.assign(Object.assign({},this.options),e)}addPanel(e){var t,i;const s=this.options.createComponent({id:e.id,name:e.component});let o;e.headerComponent&&this.options.createHeaderComponent&&(o=this.options.createHeaderComponent({id:e.id,name:e.headerComponent})),o||(o=new Oa);const r=new Va({id:e.id,component:e.component,headerComponent:e.headerComponent,header:o,body:s,orientation:ee.VERTICAL,isExpanded:!!e.isExpanded,disableDnd:!!this.options.disableDnd,accessor:this,headerSize:(t=e.headerSize)!==null&&t!==void 0?t:Ma,minimumBodySize:La,maximumBodySize:Ra});this.doAddPanel(r);const l=typeof e.size=="number"?e.size:nt.Distribute,d=typeof e.index=="number"?e.index:void 0;return r.init({params:(i=e.params)!==null&&i!==void 0?i:{},minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize,isExpanded:e.isExpanded,title:e.title,containerApi:new kn(this),accessor:this}),this.paneview.addPane(r,l,d),r.orientation=this.paneview.orientation,r}removePanel(e){const i=this.panels.findIndex(s=>s===e);this.paneview.removePane(i),this.doRemovePanel(e)}movePanel(e,t){this.paneview.moveView(e,t)}getPanel(e){return this.panels.find(t=>t.id===e)}layout(e,t){const[i,s]=this.paneview.orientation===ee.HORIZONTAL?[e,t]:[t,e];this.paneview.layout(i,s)}toJSON(){const e=s=>s===Number.MAX_SAFE_INTEGER||s===Number.POSITIVE_INFINITY?void 0:s,t=s=>s<=0?void 0:s;return{views:this.paneview.getPanes().map((s,o)=>({size:this.paneview.getViewSize(o),data:s.toJSON(),minimumSize:t(s.minimumBodySize),maximumSize:e(s.maximumBodySize),headerSize:s.headerSize,expanded:s.isExpanded()})),size:this.paneview.size}}fromJSON(e){this.clear();const{views:t,size:i}=e,s=[],o=this.width,r=this.height;this.paneview=new Ca(this.element,{orientation:ee.VERTICAL,descriptor:{size:i,views:t.map(l=>{var d,c,h;const u=l.data,m=this.options.createComponent({id:u.id,name:u.component});let g;u.headerComponent&&this.options.createHeaderComponent&&(g=this.options.createHeaderComponent({id:u.id,name:u.headerComponent})),g||(g=new Oa);const p=new Va({id:u.id,component:u.component,headerComponent:u.headerComponent,header:g,body:m,orientation:ee.VERTICAL,isExpanded:!!l.expanded,disableDnd:!!this.options.disableDnd,accessor:this,headerSize:(d=l.headerSize)!==null&&d!==void 0?d:Ma,minimumBodySize:(c=l.minimumSize)!==null&&c!==void 0?c:La,maximumBodySize:(h=l.maximumSize)!==null&&h!==void 0?h:Ra});return this.doAddPanel(p),s.push(()=>{var f;p.init({params:(f=u.params)!==null&&f!==void 0?f:{},minimumBodySize:l.minimumSize,maximumBodySize:l.maximumSize,title:u.title,isExpanded:!!l.expanded,containerApi:new kn(this),accessor:this}),p.orientation=this.paneview.orientation}),setTimeout(()=>{this._onDidAddView.fire(p)},0),{size:l.size,view:p}})}}),this.layout(o,r),s.forEach(l=>l()),this._onDidLayoutfromJSON.fire()}clear(){for(const[e,t]of this._viewDisposables.entries())t.dispose();this._viewDisposables.clear(),this.paneview.dispose()}doAddPanel(e){const t=new X(e.onDidDrop(i=>{this._onDidDrop.fire(i)}),e.onUnhandledDragOver(i=>{this._onUnhandledDragOver.fire(i)}));this._viewDisposables.set(e.id,t)}doRemovePanel(e){const t=this._viewDisposables.get(e.id);t&&(t.dispose(),this._viewDisposables.delete(e.id))}dispose(){super.dispose();for(const[e,t]of this._viewDisposables.entries())t.dispose();this._viewDisposables.clear(),this.element.remove(),this.paneview.dispose()}}class Cv extends Mo{get priority(){return this._priority}set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){const e=typeof this._minimumSize=="function"?this._minimumSize():this._minimumSize;return e!==this._evaluatedMinimumSize&&(this._evaluatedMinimumSize=e,this.updateConstraints()),e}get maximumSize(){const e=typeof this._maximumSize=="function"?this._maximumSize():this._maximumSize;return e!==this._evaluatedMaximumSize&&(this._evaluatedMaximumSize=e,this.updateConstraints()),e}get snap(){return this._snap}constructor(e,t){super(e,t,new jl(e,t)),this._evaluatedMinimumSize=0,this._evaluatedMaximumSize=Number.POSITIVE_INFINITY,this._minimumSize=0,this._maximumSize=Number.POSITIVE_INFINITY,this._snap=!1,this._onDidChange=new z,this.onDidChange=this._onDidChange.event,this.api.initialize(this),this.addDisposables(this._onDidChange,this.api.onWillVisibilityChange(i=>{const{isVisible:s}=i,{accessor:o}=this._params;o.setVisible(this,s)}),this.api.onActiveChange(()=>{const{accessor:i}=this._params;i.setActive(this)}),this.api.onDidConstraintsChangeInternal(i=>{(typeof i.minimumSize=="number"||typeof i.minimumSize=="function")&&(this._minimumSize=i.minimumSize),(typeof i.maximumSize=="number"||typeof i.maximumSize=="function")&&(this._maximumSize=i.maximumSize),this.updateConstraints()}),this.api.onDidSizeChange(i=>{this._onDidChange.fire({size:i.size})}))}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}layout(e,t){const[i,s]=this.orientation===ee.HORIZONTAL?[e,t]:[t,e];super.layout(i,s)}init(e){super.init(e),this._priority=e.priority,e.minimumSize&&(this._minimumSize=e.minimumSize),e.maximumSize&&(this._maximumSize=e.maximumSize),e.snap&&(this._snap=e.snap)}toJSON(){const e=i=>i===Number.MAX_SAFE_INTEGER||i===Number.POSITIVE_INFINITY?void 0:i,t=i=>i<=0?void 0:i;return Object.assign(Object.assign({},super.toJSON()),{minimumSize:t(this.minimumSize),maximumSize:e(this.maximumSize)})}updateConstraints(){this.api._onDidConstraintsChange.fire({maximumSize:this._evaluatedMaximumSize,minimumSize:this._evaluatedMinimumSize})}}function Sv(n,e){return new wv(n,e).api}function Pv(n,e){const t=new xv(n,e);return new Cl(t)}function kv(n,e){const t=new bv(n,e);return new Sl(t)}function zv(n,e){const t=new Dv(n,e);return new kn(t)}class Tv{constructor(e){this._host=e}attachToGroup(e){return new X(e.model.onDidCreateTabGroup(t=>{this._host.fireDidCreateTabGroup(t)}),e.model.onDidDestroyTabGroup(t=>{this._host.fireDidDestroyTabGroup(t)}),e.model.onDidAddPanelToTabGroup(t=>{this._host.fireDidAddPanelToTabGroup(t)}),e.model.onDidRemovePanelFromTabGroup(t=>{this._host.fireDidRemovePanelFromTabGroup(t)}),e.model.onDidTabGroupChange(t=>{this._host.fireDidTabGroupChange(t)}),e.model.onDidTabGroupCollapsedChange(t=>{this._host.fireDidTabGroupCollapsedChange(t)}))}dispose(){}}const Ev=bt({name:"TabGroupChips",serviceKey:"tabGroupChipsService",create:n=>new Tv(n),init:(n,e)=>{const t=new Map;return new X(n.onDidAddGroup(i=>{t.set(i,e.attachToGroup(i))}),n.onDidRemoveGroup(i=>{var s;(s=t.get(i))===null||s===void 0||s.dispose(),t.delete(i)}),{dispose:()=>{for(const i of t.values())i.dispose();t.clear()}})}});function Fa(n){if(!(n instanceof HTMLElement))return;const e=_l(n);return e?.style.zIndex?`calc(${e.style.zIndex} * 2)`:void 0}let Gv=0;const Iv=()=>`dv-ctx-menu-item-${Gv++}`;function dn(n){return typeof n=="object"}function cn(n,e,t,i){const s=document.createElement("div");return s.className="dv-context-menu-item",s.setAttribute("role","menuitem"),i&&(s.classList.add("dv-context-menu-item--disabled"),s.setAttribute("aria-disabled","true")),s.textContent=n,i||s.addEventListener("click",()=>{t(),e()}),s}function Wa(){const n=document.createElement("div");return n.className="dv-context-menu-separator",n.setAttribute("role","separator"),n}function Av(){if(typeof window>"u"||!window.matchMedia)return!1;const n=window.matchMedia("(pointer: coarse)").matches,e=window.matchMedia("(pointer: fine)").matches;return n&&!e}function Nv(n){const e=document.createElement("div");e.className="dv-context-menu-rename";const t=document.createElement("input");return t.className="dv-context-menu-rename-input",t.type="text",t.placeholder="Name This Group",t.value=n.label,t.addEventListener("input",()=>{n.setLabel(t.value)}),t.addEventListener("keydown",i=>{i.key!=="Escape"&&i.key!=="Enter"&&i.stopPropagation()}),t.addEventListener("click",i=>{i.stopPropagation()}),e.appendChild(t),Av()||requestAnimationFrame(()=>{t.focus(),t.select()}),e}function jv(n,e){const t=document.createElement("div");if(t.className="dv-context-menu-color-picker",!e.enabled)return t;for(const i of e.entries()){const s=document.createElement("div");s.className="dv-context-menu-color-swatch",s.style.setProperty("--dv-tab-group-color",i.value),i.label&&(s.title=i.label),n.color===i.id&&s.classList.add("dv-context-menu-color-swatch--selected"),s.addEventListener("click",()=>{n.setColor(i.id)}),t.appendChild(s)}return t}class Ov{constructor(e){this.accessor=e}show(e,t,i){var s,o;if(!this.accessor.options.getTabContextMenuItems)return;const r=this.accessor.options.getTabContextMenuItems({panel:e,group:t,api:this.accessor.api,event:i});if(r.length===0)return;i.preventDefault();const l=this.accessor.getPopupServiceForGroup(t),d=()=>l.close(),c=document.createElement("div");c.className="dv-context-menu",c.setAttribute("role","menu");for(const h of r)if(h==="separator")c.appendChild(Wa());else if(h==="close")c.appendChild(cn("Close",d,()=>e.api.close()));else if(h==="closeOthers")c.appendChild(cn("Close Others",d,()=>{t.panels.filter(u=>u!==e).forEach(u=>u.api.close())}));else if(h==="closeAll")c.appendChild(cn("Close All",d,()=>{[...t.panels].forEach(u=>u.api.close())}));else if(dn(h)&&h.element)c.appendChild(h.element);else if(dn(h)&&h.component){const u=(o=(s=this.accessor.options).createContextMenuItemComponent)===null||o===void 0?void 0:o.call(s,{id:Iv(),component:h.component});u&&(u.init({panel:e,group:t,api:this.accessor.api,close:d,componentProps:h.componentProps}),c.appendChild(u.element))}else dn(h)&&h.label&&c.appendChild(cn(h.label,d,()=>{var u;return(u=h.action)===null||u===void 0?void 0:u.call(h)},h.disabled));l.openPopover(c,{x:i.clientX,y:i.clientY,zIndex:Fa(i.target)})}showForChip(e,t,i){if(!this.accessor.options.getTabGroupChipContextMenuItems)return;const s=this.accessor.options.getTabGroupChipContextMenuItems({tabGroup:e,group:t,api:this.accessor.api,event:i});if(s.length===0)return;i.preventDefault();const o=this.accessor.getPopupServiceForGroup(t),r=()=>o.close(),l=document.createElement("div");l.className="dv-context-menu",l.setAttribute("role","menu");for(const d of s)d==="separator"?l.appendChild(Wa()):d==="rename"?l.appendChild(Nv(e)):d==="colorPicker"?l.appendChild(jv(e,this.accessor.tabGroupColorPalette)):dn(d)&&d.element?l.appendChild(d.element):dn(d)&&d.label&&l.appendChild(cn(d.label,r,()=>{var c;return(c=d.action)===null||c===void 0?void 0:c.call(d)},d.disabled));o.openPopover(l,{x:i.clientX,y:i.clientY,zIndex:Fa(i.target)})}}const Mv=bt({name:"ContextMenu",serviceKey:"contextMenuService",create:n=>new Ov(n)}),Lv=30,Rv=-10;class Vv{constructor(e){this.host=e}dispatchWillDragPanel(e){this.host.fireWillDragPanel(e)}dispatchWillDragGroup(e){this.host.fireWillDragGroup(e)}dispatchWillDrop(e){this.host.fireWillDrop(e)}dispatchWillShowOverlay(e){this.host.fireWillShowOverlay(e)}buildGroupDragGhost(e){const t=this.host.options.createGroupDragGhostComponent;if(!t)return;const i=t(e);return i.init({group:e,api:this.host.api}),{element:i.element,offsetX:Lv,offsetY:Rv,dispose:i.dispose?()=>{var s;return(s=i.dispose)===null||s===void 0?void 0:s.call(i)}:void 0}}resolveOverlayModel(e,t){var i,s;return(s=(i=this.host.options).dropOverlayModel)===null||s===void 0?void 0:s.call(i,{location:e,group:t})}showPreviewOverlay(e,t){const i=e.model.contentDropTarget;return i.showOverlay(t),ke.from(()=>i.clearOverlay())}dispose(){}}const Kl=bt({name:"AdvancedDnD",serviceKey:"advancedDnDService",create:n=>new Vv(n)}),go="data-dv-kbd-moving";function Vt(n,e){const t=e.toLowerCase().split("+"),i=t[t.length-1],s=t.slice(0,-1);return n.ctrlKey===s.includes("ctrl")&&n.shiftKey===s.includes("shift")&&n.altKey===s.includes("alt")&&n.metaKey===(s.includes("meta")||s.includes("cmd"))&&n.key.toLowerCase()===i}function fo(n){const e=n.keyboardNavigation;if(e)return e===!0?{}:e}const Fv={nextTab:"ctrl+]",prevTab:"ctrl+[",focusNextGroup:"f6",focusPrevGroup:"shift+f6",focusTabs:"ctrl+shift+\\"};class Wv extends X{constructor(e){super(),this.host=e,this._focusWasInside=!1;const t=e.rootElement.ownerDocument,i=r=>this._onKeyDown(r);t.addEventListener("keydown",i,!0);const s=r=>{const l=r.target;l instanceof HTMLElement&&this.host.rootElement.contains(l)&&!l.closest('[role="dialog"]')&&(this._lastNonFloatFocus=l)};t.addEventListener("focusin",s,!0);const o=r=>this._onFloatingEscape(r);t.addEventListener("keydown",o,!1),this.addDisposables({dispose:()=>t.removeEventListener("keydown",i,!0)},{dispose:()=>t.removeEventListener("focusin",s,!0)},{dispose:()=>t.removeEventListener("keydown",o,!1)},e.onWillMutateLayout(r=>{r.kind==="remove"&&this._nav&&(this._focusWasInside=this._isFocusInside())}),e.onDidMutateLayout(r=>{r.kind==="remove"&&this._nav&&this._focusWasInside&&!this._isFocusInside()&&this._restoreFocus()}))}get _moveActive(){return this.host.rootElement.hasAttribute(go)}_isFocusInside(){const e=this.host.rootElement.ownerDocument.activeElement;return e instanceof Node&&this.host.rootElement.contains(e)}_onFloatingEscape(e){if(!this._nav||this._moveActive||e.defaultPrevented||e.key!=="Escape")return;const t=e.target;if(!(t instanceof Element))return;const i=t.closest('[role="dialog"]');!i||!this.host.rootElement.contains(i)||(e.preventDefault(),e.stopPropagation(),this._returnFocusFromFloat())}_trapFloatTab(e){const t=e.target;if(!(t instanceof Element))return!1;const i=t.closest('[role="dialog"]');if(!i||!this.host.rootElement.contains(i))return!1;e.preventDefault();const s=this._tabbables(i);if(s.length===0)return!0;const o=i.ownerDocument.activeElement,r=o instanceof HTMLElement?s.indexOf(o):-1,l=s.length,d=r===-1?e.shiftKey?l-1:0:(r+(e.shiftKey?-1:1)+l)%l;return s[d].focus(),!0}_tabbables(e){const t=e.querySelectorAll("a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]");return Array.from(t).filter(i=>i.tabIndex>=0)}_returnFocusFromFloat(){var e;const t=this._lastNonFloatFocus;if(t&&t.isConnected&&this.host.rootElement.contains(t)&&!t.closest('[role="dialog"]')){t.focus();return}(e=this.host.groups.find(i=>i.api.location.type==="grid"))===null||e===void 0||e.model.focusContent()}get _nav(){return fo(this.host.options)}get _keymap(){var e;return Object.assign(Object.assign({},Fv),(e=this._nav)===null||e===void 0?void 0:e.keymap)}_onKeyDown(e){if(!this._nav||this._moveActive||!(e.target instanceof Node)||!this.host.rootElement.contains(e.target)||e.key==="Tab"&&this._trapFloatTab(e))return;const t=this._keymap;Vt(e,t.nextTab)?(this._consume(e),this._switchTab(!1)):Vt(e,t.prevTab)?(this._consume(e),this._switchTab(!0)):Vt(e,t.focusNextGroup)?(this._consume(e),this._cycleGroup(!1)):Vt(e,t.focusPrevGroup)?(this._consume(e),this._cycleGroup(!0)):Vt(e,t.focusTabs)&&(this._consume(e),this._focusTabs())}_focusTabs(){var e;(e=this.host.activeGroup)===null||e===void 0||e.model.focusActiveTab()}_switchTab(e){const t=this.host.activeGroup;t&&(e?t.model.moveToPrevious():t.model.moveToNext(),t.model.focusContent())}_cycleGroup(e){const t=this.host.activeGroup,i=t?this.host.adjacentGroup(t,e):this.host.groups[0];this._focusGroup(i)}_focusGroup(e){e&&(e.api.setActive(),e.model.focusContent())}_restoreFocus(){var e;(e=this.host.activeGroup)===null||e===void 0||e.model.focusContent()}_consume(e){e.preventDefault(),e.stopPropagation()}}const $v=bt({name:"Accessibility",serviceKey:"accessibilityService",create:n=>new Wv(n)}),Hv={ArrowLeft:"left",ArrowRight:"right",ArrowUp:"top",ArrowDown:"bottom"},hn={focusGroupLeft:"ctrl+shift+arrowleft",focusGroupRight:"ctrl+shift+arrowright",focusGroupUp:"ctrl+shift+arrowup",focusGroupDown:"ctrl+shift+arrowdown",dock:"ctrl+m"};class Bv extends X{constructor(e){super(),this.host=e,this._move=null;const t=e.rootElement.ownerDocument,i=s=>this._onKeyDown(s);t.addEventListener("keydown",i,!0),this.addDisposables({dispose:()=>this._exit()},{dispose:()=>t.removeEventListener("keydown",i,!0)})}get _enabled(){return!!fo(this.host.options)}get _keymap(){var e,t,i,s,o,r,l;const d=(t=(e=fo(this.host.options))===null||e===void 0?void 0:e.keymap)!==null&&t!==void 0?t:{};return{focusGroupLeft:(i=d.focusGroupLeft)!==null&&i!==void 0?i:hn.focusGroupLeft,focusGroupRight:(s=d.focusGroupRight)!==null&&s!==void 0?s:hn.focusGroupRight,focusGroupUp:(o=d.focusGroupUp)!==null&&o!==void 0?o:hn.focusGroupUp,focusGroupDown:(r=d.focusGroupDown)!==null&&r!==void 0?r:hn.focusGroupDown,dock:(l=d.dock)!==null&&l!==void 0?l:hn.dock}}get _messages(){return Yl(this.host.options.messages)}_onKeyDown(e){if(!this._enabled)return;if(this._move){this._onMoveKey(e);return}if(!(e.target instanceof Node)||!this.host.rootElement.contains(e.target))return;const t=this._keymap;Vt(e,t.dock)?this._enterMoveMode(e):Vt(e,t.focusGroupLeft)?(this._consume(e),this._focusGroupInDirection("left")):Vt(e,t.focusGroupRight)?(this._consume(e),this._focusGroupInDirection("right")):Vt(e,t.focusGroupUp)?(this._consume(e),this._focusGroupInDirection("up")):Vt(e,t.focusGroupDown)&&(this._consume(e),this._focusGroupInDirection("down"))}_focusGroupInDirection(e){const t=this.host.activeGroup;t&&this._focusGroup(this.host.adjacentGroupInDirection(t,e))}_focusGroup(e){e&&(e.api.setActive(),e.model.focusContent())}_restoreFocus(){var e;(e=this.host.activeGroup)===null||e===void 0||e.model.focusContent()}_enterMoveMode(e){const t=this.host.activePanel,i=this.host.groups;if(!t||i.length===0)return;e.preventDefault(),e.stopPropagation();const s=Math.max(0,i.indexOf(t.group));this._move={source:t,groups:i,groupIndex:s,phase:"target",position:"center"},this.host.rootElement.setAttribute(go,""),this._render()}_onMoveKey(e){const t=this._move;if(e.key==="Escape"){this._consume(e),t.phase==="edge"?(t.phase="target",t.position="center",this._render()):(this._exit(),this.host.announce(this._messages.moveCancelled()),this._restoreFocus());return}if(e.key==="Enter"){this._consume(e),t.phase==="target"?(t.phase="edge",t.position="center",this._render()):this._commit();return}if(t.phase==="target"){const s=t.groups.length;e.key==="ArrowRight"||e.key==="ArrowDown"?(this._consume(e),t.groupIndex=(t.groupIndex+1)%s,this._render()):(e.key==="ArrowLeft"||e.key==="ArrowUp")&&(this._consume(e),t.groupIndex=(t.groupIndex-1+s)%s,this._render());return}const i=Hv[e.key];i?(this._consume(e),t.position=i,this._render()):(e.key===" "||e.key==="c"||e.key==="C")&&(this._consume(e),t.position="center",this._render())}_render(){var e,t;const i=this._move,s=i.groups[i.groupIndex];this._clearPreview(),this._preview=this.host.showDropPreview(s,i.position);const o=(t=(e=s.activePanel)===null||e===void 0?void 0:e.title)!==null&&t!==void 0?t:s.id,r=this._messages;i.phase==="target"?this.host.announce(r.movePickTarget(this._label(i.source),o,i.groupIndex+1,i.groups.length)):this.host.announce(r.movePickEdge(i.position,o))}_commit(){var e,t;const i=this._move,s=i.groups[i.groupIndex],o=i.position,r=i.source,l=(t=(e=s.activePanel)===null||e===void 0?void 0:e.title)!==null&&t!==void 0?t:s.id,d=this._messages;this._exit();try{this.host.dockPanel(r,s,o),this.host.announce(d.moveCommitted(this._label(r),l,o))}catch{this.host.announce(d.moveNotAllowed())}this._restoreFocus()}_exit(){this._clearPreview(),this._move=null,this.host.rootElement.removeAttribute(go)}_clearPreview(){var e;(e=this._preview)===null||e===void 0||e.dispose(),this._preview=void 0}_consume(e){e.preventDefault(),e.stopPropagation()}_label(e){var t;return(t=e.title)!==null&&t!==void 0?t:e.id}}bt({name:"KeyboardDocking",serviceKey:"keyboardDockingService",create:n=>new Bv(n),dependsOn:[Kl,Xl]});const Uv=[Ev,Mv,Kl,$v];Om(Uv);Lm();const ql=(n,e)=>{const[,t]=ne.useState(0),i=ne.useRef(n.componentProps);return ne.useImperativeHandle(e,()=>({update:s=>{i.current=Object.assign(Object.assign({},i.current),s),t(o=>o+1)}}),[]),ne.createElement(n.component,i.current)};ql.displayName="DockviewReactJsBridge";const Yv=(()=>{let n=1;return{next:()=>`dockview_react_portal_key_${(n++).toString()}`}})(),Xv=ne.createContext({});class $t{constructor(e,t,i,s,o){this.parent=e,this.portalStore=t,this.component=i,this.parameters=s,this.context=o,this._initialProps={},this.disposed=!1,this.createPortal()}update(e){if(this.disposed)throw new Error("invalid operation: resource is already disposed");this.componentInstance?this.componentInstance.update(e):this._initialProps=Object.assign(Object.assign({},this._initialProps),e)}createPortal(){if(this.disposed)throw new Error("invalid operation: resource is already disposed");if(!Kv(this.component))throw new Error("Dockview: Only React.memo(...), React.ForwardRef(...) and functional components are accepted as components");const e=ne.createElement(ne.forwardRef(ql),{component:this.component,componentProps:this.parameters,ref:s=>{this.componentInstance=s,Object.keys(this._initialProps).length>0&&(this.componentInstance.update(this._initialProps),this._initialProps={})}}),t=this.context?ne.createElement(Xv.Provider,{value:this.context},e):e,i=Vd.createPortal(t,this.parent,Yv.next());this.ref={portal:i,disposable:this.portalStore.addPortal(i)}}dispose(){var e;(e=this.ref)===null||e===void 0||e.disposable.dispose(),this.disposed=!0}}const Cs=()=>{const[n,e]=ne.useState([]);ne.useDebugValue(`Portal count: ${n.length}`);const t=ne.useCallback(i=>{e(o=>[...o,i]);let s=!1;return ke.from(()=>{if(s)throw new Error("invalid operation: resource already disposed");s=!0,e(o=>o.filter(r=>r!==i))})},[]);return[n,t]};function Kv(n){return typeof n=="function"||!!n?.$$typeof}class $a{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._onDidFocus=new z,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new z,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}focus(){}init(e){this.part=new $t(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi})}update(e){var t;(t=this.part)===null||t===void 0||t.update({params:e.params})}layout(e,t){}dispose(){var e;this._onDidFocus.dispose(),this._onDidBlur.dispose(),(e=this.part)===null||e===void 0||e.dispose()}}class Ha{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}focus(){}init(e){this.part=new $t(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi,tabLocation:e.tabLocation})}update(e){var t;(t=this.part)===null||t===void 0||t.update({params:e.params})}layout(e,t){}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}}class Ba{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new $t(this.element,this.reactPortalStore,this.component,{group:e.group,containerApi:e.containerApi})}focus(){}update(e){var t,i,s;this.parameters&&(this.parameters.params=e.params),(t=this.part)===null||t===void 0||t.update({params:(s=(i=this.parameters)===null||i===void 0?void 0:i.params)!==null&&s!==void 0?s:{}})}layout(e,t){}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}}class qv{get element(){return this._element}get part(){return this._part}constructor(e,t,i){this.component=e,this.reactPortalStore=t,this._group=i,this.mutableDisposable=new $e,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(e){this.mutableDisposable.value=new X(this._group.model.onDidAddPanel(()=>{this.updatePanels()}),this._group.model.onDidRemovePanel(()=>{this.updatePanels()}),this._group.model.onDidActivePanelChange(()=>{this.updateActivePanel()}),e.api.onDidActiveChange(()=>{this.updateGroupActive()}),e.api.onDidLocationChange(t=>{this.updateLocation(t.location)})),this._part=new $t(this.element,this.reactPortalStore,this.component,{api:e.api,containerApi:e.containerApi,panels:this._group.model.panels,activePanel:this._group.model.activePanel,isGroupActive:this._group.api.isActive,group:this._group,headerPosition:this._group.model.headerPosition,location:e.api.location})}dispose(){var e;this.mutableDisposable.dispose(),(e=this._part)===null||e===void 0||e.dispose()}update(e){var t;(t=this._part)===null||t===void 0||t.update(e.params)}updatePanels(){this.update({params:{panels:this._group.model.panels}})}updateActivePanel(){this.update({params:{activePanel:this._group.model.activePanel}})}updateGroupActive(){this.update({params:{isGroupActive:this._group.api.isActive}})}updateLocation(e){this.update({params:{location:e}})}}class Jv{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new $t(this._element,this.reactPortalStore,this.component,e)}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}}class Ua{get element(){return this._element}constructor(e,t){this.component=e,this.reactPortalStore=t,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.display="inline-flex"}init(e){this.part=new $t(this._element,this.reactPortalStore,this.component,{tabGroup:e.tabGroup,api:e.api})}update(e){var t;(t=this.part)===null||t===void 0||t.update({tabGroup:e.tabGroup})}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}}class Ya{get element(){return this._element}constructor(e,t){this.component=e,this.reactPortalStore=t,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.display="inline-flex"}init(e){this.part=new $t(this._element,this.reactPortalStore,this.component,{group:e.group,api:e.api})}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}}function Gi(n,e){return n?t=>new qv(n,e,t):void 0}const Xn="props.defaultTabComponent";function Zv(n){return mo.reduce((t,i)=>(i in n&&(t[i]=n[i]),t),{})}const Jl=ne.forwardRef((n,e)=>{const t=ne.useRef(null),i=ne.useRef(void 0),[s,o]=Cs();ne.useImperativeHandle(e,()=>t.current,[]);const r=ne.useRef({});return ne.useEffect(()=>{const l={};mo.forEach(d=>{const c=d,h=n[c];c in n&&h!==r.current[c]&&(l[c]=h)}),i.current&&i.current.updateOptions(l),r.current=n},mo.map(l=>n[l])),ne.useEffect(()=>{var l;if(!t.current)return;const d=(l=n.tabComponents)!==null&&l!==void 0?l:{};n.defaultTabComponent&&(d[Xn]=n.defaultTabComponent);const c={createLeftHeaderActionComponent:Gi(n.leftHeaderActionsComponent,{addPortal:o}),createRightHeaderActionComponent:Gi(n.rightHeaderActionsComponent,{addPortal:o}),createPrefixHeaderActionComponent:Gi(n.prefixHeaderActionsComponent,{addPortal:o}),createComponent:p=>new $a(p.id,n.components[p.name],{addPortal:o}),createTabComponent(p){return new Ha(p.id,d[p.name],{addPortal:o})},createWatermarkComponent:n.watermarkComponent?()=>new Ba("watermark",n.watermarkComponent,{addPortal:o}):void 0,defaultTabComponent:n.defaultTabComponent?Xn:void 0,createContextMenuItemComponent:p=>{if(p.component)return new Jv(p.id,p.component,{addPortal:o})}},h=Zv(n);if(n.tabGroupChipComponent){const p=n.tabGroupChipComponent;h.createTabGroupChipComponent=()=>new Ua(p,{addPortal:o})}if(n.groupDragGhostComponent){const p=n.groupDragGhostComponent;h.createGroupDragGhostComponent=()=>new Ya(p,{addPortal:o})}const u=Sv(t.current,Object.assign(Object.assign({},h),c)),{clientWidth:m,clientHeight:g}=t.current;return u.layout(m,g),n.onReady&&n.onReady({api:u}),i.current=u,()=>{i.current=void 0,u.dispose()}},[]),ne.useEffect(()=>{if(!i.current)return()=>{};const l=i.current.onDidDrop(d=>{n.onDidDrop&&n.onDidDrop(d)});return()=>{l.dispose()}},[n.onDidDrop]),ne.useEffect(()=>{if(!i.current)return()=>{};const l=i.current.onWillDrop(d=>{n.onWillDrop&&n.onWillDrop(d)});return()=>{l.dispose()}},[n.onWillDrop]),ne.useEffect(()=>{i.current&&i.current.updateOptions({createTabGroupChipComponent:n.tabGroupChipComponent?()=>new Ua(n.tabGroupChipComponent,{addPortal:o}):void 0})},[n.tabGroupChipComponent]),ne.useEffect(()=>{i.current&&i.current.updateOptions({createGroupDragGhostComponent:n.groupDragGhostComponent?()=>new Ya(n.groupDragGhostComponent,{addPortal:o}):void 0})},[n.groupDragGhostComponent]),ne.useEffect(()=>{i.current&&i.current.updateOptions({createComponent:l=>new $a(l.id,n.components[l.name],{addPortal:o})})},[n.components]),ne.useEffect(()=>{var l;if(!i.current)return;const d=(l=n.tabComponents)!==null&&l!==void 0?l:{};n.defaultTabComponent&&(d[Xn]=n.defaultTabComponent),i.current.updateOptions({defaultTabComponent:n.defaultTabComponent?Xn:void 0,createTabComponent(c){return new Ha(c.id,d[c.name],{addPortal:o})}})},[n.tabComponents,n.defaultTabComponent]),ne.useEffect(()=>{i.current&&i.current.updateOptions({createWatermarkComponent:n.watermarkComponent?()=>new Ba("watermark",n.watermarkComponent,{addPortal:o}):void 0})},[n.watermarkComponent]),ne.useEffect(()=>{i.current&&i.current.updateOptions({createRightHeaderActionComponent:Gi(n.rightHeaderActionsComponent,{addPortal:o})})},[n.rightHeaderActionsComponent]),ne.useEffect(()=>{i.current&&i.current.updateOptions({createLeftHeaderActionComponent:Gi(n.leftHeaderActionsComponent,{addPortal:o})})},[n.leftHeaderActionsComponent]),ne.useEffect(()=>{i.current&&i.current.updateOptions({createPrefixHeaderActionComponent:Gi(n.prefixHeaderActionsComponent,{addPortal:o})})},[n.prefixHeaderActionsComponent]),ne.createElement("div",{style:{height:"100%",width:"100%"},ref:t},s)});Jl.displayName="DockviewComponent";class Xa extends Cv{constructor(e,t,i,s){super(e,t),this.reactComponent=i,this.reactPortalStore=s}getComponent(){var e,t;return new $t(this.element,this.reactPortalStore,this.reactComponent,{params:(t=(e=this._params)===null||e===void 0?void 0:e.params)!==null&&t!==void 0?t:{},api:this.api,containerApi:new Cl(this._params.accessor)})}}function Qv(n){return ao.reduce((t,i)=>(i in n&&(t[i]=n[i]),t),{})}const eg=ne.forwardRef((n,e)=>{const t=ne.useRef(null),i=ne.useRef(void 0),[s,o]=Cs();ne.useImperativeHandle(e,()=>t.current,[]);const r=ne.useRef({});return ne.useEffect(()=>{const l={};ao.forEach(d=>{const c=d,h=n[c];c in n&&h!==r.current[c]&&(l[c]=h)}),i.current&&i.current.updateOptions(l),r.current=n},ao.map(l=>n[l])),ne.useEffect(()=>{if(!t.current)return()=>{};const l={createComponent:u=>new Xa(u.id,u.name,n.components[u.name],{addPortal:o})},d=Pv(t.current,Object.assign(Object.assign({},Qv(n)),l)),{clientWidth:c,clientHeight:h}=t.current;return d.layout(c,h),n.onReady&&n.onReady({api:d}),i.current=d,()=>{i.current=void 0,d.dispose()}},[]),ne.useEffect(()=>{i.current&&i.current.updateOptions({createComponent:l=>new Xa(l.id,l.name,n.components[l.name],{addPortal:o})})},[n.components]),ne.createElement("div",{style:{height:"100%",width:"100%"},ref:t},s)});eg.displayName="SplitviewComponent";class Ka extends Hl{constructor(e,t,i,s){super(e,t),this.reactComponent=i,this.reactPortalStore=s}getComponent(){var e,t;return new $t(this.element,this.reactPortalStore,this.reactComponent,{params:(t=(e=this._params)===null||e===void 0?void 0:e.params)!==null&&t!==void 0?t:{},api:this.api,containerApi:new Sl(this._params.accessor)})}}function tg(n){return ho.reduce((t,i)=>(i in n&&(t[i]=n[i]),t),{})}const ig=ne.forwardRef((n,e)=>{const t=ne.useRef(null),i=ne.useRef(void 0),[s,o]=Cs();ne.useImperativeHandle(e,()=>t.current,[]);const r=ne.useRef({});return ne.useEffect(()=>{const l={};ho.forEach(d=>{const c=d,h=n[c];c in n&&h!==r.current[c]&&(l[c]=h)}),i.current&&i.current.updateOptions(l),r.current=n},ho.map(l=>n[l])),ne.useEffect(()=>{if(!t.current)return()=>{};const l={createComponent:u=>new Ka(u.id,u.name,n.components[u.name],{addPortal:o})},d=kv(t.current,Object.assign(Object.assign({},tg(n)),l)),{clientWidth:c,clientHeight:h}=t.current;return d.layout(c,h),n.onReady&&n.onReady({api:d}),i.current=d,()=>{i.current=void 0,d.dispose()}},[]),ne.useEffect(()=>{i.current&&i.current.updateOptions({createComponent:l=>new Ka(l.id,l.name,n.components[l.name],{addPortal:o})})},[n.components]),ne.createElement("div",{style:{height:"100%",width:"100%"},ref:t},s)});ig.displayName="GridviewComponent";class Kn{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._element=document.createElement("div"),this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new $t(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,title:e.title,containerApi:e.containerApi})}toJSON(){return{id:this.id}}update(e){var t;(t=this.part)===null||t===void 0||t.update(e.params)}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}}function ng(n){return po.reduce((t,i)=>(i in n&&(t[i]=n[i]),t),{})}const sg=ne.forwardRef((n,e)=>{const t=ne.useRef(null),i=ne.useRef(void 0),[s,o]=Cs();ne.useImperativeHandle(e,()=>t.current,[]);const r=ne.useRef({});return ne.useEffect(()=>{const l={};po.forEach(d=>{const c=d,h=n[c];c in n&&h!==r.current[c]&&(l[c]=h)}),i.current&&i.current.updateOptions(l),r.current=n},po.map(l=>n[l])),ne.useEffect(()=>{var l;if(!t.current)return()=>{};const d=(l=n.headerComponents)!==null&&l!==void 0?l:{},c={createComponent:g=>new Kn(g.id,n.components[g.name],{addPortal:o}),createHeaderComponent:g=>new Kn(g.id,d[g.name],{addPortal:o})},h=zv(t.current,Object.assign(Object.assign({},ng(n)),c)),{clientWidth:u,clientHeight:m}=t.current;return h.layout(u,m),n.onReady&&n.onReady({api:h}),i.current=h,()=>{i.current=void 0,h.dispose()}},[]),ne.useEffect(()=>{i.current&&i.current.updateOptions({createComponent:l=>new Kn(l.id,n.components[l.name],{addPortal:o})})},[n.components]),ne.useEffect(()=>{var l;if(!i.current)return;const d=(l=n.headerComponents)!==null&&l!==void 0?l:{};i.current.updateOptions({createHeaderComponent:c=>new Kn(c.id,d[c.name],{addPortal:o})})},[n.headerComponents]),ne.useEffect(()=>{if(!i.current)return()=>{};const l=i.current.onDidDrop(d=>{n.onDidDrop&&n.onDidDrop(d)});return()=>{l.dispose()}},[n.onDidDrop]),ne.createElement("div",{style:{height:"100%",width:"100%"},ref:t},s)});sg.displayName="PaneviewComponent";function og(n){return n.key!=="Tab"||n.altKey||!n.ctrlKey&&!n.metaKey?0:n.shiftKey?-1:1}function ag(n,e){const t=n?.group,i=t?.panels??[];if(!t||i.length<2)return!1;const s=t.activePanel??n,o=i.findIndex(l=>l.id===s?.id);if(o<0)return!1;const r=i[(o+e+i.length)%i.length];return!r||r.id===s?.id?!1:(r.api.setActive(),!0)}function wn(n,e,t){const i=tc(t);return i?n("lcl.withHotkey",{label:e,key:i}):e}function Zl(n,e){const t=n??{},{__loc:i,__type:s,...o}=t,r=typeof s=="string"&&s||e||"";return r&&r!=="__extend"?{type:r,params:o}:null}function rg(n){const e=n.params??{},{__loc:t,__type:i,...s}=e;return{id:n.api.id,type:typeof i=="string"&&i||n.api.component||"",loc:t==="left"||t==="right"||t==="bottom"?t:"main",params:s,setTitle:o=>{ic(n.api.id),n.api.setTitle(o)},setParams:o=>ze.getState().leafById(n.api.id)?.setParams(o),close:()=>{ze.getState().isPinnedLeaf(n.api.id)||n.api.close()}}}let qa;function Ql(n){return function(t){const i=rg(t),s=(t.params??{}).__loc??"main",[o,r]=_.useState(()=>{if(s!=="main")return!1;const h=qa!==n.type;return qa=n.type,h}),l=`${i.id}:${i.type}:${Ud(i.params)}`,d=_.useRef(null);_.useEffect(()=>{const h=d.current;if(!h)return;const u=Yd(h),m=t.api.onDidVisibilityChange(g=>{g.isVisible&&u.restore()});return()=>{m.dispose(),u.dispose()}},[t.api]);const c=h=>a.jsx("div",{ref:d,className:`wb-view wb-view--${s}${o?" wb-view-enter":""}`,onAnimationEnd:u=>{u.animationName==="wb-view-enter"&&u.target===u.currentTarget&&r(!1)},children:a.jsx(nc,{children:a.jsx(_.Suspense,{fallback:a.jsx(So,{variant:oc(n.type,s)}),children:s==="main"?a.jsx(ta,{present:sc,owner:t.api,ownerKey:l,children:u=>n.factory({leaf:i,params:i.params,extendView:u})}):n.factory({leaf:i,params:i.params,extendView:h})})})});return s==="main"?c():a.jsx(ta,{present:Xd,ownerKey:l,children:c})}}function lg(n){return function(t){const i=(t.params??{}).__type||"",s=yi(i);if(!s)return null;let o=n.get(i);return o||(o=Ql(s),n.set(i,o)),a.jsx(o,{...t},i)}}const dg=({api:n,params:e})=>{const[,t]=_.useState(0);_.useEffect(()=>{const p=n.onDidTitleChange(()=>t(f=>f+1));return t(f=>f+1),()=>p.dispose()},[n]);const i=e?.__type||n.component||"",s=yi(i),o=i==="__extend"?ia:s?.icon,r=s?.TabIcon,l=ze(p=>!p.isPinnedLeaf(n.id))&&s?.closable!==!1,d=e?.__loc,c=d==="left"||d==="right",[h,u]=_.useState(null),{t:m}=ws(),g=_.useRef(null);return _.useEffect(()=>{if(!h)return;const p=()=>u(null);return window.addEventListener("click",p),window.addEventListener("contextmenu",p),()=>{window.removeEventListener("click",p),window.removeEventListener("contextmenu",p)}},[h]),_.useEffect(()=>{const p=g.current;if(!p||i==="__extend")return;const f=w=>gg(w,p,n.id);return p.addEventListener("dragstart",f),()=>p.removeEventListener("dragstart",f)},[n.id]),a.jsxs("div",{ref:g,className:`wb-tab${c?" wb-tab--icon":""}${d==="left"?" wb-tab--left":""}${i==="sidebar-empty"||i==="home"?" wb-tab--empty":""}`,title:n.title,"data-view-type":i,"data-transient":i==="__extend"?"true":void 0,draggable:i!=="__extend",onContextMenu:l?p=>{p.preventDefault(),p.stopPropagation(),u({x:p.clientX,y:p.clientY})}:void 0,children:[r?a.jsx(r,{params:e??{},size:c?15:13}):o&&a.jsx(o,{size:c?15:13,className:"wb-tab-ic"}),!c&&a.jsx("span",{className:"wb-tab-name",children:n.title}),!c&&l&&a.jsx("button",{className:"wb-tab-close",title:m("lcl.tab.close"),draggable:!1,onPointerDown:p=>p.stopPropagation(),onMouseDown:p=>{p.stopPropagation(),p.preventDefault()},onClick:p=>{p.stopPropagation(),p.preventDefault(),ze.getState().closeLeaf(n.id)},children:a.jsx(Cn,{size:12})}),h&&ec.createPortal(a.jsxs(Jt,{className:"ctx-menu",x:h.x,y:h.y,onClick:p=>p.stopPropagation(),onContextMenu:p=>p.preventDefault(),children:[i!=="__extend"&&ls()&&a.jsxs("button",{onClick:()=>{const p=Zl(e,n.component),f=ls();p&&f&&(f.detach([p]),ze.getState().closeLeaf(n.id)),u(null)},children:[a.jsx(ia,{size:13})," ",m("lcl.tab.moveToWindow")]}),a.jsxs("button",{onClick:()=>{ze.getState().closeLeaf(n.id),u(null)},children:[a.jsx(Cn,{size:13})," ",m("lcl.tab.close")]})]}),document.body)]})};function cg(n,e){return{name:n?"lcl-dark":"lcl-light",className:`dockview-theme-${n?"dark":"light"} dockview-theme-lcl`,colorScheme:n?"dark":"light",gap:e?8:0,tabAnimation:"smooth",dndOverlayMounting:"relative"}}function ed(n){return n.some(e=>{const t=e.params?.__loc;return!t||t==="main"})}function hg(){return function({panels:e,activePanel:t}){const i=!ze(h=>h.leftVisible),{t:s}=ws();Ar(h=>h.overrides),ze(h=>h.mainTabs);const o=gn(h=>h.stacks),r=t?.id??null,l=r?o[r]:void 0,d=!!l&&l.idx>0,c=!!l&&l.idx>=0&&l.idx<l.entries.length-1;return ed(e)?a.jsxs("div",{className:`dv-prefix${i?" dv-prefix--edge":""}`,children:[a.jsx("button",{className:"dv-nav-btn",disabled:!d,title:wn(s,s("lcl.nav.back"),"nav-back"),onClick:()=>{r&&gn.getState().back(r)},children:a.jsx(Kd,{size:15})}),a.jsx("button",{className:"dv-nav-btn",disabled:!c,title:wn(s,s("lcl.nav.forward"),"nav-forward"),onClick:()=>{r&&gn.getState().forward(r)},children:a.jsx(Mc,{size:15})}),a.jsx("button",{className:`dv-edge-toggle${i?"":" is-on"}`,"aria-pressed":!i,title:wn(s,s("lcl.edge.left"),"toggle-left"),onClick:()=>ze.getState().toggleSidebar("left"),children:a.jsx(qd,{size:15})})]}):null}}function ug(){return function({panels:e}){const{t}=ws();return ed(e)?a.jsx("button",{className:"dv-new-tab",title:t("lcl.tab.new"),onClick:()=>{const i=Jd();i?.newPage?i.newPage():ze.getState().openView("launcher",{},"main",{newTab:!0})},children:a.jsx(ui,{size:15})}):null}}let hi=null,Ui=null,Et=null;const td="application/x-forsion-open",qn=n=>!!Et&&"open"in Et&&!!n.dataTransfer?.types.includes(td),id=new WeakSet;function pg(n){return!n.closest(".dv-react-part")&&!!n.closest(".wb-dockview, .dv-render-overlay")}function Ja(n){const e=n.preventDefault;n.preventDefault=function(){const t=n.currentTarget;t instanceof Element&&!pg(t)&&id.add(n),e.call(n)}}let Za=0,bn=null,xn=null;function Qa(n){const e=document.createElement("div");return e.className=n,document.body.appendChild(e),e}function _o(){bn&&(bn.style.display="none"),xn&&(xn.style.display="none")}function er(n){if(n.mode==="tab"){xn&&(xn.style.display="none");const e=bn??=Qa("wb-drop-line");e.style.display="block";const t=Ks(e);e.style.left=`${Math.round(n.lineX)/t-1}px`,e.style.top=`${Math.round(n.top)/t}px`,e.style.height=`${Math.round(n.height)/t}px`}else{bn&&(bn.style.display="none");const e=xn??=Qa("wb-drop-zone");e.style.display="block";const t=Ks(e);e.style.left=`${Math.round(n.rect.left)/t}px`,e.style.top=`${Math.round(n.rect.top)/t}px`,e.style.width=`${Math.round(n.rect.width)/t}px`,e.style.height=`${Math.round(n.rect.height)/t}px`}}function Jn(){hi=null,Ui=null,Et=null,document.documentElement.dataset.dvDragging&&delete document.documentElement.dataset.dvDragging,document.querySelector(".dv-tab.wb-tab-dragging")?.classList.remove("wb-tab-dragging"),_o()}function mg(n,e){if(hi=null,Ui=null,Et=e,n){"open"in e||(n.effectAllowed="copy");try{n.setData(td,"open"in e?"item":e.type)}catch{}}document.documentElement.dataset.dvDragging="1"}function nd(n,e){const t=ze.getState();let i;"open"in e?(lc(),e.open(),i=hc()):i=t.openView(e.type,e.params??{},"main",{newTab:!0})?.id,i&&t.dropView(i,n)}function vg(n,e){const t=Or(n.group),i=ze.getState();if(t==="main"){nd(n,e);return}(t==="left"?i.leftVisible:t==="right"?i.rightVisible:i.bottomVisible)||i.toggleSidebar(t),i.openView(e.type,e.params??{},t)}function gg(n,e,t){if(n.stopPropagation(),!n.dataTransfer)return;Et=null,hi=t;const i=ze.getState().api?.getPanel(t);Ui=Zl(i?.params,i?.component),n.dataTransfer.effectAllowed="move",n.dataTransfer.setData("application/x-tangu-view",t),document.documentElement.dataset.dvDragging="1",e.closest(".dv-tab")?.classList.add("wb-tab-dragging")}const vw=({dark:n,soft:e,buildDefault:t})=>{const i=ze(p=>p.bottomVisible),s=ze(p=>p.rightVisible),{t:o}=ws();Ar(p=>p.overrides);const r=_.useRef(null);_.useEffect(()=>{const p=r.current,f=p?.parentElement;if(!p||!f)return;let w=0;const C=()=>{cancelAnimationFrame(w),w=requestAnimationFrame(()=>{f.style.setProperty("--dv-edge-actions-w",`${p.offsetWidth+10}px`);const P=p.getBoundingClientRect();f.querySelectorAll(".dv-tabs-and-actions-container").forEach(y=>{b.has(y)||(b.add(y),D.observe(y));const T=y.getBoundingClientRect();y.classList.toggle("dv-under-edge",T.width>0&&T.top<P.bottom&&T.bottom>P.top&&T.right>P.left&&T.left<P.right),y.classList.toggle("dv-under-lights",T.width>0&&T.left<70&&T.top<28)})})},b=new WeakSet,D=new ResizeObserver(C);C(),D.observe(f),D.observe(p);const k=ze.subscribe(C);return()=>{cancelAnimationFrame(w),D.disconnect(),k()}},[]);const l=Fd(p=>p.commands.find(f=>f.id==="open-mini")),[d,c]=_.useState(0);_.useEffect(()=>Nr(()=>c(p=>p+1)),[]);const h=_.useMemo(()=>{const p={};for(const f of jr())p[f.type]=Ql(f);return p.__extend=f=>a.jsx(Wd,{id:f.api.id,side:f.params.__loc}),p.__frame=lg(new Map),p},[d]),u=_.useMemo(()=>hg(),[]),m=_.useMemo(()=>ug(),[]);_.useEffect(()=>{const p=y=>{const T=ze.getState().api,S=T?ac(T,y.clientX,y.clientY):null;return S&&T&&hi&&!rc(T,hi,S)?null:S},f=y=>{if(!hi&&!Et)return;if(Et&&"open"in Et){qn(y)&&Ja(y);return}const T=p(y);if(!T){_o(),y.dataTransfer&&(y.dataTransfer.dropEffect="none");return}y.preventDefault(),y.dataTransfer&&(y.dataTransfer.dropEffect=Et?"copy":"move"),er(T)},w=y=>{const T=hi,S=Et;if(!T&&!S)return;if(S&&"open"in S){qn(y)&&Ja(y);return}y.preventDefault();const N=p(y);N&&(S?vg(N,S):T&&ze.getState().dropView(T,N)),Jn()},C=y=>{const T=y.target instanceof Element?y.target:null;if(id.has(y)||T&&(T.isContentEditable||T.closest("input, textarea")))return null;const S=p(y);return S&&Or(S.group)==="main"?S:null},b=y=>{if(!qn(y))return;const T=C(y);if(!T){_o();return}y.preventDefault(),y.dataTransfer&&(y.dataTransfer.dropEffect=y.dataTransfer.effectAllowed==="move"?"move":"copy"),er(T)},D=y=>{if(!qn(y))return;const T=C(y),S=Et;Jn(),!(!T||!S)&&(y.preventDefault(),nd(T,S))},k=y=>{const T=ls();if(!Ui||!T?.dragUpdate||!y.screenX&&!y.screenY)return;const S=Date.now();S-Za<30||(Za=S,T.dragUpdate(y.screenX,y.screenY,Ui))},P=y=>{const T=hi,S=Ui,N=ls(),O=y.clientX<0||y.clientY<0||y.clientX>window.innerWidth||y.clientY>window.innerHeight;T&&S&&N?.drop&&O&&!ze.getState().isPinnedLeaf(T)&&N.drop(y.screenX,y.screenY,S).then($=>{$&&ze.getState().closeLeaf(T)}),Jn()};return window.addEventListener("dragover",f,!0),window.addEventListener("drop",w,!0),window.addEventListener("drag",k,!0),window.addEventListener("dragend",P,!0),window.addEventListener("dragover",b),window.addEventListener("drop",D),()=>{window.removeEventListener("dragover",b),window.removeEventListener("drop",D),window.removeEventListener("dragover",f,!0),window.removeEventListener("drop",w,!0),window.removeEventListener("drag",k,!0),window.removeEventListener("dragend",P,!0),Jn()}},[]),_.useEffect(()=>{const p=f=>{const w=og(f);if(w){const C=ze.getState().api?.activePanel;ag(C,w)&&(f.preventDefault(),f.stopPropagation());return}if((f.metaKey||f.ctrlKey)&&f.altKey&&(f.key==="ArrowLeft"||f.key==="ArrowRight")){f.preventDefault(),f.stopPropagation();const C=ze.getState().api,b=C?bs(C)?.id:null;if(!b)return;f.key==="ArrowLeft"?gn.getState().back(b):gn.getState().forward(b)}};return window.addEventListener("keydown",p,!0),()=>window.removeEventListener("keydown",p,!0)},[]),_.useEffect(()=>{if(typeof ResizeObserver>"u")return;const p=document.querySelector(".wb-dockview");if(!p)return;let f=null;const w=new ResizeObserver(()=>{f&&clearTimeout(f),f=setTimeout(()=>ze.getState().repinSides(),120)});return w.observe(p),()=>{w.disconnect(),f&&clearTimeout(f)}},[]);const g=p=>{const f=ze.getState();if(f.setApi(p.api),t&&f.setDefaultBuilder(t),!Zd(p.api)){try{p.api.clear()}catch{}t?.()}Qd();const C=()=>{f.syncPanelState(),f.noteLayoutChange(),dc(p.api),cc()};p.api.onDidLayoutChange(C),p.api.onDidActivePanelChange(({panel:D})=>{f.setFocusedLeaf(D),f.refreshTabs()});const b=(p.api.activePanel?.params??{}).__type;f.setFocusedLeaf(b==="chat"?p.api.activePanel:p.api.panels.find(D=>(D.params??{}).__type==="chat")),f.refreshTabs()};return a.jsxs(a.Fragment,{children:[a.jsx(Jl,{className:`wb-dockview${e?" wb-soft":""}`,theme:cg(n,e),defaultTabComponent:dg,prefixHeaderActionsComponent:u,rightHeaderActionsComponent:m,components:h,disableDnd:!0,onReady:g}),a.jsxs("div",{className:"dv-edge-actions",ref:r,children:[a.jsx("button",{className:"dv-edge-toggle dv-edge-reset",title:o("lcl.edge.reset"),onClick:()=>ze.getState().resetLayout({undoable:!0}),children:a.jsx(rp,{size:15})}),l&&a.jsx("button",{className:"dv-edge-toggle dv-edge-mini",title:o("lcl.withHotkey",{label:Xs(l.title),key:$d("mod+shift+m",Hd())}),onClick:()=>{l.run()},children:a.jsx(sp,{size:15})}),a.jsx("button",{className:`dv-edge-toggle dv-edge-bottom${i?" is-on":""}`,"aria-pressed":i,title:wn(o,o("lcl.edge.bottom"),"toggle-bottom"),onClick:()=>ze.getState().toggleSidebar("bottom"),children:a.jsx(ip,{size:15})}),a.jsx("button",{className:`dv-edge-toggle dv-edge-right${s?" is-on":""}`,"aria-pressed":s,title:wn(o,o("lcl.edge.right"),"toggle-right"),onClick:()=>ze.getState().toggleSidebar("right"),children:a.jsx(Bd,{size:15})})]})]})};function tr(n,e){if(typeof n=="function")return n(e);n!=null&&(n.current=e)}function fg(...n){return e=>{let t=!1;const i=n.map(s=>{const o=tr(s,e);return!t&&typeof o=="function"&&(t=!0),o});if(t)return()=>{for(let s=0;s<i.length;s++){const o=i[s];typeof o=="function"?o():tr(n[s],null)}}}}function _g(...n){return _.useCallback(fg(...n),n)}class wg extends _.Component{getSnapshotBeforeUpdate(e){const t=this.props.childRef.current;if(Es(t)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const i=t.offsetParent,s=Es(i)&&i.offsetWidth||0,o=Es(i)&&i.offsetHeight||0,r=getComputedStyle(t),l=this.props.sizeRef.current;l.height=parseFloat(r.height),l.width=parseFloat(r.width),l.top=t.offsetTop,l.left=t.offsetLeft,l.right=s-l.width-l.left,l.bottom=o-l.height-l.top,l.direction=r.direction}return null}componentDidUpdate(){}render(){return this.props.children}}function bg({children:n,isPresent:e,anchorX:t,anchorY:i,root:s,pop:o}){const r=_.useId(),l=_.useRef(null),d=_.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:"ltr"}),{nonce:c}=_.useContext(Lc),h=n.props?.ref??n?.ref,u=_g(l,h);return _.useInsertionEffect(()=>{const{width:m,height:g,top:p,left:f,right:w,bottom:C,direction:b}=d.current;if(e||o===!1||!l.current||!m||!g)return;const D=b==="rtl",k=t==="left"?D?`right: ${w}`:`left: ${f}`:D?`left: ${f}`:`right: ${w}`,P=i==="bottom"?`bottom: ${C}`:`top: ${p}`;l.current.dataset.motionPopId=r;const y=document.createElement("style");c&&(y.nonce=c);const T=s??document.head;return T.appendChild(y),y.sheet&&y.sheet.insertRule(`
3
+ [data-motion-pop-id="${r}"] {
4
+ position: absolute !important;
5
+ width: ${m}px !important;
6
+ height: ${g}px !important;
7
+ ${k}px !important;
8
+ ${P}px !important;
9
+ }
10
+ `),()=>{l.current?.removeAttribute("data-motion-pop-id"),T.contains(y)&&T.removeChild(y)}},[e]),a.jsx(wg,{isPresent:e,childRef:l,sizeRef:d,pop:o,children:o===!1?n:_.cloneElement(n,{ref:u})})}const xg=({children:n,initial:e,isPresent:t,onExitComplete:i,custom:s,presenceAffectsLayout:o,mode:r,anchorX:l,anchorY:d,root:c})=>{const h=$r(yg),u=_.useId(),m=_.useRef(t),g=_.useRef(i);Hr(()=>{m.current=t,g.current=i});let p=!0,f=_.useMemo(()=>(p=!1,{id:u,initial:e,isPresent:t,custom:s,onExitComplete:w=>{h.set(w,!0);for(const C of h.values())if(!C)return;i&&i()},register:w=>(h.set(w,!1),()=>{h.delete(w),!m.current&&!h.size&&g.current?.()})}),[t,h,i]);return o&&p&&(f={...f}),_.useMemo(()=>{h.forEach((w,C)=>h.set(C,!1))},[t]),_.useEffect(()=>{!t&&!h.size&&i&&i()},[t]),n=a.jsx(bg,{pop:r==="popLayout",isPresent:t,anchorX:l,anchorY:d,root:c,children:n}),a.jsx(Rc.Provider,{value:f,children:n})};function yg(){return new Map}const Zn=n=>n.key||"";function ir(n){const e=[];return _.Children.forEach(n,t=>{_.isValidElement(t)&&e.push(t)}),e}const nr=({children:n,custom:e,initial:t=!0,onExitComplete:i,presenceAffectsLayout:s=!0,mode:o="sync",propagate:r=!1,anchorX:l="left",anchorY:d="top",root:c})=>{const[h,u]=Vc(r),m=_.useMemo(()=>ir(n),[n]),g=r&&!h?[]:m.map(Zn),p=_.useRef(!0),f=_.useRef(m),w=$r(()=>new Map),C=_.useRef(new Set),[b,D]=_.useState(m),[k,P]=_.useState(m);Hr(()=>{p.current=!1,f.current=m;for(let S=0;S<k.length;S++){const N=Zn(k[S]);g.includes(N)?(w.delete(N),C.current.delete(N)):w.get(N)!==!0&&w.set(N,!1)}},[k,g.length,g.join("-")]);const y=[];if(m!==b){let S=[...m];for(let N=0;N<k.length;N++){const O=k[N],$=Zn(O);g.includes($)||(S.splice(N,0,O),y.push(O))}return o==="wait"&&y.length&&(S=y),P(ir(S)),D(m),null}const{forceRender:T}=_.useContext(Fc);return a.jsx(a.Fragment,{children:k.map(S=>{const N=Zn(S),O=r&&!h?!1:m===k||g.includes(N),$=()=>{if(C.current.has(N))return;if(w.has(N))C.current.add(N),w.set(N,!0);else return;let F=!0;w.forEach(q=>{q||(F=!1)}),F&&(T?.(),P(f.current),r&&u?.(),i&&i())};return a.jsx(xg,{isPresent:O,initial:!p.current||t?void 0:!1,custom:e,presenceAffectsLayout:s,mode:o,root:c,onExitComplete:O?void 0:$,anchorX:l,anchorY:d,children:S},N)})})};function Dg(){!Wc.current&&$c();const[n]=_.useState(Hc.current);return n}let sr=0;const We=mi(n=>({vaults:[],activeRoot:null,mirrorVaults:[],mirrorVaultDevices:{},deviceId:null,markSupported:!1,status:{},async refresh(){const e=++sr,t=window.amadeusSync;if(t?.entrySyncGet)try{const i=await t.entrySyncGet();if(e!==sr)return;n({vaults:i.vaults,activeRoot:i.activeRoot,mirrorVaults:i.mirrorVaults??[],mirrorVaultDevices:i.mirrorVaultDevices??{},deviceId:i.deviceId??null,markSupported:i.mirrorVaultDevices!==void 0})}catch{}}}));let or=!1;function sd(){if(or)return;or=!0;const n=window.amadeusSync;We.getState().refresh(),n?.onEntrySyncChange?.(()=>{We.getState().refresh()}),n?.onStatus?.(e=>{const t=e.binding;t?We.setState(i=>({status:{...i.status,[t]:e}})):e.state==="idle"&&We.getState().refresh()})}function Tn(n,e){if(!n)return!1;const t=We.getState().vaults.find(i=>i.vaultRoot===n);return!!t&&Er(t.entries,t.exclude,e)}function Ho(n,e,t,i){if(!window.amadeusSync||t==="cloud")return rs(i);if(!e)return null;const s=n.find(o=>o.vaultRoot===e);return!s||!Er(s.entries,s.exclude,i)?null:`${s.cloudName}/${rs(i)}`}function Cg(n,e){const t=n?We.getState().vaults.find(s=>s.vaultRoot===n):null;if(!t?.exclude?.length)return!1;const i=rs(e);return t.exclude.some(s=>{const o=rs(s);return!!o&&(i===o||i.startsWith(`${o}/`)||i.startsWith(`${o.replace(/\.md$/i,"")}.fd/`))})}let vn=null;function wo(){return vn===null&&(vn=!0,window.tangu?.getConfig?.().then(n=>{vn=n?.notesUpgradeV4!==!1}).catch(()=>{})),vn}function gw(n){vn=n}wo();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 bo=mi(n=>({req:null,open:e=>n({req:e}),close:()=>n({req:null})}));function Di(n,e){bo.getState().open({path:n,kind:e})}const ar=n=>(n.split(/[\\/]/).pop()??n).replace(/\.md$/i,"");function fw(){const n=bo(e=>e.req);return n?a.jsx("div",{className:"am-app tangu-lovable",style:{display:"contents"},children:a.jsx(Sg,{req:n,onClose:()=>bo.getState().close()},`${n.kind}:${n.path}`)}):null}function Sg({req:n,onClose:e}){const{t}=Ce(),[i,s]=_.useState(null),[o,r]=_.useState(new Set),[l,d]=_.useState(new Set),[c,h]=_.useState(new Set),[u,m]=_.useState(!1),[g,p]=_.useState(null),[f,w]=_.useState("");_.useEffect(()=>{let y=!0;if(n.kind==="asset"){s({pages:[],files:[],subPages:[]});return}return window.amadeusSync?.entrySyncClosure?.(n.path,n.kind).then(T=>{if(!y)return;s({...T,subPages:T.subPages??[]}),r(new Set(T.pages)),d(new Set(T.files));const S=We.getState().activeRoot;h(new Set((T.subPages??[]).filter(N=>!Cg(S,N))))}).catch(()=>y&&s({pages:[],files:[],subPages:[]})),()=>{y=!1}},[n.path,n.kind]);const C=async y=>{const T=window.amadeusSync;if(!T?.entrySyncEnable||u)return;m(!0);const S=[{path:n.path,kind:n.kind},...[...o].map(q=>({path:q,kind:"page"})),...[...l].map(q=>({path:q,kind:"asset"}))],N=i?.subPages??[],O=N.filter(q=>!c.has(q)),$=N.filter(q=>c.has(q)),F=await T.entrySyncEnable({entries:S,exclude:O,include:$,...y}).catch(q=>({error:String(q)}));if(m(!1),F?.conflict){p(F.conflict),w(`${F.conflict} 2`);return}if(F?.error||!F?.ok){Ke.getState().toast(F?.error||t("csd.failed"),!0);return}Ke.getState().toast(t("csd.enabled",{name:F.cloudName??""})),We.getState().refresh(),e()},b=y=>{const T=[];for(let S=y;;){const N=S.lastIndexOf(".fd/");if(N<0)return T;S=`${S.slice(0,N)}.md`,T.push(S)}},D=y=>h(T=>{const S=!T.has(y),N=i?.subPages??[],O=`${y.replace(/\.md$/i,"")}.fd/`,$=new Set(T);for(const F of N)F!==y&&!F.startsWith(O)||(S?$.add(F):$.delete(F));if(S)for(const F of b(y))N.includes(F)&&$.add(F);return $}),k=(y,T)=>{const S=new Set(y);return S.has(T)?S.delete(T):S.add(T),S},P=(y,T,S,N,O,$)=>S.length>0&&a.jsxs("div",{className:"amx-csd-group",children:[a.jsxs("div",{className:"amx-csd-head",children:[y,a.jsxs("span",{children:[T,"(",N.size,"/",S.length,")"]}),a.jsx("button",{className:"amx-csd-all",onClick:()=>$(N.size<S.length),children:N.size<S.length?t("csd.selectAll"):t("csd.selectNone")})]}),a.jsx("div",{className:"amx-csd-list",children:S.map(F=>a.jsxs("label",{className:"amx-csd-item",title:F,children:[a.jsx("input",{type:"checkbox",checked:N.has(F),onChange:()=>O(F)}),a.jsx("span",{children:ar(F)}),a.jsx("span",{className:"amx-csd-path",children:F})]},F))})]});return a.jsx("div",{className:"dialog-overlay",onMouseDown:e,children:a.jsxs("div",{className:"dialog amx-csd",onMouseDown:y=>y.stopPropagation(),children:[a.jsxs("div",{className:"dialog-title",children:[a.jsx(Ki,{size:15,style:{verticalAlign:-2,marginRight:6}}),t("csd.title")]}),g?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"dialog-msg",children:t("csd.conflictMsg",{name:g})}),a.jsx("input",{className:"dialog-input",value:f,onChange:y=>w(y.target.value),placeholder:t("csd.newNamePlaceholder"),onKeyDown:y=>{y.key==="Enter"&&f.trim()&&C({cloudName:f.trim()}),y.key==="Escape"&&e()}}),a.jsxs("div",{className:"dialog-actions",children:[a.jsx("button",{className:"dialog-btn",onClick:e,children:t("csd.cancel")}),a.jsx("button",{className:"dialog-btn",disabled:u,onClick:()=>{C({cloudName:g,merge:!0})},children:t("csd.mergeInto",{name:g})}),a.jsx("button",{className:"dialog-btn","data-primary":!0,disabled:u||!f.trim(),onClick:()=>{C({cloudName:f.trim()})},children:t("csd.useNewName")})]})]}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"dialog-msg",children:t("csd.intro",{name:ar(n.path)})}),i===null?a.jsx("div",{className:"dialog-msg",children:t("csd.analyzing")}):a.jsxs(a.Fragment,{children:[P(a.jsx(Cu,{size:12}),t("csd.groupSubPages"),i.subPages,c,D,y=>h(y?new Set(i.subPages):new Set)),P(a.jsx(Yi,{size:12}),t("csd.groupLinkedPages"),i.pages,o,y=>r(T=>k(T,y)),y=>r(y?new Set(i.pages):new Set)),P(a.jsx(Sn,{size:12}),t("csd.groupAssets"),i.files,l,y=>d(T=>k(T,y)),y=>d(y?new Set(i.files):new Set)),!i.pages.length&&!i.files.length&&!i.subPages.length&&a.jsx("div",{className:"dialog-msg",style:{opacity:.6},children:t("csd.nothingElse")})]}),a.jsxs("div",{className:"dialog-actions",children:[a.jsx("button",{className:"dialog-btn",onClick:e,children:t("csd.cancel")}),a.jsx("button",{className:"dialog-btn","data-primary":!0,disabled:u||i===null,onClick:()=>{C()},children:t(u?"csd.enabling":"csd.enable")})]})]})]})})}const Pg=n=>Pd(n).filter(e=>!/^(?:app|window):\/\//i.test(e));function rr(n,e){const t=o=>`${o.ghost?"g:":""}${o.path}`,i=n.map(t).sort(),s=e.map(o=>{const r=t(n[o.a]),l=t(n[o.b]);return r<l?`${r}>${l}`:`${l}>${r}`}).sort();return`${i.join("|")}::${s.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 ms=()=>K.getState(),xo=n=>(n.split(/[\\/]/).pop()??n).replace(/\.md$/i,""),od=mi(n=>({seed:null,request:e=>n(t=>({seed:{q:e,n:(t.seed?.n??0)+1}}))}));function _w(){const{t:n}=Ce(),e=K(c=>c.vaultRoot),[t,i]=_.useState(""),s=od(c=>c.seed);_.useEffect(()=>{s&&i(s.q)},[s]);const[o,r]=_.useState([]),l=_.useRef(0);_.useEffect(()=>{ms().flushSave()},[]),_.useEffect(()=>{const c=t.trim();if(!c){r([]);return}const h=++l.current,u=setTimeout(()=>{me.search(c).then(m=>{h===l.current&&r(m)})},120);return()=>clearTimeout(u)},[t]);const d=(c,h)=>{const u=t.trim().toLowerCase();qe(c.path,h).then(()=>{if(!u)return;const m=Object.values(ms().blocks).find(g=>Gr(g.content).toLowerCase().includes(u));requestAnimationFrame(()=>{const g=m?document.querySelector(`[data-block-id="${m.id}"]`):null;if(g){g.scrollIntoView({behavior:"smooth",block:"center"}),g.classList.add("amx-block-flash"),setTimeout(()=>g.classList.remove("amx-block-flash"),1300);return}const p=u.split(/[\s\-_/.]+/).filter(Boolean);Br(c.path,p.length>1?[u,...p]:[u])})})};return a.jsxs("div",{className:"amx-panel",children:[a.jsx("div",{className:"amx-panel-head",children:n("amxpanel.searchHead")}),a.jsxs("div",{className:"t2s-search amx-search-box",children:[a.jsx(To,{size:13,className:"t2s-dim"}),a.jsx("input",{autoFocus:!0,value:t,placeholder:n("amxpanel.searchPlaceholder"),onChange:c=>i(c.target.value)}),t.trim()&&a.jsx("button",{className:"amx-search-save",title:n("amxpanel.saveCollectionTip"),onClick:()=>{Ot(n("amxpanel.saveCollection"),t.trim(),{label:n("amxpanel.saveCollectionHint")}).then(c=>{const h=c?.trim();h&&Be.getState().saveCollection(h,t.trim())})},children:n("amxpanel.saveCollection")})]}),e?t.trim()?o.length===0?a.jsx("div",{className:"amx-panel-empty",children:n("amxpanel.noResults")}):a.jsx("div",{className:"amx-list",children:o.map(c=>a.jsxs("button",{className:"amx-list-item",onClick:h=>d(c,ft(h)),title:c.path,children:[c.title,c.snippet&&a.jsx("span",{className:"amx-backlink-snippet amx-search-snippet",children:kg(c.snippet,t.trim())})]},c.path))}):a.jsx("div",{className:"amx-panel-empty",children:n("amxpanel.searchEmpty")}):a.jsx("div",{className:"amx-panel-empty",children:n("amxpanel.noVault")})]})}function kg(n,e){if(!e)return n;const t=n.toLowerCase().indexOf(e.toLowerCase());return t<0?n:a.jsxs(a.Fragment,{children:[n.slice(0,t),a.jsx("mark",{children:n.slice(t,t+e.length)}),n.slice(t+e.length)]})}const ad=mi(n=>({seed:null,request:e=>n(t=>({seed:{tag:e,n:(t.seed?.n??0)+1}}))}));function ww(n){ad.getState().request(n.replace(/^#/,""));const e=Xe.getState();e.showSideView("left","amadeus-tags");const t=Xe.getState(),i=t.api;t.leftVisible&&!i?.panels.some(s=>s.params?.__type==="amadeus-tags")&&e.openView("amadeus-tags",{},"left")}function bw(){const{t:n}=Ce(),e=K(u=>u.vaultRoot),t=K(u=>u.linkGraphVersion),[i,s]=_.useState([]),[o,r]=_.useState(null),[l,d]=_.useState([]),c=ad(u=>u.seed);_.useEffect(()=>{c&&r(c.tag)},[c]);const h=o&&!i.some(u=>u.tag.toLowerCase()===o.toLowerCase())?[{tag:o,count:l.length},...i]:i;return _.useEffect(()=>{let u=!0;if(!e){s([]);return}return me.listTags().then(m=>{u&&s(m)}),()=>{u=!1}},[e,t]),_.useEffect(()=>{let u=!0;if(!o){d([]);return}return me.pagesByTag(o).then(m=>{u&&d(m)}),()=>{u=!1}},[o,t]),a.jsxs("div",{className:"amx-panel",children:[a.jsx("div",{className:"amx-panel-head",children:n("amxpanel.tagsHead",{n:i.length})}),e?h.length===0?a.jsx("div",{className:"amx-panel-empty",children:n("amxpanel.tagsEmpty")}):a.jsx("div",{className:"amx-list",children:h.map(u=>a.jsxs("div",{children:[a.jsxs("button",{className:`amx-list-item amx-tag${o===u.tag?" active":""}`,ref:o===u.tag&&c?m=>m?.scrollIntoView({block:"nearest"}):void 0,onClick:()=>r(m=>m===u.tag?null:u.tag),children:[a.jsxs("span",{className:"amx-tag-name",children:["#",u.tag]}),a.jsx("span",{className:"amx-tag-count",children:u.count})]}),o===u.tag&&l.map(m=>a.jsx("button",{className:"amx-list-item amx-tag-page",onClick:g=>{qe(m,ft(g)).then(()=>Br(m,[`#${u.tag}`],{tag:!0}))},title:m,children:xo(m)},m))]},u.tag))}):a.jsx("div",{className:"amx-panel-empty",children:n("amxpanel.noVault")})]})}const Li=320,Ri=280,yn=(n,e,t)=>Math.min(t,Math.max(e,n));function zg(n,e,t){const i=Li/2,s=Ri/2;for(let o=0;o<n.length;o++){const r=n[o];if(r.pinned)continue;let l=(i-r.x)*.005,d=(s-r.y)*.005;for(let c=0;c<n.length;c++){if(o===c)continue;const h=n[c],u=r.x-h.x,m=r.y-h.y,g=Math.max(64,u*u+m*m),p=1400/g;l+=u/Math.sqrt(g)*p,d+=m/Math.sqrt(g)*p}for(const c of e){if(c.a!==o&&c.b!==o)continue;const h=n[c.a===o?c.b:c.a],u=h.x-r.x,m=h.y-r.y,g=Math.max(1,Math.hypot(u,m)),p=(g-86)*.02;l+=u/g*p,d+=m/g*p}r.vx=(r.vx+l*t*2)*.82,r.vy=(r.vy+d*t*2)*.82,r.x=yn(r.x+r.vx,16,Li-16),r.y=yn(r.y+r.vy,16,Ri-16)}}function xw(){const{t:n}=Ce(),e=K(P=>P.activePage??P.activeNotePath),t=K(P=>P.linkGraphVersion),[i,s]=_.useState(null),[,o]=_.useState(0),[r,l]=_.useState(null),[d,c]=_.useState({x:0,y:0,k:1}),h=_.useRef(null),u=_.useRef(i);u.current=i;const m=_.useRef(d);m.current=d;const g=_.useRef({alpha:0,raf:0,dragging:!1}),p=_.useRef(!1),f=()=>{if(g.current.raf)return;const P=()=>{const y=u.current,T=g.current;if(!y){T.raf=0;return}zg(y.nodes,y.edges,T.alpha),T.dragging||(T.alpha-=.006),o(S=>S+1),T.alpha>.02||T.dragging?T.raf=requestAnimationFrame(P):T.raf=0};g.current.raf=requestAnimationFrame(P)};_.useEffect(()=>()=>{g.current.raf&&cancelAnimationFrame(g.current.raf)},[]);const w=(P,y)=>{const T=h.current?.getScreenCTM();if(!T)return null;const S=new DOMPoint(P,y).matrixTransform(T.inverse());return{x:S.x,y:S.y}},C=(P,y)=>{const T=w(P,y);if(!T)return null;const S=m.current;return{x:(T.x-S.x)/S.k,y:(T.y-S.y)/S.k}};_.useEffect(()=>{let P=!0;if(!e){s(null),u.current=null;return}return u.current?.nodes[0]?.path!==e&&(u.current=null,s(null)),(async()=>{const y=await me.backlinks(e).catch(()=>[]);if(!P)return;const T=ms(),S=await me.readTextFile(e).catch(()=>null);if(!P)return;const N=Gr(kd(S??"")),O=[],$=[],F=new Set;for(const de of Pg(N)){const ce=zd(de,T.pages,e);ce?ce!==e&&!O.includes(ce)&&O.push(ce):F.has(de.toLowerCase())||(F.add(de.toLowerCase()),uc(de,T.files,e)||$.push(de))}const q=[...new Set([...O,...y.map(de=>de.path).filter(de=>de!==e)])],re=[...q,...$],V=[{path:e,label:xo(e),center:!0,x:Li/2,y:Ri/2,vx:0,vy:0,pinned:!0},...re.map((de,ce)=>{const be=ce/Math.max(1,re.length)*Math.PI*2,Se=ce>=q.length;return{path:de,label:Se?de:xo(de),center:!1,ghost:Se,x:Li/2+Math.cos(be)*90,y:Ri/2+Math.sin(be)*90,vx:0,vy:0,pinned:!1}})],B=new Map(V.slice(0,1+q.length).map((de,ce)=>[de.path,ce])),te=[],we=new Set;for(const de of[...O,...y.map(ce=>ce.path)]){const ce=B.get(de);ce===void 0||we.has(de)||(we.add(de),te.push({a:0,b:ce}))}for(let de=0;de<$.length;de++)te.push({a:0,b:1+q.length+de});if(!P)return;const xe={nodes:V,edges:te},j=u.current;if(!(j&&rr(j.nodes,j.edges)===rr(xe.nodes,xe.edges))){if(j?.nodes[0]?.path===e){const de=new Map(j.nodes.map(ce=>[`${ce.ghost?"g:":""}${ce.path}`,ce]));for(const ce of xe.nodes){const be=de.get(`${ce.ghost?"g:":""}${ce.path}`);be&&(ce.x=be.x,ce.y=be.y,ce.vx=be.vx,ce.vy=be.vy)}}u.current=xe,s(xe),l(null),g.current.alpha=j?.38:1,f()}})(),()=>{P=!1}},[e,t]);const b=P=>y=>{if(y.button!==0)return;y.stopPropagation();const T=u.current;if(!T)return;const S=T.nodes[P],N=S.pinned;S.pinned=!0,p.current=!1,g.current.dragging=!0,g.current.alpha=Math.max(g.current.alpha,.6),f();const O=F=>{const q=C(F.clientX,F.clientY);q&&(p.current=!0,S.x=yn(q.x,16,Li-16),S.y=yn(q.y,16,Ri-16),S.vx=0,S.vy=0,g.current.alpha=Math.max(g.current.alpha,.6))},$=()=>{window.removeEventListener("pointermove",O),window.removeEventListener("pointerup",$),S.pinned=N,g.current.dragging=!1,g.current.alpha=Math.max(g.current.alpha,.5),f()};window.addEventListener("pointermove",O),window.addEventListener("pointerup",$)},D=P=>{if(P.button!==0||P.target!==P.currentTarget)return;const y=w(P.clientX,P.clientY);if(!y)return;const T=m.current,S=O=>{const $=w(O.clientX,O.clientY);$&&c({k:T.k,x:T.x+($.x-y.x),y:T.y+($.y-y.y)})},N=()=>{window.removeEventListener("pointermove",S),window.removeEventListener("pointerup",N)};window.addEventListener("pointermove",S),window.addEventListener("pointerup",N)},k=!!i&&i.nodes.length>1;return _.useEffect(()=>{const P=h.current;if(!P||!k)return;const y=T=>{T.preventDefault();const S=w(T.clientX,T.clientY);if(!S)return;const N=m.current,O=yn(N.k*Math.exp(-T.deltaY*.0022),.4,3),$=(S.x-N.x)/N.k,F=(S.y-N.y)/N.k;c({k:O,x:S.x-$*O,y:S.y-F*O})};return P.addEventListener("wheel",y,{passive:!1}),()=>P.removeEventListener("wheel",y)},[k]),a.jsxs("div",{className:"amx-panel",children:[a.jsx("div",{className:"amx-panel-head",children:n("amxpanel.graphHead")}),e?!i||!k?a.jsx("div",{className:"amx-panel-empty",children:n("amxpanel.graphEmpty")}):a.jsx("svg",{ref:h,className:"amx-graph",viewBox:`0 0 ${Li} ${Ri}`,onPointerDown:D,onDoubleClick:()=>c({x:0,y:0,k:1}),children:a.jsxs("g",{transform:`translate(${d.x} ${d.y}) scale(${d.k})`,children:[i.edges.map((P,y)=>a.jsx("line",{x1:i.nodes[P.a].x,y1:i.nodes[P.a].y,x2:i.nodes[P.b].x,y2:i.nodes[P.b].y,className:`amx-graph-edge${r!==null?P.a===r||P.b===r?" hl":" dim":""}`},y)),i.nodes.map((P,y)=>{const T=r===null||y===r||i.edges.some(S=>S.a===r&&S.b===y||S.b===r&&S.a===y);return a.jsxs("g",{className:`amx-graph-node${P.center?" center":""}${P.ghost?" ghost":""}${r!==null?T?" hl":" dim":""}`,onPointerDown:b(y),onPointerEnter:()=>l(y),onPointerLeave:()=>l(null),onClick:S=>{p.current||P.center||(P.ghost?ms().openWikiLink(P.path):qe(P.path,ft(S)))},children:[a.jsx("circle",{cx:P.x,cy:P.y,r:P.center?8:5.5}),a.jsx("text",{x:P.x,y:P.y+(P.center?20:16),textAnchor:"middle",children:P.label.length>12?`${P.label.slice(0,12)}…`:P.label})]},P.ghost?`g:${P.path}`:P.path)})]})}):a.jsx("div",{className:"amx-panel-empty",children:n("amxpanel.graphNoNote")})]})}const Tg=n=>/\.md$/i.test(n);function Eg(n){const e=n.replace(/\.md$/i,""),t=e.split(/[\\/]/).pop()||e;return e===t?e:`${e}|${t}`}function Gg(n){return Bc(n).filter(e=>e.kind==="note").map(e=>Tg(e.path)?`[[${Eg(e.path)}]]`:`![[${e.path}]]`)}const Ig=/[^./\\]\.[^./\\]+\.md$/;function Ag(n,e){if(!n||!Ig.test(n)||e.pages.includes(n))return"note";if(e.filesPendingFor!=null&&e.filesPendingFor===e.vaultRoot)return"pending";const t=n.replace(/\\/g,"/");return e.files.some(i=>i.replace(/\\/g,"/")===t)?"plugin":"note"}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 Bo(n){try{await Ir(n,!0)}catch(t){return{ok:!1,reason:Q("unilock.failed.save",{err:Mr(t)})}}const e=await me.readTextFile(n).catch(()=>null);return e==null?{ok:!1,reason:Q("unilock.failed.read")}:{ok:!0,raw:e}}const Ng=n=>(n.split("/").pop()??n).replace(/\.md$/i,"");function rd(n,e,t,i){Po({level:"error",dedupeKey:`amx-lock:${n}`,text:Q(e?"unilock.failed.lock":"unilock.failed.unlock",{name:Ng(n),reason:t}),action:{label:Q("unilock.retry"),run:i}})}async function ld(n,e,t){const i=await Bo(e);return i.ok?(pc(n,e,t),!0):(rd(e,t,i.reason,()=>{ld(n,e,t)}),!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 jg=n=>(n.split("/").pop()??n).replace(/\.md$/i,"");function Qn(n,e,t){Po({level:"error",dedupeKey:`amx-hist-restore:${n}`,text:Q("pghist.failed",{name:jg(n),reason:e}),...t?{action:{label:Q("pghist.retry"),run:t}}:{}})}async function Og(n,e){const t=me.restorePageHistory;if(!t)return!1;const i=()=>{Og(n,e)},s=await Bo(n);if(!s.ok)return Qn(n,s.reason,i),!1;let o;try{o=await t(n,e.id,Ed(s.raw))}catch(r){return Qn(n,Mr(r),i),!1}return o.ok?(Gd(n,{}),Po({level:"success",text:Q("pghist.done",{time:Ur(e.at)})}),!0):(o.current==null?Qn(n,Q("pghist.failed.gone")):Qn(n,Q("pghist.failed.conflict"),i),!1)}const Mg=Uc(()=>Td(()=>import("./PageHistoryPanel-B1EAPZeX.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50]),import.meta.url));function Lg({path:n,locked:e,onClose:t}){return a.jsx(_.Suspense,{fallback:null,children:a.jsx(Mg,{path:n,locked:e,onClose:t})})}async function Rg(n){await Ir(n);const e=Id(n);if(e!=null)return e;const t=await me.readTextFile(n).catch(()=>null);return t==null?null:tu(t).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 Vg=["default","serif","mono"];function Fg(n,e,t=Q){return[{kind:"choice",id:"font",label:t("amxpage.font"),options:Vg.map(i=>({id:i,label:t(`amxpage.font.${i}`),on:n.font===i,run:()=>e({font:i})}))},{kind:"toggle",id:"wide",label:t("amxpage.wide"),on:n.wide,run:()=>e({wide:!n.wide})},{kind:"toggle",id:"small",label:t("amxpage.small"),on:n.small,run:()=>e({small:!n.small})}]}function Wg(n,e){const[,t]=_.useState(0);return _.useEffect(()=>mc(()=>t(i=>i+1)),[]),e?gc(n,e):vc}function $g(n,e,t){fc(n,e,t)}function Hg(n){return{...n.wide?{"data-page-wide":""}:{},...n.small?{"data-page-small":""}:{},...n.font!=="default"?{"data-page-font":n.font}:{}}}const Bg={wide:ll,small:hl};function Ug({entries:n}){return a.jsx("div",{className:"amx-pagestyle","data-pagestyle-menu":"",children:n.map(e=>e.kind==="choice"?a.jsxs("div",{className:"amx-pagefont",role:"group","aria-label":e.label,children:[a.jsx("div",{className:"ctx-head",children:e.label}),a.jsx("div",{className:"amx-pagefont-row",children:e.options.map(t=>a.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":t.on,className:`amx-pagefont-opt${t.on?" on":""}`,"data-font":t.id,onClick:t.run,children:[a.jsx("span",{className:"amx-pagefont-aa","aria-hidden":!0,children:"Aa"}),a.jsx("span",{className:"amx-pagefont-name",children:t.label})]},t.id))})]},e.id):a.jsx(Yg,{entry:e},e.id))})}function Yg({entry:n}){const e=Bg[n.id];return a.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":n.on,"data-pagestyle":n.id,onClick:n.run,children:[a.jsx(e,{size:13}),a.jsx("span",{className:"amx-pagestyle-label",children:n.label}),n.on&&a.jsx(ei,{size:13,className:"amx-pagestyle-check"})]})}function Xg({host:n,label:e,scanTrigger:t}){return a.jsx(vu,{scrollContainer:n,contentRoot:n,selector:".page-view h1, .page-view h2, .page-view h3",label:e,scanTrigger:t,placement:"sticky",topOffset:fu,topInset:gu})}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 qi=(n,e)=>Q("fileimport.withReason",{name:n,reason:e}),Lt=()=>K.getState(),Wt=n=>Lr.getState().notify(n);function Kg(){return window.amadeusSync?Lt().vaultSide==="cloud":!!window.amadeusCloudVaults}function qg(n,e){const t=/[ ()<>]/.test(e)?`<${e}>`:e;return`[${n.replace(/[[\]]/g,"")}](${t})`}function Jg(n,e,t,i){return i&&!/[[\]|#]/.test(n)?`![[${n}]]`:qg(e,t)}function Ss(n){const e=n instanceof Error?n.message:String(n);return/TOO_LARGE|\b413\b/.test(e)?Q("fileimport.tooLargeCloud"):/VAULT_FULL/.test(e)?Q("fileimport.vaultFull"):e||Q("fileimport.unknownError")}async function Zg(){const n=window.amadeusSync?(await window.amadeusSync.get().catch(()=>null))?.maxFileBytes:window.amadeusCloudMaxFileBytes;return typeof n=="number"&&n>0?n:null}const Qg=n=>`${+(n/1048576).toFixed(1)} MB`;async function Uo(n){if(!Kg())return null;const e=await Zg();return e!==null&&n.size>e?Qg(e):null}async function Yo(){try{await Lt().refreshStructure?.()}catch{}}function Xo(n){let e=-1;return(t,i)=>{const s=i>0?Math.min(100,Math.floor(t/i*100)):0;s!==e&&(e=s,Wt(Q("fileimport.uploading",{name:n,pct:s})))}}function dd(n,e){const t=Q("fileimport.placeholder",{name:e}),i=Lt().activePage===n?Lt().insertBlockAfter(null,void 0,t):null,s=()=>!!i&&Lt().activePage===n&&Lt().blocks[i]?.content===t;return{done:o=>s()?(Lt().setBlockContent(i,o),!0):!1,fail:()=>{s()&&Lt().setBlockContent(i,Q("fileimport.placeholderFailed",{name:e}))}}}async function vs(n,e){if(!n.length||!e)return;const{opts:t,preview:i}=await Yc();let s=0,o=0;const r=[];for(const l of n){const d=await Uo(l);if(d){r.push(qi(l.name,Q("fileimport.overCloudLimit",{limit:d})));continue}const c=dd(e,l.name);try{const h=new Uint8Array(await l.arrayBuffer()),{pageRel:u,base:m}=await me.saveAttachment(e,l.name,h,t,Xo(l.name));c.done(Jg(m,l.name,u,i))||Lt().activePage===e?s++:o++}catch(h){c.fail(),r.push(qi(l.name,Ss(h)))}}await Yo(),r.length?Wt(Q(r.length===1?"fileimport.notImportedOne":"fileimport.notImportedMany",{n:r.length,first:r[0]})):o?Wt(Q("fileimport.movedAway")):n.length>1?Wt(Q(s===1?"fileimport.importedOne":"fileimport.importedMany",{n:s})):Wt(Q("fileimport.uploadedOne",{name:n[0].name}))}async function lr(n,e){if(!n.length)return;let t=0;const i=[];for(const o of n){const r=await Uo(o);if(r){i.push(qi(o.name,Q("fileimport.overCloudLimit",{limit:r})));continue}try{const l=new Uint8Array(await o.arrayBuffer());await me.saveAttachment("",o.name,l,{mode:"vault",folder:e},Xo(o.name)),t++}catch(l){i.push(qi(o.name,Ss(l)))}}await Yo();const s=e?e.split("/").pop()||e:Q("fileimport.vaultRoot");i.length?Wt(Q(i.length===1?"fileimport.notImportedOne":"fileimport.notImportedMany",{n:i.length,first:i[0]})):Wt(Q(t===1?"fileimport.importedToOne":"fileimport.importedToMany",{n:t,where:s}))}async function ef(n){const e=window.tangu?.readHostFile;if(!e)return[];const t=[],i=[];for(const s of n){const o=s.split(/[\\/]/).pop()||s;try{const r=await e(s);if(!r||r.tooLarge){i.push(qi(o,Q(r?.tooLarge?"fileimport.over50mb":"fileimport.unreadable")));continue}t.push(new File([Xc(r.content)],o,{type:r.mimeType}))}catch(r){i.push(qi(o,Ss(r)))}}return i.length&&Wt(Q(i.length===1?"fileimport.unreadableOne":"fileimport.unreadableMany",{n:i.length,first:i[0]})),t}async function tf(n,e){if(!n.length||!e)return;let t=0;const i=[];for(const s of n){const o=await Uo(s);if(o){i.push(Q("fileimport.imageOverCloudLimit",{limit:o}));continue}const r=(s.name||"pasted.png").replace(/\s+/g,"_"),l=dd(e,r);try{const d=new Uint8Array(await s.arrayBuffer()),c=await me.saveAsset(e,r,d,Xo(r));!l.done(`![](${c})`)&&Lt().activePage!==e&&t++}catch(d){l.fail(),i.push(Ss(d))}}await Yo(),i.length?Wt(Q("fileimport.pasteFailed",{first:i[0]})):t&&Wt(Q("fileimport.imageMovedAway"))}function dr(n,e,t=!1){return!!n&&!e&&!t}function nf(n){const e=n.cloneNode(!0),t=[...n.querySelectorAll("input.amx-title-input, textarea.amx-title-input")];return e.querySelectorAll("input.amx-title-input, textarea.amx-title-input").forEach((i,s)=>{const o=t[s],r=document.createElement("h1");r.className="amx-title-input amx-title-static",r.textContent=o?.value||o?.placeholder||"",i.replaceWith(r)}),e}const yo="forsion_tangu_recent_views",sf=24;function of(){try{const n=JSON.parse(localStorage.getItem(yo)||"[]");return Array.isArray(n)?n.filter(e=>e&&e.key&&e.id):[]}catch{return[]}}const Ps=mi(n=>({items:of(),record:e=>n(t=>{const i=[{...e,ts:Date.now()},...t.items.filter(s=>s.key!==e.key)].slice(0,sf);try{localStorage.setItem(yo,JSON.stringify(i))}catch{}return{items:i}}),remove:e=>n(t=>{const i=t.items.filter(s=>s.key!==e);try{localStorage.setItem(yo,JSON.stringify(i))}catch{}return{items:i}})})),cr="amx.sec.";function af(n,e){return n==="1"?!0:n==="0"?!1:e}function gs(n,e=!1){const[t,i]=_.useState(()=>{try{return af(localStorage.getItem(cr+n),e)}catch{return e}});return[t,()=>i(o=>{const r=!o;try{localStorage.setItem(cr+n,r?"1":"0")}catch{}return r})]}const rf=14,lf=10.5,df=4.5;function Ko(n){return rf+n*lf}function cf(n){return Ko(n)-df}const hf=18.4,uf=5.5;function yw(n){return Ko(n)+hf+uf}function cd(n,e){const t=e==="first",i=t?n.children[0]:n.children.at(-1),s=t?i?.columns[0]:i?.columns.at(-1);return(t?s?.children[0]:s?.children.at(-1))?.ref??null}const hd="amadeus.heading.fold";function pf(n){const e=(n??"").split(`
11
+ `,1)[0]??"",t=/^ {0,3}(#{1,6})\s/.exec(e);return t?t[1].length:0}function hr(n){const e=n??"";if(!e.includes("#"))return 0;let t=0,i=!1;for(const s of e.split(`
12
+ `)){if(/^ {0,3}(```|~~~)/.test(s)){i=!i;continue}if(i)continue;const o=/^ {0,3}(#{1,6})\s/.exec(s);if(o&&((!t||o[1].length<t)&&(t=o[1].length),t===1))break}return t}const mf=()=>{try{const n=JSON.parse(localStorage.getItem(hd)||"{}");return n&&typeof n=="object"?n:{}}catch{return{}}},ur=mi(n=>({byPage:mf(),toggle:(e,t)=>n(i=>{const s=i.byPage[e]??[],o=s.includes(t)?s.filter(l=>l!==t):[...s,t],r={...i.byPage};o.length?r[e]=o:delete r[e];try{localStorage.setItem(hd,JSON.stringify(r))}catch{}return{byPage:r}})}));function vf(n,e){return new Set(n[e]??[])}function gf({col:n,gutterLead:e}){const t=K(r=>r.insertBlockAfter),{setNodeRef:i,isOver:s}=Eo({id:`col:${n.id}`}),o=n.children.map(r=>r.ref);return a.jsxs("div",{ref:i,className:"column","data-col":n.id,"data-over":s||void 0,style:{flexGrow:n.width,flexBasis:0},children:[a.jsx(Yr,{items:o,strategy:Kc,children:o.map((r,l)=>a.jsx(Xr,{blockId:r,gutterLead:l===0?e:void 0},r))}),a.jsx("button",{className:"col-add",onClick:()=>t(null,n.id),children:"+ 块"})]})}Ve({"colresizer.dragHint":{zh:"拖动调整列宽",en:"Drag to resize columns"}});function ff({rowId:n,leftColId:e,rightColId:t}){const i=K(l=>l.resizeColumns),{t:s}=Ce(),o=_.useRef(null),r=l=>{l.preventDefault();const d=o.current?.closest(".row-cols");if(!d)return;const c=u=>{const m=d.querySelector(`[data-col="${e}"]`),g=d.querySelector(`[data-col="${t}"]`);if(!m||!g)return;const p=m.getBoundingClientRect().left,f=g.getBoundingClientRect().right;f<=p||i(n,e,t,(u.clientX-p)/(f-p))},h=()=>{window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",h)};window.addEventListener("pointermove",c),window.addEventListener("pointerup",h)};return a.jsx("div",{ref:o,className:"col-resizer",onPointerDown:r,title:s("colresizer.dragHint")})}function _f({row:n,gutterLead:e}){const t=n.columns.length===1&&n.columns[0].children.length>1;return a.jsxs("div",{className:"row",children:[!t&&a.jsx(pr,{rowId:n.id,side:"left"}),a.jsx("div",{className:"row-cols",children:n.columns.map((i,s)=>a.jsxs(_.Fragment,{children:[s>0&&a.jsx(ff,{rowId:n.id,leftColId:n.columns[s-1].id,rightColId:i.id}),a.jsx(gf,{col:i,gutterLead:s===0?e:void 0})]},i.id))}),!t&&a.jsx(pr,{rowId:n.id,side:"right"})]})}function pr({rowId:n,side:e}){const{setNodeRef:t,isOver:i}=Eo({id:`edge:${n}:${e}`});return a.jsx("div",{ref:t,className:"edge-zone","data-side":e,"data-over":i||void 0})}function wf(){const n=K(l=>l.activePage),e=K(l=>l.linkGraphVersion),t=K(l=>l.loadPage),[i,s]=_.useState([]),[o,r]=_.useState(!1);return _.useEffect(()=>{let l=!0;if(!n){s([]);return}return me.backlinks(n).then(d=>{l&&s(d)}),()=>{l=!1}},[n,e]),n?a.jsxs("section",{className:"backlinks",children:[a.jsxs("button",{className:"backlinks-head",onClick:()=>r(l=>!l),children:[a.jsx("span",{className:"backlinks-chevron",children:o?"▸":"▾"}),"链接到本页 · ",i.length]}),!o&&a.jsxs("div",{className:"backlinks-list",children:[i.length===0&&a.jsx("div",{className:"backlinks-empty",children:"还没有其它页面链接到这里"}),i.map(l=>a.jsxs("button",{className:"page-item backlink-item",onClick:()=>{t(l.path)},title:l.path,children:[a.jsx("span",{className:"backlink-title",children:l.title}),l.snippet&&a.jsx("span",{className:"backlink-snippet",children:l.snippet})]},l.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 bf(n,e){return n==="saving"?e("amxpv.statusSaving"):n==="loading"?e("amxpv.statusLoading"):n==="ready"?e("amxpv.statusReady"):""}function xf(n,e){if(!n)return e("amxpv.emptyBlock");const t=n.replace(/[#>*_`\-[\]]/g,"").trim().split(`
13
+ `)[0];return t.length>48?t.slice(0,48)+"…":t||e("amxpv.emptyBlock")}function mr({index:n}){const{setNodeRef:e,isOver:t}=Eo({id:`gap:${n}`});return a.jsx("div",{ref:e,className:"row-gap","data-over":t||void 0})}function fs(n){const e=(n??ko(xs())).getState(),t=e.manifest?cd(e.manifest.root,"first"):null;t?e.requestFocus(t,"start"):e.insertBlockAfter(null)}const yf=n=>{const e=el(n);return e.length?e:Qc(n)};function Df(n){const e=n.getState(),t=e.manifest?cd(e.manifest.root,"last"):null;t&&!e.blocks[t]?.content?e.requestFocus(t,"end"):e.insertBlockAfter(null)}const Hs=24,Cf=16,Sf=typeof requestIdleCallback=="function"?n=>requestIdleCallback(n,{timeout:200}):n=>window.setTimeout(n,16),Pf=typeof cancelIdleCallback=="function"?cancelIdleCallback:clearTimeout;function kf({bare:n=!1}={}){const{t:e}=Ce(),t=K(L=>L.manifest),i=K(L=>L.blocks),s=K(L=>L.status),o=K(L=>L.activePage),r=K(L=>L.moveBlock),l=K(L=>L.addColumnWithBlock),d=K(L=>L.addRowWithBlock),c=K(L=>L.insertBlockAfter),h=K(L=>L.renamePage),u=K(L=>L.setDnd),m=Rr(),g=Si();_.useEffect(()=>{const L=Kr(m);L&&g.getState().requestFocusAt(L.blockId,L.anchor)},[]);const[p,f]=_.useState([]),w=_.useRef([]),C=p[0]??null,[b,D]=_.useState(!1),[k,P]=_.useState(""),y=qr(qs(qc,{activationConstraint:{distance:5}})),T=ur(L=>L.byPage);_.useEffect(()=>{const L=J=>{if(!(J.metaKey||J.ctrlKey))return;const oe=J.key.toLowerCase();if(oe!=="z"&&oe!=="y")return;const ae=J.target;if(ae&&(ae.tagName==="INPUT"||ae.tagName==="TEXTAREA"||ae.isContentEditable)||J.defaultPrevented||xs()!==m)return;J.preventDefault();const Pe=g.getState();oe==="y"||J.shiftKey?Pe.redo():Pe.undo()};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[]);const S=t?.root.children.length??0,[N,O]=_.useState({page:o,n:Hs});N.page!==o&&O({page:o,n:Hs});const $=N.page===o?N.n:Hs;if(_.useEffect(()=>{if($>=S)return;const L=Sf(()=>O(J=>({...J,n:J.n+Cf})));return()=>Pf(L)},[$,S]),!t)return a.jsx("div",{className:"empty-state",children:e("amxpv.openVault")});const F=t.root,q=L=>{const J=(L??"").indexOf(`
14
+ `);return J<0?"":(L??"").slice(J+1)},re=F.children.map(L=>{const J=L.columns[0]?.children[0]?.ref;let oe=0,ae=0;for(const Pe of L.columns)for(const ge of Pe.children){const H=i[ge.ref]?.content,ie=hr(H);ie&&(!oe||ie<oe)&&(oe=ie);const xt=ge.ref===J?hr(q(H)):ie;xt&&(!ae||xt<ae)&&(ae=xt)}return{firstId:J,level:pf(J?i[J]?.content:void 0),bound:oe,self:ae}}),V=L=>{const J=re[L];if(!J.level||J.self&&J.self<=J.level)return 0;let oe=0;for(let ae=L+1;ae<re.length&&!(re[ae].bound&&re[ae].bound<=J.level);ae++)oe++;return oe},B=vf(T,o??""),te=new Set;if(!C)for(let L=0;L<re.length;L++){const J=re[L];if(!(!J.level||!J.firstId||!B.has(J.firstId)))for(let oe=L+1;oe<=L+V(L);oe++)te.add(oe)}const we=t.title||o?.split("/").pop()||"",xe=()=>{P(we),D(!0)},j=async()=>{D(!1);const L=k.trim();L&&L!==we&&await h(L)},de=L=>{for(const J of F.children)for(const oe of J.columns)if(oe.children.some(ae=>ae.ref===L))return oe.id;return null},ce=L=>{const J=String(L.active.id),oe=Zc.getState(),ae=oe.ids.has(J)?g.getState().flatOrder().filter(ge=>oe.ids.has(ge)):[J];oe.ids.has(J)||oe.select(J);const Pe=ae.length?ae:[J];w.current=Pe,f(Pe),u(J,null)},be=L=>{const J=String(L.active.id),oe=L.over?String(L.over.id):"",ae=oe&&!oe.includes(":")&&oe!==J?oe:null;u(J,ae)},Se=()=>{w.current=[],f([]),u(null,null)},st=L=>{const J=String(L.active.id),oe=w.current.includes(J)?w.current:[J];if(w.current=[],f([]),u(null,null),!L.over)return;const ae=String(L.over.id);if(ae.startsWith("bedge:")){const[,Pe,ge]=ae.split(":");g.getState().pairBlocks(oe,Pe,ge==="left"?"left":"right")}else if(ae.startsWith("edge:")){const[,Pe,ge]=ae.split(":");l(Pe,oe,ge==="left"?"left":"right")}else if(ae.startsWith("gap:"))d(Number(ae.slice(4)),oe);else if(ae.startsWith("col:"))r(oe,ae.slice(4),null);else if(ae!==J){const Pe=de(ae);Pe&&r(oe,Pe,ae)}};return a.jsxs("div",{className:"page-view","data-bare":n||void 0,children:[a.jsx(Jc,{}),!n&&a.jsxs("header",{className:"page-header",children:[b?a.jsx("input",{className:"page-title-edit",autoFocus:!0,value:k,onChange:L=>P(L.target.value),onBlur:()=>{j()},onKeyDown:L=>{if(L.key==="Enter")L.preventDefault(),fs(g),j();else if(L.key==="ArrowRight"||L.key==="ArrowDown"){const J=L.currentTarget;J.selectionStart===J.value.length&&J.selectionEnd===J.value.length&&(L.preventDefault(),fs(g),j())}else L.key==="Escape"&&D(!1)}}):a.jsx("div",{className:"page-title",onClick:xe,title:e("amxpv.renameTitle"),children:we}),a.jsx("div",{className:"page-status","data-status":s,children:bf(s,e)})]}),a.jsxs(Jr,{sensors:y,collisionDetection:yf,measuring:{droppable:{strategy:Zr.Always}},onDragStart:ce,onDragOver:be,onDragEnd:st,onDragCancel:Se,children:[a.jsxs("div",{className:"stack","data-dnd":C?"":void 0,children:[a.jsx(mr,{index:-1}),F.children.map((L,J)=>{if(J>=$||te.has(J))return null;const oe=re[J],ae=V(J),Pe=!!(oe.firstId&&B.has(oe.firstId));return a.jsxs(_.Fragment,{children:[a.jsxs("div",{className:`amx-hfold-wrap${ae>0&&oe.firstId?" has-fold":""}`,children:[Pe&&ae>0&&a.jsx("span",{className:"amx-hfold-count",children:ae}),a.jsx(_f,{row:L,gutterLead:ae>0&&oe.firstId?a.jsx("button",{className:`amx-hfold${Pe?" folded":""}`,title:Pe?e("amxpv.expandSection",{n:ae}):e("amxpv.foldSection"),onClick:ge=>{ge.stopPropagation(),ur.getState().toggle(o??"",oe.firstId)},children:"›"}):void 0})]}),a.jsx(mr,{index:J})]},L.id)})]}),a.jsx(Qr,{dropAnimation:null,children:C?a.jsxs("div",{className:"drag-overlay",children:[p.length>1?`${e("amxpv.dragBlocks",{n:p.length})} · `:"",xf(i[C]?.content,e)]}):null})]}),n&&a.jsx("div",{className:"page-tail",onClick:()=>Df(g)}),!n&&a.jsxs("div",{className:"page-footer",children:[a.jsx("button",{className:"add-block",onClick:()=>c(null),children:e("amxpv.addBlock")}),a.jsx("span",{className:"hint-inline",children:e("amxpv.dndHint")})]}),!n&&a.jsx(wf,{})]})}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 zf({onClose:n}){const{t:e}=Ce(),t=window.amadeusCollab,i=(b,D=!1)=>Ke.getState().toast(b,D),[s,o]=_.useState([]),[r,l]=_.useState(""),[d,c]=_.useState([]),[h,u]=_.useState([]),[m,g]=_.useState(null),[p,f]=_.useState(null),w=()=>{t&&(t.listVaults().then(b=>o(b.map(D=>({id:D.id,name:D.name})))).catch(()=>{}),t.activeVaultId().then(l).catch(()=>{}),t.sharedWithMe().then(c).catch(()=>c([])),t.publishes().then(b=>{u(b.shares),g(b.quota)}).catch(()=>u([])))};if(_.useEffect(w,[]),!t)return null;const C=(b,D)=>{navigator.clipboard.writeText(b).then(()=>{f(D),setTimeout(()=>f(null),1200)})};return a.jsx("div",{className:"amxc-overlay",onClick:n,children:a.jsxs("div",{className:"amxc-panel",onClick:b=>b.stopPropagation(),children:[a.jsxs("div",{className:"amxc-head",children:[a.jsxs("span",{children:[a.jsx(Qt,{size:14})," ",e("cloudvault.title")]}),a.jsx("button",{className:"amxc-x",onClick:n,children:a.jsx(Cn,{size:14})})]}),a.jsx("div",{className:"amxc-sec",children:e("cloudvault.myVaults")}),s.map(b=>a.jsxs("button",{className:`amxc-row${b.id===r?" on":""}`,onClick:()=>{b.id!==r&&t.switchVault(b.id)},children:[a.jsx("span",{className:"amxc-row-name",children:b.name}),b.id===r&&a.jsx(ei,{size:13})]},b.id)),a.jsxs("div",{className:"amxc-sec",children:[a.jsx(Vr,{size:12})," ",e("cloudvault.sharedWithMe",{n:d.length})]}),d.length===0&&a.jsx("div",{className:"amxc-hint",children:e("cloudvault.sharedEmpty")}),d.map(b=>a.jsxs("button",{className:"amxc-row",onClick:D=>{n(),b.vaultId===r?qe(b.path,ft(D)):t.switchVault(b.vaultId)},children:[a.jsx("span",{className:"amxc-row-name",children:b.title}),a.jsxs("span",{className:"amxc-tag",children:[b.role==="viewer"?e("cloudvault.roleViewer"):e("cloudvault.roleEditor"),b.ownerName?` · ${b.ownerName}`:""]})]},`${b.vaultId}:${b.path}`)),a.jsxs("div",{className:"amxc-sec",children:[a.jsx(Go,{size:12})," ",e("cloudvault.published",{n:h.length}),m&&Number.isFinite(m.publish)?` / ${m.publish}`:""]}),h.length===0&&a.jsx("div",{className:"amxc-hint",children:e("cloudvault.publishedEmpty")}),h.map(b=>a.jsxs("div",{className:"amxc-row static",children:[a.jsxs("span",{className:"amxc-row-name",title:b.path,children:[b.mode==="subtree"?"📁 ":"📄 ",b.path]}),a.jsx("button",{className:"amxc-ic",title:e("cloudvault.copyLink"),onClick:()=>C(t.publishUrl(b.token),b.token),children:p===b.token?a.jsx(ei,{size:12}):a.jsx($i,{size:12})}),a.jsx("button",{className:"amxc-ic",title:e("cloudvault.unpublish"),onClick:()=>{t.revokePublish(b.token).then(()=>{i(e("cloudvault.unpublished")),w()})},children:a.jsx(gt,{size:12})})]},b.token))]})})}Ve({"presencedots.viewing":{zh:"{name} 正在看 {page}",en:"{name} is viewing {page}"},"presencedots.online":{zh:"{name} 在线",en:"{name} is online"}});function Tf(){const{t:n}=Ce(),e=window.amadeusCollab,t=K(c=>c.activePage??c.activeNotePath),i=K(c=>c.vaultSide),[s,o]=_.useState([]),r=!window.amadeusSync||i==="cloud";if(_.useEffect(()=>{if(!e||!r)return;const c=e.onPresence(o);return()=>{c(),e.stopHeartbeat()}},[e,r]),_.useEffect(()=>{r&&e?.heartbeat(t)},[e,t,r]),!e||!r)return null;const l=e.myUserId(),d=s.filter(c=>c.userId!==l);return d.length?a.jsxs("span",{className:"amxc-presence",title:d.map(c=>`${c.username}${c.page?` · ${c.page.replace(/\.md$/i,"")}`:""}`).join(`
15
+ `),children:[d.slice(0,5).map(c=>a.jsx("span",{className:`amxc-dot${c.page&&c.page===t?" same":""}`,title:c.page?n("presencedots.viewing",{name:c.username,page:c.page.replace(/\.md$/i,"")}):n("presencedots.online",{name:c.username}),children:(c.username||"?").slice(0,1).toUpperCase()},c.userId)),d.length>5&&a.jsxs("span",{className:"amxc-dot more",children:["+",d.length-5]})]}):null}function Ef(n,e){return n.path===e?!0:n.mode==="subtree"?e.startsWith(`${n.path}/`):e.startsWith(`${n.path.replace(/\.md$/i,"")}.fd/`)}function ud(n,e){const t=e.find(s=>s.path===n);if(t)return{kind:"direct",token:t.token};const i=e.find(s=>Ef(s,n));return i?{kind:"inherited",via:i.path,viaMode:i.mode==="subtree"?"subtree":"page",token:i.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 vr=n=>Number.isFinite(n)?String(n):Q("share.unlimited"),Gf=n=>(n.split("/").pop()??n).replace(/\.md$/i,"");function If({path:n,anchor:e,onClose:t}){const i=K(l=>l.vaultRoot),s=K(l=>l.vaultSide),o=We(l=>l.vaults),r=Ho(o,i,s,n)??"";return a.jsx(Af,{path:r,localPath:n,anchor:e,onClose:t},JSON.stringify([i,s,n,r]))}function Af({path:n,localPath:e,anchor:t,onClose:i}){const s=window.amadeusCollab,{t:o}=Ce(),r=(te,we=!1)=>Ke.getState().toast(te,we),l=_.useRef(!1),d=_.useRef(0),[c,h]=_.useState("share"),[u,m]=_.useState(null),[g,p]=_.useState(null),[f,w]=_.useState(null),[C,b]=_.useState({kind:"none"}),[D,k]=_.useState(0),[P,y]=_.useState(!1),[T,S]=_.useState(null),[N,O]=_.useState(""),[$,F]=_.useState(!1),q=()=>{if(!l.current||!s||!n)return;const te=++d.current,we=()=>l.current&&te===d.current;s.pageShare(n).then(xe=>{we()&&(m(xe.share),p(xe.quota),F(!1))}).catch(xe=>{we()&&xe?.status===404&&F(!0)}),s.publishes().then(xe=>{if(!we())return;p(xe.quota),k(xe.shares.length);const j=xe.shares.find(de=>de.path===n&&de.mode==="page");w(j?{token:j.token,url:s.publishUrl(j.token)}:null),b(ud(n,xe.shares))}).catch(()=>{})};if(_.useEffect(()=>(l.current=!0,q(),()=>{l.current=!1,d.current++}),[s,n]),!s)return null;const re=(te,we)=>{navigator.clipboard.writeText(te).then(()=>{l.current&&(S(we),setTimeout(()=>{l.current&&S(null)},1200))})},V=(te,we)=>{const xe=te;if(xe?.status===404){r(o("share.notUploaded"),!0);return}r(xe?.code==="QUOTA"?xe.message||o("share.quotaReached"):we,!0)},B=(te,we,xe=o("share.opFailed"))=>{y(!0),te.then(()=>{l.current&&(we&&r(we),q())}).catch(j=>{l.current&&V(j,xe)}).finally(()=>{l.current&&y(!1)})};return a.jsx("div",{className:"amxc-cardwrap",onClick:i,children:a.jsxs(Jt,{className:"amxc-card",x:t.x-340,y:t.y+6,onClick:te=>te.stopPropagation(),children:[a.jsxs("div",{className:"amxc-tabs",children:[a.jsx("button",{className:c==="share"?"on":"",onClick:()=>h("share"),children:o("share.tabShare")}),a.jsx("button",{className:c==="publish"?"on":"",onClick:()=>h("publish"),children:o("share.tabPublish")}),a.jsx("span",{className:"amxc-flex"}),a.jsx("button",{className:"amxc-x",onClick:i,children:a.jsx(Cn,{size:14})})]}),n?$?a.jsx("div",{className:"amxc-hint",style:{padding:"18px 8px"},children:o("share.ownerOnly")}):c==="share"?u?a.jsxs("div",{className:"amxc-body",children:[a.jsxs("div",{className:"amxc-frow",children:[a.jsx("input",{className:"amxc-input",readOnly:!0,value:s.inviteUrl(u.inviteToken)}),a.jsx("button",{className:"amxc-ic",title:o("share.copyInvite"),onClick:()=>re(s.inviteUrl(u.inviteToken),"inv"),children:T==="inv"?a.jsx(ei,{size:13}):a.jsx($i,{size:13})}),a.jsx("button",{className:"amxc-ic",title:o("share.rotate"),onClick:()=>B(s.updatePageShare(u.id,{rotate:!0}),o("share.rotated")),children:a.jsx(th,{size:13})})]}),a.jsxs("div",{className:"amxc-frow",children:[a.jsx("span",{className:"amxc-lbl",children:o("share.linkRole")}),a.jsxs("select",{value:u.inviteRole,onChange:te=>B(s.updatePageShare(u.id,{role:te.target.value})),children:[a.jsx("option",{value:"editor",children:o("share.roleEditor")}),a.jsx("option",{value:"viewer",children:o("share.roleViewer")})]}),a.jsx("span",{className:"amxc-lbl",children:o("share.openFor")}),a.jsxs("select",{value:u.expiresAt===null?"forever":"7",onChange:te=>B(s.updatePageShare(u.id,{expiresDays:te.target.value==="forever"?null:Number(te.target.value)})),children:[a.jsx("option",{value:"7",children:o("share.days7")}),a.jsx("option",{value:"30",children:o("share.days30")}),a.jsx("option",{value:"forever",children:o("share.forever")})]})]}),a.jsxs("div",{className:"amxc-frow",children:[a.jsx("span",{className:"amxc-lbl",children:o("share.password")}),u.hasPassword?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"amxc-tag",children:o("share.passwordSet")}),a.jsx("button",{className:"amxc-ic",title:o("share.clearPassword"),onClick:()=>B(s.updatePageShare(u.id,{password:null}),o("share.passwordCleared")),children:a.jsx(gt,{size:12})})]}):a.jsxs(a.Fragment,{children:[a.jsx("input",{className:"amxc-input",placeholder:o("share.passwordOptional"),value:N,onChange:te=>O(te.target.value)}),a.jsx("button",{className:"amxc-ic",title:o("share.setPassword"),disabled:!N.trim(),onClick:()=>{const te=N.trim();O(""),B(s.updatePageShare(u.id,{password:te}),o("share.passwordSaved"))},children:a.jsx(ei,{size:13})})]})]}),a.jsx("div",{className:"amxc-sec",children:o("share.participants",{n:u.participants.length})}),u.participants.length===0&&a.jsx("div",{className:"amxc-hint",children:o("share.noParticipants")}),u.participants.map(te=>a.jsxs("div",{className:"amxc-row static",children:[a.jsx("span",{className:"amxc-row-name",children:te.username??te.userId.slice(0,8)}),a.jsxs("select",{value:te.role,onChange:we=>B(s.setParticipantRole(u.id,te.userId,we.target.value)),children:[a.jsx("option",{value:"editor",children:o("share.roleEditor")}),a.jsx("option",{value:"viewer",children:o("share.roleViewer")})]}),a.jsx("button",{className:"amxc-ic",title:o("share.removeParticipant"),onClick:()=>B(s.removeParticipant(u.id,te.userId),o("share.removed")),children:a.jsx(gt,{size:12})})]},te.userId)),a.jsx("button",{className:"amxc-danger",disabled:P,onClick:()=>B(s.revokePageShare(u.id),o("share.stopped")),children:o("share.stop")})]}):a.jsxs("div",{className:"amxc-body",children:[a.jsx("div",{className:"amxc-hint",children:o("share.intro")}),a.jsxs("button",{className:"amxc-primary",disabled:P||(g?g.collab<=0:!1),onClick:()=>B(s.createPageShare(n,{role:"editor",expiresDays:7}),o("share.enabled")),children:[a.jsx(eh,{size:13})," ",o("share.enable")]}),g&&(g.collab<=0?a.jsx("div",{className:"amxc-hint",children:o("share.planNoCollab")}):a.jsx("div",{className:"amxc-hint",children:o("share.quotaCollab",{n:vr(g.collab)})}))]}):a.jsxs("div",{className:"amxc-body",children:[f?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"amxc-frow",children:[a.jsx("input",{className:"amxc-input",readOnly:!0,value:f.url}),a.jsx("button",{className:"amxc-ic",title:o("share.copyLink"),onClick:()=>re(f.url,"pub"),children:T==="pub"?a.jsx(ei,{size:13}):a.jsx($i,{size:13})})]}),a.jsxs("div",{className:"amxc-frow",children:[a.jsx("button",{className:"amxc-danger",disabled:P,onClick:()=>B(s.revokePublish(f.token),o("share.unpublished")),children:o("share.unpublish")}),a.jsx("a",{className:"amxc-view",href:f.url,target:"_blank",rel:"noreferrer",children:o("share.viewPage")})]})]}):C.kind==="inherited"?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"amxc-hint",children:o("share.inherited",{kind:C.viaMode==="subtree"?o("share.viaFolder"):o("share.viaPage"),name:Gf(C.via)})}),a.jsxs("div",{className:"amxc-frow",children:[a.jsx("input",{className:"amxc-input",readOnly:!0,value:`${s.publishUrl(C.token)}#${encodeURIComponent(n)}`}),a.jsx("button",{className:"amxc-ic",title:o("share.copyPageLink"),onClick:()=>re(`${s.publishUrl(C.token)}#${encodeURIComponent(n)}`,"pub"),children:T==="pub"?a.jsx(ei,{size:13}):a.jsx($i,{size:13})})]}),a.jsx("div",{className:"amxc-hint",children:o("share.inheritedStop",{kind:C.viaMode==="subtree"?o("share.viaFolder"):o("share.viaPage")})})]}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"amxc-hint",children:o("share.publishIntro")}),a.jsxs("button",{className:"amxc-primary",disabled:P,onClick:()=>B(s.createPublish("page",n),o("share.published")),children:[a.jsx(Go,{size:13})," ",o("share.publish")]})]}),g&&a.jsx("div",{className:"amxc-hint",children:o("share.publishCount",{used:D,total:vr(g.publish)})})]}):a.jsx("div",{className:"amxc-hint",style:{padding:"18px 8px"},children:o("share.notInCloud")}),a.jsx(Nf,{path:e,onClose:i})]})})}function Nf({path:n,onClose:e}){const t=K(r=>r.vaultRoot),i=K(r=>r.vaultSide);We(r=>r.vaults);const{t:s}=Ce();if(!window.amadeusSync?.entrySyncEnable||i!=="local")return null;const o=Tn(t,n);return a.jsx("div",{className:"amxc-body",style:{borderTop:"1px solid var(--border, rgba(128,128,128,.25))",marginTop:4,paddingTop:8},children:o?a.jsxs("button",{className:"amxc-primary",onClick:()=>{window.amadeusSync.entrySyncDisable(n)},children:[a.jsx(io,{size:13})," ",s("share.syncOff")]}):a.jsxs("button",{className:"amxc-primary",onClick:()=>{e(),Di(n,"page")},children:[a.jsx(Ki,{size:13})," ",s("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 jf=n=>(n.split("/").pop()??n).replace(/\.md$/i,"");function Of({path:n,refreshKey:e,onOpen:t}){const i=K(l=>l.vaultRoot),s=K(l=>l.vaultSide),o=We(l=>l.vaults),r=Ho(o,i,s,n);return a.jsx(Mf,{path:r??"",refreshKey:e,onOpen:t},JSON.stringify([i,s,n,r]))}function Mf({path:n,refreshKey:e,onOpen:t}){const i=window.amadeusCollab,[s,o]=_.useState(!1),[r,l]=_.useState({kind:"none"}),{t:d}=Ce();if(_.useEffect(()=>{if(!i||!n){o(!1),l({kind:"none"});return}let u=!0;return i.pageShare(n).then(m=>u&&o(!!m.share)).catch(()=>u&&o(!1)),i.publishes().then(m=>u&&l(ud(n,m.shares))).catch(()=>u&&l({kind:"none"})),()=>{u=!1}},[i,n,e]),!i)return null;const c=r.kind!=="none";if(!s&&!c)return null;const h=u=>{u.stopPropagation();const m=u.currentTarget.getBoundingClientRect();t(m.right,m.bottom)};return a.jsxs("span",{className:"amx-sharestat",children:[s&&a.jsxs("button",{className:"amx-sharestat-chip is-collab",title:d("sharestatus.collabTitle"),onClick:h,children:[a.jsx(Vr,{size:12})," ",d("sharestatus.collab")]}),c&&a.jsxs("button",{className:"amx-sharestat-chip is-pub",title:r.kind==="inherited"?d("sharestatus.inheritedTitle",{name:jf(r.via)}):d("sharestatus.pubTitle"),onClick:h,children:[a.jsx(Go,{size:12})," ",r.kind==="inherited"?d("sharestatus.inherited"):d("sharestatus.published")]})]})}const Lf=1e3,Rf=100,En=mi(n=>({anchor:null,lines:[],open:(e,t)=>n({anchor:e,lines:t}),close:()=>n({anchor:null,lines:[]})}));let Do,Co=0,qo=0;function gr(n,e,t){const i=n.getBoundingClientRect();(async()=>{let s;try{s=await e()}catch{s=null}qo!==t||!s?.length||En.getState().open(i,s)})()}function fr(n,e){window.clearTimeout(Do);const t=++qo;Co>0&&Date.now()-Co<=Rf?gr(n,e,t):Do=window.setTimeout(()=>gr(n,e,t),Lf)}function Vi(){window.clearTimeout(Do),qo++,En.getState().anchor&&(Co=Date.now()),En.getState().close()}function _r(n,e){const t={onMouseEnter:i=>fr(i.currentTarget,n),onMouseLeave:Vi};return e?.focus&&(t.onFocus=i=>{let s=!0;try{s=i.currentTarget.matches(":focus-visible")}catch{}s&&fr(i.currentTarget,n)},t.onBlur=Vi),t}function wr(n){return Ur(n,{year:"always"})}const os=(n,e)=>Ke.getState().tr(n,e);async function Vf(n,e){const t=await window.tangu?.statPath?.(n).catch(()=>null);if(!t)return null;if(t.isDir)return[os("tip.folder",{files:t.files??0,folders:t.folders??0})];const i=[e,os("tip.modified",{t:wr(t.mtimeMs)})];return t.birthtimeMs&&i.push(os("tip.created",{t:wr(t.birthtimeMs)})),i}function Dw(){const n=En(r=>r.anchor),e=En(r=>r.lines),t=_.useRef(null),[i,s]=_.useState(!1);if(_.useLayoutEffect(()=>{if(!n||!t.current)return;const r=t.current.offsetWidth;s(n.right+10+r>window.innerWidth-8)},[n,e]),_.useEffect(()=>{if(n)return window.addEventListener("scroll",Vi,!0),window.addEventListener("resize",Vi),()=>{window.removeEventListener("scroll",Vi,!0),window.removeEventListener("resize",Vi)}},[n]),!n)return null;const o=i?{right:window.innerWidth-n.left+10,top:n.top+n.height/2}:{left:n.right+10,top:n.top+n.height/2};return a.jsx("div",{ref:t,className:"amx-tip","data-flip":i||void 0,style:o,role:"tooltip",children:e.map((r,l)=>a.jsx("div",{className:l===0?"amx-tip-head":void 0,children:r},l))},`${n.top}:${e[0]}`)}function br({className:n,depth:e=1,style:t,title:i,lead:s,children:o,trailing:r,selId:l,as:d="div",elRef:c,...h}){const u=d;return a.jsxs(u,{ref:c,className:`t2s-srow${n?` ${n}`:""}`,"data-sel-id":l,title:i,style:{paddingLeft:Ko(e),...t},...h,children:[s!==void 0&&a.jsx("span",{className:"t2s-lead",children:s}),o,r]})}const qt=n=>{const e=n.split(/[\\/]/).filter(Boolean);return e.pop(),e.join("/")};function Ff(n,e){return e?.mergedFd!=null?{folder:e.mergedFd}:/\.md$/i.test(n)&&!_i(n)&&!Hi(n)&&!e?.pluginFile?{page:n}:{folder:qt(n)}}const Bs=n=>"page"in n?n.page:n.folder;function Wf(n,e,t){return e&&n.includes(t.paths)&&!n.includes(t.ref)}function pd(n,e){const t=typeof n.params[e]=="string"?n.params[e]:"",i=_c(t,K(s=>s.vaultRoot));return _.useEffect(()=>{if(i===t)return;const s=Xe.getState().leafById(n.id);s&&n.setParams({...s.params,[e]:i})},[i,t]),i}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 $f=n=>(n.split(/[\\/]/).pop()??n).replace(/\.md$/i,"");function xr(n,e,t){const i=$f(n),s=e.filter(r=>Qo(r)===Qo(n)).length<=1,o=s?i:n.replace(/\\/g,"/").replace(/\.md$/i,"");return t===i&&s?i:`${o}|${t}`}function Hf({h:n}){if(!n.match)return a.jsx(a.Fragment,{children:n.text});const e=n.text.toLowerCase().indexOf(n.match.toLowerCase());return e<0?a.jsx(a.Fragment,{children:n.text}):a.jsxs(a.Fragment,{children:[n.text.slice(0,e),a.jsx("mark",{children:n.text.slice(e,e+n.match.length)}),n.text.slice(e+n.match.length)]})}function Bf(){const{t:n}=Ce(),e=K(g=>g.activePage??g.activeNotePath),t=K(g=>g.linkGraphVersion),i=K(g=>g.pages),[s,o]=_.useState([]),[r,l]=_.useState(!1),[d,c]=_.useState(null),[h,u]=_.useState(0);_.useEffect(()=>{let g=!0;if(!e){o([]);return}return me.backlinks(e).then(p=>{g&&o(p)}),()=>{g=!1}},[e,t,h]),_.useEffect(()=>{let g=!0;if(!e||!r||!me.unlinkedMentions){c(null);return}return me.unlinkedMentions(e).then(p=>{g&&c(p)}).catch(()=>{g&&c([])}),()=>{g=!1}},[e,r,t,h]);const m=async(g,p)=>{if(!e||!me.linkMention||p.raw===void 0||p.occ===void 0||p.col===void 0||!p.match)return;const f=xr(e,i,p.match);await me.linkMention(g,{raw:p.raw,occ:p.occ,col:p.col,match:p.match},f).catch(()=>!1)||window.dispatchEvent(new CustomEvent("amadeus:toast",{detail:{text:Q("amxbl.linkFailed")}})),u(C=>C+1)};return a.jsxs("div",{className:"amx-panel",children:[a.jsxs("div",{className:"amx-panel-head",children:[n("amadeus.backlinks")," · ",s.length]}),e?a.jsxs(a.Fragment,{children:[s.length===0?a.jsx("div",{className:"amx-panel-empty",children:n("amxv.backlinks.empty")}):a.jsx("div",{className:"amx-list",children:s.map(g=>a.jsxs("div",{className:"amx-backlink-group",children:[a.jsx("button",{className:"amx-list-item amx-backlink-src",onClick:p=>{qe(g.path,ft(p))},title:g.path,children:g.title}),(g.hits??(g.snippet?[{line:1,text:g.snippet}]:[])).map((p,f)=>a.jsxs("button",{className:"amx-list-item amx-backlink-hit",onClick:w=>{qe(g.path,ft(w))},children:[p.line===0&&a.jsx("span",{className:"amx-backlink-prop",children:n("amxbl.prop")}),p.text]},`${p.line}:${f}`))]},g.path))}),me.unlinkedMentions&&a.jsxs(a.Fragment,{children:[a.jsxs("button",{className:"amx-panel-head amx-backlink-toggle","aria-expanded":r,onClick:()=>l(g=>!g),children:[r?"▾ ":"▸ ",d&&r?n("amxbl.unlinkedCount",{n:d.length}):n("amxbl.unlinked")]}),r&&d&&(d.length===0?a.jsx("div",{className:"amx-panel-empty",children:n("amxbl.unlinkedEmpty")}):a.jsx("div",{className:"amx-list",children:d.map(g=>a.jsxs("div",{className:"amx-backlink-group",children:[a.jsx("button",{className:"amx-list-item amx-backlink-src",onClick:p=>{qe(g.path,ft(p))},title:g.path,children:g.title}),g.hits.map((p,f)=>a.jsxs("div",{className:"amx-backlink-hit amx-mention",children:[a.jsx("button",{className:"amx-list-item amx-mention-text",onClick:w=>{qe(g.path,ft(w))},children:a.jsx(Hf,{h:p})}),me.linkMention&&p.col!==void 0&&p.match&&a.jsx("button",{className:"amx-backlink-link",title:n("amxbl.linkTip",{inner:xr(e,i,p.match)}),onClick:()=>{m(g.path,p)},children:n("amxbl.link")})]},`${p.line}:${f}`))]},g.path))}))]})]}):a.jsx("div",{className:"amx-panel-empty",children:n("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.pluginFile.title":{zh:"这个文件归插件管理",en:"This file belongs to a plugin"},"amxv.pluginFile.sub":{zh:"「{path}」是某个插件的专属格式,而那个插件没有安装或没有启用。当成笔记来编辑会改坏它的格式,所以这里不打开;启用对应的插件后再打开它。",en:"“{path}” is in a plugin’s own format, and that plugin is not installed or not enabled. Editing it as a note would break the format, so it is not opened here. Enable the plugin, then open the file again."},"amxv.sec.starred":{zh:"收藏",en:"Starred"},"amxv.sec.collections":{zh:"集合",en:"Collections"},"amxv.sec.searchTip":{zh:"搜索:{q}",en:"Search: {q}"},"amxv.sec.removeCollection":{zh:"移除集合",en:"Remove collection"},"amxv.sec.sharedWithMe":{zh:"与我共享",en:"Shared with me"},"amxv.sec.pinned":{zh:"置顶",en:"Pinned"},"amxv.sec.cloudSync":{zh:"云同步",en:"Cloud sync"},"amxv.sec.cloudWorkspace":{zh:"Cloud工作区",en:"Cloud vault"},"amxv.role.viewer":{zh:"只读",en:"Read-only"},"amxv.role.editor":{zh:"可编辑",en:"Can edit"},"amxv.cloudsync.hint":{zh:"拖入笔记/文件,或右键条目「开启云同步」",en:"Drag notes or files here, or right-click an item and choose “Turn on cloud sync”"},"amxv.skip.tooLarge":{zh:"超过云端单文件上限,云端不收",en:"Over the cloud file size limit — the cloud will not accept it"},"amxv.skip.assetMissing":{zh:"云端缺失",en:"Missing in the cloud"},"amxv.skip.summary":{zh:"⚠ {n} 项未同步{extra},悬停看明细",en:"⚠ {n} item(s) not synced{extra} — hover for details"},"amxv.skip.tooLargeNote":{zh:"(有文件超过云端单文件上限:笔记 5MB,附件随会员档位)",en:" (some files are over the per-file cloud limit: 5 MB for notes, plan-based for attachments)"},"amxv.cloud.dotTitle":{zh:"云端「{name}」",en:"Cloud “{name}”"},"amxv.cloud.skippedCount":{zh:"{n} 项跳过",en:"{n} skipped"},"amxv.cloud.notEnabled":{zh:"尚未开启云同步",en:"Cloud sync is not on yet"},"amxv.cloud.missing":{zh:"{path}(已不存在)",en:"{path} (no longer exists)"},"amxv.cloud.disableTip":{zh:"关闭云同步(云端副本保留)",en:"Turn off cloud sync (the cloud copy is kept)"},"amxv.empty":{zh:"空",en:"Empty"},"amxv.syncNotArrived":{zh:"同步内容尚未到达",en:"Synced content has not arrived yet"},"amxv.vault.thisDevice":{zh:"本机",en:"This device"},"amxv.vault.devicesTitle":{zh:"在同步这个库的设备:{list}",en:"Devices syncing this vault: {list}"},"amxv.vault.deviceSince":{zh:"{name}({since} 起)",en:"{name} (since {since})"},"amxv.menu.vaultSectionOn":{zh:"设为同步库分区",en:"Show as synced vault"},"amxv.menu.vaultSectionOff":{zh:"不再作为同步库分区",en:"Stop showing as synced vault"},"amxv.vaultSection.failed":{zh:"没能更新同步库分区:{e}",en:"Could not update the synced vault section: {e}"},"amxv.searchNotes":{zh:"搜索笔记",en:"Search notes"},"amxv.phone.tabs":{zh:"笔记分类",en:"Note lists"},"amxv.phone.tab.recent":{zh:"最近",en:"Recent"},"amxv.phone.tab.tree":{zh:"文件夹",en:"Folders"},"amxv.phone.tab.boards":{zh:"白板",en:"Whiteboards"},"amxv.phone.noRecent":{zh:"还没有最近打开的笔记",en:"No recently opened notes yet"},"amxv.phone.noBoards":{zh:"还没有白板",en:"No whiteboards yet"},"amxv.phone.new":{zh:"新建",en:"New"},"amxv.phone.hint":{zh:"向左滑动一行:收藏、重命名、删除。长按右下角的按钮:新建白板、文件夹等。",en:"Swipe a row left to star, rename or delete it. Press and hold the button at the bottom right for a new whiteboard, folder and more."},"amxv.noMatches":{zh:"没有匹配的笔记",en:"No matching notes"},"amxv.openVaultHint":{zh:"打开一个智库文件夹开始。",en:"Open a vault folder to get started."},"amxv.cloudVault":{zh:"云端智库",en:"Cloud vault"},"amxv.cloudVaultTip":{zh:"云端智库(切换 / 成员 / 分享)",en:"Cloud vault (switch / members / sharing)"},"amxv.vaultNamed":{zh:"智库:{name}",en:"Vault: {name}"},"amxv.openVault":{zh:"打开智库",en:"Open vault"},"amxv.folder.actions":{zh:"文件夹操作",en:"Folder actions"},"amxv.folder.newNoteHere":{zh:"在此文件夹新建笔记",en:"New note in this folder"},"amxv.renameFolder":{zh:"重命名文件夹",en:"Rename folder"},"amxv.menu.openInNewTab":{zh:"在新标签页打开",en:"Open in new tab"},"amxv.menu.openNInNewTabs":{zh:"在新标签页打开 {n} 项",en:"Open {n} items in new tabs"},"amxv.menu.deleteN":{zh:"删除 {n} 项",en:"Delete {n} items"},"amxv.menu.rename":{zh:"重命名",en:"Rename"},"amxv.menu.star":{zh:"收藏",en:"Star"},"amxv.menu.unstar":{zh:"取消收藏",en:"Unstar"},"amxv.menu.cloudSyncOff":{zh:"关闭云同步",en:"Turn off cloud sync"},"amxv.menu.cloudSyncOn":{zh:"开启云同步",en:"Turn on cloud sync"},"amxv.menu.reveal":{zh:"在文件管理器中显示",en:"Show in file manager"},"amxv.menu.delete":{zh:"删除",en:"Delete"},"amxv.menu.open":{zh:"打开",en:"Open"},"amxv.menu.openWithSystem":{zh:"用系统程序打开",en:"Open with the system app"},"amxv.menu.openBuiltinReader":{zh:"用内置阅读器打开",en:"Open with the built-in reader"},"amxv.menu.openDrawing":{zh:"打开白板",en:"Open whiteboard"},"amxv.menu.newSubfolder":{zh:"新建子文件夹",en:"New subfolder"},"amxv.menu.publishFolder":{zh:"发布此文件夹(公开链接)",en:"Publish this folder (public link)"},"amxv.menu.exportPdf":{zh:"导出为 PDF",en:"Export as PDF"},"amxv.menu.exportCanvas":{zh:"导出为 JSON Canvas",en:"Export as JSON Canvas"},"amxv.menu.deleteNote":{zh:"删除笔记",en:"Delete note"},"amxv.publish.done":{zh:"文件夹已发布,公开链接已复制(任何人可只读浏览)",en:"Folder published — the public link is copied (anyone can read it)"},"amxv.publish.quota":{zh:"发布页数已达套餐上限",en:"You have reached your plan limit for published pages"},"amxv.publish.ownerOnly":{zh:"只有库所有者能发布",en:"Only the vault owner can publish"},"amxv.publish.notUploaded":{zh:"云端尚未找到此文件夹,请等待同步完成后重试",en:"This folder is not in the cloud yet. Wait for sync to finish and try again."},"amxv.publish.failed":{zh:"发布失败",en:"Publishing failed"},"amxv.mbar.insertBlock":{zh:"插入块",en:"Insert block"},"amxv.uploadToPage":{zh:"上传文件到本页",en:"Upload files to this note"},"amxv.mbar.toDocument":{zh:"切换到文档",en:"Switch to document"},"amxv.mbar.toCanvas":{zh:"切换到画布",en:"Switch to canvas"},"amxv.mbar.undo":{zh:"撤销",en:"Undo"},"amxv.mbar.redo":{zh:"重做",en:"Redo"},"amxv.mbar.outdent":{zh:"减少缩进",en:"Outdent"},"amxv.mbar.indent":{zh:"增加缩进",en:"Indent"},"amxv.moreActions":{zh:"更多操作",en:"More actions"},"amxv.mbar.hideKeyboard":{zh:"收起键盘",en:"Hide keyboard"},"amxv.title.changeIcon":{zh:"更换/移除页面图标",en:"Change or remove the page icon"},"amxv.title.addIcon":{zh:"添加图标",en:"Add icon"},"amxv.title.addCover":{zh:"添加封面",en:"Add cover"},"amxv.pdf.exported":{zh:"已导出 PDF:{path}",en:"PDF exported: {path}"},"amxv.pdf.exportFailed":{zh:"导出 PDF 失败:{e}",en:"PDF export failed: {e}"},"amxv.pin":{zh:"置顶",en:"Pin"},"amxv.unpin":{zh:"取消置顶",en:"Unpin"},"amxv.shareOrPublish":{zh:"共享 / 发布",en:"Share / publish"},"amxv.toVisualLong":{zh:"切换到可视编辑(所见即所得)",en:"Switch to visual editing (WYSIWYG)"},"amxv.toVisual":{zh:"切换到可视编辑",en:"Switch to visual editing"},"amxv.toSource":{zh:"切换到源码 Markdown",en:"Switch to Markdown source"},"amxv.retry":{zh:"重试",en:"Retry"},"amxv.welcome.loadFailed":{zh:"📓 笔记加载失败",en:"📓 Could not load the note"},"amxv.welcome.title":{zh:"📓 笔记",en:"📓 Notes"},"amxv.welcome.pickNote":{zh:"从左栏选一篇笔记开始,或新建一篇。",en:"Pick a note in the sidebar to get started, or create a new one."},"amxv.welcome.noVault":{zh:"把任意文件夹选作你的智库就能开写 —— 所见即所得,像 Obsidian 一样用双链把想法连起来。",en:"Choose any folder as your vault and start writing — WYSIWYG editing, with Obsidian-style wikilinks to connect your ideas."},"amxv.welcome.tutorial":{zh:"使用教程",en:"Tutorial"},"amxv.welcome.manual":{zh:"使用手册",en:"User manual"},"amxv.welcome.openVaultFolder":{zh:"打开智库文件夹",en:"Open a vault folder"},"amxv.welcome.tip1":{zh:"引用其它笔记,自动生成反向链接",en:"links to another note, and backlinks are generated automatically"},"amxv.welcome.tip2":{zh:"拖入图片 / 文件直接插入;支持多维表块、LaTeX、代码高亮",en:"Drop in images or files to insert them; database blocks, LaTeX and syntax highlighting are all supported"},"amxv.welcome.tip3":{zh:"顶栏切「可视 / 源码」,右上角 ⋮ 可导出 PDF",en:"Toggle visual / source mode in the top bar; export to PDF from the ⋮ menu"},"amxv.floatingToc":{zh:"笔记目录",en:"Note table of contents"},"amxv.outline.empty":{zh:"没有标题",en:"No headings"},"amxv.outline.noNote":{zh:"未指定笔记",en:"No note specified"},"amxv.backlinks.noNote":{zh:"未打开笔记",en:"No note open"},"amxv.backlinks.empty":{zh:"还没有其它笔记链接到这里",en:"No other notes link here yet"}});const Oe=()=>K.getState(),Ne=n=>n.split(/[\\/]/).pop().replace(/\.md$/,""),es=n=>n.split("/").pop()||n,Xt=n=>{const e=[];let t="";for(const i of n.split(/[\\/]/).filter(Boolean))t=t?`${t}/${i}`:i,e.push(t);return e};function md(n,e){const t=Xe.getState();for(const i of t.api?.panels??[]){const s=i.params??{};s.__type==="amadeus-editor"&&s.notePath===n&&t.navigateLeaf(i.id,"amadeus-editor",{...s,notePath:e})}}async function yr(n,e){try{await Nc();const t=await me.renamePageFile(n,e);if(t!==n){pn(n,"file",t),jc(n,t,"file"),await Oc(n,t),md(n,t);const i=Oe();i.activePage===t&&i.loadPage(t)}}catch(t){window.alert(Q("amxv.renameFailed",{e:t instanceof Error?t.message:String(t)}))}await Oe().refreshStructure()}const Uf=()=>!!me.trashEntry;function Yf(n){const e=wi(n),t=[...Oe().pages,...Oe().files].filter(i=>i.startsWith(`${e}/`)).length;return t>0?Q("amxv.confirm.deleteNoteWithChildren",{name:Ne(n),n:t}):Q("amxv.confirm.deleteNote",{name:Ne(n)})}async function Dn(n,e=Oe){if(!as("note",n))return;const t=await me.exclusiveAssets?.(n).catch(()=>[])??[];let i=t.length>0?uu():!1;if(t.length>0&&i===null){const s=await pu(Ne(n),t);if(s===null)return;i=s==="with"}Ps.getState().remove(`note:${n}`),await e().deletePage(n),i&&(await Tc(t),await e().refreshStructure())}function as(n,e){return Uf()?!0:n==="note"?window.confirm(Yf(e)):n==="file"?window.confirm(Q("amxv.confirm.deleteFile",{name:e.split(/[\\/]/).pop()})):window.confirm(Q("amxv.confirm.deleteFolder",{name:e.split(/[\\/]/).pop()}))}const vd=mi(n=>({locate:null,requestLocate:e=>n(t=>({locate:{path:e,n:(t.locate?.n??0)+1}}))}));K.subscribe((n,e)=>{const t=n.activePage;if(!t||t===e.activePage||Hi(t)&&ih()!=="mini")return;const i=xs();queueMicrotask(()=>{const s=Xe.getState().api,o=s?bs(s):null,r=o&&(o.params??{}).__type==="amadeus-editor"&&o.id===i?o.id:i;Fr(r,`amadeus:${t}`,()=>{const l=Xe.getState(),d=r?l.leafById(r):null;d&&(d.type!=="amadeus-editor"&&l.navigateLeaf(r,"amadeus-editor",{notePath:t}),ko(r).getState().loadPage(t))})}),Ps.getState().record({key:`note:${t}`,kind:"note",id:t,title:Ne(t)})});function Jo({path:n,hideLoneLeaf:e}={}){const t=K(u=>u.activePage),i=vd(u=>u.requestLocate),s=n??t;if(!s||e&&!s.includes("/"))return null;const o=s.replace(/(\.dashboard)?\.md$/i,"").split("/"),r=tl(s),l=r?Mi(s,r.extensions):o[o.length-1],d=o.slice(0,-1).map((u,m)=>({seg:u,target:o.slice(0,m+1).join("/")})),c=d.length>3?[...d.slice(0,2),{seg:"…",target:null},d[d.length-1]]:d,h=c.length;return a.jsxs("div",{className:"amx-crumbs",children:[h>0&&a.jsx("span",{className:"amx-crumbs-parents",children:a.jsx("span",{className:"amx-crumbs-parents-in",children:c.map((u,m)=>a.jsxs("span",{className:"amx-crumb-seg",style:{"--d":`${(h-1-m)*25}ms`},children:[u.target?a.jsx("button",{className:"amx-crumb",title:u.target,onClick:()=>i(u.target),children:u.seg.replace(/\.fd$/i,"")}):a.jsx("span",{className:"amx-crumb amx-crumb-ellipsis",title:s,children:"…"}),a.jsx("span",{className:"amx-crumb-sep",children:"/"})]},`${u.target??"gap"}-${m}`))})}),a.jsx("button",{className:"amx-crumb amx-crumb-leaf",title:s,onClick:()=>i(s),children:l})]})}const ci=n=>/\.md$/i.test(n),xi=n=>/\.db$/i.test(n),Dr=n=>/\.pdf$/i.test(n),ts=n=>/\.(png|jpe?g|gif|webp|svg|avif|bmp|ico)$/i.test(n),Cr=n=>(n.split(/[\\/]/).pop()||n).replace(/\.db$/i,"");function Xf(){const{t:n}=Ce(),[e,t]=_.useState(null),[i,s]=_.useState(!1),o=!!me.listTrash,r=()=>{me.listTrash?.().then(t).catch(()=>{})};if(_.useEffect(()=>{o&&r()},[o]),_.useEffect(()=>{if(o)return me.onStructureChange(()=>r())},[o]),!o)return null;const l=e?.length??0,d=c=>{const h=c.replace(/\\/g,"/").lastIndexOf("/");return h===-1?"/":c.slice(0,h)};return a.jsxs(a.Fragment,{children:[a.jsxs("button",{className:"t2s-special amx-trash-entry",onClick:()=>{r(),s(!0)},title:n("amxv.trash.entryTip"),children:[a.jsx("span",{className:"t2s-special-ic",children:a.jsx(gt,{})}),a.jsxs("span",{className:"t2s-special-title",children:[n("amxv.trash.title"),l>0?` (${l})`:""]})]}),i&&a.jsx("div",{className:"amx-trash-wrap",onMouseDown:()=>s(!1),children:a.jsxs("div",{className:"amx-trash-pop",onMouseDown:c=>c.stopPropagation(),children:[a.jsxs("div",{className:"amx-trash-head",children:[a.jsx("span",{children:n("amxv.trash.title")}),l>0&&a.jsx("button",{className:"amx-trash-clear",onClick:()=>{window.confirm(n("amxv.trash.confirmEmpty"))&&me.emptyTrash?.().then(r)},children:n("amxv.trash.emptyAction")})]}),a.jsxs("div",{className:"amx-trash-list",children:[(e??[]).map(c=>a.jsxs("div",{className:"amx-trash-row",children:[a.jsx("span",{className:"amx-trash-ic",children:c.dir?a.jsx(Io,{}):a.jsx(Yi,{})}),a.jsxs("span",{className:"amx-trash-name",title:n("amxv.trash.origin",{path:c.original}),children:[c.name,a.jsx("span",{className:"amx-trash-orig",children:d(c.original)})]}),a.jsx("button",{className:"amx-trash-act",onClick:()=>{me.restoreTrash?.(c.name).then(()=>{r(),Oe().refreshStructure()})},children:n("amxv.trash.restore")}),a.jsx("button",{className:"amx-trash-act amx-trash-danger",onClick:()=>{window.confirm(n("amxv.trash.confirmDelete",{name:c.name}))&&me.deleteTrashEntry?.(c.name).then(r)},"aria-label":"delete forever",children:n("amxv.menu.delete")})]},c.name)),l===0&&a.jsx("div",{className:"t2s-hint",children:n("amxv.trash.emptyHint")})]})]})})]})}function Kf({row:n,pages:e}){const{t}=Ce(),i=Be(m=>m.starred),s=Be(m=>m.collections),[o,r]=gs("starred"),[l,d]=gs("collections"),c=new Set(e),h=i.filter(m=>c.has(m));if(!h.length&&!s.length)return null;const u=(m,g,p,f)=>g.length>0&&a.jsxs("div",{className:"amx-prefs-group",children:[a.jsx("button",{className:"t2s-group-toggle amx-sec-grab",onClick:f,children:a.jsxs("span",{className:"t2s-group-name amx-sec-head",children:[a.jsx("span",{className:"t2s-group-label",children:m}),a.jsx("span",{className:`t2s-chev${p?" open":""}`,children:a.jsx(Fi,{size:12})}),a.jsx("span",{className:"t2s-count",children:g.length})]})}),p&&a.jsx("div",{className:"t2s-group-sessions",children:g.map(w=>n(w))})]});return a.jsxs(a.Fragment,{children:[u(t("amxv.sec.starred"),h,o,r),s.length>0&&a.jsxs("div",{className:"amx-prefs-group",children:[a.jsx("button",{className:"t2s-group-toggle amx-sec-grab",onClick:d,children:a.jsxs("span",{className:"t2s-group-name amx-sec-head",children:[a.jsx("span",{className:"t2s-group-label",children:t("amxv.sec.collections")}),a.jsx("span",{className:`t2s-chev${l?" open":""}`,children:a.jsx(Fi,{size:12})}),a.jsx("span",{className:"t2s-count",children:s.length})]})}),l&&a.jsx("div",{className:"t2s-group-sessions",children:s.map(m=>a.jsxs("div",{className:"t2s-srow amx-coll-row",role:"button",tabIndex:0,title:t("amxv.sec.searchTip",{q:m.query}),onClick:()=>{bh(),od.getState().request(m.query)},children:[a.jsx("span",{className:"amx-coll-ic",children:a.jsx(To,{})}),a.jsx("span",{className:"amx-coll-name",children:m.name}),a.jsx("button",{className:"amx-coll-del",title:t("amxv.sec.removeCollection"),"aria-label":"remove collection",onClick:g=>{g.stopPropagation(),Be.getState().removeCollection(m.name)},children:"✕"})]},m.name))})]})]})}function qf(){const{t:n}=Ce(),e=window.amadeusCollab,[t,i]=_.useState([]),[s,o]=_.useState("");return _.useEffect(()=>{e&&(e.sharedWithMe().then(i).catch(()=>{}),e.activeVaultId().then(o).catch(()=>{}))},[e]),!e||t.length===0?null:a.jsxs("div",{className:"t2s-special-group",style:{marginTop:6},children:[a.jsx("div",{className:"t2s-hint amx-sec-grab",style:{padding:"2px 10px 2px",fontSize:"var(--ui-font-caption, 11px)"},children:n("amxv.sec.sharedWithMe")}),t.map(r=>a.jsxs("button",{className:"t2s-special",title:`${r.ownerName??""} · ${r.role==="viewer"?n("amxv.role.viewer"):n("amxv.role.editor")}`,onClick:l=>{r.localPath?qe(r.localPath,ft(l)):r.vaultId===s?qe(r.path,ft(l)):e.switchVault(r.vaultId)},children:[a.jsx("span",{className:"t2s-special-ic",children:a.jsx(cs,{})}),a.jsx("span",{className:"t2s-special-title",children:r.title})]},`${r.vaultId}:${r.path}`))]})}function Jf(n,e){if(!n.length)return;const t=s=>s.id===e?Q("amxv.vault.thisDevice"):s.name,i=n.map(s=>s.since?Q("amxv.vault.deviceSince",{name:t(s),since:s.since}):t(s)).join(", ");return a.jsxs("span",{className:"amx-sec-device",title:Q("amxv.vault.devicesTitle",{list:i}),children:[a.jsx(ch,{size:11}),a.jsx("span",{className:"amx-sec-device-name",children:t(n[0])}),n.length>1&&a.jsxs("span",{children:["+",n.length-1]})]})}function _s({id:n,defaultOpen:e,label:t,count:i,extra:s,dropProps:o,dropActive:r,onContextMenu:l,children:d}){const[c,h]=gs(n,e);return a.jsxs("div",{className:`amx-prefs-group${r?" amx-drop-into":""}`,...o,children:[a.jsx("button",{className:"t2s-group-toggle amx-sec-grab",onClick:h,onContextMenu:l,children:a.jsxs("span",{className:"t2s-group-name amx-sec-head",children:[a.jsx("span",{className:"t2s-group-label",children:t}),a.jsx("span",{className:`t2s-chev${c?" open":""}`,children:a.jsx(Fi,{size:12})}),i!==void 0&&a.jsx("span",{className:"t2s-count",children:i}),s]})}),c&&a.jsx("div",{className:"t2s-group-sessions",children:d})]})}function Zf({row:n,dragPath:e}){const{t}=Ce(),i=Be(h=>h.pins),s=K(h=>h.pages),o=K(h=>h.vaultRoot),[r,l]=_.useState(!1),d=_.useMemo(()=>s.filter(h=>i.includes(h)),[s,i]);if(!o||!d.length)return null;const c=!!e&&ci(e)&&!i.includes(e);return a.jsx(_s,{id:"pinned",label:t("amxv.sec.pinned"),count:d.length,dropActive:r,dropProps:{onDragOver:h=>{c&&(h.preventDefault(),h.stopPropagation(),h.dataTransfer.dropEffect="move",r||l(!0))},onDragLeave:()=>l(!1),onDrop:h=>{c&&(h.preventDefault(),h.stopPropagation(),l(!1),Be.getState().togglePin(e))}},children:d.map(h=>n(h))})}const Qf=n=>n==="TOO_LARGE"?Q("amxv.skip.tooLarge"):n==="ASSET_404"?Q("amxv.skip.assetMissing"):n,gd=n=>a.jsx("div",{className:"t2s-hint amx-sec-hint amx-cs-warn",title:n.map(e=>`${e.path} — ${Qf(e.reason)}`).join(`
16
+ `),children:Q("amxv.skip.summary",{n:n.length,extra:n.some(e=>e.reason==="TOO_LARGE")?Q("amxv.skip.tooLargeNote"):""})});function e_(){Ce();const[n,e]=_.useState(null);return _.useEffect(()=>{const t=window.amadeusSync;if(t)return t.get().then(e).catch(()=>{}),t.onStatus(i=>{i.binding||e(i)})},[]),!n?.enabled||!n.skipped.length?null:gd(n.skipped)}function t_({dragPath:n}){const{t:e}=Ce(),t=K(k=>k.vaultRoot),i=K(k=>k.pages),s=K(k=>k.files),o=K(k=>k.folders),r=We(k=>k.vaults),l=We(k=>t?k.status[t]:void 0),[d,c]=_.useState(!1),h=r.find(k=>k.vaultRoot===t);if(!window.amadeusSync?.entrySyncEnable||!t)return null;const u=h?.entries??[];if(!u.length&&!l?.skipped.length)return null;const m=k=>k.replace(/\\/g,"/").normalize("NFC"),g=new Set(i.map(m)),p=new Set(s.map(m)),f=new Set(o.map(m)),w=k=>k.kind==="folder"?f.has(k.path):k.kind==="page"?g.has(k.path):p.has(k.path),C=l?.state==="error"||l?.state==="auth-required"?"err":l?.state==="offline"?"off":"ok",b=h?`${e("amxv.cloud.dotTitle",{name:h.cloudName})}${l?` · ${l.state}${l.skipped.length?` · ${e("amxv.cloud.skippedCount",{n:l.skipped.length})}`:""}`:""}`:e("amxv.cloud.notEnabled"),D=!!n&&!Tn(t,n);return a.jsxs(_s,{id:"cloudsync",label:e("amxv.sec.cloudSync"),count:u.length,extra:h?a.jsx("span",{className:`amx-sync-dot ${C}`,title:b}):void 0,dropActive:d,dropProps:{onDragOver:k=>{D&&(k.preventDefault(),k.stopPropagation(),k.dataTransfer.dropEffect="move",d||c(!0))},onDragLeave:()=>c(!1),onDrop:k=>{D&&(k.preventDefault(),k.stopPropagation(),c(!1),Di(n,ci(n)?"page":"asset"))}},children:[!u.length&&a.jsx("div",{className:"t2s-hint amx-sec-hint",children:e("amxv.cloudsync.hint")}),!!l?.skipped.length&&gd(l.skipped),u.map(k=>{const P=w(k);return a.jsxs("div",{className:`t2s-srow amx-cs-row${P?"":" amx-cs-ghost"}`,role:"button",tabIndex:0,title:P?k.path:e("amxv.cloud.missing",{path:k.path}),onClick:y=>{P&&(k.kind==="page"?qe(k.path,ft(y)):k.kind==="asset"&&xi(k.path)&&ss(k.path,ft(y)))},children:[a.jsx("span",{className:"amx-cs-ic",children:k.kind==="folder"?a.jsx(Io,{}):k.kind==="page"?a.jsx(Yi,{}):a.jsx(Sn,{})}),a.jsx("span",{className:"t2s-srow-title",children:k.kind==="page"?Ne(k.path):k.path.split(/[\\/]/).pop()}),a.jsx("button",{className:"amx-coll-del",title:e("amxv.cloud.disableTip"),onClick:y=>{y.stopPropagation(),window.amadeusSync?.entrySyncDisable?.(k.path)},children:"✕"})]},k.path)})]})}const i_=[],Sr=[];function n_(){const{t:n}=Ce(),e=K(v=>v.pages),t=K(v=>v.folders),i=K(v=>v.files),s=K(v=>v.icons),o=K(v=>v.pendingPage??v.activePage??v.activeNotePath),r=K(v=>v.vaultRoot),l=K(v=>v.vaultSide),d=K(v=>v.vaultLoading),c=!!window.amadeusCloudVaults||l==="cloud",[h,u]=_.useState(""),[m,g]=_.useState(new Set),[p,f]=_.useState(!1),[w,C]=_.useState(null),[b,D]=_.useState(null),k=_.useRef(null),P=sh(k),y=wc(),[T,S]=_.useState(()=>{try{const v=localStorage.getItem("forsion_notes_phone_tab");return v==="recent"||v==="tree"||v==="boards"?v:null}catch{return null}}),N=Ps(v=>y?v.items:i_),O=Be(v=>y?v.recents:Sr),$=Be(v=>y?v.starred:Sr),F=_.useMemo(()=>{const v=new Set([...e,...i]),G=new Set,E=[];for(const R of N)(R.kind==="note"||R.kind==="file")&&v.has(R.id)&&!G.has(R.id)&&(G.add(R.id),E.push({path:R.id,at:R.ts}));for(const R of O)v.has(R)&&!G.has(R)&&(G.add(R),E.push({path:R,at:0}));return E},[N,O,e,i]),q=_.useMemo(()=>[...new Set([...i,...e])].filter(_i).sort((v,G)=>Ne(v).localeCompare(Ne(G))),[e,i]),re=T??(F.length?"recent":"tree"),V=v=>{S(v);try{localStorage.setItem("forsion_notes_phone_tab",v)}catch{}},B=y&&!!r&&re!=="tree",te=()=>Zs.getState().openPalette();Pu(k,y?te:void 0);const we=bc(v=>v.items.find(G=>G.id==="rb-units-mobile"));xc(y?{where:"list",search:{label:n("amxv.searchNotes"),run:te},...r?{title:{sub:l==="cloud"?n("amxv.cloudVault"):Ne(r),run:we?.onClick}}:{}}:null);const[xe,j]=_.useState(()=>{try{const v=JSON.parse(localStorage.getItem("amx.sec.order")||"[]");return Array.isArray(v)?v.filter(G=>typeof G=="string"):[]}catch{return[]}}),[de,ce]=_.useState(null),[be,Se]=_.useState(null),[st,L]=_.useState(null);_.useEffect(()=>{if(!de)return;const v=()=>ce(null);return window.addEventListener("pointerup",v),window.addEventListener("pointercancel",v),()=>{window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",v)}},[de]);const J=["pinned","cloudsync","shared","prefs","tree"],oe=new Map(xe.map((v,G)=>[v,G])),ae=xe.length?[...J].sort((v,G)=>(oe.get(v)??xe.length)-(oe.get(G)??xe.length)):J,Pe=(v,G,E)=>{const R=ae.filter(Ge=>Ge!==v),_e=R.indexOf(G);R.splice(_e<0?R.length:E?_e+1:_e,0,v),j(R);try{localStorage.setItem("amx.sec.order",JSON.stringify(R))}catch{}},ge=(v,G)=>a.jsx("div",{className:`amx-sec-wrap${st===v&&be&&be!==v?" amx-sec-over":""}`,draggable:de===v,onPointerDown:E=>{E.pointerType!=="mouse"||E.button!==0||E.target.closest(".amx-sec-grab")&&ce(v)},onDragStart:E=>{if(de===v){E.stopPropagation(),E.dataTransfer.effectAllowed="move";try{E.dataTransfer.setData("application/x-amx-section",v)}catch{}Se(v)}},onDragEnd:()=>{Se(null),L(null),ce(null)},onDragOver:E=>{!be||be===v||(E.preventDefault(),E.stopPropagation(),E.dataTransfer.dropEffect="move",st!==v&&L(v))},onDragLeave:E=>{st===v&&!E.currentTarget.contains(E.relatedTarget)&&L(null)},onDrop:E=>{if(!be||be===v)return;E.preventDefault(),E.stopPropagation();const R=E.currentTarget.getBoundingClientRect();Pe(be,v,E.clientY>R.top+R.height/2),Se(null),L(null)},children:G},v),[H,ie]=_.useState(null),[xt,yt]=gs("vault",!0),[et,Ht]=_.useState(null),[Dt,oi]=_.useState(""),Ue=_.useRef(null),Ze=vd(v=>v.locate),[dt,Nt]=_.useState(null),tt=_.useRef(null);_.useEffect(()=>{oh()},[]),_.useEffect(()=>{sd(),We.getState().refresh()},[r,e,t]);const fe=We(v=>v.vaults),Bt=We(v=>v.mirrorVaults),it=We(v=>v.mirrorVaultDevices),Qe=We(v=>v.deviceId),ct=We(v=>v.markSupported)&&!!window.amadeusSync?.entrySyncMark,Ct=(v,G)=>{window.amadeusSync.entrySyncMark(v,G).then(E=>{if(E?.error)throw new Error(E.error)}).catch(E=>Ke.getState().toast(n("amxv.vaultSection.failed",{e:E instanceof Error?E.message:String(E)}),!0))};_.useEffect(()=>{et&&Ue.current?.select()},[et]),_.useEffect(()=>{if(!H)return;const v=()=>ie(null);return window.addEventListener("click",v),window.addEventListener("contextmenu",v),()=>{window.removeEventListener("click",v),window.removeEventListener("contextmenu",v)}},[H]),_.useEffect(()=>{if(!Ze)return;const v=t.includes(Ze.path)?Ze.path:qt(Ze.path);v&&g(E=>new Set([...E,...Xt(v)])),Nt(Ze.path);const G=setTimeout(()=>Nt(null),1200);return()=>clearTimeout(G)},[Ze?.n]),_.useEffect(()=>{dt&&tt.current?.scrollIntoView({block:"nearest"})},[dt]);const ht=h.trim().toLowerCase(),St=_.useMemo(()=>bu(xu([...e,...i],t)),[e,i,t]),Ut=_.useMemo(()=>ht?[...e,...i].filter(v=>Ne(v).toLowerCase().includes(ht)):[],[ht,e,i]),[A,se]=_.useState([]),[le,he]=_.useState({});_.useEffect(()=>{const v=window;if(!v.amadeusCloudVaults||window.amadeusSync)return;let G=!0;return v.amadeusCloudVaults().then(E=>{G&&(se(E),v.amadeusCloudVaultDevices?.(E).then(R=>{G&&he(R)}).catch(()=>{}))}).catch(()=>{}),()=>{G=!1}},[e,t]);const je=_.useMemo(()=>{const v=!!window.amadeusSync&&l==="cloud",G=!window.amadeusSync&&!!window.amadeusCloudVaults;if(!v&&!G)return null;const E=new Set(v?fe.filter(Y=>Y.entries.length).map(Y=>Y.cloudName):[]),R=v?[...new Set([...E,...Bt])].sort():A,_e=v?it:le,Ge=new Map(St.children.filter(Y=>Y.kind==="folder").map(Y=>[Y.path,Y])),at=R.map(Y=>{const Ie=Object.prototype.hasOwnProperty.call(_e,Y)?_e[Y]:void 0,tn=Array.isArray(Ie)?Ie:[],nn=E.has(Y)&&Qe&&!tn.some(sn=>sn.id===Qe)?[{id:Qe,name:""}]:[];return{name:Y,node:Ge.get(Y)??null,devices:[...nn,...tn],mine:E.has(Y)}}),ve=new Set(R),rt=St.children.filter(Y=>!(Y.kind==="folder"&&ve.has(Y.path)));return{vaultSecs:at,rest:rt,mine:E}},[St,fe,Bt,it,Qe,l,A,le]),ot=Xe(v=>v.mainTabs),ai=_.useMemo(()=>{const v=Xe.getState().api,G=v?bs(v):null,E=G?{id:G.id,type:String((G.params??{}).__type??"")}:ot.find(Ge=>Ge.active),R=E&&ah[E.type],_e=R?Xe.getState().leafById(E.id)?.params?.[R]:null;return typeof _e=="string"?_e:null},[ot]),He=Js(v=>v.fileTypes),In=Js(v=>v.fileCreators),Ji=(v,G,E)=>{ie(null),v&&g(R=>new Set([...R,...Xt(v)])),Promise.resolve().then(()=>E(v)).catch(R=>{console.error("[plugin] file creator failed",R),Ke.getState().toast(Q("amxv.fileCreatorFailed",{label:G,e:R instanceof Error?R.message:String(R)}),!0)})},An=v=>g(G=>{const E=new Set(G);return E.has(v)?E.delete(v):E.add(v),E}),ri=v=>{const G=(w?P.batch(w):[]).filter(R=>{if(qt(R)===v)return!1;if(Rn(R)){const _e=wi(R);if(v===_e||v.startsWith(`${_e}/`))return!1}return!0});C(null),D(null);const E=ko(xs());(async()=>{for(const R of G)await E.getState().movePage(R,v)})().catch(R=>E.setState({error:String(R)}))},Pi=v=>Array.from(v.dataTransfer?.types??[]).includes("Files"),ki=v=>Wf(Array.from(v.dataTransfer?.types??[]),!!r&&!!window.tangu?.copyHostFiles&&!(window.amadeusSync&&l==="cloud"),{paths:Ns,ref:sl}),Nn=v=>{if(!ki(v))return[];try{const G=JSON.parse(v.dataTransfer?.getData(Ns)||"null");return Array.isArray(G)?G:[]}catch{return[]}},zi=(v,G)=>{const E=Nn(v);return E.length?(v.preventDefault(),v.stopPropagation(),D(null),window.tangu.copyHostFiles(E,G?`${r}/${G}`:r).catch(R=>Lr.getState().notify(Q("amxv.copyFailed",{e:R instanceof Error?R.message:String(R)}))).finally(()=>{Oe().refreshStructure()}),!0):!1},ks=(v,G)=>{const E=Nn(v);return E.length?(v.preventDefault(),v.stopPropagation(),D(null),qe(G).then(()=>ef(E)).then(R=>{R.length&&Zi(R,G)}),!0):!1},Ti=(v,G)=>!Pi(v)&&!ki(v)?!1:(v.preventDefault(),v.stopPropagation(),v.dataTransfer&&(v.dataTransfer.dropEffect="copy"),b!==G&&D(G),!0),vi=(v,G)=>{if(zi(v,G))return!0;const E=Array.from(v.dataTransfer?.files??[]);return E.length?(v.preventDefault(),v.stopPropagation(),D(null),lr(E,G),!0):!1},gi=(v,G)=>Ff(v,{mergedFd:G,pluginFile:!!Kt(He,v)}),Zi=(v,G)=>{Ys(G,v)||vs(v,G)},jn=(v,G,E)=>Ti(v,Bs(gi(G,E))),zs=(v,G,E)=>{const R=gi(G,E);if("page"in R?ks(v,R.page):zi(v,R.folder))return!0;const _e=Array.from(v.dataTransfer?.files??[]);if(!_e.length)return!1;v.preventDefault(),v.stopPropagation(),D(null);const Ge=gi(G,E);return"page"in Ge?qe(Ge.page).then(()=>Zi(_e,Ge.page)):lr(_e,Ge.folder),!0},Ei=(v,G)=>!Pi(v)&&!ki(v)?!1:(v.target.closest(G)||Ti(v,""),!0),On=(v,G)=>!Pi(v)&&!ki(v)?!1:(v.target.closest(G)||vi(v,""),!0),x=()=>{const v=et;Ht(null);const G=Dt.trim();if(!v||!G)return;const E=Kt(He,v);if(E){const R=E.extensions.find(Ge=>v.toLowerCase().endsWith(Ge.toLowerCase()));if(!R||!/\.md$/i.test(R))return;const _e=yu(G,R);_e!==Mi(v,E.extensions)+R.replace(/\.md$/i,"")&&yr(v,_e);return}ci(v)?G!==Ne(v)&&yr(v,G):xi(v)&&G.replace(/\.db$/i,"")!==Cr(v)&&wh(v,G).catch(R=>window.alert(Q("amxv.renameFailed",{e:R instanceof Error?R.message:String(R)})))},I=v=>{const G=Kt(He,v);oi(G?Mi(v,G.extensions):xi(v)?Cr(v):Ne(v)),Ht(v),ie(null)},M=async v=>{const G=(await Ot(v?Q("amadeus.new.folderIn",{folder:es(v)}):Q("amadeus.new.folder"),Q("amadeus.default.folder")))?.trim();G&&(Oe().createFolder(v,G),g(E=>new Set([...E,...Xt(v?`${v}/${G}`:G)]))),ie(null)},Z=async v=>{ie(null);const G=(await Ot(v?Q("amadeus.new.databaseIn",{folder:es(v)}):Q("amadeus.new.database"),Q("amadeus.default.database")))?.trim().replace(/[\\/]/g,"");if(!G)return;const E=v?`${v}/${G}.db`:`${G}.db`;if(Oe().files.some(R=>R.replace(/\\/g,"/")===E)){window.alert(Q("amadeus.exists",{name:`${G}.db`}));return}(async()=>{const R=new TextEncoder().encode(Nd(jd(G)));await me.saveAttachment("",`${G}.db`,R,{mode:"vault",folder:v}),Ec("base.create"),Gc("base.create",{f:E}),await Oe().refreshStructure(),v&&g(_e=>new Set([..._e,...Xt(v)])),ss(E)})().catch(R=>window.alert(Q("amxv.newBaseFailed",{e:R instanceof Error?R.message:String(R)})))},pe=v=>{ie(null),ph(v).then(G=>{G&&v&&g(E=>new Set([...E,...Xt(v)]))})},ue=v=>{ie(null),vh(v).then(G=>{G&&v&&g(E=>new Set([...E,...Xt(v)]))})},ye=()=>[{id:"new-note",label:n("amadeus.new.note"),icon:a.jsx(ji,{size:13}),run:()=>{Oe().createPage(),ie(null)}},{id:"new-folder",label:n("amadeus.new.folder"),icon:a.jsx(ba,{size:13}),run:()=>{M("")}},{id:"new-database",label:n("amadeus.new.database"),icon:a.jsx(Ln,{size:13}),run:()=>{Z("")}},{id:"new-drawing",label:n("amadeus.new.drawing"),icon:a.jsx(rn,{size:13}),run:()=>pe("")},{id:"new-dashboard",label:n("amadeus.new.dashboard"),icon:a.jsx($n,{size:13}),run:()=>ue("")},...In.map(v=>({id:`creator:${v.item.id}`,label:v.item.label,icon:a.jsx("span",{style:{display:"inline-flex",width:13,justifyContent:"center",fontSize:13},children:Is(v.item.icon,"📄")}),run:()=>Ji("",v.item.label,v.item.run)}))],De=H?.kind==="root"?H:null,Re=Du(De,()=>De&&{title:n("amxv.phone.new"),sections:[{items:ye()}]},()=>ie(null)),Pt=(v,G,E)=>{if(!Ti(v,E)&&w&&(v.stopPropagation(),!(w===G||qt(w)===E))){if(Rn(w)){const R=wi(w);if(E===R||E.startsWith(`${R}/`))return}v.preventDefault(),v.dataTransfer.dropEffect="move",b!==E&&D(E)}},ut=v=>()=>r?Vf(`${r}/${v}`,ci(v)?Ne(v):v.split(/[\\/]/).pop()??v):null,kt=v=>{Oe().createChildNote(v,Q("amadeus.default.note")).then(G=>{g(E=>new Set([...E,...Xt(wi(v))])),qe(G)},()=>{})},pt=(v,G)=>{const E=_i(v),R=!E&&Hi(v);(!E&&!R?Kt(He,v):void 0)?Gs(v,G):R?mh(v,G):E?oa(v,G):ci(v)?qe(v,G):xi(v)?ss(v,G):Dr(v)?na(v,void 0,G):ts(v)?sa(v,G):me.openVaultFile(v).catch(()=>{})},Mn=(v,G)=>{const E=_i(v),R=!E&&Hi(v),_e=!E&&!R?Kt(He,v):void 0,Ge=!E&&!R&&!_e&&ci(v),at=Ge||R,ve=xi(v)?Ln:E?rn:R?$n:Ge?Yi:ts(v)?ha:Sn,rt=$.includes(v),Y=[...at?[{id:"star",label:n(rt?"amxv.menu.unstar":"amxv.menu.star"),icon:rt?a.jsx(hp,{}):a.jsx(ds,{}),run:()=>Be.getState().toggleStar(v)},{id:"rename",label:n("amxv.menu.rename"),icon:a.jsx(mn,{}),run:()=>I(v)}]:[],{id:"delete",label:n("amxv.menu.delete"),icon:a.jsx(gt,{}),tone:"danger",run:()=>{at?Dn(v):as("file",v)&&Oe().deletePage(v)}}];return a.jsx(Nu,{actions:Y,children:a.jsx(br,{as:"button",className:v===(ai??o)?"active":void 0,style:{paddingLeft:void 0},lead:s[v]?a.jsx("span",{className:"amx-page-emoji",children:s[v]}):a.jsx(ve,{className:"t2s-lead-icon t2s-dim"}),trailing:G?a.jsx("span",{className:"t2s-srow-time",children:hh(G)}):void 0,onClick:()=>pt(v),onContextMenu:Ie=>{Ie.preventDefault(),Ie.stopPropagation(),ie({kind:at?"page":"asset",path:v,x:Ie.clientX,y:Ie.clientY})},children:et===v?a.jsx("input",{ref:Ue,className:"t2s-rename",value:Dt,onChange:Ie=>oi(Ie.target.value),onBlur:x,onKeyDown:Ie=>{Ie.key==="Enter"&&x(),Ie.key==="Escape"&&Ht(null)},onClick:Ie=>Ie.stopPropagation()}):a.jsxs("span",{className:"t2s-srow-text",children:[a.jsx("span",{className:"t2s-srow-title",children:_e?Mi(v,_e.extensions):E?Ne(v).replace(/\.excalidraw$/i,""):Ge?Ne(v):v.split(/[\\/]/).pop()}),qt(v)&&a.jsx("span",{className:"t2s-srow-sub",children:qt(v)})]})})},v)},jt=(v,G=0,E)=>{const R=_i(v),_e=!R&&Hi(v),Ge=!R&&!_e?Kt(He,v):void 0,at=!R&&!_e&&!Ge&&ci(v),ve=at||_e?"page":"asset",rt=xi(v)?Ln:R?rn:_e?$n:at?Yi:ts(v)?ha:Sn;return a.jsxs(br,{as:"button",elRef:Y=>{v===dt&&(tt.current=Y)},className:`${v===(ai??o)?"active":""}${P.has(v)?" sel":""}${v===dt?" amx-flash":""}${v===w?" dragging":""}${b===Bs(gi(v,E?.fd))?" amx-drop-into":""}`.trim()||void 0,selId:v,depth:G,lead:a.jsxs(a.Fragment,{children:[s[v]?a.jsx("span",{className:"amx-page-emoji",children:s[v]}):Ge?.icon?a.jsx("span",{className:"amx-page-emoji",children:Is(Ge.icon,a.jsx(rt,{className:"t2s-lead-icon t2s-dim"}))}):a.jsx(rt,{className:"t2s-lead-icon t2s-dim"}),E&&a.jsx("span",{className:`t2s-chev t2s-lead-chev${E.open?" open":""}`,onClick:Y=>{Y.stopPropagation(),An(E.fd)},children:a.jsx(Fi,{size:12})})]}),onClick:Y=>{const Ie=P.click(v,Y);Ie.open!=="none"&&pt(v,Ie.open==="new"?{newTab:!0}:void 0)},onContextMenu:Y=>{Y.preventDefault(),Y.stopPropagation();const Ie=P.batch(v);Ie.length===1&&P.only(v),ie(Ie.length>1?{kind:"multi",path:v,paths:Ie,x:Y.clientX,y:Y.clientY}:{kind:ve,path:v,x:Y.clientX,y:Y.clientY})},draggable:et!==v,onDragStart:Y=>{const Ie=Y.currentTarget.getBoundingClientRect();Y.dataTransfer.setDragImage(Y.currentTarget,Y.clientX-Ie.left,Y.clientY-Ie.top),Y.dataTransfer.effectAllowed="copyMove";const tn=P.batch(v);if(uh(Y.dataTransfer,tn.map(nn=>({kind:"note",path:nn}))),r&&!(window.amadeusSync&&l==="cloud")){const nn=tn.flatMap(sn=>{const Ts=Rn(sn)?wi(sn):"";return[`${r}/${sn}`,...Ts&&t.includes(Ts)?[`${r}/${Ts}`]:[]]});try{Y.dataTransfer.setData(Ns,JSON.stringify(nn))}catch{}}mg(Y.dataTransfer,{open:()=>pt(v)}),C(v)},onDragEnd:()=>{C(null),D(null)},onDragOver:Y=>{jn(Y,v,E?.fd)||E&&Pt(Y,v,E.fd)},onDragLeave:()=>{b===Bs(gi(v,E?.fd))&&D(null)},onDrop:Y=>{zs(Y,v,E?.fd)||E&&(Y.preventDefault(),Y.stopPropagation(),ri(E.fd))},..._r(ut(v)),children:[et===v?a.jsx("input",{ref:Ue,className:"t2s-rename",value:Dt,onChange:Y=>oi(Y.target.value),onBlur:x,onKeyDown:Y=>{Y.key==="Enter"&&x(),Y.key==="Escape"&&Ht(null)},onClick:Y=>Y.stopPropagation()}):a.jsx("span",{className:"t2s-srow-title",children:Ge?Mi(v,Ge.extensions):at||R?Ne(v):v.split(/[\\/]/).pop()}),a.jsx("span",{className:"t2s-srow-menu",onClick:Y=>{Y.stopPropagation(),ie({kind:ve,path:v,x:Y.clientX,y:Y.clientY})},children:a.jsx(Xi,{size:14})}),at&&a.jsx("span",{className:"t2s-srow-menu",title:n("amadeus.new.childNote"),onClick:Y=>{Y.stopPropagation(),kt(v)},children:a.jsx(ui,{size:14})})]},v)},li=(v,G)=>{if(v.kind==="file"){if(!v.children.length)return jt(v.path,G);const ve=wi(v.path),rt=m.has(ve);return a.jsxs("div",{children:[jt(v.path,G,{fd:ve,open:rt,count:v.children.filter(Y=>Y.kind==="file").length}),rt&&a.jsx("div",{className:`t2s-group-sessions${b===ve?" amx-drop-into":""}`,onDragOver:Y=>Pt(Y,v.path,ve),onDragLeave:()=>{b===ve&&D(null)},onDrop:Y=>{vi(Y,ve)||(Y.preventDefault(),Y.stopPropagation(),ri(ve))},children:v.children.map(Y=>li(Y,G+1))})]},v.path)}const E=v.path,R=!m.has(E),_e=v.children.filter(ve=>ve.kind==="file").length,Ge=v.children.length-_e,at=ve=>{if(!Ti(ve,E)&&w&&(ve.stopPropagation(),qt(w)!==E)){if(Rn(w)){const rt=wi(w);if(E===rt||E.startsWith(`${rt}/`))return}ve.preventDefault(),ve.dataTransfer.dropEffect="move",b!==E&&D(E)}};return a.jsxs("div",{children:[a.jsxs("div",{ref:ve=>{E===dt&&(tt.current=ve)},className:`t2s-group${E===dt?" amx-flash":""}${b===E?" amx-drop-into":""}`,style:{paddingLeft:cf(G)},..._r(()=>[os("tip.folder",{files:_e,folders:Ge})]),onContextMenu:ve=>{ve.preventDefault(),ve.stopPropagation(),ie({kind:"folder",path:E,x:ve.clientX,y:ve.clientY})},onDragOver:at,onDragLeave:()=>{b===E&&D(null)},onDrop:ve=>{vi(ve,E)||(ve.preventDefault(),ve.stopPropagation(),ri(E))},children:[a.jsxs("button",{className:"t2s-group-toggle t2s-folder-row",onClick:()=>An(E),children:[a.jsxs("span",{className:"t2s-lead",children:[R?a.jsx(Io,{className:"t2s-lead-icon"}):a.jsx(Qt,{className:"t2s-lead-icon"}),a.jsx("span",{className:`t2s-chev t2s-lead-chev${R?"":" open"}`,children:a.jsx(Fi,{size:12})})]}),a.jsx("span",{className:"t2s-group-label",children:es(E)})]}),a.jsx("button",{className:"t2s-group-add",title:n("amxv.folder.actions"),onClick:ve=>{ve.stopPropagation(),ie({kind:"folder",path:E,x:ve.clientX,y:ve.clientY})},children:a.jsx(Xi,{size:14})}),a.jsx("button",{className:"t2s-group-add",title:n("amxv.folder.newNoteHere"),onClick:()=>{g(ve=>new Set([...ve,...Xt(E)])),Oe().createPageInFolder(E)},children:a.jsx(ui,{size:14})})]}),!R&&a.jsx("div",{className:`t2s-group-sessions${b===E?" amx-drop-into":""}`,onDragOver:at,onDragLeave:()=>{b===E&&D(null)},onDrop:ve=>{vi(ve,E)||(ve.preventDefault(),ve.stopPropagation(),ri(E))},children:v.children.map(ve=>li(ve,G+1))})]},E)},Qi=je?a.jsxs(a.Fragment,{children:[a.jsx(e_,{}),je.vaultSecs.map(({name:v,node:G,devices:E,mine:R})=>a.jsx(_s,{id:`vault:${v}`,defaultOpen:!0,label:v,extra:Jf(E,Qe),onContextMenu:ct&&!R&&!E.length?_e=>{_e.preventDefault(),_e.stopPropagation(),ie({kind:"vaultsec",path:v,x:_e.clientX,y:_e.clientY})}:void 0,children:G&&G.children.length?G.children.map(_e=>li(_e,0)):a.jsx("div",{className:"t2s-hint amx-sec-hint",children:n(G?"amxv.empty":"amxv.syncNotArrived")})},v)),a.jsx(_s,{id:"cloud-ws",defaultOpen:!0,label:n("amxv.sec.cloudWorkspace"),children:je.rest.length?je.rest.map(v=>li(v,0)):a.jsx("div",{className:"t2s-hint amx-sec-hint",children:n("amxv.empty")})})]}):r?a.jsxs("div",{className:"amx-prefs-group",children:[a.jsx("button",{className:"t2s-group-toggle amx-sec-grab",onClick:yt,children:a.jsxs("span",{className:"t2s-group-name amx-sec-head",children:[a.jsx("span",{className:"t2s-group-label",children:Ne(r)}),a.jsx("span",{className:`t2s-chev${xt?" open":""}`,children:a.jsx(Fi,{size:12})})]})}),xt&&a.jsx("div",{className:`t2s-group-sessions${b===""?" amx-drop-root":""}`,onDragOver:v=>{Ei(v,".t2s-srow, .t2s-group")||!w||qt(w)===""||ht||v.target.closest(".t2s-srow, .t2s-group")||(v.preventDefault(),v.dataTransfer.dropEffect="move",b!==""&&D(""))},onDragLeave:()=>{b===""&&D(null)},onDrop:v=>{On(v,".t2s-srow, .t2s-group")||v.target.closest(".t2s-srow, .t2s-group")||(v.preventDefault(),ri(""))},children:St.children.map(v=>li(v,0))})]}):a.jsx(a.Fragment,{children:St.children.map(v=>li(v,0))}),en=a.jsxs("div",{className:"t2s-foot",children:[a.jsx(Xf,{}),a.jsxs("button",{className:"t2s-special",onClick:()=>c?f(!0):void Oe().openVault(),title:c?n("amxv.cloudVaultTip"):r||void 0,children:[a.jsx("span",{className:"t2s-special-ic",children:a.jsx(Qt,{})}),a.jsx("span",{className:"t2s-special-title",children:c?n("amxv.cloudVault"):r?n("amxv.vaultNamed",{name:Ne(r)}):n("amxv.openVault")})]})]});return a.jsxs("div",{style:{display:"flex",flex:1,minHeight:0,minWidth:0},children:[a.jsxs("aside",{className:"t2s-side amx-tree","data-timeline":B?"":void 0,children:[y?!!r&&a.jsx(ku,{label:n("amxv.phone.tabs"),items:[{id:"recent",label:n("amxv.phone.tab.recent")},{id:"tree",label:n("amxv.phone.tab.tree")},{id:"boards",label:n("amxv.phone.tab.boards")}],value:re,onChange:V}):a.jsxs("div",{className:"t2s-search",children:[a.jsx(To,{size:13,className:"t2s-dim"}),a.jsx("input",{value:h,placeholder:n("amxv.searchNotes"),onChange:v=>u(v.target.value)})]}),a.jsxs("div",{ref:k,className:`t2s-scroll${b===""?" amx-drop-root":""}`,"data-under-dock":y?"":void 0,onTouchStart:B?zu:void 0,onClick:v=>{v.target===v.currentTarget&&P.clear()},onContextMenu:v=>{v.target.closest(".t2s-srow, .t2s-group, .t2s-special-group")||r&&(v.preventDefault(),v.stopPropagation(),ie({kind:"root",path:"",x:v.clientX,y:v.clientY}))},onDragOver:v=>{Ei(v,".t2s-srow, .t2s-group, .t2s-group-sessions, .t2s-special-group")||!w||qt(w)===""||ht||v.target.closest(".t2s-srow, .t2s-group, .t2s-group-sessions, .t2s-special-group")||(v.preventDefault(),v.dataTransfer.dropEffect="move",b!==""&&D(""))},onDragLeave:()=>{b===""&&D(null)},onDrop:v=>{On(v,".t2s-srow, .t2s-group, .t2s-group-sessions, .t2s-special-group")||v.target.closest(".t2s-srow, .t2s-group, .t2s-group-sessions, .t2s-special-group")||(v.preventDefault(),ri(""))},children:[y&&a.jsx(Tu,{}),B&&a.jsx(Eu,{id:"notes",children:n("amxv.phone.hint")}),B&&re==="recent"&&(F.length?Gu(F,v=>ju(v.at)).map(v=>"section"in v?a.jsx(Iu,{bucket:v.section},`sec:${v.section}`):Mn(v.item.path,v.item.at)):a.jsx("div",{className:"t2s-hint",children:n("amxv.phone.noRecent")})),B&&re==="boards"&&(q.length?q.map(v=>Mn(v,0)):a.jsx("div",{className:"t2s-hint",children:n("amxv.phone.noBoards")})),B?null:ht?Ut.length?Ut.map(v=>jt(v)):a.jsx("div",{className:"t2s-hint",children:n("amxv.noMatches")}):a.jsxs(a.Fragment,{children:[!y&&a.jsxs("div",{className:"t2s-special-group",children:[a.jsxs("button",{className:"t2s-special","data-guide-anchor":"note-new",onClick:()=>{Oe().createPage()},children:[a.jsx("span",{className:"t2s-special-ic",children:a.jsx(ji,{})}),a.jsx("span",{className:"t2s-special-title",children:n("amadeus.new.note")})]}),a.jsxs("button",{className:"t2s-special",onClick:()=>pe(""),children:[a.jsx("span",{className:"t2s-special-ic",children:a.jsx(rn,{})}),a.jsx("span",{className:"t2s-special-title",children:n("amadeus.new.drawing")})]})]}),!r&&(d?a.jsx(So,{variant:"list"}):a.jsx("div",{className:"t2s-hint",children:n("amxv.openVaultHint")})),(()=>{const v={pinned:a.jsx(Zf,{row:jt,dragPath:w}),cloudsync:l==="local"?a.jsx(t_,{dragPath:w}):null,shared:a.jsx(qf,{}),prefs:a.jsx(Kf,{row:jt,pages:e}),tree:Qi};return ae.map(G=>v[G]==null?null:ge(G,v[G]))})()]}),y&&en]}),!y&&en,y&&r&&a.jsx(Au,{label:n("amadeus.new.note"),icon:a.jsx(ji,{}),onClick:()=>{Oe().createPage()},onMenu:v=>ie({kind:"root",path:"",x:v.x,y:v.y})})]}),H?.kind==="multi"&&a.jsxs(Jt,{className:"ctx-menu",x:H.x,y:H.y,onClick:v=>v.stopPropagation(),children:[a.jsxs("button",{onClick:()=>{const v=H.paths??[];ie(null);for(const G of v)pt(G,{newTab:!0})},children:[a.jsx(ui,{size:13})," ",n("amxv.menu.openNInNewTabs",{n:H.paths?.length??0})]}),a.jsxs("button",{className:"danger",onClick:()=>{const v=H.paths??[];ie(null),window.confirm(n("amxv.confirm.deleteSelected",{n:v.length}))&&(async()=>{for(const G of v)ci(G)&&!_i(G)?await Dn(G):await Oe().deletePage(G);P.clear()})()},children:[a.jsx(gt,{size:13})," ",n("amxv.menu.deleteN",{n:H.paths?.length??0})]})]}),H?.kind==="page"&&a.jsxs(Jt,{className:"ctx-menu",x:H.x,y:H.y,onClick:v=>v.stopPropagation(),children:[a.jsxs("button",{onClick:()=>{qe(H.path,{newTab:!0}),ie(null)},children:[a.jsx(ui,{size:13})," ",n("amxv.menu.openInNewTab")]}),a.jsxs("button",{onClick:()=>{const v=H.path;ie(null),kt(v)},children:[a.jsx(ji,{size:13})," ",n("amadeus.new.childNote")]}),a.jsxs("button",{onClick:()=>I(H.path),children:[a.jsx(mn,{size:13})," ",n("amxv.menu.rename")]}),a.jsxs("button",{onClick:()=>{Be.getState().toggleStar(H.path),ie(null)},children:[a.jsx(ds,{size:13})," ",Be.getState().starred.includes(H.path)?n("amxv.menu.unstar"):n("amxv.menu.star")]}),window.amadeusSync?.entrySyncEnable&&l==="local"&&(Tn(r,H.path)?a.jsxs("button",{onClick:()=>{const v=H.path;ie(null),window.amadeusSync.entrySyncDisable(v)},children:[a.jsx(io,{size:13})," ",n("amxv.menu.cloudSyncOff")]}):a.jsxs("button",{onClick:()=>{const v=H.path;ie(null),Di(v,"page")},children:[a.jsx(Ki,{size:13})," ",n("amxv.menu.cloudSyncOn")]})),fn()&&a.jsxs("button",{onClick:()=>{me.revealInFileManager(H.path),ie(null)},children:[a.jsx(Qt,{size:13})," ",n("amxv.menu.reveal")]}),a.jsxs("button",{className:"danger",onClick:()=>{const v=H.path;ie(null),Dn(v)},children:[a.jsx(gt,{size:13})," ",n("amxv.menu.delete")]})]}),H?.kind==="asset"&&a.jsxs(Jt,{className:"ctx-menu",x:H.x,y:H.y,onClick:v=>v.stopPropagation(),children:[xi(H.path)?a.jsxs(a.Fragment,{children:[a.jsxs("button",{onClick:()=>{ss(H.path),ie(null)},children:[a.jsx(Zt,{size:13})," ",n("amxv.menu.open")]}),a.jsxs("button",{onClick:()=>I(H.path),children:[a.jsx(mn,{size:13})," ",n("amxv.menu.rename")]}),a.jsxs("button",{onClick:()=>{me.openVaultFile(H.path).catch(()=>{}),ie(null)},children:[a.jsx(Ai,{size:13})," ",n("amxv.menu.openWithSystem")]})]}):Dr(H.path)?a.jsxs(a.Fragment,{children:[a.jsxs("button",{onClick:()=>{Gs(H.path),ie(null)},children:[a.jsx(Zt,{size:13})," ",n("amxv.menu.open")]}),Kt(He,H.path)&&a.jsxs("button",{onClick:()=>{na(H.path),ie(null)},children:[a.jsx(il,{size:13})," ",n("amxv.menu.openBuiltinReader")]}),a.jsxs("button",{onClick:()=>{me.openVaultFile(H.path).catch(()=>{}),ie(null)},children:[a.jsx(Ai,{size:13})," ",n("amxv.menu.openWithSystem")]})]}):ts(H.path)?a.jsxs(a.Fragment,{children:[a.jsxs("button",{onClick:()=>{sa(H.path),ie(null)},children:[a.jsx(Zt,{size:13})," ",n("amxv.menu.open")]}),a.jsxs("button",{onClick:()=>{me.openVaultFile(H.path).catch(()=>{}),ie(null)},children:[a.jsx(Ai,{size:13})," ",n("amxv.menu.openWithSystem")]})]}):_i(H.path)?a.jsxs(a.Fragment,{children:[a.jsxs("button",{onClick:()=>{oa(H.path),ie(null)},children:[a.jsx(Zt,{size:13})," ",n("amxv.menu.openDrawing")]}),a.jsxs("button",{onClick:()=>{me.openVaultFile(H.path).catch(()=>{}),ie(null)},children:[a.jsx(Ai,{size:13})," ",n("amxv.menu.openWithSystem")]})]}):Kt(He,H.path)?a.jsxs(a.Fragment,{children:[a.jsxs("button",{onClick:()=>{Gs(H.path),ie(null)},children:[a.jsx(Zt,{size:13})," ",n("amxv.menu.open")]}),a.jsxs("button",{onClick:()=>{me.openVaultFile(H.path).catch(()=>{}),ie(null)},children:[a.jsx(Ai,{size:13})," ",n("amxv.menu.openWithSystem")]})]}):a.jsxs("button",{onClick:()=>{me.openVaultFile(H.path).catch(()=>{}),ie(null)},children:[a.jsx(Zt,{size:13})," ",n("amxv.menu.open")]}),fn()&&a.jsxs("button",{onClick:()=>{me.revealInFileManager(H.path),ie(null)},children:[a.jsx(Qt,{size:13})," ",n("amxv.menu.reveal")]}),a.jsxs("button",{className:"danger",onClick:()=>{const v=H.path;ie(null),as("file",v)&&Oe().deletePage(v)},children:[a.jsx(gt,{size:13})," ",n("amxv.menu.delete")]})]}),H?.kind==="folder"&&a.jsxs(Jt,{className:"ctx-menu",x:H.x,y:H.y,onClick:v=>v.stopPropagation(),children:[a.jsxs("button",{onClick:()=>{g(v=>new Set([...v,...Xt(H.path)])),Oe().createPageInFolder(H.path),ie(null)},children:[a.jsx(ji,{size:13})," ",n("amadeus.new.note")]}),a.jsxs("button",{onClick:()=>M(H.path),children:[a.jsx(ba,{size:13})," ",n("amxv.menu.newSubfolder")]}),a.jsxs("button",{onClick:()=>Z(H.path),children:[a.jsx(Ln,{size:13})," ",n("amadeus.new.database")]}),a.jsxs("button",{onClick:()=>pe(H.path),children:[a.jsx(rn,{size:13})," ",n("amadeus.new.drawing")]}),a.jsxs("button",{onClick:()=>ue(H.path),children:[a.jsx($n,{size:13})," ",n("amadeus.new.dashboard")]}),In.map(v=>a.jsxs("button",{onClick:()=>Ji(H.path,v.item.label,v.item.run),children:[a.jsx("span",{style:{display:"inline-flex",width:13,justifyContent:"center",fontSize:13},children:Is(v.item.icon,"📄")})," ",v.item.label]},v.item.id)),a.jsxs("button",{onClick:()=>{const v=H.path;ie(null),Ot(n("amxv.renameFolder"),es(v)).then(G=>{const E=G?.trim();E&&Oe().renameFolder(v,E)})},children:[a.jsx(mn,{size:13})," ",n("amxv.menu.rename")]}),fn()&&a.jsxs("button",{onClick:()=>{me.revealInFileManager(H.path),ie(null)},children:[a.jsx(Qt,{size:13})," ",n("amxv.menu.reveal")]}),window.amadeusSync?.entrySyncEnable&&l==="local"&&(Tn(r,H.path)?a.jsxs("button",{onClick:()=>{const v=H.path;ie(null),window.amadeusSync.entrySyncDisable(v)},children:[a.jsx(io,{size:13})," ",n("amxv.menu.cloudSyncOff")]}):a.jsxs("button",{onClick:()=>{const v=H.path;ie(null),Di(v,"folder")},children:[a.jsx(Ki,{size:13})," ",n("amxv.menu.cloudSyncOn")]})),ct&&l==="cloud"&&!H.path.includes("/")&&!je?.vaultSecs.some(v=>v.name===H.path)&&a.jsxs("button",{onClick:()=>{const v=H.path;ie(null),Ct(v,!0)},children:[a.jsx(Yu,{size:13})," ",n("amxv.menu.vaultSectionOn")]}),window.amadeusCollab&&a.jsxs("button",{onClick:()=>{const v=H.path;ie(null);const G=Ho(fe,r,l,v);if(!G){Di(v,"folder");return}window.amadeusCollab.createPublish("subtree",G).then(E=>navigator.clipboard.writeText(E.url).then(()=>Ke.getState().toast(n("amxv.publish.done")))).catch(E=>Ke.getState().toast(E?.code==="QUOTA"?E.message||n("amxv.publish.quota"):E?.status===404?n("amxv.publish.notUploaded"):n("amxv.publish.failed"),!0))},children:[a.jsx(cs,{size:13})," ",n("amxv.menu.publishFolder")]}),a.jsxs("button",{className:"danger",onClick:()=>{const v=H.path;ie(null),as("folder",v)&&Oe().deleteFolder(v)},children:[a.jsx(gt,{size:13})," ",n("amxv.menu.delete")]})]}),H?.kind==="vaultsec"&&a.jsx(Jt,{className:"ctx-menu",x:H.x,y:H.y,onClick:v=>v.stopPropagation(),children:a.jsxs("button",{onClick:()=>{const v=H.path;ie(null),Ct(v,!1)},children:[a.jsx(Ou,{size:13})," ",n("amxv.menu.vaultSectionOff")]})}),De&&Re&&a.jsx(Jt,{className:"ctx-menu",x:De.x,y:De.y,onClick:v=>v.stopPropagation(),children:a.jsx(Su,{items:ye()})}),p&&a.jsx(zf,{onClose:()=>f(!1)})]})}function fd(n){return n.map(e=>e.kind==="choice"?{id:`page-${e.id}`,icon:a.jsx(cl,{size:16}),label:e.label,run:()=>{},choices:e.options}:{id:`page-${e.id}`,icon:e.id==="wide"?a.jsx(ll,{size:16}):a.jsx(hl,{size:16}),label:e.label,checked:e.on,run:e.run})}function s_(){const[n,e]=_.useState(0),t=_.useRef(0),i=_.useRef({w:0,h:0});return _.useEffect(()=>{const o=()=>{const r=i.current;r.w!==window.innerWidth?i.current={w:window.innerWidth,h:window.innerHeight}:window.innerHeight>r.h&&(r.h=window.innerHeight);const l=window.visualViewport,d=l?Math.max(0,window.innerHeight-l.height-l.offsetTop):0,c=Math.max(d,Math.max(0,i.current.h-window.innerHeight));c>120&&(t.current=c),e(d)};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:n,kbHeight:()=>t.current||Math.min(380,Math.max(240,Math.round(window.innerHeight*.42)))}}function o_({height:n,onClose:e}){const t=_u(),i=_.useMemo(()=>{const s=new Map;for(const o of t)(s.get(o.group)??s.set(o.group,[]).get(o.group)).push(o);return[...s]},[t]);return a.jsx("div",{className:"amx-bpick",style:{height:n},children:a.jsx("div",{className:"amx-bpick-scroll",children:i.map(([s,o])=>a.jsxs(_.Fragment,{children:[a.jsx("div",{className:"amx-bpick-label",children:s}),a.jsx("div",{className:"amx-bpick-grid",children:o.map(r=>a.jsxs("button",{className:"amx-bpick-item",onClick:()=>{dl()?.(r),e()},children:[a.jsx("span",{className:"amx-bpick-icon",children:r.icon}),a.jsx("span",{className:"amx-bpick-name",children:r.label})]},r.key))})]},s))})})}function _d({actions:n,onUpload:e,undo:t,redo:i,indent:s,sourceMode:o,onNeedFocus:r,canvas:l}){const{t:d}=Ce(),{lift:c,kbHeight:h}=s_(),[u,m]=_.useState(!1),[g,p]=_.useState(0);aa(u,()=>m(!1)),aa(g>0,()=>p(0));const f=_.useRef(null),w=P=>P.preventDefault(),C=f.current?Ks(f.current):1,b=g?Math.round(g/C):0,D=b||Math.round(c/C),k=()=>{dl()||r();const P=h();document.activeElement?.blur?.(),p(P)};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{ref:f,className:"amx-mbar","data-kb-rise":!0,style:D?{transform:`translateY(-${D}px)`}:void 0,children:[!o&&a.jsx("button",{onPointerDown:w,onClick:()=>g?p(0):k(),className:g?"on":void 0,title:d("amxv.mbar.insertBlock"),children:a.jsx(ui,{size:19})}),!o&&a.jsx("button",{onPointerDown:w,onClick:e,title:d("amxv.uploadToPage"),children:a.jsx(to,{size:19})}),!o&&l&&!yc()&&a.jsx("button",{onPointerDown:w,onClick:l.toggle,className:l.on?"on":void 0,title:l.on?d("amxv.mbar.toDocument"):d("amxv.mbar.toCanvas"),children:a.jsx(Mu,{size:19})}),!o&&s&&a.jsx("button",{onPointerDown:w,onClick:()=>s(-1),title:d("amxv.mbar.outdent"),children:a.jsx(Zu,{size:19})}),!o&&s&&a.jsx("button",{onPointerDown:w,onClick:()=>s(1),title:d("amxv.mbar.indent"),children:a.jsx(ep,{size:19})}),!o&&a.jsx("button",{onPointerDown:w,onClick:t,title:d("amxv.mbar.undo"),children:a.jsx(Lu,{size:19})}),!o&&a.jsx("button",{onPointerDown:w,onClick:i,title:d("amxv.mbar.redo"),children:a.jsx(Ru,{size:19})}),a.jsx("button",{onPointerDown:w,onClick:()=>m(!0),title:d("amxv.moreActions"),children:a.jsx(Xi,{size:19})}),a.jsx("button",{onClick:()=>{p(0),document.activeElement?.blur?.()},title:d("amxv.mbar.hideKeyboard"),children:a.jsx(iu,{size:19})})]}),b>0&&a.jsx(o_,{height:b,onClose:()=>p(0)}),u&&a.jsx("div",{className:"mb-sheet-scrim",onClick:()=>m(!1),children:a.jsxs("div",{className:"mb-sheet",onClick:P=>P.stopPropagation(),style:{paddingBottom:"env(safe-area-inset-bottom)"},children:[a.jsx("div",{className:"mb-sheet-grip"}),n.map(P=>P.choices?a.jsxs("div",{className:"mb-sheet-row amx-sheet-choice",role:"group","aria-label":P.label,"data-action":P.id,children:[P.icon,a.jsx("span",{children:P.label}),a.jsx("span",{className:"amx-sheet-seg",children:P.choices.map(y=>a.jsx("button",{type:"button",role:"radio","aria-checked":y.on,"data-font":y.id,className:y.on?"on":void 0,onClick:y.run,children:y.label},y.id))})]},P.id):a.jsxs("button",{className:`mb-sheet-row${P.danger?" danger":""}${P.on?" on":""}`,role:P.checked!==void 0?"switch":void 0,"aria-checked":P.checked,"data-action":P.id,onClick:()=>{P.checked===void 0&&m(!1),P.run()},children:[P.icon,a.jsx("span",{children:P.label}),P.checked&&a.jsx(ei,{size:16,className:"amx-sheet-check"})]},P.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 a_(n,e){const[,t]=_.useState(0);return _.useEffect(()=>Ic(()=>t(i=>i+1)),[]),!!e&&Ac(n,e)}function r_({children:n,dragging:e,rootRef:t,onDrop:i,onDragOver:s,onDragLeave:o,onClick:r,onPaste:l,pageAttrs:d}){const c=nl(h=>h.mode);return a.jsx("div",{ref:h=>{t&&(t.current=h)},className:`am-app tangu-lovable amx-pane amx-editor${e?" amx-dragover":""}`,"data-mode":c,...d,onDrop:i,onDragOver:s,onDragLeave:o,onClick:r,onPaste:l,children:n})}function l_({params:n,size:e}){const t=typeof n.notePath=="string"?n.notePath:"",i=K(s=>t?s.icons[t]??null:null);return i?a.jsx("span",{className:"wb-tab-ic amx-tab-emoji",style:{fontSize:e},"aria-hidden":!0,children:i}):a.jsx(Yi,{size:e,className:"wb-tab-ic"})}function wd(){const{t:n}=Ce(),e=Si(),t=()=>e.getState(),i=K(b=>b.activePage),s=K(b=>b.manifest),o=K(b=>i?b.icons[i]??null:null),r=i?tl(i):void 0,l=r&&i?Mi(i,r.extensions):s?.title||(i?Ne(i):""),d=mu.test(l)?"":l,[c,h]=_.useState(d),[u,m]=_.useState(null),g=_.useRef(null);_.useEffect(()=>{h(d)},[i]),_.useEffect(()=>{if(!Dc(i))return;const b=g.current;if(!b)return;b.focus();const D=b.value.length;b.setSelectionRange(D,D)},[i]);const p=()=>{const b=c.trim();b&&b!==l?t().renamePage(b):h(d)},f=nu(),[w,C]=_.useState(null);return a.jsxs("div",{className:"amx-title-wrap",children:[o&&a.jsx("button",{className:"amx-title-bigicon",title:n("amxv.title.changeIcon"),onClick:b=>{const D=b.currentTarget.getBoundingClientRect();m({x:D.left,y:D.bottom+6})},children:o}),i&&(!o||!f)&&a.jsxs("div",{className:"amx-title-actions",children:[!o&&a.jsxs("button",{onClick:()=>{t().setPageIcon(i,ou())},children:[a.jsx(su,{size:14,strokeWidth:1.7,"aria-hidden":"true"}),n("amxv.title.addIcon")]}),!f&&a.jsxs("button",{onClick:b=>{const D=b.currentTarget.getBoundingClientRect();C({x:D.right,y:D.bottom+6})},children:[a.jsx(Cc,{size:14,strokeWidth:1.7,"aria-hidden":"true"}),n("amxv.title.addCover")]})]}),a.jsx("div",{className:"amx-title-row",children:a.jsx("input",{ref:g,className:"amx-title-input",value:c,placeholder:"New Page",onChange:b=>h(b.target.value),onBlur:p,onKeyDown:b=>{const D=b.currentTarget,k=D.selectionStart===D.value.length&&D.selectionEnd===D.value.length;(b.key==="Enter"||(b.key==="ArrowRight"||b.key==="ArrowDown")&&k)&&(b.preventDefault(),fs(e),D.blur()),b.key==="Escape"&&(h(d),D.blur())}})}),u&&i&&a.jsx(au,{x:u.x,y:u.y,current:o,onPick:b=>{t().setPageIcon(i,b),m(null)},onClose:()=>m(null)}),w&&i&&a.jsx(ru,{page:i,x:w.x,y:w.y,onClose:()=>C(null)})]})}function d_(n){for(let e=n.parentElement;e;e=e.parentElement)if(/(auto|scroll)/.test(getComputedStyle(e).overflowY)&&e.scrollHeight>e.clientHeight)return e;return null}function c_(){const n=Si(),e=Rr(),t=()=>n.getState(),i=()=>{const u=t().manifest;if(!u)return"";const m={};for(const[g,p]of Object.entries(t().blocks))m[g]=p.content;return Md(u,m)},[s,o]=_.useState(i),r=_.useRef(null),l=()=>{const u=r.current;u&&(u.style.height="auto",u.style.height=`${u.scrollHeight}px`)};_.useEffect(l,[s]);const d=_.useRef(s);d.current=s;const c=_.useRef(0);_.useEffect(()=>{const u=r.current,m=Kr(e);if(u&&m){const g=gh(d.current,m);if(g>=0){u.focus(),u.setSelectionRange(g,g),c.current=g;const p=d.current.slice(0,g).split(`
17
+ `).length-1,f=parseFloat(getComputedStyle(u).lineHeight)||20,w=d_(u);w&&(w.scrollTop=Math.max(0,u.offsetTop+p*f-w.clientHeight/2))}}return()=>fh(_h(d.current,c.current),e)},[]);const h=()=>{const u=t().activePage;if(!u||s===i())return;const m=Ld(u,s,new Date().toISOString());t()._commit(m.manifest,m.blocks)};return a.jsx("textarea",{ref:r,className:"amx-source",value:s,spellCheck:!1,onChange:u=>{c.current=u.target.selectionStart,o(u.target.value)},onSelect:u=>{c.current=u.currentTarget.selectionStart},onBlur:h})}function h_(n){return a.jsx(zo.Provider,{value:n.leaf.id,children:a.jsx(u_,{...n})})}function u_({leaf:n}){const{t:e}=Ce(),t=Si(),i=()=>t.getState(),s=K(A=>A.activePage),o=K(A=>A.vaultRoot),r=K(A=>A.pendingPage),l=K(A=>A.error),d=Js(A=>A.fileTypes),c=Vn(A=>rh(A,n.id)),[h,u]=_.useState(!1);_.useEffect(()=>{if(!h)return;const A=()=>u(!1);return window.addEventListener("dragend",A),window.addEventListener("drop",A),()=>{window.removeEventListener("dragend",A),window.removeEventListener("drop",A)}},[h]);const[m,g]=_.useState(null),[p,f]=_.useState(null),[w,C]=_.useState(null),b=_.useRef(null),D=_.useRef(null),k=_.useRef(null),[P,y]=_.useState(null),[T,S]=_.useState(0),N=_.useRef(null),O=_.useRef(null),$=Be(A=>A.starred),F=Be(A=>A.pins),q=K(A=>A.vaultSide);We(A=>A.vaults),_.useEffect(()=>{sd()},[]);const re=!!window.amadeusSync?.entrySyncEnable&&q==="local";_.useEffect(()=>{if(!m)return;const A=()=>g(null);return window.addEventListener("click",A),window.addEventListener("contextmenu",A),()=>{window.removeEventListener("click",A),window.removeEventListener("contextmenu",A)}},[m]);const V=async()=>{const A=i().activePage??fe,se=N.current;if(!A||!se)return;const le=document.createElement("div");le.id="amx-print-root";const he=nf(se);he.setAttribute("data-mode","light"),le.appendChild(he),document.body.appendChild(le);try{const je=await me.exportPdf(Ne(A));je&&Ke.getState().toast(e("amxv.pdf.exported",{path:je}))}catch(je){Ke.getState().toast(e("amxv.pdf.exportFailed",{e:String(je)}),!0)}finally{le.remove()}},B=async()=>{if(fe)try{const A=await Rg(fe);if(A==null)throw new Error(fe);await navigator.clipboard.writeText(A),Ke.getState().toast(e("amxv.copyMd.done"))}catch(A){Ke.getState().toast(e("amxv.copyFailed",{e:A instanceof Error?A.message:String(A)}),!0)}},te=Xe(A=>A.mainTabs.find(se=>se.id===n.id)?.active??!1),we=Xe(A=>{if(!A.api)return!1;const se=bs(A.api),le=A.mainTabs.filter(he=>he.type==="amadeus-editor");return(le.find(he=>he.id===se?.id)??le.find(he=>he.front)??le[0])?.id===n.id}),xe=Sc(),j=pd(n,"notePath")||null,de=_.useRef(!1),[ce,be]=_.useState(null),[Se,st]=_.useState(0),L=_.useRef(null),J=K(A=>j?A.pages.includes(j):!1),oe=K(A=>Ag(j,A)),ae=oe==="plugin";_.useEffect(()=>{if(oe!=="pending")return;const A=setInterval(()=>{K.getState().refreshStructure().catch(()=>{})},3e3);return()=>clearInterval(A)},[oe]),_.useEffect(()=>{if(!j){be(null);return}if(ae){pn(j),L.current=null,be(null);return}const A=L.current;if(oe==="pending"){A&&A.path===j&&pn(j),L.current=null,be(null);return}if(A&&A.path===j&&(A.root===o||A.root===null))return;A&&A.path===j&&pn(j);let se=!0;return(async()=>{let le=await me.readTextFile(j).catch(()=>null);for(let je=0;le==null&&!i().vaultRoot&&je<30;je++){if(await new Promise(ot=>setTimeout(ot,100)),!se)return;le=await me.readTextFile(j).catch(()=>null)}if(!se)return;const he=wa(j,le,wo(),new Date().toISOString());if(he.editor==="missing"&&i().pages.includes(j)){L.current=null,be({forPath:j,decision:he,root:i().vaultRoot,unreadable:!0});return}he.editor==="missing"?(pn(j),L.current=null):L.current={path:j,root:i().vaultRoot},be({forPath:j,decision:he,root:i().vaultRoot})})(),()=>{se=!1}},[j,o,J,Se,oe]);const Pe=oe==="note"&&ce&&ce.forPath===j?ce.decision:null,ge=Pe?.editor==="unified"?Pe:null,H=!!j&&!!ce?.unreadable&&ce.forPath===j,ie=Pe?.editor==="missing"&&!!j&&!H,xt=ce&&ce.forPath===j?ce.root??"":"",yt=a_(o,j),[et,Ht]=_.useState({path:j,on:yt}),[Dt,oi]=_.useState(0),Ue=et.path===j?et.on:yt;_.useEffect(()=>{if(et.path!==j){Ht({path:j,on:yt});return}if(et.on===yt||!j)return;let A=!0;return(async()=>{const se=await Bo(j);if(!A)return;if(!se.ok){rd(j,yt,se.reason,()=>oi(he=>he+1));return}const le=wa(j,se.raw,wo(),new Date().toISOString());le.editor==="unified"&&be(he=>he&&he.forPath===j?{...he,decision:le}:he),Ht({path:j,on:yt})})(),()=>{A=!1}},[yt,et,j,Dt]);const Ze=()=>{j&&ld(o,j,!Ue)},dt=Wg(o,ge?j:null),Nt=ge&&j?Fg(dt,A=>$g(o,j,A),e):[],tt=!ge&&!ie&&!H&&!ae&&(!!r&&r!==s||!!j&&!l&&j!==s),fe=s??(ge&&j?j:null),Bt=!!fe&&$.includes(fe),it=!!fe&&F.includes(fe),Qe=re&&!!fe&&Tn(i().vaultRoot,fe);_.useEffect(()=>{if(!ge||!j)return;const A=i().activePage;i().releasePage(A??j)},[ge,j]),_.useEffect(()=>{j&&n.setTitle(Ne(j))},[j]),_.useEffect(()=>{if(Pc!=="mobile"||j)return;const A=()=>{const le=i();if(!le.vaultRoot)return!1;let he=null;try{he=localStorage.getItem(`amx.lastNote:${le.vaultRoot}`)}catch{}return he&&le.pages.includes(he)&&n.setParams({...n.params,notePath:he}),!0};if(A())return;const se=t.subscribe(le=>{le.vaultRoot&&A()&&se()});return se},[j]),_.useEffect(()=>{i().setActiveNotePath(j)},[j]),_.useEffect(()=>{!ge||!j||(Fr(n.id,`amadeus:${j}`,()=>{const A=Xe.getState(),se=A.leafById(n.id);se&&A.navigateLeaf(n.id,"amadeus-editor",{...se.params,notePath:j})}),Ps.getState().record({key:`note:${j}`,kind:"note",id:j,title:Ne(j)}))},[ge,j]),_.useEffect(()=>{if(j)return kc((A,se,le)=>{const he=ai=>Ad(ai,A,se);if(!he(j))return;if(le){n.setParams({...n.params,notePath:se==="file"?le:le+j.slice(A.length)});return}const je=i(),ot=je.activePage;n.setParams({...n.params,notePath:(ot&&!he(ot)?ot:je.pages.find(ai=>!he(ai)))??void 0})})},[j]),_.useEffect(()=>{if(!j)return;const A=i().vaultRoot;if(A)try{localStorage.setItem(`amx.lastNote:${A}`,j)}catch{}},[j]),_.useEffect(()=>{j&&Pe?.editor==="block"&&j!==i().activePage&&i().loadPage(j)},[j,Pe]),_.useEffect(()=>{te&&Wi(n.id),de.current=te},[te,n.id]),_.useEffect(()=>{we&&xe===zc&&o&&Wi(n.id)},[we,xe,o,n.id]),_.useEffect(()=>{!s||s===j||Kt(d,s)||Hi(s)||(n.setParams({...n.params,notePath:s}),n.setTitle(Ne(s)))},[s]),_.useEffect(()=>()=>Wr(n.id),[n.id]);const ct=async A=>{u(!1);const se=Gg(A.dataTransfer);if(se.length){if(A.preventDefault(),ge&&j){const ot=se.join(`
18
+
19
+ `);if(k.current?k.current(ot):Od(j,ot,"cursor"))return}const je=i();if(!je.activePage)return;je.insertBlocksAfter(null,se);return}const le=Array.from(A.dataTransfer?.files??[]);if(!le.length||(A.preventDefault(),ge&&j&&(D.current?D.current(le):Ys(j,le))))return;const he=i().activePage;he&&await vs(le,he)},Ct=A=>{const se=Array.from(A.dataTransfer?.types??[]),le=se.includes(sl);!se.includes("Files")&&!le||(A.preventDefault(),le&&A.dataTransfer&&(A.dataTransfer.dropEffect="copy"),h||u(!0))},ht=A=>{A.currentTarget.contains(A.relatedTarget)||u(!1)},St=A=>{const se=A.target.closest("a");if(!se||se.classList.contains("wikilink"))return;const le=se.getAttribute("href")||"";if(!le||wu(le)!=="file")return;A.preventDefault();const he=i().activePage??fe;he&&me.openAttachment(he,le)},Ut=A=>{if(A.defaultPrevented||A.target.closest("input, textarea, .t2s-rename"))return;const se=Array.from(A.clipboardData?.items??[]).filter(he=>he.kind==="file"&&he.type.startsWith("image/")).map(he=>he.getAsFile()).filter(he=>!!he);if(!se.length)return;A.preventDefault();const le=i().activePage;le&&tf(se,le)};return a.jsxs(a.Fragment,{children:[a.jsxs(r_,{rootRef:N,pageAttrs:ge?Hg(dt):void 0,dragging:h,onDrop:A=>{ct(A)},onDragOver:Ct,onDragLeave:ht,onClick:St,onPaste:Ut,children:[fe&&c!=="source"&&!w?.on&&!n.params.miniSurface&&!As()&&a.jsx(Xg,{host:N,label:e("amxv.floatingToc"),scanTrigger:fe}),a.jsx("input",{ref:O,type:"file",multiple:!0,style:{display:"none"},onChange:A=>{const se=Array.from(A.currentTarget.files??[]);if(A.currentTarget.value="",!se.length||ge&&j&&(D.current?D.current(se):Ys(j,se)))return;const le=i().activePage;le&&vs(se,le)}}),fe&&!As()&&!n.params.miniSurface&&a.jsxs("div",{className:"amx-toolbar amx-vhead",children:[a.jsx(Jo,{path:fe,hideLoneLeaf:!!ge}),a.jsx("span",{className:lu}),window.amadeusCollab&&a.jsx(Of,{path:fe,refreshKey:T,onOpen:(A,se)=>y({x:A,y:se})}),a.jsx("button",{className:`amx-mode-btn amx-pin-btn${it?" amx-pin-on":""}`,title:e(it?"amxv.unpin":"amxv.pin"),onClick:()=>Be.getState().togglePin(fe),children:a.jsx(no,{size:14})}),re&&a.jsx("button",{className:`amx-mode-btn amx-pin-btn${Qe?" amx-pin-on":""}`,title:e(Qe?"amxv.cloud.disableTip":"amxv.menu.cloudSyncOn"),onClick:()=>{Qe?window.amadeusSync?.entrySyncDisable?.(fe):Di(fe,"page")},children:a.jsx(Ki,{size:14})}),window.amadeusCollab&&a.jsx(Tf,{}),window.amadeusCollab&&a.jsx("button",{className:"amx-mode-btn",title:e("amxv.shareOrPublish"),onClick:A=>{A.stopPropagation();const se=A.currentTarget.getBoundingClientRect();y({x:se.right,y:se.bottom})},children:a.jsx(cs,{size:14})}),c==="source"&&a.jsx("button",{className:"amx-mode-btn",onClick:()=>Vn.getState().toggleEditorMode(n.id),title:e("amxv.toVisualLong"),children:a.jsx(Zt,{size:14})}),a.jsx("button",{className:"amx-mode-btn amx-more-btn",title:e("amxv.moreActions"),onClick:A=>{A.stopPropagation();const se=A.currentTarget.getBoundingClientRect();g({x:Math.max(8,Math.min(se.right-180,window.innerWidth-196)),y:se.bottom+4})},children:a.jsx(Xi,{size:14})})]}),m&&fe&&a.jsxs(Jt,{className:"ctx-menu",x:m.x,y:m.y,onClick:A=>A.stopPropagation(),children:[Nt.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(Ug,{entries:Nt}),a.jsx("div",{className:"ctx-separator"})]}),a.jsxs("button",{"data-note-mode":!0,onClick:()=>{g(null),Vn.getState().toggleEditorMode(n.id)},children:[c==="source"?a.jsx(Zt,{size:13}):a.jsx(Vs,{size:13})," ",e(c==="source"?"amxv.toVisual":"amxv.toSource")]}),dr(fe,Ue,!!ge&&c==="source")&&a.jsxs("button",{"data-note-upload":!0,onClick:()=>{g(null),O.current?.click()},children:[a.jsx(to,{size:13})," ",e("amxv.uploadToPage")]}),ge&&a.jsxs("button",{onClick:()=>{g(null),B()},children:[a.jsx($i,{size:13})," ",e("amxv.menu.copyMd")]}),ra()&&a.jsxs("button",{onClick:()=>{g(null),V()},children:[a.jsx(Wn,{size:13})," ",e("amxv.menu.exportPdf")]}),w?.on&&w.exportCanvas&&a.jsxs("button",{onClick:()=>{const A=w.exportCanvas;g(null),A?.()},children:[a.jsx(Wn,{size:13})," ",e("amxv.menu.exportCanvas")]}),a.jsxs("button",{onClick:()=>{Be.getState().toggleStar(fe),g(null)},children:[a.jsx(ds,{size:13})," ",e(Bt?"amxv.menu.unstar":"amxv.menu.star")]}),fn()&&a.jsxs("button",{onClick:()=>{me.revealInFileManager(fe),g(null)},children:[a.jsx(Qt,{size:13})," ",e("amxv.menu.reveal")]}),ge&&a.jsxs("button",{onClick:()=>{g(null),Ze()},children:[a.jsx(la,{size:13})," ",e(Ue?"amxv.menu.unlockPage":"amxv.menu.lockPage")]}),ge&&da()&&a.jsxs("button",{"data-page-history":!0,onClick:()=>{g(null),f(fe)},children:[a.jsx(ca,{size:13})," ",e("pghist.menu")]}),a.jsxs("button",{className:"danger",onClick:()=>{const A=fe;g(null),Dn(A,i)},children:[a.jsx(gt,{size:13})," ",e("amxv.menu.deleteNote")]})]}),p&&a.jsx(Lg,{path:p,locked:p===j&&Ue,onClose:()=>f(null)}),P&&fe&&a.jsx(If,{path:fe,anchor:P,onClose:()=>{y(null),S(A=>A+1)}}),ae&&j?a.jsxs("div",{className:"amx-welcome","data-plugin-owned-file":j,children:[a.jsx("div",{className:"amx-welcome-title",children:e("amxv.pluginFile.title")}),a.jsx("p",{className:"amx-welcome-sub",children:e("amxv.pluginFile.sub",{path:j})}),a.jsx("div",{className:"amx-welcome-actions",children:a.jsx("button",{className:"amx-welcome-btn",onClick:()=>Xe.getState().closeLeaf(n.id),children:e("amxv.missing.close")})})]}):ge&&j?a.jsx(du,{compact:!!n.params.miniSurface,readOnly:Ue,onUnlock:Ue?Ze:void 0,path:j,initial:ge.initial,diskRaw:ge.diskRaw,onCanvasMode:C,historyRef:b,filesRef:D,mdRef:k,onRenamed:A=>{n.setParams({...n.params,notePath:A}),n.setTitle(Ne(A)),md(j,A)}},`${xt}\0${j}${Ue?"\0locked":""}`):H&&j?a.jsxs("div",{className:"amx-welcome",children:[a.jsx("div",{className:"amx-welcome-title",children:e("amxv.welcome.loadFailed")}),a.jsx("p",{className:"amx-welcome-sub",children:j}),a.jsx("div",{className:"amx-welcome-actions",children:a.jsx("button",{className:"amx-welcome-btn",onClick:()=>st(A=>A+1),children:e("amxv.retry")})})]}):ie&&j?a.jsxs("div",{className:"amx-welcome",children:[a.jsx("div",{className:"amx-welcome-title",children:e("amxv.missing.title")}),a.jsx("p",{className:"amx-welcome-sub",children:e("amxv.missing.sub",{path:j})}),a.jsx("div",{className:"amx-welcome-actions",children:a.jsx("button",{className:"amx-welcome-btn",onClick:()=>Xe.getState().closeLeaf(n.id),children:e("amxv.missing.close")})})]}):tt?a.jsx(So,{variant:"document"}):s?c==="source"?a.jsx(c_,{},s):a.jsxs(a.Fragment,{children:[a.jsx(cu,{}),a.jsxs("div",{className:"amx-doc",children:[a.jsx(wd,{}),a.jsx(hu,{})]}),a.jsx(kf,{bare:!0})]}):j&&l?a.jsxs("div",{className:"amx-welcome",children:[a.jsx("div",{className:"amx-welcome-title",children:e("amxv.welcome.loadFailed")}),a.jsx("p",{className:"amx-welcome-sub",children:l}),a.jsx("div",{className:"amx-welcome-actions",children:a.jsx("button",{className:"amx-welcome-btn",onClick:()=>{j&&i().loadPage(j)},children:e("amxv.retry")})})]}):a.jsxs("div",{className:"amx-welcome",children:[a.jsx("div",{className:"amx-welcome-title",children:e("amxv.welcome.title")}),a.jsx("p",{className:"amx-welcome-sub",children:e(o?"amxv.welcome.pickNote":"amxv.welcome.noVault")}),a.jsx("div",{className:"amx-welcome-actions",children:o?a.jsxs(a.Fragment,{children:[a.jsxs("button",{className:"amx-welcome-btn",onClick:()=>{i().createPage()},children:[a.jsx(ji,{size:16})," ",e("amadeus.new.note")]}),a.jsxs("button",{className:"amx-welcome-btn ghost",onClick:()=>{lh()},children:[a.jsx(il,{size:16})," ",e("amxv.welcome.tutorial")]}),a.jsxs("button",{className:"amx-welcome-btn ghost",onClick:()=>{dh()},children:[a.jsx(Wu,{size:16})," ",e("amxv.welcome.manual")]})]}):a.jsxs("button",{className:"amx-welcome-btn",onClick:()=>{i().openVault()},children:[a.jsx(Qt,{size:16})," ",e("amxv.welcome.openVaultFolder")]})}),a.jsxs("ul",{className:"amx-welcome-tips",children:[a.jsxs("li",{children:[a.jsx("span",{className:"amx-kbd",children:"[["})," ",e("amxv.welcome.tip1")]}),a.jsxs("li",{children:[a.jsx(Sn,{size:13})," ",e("amxv.welcome.tip2")]}),a.jsxs("li",{children:[a.jsx(Vs,{size:13})," ",e("amxv.welcome.tip3")]})]})]})]}),As()&&fe&&!tt&&a.jsx(_d,{sourceMode:c==="source",canvas:w,onUpload:()=>O.current?.click(),undo:()=>{b.current?b.current.undo():s&&i().undo()},redo:()=>{b.current?b.current.redo():s&&i().redo()},indent:w?A=>{b.current?.indent?.(A)}:null,onNeedFocus:()=>{s&&fs(t)},actions:[{id:"mode",icon:c==="source"?a.jsx(Zt,{size:16}):a.jsx(Vs,{size:16}),label:e(c==="source"?"amxv.toVisual":"amxv.toSource"),run:()=>Vn.getState().toggleEditorMode(n.id)},...dr(fe,Ue,!!ge&&c==="source")?[{id:"upload",icon:a.jsx(to,{size:16}),label:e("amxv.uploadToPage"),run:()=>O.current?.click()}]:[],...ge?[{id:"lock",icon:a.jsx(la,{size:16}),label:e(Ue?"amxv.menu.unlockPage":"amxv.menu.lockPage"),on:Ue,run:Ze}]:[],...ge&&da()?[{id:"history",icon:a.jsx(ca,{size:16}),label:e("pghist.menu"),run:()=>f(fe)}]:[],...fd(Nt),{id:"pin",icon:a.jsx(no,{size:16}),label:e(it?"amxv.unpin":"amxv.pin"),on:it,run:()=>Be.getState().togglePin(fe)},{id:"star",icon:a.jsx(ds,{size:16}),label:e(Bt?"amxv.menu.unstar":"amxv.menu.star"),on:Bt,run:()=>Be.getState().toggleStar(fe)},...re?[{id:"sync",icon:a.jsx(Ki,{size:16}),label:e(Qe?"amxv.cloud.disableTip":"amxv.menu.cloudSyncOn"),on:Qe,run:()=>{Qe?window.amadeusSync?.entrySyncDisable?.(fe):Di(fe,"page")}}]:[],...window.amadeusCollab?[{id:"share",icon:a.jsx(cs,{size:16}),label:e("amxv.shareOrPublish"),run:()=>y({x:window.innerWidth/2,y:window.innerHeight/2})}]:[],...ge?[{id:"copymd",icon:a.jsx($i,{size:16}),label:e("amxv.menu.copyMd"),run:()=>{B()}}]:[],...ra()?[{id:"pdf",icon:a.jsx(Wn,{size:16}),label:e("amxv.menu.exportPdf"),run:()=>{V()}}]:[],...w?.on&&w.exportCanvas?[{id:"canvas-export",icon:a.jsx(Wn,{size:16}),label:e("amxv.menu.exportCanvas"),run:()=>w.exportCanvas?.()}]:[],...fn()?[{id:"reveal",icon:a.jsx(Qt,{size:16}),label:e("amxv.menu.reveal"),run:()=>{me.revealInFileManager(fe)}}]:[],{id:"delete",icon:a.jsx(gt,{size:16}),label:e("amxv.menu.deleteNote"),danger:!0,run:()=>{Dn(fe,i)}}]})]})}function bd(){const{t:n}=Ce(),e=nh();return a.jsxs("div",{className:"amx-panel",children:[a.jsx("div",{className:"amx-panel-head",children:n("amadeus.outline")}),e.length===0?a.jsx("div",{className:"amx-panel-empty",children:n("amxv.outline.empty")}):a.jsx("div",{className:"amx-list",children:e.map(t=>a.jsx("button",{className:"amx-list-item",style:{paddingLeft:10+(t.level-1)*12},onClick:t.go,title:t.text,children:t.text},t.key))})]})}function p_({path:n,scope:e}){return a.jsx(zo.Provider,{value:e,children:a.jsx(m_,{path:n,scope:e})})}function m_({path:n,scope:e}){const{t}=Ce(),i=Si();return _.useEffect(()=>{n&&i.getState().activePage!==n&&i.getState().loadPage(n)},[n]),_.useEffect(()=>()=>Wr(e),[e]),n?a.jsx(bd,{}):a.jsx("div",{className:"amx-panel",children:a.jsx("div",{className:"amx-panel-empty",children:t("amxv.outline.noNote")})})}const Cw=Object.freeze(Object.defineProperty({__proto__:null,AmadeusBacklinksView:Bf,AmadeusEditorView:h_,AmadeusOutlineView:bd,AmadeusPagesView:n_,AmxMobileBar:_d,Breadcrumb:Jo,NoteTabIcon:l_,NoteTitle:wd,ScopedPageOutline:p_,pageStyleSheetActions:fd},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 lt=({children:n})=>a.jsx("div",{className:"dash-widget",children:a.jsx("div",{className:"dash-widget-note",children:n})});function xd(n){const e=Bi(t=>t.gen);return _.useEffect(()=>{n&&Bi.getState().load(n,n)},[n,e]),Bi(t=>n?t.entries[n]:void 0)}function yd(){const[n,e]=_.useState(ua),[t,i]=_.useState(0);return _.useEffect(()=>{const s=new Date,o=new Date(s.getFullYear(),s.getMonth(),s.getDate()+1).getTime(),r=setTimeout(()=>{e(ua()),i(l=>l+1)},Math.max(o-s.getTime()+1e3,1e3));return()=>clearTimeout(r)},[n,t]),n}function Dd(n){const e=new Map(n.map(t=>[t.id,ol(t.type)]));return t=>e.get(t)??null}function v_({opts:n,filters:e}){const{t}=Ce(),i=_.useMemo(()=>xh(n),[JSON.stringify(n)]),s=i.ok?i.spec.source:"",o=xd(s);if(!i.ok)return a.jsx(lt,{children:t("dashcards.statError",{err:i.error})});if(i.spec.literal!==null){const r=i.spec;return a.jsxs("div",{className:"dash-widget dash-stat",children:[a.jsxs("div",{className:"dash-stat-value",children:[r.literal,r.unit&&a.jsx("span",{className:"dash-stat-unit",children:r.unit})]}),a.jsx("div",{className:"dash-stat-label",children:r.label||"—"})]})}return a.jsx(g_,{spec:i.spec,entry:o,filters:e})}function g_({spec:n,entry:e,filters:t}){const{t:i}=Ce(),s=yd(),o=_.useMemo(()=>{if(!e?.data)return null;const l=Dd(e.data.columns);return Dh(e.data.rows,e.data.columns,n,t,l,e.data.views)},[e?.data,n,t,s]);if(!e||e.status==="loading")return a.jsx(lt,{children:i("dashcards.loading")});if(e.status==="missing")return a.jsx(lt,{children:i("dashcards.missing",{source:n.source})});if(e.status==="corrupt")return a.jsx(lt,{children:i("dashcards.corrupt",{source:n.source,err:e.message})});if(!o)return a.jsx(lt,{children:i("dashcards.noData")});if(o.error)return a.jsx(lt,{children:i("dashcards.statError",{err:o.error})});const r=n.label||(n.col?`${n.col} · ${n.stat}`:e.data?.name||i("dashcards.rowCount"));return a.jsxs("div",{className:"dash-widget dash-stat",children:[a.jsxs("div",{className:"dash-stat-value",children:[o.text,n.unit&&a.jsx("span",{className:"dash-stat-unit",children:n.unit})]}),a.jsx("div",{className:"dash-stat-label",children:r}),!!t.length&&a.jsx("div",{className:"dash-stat-sub",children:i("dashcards.filteredRows",{n:o.rows})})]})}function f_({opts:n,filters:e}){const{t}=Ce(),i=_.useMemo(()=>yh(n),[JSON.stringify(n)]),s=i.ok?i.spec.source:"",o=xd(s);return i.ok?a.jsx(__,{spec:i.spec,entry:o,filters:e}):a.jsx(lt,{children:t("dashcards.chartError",{err:i.error})})}function __({spec:n,entry:e,filters:t}){const{t:i}=Ce(),s=yd(),o=_.useMemo(()=>{if(!e?.data)return null;const d=Dd(e.data.columns);return Ch(e.data.rows,e.data.columns,n,t,d,e.data.views)},[e?.data,n,t,s]);if(!e||e.status==="loading")return a.jsx(lt,{children:i("dashcards.loading")});if(e.status==="missing")return a.jsx(lt,{children:i("dashcards.missing",{source:n.source})});if(e.status==="corrupt")return a.jsx(lt,{children:i("dashcards.corrupt",{source:n.source,err:e.message})});if(!o)return a.jsx(lt,{children:i("dashcards.noData")});if(o.error)return a.jsx(lt,{children:i("dashcards.chartError",{err:o.error})});if(!o.slices.length)return a.jsx(lt,{children:i("dashcards.noMatch")});const r=n.agg==="count"?i("dashcards.aggCount"):i(n.agg==="sum"?"dashcards.aggSum":"dashcards.aggAvg",{col:n.value}),l=n.label||`${n.group} · ${r}`;return a.jsxs("div",{className:"dash-chart",children:[a.jsx("div",{className:"dash-chart-title",children:l}),a.jsx("div",{className:"dash-chart-body",children:n.kind==="donut"?a.jsx(Sh,{slices:o.slices}):n.kind==="line"?a.jsx(Ph,{slices:o.slices}):a.jsx(kh,{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 Pr({widget:n,filters:e=[]}){return n.kind==="clock"?a.jsx(b_,{opts:n.opts}):n.kind==="weather"?a.jsx(C_,{opts:n.opts}):n.kind==="webview"?a.jsx(S_,{opts:n.opts}):n.kind==="section"?a.jsx(w_,{opts:n.opts}):n.kind==="stat"?a.jsx(v_,{opts:n.opts,filters:e}):n.kind==="chart"?a.jsx(f_,{opts:n.opts,filters:e}):null}function w_({opts:n}){const{t:e}=Ce();return a.jsxs("div",{className:"dash-widget dash-section",children:[a.jsx("span",{className:"dash-section-title",children:n.title||e("dashwidget.sectionUntitled")}),n.note&&a.jsx("span",{className:"dash-section-note",children:n.note})]})}function Cd(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function b_({opts:n}){const{t:e,locale:t}=Ce(),[i,s]=_.useState(()=>new Date);_.useEffect(()=>{let c;const h=window.setTimeout(()=>{s(new Date),c=window.setInterval(()=>s(new Date),1e3)},1e3-Date.now()%1e3);return()=>{clearTimeout(h),c&&clearInterval(c)}},[]);const o=n.tz||Cd();let r,l,d=!1;try{({time:r,date:l}=pa(i,{locale:t,timeZone:o}))}catch{d=!0,{time:r,date:l}=pa(i,{locale:t})}return a.jsxs("div",{className:"dash-widget dash-clock",children:[a.jsx("div",{className:"dash-clock-time",children:r}),a.jsxs("div",{className:"dash-clock-sub",children:[l,(n.label||o)&&a.jsx("span",{className:"dash-clock-tz",children:n.label||o.split("/").pop()})]}),d&&a.jsx("div",{className:"dash-widget-note",children:e("dashwidget.clockBadTz",{tz:o})})]})}function x_(n){return n===0?{icon:"☀️",key:"dashwidget.wmoClear"}:n<=2?{icon:"🌤️",key:"dashwidget.wmoPartly"}:n===3?{icon:"☁️",key:"dashwidget.wmoOvercast"}:n<=49?{icon:"🌫️",key:"dashwidget.wmoFog"}:n<=59?{icon:"🌦️",key:"dashwidget.wmoDrizzle"}:n<=69?{icon:"🌧️",key:"dashwidget.wmoRain"}:n<=79?{icon:"🌨️",key:"dashwidget.wmoSnow"}:n<=84?{icon:"🌧️",key:"dashwidget.wmoShowers"}:n<=94?{icon:"🌨️",key:"dashwidget.wmoSnowShowers"}:{icon:"⛈️",key:"dashwidget.wmoThunder"}}async function y_(n,e){let t=Number(n.lat),i=Number(n.lon),s=n.label||n.city||"";if(!Number.isFinite(t)||!Number.isFinite(i)){const l=n.city||n.label;if(!l)throw new Error(Q("dashwidget.weatherNoCity"));const h=(await(await fetch(`https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(l)}&count=1&language=zh&format=json`,{signal:e})).json()).results?.[0];if(!h)throw new Error(Q("dashwidget.weatherCityNotFound",{city:l}));t=h.latitude,i=h.longitude,s=s||h.name}const r=await(await fetch(`https://api.open-meteo.com/v1/forecast?latitude=${t}&longitude=${i}&current=temperature_2m,weather_code,wind_speed_10m`,{signal:e})).json();if(!r.current)throw new Error(Q("dashwidget.weatherBadResponse"));return{temp:r.current.temperature_2m,code:r.current.weather_code,wind:r.current.wind_speed_10m,place:s}}const D_=900*1e3;function C_({opts:n}){const{t:e}=Ce(),[t,i]=_.useState(null),[s,o]=_.useState(null),r=JSON.stringify(n);if(_.useEffect(()=>{const d=new AbortController,c=()=>{y_(n,d.signal).then(u=>{i(u),o(null)}).catch(u=>{d.signal.aborted||o(u instanceof Error?u.message:String(u))})};c();const h=window.setInterval(c,D_);return()=>{d.abort(),clearInterval(h)}},[r]),s)return a.jsx("div",{className:"dash-widget dash-weather",children:a.jsx("div",{className:"dash-widget-note",children:e("dashwidget.weatherError",{msg:s})})});if(!t)return a.jsx("div",{className:"dash-widget dash-weather",children:a.jsx("div",{className:"dash-widget-note",children:e("dashwidget.loading")})});const l=x_(t.code);return a.jsxs("div",{className:"dash-widget dash-weather",children:[a.jsxs("div",{className:"dash-weather-main",children:[a.jsx("span",{className:"dash-weather-icon",children:l.icon}),a.jsxs("span",{className:"dash-weather-temp",children:[Math.round(t.temp),"°"]})]}),a.jsxs("div",{className:"dash-clock-sub",children:[e(l.key)," · ",e("dashwidget.weatherWind",{n:Math.round(t.wind)}),t.place&&a.jsx("span",{className:"dash-clock-tz",children:t.place})]})]})}function S_({opts:n}){const{t:e}=Ce(),t=n.url||"",i=_.useRef(null);return t?al(t)?window.tangu?a.jsx(zh,{ref:i,src:t,partition:Th,className:"dash-webview"}):a.jsx("div",{className:"dash-widget",children:a.jsxs("div",{className:"dash-widget-note",children:[e("dashwidget.webviewUnsupported")," · ",a.jsx("a",{href:t,target:"_blank",rel:"noreferrer",children:t})]})}):a.jsx("div",{className:"dash-widget",children:a.jsxs("div",{className:"dash-widget-note",children:[e("dashwidget.webviewBlocked"),a.jsx("br",{}),a.jsx("code",{children:t.slice(0,120)})]})}):a.jsx("div",{className:"dash-widget",children:a.jsx("div",{className:"dash-widget-note",children:e("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 P_({dashLeafId:n,dashPath:e,blockId:t,opts:i,size:s,onClose:o}){const r=Si(),{t:l}=Ce(),d=i.type??"",[,c]=_.useState(0);_.useEffect(()=>Nr(()=>c(C=>C+1)),[]);const h=_.useRef(o);h.current=o;const u=JSON.stringify(i),m=_.useMemo(()=>{const{type:C,...b}=JSON.parse(u);return b},[u]),g=_.useMemo(()=>({id:`${n}::${t}`,type:d,loc:"main",params:m,setTitle:()=>{},setParams:C=>{const b=r.getState();if(b.activePage!==e)return;const D={type:d};for(const[P,y]of Object.entries(C))P!=="type"&&(typeof y=="string"||typeof y=="number"||typeof y=="boolean")&&(D[P]=String(y));const k=Fe("view",D);(b.blocks[t]?.content??"").trim()!==k&&b.setBlockContent(t,k)},close:()=>h.current()}),[n,e,t,d,m,r]);if(!d)return a.jsx("div",{className:"dash-widget",children:a.jsx("div",{className:"dash-widget-note",children:l("viewcard.missingType")})});const p=yi(d);if(!p)return a.jsx("div",{className:"dash-widget",children:a.jsx("div",{className:"dash-widget-note",children:l("viewcard.unavailable",{type:d})})});const f=s??p.dashboard?.defaultSize??"lg",w=p.dashboard?.factory?p.dashboard.factory({leaf:g,params:m},{size:f}):p.factory({leaf:g,params:m});return a.jsx("div",{className:`wb-view dash-viewcard${p.dashboard?.factory?" dash-viewcard--compact":" dash-viewcard--interactive"}`,"data-view-type":d,onPointerDownCapture:()=>{d==="amadeus-editor"&&Wi(g.id)},children:w})}const kr=new Set(["chat","browser","terminal","dashboard","amadeus-dashboard","sidebar-empty","home"]);function k_(n,e){return n.type==="outline"?{param:"sourcePath",accept:(t,i)=>e(i)==="amadeus-editor"}:!n.idParam||!n.fileMatch?null:{param:n.idParam,accept:(t,i)=>e(i)===n.type}}async function z_(n){const e=Bi.getState();await e.load(n,n);const t=Bi.getState().entries[n]?.data;if(!t)return null;const i=ea(t),s=i.find(d=>d.type==="chart");if(s)return s.name;const o=new Set(i.map(d=>d.name));let r="图表";for(let d=2;o.has(r);d++)r=`图表 ${d}`;const l={id:Rd(),name:r,type:"chart"};return e.mutate(n,d=>({...d,views:[...ea(d),l]})),r}function T_(n,e){const t=Object.entries(n).find(([s,o])=>s!=="type"&&/path$/i.test(s)&&o);if(!t)return e;const i=(t[1].split(/[\\/]/).pop()??t[1]).replace(/\.[^.]+$/,"");return i?`${e} · ${i}`:e}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 E_(){const n=Bi(e=>e.entries);return _.useMemo(()=>{const e=new Map;for(const t of Object.values(n))if(!(t.status!=="ok"||!t.data))for(const i of t.data.columns)e.has(i.name)||e.set(i.name,{name:i.name,kind:ol(i.type),options:i.options??[]});return[...e.values()].sort((t,i)=>t.name.localeCompare(i.name))},[n])}function G_({filters:n,editable:e,onChange:t}){const i=E_(),[s,o]=_.useState(!1),[r,l]=_.useState(null),d=ns(s),{t:c}=Ce();if(!n.length&&!e)return null;const h=()=>{const p=i[0];p&&(l({prop:p.name,op:js[p.kind]?.[0]??"eq",value:""}),o(!0))},u=r?i.find(p=>p.name===r.prop):null,m=u?js[u.kind]??["eq"]:["eq"],g=()=>{if(!r)return;const p=va.has(r.op);!p&&!r.value.trim()||(t([...n,{prop:r.prop,op:r.op,...p?{}:{value:r.value.trim()}}]),l(null),o(!1))};return a.jsxs("div",{className:"dash-filterbar",children:[a.jsx(Eh,{size:12,className:"dash-filterbar-label"}),a.jsx("span",{className:"dash-filterbar-label",children:c("dashfilter.label")}),n.map((p,f)=>a.jsxs("span",{className:"dash-filter-chip",children:[a.jsx("b",{children:p.prop}),a.jsx("span",{children:ma[p.op]??p.op}),p.value!==void 0&&a.jsx("span",{children:p.value}),e&&a.jsx("button",{title:c("dashfilter.remove"),onClick:()=>t(n.filter((w,C)=>C!==f)),children:a.jsx(Cn,{size:11})})]},`${p.prop}-${p.op}-${f}`)),e&&a.jsxs("span",{style:{position:"relative",display:"inline-flex"},children:[a.jsxs("button",{className:"dash-filter-add",onClick:h,disabled:!i.length,title:i.length?c("dashfilter.addTitle"):c("dashfilter.noCards"),children:[a.jsx(ui,{size:11})," ",c("dashfilter.add")]}),s&&r&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"dash-menu-scrim",onClick:()=>{o(!1),l(null)}}),a.jsxs("div",{ref:d.ref,className:"dash-add-menu dash-filter-editor",style:d.style,children:[a.jsx("select",{value:r.prop,onChange:p=>{const f=i.find(w=>w.name===p.target.value);l({prop:p.target.value,op:(f&&js[f.kind]?.[0])??"eq",value:""})},children:i.map(p=>a.jsx("option",{value:p.name,children:p.name},p.name))}),a.jsx("select",{value:r.op,onChange:p=>l({...r,op:p.target.value}),children:m.map(p=>a.jsx("option",{value:p,children:ma[p]??p},p))}),!va.has(r.op)&&(u?.options.length?a.jsxs("select",{value:r.value,onChange:p=>l({...r,value:p.target.value}),children:[a.jsx("option",{value:"",children:c("dashfilter.pickOne")}),u.options.map(p=>a.jsx("option",{value:p,children:p},p))]}):a.jsx("input",{value:r.value,placeholder:c("dashfilter.valuePlaceholder"),onChange:p=>l({...r,value:p.target.value}),onKeyDown:p=>{p.key==="Enter"&&g()},autoFocus:!0})),a.jsx("button",{className:"dash-filter-commit",onClick:g,children:c("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 I_=[{key:"section",labelKey:"dashgrid.add.section",icon:Ku},{key:"stat",labelKey:"dashgrid.add.stat",icon:Mh},{key:"chart",labelKey:"dashgrid.add.chart",icon:Lh},{key:"text",labelKey:"dashgrid.add.text",icon:cl},{key:"clock",labelKey:"dashgrid.add.clock",icon:rl},{key:"weather",labelKey:"dashgrid.add.weather",icon:Bu},{key:"webview",labelKey:"dashgrid.add.webview",icon:Ni}],A_={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"},N_=[{key:"today",nameKey:"dashgrid.tpl.today.name",hintKey:"dashgrid.tpl.today.hint",cards:[{content:Fe("section",{title:Q("dashgrid.tpl.today")}),w:12,h:1},{content:Fe("clock",{}),w:6,h:2},{content:Fe("weather",{city:"上海"}),w:6,h:2},{content:Fe("view",{type:"todo-list"}),w:6,h:5},{content:Fe("view",{type:"calendar"}),w:6,h:5}]},{key:"work",nameKey:"dashgrid.tpl.work.name",hintKey:"dashgrid.tpl.work.hint",cards:[{content:Fe("section",{title:Q("dashgrid.tpl.doing")}),w:12,h:1},{content:Fe("view",{type:"inbox-list"}),w:6,h:5},{content:Fe("view",{type:"todo-list"}),w:6,h:5},{content:Fe("section",{title:Q("dashgrid.tpl.recent")}),w:12,h:1},{content:Fe("view",{type:"activity-log"}),w:12,h:5}]},{key:"blank",nameKey:"dashgrid.tpl.blank.name",hintKey:"dashgrid.tpl.blank.hint",cards:[]}],un=n=>n==="section",Zo={w:4,h:3},Sd={sizes:["lg","full"],defaultSize:"lg",surface:"workspace",min:Zo},zr={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:Zo},text:{sizes:["md","wide","lg","full"],defaultSize:"wide",surface:"note"}},Us=n=>n.min??Fh(n.sizes);function Ii(n){const e=bi(n);if(e?.kind==="view"){const t=yi(e.opts.type??"")?.dashboard;return t?{sizes:t.sizes,defaultSize:t.defaultSize,surface:t.surface??"workspace",min:t.min??Zo}:Sd}return zr[e?.kind??"text"]??zr.text}const is=(n,e=0)=>{const t=Qs(n);return{order:e,w:t.w,h:t.h}},j_=()=>null;function O_(n,e,t){const i=n.indexOf(e),s=n.indexOf(t);if(i<0||s<0||i===s)return n;const o=n.filter(r=>r!==e);return o.splice(i<s?o.indexOf(t)+1:o.indexOf(t),0,e),o}const M_=(n,e)=>Wh(n,e)??e[0]??"lg",L_=[],R_={},Tr=(n,e)=>{if(!n)return!1;const t=Object.keys(n);return t.length===Object.keys(e).length&&t.every(i=>e[i]&&n[i].row===e[i].row&&n[i].col===e[i].col)};function Sw(n){return a.jsx(zo.Provider,{value:n.leaf.id,children:a.jsx(V_,{...n})})}function V_({leaf:n}){const{t:e}=Ce(),t=Si(),i=pd(n,"dashPath"),s=n.params.locked!==!1,o=nl(x=>x.mode),r=K(x=>x.manifest),l=K(x=>x.blocks),d=K(x=>x.activePage),c=K(x=>x.manifest?.fmExtra??""),h=Be(x=>!!i&&x.pins.includes(i)),u=Dg(),[m,g]=_.useState(!1),[p,f]=_.useState(null),[w,C]=_.useState(null),b=ns(m),D=ns(p?`${p.x},${p.y}`:""),k=ns(w?`${w.x},${w.y}`:""),[P,y]=_.useState(!1);_.useEffect(()=>{i&&n.setTitle(Os(i))},[i]),_.useEffect(()=>{i&&i!==t.getState().activePage&&t.getState().loadPage(i)},[i]);const T=Xe(x=>x.mainTabs.find(I=>I.id===n.id)?.active??!1);_.useEffect(()=>{T&&Wi(n.id)},[T,n.id]);const S=_.useMemo(()=>{if(!r)return[];const x=[];for(const I of r.root.children)for(const M of I.columns)for(const Z of M.children)x.push(Z.ref);return x},[r]),N=_.useMemo(()=>Ms(c),[c]),O=N.ok?N.layout:{},$=N.ok&&Gh(O,S),F=_.useMemo(()=>ga(c),[c]),q=F.ok?F.pins:R_,re=_.useMemo(()=>Ih(c),[c]),V=re.ok?re.filters:L_,B=()=>{const x=t.getState();return x.activePage===i?x.loadNonce:null},te=(x,I)=>{const M=t.getState();if(M.activePage!==i||I!==void 0&&(I===null||M.loadNonce!==I))return!1;const Z=M.manifest?.fmExtra??"";return x===null||x===Z?!1:(M.setFmExtra(x),!0)},we=(x,I)=>te(Ls(t.getState().manifest?.fmExtra??"",x),I),xe=()=>{const x=Ms(t.getState().manifest?.fmExtra??"");return x.ok?x.layout:null};_.useEffect(()=>{if(!r||d!==i||!S.length||!N.ok||$)return;const x=fa(O,S),I=F.ok?Ah(q,S):null;if(!x&&!I)return;let M=t.getState().manifest?.fmExtra??"";x&&(M=Ls(M,x)??M),I&&(M=Rs(M,I)??M),te(M)},[S,O,q,r,d,i,N.ok,F.ok,$]);const j=_.useRef(null),de=_.useRef(null),[ce,be]=_.useState(0);_.useLayoutEffect(()=>{const x=de.current;if(!x)return;const I=new ResizeObserver(([Z])=>be(Z.contentRect.width));I.observe(x);const M=getComputedStyle(x);return be(x.clientWidth-parseFloat(M.paddingLeft||"0")-parseFloat(M.paddingRight||"0")),()=>I.disconnect()},[]);const Se=Nh(ce),st=Se>0?(ce-zt*(Se-1))/Se:0,L=_.useMemo(()=>jh(O,S),[O,S]),[J,oe]=_.useState(null),ae=_.useRef(new Map),Pe=_.useRef(null),ge=_.useRef(null),H=(x,I)=>{if(s||ge.current)return;x.preventDefault(),x.stopPropagation();const M=Ii(l[I]?.content??""),Z=Us(M),pe=O[I]??is(M.defaultSize),ue=ae.current.get(I)??{...pe,w:Math.max(Z.w,pe.w),h:Math.max(Z.h,pe.h)};ge.current={id:I,pointerId:x.pointerId,nonce:B(),x:x.clientX,y:x.clientY,w:ue.w,h:ue.h},Pe.current={id:I,w:ue.w,h:ue.h},oe({id:I,w:ue.w,h:ue.h}),x.currentTarget.setPointerCapture(x.pointerId)},ie=x=>{const I=ge.current;if(!I||I.pointerId!==x.pointerId||st<=0)return;const M=Hh(I.w,Se),Z=M*st+(M-1)*zt+(x.clientX-I.x),pe=Math.max(1,Math.min(Se,Math.round((Z+zt)/(st+zt)))),ue=Math.max(1,Math.min(on,Math.round(pe*on/Se))),ye=I.h*an+(I.h-1)*zt+(x.clientY-I.y),De=Math.max(1,Math.min(Zh,Math.round((ye+zt)/(an+zt)))),Re=Ii(l[I.id]?.content??""),Pt=Us(Re),ut={w:Math.max(Pt.w,ue),h:Math.max(Pt.h,De)};Pe.current={id:I.id,w:ut.w,h:ut.h},oe(kt=>kt&&kt.w===ut.w&&kt.h===ut.h?kt:{id:I.id,w:ut.w,h:ut.h})},xt=x=>{const I=ge.current;if(I&&x&&I.pointerId!==x.pointerId)return;const M=Pe.current;if(ge.current=null,Pe.current=null,oe(null),!I||!M||M.w===I.w&&M.h===I.h)return;const Z=xe();!Z||!Z[I.id]||we({...Z,[I.id]:{...Z[I.id],w:M.w,h:M.h}},I.nonce)},yt=x=>{const I=ga(t.getState().manifest?.fmExtra??"");if(!I.ok||!I.pins[x])return;const M=I.pins[x].row,Z={};for(const[pe,ue]of Object.entries(I.pins))ue.row!==M&&(Z[pe]=ue);te(Rs(t.getState().manifest?.fmExtra??"",Z))},et=(x,I,M)=>{const Z=xe();!Z||!Z[x]||we({...Z,[x]:{...Z[x],w:I,h:M}})},Ht=qr(qs(Kh,{activationConstraint:{distance:4}}),qs(Xh,{activationConstraint:{delay:150,tolerance:8}})),[Dt,oi]=_.useState(null),[Ue,Ze]=_.useState(null);_.useLayoutEffect(()=>{s&&Ze(null)},[s]);const[dt,Nt]=_.useState(null),tt=_.useRef(null),[fe,Bt]=_.useState(null),it=_.useRef(null),Qe=_.useRef(0),ct=_.useRef(null),Ct=_.useRef({bands:[],byId:new Map}),ht=_.useRef(null),St=_.useRef(null),Ut=_.useRef(1),A=x=>{St.current=B(),Ze(null),ht.current=new Map(ae.current);const I=de.current,M=I&&I.offsetWidth>0?I.getBoundingClientRect().width/I.offsetWidth:1;Ut.current=Math.abs(M-1)<.005?1:M,Qe.current=Yh(q),ct.current=null,it.current=null,oi(String(x.active.id))},se=x=>{Tr(it.current,x)||(it.current=x,Bt(x))},le=x=>{const I=String(x.active.id),M=x.over?String(x.over.id):null;if(!M||M===I)return;ct.current=null;const Z={...q};delete Z[I],se(Z);const pe=tt.current??L,ue=O_(pe,I,M);ue.join(`
20
+ `)!==pe.join(`
21
+ `)&&(tt.current=ue,Nt(ue))},he=x=>{const I=String(x.active.id);if(x.over&&String(x.over.id)!==I||un(bi(l[I]?.content??"")?.kind)||!F.ok)return;const M=x.active.rect.current.translated,Z=de.current,pe=Z?.getBoundingClientRect(),ue=Ct.current.byId.get(I);if(!M||!Z||!pe||!ue||st<=0)return;const ye=getComputedStyle(Z),De=Ut.current,Re=x.activatorEvent,Pt=typeof Re?.clientY=="number"?Re.clientY:Re?.touches?.[0]?.clientY,ut=typeof Pt=="number"?Pt+x.delta.y:M.top+M.height/2,kt=(M.left-pe.left)/De-parseFloat(ye.paddingLeft||"0"),pt=(ut-pe.top)/De-parseFloat(ye.paddingTop||"0"),Mn=an+zt,jt=Ct.current.bands.findIndex(G=>pt>=G.top&&pt<G.top+G.h*Mn);if(jt<0)return;const li=Math.round(kt/(st+zt)),Qi=Math.max(0,Math.min(on-ue.w,Math.round(li*on/Se)));if(ct.current&&ct.current.band===jt&&ct.current.col===Qi)return;ct.current={band:jt,col:Qi};const en=Ct.current.bands[jt].ids.filter(G=>G!==I);if(en.some(G=>un(bi(l[G]?.content??"")?.kind)))return;const v=Uh(tt.current??L,it.current??q,[{id:I,col:Qi,w:ue.w},...en.map(G=>({id:G,col:Ct.current.byId.get(G)?.col??0,w:Ct.current.byId.get(G)?.w??1}))],Qe.current);se(v.pins),v.ids.join(`
22
+ `)!==(tt.current??L).join(`
23
+ `)&&(tt.current=v.ids,Nt(v.ids))},je=()=>{const x={nonce:St.current,seq:tt.current,pins:it.current};return St.current=null,tt.current=null,it.current=null,ht.current=null,ct.current=null,oi(null),Nt(null),Bt(null),x},ot=()=>{je()},ai=()=>{const{nonce:x,seq:I,pins:M}=je();if(!I&&!M)return;const Z=xe();if(!Z)return;const pe=(I??L).filter(Re=>S.includes(Re));for(const Re of S)pe.includes(Re)||pe.push(Re);const ue=pe.join(`
24
+ `)!==L.join(`
25
+ `),ye=!!M&&F.ok&&!Tr(M,q);if(!ue&&!ye)return;let De=t.getState().manifest?.fmExtra??"";ue&&(De=Ls(De,Bh(Z,pe))??De),ye&&(De=Rs(De,M)??De),te(De,x)},He=(x,I)=>{const M=t.getState();if(M.activePage!==i)return null;const Z=S[S.length-1]??null,pe=M.insertBlockAfter(Z,void 0,x);if(!pe)return null;const ue=Ms(t.getState().manifest?.fmExtra??"");if(ue.ok){const ye=Object.values(ue.layout).reduce((De,Re)=>Math.max(De,Re.order+1),0);we({...ue.layout,[pe]:{order:ye,w:I.w,h:I.h}})}return pe},In=x=>{g(!1),(async()=>{if(x==="text"){He("",Qh);return}if(x==="section"){const M=await Ot(e("dashgrid.add.section"),e("dashgrid.default.section"));if(!M?.trim())return;He(Fe("section",{title:M.trim()}),{w:12,h:1});return}if(x==="clock"){He(Fe("clock",{tz:Cd()}),Fn);return}if(x==="weather"){const M=await Ot(e("dashgrid.prompt.weather"),"上海");if(!M?.trim())return;He(Fe("weather",{city:M.trim()}),Fn);return}if(x==="stat"){await An();return}if(x==="chart"){await ri();return}const I=await Ot(e("dashgrid.prompt.webview"),"https://");if(I?.trim()){if(!al(I.trim())){Ke.getState().toast(e("dashgrid.webviewRejected"),!0);return}He(Fe("webview",{url:I.trim()}),eu)}})()},Ji=x=>new Promise(I=>{Zs.getState().openPicker({title:x,accept:(M,Z)=>_a(Z)==="amadeus-db",onPick:M=>I(M)})}),An=async()=>{const x=await Ji(e("dashgrid.pickDbStat"));if(!x)return;const I=(await Ot(e("dashgrid.prompt.statCol"),""))?.trim()??"";if(!I){He(Fe("stat",{source:x}),Fn);return}const M=(await Ot(e("dashgrid.prompt.statFn"),"sum"))?.trim();M&&He(Fe("stat",{source:x,col:I,stat:M}),Fn)},ri=async()=>{const x=await Ji(e("dashgrid.pickDbChart"));if(!x)return;const I=await z_(x);He(Fe("view",{type:"amadeus-db",dbPath:x,...I?{view:I}:{}}),is("lg"))},Pi=_.useMemo(()=>jr().filter(x=>x.embeddable&&!kr.has(x.type)).map(x=>({type:x.type,name:Xs(x.displayName),Icon:x.icon??Ni,spec:k_(x,_a)})).sort((x,I)=>x.name.localeCompare(I.name)),[m]),ki=x=>{g(!1);const I=yi(x.type),M=is(I?.dashboard?.defaultSize??Sd.defaultSize);if(!x.spec){He(Fe("view",{type:x.type}),M);return}const{param:Z,accept:pe}=x.spec;Zs.getState().openPicker({title:e("dashgrid.pickFileFor",{name:x.name}),accept:pe,onPick:ue=>{He(Fe("view",{type:x.type,[Z]:ue}),M)}})},Nn=x=>{const I=t.getState();if(I.activePage!==i||!x.cards.length)return;const M=xe();if(!M){Ke.getState().toast(e("dashgrid.layoutUnreadable"),!0);return}let Z=S[S.length-1]??null;const pe={...M};let ue=Object.values(pe).reduce((ye,De)=>Math.max(ye,De.order+1),0);for(const ye of x.cards){const De=I.insertBlockAfter(Z,void 0,ye.content);if(!De)break;pe[De]={order:ue++,w:ye.w,h:ye.h},Z=De}we(pe)},zi=x=>{t.getState().activePage===i&&t.getState().deleteBlock(x)},ks=x=>{te($h(t.getState().manifest?.fmExtra??"",x))},Ti=()=>{f(null),te(Jh(t.getState().manifest?.fmExtra??"","canvas"))};if(!i)return a.jsx("div",{className:"amx-draw-state",children:e("dashgrid.noFile")});const vi=x=>{const I=bi(l[x]?.content??"");if(I?.kind!=="view")return{widget:I,title:null,Icon:null,openable:null};const M=I.opts.type??"",Z=yi(M);if(!Z)return{widget:I,title:e("dashgrid.viewUnavailable",{type:M}),Icon:Ni,openable:null};const{type:pe,...ue}=I.opts;return{widget:I,title:T_(I.opts,Xs(Z.displayName)),Icon:Z.icon??Ni,openable:()=>Xe.getState().openView(M,ue,"main",{newTab:!0})}},gi=(x,I)=>{const M=bi(l[x]?.content??"");if(M?.kind==="view"){const Z=M.opts.type??"",pe=yi(Z);return!pe||kr.has(Z)||!pe.embeddable?a.jsx("div",{className:"dash-widget",children:a.jsx("div",{className:"dash-widget-note",children:e("dashgrid.viewNotEmbeddable",{type:Z})})}):a.jsx(P_,{dashLeafId:n.id,dashPath:i,blockId:x,opts:M.opts,size:I,onClose:()=>zi(x)})}return M?a.jsx(Pr,{widget:M,filters:V}):a.jsx(Xr,{blockId:x})},Zi=(()=>{if(!dt)return L;const x=dt.filter(I=>S.includes(I));for(const I of L)x.includes(I)||x.push(I);return x})(),jn=fe??q,zs=Oh(Zi.map(x=>{const I=Ii(l[x]?.content??""),M=O[x]??is(I.defaultSize),Z=ht.current?.get(x),pe=Z?{...M,w:Z.w,h:Z.h}:M,ue=J?.id===x?{...pe,...J}:pe,ye=un(bi(l[x]?.content??"")?.kind),De=Us(I),Re={key:M_(ue,I.sizes),w:Math.max(De.w,ue.w),h:Math.max(De.h,ue.h)},Pt=Qs(I.defaultSize),ut=!jn[x]&&(!O[x]||O[x].w===Pt.w&&O[x].h===Pt.h),kt=J?.id===x||!ut?[Re]:[Re,...I.sizes.map(pt=>Qs(pt)).filter(pt=>pt.w!==Re.w||pt.h!==Re.h)];return{id:x,preferred:ue,choices:kt,chrome:ye}}),jn,Se),Ei=[];{let x=1;const I=[],M=new Map;for(const Z of zs){let pe=1;const ue=[];for(const ye of Z.items){const De=ye.start??pe;Ei.push({id:ye.id,rowStart:x,rowSpan:ye.h,colStart:De,colSpan:ye.span,size:ye.size,cell:ye.cell,chrome:ye.chrome}),pe=De+ye.span,ue.push(ye.id),M.set(ye.id,{col:Math.round((De-1)*on/Se),w:ye.cell.w})}I.push({top:(x-1)*(an+zt),h:Z.h,ids:ue}),x+=Z.h}Ct.current={bands:I,byId:M}}ae.current=new Map(Ei.map(x=>[x.id,x.cell]));const On=(()=>{if(!Dt)return null;const x=bi(l[Dt]?.content??""),I=x?.kind??"text";if(x&&un(I))return a.jsx("div",{className:"dash3-card dash3-card--chrome dash3-card--lift",children:a.jsx("div",{className:"dash3-card-body",children:a.jsx(Pr,{widget:x})})});const M=vi(Dt);return a.jsxs("div",{className:"dash3-card dash3-card--lift","data-kind":I,"data-surface":Ii(l[Dt]?.content??"").surface,children:[M.title&&a.jsxs("div",{className:"dash3-card-head",children:[M.Icon&&a.jsx(M.Icon,{size:13,className:"dash3-card-icon"}),a.jsx("span",{className:"dash3-card-title",children:M.title})]}),a.jsx("div",{className:"dash3-card-body dash3-overlay-ghost"})]})})();return a.jsxs("div",{className:`am-app tangu-lovable amx-pane amx-editor dash3${P?" amx-dragover":""}`,"data-mode":o,onPointerDownCapture:x=>{Wi(n.id),Ue&&!x.target.closest?.(`.dash3-card[data-key="${CSS.escape(Ue)}"]`)&&Ze(null)},onDragOver:x=>{s||!Array.from(x.dataTransfer?.types??[]).includes("Files")||(x.preventDefault(),y(!0))},onDragLeave:x=>{x.currentTarget.contains(x.relatedTarget)||y(!1)},onDrop:x=>{y(!1);const I=Array.from(x.dataTransfer?.files??[]);s||!I.length||(x.preventDefault(),Wi(n.id),vs(I,i))},children:[a.jsxs("div",{className:"amx-toolbar",children:[a.jsx(Jo,{}),a.jsx("button",{className:`amx-mode-btn amx-pin-btn${h?" amx-pin-on":""}`,title:e(h?"dashgrid.unpin":"dashgrid.pin"),onClick:()=>Be.getState().togglePin(i),children:a.jsx(no,{size:14})}),a.jsxs("button",{className:`amx-mode-btn dash3-mode-btn${s?"":" amx-pin-on"}`,title:e(s?"dashgrid.editLayoutTip":"dashgrid.done"),onClick:()=>n.setParams({...n.params,locked:!s}),children:[s?a.jsx(mn,{size:13}):a.jsx(ei,{size:14}),a.jsx("span",{children:e(s?"dashgrid.editLayout":"dashgrid.done")})]}),a.jsx(nr,{initial:!1,children:!s&&a.jsxs(eo.div,{className:"dash-add-wrap",initial:u?!1:{opacity:0,scale:.9,x:-4},animate:{opacity:1,scale:1,x:0},exit:u?{opacity:0}:{opacity:0,scale:.9,x:-4},transition:{duration:u?0:.18,ease:[.16,1,.3,1]},children:[a.jsx("button",{className:"amx-mode-btn",title:e("dashgrid.addCard"),onClick:x=>{x.stopPropagation(),g(I=>!I)},children:a.jsx(ui,{size:14})}),m&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"dash-menu-scrim",onClick:()=>g(!1)}),a.jsxs("div",{ref:b.ref,className:"dash-add-menu",style:b.style,children:[I_.map(x=>a.jsxs("button",{onClick:()=>In(x.key),children:[a.jsx(x.icon,{size:13})," ",e(x.labelKey)]},x.key)),Pi.length>0&&a.jsx("div",{className:"dash-menu-sep",children:e("dashgrid.menuViews")}),Pi.map(x=>a.jsxs("button",{onClick:()=>ki(x),title:x.type,children:[a.jsx(x.Icon,{size:13})," ",x.name,x.spec?"…":""]},x.type))]})]})]})}),a.jsx("button",{className:"amx-mode-btn amx-more-btn",title:e("dashgrid.more"),onClick:x=>{x.stopPropagation();const I=x.currentTarget.getBoundingClientRect();f({x:Math.max(8,Math.min(I.right-180,window.innerWidth-196)),y:I.bottom+4})},children:a.jsx(Xi,{size:14})})]}),!N.ok&&a.jsx("div",{className:"dash-banner dash-banner-warn",children:e("dashgrid.fmBroken",{error:N.error})}),$&&a.jsxs("div",{className:"dash-banner",children:[e("dashgrid.staleBanner"),a.jsx("button",{onClick:()=>we(fa({},S)??{}),children:e("dashgrid.reflowNow")})]}),a.jsx(G_,{filters:V,editable:!s,onChange:ks}),a.jsx(Rh.Provider,{value:V,children:a.jsxs(eo.div,{layoutScroll:!0,ref:j,className:"dash3-host","data-locked":s||void 0,onPointerMove:ie,onPointerUp:xt,onPointerCancel:xt,children:[a.jsxs(Jr,{sensors:Ht,collisionDetection:el,measuring:{droppable:{strategy:Zr.Always}},onDragStart:A,onDragMove:he,onDragOver:le,onDragEnd:ai,onDragCancel:ot,children:[a.jsx(Yr,{items:Zi,strategy:j_,children:a.jsx("div",{ref:de,className:"dash3-grid",style:{"--dash3-cols":Se,"--dash3-row":`${an}px`,"--dash3-gap":`${zt}px`},children:ce>0&&a.jsx(nr,{initial:!1,mode:"popLayout",children:Ei.map(({id:x,rowStart:I,rowSpan:M,colStart:Z,colSpan:pe,size:ue})=>{const ye=vi(x);return a.jsx(F_,{id:x,rowStart:I,rowSpan:M,colStart:Z,colSpan:pe,locked:s,chrome:un(ye.widget?.kind),kind:ye.widget?.kind??"text",surface:Ii(l[x]?.content??"").surface,size:ue,dragging:Dt===x,sizing:J?.id===x,interact:Ue===x,reduceMotion:!!u,title:ye.title,Icon:ye.Icon,onOpen:ye.openable,onInteract:()=>Ze(x),onDelete:()=>zi(x),onMenu:(De,Re)=>C({x:De,y:Re,id:x}),onGripDown:De=>H(De,x),children:gi(x,ue)},x)})})})}),a.jsx(Qr,{zIndex:30,style:Ut.current!==1?{zoom:1/Ut.current}:void 0,dropAnimation:u?null:{duration:200,easing:"cubic-bezier(0.16, 1, 0.3, 1)"},children:On})]}),!S.length&&a.jsx("div",{className:"dash3-empty",children:a.jsxs("div",{className:"dash3-empty-panel",children:[a.jsx("div",{className:"dash3-empty-mark","aria-hidden":"true",children:a.jsx(Ni,{size:18})}),a.jsxs("div",{className:"dash3-empty-copy",children:[a.jsx("div",{className:"dash3-empty-title",children:e("dashgrid.emptyTitle")}),a.jsx("div",{className:"dash3-empty-sub",children:e("dashgrid.emptySub")})]}),a.jsx("div",{className:"dash3-templates","aria-label":e("dashgrid.templatesLabel"),children:N_.filter(x=>x.cards.length).map(x=>{const I=x.key==="today"?rl:Ni;return a.jsxs("button",{type:"button",className:"dash3-template",onClick:()=>Nn(x),children:[a.jsx("span",{className:"dash3-template-icon","aria-hidden":"true",children:a.jsx(I,{size:16})}),a.jsxs("span",{className:"dash3-template-copy",children:[a.jsx("span",{className:"dash3-template-name",children:e(x.nameKey)}),a.jsx("span",{className:"dash3-template-hint",children:e(x.hintKey)})]})]},x.key)})})]})})]})}),w&&!s&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"dash-menu-scrim",onClick:()=>C(null)}),a.jsxs("div",{ref:k.ref,className:"dash-add-menu",style:{position:"fixed",left:w.x,top:w.y,...k.style},children:[a.jsx("div",{className:"dash-menu-sep",children:e("dashgrid.menuSize")}),Vh.filter(x=>Ii(l[w.id]?.content??"").sizes.includes(x.key)).map(x=>a.jsxs("button",{onClick:()=>{et(w.id,x.w,x.h),C(null)},children:[e(A_[x.key])," ",a.jsxs("span",{className:"dash3-size-dim",children:[x.w,"×",x.h]})]},x.key)),q[w.id]&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"dash-menu-sep"}),a.jsx("button",{onClick:()=>{yt(w.id),C(null)},children:e("dashgrid.restoreAuto")})]}),a.jsx("div",{className:"dash-menu-sep"}),a.jsx("button",{className:"dash-danger",onClick:()=>{zi(w.id),C(null)},children:e("dashgrid.deleteCard")})]})]}),p&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"dash-menu-scrim",onClick:()=>f(null)}),a.jsxs("div",{ref:D.ref,className:"dash-add-menu",style:{position:"fixed",left:p.x,top:p.y,...D.style},children:[a.jsx("button",{onClick:Ti,children:e("dashgrid.switchToCanvas")}),a.jsx("button",{onClick:()=>{f(null),(async()=>{const x=(await Ot(e("dashgrid.renameTitle"),Os(i)))?.trim().replace(/[\\/]/g,"");if(!x)return;const I=await t.getState().renamePage(`${x}.dashboard`),M=t.getState().activePage;I&&M&&M!==i&&n.setParams({...n.params,dashPath:M})})()},children:e("dashgrid.rename")}),a.jsx("button",{className:"dash-danger",onClick:()=>{f(null),window.confirm(e("dashgrid.confirmDelete",{name:Os(i)}))&&t.getState().deletePage(i).then(()=>{const x=t.getState().error;if(x){Ke.getState().toast(e("dashgrid.deleteFailed",{error:x}),!0);return}Ke.getState().toast(e("dashgrid.deleted")),Xe.getState().closeLeaf(n.id)})},children:e("dashgrid.delete")})]})]})]})}function F_({id:n,rowStart:e,rowSpan:t,colStart:i,colSpan:s,locked:o,chrome:r,kind:l,surface:d,size:c,dragging:h,sizing:u,interact:m,reduceMotion:g,title:p,Icon:f,children:w,onOpen:C,onInteract:b,onDelete:D,onMenu:k,onGripDown:P}){const{t:y}=Ce(),{attributes:T,listeners:S,setNodeRef:N,isDragging:O}=qh({id:n,disabled:o,transition:null}),$={gridRow:`${e} / span ${t}`,gridColumn:`${i} / span ${s}`};return a.jsx(eo.div,{ref:N,layout:!0,className:"dash3-card-slot",style:$,initial:g?!1:{opacity:0,scale:.97,y:8},animate:{opacity:1,scale:1,y:0},exit:g?{opacity:0}:{opacity:0,scale:.96,y:-6},transition:{duration:g?0:u?.16:.28,ease:[.16,1,.3,1]},children:a.jsxs("div",{className:`dash3-card${r?" dash3-card--chrome":""}`,"data-key":n,"data-kind":l,"data-surface":d,"data-size":c,"data-dragging":O||h||void 0,"data-sizing":u||void 0,"data-interact":m||void 0,children:[p&&!r&&a.jsxs("div",{className:"dash3-card-head",children:[f&&a.jsx(f,{size:13,className:"dash3-card-icon"}),a.jsx("span",{className:"dash3-card-title",children:p}),o&&C&&a.jsx("button",{type:"button",className:"dash3-card-open",title:y("dashgrid.openInTab"),"aria-label":y("dashgrid.openInTabAria",{title:p}),onClick:C,children:a.jsx(Ai,{size:12})})]}),a.jsx("div",{className:"dash3-card-body",children:w}),!o&&a.jsxs(a.Fragment,{children:[!m&&a.jsx("div",{className:"dash3-shield",...T,...S,onDoubleClick:r?void 0:b,title:y(r?"dashgrid.dragToReorder":"dashgrid.dragOrEnter")}),a.jsx("button",{type:"button",className:"dash3-card-btn dash3-card-more",title:y("dashgrid.sizeAndMore"),"aria-label":y("dashgrid.setCardSize"),onClick:F=>{F.stopPropagation();const q=F.currentTarget.getBoundingClientRect();k(Math.max(8,Math.min(q.left-60,window.innerWidth-196)),q.bottom+4)},children:a.jsx(Xi,{size:12})}),a.jsx("button",{type:"button",className:"dash3-card-btn dash3-card-del",title:y("dashgrid.deleteThisCard"),"aria-label":y("dashgrid.deleteThisCard"),onClick:F=>{F.stopPropagation(),D()},children:a.jsx(gt,{size:12})}),!r&&a.jsx("div",{className:"dash3-grip",title:y("dashgrid.resize"),onPointerDown:P})]})]})})}export{nr as A,Jo as B,io as C,Sw as D,kr as E,br as F,mg as G,Dw as H,Ko as I,yw as J,Vf as K,$n as L,n_ as M,wd as N,p_ as O,no as P,bd as Q,Og as R,ji as S,Cw as T,P_ as V,vw as W,ip as a,fw as b,pd as c,Bu as d,sd as e,z_ as f,Pr as g,Dg as h,vs as i,kf as j,l_ as k,Cd as l,h_ as m,Bf as n,ww as o,k_ as p,_w as q,bw as r,gw as s,xw as t,We as u,Ps as v,Vi as w,_r as x,os as y,cf as z};