@forsion/unit 2.12.2 → 2.13.0

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 +987 -495
  4. package/package.json +1 -1
  5. package/release.json +5 -5
  6. package/web/assets/ArtificialView-BSv3Mx5C.js +1 -0
  7. package/web/assets/{AutomationBuilder-sxWdUa0L.js → AutomationBuilder-BuiHtVB-.js} +1 -1
  8. package/web/assets/CalendarConfigView-BJtG6cqN.js +1 -0
  9. package/web/assets/CalendarView-C-FX1RED.js +1 -0
  10. package/web/assets/CapabilityMenu-kx1TIJYN.js +1 -0
  11. package/web/assets/{CheckboxInput-BsaoUHZ0.js → CheckboxInput-eW7xdiRS.js} +1 -1
  12. package/web/assets/Chrome-B77-lQyh.js +1 -0
  13. package/web/assets/{CodeView-j065KtVh.js → CodeView-Df3AiSIi.js} +3 -3
  14. package/web/assets/DashboardGridView-MlO1dpuo.js +17 -0
  15. package/web/assets/{EventCard-BmDQkEj9.js → EventCard-CDmeCbI8.js} +1 -1
  16. package/web/assets/ExcalidrawCanvas-D9vkBh_5.js +1 -0
  17. package/web/assets/{FloatingToc-CENybkAA.js → FloatingToc-tART_jC4.js} +1 -1
  18. package/web/assets/HomepageView-Trqmd3RV.js +1 -0
  19. package/web/assets/ImageStudioPanels-BfCVTnKC.js +3 -0
  20. package/web/assets/ImageStudioView-KJhx0wJk.js +1 -0
  21. package/web/assets/InlineFiles-BHwivGbQ.js +1 -0
  22. package/web/assets/MarkdownBlock--__nPQGh.css +1 -0
  23. package/web/assets/MarkdownBlock-D8LgHFYY.js +58 -0
  24. package/web/assets/ModelPill-DrW2cG0l.js +2 -0
  25. package/web/assets/MuseLibraryView-CW78Uivf.js +2 -0
  26. package/web/assets/{MuseView-d-iBk3sc.js → MuseView-Cb6R_l4i.js} +2 -2
  27. package/web/assets/{PageHistoryPanel-CR-k1AM7.js → PageHistoryPanel-BQs9IWTP.js} +2 -2
  28. package/web/assets/PdfAnnotator-BFTBkxvO.js +505 -0
  29. package/web/assets/PdfAnnotator-C_kglLCA.css +1 -0
  30. package/web/assets/{ProductView-u2aezVsl.js → ProductView-mB-S0j81.js} +1 -1
  31. package/web/assets/RightPanel-BVZeVO3c.js +4 -0
  32. package/web/assets/RunLocationPicker-BE5mxnab.css +1 -0
  33. package/web/assets/RunLocationPicker-CyVa0RJa.js +38 -0
  34. package/web/assets/{SidebarRow-BuSkKH5q.js → SidebarRow-D77yrSLf.js} +1 -1
  35. package/web/assets/{SketchCard-D87GADyG.js → SketchCard-CAAr_cqF.js} +5 -5
  36. package/web/assets/{StudioGuestSurface-BijU_EEb.js → StudioGuestSurface-DthpuVGg.js} +1 -1
  37. package/web/assets/{TodoListView-DPPVpPUn.js → TodoListView-C3ZkMIIf.js} +1 -1
  38. package/web/assets/{Tooltip-DY4ISA-e.js → Tooltip-D9Dt9ZTr.js} +1 -1
  39. package/web/assets/UnifiedPage-C75y-MKT.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-D5wZKuag.js} +3 -3
  42. package/web/assets/{amadeus-manual.zh--7D5TS8X.js → amadeus-manual.zh-Br5fidrj.js} +3 -3
  43. package/web/assets/{appStore-Dg9WALEA.js → appStore-B1ynyt42.js} +186 -120
  44. package/web/assets/appStore-BC_CQv-L.css +1 -0
  45. package/web/assets/{arrow-up-right-CpQs92mu.js → arrow-up-right-R10mR2I6.js} +1 -1
  46. package/web/assets/{astryxBridge-BZhaZPs4.js → astryxBridge-CU_kQTEl.js} +3 -3
  47. package/web/assets/automationListSource-B8EIRmDW.js +1 -0
  48. package/web/assets/book-open-DBJ3dDpw.js +1 -0
  49. package/web/assets/{calendarNavStore-C7fGRpoH.js → calendarNavStore-DGvUlU5N.js} +1 -1
  50. package/web/assets/{canvasPrefs-BeG4oEgP.js → canvasPrefs-DwL_OAAo.js} +1 -1
  51. package/web/assets/chatBoxSurface-Lq-2qfd3.js +1 -0
  52. package/web/assets/{circle-question-mark-WL3vbp-Z.js → circle-question-mark-HPZpZQxd.js} +1 -1
  53. package/web/assets/{circle-x-D7s-M5sB.js → circle-x-BZfe7d6S.js} +1 -1
  54. package/web/assets/{client-BSKpsyAw.js → client-DxGbwZLy.js} +1 -1
  55. package/web/assets/{code-xml-BALV9u_c.js → code-xml-joKQ-qGS.js} +1 -1
  56. package/web/assets/{codeStudioStore-C2mWfm32.js → codeStudioStore-C7rGKlOC.js} +1 -1
  57. package/web/assets/codingNavigation-CZB4v1ZW.css +1 -0
  58. package/web/assets/codingNavigation-CjeWG4xm.js +47 -0
  59. package/web/assets/{create-4xUyKtAF.js → create-BjBRKATq.js} +4 -4
  60. package/web/assets/dashboardSurface-Cojgf_-U.js +1 -0
  61. package/web/assets/{deskCapture-Df701U8L.js → deskCapture-DnGWk1iq.js} +1 -1
  62. package/web/assets/{diff2html-BV-zCH4d.js → diff2html-Cd1rVi_Z.js} +1 -1
  63. package/web/assets/{docx-preview-DW4IyU_Q.js → docx-preview-CK0k1mUD.js} +1 -1
  64. package/web/assets/{emoji-DGaxpCIu.js → emoji-Cjm3bKiF.js} +1 -1
  65. package/web/assets/floatingTocSurface-Dd1pT5j5.js +1 -0
  66. package/web/assets/foldActions-Dm-uAt3L.js +1 -0
  67. package/web/assets/folder-CvZyHIgb.js +1 -0
  68. package/web/assets/{folder-plus-D1TDb7k9.js → folder-plus-BRScGQ9m.js} +1 -1
  69. package/web/assets/gestures-CZQVefU0.js +1 -0
  70. package/web/assets/{hand-Crrw-nSn.js → hand-D3QspKYq.js} +1 -1
  71. package/web/assets/{hard-drive-BbyVSbfP.js → hard-drive-BQsHSala.js} +1 -1
  72. package/web/assets/i18n-ecQQxiMQ.css +1 -0
  73. package/web/assets/i18n.generated-BZRHO2Nc.js +15 -0
  74. package/web/assets/imageStudio--KF9gwHA.css +1 -0
  75. package/web/assets/imageStudio-Cy3_437s.js +2 -0
  76. package/web/assets/{index-CflzrdSt.js → index-0AYHATDX.js} +1 -1
  77. package/web/assets/{index-Dg9oixs4.js → index-1FhRiJ_X.js} +1 -1
  78. package/web/assets/{index-CqyM6tQ0.js → index-4E9nrhwf.js} +1 -1
  79. package/web/assets/{index-Cmr7gVZQ.js → index-8ag1K7AZ.js} +1 -1
  80. package/web/assets/{index-SZ5waGAq.js → index-9BmmlTjY.js} +1 -1
  81. package/web/assets/{index-CzM-C2Sd.js → index-B5GxvbNm.js} +1 -1
  82. package/web/assets/{index-DKhyDkGB.js → index-BPhwi4-v.js} +1 -1
  83. package/web/assets/index-BaRySZ-M.js +1 -0
  84. package/web/assets/{index-Brik2pf9.js → index-BcVGjCAJ.js} +1 -1
  85. package/web/assets/{index-OHi69jDq.js → index-BdZaheMZ.js} +1 -1
  86. package/web/assets/{index-D1f_JwPH.js → index-BgDZGDqt.js} +1 -1
  87. package/web/assets/{index-C6GJulug.js → index-BgtO11q8.js} +1 -1
  88. package/web/assets/{index-CF4RV4mh.js → index-Bh_nLVTc.js} +90 -90
  89. package/web/assets/{index-DjzSBM0U.js → index-BnWj6ggb.js} +1 -1
  90. package/web/assets/{index-BRW82CsP.js → index-Bpc3R3DS.js} +1 -1
  91. package/web/assets/{index-BCZZVJ_w.js → index-C9yo04Ck.js} +1 -1
  92. package/web/assets/{index--drOLtq7.js → index-CcOag8eb.js} +1 -1
  93. package/web/assets/{index-Czu_bbDM.js → index-D0FLFLfh.js} +1 -1
  94. package/web/assets/{index-KL5Rj9kP.js → index-D6mpAJ9S.js} +1 -1
  95. package/web/assets/{index-tAXBa_fN.js → index-DElrDw66.js} +1 -1
  96. package/web/assets/{index-DUWR2nZi.js → index-DJLWTPtq.js} +1 -1
  97. package/web/assets/{index-gPSbFSUn.js → index-DNE_PBJt.js} +1 -1
  98. package/web/assets/index-Dj-PygjB.js +1 -0
  99. package/web/assets/{index-BYsdKR_1.js → index-Dkd-nl1u.js} +1 -1
  100. package/web/assets/{index-C7U6T-k8.js → index-GjLSlygt.js} +1 -1
  101. package/web/assets/{invitePage-lLQ-e0pj.js → invitePage-B4gMvEKi.js} +1 -1
  102. package/web/assets/{ipc-DQOD2UKk.js → ipc-CPhL3bPp.js} +1 -1
  103. package/web/assets/{jszip.min-DZxV9uZ_.js → jszip.min-DAJT9RUA.js} +1 -1
  104. package/web/assets/launchpad-C2c1MSVX.css +1 -0
  105. package/web/assets/{layout-grid-B_pjJwz4.js → layout-grid-DfUfnvDS.js} +1 -1
  106. package/web/assets/{linkFollow-C0_3k_PC.js → linkFollow-C6PHGUxk.js} +5 -5
  107. package/web/assets/{list-tree-DkAJYEXd.js → list-tree-DaGpnIYu.js} +1 -1
  108. package/web/assets/{listFold-BsOVn9UZ.js → listFold-Q_8mh5ZG.js} +1 -1
  109. package/web/assets/{lock-BnGHxjeE.js → lock-DQ_yL4nF.js} +1 -1
  110. package/web/assets/{log-out-DBuMeqik.js → log-out-DFwTeh2X.js} +1 -1
  111. package/web/assets/main-CwqZ_ymb.js +19 -0
  112. package/web/assets/markdownEditorSurface-e_oMhqx-.js +3 -0
  113. package/web/assets/mdMarkStore-DjN4bf1T.js +2 -0
  114. package/web/assets/{mdMarks-Bq7Hl-4C.js → mdMarks-cmL6vzR-.js} +1 -1
  115. package/web/assets/{message-square-plus-BiAZAvcw.js → message-square-plus-CEHkduIL.js} +1 -1
  116. package/web/assets/{messages-BH5MfQdZ.js → messages-CBtmbpur.js} +1 -1
  117. package/web/assets/minus-BUT48dAC.js +1 -0
  118. package/web/assets/mobileEntry-qR7BAROr.js +13 -0
  119. package/web/assets/nativeDownload-CziEyW_p.js +1 -0
  120. package/web/assets/{pageChrome-xLNdFaSg.css → pageChrome-CovzZPdb.css} +1 -1
  121. package/web/assets/pageChrome-DFz_AAzZ.js +1 -0
  122. package/web/assets/{pageTree-CZH2J6cc.js → pageTree-yVO1_fSy.js} +2 -2
  123. package/web/assets/{pen-tool-lkmBqliH.js → pen-tool-uxsFELYC.js} +1 -1
  124. package/web/assets/{pencil-Cvk91P_Z.js → pencil-BSbra1Ra.js} +1 -1
  125. package/web/assets/pluginChat-BMFnf_j2.js +2 -0
  126. package/web/assets/{redo-2-DSi54z4e.js → redo-2-BK5LMNa5.js} +1 -1
  127. package/web/assets/{rotate-ccw-CUlnplr0.js → rotate-ccw-HedfU4na.js} +1 -1
  128. package/web/assets/{sharePage-MM6UpPJ9.js → sharePage-CpzDpuU1.js} +2 -2
  129. package/web/assets/{shareViewer-CDZ8lTdy.js → shareViewer-BwzH2bIs.js} +1 -1
  130. package/web/assets/{star-CwDiGyUW.js → star-CgYon3z4.js} +1 -1
  131. package/web/assets/tableSurface-CmDwnKnd.js +1 -0
  132. package/web/assets/{terminal-DIXogYJY.js → terminal-krsPf1mc.js} +1 -1
  133. package/web/assets/{terminalView-B3aZSsrQ.js → terminalView-4e2_u5_I.js} +1 -1
  134. package/web/assets/theme-C6D3tMGV.css +1 -0
  135. package/web/assets/type-GJYLEhY-.js +1 -0
  136. package/web/assets/{undo-2-tUKCv5Gs.js → undo-2-DCTs4Ro4.js} +1 -1
  137. package/web/assets/{unitAccount-D8lVwaaT.js → unitAccount-D3xjX3cu.js} +1 -1
  138. package/web/assets/{unitBridge-D547ublk.js → unitBridge-D5JcIkAP.js} +1 -1
  139. package/web/assets/{unitCloudTransport-BVF6lVp4.js → unitCloudTransport-B44L3x6M.js} +1 -1
  140. package/web/assets/{unitOwnerAccess-BfnEjsZb.js → unitOwnerAccess-CRUHWGpf.js} +1 -1
  141. package/web/assets/{unitShim-DxetRgmP.js → unitShim-_VzxvdEG.js} +3 -3
  142. package/web/assets/{upload-BbeAsMuD.js → upload-MVVRQtkj.js} +1 -1
  143. package/web/assets/userSpaces-CI4eqEgh.js +1 -0
  144. package/web/assets/viewportLock-BH26xHQO.js +611 -0
  145. package/web/assets/viewportLock-IP1zaVkz.css +1 -0
  146. package/web/assets/{workflow-DuoVRSSX.js → workflow-DzeW9OXR.js} +1 -1
  147. package/web/assets/{zoom-in-hr5bRpDL.js → zoom-in-CovPsw4g.js} +1 -1
  148. package/web/index.html +212 -13
  149. package/web/assets/ArtificialView-B4ESD4iK.js +0 -1
  150. package/web/assets/CalendarConfigView-cCfo_EvZ.js +0 -1
  151. package/web/assets/CalendarView-wgLapctk.js +0 -1
  152. package/web/assets/CapabilityMenu-BQBsM638.js +0 -1
  153. package/web/assets/ChatView-BIUk0OJd.css +0 -1
  154. package/web/assets/ChatView-C-jCJnyS.js +0 -47
  155. package/web/assets/Chrome-CwFiDmre.js +0 -1
  156. package/web/assets/DashboardGridView-DXqe0vPd.js +0 -17
  157. package/web/assets/ExcalidrawCanvas-C3egkikA.js +0 -1
  158. package/web/assets/HomepageView-CRdhjLXu.js +0 -1
  159. package/web/assets/ImageStudioPanels-Dke7xf8E.js +0 -3
  160. package/web/assets/ImageStudioView-g38V8gaj.js +0 -1
  161. package/web/assets/InlineFiles-C_hjvn3u.js +0 -1
  162. package/web/assets/MarkdownBlock-DIjYEhTK.js +0 -56
  163. package/web/assets/ModelPill-BPlgovPo.js +0 -1
  164. package/web/assets/MuseLibraryView-CenyTTim.js +0 -2
  165. package/web/assets/PdfAnnotator-CGzC_o1Q.css +0 -1
  166. package/web/assets/PdfAnnotator-D79ip27w.js +0 -560
  167. package/web/assets/RightPanel-C3OJTIqT.js +0 -4
  168. package/web/assets/RunLocationPicker-BNcZ7KKF.css +0 -1
  169. package/web/assets/RunLocationPicker-CTYXUH2z.js +0 -34
  170. package/web/assets/UnifiedPage-CKNtVD_n.js +0 -57
  171. package/web/assets/UnifiedPage-DX_sTpyZ.css +0 -1
  172. package/web/assets/appStore-Di8LXuJ9.css +0 -1
  173. package/web/assets/automationListSource-DP5xZBxo.js +0 -1
  174. package/web/assets/chatBoxSurface-zvcyfrxE.js +0 -1
  175. package/web/assets/dashboardSurface-CFTH5z4c.js +0 -1
  176. package/web/assets/ellipsis-r1EcXsFq.js +0 -1
  177. package/web/assets/floatingTocSurface-C6RJ6i41.js +0 -1
  178. package/web/assets/foldActions-B7KByFdN.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 +0,0 @@
1
- import{r as G,R as ft,co as gt,t as E,j as n,d as u,u as K,cp as xt,cq as bt}from"./index-CF4RV4mh.js";import{z as pe,qx as yt,Z as vt,eM as kt,aM as qe,jz as Xe,eN as Ze,dw as St,qy as ye,qz as Te,qA as ve,qB as wt,qC as Et,qD as Ct,dN as Ae,bp as ke,qE as jt,qF as Se}from"./appStore-Dg9WALEA.js";import{R as It}from"./client-BSKpsyAw.js";import{P as Nt}from"./pen-tool-lkmBqliH.js";import{H as Ge,P as Lt}from"./pen-line-m6_HvWZ9.js";import{P as Je}from"./pencil-Cvk91P_Z.js";import{F as Pt}from"./frame-_xBVYe3P.js";import{T as Mt}from"./type-Cqoabh7H.js";import{M as Qe}from"./minus-Cyv1YzOU.js";import{H as zt}from"./hand-Crrw-nSn.js";import{L as Rt}from"./lock-BnGHxjeE.js";import"./nativeDownload-D-f1_L2S.js";import"./ipc-DQOD2UKk.js";const Ot=[["path",{d:"m11 10 3 3",key:"fzmg1i"}],["path",{d:"M6.5 21A3.5 3.5 0 1 0 3 17.5a2.62 2.62 0 0 1-.708 1.792A1 1 0 0 0 3 21z",key:"p4q2r7"}],["path",{d:"M9.969 17.031 21.378 5.624a1 1 0 0 0-3.002-3.002L6.967 14.031",key:"wy6l02"}]],Tt=pe("brush",Ot);const At=[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z",key:"1f1r0c"}]],et=pe("diamond",At);const Ft=[["path",{d:"M12.67 19a2 2 0 0 0 1.416-.588l6.154-6.172a6 6 0 0 0-8.49-8.49L5.586 9.914A2 2 0 0 0 5 11.328V18a1 1 0 0 0 1 1z",key:"18jl4k"}],["path",{d:"M16 8 2 22",key:"vp34q"}],["path",{d:"M17.5 15H9",key:"1oz8nu"}]],Dt=pe("feather",Ft);const Bt=[["path",{d:"M22 2 2 22",key:"y4kqgn"}]],Ht=pe("slash",Bt),Ee="amx.boardUiMode",se=new Set,Wt=["full","compact"];let le=null;const ie=()=>{if(le)return le;try{const e=localStorage.getItem(Ee);if(e&&Wt.includes(e))return e;if(localStorage.getItem("amx.boardCompact")==="1")return"compact"}catch{}return"compact"},_t=e=>{le=e;try{localStorage.setItem(Ee,e)}catch{}for(const t of se)t()},$t=e=>(se.add(e),()=>se.delete(e));typeof window<"u"&&window.addEventListener("storage",e=>{if(e.key===Ee){le=null;for(const t of se)t()}});G({"boardengine.assetLoadFailed":{zh:"画板引擎资源加载失败:{url}(自托管副本缺失?重跑 npm run postinstall)",en:"Whiteboard engine assets failed to load: {url} (self-hosted copy missing? Re-run npm run postinstall)"},"boardengine.libMissing":{zh:"画板引擎已加载但没挂上 ExcalidrawLib",en:"Whiteboard engine loaded but did not expose ExcalidrawLib"}});const Fe={getPreferredUIMode:ie,settings:{get desktopUIMode(){return ie()},tabletUIMode:"compact",phoneUIMode:"mobile",disableContextMenu:!1,disableDoubleClickTextEditing:!1,penModeCrosshairVisible:!0,penModeDoubleTapEraser:!0,penModeSingleFingerPanning:!0,syncElementLinkWithText:!1,zoomMax:30,zoomMin:.1,zoomStep:.05,zoomToFitMaxLevel:2},excalidrawConfig:{areaLimit:16777216,widthHeightLimit:32767},getObsidianDevice:()=>{const e=navigator.userAgent,t=/Android/i.test(e),r=/iPad|iPhone|iPod/.test(e)||/Mac/.test(e)&&"ontouchend"in document,a=t||r,s=a&&Math.min(screen.width,screen.height)<600;return{isDesktop:!a,isPhone:s,isTablet:a&&!s,isMobile:a,isMacOS:/Mac/.test(e)&&!r,isWindows:/Win/.test(e),isLinux:/Linux/.test(e)&&!t,isIOS:r,isAndroid:t}},getHighlightColor:()=>{},getMermaid:async()=>null,loadFontFromFile:async()=>null,activeExcalidrawView:null,attachInlineLinkSuggester:()=>({destroy:()=>{}}),runAction:()=>{},getLabel:e=>e},Y=globalThis;Y.React=ft;Y.ReactDOM=Object.assign({},yt,It);Y.ReactJSXRuntime=gt;const De=Y.app;De?.plugins?.plugins?De.plugins.plugins["obsidian-excalidraw-plugin"]=Fe:Y.app={plugins:{plugins:{"obsidian-excalidraw-plugin":Fe}}};const tt=new URL("excalidraw/",document.baseURI).href,Be=(e,t)=>new Promise((r,a)=>{e.onload=()=>r(),e.onerror=()=>a(new Error(E("boardengine.assetLoadFailed",{url:t}))),document.head.appendChild(e)}),ce=document.createElement("link");ce.rel="stylesheet";ce.href=`${tt}excalidraw.css`;const we=document.createElement("script");we.src=`${tt}excalidraw.js`;await Promise.all([Be(ce,ce.href),Be(we,we.src)]);const nt=Y.ExcalidrawLib;if(!nt)throw new Error(E("boardengine.libMissing"));const{Excalidraw:Ut,MainMenu:j,serializeAsJSON:Vt,restoreElements:Kt,newElementWith:Yt,CaptureUpdateAction:V}=nt,qt=["default","finetip","fountain","marker","highlighter","thick-thin","thin-thick-thin"];G({"excalipen.default":{zh:"默认",en:"Default"},"excalipen.finetip":{zh:"细尖笔",en:"Fine tip"},"excalipen.fountain":{zh:"钢笔",en:"Fountain pen"},"excalipen.marker":{zh:"马克笔",en:"Marker"},"excalipen.highlighter":{zh:"荧光笔",en:"Highlighter"},"excalipen.thickThin":{zh:"粗到细",en:"Thick to thin"},"excalipen.thinThickThin":{zh:"两头细",en:"Tapered ends"}});const He={get default(){return E("excalipen.default")},get finetip(){return E("excalipen.finetip")},get fountain(){return E("excalipen.fountain")},get marker(){return E("excalipen.marker")},get highlighter(){return E("excalipen.highlighter")},get"thick-thin"(){return E("excalipen.thickThin")},get"thin-thick-thin"(){return E("excalipen.thinThickThin")}},at={default:{type:"default",freedrawOnly:!1,strokeColor:"#000000",backgroundColor:"transparent",fillStyle:"hachure",strokeWidth:0,roughness:0,penOptions:{highlighter:!1,constantPressure:!1,hasOutline:!1,outlineWidth:1,options:{thinning:.6,smoothing:.5,streamline:.5,easing:"easeOutSine",start:{cap:!0,taper:0,easing:"linear"},end:{cap:!0,taper:0,easing:"linear"}}}},highlighter:{type:"highlighter",freedrawOnly:!0,strokeColor:"#FFC47C",backgroundColor:"#FFC47C",fillStyle:"solid",strokeWidth:4,roughness:null,penOptions:{highlighter:!0,constantPressure:!0,hasOutline:!1,outlineWidth:1,options:{thinning:0,smoothing:.5,streamline:.5,easing:"linear",start:{taper:0,cap:!1,easing:"linear"},end:{taper:0,cap:!1,easing:"linear"}}}},finetip:{type:"finetip",freedrawOnly:!1,strokeColor:"#3E6F8D",backgroundColor:"transparent",fillStyle:"hachure",strokeWidth:.5,roughness:0,penOptions:{highlighter:!1,hasOutline:!1,outlineWidth:1,constantPressure:!0,options:{smoothing:.4,thinning:-.5,streamline:.4,easing:"linear",start:{taper:5,cap:!1,easing:"linear"},end:{taper:5,cap:!1,easing:"linear"}}}},fountain:{type:"fountain",freedrawOnly:!1,strokeColor:"#000000",backgroundColor:"transparent",fillStyle:"hachure",strokeWidth:2,roughness:0,penOptions:{highlighter:!1,constantPressure:!1,hasOutline:!1,outlineWidth:1,options:{smoothing:.2,thinning:.6,streamline:.2,easing:"easeInOutSine",start:{taper:150,cap:!0,easing:"linear"},end:{taper:1,cap:!0,easing:"linear"}}}},marker:{type:"marker",freedrawOnly:!0,strokeColor:"#B83E3E",backgroundColor:"#FF7C7C",fillStyle:"dashed",strokeWidth:2,roughness:3,penOptions:{highlighter:!1,constantPressure:!0,hasOutline:!0,outlineWidth:4,options:{thinning:1,smoothing:.5,streamline:.5,easing:"linear",start:{taper:0,cap:!0,easing:"linear"},end:{taper:0,cap:!0,easing:"linear"}}}},"thick-thin":{type:"thick-thin",freedrawOnly:!0,strokeColor:"#CECDCC",backgroundColor:"transparent",fillStyle:"hachure",strokeWidth:0,roughness:null,penOptions:{highlighter:!0,constantPressure:!0,hasOutline:!1,outlineWidth:1,options:{thinning:1,smoothing:.5,streamline:.5,easing:"linear",start:{taper:0,cap:!0,easing:"linear"},end:{cap:!0,taper:!0,easing:"linear"}}}},"thin-thick-thin":{type:"thin-thick-thin",freedrawOnly:!0,strokeColor:"#CECDCC",backgroundColor:"transparent",fillStyle:"hachure",strokeWidth:0,roughness:null,penOptions:{highlighter:!0,constantPressure:!0,hasOutline:!1,outlineWidth:1,options:{thinning:1,smoothing:.5,streamline:.5,easing:"linear",start:{cap:!0,taper:!0,easing:"linear"},end:{cap:!0,taper:!0,easing:"linear"}}}}},Xt={default:Je,finetip:Lt,fountain:Dt,marker:Tt,highlighter:Ge,"thick-thin":Nt,"thin-thick-thin":Ht},Zt={.25:"extraThin",.5:"thin",1:"medium",2:"bold",4:"extraBold"},Gt=e=>{const t=Zt[e];return t?{currentItemStrokeWidthKey:t,currentItemStrokeWidth:null}:{currentItemStrokeWidthKey:null,currentItemStrokeWidth:e}},Jt={topPicks:{elementStroke:["#1e1e1e","#e03131","#2f9e44","#1971c2","#ffd43b"]}};function rt(e,t){const r=t.getAppState();t.updateScene({appState:{currentStrokeOptions:{...e.penOptions,options:{...e.penOptions.options}},colorPalette:e.type==="highlighter"?Jt:void 0,...e.strokeWidth?Gt(e.strokeWidth):null,currentItemStrokeVariability:e.penOptions?.constantPressure?"constant":"variable",...e.backgroundColor?{currentItemBackgroundColor:e.backgroundColor}:null,...e.strokeColor?{currentItemStrokeColor:e.strokeColor}:null,...e.fillStyle?{currentItemFillStyle:e.fillStyle}:null,...e.roughness!==null?{currentItemRoughness:e.roughness}:null,...r.resetCustomPen?null:{resetCustomPen:{currentItemStrokeWidthKey:r.currentItemStrokeWidthKey??null,currentItemStrokeWidth:r.currentItemStrokeWidth??null,currentItemStrokeVariability:r.currentItemStrokeVariability??null,currentItemBackgroundColor:r.currentItemBackgroundColor??null,currentItemStrokeColor:r.currentItemStrokeColor??null,currentItemFillStyle:r.currentItemFillStyle??null,currentItemRoughness:r.currentItemRoughness??null}}},captureUpdate:V.NEVER})}function Ce(e,t,r){t.updateScene({appState:{...e?{currentItemStrokeWidthKey:e.currentItemStrokeWidthKey??null,currentItemStrokeWidth:e.currentItemStrokeWidth??null,currentItemStrokeVariability:e.currentItemStrokeVariability??null,currentItemBackgroundColor:e.currentItemBackgroundColor??null,currentItemStrokeColor:e.currentItemStrokeColor??null,currentItemFillStyle:e.currentItemFillStyle??null,currentItemRoughness:e.currentItemRoughness??null}:null,resetCustomPen:null,...r?{currentStrokeOptions:null,colorPalette:void 0}:null},captureUpdate:V.NEVER})}const Qt=()=>({active:null,pending:!1});function ot(e,t,r){const a=t.current,s=e.getAppState();if(a.active===r&&s.activeTool.type==="freedraw"){a.active=null,a.pending=!1,Ce(s.resetCustomPen,e,!0);return}a.active=r,a.pending=!0,rt(at[r],e),e.setActiveTool({type:"freedraw"})}function en(e,t){const r=e.getAppState().currentStrokeOptions;r?.options&&e.updateScene({appState:{currentStrokeOptions:{...r,options:{...r.options,thinning:0,start:{...r.options.start,cap:t,taper:0},end:{...r.options.end,cap:t,taper:0}}}},captureUpdate:V.NEVER})}function tn(e,t){const r=t.current;r.active&&(r.active=null,r.pending=!1,Ce(e.getAppState().resetCustomPen,e,!0))}function nn(e,t,r,a){const s=a.current;s.pending&&t==="freedraw"&&(s.pending=!1),u.useEffect(()=>{const o=s.active;if(!e||!o||s.pending)return;const l=at[o];l.freedrawOnly&&(t!=="freedraw"&&r?Ce(r,e,!1):t==="freedraw"&&!r&&rt(l,e))},[e,s,t,r])}function an({api:e,ui:t,state:r}){const a=r.current,s=t.tool;return e?n.jsx("div",{className:"amx-penrow buttonList",children:qt.map(o=>{const l=Xt[o],p=a.active===o&&s==="freedraw";return n.jsx("label",{className:p?"active":"",title:He[o],"data-on":p||void 0,onClick:()=>ot(e,r,o),children:n.jsx(l,{size:16,"aria-label":He[o]})},o)})}):null}const ue=["left","mid","right"],z={left:["lock","hand"],mid:["selection","shape","line","freedraw","highlighter","text","eraser"],right:["frame","laser"]},rn=[...z.left,...z.mid,...z.right],me="amx.boardToolbar",X=new Set;let M=null;const on=e=>e<9?String(e+1):e===9?"0":null;function st(e){const t=new Set,r={left:[],mid:[],right:[]},a=e??{};for(const s of ue)for(const o of Array.isArray(a[s])?a[s]:[])typeof o!="string"||!rn.includes(o)||t.has(o)||(t.add(o),r[s].push(o));for(const s of ue)for(const o of z[s])t.has(o)||r[s].push(o);return r}const Z=()=>{if(M)return M;try{const e=localStorage.getItem(me);if(e)return M=st(JSON.parse(e))}catch{}return M=z},sn=e=>{M=st(e);try{localStorage.setItem(me,JSON.stringify(M))}catch{}for(const t of X)t()},ln=()=>{M=z;try{localStorage.removeItem(me)}catch{}for(const e of X)e()},cn=e=>ue.every(t=>e[t].length===z[t].length&&e[t].every((r,a)=>r===z[t][a])),lt=e=>(X.add(e),()=>X.delete(e));function un(e,t,r,a){const s={left:[...e.left],mid:[...e.mid],right:[...e.right]};for(const o of ue){const l=s[o].indexOf(t);l>=0&&s[o].splice(l,1)}return s[r].splice(Math.max(0,Math.min(a,s[r].length)),0,t),s}typeof window<"u"&&window.addEventListener("storage",e=>{if(e.key===me){M=null;for(const t of X)t()}});G({"boardtoolbar.shapeRectangle":{zh:"矩形",en:"Rectangle"},"boardtoolbar.shapeDiamond":{zh:"菱形",en:"Diamond"},"boardtoolbar.shapeEllipse":{zh:"椭圆",en:"Ellipse"},"boardtoolbar.lineArrow":{zh:"箭头",en:"Arrow"},"boardtoolbar.lineSegment":{zh:"线段",en:"Line"},"boardtoolbar.toolLock":{zh:"保持工具选中",en:"Keep tool selected"},"boardtoolbar.toolHand":{zh:"抓手",en:"Hand"},"boardtoolbar.toolSelection":{zh:"选择",en:"Selection"},"boardtoolbar.toolShape":{zh:"形状",en:"Shape"},"boardtoolbar.toolLine":{zh:"线",en:"Line"},"boardtoolbar.toolFreedraw":{zh:"画笔",en:"Draw"},"boardtoolbar.toolHighlighter":{zh:"荧光笔",en:"Highlighter"},"boardtoolbar.toolText":{zh:"文字",en:"Text"},"boardtoolbar.toolEraser":{zh:"橡皮",en:"Eraser"},"boardtoolbar.toolFrame":{zh:"画框",en:"Frame"},"boardtoolbar.toolLaser":{zh:"激光笔",en:"Laser pointer"}});const de=["rectangle","diamond","ellipse"],he=["arrow","line"],dn=()=>({shape:"rectangle",line:"arrow"}),hn={rectangle:Ze,diamond:et,ellipse:Xe},pn={arrow:qe,line:Qe},We={get rectangle(){return E("boardtoolbar.shapeRectangle")},get diamond(){return E("boardtoolbar.shapeDiamond")},get ellipse(){return E("boardtoolbar.shapeEllipse")}},_e={get arrow(){return E("boardtoolbar.lineArrow")},get line(){return E("boardtoolbar.lineSegment")}},mn={lock:"boardtoolbar.toolLock",hand:"boardtoolbar.toolHand",selection:"boardtoolbar.toolSelection",shape:"boardtoolbar.toolShape",line:"boardtoolbar.toolLine",freedraw:"boardtoolbar.toolFreedraw",highlighter:"boardtoolbar.toolHighlighter",text:"boardtoolbar.toolText",eraser:"boardtoolbar.toolEraser",frame:"boardtoolbar.toolFrame",laser:"boardtoolbar.toolLaser"};function it(e,t,r){const a=t.getAppState();switch(e){case"lock":t.setActiveTool({...a.activeTool,locked:!a.activeTool.locked});return;case"shape":t.setActiveTool({type:r.group.current.shape});return;case"line":t.setActiveTool({type:r.group.current.line});return;case"freedraw":tn(t,r.pen),t.setActiveTool({type:"freedraw"});return;case"highlighter":ot(t,r.pen,"highlighter");return;default:t.setActiveTool({type:e})}}function fn(e,t){switch(e){case"lock":return Rt;case"hand":return zt;case"selection":return St;case"shape":return hn[t.shape];case"line":return pn[t.line];case"freedraw":return Je;case"highlighter":return Ge;case"text":return Mt;case"eraser":return kt;case"frame":return Pt;case"laser":return vt}}function gn(e,t,r){const a=t.tool;switch(e){case"lock":return t.locked;case"shape":return de.includes(a);case"line":return he.includes(a);case"freedraw":return a==="freedraw"&&r.active!=="highlighter";case"highlighter":return a==="freedraw"&&r.active==="highlighter";default:return a===e}}const $e=["left","mid","right"];function xn({api:e,ui:t,refs:r}){const{t:a}=K(),s=u.useSyncExternalStore(lt,Z,Z),[o,l]=u.useState(null),p=u.useRef(null),x=u.useRef(null),d=o?.layout??s;if(!e)return null;const fe=r.group.current,R=r.pen.current,J=(f,g)=>{const b=x.current;if(!b)return null;let v=null,H=1/0;for(const y of $e){const P=b.querySelector(`[data-seg="${y}"]`);if(!P)continue;const S=P.getBoundingClientRect();if(f>=S.left&&f<=S.right){v=y;break}const te=f<S.left?S.left-f:f-S.right;te<H&&(H=te,v=y)}if(!v)return null;const N=[...b.querySelectorAll(`[data-seg="${v}"] [data-tool]`)];let C=N.length;for(let y=0;y<N.length;y++){const P=N[y].getBoundingClientRect();if(f<P.left+P.width/2){C=y;break}}const L=N.findIndex(y=>y.dataset.tool===g);return L>=0&&L<C&&C--,{seg:v,index:C}},Q=(f,g)=>{f.button===0&&(p.current={x:f.clientX,y:f.clientY,id:g,moved:!1},f.currentTarget.setPointerCapture(f.pointerId))},ee=f=>{const g=p.current;if(!g||!g.moved&&Math.hypot(f.clientX-g.x,f.clientY-g.y)<5)return;g.moved=!0;const b=J(f.clientX,g.id);b&&l({id:g.id,layout:un(s,g.id,b.seg,b.index)})},O=u.useRef(0),q=f=>{const g=p.current;p.current=null,f.currentTarget.releasePointerCapture?.(f.pointerId),O.current=g?.moved?Date.now():0,g?.moved&&o&&sn(o.layout),l(null)},B=f=>{if(Date.now()-O.current<400){O.current=0;return}it(f,e,r)};return n.jsx("div",{className:"amx-toolbar",ref:x,"data-dragging":o?"":void 0,children:$e.map((f,g)=>n.jsxs("div",{className:"amx-toolbar-seg","data-seg":f,children:[g>0&&n.jsx("span",{className:"amx-toolbar-sep","aria-hidden":!0}),d[f].map((b,v)=>{const H=fn(b,fe),N=gn(b,t,R),C=f==="mid"?on(v):null,L=a(mn[b]);return n.jsxs("button",{type:"button","data-tool":b,"data-on":N||void 0,"data-drag":o?.id===b||void 0,className:"amx-tool",title:C?`${L} — ${C}`:L,"aria-label":L,"aria-pressed":N,onPointerDown:y=>Q(y,b),onPointerMove:ee,onPointerUp:q,onClick:()=>B(b),onPointerCancel:()=>{p.current=null,O.current=0,l(null)},children:[n.jsx(H,{size:17}),C&&n.jsx("span",{className:"amx-tool-key",children:C})]},b)})]},f))})}G({"panelextras.secPen":{zh:"笔",en:"Pen"},"panelextras.secStroke":{zh:"笔触",en:"Stroke"},"panelextras.capRound":{zh:"圆头",en:"Round cap"},"panelextras.capButt":{zh:"方头",en:"Flat cap"},"panelextras.secShape":{zh:"形状",en:"Shape"},"panelextras.secLine":{zh:"线",en:"Line"}});const bn={rectangle:Ze,diamond:et,ellipse:Xe},yn={arrow:qe,line:Qe};function re({title:e,children:t}){return n.jsxs("fieldset",{className:"amx-panelsec",children:[n.jsx("legend",{children:e}),t]})}function vn({api:e,ui:t,pen:r,group:a}){const{t:s}=K();if(!e)return null;const o=t.tool;if(o==="freedraw"){const l=r.current.active==="highlighter";return n.jsxs(n.Fragment,{children:[n.jsx(re,{title:s("panelextras.secPen"),children:n.jsx(an,{api:e,ui:t,state:r})}),l&&n.jsx(re,{title:s("panelextras.secStroke"),children:n.jsx("div",{className:"amx-panelrow buttonList",children:[!1,!0].map(p=>{const x=t.capRound===p,d=s(p?"panelextras.capRound":"panelextras.capButt");return n.jsx("label",{className:x?"active":"",title:d,"data-on":x||void 0,onClick:()=>en(e,p),children:n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18","aria-label":d,children:n.jsx("line",{x1:"4",y1:"9",x2:"14",y2:"9",stroke:"currentColor",strokeWidth:"7",strokeLinecap:p?"round":"butt"})})},String(p))})})})]})}return de.includes(o)?n.jsx(re,{title:s("panelextras.secShape"),children:n.jsx("div",{className:"amx-panelrow buttonList",children:de.map(l=>{const p=bn[l],x=o===l;return n.jsx("label",{className:x?"active":"",title:We[l],"data-on":x||void 0,onClick:()=>{a.current.shape=l,e.setActiveTool({type:l})},children:n.jsx(p,{size:16,"aria-label":We[l]})},l)})})}):he.includes(o)?n.jsx(re,{title:s("panelextras.secLine"),children:n.jsx("div",{className:"amx-panelrow buttonList",children:he.map(l=>{const p=yn[l],x=o===l;return n.jsx("label",{className:x?"active":"",title:_e[l],"data-on":x||void 0,onClick:()=>{a.current.line=l,e.setActiveTool({type:l})},children:n.jsx(p,{size:16,"aria-label":_e[l]})},l)})})}):null}const kn=()=>({tool:"selection",locked:!1,snapshot:null,capRound:null}),Sn=(e,t)=>e.tool===t.tool&&e.locked===t.locked&&e.snapshot===t.snapshot&&e.capRound===t.capRound;G({"excalicanvas.addPage":{zh:"+ 新建页面",en:"+ New page"},"excalicanvas.delBlankPage":{zh:"删掉这张空白页",en:"Delete this blank page"},"excalicanvas.modeFull":{zh:"常规",en:"Standard"},"excalicanvas.modeCompact":{zh:"紧凑",en:"Compact"},"excalicanvas.paper":{zh:"纸张",en:"Paper"},"excalicanvas.paperNone":{zh:"无限",en:"Infinite"},"excalicanvas.portrait":{zh:"纵向",en:"Portrait"},"excalicanvas.landscape":{zh:"横向",en:"Landscape"},"excalicanvas.flow":{zh:"页面排布",en:"Page layout"},"excalicanvas.flowV":{zh:"上下",en:"Top to bottom"},"excalicanvas.flowH":{zh:"左右",en:"Left to right"},"excalicanvas.grid":{zh:"网格",en:"Grid"},"excalicanvas.gridH":{zh:"横线",en:"Horizontal"},"excalicanvas.gridV":{zh:"竖线",en:"Vertical"},"excalicanvas.opacity":{zh:"淡浓",en:"Opacity"},"excalicanvas.uiMode":{zh:"属性面板",en:"Properties panel"},"excalicanvas.allBoards":{zh:"所有白板",en:"All boards"},"excalicanvas.toolbar":{zh:"工具栏",en:"Toolbar"},"excalicanvas.resetOrder":{zh:"恢复默认顺序",en:"Reset to default order"}});const oe=4,wn="linear-gradient(90deg, var(--amx-grid-line) 0 1px, transparent 1px)",En="linear-gradient(180deg, var(--amx-grid-line) 0 1px, transparent 1px)",Ue=(e,t,r)=>Math.min(Math.max(e,t),r),Ve=(e,t)=>(e%t+t)%t;function Ke(e,t,r){const[a,s]=u.useState(null);return u.useEffect(()=>{if(!e)return;let o=null;const l=()=>{const x=e.querySelector(t);if(!x){o&&(o.remove(),o=null,s(null));return}if(o&&o.parentElement===x)return;o?.remove();const d=document.createElement("div");d.className=r,x.insertBefore(d,x.firstChild),o=d,s(d)};l();const p=new MutationObserver(l);return p.observe(e,{childList:!0,subtree:!0}),()=>{p.disconnect(),o?.remove(),s(null)}},[e,t,r]),a}function Cn(e){u.useEffect(()=>{const t=new Map,r=o=>{o.classList.contains("amx-board-portal")||o.classList.add("amx-board-portal"),o.style.zoom!==e&&(o.style.zoom=e)},a=o=>{if(!(o instanceof HTMLElement)||!o.classList.contains("excalidraw")||o.closest(".amx-boardhost")||(r(o),t.has(o)))return;const l=new MutationObserver(()=>r(o));l.observe(o,{attributes:!0,attributeFilter:["class","style"]}),t.set(o,l)};for(const o of[...document.body.children])a(o);const s=new MutationObserver(o=>{for(const l of o){for(const p of l.addedNodes)a(p);for(const p of l.removedNodes)p instanceof HTMLElement&&t.has(p)&&(t.get(p)?.disconnect(),t.delete(p))}});return s.observe(document.body,{childList:!0}),()=>{s.disconnect();for(const o of t.values())o.disconnect()}},[e])}function Un({initialData:e,theme:t,langCode:r,settings:a,onSettings:s,onSceneChange:o,registerApplier:l,viewMode:p=!1}){const{t:x}=K(),[d,fe]=u.useState(null),R=u.useRef(null),J=u.useRef([]),Q=u.useRef(null),ee=u.useRef(null),O=u.useRef(null),q=u.useRef(!1),[B,f]=u.useState(null),[g,b]=u.useState(null),v=u.useMemo(()=>ye(a)?Te(a,g):{min:0,max:0},[a,g]),H=u.useMemo(()=>Array.from({length:v.max-v.min+1},(c,i)=>v.min+i),[v]),N=u.useMemo(()=>Te({...a,pageFirst:0,pageLast:0},g),[a,g]),C=u.useSyncExternalStore($t,ie,ie),L=u.useRef(Qt()),y=u.useRef(dn()),P=u.useMemo(()=>({pen:L,group:y}),[]),[S,te]=u.useState(kn),[ct,ut]=u.useState(""),[je,Ie]=u.useState(null),Ne=Ke(je,".App-toolbar","amx-toolbar-slot"),Le=Ke(je,".Island > .selected-shape-actions, .Island > .compact-shape-actions, .Island.compact-shape-actions","amx-panel-slot");Cn(ct),nn(d,S.tool,S.snapshot,L),u.useEffect(()=>{de.includes(S.tool)&&(y.current.shape=S.tool),he.includes(S.tool)&&(y.current.line=S.tool)},[S.tool]),u.useEffect(()=>{if(!d)return;const c=i=>{if(i.metaKey||i.ctrlKey||i.altKey||!/^[0-9]$/.test(i.key))return;const h=R.current?.querySelector(".excalidraw"),m=i.target;if(!h||!m||!h.contains(m)||m.isContentEditable||m.tagName==="INPUT"||m.tagName==="TEXTAREA")return;const w=Z().mid[i.key==="0"?9:Number(i.key)-1];w&&(i.preventDefault(),i.stopImmediatePropagation(),it(w,d,P))};return window.addEventListener("keydown",c,!0),()=>window.removeEventListener("keydown",c,!0)},[d,P]),u.useEffect(()=>{d?.setDesktopUIMode(C)},[d,C]),u.useEffect(()=>{if(!(!d||!l))return l(c=>{const i=d.getSceneElementsIncludingDeleted(),h=xt(i,c.elements??[]);if(bt(h,i))return;d.updateScene({elements:Kt(h,null),captureUpdate:V.NEVER});const m=Object.values(c.files??{});m.length&&d.addFiles(m)})},[d,l]),u.useEffect(()=>{const c=d&&R.current?.querySelector(".excalidraw");if(!c)return;const i=document.createElement("div");return i.style.display="contents",c.insertBefore(i,c.firstChild),f(i),Ie(c),()=>{i.remove(),f(null),Ie(null)}},[d]);const W=u.useCallback(c=>{const i=Q.current,h=J.current.filter(k=>!!k);if(!i||!h.length)return;const m=c.zoom.value,w=ye(a),T=a.gridV*m,ne=a.gridH*m,ae=[],xe=[],be=[],dt=w||T<oe?0:Ve(c.scrollX*m,T),ht=w||ne<oe?0:Ve(c.scrollY*m,ne);T>=oe&&(ae.push(wn),xe.push(`${T}px 100%`),be.push(`${dt}px 0px`)),ne>=oe&&(ae.push(En),xe.push(`100% ${ne}px`),be.push(`0px ${ht}px`));for(const k of h)k.style.backgroundImage=ae.join(", "),k.style.backgroundSize=xe.join(", "),k.style.backgroundPosition=be.join(", "),k.style.opacity=a.gridOpacity>=100?"":String(a.gridOpacity/100),k.style.display=ae.length||w?"":"none";if(!w){Object.assign(h[0].style,{left:"0px",top:"0px",width:"100%",height:"100%"}),i.style.display="none";return}const Me=(k,I,A)=>{if(!k)return;const F=(I.x+c.scrollX)*m,U=(I.y+c.scrollY)*m,D=22,pt=a.flow==="h"?A?F+I.w*m+D:F-D:F+I.w*m/2,mt=a.flow==="h"?U+I.h*m/2:A?U+I.h*m+D:U-D;k.style.left=`${pt}px`,k.style.top=`${mt}px`},ze=[];for(let k=0;k<h.length;k++){const I=ve(a,v.min+k);if(!I)continue;const A=(I.x+c.scrollX)*m,F=(I.y+c.scrollY)*m,U=I.w*m,D=I.h*m;Object.assign(h[k].style,{left:`${A}px`,top:`${F}px`,width:`${U}px`,height:`${D}px`}),ze.push(`M${A.toFixed(1)} ${F.toFixed(1)}H${(A+U).toFixed(1)}V${(F+D).toFixed(1)}H${A.toFixed(1)}Z`)}const Re=ve(a,v.min),Oe=ve(a,v.max);Re&&Me(ee.current,Re,!1),Oe&&Me(O.current,Oe,!0),i.style.display="",i.style.clipPath=`path(evenodd,"M0 0H${i.offsetWidth}V${i.offsetHeight}H0Z ${ze.join(" ")}")`},[a,v]),_=u.useCallback(c=>{if(!d||q.current)return c;const i=d.getAppState();if(i.cursorButton==="down")return c;const h=wt(a,{scrollX:c.scrollX,scrollY:c.scrollY,zoom:c.zoom.value,width:i.width,height:i.height},g);if(!h)return c;q.current=!0;try{d.updateScene({appState:{scrollX:h.scrollX,scrollY:h.scrollY,zoom:{value:h.zoom}},captureUpdate:V.NEVER})}finally{q.current=!1}return{scrollX:h.scrollX,scrollY:h.scrollY,zoom:{value:h.zoom}}},[d,a,g]),ge=u.useCallback(c=>{const i=Et(c);b(h=>h&&i&&h.minX===i.minX&&h.minY===i.minY&&h.maxX===i.maxX&&h.maxY===i.maxY?h:i)},[]),Pe=u.useRef(a.flow);u.useEffect(()=>{const c=Pe.current,i=a.flow;if(Pe.current=i,c===i||!d||!a.paper)return;const h=d.getSceneElements();h.length&&d.updateScene({elements:h.map(m=>{const w=Ct(a,c,i,m.x,m.y);return w.x===m.x&&w.y===m.y?m:Yt(m,{x:w.x,y:w.y})}),captureUpdate:V.IMMEDIATELY})},[d,a]),u.useEffect(()=>{!d||!B||(ge(d.getSceneElements()),W(_(d.getAppState())))},[d,B,W,_,ge]);const $=u.useCallback(()=>{const c=R.current;if(!c)return;const i=c.parentElement?.currentCSSZoom??1,h=Math.abs(i-1)>1e-6?String(1/i):"";c.style.zoom!==h&&(c.style.zoom=h),ut(m=>m===h?m:h)},[]);return u.useEffect(()=>($(),window.addEventListener(Ae,$),()=>window.removeEventListener(Ae,$)),[$]),u.useEffect(()=>{const c=R.current;if(!c||!d||typeof ResizeObserver>"u")return;const i=new ResizeObserver(()=>{$(),W(_(d.getAppState()))});return i.observe(c),()=>i.disconnect()},[d,W,_,$]),n.jsxs("div",{className:"amx-boardhost",ref:R,children:[n.jsx(Ut,{onExcalidrawAPI:fe,initialData:e,theme:t,langCode:r,viewModeEnabled:p,onScrollChange:(c,i,h)=>W(_({scrollX:c,scrollY:i,zoom:h})),onChange:(c,i,h)=>{ge(c),W(_(i));const m=i.currentStrokeOptions,w={tool:i.activeTool.type,locked:!!i.activeTool.locked,snapshot:i.resetCustomPen??null,capRound:m?!!m.options?.start?.cap:null};te(T=>Sn(T,w)?T:w),o(Vt(c,i,h,"local"))},children:n.jsxs(j,{children:[n.jsx(j.DefaultItems.LoadScene,{}),n.jsx(j.DefaultItems.SaveToActiveFile,{}),n.jsx(j.DefaultItems.Export,{}),n.jsx(j.DefaultItems.SaveAsImage,{}),n.jsx(j.DefaultItems.SearchMenu,{}),n.jsx(j.DefaultItems.Help,{}),n.jsx(j.DefaultItems.ClearCanvas,{}),n.jsx(j.Separator,{}),n.jsx(j.DefaultItems.ToggleTheme,{allowSystemTheme:!1}),n.jsx(j.DefaultItems.ChangeCanvasBackground,{}),n.jsx(j.Separator,{}),n.jsx(j.ItemCustom,{children:n.jsx(Nn,{settings:a,onSettings:s,uiMode:C,onUiMode:_t})})]})}),Ne&&ke.createPortal(n.jsx(xn,{api:d,ui:S,refs:P}),Ne),Le&&ke.createPortal(n.jsx(vn,{api:d,ui:S,pen:L,group:y}),Le),B&&ke.createPortal(n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"amx-matte",ref:Q,onWheel:jn}),H.map((c,i)=>n.jsx("div",{className:"amx-grid","data-page":c,ref:h=>{J.current[i]=h}},c)),!!ye(a)&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"amx-pageadd","data-end":"before","data-flow":a.flow,ref:ee,children:[n.jsx("button",{onClick:()=>s({pageFirst:a.pageFirst-1}),children:x("excalicanvas.addPage")}),a.pageFirst<N.min&&n.jsx("button",{className:"amx-pageadd-del",title:x("excalicanvas.delBlankPage"),onClick:()=>s({pageFirst:a.pageFirst+1}),children:"−"})]}),n.jsxs("div",{className:"amx-pageadd","data-end":"after","data-flow":a.flow,ref:O,children:[n.jsx("button",{onClick:()=>s({pageLast:a.pageLast+1}),children:x("excalicanvas.addPage")}),a.pageLast>N.max&&n.jsx("button",{className:"amx-pageadd-del",title:x("excalicanvas.delBlankPage"),onClick:()=>s({pageLast:a.pageLast-1}),children:"−"})]})]})]}),B)]})}function jn(e){const t=e.currentTarget.closest(".excalidraw")?.querySelector("canvas.excalidraw__canvas.interactive");t&&(e.preventDefault(),t.dispatchEvent(new WheelEvent("wheel",{deltaX:e.deltaX,deltaY:e.deltaY,deltaMode:e.deltaMode,clientX:e.clientX,clientY:e.clientY,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,bubbles:!0,cancelable:!0})))}const In=[{id:"full",labelKey:"excalicanvas.modeFull"},{id:"compact",labelKey:"excalicanvas.modeCompact"}];function Nn({settings:e,onSettings:t,uiMode:r,onUiMode:a}){const{t:s}=K(),o=t;return n.jsxs("div",{className:"amx-bs",children:[n.jsx("div",{className:"amx-bs-h",children:s("excalicanvas.paper")}),n.jsxs("div",{className:"amx-bs-row",children:[n.jsx("button",{className:"amx-bs-chip","data-on":!e.paper||void 0,onClick:()=>o({paper:null}),children:s("excalicanvas.paperNone")}),jt.map(l=>n.jsx("button",{className:"amx-bs-chip","data-on":e.paper===l||void 0,onClick:()=>o({paper:l}),children:l},l))]}),e.paper&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"amx-bs-row",children:[n.jsx("button",{className:"amx-bs-chip","data-on":!e.landscape||void 0,onClick:()=>o({landscape:!1}),children:s("excalicanvas.portrait")}),n.jsx("button",{className:"amx-bs-chip","data-on":e.landscape||void 0,onClick:()=>o({landscape:!0}),children:s("excalicanvas.landscape")})]}),n.jsx("div",{className:"amx-bs-h",children:s("excalicanvas.flow")}),n.jsxs("div",{className:"amx-bs-row",children:[n.jsx("button",{className:"amx-bs-chip","data-on":e.flow==="v"||void 0,onClick:()=>o({flow:"v"}),children:s("excalicanvas.flowV")}),n.jsx("button",{className:"amx-bs-chip","data-on":e.flow==="h"||void 0,onClick:()=>o({flow:"h"}),children:s("excalicanvas.flowH")})]})]}),n.jsx("div",{className:"amx-bs-h",children:s("excalicanvas.grid")}),n.jsx(Ye,{label:s("excalicanvas.gridH"),value:e.gridH,onChange:l=>o({gridH:l})}),n.jsx(Ye,{label:s("excalicanvas.gridV"),value:e.gridV,onChange:l=>o({gridV:l})}),n.jsx(Pn,{value:e.gridOpacity,disabled:e.gridH<=0&&e.gridV<=0,onCommit:l=>o({gridOpacity:l})}),n.jsxs("div",{className:"amx-bs-h",children:[s("excalicanvas.uiMode")," ",n.jsx("span",{className:"amx-bs-note",children:s("excalicanvas.allBoards")})]}),n.jsx("div",{className:"amx-bs-row",children:In.map(l=>n.jsx("button",{className:"amx-bs-chip","data-on":r===l.id||void 0,onClick:()=>a(l.id),children:s(l.labelKey)},l.id))}),n.jsx(Ln,{})]})}function Ln(){const{t:e}=K(),t=u.useSyncExternalStore(lt,Z,Z);return cn(t)?null:n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"amx-bs-h",children:[e("excalicanvas.toolbar")," ",n.jsx("span",{className:"amx-bs-note",children:e("excalicanvas.allBoards")})]}),n.jsx("div",{className:"amx-bs-row",children:n.jsx("button",{className:"amx-bs-chip",onClick:()=>ln(),children:e("excalicanvas.resetOrder")})})]})}function Pn({value:e,disabled:t,onCommit:r}){const{t:a}=K(),[s,o]=u.useState(e);return u.useEffect(()=>o(e),[e]),n.jsxs("label",{className:"amx-bs-check",children:[n.jsx("span",{className:"amx-bs-lbl",children:a("excalicanvas.opacity")}),n.jsx("input",{className:"amx-bs-range",type:"range",min:10,max:100,step:5,disabled:t,value:s,onChange:l=>{const p=Number(l.target.value);o(p);for(const x of l.currentTarget.closest(".excalidraw")?.querySelectorAll(".amx-grid")??[])x.style.opacity=p>=100?"":String(p/100)},onPointerUp:()=>r(s),onKeyUp:()=>r(s)}),n.jsxs("span",{className:"amx-bs-note",children:[s,"%"]})]})}function Ye({label:e,value:t,onChange:r}){const[a,s]=u.useState(String(t||Se));u.useEffect(()=>{t>0&&s(String(t))},[t]);const o=()=>{const l=Math.round(Number(a)),p=Number.isFinite(l)&&l>0?Ue(l,4,400):Se;s(String(p)),t>0&&p!==t&&r(p)};return n.jsxs("label",{className:"amx-bs-check",children:[n.jsx("input",{type:"checkbox",checked:t>0,onChange:l=>r(l.target.checked?Ue(Math.round(Number(a))||Se,4,400):0)}),n.jsx("span",{className:"amx-bs-lbl",children:e}),n.jsx("input",{className:"amx-bs-num",type:"number",min:4,max:400,disabled:t<=0,value:a,onChange:l=>s(l.target.value),onBlur:o,onKeyDown:l=>{l.key==="Enter"&&o()}}),n.jsx("span",{className:"amx-bs-note",children:"px"})]})}export{Un as default};
@@ -1 +0,0 @@
1
- import{u as bn,d as g,j as e}from"./index-CF4RV4mh.js";import{z as Ke,an as fe,_ as Q,f3 as Cn,je as Le,jf as Sn,jg as kn,jh as yn,K as Nn,f7 as de,ji as pe,jj as ue,jk as ze,au as he,aI as ge,aF as Mn,jl as qe,a8 as Pn,fa as Fe,a9 as En,da as Dn,u as V,b8 as In,gG as On,jm as An,jn as Wn,jo as Rn,jp as Tn,jq as Ln,h8 as zn,jr as Fn,js as _n,jt as $n,ju as Ye,aa as L,jv as xe,Y as Bn,ab as _e,ac as $e,dy as Un,du as Hn,a2 as $,i as Be,ad as Vn,jw as Gn}from"./appStore-Dg9WALEA.js";import{V as Kn,W as qn,X as Yn,C as Jn}from"./RunLocationPicker-CTYXUH2z.js";import{U as Xn}from"./upload-BbeAsMuD.js";import{F as Zn}from"./folder-plus-D1TDb7k9.js";import{P as Qn}from"./pencil-Cvk91P_Z.js";import{L as es}from"./log-out-DBuMeqik.js";import"./nativeDownload-D-f1_L2S.js";import"./ipc-DQOD2UKk.js";import"./client-BSKpsyAw.js";import"./codeStudioStore-C2mWfm32.js";import"./RightPanel-C3OJTIqT.js";import"./folder-DlxnPmWY.js";import"./ModelPill-BPlgovPo.js";import"./create-4xUyKtAF.js";import"./approvalText-Cy2UAUAQ.js";import"./SidebarRow-BuSkKH5q.js";import"./message-square-plus-BiAZAvcw.js";import"./hand-Crrw-nSn.js";import"./waves-horizontal-B8ZpHQ5H.js";import"./ellipsis-r1EcXsFq.js";import"./pageChrome-C9_azUYW.js";import"./emoji-DGaxpCIu.js";const ns=[["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],ss=Ke("folder-minus",ns);const ts=[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 12h18",key:"1i2n21"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]],Ue=Ke("grid-2x2",ts),Je="forsion.homepage.wallpaper.v1",os=32*1024*1024,Xe={source:"theme",themePreset:"rings",bingDaily:!0,focusBlur:!0,vignette:!0,bing:null},A=t=>typeof t=="string"?t:"";function He(t){const s=A(t);try{const i=new URL(s);return i.protocol==="https:"&&(i.hostname==="www.bing.com"||i.hostname.endsWith(".bing.com"))?i.toString():""}catch{return""}}function je(t){if(!t||typeof t!="object")return null;const s=t,i=He(s.url);if(!i)return null;const d=He(s.thumbnailUrl)||i,p=A(s.startDate);return{id:A(s.id)||p||i,url:i,thumbnailUrl:d,title:A(s.title),copyright:A(s.copyright),startDate:p}}function as(t){if(!t||typeof t!="object")return{...Xe};const s=t,i=s.source==="bing"||s.source==="custom"?s.source:"theme",d=s.themePreset==="topography"||s.themePreset==="weave"||s.themePreset==="hack2gate"?s.themePreset:"rings";return{source:i,themePreset:d,bingDaily:s.bingDaily!==!1,focusBlur:s.focusBlur!==!1,vignette:s.vignette!==!1,bing:je(s.bing)}}function rs(){try{return as(JSON.parse(localStorage.getItem(Je)||"null"))}catch{return{...Xe}}}function is(t){try{localStorage.setItem(Je,JSON.stringify(t))}catch{}}function ls(t){return(Array.isArray(t)?t:t&&typeof t=="object"&&Array.isArray(t.images)?t.images:[]).flatMap(i=>{if(!i||typeof i!="object")return[];const d=i,p=A(d.urlbase),a=A(d.url),u=p?`https://www.bing.com${p}_UHD.jpg`:a.startsWith("/")?`https://www.bing.com${a}`:a,f=p?`https://www.bing.com${p}_400x240.jpg`:u,l=je({id:A(d.startdate)||p||u,url:u,thumbnailUrl:f,title:d.title,copyright:d.copyright,startDate:d.startdate});return l?[l]:[]})}async function cs(t){if(window.tangu?.wallpaperListBing){const i=await window.tangu.wallpaperListBing(t==="zh"?"zh-CN":"en-US",8);if(!i.ok)throw new Error(i.error||"Bing wallpaper unavailable");return i.items.map(je).filter(d=>!!d)}const s=await fetch(`/api/wallpaper/daily?mkt=${t==="zh"?"zh-CN":"en-US"}&n=8&idx=0`);if(!s.ok)throw new Error(`HTTP ${s.status}`);return ls(await s.json())}const ds="forsion-homepage",ee="wallpaper",we="custom";function ps(){return new Promise((t,s)=>{const i=indexedDB.open(ds,1);i.onupgradeneeded=()=>{i.result.objectStoreNames.contains(ee)||i.result.createObjectStore(ee)},i.onsuccess=()=>t(i.result),i.onerror=()=>s(i.error||new Error("IndexedDB unavailable"))})}async function ve(t,s){const i=await ps();try{return await new Promise((d,p)=>{const a=i.transaction(ee,t),u=s(a.objectStore(ee));let f;u.onsuccess=()=>{f=u.result},u.onerror=()=>p(u.error||a.error||new Error("Wallpaper storage failed")),a.oncomplete=()=>d(f),a.onerror=()=>p(a.error||new Error("Wallpaper storage failed")),a.onabort=()=>p(a.error||new Error("Wallpaper storage aborted"))})}finally{i.close()}}async function us(){const t=await ve("readonly",s=>s.get(we));return t instanceof Blob&&t.type.startsWith("image/")?t:null}async function hs(t){if(!t.type.startsWith("image/"))throw new Error("NOT_IMAGE");if(t.size>os)throw new Error("TOO_LARGE");await ve("readwrite",s=>s.put(t,we))}async function gs(){await ve("readwrite",t=>t.delete(we))}const ne="home",ms=140,fs=6,Ze="forsion.homepage.pinned-spaces.v1",me="homepage:pinned-spaces",G="homepage:pinned:",xs=["rb-market","rb-achievements"],js=["rings","topography","weave","hack2gate"],Ve=t=>{const s=_n(t);return s.length?s:qe(t)};function ws({onDispatch:t,onStartCall:s,onInputModeChange:i}){const d=Dn(o=>o.vaultRoot),p=fe(o=>o.activeSpaceId),a=V(In(o=>({cfg:o.cfg,desktopConfig:o.desktopConfig,desktopMode:o.desktopMode,homeDir:o.homeDir,defaultWsDir:o.defaultWsDir,modelsResp:o.modelsResp,newChatWs:o.newChatWs,newChatCfg:o.newChatCfg,newChatModel:o.newChatModel,sessionMode:o.sessionMode,setSessionMode:o.setSessionMode,engines:o.engines,engineCaps:o.engineCaps,agentDefs:o.agentDefs,defaultAgentSlug:o.defaultAgentSlug,skillsList:o.skillsList,connState:o.connState,voiceOnByAgent:o.voiceOnByAgent,ensureEngineCaps:o.ensureEngineCaps,refreshVoiceMode:o.refreshVoiceMode,setSessionModel:o.setSessionModel,setNewChatCfg:o.setNewChatCfg,setSessionThinking:o.setSessionThinking,setDefaultModel:o.setDefaultModel,setModelContextWindow:o.setModelContextWindow,setVoiceMode:o.setVoiceMode,setExecConfig:o.setExecConfig,openSettings:o.openSettings,setNewChatWs:o.setNewChatWs,addLocalWorkspace:o.addLocalWorkspace,addCloudProject:o.addCloudProject,workspaces:o.workspaces,sessions:o.sessions,archivedSessions:o.archivedSessions,cloudProjects:o.cloudProjects,channelWorkspaces:o.channelWorkspaces,tr:o.tr})));On();const u=An(a),f=g.useMemo(()=>a.workspaces(),[a.workspaces,a.sessions,a.archivedSessions,a.cloudProjects,a.channelWorkspaces,a.defaultWsDir,a.homeDir,a.tr,d]),l=Wn(a.sessionMode,u),j=l==="chat"||u.kind==="cloud"||u.kind==="rootless",m=g.useMemo(()=>Rn(Tn(Ln({execMode:j?"sandbox":"host",...zn(a.desktopConfig,!j,l),cwd:j?void 0:u.path||void 0,...a.newChatCfg},l),d)),[j,l,a.desktopConfig,a.newChatCfg,u.path,d]),C=Fn(a)||"",W=a.modelsResp?.models?a.modelsResp.models.filter(o=>(o.modelType||"llm")==="llm"&&(!j||o.source==="forsion")):null,v=m.agentSlug||a.defaultAgentSlug,E=v?!!a.voiceOnByAgent[v]:!1;return g.useEffect(()=>{a.ensureEngineCaps(m.engineId||void 0)},[m.engineId,a.ensureEngineCaps]),g.useEffect(()=>{v&&a.refreshVoiceMode(v)},[v,a.refreshVoiceMode]),e.jsxs("div",{className:"hp-composer",onClick:o=>o.stopPropagation(),onPointerDownCapture:()=>i(!0),onPointerDown:o=>o.stopPropagation(),onFocusCapture:()=>i(!0),onBlurCapture:o=>{o.relatedTarget instanceof Node&&!o.currentTarget.contains(o.relatedTarget)&&i(!1)},onKeyDownCapture:o=>{o.key==="Escape"&&o.target.matches?.(".t2c-ta")&&(o.target.blur(),i(!1))},children:[e.jsx("div",{className:"newchat-pickers",children:e.jsx(Kn,{sessionId:null,cfg:m})}),e.jsxs("div",{className:"hp-projectbar",children:[e.jsx(qn,{}),e.jsx(Yn,{workspaces:f,value:u.key,onChange:a.setNewChatWs,onAddProject:window.tangu?.pickDirectory?()=>{a.addLocalWorkspace()}:void 0,onAddCloudProject:o=>{a.addCloudProject(o)}})]}),e.jsx(Jn,{sessionId:null,liveOwner:p==="home",prepareLiveSession:s,autoFocus:!1,disabled:a.connState!=="ok",running:!1,execConfig:m,models:W,modelsResponse:a.modelsResp,modelId:C,onModelChange:o=>a.setSessionModel(o,null),engines:a.engines,engineId:m.engineId,engineModels:m.engineId?a.engineCaps[m.engineId]?.models??[]:void 0,engineModelId:m.engineModelId,onEngineModelChange:o=>a.setNewChatCfg(w=>({...w,engineModelId:o||void 0})),engineCommands:m.engineId?a.engineCaps[m.engineId]?.commands??[]:void 0,thinkingLevel:m.thinkingLevel,ultra:m.ultra,onThinkingChange:(o,w)=>a.setSessionThinking(o,null,void 0,w),defaultModelIds:{backgroundModelId:a.desktopConfig?.backgroundModelId||"",imageModelId:a.cfg.imageModelId||"",visionModelId:a.cfg.visionModelId||""},onDefaultModelChange:a.setDefaultModel,onContextWindowChange:(o,w)=>{a.setModelContextWindow(o,w)},maxIterations:m.maxIterations,onMaxIterationsChange:o=>a.setNewChatCfg(w=>({...w,maxIterations:o})),verifyCommand:m.verifyCommand,onVerifyCommandChange:o=>a.setNewChatCfg(w=>({...w,verifyCommand:o||void 0})),planMode:m.planMode,onPlanModeChange:o=>a.setNewChatCfg(w=>({...w,planMode:o})),preset:m.preset,onPresetChange:o=>a.setSessionMode(o),voiceMode:E,onVoiceModeChange:v?o=>{a.setVoiceMode(v,o)}:void 0,groupChat:m.groupChat,groupAgents:m.groupAgents,groupTempAgents:m.groupTempAgents,onGroupChange:o=>a.setNewChatCfg(w=>({...w,...o})),skills:a.skillsList,agents:a.agentDefs,currentAgentSlug:v,onOpenSettings:()=>a.openSettings("skills"),onExecConfigChange:o=>a.setExecConfig(o,null),onSend:(o,w,R,S,M)=>t(o,w,R,S,M),onStop:()=>{},autoRefFromMain:!1})]})}function B({tile:t}){return t.kind==="space"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"hp-tile-icon",children:t.space.icon&&e.jsx(t.space.icon,{size:21})}),e.jsx("span",{className:"hp-tile-name",children:L(t.space.name)})]}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"hp-tile-icon hp-fpreview",children:[t.members.slice(0,4).map(s=>e.jsx("span",{className:"hp-fmini",children:s.icon&&e.jsx(s.icon,{size:11})},s.id)),t.members.length===0&&e.jsx(Bn,{size:19})]}),e.jsx("span",{className:"hp-tile-name",children:t.folder.name}),e.jsx("span",{className:"hp-folder-count",children:t.members.length})]})}function vs(){try{const t=JSON.parse(localStorage.getItem(Ze)||"[]");return Array.isArray(t)?[...new Set(t.filter(s=>typeof s=="string"&&s!==ne))]:[]}catch{return[]}}function bs({item:t}){const s=t.icon,i=t.tooltip?L(t.tooltip):"";return e.jsxs("button",{type:"button",className:"hp-tile hp-pinned-action","data-fixed-id":t.id,draggable:!1,"aria-label":i||void 0,title:i,onClick:t.onClick,children:[e.jsx("span",{className:"hp-tile-icon",children:s&&e.jsx(s,{size:21})}),e.jsx("span",{className:"hp-tile-name",children:i})]})}function Cs({space:t,onLaunch:s}){const i=`${G}${t.id}`,{attributes:d,listeners:p,setNodeRef:a,transform:u,isDragging:f}=Gn({id:i}),l={kind:"space",id:`space:${t.id}`,space:t};return e.jsx("button",{ref:a,type:"button",className:`hp-tile hp-pinned-space${f?" dragging":""}`,"data-space-id":t.id,style:{transform:xe.Transform.toString(u)},"aria-label":L(t.name),title:L(t.name),...d,...p,onClick:()=>{f||s(t.id)},children:e.jsx(B,{tile:l})})}function Ss({actions:t,spaces:s,onLaunch:i,labelText:d}){const{isOver:p,setNodeRef:a}=$n({id:me});return e.jsxs("div",{ref:a,className:"hp-pinned-zone","data-over":p||void 0,"aria-label":d,children:[t.map(u=>e.jsx(bs,{item:u},u.id)),s.map(u=>e.jsx(Cs,{space:u,onLaunch:i},u.id))]})}function Ge({tile:t,over:s,open:i,onOpen:d,onLaunch:p,onMenu:a}){const{attributes:u,listeners:f,setNodeRef:l,transform:j,transition:m,isDragging:C}=Ye({id:t.id}),W=t.kind==="space"?L(t.space.name):t.folder.name,v={transform:xe.Transform.toString(j),transition:m?`${m}, color var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out)`:void 0};return e.jsx("button",{ref:l,type:"button",style:v,className:`hp-tile${t.kind==="folder"?" hp-folder":""}${C?" dragging":""}${i?" on":""}`,"data-id":t.id,"data-over":s||void 0,"aria-label":W,title:W,...u,...f,onClick:E=>{C||(t.kind==="folder"?(E.stopPropagation(),d(E,t.id)):p(t.space.id))},onContextMenu:t.kind==="folder"?E=>a(E,t.id):void 0,children:e.jsx(B,{tile:t})})}function ks({member:t,onLaunch:s,onMenu:i}){const d=`space:${t.id}`,{attributes:p,listeners:a,setNodeRef:u,transform:f,transition:l,isDragging:j}=Ye({id:d});return e.jsxs("button",{ref:u,type:"button",className:`hp-folder-app${j?" dragging":""}`,style:{transform:xe.Transform.toString(f),transition:l},"data-id":d,title:L(t.name),...p,...a,onClick:()=>{j||s(t.id)},onContextMenu:m=>i(m,d),children:[e.jsx("span",{className:"hp-folder-app-icon",children:t.icon&&e.jsx(t.icon,{size:24})}),e.jsx("span",{children:L(t.name)})]})}function ys(t){const s=()=>{const p=new Date;return{time:Hn(p),date:Un(p,{locale:t}),hour:p.getHours()}},[i,d]=g.useState(s);return g.useEffect(()=>{const p=()=>d(u=>{const f=s();return f.time===u.time&&f.date===u.date?u:f});p();const a=setInterval(p,1e3);return()=>clearInterval(a)},[t]),i}function Ns(){const[t,s]=g.useState("");return g.useEffect(()=>{let i=!0;const d=()=>{window.tangu?.authStatus?.().then(a=>{i&&s(a?.loggedIn&&(a.nickname||a.username)||"")}).catch(()=>{})};d();const p=window.tangu?.onAuthChanged?.(d);return()=>{i=!1,p?.()}},[]),t}function Ms(){const t=fe(l=>l.spaces),s=Q(l=>l.order),d=Q(l=>l.folders).filter(l=>l.zone==="top"),p=l=>t.find(j=>`space:${j.id}`===l),a=new Set(d.flatMap(l=>l.items)),u=En([...t.map(l=>`space:${l.id}`),...d.map(l=>l.id)],s).filter(l=>!a.has(l)),f=[];for(const l of u){if(l===`space:${ne}`)continue;const j=d.find(C=>C.id===l);if(j){f.push({kind:"folder",id:l,folder:j,members:j.items.map(p).filter(C=>!!C)});continue}const m=p(l);m&&f.push({kind:"space",id:l,space:m})}return{tiles:f,topIds:u,order:s}}function Xs(t){const{t:s,locale:i}=bn(),d=i==="zh",p=ys(i),a=Ns(),u=fe(n=>n.spaces),f=Q(n=>n.items),{tiles:l,topIds:j,order:m}=Ms(),[C,W]=g.useState(vs),[v,E]=g.useState(null),[o,w]=g.useState(null),[R,S]=g.useState(!1),[M,y]=g.useState(null),[O,N]=g.useState(null),[Qe,en]=g.useState(!1),[nn,be]=g.useState(!1),[K,U]=g.useState(!1),[h,se]=g.useState(rs),[T,te]=g.useState(null),[H,sn]=g.useState([]),[Ce,Se]=g.useState(!1),[ke,q]=g.useState(""),[tn,on]=g.useState(0),ye=g.useRef(null),oe=g.useRef(null),z=g.useRef(null),Y=g.useRef(null),[Ne]=g.useState(()=>{try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}),ae=Cn(Le(yn,{activationConstraint:{distance:6}}),Le(kn,{coordinateGetter:Sn}));g.useEffect(()=>{is(h)},[h]),g.useEffect(()=>{try{localStorage.setItem(Ze,JSON.stringify(C))}catch{}},[C]),g.useEffect(()=>{let n=!0;return us().then(r=>{if(n){if(!r){se(c=>c.source==="custom"?{...c,source:"theme"}:c);return}te(URL.createObjectURL(r))}}).catch(()=>{}),()=>{n=!1}},[]),g.useEffect(()=>()=>{T&&URL.revokeObjectURL(T)},[T]),g.useEffect(()=>{if(h.source!=="bing")return;let n=!0;return Se(!0),q(""),cs(i).then(r=>{n&&(sn(r),r[0]&&se(c=>c.source==="bing"&&c.bingDaily&&c.bing?.id!==r[0].id?{...c,bing:r[0]}:c))}).catch(()=>{n&&q(s("home.wallpaper.bingError"))}).finally(()=>{n&&Se(!1)}),()=>{n=!1}},[tn,i,s,h.source]),g.useEffect(()=>()=>{z.current&&(window.clearTimeout(z.current),z.current=null);const n=Y.current;Y.current=null,n?.()},[]);const F=n=>z.current?!1:Ne?(n(),!0):(en(!0),Y.current=n,z.current=window.setTimeout(()=>{z.current=null,Y.current=null,n()},ms),!0),re=u.some(n=>n.id==="tangu"),Me=p.hour<5?"home.greet.night":p.hour<11?"home.greet.morning":p.hour<18?"home.greet.afternoon":"home.greet.evening",D=()=>Q.getState(),an=()=>{y(null),S(!1),N(null)},J=h.source==="bing"?h.bing?.url||null:h.source==="custom"?T:null,I=n=>{se(r=>({...r,...n}))},rn=n=>{if(n==="custom"&&!T){oe.current?.click();return}if(n==="bing"){I({source:n,bing:h.bing||H[0]||null});return}I({source:n})},ln=n=>{n&&(q(""),hs(n).then(()=>{te(URL.createObjectURL(n)),I({source:"custom"})}).catch(r=>{q(s(r instanceof Error&&r.message==="TOO_LARGE"?"home.wallpaper.tooLarge":"home.wallpaper.invalid"))}))},cn=()=>{gs().catch(()=>{}),te(null),I({source:"theme"})},dn=(n,r)=>{if(!n||n===r)return;const c=Vn(m,j),x=c.indexOf(r);D().setZoneOrder("top",_e(c,n,x>=0?x:c.length))},pn=(n,r)=>{!n||n===r||n.startsWith("folder:")||(D().moveIntoFolder(r,n),D().setZoneOrder("top",$e(m,j,n)))},un=n=>{D().moveOutOfFolder(n),D().setZoneOrder("top",[...$e(m,j,n),n]),S(!0)},hn=()=>{N(null),Fe(d?"新建收纳夹":"New folder",d?"收纳夹":"Folder").then(n=>{const r=n?.trim();r&&(D().addFolder("top",r),S(!0))})},Pe=()=>{E(null),w(null)},Ee=n=>{y(null),N(null),E(String(n.active.id))},De=n=>w(n.over?String(n.over.id):null),Ie=n=>Pe(),Oe=n=>{const r=String(n.active.id),c=n.over?String(n.over.id):null;if(Pe(),r.startsWith(G)){if(c!==me){const k=r.slice(G.length);W(P=>P.filter(Te=>Te!==k))}return}if(c===me){const k=l.find(P=>P.id===r);k?.kind==="space"&&k.space.id!==ne&&W(P=>P.includes(k.space.id)?P:[...P,k.space.id]);return}if(!c||r===c)return;const x=l.find(k=>k.id===c);!r.startsWith("folder:")&&x?.kind==="folder"?pn(r,c):dn(r,c)},ie=(n,r,c)=>{n.preventDefault(),n.stopPropagation(),y(null),N({x:n.clientX,y:n.clientY,kind:r,id:c})},Ae=(n,r)=>{const c=n.currentTarget.getBoundingClientRect(),x=ye.current?.getBoundingClientRect();N(null),S(!1),y(k=>k?.id===r?null:{id:r,dx:x?c.left+c.width/2-(x.left+x.width/2):0,dy:x?c.top+c.height/2-(x.top+x.height/2):0})},b=M?l.find(n=>n.id===M.id):void 0,X=b?.kind==="folder"?b.members:[],Z=l.slice(0,fs),We=Math.max(0,l.length-Z.length),_=v?l.find(n=>n.id===v):void 0,le=v?.startsWith(G)?u.find(n=>n.id===v.slice(G.length)):void 0,gn=C.map(n=>u.find(r=>r.id===n)).filter(n=>!!n),mn=xs.map(n=>f.find(r=>r.id===n)).filter(n=>!!n),fn=Math.max(0,u.length-(u.some(n=>n.id===ne)?1:0)),xn=n=>{if(!b||b.kind!=="folder"||!n.over)return;const r=String(n.active.id),c=String(n.over.id);if(r===c)return;const x=b.folder.items.indexOf(c);D().setFolderItems(b.id,_e(b.folder.items,r,x<0?b.folder.items.length:x))},jn=(n,r,c,x,k)=>re?new Promise(P=>{F(()=>{$("tangu"),Be.getState().openView("chat",{followActive:!0,reuseKey:"primary"},"main"),P(V.getState().send(n,r,c,x,k,null))})||P(!1)}):Promise.resolve(!1),wn=()=>re?new Promise(n=>{F(()=>{$("tangu"),Be.getState().openView("chat",{followActive:!0,reuseKey:"primary"},"main");const c=V.getState().activeId;V.getState().newSession().then(()=>{const x=V.getState().activeId;n(x&&x!==c?x:null)},()=>n(null))})||n(null)}):Promise.resolve(null),ce=()=>{const n=document.activeElement;n instanceof HTMLTextAreaElement&&n.matches(".hp-composer .t2c-ta")&&n.blur(),be(!1)},Re=()=>{ce(),U(!1),y(null),N(null),S(!0)},vn=n=>{n.target.closest('button, input, textarea, [contenteditable="true"], .hp-composer, .ctx-menu, .hp-wallpaper-sheet')||(n.preventDefault(),n.stopPropagation(),N(null),M?y(null):R?S(!1):K?U(!1):Re())};return e.jsxs("div",{ref:ye,className:`hp-root${Ne?" hp-still":""}${nn?" hp-composer-focused":""}${K?" hp-layer-focused":""}${M||R?" hp-secondary-open":""}`,"data-wallpaper":J||h.themePreset==="hack2gate"?"true":void 0,"data-theme-preset":h.themePreset,"data-focus-blur":h.focusBlur?"true":"false","data-vignette":h.vignette?"true":"false",onPointerDown:n=>{n.target.closest(".hp-composer")||ce()},onContextMenu:vn,onClick:an,children:[e.jsx("div",{className:"hp-wallpaper",style:J?{backgroundImage:`url(${JSON.stringify(J)})`}:void 0,"aria-hidden":!0}),e.jsx("div",{className:"hp-wallpaper-art","aria-hidden":!0}),e.jsx("div",{className:"hp-wallpaper-edge","aria-hidden":!0}),e.jsx("div",{className:"hp-wallpaper-tone","aria-hidden":!0}),e.jsx("div",{className:"hp-glow","aria-hidden":!0}),e.jsx("button",{type:"button",className:`hp-wallpaper-button${K?" on":""}`,"aria-label":s("home.wallpaper.open"),title:s("home.wallpaper.open"),onClick:n=>{n.stopPropagation(),ce(),N(null),y(null),S(!1),U(r=>!r)},children:e.jsx(Nn,{size:16})}),e.jsxs("div",{className:`hp-stack${Qe?" leaving":""}`,children:[e.jsxs("div",{className:"hp-title",children:[e.jsx("div",{className:"hp-brand",children:"Forsion is All You Need"}),e.jsx("div",{className:"hp-clock",children:p.time}),e.jsx("div",{className:"hp-date",children:p.date}),e.jsx("div",{className:"hp-greet",children:a?s(Me+".named",{name:a}):s(Me)})]}),re&&e.jsx(ws,{onDispatch:jn,onStartCall:wn,onInputModeChange:be}),e.jsx("section",{className:"hp-spaces","data-total":l.length,children:e.jsxs(de,{sensors:ae,collisionDetection:Ve,onDragStart:Ee,onDragOver:De,onDragCancel:Ie,onDragEnd:Oe,children:[e.jsxs("div",{className:"hp-space-row",children:[e.jsx(Ss,{actions:mn,spaces:gn,labelText:s("home.pinnedSpaces"),onLaunch:n=>F(()=>$(n))}),e.jsx("span",{className:"hp-space-divider","aria-hidden":!0}),e.jsx("div",{className:"hp-space-main",children:Z.length>0?e.jsx(pe,{items:Z.map(n=>n.id),strategy:ue,children:e.jsxs("div",{className:"hp-dock",children:[Z.map(n=>e.jsx(Ge,{tile:n,over:o===n.id,open:M?.id===n.id,onOpen:Ae,onLaunch:r=>F(()=>$(r)),onMenu:(r,c)=>ie(r,"folder",c)},n.id)),We>0&&e.jsxs("button",{type:"button",className:"hp-tile hp-more",onClick:n=>{n.stopPropagation(),Re()},title:s("home.showAll"),children:[e.jsx("span",{className:"hp-tile-icon",children:e.jsx(Ue,{size:20})}),e.jsx("span",{className:"hp-tile-name",children:s("home.showAll")}),e.jsxs("span",{className:"hp-more-count",children:["+",We]})]})]})}):e.jsx("div",{className:"hp-spaces-empty",children:s("home.noSpaces")})})]}),e.jsxs(ze,{dropAnimation:null,children:[_&&!R&&e.jsx("div",{className:`hp-tile hp-drag-overlay${_.kind==="folder"?" hp-folder":""}`,children:e.jsx(B,{tile:_})}),le&&!R&&e.jsx("div",{className:"hp-tile hp-drag-overlay hp-pinned-space",children:e.jsx(B,{tile:{kind:"space",id:`space:${le.id}`,space:le}})})]})]})})]}),e.jsx("input",{ref:oe,className:"hp-wallpaper-file",type:"file",accept:"image/*",onChange:n=>{ln(n.currentTarget.files?.[0]),n.currentTarget.value=""}}),J&&h.source==="bing"&&h.bing?.copyright&&e.jsx("div",{className:"hp-wallpaper-credit",title:h.bing.copyright,children:h.bing.copyright}),K&&e.jsx("div",{className:"hp-wallpaper-stage",onClick:()=>U(!1),children:e.jsxs("section",{className:"hp-wallpaper-sheet","aria-label":s("home.wallpaper.title"),onClick:n=>n.stopPropagation(),children:[e.jsxs("header",{className:"hp-wallpaper-head",children:[e.jsxs("div",{children:[e.jsx("strong",{children:s("home.wallpaper.title")}),e.jsx("span",{children:s("home.wallpaper.subtitle")})]}),e.jsx("button",{type:"button",onClick:()=>U(!1),"aria-label":s("common.close"),children:e.jsx(he,{size:16})})]}),e.jsx("div",{className:"hp-wallpaper-sources","aria-label":s("home.wallpaper.source"),children:["theme","bing","custom"].map(n=>e.jsxs("button",{type:"button",className:h.source===n?"on":"","aria-pressed":h.source===n,"data-source":n,onClick:()=>rn(n),children:[h.source===n&&e.jsx(ge,{size:12}),s(`home.wallpaper.${n}`)]},n))}),ke&&e.jsx("div",{className:"hp-wallpaper-error",children:ke}),h.source==="theme"&&e.jsxs("div",{className:"hp-theme-presets",children:[e.jsx("p",{children:s("home.wallpaper.themeHint")}),e.jsx("div",{children:js.map(n=>e.jsxs("button",{type:"button",className:h.themePreset===n?"on":"","data-preset":n,"aria-pressed":h.themePreset===n,onClick:()=>I({source:"theme",themePreset:n}),children:[e.jsx("span",{className:"hp-theme-preview","data-preset":n,"aria-hidden":!0}),e.jsx("span",{children:s(`home.wallpaper.preset.${n}`)}),h.themePreset===n&&e.jsx("i",{children:e.jsx(ge,{size:11})})]},n))})]}),h.source==="bing"&&e.jsxs("div",{className:"hp-wallpaper-bing",children:[e.jsxs("div",{className:"hp-wallpaper-row",children:[e.jsxs("button",{type:"button",className:`hp-wallpaper-switch${h.bingDaily?" on":""}`,role:"switch","aria-checked":h.bingDaily,onClick:()=>{const n=!h.bingDaily;I({bingDaily:n,bing:n&&H[0]||h.bing})},children:[e.jsx("span",{"aria-hidden":!0})," ",s("home.wallpaper.daily")]}),e.jsxs("button",{type:"button",className:"hp-wallpaper-refresh",disabled:Ce,onClick:()=>on(n=>n+1),children:[e.jsx(Mn,{size:13})," ",s("home.wallpaper.refresh")]})]}),Ce&&H.length===0&&e.jsx("div",{className:"hp-wallpaper-loading",children:s("home.wallpaper.loading")}),H.length>0&&e.jsx("div",{className:"hp-wallpaper-grid",children:H.map((n,r)=>e.jsxs("button",{type:"button",className:h.bing?.id===n.id?"on":"",title:n.copyright||n.title,"aria-label":n.title||n.copyright||s("home.wallpaper.bing"),onClick:()=>I({source:"bing",bing:n,bingDaily:r===0&&h.bingDaily}),children:[e.jsx("img",{src:n.thumbnailUrl,alt:""}),h.bing?.id===n.id&&e.jsx("span",{children:e.jsx(ge,{size:12})})]},n.id))})]}),h.source==="custom"&&e.jsxs("div",{className:"hp-wallpaper-custom",children:[e.jsx("div",{className:"hp-wallpaper-custom-preview",style:T?{backgroundImage:`url(${JSON.stringify(T)})`}:void 0}),e.jsxs("div",{children:[e.jsx("strong",{children:s("home.wallpaper.customReady")}),e.jsx("span",{children:s("home.wallpaper.customHint")})]}),e.jsxs("button",{type:"button",onClick:()=>oe.current?.click(),children:[e.jsx(Xn,{size:13})," ",s("home.wallpaper.replace")]}),e.jsx("button",{type:"button",onClick:cn,children:s("home.wallpaper.remove")})]}),e.jsxs("div",{className:"hp-wallpaper-options",children:[e.jsxs("button",{type:"button",className:h.focusBlur?"on":"",role:"switch","aria-checked":h.focusBlur,onClick:()=>I({focusBlur:!h.focusBlur}),children:[e.jsxs("span",{children:[e.jsx("strong",{children:s("home.wallpaper.focusBlur")}),e.jsx("small",{children:s("home.wallpaper.focusBlurHint")})]}),e.jsx("i",{"aria-hidden":!0})]}),e.jsxs("button",{type:"button",className:h.vignette?"on":"",role:"switch","aria-checked":h.vignette,onClick:()=>I({vignette:!h.vignette}),children:[e.jsxs("span",{children:[e.jsx("strong",{children:s("home.wallpaper.vignette")}),e.jsx("small",{children:s("home.wallpaper.vignetteHint")})]}),e.jsx("i",{"aria-hidden":!0})]})]})]})}),R&&e.jsx("div",{className:"hp-organizer-stage",onClick:()=>S(!1),children:e.jsxs("section",{className:"hp-organizer-panel","aria-label":s("home.organizer.title"),onClick:n=>n.stopPropagation(),children:[e.jsxs("header",{className:"hp-organizer-head",children:[e.jsxs("div",{children:[e.jsx("span",{className:"hp-organizer-mark",children:e.jsx(Ue,{size:16})}),e.jsxs("span",{children:[e.jsx("strong",{children:s("home.organizer.title")}),e.jsx("small",{children:s("home.spaceCount",{n:fn})})]})]}),e.jsx("button",{type:"button",onClick:()=>S(!1),"aria-label":s("common.close"),children:e.jsx(he,{size:16})})]}),e.jsxs(de,{sensors:ae,collisionDetection:Ve,onDragStart:Ee,onDragOver:De,onDragCancel:Ie,onDragEnd:Oe,children:[e.jsx(pe,{items:l.map(n=>n.id),strategy:ue,children:e.jsxs("div",{className:"hp-organizer-grid",children:[l.map(n=>e.jsx(Ge,{tile:n,over:o===n.id,open:!1,onOpen:Ae,onLaunch:r=>{S(!1),F(()=>$(r))},onMenu:(r,c)=>ie(r,"folder",c)},n.id)),e.jsxs("button",{type:"button",className:"hp-organizer-new",onClick:hn,children:[e.jsx("span",{children:e.jsx(Zn,{size:22})}),e.jsx("small",{children:s("home.newFolder")})]})]})}),e.jsx(ze,{dropAnimation:null,children:_&&e.jsx("div",{className:`hp-tile hp-drag-overlay${_.kind==="folder"?" hp-folder":""}`,children:e.jsx(B,{tile:_})})})]}),e.jsx("footer",{children:s("home.organizer.hint")})]})}),M&&b?.kind==="folder"&&e.jsx("div",{className:"hp-folder-stage",onClick:()=>y(null),children:e.jsxs("section",{className:"hp-folder-panel",style:{"--hp-folder-dx":`${M.dx}px`,"--hp-folder-dy":`${M.dy}px`},"aria-label":b.folder.name,onClick:n=>n.stopPropagation(),children:[e.jsxs("header",{className:"hp-folder-head",children:[e.jsxs("div",{className:"hp-folder-identity",children:[e.jsx("span",{className:"hp-folder-hero",children:e.jsx(B,{tile:b})}),e.jsxs("span",{children:[e.jsx("strong",{children:b.folder.name}),e.jsx("small",{children:s("home.folderCount",{n:X.length})})]})]}),e.jsx("button",{type:"button",onClick:()=>y(null),"aria-label":s("common.close"),children:e.jsx(he,{size:16})})]}),X.length===0&&e.jsx("div",{className:"hp-folder-empty",children:s("home.folderEmpty")}),X.length>0&&e.jsx(de,{sensors:ae,collisionDetection:qe,onDragEnd:xn,children:e.jsx(pe,{items:b.folder.items,strategy:ue,children:e.jsx("div",{className:"hp-folder-grid",children:X.map(n=>e.jsx(ks,{member:n,onLaunch:r=>{y(null),F(()=>$(r))},onMenu:(r,c)=>ie(r,"member",c)},n.id))})})}),e.jsx("footer",{children:s("home.folderHint")})]})}),O&&e.jsxs(Pn,{className:"ctx-menu",x:O.x,y:O.y,onClick:n=>n.stopPropagation(),children:[O.kind==="folder"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{const n=O.id,r=l.find(c=>c.id===n);N(null),Fe(d?"重命名收纳夹":"Rename folder",r?.kind==="folder"?r.folder.name:"").then(c=>{const x=c?.trim();x&&D().renameFolder(n,x)})},children:[e.jsx(Qn,{size:13})," ",d?"重命名":"Rename"]}),e.jsxs("button",{onClick:()=>{D().removeFolder(O.id),N(null)},children:[e.jsx(ss,{size:13})," ",d?"解散收纳夹":"Dissolve folder"]})]}),O.kind==="member"&&e.jsxs("button",{onClick:()=>{un(O.id),N(null),y(null)},children:[e.jsx(es,{size:13})," ",d?"移出收纳夹":"Move out"]})]})]})}export{Xs as HomepageView};
@@ -1,3 +0,0 @@
1
- import{u as E,d as j,j as e,t as z}from"./index-CF4RV4mh.js";import{v as G,E as O,o as Q,u as b,b as B,i as k,r as F,m as D,d as K,e as W,t as J}from"./RightPanel-C3OJTIqT.js";import{z as P,u as $,S as A,i as Z,jA as ee,cn as ie,jB as T,C as q,aO as te,af as ae,gD as se,bQ as ne,bR as oe,aQ as re,c0 as le,aP as de}from"./appStore-Dg9WALEA.js";import{C as ce,G as me}from"./ChatView-C-jCJnyS.js";import{j as ue,k as he,a as H,l as pe,n as ge,o as _,L as U,q as xe,t as je,e as Se,p as fe,b as be,d as ve}from"./imageStudio-C_Rs630L.js";import{L as ye}from"./lock-BnGHxjeE.js";import{L as we}from"./InlineFiles-C_hjvn3u.js";import{R as Ce}from"./rotate-ccw-CUlnplr0.js";import"./nativeDownload-D-f1_L2S.js";import"./folder-DlxnPmWY.js";import"./folder-plus-D1TDb7k9.js";import"./upload-BbeAsMuD.js";import"./pencil-Cvk91P_Z.js";import"./ipc-DQOD2UKk.js";import"./client-BSKpsyAw.js";import"./RunLocationPicker-CTYXUH2z.js";import"./codeStudioStore-C2mWfm32.js";import"./ModelPill-BPlgovPo.js";import"./create-4xUyKtAF.js";import"./approvalText-Cy2UAUAQ.js";import"./SidebarRow-BuSkKH5q.js";import"./message-square-plus-BiAZAvcw.js";import"./hand-Crrw-nSn.js";import"./waves-horizontal-B8ZpHQ5H.js";import"./ellipsis-r1EcXsFq.js";import"./pageChrome-C9_azUYW.js";import"./emoji-DGaxpCIu.js";import"./pdf.worker.min-CGb3BKV9.js";import"./code-xml-BALV9u_c.js";import"./zoom-in-hr5bRpDL.js";import"./undo-2-tUKCv5Gs.js";import"./SketchCard-D87GADyG.js";import"./terminal-DIXogYJY.js";import"./circle-x-D7s-M5sB.js";import"./circle-question-mark-WL3vbp-Z.js";import"./FloatingToc-CENybkAA.js";import"./MarkdownBlock-DIjYEhTK.js";import"./index-BCubCwdT.js";import"./linkFollow-C0_3k_PC.js";import"./mdMarks-Bq7Hl-4C.js";import"./listFold-BsOVn9UZ.js";import"./mdMarkStore-CsKl7C8O.js";import"./arrow-up-right-CpQs92mu.js";const Ne=[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]],ke=P("crop",Ne);const Me=[["path",{d:"m3 7 5 5-5 5V7",key:"couhi7"}],["path",{d:"m21 7-5 5 5 5V7",key:"6ouia7"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 2v2",key:"tus03m"}]],Ie=P("flip-horizontal-2",Me);const ze=[["path",{d:"m17 3-5 5-5-5h10",key:"1ftt6x"}],["path",{d:"m17 21-5-5-5 5h10",key:"1m0wmu"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}]],Ee=P("flip-vertical-2",ze);function $e({image:i,onApply:r,onCancel:n}){const{t:l}=E(),a=ue(i.blob),[c,h]=j.useState(i.crop||{x:0,y:0,w:i.width,h:i.height}),s=j.useRef(null),p=j.useRef(null),S=o=>{const d=Math.max(0,Math.min(i.width-1,Math.round(o.x))),f=Math.max(0,Math.min(i.height-1,Math.round(o.y)));return{x:d,y:f,w:Math.max(1,Math.min(i.width-d,Math.round(o.w))),h:Math.max(1,Math.min(i.height-f,Math.round(o.h)))}};return e.jsxs("div",{className:"ims-crop",onKeyDown:o=>{o.key==="Escape"&&(o.stopPropagation(),n())},children:[e.jsx("h4",{children:l("imageStudio.crop")}),e.jsx("p",{children:l("imageStudio.cropHint")}),e.jsxs("div",{ref:p,className:"ims-crop-stage",style:{aspectRatio:i.width/i.height},onPointerDown:o=>{const d=o.currentTarget.getBoundingClientRect(),f=o.target.dataset.edge||"move";s.current={pointer:o.pointerId,x:o.clientX,y:o.clientY,base:c,edge:f,sx:i.width/d.width,sy:i.height/d.height},o.currentTarget.setPointerCapture(o.pointerId),o.preventDefault()},onPointerMove:o=>{const d=s.current;if(!d||d.pointer!==o.pointerId)return;const f=(o.clientX-d.x)*d.sx,g=(o.clientY-d.y)*d.sy,u=d.base;if(d.edge==="move")h(S({...u,x:Math.max(0,Math.min(i.width-u.w,u.x+f)),y:Math.max(0,Math.min(i.height-u.h,u.y+g))}));else{const y=d.edge.includes("w")?Math.max(0,Math.min(u.x+u.w-1,u.x+f)):u.x,t=d.edge.includes("n")?Math.max(0,Math.min(u.y+u.h-1,u.y+g)):u.y,x=d.edge.includes("e")?Math.min(i.width,Math.max(u.x+1,u.x+u.w+f)):u.x+u.w,v=d.edge.includes("s")?Math.min(i.height,Math.max(u.y+1,u.y+u.h+g)):u.y+u.h;h(S({x:y,y:t,w:x-y,h:v-t}))}},onPointerUp:()=>{s.current=null},onPointerCancel:()=>{s.current=null},children:[a&&e.jsx("img",{src:a,alt:i.name,draggable:!1}),e.jsx("div",{className:"ims-crop-box",style:{left:`${c.x/i.width*100}%`,top:`${c.y/i.height*100}%`,width:`${c.w/i.width*100}%`,height:`${c.h/i.height*100}%`},children:["nw","ne","sw","se"].map(o=>e.jsx("span",{"data-edge":o,className:`ims-crop-handle ${o}`},o))})]}),e.jsxs("select",{"aria-label":l("imageStudio.cropRatio"),defaultValue:"",onChange:o=>{const d=Number(o.target.value)||i.width/i.height,f=Math.min(i.width,i.height*d),g=f/d;h(S({x:(i.width-f)/2,y:(i.height-g)/2,w:f,h:g}))},children:[e.jsx("option",{value:"",disabled:!0,children:l("imageStudio.cropRatio")}),e.jsx("option",{value:"0",children:l("imageStudio.original")}),[[1,"1:1"],[.8,"4:5"],[2/3,"2:3"],[16/9,"16:9"],[9/16,"9:16"]].map(([o,d])=>e.jsx("option",{value:o,children:d},d))]}),e.jsx("div",{className:"ims-fields",children:["x","y","w","h"].map(o=>e.jsxs("label",{children:[l(`imageStudio.${o}`),e.jsx("input",{type:"number","aria-label":l(`imageStudio.crop.${o}`),value:c[o],min:o==="x"||o==="y"?0:1,max:o==="x"||o==="w"?i.width:i.height,onChange:d=>h(S({...c,[o]:Number(d.target.value)||0}))})]},o))}),e.jsxs("div",{className:"ims-button-row",children:[e.jsx("button",{onClick:n,children:l("imageStudio.cancel")}),e.jsx("button",{className:"ims-primary",disabled:!G(c,i.width,i.height),onClick:()=>r(c),children:l("imageStudio.applyCrop")})]})]})}const Pe=O,Le=["low","medium","high","xhigh","max"];function Re(i,r,n,l){const[a,c]=n.split(":").map(Number),h=1+Math.max(.1,Math.min(1,l)),s=Math.ceil(Math.max(i*h,r*h*a/c)),p=Math.ceil(s*c/a);return{w:s,h:p,x:Math.floor((s-i)/2),y:Math.floor((p-r)/2)}}async function Fe(i,r,n,l,a){if(!i.length||i.length>8)throw new Error(z("imageStudio.ai.referenceLimit"));if(r!=="expand")return Promise.all(i.map(s=>he(s,a)));const c=await H([i[0]],!0,1024),h=await pe(c);try{const s=Re(h.width,h.height,n,l),p=Math.min(1,1536/Math.max(s.w,s.h)),S=document.createElement("canvas");S.width=Math.round(s.w*p),S.height=Math.round(s.h*p);const o=S.getContext("2d");if(!o)throw new Error("Canvas unavailable");o.drawImage(h,s.x*p,s.y*p,h.width*p,h.height*p);const d=await new Promise((g,u)=>S.toBlob(y=>y?g(y):u(new Error("PNG encoding failed")),"image/png")),f=await ge(d);return[{name:"expand-reference.png",mimeType:"image/png",size:d.size,data:f.split(",")[1]}]}finally{h.close()}}function Ae(i,r,n,l,a,c=""){return[z(`imageStudio.ai.prompt.${i}`),z(`imageStudio.ai.sourcePrompt.${i==="expand"?"current":a}`),r.trim(),z("imageStudio.ai.outputPrompt",{ratio:n.requested,engineRatio:n.engine,count:l}),c?z("imageStudio.ai.qualityPrompt",{quality:c}):""].filter(Boolean).join(`
2
-
3
- `)}function Be({board:i,images:r}){const{t:n}=E(),[l,a]=j.useState("edit"),[c,h]=j.useState(""),[s,p]=j.useState("original"),[S,o]=j.useState("current"),[d,f]=j.useState(1),[g,u]=j.useState(.5),[y,t]=j.useState(""),[x,v]=j.useState(!1),[w,L]=j.useState(""),N=$(m=>!!(i.sessionId&&m.runningBySession[i.sessionId])),C=Q(r[0],s),V=async()=>{v(!0),L("");let m=[];try{const M=await _(i.id);if(b.getState().activeId!==i.id)return;if($.getState().runningBySession[M])throw new Error(n("imageStudio.ai.wait"));m=b.getState().beginGeneration(i.id,M,{count:d,aspect:C.aspect,ratio:C.requested,kind:"edit",sourceIds:r.map(Y=>Y.id)});const R=l==="expand"?"current":S,X=await Fe(r,l,C.requested,g,R);if(Z.getState().openView("image-studio-chat",{},"left"),!await $.getState().send(Ae(l,c,C,d,R,y),X,void 0,void 0,void 0,M))throw new Error(n("imageStudio.ai.sendFailed"));b.getState().activateGeneration(m)}catch(M){m.length&&b.getState().failGeneration(i.id,{ids:m}),L(M instanceof Error?M.message:String(M))}finally{v(!1)}};return e.jsxs("details",{className:"ims-ai",open:!0,children:[e.jsxs("summary",{children:[e.jsx(A,{size:15}),n("imageStudio.ai.title"),e.jsxs("span",{children:[r.length," ",n("imageStudio.ai.references")]})]}),e.jsxs("div",{className:"ims-ai-body",children:[e.jsx("div",{className:"ims-ai-modes",role:"group","aria-label":n("imageStudio.ai.mode"),children:["edit","background","expand"].map(m=>e.jsx("button",{"aria-pressed":l===m,disabled:N||x||m!=="edit"&&r.length!==1,onClick:()=>a(m),children:n(`imageStudio.ai.${m}`)},m))}),e.jsx("p",{className:"ims-caption",children:n(`imageStudio.ai.hint.${l}`)}),e.jsx("textarea",{"aria-label":n("imageStudio.ai.instruction"),placeholder:n("imageStudio.ai.placeholder"),value:c,onChange:m=>h(m.target.value),maxLength:8e3,rows:3,disabled:x||N}),e.jsxs("label",{className:"ims-ai-source",children:[n("imageStudio.ai.source"),e.jsxs("select",{"aria-label":n("imageStudio.ai.source"),value:l==="expand"?"current":S,onChange:m=>o(m.target.value),disabled:x||N||l==="expand",children:[e.jsx("option",{value:"current",children:n("imageStudio.ai.source.current")}),e.jsx("option",{value:"original",children:n("imageStudio.ai.source.original")})]})]}),e.jsxs("div",{className:"ims-fields",children:[e.jsxs("label",{children:[n("imageStudio.ai.ratio"),e.jsxs("select",{"aria-label":n("imageStudio.ai.ratio"),value:s,onChange:m=>p(m.target.value),disabled:x||N,children:[e.jsx("option",{value:"original",children:n("imageStudio.ai.ratio.original",{ratio:C.originalLabel})}),Pe.map(m=>e.jsx("option",{value:m,children:m},m))]})]}),e.jsxs("label",{children:[n("imageStudio.ai.count"),e.jsx("select",{"aria-label":n("imageStudio.ai.count"),value:d,onChange:m=>f(Number(m.target.value)),disabled:x||N,children:[1,2,3,4].map(m=>e.jsx("option",{children:m},m))})]}),e.jsxs("label",{children:[n("imageStudio.ai.quality"),e.jsxs("select",{"aria-label":n("imageStudio.ai.quality"),value:y,onChange:m=>t(m.target.value),disabled:x||N,children:[e.jsx("option",{value:"",children:n("imageStudio.ai.quality.default")}),Le.map(m=>e.jsx("option",{value:m,children:n(`imageStudio.ai.quality.${m}`)},m))]})]})]}),C.requested!==C.engine&&e.jsx("p",{className:"ims-caption ims-ai-ratio-note",children:n("imageStudio.ai.ratioFit",{ratio:C.requested,engineRatio:C.engine})}),(y==="xhigh"||y==="max")&&e.jsx("p",{className:"ims-caption",children:n("imageStudio.ai.qualityNote")}),l==="expand"&&e.jsxs("label",{children:[n("imageStudio.ai.margin"),e.jsx("input",{"aria-label":n("imageStudio.ai.margin"),type:"range",min:".1",max:"1",step:".1",value:g,onChange:m=>u(Number(m.target.value))}),e.jsxs("output",{children:[Math.round(g*100),"%"]})]}),e.jsxs("button",{className:"ims-primary",disabled:x||N||!r.length||r.length>8||l==="edit"&&!c.trim(),onClick:()=>{V()},children:[e.jsx(A,{size:15}),n(N||x?"imageStudio.ai.running":"imageStudio.ai.submit")]}),e.jsx("p",{className:"ims-caption",children:n("imageStudio.ai.preserve")}),w&&e.jsx("p",{role:"alert",children:w})]})]})}function Ii(i){const{t:r}=E(),n=b(s=>s.activeId?s.boards[s.activeId]:void 0),[l,a]=j.useState(!1),[c,h]=j.useState("");return j.useEffect(()=>{b.getState().hydrate()},[]),j.useEffect(()=>{n?.sessionId&&$.getState().loadSessionHistory(n.sessionId)},[n?.sessionId]),n?.sessionId?e.jsx("div",{className:"ims-chat","data-image-studio-chat":n.id,children:e.jsx(ce,{...i,params:{...i.params,followActive:!1,sessionId:n.sessionId,childSurface:!0}},n.sessionId)}):e.jsxs("div",{className:"ims-panel ims-chat-empty",children:[e.jsx(q,{size:26,strokeWidth:1.3}),e.jsx("h3",{children:r("imageStudio.chat")}),e.jsx("p",{children:r(n?"imageStudio.chatHint":"imageStudio.choose")}),n&&e.jsxs("button",{className:"ims-primary",disabled:l,onClick:async()=>{a(!0),h("");try{await _(n.id)}catch(s){h(String(s))}finally{a(!1)}},children:[l?e.jsx(te,{size:15,className:"ims-spin"}):e.jsx(ae,{size:15}),r("imageStudio.connect")]}),c&&e.jsx("p",{role:"alert",children:r("imageStudio.error",{error:c})})]})}function zi(){const{t:i}=E(),r=b(s=>s.activeId?s.boards[s.activeId]:void 0),n=b(s=>s.selection),[l,a]=j.useState(""),c=r?B(r).reverse().filter(s=>s.name.toLocaleLowerCase().includes(l.toLocaleLowerCase())):[],h=(s,p)=>r&&b.getState().update(r.id,S=>D(S,o=>o.id===s?{...o,...p}:o));return e.jsxs("section",{className:"ims-panel ims-layers",children:[e.jsx("h3",{children:i("imageStudio.layers")}),e.jsx("input",{type:"search","aria-label":i("imageStudio.searchLayers"),placeholder:i("imageStudio.searchLayers"),value:l,onChange:s=>a(s.target.value)}),e.jsx("div",{className:"ims-asset-list",children:c.map(s=>e.jsxs("div",{className:`ims-layer-row${n.includes(s.id)?" is-selected":""}`,"data-layer-id":s.id,children:[e.jsxs("button",{className:"ims-asset","aria-pressed":n.includes(s.id),onClick:p=>b.setState({selection:p.shiftKey?n.includes(s.id)?n.filter(S=>S!==s.id):[...n,s.id]:[s.id]}),children:[e.jsx("div",{className:"ims-layer-thumb",children:e.jsx(U,{item:s})}),e.jsxs("span",{children:[e.jsx("strong",{children:s.name}),e.jsx("small",{children:i(`imageStudio.kind.${xe(s)}`)})]})]}),e.jsx("button",{"aria-label":i(s.hidden?"imageStudio.show":"imageStudio.hide"),title:i(s.hidden?"imageStudio.show":"imageStudio.hide"),onClick:()=>h(s.id,{hidden:!s.hidden}),children:s.hidden?e.jsx(ee,{size:14}):e.jsx(ie,{size:14})}),e.jsx("button",{"aria-label":i(s.locked?"imageStudio.unlock":"imageStudio.lock"),title:i(s.locked?"imageStudio.unlock":"imageStudio.lock"),onClick:()=>h(s.id,{locked:!s.locked}),children:s.locked?e.jsx(ye,{size:14}):e.jsx(we,{size:14})})]},s.id))}),!c.length&&e.jsxs("div",{className:"ims-panel-empty",children:[e.jsx(T,{size:26}),e.jsx("p",{children:i("imageStudio.noLayers")})]}),e.jsx("p",{className:"ims-caption",children:i("imageStudio.layersHint")})]})}function I({label:i,value:r,onChange:n,min:l=-1e5,max:a=1e5}){const[c,h]=j.useState(String(Math.round(r*100)/100));j.useEffect(()=>h(String(Math.round(r*100)/100)),[r]);const s=()=>{const p=Number(c);c.trim()&&Number.isFinite(p)?n(Math.max(l,Math.min(a,p))):h(String(r))};return e.jsxs("label",{children:[i,e.jsx("input",{type:"number","aria-label":i,value:c,min:l,max:a,onChange:p=>h(p.target.value),onBlur:s,onKeyDown:p=>{p.key==="Enter"&&p.currentTarget.blur()}})]})}function Ei(){const{t:i}=E(),r=b(t=>t.activeId?t.boards[t.activeId]:void 0),n=b(t=>t.selection),l=r?B(r).filter(t=>n.includes(t.id)):[],a=l[0],c=a&&k(a)&&a.parentId?r?.images.find(t=>t.id===a.parentId):void 0,[h,s]=j.useState(""),[p,S]=j.useState(!1),[o,d]=j.useState(!1);j.useEffect(()=>{d(!1),s("")},[r?.id,a?.id]);const f=async t=>{S(!0),s("");try{await t()}catch(x){s(String(x))}finally{S(!1)}};if(!r||!a)return e.jsxs("div",{className:"ims-panel ims-panel-empty",children:[e.jsx(T,{size:26}),e.jsx("p",{children:i("imageStudio.select")})]});const g=t=>b.getState().update(r.id,x=>D(x,v=>v.id===a.id&&!v.locked?{...v,...t}:v)),u=t=>{k(a)&&g(J(a,t))},y=(t,x)=>{let v={x:a.x,y:a.y,w:a.w,h:a.h,[t]:x};if(k(a)&&(t==="w"||t==="h")){const w=K(a);v={...v,...t==="w"?{h:x*w.h/w.w}:{w:x*w.w/w.h}}}b.getState().update(r.id,w=>W(w,new Map([[a.id,v]])))};return e.jsxs("section",{className:"ims-panel ims-inspector",children:[e.jsx("h3",{children:i(l.length>1?"imageStudio.selection":"imageStudio.inspector")}),l.every(k)&&e.jsx(Be,{board:r,images:l.filter(k)},`${r.id}:${n.join(",")}`),l.length===1?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"ims-preview",style:{aspectRatio:a.w/a.h},children:e.jsx(U,{item:a})}),e.jsxs("fieldset",{disabled:a.locked,className:"ims-properties",children:[e.jsx("input",{"aria-label":i("imageStudio.layerName"),value:a.name,onChange:t=>g({name:t.target.value})}),e.jsx("div",{className:"ims-fields",children:["x","y","w","h"].map(t=>e.jsx(I,{label:i(`imageStudio.${t}`),value:a[t],min:t==="w"||t==="h"?1:-1e5,onChange:x=>y(t,x)},t))}),k(a)?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"ims-meta",children:[e.jsx("span",{children:i("imageStudio.original")}),e.jsxs("span",{children:[a.width," × ",a.height]})]}),c&&e.jsxs("button",{className:"ims-lineage",onClick:()=>b.setState({selection:[c.id]}),children:[e.jsx(me,{size:14}),e.jsx("span",{children:i("imageStudio.versionOf")}),e.jsx("strong",{children:c.name})]}),e.jsxs("div",{className:"ims-button-row ims-transform",children:[e.jsx("button",{title:i("imageStudio.crop"),"aria-label":i("imageStudio.crop"),onClick:()=>d(!o),children:e.jsx(ke,{size:16})}),e.jsx("button",{title:i("imageStudio.rotate"),"aria-label":i("imageStudio.rotate"),onClick:()=>u({rotation:((a.rotation||0)+90)%360}),children:e.jsx(se,{size:16})}),e.jsx("button",{title:i("imageStudio.flipX"),"aria-label":i("imageStudio.flipX"),onClick:()=>u({flipX:!a.flipX}),children:e.jsx(Ie,{size:16})}),e.jsx("button",{title:i("imageStudio.flipY"),"aria-label":i("imageStudio.flipY"),onClick:()=>u({flipY:!a.flipY}),children:e.jsx(Ee,{size:16})})]}),o&&e.jsx($e,{image:a,onCancel:()=>d(!1),onApply:t=>{u({crop:t}),d(!1)}},a.id),e.jsx(I,{label:i("imageStudio.angle"),value:a.rotation||0,min:0,max:359,onChange:t=>u({rotation:t})}),e.jsx("button",{onClick:()=>u({crop:void 0,rotation:0,flipX:!1,flipY:!1}),children:i("imageStudio.resetTransform")}),e.jsx("div",{className:"ims-adjustments",children:["brightness","contrast","saturation"].map(t=>e.jsxs("label",{children:[e.jsxs("span",{children:[i(`imageStudio.${t}`),e.jsxs("output",{children:[a[t],"%"]})]}),e.jsx("input",{"aria-label":i(`imageStudio.${t}`),type:"range",min:"0",max:"200",step:"5",value:a[t],onChange:x=>g({[t]:Number(x.target.value)})})]},t))}),e.jsxs("button",{onClick:()=>g({brightness:100,contrast:100,saturation:100}),children:[e.jsx(Ce,{size:14}),i("imageStudio.reset")]})]}):e.jsxs(e.Fragment,{children:[a.kind==="frame"&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:[i("imageStudio.framePreset"),e.jsxs("select",{"aria-label":i("imageStudio.framePreset"),value:"",onChange:t=>{const[x,v]=t.target.value.split("x").map(Number);g({w:x,h:v})},children:[e.jsx("option",{value:"",disabled:!0,children:i("imageStudio.customSize")}),e.jsx("option",{value:"1080x1080",children:"1:1 · 1080 × 1080"}),e.jsx("option",{value:"1080x1350",children:"4:5 · 1080 × 1350"}),e.jsx("option",{value:"1080x1920",children:"9:16 · 1080 × 1920"}),e.jsx("option",{value:"1920x1080",children:"16:9 · 1920 × 1080"})]})]}),e.jsx("p",{children:i("imageStudio.frameHint")})]}),a.kind==="text"&&e.jsxs(e.Fragment,{children:[e.jsx("textarea",{"aria-label":i("imageStudio.textContent"),value:a.text,maxLength:1e4,rows:4,onChange:t=>g({text:t.target.value})}),e.jsxs("div",{className:"ims-fields",children:[e.jsxs("label",{children:[i("imageStudio.font"),e.jsx("select",{"aria-label":i("imageStudio.font"),value:a.fontFamily,onChange:t=>g({fontFamily:t.target.value}),children:["sans-serif","serif","monospace"].map(t=>e.jsx("option",{value:t,children:i(`imageStudio.font.${t}`)},t))})]}),e.jsx(I,{label:i("imageStudio.fontSize"),value:a.fontSize,min:6,max:500,onChange:t=>g({fontSize:t})})]}),e.jsxs("div",{className:"ims-fields",children:[e.jsxs("label",{children:[i("imageStudio.textAlign"),e.jsx("select",{"aria-label":i("imageStudio.textAlign"),value:a.align,onChange:t=>g({align:t.target.value}),children:["left","center","right"].map(t=>e.jsx("option",{value:t,children:i(`imageStudio.align.${t}`)},t))})]}),e.jsxs("label",{className:"ims-checkbox",children:[e.jsx("input",{type:"checkbox",checked:a.bold,onChange:t=>g({bold:t.target.checked})}),i("imageStudio.bold")]})]})]}),e.jsxs("div",{className:"ims-fields",children:[e.jsxs("label",{children:[i("imageStudio.fill"),e.jsx("input",{type:"color","aria-label":i("imageStudio.fill"),value:a.fill==="transparent"?"#ffffff":a.fill,onChange:t=>g({fill:t.target.value})})]}),a.kind!=="text"&&e.jsxs("label",{children:[i("imageStudio.stroke"),e.jsx("input",{type:"color","aria-label":i("imageStudio.stroke"),value:a.stroke,onChange:t=>g({stroke:t.target.value})})]})]}),a.kind!=="text"&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"ims-checkbox",children:[e.jsx("input",{type:"checkbox",checked:a.fill==="transparent",onChange:t=>g({fill:t.target.checked?"transparent":"#ffffff"})}),i("imageStudio.noFill")]}),e.jsxs("div",{className:"ims-fields",children:[e.jsx(I,{label:i("imageStudio.strokeWidth"),value:a.strokeWidth,min:0,max:100,onChange:t=>g({strokeWidth:t})}),e.jsx(I,{label:i("imageStudio.radius"),value:a.radius,min:0,max:1e3,onChange:t=>g({radius:t})})]})]})]})]}),a.locked&&e.jsx("p",{children:i("imageStudio.lockedHint")}),k(a)&&a.prompt&&e.jsxs("details",{className:"ims-prompt",children:[e.jsx("summary",{children:i("imageStudio.prompt")}),e.jsx("p",{children:a.prompt})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{children:i("imageStudio.selectedCount",{count:l.length})}),e.jsx("div",{className:"ims-align",children:["left","center","right","top","middle","bottom"].map(t=>e.jsx("button",{onClick:()=>b.getState().update(r.id,x=>je(x,n,t)),children:i(`imageStudio.align.${t}`)},t))})]}),e.jsxs("div",{className:"ims-button-row",children:[e.jsx("button",{title:i("imageStudio.layerUp"),"aria-label":i("imageStudio.layerUp"),onClick:()=>b.getState().update(r.id,t=>F(t,n,"up")),children:e.jsx(ne,{size:15})}),e.jsx("button",{title:i("imageStudio.layerDown"),"aria-label":i("imageStudio.layerDown"),onClick:()=>b.getState().update(r.id,t=>F(t,n,"down")),children:e.jsx(oe,{size:15})}),e.jsx("button",{title:i("imageStudio.remove"),"aria-label":i("imageStudio.remove"),onClick:Se,children:e.jsx(re,{size:15})})]}),e.jsxs("div",{className:"ims-panel-actions",children:[e.jsxs("button",{disabled:p||l.every(t=>t.hidden),onClick:()=>{f(be)},children:[e.jsx(q,{size:14}),i("imageStudio.reference")]}),e.jsxs("button",{onClick:()=>fe(!0),children:[e.jsx(le,{size:14}),i("imageStudio.duplicate")]}),l.length===1&&k(a)&&e.jsxs("button",{className:"ims-primary",disabled:p,onClick:()=>{f(async()=>ve(await H([a],!0),a.name.replace(/\.[^.]+$/,"")+".png"))},children:[e.jsx(de,{size:14}),i("imageStudio.export")]})]}),h&&e.jsx("p",{role:"alert",children:i("imageStudio.error",{error:h})})]})}export{zi as ImageStudioAssets,Ii as ImageStudioChat,Ei as ImageStudioInspector,I as NumberField};
@@ -1 +0,0 @@
1
- import{u as W,d as r,j as t}from"./index-CF4RV4mh.js";import{z as xe,au as fe,aO as te,aP as B,C as J,jx as Se,c0 as je,bQ as Te,bR as Oe,aQ as ve,u as Be,e$ as Re,i as ue,fc as _,af as Ae,Y as Fe,L as He,jy as Ue,S as qe,dw as Ve,eN as _e,jz as Ke,f8 as We}from"./appStore-Dg9WALEA.js";import{u as Ye}from"./gestures-CkW1Kfs9.js";import{C as Xe,a as Ge}from"./Chrome-CwFiDmre.js";import{b as O,i as be,u as o,a as Qe,C as Ze,r as me,m as Je,c as ge,d as et,e as pe,f as tt,n as it,g as st}from"./RightPanel-C3OJTIqT.js";import{s as at,d as ee,r as nt,h as ot,a as rt,b as ye,c as we,p as A,e as Ce,u as lt,L as dt,f as ct,g as ut,i as mt,m as gt}from"./imageStudio-C_Rs630L.js";import{L as pt}from"./lock-BnGHxjeE.js";import{L as ht}from"./InlineFiles-C_hjvn3u.js";import{U as K}from"./upload-BbeAsMuD.js";import{F as xt,R as ft}from"./redo-2-DSi54z4e.js";import{U as St}from"./undo-2-tUKCv5Gs.js";import{L as jt}from"./layout-grid-B_pjJwz4.js";import{A as vt}from"./arrow-up-right-CpQs92mu.js";import{H as bt}from"./hand-Crrw-nSn.js";import{T as yt}from"./type-Cqoabh7H.js";import{F as wt}from"./frame-_xBVYe3P.js";import"./nativeDownload-D-f1_L2S.js";import"./ipc-DQOD2UKk.js";import"./client-BSKpsyAw.js";import"./minus-Cyv1YzOU.js";import"./folder-DlxnPmWY.js";import"./folder-plus-D1TDb7k9.js";import"./pencil-Cvk91P_Z.js";const Ct=[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]],kt=xe("clipboard-paste",Ct);const zt=[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Nt=xe("copy-plus",zt);function It({board:s,selection:a,onClose:z}){const{t:d}=W(),[j,f]=r.useState("png"),[w,v]=r.useState(1),[l,C]=r.useState("transparent"),[x,b]=r.useState(.92),[P,h]=r.useState(!1),[M,u]=r.useState(""),N=at(s,a),L=N?.bounds,$=Math.round((L?.w||0)*w),I=Math.round((L?.h||0)*w),R=!L||$<1||I<1||$*I>4e7||Math.max($,I)>16384;return t.jsxs("section",{className:"ims-export ims-panel","aria-label":d("imageStudio.exportOptions"),children:[t.jsxs("div",{className:"ims-section-head",children:[t.jsx("h3",{children:d("imageStudio.exportOptions")}),t.jsx("button",{"aria-label":d("imageStudio.close"),onClick:z,children:t.jsx(fe,{size:15})})]}),t.jsxs("div",{className:"ims-fields",children:[t.jsxs("label",{children:[d("imageStudio.format"),t.jsx("select",{"aria-label":d("imageStudio.format"),value:j,onChange:g=>f(g.target.value),children:["png","jpeg","webp","svg"].map(g=>t.jsx("option",{value:g,children:g.toUpperCase()},g))})]}),t.jsxs("label",{children:[d("imageStudio.scale"),t.jsx("select",{"aria-label":d("imageStudio.scale"),value:w,onChange:g=>v(Number(g.target.value)),children:[.5,1,2,3].map(g=>t.jsxs("option",{value:g,children:[g,"×"]},g))})]}),t.jsxs("label",{children:[d("imageStudio.background"),t.jsxs("select",{"aria-label":d("imageStudio.background"),value:l,onChange:g=>C(g.target.value),children:[t.jsx("option",{value:"transparent",children:d("imageStudio.transparent")}),t.jsx("option",{value:"#ffffff",children:d("imageStudio.white")}),t.jsx("option",{value:"#000000",children:d("imageStudio.black")})]})]}),(j==="jpeg"||j==="webp")&&t.jsxs("label",{children:[d("imageStudio.quality"),t.jsx("input",{"aria-label":d("imageStudio.quality"),type:"range",min:".1",max:"1",step:".05",value:x,onChange:g=>b(Number(g.target.value))})]})]}),t.jsxs("p",{children:[$," × ",I," px · ",d(a.length?"imageStudio.selectedOnly":"imageStudio.allVisible")]}),j==="svg"&&t.jsx("p",{children:d("imageStudio.svgHint")}),j==="jpeg"&&l==="transparent"&&t.jsx("p",{children:d("imageStudio.jpegHint")}),R&&t.jsx("p",{role:"alert",children:d("imageStudio.exportLimit")}),t.jsxs("button",{className:"ims-primary",disabled:P||R,onClick:async()=>{h(!0),u("");try{ee(await nt(s,a,{format:j,scale:w,background:l,quality:x}),`${s.name}.${j==="jpeg"?"jpg":j}`)}catch(g){u(String(g))}finally{h(!1)}},children:[P?t.jsx(te,{className:"ims-spin",size:15}):t.jsx(B,{size:15}),d("imageStudio.download")]}),M&&t.jsx("p",{role:"alert",children:d("imageStudio.error",{error:M})})]})}function Et({target:s,board:a,busy:z,onClose:d,onImport:j,onExport:f,onInspect:w,run:v}){const{t:l}=W(),C=a?O(a).filter(u=>s.ids.includes(u.id)):[],x=C.length===1&&be(C[0])?C[0]:void 0,b=C.filter(u=>!u.locked).map(u=>u.id),P=/Mac|iPhone|iPad/.test(navigator.platform)?"⌘":"Ctrl+",h=u=>()=>{a&&o.getState().activeId!==a.id||(o.setState({selection:C.map(N=>N.id)}),u())},M=[];return x&&M.push({label:l("imageStudio.downloadImage"),icon:t.jsx(B,{size:14}),disabled:z,run:h(()=>{v(async()=>ee(await rt([x],!0),x.name.replace(/\.[^.]+$/,"")+".png"))})},{label:l("imageStudio.downloadOriginal"),icon:t.jsx(B,{size:14}),run:h(()=>{const u={"image/png":"png","image/jpeg":"jpg","image/webp":"webp","image/gif":"gif"}[x.blob.type]||"png";ee(x.blob,x.name.replace(/\.[^.]+$/,"")+"-original."+u)})}),C.length&&a?M.push({label:l("imageStudio.exportSelection"),icon:t.jsx(B,{size:14}),disabled:z,run:h(f)},{label:l("imageStudio.reference"),icon:t.jsx(J,{size:14}),separatorBefore:!0,disabled:z||C.length>8,run:h(()=>{v(ye)})},{label:l("imageStudio.inspector"),icon:t.jsx(Se,{size:14}),run:h(w)},{label:l("imageStudio.copyObjects"),icon:t.jsx(je,{size:14}),shortcut:`${P}C`,separatorBefore:!0,run:h(we)},{label:l("imageStudio.duplicate"),icon:t.jsx(Nt,{size:14}),shortcut:`${P}D`,run:h(()=>A(!0))},{label:l("imageStudio.layerUp"),icon:t.jsx(Te,{size:14}),separatorBefore:!0,disabled:!b.length,run:h(()=>o.getState().update(a.id,u=>me(u,b,"up")))},{label:l("imageStudio.layerDown"),icon:t.jsx(Oe,{size:14}),disabled:!b.length,run:h(()=>o.getState().update(a.id,u=>me(u,b,"down")))},{label:l(b.length?"imageStudio.lock":"imageStudio.unlock"),icon:b.length?t.jsx(pt,{size:14}):t.jsx(ht,{size:14}),run:h(()=>o.getState().update(a.id,u=>Je(u,N=>s.ids.includes(N.id)?{...N,locked:!!b.length}:N)))},{label:l("imageStudio.remove"),icon:t.jsx(ve,{size:14}),shortcut:"⌫",separatorBefore:!0,danger:!0,disabled:!b.length,run:h(Ce)}):M.push({label:l("imageStudio.import"),icon:t.jsx(K,{size:14}),disabled:z,run:j},{label:l("imageStudio.pasteObjects"),icon:t.jsx(kt,{size:14}),shortcut:`${P}V`,disabled:!a||!ot(),run:h(()=>A())},{label:l("imageStudio.selectAll"),icon:t.jsx(Qe,{size:14}),disabled:!a?.images.length&&!a?.elements?.length,run:()=>o.setState({selection:a?O(a).filter(u=>!u.hidden).map(u=>u.id):[]})},{label:l("imageStudio.exportBoard"),icon:t.jsx(B,{size:14}),separatorBefore:!0,disabled:z||!a||!O(a).some(u=>!u.hidden),run:h(f)}),t.jsx(Ze,{menu:{x:s.x,y:s.y,items:M},onClose:d,autoFocus:!0})}const he=[];function ti(s){const{t:a}=W(),z=o(f=>f.ready),d=o(f=>f.error),j=o(f=>f.activeId);return r.useEffect(()=>{o.getState().hydrate();const f=()=>{o.getState().flush()},w=v=>{const l=o.getState();(l.saving||l.ready&&l.error)&&(f(),v.preventDefault(),v.returnValue="")};return window.addEventListener("pagehide",f),window.addEventListener("beforeunload",w),()=>{window.removeEventListener("pagehide",f),window.removeEventListener("beforeunload",w),f()}},[]),z?t.jsx(Pt,{},j||"new"):t.jsx("div",{className:"ims-panel ims-panel-empty",children:d?t.jsxs(t.Fragment,{children:[t.jsx("p",{role:"alert",children:a("imageStudio.error",{error:d})}),t.jsx("button",{onClick:()=>{o.getState().hydrate()},children:a("imageStudio.retry")})]}):t.jsx(te,{className:"ims-spin"})})}function Pt(){const{t:s}=W(),a=o(e=>e.activeId?e.boards[e.activeId]:void 0),z=o(e=>e.boards),d=o(e=>e.saving),j=o(e=>e.error),f=o(e=>a&&e.past[a.id]?.length||0),w=o(e=>a&&e.future[a.id]?.length||0),v=o(e=>e.selection),l=o(e=>a&&e.placeholders[a.id]||he),C=Be(e=>!!(a?.sessionId&&e.runningBySession[a.sessionId])),[x,b]=r.useState(!1),[P,h]=r.useState(""),[M,u]=r.useState(0),[N,L]=r.useState(!1),[$,I]=r.useState(!1),[R,g]=r.useState(!1),D=r.useRef(null),[ie,ke]=r.useState(!0),[se,ze]=r.useState(!1),[Ne,Y]=r.useState(!1),y=r.useRef(null),F=r.useRef(null),ae=r.useRef(null),[ne,oe]=r.useState(null),Ie=r.useCallback(()=>{oe(null),y.current?.focus({preventScroll:!0})},[]),c=Re(y,`image-studio:${a?.id||""}`,void 0,{x:56,y:64,z:1}),H=a?.images||[],E=a?O(a):[],U=E.filter(e=>!e.hidden),Ee=!E.length&&!f&&!w,X=[...U,...l],q=r.useRef(!0);r.useEffect(()=>(q.current=!0,()=>{q.current=!1}),[]);const re=r.useCallback(e=>{q.current&&h(e)},[]);lt(a||Mt,re,M);const p=Ye(y,c,{boxes:()=>new Map(U.map(e=>[e.id,e])),identity:()=>a?.id,commit:e=>{a&&o.getState().update(a.id,i=>pe(i,e))},constrain:(e,i)=>{if(i.kind!=="resize")return e;const n=H.find(De=>De.id===i.key),m=e.get(i.key);if(!n||!m)return e;const S=et(n),k=Math.max(48,m.w),$e=k*S.h/S.w;return new Map(e).set(i.key,{...m,w:k,h:$e})},hitKey:e=>e.closest("[data-image-id]")?.dataset.imageId||null,isEditing:e=>!!E.find(i=>i.id===e)?.locked,hitEdge:e=>e.dataset.resize||null,onDelete:e=>{a&&o.getState().update(a.id,i=>ge(i,O(i).filter(n=>n.locked||!e.includes(n.id))))},onDoubleClick:e=>{e&&(o.setState({selection:[e]}),ue.getState().openView("image-studio-inspector",{},"right"))},onContextMenu:(e,i)=>{const n=e?p.sel.includes(e)?p.sel:[e]:[];p.setSel(n),o.setState({selection:n}),oe({x:i.clientX,y:i.clientY,ids:n})},minW:48,minH:48,repel:!1},ie);r.useEffect(()=>p.bind(y.current),[p.bind]),r.useEffect(()=>c.bindWheel(y.current),[c.bindWheel]),r.useEffect(()=>{const e=()=>{g(!1),D.current=null};return window.addEventListener("blur",e),()=>window.removeEventListener("blur",e)},[]);const le=r.useRef(p.sel);r.useEffect(()=>{le.current!==p.sel&&(le.current=p.sel,o.setState({selection:p.sel}))},[p.sel]),r.useEffect(()=>{if(v.join("|")!==p.sel.join("|")){p.setSel(v);const e=E.find(i=>i.id===v[0]);if(e){const{w:i,h:n}=_(y.current),m=c.vpRef.current,S=(e.x+e.w/2)*m.z+m.x,k=(e.y+e.h/2)*m.z+m.y;(S<0||S>i||k<0||k>n)&&c.centerOn(e.x+e.w/2,e.y+e.h/2)}}},[v,p.setSel]);const de=r.useRef(0);r.useEffect(()=>{const e=E.length+l.length;e>de.current&&c.fitTo(X,64),de.current=e},[E,l,c.fitTo]);const T=async e=>{b(!0),h("");try{await e()}catch(i){re(String(i))}finally{q.current&&b(!1)}},G=()=>a?.id||o.getState().create(s("imageStudio.untitled")),ce=async e=>{const i=await Promise.all(e.map(m=>gt(m,m.name,"import")));if(!i.length)return;const n=G();o.getState().update(n,m=>{const S=[...m.images];for(const k of i)S.push({...k,...st(k.width,k.height,S)});return{...m,images:S}})},Pe=e=>{T(async()=>{const i=G();await ct(i,s(e))})},V=e=>ue.getState().openView(e,{},e==="image-studio-chat"?"left":"right"),Q=E.filter(e=>v.includes(e.id)),Me=a&&p.live?O(pe(a,p.live)):E,Z=e=>{const i=G(),{w:n,h:m}=_(y.current),S=it(e,s(`imageStudio.new.${e}`),(n/2-c.vp.x)/c.vp.z,(m/2-c.vp.y)/c.vp.z);S.x-=S.w/2,S.y-=S.h/2,o.getState().update(i,k=>ge(k,[...O(k),S])),o.setState({selection:[S.id]}),V("image-studio-inspector")},Le=e=>{const{w:i,h:n}=_(y.current);c.setVp(We(c.vp,c.vp.z*e,i/2,n/2))};return t.jsxs("div",{className:"ims",onKeyDownCapture:e=>{if(e.target.closest('input, select, textarea, button, [contenteditable="true"]'))return;const i=e.metaKey||e.ctrlKey,n=e.key.toLowerCase();let m=!0;i&&n==="z"&&a?o.getState().undo(a.id,e.shiftKey):i&&n==="c"?we():i&&n==="v"?A():i&&n==="d"?A(!0):i&&n==="e"?L(!0):!i&&n==="t"?Z("text"):!i&&n==="f"?Z("frame"):!i&&n==="h"?I(!0):!i&&n==="v"?I(!1):n===" "?g(!0):(n==="escape"&&(I(!1),L(!1)),m=!1),m&&(e.preventDefault(),e.stopPropagation())},onKeyUpCapture:e=>{e.key===" "&&(g(!1),e.preventDefault(),e.stopPropagation())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(g(!1),D.current=null)},children:[t.jsxs("header",{className:"ims-header",children:[t.jsxs("div",{className:"ims-project-picker",children:[t.jsxs("select",{"aria-label":s("imageStudio.projects"),value:a?.id||"",onChange:e=>o.getState().open(e.target.value),children:[t.jsx("option",{value:"",disabled:!0,children:s("imageStudio.projects")}),Object.values(z).sort((e,i)=>i.updatedAt-e.updatedAt).map(e=>t.jsx("option",{value:e.id,children:e.name},e.id))]}),t.jsx("button",{title:s("imageStudio.new"),"aria-label":s("imageStudio.new"),onClick:()=>o.getState().create(s("imageStudio.untitled")),children:t.jsx(Ae,{size:16})})]}),t.jsxs("div",{className:"ims-head-actions",children:[t.jsx("button",{title:s("imageStudio.restore"),"aria-label":s("imageStudio.restore"),onClick:()=>ae.current?.click(),children:t.jsx(Fe,{size:16})}),a&&t.jsx("button",{disabled:x,title:s("imageStudio.backup"),"aria-label":s("imageStudio.backup"),onClick:()=>{T(()=>ut(a))},children:t.jsx(xt,{size:16})}),t.jsxs("button",{className:"ims-primary",disabled:!U.length||x,onClick:()=>L(!N),children:[t.jsx(B,{size:14}),t.jsx("span",{children:s("imageStudio.exportOptions")})]})]})]}),t.jsxs("div",{className:"ims-toolbar",role:"toolbar","aria-label":s("imageStudio.title"),children:[t.jsxs("button",{disabled:x,onClick:()=>F.current?.click(),children:[t.jsx(K,{size:15}),t.jsx("span",{children:s("imageStudio.import")})]}),!Ee&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"ims-divider"}),t.jsx("button",{disabled:!f,title:s("imageStudio.undo"),"aria-label":s("imageStudio.undo"),onClick:()=>a&&o.getState().undo(a.id),children:t.jsx(St,{size:15})}),t.jsx("button",{disabled:!w,title:s("imageStudio.redo"),"aria-label":s("imageStudio.redo"),onClick:()=>a&&o.getState().undo(a.id,!0),children:t.jsx(ft,{size:15})}),t.jsx("button",{disabled:!H.some(e=>!e.locked&&!e.hidden),title:s("imageStudio.arrange"),"aria-label":s("imageStudio.arrange"),onClick:()=>{if(a){const e=tt(H.filter(i=>!i.locked&&!i.hidden));o.getState().update(a.id,i=>({...i,images:i.images.map(n=>e.find(m=>m.id===n.id)||n)})),c.fitTo(e)}},children:t.jsx(jt,{size:15})}),t.jsx("button",{disabled:!Q.length,title:s("imageStudio.remove"),"aria-label":s("imageStudio.remove"),onClick:Ce,children:t.jsx(ve,{size:15})}),t.jsx("button",{disabled:!Q.length,title:s("imageStudio.duplicate"),"aria-label":s("imageStudio.duplicate"),onClick:()=>A(!0),children:t.jsx(je,{size:15})}),t.jsx("button",{disabled:!Q.length||x,title:s("imageStudio.reference"),"aria-label":s("imageStudio.reference"),onClick:()=>{T(ye)},children:t.jsx(J,{size:15})})]}),t.jsx("span",{className:"ims-toolbar-space"}),[["image-studio-chat",J,"imageStudio.chat"],["image-studio-assets",He,"imageStudio.assets"],["image-studio-inspector",Se,"imageStudio.inspector"]].map(([e,i,n])=>t.jsx("button",{title:s(n),"aria-label":s(n),onClick:()=>V(e),children:t.jsx(i,{size:16})},e))]}),N&&a&&t.jsx(It,{board:a,selection:v,onClose:()=>L(!1)}),j&&t.jsxs("div",{className:"ims-error",role:"alert",children:[s("imageStudio.saveError"),t.jsx("button",{onClick:()=>{o.getState().flush()},children:s("imageStudio.retry")})]}),P&&t.jsxs("div",{className:"ims-error",role:"alert",children:[s("imageStudio.error",{error:P}),t.jsx("button",{onClick:()=>{h(""),u(e=>e+1)},children:s("imageStudio.retry")})]}),t.jsxs("div",{ref:y,className:`ims-stage${$||R?" is-panning":""}`,tabIndex:0,onContextMenu:e=>e.stopPropagation(),onPointerDownCapture:e=>{e.button===2||!($||R)||e.target.closest(".amx-stage-tools, .amx-stage-hud, .amx-stage-minimap")||(e.stopPropagation(),e.preventDefault(),e.currentTarget.focus(),e.currentTarget.setPointerCapture(e.pointerId),D.current={id:e.pointerId,x:e.clientX,y:e.clientY,vx:c.vp.x,vy:c.vp.y})},onPointerMoveCapture:e=>{const i=D.current;if(!i||i.id!==e.pointerId)return;e.stopPropagation();const{u:n}=_(y.current);c.setVp({...c.vp,x:i.vx+(e.clientX-i.x)/n,y:i.vy+(e.clientY-i.y)/n})},onPointerUpCapture:e=>{D.current?.id===e.pointerId&&(e.stopPropagation(),D.current=null)},onPointerCancel:()=>{D.current=null},"aria-label":s("imageStudio.title"),onDragOver:e=>{e.dataTransfer.types.includes("Files")&&(e.preventDefault(),Y(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||Y(!1)},onDrop:e=>{e.preventDefault(),Y(!1),x||T(()=>ce(Array.from(e.dataTransfer.files)))},children:[t.jsx("div",{className:"ims-grid",style:Ue(c.vp)}),t.jsxs("div",{className:"ims-world",style:{transform:`translate(${c.vp.x}px, ${c.vp.y}px) scale(${c.vp.z})`},children:[U.map(e=>{const i=Me.find(n=>n.id===e.id)||e;return t.jsxs("div",{"data-image-id":e.id,className:`ims-layer ${be(e)?"ims-image":`ims-${e.kind}`}${p.sel.includes(e.id)?" is-selected":""}${e.locked?" is-locked":""}`,style:{left:i.x,top:i.y,width:i.w,height:i.h},children:[t.jsx(dt,{item:e}),t.jsx("div",{className:"ims-image-label",children:e.name}),p.sel.includes(e.id)&&!e.locked&&t.jsx("div",{className:"ims-resize","data-resize":"se"})]},e.id)}),l.map(e=>{const i=H.find(n=>n.id===e.sourceIds[0]);return t.jsxs("div",{"data-generation-id":e.id,className:`ims-generation${e.status==="failed"?" is-failed":""}`,style:{left:e.x,top:e.y,width:e.w,height:e.h},role:e.status==="failed"?"alert":"status","aria-live":"polite",onPointerDown:n=>n.stopPropagation(),children:[t.jsx("div",{className:"ims-generation-sheen"}),t.jsxs("div",{className:"ims-generation-copy",children:[t.jsx(qe,{size:20,strokeWidth:1.5}),t.jsx("strong",{children:s(e.kind==="edit"?"imageStudio.generation.editing":"imageStudio.generation.creating")}),t.jsx("span",{children:e.status==="failed"?s("imageStudio.generation.failed"):s(e.status==="preparing"?"imageStudio.generation.preparing":"imageStudio.generation.running")}),i&&t.jsx("small",{children:s("imageStudio.generation.versionOf",{name:i.name})}),e.count>1&&t.jsxs("small",{children:[e.index+1," / ",e.count]})]}),e.status==="failed"&&t.jsxs("div",{className:"ims-generation-actions amx-stage-tools",children:[t.jsx("button",{onClick:()=>V("image-studio-chat"),children:s("imageStudio.generation.openChat")}),t.jsx("button",{title:s("imageStudio.generation.dismiss"),"aria-label":s("imageStudio.generation.dismiss"),onClick:()=>o.getState().removeGeneration(a.id,e.id),children:t.jsx(fe,{size:14})})]})]},e.id)}),p.marquee&&t.jsx("div",{className:"ims-marquee",style:{left:p.marquee.x,top:p.marquee.y,width:p.marquee.w,height:p.marquee.h}})]}),!E.length&&!l.length&&t.jsxs("div",{className:"ims-empty amx-stage-tools",children:[t.jsxs("div",{className:"ims-eyebrow",children:[s("imageStudio.title")," ",t.jsx("span",{children:"/"})," ",s("imageStudio.new")]}),t.jsx("h1",{children:s("imageStudio.headline")}),t.jsx("p",{children:s("imageStudio.intro")}),t.jsx("div",{className:"ims-starters",children:["poster","product","illustration"].map(e=>t.jsxs("button",{disabled:x,onClick:()=>Pe(`imageStudio.${e}Prompt`),children:[t.jsx("span",{children:s(`imageStudio.${e}`)}),t.jsx(vt,{size:14})]},e))}),t.jsxs("button",{className:"ims-empty-import",disabled:x,onClick:()=>F.current?.click(),children:[t.jsx(K,{size:16}),s("imageStudio.import")]}),t.jsx("small",{children:s("imageStudio.importLimit")})]}),!l.length&&(C||x)&&t.jsxs("div",{className:"ims-progress amx-stage-tools",role:"status",children:[t.jsx(te,{size:15,className:"ims-spin"}),s(C?"imageStudio.generating":"imageStudio.busy")]}),Ne&&t.jsxs("div",{className:"ims-drop",children:[t.jsx(K,{size:28}),s("imageStudio.drop")]}),t.jsxs("div",{className:"ims-create-tools amx-stage-tools",role:"toolbar","aria-label":s("imageStudio.canvasTools"),children:[t.jsx("button",{title:s("imageStudio.selectTool"),"aria-label":s("imageStudio.selectTool"),"aria-pressed":!$,onClick:()=>{I(!1),y.current?.focus()},children:t.jsx(Ve,{size:17})}),t.jsx("button",{title:s("imageStudio.handTool"),"aria-label":s("imageStudio.handTool"),"aria-pressed":$,onClick:()=>{I(!0),y.current?.focus()},children:t.jsx(bt,{size:17})}),t.jsx("span",{}),[["text",yt],["rectangle",_e],["ellipse",Ke],["frame",wt]].map(([e,i])=>t.jsx("button",{title:s(`imageStudio.add.${e}`),"aria-label":s(`imageStudio.add.${e}`),onClick:()=>Z(e),children:t.jsx(i,{size:17})},e))]}),se&&t.jsx(Xe,{hostRef:y,vp:c.vp,items:X.map(e=>({key:e.id,kind:"card",box:e})),onCenter:c.centerOn}),t.jsx(Ge,{zoom:c.vp.z,onZoomBy:Le,onFit:()=>c.fitTo(X),snap:ie,onSnap:ke,mini:se,onMini:ze})]}),t.jsxs("footer",{className:"ims-footer",children:[t.jsx("span",{title:s("imageStudio.hint"),children:s(a?j?"imageStudio.unsaved":d?"imageStudio.saving":"imageStudio.local":"imageStudio.empty")}),a&&t.jsx("input",{"aria-label":s("imageStudio.name"),value:a.name,onChange:e=>o.getState().update(a.id,i=>({...i,name:e.target.value}),!1)}),t.jsx("span",{children:s("imageStudio.itemCount",{count:E.length})})]}),ne&&t.jsx(Et,{target:ne,board:a,busy:x,onClose:Ie,onImport:()=>F.current?.click(),onExport:()=>L(!0),onInspect:()=>V("image-studio-inspector"),run:T}),t.jsx("input",{ref:F,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",multiple:!0,hidden:!0,onChange:e=>{const i=Array.from(e.target.files||[]);e.target.value="",T(()=>ce(i))}}),t.jsx("input",{ref:ae,type:"file",accept:".json",hidden:!0,onChange:e=>{const i=e.target.files?.[0];e.target.value="",i&&T(async()=>{const n=await mt(i),m=o.getState().create(n.name);o.getState().update(m,S=>({...n,id:S.id}))})}})]})}const Mt={version:1,id:"",name:"",updatedAt:0,sessionId:null,images:[],collected:[]};export{ti as ImageStudioView};
@@ -1 +0,0 @@
1
- import{z,lr as k,k7 as L,cd as w,k9 as p,k8 as x,ls as U,jH as f}from"./appStore-Dg9WALEA.js";import{j as l,d as y}from"./index-CF4RV4mh.js";import{n as T}from"./nativeDownload-D-f1_L2S.js";const S=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]],A=z("lock-open",S),R=t=>(t.mime?.startsWith("image/")??!1)||/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(t.name);function N(t){const n=t.match(/^data:([^;]+);base64,(.*)$/),e=p(n?.[2]||"");return{mimeType:n?.[1]||"application/octet-stream",bytes:e,size:e.length}}function E(t,n,e,i){e=t.sourceSessionId||e;const o=i==="host"?k(e):null,s=r=>{T({text:r?.message||String(r),level:"error"})},a=o?.downloadHostFile;return{name:t.name,path:o?.local&&t.path&&/^([/~]|[A-Za-z]:[\\/])/.test(t.path)?t.path:void 0,load:async()=>{if(t.dataUrl)return N(t.dataUrl);if(!t.path)return null;if(o){const c=await o.readHostFile(t.path);return c.tooLarge?{tooLarge:!0,size:c.size}:{mimeType:c.mimeType,bytes:p(c.content),size:c.size}}const r=await x(w(e),e,t.path);return{mimeType:r.mimeType,bytes:p(r.content),size:r.size}},download:t.path?i==="host"?a?()=>{a(t.path,t.name).catch(s)}:void 0:()=>{L(w(e),e,t.path).catch(s)}:void 0}}const v=({f:t,onClick:n})=>{const e=f(t.mime||"",t.name);return l.jsxs("button",{className:"inline-file-card",title:t.name,onClick:n,children:[l.jsx(e,{size:15}),l.jsx("span",{className:"inline-file-name",children:t.name})]})},H=({f:t,cfg:n,sessionId:e,execMode:i,onClick:o})=>{e=t.sourceSessionId||e;const s=t.dataUrl||(t.path&&i!=="host"?U(w(e),e,t.path):null),[a,r]=y.useState(s),[c,h]=y.useState(!1),d=y.useRef(null);return y.useEffect(()=>{if(h(!1),s){r(s);return}let u=!1;return(async()=>{if(!t.path)return;const j=i==="host"?k(e):null;try{let g=null,b="";if(j){const m=await j.readHostFile(t.path);if(u)return;if(m.tooLarge){h(!0);return}g=p(m.content),b=m.mimeType}else if(i!=="host"){const m=await x(w(e),e,t.path);if(u)return;g=p(m.content),b=m.mimeType}if(!g||u)return;const F=URL.createObjectURL(new Blob([g],{type:b||t.mime||"image/png"}));d.current=F,r(F)}catch{u||h(!0)}})(),()=>{u=!0,d.current&&(URL.revokeObjectURL(d.current),d.current=null)}},[t.path,t.dataUrl]),c?l.jsx(v,{f:t,onClick:o}):a?l.jsx("img",{className:"inline-file-img",src:a,alt:t.name,title:t.name,onClick:o,draggable:!1,onError:()=>h(!0)}):null},B=({files:t,cfg:n,sessionId:e,execMode:i,onOpenPreview:o})=>{if(!t.length)return null;const s=a=>o?.(E(a,n,e,i));return l.jsx("div",{className:"inline-file-grid",children:t.map((a,r)=>R(a)?l.jsx(H,{f:a,cfg:n,sessionId:e,execMode:i,onClick:()=>s(a)},r):l.jsx(v,{f:a,onClick:()=>s(a)},r))})};export{B as I,A as L,E as t};