@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 +1 @@
1
- import{t as i,cu as D,cv as U}from"./index-CF4RV4mh.js";import{I as a,L as I,l as L}from"./ipc-DQOD2UKk.js";async function M(o){let P=null,u="";const S=typeof crypto.randomUUID=="function"?crypto.randomUUID():Array.from(crypto.getRandomValues(new Uint8Array(16)),e=>e.toString(16).padStart(2,"0")).join(""),E=e=>{if(!(e instanceof Uint8Array))return e;let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return{__u8:btoa(t)}},A=e=>{const t=e?.__u8;if(typeof t!="string")return e;const n=atob(t),s=new Uint8Array(n.length);for(let l=0;l<n.length;l++)s[l]=n.charCodeAt(l);return s},r=async(e,t=[])=>{if(o.browserStorage){const d=`unit:${o.browserStorage}:plugin:${String(t[0])}`;if(e===a.pluginDataRead)return o.pluginData?await o.pluginData.read(String(t[0])):sessionStorage.getItem(d);if(e===a.pluginDataWrite){if(o.pluginData)return await o.pluginData.write(String(t[0]),String(t[1]));sessionStorage.setItem(d,String(t[1]));return}if(e===a.restoreVault)return null;if([a.listPages,a.listFiles,a.listFolders].includes(e))return[];if(e===a.pageIcons)return{};throw new Error("This Unit does not publish a vault")}const n=t.some(d=>d instanceof Uint8Array),s=new AbortController,l=setTimeout(()=>s.abort(),n?12e4:3e4);let c;try{c=await fetch(new URL("vault/rpc",o.base),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o.getToken()}`},body:JSON.stringify({ch:e,args:t.map(E),client:S}),signal:s.signal})}catch(d){throw new Error(s.signal.aborted?i("amxbridge.deviceTimeout"):i("amxbridge.deviceUnreachable",{msg:d instanceof Error?d.message:String(d)}))}finally{clearTimeout(l)}if(c.status===401)throw o.onAuthError(),new Error(i("amxbridge.deviceRevoked"));if(c.status===413)throw new Error(i("amxbridge.deviceTooLarge"));const m=await c.json().catch(()=>null);if(c.status===403&&m?.code===I)throw new Error(L());if(!c.ok||!m)throw new Error(i("amxbridge.deviceHttpError",{status:c.status}));if(!m.ok)throw new Error(m.error||i("amxbridge.deviceCallFailed"));return A(m.result)},k=(e,t)=>{const n=new URL("vault/asset",o.base);n.searchParams.set("ref",e);const s=t===void 0?P:t;return s&&n.searchParams.set("page",s),u&&n.searchParams.set("at",u),n.href};let h=null;const v=async()=>{const e=new AbortController,t=setTimeout(()=>e.abort(),1e4);try{const n=await fetch(new URL("vault/asset-token",o.base),{method:"POST",headers:{Authorization:`Bearer ${o.getToken()}`},signal:e.signal}),s=await n.json();if(!n.ok||!s.token)throw new Error(`HTTP ${n.status}`);u=s.token,C(),h=setTimeout(()=>{v()},Math.max(60,s.ttlSec||600)/2*1e3)}catch{h=setTimeout(()=>{v()},3e4)}finally{clearTimeout(t)}},w=new Set,p=new Set,T=new Set,F=new Set;let g=null,f=1e3,x=!1;const b=(e,t)=>{if(typeof t=="string")for(const n of[...e])n(t)};function C(){if(g)return;const e=new EventSource(new URL(`vault/events?at=${encodeURIComponent(u)}`,o.base));g=e,e.onopen=()=>{if(f=1e3,x){for(const t of[...p])t();for(const t of new Set([P,...D()]))t&&b(w,t)}x=!0},e.onmessage=t=>{let n={};try{n=JSON.parse(t.data)}catch{return}const s=n.origin===S;if(n.ch===a.externalChange)s||b(w,n.payload);else if(n.ch===a.structureChange)for(const l of[...p])l();else n.ch===a.dbChange?s||b(T,n.payload):n.ch===a.fileChange&&(s||b(F,n.payload))},e.onerror=()=>{e.close(),g=null;const t=f;f=Math.min(3e4,f*2),setTimeout(()=>{g||C()},t+Math.random()*500)}}window.addEventListener("beforeunload",()=>{g?.close(),h&&clearTimeout(h)}),o.browserStorage||await v(),U(e=>k(e));const y=e=>()=>{throw new Error(i("amxbridge.remoteOnly",{what:e()}))};return{openVault:async()=>null,restoreVault:()=>r(a.restoreVault),listPages:()=>r(a.listPages),listFiles:()=>r(a.listFiles),loadPage:async e=>{const t=await r(a.loadPage,[e]);return P=e,t},readPage:e=>r(a.readPage,[e]),newPage:e=>r(a.newPage,[e]),savePage:(e,t,n)=>r(a.savePage,[e,t,n]),patchMark:(e,t,n,s)=>r(a.patchMark,[e,t,n,s]),renamePage:(e,t,n,s)=>r(a.renamePage,[e,t,n,s]),reconcilePage:(e,t,n)=>r(a.reconcilePage,[e,t,n]),saveAsset:(e,t,n)=>r(a.saveAsset,[e,t,n]),saveVaultBytes:(e,t)=>r(a.saveVaultBytes,[e,t]),readVaultBytes:e=>r(a.readVaultBytes,[e]),saveAttachment:(e,t,n,s)=>r(a.saveAttachment,[e,t,n,s]),openAttachment:async(e,t)=>{window.open(k(t.replace(/^!?\[\[|\]\]$/g,""),e),"_blank","noopener")},openVaultFile:async e=>{const t=new URL("vault/asset",o.base);t.searchParams.set("path",e),u&&t.searchParams.set("at",u),window.open(t.href,"_blank","noopener")},exportPdf:async()=>(window.print(),null),onExternalChange:e=>(w.add(e),()=>{w.delete(e)}),search:e=>r(a.search,[e]),backlinks:e=>r(a.backlinks,[e]),exclusiveAssets:e=>r(a.exclusiveAssets,[e]),reindex:()=>r(a.reindex),listTags:()=>r(a.listTags),pagesByTag:e=>r(a.pagesByTag,[e]),deletePage:e=>r(a.deletePage,[e]),movePage:(e,t)=>r(a.movePage,[e,t]),resolveEmbed:(e,t)=>r(a.resolveEmbed,t?[e,t]:[e]),blockBacklinks:e=>r(a.blockBacklinks,[e]),listFolders:()=>r(a.listFolders),createFolder:(e,t)=>r(a.createFolder,[e,t]),renameFolder:(e,t)=>r(a.renameFolder,[e,t]),deleteFolder:e=>r(a.deleteFolder,[e]),moveFolder:(e,t)=>r(a.moveFolder,[e,t]),trashEntry:e=>r(a.trashEntry,[e]),listTrash:()=>r(a.listTrash),restoreTrash:e=>r(a.restoreTrash,[e]),deleteTrashEntry:e=>r(a.deleteTrashEntry,[e]),emptyTrash:()=>r(a.emptyTrash),pageIcons:()=>r(a.pageIcons),fetchLinkMeta:e=>r(a.fetchLinkMeta,[e]),searchImages:e=>r(a.searchImages,[e]),onStructureChange:e=>(p.add(e),()=>{p.delete(e)}),onDbExternalChange:e=>(T.add(e),()=>{T.delete(e)}),onFileExternalChange:e=>(F.add(e),()=>{F.delete(e)}),readPluginData:e=>r(a.pluginDataRead,[e]),writePluginData:(e,t)=>r(a.pluginDataWrite,[e,t]),listPlugins:async()=>[],openPluginsFolder:y(()=>i("amxbridge.op.openPluginsFolder")),scaffoldSamplePlugin:y(()=>i("amxbridge.op.scaffoldSamplePlugin")),uninstallPlugin:y(()=>i("amxbridge.op.uninstallPlugin")),revealInFileManager:y(()=>i("amxbridge.op.reveal")),hostCaps:{revealInFileManager:!1},readDatabase:(e,t)=>r(a.dbRead,[e,t]),writeDatabase:(e,t)=>r(a.dbWrite,[e,t]),writeDatabaseCas:(e,t,n)=>r(a.dbWriteCas,[e,t,n]),readDrawing:(e,t)=>r(a.drawingRead,[e,t]),writeDrawing:(e,t)=>r(a.drawingWrite,[e,t]),readTextFile:e=>r(a.readTextFile,[e]),writeTextFile:(e,t,n)=>r(a.writeTextFile,n?[e,t,n]:[e,t]),listPageProps:e=>r(a.listPageProps,[e]),setPageFrontmatter:(e,t)=>r(a.setPageFrontmatter,[e,t]),renamePageFile:(e,t)=>r(a.renamePageFile,[e,t]),renameDbFile:(e,t)=>r(a.renameDbFile,[e,t])}}export{M as createUnitAmadeusBridge};
1
+ import{t as i,cu as D,cv as U}from"./index-BM2o7PeV.js";import{I as a,L as I,l as L}from"./ipc-CxAyeo8q.js";async function M(o){let P=null,u="";const S=typeof crypto.randomUUID=="function"?crypto.randomUUID():Array.from(crypto.getRandomValues(new Uint8Array(16)),e=>e.toString(16).padStart(2,"0")).join(""),E=e=>{if(!(e instanceof Uint8Array))return e;let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return{__u8:btoa(t)}},A=e=>{const t=e?.__u8;if(typeof t!="string")return e;const n=atob(t),s=new Uint8Array(n.length);for(let l=0;l<n.length;l++)s[l]=n.charCodeAt(l);return s},r=async(e,t=[])=>{if(o.browserStorage){const d=`unit:${o.browserStorage}:plugin:${String(t[0])}`;if(e===a.pluginDataRead)return o.pluginData?await o.pluginData.read(String(t[0])):sessionStorage.getItem(d);if(e===a.pluginDataWrite){if(o.pluginData)return await o.pluginData.write(String(t[0]),String(t[1]));sessionStorage.setItem(d,String(t[1]));return}if(e===a.restoreVault)return null;if([a.listPages,a.listFiles,a.listFolders].includes(e))return[];if(e===a.pageIcons)return{};throw new Error("This Unit does not publish a vault")}const n=t.some(d=>d instanceof Uint8Array),s=new AbortController,l=setTimeout(()=>s.abort(),n?12e4:3e4);let c;try{c=await fetch(new URL("vault/rpc",o.base),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o.getToken()}`},body:JSON.stringify({ch:e,args:t.map(E),client:S}),signal:s.signal})}catch(d){throw new Error(s.signal.aborted?i("amxbridge.deviceTimeout"):i("amxbridge.deviceUnreachable",{msg:d instanceof Error?d.message:String(d)}))}finally{clearTimeout(l)}if(c.status===401)throw o.onAuthError(),new Error(i("amxbridge.deviceRevoked"));if(c.status===413)throw new Error(i("amxbridge.deviceTooLarge"));const m=await c.json().catch(()=>null);if(c.status===403&&m?.code===I)throw new Error(L());if(!c.ok||!m)throw new Error(i("amxbridge.deviceHttpError",{status:c.status}));if(!m.ok)throw new Error(m.error||i("amxbridge.deviceCallFailed"));return A(m.result)},k=(e,t)=>{const n=new URL("vault/asset",o.base);n.searchParams.set("ref",e);const s=t===void 0?P:t;return s&&n.searchParams.set("page",s),u&&n.searchParams.set("at",u),n.href};let h=null;const v=async()=>{const e=new AbortController,t=setTimeout(()=>e.abort(),1e4);try{const n=await fetch(new URL("vault/asset-token",o.base),{method:"POST",headers:{Authorization:`Bearer ${o.getToken()}`},signal:e.signal}),s=await n.json();if(!n.ok||!s.token)throw new Error(`HTTP ${n.status}`);u=s.token,C(),h=setTimeout(()=>{v()},Math.max(60,s.ttlSec||600)/2*1e3)}catch{h=setTimeout(()=>{v()},3e4)}finally{clearTimeout(t)}},w=new Set,p=new Set,T=new Set,F=new Set;let g=null,f=1e3,x=!1;const b=(e,t)=>{if(typeof t=="string")for(const n of[...e])n(t)};function C(){if(g)return;const e=new EventSource(new URL(`vault/events?at=${encodeURIComponent(u)}`,o.base));g=e,e.onopen=()=>{if(f=1e3,x){for(const t of[...p])t();for(const t of new Set([P,...D()]))t&&b(w,t)}x=!0},e.onmessage=t=>{let n={};try{n=JSON.parse(t.data)}catch{return}const s=n.origin===S;if(n.ch===a.externalChange)s||b(w,n.payload);else if(n.ch===a.structureChange)for(const l of[...p])l();else n.ch===a.dbChange?s||b(T,n.payload):n.ch===a.fileChange&&(s||b(F,n.payload))},e.onerror=()=>{e.close(),g=null;const t=f;f=Math.min(3e4,f*2),setTimeout(()=>{g||C()},t+Math.random()*500)}}window.addEventListener("beforeunload",()=>{g?.close(),h&&clearTimeout(h)}),o.browserStorage||await v(),U(e=>k(e));const y=e=>()=>{throw new Error(i("amxbridge.remoteOnly",{what:e()}))};return{openVault:async()=>null,restoreVault:()=>r(a.restoreVault),listPages:()=>r(a.listPages),listFiles:()=>r(a.listFiles),loadPage:async e=>{const t=await r(a.loadPage,[e]);return P=e,t},readPage:e=>r(a.readPage,[e]),newPage:e=>r(a.newPage,[e]),savePage:(e,t,n)=>r(a.savePage,[e,t,n]),patchMark:(e,t,n,s)=>r(a.patchMark,[e,t,n,s]),renamePage:(e,t,n,s)=>r(a.renamePage,[e,t,n,s]),reconcilePage:(e,t,n)=>r(a.reconcilePage,[e,t,n]),saveAsset:(e,t,n)=>r(a.saveAsset,[e,t,n]),saveVaultBytes:(e,t)=>r(a.saveVaultBytes,[e,t]),readVaultBytes:e=>r(a.readVaultBytes,[e]),saveAttachment:(e,t,n,s)=>r(a.saveAttachment,[e,t,n,s]),openAttachment:async(e,t)=>{window.open(k(t.replace(/^!?\[\[|\]\]$/g,""),e),"_blank","noopener")},openVaultFile:async e=>{const t=new URL("vault/asset",o.base);t.searchParams.set("path",e),u&&t.searchParams.set("at",u),window.open(t.href,"_blank","noopener")},exportPdf:async()=>(window.print(),null),onExternalChange:e=>(w.add(e),()=>{w.delete(e)}),search:e=>r(a.search,[e]),backlinks:e=>r(a.backlinks,[e]),exclusiveAssets:e=>r(a.exclusiveAssets,[e]),reindex:()=>r(a.reindex),listTags:()=>r(a.listTags),pagesByTag:e=>r(a.pagesByTag,[e]),deletePage:e=>r(a.deletePage,[e]),movePage:(e,t)=>r(a.movePage,[e,t]),resolveEmbed:(e,t)=>r(a.resolveEmbed,t?[e,t]:[e]),blockBacklinks:e=>r(a.blockBacklinks,[e]),listFolders:()=>r(a.listFolders),createFolder:(e,t)=>r(a.createFolder,[e,t]),renameFolder:(e,t)=>r(a.renameFolder,[e,t]),deleteFolder:e=>r(a.deleteFolder,[e]),moveFolder:(e,t)=>r(a.moveFolder,[e,t]),trashEntry:e=>r(a.trashEntry,[e]),listTrash:()=>r(a.listTrash),restoreTrash:e=>r(a.restoreTrash,[e]),deleteTrashEntry:e=>r(a.deleteTrashEntry,[e]),emptyTrash:()=>r(a.emptyTrash),pageIcons:()=>r(a.pageIcons),fetchLinkMeta:e=>r(a.fetchLinkMeta,[e]),searchImages:e=>r(a.searchImages,[e]),onStructureChange:e=>(p.add(e),()=>{p.delete(e)}),onDbExternalChange:e=>(T.add(e),()=>{T.delete(e)}),onFileExternalChange:e=>(F.add(e),()=>{F.delete(e)}),readPluginData:e=>r(a.pluginDataRead,[e]),writePluginData:(e,t)=>r(a.pluginDataWrite,[e,t]),listPlugins:async()=>[],openPluginsFolder:y(()=>i("amxbridge.op.openPluginsFolder")),scaffoldSamplePlugin:y(()=>i("amxbridge.op.scaffoldSamplePlugin")),uninstallPlugin:y(()=>i("amxbridge.op.uninstallPlugin")),revealInFileManager:y(()=>i("amxbridge.op.reveal")),hostCaps:{revealInFileManager:!1},readDatabase:(e,t)=>r(a.dbRead,[e,t]),writeDatabase:(e,t)=>r(a.dbWrite,[e,t]),writeDatabaseCas:(e,t,n)=>r(a.dbWriteCas,[e,t,n]),readDrawing:(e,t)=>r(a.drawingRead,[e,t]),writeDrawing:(e,t)=>r(a.drawingWrite,[e,t]),readTextFile:e=>r(a.readTextFile,[e]),writeTextFile:(e,t,n)=>r(a.writeTextFile,n?[e,t,n]:[e,t]),listPageProps:e=>r(a.listPageProps,[e]),setPageFrontmatter:(e,t)=>r(a.setPageFrontmatter,[e,t]),renamePageFile:(e,t)=>r(a.renamePageFile,[e,t]),renameDbFile:(e,t)=>r(a.renameDbFile,[e,t])}}export{M as createUnitAmadeusBridge};
@@ -1 +1 @@
1
- import{cr as D,A as p,cs as L,ct as j}from"./index-CF4RV4mh.js";function F(c){const{visitor:h,capabilities:o}=c,e=h.account,d=e.generation,a=new AbortController,b=e.getIdentity();if(!b||!e.getToken())throw new Error("Cloud services require a verified visitor account");const r=new URL(c.accountApiBase,location.origin);if(r.origin!==location.origin||r.username||r.password||r.search||r.hash)throw new Error("Unsupported account endpoint");if(!o.amadeus&&!o.tangu)throw new Error("No cloud service was declared");for(const n of[o.amadeus,o.tangu]){if(!n)continue;const t=new URL(n.apiBase,location.origin);if(n.adapter!=="forsion-cloud-v1"||t.origin!==location.origin||t.username||t.password||t.search||t.hash||t.href.replace(/\/+$/,"")!==r.href.replace(/\/+$/,""))throw new Error("Unsupported cloud service endpoint")}if(o.tangu&&o.tangu.execution!=="fleet")throw new Error("Unsupported cloud execution mode");const s=r.href.replace(/\/+$/,""),i=()=>{if(a.signal.aborted||e.generation!==d||!e.getToken())throw new p},l=()=>(i(),e.getToken()),m=async(n,t)=>(i(),h.capability.request(n,t)),v=window.fetch.bind(window),C=D({apiBase:s,getToken:l,request:m,fallback:v});window.fetch=C;const B=e.subscribe(()=>{e.generation!==d&&a.abort(new p)}),g=()=>{a.abort(new p),B(),window.removeEventListener("pagehide",g),window.fetch===C&&(window.fetch=v)};window.addEventListener("pagehide",g,{once:!0});const y=()=>{e.generation===d&&e.clearSession({prepare:!1}).catch(()=>{})},E={apiBase:s,getToken:l,request:m,signal:a.signal,linkBase:c.projectionBase,getUserId:()=>(i(),b.userId),onAuthError:y};function A(n){return Object.fromEntries(Object.entries(n).map(([t,f])=>[t,typeof f!="function"?f:(...k)=>{if(t==="stopHeartbeat")return f(...k);i();const x=k.map(u=>typeof u!="function"?u:(...T)=>{if(!a.signal.aborted&&e.generation===d)return u(...T)}),w=f(...x);return w&&typeof w.then=="function"?w.then(u=>(i(),u)):(i(),w)}]))}let U;if(o.amadeus){const n=L(E);n.readPluginData=c.pluginData.read,n.writePluginData=c.pluginData.write,U=A(n),o.amadeus.collaboration&&(j(E),window.amadeusCollab&&(window.amadeusCollab=A(window.amadeusCollab)))}return{amadeus:U,stop:g,config:{mode:"external",backendUrl:s,token:o.tangu?l():"",cloudUrl:s,cloudApiBase:s,sandbox:"none"},getToken:l,signal:a.signal}}export{F as installUnitCloudTransport};
1
+ import{cr as D,A as p,cs as L,ct as j}from"./index-BM2o7PeV.js";function F(c){const{visitor:h,capabilities:o}=c,e=h.account,d=e.generation,a=new AbortController,b=e.getIdentity();if(!b||!e.getToken())throw new Error("Cloud services require a verified visitor account");const r=new URL(c.accountApiBase,location.origin);if(r.origin!==location.origin||r.username||r.password||r.search||r.hash)throw new Error("Unsupported account endpoint");if(!o.amadeus&&!o.tangu)throw new Error("No cloud service was declared");for(const n of[o.amadeus,o.tangu]){if(!n)continue;const t=new URL(n.apiBase,location.origin);if(n.adapter!=="forsion-cloud-v1"||t.origin!==location.origin||t.username||t.password||t.search||t.hash||t.href.replace(/\/+$/,"")!==r.href.replace(/\/+$/,""))throw new Error("Unsupported cloud service endpoint")}if(o.tangu&&o.tangu.execution!=="fleet")throw new Error("Unsupported cloud execution mode");const s=r.href.replace(/\/+$/,""),i=()=>{if(a.signal.aborted||e.generation!==d||!e.getToken())throw new p},l=()=>(i(),e.getToken()),m=async(n,t)=>(i(),h.capability.request(n,t)),v=window.fetch.bind(window),C=D({apiBase:s,getToken:l,request:m,fallback:v});window.fetch=C;const B=e.subscribe(()=>{e.generation!==d&&a.abort(new p)}),g=()=>{a.abort(new p),B(),window.removeEventListener("pagehide",g),window.fetch===C&&(window.fetch=v)};window.addEventListener("pagehide",g,{once:!0});const y=()=>{e.generation===d&&e.clearSession({prepare:!1}).catch(()=>{})},E={apiBase:s,getToken:l,request:m,signal:a.signal,linkBase:c.projectionBase,getUserId:()=>(i(),b.userId),onAuthError:y};function A(n){return Object.fromEntries(Object.entries(n).map(([t,f])=>[t,typeof f!="function"?f:(...k)=>{if(t==="stopHeartbeat")return f(...k);i();const x=k.map(u=>typeof u!="function"?u:(...T)=>{if(!a.signal.aborted&&e.generation===d)return u(...T)}),w=f(...x);return w&&typeof w.then=="function"?w.then(u=>(i(),u)):(i(),w)}]))}let U;if(o.amadeus){const n=L(E);n.readPluginData=c.pluginData.read,n.writePluginData=c.pluginData.write,U=A(n),o.amadeus.collaboration&&(j(E),window.amadeusCollab&&(window.amadeusCollab=A(window.amadeusCollab)))}return{amadeus:U,stop:g,config:{mode:"external",backendUrl:s,token:o.tangu?l():"",cloudUrl:s,cloudApiBase:s,sandbox:"none"},getToken:l,signal:a.signal}}export{F as installUnitCloudTransport};
@@ -1 +1 @@
1
- import{f as b}from"./index-CF4RV4mh.js";async function h(p,l,u=""){const n=b()==="zh",o=document.createElement("main");o.style.cssText="max-width:420px;margin:12vh auto;padding:28px;font:15px/1.6 system-ui;color:#222";const c=document.createElement("h1");c.textContent=p;const i=document.createElement("p");i.textContent=n?"输入此设备的访问密钥,打开本地工作区。":"Enter this device’s access key to open its local workspace.";const s=document.createElement("form"),a=document.createElement("label");a.textContent=n?"设备访问密钥":"Device access key";const e=document.createElement("input");e.type="password",e.required=!0,e.autocomplete="off",e.value=u,e.style.cssText="display:block;width:100%;box-sizing:border-box;margin:8px 0 18px;padding:10px;border:1px solid #bbb;border-radius:8px",a.append(e);const t=document.createElement("button");t.type="submit",t.textContent=n?"打开工作区":"Open workspace",t.style.cssText="padding:10px 18px;border:1px solid #aaa;border-radius:8px;cursor:pointer";const r=document.createElement("p");r.setAttribute("role","alert"),s.append(a,t,r),o.append(c,i,s),document.body.append(o);try{return await new Promise(m=>{s.onsubmit=async x=>{x.preventDefault(),t.disabled=!0;try{const d=e.value.trim();if((await fetch(new URL("unit/whoami",l),{headers:{Authorization:`Bearer ${d}`}})).ok){m(d);return}r.textContent=n?"访问密钥无效。":"Invalid access key."}catch{r.textContent=n?"无法连接此设备。":"Cannot reach this device."}finally{t.disabled=!1}},e.focus()})}finally{o.remove()}}export{h as ownerAccess};
1
+ import{f as b}from"./index-BM2o7PeV.js";async function h(p,l,u=""){const n=b()==="zh",o=document.createElement("main");o.style.cssText="max-width:420px;margin:12vh auto;padding:28px;font:15px/1.6 system-ui;color:#222";const c=document.createElement("h1");c.textContent=p;const i=document.createElement("p");i.textContent=n?"输入此设备的访问密钥,打开本地工作区。":"Enter this device’s access key to open its local workspace.";const s=document.createElement("form"),a=document.createElement("label");a.textContent=n?"设备访问密钥":"Device access key";const e=document.createElement("input");e.type="password",e.required=!0,e.autocomplete="off",e.value=u,e.style.cssText="display:block;width:100%;box-sizing:border-box;margin:8px 0 18px;padding:10px;border:1px solid #bbb;border-radius:8px",a.append(e);const t=document.createElement("button");t.type="submit",t.textContent=n?"打开工作区":"Open workspace",t.style.cssText="padding:10px 18px;border:1px solid #aaa;border-radius:8px;cursor:pointer";const r=document.createElement("p");r.setAttribute("role","alert"),s.append(a,t,r),o.append(c,i,s),document.body.append(o);try{return await new Promise(m=>{s.onsubmit=async x=>{x.preventDefault(),t.disabled=!0;try{const d=e.value.trim();if((await fetch(new URL("unit/whoami",l),{headers:{Authorization:`Bearer ${d}`}})).ok){m(d);return}r.textContent=n?"访问密钥无效。":"Invalid access key."}catch{r.textContent=n?"无法连接此设备。":"Cannot reach this device."}finally{t.disabled=!1}},e.focus()})}finally{o.remove()}}export{h as ownerAccess};
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./unitAccount-D8lVwaaT.js","./index-CF4RV4mh.js","./unitOwnerAccess-BfnEjsZb.js","./unitCloudTransport-BVF6lVp4.js","./unitBridge-D547ublk.js","./ipc-DQOD2UKk.js","./nativeDownload-D-f1_L2S.js"])))=>i.map(i=>d[i]);
2
- import{_ as y}from"./index-CF4RV4mh.js";const r=()=>new URL(".",document.baseURI);async function R(o){const c=document.createElement("div");c.setAttribute("style","position:fixed;inset:0;display:flex;align-items:center;justify-content:center;background:#f7f6f4;font-family:system-ui;z-index:99999");const l=document.createElement("div");l.setAttribute("style","max-width:380px;padding:32px;border-radius:16px;background:#fff;box-shadow:0 8px 40px rgba(0,0,0,.08);text-align:center"),c.appendChild(l),document.body.appendChild(c);const d=n=>{l.innerHTML=n},s=n=>n.replace(/[&<>"]/g,i=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[i]);try{for(;;){d(`<h3 style="margin:0 0 8px">连接「${s(o.name)}」</h3><p style="color:#777;font-size:13px">正在请求配对…</p>`);let n=null;try{const i=await fetch(new URL("unit/pair/request",r()),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"来访设备"})});if(i.status===429){d('<h3 style="margin:0 0 8px">稍等一下</h3><p style="color:#777;font-size:13px">对方还有一个待确认的配对请求,请稍后重试。</p><button id="up-retry" style="margin-top:12px;padding:8px 20px;border-radius:999px;border:1px solid #ddd;background:#fff;cursor:pointer">重试</button>'),await new Promise(a=>{l.querySelector("#up-retry")?.addEventListener("click",()=>a())});continue}n=await i.json()}catch{}if(!n?.requestId||!n.code){d('<h3 style="margin:0 0 8px">连接失败</h3><p style="color:#777;font-size:13px">联系不上对方设备,确认它开着 Forsion 并启用了互联。</p><button id="up-retry" style="margin-top:12px;padding:8px 20px;border-radius:999px;border:1px solid #ddd;background:#fff;cursor:pointer">重试</button>'),await new Promise(i=>{l.querySelector("#up-retry")?.addEventListener("click",()=>i())});continue}for(d(`<h3 style="margin:0 0 8px">在「${s(o.name)}」上确认</h3>
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./unitAccount-DwutFPPw.js","./index-BM2o7PeV.js","./unitOwnerAccess-LBlJ1YfA.js","./unitCloudTransport-vA7cLDts.js","./unitBridge-CcgQpkqV.js","./ipc-CxAyeo8q.js","./nativeDownload-BYT082bY.js"])))=>i.map(i=>d[i]);
2
+ import{_ as y}from"./index-BM2o7PeV.js";const r=()=>new URL(".",document.baseURI);async function R(o){const c=document.createElement("div");c.setAttribute("style","position:fixed;inset:0;display:flex;align-items:center;justify-content:center;background:#f7f6f4;font-family:system-ui;z-index:99999");const l=document.createElement("div");l.setAttribute("style","max-width:380px;padding:32px;border-radius:16px;background:#fff;box-shadow:0 8px 40px rgba(0,0,0,.08);text-align:center"),c.appendChild(l),document.body.appendChild(c);const d=n=>{l.innerHTML=n},s=n=>n.replace(/[&<>"]/g,i=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[i]);try{for(;;){d(`<h3 style="margin:0 0 8px">连接「${s(o.name)}」</h3><p style="color:#777;font-size:13px">正在请求配对…</p>`);let n=null;try{const i=await fetch(new URL("unit/pair/request",r()),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"来访设备"})});if(i.status===429){d('<h3 style="margin:0 0 8px">稍等一下</h3><p style="color:#777;font-size:13px">对方还有一个待确认的配对请求,请稍后重试。</p><button id="up-retry" style="margin-top:12px;padding:8px 20px;border-radius:999px;border:1px solid #ddd;background:#fff;cursor:pointer">重试</button>'),await new Promise(a=>{l.querySelector("#up-retry")?.addEventListener("click",()=>a())});continue}n=await i.json()}catch{}if(!n?.requestId||!n.code){d('<h3 style="margin:0 0 8px">连接失败</h3><p style="color:#777;font-size:13px">联系不上对方设备,确认它开着 Forsion 并启用了互联。</p><button id="up-retry" style="margin-top:12px;padding:8px 20px;border-radius:999px;border:1px solid #ddd;background:#fff;cursor:pointer">重试</button>'),await new Promise(i=>{l.querySelector("#up-retry")?.addEventListener("click",()=>i())});continue}for(d(`<h3 style="margin:0 0 8px">在「${s(o.name)}」上确认</h3>
3
3
  <p style="color:#777;font-size:13px">对方屏幕会弹出同一组配对码,核对一致后点「允许」:</p>
4
4
  <div style="font-size:34px;letter-spacing:8px;font-weight:700;margin:16px 0">${s(n.code)}</div>
5
- <p style="color:#aaa;font-size:12px">等待对方确认…(2 分钟内有效)</p>`);;){await new Promise(a=>setTimeout(a,1500));let i={};try{i=await(await fetch(new URL(`unit/pair/poll?id=${n.requestId}`,r()))).json()}catch{}if(i.status==="approved"&&i.token)return i.token;if(i.status==="denied"||i.status==="expired"){d(`<h3 style="margin:0 0 8px">${i.status==="denied"?"对方拒绝了连接":"配对超时"}</h3><button id="up-retry" style="margin-top:12px;padding:8px 20px;border-radius:999px;border:1px solid #ddd;background:#fff;cursor:pointer">重新配对</button>`),await new Promise(a=>{l.querySelector("#up-retry")?.addEventListener("click",()=>a())});break}}}}finally{c.remove()}}async function L(){const o=window.__FORSION_UNIT_PAGE__;if(!o)return!1;const c=o.projection==="local",l=c?`unit_owner_${o.instanceId}`:`unit_pair_${o.instanceId}`;let d;try{d=c?sessionStorage:localStorage}catch{}const s=o.projection==="public",n=s&&o.account?await(await y(async()=>{const{installUnitAccount:t}=await import("./unitAccount-D8lVwaaT.js");return{installUnitAccount:t}},__vite__mapDeps([0,1]),import.meta.url)).installUnitAccount({...o,account:o.account},r()):null,i=s&&!!(o.capabilities?.amadeus||o.capabilities?.tangu);if(i&&!n)throw new Error("Cloud services require the Unit account provider");if(i&&!n.account.getIdentity())return await n.login(),!1;let a="";try{a=d?.getItem(l)||""}catch{}c&&location.hash.startsWith("#unit-owner=")&&(a=new URLSearchParams(location.hash.slice(1)).get("unit-owner")||"",history.replaceState(null,"",location.pathname+location.search));const m=await fetch(new URL("unit/whoami",r()),{headers:a?{Authorization:`Bearer ${a}`}:void 0}).catch(()=>null);if(s&&!m?.ok)throw new Error("Unit projection is unavailable");if(!s&&(!m||m.status===401)){const t=c?await(await y(async()=>{const{ownerAccess:e}=await import("./unitOwnerAccess-BfnEjsZb.js");return{ownerAccess:e}},__vite__mapDeps([2,1]),import.meta.url)).ownerAccess(o.name,r()):await R(o);if(!t)return!1;a=t;try{d?.setItem(l,a)}catch{}}if(c&&a)try{d?.setItem(l,a)}catch{}a||(a="tunnel"),window.__FORSION_UNIT_TOKEN__=a;const p=a,b=n?{read:async t=>{if(!n.account.getIdentity())return null;const e=await n.request(`unit/plugin-data/${encodeURIComponent(t)}`);if(!e.ok)throw new Error(`Plugin data HTTP ${e.status}`);return(await e.json()).data},write:async(t,e)=>{if(!n.account.getIdentity())throw new Error("Sign in to save plugin data");const f=await n.request(`unit/plugin-data/${encodeURIComponent(t)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:e})});if(!f.ok)throw new Error(`Plugin data HTTP ${f.status}`);await f.json()}}:void 0,g=i?(await y(async()=>{const{installUnitCloudTransport:t}=await import("./unitCloudTransport-BVF6lVp4.js");return{installUnitCloudTransport:t}},__vite__mapDeps([3,1]),import.meta.url)).installUnitCloudTransport({capabilities:o.capabilities,accountApiBase:o.account.apiBase,projectionBase:r().href,visitor:n,pluginData:b}):null;if(g?.amadeus)window.amadeus=g.amadeus;else{const{createUnitAmadeusBridge:t}=await y(async()=>{const{createUnitAmadeusBridge:e}=await import("./unitBridge-D547ublk.js");return{createUnitAmadeusBridge:e}},__vite__mapDeps([4,1,5]),import.meta.url);window.amadeus=await t({base:r().href,browserStorage:s||c&&!o.localCapabilities?.vault?n?.scope||o.instanceId:void 0,pluginData:b,getToken:()=>p,onAuthError:()=>{try{d?.removeItem(l)}catch{}location.reload()}})}const x=new URL("engine",r()).href,U=g?.config??{mode:"external",backendUrl:x,token:s?"":a,cloudUrl:"",cloudApiBase:"",sandbox:"none"},w=()=>p&&p!=="tunnel"?{Authorization:`Bearer ${p}`}:void 0;let u={};const _=async()=>{if(n){if(!n.account.getIdentity()){u={};return}const e=await n.request("unit/config");if(!e.ok)throw new Error(`Preferences HTTP ${e.status}`);u=(await e.json()).config||{};return}if(s){u=JSON.parse(sessionStorage.getItem(`unit:${o.instanceId}:preferences`)||"{}");return}const t=await fetch(new URL("unit/config",r()),{headers:w()});t.ok&&(u=(await t.json()).config||{})};try{await _()}catch{}const h=()=>({modelId:"",...u,...U}),v=window;return v.tangu={unitPage:!0,remoteCaller:!c,hostFiles:!s,executionCapabilities:{host:c?!!o.localCapabilities?.host:!s},...g?{cloudWeb:!0}:{},initialConfig:h(),...n?{account:n.capability,forsionLogin:n.login,forsionLogout:async()=>(await n.account.logout(),{ok:!0}),onAuthChanged:n.capability.subscribe,onAuthWillChange:n.onAuthWillChange}:{},...c?{backendStatus:async()=>{const t=await fetch(new URL("unit/meta",r()));if(!t.ok)throw new Error("Unit status unavailable");const e=await t.json();return{state:e.localCapabilities?.engine?"ready":"stopped",url:e.localCapabilities?.engine?x:null,pid:null,lastError:null}}}:{},appVersion:async()=>o.version,platform:void 0,getConfig:async()=>{try{await _()}catch{}return h()},setConfig:async t=>{if(n){if(!n.account.getIdentity())return h();const e=await n.request("unit/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!e.ok)throw new Error(`Preferences HTTP ${e.status}`);return u=(await e.json()).config||{},h()}if(s)return u={...u,...t},sessionStorage.setItem(`unit:${o.instanceId}:preferences`,JSON.stringify(u)),h();try{const e=await fetch(new URL("unit/config",r()),{method:"PUT",headers:{"Content-Type":"application/json",...w()||{}},body:JSON.stringify(t||{})});e.ok&&(u=(await e.json()).config||u)}catch{u={...u,...t}}return h()},authStatus:n?.account.authStatus||(async()=>({loggedIn:!1,cloudUrl:"",username:o.name,nickname:o.name,tokenSource:null})),...s?{}:{listProviders:async()=>{const t=await fetch(new URL("unit/providers",r()),{headers:w()});if(!t.ok)throw new Error(`unit providers HTTP ${t.status}`);return(await t.json()).providers||[]},readHostFile:async t=>{const e=await fetch(new URL(`unit/hostfile?path=${encodeURIComponent(t)}`,r()),{headers:w()});if(!e.ok)throw new Error(`hostfile HTTP ${e.status}`);return e.json()},downloadHostFile:async(t,e)=>{const f=await fetch(new URL(`unit/hostfile/download?path=${encodeURIComponent(t)}`,r()),{headers:w()}),{hostDownloadError:k,saveResponseAs:I}=await y(async()=>{const{hostDownloadError:T,saveResponseAs:E}=await import("./nativeDownload-D-f1_L2S.js").then(P=>P.b);return{hostDownloadError:T,saveResponseAs:E}},__vite__mapDeps([6,1]),import.meta.url);if(!f.ok)throw await k(f);await I(e,f)},listDir:async t=>{try{const e=await fetch(new URL(`unit/hostdir?path=${encodeURIComponent(t)}`,r()),{headers:w()});return e.ok?(await e.json()).entries||[]:[]}catch{return[]}},statPath:async t=>{try{const e=await fetch(new URL(`unit/hoststat?path=${encodeURIComponent(t)}`,r()),{headers:w()});return e.ok?e.json():null}catch{return null}}},spacesList:async()=>{const t=await fetch(new URL("unit/spaces",r()),{headers:p&&p!=="tunnel"?{Authorization:`Bearer ${p}`}:void 0});if(!t.ok)throw new Error(`unit spaces HTTP ${t.status}`);return(await t.json()).spaces||[]}},document.title=`${o.name} · Forsion`,!0}export{L as installUnitShim};
5
+ <p style="color:#aaa;font-size:12px">等待对方确认…(2 分钟内有效)</p>`);;){await new Promise(a=>setTimeout(a,1500));let i={};try{i=await(await fetch(new URL(`unit/pair/poll?id=${n.requestId}`,r()))).json()}catch{}if(i.status==="approved"&&i.token)return i.token;if(i.status==="denied"||i.status==="expired"){d(`<h3 style="margin:0 0 8px">${i.status==="denied"?"对方拒绝了连接":"配对超时"}</h3><button id="up-retry" style="margin-top:12px;padding:8px 20px;border-radius:999px;border:1px solid #ddd;background:#fff;cursor:pointer">重新配对</button>`),await new Promise(a=>{l.querySelector("#up-retry")?.addEventListener("click",()=>a())});break}}}}finally{c.remove()}}async function L(){const o=window.__FORSION_UNIT_PAGE__;if(!o)return!1;const c=o.projection==="local",l=c?`unit_owner_${o.instanceId}`:`unit_pair_${o.instanceId}`;let d;try{d=c?sessionStorage:localStorage}catch{}const s=o.projection==="public",n=s&&o.account?await(await y(async()=>{const{installUnitAccount:t}=await import("./unitAccount-DwutFPPw.js");return{installUnitAccount:t}},__vite__mapDeps([0,1]),import.meta.url)).installUnitAccount({...o,account:o.account},r()):null,i=s&&!!(o.capabilities?.amadeus||o.capabilities?.tangu);if(i&&!n)throw new Error("Cloud services require the Unit account provider");if(i&&!n.account.getIdentity())return await n.login(),!1;let a="";try{a=d?.getItem(l)||""}catch{}c&&location.hash.startsWith("#unit-owner=")&&(a=new URLSearchParams(location.hash.slice(1)).get("unit-owner")||"",history.replaceState(null,"",location.pathname+location.search));const m=await fetch(new URL("unit/whoami",r()),{headers:a?{Authorization:`Bearer ${a}`}:void 0}).catch(()=>null);if(s&&!m?.ok)throw new Error("Unit projection is unavailable");if(!s&&(!m||m.status===401)){const t=c?await(await y(async()=>{const{ownerAccess:e}=await import("./unitOwnerAccess-LBlJ1YfA.js");return{ownerAccess:e}},__vite__mapDeps([2,1]),import.meta.url)).ownerAccess(o.name,r()):await R(o);if(!t)return!1;a=t;try{d?.setItem(l,a)}catch{}}if(c&&a)try{d?.setItem(l,a)}catch{}a||(a="tunnel"),window.__FORSION_UNIT_TOKEN__=a;const p=a,b=n?{read:async t=>{if(!n.account.getIdentity())return null;const e=await n.request(`unit/plugin-data/${encodeURIComponent(t)}`);if(!e.ok)throw new Error(`Plugin data HTTP ${e.status}`);return(await e.json()).data},write:async(t,e)=>{if(!n.account.getIdentity())throw new Error("Sign in to save plugin data");const f=await n.request(`unit/plugin-data/${encodeURIComponent(t)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:e})});if(!f.ok)throw new Error(`Plugin data HTTP ${f.status}`);await f.json()}}:void 0,g=i?(await y(async()=>{const{installUnitCloudTransport:t}=await import("./unitCloudTransport-vA7cLDts.js");return{installUnitCloudTransport:t}},__vite__mapDeps([3,1]),import.meta.url)).installUnitCloudTransport({capabilities:o.capabilities,accountApiBase:o.account.apiBase,projectionBase:r().href,visitor:n,pluginData:b}):null;if(g?.amadeus)window.amadeus=g.amadeus;else{const{createUnitAmadeusBridge:t}=await y(async()=>{const{createUnitAmadeusBridge:e}=await import("./unitBridge-CcgQpkqV.js");return{createUnitAmadeusBridge:e}},__vite__mapDeps([4,1,5]),import.meta.url);window.amadeus=await t({base:r().href,browserStorage:s||c&&!o.localCapabilities?.vault?n?.scope||o.instanceId:void 0,pluginData:b,getToken:()=>p,onAuthError:()=>{try{d?.removeItem(l)}catch{}location.reload()}})}const x=new URL("engine",r()).href,U=g?.config??{mode:"external",backendUrl:x,token:s?"":a,cloudUrl:"",cloudApiBase:"",sandbox:"none"},w=()=>p&&p!=="tunnel"?{Authorization:`Bearer ${p}`}:void 0;let u={};const _=async()=>{if(n){if(!n.account.getIdentity()){u={};return}const e=await n.request("unit/config");if(!e.ok)throw new Error(`Preferences HTTP ${e.status}`);u=(await e.json()).config||{};return}if(s){u=JSON.parse(sessionStorage.getItem(`unit:${o.instanceId}:preferences`)||"{}");return}const t=await fetch(new URL("unit/config",r()),{headers:w()});t.ok&&(u=(await t.json()).config||{})};try{await _()}catch{}const h=()=>({modelId:"",...u,...U}),v=window;return v.tangu={unitPage:!0,remoteCaller:!c,hostFiles:!s,executionCapabilities:{host:c?!!o.localCapabilities?.host:!s},...g?{cloudWeb:!0}:{},initialConfig:h(),...n?{account:n.capability,forsionLogin:n.login,forsionLogout:async()=>(await n.account.logout(),{ok:!0}),onAuthChanged:n.capability.subscribe,onAuthWillChange:n.onAuthWillChange}:{},...c?{backendStatus:async()=>{const t=await fetch(new URL("unit/meta",r()));if(!t.ok)throw new Error("Unit status unavailable");const e=await t.json();return{state:e.localCapabilities?.engine?"ready":"stopped",url:e.localCapabilities?.engine?x:null,pid:null,lastError:null}}}:{},appVersion:async()=>o.version,platform:void 0,getConfig:async()=>{try{await _()}catch{}return h()},setConfig:async t=>{if(n){if(!n.account.getIdentity())return h();const e=await n.request("unit/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!e.ok)throw new Error(`Preferences HTTP ${e.status}`);return u=(await e.json()).config||{},h()}if(s)return u={...u,...t},sessionStorage.setItem(`unit:${o.instanceId}:preferences`,JSON.stringify(u)),h();try{const e=await fetch(new URL("unit/config",r()),{method:"PUT",headers:{"Content-Type":"application/json",...w()||{}},body:JSON.stringify(t||{})});e.ok&&(u=(await e.json()).config||u)}catch{u={...u,...t}}return h()},authStatus:n?.account.authStatus||(async()=>({loggedIn:!1,cloudUrl:"",username:o.name,nickname:o.name,tokenSource:null})),...s?{}:{listProviders:async()=>{const t=await fetch(new URL("unit/providers",r()),{headers:w()});if(!t.ok)throw new Error(`unit providers HTTP ${t.status}`);return(await t.json()).providers||[]},readHostFile:async t=>{const e=await fetch(new URL(`unit/hostfile?path=${encodeURIComponent(t)}`,r()),{headers:w()});if(!e.ok)throw new Error(`hostfile HTTP ${e.status}`);return e.json()},downloadHostFile:async(t,e)=>{const f=await fetch(new URL(`unit/hostfile/download?path=${encodeURIComponent(t)}`,r()),{headers:w()}),{hostDownloadError:k,saveResponseAs:I}=await y(async()=>{const{hostDownloadError:T,saveResponseAs:E}=await import("./nativeDownload-BYT082bY.js").then(P=>P.b);return{hostDownloadError:T,saveResponseAs:E}},__vite__mapDeps([6,1]),import.meta.url);if(!f.ok)throw await k(f);await I(e,f)},listDir:async t=>{try{const e=await fetch(new URL(`unit/hostdir?path=${encodeURIComponent(t)}`,r()),{headers:w()});return e.ok?(await e.json()).entries||[]:[]}catch{return[]}},statPath:async t=>{try{const e=await fetch(new URL(`unit/hoststat?path=${encodeURIComponent(t)}`,r()),{headers:w()});return e.ok?e.json():null}catch{return null}}},spacesList:async()=>{const t=await fetch(new URL("unit/spaces",r()),{headers:p&&p!=="tunnel"?{Authorization:`Bearer ${p}`}:void 0});if(!t.ok)throw new Error(`unit spaces HTTP ${t.status}`);return(await t.json()).spaces||[]}},document.title=`${o.name} · Forsion`,!0}export{L as installUnitShim};
@@ -1 +1 @@
1
- import{z as a}from"./appStore-Dg9WALEA.js";const o=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],t=a("upload",o);export{t as U};
1
+ import{F as a}from"./appStore-DWP8UET9.js";const o=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],t=a("upload",o);export{t as U};
@@ -0,0 +1 @@
1
+ import{b as re,r as Z,j as y,d as le,u as nt,J as it}from"./index-BM2o7PeV.js";import{F as v,nV as ot,nW as st,nX as rt,nY as lt,a5 as h,d3 as S,m as ct,a as q,nZ as T,bp as dt,ah as ft,ae as ce,ao as Ae,aJ as ut,dd as w,n_ as gt,G as _e,U as pt,I as Ie,n$ as ht,o0 as mt,o1 as yt,o2 as St,o3 as vt,o4 as M,ib as kt,g as xe,o5 as Pt,o6 as bt,o7 as wt,i4 as zt,p as Q,u as Me,o8 as ee,a_ as De,b1 as F,o9 as de,oa as I,ob as E,oc as At,cN as Ce,e_ as Ee,aa as L,cY as _t,c$ as It,od as Oe,oe as Te,ax as xt,of as Mt,aC as fe,b8 as Dt,og as Ct,oh as Et,aH as Le,iH as Ot,b9 as te,K as Tt,Y as Lt,W as Nt,a2 as Vt,a3 as jt,Z as $t,a4 as Rt,T as Ut,gH as Ft,oi as Ht,aB as Wt,oj as Bt}from"./appStore-DWP8UET9.js";import"./client-0MPbodA6.js";import{A as Ne}from"./automationListSource-C8BNy6RY.js";import{C as Gt}from"./code-xml-Cuna8Kh4.js";import{W as qt}from"./workflow-DPoG4QE2.js";import{L as Kt}from"./list-tree-4-0QDbLu.js";import{L as Jt}from"./layout-grid-BBVuEdWG.js";import{T as Yt}from"./terminal-l9k6RDrH.js";import{S as Xt}from"./star-BQWMXnn7.js";import{F as Zt}from"./folder-BpsfOHD4.js";import{B as Qt}from"./book-open-OLNm7OaB.js";const ea=[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]],Ve=v("boxes",ea);const ta=[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]],aa=v("briefcase",ta);const na=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],ia=v("code",na);const oa=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}]],sa=v("heart",oa);const ra=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],la=v("mail",ra);const ca=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],da=v("music",ca);const fa=[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M9.5 8h5",key:"11mslq"}],["path",{d:"M9.5 12H16",key:"ktog6x"}],["path",{d:"M9.5 16H14",key:"p1seyn"}]],je=v("notebook-text",fa);const ua=[["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}],["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09",key:"u4xsad"}],["path",{d:"M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z",key:"676m9"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05",key:"92ym6u"}]],ga=v("rocket",ua);const pa=[["path",{d:"m10.852 14.772-.383.923",key:"11vil6"}],["path",{d:"M13.148 14.772a3 3 0 1 0-2.296-5.544l-.383-.923",key:"1v3clb"}],["path",{d:"m13.148 9.228.383-.923",key:"t2zzyc"}],["path",{d:"m13.53 15.696-.382-.924a3 3 0 1 1-2.296-5.544",key:"1bxfiv"}],["path",{d:"m14.772 10.852.923-.383",key:"k9m8cz"}],["path",{d:"m14.772 13.148.923.383",key:"1xvhww"}],["path",{d:"M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5",key:"tn8das"}],["path",{d:"M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5",key:"1g2pve"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"m9.228 10.852-.923-.383",key:"1wtb30"}],["path",{d:"m9.228 13.148-.923.383",key:"1a830x"}]],ha=v("server-cog",pa);const ma=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],ya=v("server",ma);const Sa=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],va=v("target",Sa);const ka=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],Pa=v("video",ka),ue=["right","left","full","main"],$e=/^[a-z0-9][a-z0-9-]{0,63}$/;function ba(e,t){const i=e.replace(/^v/i,"").split("."),a=t.replace(/^v/i,"").split(".");for(let o=0;o<Math.max(i.length,a.length);o++){const s=parseInt(i[o]??"0",10)||0,n=parseInt(a[o]??"0",10)||0;if(s!==n)return s<n?-1:1}return 0}function A(e,t){if(e===void 0)return[];if(!Array.isArray(e))return`layout.${t} 必须是数组`;const i=[];for(const a of e){if(!a||typeof a!="object"||typeof a.type!="string"||!a.type)return`layout.${t} 的条目必须是 { type: string }`;const o=a.params;if(o!==void 0&&(typeof o!="object"||o===null||Array.isArray(o)))return`layout.${t} 的 params 必须是对象`;const s=a.split,n=a.splitFrom;if(s!==void 0&&s!=="right"&&s!=="down")return`layout.${t} 的 split 必须是 right 或 down`;if(n!==void 0&&(t!=="main"||!s||!Number.isInteger(n)||n<0||n>=i.length))return`layout.${t} 的 splitFrom 必须指向此前的 main 条目(从 0 开始),且同时声明 split`;const r=a.pinned;if(r!==void 0&&(typeof r!="boolean"||r&&t==="bottom"))return`layout.${t} 的 pinned 必须是布尔值,且底部面板不支持固定`;i.push({type:a.type,...o?{params:o}:{},...s?{split:s}:{},...n!==void 0?{splitFrom:n}:{},...r?{pinned:!0}:{}})}return i}function wa(e){return e.map((t,i)=>i===0?{panel:t,mode:"first"}:t.split?{panel:t,mode:"split",direction:t.split,from:t.splitFrom??i-1}:{panel:t,mode:"tab"})}function za(e,t){let i;try{i=JSON.parse(e)}catch{return{ok:!1,error:"space.json 不是合法 JSON"}}if(!i||typeof i!="object")return{ok:!1,error:"space.json 必须是对象"};const a=i,o=a.id;if(typeof o!="string"||!$e.test(o))return{ok:!1,error:"id 必须是 kebab-case(a-z0-9-)"};if(t.reservedIds.includes(o))return{ok:!1,error:`id "${o}" 是内置 Space 保留名`};const s=a.name;if(!(typeof s=="string"&&s.trim()||!!s&&typeof s=="object"&&!Array.isArray(s)&&(typeof s.zh=="string"||typeof s.en=="string")))return{ok:!1,error:"name 必须是非空字符串或 {zh?,en?}"};if(a.icon!==void 0&&typeof a.icon!="string")return{ok:!1,error:"icon 必须是字符串"};if(a.minAppVersion!==void 0&&typeof a.minAppVersion!="string")return{ok:!1,error:"minAppVersion 必须是字符串"};if(typeof a.minAppVersion=="string"&&t.appVersion&&ba(t.appVersion,a.minAppVersion)<0)return{ok:!1,error:`需要应用版本 ≥ ${a.minAppVersion}(当前 ${t.appVersion})`};if(!a.layout||typeof a.layout!="object")return{ok:!1,error:"缺少 layout"};const r=a.layout,u=A(r.main,"main"),m=A(r.left,"left"),p=A(r.right,"right"),g=A(r.bottom,"bottom");for(const f of[u,m,p,g])if(typeof f=="string")return{ok:!1,error:f};if(!u.length)return{ok:!1,error:"layout.main 至少要有一个视图"};if(u[0].split)return{ok:!1,error:"layout.main 第一项不能声明 split"};if([m,p,g].some(f=>f.some(z=>z.split)))return{ok:!1,error:"split 只适用于 layout.main"};if(r.bottomSpan!==void 0&&!ue.includes(r.bottomSpan))return{ok:!1,error:`layout.bottomSpan 必须是 ${ue.join(" / ")} 之一`};let k;if(a.mini!==void 0){if(!a.mini||typeof a.mini!="object"||Array.isArray(a.mini))return{ok:!1,error:"mini 必须是 {view, mainView} 对象"};const f=a.mini,z=A([f.view],"mini.view"),N=A([f.mainView],"mini.mainView");if(typeof z=="string")return{ok:!1,error:z};if(typeof N=="string")return{ok:!1,error:N};if(z[0].type===N[0].type)return{ok:!1,error:"mini.view 必须单独适配,不能复用 mainView 的视图类型"};if(f.name!==void 0&&!(typeof f.name=="string"&&f.name.trim())&&!(f.name&&typeof f.name=="object"&&!Array.isArray(f.name)&&Object.values(f.name).some(se=>typeof se=="string"&&se.trim())))return{ok:!1,error:"mini.name 必须是名称或双语对象"};k={view:z[0],mainView:N[0],name:f.name}}const l=a.requires,P=Array.isArray(l?.views)?l.views.filter(f=>typeof f=="string"):[],at=[u,m,p,g].flatMap(f=>f).map(f=>f.type).concat(P),oe=[...new Set(at.filter(f=>!t.isViewRegistered(f)))];return oe.length?{ok:!1,error:`引用了未注册的视图: ${oe.join(", ")}(可能需要升级应用或安装对应 Space App)`}:{ok:!0,spec:{id:o,name:s,icon:typeof a.icon=="string"?a.icon:void 0,iconFile:typeof a.iconFile=="string"?a.iconFile:void 0,version:typeof a.version=="string"?a.version:void 0,mini:k,minAppVersion:typeof a.minAppVersion=="string"?a.minAppVersion:void 0,layout:{main:u,left:m,right:p,...g.length?{bottom:g}:{},...r.bottomSpan?{bottomSpan:r.bottomSpan}:{}},requires:P.length?{views:P}:void 0}}}function Re(e){const t=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48);return $e.test(t)?t:"space"}function Ue(e,t){if(!t.has(e))return e;for(let i=2;;i++)if(!t.has(`${e}-${i}`))return`${e}-${i}`}function Aa(e){return e==="bottom"?null:e==="left"||e==="right"?e:"main"}const Fe="plugin:inbox:messages",_a=new Set(["amadeus-editor","amadeus-drawing","dashboard","amadeus-dashboard","amadeus-db","amadeus-pdf"]);function gn(e,t,i="sessions",a){return e!=="right"&&a?a:t==="chat"?e==="right"?"files":"sessions":t&&_a.has(t)?e==="right"?"files":"notes":t==="code-studio"||e==="right"?"files":i}function pn(e,t,i){const a=t==="notes"&&!i?"files":t;return{automatic:a,active:e==="auto"?a:e}}function hn(e,t){if(!t)return null;const i=s=>s.replace(/\\/g,"/").replace(/\/+$/,""),a=i(t);let o=null;for(const s of e){const n=s.path?i(s.path):"";!n||a!==n&&!a.startsWith(`${n}/`)||(!o||n.length>o.len)&&(o={key:s.key,len:n.length})}return o?.key??null}function ge(e){const t=structuredClone(e),i=new Set(["chat-panel","memory","subchats"]),a=t.sidebars.right.stash.filter(l=>!i.has(l.type)&&l.type!=="tangu-details");t.sidebars.right.stash=[{type:"tangu-details",params:{}},...a];const o=t.dockview;if(!o?.panels)return t;const s=Object.entries(o.panels).filter(([,l])=>l.params?.__loc==="right"&&i.has(l.params?.__type)),r=Object.entries(o.panels).find(([,l])=>l.params?.__loc==="right"&&l.params?.__type==="tangu-details")?.[0]||s[0]?.[0];if(!r)return t;const u=o.panels[r];u.params={__type:"tangu-details",__loc:"right"},u.contentComponent="tangu-details";const m=new Set(s.map(([l])=>l).filter(l=>l!==r));for(const l of m)delete o.panels[l];const p=l=>{if(!(!l||typeof l!="object")){Array.isArray(l.views)&&(l.views=l.views.filter(P=>!m.has(P)),m.has(l.activeView)&&(l.activeView=l.views[0]));for(const P of Object.values(l))Array.isArray(P)?P.forEach(p):P&&typeof P=="object"&&p(P)}};p(o.grid);const g=new Set,k=l=>{if(Array.isArray(l?.data?.views)){if(!l.data.views.length)return!1;l.data.id&&g.add(l.data.id)}return Array.isArray(l?.data)?(l.data=l.data.filter(k),l.data.length>0):!0};return k(o.grid?.root),o.activeGroup&&g.size&&!g.has(o.activeGroup)&&(o.activeGroup=[...g][0]),t}function Ia(){try{if(localStorage.getItem(re("tangu_details_layout_v1"))==="1")return;const e=ot("space:tangu");if(e&&st("space:tangu",ge(e)),(localStorage.getItem("forsion_tangu_active_space")||"tangu")==="tangu"){const t=rt();t&&lt(ge(t))}localStorage.setItem(re("tangu_details_layout_v1"),"1")}catch{}}Z({"agentProfile.title":{zh:"Tangu 详情",en:"Tangu details"},"agentProfile.space":{zh:"Agents",en:"Agents"},"agentProfile.roster":{zh:"Agent 名册",en:"Agent roster"},"agentProfile.search":{zh:"搜索 Agent",en:"Search agents"},"agentProfile.skills":{zh:"技能",en:"Skills"},"agentProfile.mcp":{zh:"MCP",en:"MCP"},"agentProfile.memory":{zh:"记忆",en:"Memory"},"agentProfile.evolution":{zh:"进化",en:"Evolution"},"agentProfile.config":{zh:"配置",en:"Settings"},"agentProfile.full":{zh:"在 Agents 中打开",en:"Open in Agents"},"agentProfile.session":{zh:"当前会话",en:"Current conversation"},"agentProfile.project":{zh:"项目",en:"Project"},"agentProfile.model":{zh:"模型",en:"Model"},"agentProfile.default":{zh:"跟随默认设置",en:"Use default settings"},"agentProfile.standby":{zh:"待命",en:"Standby"},"agentProfile.working":{zh:"工作中",en:"Working"},"agentProfile.waiting":{zh:"等待你的回应",en:"Waiting for your response"},"agentProfile.offline":{zh:"离线",en:"Offline"},"agentProfile.all":{zh:"全部可用",en:"All available"},"agentProfile.selected":{zh:"仅选中的装备",en:"Selected only"},"agentProfile.none":{zh:"尚无可用项目",en:"Nothing available yet"},"agentProfile.manageSkills":{zh:"管理技能库",en:"Manage skill library"},"agentProfile.manageMcp":{zh:"管理 MCP 连接",en:"Manage MCP connections"},"agentProfile.saved":{zh:"已保存,将在下一次运行生效",en:"Saved. Changes apply to the next run."},"agentProfile.save":{zh:"保存配置",en:"Save configuration"},"agentProfile.cancel":{zh:"放弃修改",en:"Discard changes"},"agentProfile.edit":{zh:"编辑",en:"Edit"},"agentProfile.name":{zh:"名称",en:"Name"},"agentProfile.description":{zh:"简介",en:"Description"},"agentProfile.descriptionPlaceholder":{zh:"添加简介…",en:"Add a description…"},"agentProfile.avatarChange":{zh:"更换头像",en:"Change avatar"},"agentProfile.avatarRemove":{zh:"移除头像",en:"Remove avatar"},"agentProfile.avatarHint":{zh:"PNG、JPEG、GIF 或 WebP,不超过 1 MB;头像修改会立即保存。",en:"PNG, JPEG, GIF or WebP, up to 1 MB. Avatar changes are saved immediately."},"agentProfile.avatarTooLarge":{zh:"头像不能超过 1 MB。",en:"The avatar must be no larger than 1 MB."},"agentProfile.avatarReadFailed":{zh:"读取头像失败。",en:"Could not read the avatar."},"agentProfile.avatarSaved":{zh:"头像已保存",en:"Avatar saved"},"agentProfile.avatarRemoved":{zh:"头像已移除",en:"Avatar removed"},"agentProfile.prompt":{zh:"工作指令",en:"Instructions"},"agentProfile.soul":{zh:"人格",en:"Persona"},"agentProfile.thinking":{zh:"思考档位",en:"Thinking effort"},"agentProfile.approval":{zh:"审批模式",en:"Approval mode"},"agentProfile.readonly":{zh:"只读",en:"Read only"},"agentProfile.autoEdit":{zh:"自动编辑",en:"Auto edit"},"agentProfile.fullAuto":{zh:"完全自动",en:"Full auto"},"agentProfile.custom":{zh:"自定义",en:"Custom"},"agentProfile.sharedMemory":{zh:"共用默认 Agent 的记忆",en:"Share the default agent’s memory"},"agentProfile.privateMemory":{zh:"独立记忆",en:"Private memory"},"agentProfile.scopeHint":{zh:"修改此 Agent 的默认配置,适用于独立会话与项目会话;会话自身的设置优先。",en:"Edit defaults for this agent across independent and project sessions. Session overrides take precedence."},"agentProfile.noAgent":{zh:"选择或创建一个 Agent,查看它的状态与装备。",en:"Select or create an agent to inspect its status and capabilities."},"agentProfile.create":{zh:"创建 Agent",en:"Create agent"},"agentProfile.createHint":{zh:"先写下它的用途和工作指令,创建后可以在档案里继续完善能力。",en:"Give this agent a purpose and instructions. You can refine its capabilities in the profile."},"agentProfile.createInstructionsPlaceholder":{zh:"描述它如何协助你、做事时应遵守什么原则…",en:"Describe how it should help and the principles it should follow…"},"agentProfile.isDefault":{zh:"默认 Agent",en:"Default agent"},"agentProfile.actionsFor":{zh:"{name} 的操作",en:"Actions for {name}"},"agentProfile.reorder":{zh:"调整顺序",en:"Reorder"},"agentProfile.moveUp":{zh:"上移",en:"Move up"},"agentProfile.moveDown":{zh:"下移",en:"Move down"},"agentProfile.makeDefault":{zh:"设为默认",en:"Set as default"},"agentProfile.delete":{zh:"删除 Agent",en:"Delete agent"},"agentProfile.backToCurrent":{zh:"回到当前会话",en:"Back to current session"},"agentProfile.deleteFailed":{zh:"无法删除此 Agent。请检查它是否仍在运行或被设为默认。",en:"Could not delete this agent. Check whether it is running or set as default."},"agentProfile.team":{zh:"团队",en:"Team"},"agentProfile.context":{zh:"上下文",en:"Context"},"agentProfile.maxIterations":{zh:"最大运行轮数",en:"Maximum iterations"},"agentProfile.tools":{zh:"内置工具",en:"Built-in tools"},"agentProfile.denyTools":{zh:"禁用选中的工具",en:"Disable selected tools"},"agentProfile.allowTools":{zh:"仅允许选中的工具",en:"Allow selected tools only"},"agentProfile.activityAccess":{zh:"允许读取活动日志",en:"Allow activity log access"},"agentProfile.cloudSync":{zh:"跨设备同步此 Agent",en:"Sync this agent across devices"},"agentProfile.teamContext":{zh:"成员各自保留独立上下文,可在 Pin Summary 中打开子会话继续交流。",en:"Members retain their own context. Open a member in Pin Summary to continue its conversation."},"agentProfile.library":{zh:"记忆、日志与资料库",en:"Memory, journal and library"},"agentProfile.searchModels":{zh:"搜索模型或输入模型 ID",en:"Search models or enter a model ID"},"agentProfile.useModelId":{zh:"使用模型 ID:{id}",en:"Use model ID: {id}"},"agentProfile.customModelId":{zh:"自定义 ID",en:"Custom ID"},"agentProfile.noResults":{zh:"没有匹配的结果",en:"No matching results"},"agentProfile.preview":{zh:"阅读预览",en:"Preview"},"agentProfile.emptyText":{zh:"尚未填写内容",en:"No content yet"},"agentProfile.characters":{zh:"{count} 字符",en:"{count} characters"},"agentProfile.quickSettings":{zh:"运行设置",en:"Run settings"},"agentProfile.agentDefaults":{zh:"Agent 默认配置",en:"Agent defaults"},"agentProfile.sessionModel":{zh:"当前会话模型",en:"Conversation model"},"agentProfile.sessionModelHint":{zh:"此项立即保存,仅影响当前会话。",en:"Saved immediately for this conversation only."},"agentProfile.defaultsHint":{zh:"设置此 Agent 的默认行为;已有会话的单独设置优先。",en:"Set this agent’s defaults. Existing session overrides take precedence."},"agentProfile.identity":{zh:"基本信息",en:"Identity"},"agentProfile.instructions":{zh:"指令与人格",en:"Instructions and persona"},"agentProfile.permissions":{zh:"权限与工具",en:"Permissions and tools"},"agentProfile.advanced":{zh:"高级设置",en:"Advanced settings"},"agentProfile.instructionsHint":{zh:"工作指令定义任务与边界,人格定义表达方式。支持 Markdown 预览。",en:"Instructions define tasks and boundaries; persona defines communication style. Markdown preview is available."},"agentProfile.searchEquipment":{zh:"搜索名称或描述",en:"Search names or descriptions"},"agentProfile.enabledOnly":{zh:"仅看已启用",en:"Enabled only"},"agentProfile.selectedCount":{zh:"已启用 {count} / {total}",en:"{count} of {total} enabled"},"agentProfile.selectAll":{zh:"全部启用",en:"Enable all"},"agentProfile.clearAll":{zh:"全部停用",en:"Disable all"},"agentProfile.loadoutHint":{zh:"全部可用会自动包含未来新增的项目;手动勾选后仅使用选中的项目。",en:"All available includes future additions. Manual selection uses only the items you choose."},"agentProfile.loading":{zh:"正在加载能力…",en:"Loading capabilities…"},"agentProfile.unavailable":{zh:"当前不可用,保留原有选择",en:"Unavailable; existing selection retained"},"agentProfile.retry":{zh:"重新加载",en:"Retry"},"agentProfile.memoryScope":{zh:"记忆归属",en:"Memory scope"},"agentProfile.memoryScopeHint":{zh:"更改归属后保存配置,再查看对应的记忆。",en:"Save scope changes to view the corresponding memory."},"agentProfile.unsaved":{zh:"有未保存的修改",en:"Unsaved changes"},"agentProfile.saving":{zh:"正在保存…",en:"Saving…"},"agentProfile.savedShort":{zh:"配置已保存",en:"Configuration saved"},"agentProfile.currentSection":{zh:"配置分区",en:"Configuration sections"},"agentProfile.nameRequired":{zh:"请填写 Agent 名称。",en:"Enter an agent name."},"agentProfile.loadoutMode":{zh:"启用方式",en:"Availability"},"agentProfile.skillPolicy":{zh:"技能使用方式",en:"Skill use"},"agentProfile.skillPolicyHint":{zh:"自动包含新技能;自选只使用选中的技能;关闭则不使用。",en:"Automatic includes new skills. Selected uses only chosen skills. Off uses none."},"agentProfile.skillPolicy.auto":{zh:"自动使用适用技能,新技能也会加入。可为此 Agent 单独停用某项。",en:"Use relevant skills automatically, including future additions. You can disable any skill for this agent."},"agentProfile.skillPolicy.selected":{zh:"只使用勾选的技能。新技能需手动加入。",en:"Use checked skills only. Add new skills manually."},"agentProfile.skillPolicy.off":{zh:"此 Agent 暂不使用技能。",en:"This agent does not use skills."},"agentProfile.skillLegacyHint":{zh:"当前引擎只提供旧版技能清单。手动取消勾选会切换为自选;新技能不会自动加入。",en:"This engine provides the older skill list. Unchecking switches to a selected list; new skills will need to be added manually."},"agentProfile.skillCatalogUnavailable":{zh:"此引擎暂不提供技能目录。",en:"The skill catalog is unavailable on this engine."},"agentProfile.skillAuto":{zh:"自动",en:"Automatic"},"agentProfile.skillSelected":{zh:"自选",en:"Selected"},"agentProfile.skillOff":{zh:"全部关闭",en:"Off"},"agentProfile.agentSkills":{zh:"此 Agent 专属",en:"For this agent"},"agentProfile.agentSkillsHint":{zh:"只属于这个 Agent,可在此创建和编辑。",en:"Belongs to this agent. Create and edit it here."},"agentProfile.inheritedSkills":{zh:"继承自全局",en:"Inherited from global"},"agentProfile.inheritedSkillsHint":{zh:"全局原件由设置管理;这里的开关只影响此 Agent。",en:"Manage originals in Settings. Switches here affect this agent only."},"agentProfile.otherSkills":{zh:"其他可选技能",en:"Other skills"},"agentProfile.otherSkillsHint":{zh:"云端与跨 Agent 共享技能不属于本机全局原件;原有但当前未找到的选择也会保留。",en:"Cloud and shared skills are separate from local global originals. Existing selections that are currently missing are retained."},"agentProfile.sharedAgentSkill":{zh:"其他 Agent 共享",en:"Shared by another agent"},"agentProfile.localExtraSkill":{zh:"本机其他来源",en:"Other local source"},"agentProfile.cloudExtraSkill":{zh:"云端技能",en:"Cloud skill"},"agentProfile.extraChoose":{zh:"切换为自选后可单独调整",en:"Switch to selected mode to change"},"agentProfile.skillUnavailableKept":{zh:"当前目录不可见;保留原有选择。取消勾选才会移除。",en:"Not in the current catalog. Existing selection is kept until you uncheck it."},"agentProfile.addSkill":{zh:"新建技能",en:"New skill"},"agentProfile.importAgentSkill":{zh:"导入文件夹到此 Agent",en:"Import folder for this agent"},"agentProfile.noAgentSkills":{zh:"还没有专属技能。",en:"No skills for this agent yet."},"agentProfile.noGlobalSkills":{zh:"还没有可继承的全局技能。",en:"No global skills to inherit yet."},"agentProfile.skillForAgent":{zh:"{name} 对此 Agent 可用",en:"Make {name} available to this agent"},"agentProfile.skillAvailable":{zh:"可用",en:"Available"},"agentProfile.skillAgentOff":{zh:"已为此 Agent 停用",en:"Disabled for this agent"},"agentProfile.skillGlobalOff":{zh:"全局已停用",en:"Disabled globally"},"agentProfile.skillShadowed":{zh:"被此 Agent 的专属版本覆盖",en:"Overridden by this agent’s copy"},"agentProfile.skillPolicyOff":{zh:"此 Agent 的技能已关闭",en:"Skills are off for this agent"},"agentProfile.skillNotSelected":{zh:"未加入自选清单",en:"Not in the selected list"},"agentProfile.skillReadOnly":{zh:"原件只读",en:"Original is read only"},"agentProfile.skillLegacyDirectory":{zh:"旧目录名只读;可复制为合法名称的新技能",en:"Legacy folder name is read only. Copy it with a valid new name."},"agentProfile.skillFolder":{zh:"文件夹名",en:"Folder name"},"agentProfile.skillInstructions":{zh:"技能说明",en:"Skill instructions"},"agentProfile.skillFiles":{zh:"附属文件({count})",en:"Attached files ({count})"},"agentProfile.skillDetail":{zh:"技能详情",en:"Skill details"},"agentProfile.copyToAgent":{zh:"复制为此 Agent 专属",en:"Copy for this agent"},"agentProfile.copySkillHint":{zh:"复制后可独立编辑。若已有同名专属技能,请给新副本换一个文件夹名。",en:"Edit the copy independently. Choose a different folder name if this agent already has one with the same name."},"agentProfile.editGlobalSkill":{zh:"在设置中编辑全局原件",en:"Edit global original in Settings"},"agentProfile.skillDelete":{zh:"删除技能",en:"Delete skill"},"agentProfile.skillDeleteConfirm":{zh:"删除此 Agent 的「{name}」技能文件夹?若有同名全局技能,删除后将重新使用全局版本。文件夹会先备份。",en:"Delete this agent’s “{name}” skill folder? A global skill with the same name will become available again. The folder will be backed up first."},"agentProfile.skillDeleteFailed":{zh:"技能未删除。",en:"The skill was not deleted."},"agentProfile.skillEditConflict":{zh:"这份技能已在另一处修改。请关闭编辑并重新打开,避免覆盖新内容。",en:"This skill changed elsewhere. Close and reopen the editor to avoid overwriting the new content."},"agentProfile.skillRemovedElsewhere":{zh:"这份技能已在另一处删除,目录已刷新。",en:"This skill was deleted elsewhere. The catalog has been refreshed."},"agentProfile.skillEnabled":{zh:"此 Agent 现在可使用该技能",en:"This agent can now use the skill"},"agentProfile.skillDisabled":{zh:"已为此 Agent 停用该技能",en:"Skill disabled for this agent"},"agentProfile.skillCreated":{zh:"专属技能已创建",en:"Agent skill created"},"agentProfile.skillImported":{zh:"技能文件夹已导入",en:"Skill folder imported"},"agentProfile.skillSaved":{zh:"技能已保存",en:"Skill saved"},"agentProfile.skillDeleted":{zh:"技能已删除",en:"Skill deleted"},"agentProfile.skillDeletedBackup":{zh:"技能已删除;备份位于 {path}",en:"Skill deleted. Backup: {path}"},"agentProfile.skillCopied":{zh:"已复制到此 Agent",en:"Copied to this agent"},"agentProfile.saveConflict":{zh:"此 Agent 的相同设置已在另一处改变。请放弃本次草稿并重试,避免覆盖新值。",en:"The same setting changed elsewhere. Discard this draft and try again to avoid overwriting the new value."},"agentProfile.allSelectionHint":{zh:"自动包含以后新增的项目。",en:"Includes future additions automatically."},"agentProfile.manualSelectionHint":{zh:"仅使用勾选的项目。",en:"Only checked items are available."},"agentProfile.growth":{zh:"成长",en:"Growth"},"agentProfile.schedule":{zh:"日程",en:"Schedule"},"agentProfile.memoryCaption":{zh:"它记住的事实",en:"What it knows"},"agentProfile.evolutionCaption":{zh:"它总结的做法",en:"How it works"},"agentProfile.builtinSkills":{zh:"内置技能",en:"Built-in skills"},"agentProfile.scheduleLoading":{zh:"正在读取日程…",en:"Loading schedule…"},"agentProfile.scheduleLocalOnly":{zh:"日程只在本地引擎上可用。",en:"Schedules are available on the local engine only."},"agentProfile.scheduleCount":{zh:"{count} 条日程",en:"Schedule entries: {count}"},"agentProfile.scheduleAuto":{zh:"自动执行",en:"Automatic"},"agentProfile.schedulePlan":{zh:"仅规划",en:"Plan only"},"agentProfile.scheduleNoDate":{zh:"未定日期",en:"No date"},"agentProfile.scheduleLastRun":{zh:"上次执行 {time}",en:"Last run {time}"},"agentProfile.schedulePast":{zh:"已过期或未定日期({count})",en:"Past or undated ({count})"},"agentProfile.scheduleRules":{zh:"会唤醒它的自动化规则({count})",en:"Automation rules that wake it ({count})"},"agentProfile.scheduleRuleOff":{zh:"已停用",en:"Disabled"},"agentProfile.scheduleOpenCalendar":{zh:"在日历中查看",en:"View in Calendar"},"agentProfile.scheduleOpenAutomation":{zh:"在自动化中管理",en:"Manage in Automation"},"agentProfile.scheduleDeleteConfirm":{zh:"删除日程「{name}」?到点将不再执行。",en:'Delete the schedule entry "{name}"? It will no longer run.'},"agentProfile.scheduleEmpty":{zh:"还没有日程。在对话里告诉它「每天 9 点帮我整理新闻」这类定时的事,它会自己排进这里,并显示在日历上。",en:'No schedule yet. Ask it in a conversation for something timed, such as "summarize the news every day at 9", and it will add the entry here and to your Calendar.'},"agentProfile.scheduleEmptyMuse":{zh:"还没有日程。Muse 为自己安排的后续跟进会出现在这里;把它的待办交给它执行,也会排进来。两者都会显示在日历上。",en:"No schedule yet. Follow-ups Muse plans for itself appear here, and so do todos you hand over for it to carry out. Both show up in your Calendar."},"agentProfile.folder":{zh:"文件夹名",en:"Folder name"},"agentProfile.folderHint":{zh:"文件夹名也是这个 Agent 的 ID,回车改名",en:"The folder name is also this agent ID. Press Enter to rename"},"agentProfile.folderFixed":{zh:"这个 Agent 的文件夹名不可改",en:"This agent keeps its folder name"},"agentProfile.renamed":{zh:"已改名为 {slug}",en:"Renamed to {slug}"},"agentProfile.renameInvalid":{zh:"只能用小写字母、数字和连字符,且以字母或数字开头",en:"Use lowercase letters, digits and hyphens, starting with a letter or digit"},"agentProfile.renameExists":{zh:"已有同名文件夹",en:"That folder name is already taken"},"agentProfile.renameCloudSynced":{zh:"这个 Agent 同步过云端,改名会在云端留下旧文件夹;请新建一个 Agent 代替",en:"This agent has been synced to the cloud, so renaming would leave the old folder there. Create a new agent instead"},"agentProfile.renamePluginSeeded":{zh:"插件安装的 Agent 不能改文件夹名",en:"Agents installed by a plugin keep their folder name"},"agentProfile.renameBusy":{zh:"它正在会话里工作,等这轮结束再改名",en:"It is busy in a session. Rename once that run finishes"},"agentProfile.renameWarnings":{zh:"已改名为 {slug},但有几处引用没更新:{detail}",en:"Renamed to {slug}, but some references were not updated: {detail}"}});Z({"homeSlot.menuHead":{zh:"主位放哪个 Space",en:"Space in the home slot"},"homeSlot.openInNewWindow":{zh:"在新窗口中打开",en:"Open in new window"}});const He="forsion_home_slot_space",We="home";function Be(){try{return localStorage.getItem(He)||null}catch{return null}}function xa(){return Be()??We}function Ge(){const e=h.getState().spaces,t=i=>e.some(a=>a.id===i);for(const i of[xa(),We,S.defaultSpace])if(i&&t(i))return i;return e[0]?.id??null}function Ma(e){try{localStorage.setItem(He,e)}catch{}Y()}function Da({space:e,expanded:t}){const i=h(n=>n.spaces),[a,o]=le.useState(null),{t:s}=nt();return le.useEffect(()=>{if(!a)return;const n=()=>o(null);return window.addEventListener("click",n),window.addEventListener("contextmenu",n),()=>{window.removeEventListener("click",n),window.removeEventListener("contextmenu",n)}},[a]),y.jsxs("span",{className:"rb-homeslot",onContextMenu:n=>{n.preventDefault(),n.stopPropagation(),o({x:n.clientX,y:n.clientY})},children:[y.jsx(T,{space:e,expanded:t}),a&&dt.createPortal(y.jsxs(ft,{className:"ctx-menu",x:a.x,y:a.y,onClick:n=>n.stopPropagation(),children:[ce()?.openSpace&&y.jsx("button",{onClick:()=>{ce()?.openSpace?.(e.id),o(null)},children:s("homeSlot.openInNewWindow")}),y.jsx("div",{className:"ctx-head",children:s("homeSlot.menuHead")}),i.map(n=>y.jsxs("button",{onClick:()=>{Ma(n.id),o(null)},children:[n.icon?y.jsx(n.icon,{size:13}):y.jsx("span",{style:{width:13}}),Ae(n.name),n.id===e.id&&y.jsx(ut,{size:12,style:{marginLeft:"auto",opacity:.7}})]},n.id))]}),document.body)]})}function Y(){const e=Ge(),t=ct.getState().items;for(const i of h.getState().spaces){const a=`space:${i.id}`,o=i.id===e?"home":"top",s=t.find(n=>n.id===a);!s||s.side===o||q({...s,side:o,component:o==="home"?({expanded:n})=>y.jsx(Da,{space:i,expanded:n}):({expanded:n})=>y.jsx(T,{space:i,expanded:n})})}}let pe=!1;function Ca(){Y(),!pe&&(pe=!0,h.subscribe((e,t)=>{e.spaces!==t.spaces&&Y()}))}const c=()=>Q.getState(),b=()=>Me.getState(),Ea="forsion_default_space",H="__last__",W="__home__";function B(){try{return localStorage.getItem(Ea)||W}catch{return W}}function Oa(e){const t=B();return t===W?Ge()??S.defaultSpace:t===H?e:h.getState().spaces.some(i=>i.id===t)?t:S.defaultSpace}function Ta(){const e=B();if(e===H)return null;const t=e===W?Be():e;return t&&!h.getState().spaces.some(i=>i.id===t)?t:null}const ae={type:"workspace",params:{mode:"files"}},K={type:"chat",params:{followActive:!0,reuseKey:"primary"}},V={type:"workspace",params:{mode:"orbits"}},he={left:[V],right:[{type:"tangu-details",params:{}},ae,{type:"outline",params:{}}],bottom:[{type:"terminal",params:{}}]},La={id:"tangu",mini:{name:"Tangu",view:{type:"mini-tangu",params:{followActive:!0}},mainView:{type:"chat"}},name:()=>b().tr("space.tangu"),icon:_e,autoWorkspaceMode:"orbits",sidebarDefaults:he,pinned:{main:[K],left:[V],right:[{type:"tangu-details",params:{}}]},build(){c().setSidebarDefaults(he),c().openView(K.type,K.params,"main"),c().openView(V.type,V.params,"left"),c().initializeSidebar("right",!1),c().initializeSidebar("bottom",!1)}},Na={id:"agents",name:()=>b().tr("agentProfile.space"),icon:pt,sidebarDefaults:{left:[{type:"agents-roster",params:{}}],right:[],bottom:[]},pinned:{main:[{type:"agent-profile",params:{}}],left:[{type:"agents-roster",params:{}}]},build(){c().setSidebarDefaults({left:[{type:"agents-roster",params:{}}],right:[],bottom:[]}),c().openView("agent-profile",{},"main"),c().openView("agents-roster",{},"left"),c().initializeSidebar("bottom",!1),c().initializeSidebar("right",!1)}},j={type:"workspace",params:{mode:Fe}},me={left:[j],right:[ae]},Va={id:"inbox",name:()=>b().tr("space.inbox"),icon:Ie,sidebarDefaults:me,pinned:{main:[{type:"inbox-reader",params:{}}],left:[j]},autoWorkspaceMode:Fe,resizableSides:{left:!0},sideDefaultScale:{left:1.3},build(){c().setSidebarDefaults(me),c().openView("inbox-reader",{},"main"),c().openView(j.type,j.params,"left"),c().initializeSidebar("right",!1)}},qe=w("tangu"),$={type:"workspace",params:{mode:"notes"}},ye={left:[$,{type:"amadeus-search",params:{}},{type:"amadeus-tags",params:{}}],right:[...qe?[{type:"chat-panel",params:{followActive:!0}}]:[],{type:"outline",params:{}},{type:"amadeus-backlinks",params:{}},{type:"amadeus-graph",params:{}}]},ja={id:"amadeus",mini:{name:"Amadeus",view:{type:"mini-amadeus"},mainView:{type:"amadeus-editor"}},name:()=>b().tr("space.amadeus"),icon:je,sidebarDefaults:ye,pinned:{left:[$]},resizableSides:{left:!0},autoWorkspaceMode:"notes",build(){c().setSidebarDefaults(ye),c().openView("amadeus-editor",{},"main");const e=c().openView($.type,$.params,"left");c().openView("amadeus-search",{},"left"),c().openView("amadeus-tags",{},"left"),c().initializeSidebar("right",!1),e&&c().activateLeaf(e.id)}},Se={left:[{type:"coding-navigation",params:{}}],right:[ae],bottom:[{type:"terminal",params:{}}]},$a={id:"coding",name:()=>b().tr("space.coding"),icon:Gt,sidebarDefaults:Se,pinned:{main:[{type:"code-studio",params:{}}],left:[{type:"coding-navigation",params:{}}]},resizableSides:{left:!0},sideDefaultScale:{left:1},build(){c().setSidebarDefaults(Se),b().selectNewChatAgent?.("coding"),c().openView("code-studio",{},"main"),c().openView("coding-navigation",{},"left"),c().initializeSidebar("right",!1),c().initializeSidebar("bottom",!1)}},R={type:"workspace",params:{mode:Ne}},ve={left:[R],right:[]},Ra={id:"automation",autoWorkspaceMode:Ne,name:()=>b().tr("space.automation"),icon:qt,sidebarDefaults:ve,pinned:{main:[{type:"automation-detail",params:{}}],left:[R]},resizableSides:{left:!0,right:!0},build(){c().setSidebarDefaults(ve),c().openView("automation-detail",{},"main"),c().openView(R.type,R.params,"left")}},ke={left:[],right:[]},Ua={id:"public",name:()=>b().tr("space.public"),icon:ga,sidebarDefaults:ke,pinned:{main:[{type:"public-view",params:{}}]},build(){c().setSidebarDefaults(ke),c().openView("public-view",{},"main")}},Ke=S.nativeFeatures===void 0||w("amadeus"),D=[...vt()&&M("home")?[gt]:[],...w("tangu")?[La,Na]:[],...kt()?[Va]:[],...w("amadeus")&&xe()&&Ke?[ja]:[],...Pt()&&M("calendar")?[ht]:[],...S.nativeFeatures===void 0&&S.spaces.includes("coding")&&window.tangu?.codePreviewServe?[$a]:[],...bt()&&M("artificial")?[mt]:[],...wt()&&M("image-studio")?[yt]:[],...w("automation")&&window.tangu?.backendStatus?[Ra]:[],...zt()&&M("muse")?[St]:[],...w("public")&&(window.tangu?.connectPublish||window.amadeusCollab)?[Ua]:[]];function mn(){w("tangu")&&Ia();for(const t of D)ee(t),q({id:`space:${t.id}`,side:"top",component:({expanded:i})=>y.jsx(T,{space:t,expanded:i})});if(Ca(),new URLSearchParams(location.search).get("window")==="mini")return;const e=h.getState().activeSpaceId;if(!De&&D.length&&!D.some(t=>t.id===e)){const t=D.some(i=>i.id===S.defaultSpace)?S.defaultSpace:D[0].id;h.setState({activeSpaceId:t})}try{F()==="main"&&localStorage.getItem("forsion_pinned_layout_v1")!=="1"&&(de(),localStorage.setItem("forsion_pinned_layout_v1","1"))}catch{}try{F()==="main"&&localStorage.getItem("forsion_image_studio_layout_v2")!=="1"&&(de("image-studio"),localStorage.setItem("forsion_image_studio_layout_v2","1"))}catch{}try{if(localStorage.getItem("forsion_rightpanel_collapse_v1")!=="1"){I("space:amadeus"),I("space:tangu");const t=localStorage.getItem("forsion_tangu_active_space");(t==="amadeus"||t==="tangu")&&E(),localStorage.setItem("forsion_rightpanel_collapse_v1","1")}}catch{}if(xe()&&Ke){At();try{localStorage.getItem("amadeus_layout_v2")!=="1"&&(I("space:amadeus"),localStorage.getItem("forsion_tangu_active_space")==="amadeus"&&E(),localStorage.setItem("amadeus_layout_v2","1")),qe&&localStorage.getItem("amadeus_layout_v3")!=="1"&&(I("space:amadeus"),localStorage.getItem("forsion_tangu_active_space")==="amadeus"&&E(),localStorage.setItem("amadeus_layout_v3","1"))}catch{}}}Z({"spaces.delete":{zh:"删除 Space…",en:"Delete Space…"}});const ne=["tangu","inbox","amadeus","calendar","muse"],Fa={bot:_e,inbox:Ie,mail:la,"notebook-text":je,"book-open":Qt,briefcase:aa,"calendar-days":Ft,"message-circle":Ut,folder:Zt,"folder-open":Rt,"file-text":$t,star:Xt,heart:sa,home:jt,target:va,zap:Vt,globe:Nt,music:da,image:Lt,video:Pa,code:ia,terminal:Yt,"layout-grid":Jt,sparkles:Tt,boxes:Ve,"list-tree":Kt,server:ya,"server-cog":ha},Ha=/^data:image\/(png|svg\+xml);base64,[A-Za-z0-9+/=]+$/;function Je(e){const t=`url("${e}") center / contain no-repeat`;return e.startsWith("data:image/svg+xml")?({size:i=18})=>y.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",flex:"none",width:i,height:i,background:"currentColor",mask:t,WebkitMask:t}}):({size:i=18})=>y.jsx("img",{"aria-hidden":"true",alt:"",src:e,width:i,height:i,draggable:!1,style:{flex:"none",borderRadius:"22%",objectFit:"cover"}})}const d=()=>Q.getState(),x=()=>Me.getState(),O=new Map,G=new Map,X=new Map,U=new Map;let Pe=!1;const Ye=new Set;let C=!1,Xe=!1;const Wa=e=>O.has(e);function Ba(){Xe=!0;const e=h.subscribe((t,i)=>{t.activeSpaceId!==i.activeSpaceId&&(e(),C=!0)})}function be(e){return()=>typeof e.name=="string"?e.name:(it()==="zh"?e.name.zh??e.name.en:e.name.en??e.name.zh)??e.id}const _=e=>e.map(t=>({type:t.type,params:t.params??{}})),we="forsion_space_recipe_ver";function Ze(e){if(F()==="mini"||!e.version)return;let t={};try{t=JSON.parse(localStorage.getItem(we)||"{}")}catch{}if((typeof t!="object"||!t)&&(t={}),t[e.id]!==e.version){I(te(e.id)),Ye.add(e.id),De===e.id?E():h.getState().activeSpaceId===e.id&&Q.getState().resetLayout(),t[e.id]=e.version;try{localStorage.setItem(we,JSON.stringify(t))}catch{}}}function Qe(e,t){const i={left:_(e.layout.left),right:_(e.layout.right),bottom:_(e.layout.bottom??[])};return{id:e.id,mini:e.mini?{...e.mini,name:e.mini.name?be({...e,name:e.mini.name}):void 0}:void 0,name:be(e),icon:t?Je(t):Fa[e.icon??""]??Ve,sidebarDefaults:i,pinned:{main:_(e.layout.main.filter(a=>a.pinned)),left:_(e.layout.left.filter(a=>a.pinned)),right:_(e.layout.right.filter(a=>a.pinned))},bottomSpan:e.layout.bottomSpan,build(){d().setSidebarDefaults(i);const a=[];for(const o of wa(e.layout.main)){let s=null;if(o.mode==="first")s=d().openView(o.panel.type,o.panel.params??{},"main");else if(o.mode==="tab")s=d().openView(o.panel.type,o.panel.params??{},"main",{newTab:!0});else{const n=a[o.from];n&&d().activateLeaf(n.id);const r=n?d().splitActive(o.direction):null;s=r?d().navigateLeaf(r.id,o.panel.type,o.panel.params??{}):d().openView(o.panel.type,o.panel.params??{},"main",{newTab:!0})}s&&a.push(s)}a.length>1&&a[0]&&d().activateLeaf(a[0].id);for(const o of["left","right"]){for(const s of i[o])d().openView(s.type,s.params,o);i[o].length||d().initializeSidebar(o,!1)}if(Ht())for(const o of i.bottom??[])d().openView(o.type,o.params,"bottom")}}}function ie(e,t=e.id,i){Ze(e);const a=Qe(e,i);ee(a),O.set(e.id,t),q({id:`space:${e.id}`,side:"top",component:({expanded:o})=>y.jsx(T,{space:a,expanded:o}),menu:()=>[{label:x().tr("spaces.delete"),onClick:()=>{window.confirm(x().tr("spaces.deleteConfirm",{name:Ae(a.name)}))&&et(e.id)}}]})}function ze(e,t,i){Ze(e);const a=Qe(e,i);ee(a),G.set(e.id,t),q({id:`space:${e.id}`,side:"top",component:({expanded:o})=>y.jsx(T,{space:a,expanded:o})})}function Ga(e){h.getState().activeSpaceId===e&&L("tangu"),Oe(e),Te(`space:${e}`),G.delete(e),X.delete(e),U.delete(e)}let J=Promise.resolve();function qa(){return J=J.catch(()=>{}).then(Ja),J}function Ka(){if(C||F()!=="main"||xt==="mobile")return;const e=Oa(Ot),t=h.getState();if(!t.spaces.some(n=>n.id===e))return;const i=Ta()===null,a=i&&Xe&&!!d().api;if(B()===H){let n=null;try{n=localStorage.getItem("forsion_tangu_active_space")}catch{}if(n!==null&&n!==e){C=!0;return}}const o=Ye.delete(e)||Mt()&&t.activeSpaceId!==e,s=()=>{const n=Le();n&&(d().setSidebarDefaults(n.sidebarDefaults),d().setSideProfile(n.id,n.resizableSides??{},n.sideDefaultScale,n.bottomSpan),d().setPinned(n.pinned))};if(o&&!a){E(),t.activeSpaceId!==e&&fe(e),s(),d().resetLayout(),i&&(C=!0);return}if(t.activeSpaceId!==e)if(B()===H&&!a){const n=Dt();if(fe(e),s(),Bt()||n!==null&&n!==e){const r=te(e);Ct(r)&&d().applyNamed(r)?(d().ensurePinned(),d().saveCurrent()):d().resetLayout()}else d().realignRegions?.()}else L(e);else d().sideProfileKey!==e&&(s(),d().realignRegions?.());i&&(C=!0)}async function Ja(){const e=await window.tangu?.spacesList?.().catch(()=>null);if(!e)return;const t=await window.tangu?.appVersion?.().catch(()=>null)??null,i=new Set(Et()),a=new Map;for(const{slug:n,json:r,plugin:u,iconUrl:m}of e){const p=typeof m=="string"&&Ha.test(m)?m:void 0;if(u&&i.has(u))continue;const g=za(r,{isViewRegistered:k=>!!Wt(k),appVersion:t,reservedIds:ne});if(!g.ok){console.warn(`[spaces] 跳过 ${n}: ${g.error}`);continue}a.has(g.spec.id)||a.set(g.spec.id,{spec:g.spec,dirSlug:n,plugin:u,raw:r,iconUrl:p})}for(const[n,r]of[...G]){const u=a.get(n);(!u||u.plugin!==r||X.get(n)!==u.raw)&&Ga(n)}const o=new Set(h.getState().spaces.map(n=>n.id));for(const[n,r]of a){if(o.has(n)){r.plugin&&G.get(n)===r.plugin&&U.get(n)!==r.iconUrl&&(ze(r.spec,r.plugin,r.iconUrl),U.set(n,r.iconUrl));continue}o.add(n),r.plugin?(ze(r.spec,r.plugin,r.iconUrl),X.set(n,r.raw),U.set(n,r.iconUrl)):ie(r.spec,r.dirSlug,r.iconUrl)}!Pe&&S.spaces.length===0&&h.getState().spaces.some(n=>n.id===S.defaultSpace)&&(Pe=!0,h.getState().activeSpaceId!==S.defaultSpace?L(S.defaultSpace):d().mainTabs.length===0&&d().resetLayout());const s=Le();s&&d().setSidebarDefaults(s.sidebarDefaults)}const Ya={workspace:["mode"],chat:["followActive","reuseKey"]},Xa=new Set(["launcher","wsfile","sidebar-empty","home"]);async function Za(e){const t=d().api;if(!t||!window.tangu?.spacesSave)return;const i={main:[],left:[],right:[]},a=new Set;for(const r of t.panels){const u=r.params??{},m=Aa(u.__loc);if(!m)continue;const p=typeof u.__type=="string"?u.__type:"";if(!p||Xa.has(p)||a.has(`${m}:${p}`))continue;a.add(`${m}:${p}`);const g={};for(const k of Ya[p]??[])u[k]!==void 0&&(g[k]=u[k]);i[m].push(Object.keys(g).length?{type:p,params:g}:{type:p})}i.main.length||i.main.push({type:"chat",params:{followActive:!0,reuseKey:"primary"}});const o=new Set([...ne,...h.getState().spaces.map(r=>r.id)]),s=Ue(Re(e),o),n={id:s,name:e,icon:"boxes",layout:i};await window.tangu.spacesSave(s,JSON.stringify(n,null,2)),Ce("space.save"),Ee("space.save",{id:s}),ie(n),x().toast(x().tr("spaces.saved",{name:e}))}async function Qa(e){if(!window.tangu?.spacesSave)return;const t=new Set([...ne,...h.getState().spaces.map(o=>o.id)]),i=Ue(Re(e)||"space",t),a={id:i,name:e,icon:"boxes",layout:{main:[{type:"launcher"}],left:[],right:[]}};await window.tangu.spacesSave(i,JSON.stringify(a,null,2)),Ce("space.save"),Ee("space.save",{id:i,blank:!0}),ie(a),L(i),x().toast(x().tr("spaces.saved",{name:e}))}async function et(e){const t=O.get(e);if(!t)return!1;try{await window.tangu?.spacesDelete?.(t)}catch(i){return _t(It(i),!0),!1}return tt(e),window.tangu?.requestMainAction?.("space-removed",e),!0}function tt(e){O.has(e)&&(h.getState().activeSpaceId===e&&L("tangu"),Oe(e),Te(`space:${e}`),I(te(e)),O.delete(e))}const yn=Object.freeze(Object.defineProperty({__proto__:null,createBlankSpace:Qa,deleteUserSpace:et,forgetUserSpace:tt,imageIcon:Je,isUserSpace:Wa,loadUserSpaces:qa,parkOnStartupFallback:Ba,saveCurrentAsSpace:Za,settleAsyncStartupSpace:Ka},Symbol.toStringTag,{value:"Module"}));export{Ke as A,ia as C,Ea as D,sa as H,Fe as I,H as L,la as M,je as N,ga as R,ya as S,va as T,Pa as V,da as a,W as b,Ma as c,et as d,gn as e,tt as f,mn as g,Ge as h,Wa as i,Oa as j,Ta as k,qa as l,Ka as m,Qa as n,Za as o,Ba as p,pn as r,B as s,yn as u,hn as w};