@forsion/unit 2.12.2 → 2.13.1

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 (204) hide show
  1. package/README.md +61 -0
  2. package/backendWorker.mjs +6 -2
  3. package/main.mjs +991 -497
  4. package/package.json +1 -1
  5. package/release.json +5 -5
  6. package/web/assets/ArtificialView-XwHMLUFb.js +1 -0
  7. package/web/assets/{AutomationBuilder-sxWdUa0L.js → AutomationBuilder-hqs0QhMt.js} +1 -1
  8. package/web/assets/CalendarConfigView-DKib8Oed.js +1 -0
  9. package/web/assets/CalendarView-DJ5iOzvu.js +1 -0
  10. package/web/assets/CapabilityMenu-SwVlZ06x.js +1 -0
  11. package/web/assets/{CheckboxInput-BsaoUHZ0.js → CheckboxInput-BC-5a_C9.js} +1 -1
  12. package/web/assets/Chrome-HdfyYV3i.js +1 -0
  13. package/web/assets/{CodeView-j065KtVh.js → CodeView-CFL6yQ-6.js} +3 -3
  14. package/web/assets/DashboardGridView-B9DCWYVb.js +17 -0
  15. package/web/assets/{EventCard-BmDQkEj9.js → EventCard-B_ndpqH_.js} +1 -1
  16. package/web/assets/ExcalidrawCanvas-BQ4KKLJP.js +1 -0
  17. package/web/assets/{FloatingToc-CENybkAA.js → FloatingToc-Ce9GamvH.js} +1 -1
  18. package/web/assets/HomepageView-RCOfcVbE.js +1 -0
  19. package/web/assets/ImageStudioPanels-lkS_y2uM.js +3 -0
  20. package/web/assets/ImageStudioView-UPv52acl.js +1 -0
  21. package/web/assets/InlineFiles-CQbQumkf.js +1 -0
  22. package/web/assets/MarkdownBlock--__nPQGh.css +1 -0
  23. package/web/assets/MarkdownBlock-CkqiwPXa.js +58 -0
  24. package/web/assets/ModelPill-CY-rU1RU.js +2 -0
  25. package/web/assets/MuseLibraryView-CtTHlVnT.js +2 -0
  26. package/web/assets/{MuseView-d-iBk3sc.js → MuseView-CC2A7MBs.js} +2 -2
  27. package/web/assets/{PageHistoryPanel-CR-k1AM7.js → PageHistoryPanel-KhKT1DLy.js} +2 -2
  28. package/web/assets/PdfAnnotator-C_kglLCA.css +1 -0
  29. package/web/assets/PdfAnnotator-DUyrgY-t.js +505 -0
  30. package/web/assets/{ProductView-u2aezVsl.js → ProductView-CgsIYZqD.js} +1 -1
  31. package/web/assets/RightPanel-BHDgqTFs.js +4 -0
  32. package/web/assets/RunLocationPicker-BE5mxnab.css +1 -0
  33. package/web/assets/RunLocationPicker-DBnXYV5B.js +38 -0
  34. package/web/assets/{SidebarRow-BuSkKH5q.js → SidebarRow-BAJxbMcx.js} +1 -1
  35. package/web/assets/{SketchCard-D87GADyG.js → SketchCard-BGYz-bXP.js} +5 -5
  36. package/web/assets/{StudioGuestSurface-BijU_EEb.js → StudioGuestSurface-lt6znmkl.js} +1 -1
  37. package/web/assets/{TodoListView-DPPVpPUn.js → TodoListView-DPKhee6i.js} +1 -1
  38. package/web/assets/{Tooltip-DY4ISA-e.js → Tooltip-ZxrDqN4p.js} +1 -1
  39. package/web/assets/UnifiedPage-BX6ZQL0h.js +68 -0
  40. package/web/assets/UnifiedPage-CWXc_mo1.css +1 -0
  41. package/web/assets/{amadeus-manual.en-DWaN2fPs.js → amadeus-manual.en-DzRWr4BL.js} +18 -18
  42. package/web/assets/{amadeus-manual.zh--7D5TS8X.js → amadeus-manual.zh-DW32DkL7.js} +18 -18
  43. package/web/assets/{appStore-Dg9WALEA.js → appStore-DWP8UET9.js} +208 -122
  44. package/web/assets/appStore-wtOILggO.css +1 -0
  45. package/web/assets/{arrow-up-right-CpQs92mu.js → arrow-up-right-DrCXuWS7.js} +1 -1
  46. package/web/assets/{astryxBridge-BZhaZPs4.js → astryxBridge-D-m4_kYt.js} +3 -3
  47. package/web/assets/automationListSource-C8BNy6RY.js +1 -0
  48. package/web/assets/book-open-OLNm7OaB.js +1 -0
  49. package/web/assets/{calendarNavStore-C7fGRpoH.js → calendarNavStore-Cylfvv3s.js} +1 -1
  50. package/web/assets/{canvasPrefs-BeG4oEgP.js → canvasPrefs-8taQ42Cz.js} +1 -1
  51. package/web/assets/chatBoxSurface-CIlzs45H.js +1 -0
  52. package/web/assets/{circle-question-mark-WL3vbp-Z.js → circle-question-mark-XbAFplz1.js} +1 -1
  53. package/web/assets/{circle-x-D7s-M5sB.js → circle-x-fcReAZaE.js} +1 -1
  54. package/web/assets/{client-BSKpsyAw.js → client-0MPbodA6.js} +1 -1
  55. package/web/assets/{code-xml-BALV9u_c.js → code-xml-Cuna8Kh4.js} +1 -1
  56. package/web/assets/{codeStudioStore-C2mWfm32.js → codeStudioStore-BBU62GTy.js} +1 -1
  57. package/web/assets/codingNavigation-CZB4v1ZW.css +1 -0
  58. package/web/assets/codingNavigation-DDlPpPk5.js +47 -0
  59. package/web/assets/{create-4xUyKtAF.js → create-BGtEfCcg.js} +4 -4
  60. package/web/assets/dashboardSurface-BYM3C7WG.js +1 -0
  61. package/web/assets/{deskCapture-Df701U8L.js → deskCapture-BiUCmqfc.js} +1 -1
  62. package/web/assets/{diff2html-BV-zCH4d.js → diff2html-BNp2FTbk.js} +1 -1
  63. package/web/assets/{docx-preview-DW4IyU_Q.js → docx-preview-CFznGVOU.js} +1 -1
  64. package/web/assets/{emoji-DGaxpCIu.js → emoji-6zl4yfOS.js} +1 -1
  65. package/web/assets/floatingTocSurface-DreXPCa6.js +1 -0
  66. package/web/assets/{foldActions-B7KByFdN.js → foldActions-05QcQziQ.js} +1 -1
  67. package/web/assets/folder-BpsfOHD4.js +1 -0
  68. package/web/assets/{folder-plus-D1TDb7k9.js → folder-plus-BeQHr4AZ.js} +1 -1
  69. package/web/assets/gestures-DQBCcK4y.js +1 -0
  70. package/web/assets/{hand-Crrw-nSn.js → hand-Bko7ms15.js} +1 -1
  71. package/web/assets/{hard-drive-BbyVSbfP.js → hard-drive-BpuI5ebj.js} +1 -1
  72. package/web/assets/i18n-ecQQxiMQ.css +1 -0
  73. package/web/assets/i18n.generated-BuLjnmY8.js +15 -0
  74. package/web/assets/imageStudio--KF9gwHA.css +1 -0
  75. package/web/assets/imageStudio-BLVNKmEG.js +2 -0
  76. package/web/assets/{index-DKhyDkGB.js → index-BF10xp_K.js} +1 -1
  77. package/web/assets/{index-C7U6T-k8.js → index-BHm6K743.js} +1 -1
  78. package/web/assets/{index-CF4RV4mh.js → index-BM2o7PeV.js} +90 -90
  79. package/web/assets/{index-Brik2pf9.js → index-BgnNNv3e.js} +1 -1
  80. package/web/assets/{index--drOLtq7.js → index-C0Gy2NQ6.js} +1 -1
  81. package/web/assets/{index-CflzrdSt.js → index-C1doZp5H.js} +1 -1
  82. package/web/assets/{index-SZ5waGAq.js → index-C4L6vjd_.js} +1 -1
  83. package/web/assets/{index-Cmr7gVZQ.js → index-CD3yIkOA.js} +1 -1
  84. package/web/assets/{index-BYsdKR_1.js → index-CJeUgjPU.js} +1 -1
  85. package/web/assets/{index-CzM-C2Sd.js → index-CLHoq1w-.js} +1 -1
  86. package/web/assets/{index-tAXBa_fN.js → index-CUZI62qU.js} +1 -1
  87. package/web/assets/{index-C6GJulug.js → index-Cff42k7q.js} +1 -1
  88. package/web/assets/index-Ck_O3Jdd.js +1 -0
  89. package/web/assets/index-CuiYK18N.js +1 -0
  90. package/web/assets/{index-BRW82CsP.js → index-CwcOeZdT.js} +1 -1
  91. package/web/assets/{index-DUWR2nZi.js → index-D6AycQIz.js} +1 -1
  92. package/web/assets/{index-BCZZVJ_w.js → index-D7gVhvNY.js} +1 -1
  93. package/web/assets/{index-DjzSBM0U.js → index-D9UZQy42.js} +1 -1
  94. package/web/assets/{index-KL5Rj9kP.js → index-DuBQ0j2g.js} +1 -1
  95. package/web/assets/{index-Dg9oixs4.js → index-OD1gSX3h.js} +1 -1
  96. package/web/assets/{index-gPSbFSUn.js → index-Uo5tswys.js} +1 -1
  97. package/web/assets/{index-D1f_JwPH.js → index-o8cj0pRH.js} +1 -1
  98. package/web/assets/{index-OHi69jDq.js → index-rHjhbwvm.js} +1 -1
  99. package/web/assets/{index-CqyM6tQ0.js → index-rggq2czF.js} +1 -1
  100. package/web/assets/{index-Czu_bbDM.js → index-sCXThwqZ.js} +1 -1
  101. package/web/assets/{invitePage-lLQ-e0pj.js → invitePage-b0HGvMj6.js} +1 -1
  102. package/web/assets/{ipc-DQOD2UKk.js → ipc-CxAyeo8q.js} +1 -1
  103. package/web/assets/{jszip.min-DZxV9uZ_.js → jszip.min-B94KpE21.js} +1 -1
  104. package/web/assets/launchpad-C2c1MSVX.css +1 -0
  105. package/web/assets/{layout-grid-B_pjJwz4.js → layout-grid-BBVuEdWG.js} +1 -1
  106. package/web/assets/{linkFollow-C0_3k_PC.js → linkFollow-B7ivDZMM.js} +4 -4
  107. package/web/assets/{list-tree-DkAJYEXd.js → list-tree-4-0QDbLu.js} +1 -1
  108. package/web/assets/{listFold-BsOVn9UZ.js → listFold-DLuxXiIj.js} +1 -1
  109. package/web/assets/{lock-BnGHxjeE.js → lock-CnbZm4vo.js} +1 -1
  110. package/web/assets/{log-out-DBuMeqik.js → log-out-BEynWaHa.js} +1 -1
  111. package/web/assets/{main-NgUPPqDn.css → main-BiS_5wrB.css} +1 -1
  112. package/web/assets/main-sIq2N9Z5.js +20 -0
  113. package/web/assets/markdownEditorSurface-ZSJ3RHAv.js +3 -0
  114. package/web/assets/mdMarkStore-DQHDjG7s.js +2 -0
  115. package/web/assets/{mdMarks-Bq7Hl-4C.js → mdMarks-DbIcRa0O.js} +1 -1
  116. package/web/assets/{message-square-plus-BiAZAvcw.js → message-square-plus-CpiKDvle.js} +1 -1
  117. package/web/assets/{messages-BH5MfQdZ.js → messages-_jta1lSI.js} +1 -1
  118. package/web/assets/minus-C9ndHJ9O.js +1 -0
  119. package/web/assets/mobileEntry-CPmU_c4m.js +13 -0
  120. package/web/assets/nativeDownload-BYT082bY.js +1 -0
  121. package/web/assets/{pageChrome-xLNdFaSg.css → pageChrome-CovzZPdb.css} +1 -1
  122. package/web/assets/pageChrome-D3Niv1JM.js +1 -0
  123. package/web/assets/{pageTree-CZH2J6cc.js → pageTree-CgfvpzIj.js} +2 -2
  124. package/web/assets/{pen-tool-lkmBqliH.js → pen-tool-BXEFnU2i.js} +1 -1
  125. package/web/assets/{pencil-Cvk91P_Z.js → pencil-cqvCkekG.js} +1 -1
  126. package/web/assets/pluginChat-BbBukMuN.js +2 -0
  127. package/web/assets/{redo-2-DSi54z4e.js → redo-2-BO7wCDwy.js} +1 -1
  128. package/web/assets/{rotate-ccw-CUlnplr0.js → rotate-ccw-BvipPIjC.js} +1 -1
  129. package/web/assets/{sharePage-MM6UpPJ9.js → sharePage-XbN50US7.js} +2 -2
  130. package/web/assets/{shareViewer-CDZ8lTdy.js → shareViewer-BaYogetW.js} +1 -1
  131. package/web/assets/{star-CwDiGyUW.js → star-BQWMXnn7.js} +1 -1
  132. package/web/assets/tableSurface-BXqqidd1.js +1 -0
  133. package/web/assets/{terminal-DIXogYJY.js → terminal-l9k6RDrH.js} +1 -1
  134. package/web/assets/{terminalView-B3aZSsrQ.js → terminalView-Cpnt5_0P.js} +1 -1
  135. package/web/assets/theme-C6D3tMGV.css +1 -0
  136. package/web/assets/type-CFoaj2eD.js +1 -0
  137. package/web/assets/{undo-2-tUKCv5Gs.js → undo-2-DusxpdLa.js} +1 -1
  138. package/web/assets/{unitAccount-D8lVwaaT.js → unitAccount-DwutFPPw.js} +1 -1
  139. package/web/assets/{unitBridge-D547ublk.js → unitBridge-CcgQpkqV.js} +1 -1
  140. package/web/assets/{unitCloudTransport-BVF6lVp4.js → unitCloudTransport-vA7cLDts.js} +1 -1
  141. package/web/assets/{unitOwnerAccess-BfnEjsZb.js → unitOwnerAccess-LBlJ1YfA.js} +1 -1
  142. package/web/assets/{unitShim-DxetRgmP.js → unitShim-B_M9IrbC.js} +3 -3
  143. package/web/assets/{upload-BbeAsMuD.js → upload-ZrOj6tXA.js} +1 -1
  144. package/web/assets/userSpaces-uJOnsedR.js +1 -0
  145. package/web/assets/viewportLock-D3SNkwS2.js +631 -0
  146. package/web/assets/viewportLock-IP1zaVkz.css +1 -0
  147. package/web/assets/{workflow-DuoVRSSX.js → workflow-DPoG4QE2.js} +1 -1
  148. package/web/assets/{zoom-in-hr5bRpDL.js → zoom-in-lbTgzdQP.js} +1 -1
  149. package/web/index.html +232 -13
  150. package/web/assets/ArtificialView-B4ESD4iK.js +0 -1
  151. package/web/assets/CalendarConfigView-cCfo_EvZ.js +0 -1
  152. package/web/assets/CalendarView-wgLapctk.js +0 -1
  153. package/web/assets/CapabilityMenu-BQBsM638.js +0 -1
  154. package/web/assets/ChatView-BIUk0OJd.css +0 -1
  155. package/web/assets/ChatView-C-jCJnyS.js +0 -47
  156. package/web/assets/Chrome-CwFiDmre.js +0 -1
  157. package/web/assets/DashboardGridView-DXqe0vPd.js +0 -17
  158. package/web/assets/ExcalidrawCanvas-C3egkikA.js +0 -1
  159. package/web/assets/HomepageView-CRdhjLXu.js +0 -1
  160. package/web/assets/ImageStudioPanels-Dke7xf8E.js +0 -3
  161. package/web/assets/ImageStudioView-g38V8gaj.js +0 -1
  162. package/web/assets/InlineFiles-C_hjvn3u.js +0 -1
  163. package/web/assets/MarkdownBlock-DIjYEhTK.js +0 -56
  164. package/web/assets/ModelPill-BPlgovPo.js +0 -1
  165. package/web/assets/MuseLibraryView-CenyTTim.js +0 -2
  166. package/web/assets/PdfAnnotator-CGzC_o1Q.css +0 -1
  167. package/web/assets/PdfAnnotator-D79ip27w.js +0 -560
  168. package/web/assets/RightPanel-C3OJTIqT.js +0 -4
  169. package/web/assets/RunLocationPicker-BNcZ7KKF.css +0 -1
  170. package/web/assets/RunLocationPicker-CTYXUH2z.js +0 -34
  171. package/web/assets/UnifiedPage-CKNtVD_n.js +0 -57
  172. package/web/assets/UnifiedPage-DX_sTpyZ.css +0 -1
  173. package/web/assets/appStore-Di8LXuJ9.css +0 -1
  174. package/web/assets/automationListSource-DP5xZBxo.js +0 -1
  175. package/web/assets/chatBoxSurface-zvcyfrxE.js +0 -1
  176. package/web/assets/dashboardSurface-CFTH5z4c.js +0 -1
  177. package/web/assets/ellipsis-r1EcXsFq.js +0 -1
  178. package/web/assets/floatingTocSurface-C6RJ6i41.js +0 -1
  179. package/web/assets/folder-DlxnPmWY.js +0 -1
  180. package/web/assets/frame-_xBVYe3P.js +0 -1
  181. package/web/assets/gestures-CkW1Kfs9.js +0 -1
  182. package/web/assets/i18n-D-eU58uw.css +0 -1
  183. package/web/assets/i18n.generated-Bbsz16cl.js +0 -15
  184. package/web/assets/imageStudio-BqbNOvpu.css +0 -1
  185. package/web/assets/imageStudio-C_Rs630L.js +0 -2
  186. package/web/assets/index-BCubCwdT.js +0 -1
  187. package/web/assets/index-DZfZTksa.js +0 -1
  188. package/web/assets/main-Dki8NlsT.js +0 -21
  189. package/web/assets/markdownEditorSurface-B4PeUzed.js +0 -3
  190. package/web/assets/mdMarkStore-CsKl7C8O.js +0 -2
  191. package/web/assets/minus-Cyv1YzOU.js +0 -1
  192. package/web/assets/mobileEntry-Bd_nKr0D.js +0 -13
  193. package/web/assets/nativeDownload-D-f1_L2S.js +0 -1
  194. package/web/assets/pageChrome-C9_azUYW.js +0 -1
  195. package/web/assets/panel-left-rOc8As0s.js +0 -1
  196. package/web/assets/pen-line-m6_HvWZ9.js +0 -1
  197. package/web/assets/sticky-note-BIuPUSOU.js +0 -1
  198. package/web/assets/tableSurface-Y_JBQsuz.js +0 -1
  199. package/web/assets/theme-DfEi_DND.css +0 -1
  200. package/web/assets/type-Cqoabh7H.js +0 -1
  201. package/web/assets/userSpaces-DyyAn7vj.js +0 -1
  202. package/web/assets/viewportLock-C4SX-9PO.js +0 -103
  203. package/web/assets/viewportLock-DYSe7Jsn.css +0 -1
  204. package/web/assets/waves-horizontal-B8ZpHQ5H.js +0 -1
@@ -1,21 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./appStore-Dg9WALEA.js","./index-CF4RV4mh.js","./nativeDownload-D-f1_L2S.js","./ipc-DQOD2UKk.js","./client-BSKpsyAw.js","./appStore-Di8LXuJ9.css"])))=>i.map(i=>d[i]);
2
- import{d as l,j as e,r as xt,t as wt,u as Te,_ as Qe,f as xs,L as ws}from"./index-CF4RV4mh.js";import{c as ys}from"./client-BSKpsyAw.js";import{z as ze,M as js,B as Cn,I as Ss,D as Ns,L as Cs,P as En,S as Dt,F as Es,A as Ft,U as Is,C as Ms,E as In,G as nt,J as Ts,K as zs,N as _t,W as Mn,R as Tn,T as $t,V as Ls,Z as zn,X as Rs,Y as As,_ as De,$ as Os,a0 as Ps,a1 as Ln,a2 as yt,a3 as an,a4 as Ds,a5 as Fs,a6 as zt,a7 as Bt,a8 as rn,a9 as _s,aa as st,ab as ct,ac as on,ad as $s,ae as Bs,af as qs,ag as Rn,ah as Vs,ai as Ws,aj as Hs,ak as Us,al as Ks,am as An,an as gt,ao as jt,ap as St,aq as et,ar as at,as as Ys,at as ht,au as Kt,av as On,aw as bt,ax as Yt,u as T,ay as kt,h as We,az as Gs,aA as Pn,aB as Ie,aC as Zs,aD as qt,aE as ln,aF as Ge,aG as Xs,aH as Dn,aI as Ze,aJ as Js,aK as Qs,aL as dt,aM as ea,aN as ta,aO as it,aP as Fn,aQ as na,aR as sa,aS as aa,aT as ia,aU as cn,aV as _n,aW as ra,aX as oa,aY as Ve,aZ as la,a_ as ca,a$ as da,b0 as ua,b1 as ma,b2 as pa,b3 as dn,b4 as ha,b5 as fa,i as be,b6 as ga,b7 as Gt,k as Zt,b8 as $n,b9 as ba,ba as un,bb as Bn,e as ka,bc as va,Q as xa,bd as qn,O as wa,be as mn,bf as ya,bg as Xt,g as Vn,bh as ja,bi as Sa,bj as Na,bk as Ca,m as Ea,r as Ia,q as Ma,s as Ta,bl as za,v as La,w as Ra,x as Aa,y as Oa}from"./appStore-Dg9WALEA.js";import{f as Pa,g as Da,L as Wn,T as Fa,S as _a,C as pn,W as $a,h as Ba,P as qa,M as Va,j as hn,k as Wa,u as Ha,l as Ua,s as Ka,m as Ya,b as Ga,D as Za,A as Hn,F as tt,c as Un,a as Kn,B as Xa,d as Ja,N as Qa,n as ei,o as ti,p as ni,i as si,e as ai}from"./viewportLock-C4SX-9PO.js";import{P as ii}from"./pen-tool-lkmBqliH.js";import{T as ri,R as oi,M as li,V as ci,a as di,C as ui,H as mi,l as vt,f as Yn}from"./userSpaces-DyyAn7vj.js";import{C as Gn,P as pi,H as hi,A as Ye,m as fi}from"./SidebarRow-BuSkKH5q.js";import{M as gi}from"./Chrome-CwFiDmre.js";import{T as bi}from"./terminal-DIXogYJY.js";import{B as ki}from"./AutomationBuilder-sxWdUa0L.js";import{S as vi}from"./star-CwDiGyUW.js";import{F as Zn}from"./folder-DlxnPmWY.js";import{E as xi}from"./ellipsis-r1EcXsFq.js";import{F as Xn}from"./UnifiedPage-CKNtVD_n.js";import{G as wi,i as yi,q as ji,o as fn,a as Si,c as Ni,A as Ci,p as Ei,d as Ii,E as Mi}from"./ChatView-C-jCJnyS.js";import{L as Ti}from"./layout-grid-B_pjJwz4.js";import{r as Be}from"./ipc-DQOD2UKk.js";import{C as zi}from"./circle-question-mark-WL3vbp-Z.js";import"./i18n.generated-Bbsz16cl.js";import{S as Li,C as Ri}from"./RunLocationPicker-CTYXUH2z.js";import{R as Ai}from"./RightPanel-C3OJTIqT.js";import{n as Oi}from"./codeStudioStore-C2mWfm32.js";import"./nativeDownload-D-f1_L2S.js";import"./panel-left-rOc8As0s.js";import"./ModelPill-BPlgovPo.js";import"./rotate-ccw-CUlnplr0.js";import"./hard-drive-BbyVSbfP.js";import"./CapabilityMenu-BQBsM638.js";import"./folder-plus-D1TDb7k9.js";import"./upload-BbeAsMuD.js";import"./DashboardGridView-DXqe0vPd.js";import"./FloatingToc-CENybkAA.js";import"./MarkdownBlock-DIjYEhTK.js";import"./index-BCubCwdT.js";import"./linkFollow-C0_3k_PC.js";import"./mdMarks-Bq7Hl-4C.js";import"./emoji-DGaxpCIu.js";import"./listFold-BsOVn9UZ.js";import"./pageChrome-C9_azUYW.js";import"./pageTree-CZH2J6cc.js";import"./pluginExt-Byb64tQO.js";import"./list-tree-DkAJYEXd.js";import"./pencil-Cvk91P_Z.js";import"./frame-_xBVYe3P.js";import"./undo-2-tUKCv5Gs.js";import"./redo-2-DSi54z4e.js";import"./type-Cqoabh7H.js";import"./code-xml-BALV9u_c.js";import"./lock-BnGHxjeE.js";import"./InlineFiles-C_hjvn3u.js";import"./workflow-DuoVRSSX.js";import"./canvasPrefs-BeG4oEgP.js";import"./gestures-CkW1Kfs9.js";import"./MuseView-d-iBk3sc.js";import"./automationListSource-DP5xZBxo.js";import"./messages-BH5MfQdZ.js";import"./approvalText-Cy2UAUAQ.js";import"./circle-x-D7s-M5sB.js";import"./message-square-plus-BiAZAvcw.js";import"./log-out-DBuMeqik.js";import"./index-DZfZTksa.js";import"./StudioGuestSurface-BijU_EEb.js";import"./minus-Cyv1YzOU.js";import"./SketchCard-D87GADyG.js";import"./hand-Crrw-nSn.js";import"./sticky-note-BIuPUSOU.js";import"./foldActions-B7KByFdN.js";import"./create-4xUyKtAF.js";import"./pdf.worker.min-CGb3BKV9.js";import"./zoom-in-hr5bRpDL.js";import"./mdMarkStore-CsKl7C8O.js";import"./arrow-up-right-CpQs92mu.js";import"./waves-horizontal-B8ZpHQ5H.js";const Pi=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],Di=ze("box",Pi);const Fi=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],_i=ze("calendar",Fi);const $i=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Bi=ze("chevron-up",$i);const qi=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],Vi=ze("chevrons-left",qi);const Wi=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],Hi=ze("chevrons-right",Wi);const Ui=[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",key:"1jaruq"}]],Ki=ze("flag",Ui);const Yi=[["path",{d:"M12 22v-9",key:"x3hkom"}],["path",{d:"M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z",key:"2ntwy6"}],["path",{d:"M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13",key:"1pmm1c"}],["path",{d:"M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z",key:"12ttoo"}]],Lt=ze("package-open",Yi);const Gi=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],Zi=ze("tag",Gi);const Xi=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Ji=ze("user",Xi),Jn={folder:Zn,"folder-open":As,star:vi,heart:mi,home:Rs,zap:zn,bookmark:Ls,bell:ki,tag:Zi,flag:Ki,pin:pi,box:Di,package:$t,settings:Tn,wrench:Mn,terminal:bi,code:ui,"file-text":_t,image:zs,music:di,video:ci,camera:Ts,globe:nt,compass:In,map:gi,calendar:_i,clock:Gn,mail:li,"message-circle":Ms,users:Is,user:Ji,search:Ft,filter:Es,sparkles:Dt,rocket:oi,target:ri,trophy:Fa,lightbulb:Wn,coffee:Da,palette:En,layers:Cs,database:Ns,"pen-tool":ii,inbox:Ss,bot:Cn,command:Pa,moon:js},Qi=Object.keys(Jn),Rt=t=>t?Jn[t]:void 0,At=4,er=5,tr=4,nr=1e3,sr=100;function gn(t){if(t>=9)return"";const a=Ws({id:`space-slot-${t+1}`,hotkey:`mod+${t+1}`});return a?Hs(a,Us()):""}function ut({item:t,expanded:a}){if(t.component){const r=t.component;return e.jsx(r,{expanded:a})}const s=t.icon,d=t.tooltip?st(t.tooltip):"";return e.jsxs("button",{className:"rb-btn","aria-label":d||void 0,"data-rb-tip":a?void 0:d||void 0,onClick:t.onClick,children:[s&&e.jsx(s,{size:18}),a&&e.jsx("span",{className:"rb-label",children:d})]})}function ar({cmd:t,expanded:a,overrideIcon:s}){const[,d]=l.useReducer(h=>h+1,0),r=s??t.icon??zn,g=st(t.title);let p;if(t.checked)try{p=!!t.checked()}catch{p=void 0}return e.jsxs("button",{className:`rb-btn${p?" is-on":""}`,"aria-pressed":p,"aria-label":g,"data-rb-tip":a?void 0:g,onMouseEnter:t.checked?d:void 0,onMouseLeave:t.checked?d:void 0,onClick:()=>{const h=t.run();t.checked&&(d(),h&&typeof h.then=="function"&&h.then(d,d))},children:[e.jsx(r,{size:18}),a&&e.jsx("span",{className:"rb-label",children:g})]})}function ir(){const t=De(n=>n.items),a=De(n=>n.expanded),s=De(n=>n.order),d=De(n=>n.bottomOrder),r=De(n=>n.folders),g=De(n=>n.commandItems),p=De(n=>n.commandIcons),h=Os(n=>n.commands);Ps(n=>n.overrides);const{t:o}=Ln(),m=()=>De.getState(),[f,C]=l.useState(null),[v,j]=l.useState(null),[z,x]=l.useState(null),[A,L]=l.useState(null),[I,D]=l.useState(null),[Q,O]=l.useState(null),[Z,H]=l.useState(null),[b,N]=l.useState(99),P=l.useRef(null),Y=l.useRef(null),X=l.useRef(null),ne=l.useRef(null),ee=l.useRef(null),ie=l.useRef(null),ke=l.useRef(null),[Le,F]=l.useState({top:0,bottom:0}),[U,ve]=l.useState(null),[re,xe]=l.useState({}),se=l.useRef({}),Re=l.useRef({});l.useEffect(()=>()=>{for(const n of Object.values(se.current))window.clearTimeout(n?.timer)},[]);const[oe,Ae]=l.useState(null),S=l.useRef(null),K=l.useRef(void 0),q=l.useRef(!1),G=l.useRef(0),ae=()=>{window.clearTimeout(K.current),S.current=null,q.current&&(q.current=!1,G.current=Date.now()),Ae(null)},je=!!f||!!Q||!!Z||!!I;l.useEffect(()=>{(je||a)&&ae()},[je,a]),l.useEffect(()=>()=>window.clearTimeout(K.current),[]);const le=n=>{const c=n.target.closest("[data-rb-tip]");if(c===S.current)return;const u=q.current||Date.now()-G.current<=sr;if(ae(),!c||je||a)return;S.current=c;const y=()=>{if(S.current!==c||!c.isConnected||!c.dataset.rbTip)return;const k=c.getBoundingClientRect();q.current=!0,Ae({text:c.dataset.rbTip,mid:k.top+k.height/2})};u?y():K.current=window.setTimeout(y,nr)},we=new Set(r.flatMap(n=>n.items)),Oe=new Map,Pe=n=>{const c=[];for(const y of t)(y.side??"top")===n&&!y.pinned&&c.push({kind:"item",id:y.id,item:y});if(n==="bottom")for(const y of g){const k=h.find(R=>R.id===y);k&&c.push({kind:"cmd",id:`cmd:${y}`,cmd:k})}for(const y of r)y.zone===n&&c.push({kind:"folder",id:y.id,folder:y});for(const y of c)Oe.set(y.id,y);return _s(c.map(y=>y.id),n==="top"?s:d).map(y=>Oe.get(y)).filter(y=>!we.has(y.id))},ce=Pe("top"),de=Pe("bottom"),Xe=n=>n.items.reduce((c,u)=>c+(Oe.has(u)?1:0),0),Ct=t.filter(n=>n.side==="bottom"&&n.pinned),Et=t.filter(n=>n.side==="head"),It=t.filter(n=>n.side==="home"),V=(a?34:32)+At;l.useLayoutEffect(()=>{const n=P.current;if(!n)return;const c=()=>{const y=getComputedStyle(n),k=(Y.current?.offsetHeight??0)+(ne.current?.offsetHeight??0),R=n.clientHeight-parseFloat(y.paddingTop)-parseFloat(y.paddingBottom)-k-(X.current?.offsetHeight??0)-2*V-48;N(Math.max(2,Math.floor(R/V)))};c();const u=new ResizeObserver(c);return u.observe(n),ne.current&&u.observe(ne.current),()=>u.disconnect()},[a,V,t.length,r.length,g.length,U]);const Se=(n,c)=>n<=c?n:c+1,rt=Se(ce.length,er),Fe=Se(de.length,tr);let ye=rt,W=Fe;if(U)U==="top"?ye=b:W=b;else if(ye+W>b)if(ce.length===0)ye=0,W=b;else if(de.length===0)ye=b,W=0;else{const n=Math.floor(b/2);ye=Math.max(1,Math.min(rt,Math.max(n,b-Fe))),W=Math.max(1,Math.min(Fe,b-ye))}const ue=(n,c,u,y)=>{if(n.length<=c)return{shown:n,tail:[],start:0,max:0};const k=Math.max(0,c-1),R=n.length-k,B=Math.min(Math.max(0,y),R),Ee=u?n.length-k-B:B;return{shown:n.slice(Ee,Ee+k),tail:[...n.slice(0,Ee),...n.slice(Ee+k)],start:Ee,max:R}},me=ue(ce,ye,!1,Le.top),_e=ue(de,W,!0,Le.bottom),J=(n,c)=>u=>{const y=Re.current[n];if(!c.max||f||!u.deltaY||!y)return;let k=se.current[n];k||(k=se.current[n]={px:c.start*V,from:c.start,timer:0},xe(B=>({...B,[n]:!0}))),window.clearTimeout(k.timer);const R=u.deltaMode?Math.sign(u.deltaY)*V:Math.max(-V,Math.min(V,u.deltaY));k.px=Math.max(0,Math.min(c.max*V,k.px+R)),y.style.transform=`translateY(${-k.px}px)`,k.timer=window.setTimeout(()=>ot(n,c),120)},ot=(n,c)=>{const u=se.current[n],y=Re.current[n];if(!u||!y)return;const k=u.px-u.from*V;let R=Math.round(u.px/V);R===u.from&&k&&(R+=Math.sign(k)),R=Math.max(0,Math.min(c.max,R)),u.px=R*V,y.style.transform=R?`translateY(${-R*V}px)`:"",u.timer=window.setTimeout(()=>{delete se.current[n],xe(B=>({...B,[n]:!1})),F(B=>({...B,[n]:n==="top"?R:c.max-R}))},240)},pe=I?.folderId?r.find(n=>n.id===I.folderId):void 0,He=()=>{ie.current&&(window.clearTimeout(ie.current),ie.current=null)},Ue=()=>{He(),ie.current=window.setTimeout(()=>{f||D(null)},150)},Ke=(n,c,u,y)=>{He(),D({key:n,zone:c,folderId:y,top:u.getBoundingClientRect().top})};l.useLayoutEffect(()=>{const n=ee.current;if(!n||!I)return;const c=n.getBoundingClientRect().bottom-(window.innerHeight-8);c>0&&D({...I,top:Math.max(8,I.top-c)})},[I?.key,pe?.items.length]);const $e=!!I;l.useEffect(()=>{if(!$e)return;const n=u=>{u.key==="Escape"&&D(null)},c=u=>{const y=u.target;!ee.current?.contains(y)&&!P.current?.contains(y)&&D(null)};return window.addEventListener("keydown",n),window.addEventListener("mousedown",c),()=>{window.removeEventListener("keydown",n),window.removeEventListener("mousedown",c)}},[$e]),l.useEffect(()=>{if(!U)return;const n=()=>ve(null),c=y=>{if(y.button!==0)return;const k=y.target;k?.closest?.(".rb-menu, .rb-iconpick, .rb-fly")||k&&P.current?.contains(k)&&k.closest("button")||n()},u=y=>{y.key==="Escape"&&n()};return window.addEventListener("pointerdown",c,!0),window.addEventListener("keydown",u),window.addEventListener("blur",n),()=>{window.removeEventListener("pointerdown",c,!0),window.removeEventListener("keydown",u),window.removeEventListener("blur",n)}},[U]);const Je=l.useRef(new Map),lt=l.useRef(()=>{});l.useEffect(()=>{lt.current=n=>{const c=ce[n];if(c){if(c.kind==="folder"){const u=Je.current.get(c.id)??P.current;u&&Ke(c.id,"top",u,c.id);return}D(null),c.kind==="cmd"?c.cmd.run():c.id.startsWith("space:")?yt(c.id.slice(6)):c.item.onClick?.()}}});const i=Math.min(9,ce.length);l.useEffect(()=>{for(let n=1;n<=9;n++){if(n>i){an(`space-slot-${n}`);continue}Ds({id:`space-slot-${n}`,title:()=>Fs("lcl.ribbon.switchSpace",{n}),keywords:`space switch ${n} 切换 空间`,hotkey:`mod+${n}`,run:()=>lt.current(n-1)})}return()=>{for(let n=1;n<=9;n++)an(`space-slot-${n}`)}},[i]);const w=(n,c,u,y)=>{n.dataTransfer.effectAllowed="move";const k=n.currentTarget.getBoundingClientRect();n.dataTransfer.setDragImage(n.currentTarget,n.clientX-k.left,n.clientY-k.top),C({id:c,zone:u,from:y})},E=()=>{ke.current=null,C(null),j(null),x(null),L(null)},M=(n,c,u)=>{c&&(n.preventDefault(),n.stopPropagation(),n.dataTransfer.dropEffect="move",u?.())},_=(n,c)=>{const u=n.querySelectorAll(".rb-slot"),y=u[0]?.getBoundingClientRect().top??0,k=u.length>1?u[1].getBoundingClientRect().top-y:0;return{top:y,pitch:k,grabDy:c??k/2}},$=(n,c,u)=>Vs(c,u,ke.current??_(n)),he=(n,c)=>{const u=n.parentElement;u&&(ke.current=_(u,c-n.getBoundingClientRect().top))},te=(n,c)=>{const u=f;if(E(),!u||u.zone!==n||u.id===c)return;u.from&&m().moveOutOfFolder(u.id);const y=n==="top"?m().order:m().bottomOrder,k=$s(y,(n==="top"?ce:de).map(B=>B.id)),R=c?k.indexOf(c):-1;m().setZoneOrder(n,ct(k,u.id,R>=0?R:k.length))},fe=(n,c)=>{const u=f;if(E(),!(!u||u.zone!==n.zone||u.id.startsWith("folder:"))){if(u.from===n.id)m().setFolderItems(n.id,ct(n.items,u.id,c??n.items.length));else if(m().moveIntoFolder(n.id,u.id),u.from||m().setZoneOrder(n.zone,on(n.zone==="top"?m().order:m().bottomOrder,(n.zone==="top"?ce:de).map(y=>y.id),u.id)),c!==void 0){const y=m().folders.find(k=>k.id===n.id);y&&m().setFolderItems(n.id,ct(y.items,u.id,c))}}},Ne=zt.prompt??((n,c)=>Promise.resolve(window.prompt(n,c))),ge=n=>{Ne(o("lcl.ribbon.newFolder"),o("lcl.ribbon.folderDefaultName")).then(c=>{const u=c?.trim();u&&m().addFolder(n,u)})},Ce=n=>[...n==="top"&&zt.newSpace?[{label:o("lcl.ribbon.newSpace"),onClick:zt.newSpace}]:[],...n==="bottom"?[{label:o("lcl.ribbon.addCommand"),onClick:()=>Bs(c=>m().addCommandItem(c))}]:[],{label:o(n==="top"?"lcl.ribbon.newFolderSpaces":"lcl.ribbon.newFolderCommands"),onClick:()=>ge(n)}],hs=n=>c=>{c.defaultPrevented||(c.preventDefault(),O({x:c.clientX,y:c.clientY,entries:Ce(n)}))},fs=n=>{n.defaultPrevented||(n.preventDefault(),O({x:n.clientX,y:n.clientY,entries:[...Ce("top"),...Ce("bottom")]}))},Qt=(n,c,u,y)=>{O(null),H({x:n,y:c,current:u,apply:y})},gs=n=>c=>{c.preventDefault(),c.stopPropagation();const u=c.clientX,y=c.clientY;O({x:u,y,entries:[{label:o("lcl.ribbon.changeIcon"),onClick:()=>Qt(u,y,n.icon,k=>m().setFolderIcon(n.id,k))},{label:o("lcl.ribbon.rename"),onClick:()=>{Ne(o("lcl.ribbon.renameFolder"),n.name).then(k=>{const R=k?.trim();R&&m().renameFolder(n.id,R)})}},{label:o("lcl.ribbon.dissolveFolder"),onClick:()=>m().removeFolder(n.id)}]})},en=n=>c=>{c.preventDefault(),c.stopPropagation();const u=c.clientX,y=c.clientY;O({x:u,y,entries:[{label:o("lcl.ribbon.setIcon"),onClick:()=>Qt(u,y,m().commandIcons[n],k=>m().setCommandIcon(n,k))},{label:o("lcl.ribbon.removeCommand"),onClick:()=>m().removeCommandItem(n)}]})},bs=n=>{const c=Rt(n.icon)??Zn;return e.jsxs("button",{ref:u=>{u?Je.current.set(n.id,u):Je.current.delete(n.id)},className:`rb-btn rb-folder${A===n.id?" drag-into":""}`,"aria-label":`${n.name} (${Xe(n)})`,onMouseEnter:u=>Ke(n.id,n.zone,u.currentTarget,n.id),onMouseLeave:Ue,onContextMenu:gs(n),onDragOver:u=>M(u,!!f&&f.zone===n.zone&&!f.id.startsWith("folder:"),()=>{x(null),L(n.id)}),onDragLeave:()=>{A===n.id&&L(null)},onDrop:u=>{!f||f.id.startsWith("folder:")||(u.preventDefault(),u.stopPropagation(),fe(n))},children:[e.jsx(c,{size:18}),a&&e.jsx("span",{className:"rb-label",children:n.name})]})},tn=n=>{const c=U===n,u=o(c?"lcl.ribbon.less":"lcl.ribbon.more"),y=c?n==="top"?Bi:Rn:xi;return e.jsxs("button",{className:`rb-btn rb-more${c?" is-open":""}${A===`more:${n}`?" drag-into":""}`,"aria-label":u,"aria-expanded":c,"data-rb-tip":a?void 0:u,onClick:()=>ve(c?null:n),onDragOver:k=>M(k,!!f&&f.zone===n,()=>{x(null),L(`more:${n}`)}),onDragLeave:()=>{A===`more:${n}`&&L(null)},onDrop:k=>{k.preventDefault(),k.stopPropagation(),te(n,n==="bottom"?de[0]?.id??null:null)},children:[e.jsx(y,{size:18}),a&&e.jsx("span",{className:"rb-label",children:u})]})},Mt=(n,c)=>{const u=c??a;return n.kind==="item"?e.jsx(ut,{item:n.item,expanded:u}):n.kind==="cmd"?e.jsx(ar,{cmd:n.cmd,expanded:u,overrideIcon:Rt(p[n.cmd.id])}):bs(n.folder)},ks=(n,c,u,y,k,R)=>{const B=y?y.indexOf(n.id):u;return e.jsxs("div",{"data-id":n.id,className:`rb-slot${f?.id===n.id?" dragging":""}${k?" drag-over":""}`,style:B!==u?{transform:`translateY(${(B-u)*V}px)`}:void 0,draggable:!0,onDragStart:Ee=>{he(Ee.currentTarget,Ee.clientY),w(Ee,n.id,c,null)},onDragEnd:E,onContextMenu:n.kind==="cmd"?en(n.cmd.id):void 0,children:[Mt(n),c==="top"&&a&&gn(R)&&e.jsx("span",{className:"rb-key",children:gn(R)})]},n.id)},Tt=n=>o(n==="top"?"lcl.ribbon.addSpaceOrFolder":"lcl.ribbon.addCommand"),nn=n=>e.jsxs("button",{className:"rb-btn rb-plus","aria-label":Tt(n),"data-rb-tip":a?void 0:Tt(n),onClick:c=>{const u=c.currentTarget.getBoundingClientRect();O({x:u.right+6,y:u.top,entries:Ce(n)})},children:[e.jsx(qs,{size:16}),a&&e.jsx("span",{className:"rb-label",children:Tt(n)})]}),sn=(n,c)=>{const u=c.shown.map(k=>k.id),y=f&&z?.zone===n&&u.includes(f.id)?ct(u,f.id,z.index):null;return e.jsxs("div",{className:`rb-group rb-${n}`,onContextMenu:hs(n),onWheel:J(n,c),onDragOver:k=>{const R=$(k.currentTarget,k.clientY,u.length);M(k,!!f&&f.zone===n,()=>{L(null),x(B=>B?.zone===n&&B.index===R?B:{zone:n,index:R})})},onDrop:k=>{k.preventDefault(),k.stopPropagation(),te(n,(z?.zone===n?u[z.index]:null)??null)},children:[n==="bottom"&&e.jsxs(e.Fragment,{children:[nn(n),(c.tail.length>0||U===n)&&tn(n)]}),e.jsx("div",{className:"rb-strip",style:{height:Math.max(0,c.shown.length*V-At)},children:e.jsx("div",{ref:k=>{Re.current[n]=k},className:"rb-strip-in",style:c.start?{transform:`translateY(${-c.start*V}px)`}:void 0,children:(n==="top"?ce:de).map((k,R)=>{const B=R-c.start;return B>=0&&B<c.shown.length?ks(k,n,B,y,!y&&z?.zone===n&&z.index===B,R):e.jsx("div",{className:"rb-cell","aria-hidden":!0,inert:!0,style:{height:V-At},children:re[n]&&Mt(k)},k.id)})})}),n==="top"&&e.jsxs(e.Fragment,{children:[(c.tail.length>0||U===n)&&tn(n),nn(n)]})]})},vs=(n,c,u,y)=>e.jsx("div",{"data-id":n.id,className:`rb-fly-row${f?.id===n.id?" dragging":""}${v===n.id&&f?.id!==n.id?` drag-over${f&&y.indexOf(f.id)>=0&&y.indexOf(f.id)<u?" below":""}`:""}`,draggable:!0,onDragStart:k=>{k.stopPropagation(),w(k,n.id,c.zone,c.id)},onDragOver:k=>M(k,!!f&&f.zone===c.zone&&f.id!==n.id&&!f.id.startsWith("folder:"),()=>j(n.id)),onDragLeave:()=>{v===n.id&&j(null)},onDrop:k=>{k.preventDefault(),k.stopPropagation(),fe(c,u)},onDragEnd:E,onContextMenu:n.kind==="cmd"?en(n.cmd.id):k=>{k.preventDefault(),k.stopPropagation(),O({x:k.clientX,y:k.clientY,entries:[{label:o("lcl.ribbon.moveOut"),onClick:()=>{m().moveOutOfFolder(n.id);const R=c.zone==="top"?m().order:m().bottomOrder;m().setZoneOrder(c.zone,[...on(R,(c.zone==="top"?ce:de).map(B=>B.id),n.id),n.id])}}]})},children:Mt(n,!0)},n.id);return e.jsxs("div",{ref:P,className:`rb${a?" rb-expanded":""}${f?" rb-dragging":""}${U?` rb-open-${U}`:""}`,onContextMenu:fs,onMouseOver:le,onMouseLeave:ae,onMouseDownCapture:n=>{ae(),S.current=n.target.closest("[data-rb-tip]")},onDragOver:n=>M(n,!!f),onDrop:n=>{if(!f)return;n.preventDefault();const c=f.zone,u=z?.zone===c?(c==="top"?me:_e).shown[z.index]?.id:void 0;if(u===void 0){E();return}te(c,u)},children:[e.jsxs("div",{ref:Y,className:"rb-head",children:[e.jsxs("button",{className:"rb-btn rb-toggle","aria-label":o(a?"lcl.ribbon.iconsOnly":"lcl.ribbon.showLabels"),"aria-expanded":a,"data-rb-tip":a?void 0:o("lcl.ribbon.showLabels"),onClick:()=>m().toggleExpanded(),children:[a?e.jsx(Vi,{size:18}):e.jsx(Hi,{size:18}),a&&e.jsx("span",{className:"rb-label",children:o("lcl.ribbon.iconsOnly")})]}),Et.map(n=>e.jsx(ut,{item:n,expanded:a},n.id))]}),e.jsx("div",{ref:X,className:"rb-group rb-home",children:It.map(n=>e.jsx(ut,{item:n,expanded:a},n.id))}),U!=="bottom"&&sn("top",me),U!=="top"&&sn("bottom",_e),e.jsx("div",{ref:ne,className:"rb-group rb-pinned",children:Ct.map(n=>e.jsx(ut,{item:n,expanded:a},n.id))}),I&&pe&&e.jsxs("div",{ref:ee,className:"rb-fly",style:(()=>{const n=Bt(P.current);return{left:((P.current?.getBoundingClientRect().right??44)+4)/n,top:I.top/n}})(),onMouseEnter:He,onMouseLeave:Ue,onDragOver:n=>M(n,!!f&&f.zone===I.zone&&!f.id.startsWith("folder:")&&n.target===n.currentTarget),onDrop:n=>{n.target===n.currentTarget&&(n.preventDefault(),fe(pe))},children:[e.jsx("div",{className:"rb-fly-head",children:pe.name}),Xe(pe)===0&&e.jsx("div",{className:"rb-fly-empty",children:o("lcl.ribbon.folderEmpty")}),pe.items.map((n,c)=>{const u=Oe.get(n);return u?vs(u,pe,c,pe.items):null})]}),oe&&!a&&e.jsx("div",{className:"rb-tip",role:"tooltip",style:(()=>{const n=Bt(P.current);return{left:((P.current?.getBoundingClientRect().right??44)+6)/n,top:oe.mid/n}})(),children:oe.text}),Q&&e.jsx("div",{className:"rb-menu-backdrop",onMouseDown:()=>O(null),onContextMenu:n=>{n.preventDefault(),O(null)},children:e.jsx(rn,{className:"rb-menu",x:Q.x,y:Q.y,onMouseDown:n=>n.stopPropagation(),children:Q.entries.map((n,c)=>e.jsx("button",{onClick:()=>{O(null),n.onClick()},children:n.label},c))})}),Z&&e.jsx("div",{className:"rb-menu-backdrop",onMouseDown:()=>H(null),onContextMenu:n=>{n.preventDefault(),H(null)},children:e.jsxs(rn,{className:"rb-iconpick",x:Z.x,y:Z.y,onMouseDown:n=>n.stopPropagation(),children:[e.jsx("button",{className:"rb-iconpick-reset",onClick:()=>{const n=Z.apply;H(null),n("")},children:o("lcl.ribbon.defaultIcon")}),e.jsx("div",{className:"rb-iconpick-grid",children:Qi.map(n=>{const c=Rt(n);return e.jsx("button",{className:`rb-iconpick-btn${Z.current===n?" on":""}`,title:n,onClick:()=>{const u=Z.apply;H(null),u(n)},children:e.jsx(c,{size:17})},n)})})]})})]})}const bn=8,rr=t=>t.dataset.lclShift==="end"?bn:t.dataset.lclShift==="start"?-bn:0;function or(){const t=Array.from(document.querySelectorAll(".dv-groupview")).map(s=>({r:s.getBoundingClientRect(),papery:!s.querySelector(".wb-tab--icon")})).filter(s=>s.r.width>0&&s.r.height>0),a=3;for(const s of document.querySelectorAll(".dv-sash")){const d=!!s.closest(".dv-split-view-container.dv-horizontal"),r=s.getBoundingClientRect();if(!r.width&&!r.height)continue;const g=d?r.left+r.width/2:r.top+r.height/2,[p,h]=d?[r.top,r.bottom]:[r.left,r.right];let o=null,m=null;for(const C of t){const[v,j,z,x]=d?[C.r.left,C.r.right,C.r.top,C.r.bottom]:[C.r.top,C.r.bottom,C.r.left,C.r.right];x<=p||z>=h||(o===null&&Math.abs(j-g)<=a&&(o=C.papery),m===null&&Math.abs(v-g)<=a&&(m=C.papery))}const f=o===!1&&m===!0?"end":o===!0&&m===!1?"start":"";f?s.dataset.lclShift=f:delete s.dataset.lclShift}}function lr(){const t=document.createElement("div");t.className="lcl-sash-tick",document.body.appendChild(t);let a=null,s=0;const d=(v,j)=>{const z=!!v.closest(".dv-split-view-container.dv-horizontal"),x=v.getBoundingClientRect(),A=rr(v);cancelAnimationFrame(s),s=requestAnimationFrame(()=>{t.classList.add("show"),t.classList.toggle("h",!z);const L=Bt(t);z?(t.style.left=`${(x.left+x.width/2+A)/L}px`,t.style.top=`${Math.min(Math.max(j.clientY,x.top),x.bottom)/L}px`):(t.style.left=`${Math.min(Math.max(j.clientX,x.left),x.right)/L}px`,t.style.top=`${(x.top+x.height/2+A)/L}px`)})},r=v=>v instanceof Element?v.closest(".dv-sash"):null,g=v=>{const j=a instanceof HTMLElement?a:r(v.target);j?d(j,v):t.classList.contains("show")&&(cancelAnimationFrame(s),t.classList.remove("show"))},p=v=>{a=r(v.target)},h=v=>{a&&(a=null,r(v.target)||(cancelAnimationFrame(s),t.classList.remove("show")))};let o=0;const m=()=>{window.clearTimeout(o),o=window.setTimeout(or,120)},f=v=>v instanceof Element&&(v.matches(".dv-sash, .dv-view, .dv-groupview")||!!v.querySelector(".dv-sash, .dv-groupview")),C=new MutationObserver(v=>{for(const j of v)for(const z of[...j.addedNodes,...j.removedNodes])if(f(z)){m();return}});return C.observe(document.body,{childList:!0,subtree:!0}),m(),document.addEventListener("pointermove",g,{passive:!0}),document.addEventListener("pointerdown",p,{passive:!0}),document.addEventListener("pointerup",h,{passive:!0}),()=>{C.disconnect(),window.clearTimeout(o),cancelAnimationFrame(s),document.removeEventListener("pointermove",g),document.removeEventListener("pointerdown",p),document.removeEventListener("pointerup",h),t.remove()}}const Qn=({dark:t,soft:a,buildDefault:s,header:d,noRibbon:r,footer:g})=>(l.useEffect(()=>Ks(),[]),l.useEffect(()=>lr(),[]),An==="mobile"?e.jsxs(e.Fragment,{children:[e.jsx(_a,{dark:t,soft:a,buildDefault:s}),e.jsx(pn,{})]}):e.jsxs("div",{className:"shell",children:[d,e.jsxs("div",{className:"shell-top",children:[!r&&e.jsx(ir,{}),e.jsxs("div",{className:"shell-work",children:[e.jsx($a,{dark:t,soft:a,buildDefault:s}),g]})]}),e.jsx(pn,{})]})),cr=({buildDefault:t,direct:a})=>{const s=gt(I=>I.spaces),d=gt(I=>I.activeSpaceId),[,r]=l.useReducer(I=>I+1,0);l.useEffect(()=>jt(r),[]);const g=s.filter(St),p=g.find(I=>I.id===d),h=et(I=>I.mainLeaves.find(D=>D.id===I.activeMainId)),[o,m]=l.useState(!1),{t:f}=Ln(),C=p?.icon,v=a?at(a.view.type):void 0,j=l.useRef(!1);v&&(j.current=!0),l.useEffect(()=>{a&&j.current&&!v&&window.tangu?.closeSelf?.()},[a,v]);const z=a?.title||(v?st(v.displayName):p?st(p.mini?.name??p.name):"Mini Panel");l.useEffect(()=>{const I=et.getState();if(I.setDefaultBuilder(t),!a)if(p)I.getActiveLeaf()?.type!==p.mini.view.type&&I.resetLayout();else{const D=g.find(Q=>Q.id==="tangu")??g[0];D&&Ys(D.id),I.resetLayout()}},[s,d,p,t,a]),l.useEffect(()=>{const I=D=>{D.key==="Escape"&&m(!1)};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[]);const x=h&&(a?h.type===a.view.type:p&&h.type===p.mini.view.type)?et.getState().getActiveLeaf():null,A=x?at(x.type):null,L=()=>{if(a){bt({type:a.mainView.type,params:{...a.mainView.params,...et.getState().getActiveLeaf()?.params}});return}const I=Yt();I?.mini&&bt({spaceId:I.id,type:I.mini.mainView.type,params:{...I.mini.mainView.params,...et.getState().getActiveLeaf()?.params}})};return e.jsxs("div",{className:"mini-card-shell","data-space":a?"direct":p?.id,children:[e.jsxs("header",{className:"mini-card-chrome",children:[e.jsxs("button",{className:"mini-card-space","aria-label":f("lcl.mini.switchSpace"),"aria-expanded":o,disabled:!!a||g.length<2,onClick:()=>m(!o),children:[!a&&C&&e.jsx(C,{size:15}),e.jsx("span",{children:z}),!a&&g.length>1&&e.jsx(Rn,{size:12})]}),e.jsx("div",{className:"mini-card-drag-title"}),e.jsx("button",{className:"mini-card-action","aria-label":f("lcl.mini.showMain"),title:f("lcl.mini.showMain"),disabled:!a&&!p,onClick:L,children:e.jsx(ht,{size:15})}),e.jsx("button",{className:"mini-card-action mini-card-close","aria-label":f("lcl.mini.close"),onClick:()=>window.tangu?.closeSelf?.(),children:e.jsx(Kt,{size:15})})]}),e.jsx("main",{className:"mini-card-main",children:x&&A?e.jsx("div",{className:"mini-panel-view","data-view":x.type,children:e.jsx(On,{children:e.jsx(l.Suspense,{fallback:null,children:A.factory({leaf:x,params:x.params})})})},`${x.id}:${x.type}`):e.jsx("div",{className:"mini-panel-empty",children:f("lcl.mini.empty")})}),o&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"mini-card-dismiss","aria-label":f("lcl.mini.closeMenu"),onClick:()=>m(!1)}),e.jsx("section",{className:"mini-card-popover","aria-label":f("lcl.mini.switchSpace"),children:e.jsx("div",{className:"mini-card-popover-list",children:g.map(I=>{const D=I.icon;return e.jsxs("button",{className:`mini-card-row${I.id===d?" active":""}`,onClick:()=>{yt(I.id),m(!1)},children:[D&&e.jsx(D,{size:15}),e.jsx("span",{className:"mini-card-row-label",children:st(I.mini.name??I.name)})]},I.id)})})})]})]})};function dr(){return e.jsx("div",{className:"mac-titlebar"})}xt({"marketsvc.desktopOnly":{zh:"应用市场仅在桌面端可用",en:"The app market is only available on desktop"},"marketsvc.resolveFailed":{zh:"没能从 Forsion 服务器拿到下载地址({detail})",en:"Couldn’t get the download link from the Forsion server ({detail})"}});function Jt(){const t=window.tangu;if(!t?.marketList)throw new Error(wt("marketsvc.desktopOnly"));return t}const es=t=>Jt().marketList(t).then(a=>a.items||[]),ur=t=>Jt().marketDetail(t),mr=t=>{const a=(t?.message||String(t)).replace(/^Error invoking remote method '[^']+': (?:\w*Error: )?/,""),s=/^resolve: (.+)$/.exec(a);throw s?Object.assign(new Error(wt("marketsvc.resolveFailed",{detail:s[1]})),{stage:"resolve"}):new Error(a)},ts=t=>Jt().marketInstall(t).catch(mr),pr=t=>window.tangu?.onMarketInstallProgress?.(t)??(()=>{}),Vt=()=>window.tangu?.marketInstalled?.()??Promise.resolve({});async function ns(t,a,s,d){const r={restart:!1,fresh:[]};if(t==="plugin")return{restart:await T.getState().onPluginInstalled(d,s),fresh:[]};if(t==="space")return await vt(),kt("space"),r;if(t==="theme")return await We.getState().reloadThemes(),kt("theme"),r;if(t==="skill"||t==="agent")return window.tangu?.requestMainAction?.(t==="skill"?"skills-changed":"agents-changed"),r;if(t!=="amadeus-plugin"||!window.amadeus)return r;Gs();const{before:g,after:p,fresh:h}=await Pn({also:a?.id?[a.id]:[]}),o=v=>v.find(j=>j.id===a?.id)?.bundle?.enginePlugins??[],m=o(g),f=o(p),C=m.length||f.length?await T.getState().onPluginInstalled(d,m.length>0):!1;return await vt(),{restart:C,fresh:h}}const ss=()=>!!window.tangu?.backendRestart&&T.getState().desktopConfig?.mode==="managed";async function as(){return(await window.tangu?.backendRestart?.().catch(()=>null))?.state==="ready"}function hr(t,a){const s=h=>/^v?(\d+)\.(\d+)(?:\.(\d+))?(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/.exec(h?.trim()||""),d=s(t),r=s(a);if(!d||!r)return null;for(let h=1;h<=3;h++){const o=Number(d[h]||0)-Number(r[h]||0);if(o)return Math.sign(o)}if(!d[4]||!r[4])return d[4]===r[4]?0:d[4]?-1:1;const g=d[4].split("."),p=r[4].split(".");for(let h=0;h<Math.max(g.length,p.length);h++){if(g[h]===void 0||p[h]===void 0)return g[h]===p[h]?0:g[h]===void 0?-1:1;if(g[h]===p[h])continue;const o=/^\d+$/.test(g[h]),m=/^\d+$/.test(p[h]);return o&&m?Math.sign(Number(g[h])-Number(p[h])):o!==m?o?-1:1:g[h]<p[h]?-1:1}return 0}xt({"market.submissionsDescription":{zh:"投稿内容,查看审核结果并管理版本更新。",en:"Submit your work, view review results and manage version updates."}});const Wt=["skill","agent","plugin","space","theme","amadeus-plugin"],fr=[...Wt.filter(t=>t!=="amadeus-plugin"),...window.tangu?.connectStore?["webapp"]:[]];function Ht({type:t,size:a=20}){const s=t==="skill"?Mn:t==="agent"?Cn:t==="plugin"||t==="amadeus-plugin"?ta:t==="space"?Ti:t==="theme"?En:nt;return e.jsx(s,{size:a,strokeWidth:1.7})}function Ot({url:t,type:a,size:s}){const[d,r]=l.useState(!1);return!t||d?e.jsx(Ht,{type:a,size:s}):e.jsx("img",{className:"mk-icon-img",src:t,alt:"",loading:"lazy",draggable:!1,onError:()=>r(!0)})}function kn(t,a){return(hr(t,a)??0)>0}function vn(t){if(!t)return 0;const a=Date.parse(t);return Number.isFinite(a)?a:0}function mt(t,a){const s={...t};return delete s[a],s}function gr(t){return t>=1024*1024?`${(t/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(t/1024))} KB`}function xn(t){if(!t)return"";const a=new Date(t);return Number.isNaN(a.getTime())?"":sa(a,{year:"always"})}function is({onClose:t,initialQuery:a}={}){const{t:s}=Te(),d=Ba(),r=Ie(i=>i.settingsViews),g=Ie(i=>i.plugins),p=Ie(i=>i.activeIds),h=!window.tangu?.unitPage&&window.tangu?.cloudInvoke?r.find(i=>i.pluginId==="forsion-extend"&&i.item.id==="submission"&&p.includes(i.pluginId)&&Zs(g.find(w=>w.id===i.pluginId),i.item)):void 0,o=T(i=>i.closeMarket),m=t??o,[f,C]=l.useState(null),v=l.useCallback((i,w=!1,E)=>C(M=>M?.error&&!w?M:{text:i,error:w,hint:E}),[]);l.useEffect(()=>{if(!f||f.error||f.restart)return;const i=setTimeout(()=>C(null),4e3);return()=>clearTimeout(i)},[f]);const j=i=>{ss()?C(w=>w?.error?w:{text:i,error:!1,hint:s("market.restartBackendHint"),restart:"idle"}):v(i)},z=async()=>{C(w=>w&&{...w,restart:"running"});const i=await as();C(i?{text:s("market.backendRestarted"),error:!1}:{text:s("market.backendRestartFailed"),error:!0,restart:"idle"})},[x,A]=l.useState("discover"),[L,I]=l.useState([]),[D,Q]=l.useState(""),[O,Z]=l.useState({}),[H,b]=l.useState([]),[N,P]=l.useState(null),[Y,X]=l.useState(!1),[ne,ee]=l.useState({}),[ie,ke]=l.useState({}),[Le,F]=l.useState({});l.useEffect(()=>pr(i=>ke(w=>({...w,[i.id]:i}))),[]);const[U,ve]=l.useState(null),[re,xe]=l.useState(null),[se,Re]=l.useState(!1),[oe,Ae]=l.useState(""),[S,K]=l.useState(!0),[q,G]=l.useState(a??""),[ae,je]=l.useState("popular");l.useEffect(()=>{Vt().then(Z).catch(()=>{})},[d]);const le=l.useCallback(async()=>{K(!0),Q("");const i=await Vt().catch(()=>({}));Z(i);const w=await Promise.allSettled(Wt.map($=>es($))),M=w.map($=>$.status==="fulfilled"?$.value:[]).flat();I(M),w.every($=>$.status==="rejected")&&Q(s("market.loadFailShort"));const _=M.filter($=>{const te=($.type==="plugin"||$.type==="amadeus-plugin"?[...i[$.type]||[],...i[$.type==="plugin"?"amadeus-plugin":"plugin"]||[]]:i[$.type]||[]).find(fe=>fe.slug===$.installSlug);return!!te&&kn($.latestVersion,te.version)});b(_),K(!1)},[s]);l.useEffect(()=>{le()},[le]),l.useEffect(()=>{x!=="webapp"||re||se||oe||(Re(!0),Ae(""),window.tangu.connectStore().then(i=>{if(!i.ok)throw new Error(i.detail||"error");xe({base:i.base||"",items:i.items||[]})}).catch(i=>Ae(s("market.loadFail",{e:i?.message||String(i)}))).finally(()=>Re(!1)))},[x,s,re,oe,se]);const we=l.useCallback(i=>{const w=M=>(O[M]||[]).find(_=>_.slug===i.installSlug),E=w(i.type);if(E)return{entry:E,realType:i.type};if(i.type==="plugin"||i.type==="amadeus-plugin"){const M=i.type==="plugin"?"amadeus-plugin":"plugin",_=w(M);if(_)return{entry:_,realType:M}}return null},[O]),Oe=i=>we(i)?.entry,Pe=i=>!!Oe(i),ce=i=>kn(i.latestVersion,Oe(i)?.version??null),de=i=>(i.type==="plugin"||i.type==="amadeus-plugin")&&Pe(i)?e.jsx(Va,{id:i.id,item:d.items.find(w=>w.id===i.id),disabled:!!ne[i.id]||U===i.id,onError:w=>v(w,!0)}):null,Xe=i=>{const w=we(i)?.realType;return w==="amadeus-plugin"?!!window.amadeus:w==="plugin"},Ct=i=>{!we(i)||!Xe(i)||(m(),T.getState().openSettings("amadeus-plugins"))},Et=async i=>{ee(E=>({...E,[i.id]:!0})),ke(E=>mt(E,i.id)),F(E=>mt(E,i.id)),C(null);const w=Pe(i);try{const E=await ts(i.id),M=E?.type||i.type;ia("market.install"),cn("market.install",{id:i.id});const{restart:_,fresh:$}=await ns(M,E,w,v),he=Ie.getState();for(const te of $)if(he.activeIds.includes(te.id)&&_n(te)&&await ra(te.id))break;if(_)j(s("market.pluginInstalledRestartHint"));else if(M==="space")v(s("market.spaceInstalled",{name:i.name}));else if(M==="theme")v(s("market.themeInstalled",{name:i.name}));else if(M==="amadeus-plugin"){const te=Ie.getState().plugins.find(ge=>ge.id===E?.id),fe=Ie.getState().plugins,Ne=te?oa(te).map(ge=>fe.find(Ce=>Ce.id===ge.dep.id)?.name||ge.dep.name||ge.dep.id):[];v(Ne.length?s("market.amadeusPluginNeedsDeps",{name:i.name,list:Ne.join(s("common.listSep"))}):s("market.amadeusPluginInstalled",{name:i.name}))}else M!=="plugin"&&v(s("market.installOk",{name:i.name}));await le()}catch(E){F(M=>({...M,[i.id]:!0})),v(s("market.installFailNamed",{name:i.name,e:E?.message||String(E)}),!0,i.source==="github"&&E?.stage!=="resolve"?s("market.installHintGithub"):void 0)}finally{ee(E=>mt(E,i.id)),ke(E=>mt(E,i.id))}},It=async i=>{const w=we(i);if(!w)return;const E=w.realType==="agent"?s("market.uninstallWarnAgent"):w.realType==="skill"?s("market.uninstallWarnSkill"):"";if(window.confirm(s("market.uninstallConfirm",{name:i.name})+(E?`
3
-
4
- ${E}`:""))){ve(i.id);try{const M=await window.tangu.marketUninstall(w.realType,i.installSlug);cn("market.uninstall",{id:i.id});let _=w.realType==="plugin";if(w.realType==="space")M?.id&&(Yn(M.id),window.tangu?.requestMainAction?.("space-removed",M.id)),await vt(),kt("space");else if(w.realType==="theme")await We.getState().reloadThemes(),kt("theme");else if(w.realType==="amadeus-plugin"){if(window.amadeus){const{removed:$}=await Pn();_=$.some(he=>he.bundle?.enginePlugins?.length),await vt()}}else(w.realType==="skill"||w.realType==="agent")&&window.tangu?.requestMainAction?.(w.realType==="skill"?"skills-changed":"agents-changed");_?j(s("market.uninstalledNeedsRestart",{name:i.name})):v(s("market.uninstalled",{name:i.name})),await le()}catch(M){v(s("market.uninstallFail",{e:M?.message||String(M)}),!0)}finally{ve(null)}}},V=i=>{X(!0),P(null),ur(i.id).then(P).catch(w=>v(s("market.loadFail",{e:w?.message||String(w)}),!0)).finally(()=>X(!1))},Se=i=>{A(i),P(null),G("")},rt=i=>!i||i.phase==="resolve"?s("market.phase.resolve"):i.phase==="install"?s("market.installing"):i.received?i.total?s("market.phase.percent",{n:Math.min(99,Math.floor(i.received/i.total*100))}):s("market.phase.bytes",{size:gr(i.received)}):(i.attempts??1)>1?s("market.phase.connectN",{n:i.attempt??1,m:i.attempts??1}):s("market.phase.connect"),Fe=(i,w="")=>{const E=d.items.find(ge=>ge.id===i.id),M=!!ne[i.id]||E?.phase==="downloading",_=!!E?.pendingVersion,$=Pe(i),he=ce(i),te=Oe(i),fe=!M&&!!Le[i.id],Ne=M?ie[i.id]:void 0;return e.jsxs("button",{className:`btn sm ${he||!$?"primary":""} ${w}`.trim(),disabled:M,"data-install-state":M?E?.phase==="downloading"?"download":Ne?.phase||"resolve":fe?"failed":void 0,title:Ne?.host||(he?s("market.updateTitle",{from:te?.version||"?",to:i.latestVersion||"?"}):void 0),onClick:ge=>{ge.stopPropagation(),_?window.tangu?.restartForUpdate?.().catch(Ce=>v(String(Ce?.message||Ce),!0)):Et(i)},children:[M?e.jsx(it,{size:13,className:"mk-spin"}):fe||he?e.jsx(Ge,{size:13}):$?e.jsx(Ze,{size:13}):e.jsx(Fn,{size:13}),_?s("restartUpdate.button"):M?E?.phase==="downloading"?s("market.autoUpdateDownloading"):rt(Ne):s(fe?"market.installRetry":he?"market.update":$?"market.reinstall":"market.install")]})},ye=(i,w="")=>{if(!Pe(i))return null;const E=U===i.id;return e.jsx("button",{className:`btn sm ghost ${w}`.trim(),disabled:E||!!ne[i.id],title:s("market.uninstall"),"aria-label":s("market.uninstall"),onClick:M=>{M.stopPropagation(),It(i)},children:E?e.jsx(it,{size:13,className:"mk-spin"}):e.jsx(na,{size:13})})},W={discover:s("market.tab.discover"),skill:s("market.tab.skills"),agent:s("market.tab.agents"),plugin:s("market.tab.plugins"),space:s("market.tab.spaces"),theme:s("market.tab.themes"),"amadeus-plugin":s("market.tab.plugins"),webapp:s("market.tab.webapps"),installed:s("market.tab.installed"),updates:s("market.tab.updates"),submit:s("market.tab.submit")},ue=l.useCallback(i=>{const w=q.trim().toLocaleLowerCase();return w?[i.name,i.summary,i.author,i.installSlug,...i.tags||[]].some(E=>E.toLocaleLowerCase().includes(w)):!0},[q]),me=l.useCallback((i,w=ae)=>{const E=[...i];return w==="name"?E.sort((M,_)=>M.name.localeCompare(_.name)):w==="latest"?E.sort((M,_)=>vn(_.updatedAt||_.createdAt)-vn(M.updatedAt||M.createdAt)):E.sort((M,_)=>_.downloads-M.downloads)},[ae]),_e=l.useMemo(()=>{let i=x==="installed"?L.filter(w=>!!we(w)):x==="updates"?H:Wt.includes(x)?L.filter(w=>x==="plugin"?w.type==="plugin"||w.type==="amadeus-plugin":w.type===x):L;return i=i.filter(ue),me(i)},[L,we,ue,me,x,H]),J=l.useMemo(()=>me(L.filter(ue),"popular")[0],[L,ue,me]),ot=l.useMemo(()=>me(L.filter(ue),"latest").slice(0,4),[L,ue,me]),pe=l.useMemo(()=>me(L.filter(ue),"popular").filter(i=>i.id!==J?.id).slice(0,6),[L,J?.id,ue,me]),He=l.useMemo(()=>{const i=q.trim().toLocaleLowerCase();return(re?.items||[]).filter(w=>!i||[w.name,w.summary,w.handle].some(E=>E.toLocaleLowerCase().includes(i)))},[q,re]),Ue=i=>{re&&(aa(re.base+i.url),m())},Ke=(i,w=!1)=>e.jsxs("article",{className:`mk-card ${w?"compact":""}`,onClick:()=>V(i),children:[e.jsx("div",{className:"mk-card-visual","aria-hidden":"true",children:e.jsx(Ot,{url:i.iconUrl,type:i.type,size:w?20:24})}),e.jsxs("div",{className:"mk-card-content",children:[e.jsxs("div",{className:"mk-card-eyeline",children:[e.jsx("span",{children:W[i.type]}),Pe(i)&&e.jsxs("span",{className:"mk-installed-badge",children:[e.jsx(Ze,{size:11}),s("market.installed")]})]}),e.jsx("button",{className:"mk-card-title",onClick:E=>{E.stopPropagation(),V(i)},children:i.name}),e.jsx("div",{className:"mk-card-summary",children:i.summary||s("market.summaryFallback")}),!!i.tags?.length&&e.jsx("div",{className:"mk-tags",children:i.tags.slice(0,w?2:3).map(E=>e.jsx("span",{children:E},E))}),e.jsxs("div",{className:"mk-card-foot",children:[e.jsxs("span",{className:"mk-card-meta",children:[i.author,e.jsx("span",{"aria-hidden":"true",children:" · "}),s("market.downloadsShort",{n:i.downloads})]}),Fe(i),ye(i)]}),de(i)]})]},i.id),$e=i=>S?e.jsx(dt,{variant:"list"}):D&&L.length===0?e.jsxs("div",{className:"mk-state-card",children:[e.jsx(Lt,{size:28}),e.jsx("strong",{children:D}),e.jsxs("button",{className:"btn sm",onClick:()=>{le()},children:[e.jsx(Ge,{size:13}),s("market.retry")]})]}):i.length===0?e.jsxs("div",{className:"mk-state-card",children:[e.jsx(Ft,{size:28}),e.jsx("strong",{children:s(q?"market.noResults":x==="installed"?"market.noInstalled":"market.empty")}),e.jsx("span",{children:s(q?"market.noResultsHint":"market.emptyHint")}),(q||x==="installed")&&e.jsx("button",{className:"btn sm",onClick:()=>q?G(""):Se("discover"),children:s(q?"market.clearSearch":"market.browse")})]}):e.jsx("div",{className:"mk-grid",children:i.map(w=>Ke(w))}),Je=!N&&x!=="submit",lt=!N&&x!=="submit"&&x!=="webapp";return e.jsxs("div",{className:"settings-page mk-page",children:[e.jsxs("aside",{className:"settings-nav","aria-label":"Market navigation",children:[e.jsxs("div",{className:"settings-nav-top",children:[e.jsxs("button",{className:"settings-back",onClick:m,children:[e.jsx(qt,{size:15})," ",s("settings.backToApp")]}),e.jsxs("div",{className:"mk-nav-brand",children:[e.jsx("div",{className:"mk-nav-mark",children:e.jsx(Dt,{size:17})}),e.jsxs("div",{children:[e.jsx("strong",{children:s("market.title")}),e.jsx("span",{children:s("market.navSubtitle")})]})]})]}),e.jsxs("div",{className:"settings-nav-list",children:[e.jsxs("div",{className:"settings-nav-group",children:[e.jsx("div",{className:"settings-nav-grouphead",children:s("market.group.discover")}),e.jsxs("button",{className:x==="discover"?"active":"",onClick:()=>Se("discover"),children:[e.jsx(In,{size:15}),W.discover]})]}),e.jsxs("div",{className:"settings-nav-group",children:[e.jsx("div",{className:"settings-nav-grouphead",children:s("market.group.categories")}),fr.map(i=>e.jsxs("button",{className:x===i?"active":"",onClick:()=>Se(i),children:[e.jsx(Ht,{type:i,size:15}),W[i]]},i))]}),e.jsxs("div",{className:"settings-nav-group",children:[e.jsx("div",{className:"settings-nav-grouphead",children:s("market.group.manage")}),e.jsxs("button",{className:x==="installed"?"active":"",onClick:()=>Se("installed"),children:[e.jsx(ln,{size:15}),W.installed]}),e.jsxs("button",{className:x==="updates"?"active":"",onClick:()=>Se("updates"),children:[e.jsx(Ge,{size:15}),W.updates,H.length>0&&e.jsx("span",{className:"mk-nav-count",children:H.length})]}),(!!h||!!window.tangu?.openAccountCenter)&&e.jsxs("button",{className:x==="submit"?"active":"",onClick:()=>Se("submit"),children:[e.jsx(Xs,{size:15}),W.submit]})]})]})]}),e.jsxs("section",{className:"settings-main",children:[e.jsxs("div",{className:"settings-main-head mk-main-head",children:[e.jsxs("div",{className:"mk-title-block",children:[e.jsx("div",{className:"settings-main-title",children:N?N.name:W[x]}),e.jsx("div",{className:"mk-title-subtitle",children:N?s("market.detailSubtitle"):x==="discover"?s("market.subtitle"):x==="submit"?s("market.submissionsDescription"):s("market.sectionSubtitle",{section:W[x]})})]}),Je&&e.jsxs("label",{className:"mk-search",children:[e.jsx(Ft,{size:16}),e.jsx("input",{value:q,onChange:i=>G(i.target.value),placeholder:s("market.searchPlaceholder")}),q&&e.jsx("button",{onClick:()=>G(""),"aria-label":s("market.clearSearch"),children:"×"})]}),lt&&e.jsxs("label",{className:"mk-sort",children:[e.jsx("span",{children:s("market.sort.label")}),e.jsxs("select",{value:ae,onChange:i=>je(i.target.value),children:[e.jsx("option",{value:"popular",children:s("market.sort.popular")}),e.jsx("option",{value:"latest",children:s("market.sort.latest")}),e.jsx("option",{value:"name",children:s("market.sort.name")})]})]})]}),f&&e.jsxs("div",{className:`mk-notice${f.error?" is-error":""}`,role:f.error?"alert":"status",children:[f.error?e.jsx(Dn,{size:15}):e.jsx(Ze,{size:15}),e.jsxs("div",{className:"mk-notice-body",children:[e.jsx("span",{children:f.text}),f.hint&&e.jsx("small",{children:f.hint})]}),f.restart&&e.jsx("button",{className:"btn sm primary","data-market-restart":!0,disabled:f.restart==="running",onClick:()=>{z()},children:f.restart==="running"?s("market.backendRestarting"):s("market.restartBackend")}),e.jsx("button",{className:"mk-notice-close",onClick:()=>C(null),"aria-label":s("common.close"),children:e.jsx(Kt,{size:13})})]}),e.jsx("div",{className:"settings-body mk-body",children:N?e.jsxs("div",{className:"mk-detail",children:[e.jsxs("button",{className:"settings-back mk-detail-back",onClick:()=>P(null),children:[e.jsx(qt,{size:14}),s("market.detailBack")]}),e.jsxs("div",{className:"mk-detail-hero",children:[e.jsx("div",{className:"mk-detail-icon",children:e.jsx(Ot,{url:N.iconUrl,type:N.type,size:36})}),e.jsxs("div",{className:"mk-detail-intro",children:[e.jsx("span",{className:"mk-detail-kind",children:W[N.type]}),e.jsx("h2",{children:N.name}),e.jsx("p",{children:N.summary||s("market.summaryFallback")}),e.jsxs("div",{className:"mk-detail-byline",children:[s("market.author")," ",N.author,e.jsx("span",{"aria-hidden":"true",children:" · "}),s("market.downloads",{n:N.downloads})]})]})]}),e.jsxs("div",{className:"mk-detail-layout",children:[e.jsxs("main",{className:"mk-detail-main",children:[e.jsx("div",{className:"mk-detail-section-title",children:s("market.overview")}),!!N.tags?.length&&e.jsx("div",{className:"mk-tags",children:N.tags.map(i=>e.jsx("span",{children:i},i))}),e.jsx("div",{className:"mk-readme",children:N.readme?e.jsx(Js,{content:N.readme}):e.jsx("span",{className:"mk-muted",children:s("market.readmeEmpty")})})]}),e.jsxs("aside",{className:"mk-detail-sidebar",children:[e.jsxs("div",{className:"mk-detail-actions",children:[Fe(N,"mk-wide-btn"),ye(N),Xe(N)&&e.jsxs("button",{className:"btn sm mk-wide-btn",onClick:()=>Ct(N),children:[e.jsx(Tn,{size:13}),s("market.openSettings")]}),de(N)]}),e.jsxs("div",{className:"mk-trust-row",children:[e.jsx(Qs,{size:17}),e.jsxs("div",{children:[e.jsx("strong",{children:s("market.reviewed")}),e.jsx("span",{children:s("market.reviewedHint")})]})]}),e.jsxs("dl",{className:"mk-facts",children:[e.jsxs("div",{children:[e.jsx("dt",{children:s("market.type")}),e.jsx("dd",{children:W[N.type]})]}),e.jsxs("div",{children:[e.jsx("dt",{children:s("market.version")}),e.jsx("dd",{children:N.latestVersion?`v${N.latestVersion}`:s("market.unknown")})]}),e.jsxs("div",{children:[e.jsx("dt",{children:s("market.source")}),e.jsx("dd",{children:N.source==="github"?"GitHub":N.source==="npm"?"npm":s("market.sourceUpload")})]}),!!xn(N.updatedAt||N.createdAt)&&e.jsxs("div",{children:[e.jsx("dt",{children:s("market.updated")}),e.jsx("dd",{children:xn(N.updatedAt||N.createdAt)})]})]}),N.npmPackage&&e.jsxs("a",{className:"mk-repo-link",href:`https://www.npmjs.com/package/${encodeURIComponent(N.npmPackage)}`,target:"_blank",rel:"noreferrer",children:[e.jsx($t,{size:14}),N.npmPackage,e.jsx(ht,{size:12})]}),N.githubRepoUrl&&e.jsxs("a",{className:"mk-repo-link",href:N.githubRepoUrl,target:"_blank",rel:"noreferrer",children:[e.jsx(wi,{size:14}),s("market.openRepo"),e.jsx(ht,{size:12})]})]})]})]}):Y?e.jsx(dt,{variant:"document"}):x==="discover"?S?e.jsx(dt,{variant:"document"}):D&&L.length===0?$e([]):q?e.jsxs("section",{className:"mk-section",children:[e.jsx("div",{className:"mk-section-head",children:e.jsxs("div",{children:[e.jsx("h2",{children:s("market.searchResults")}),e.jsx("p",{children:s("market.resultCount",{n:_e.length})})]})}),$e(_e)]}):L.length===0?$e([]):e.jsxs("div",{className:"mk-discover",children:[J&&e.jsxs("section",{className:"mk-featured",onClick:()=>V(J),children:[e.jsxs("div",{className:"mk-featured-copy",children:[e.jsxs("span",{className:"mk-featured-label",children:[e.jsx(Dt,{size:13}),s("market.featured")]}),e.jsx("h2",{children:J.name}),e.jsx("p",{children:J.summary||s("market.summaryFallback")}),e.jsxs("div",{className:"mk-featured-meta",children:[W[J.type],e.jsx("span",{"aria-hidden":"true",children:" · "}),J.author,e.jsx("span",{"aria-hidden":"true",children:" · "}),s("market.downloadsShort",{n:J.downloads})]}),e.jsxs("div",{className:"mk-featured-actions",children:[e.jsxs("button",{className:"btn sm",onClick:i=>{i.stopPropagation(),V(J)},children:[s("market.viewDetails"),e.jsx(ea,{size:13})]}),Fe(J)]})]}),e.jsxs("div",{className:"mk-featured-art","aria-hidden":"true",children:[e.jsx(Ot,{url:J.iconUrl,type:J.type,size:58}),e.jsx("span",{children:W[J.type]})]})]}),ot.length>0&&e.jsxs("section",{className:"mk-section",children:[e.jsxs("div",{className:"mk-section-head",children:[e.jsxs("div",{children:[e.jsx("h2",{children:s("market.recent")}),e.jsx("p",{children:s("market.recentHint")})]}),e.jsx(Gn,{size:18})]}),e.jsx("div",{className:"mk-recent-grid",children:ot.map(i=>Ke(i,!0))})]}),pe.length>0&&e.jsxs("section",{className:"mk-section",children:[e.jsxs("div",{className:"mk-section-head",children:[e.jsxs("div",{children:[e.jsx("h2",{children:s("market.popular")}),e.jsx("p",{children:s("market.popularHint")})]}),e.jsx($t,{size:18})]}),e.jsx("div",{className:"mk-grid",children:pe.map(i=>Ke(i))})]})]}):x==="webapp"?se?e.jsx(dt,{variant:"list"}):oe?e.jsxs("div",{className:"mk-state-card",children:[e.jsx(Lt,{size:28}),e.jsx("strong",{children:oe}),e.jsx("button",{className:"btn sm",onClick:()=>{xe(null),Ae("")},children:s("market.retry")})]}):He.length===0?e.jsxs("div",{className:"mk-state-card",children:[e.jsx(nt,{size:28}),e.jsx("strong",{children:s(q?"market.noResults":"market.empty")}),e.jsx("span",{children:s(q?"market.noResultsHint":"market.webHint")})]}):e.jsxs("div",{className:"mk-webapps",children:[e.jsx("p",{className:"mk-web-hint",children:s("market.webHint")}),e.jsx("div",{className:"mk-grid",children:He.map(i=>e.jsxs("article",{className:"mk-card",onClick:()=>Ue(i),children:[e.jsx("div",{className:"mk-card-visual",children:e.jsx(nt,{size:24})}),e.jsxs("div",{className:"mk-card-content",children:[e.jsx("div",{className:"mk-card-eyeline",children:e.jsx("span",{children:W.webapp})}),e.jsx("button",{className:"mk-card-title",onClick:w=>{w.stopPropagation(),Ue(i)},children:i.name}),e.jsx("div",{className:"mk-card-summary",children:i.summary||s("market.summaryFallback")}),e.jsxs("div",{className:"mk-card-foot",children:[e.jsx("span",{className:"mk-card-meta",children:i.handle}),e.jsxs("button",{className:"btn sm primary",onClick:w=>{w.stopPropagation(),Ue(i)},children:[e.jsx(nt,{size:13}),s("market.webOpen")]})]})]})]},`${i.handle}/${i.slug}`))})]}):x==="submit"?h?e.jsx(qa,{pluginId:h.pluginId,def:h.item,bare:!0}):e.jsxs("section",{className:"mk-submit",children:[e.jsxs("div",{className:"mk-submit-copy",children:[e.jsx("span",{children:s("market.submitKicker")}),e.jsx("h2",{children:s("market.submitTitle")}),e.jsx("p",{children:s("market.submitHint")}),e.jsxs("button",{className:"btn primary",onClick:()=>{window.tangu?.openAccountCenter?.("submission")},children:[e.jsx(ht,{size:15}),s("market.submitOpen")]})]}),e.jsxs("div",{className:"mk-submit-art",children:[e.jsx(Lt,{size:44}),e.jsx("strong",{children:s("market.submitArtTitle")}),e.jsx("span",{children:s("market.submitArtHint")})]})]}):e.jsxs("section",{className:"mk-section",children:[e.jsxs("div",{className:"mk-section-head",children:[e.jsxs("div",{children:[e.jsx("h2",{children:W[x]}),e.jsx("p",{children:s("market.resultCount",{n:_e.length})})]}),x==="updates"&&window.tangu?.marketCheckUpdates?e.jsxs("button",{className:"btn sm",disabled:d.checking,onClick:()=>{window.tangu.marketCheckUpdates().then(le).catch(i=>v(String(i?.message||i),!0))},children:[e.jsx(Ge,{size:14}),s("market.autoUpdateCheck")]}):x==="updates"?e.jsx(Ge,{size:18}):x==="installed"?e.jsx(ln,{size:18}):e.jsx(Ht,{type:x,size:18})]}),x==="updates"&&!S&&H.length===0&&!q?e.jsxs("div",{className:"mk-state-card",children:[e.jsx(Ze,{size:28}),e.jsx("strong",{children:s("market.allUpToDate")}),e.jsx("span",{children:s("market.allUpToDateHint")})]}):$e(_e)]})})]})]})}const br=({rec:t,preInstalled:a})=>{const{t:s}=Te(),[d,r]=l.useState(null),[g,p]=l.useState(a?"done":"loading"),[h,o]=l.useState(""),[m,f]=l.useState("no");l.useEffect(()=>{if(a)return;let v=!0;return es(t.type).then(j=>{if(!v)return;const z=j.find(x=>x.installSlug===t.slug);z?(r(z),p("ready")):p("missing")}).catch(()=>{v&&p("missing")}),()=>{v=!1}},[t,a]);const C=async()=>{if(d){p("installing"),o("");try{const v=await ts(d.id),j=v?.type||t.type;let z=!1;(await ns(j,v,!1,(A,L)=>{L&&(z=!0,o(A))})).restart&&f("needed"),p(z?"ready":"done")}catch(v){o(s("market.installFail",{e:v?.message||String(v)})),p("ready")}}};return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:"var(--ui-font-meta, 12px)"},children:d?.name||t.name||t.slug}),t.reason&&e.jsx("div",{style:{fontSize:"var(--ui-font-caption, 11px)",color:"var(--text-faint)"},children:t.reason}),h&&e.jsx("div",{role:"alert",style:{fontSize:"var(--ui-font-caption, 11px)",color:"var(--danger)",overflowWrap:"anywhere"},children:h}),m!=="no"&&e.jsx("div",{"data-rec-restart-hint":!0,style:{fontSize:"var(--ui-font-caption, 11px)",color:"var(--text-muted)"},children:s("market.pluginInstalledRestartHint")})]}),g==="done"&&m!=="no"&&ss()?e.jsx("button",{className:"btn sm primary","data-rec-restart":!0,disabled:m==="running",onClick:()=>{f("running"),as().then(v=>{f(v?"no":"needed"),o(v?"":s("market.backendRestartFailed"))})},children:s(m==="running"?"market.backendRestarting":"market.restartBackend")}):g==="done"?e.jsx("span",{style:{fontSize:"var(--ui-font-caption, 11px)",color:"var(--ok, #3aa675)",whiteSpace:"nowrap"},children:s("plugin.onboarding.installed")}):g==="missing"?e.jsx("span",{style:{fontSize:"var(--ui-font-caption, 11px)",color:"var(--text-faint)",whiteSpace:"nowrap"},children:s("plugin.onboarding.notFound")}):e.jsx("button",{className:"btn sm",disabled:g!=="ready",onClick:()=>{C()},children:s(g==="installing"?"plugin.onboarding.installing":"plugin.onboarding.install")})]})},wn=({result:t,checking:a})=>{const{t:s}=Te();if(a&&!t)return e.jsxs("span",{className:"plugin-req-state","data-state":"checking",children:[e.jsx(it,{size:12,className:"spin","aria-hidden":"true"}),s("plugin.onboarding.checking")]});const d=t?.state??"unknown";return e.jsxs("span",{className:"plugin-req-state","data-state":d,style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:"var(--ui-font-caption, 11px)",whiteSpace:"nowrap",color:d==="ok"?"var(--ok, #3aa675)":d==="unmet"?"var(--warn, #b8860b)":"var(--text-faint)"},children:[d==="ok"?e.jsx(Ze,{size:12,"aria-hidden":"true"}):d==="unmet"?e.jsx(Dn,{size:12,"aria-hidden":"true"}):e.jsx(zi,{size:12,"aria-hidden":"true"}),s(`plugin.onboarding.req.${d}`)]})},kr=({plugin:t})=>{const{t:a,locale:s}=Te(),d=We(b=>b.mode),r=la(t.onboarding,s),g=ca(t),p=Ve(b=>b.results[t.id])??{},h=Ve(b=>!!b.checking[t.id]),o=Ie(b=>b.settings).filter(b=>b.pluginId===t.id),m=Ie(b=>b.readiness).filter(b=>b.pluginId===t.id),f=b=>{Ve.getState().evaluate(t.id,{checks:b})};l.useEffect(()=>{f(!0)},[t.id]);const C=g.filter(b=>b.kind==="setting"),v=g.filter(b=>b.kind==="check"),j=g.flatMap(b=>b.kind==="permission"?[b.id]:[]),z=new Set(C.map(b=>b.key)),x=(r.settings===!0?o.filter(b=>b.item.key!==da):Array.isArray(r.settings)?o.filter(b=>r.settings.includes(b.item.key)):[]).filter(b=>!z.has(b.item.key)),[A,L]=l.useState(null);l.useEffect(()=>{if(!r.recommends?.length){L({});return}Vt().then(b=>{const N={};for(const[P,Y]of Object.entries(b))N[P]=new Set(Y.map(X=>X.slug));L(N)}).catch(()=>L({}))},[r]);const I=g.map(b=>p[Be(b)]?.state),D=I.filter(b=>b==="unmet").length,Q=I.filter(b=>b!=="ok"&&b!=="unmet").length,O=!h&&g.length>0&&I.every(b=>b==="ok"),Z=()=>{pa(t),Ve.getState().close()},H=()=>Ve.getState().close();return e.jsx("div",{className:"dialog-overlay",onMouseDown:Z,children:e.jsxs("div",{className:"dialog plugin-onboarding-card",style:{width:"min(520px, 92vw)"},onMouseDown:b=>b.stopPropagation(),children:[e.jsx("div",{className:"dialog-title",children:a("plugin.onboarding.title",{name:ua(t,s)})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,maxHeight:"64vh",overflowY:"auto",padding:"2px 0"},children:[r.intro&&e.jsx("div",{style:{fontSize:"var(--ui-font-meta, 12px)",color:"var(--text-faint)"},children:r.intro}),e.jsxs("div",{className:"plugin-onboarding-requires",children:[e.jsx("div",{className:"hint",style:{marginBottom:6},children:a("plugin.onboarding.requiresTitle")}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[C.map(b=>{const N=o.find(P=>P.item.key===b.key)?.item;return e.jsxs("div",{"data-requirement":Be(b),style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("div",{style:{flex:1,minWidth:0},children:N?e.jsx(hn,{pluginId:t.id,def:N}):e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontSize:"var(--ui-font-meta, 12px)"},children:b.key}),e.jsx("div",{style:{fontSize:"var(--ui-font-caption, 11px)",color:"var(--text-faint)"},children:a("plugin.onboarding.req.inactive")})]})}),e.jsx(wn,{result:p[Be(b)]})]},Be(b))}),v.map(b=>{const N=m.find(ne=>ne.item.id===b.id)?.item,P=N?typeof N.label=="function"?N.label():N.label:b.id,Y=p[Be(b)],X=Y?.detail==="timeout"?a("plugin.onboarding.req.timeout"):Y?.detail;return e.jsxs("div",{"data-requirement":Be(b),style:{display:"flex",alignItems:"flex-start",gap:8},children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:"var(--ui-font-meta, 12px)"},children:P}),X&&e.jsx("div",{style:{fontSize:"var(--ui-font-caption, 11px)",color:"var(--text-faint)"},children:X}),!N&&e.jsx("div",{style:{fontSize:"var(--ui-font-caption, 11px)",color:"var(--text-faint)"},children:a("plugin.onboarding.req.inactive")})]}),e.jsx(wn,{result:Y,checking:h})]},Be(b))}),j.length>0&&e.jsx(ma,{mode:d,only:j,onSnapshot:b=>{Ve.getState().evaluate(t.id,{permissions:b})}})]})]}),!!r.steps?.length&&e.jsxs("div",{children:[e.jsx("div",{className:"hint",style:{marginBottom:6},children:a("plugin.onboarding.stepsTitle")}),e.jsx("ol",{style:{margin:0,paddingLeft:18,display:"flex",flexDirection:"column",gap:6},children:r.steps.map((b,N)=>e.jsxs("li",{style:{fontSize:"var(--ui-font-meta, 12px)"},children:[b.title,b.description&&e.jsx("div",{style:{fontSize:"var(--ui-font-caption, 11px)",color:"var(--text-faint)"},children:b.description})]},N))})]}),x.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"hint",style:{marginBottom:6},children:a("plugin.onboarding.settingsTitle")}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:x.map(b=>e.jsx(hn,{pluginId:t.id,def:b.item},b.item.key))})]}),!!r.recommends?.length&&A&&e.jsxs("div",{children:[e.jsx("div",{className:"hint",style:{marginBottom:6},children:a("plugin.onboarding.recommendsTitle")}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:r.recommends.map(b=>e.jsx(br,{rec:b,preInstalled:b.type==="plugin"||b.type==="amadeus-plugin"?!!(A.plugin?.has(b.slug)||A["amadeus-plugin"]?.has(b.slug)):!!A[b.type]?.has(b.slug)},`${b.type}:${b.slug}`))})]}),e.jsx("div",{className:"plugin-onboarding-summary","data-ready":O?"1":"0",style:{fontSize:"var(--ui-font-caption, 11px)",color:O?"var(--ok, #3aa675)":"var(--text-faint)"},children:O?a("plugin.onboarding.allReady"):D===0&&!h?a("plugin.onboarding.someUnknown",{n:Q}):a("plugin.onboarding.laterHint")})]}),e.jsx("div",{className:"dialog-actions",children:D>0?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"dialog-btn",onClick:Z,children:a("plugin.onboarding.later")}),e.jsx("button",{className:"dialog-btn","data-primary":!0,disabled:h,onClick:()=>f(!0),children:a(h?"plugin.onboarding.checking":"plugin.onboarding.recheck")})]}):e.jsxs(e.Fragment,{children:[!O&&e.jsx("button",{className:"dialog-btn",disabled:h,onClick:()=>f(!0),children:a("plugin.onboarding.recheck")}),e.jsx("button",{className:"dialog-btn","data-primary":!0,onClick:H,children:a("plugin.onboarding.done")})]})})]})})};function rs(){const t=Ve(d=>d.pluginId),a=Ie(d=>d.plugins),s=t?a.find(d=>d.id===t):void 0;return!s||!_n(s)?null:e.jsx("div",{className:"am-app tangu-lovable",style:{display:"contents"},children:e.jsx(kr,{plugin:s})})}const Pt=9e3,vr=5*1024*1024;function Ut(t){return typeof t=="string"?t.replace(/\bBearer\s+[A-Za-z0-9._~+\/-]+=*/gi,"Bearer [redacted]").replace(/\b(sk-[a-zA-Z0-9_-]{12,})\b/g,"[redacted]").replace(/((?:["']?)(?:api[_-]?key|access[_-]?token|refresh[_-]?token|token|password|secret|authorization|cookie)(?:["']?)\s*[:=]\s*["']?)([^\s,"';&}]+)/gi,"$1[redacted]"):Array.isArray(t)?t.map(Ut):t&&typeof t=="object"?Object.fromEntries(Object.entries(t).map(([a,s])=>[a,/^(?:token|.*api[_-]?key|access[_-]?token|refresh[_-]?token|password|secret|authorization|cookie|set-cookie)$/i.test(a)?"[redacted]":Ut(s)])):t}async function xr(t,a,s){const d=await Wa(t,a,s),r=JSON.stringify(Ut({...d,feedbackSelection:s}),null,2);return{json:r,filename:`tangu-feedback-${a?.id.slice(0,8)||"app"}-${new Date().toISOString().slice(0,10)}.json`,bytes:new TextEncoder().encode(r).byteLength,missing:Object.entries(d.sources).filter(([,g])=>g!=="included").map(([g])=>g),truncated:!!d.messagesTruncated||!!d.activityLogTruncated}}xt({"feedback.subtitle":{zh:"告诉我们哪里可以做得更好。",en:"Tell us what could work better."},"feedback.kind":{zh:"反馈类型",en:"Feedback type"},"feedback.bug":{zh:"遇到问题",en:"Report a problem"},"feedback.idea":{zh:"功能建议",en:"Suggest a feature"},"feedback.other":{zh:"其他反馈",en:"Something else"},"feedback.description":{zh:"具体发生了什么?",en:"What happened?"},"feedback.bugPlaceholder":{zh:`你当时在做什么?预期的结果是什么,实际又发生了什么?
5
- 如果可以,请写下重现步骤。`,en:`What were you doing? What did you expect, and what happened instead?
6
- Include steps to reproduce it if you can.`},"feedback.ideaPlaceholder":{zh:"你想完成什么?哪项改进会对你有帮助?",en:"What are you trying to do? What change would help?"},"feedback.otherPlaceholder":{zh:"分享你的使用体验或想法……",en:"Share your experience or thoughts…"},"feedback.context":{zh:"附带诊断信息",en:"Include diagnostic information"},"feedback.diagnostics":{zh:"应用与运行日志",en:"App and runtime logs"},"feedback.diagnosticsHint":{zh:"版本、界面状态、错误、运行时间线与用量;进程日志可能涉及其他会话。",en:"Version, interface state, errors, run timeline and usage. Process logs may include other sessions."},"feedback.conversation":{zh:"当前会话内容",en:"Current conversation"},"feedback.conversationHint":{zh:"最多 500 条消息,包含工具输入与输出。",en:"Up to 500 messages, including tool inputs and outputs."},"feedback.activity":{zh:"近期活动记录",en:"Recent activity"},"feedback.activityHint":{zh:"近 2 天内最新 500 行,可能包含文件名与操作路径。",en:"The latest 500 lines from the last 2 days; may contain file names and paths."},"feedback.sessionContext":{zh:"关联会话:{name}",en:"Linked conversation: {name}"},"feedback.withoutSession":{zh:"未关联会话,仍可提交应用问题。",en:"No linked conversation. You can still report an app issue."},"feedback.privacy":{zh:"已过滤常见凭据字段。日志仍可能包含路径或内容片段,请按需选择并预览。",en:"Common credential fields are filtered. Logs may still contain paths or content excerpts; choose what to include and review the preview."},"feedback.preview":{zh:"预览附件",en:"Preview attachment"},"feedback.export":{zh:"导出日志文件",en:"Export log file"},"feedback.backToForm":{zh:"返回反馈",en:"Back to feedback"},"feedback.preparing":{zh:"正在准备诊断信息…",en:"Preparing diagnostics…"},"feedback.sending":{zh:"正在提交…",en:"Sending…"},"feedback.ready":{zh:"诊断附件已就绪 · {size}",en:"Diagnostics ready · {size}"},"feedback.textOnly":{zh:"仅提交反馈文字",en:"Only your feedback text will be sent"},"feedback.partial":{zh:"部分诊断来源不可用:{sources}。将提交已获取的内容。",en:"Some diagnostic sources are unavailable: {sources}. Available information will be sent."},"feedback.source.appVersion":{zh:"应用版本",en:"app version"},"feedback.source.messages":{zh:"会话内容",en:"conversation"},"feedback.source.agentConfig":{zh:"会话设置",en:"session settings"},"feedback.source.backendLogs":{zh:"运行输出",en:"runtime output"},"feedback.source.connection":{zh:"连接信息",en:"connection details"},"feedback.source.backendStatus":{zh:"引擎状态",en:"engine status"},"feedback.source.usage":{zh:"用量",en:"usage"},"feedback.source.timeline":{zh:"运行时间线",en:"run timeline"},"feedback.source.activityLog":{zh:"活动记录",en:"activity"},"feedback.truncated":{zh:"部分记录已达到数量上限,附件内已标记。",en:"Some records reached the collection limit; this is marked in the attachment."},"feedback.tooLarge":{zh:"附件超过 5 MB,请减少勾选的内容后再提交。",en:"The attachment exceeds 5 MB. Deselect some information before sending."},"feedback.prepareFailed":{zh:"诊断信息准备失败。请重试,或取消勾选后仅提交文字。",en:"Could not prepare diagnostics. Retry, or deselect the options to send text only."},"feedback.refresh":{zh:"重新收集",en:"Collect again"},"feedback.successTitle":{zh:"反馈已收到",en:"Feedback received"},"feedback.successHint":{zh:"感谢你帮助我们改进 Tangu。你可以在账户中心查看回复。",en:"Thanks for helping improve Tangu. You can view replies in your account center."},"feedback.ticket":{zh:"反馈编号:{id}",en:"Reference: {id}"},"feedback.viewFeedback":{zh:"查看我的反馈",en:"View my feedback"},"feedback.done":{zh:"完成",en:"Done"},"feedback.limit":{zh:"反馈内容不能超过 {max} 字。",en:"Feedback cannot exceed {max} characters."},"feedback.retry":{zh:"重试提交",en:"Try again"},"feedback.diagnosePrompt":{zh:`我在使用 Tangu 时遇到一个问题,想请你帮我诊断:
7
-
8
- {description}
9
-
10
- 请结合当前会话的上下文分析可能的原因,并给出排查步骤。`,en:`I ran into a problem while using Tangu and would like your help diagnosing it:
11
-
12
- {description}
13
-
14
- Using the context of this session, analyze the likely causes and suggest troubleshooting steps.`}});function os(t){T.getState().setPendingDraft(t),be.getState().openView("chat",{followActive:!0,reuseKey:"primary"},"main")}const ls=({cfg:t,activeSession:a,onClose:s,surface:d="modal"})=>{const{t:r}=Te(),[g]=l.useState(()=>({cfg:t,session:a})),p=T(S=>S.feedbackDraft),[h,o]=l.useState("bug"),[m,f]=l.useState(!0),[C,v]=l.useState(!1),[j,z]=l.useState(!1),[x,A]=l.useState(0),[L,I]=l.useState(null),[D,Q]=l.useState(!1),[O,Z]=l.useState(!1),[H,b]=l.useState(null),[N,P]=l.useState(""),Y=l.useRef(null),X=l.useRef(!1),ne=l.useRef(s);ne.current=s;const ee=m||C||j,ie=`${m}:${C}:${j}:${x}`,ke=L?.key===ie?L:null,Le=ee&&!ke,F=ee?ke?.report:void 0,U=!!F&&F.bytes>vr,ve=p.trim().length>Pt,re=!!p.trim()&&!ve&&!O&&!H&&!Le&&!U&&(!ee||!!F),xe=()=>{X.current||ne.current()};l.useEffect(()=>{if(!ee)return;let S=!0;return xr(g.cfg,g.session,{diagnostics:m,conversation:C,activity:j}).then(K=>{S&&I({key:ie,report:K})}).catch(()=>{S&&I({key:ie,failed:!0})}),()=>{S=!1}},[g,m,C,j,x,ie,ee]),l.useEffect(()=>{const S=document.activeElement,K=requestAnimationFrame(()=>Y.current?.querySelector("textarea")?.focus()),q=G=>{if(G.key==="Escape"&&(G.preventDefault(),G.stopImmediatePropagation(),X.current||ne.current()),G.key==="Tab"){const ae=Array.from(Y.current?.querySelectorAll('button:not(:disabled), textarea:not(:disabled), input:not(:disabled), [tabindex="0"]')||[]).filter(we=>we.getClientRects().length>0),je=ae[0],le=ae[ae.length-1];if(!je){G.preventDefault(),Y.current?.focus();return}G.shiftKey&&(document.activeElement===je||!Y.current?.contains(document.activeElement))?(G.preventDefault(),le.focus()):!G.shiftKey&&(document.activeElement===le||!Y.current?.contains(document.activeElement))&&(G.preventDefault(),je.focus())}};return document.addEventListener("keydown",q,!0),()=>{cancelAnimationFrame(K),document.removeEventListener("keydown",q,!0),S?.focus()}},[]);const se=async()=>{if(!(!re||X.current)){if(!window.tangu?.submitFeedback){P(r("feedback.errUnavailable"));return}X.current=!0,Z(!0),P("");try{const S=await window.tangu.submitFeedback({description:`[Tangu · ${r(`feedback.${h}`)}]
15
-
16
- ${p.trim()}`,...F?{sessionLogJson:F.json,sessionLogName:F.filename}:{}});S.ok?(b(S),T.setState({feedbackDraft:""})):P(S.error==="attachment-too-large"?r("feedback.tooLarge"):r("feedback.errFail",{err:S.error==="not-logged-in"?r("feedback.errNotLoggedIn"):S.error||"Unknown error"}))}catch(S){P(r("feedback.errFail",{err:String(S?.message||S)}))}finally{X.current=!1,Z(!1)}}},Re=()=>{if(!p.trim()||O)return;const S=r("feedback.diagnosePrompt",{description:p.trim()});window.tangu?.requestMainAction?window.tangu.requestMainAction("chat-draft",S):os(S),xe()},oe=F?`${(F.bytes/1024).toFixed(1)} KB`:"",Ae=()=>{if(!F)return;const S=URL.createObjectURL(new Blob([F.json],{type:"application/json;charset=utf-8"})),K=document.createElement("a");K.href=S,K.download=F.filename,K.click(),setTimeout(()=>URL.revokeObjectURL(S),1e4)};return e.jsx("div",{className:d==="panel"?"feedback-panel-surface":"memv-modal feedback-overlay",onClick:S=>{d==="modal"&&S.target===S.currentTarget&&xe()},children:e.jsxs("div",{ref:Y,className:"modal feedback-modal",role:"dialog","aria-modal":"true","aria-labelledby":"feedback-title",tabIndex:-1,onKeyDown:S=>{(S.metaKey||S.ctrlKey)&&S.key==="Enter"&&!S.nativeEvent.isComposing&&(S.preventDefault(),se())},children:[e.jsxs("div",{className:"modal-head feedback-head",children:[e.jsxs("div",{className:"feedback-heading",children:[e.jsx(dn,{size:19}),e.jsxs("div",{children:[e.jsx("h2",{id:"feedback-title",children:r("feedback.title")}),e.jsx("p",{children:r("feedback.subtitle")})]})]}),e.jsx("button",{className:"icon-btn",onClick:xe,disabled:O,"aria-label":r("settings.btn.cancel"),children:e.jsx(Kt,{size:18})})]}),H?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"modal-body feedback-success",role:"status",children:[e.jsx("span",{className:"feedback-success-icon",children:e.jsx(Ze,{size:28})}),e.jsx("h3",{children:r("feedback.successTitle")}),e.jsx("p",{children:r("feedback.successHint")}),H.id&&e.jsx("code",{children:r("feedback.ticket",{id:H.id})}),H.attachmentSkipped&&e.jsx("p",{className:"feedback-warning",children:r("feedback.okNoLog")}),N&&e.jsx("p",{className:"feedback-warning",role:"alert",children:N})]}),e.jsxs("div",{className:"feedback-footer",children:[window.tangu?.openAccountCenter&&e.jsx("button",{className:"btn ghost",onClick:()=>{P(""),window.tangu.openAccountCenter("feedback").catch(()=>P(r("feedback.errUnavailable")))},children:r("feedback.viewFeedback")}),e.jsx("span",{className:"grow"}),e.jsx("button",{autoFocus:!0,className:"btn primary",onClick:xe,children:r("feedback.done")})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"modal-body feedback-body",children:[D?e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn ghost sm feedback-back",onClick:()=>Q(!1),children:[e.jsx(qt,{size:14}),r("feedback.backToForm")]}),e.jsxs("div",{className:"feedback-file",children:[e.jsx(_t,{size:15}),e.jsx("span",{children:F?.filename}),e.jsx("span",{children:oe})]}),e.jsx("pre",{className:"feedback-preview",tabIndex:0,children:F?.json})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"feedback-kinds",role:"group","aria-label":r("feedback.kind"),children:[{id:"bug",Icon:ha},{id:"idea",Icon:Wn},{id:"other",Icon:dn}].map(({id:S,Icon:K})=>e.jsxs("button",{className:"btn ghost","aria-pressed":h===S,disabled:O,onClick:()=>o(S),children:[e.jsx(K,{size:15}),r(`feedback.${S}`)]},S))}),e.jsxs("div",{className:"feedback-description",children:[e.jsx("label",{htmlFor:"feedback-description",children:r(h==="bug"?"feedback.description":"feedback.label")}),e.jsx("textarea",{id:"feedback-description",value:p,onChange:S=>{T.setState({feedbackDraft:S.target.value}),P("")},placeholder:r(`feedback.${h}Placeholder`),disabled:O,"aria-invalid":ve,"aria-describedby":"feedback-count"}),e.jsxs("span",{id:"feedback-count",className:ve?"feedback-warning":"feedback-count",children:[p.trim().length.toLocaleString()," / ",Pt.toLocaleString()]})]}),e.jsxs("section",{className:"feedback-context","aria-labelledby":"feedback-context-title",children:[e.jsxs("div",{className:"feedback-section-heading",children:[e.jsx("h3",{id:"feedback-context-title",children:r("feedback.context")}),e.jsx("code",{children:"/feedback"})]}),e.jsx("p",{className:"feedback-session",children:g.session?r("feedback.sessionContext",{name:g.session.title||g.session.id.slice(0,8)}):r("feedback.withoutSession")}),[{id:"diagnostics",checked:m,change:f,unavailable:!1},{id:"conversation",checked:C,change:v,unavailable:!g.session},{id:"activity",checked:j,change:z,unavailable:!window.tangu?.exportActivity}].map(S=>e.jsxs("label",{className:"feedback-option","data-disabled":S.unavailable||void 0,children:[e.jsx("input",{type:"checkbox",checked:S.checked,onChange:K=>S.change(K.target.checked),disabled:O||S.unavailable}),e.jsxs("span",{children:[e.jsx("strong",{children:r(`feedback.${S.id}`)}),e.jsx("small",{children:r(`feedback.${S.id}Hint`)})]})]},S.id))]}),e.jsxs("div",{className:"feedback-report-status",role:"status",children:[e.jsx("span",{children:Le?e.jsxs(e.Fragment,{children:[e.jsx(it,{size:13,className:"spin"}),r("feedback.preparing")]}):F?e.jsxs(e.Fragment,{children:[e.jsx(_t,{size:13}),r("feedback.ready",{size:oe})]}):r(ee?"feedback.prepareFailed":"feedback.textOnly")}),e.jsxs("div",{children:[F&&e.jsx("button",{className:"btn ghost sm",onClick:()=>Q(!0),disabled:O,children:r("feedback.preview")}),F&&e.jsxs("button",{className:"btn ghost sm",onClick:Ae,disabled:O,children:[e.jsx(Fn,{size:13}),r("feedback.export")]}),ee&&e.jsx("button",{className:"icon-btn",onClick:()=>A(S=>S+1),disabled:O||Le,"aria-label":r("feedback.refresh"),title:r("feedback.refresh"),children:e.jsx(Ge,{size:13})})]})]}),!!F?.missing.length&&e.jsx("p",{className:"feedback-warning",children:r("feedback.partial",{sources:F.missing.map(S=>r(`feedback.source.${S}`)).join(", ")})}),F?.truncated&&e.jsx("p",{className:"feedback-note",children:r("feedback.truncated")}),ee&&e.jsx("p",{className:"feedback-note",children:r("feedback.privacy")})]}),U&&e.jsx("p",{className:"feedback-warning",role:"alert",children:r("feedback.tooLarge")}),ve&&e.jsx("p",{className:"feedback-warning",role:"alert",children:r("feedback.limit",{max:Pt})}),N&&e.jsx("p",{className:"feedback-warning",role:"alert",children:N})]}),e.jsxs("div",{className:"feedback-footer",children:[e.jsxs("button",{className:"btn ghost feedback-diagnose",onClick:Re,disabled:O||!p.trim(),title:r("feedback.diagnoseViaChatHint"),children:[e.jsx(fa,{size:15}),r("feedback.diagnoseViaChat")]}),e.jsx("span",{className:"grow"}),e.jsxs("button",{className:"btn primary",onClick:()=>{se()},disabled:!re,children:[O&&e.jsx(it,{size:14,className:"spin"}),r(O?"feedback.sending":N?"feedback.retry":"feedback.submit")]})]})]})]})})};function pt(t){return Array.from(t.dataTransfer?.types??[]).includes("Files")}function Nt(){let t=0;const a=o=>{if(o){document.body.setAttribute("data-file-drag","1");return}t=0,document.body.removeAttribute("data-file-drag")},s=o=>{!pt(o)||o.defaultPrevented||(o.preventDefault(),o.dataTransfer&&(o.dataTransfer.dropEffect="none"))},d=o=>{pt(o)&&!o.defaultPrevented&&o.preventDefault()},r=()=>a(!1),g=o=>{pt(o)&&(t++,a(!0))},p=o=>{pt(o)&&(t=Math.max(0,t-1),t||a(!1))},h=()=>a(!1);return document.addEventListener("dragover",s),document.addEventListener("drop",d),document.addEventListener("drop",r,!0),document.addEventListener("dragenter",g),document.addEventListener("dragleave",p),window.addEventListener("dragend",h),window.addEventListener("blur",h),()=>{document.removeEventListener("dragover",s),document.removeEventListener("drop",d),document.removeEventListener("drop",r,!0),document.removeEventListener("dragenter",g),document.removeEventListener("dragleave",p),window.removeEventListener("dragend",h),window.removeEventListener("blur",h),document.body.removeAttribute("data-file-drag")}}function cs({target:t,onUnavailable:a}){const[,s]=l.useReducer(m=>m+1,0),[d,r]=l.useState(()=>({...t.params??{}})),g=l.useRef(d);g.current=d;const p=l.useRef(!1);l.useEffect(()=>jt(s),[]),l.useEffect(()=>r({...t.params??{}}),[t]);const h=at(t.type);h&&(p.current=!0),l.useEffect(()=>{p.current&&!h&&a?.()},[h,a]);const o=l.useMemo(()=>({id:`floating:${t.type}`,type:t.type,loc:"main",get params(){return g.current},setTitle:m=>{document.title=m},setParams:m=>r({...m}),close:()=>a?.()}),[t.type,a]);return h?e.jsx("div",{className:"floating-plugin-view","data-view":t.type,children:e.jsx(On,{children:e.jsx(l.Suspense,{fallback:null,children:h.factory({leaf:o,params:d})})})}):e.jsx("div",{className:"floating-panel-empty",children:"Loading panel…"})}const wr=[[390,"iPhone"],[414,"Max"],[768,"iPad"]];function yr({children:t}){const[a,s]=l.useState(390);return An!=="mobile"?e.jsx(e.Fragment,{children:t}):window.innerWidth<=820?e.jsx(e.Fragment,{children:t}):e.jsxs("div",{className:"sc-frame",children:[e.jsx("div",{className:"sc-bar",children:wr.map(([d,r])=>e.jsxs("button",{className:`sc-size${a===d?" on":""}`,onClick:()=>s(d),children:[r," · ",d]},d))}),e.jsx("div",{className:"sc-device",style:{width:a},children:t})]})}function jr(){Ha(),l.useEffect(()=>Nt(),[]),l.useEffect(()=>{Ua(),yi()},[]),l.useEffect(()=>window.tangu?.onMainAction?.((o,m)=>{o==="onboarding"&&T.getState().setOnboarding(!0),o==="dev-commands"&&Ka(),o==="test-notification"&&Ya(),o==="reset-layout"&&be.getState().resetLayout({undoable:!0}),o==="achievement-toast"&&ga(),o==="space-removed"&&m&&Yn(m),o==="chat-draft"&&m&&os(m),o==="chat-quote"&&m&&ji(m),o==="agents-changed"&&(T.getState().refreshAgents(),window.dispatchEvent(new Event("forsion:agents-changed"))),o==="skills-changed"&&(Gt(Zt()).then(f=>T.setState({skillsList:f})).catch(()=>{}),window.dispatchEvent(new Event("forsion:skills-changed"))),o==="open-agents"&&fn(T.getState().defaultAgentSlug||""),o==="open-agent"&&m&&/^[a-z0-9][a-z0-9-]{0,63}$/.test(m)&&fn(m)}),[]);const t=We(),a=T($n(o=>({sessions:o.sessions,archivedSessions:o.archivedSessions,activeId:o.activeId,settingsOpen:o.settingsOpen,settingsTab:o.settingsTab,settingsSkillKey:o.settingsSkillKey,onboarding:o.onboarding,feedbackOpen:o.feedbackOpen,marketOpen:o.marketOpen,closeMarket:o.closeMarket,achievementsOpen:o.achievementsOpen,cfg:o.cfg,tr:o.tr,openSettings:o.openSettings,closeSettings:o.closeSettings,patchConfig:o.patchConfig,connect:o.connect,setOnboarding:o.setOnboarding,closeFeedback:o.closeFeedback}))),s=a.sessions.find(o=>o.id===a.activeId)||a.archivedSessions.find(o=>o.id===a.activeId)||null,d=l.useSyncExternalStore(ba,un,un),[r,g]=l.useState(!1),p=l.useRef(a.onboarding);l.useEffect(()=>{const o=p.current;if(p.current=a.onboarding,o&&!a.onboarding){g(!0);const m=setTimeout(()=>g(!1),650);return()=>clearTimeout(m)}},[a.onboarding]);const h=a.settingsOpen||a.marketOpen||a.achievementsOpen||a.feedbackOpen||!!d||a.onboarding;return e.jsxs(yr,{children:[e.jsx("div",{className:`shell-host${r?" main-enter":""}`,style:a.onboarding?{visibility:"hidden"}:void 0,children:e.jsx(Qn,{dark:t.mode==="dark",soft:!!Bn(t.lang)?.manifest.panelGap,buildDefault:Ga,header:e.jsx(dr,{}),footer:e.jsx(Za,{})})}),ka()&&e.jsx(Hn,{}),e.jsx(va,{}),e.jsx(xa,{}),e.jsx(Xn,{}),e.jsx(hi,{}),e.jsx(Ye,{children:a.settingsOpen&&e.jsx(tt,{title:a.tr("settings.title"),onClose:()=>a.closeSettings(),children:e.jsx(Un,{open:!0,initialTab:a.settingsTab??void 0,initialSkillKey:a.settingsSkillKey??void 0,cfg:a.cfg,activeSession:s,themeLang:t.lang,themeSkin:t.skin,themeMode:t.mode,themeModePref:t.modePref,flatOn:t.flat,glassOn:t.glass,themeSeed:t.seed,onClose:()=>a.closeSettings(),onConfigChange:a.patchConfig,onThemeChange:(o,m,f)=>t.setTheme(o,m,t.bg,f),onFlatChange:t.setFlat,onGlassChange:o=>t.setGlass(o),onSeedChange:o=>t.setSeedValue(o),onReloadThemes:()=>t.reloadThemes(),onReconnect:o=>{a.connect({...a.cfg,...o||{}})},onRelaunchOnboarding:()=>{a.closeSettings();try{localStorage.removeItem(qn)}catch{}a.setOnboarding(!0)}})},"settings")}),e.jsx(Ye,{children:a.onboarding&&e.jsx(fi.div,{style:{position:"fixed",inset:0,zIndex:60,background:"var(--bg)"},initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,scale:1.06},transition:{duration:.45,ease:[.2,.8,.2,1]},children:e.jsx(wa,{themeLang:t.lang,themeSkin:t.skin,themeMode:t.mode,themeModePref:t.modePref,themeSeed:t.seed,onThemeChange:(o,m,f)=>t.setTheme(o,m,t.bg,f),onSeedChange:o=>t.setSeedValue(o),onReconnect:()=>{window.tangu?.getConfig().then(o=>{const m={backendUrl:o.backendUrl,token:o.token,modelId:o.modelId};T.setState({cfg:m,desktopMode:"managed"}),T.getState().connect(m)})},onFinish:()=>{a.setOnboarding(!1),window.tangu?.getConfig().then(o=>{const m={backendUrl:o.backendUrl,token:o.token,modelId:o.modelId};T.setState({cfg:m,homeDir:o.homeDir,defaultWsDir:o.defaultWorkspaceDir||""}),T.getState().connect(m)})}})},"onboarding")}),e.jsx(Ye,{children:a.marketOpen&&e.jsx(tt,{title:a.tr("market.title"),onClose:()=>a.closeMarket(),children:e.jsx(is,{onClose:()=>a.closeMarket()})},"market")}),e.jsx(Ye,{children:a.achievementsOpen&&e.jsx(tt,{title:a.tr("achievements.title"),onClose:()=>T.getState().closeAchievements(),children:e.jsx(Kn,{onClose:()=>T.getState().closeAchievements()})},"achievements")}),e.jsx(Ye,{children:a.feedbackOpen&&e.jsx(tt,{compact:!0,title:a.tr("feedback.title"),onClose:()=>a.closeFeedback(),children:e.jsx(ls,{surface:"panel",cfg:a.cfg,activeSession:s,onClose:()=>a.closeFeedback()})},"feedback")}),e.jsx(Xa,{}),e.jsx(Ye,{children:d?.view&&e.jsx(tt,{title:d.title,onClose:mn,children:e.jsx(cs,{target:d.view,onUnavailable:mn})},d.id)}),!h&&e.jsx(rs,{}),!h&&e.jsx(Ja,{onOpen:()=>T.getState().openAchievements()}),!a.onboarding&&e.jsx(Qa,{})]})}xt({"chatpreview.msg.ask":{zh:"帮我把 LCL 的 hash 路由分支理一下,再决定要不要抽成表。",en:"Walk me through the hash route branches in LCL, then decide whether to pull them into a table."},"chatpreview.msg.reasoning":{zh:"先看 main.tsx 的 hash 分支顺序,确认 #/aion 与 #/tangu 不会被前面的 frame 分支吞掉,再决定是否抽一个 routes 表。整体规模还小,优先可读性。",en:"Start with the order of the hash branches in main.tsx, confirm that #/aion and #/tangu are not swallowed by the earlier frame branch, then decide whether to extract a routes table. The whole thing is still small, so readability wins."},"chatpreview.todo.read":{zh:"读 main.tsx 路由分支",en:"Read the route branches in main.tsx"},"chatpreview.todo.addRoute":{zh:"加 #/tangu 分支",en:"Add the #/tangu branch"},"chatpreview.todo.navLink":{zh:"补 Navigator 链接",en:"Add the Navigator link"},"chatpreview.todo.build":{zh:"跑 tsc / build",en:"Run tsc / build"},"chatpreview.plan":{zh:`1. 检查 hash 分支顺序
17
- 2. 补路由与导航
18
- 3. 运行 typecheck / build`,en:`1. Check the order of the hash branches
19
- 2. Add the route and the navigation link
20
- 3. Run typecheck / build`},"chatpreview.msg.answer":{zh:"看完了。当前是 5 条 `if (route.view === …)` 顺序分支,`frame` 在前、`aion/tangu` 在后,互不吞。\n\n```ts\nif (route.view === 'frame') return <Frame/>\nif (route.view === 'tangu') return <Tangu/>\n```\n\n规模还小,**暂不必抽表**——超过 ~8 条再说。",en:"Had a look. Right now there are 5 sequential `if (route.view === …)` branches — `frame` first, then `aion/tangu` — and none of them swallows another.\n\n```ts\nif (route.view === 'frame') return <Frame/>\nif (route.view === 'tangu') return <Tangu/>\n```\n\nAt this size a table is **not worth extracting yet** — revisit past ~8 branches."},"chatpreview.msg.buildFirst":{zh:"我先跑一遍构建确认。",en:"Let me run a build first to confirm."},"chatpreview.plan.question":{zh:"计划已就绪。是否批准?",en:"The plan is ready. Approve it?"},"chatpreview.inquiry.question":{zh:"路由是抽成表驱动,还是保持 if 分支?",en:"Should routing become table-driven, or stay as if branches?"},"chatpreview.inquiry.optTable":{zh:"抽成 routes 表",en:"Extract a routes table"},"chatpreview.inquiry.optIf":{zh:"保持 if 分支",en:"Keep the if branches"},"chatpreview.session.routing":{zh:"重构 LCL 路由层",en:"Refactor the LCL routing layer"},"chatpreview.session.weekly":{zh:"周报整理",en:"Compile the weekly report"},"chatpreview.session.scraper":{zh:"爬虫脚本调试",en:"Debug the scraper script"},"chatpreview.session.design":{zh:"设计系统对照",en:"Design system comparison"}});function Sr(t){const a=Date.now()-6e4;return[{id:"u1",role:"user",content:t("chatpreview.msg.ask"),attachments:[{name:"routes.md",mimeType:"text/markdown",data:"",size:128}],status:"done",timestamp:a+1},{id:"a1",role:"assistant",agentName:"Tangu",status:"done",timestamp:a+2,systemPrompt:"You are Tangu, a coding agent. Keep changes scoped and verify them.",reasoning:t("chatpreview.msg.reasoning"),toolEvents:[{id:"t1",name:"read_file",arguments:"src/main.tsx",done:!0,elapsedMs:400},{id:"t2",name:"run_shell",arguments:"npx tsc --noEmit",done:!0,isError:!0,elapsedMs:1200}],todos:[{status:"completed",content:t("chatpreview.todo.read")},{status:"in_progress",content:t("chatpreview.todo.addRoute")},{status:"pending",content:t("chatpreview.todo.navLink")},{status:"pending",content:t("chatpreview.todo.build")}],planProposal:t("chatpreview.plan"),inquiries:[{inquiryId:"iqp",runId:"r1",question:t("chatpreview.plan.question"),options:[],status:"pending",kind:"plan"}],content:t("chatpreview.msg.answer")},{id:"a2",role:"assistant",agentName:"Tangu",status:"done",timestamp:a+3,content:t("chatpreview.msg.buildFirst"),approvals:[{approvalId:"ap1",runId:"r1",name:"run_bash",arguments:JSON.stringify({command:"npm run build && npx tsc --noEmit"}),preview:"$ npm run build && npx tsc --noEmit",status:"pending",reason:{kind:"mode",mode:"auto-edit"}},{approvalId:"ap2",runId:"r1",name:"write_file",arguments:JSON.stringify({path:"/etc/hosts",content:`127.0.0.1 tangu.local
21
- `}),preview:"⚠ Write outside the workspace · write /etc/hosts (22 chars)",status:"pending",reason:{kind:"escalate",mode:"auto-edit"}}]},{id:"a3",role:"assistant",agentName:"Tangu",status:"done",timestamp:a+4,content:"",inquiries:[{inquiryId:"iq1",runId:"r1",question:t("chatpreview.inquiry.question"),options:[t("chatpreview.inquiry.optTable"),t("chatpreview.inquiry.optIf")],status:"pending"}]}]}const yn=new Date().toISOString(),Nr=["chatpreview.session.routing","chatpreview.session.weekly","chatpreview.session.scraper","chatpreview.session.design"];function Cr(t){return Nr.map((a,s)=>({id:`s${s+1}`,title:t(a),model_id:null,archived:!1,emoji:null,agent_config:null,project_path:"/tangu",project_name:t("app.defaultWorkspace"),created_at:yn,updated_at:yn}))}function Er(t){return[{key:"__cloud__",name:t("app.cloudWorkspace"),kind:"cloud",path:null,system:!0},{key:"/tangu",name:t("app.defaultWorkspace"),kind:"local",path:"/tangu",system:!0}]}const jn={backendUrl:"http://localhost:8787",token:"",modelId:""};function Ir(){const{t}=Te(),[a,s]=l.useState(!1),[d,r]=l.useState(""),g=l.useRef(null),p=l.useMemo(()=>Sr(t),[t]),h=l.useMemo(()=>Cr(t),[t]),o=l.useMemo(()=>Er(t),[t]);return e.jsxs("div",{className:"t2-preview-shell",children:[e.jsx("div",{className:"t2-preview-side",children:e.jsx(Li,{collapsed:!1,sessions:h,archivedSessions:[],activeId:"s1",runningIds:new Set(["s2"]),unreadIds:new Set(["s3"]),cfg:jn,modelId:"",activeSession:h[0],workspaces:o,onSelect:()=>{},onNewInWorkspace:()=>{},onAddWorkspace:()=>{},onRenameWorkspace:()=>{},onRemoveWorkspace:()=>{},onRename:()=>{},onArchive:()=>{},onDelete:()=>{},onOpenSettings:()=>{},showSpecial:!0,onNewChat:()=>s(!0),onOpenWorkspace:()=>{}})}),e.jsxs("div",{className:"t2-preview-main t2-chat-view",children:[e.jsxs("div",{className:"t2-toolbar",children:[e.jsx("div",{className:"t2-toolbar-title",children:h[0].title}),e.jsx("span",{className:"t2-toolbar-grow"}),e.jsx("button",{className:"t2-pill",onClick:()=>s(!1),style:{fontWeight:a?400:600},children:t("workbench.chat")}),e.jsx("button",{className:"t2-pill",onClick:()=>s(!0),style:{fontWeight:a?600:400},children:t("chat.emptyHint")}),d&&e.jsx("span",{className:"t2-toolbar-pill","data-preview-action":!0,children:d})]}),a?e.jsx(Si,{}):e.jsx("div",{className:"t2-stream",ref:g,children:e.jsx("div",{className:"t2-stream-inner",children:p.map(m=>e.jsx(Ni,{msg:m},m.id))})}),e.jsx(Ri,{approvalTray:a?void 0:e.jsx(Ci,{items:Ei(p),onDecide:(m,f,C,v)=>(r(`approval:${C}:${String(v?.command||"")}`),!1),onAnswer:(m,f,C)=>(r(`inquiry:${C}`),!1)}),disabled:!1,running:!1,execConfig:{execMode:"host",approvalMode:"auto-edit"},models:null,modelId:"",onModelChange:()=>{},planMode:!1,onPlanModeChange:()=>{},onExecConfigChange:()=>{},onSend:async()=>!0,onStop:()=>{},contextWindow:2e5,ctxTokens:84e3,sessionTokens:12e3,onCompact:()=>{}})]}),e.jsxs("div",{className:"t2-preview-right",children:[e.jsx("div",{className:"t2-preview-right-title",children:t("panel.tab.toc")}),e.jsx(Ai,{view:"toc",cfg:jn,sessionId:"s1",sessionConfig:{},running:!1,messages:a?[]:p,chatScrollRef:g,onToast:()=>{},onOpenPreview:()=>{},subChats:[]})]})]})}function Mr(){be.getState().openView("home",{},"main")}function Tr(){const{t}=Te(),a=We();l.useEffect(()=>{T.getState().setTr((d,r)=>t(d,r))},[t]),l.useEffect(()=>{T.getState().boot()},[]),l.useEffect(()=>Nt(),[]),l.useEffect(()=>window.tangu?.onMainAction?.(d=>{d==="agents-changed"&&(T.getState().refreshAgents(),window.dispatchEvent(new Event("forsion:agents-changed"))),d==="skills-changed"&&(Gt(Zt()).then(r=>T.setState({skillsList:r})).catch(()=>{}),window.dispatchEvent(new Event("forsion:skills-changed")))}),[]),l.useEffect(()=>{window.tangu?.detachedReady?.(ya()).then(d=>{if(!d?.length)return;const r=be.getState();for(const g of d)r.openView(g.type,g.params??{},"main")})},[]);const s=(()=>{try{return window.tangu?.platform==="darwin"}catch{return!1}})();return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"shell-host",children:e.jsx(Qn,{noRibbon:!0,dark:a.mode==="dark",soft:!!Bn(a.lang)?.manifest.panelGap,buildDefault:Mr,header:s?e.jsx("div",{style:{height:38,flex:"0 0 auto",WebkitAppRegion:"drag"}}):void 0})}),window.amadeus&&e.jsx(Hn,{}),e.jsx(Xn,{})]})}let Me=null;Xt()==="mini"&&(ja(async t=>{t.type==="amadeus-editor"&&await Na();const a={...t.params};delete a.miniSurface,t.type==="chat"&&(a.sessionId||=T.getState().activeId||void 0,a.followActive=!a.sessionId),window.tangu?.showMainPanel?.({...t,params:a})}),Sa(t=>{if(Me?.view)return t.type===Me.view.type?t:t.type===(Me.mainView?.type||Me.view.type)?{type:Me.view.type,params:{...Me.view.params,...t.params}}:(bt({...t}),null);const a=Yt();if(!a||!St(a))return null;const s=a.mini;return t.type===s.view.type?t:t.type===s.mainView.type?{type:s.view.type,params:{...s.view.params,...t.params}}:(bt({...t}),null)}));function zr(){const t=Yt();t&&St(t)&&be.getState().openView(t.mini.view.type,t.mini.view.params??{},"main")}function Lr(){const{t}=Te(),[a,s]=l.useState(null);return l.useEffect(()=>{T.getState().setTr((d,r)=>t(d,r))},[t]),l.useEffect(()=>{let d=!1,r=!1;const g=new URLSearchParams(location.search);let p=g.get("sessionId")?{sessionId:g.get("sessionId")}:null;const h=()=>{if(!d||!p)return;if(p.view){const x=p.view;if(!at(x.type)){r&&window.tangu?.closeSelf?.();return}r=!0;const A=p;p=null,Me=A,s(A),be.getState().openView(x.type,{...x.params,...A.params},"main");return}const C=p.spaceId||(p.sessionId?"tangu":void 0),v=gt.getState().spaces.find(x=>x.id===C);if(!v||!St(v))return;const j=p;p=null,Me=null,s(null),yt(v.id);const z={...v.mini.view.params,...j.params,...j.sessionId?{sessionId:j.sessionId,followActive:!1}:{}};be.getState().openView(v.mini.view.type,z,"main"),j.sessionId&&T.getState().setActiveId(j.sessionId)},o=window.tangu?.onMiniTarget?.(C=>{p=C,h()});window.tangu?.miniReady?.();const m=gt.subscribe(h),f=jt(h);return T.getState().boot().finally(()=>{d=!0,h()}),()=>{o?.(),m(),f(),d=!1,Me=null}},[]),l.useEffect(()=>{window.amadeus&&Vn()},[]),l.useEffect(()=>Nt(),[]),e.jsx(cr,{buildDefault:zr,direct:a?.view?{title:a.title,view:a.view,mainView:a.mainView??a.view}:null})}const Rr={settings:"settings.title",market:"market.title",achievements:"achievements.title",feedback:"feedback.title",btw:"btw.title"};function Ar(t,a){return t.builtin?a(Rr[t.builtin]):t.title}function Or(){const{t}=Te(),a=We(),[s,d]=l.useState(null),r=T($n(j=>({cfg:j.cfg,cfgLoaded:j.cfgLoaded,closeSettings:j.closeSettings,closeMarket:j.closeMarket,closeAchievements:j.closeAchievements,closeFeedback:j.closeFeedback,patchConfig:j.patchConfig,connect:j.connect}))),g=s?.params?.session?.id?s.params.session:null,p=()=>window.tangu?.closeSelf?.(),h=s?.builtin==="btw"?Ii(s.params):null,o=s?Ar(s,t):"";if(l.useEffect(()=>{s?.builtin&&o&&(document.title=o)},[s?.builtin,o]),l.useEffect(()=>{T.getState().setTr((j,z)=>t(j,z))},[t]),l.useEffect(()=>{T.getState().boot()},[]),l.useEffect(()=>{window.amadeus&&Vn()},[]),l.useEffect(()=>Nt(),[]),l.useEffect(()=>window.tangu?.onMainAction?.(j=>{j==="agents-changed"&&(T.getState().refreshAgents(),window.dispatchEvent(new Event("forsion:agents-changed"))),j==="skills-changed"&&(Gt(Zt()).then(z=>T.setState({skillsList:z})).catch(()=>{}),window.dispatchEvent(new Event("forsion:skills-changed")))}),[]),l.useEffect(()=>{const j=Ca(),z=window.tangu?.onFloatingTarget?.(d);return window.tangu?.floatingReady?.(j).then(x=>{x&&d(x)}),()=>z?.()},[]),l.useEffect(()=>{s?.builtin==="feedback"&&typeof s.params?.description=="string"&&T.setState({feedbackDraft:s.params.description})},[s]),!s)return e.jsx("div",{className:"floating-native-root"});const m=()=>{r.closeSettings(),p()},f=()=>{r.closeMarket(),p()},C=()=>{r.closeAchievements(),p()},v=()=>{r.closeFeedback(),p()};return e.jsxs("div",{className:"floating-native-root",children:[window.tangu?.platform==="darwin"&&e.jsx("header",{className:"floating-native-chrome",children:e.jsx("span",{title:o,children:o})}),e.jsxs("main",{className:"floating-native-content",children:[s.builtin==="settings"&&e.jsx(Un,{open:!0,initialTab:typeof s.params?.tab=="string"?s.params.tab:void 0,initialSkillKey:typeof s.params?.skillKey=="string"?s.params.skillKey:void 0,cfg:r.cfg,activeSession:g,themeLang:a.lang,themeSkin:a.skin,themeMode:a.mode,themeModePref:a.modePref,flatOn:a.flat,glassOn:a.glass,themeSeed:a.seed,onClose:m,onConfigChange:r.patchConfig,onThemeChange:(j,z,x)=>a.setTheme(j,z,a.bg,x),onFlatChange:a.setFlat,onGlassChange:a.setGlass,onSeedChange:a.setSeedValue,onReloadThemes:a.reloadThemes,onReconnect:j=>{r.connect({...r.cfg,...j||{}})},onRelaunchOnboarding:()=>{try{localStorage.removeItem(qn)}catch{}window.tangu?.requestMainAction?.("onboarding"),p()}},JSON.stringify(s.params??{})),s.builtin==="market"&&e.jsx(is,{initialQuery:typeof s.params?.q=="string"?s.params.q:void 0,onClose:f},String(s.params?.q??"")),s.builtin==="achievements"&&e.jsx(Kn,{onClose:C}),s.builtin==="feedback"&&r.cfgLoaded&&e.jsx(ls,{surface:"panel",cfg:r.cfg,activeSession:g,onClose:v},g?.id||""),s.builtin==="btw"&&r.cfgLoaded&&h&&e.jsx(ei,{seed:h,onClose:p}),s.view&&e.jsx(cs,{target:s.view,onUnavailable:p})]}),(s.builtin==="settings"||s.builtin==="market")&&e.jsx(rs,{})]})}let qe=null;function Sn(t){if(!t){qe&&(qe.style.display="none");return}qe||(qe=document.createElement("div"),Object.assign(qe.style,{position:"fixed",inset:"0",pointerEvents:"none",zIndex:"99998",boxSizing:"border-box",border:"3px solid var(--accent, #4d8794)",background:"color-mix(in srgb, var(--accent, #4d8794) 8%, transparent)"}),document.body.appendChild(qe)),qe.style.display="block"}function Pr(){const t=window.tangu;if(t?.openDetached){if(Xt()==="main"){let a="";const s=()=>{const p=T.getState(),h=p.activeId,o={sessionId:h,runId:h?p.runningBySession[h]??null:null},m=JSON.stringify(o);m!==a&&(a=m,t.reportMiniSession?.(o))};T.subscribe(s),s();let d=null;const r=()=>{if(!be.getState().api||!d||!at(d.type))return;const h=d;d=null,h.spaceId&&yt(h.spaceId);const o=be.getState().openView(h.type,h.params??{},"main");o&&h.params&&o.setParams({...o.params,...h.params})};t.onMainPanelTarget?.(p=>{d=p,r()}),jt(r);let g=!1;be.subscribe(p=>{p.api&&(g||(g=!0,t.mainPanelReady?.()),r())})}ti({detach:(a,s)=>{t.openDetached?.(a,s)},dragUpdate:(a,s,d)=>t.dragUpdate?.(a,s,d),drop:async(a,s,d)=>(await t.dropView?.(a,s,d))?.routed??!1}),t.onAcceptView?.(a=>{Sn(null),be.getState().openView(a.type,a.params??{},"main")}),t.onDragPreview?.(a=>Sn(a))}}function Dr(){const t=window.tangu;if(!t?.reportRunningSessions)return;const a=s=>t.reportRunningSessions(Object.keys(s).length);a(T.getState().runningBySession),T.subscribe((s,d)=>{s.runningBySession!==d.runningBySession&&a(s.runningBySession)})}const Nn=t=>Oi(t).toLowerCase(),ds=(t,a)=>t.configBySession[a]?.cwd||t.sessions.find(s=>s.id===a)?.project_path||"",us=(t,a)=>Object.keys(t.runningBySession).some(s=>Nn(ds(t,s))===Nn(a));function Fr(){const t=window.tangu;if(!(!t?.codeStudioGitCommit||!t.codeStudioGitStatus||!t.productsIsCreation))return T.subscribe((a,s)=>{if(a.runningBySession!==s.runningBySession)for(const d of Object.keys(s.runningBySession)){if(a.runningBySession[d])continue;const r=ds(a,d);!r||us(a,r)||_r(r,d)}})}async function _r(t,a){try{if(!await window.tangu.productsIsCreation(t))return;const s=await window.tangu.codeStudioGitStatus(t);if(!(s?.auto??s?.writable)||us(T.getState(),t))return;const d=ni(T.getState().messagesBySession[a]||[]);await window.tangu.codeStudioGitCommit(t,{name:d,auto:!0,untitled:wt("studio.history.untitled")})}catch(s){console.warn("[creations] 自动存版本失败",s)}}function $r(){if(!window.tangu?.onAuthWillChange)return()=>{};let t=!1,a=null,s=!1,d=0,r=Promise.resolve(),g=!1;const p=()=>{a&&(a.inert=s),a=null},h=window.tangu.onAuthWillChange(async()=>{const m=++d;a||(a=document.body,s=a?.inert??!1,a&&(a.inert=!0));try{if(await r,m!==d||g||!window.amadeus)return;const[{flushAllScopes:f,resetAllScopeDocs:C,usePageStore:v},{useDbStore:j},{useDrawStore:z},x]=await Promise.all([Qe(()=>import("./appStore-Dg9WALEA.js").then(A=>A.qN),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url),Qe(()=>import("./appStore-Dg9WALEA.js").then(A=>A.qO),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url),Qe(()=>import("./appStore-Dg9WALEA.js").then(A=>A.qQ),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url),Qe(()=>import("./index-CF4RV4mh.js").then(A=>A.cx),[],import.meta.url)]);if(await Promise.all([f(!0),j.getState().flushAll(!0),z.getState().flushAll(!0)]),m!==d)return;t=v.getState().vaultSide==="cloud",t&&(x.retireAllUnifiedScopes(),C(),v.setState({vaultRoot:null,pages:[],folders:[],files:[],icons:{}}))}catch(f){throw m===d&&p(),f}}),o=window.tangu.onAuthChanged?.(()=>{const m=++d;if(!t){r.finally(()=>{m===d&&p()});return}t=!1,r=r.then(async()=>{const{usePageStore:f}=await Qe(async()=>{const{usePageStore:C}=await import("./appStore-Dg9WALEA.js").then(v=>v.qN);return{usePageStore:C}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url);g||(await f.getState().restoreVault(),await f.getState().initVaultSide())}).catch(f=>console.error("[auth] Cannot restore vault after account change:",f)).finally(()=>{m===d&&p()})});return()=>{g=!0,++d,h(),o?.(),p()}}$r();window.addEventListener("error",t=>{console.error("[tangu] window error:",t.error||t.message)});window.addEventListener("unhandledrejection",t=>{console.error("[tangu] unhandledrejection:",t.reason)});const Br=(()=>{try{return location.hash==="#preview"}catch{return!1}})(),ft=Xt();try{document.documentElement.dataset.window=ft}catch{}try{document.documentElement.lang=xs()==="zh"?"zh-CN":"en"}catch{}try{window.tangu?.platform==="darwin"&&(document.documentElement.dataset.platform="mac")}catch{}let ms,ps=null;try{ms=localStorage.getItem("forsion_theme_seed")||void 0}catch{}try{ps=localStorage.getItem("forsion_theme_lang")}catch{}try{Ea(Ia(),Ma(),Ta(),za(),{customColor:ms}),La(),document.documentElement.style.removeProperty("background"),We.getState().initThemes(ps),T.getState().setTr(wt),si(),Pr(),Dr(),Fr(),Ra(),ai(),Aa()}catch(t){console.error("[tangu] init failed, continue to mount:",t),Oa("init",t)}ys.createRoot(document.getElementById("root")).render(e.jsx(ws,{children:e.jsx(Mi,{children:Br?e.jsx(Ir,{}):ft==="mini"?e.jsx(Lr,{}):ft==="floating"?e.jsx(Or,{}):ft==="detached"?e.jsx(Tr,{}):e.jsx(jr,{})})}));
@@ -1,3 +0,0 @@
1
- import{P as z,Q as A,U as O,W as H,j as y,J as W,u as F,d as w,r as V}from"./index-CF4RV4mh.js";import{lE as B,lF as I,lG as _,fv as T}from"./appStore-Dg9WALEA.js";import{P as G}from"./MarkdownBlock-DIjYEhTK.js";import"./nativeDownload-D-f1_L2S.js";import"./ipc-DQOD2UKk.js";import"./client-BSKpsyAw.js";import"./index-BCubCwdT.js";import"./linkFollow-C0_3k_PC.js";import"./mdMarks-Bq7Hl-4C.js";import"./emoji-DGaxpCIu.js";import"./listFold-BsOVn9UZ.js";const N=z().use(A).use(O,{singleTilde:!1}).use(H,["yaml"]).use(B).use(I,{singleTilde:!1}),c=t=>String(t??"").replace(/[&<>"']/g,m=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[m]);function L(t,m=!1){if(!t||/[\u0000-\u0020\u007f\\]/.test(t)||t.startsWith("//"))return null;if(t.startsWith("/")||t.startsWith("#"))return t;try{const o=new URL(t);if(o.protocol==="https:"||o.protocol==="http:"||!m&&o.protocol==="mailto:")return o.href}catch{}return!t.includes(":")&&!t.startsWith(".")?t:null}function j(t){return t.value??(t.children??[]).map(j).join("")}function M(t){return t.type!=="paragraph"?null:/^!\[\[([^\]\n]+)\]\]$/.exec(j(t).trim())?.[1]?.replace(/\|\d+$/,"")??null}function J(t){return t.type==="paragraph"&&t.children?.length===1&&t.children[0].type==="image"?t.children[0]:null}function Q(t,m={}){const o=N.parse(t),d=m.locale==="zh",u=(e,n=!1)=>{const r=L(e,n);if(!r||!m.baseUrl||r.startsWith("#"))return r;try{return L(new URL(r,m.baseUrl).href,n)}catch{return r}};let h=!0;const g=()=>{const e=!!m.priorityFirstImage&&h;return h=!1,e?'loading="eager" fetchpriority="high"':'loading="lazy"'},i=new Map((o.children??[]).filter(e=>e.type==="definition").map(e=>[e.identifier,e]));let v=0;const p=e=>(e.children??[]).map(s).join(""),$=(e,n)=>{const r=_(e),a=u(r?.provider==="Bilibili"&&/^BV[\w]{10}$/i.test(e.trim())?"https://www.bilibili.com/video/"+e.trim():e,!0);if(!a)return null;let f=a;try{f=new URL(a,"https://forsion.example").pathname}catch{}const b=/\.(mp4|webm|mov|m4v|ogv)$/i.test(f),C=/\.(mp3|m4a|ogg|wav|flac)$/i.test(f);if(!r&&!b&&!C)return null;const S=n?.alt||r?.provider||(d?C?"音频":"视频演示":C?"Audio":"Video demo"),q=n?.url?u(n.url,!0):null,x=/^(\d{1,4})[:/](\d{1,4})$/.exec(n?.title||""),R=x&&+x[1]>0&&+x[2]>0?` style="aspect-ratio:${+x[1]}/${+x[2]}"`:"",U=q?`<img src="${c(q)}" alt="${c(S)}" ${g()} decoding="async">`:`<div class="md-media-placeholder"><span>${c(S)}</span></div>`;return`<figure class="md-media" data-amadeus-media="${r?"platform":C?"audio":"video"}" data-src="${c(r?.src||a)}"><div class="md-media-stage${q?" has-poster":""}"${R}>${U}</div><figcaption><span>${c(S)}</span><button type="button" class="play-button">${d?"播放":"Play"}${r?` · ${r.provider}`:""}</button><a href="${c(a)}" target="_blank" rel="noopener noreferrer">${d?"打开原视频":"Open original"} ↗</a></figcaption><p class="md-media-error" role="status" hidden>${d?"暂时无法播放,请打开原视频。":"Playback is unavailable. Open the original video."}</p></figure>`};function s(e){const n=()=>p(e);switch(e.type){case"text":return c(e.value);case"strong":return`<strong>${n()}</strong>`;case"emphasis":return`<em>${n()}</em>`;case"delete":return`<del>${n()}</del>`;case"inlineCode":return`<code>${c(e.value)}</code>`;case"break":return"<br>";case"heading":{const r=Math.min(6,(e.depth??2)+(m.headingOffset??0));return`<h${r} id="${c(m.idPrefix||"md")}-${++v}">${n()}</h${r}>`}case"paragraph":{const r=M(e);if(r){const a=u(r,!0);if(a&&/\.(?:png|jpe?g|gif|webp|avif|svg)(?:[?#]|$)/i.test(a))return`<figure class="md-image"><img src="${c(a)}" alt="${c(r)}" ${g()} decoding="async"></figure>`;const f=$(r);if(f)return f;const b=u(r);return b?`<p class="md-bookmark"><a href="${c(b)}" target="_blank" rel="noopener noreferrer">${c(r)} ↗</a></p>`:`<p>${c(j(e))}</p>`}return`<p>${n()}</p>`}case"link":case"linkReference":{const r=e.url??i.get(e.identifier)?.url??"",a=u(r);return a?`<a href="${c(a)}"${/^https?:/.test(a)?' target="_blank" rel="noopener noreferrer"':""}>${n()}</a>`:n()}case"image":case"imageReference":{const r=i.get(e.identifier),a=u(e.url??r?.url??"",!0);return a?`<img src="${c(a)}" alt="${c(e.alt||"")}" ${g()} decoding="async">`:c(e.alt||"")}case"list":return`<${e.ordered?"ol":"ul"}${e.ordered&&e.start?` start="${e.start}"`:""}>${n()}</${e.ordered?"ol":"ul"}>`;case"listItem":return`<li>${e.checked!=null?`<input type="checkbox" disabled aria-label="${d?"清单项":"Checklist item"}"${e.checked?" checked":""}>`:""}${n()}</li>`;case"blockquote":{const r=e.children?.[0],a=r?.type==="paragraph"?/^\[!([\w-]+)\]([+-])?\s*(.*)/.exec(j(r)):null;if(!a)return`<blockquote>${n()}</blockquote>`;const f=(e.children??[]).slice(1).map(s).join(""),b=c(a[3]||a[1]);return a[2]?`<details class="md-callout md-fold"${a[2]==="+"?" open":""}><summary>${b}</summary><div>${f}</div></details>`:`<aside class="md-callout"><p class="md-callout-title">${b}</p>${f}</aside>`}case"table":return`<div class="md-table-wrap"><table>${(e.children??[]).map((r,a)=>`<${a?"tbody":"thead"}><tr>${(r.children??[]).map(f=>`<${a?"td":"th"}>${p(f)}</${a?"td":"th"}>`).join("")}</tr></${a?"tbody":"thead"}>`).join("")}</table></div>`;case"code":return`<pre><code${e.lang?` class="language-${c(e.lang.replace(/[^\w-]/g,""))}"`:""}>${c(e.value)}</code></pre>`;case"thematicBreak":return"<hr>";case"html":case"yaml":case"definition":return"";default:return e.children?n():c(e.value)}}const l=(o.children??[]).filter(e=>!["yaml","html","definition"].includes(e.type));let P="";l[0]?.type==="heading"&&l[0].depth===1&&(P=j(l.shift()));let k="",E=!1;for(let e=0;e<l.length;e++){const n=l[e];n.type==="heading"&&n.depth===2&&(E&&(k+="</section>"),k+='<section class="md-feature">',E=!0);const r=J(n),a=l[e+1]&&M(l[e+1]),f=r&&a?$(a,r):null;if(f){k+=f,e++;continue}k+=s(n)}return E&&(k+="</section>"),{title:P,html:k}}function D(t,m="en"){const o=m==="zh",d=Array.from(t.querySelectorAll("[data-amadeus-media]")),u=new AbortController,h=i=>{d.forEach(v=>{v!==i&&v.querySelector("video,audio")?.pause()})};for(const i of d){const v=i.querySelector("button"),p=i.querySelector(".md-media-stage");v.addEventListener("click",()=>{const $=i.querySelector(".md-media-error");if($.hidden=!0,i.dataset.amadeusMedia==="platform"){if(p.querySelector("iframe")){p.querySelector("iframe").remove(),p.classList.remove("playing"),v.textContent=o?"播放":"Play";return}h(i);const l=document.createElement("iframe");l.src=i.dataset.src,l.title=i.querySelector("figcaption span")?.textContent||"Video",l.allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; fullscreen",l.allowFullscreen=!0,l.referrerPolicy="strict-origin-when-cross-origin",p.appendChild(l),p.classList.add("playing"),v.textContent=o?"关闭播放器":"Close player";return}let s=p.querySelector("video,audio");if(s||(s=document.createElement(i.dataset.amadeusMedia==="audio"?"audio":"video"),s.setAttribute("controls",""),s.setAttribute("playsinline",""),s.preload="none",s.src=i.dataset.src,p.appendChild(s),s.addEventListener("playing",()=>{p.classList.add("playing"),v.textContent=o?"暂停":"Pause"},{signal:u.signal}),s.addEventListener("pause",()=>{v.textContent=s.ended?o?"重播":"Replay":o?"继续播放":"Resume"},{signal:u.signal}),s.addEventListener("loadedmetadata",()=>{s instanceof HTMLVideoElement&&s.videoHeight&&(p.style.aspectRatio=`${s.videoWidth}/${s.videoHeight}`)},{signal:u.signal})),!s.paused){s.pause();return}h(i),s.play().catch(()=>{$.hidden=!1,p.classList.remove("playing")})},{signal:u.signal})}const g=()=>{d.forEach(i=>i.querySelector("video,audio")?.pause())};return document.addEventListener("visibilitychange",()=>{document.hidden&&g()},{signal:u.signal}),()=>{u.abort(),g(),d.forEach(i=>i.querySelector("iframe")?.remove())}}V({"publishing.visual":{zh:"Amadeus 编辑",en:"Amadeus editor"},"publishing.source":{zh:"Markdown 源码",en:"Markdown source"},"publishing.preview":{zh:"预览",en:"Preview"}});function K({options:t,revision:m,alive:o}){const{t:d,locale:u}=F(),[h,g]=w.useState(t.value),[i,v]=w.useState("visual"),p=w.useRef(null);w.useEffect(()=>{g(t.value)},[t.value,m]);const $=l=>{o()&&(t.value=l,g(l),t.onChange?.(l))};w.useEffect(()=>p.current?D(p.current,u):void 0,[i,h,u,t.previewBaseUrl]);const s=i==="preview"?Q(h,{locale:u,baseUrl:t.previewBaseUrl}):null;return y.jsxs("div",{className:"am-app amx-publishing-editor","aria-label":t.label,children:[y.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6,padding:"8px 0"},children:["visual","source","preview"].map(l=>y.jsx("button",{className:"btn",type:"button","aria-pressed":i===l,onClick:()=>v(l),children:d(`publishing.${l}`)},l))}),i==="visual"&&y.jsx(G,{initial:h,onChange:$,readOnly:t.readOnly,immediate:!0}),i==="source"&&y.jsx("textarea",{"aria-label":t.label||d("publishing.source"),value:h,readOnly:t.readOnly,onChange:l=>$(l.target.value),style:{width:"100%",minHeight:420,resize:"vertical",padding:12,font:"inherit",fontFamily:"var(--font-mono)",color:"var(--text)",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"var(--radius-sm)"}}),s&&y.jsx("div",{ref:p,className:"amadeus-published",dangerouslySetInnerHTML:{__html:(s.title?`<h1>${s.title.replace(/[&<>"']/g,l=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[l])}</h1>`:"")+s.html}})]})}function oe(t,m){const o={...m};let d=!0,u=0,h=()=>{};const g=()=>{h=T(t,y.jsx(W,{children:y.jsx(K,{options:o,revision:u++,alive:()=>d})}))};return g(),{getValue(){return o.value},update(i){d&&(Object.assign(o,i),g())},insertMarkdown(i){d&&!o.readOnly&&(o.value+=`
2
-
3
- `+i,o.onChange?.(o.value),g())},focus(){d&&t.querySelector('[contenteditable="true"],textarea')?.focus()},dispose(){d&&(d=!1,h())}}}export{oe as mountPluginMarkdownEditor};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./appStore-Dg9WALEA.js","./index-CF4RV4mh.js","./nativeDownload-D-f1_L2S.js","./ipc-DQOD2UKk.js","./client-BSKpsyAw.js","./appStore-Di8LXuJ9.css"])))=>i.map(i=>d[i]);
2
- import{u as y,d as f,_ as g,t as l,r as w}from"./index-CF4RV4mh.js";import{w as M,a as S}from"./mdMarks-Bq7Hl-4C.js";import{d4 as d,da as m}from"./appStore-Dg9WALEA.js";import{c as _,n as N}from"./nativeDownload-D-f1_L2S.js";w({"mdmark.patchFailed":{zh:"改不动「{name}」—— 笔记里那一行已经变了",en:"Can’t update “{name}” — that line in the note has changed"},"mdmark.openNote":{zh:"打开笔记",en:"Open note"},"mdmark.colName":{zh:"事项",en:"Item"},"mdmark.colDate":{zh:"时间",en:"Time"},"mdmark.colNote":{zh:"来源笔记",en:"Source note"},"mdmark.calName":{zh:"笔记",en:"Notes"}});const u=a=>`${a.path}:${a.line}`,h=new Map;let p=0,k=0;const i=_((a,c)=>({marks:[],ready:!1,overlay:{},async load(){if(!d?.listMarks){a({marks:[],ready:!0});return}const r=++k,n=m.getState().vaultRoot;try{await m.getState().flushSave().catch(()=>{});const t=await d.listMarks();r===k&&m.getState().vaultRoot===n&&a({marks:t,ready:!0})}catch{r===k&&a({marks:[],ready:!0})}},patch(r,n){const t=u(r);a(o=>({overlay:{...o.overlay,[t]:{...o.overlay[t],...n}}}));const e=h.get(t);e&&clearTimeout(e),h.set(t,window.setTimeout(()=>{h.delete(t),x(t,r)},400))}}));async function x(a,c){const r=i.getState(),n=r.overlay[a];if(!n||!d?.patchMark)return;const t=r.marks.find(o=>u(o)===a)??c;let e=t.raw;if(n.checked!==void 0&&(e=M(e,n.checked)??e),n.due!==void 0&&(e=S(e,n.due)??e),e!==t.raw){p++;try{await m.getState().flushSave().catch(()=>{}),await d.patchMark(t.path,t.raw,t.occ,e).catch(()=>!1)||N({event:"system.generic",level:"warning",text:l("mdmark.patchFailed",{name:t.text}),action:{label:l("mdmark.openNote"),run:()=>{g(()=>import("./appStore-Dg9WALEA.js").then(s=>s.qP),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url).then(s=>s.openNoteAtHeading(t.path,t.heading))}}})}finally{p--}}await i.getState().load(),!h.has(a)&&p===0&&i.setState(o=>{const s={...o.overlay};return delete s[a],{overlay:s}})}function P(){const a=i(t=>t.marks),c=i(t=>t.overlay),r=m(t=>t.vaultRoot),n=m(t=>t.activePage);return f.useEffect(()=>{const t=setTimeout(()=>{i.getState().load()},250);return()=>clearTimeout(t)},[r,n]),f.useMemo(()=>Object.keys(c).length?a.map(e=>{const o=c[u(e)];return o?{...e,due:o.due??e.due,checked:o.checked??e.checked}:e}):a,[a,c])}function E(a,c){return d?.patchMark?(i.getState().patch(a,c),!0):!1}d?.onStructureChange?.(()=>{i.getState().load()});const T="mdnote://vault-notes",C=()=>[{id:"name",name:l("mdmark.colName"),type:"text"},{id:"date",name:l("mdmark.colDate"),type:"calendarDate"},{id:"note",name:l("mdmark.colNote"),type:"text"}];function b(){const a=P(),{locale:c}=y();return f.useMemo(()=>{const r=a.filter(e=>!e.isTask);if(!r.length)return[];const n=new Map(r.map(e=>[u(e),e])),t=r.map(e=>({rowId:u(e),name:e.text,cells:{name:e.text,date:e.due,note:e.title}}));return[{path:T,name:l("mdmark.calName"),isNoteView:!1,readonly:!0,columns:C(),rows:t,writeCell:d?.patchMark?(e,o,s)=>{const v=n.get(e);!v||o!=="date"||typeof s!="string"||!s||i.getState().patch(v,{due:s})}:void 0,openRow:e=>{const o=n.get(e);o&&g(()=>import("./appStore-Dg9WALEA.js").then(s=>s.qP),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url).then(s=>s.openNoteAtHeading(o.path,o.heading))}}]},[a,c])}export{P as a,i as b,E as p,b as u};
@@ -1 +0,0 @@
1
- import{z as o}from"./appStore-Dg9WALEA.js";const s=[["path",{d:"M5 12h14",key:"1ays0h"}]],e=o("minus",s);export{e as M};