@forsion/unit 2.13.2 → 2.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/main.mjs +3 -3
  2. package/package.json +1 -1
  3. package/release.json +5 -5
  4. package/web/assets/{ArtificialView-Bs_6B211.js → ArtificialView-DS97zlMg.js} +1 -1
  5. package/web/assets/{AutomationBuilder-C-IFaaBp.js → AutomationBuilder-BsJc8wuC.js} +1 -1
  6. package/web/assets/{CalendarConfigView-DEsNvVkD.js → CalendarConfigView-BN8mraSo.js} +1 -1
  7. package/web/assets/{CalendarView-D7ZUE_dr.js → CalendarView-D55PA1vn.js} +1 -1
  8. package/web/assets/{CapabilityMenu-CrsaTtDe.js → CapabilityMenu-BVrokPpT.js} +1 -1
  9. package/web/assets/{CheckboxInput-DVO2-1J7.js → CheckboxInput-BuJ3HPm_.js} +1 -1
  10. package/web/assets/{Chrome-BvpbCvo1.js → Chrome-amTcZNE4.js} +1 -1
  11. package/web/assets/{CodeView-CB4kG7Y6.js → CodeView-DRVh13k9.js} +3 -3
  12. package/web/assets/DashboardGridView-D9s9pez_.css +1 -0
  13. package/web/assets/{DashboardGridView-tgaj9-SM.js → DashboardGridView-DlFyYfUh.js} +2 -2
  14. package/web/assets/{EventCard-c6s4uGBu.js → EventCard-DUrn2krw.js} +1 -1
  15. package/web/assets/{ExcalidrawCanvas-NdV86AR3.js → ExcalidrawCanvas-TpbzBF-J.js} +1 -1
  16. package/web/assets/{FloatingToc-ldOYWe2C.js → FloatingToc-B1d4-5EL.js} +1 -1
  17. package/web/assets/HomepageView-DnQ_5Obe.css +1 -0
  18. package/web/assets/{HomepageView-4joJWYlg.js → HomepageView-nzKfbHM-.js} +1 -1
  19. package/web/assets/{ImageStudioPanels-DgMYAsHj.js → ImageStudioPanels-B2PTq6Yb.js} +1 -1
  20. package/web/assets/{ImageStudioView-_CYHoOoG.js → ImageStudioView-Cawr6pGW.js} +1 -1
  21. package/web/assets/{InlineFiles-BIfsx3R-.js → InlineFiles-DKPH5JHz.js} +1 -1
  22. package/web/assets/{MarkdownBlock-wYEaBBOr.js → MarkdownBlock-BHpDy2qQ.js} +1 -1
  23. package/web/assets/{ModelPill-DveHcLqq.js → ModelPill-ChzAM3z1.js} +1 -1
  24. package/web/assets/{MuseLibraryView-Do9RnKiq.js → MuseLibraryView-DLuQ_jyV.js} +2 -2
  25. package/web/assets/{MuseView-3GL4Ltoj.js → MuseView-CDDwV6SR.js} +2 -2
  26. package/web/assets/{PageHistoryPanel-BMQC-V_l.js → PageHistoryPanel-BbdXpjJM.js} +2 -2
  27. package/web/assets/{PdfAnnotator-CyAw8sgq.js → PdfAnnotator-CW0wPWRB.js} +1 -1
  28. package/web/assets/{PenRow-BSB-h5Pb.js → PenRow-BY-MZLDQ.js} +1 -1
  29. package/web/assets/{ProductView-B96OeHOP.js → ProductView-0ieVL3rY.js} +1 -1
  30. package/web/assets/{RightPanel-BgSeCLnw.js → RightPanel-BRexwQ3W.js} +1 -1
  31. package/web/assets/RunLocationPicker-BrDfOu8-.css +1 -0
  32. package/web/assets/RunLocationPicker-CadYiE7C.js +43 -0
  33. package/web/assets/{SketchCard-DAD0jR0i.js → SketchCard-BcXCdBAs.js} +1 -1
  34. package/web/assets/{StudioGuestSurface-DlUKXBXv.js → StudioGuestSurface-ZJFKnNYF.js} +1 -1
  35. package/web/assets/{TodoListView-_yFkPUrw.js → TodoListView-DuRdVFgB.js} +1 -1
  36. package/web/assets/{Tooltip-DXuy9-1_.js → Tooltip-DtDUL18W.js} +1 -1
  37. package/web/assets/{UnifiedPage-EJNWKzxN.js → UnifiedPage-D7JTfABH.js} +3 -3
  38. package/web/assets/{amadeus-manual.en-DzRWr4BL.js → amadeus-manual.en-B8J-svqq.js} +1 -1
  39. package/web/assets/{amadeus-manual.zh-DW32DkL7.js → amadeus-manual.zh-CkCOFnrg.js} +1 -1
  40. package/web/assets/appStore-ClD7vq5L.css +1 -0
  41. package/web/assets/{appStore-CidPWYa0.js → appStore-affnJoin.js} +155 -117
  42. package/web/assets/{arrow-up-right-KPFbRA41.js → arrow-up-right-R4P9Mmxz.js} +1 -1
  43. package/web/assets/{astryxBridge-Bupzouso.js → astryxBridge-CT2wZJXs.js} +3 -3
  44. package/web/assets/{automationListSource-1aOVKBLw.js → automationListSource-JVBMsMbC.js} +1 -1
  45. package/web/assets/{boardSurface-BHuMoQN-.js → boardSurface-Ce0_vf9f.js} +1 -1
  46. package/web/assets/{book-open-CBeNsIpo.js → book-open-CcXCToyx.js} +1 -1
  47. package/web/assets/{calendarNavStore-Duyhbmm_.js → calendarNavStore-tQJRVpum.js} +1 -1
  48. package/web/assets/{canvasPrefs-CxfyDTMT.js → canvasPrefs-CSuX9aLF.js} +1 -1
  49. package/web/assets/{chatBoxSurface-OBzO1Z5E.js → chatBoxSurface-IG6Vu4Dz.js} +1 -1
  50. package/web/assets/{circle-question-mark-M8QUJJYk.js → circle-question-mark-O8AhUz35.js} +1 -1
  51. package/web/assets/{circle-x-Szwop5L_.js → circle-x-AV2ZWulM.js} +1 -1
  52. package/web/assets/{client-CPUljePZ.js → client-BqhpYbYL.js} +1 -1
  53. package/web/assets/{code-xml-n9mgGgkv.js → code-xml-DdR58F83.js} +1 -1
  54. package/web/assets/{codeStudioStore-DXMQwRzG.js → codeStudioStore-Dq5i8nbE.js} +1 -1
  55. package/web/assets/codingNavigation-CxdCK78-.js +53 -0
  56. package/web/assets/codingNavigation-_tOR0ell.css +1 -0
  57. package/web/assets/{create-C19zqt5N.js → create-BgJN5qsj.js} +2 -2
  58. package/web/assets/{dashboardSurface-BwcH16Qc.js → dashboardSurface-BY-AFB-r.js} +1 -1
  59. package/web/assets/{deskCapture-B_LKZSPt.js → deskCapture-BD2qD6NI.js} +1 -1
  60. package/web/assets/{diff2html-DrCCWvpR.js → diff2html-OoRdHZ_O.js} +1 -1
  61. package/web/assets/{docx-preview-Bi7wekSM.js → docx-preview-B43XC8Cn.js} +1 -1
  62. package/web/assets/{emoji-DczIG8SO.js → emoji-BPdA62d7.js} +1 -1
  63. package/web/assets/{floatingTocSurface-rc1ZC7-I.js → floatingTocSurface-BM2SYE_u.js} +1 -1
  64. package/web/assets/{foldActions-BGocXE-o.js → foldActions-BcyvNVBs.js} +1 -1
  65. package/web/assets/{folder-CoOsfQ64.js → folder-CCZqnwRc.js} +1 -1
  66. package/web/assets/{folder-plus-d5MwIMlf.js → folder-plus-BJKT1Pqg.js} +1 -1
  67. package/web/assets/{gestures-CXFaEydn.js → gestures-BwPbZDkU.js} +1 -1
  68. package/web/assets/{hand-fuehbnkI.js → hand-DRu7IJdU.js} +1 -1
  69. package/web/assets/{hard-drive-Bh1DmZg0.js → hard-drive-CXNJUCXw.js} +1 -1
  70. package/web/assets/i18n-BMo19xaR.css +1 -0
  71. package/web/assets/i18n.generated-DvY59Zq3.js +15 -0
  72. package/web/assets/{imageStudio-Dgl1wZNB.js → imageStudio-Axwmd4GW.js} +2 -2
  73. package/web/assets/imageStudio-DZ0qGU2s.css +1 -0
  74. package/web/assets/{index-e-MxdHFO.js → index-B1rE_NwA.js} +1 -1
  75. package/web/assets/{index-lfow5R3O.js → index-BFTY79aq.js} +1 -1
  76. package/web/assets/{index-38xsQSS9.js → index-BGEkZBs2.js} +1 -1
  77. package/web/assets/{index-YRWOePBS.js → index-BO2XJc36.js} +1 -1
  78. package/web/assets/{index-B5UW6SaE.js → index-BYUntVIZ.js} +2 -2
  79. package/web/assets/{index-2tD0kijW.js → index-C65u4fXd.js} +1 -1
  80. package/web/assets/{index-BCG8Wnc4.js → index-C_Ohi-I3.js} +1 -1
  81. package/web/assets/{index-Dff-DL1v.js → index-CkMhazev.js} +1 -1
  82. package/web/assets/{index-Dc8iMctf.js → index-CobUnTcv.js} +1 -1
  83. package/web/assets/{index-Dy07SBfH.js → index-D102FOuM.js} +1 -1
  84. package/web/assets/{index-B8Co6KG3.js → index-D3CYvMpl.js} +1 -1
  85. package/web/assets/{index-QjVOA7QM.js → index-D78izbLA.js} +1 -1
  86. package/web/assets/{index-BPqoEOV_.js → index-DDMXVG0h.js} +1 -1
  87. package/web/assets/{index-CPLtf9Vc.js → index-DY0M_dpd.js} +1 -1
  88. package/web/assets/{index-7kdR1oL8.js → index-DcbZwhpE.js} +1 -1
  89. package/web/assets/{index-D4CSH-v1.js → index-Dlkq7gkE.js} +1 -1
  90. package/web/assets/{index-Ch0FIsJX.js → index-HqmJW2np.js} +1 -1
  91. package/web/assets/{index-DcRyQ3eU.js → index-LxlyPm0_.js} +1 -1
  92. package/web/assets/{index-Ce1sNSS8.js → index-Uq4J2aoW.js} +1 -1
  93. package/web/assets/{index-DvOrTnw2.js → index-WbVt2P8R.js} +1 -1
  94. package/web/assets/{index-Df9jregv.js → index-XyjIhkPw.js} +1 -1
  95. package/web/assets/{index-BqGpbntz.js → index-Y2kzYlZq.js} +1 -1
  96. package/web/assets/{index-CnDAYLti.js → index-mB0EQkyZ.js} +1 -1
  97. package/web/assets/{index-fViJsYjM.js → index-pJh7JN7_.js} +1 -1
  98. package/web/assets/{index-Dx9aIoyo.js → index-taRxNsbp.js} +1 -1
  99. package/web/assets/{invitePage-Dgl3-c_m.js → invitePage-BW0BH8Ac.js} +1 -1
  100. package/web/assets/{ipc-CNlIRMtU.js → ipc-D7yENkjV.js} +1 -1
  101. package/web/assets/{jszip.min-tyV0GaJg.js → jszip.min-UE5d5vPJ.js} +1 -1
  102. package/web/assets/{layout-grid-DFmwM9NU.js → layout-grid-Hs3eDA07.js} +1 -1
  103. package/web/assets/{linkFollow-iP2zfbA3.js → linkFollow-Msu1XH9v.js} +4 -4
  104. package/web/assets/{list-tree-i07HsP3D.js → list-tree-DmuRb-p9.js} +1 -1
  105. package/web/assets/{listFold-Aea6I0Sa.js → listFold-CKxjyY5_.js} +1 -1
  106. package/web/assets/{lock-TSDKuCod.js → lock-kffGfeHt.js} +1 -1
  107. package/web/assets/{log-out-DK84lW5n.js → log-out-B5gEP0tF.js} +1 -1
  108. package/web/assets/main-DIyFlyfK.js +20 -0
  109. package/web/assets/markdownEditorSurface-Cx2rqFAY.js +3 -0
  110. package/web/assets/{message-square-plus-3wFslIMY.js → message-square-plus-DxBPIhPS.js} +1 -1
  111. package/web/assets/{messages-DEAGRsC3.js → messages-4w1Khzm1.js} +1 -1
  112. package/web/assets/minus-CfoZ4oxr.js +1 -0
  113. package/web/assets/{mobileEntry-5UaAITwY.js → mobileEntry-B8JwR53-.js} +1 -1
  114. package/web/assets/{nativeDownload-B3JGkABw.js → nativeDownload-Udrv_tmU.js} +1 -1
  115. package/web/assets/{pageChrome-DFi9zs6F.js → pageChrome-D-9npbUE.js} +1 -1
  116. package/web/assets/{pageChrome-BDHHmRnt.css → pageChrome-eO9pb2fH.css} +1 -1
  117. package/web/assets/{pageTree-DZ7Eiro-.js → pageTree-CIXFRCLk.js} +2 -2
  118. package/web/assets/{pen-tool-ChGmX6g_.js → pen-tool-D_Y9We9x.js} +1 -1
  119. package/web/assets/{pencil-CJsJD7M_.js → pencil-DGiTRzW1.js} +1 -1
  120. package/web/assets/phoneList-BQfCJwKF.css +1 -0
  121. package/web/assets/{phoneList-DrxIwJxQ.js → phoneList-DHUia6HT.js} +1 -1
  122. package/web/assets/{pluginChat-0QI9a8Q1.js → pluginChat-BXuJiMYi.js} +1 -1
  123. package/web/assets/{redo-2-CI57sDFr.js → redo-2-QgiKEg9T.js} +1 -1
  124. package/web/assets/{rotate-ccw-xgT_0UN9.js → rotate-ccw-BLoH5er1.js} +1 -1
  125. package/web/assets/{sharePage-C2Yqx0NQ.js → sharePage-DYYN5usb.js} +2 -2
  126. package/web/assets/{shareViewer-DKPWhTJv.js → shareViewer-BzuSyJv_.js} +1 -1
  127. package/web/assets/{star-C9KTji9N.js → star-BmywYD3u.js} +1 -1
  128. package/web/assets/{tableSurface-cYs6dX6B.js → tableSurface-21LDYY_G.js} +1 -1
  129. package/web/assets/{terminal-DPZazOQ2.js → terminal-BlmA_Z1C.js} +1 -1
  130. package/web/assets/{terminalView-CsJmxE_m.js → terminalView-SAxITnRW.js} +1 -1
  131. package/web/assets/{type-C5J875vb.js → type-DmIL6FB-.js} +1 -1
  132. package/web/assets/{undo-2-BOUt5qks.js → undo-2-yMeXc8Wi.js} +1 -1
  133. package/web/assets/{unitAccount-BIAIxKNp.js → unitAccount-BPYRAa3m.js} +1 -1
  134. package/web/assets/{unitBridge-b2C6zb3a.js → unitBridge-BNVzai6X.js} +1 -1
  135. package/web/assets/{unitCloudTransport-NGtDDKWo.js → unitCloudTransport-iFweA1xk.js} +1 -1
  136. package/web/assets/{unitOwnerAccess-CwH9ApZT.js → unitOwnerAccess-Bggl7bDP.js} +1 -1
  137. package/web/assets/{unitShim-CY8EVkKD.js → unitShim-BP2nBO_k.js} +3 -3
  138. package/web/assets/{upload-CrbEAW8C.js → upload-D20PZHXc.js} +1 -1
  139. package/web/assets/userSpaces-CrLrKklx.js +1 -0
  140. package/web/assets/{viewportLock-Bi3orrUs.css → viewportLock-DO1lzA2N.css} +1 -1
  141. package/web/assets/viewportLock-tlT6H_Hc.js +629 -0
  142. package/web/assets/{workflow-DY2Cnaei.js → workflow-Bd6xBHiT.js} +1 -1
  143. package/web/assets/{zoom-in-BcuPvIYd.js → zoom-in-_TgFOpyv.js} +1 -1
  144. package/web/index.html +2 -2
  145. package/web/assets/DashboardGridView-hpRmBr9B.css +0 -1
  146. package/web/assets/HomepageView-Cxf3AWBu.css +0 -1
  147. package/web/assets/RunLocationPicker-CEmFio4n.css +0 -1
  148. package/web/assets/RunLocationPicker-M1UoJyjf.js +0 -38
  149. package/web/assets/appStore-DeaC1U32.css +0 -1
  150. package/web/assets/codingNavigation-CCjs1kon.js +0 -53
  151. package/web/assets/codingNavigation-yp19w6uu.css +0 -1
  152. package/web/assets/i18n-DjziAw8r.css +0 -1
  153. package/web/assets/i18n.generated-BiQFRL2U.js +0 -15
  154. package/web/assets/imageStudio--KF9gwHA.css +0 -1
  155. package/web/assets/main-D7CEGndC.js +0 -20
  156. package/web/assets/markdownEditorSurface-DISu_twy.js +0 -3
  157. package/web/assets/minus-BBdfT_sc.js +0 -1
  158. package/web/assets/phoneList-DvpzD3zT.css +0 -1
  159. package/web/assets/userSpaces-B_Njvel_.js +0 -1
  160. package/web/assets/viewportLock-DZ927PNz.js +0 -629
@@ -1 +1 @@
1
- import{u as en,d as g,j as e,r as Dn}from"./index-B5UW6SaE.js";import{G as nn,l as An,a6 as ve,m as ne,fO as On,kx as Ue,ky as In,kz as Wn,kA as zn,Z as Tn,cQ as Rn,bI as Ln,fS as me,kB as ge,kC as fe,kD as Ve,aF as xe,aK as je,aP as _n,kE as sn,ai as Fn,aj as $n,b as Bn,u as F,aT as tn,hA as Hn,kF as Un,kG as Vn,kH as qn,ia as Gn,kI as Kn,ib as Jn,kJ as Yn,bq as Zn,ap as O,kK as Xn,kL as Qn,kM as on,kN as Ce,a5 as es,fV as qe,am as Ge,e2 as ns,dY as ss,ab as we,q as Ke,fC as ts,cW as os,fr as as,kO as rs,an as Je,al as is,kP as ls,a$ as cs,af as ds}from"./appStore-CidPWYa0.js";import"./client-CPUljePZ.js";import{a as ps,d as us}from"./phoneList-DrxIwJxQ.js";import{a4 as hs,a5 as ms,a6 as gs,C as fs,H as xs}from"./RunLocationPicker-M1UoJyjf.js";import{U as js}from"./upload-CrbEAW8C.js";import{F as ws}from"./folder-plus-d5MwIMlf.js";import{L as bs}from"./log-out-DK84lW5n.js";import{P as vs}from"./pencil-CJsJD7M_.js";import"./nativeDownload-B3JGkABw.js";import"./ipc-CNlIRMtU.js";import"./codeStudioStore-DXMQwRzG.js";import"./RightPanel-BgSeCLnw.js";import"./book-open-CBeNsIpo.js";import"./folder-CoOsfQ64.js";import"./ModelPill-DveHcLqq.js";import"./create-C19zqt5N.js";import"./approvalText-Cy2UAUAQ.js";import"./message-square-plus-3wFslIMY.js";import"./hand-fuehbnkI.js";import"./pageChrome-DFi9zs6F.js";import"./emoji-DczIG8SO.js";const Cs=[["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=nn("folder-minus",Cs);const ks=[["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"}]],Ye=nn("grid-2x2",ks),an="forsion.homepage.wallpaper.v1",ys=32*1024*1024,rn={source:"theme",themePreset:"rings",bingDaily:!0,focusBlur:!0,vignette:!0,bing:null},z=t=>typeof t=="string"?t:"";function Ze(t){const s=z(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 Se(t){if(!t||typeof t!="object")return null;const s=t,i=Ze(s.url);if(!i)return null;const d=Ze(s.thumbnailUrl)||i,l=z(s.startDate);return{id:z(s.id)||l||i,url:i,thumbnailUrl:d,title:z(s.title),copyright:z(s.copyright),startDate:l}}function Ns(t){if(!t||typeof t!="object")return{...rn};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:Se(s.bing)}}function Ms(){try{return Ns(JSON.parse(localStorage.getItem(an)||"null"))}catch{return{...rn}}}function Ps(t){try{localStorage.setItem(an,JSON.stringify(t))}catch{}}function Es(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,l=z(d.urlbase),o=z(d.url),c=l?`https://www.bing.com${l}_UHD.jpg`:o.startsWith("/")?`https://www.bing.com${o}`:o,x=l?`https://www.bing.com${l}_400x240.jpg`:c,u=Se({id:z(d.startdate)||l||c,url:c,thumbnailUrl:x,title:d.title,copyright:d.copyright,startDate:d.startdate});return u?[u]:[]})}async function Ds(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(Se).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 Es(await s.json())}const As="forsion-homepage",se="wallpaper",ke="custom";function Os(){return new Promise((t,s)=>{const i=indexedDB.open(As,1);i.onupgradeneeded=()=>{i.result.objectStoreNames.contains(se)||i.result.createObjectStore(se)},i.onsuccess=()=>t(i.result),i.onerror=()=>s(i.error||new Error("IndexedDB unavailable"))})}async function ye(t,s){const i=await Os();try{return await new Promise((d,l)=>{const o=i.transaction(se,t),c=s(o.objectStore(se));let x;c.onsuccess=()=>{x=c.result},c.onerror=()=>l(c.error||o.error||new Error("Wallpaper storage failed")),o.oncomplete=()=>d(x),o.onerror=()=>l(o.error||new Error("Wallpaper storage failed")),o.onabort=()=>l(o.error||new Error("Wallpaper storage aborted"))})}finally{i.close()}}async function Is(){const t=await ye("readonly",s=>s.get(ke));return t instanceof Blob&&t.type.startsWith("image/")?t:null}async function Ws(t){if(!t.type.startsWith("image/"))throw new Error("NOT_IMAGE");if(t.size>ys)throw new Error("TOO_LARGE");await ye("readwrite",s=>s.put(t,ke))}async function zs(){await ye("readwrite",t=>t.delete(ke))}const te="home",Ts=140,Rs=6,ln="forsion.homepage.pinned-spaces.v1",be="homepage:pinned-spaces",V="homepage:pinned:",Ls=["rb-market","rb-achievements"],_s=["rings","topography","weave","hack2gate"],Xe=t=>{const s=Xn(t);return s.length?s:sn(t)};function Fs({onDispatch:t,onStartCall:s,onInputModeChange:i}){const d=Bn(a=>a.vaultRoot),l=ve(a=>a.activeSpaceId),o=F(tn(a=>({cfg:a.cfg,desktopConfig:a.desktopConfig,desktopMode:a.desktopMode,homeDir:a.homeDir,defaultWsDir:a.defaultWsDir,modelsResp:a.modelsResp,newChatWs:a.newChatWs,newChatCfg:a.newChatCfg,newChatModel:a.newChatModel,sessionMode:a.sessionMode,setSessionMode:a.setSessionMode,engines:a.engines,engineCaps:a.engineCaps,agentDefs:a.agentDefs,defaultAgentSlug:a.defaultAgentSlug,skillsList:a.skillsList,connState:a.connState,voiceOnByAgent:a.voiceOnByAgent,ensureEngineCaps:a.ensureEngineCaps,refreshVoiceMode:a.refreshVoiceMode,setSessionModel:a.setSessionModel,setNewChatCfg:a.setNewChatCfg,setSessionThinking:a.setSessionThinking,setDefaultModel:a.setDefaultModel,setModelContextWindow:a.setModelContextWindow,setVoiceMode:a.setVoiceMode,setExecConfig:a.setExecConfig,openSettings:a.openSettings,setNewChatWs:a.setNewChatWs,addLocalWorkspace:a.addLocalWorkspace,addCloudProject:a.addCloudProject,workspaces:a.workspaces,sessions:a.sessions,archivedSessions:a.archivedSessions,cloudProjects:a.cloudProjects,channelWorkspaces:a.channelWorkspaces,tr:a.tr})));Hn();const c=Un(o),x=g.useMemo(()=>o.workspaces(),[o.workspaces,o.sessions,o.archivedSessions,o.cloudProjects,o.channelWorkspaces,o.defaultWsDir,o.homeDir,o.tr,d]),u=Vn(o.sessionMode,c),m=u==="chat"||c.kind==="cloud"||c.kind==="rootless",f=g.useMemo(()=>qn(Gn(Kn({execMode:m?"sandbox":"host",...Jn(o.desktopConfig,!m,u),cwd:m?void 0:c.path||void 0,...o.newChatCfg},u),d)),[m,u,o.desktopConfig,o.newChatCfg,c.path,d]),S=Yn(o)||"",I=o.modelsResp?.models?o.modelsResp.models.filter(a=>(a.modelType||"llm")==="llm"&&(!m||a.source==="forsion")):null,v=f.agentSlug||o.defaultAgentSlug,N=v?!!o.voiceOnByAgent[v]:!1;return g.useEffect(()=>{o.ensureEngineCaps(f.engineId||void 0)},[f.engineId,o.ensureEngineCaps]),g.useEffect(()=>{v&&o.refreshVoiceMode(v)},[v,o.refreshVoiceMode]),e.jsxs("div",{className:"hp-composer",onClick:a=>a.stopPropagation(),onPointerDownCapture:()=>i(!0),onPointerDown:a=>a.stopPropagation(),onFocusCapture:()=>i(!0),onBlurCapture:a=>{a.relatedTarget instanceof Node&&!a.currentTarget.contains(a.relatedTarget)&&i(!1)},onKeyDownCapture:a=>{a.key==="Escape"&&a.target.matches?.(".t2c-ta")&&(a.target.blur(),i(!1))},children:[e.jsx("div",{className:"newchat-pickers",children:e.jsx(hs,{sessionId:null,cfg:f})}),e.jsxs("div",{className:"hp-projectbar",children:[e.jsx(ms,{}),e.jsx(gs,{workspaces:x,value:c.key,onChange:o.setNewChatWs,onAddProject:window.tangu?.pickDirectory?()=>{o.addLocalWorkspace()}:void 0,onAddCloudProject:a=>{o.addCloudProject(a)}})]}),e.jsx(fs,{sessionId:null,liveOwner:l==="home",prepareLiveSession:s,autoFocus:!1,disabled:o.connState!=="ok",running:!1,execConfig:f,models:I,modelsResponse:o.modelsResp,modelId:S,onModelChange:a=>o.setSessionModel(a,null),engines:o.engines,engineId:f.engineId,engineModels:f.engineId?o.engineCaps[f.engineId]?.models??[]:void 0,engineModelId:f.engineModelId,onEngineModelChange:a=>o.setNewChatCfg(w=>({...w,engineModelId:a||void 0})),engineCommands:f.engineId?o.engineCaps[f.engineId]?.commands??[]:void 0,thinkingLevel:f.thinkingLevel,ultra:f.ultra,onThinkingChange:(a,w)=>o.setSessionThinking(a,null,void 0,w),defaultModelIds:{backgroundModelId:o.desktopConfig?.backgroundModelId||"",imageModelId:o.cfg.imageModelId||"",visionModelId:o.cfg.visionModelId||""},onDefaultModelChange:o.setDefaultModel,onContextWindowChange:(a,w)=>{o.setModelContextWindow(a,w)},maxIterations:f.maxIterations,onMaxIterationsChange:a=>o.setNewChatCfg(w=>({...w,maxIterations:a})),verifyCommand:f.verifyCommand,onVerifyCommandChange:a=>o.setNewChatCfg(w=>({...w,verifyCommand:a||void 0})),planMode:f.planMode,onPlanModeChange:a=>o.setNewChatCfg(w=>({...w,planMode:a})),preset:f.preset,onPresetChange:a=>o.setSessionMode(a),voiceMode:N,onVoiceModeChange:v?a=>{o.setVoiceMode(v,a)}:void 0,groupChat:f.groupChat,groupAgents:f.groupAgents,groupTempAgents:f.groupTempAgents,onGroupChange:a=>o.setNewChatCfg(w=>({...w,...a})),skills:o.skillsList,agents:o.agentDefs,currentAgentSlug:v,onOpenSettings:()=>o.openSettings("skills"),onExecConfigChange:a=>o.setExecConfig(a,null),onSend:(a,w,q,T,k)=>t(a,w,q,T,k),onStop:()=>{},autoRefFromMain:!1})]})}function $({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:O(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(es,{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 $s(){try{const t=JSON.parse(localStorage.getItem(ln)||"[]");return Array.isArray(t)?[...new Set(t.filter(s=>typeof s=="string"&&s!==te))]:[]}catch{return[]}}function Bs({item:t}){const s=t.icon,i=t.tooltip?O(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 Hs({space:t,onLaunch:s}){const i=`${V}${t.id}`,{attributes:d,listeners:l,setNodeRef:o,transform:c,isDragging:x}=ls({id:i}),u={kind:"space",id:`space:${t.id}`,space:t};return e.jsx("button",{ref:o,type:"button",className:`hp-tile hp-pinned-space${x?" dragging":""}`,"data-space-id":t.id,style:{transform:Ce.Transform.toString(c)},"aria-label":O(t.name),title:O(t.name),...d,...l,onClick:()=>{x||s(t.id)},children:e.jsx($,{tile:u})})}function Us({actions:t,spaces:s,onLaunch:i,labelText:d}){const{isOver:l,setNodeRef:o}=Qn({id:be});return e.jsxs("div",{ref:o,className:"hp-pinned-zone","data-over":l||void 0,"aria-label":d,children:[t.map(c=>e.jsx(Bs,{item:c},c.id)),s.map(c=>e.jsx(Hs,{space:c,onLaunch:i},c.id))]})}function Qe({tile:t,over:s,open:i,onOpen:d,onLaunch:l,onMenu:o}){const{attributes:c,listeners:x,setNodeRef:u,transform:m,transition:f,isDragging:S}=on({id:t.id}),I=t.kind==="space"?O(t.space.name):t.folder.name,v={transform:Ce.Transform.toString(m),transition:f?`${f}, color var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out)`:void 0};return e.jsx("button",{ref:u,type:"button",style:v,className:`hp-tile${t.kind==="folder"?" hp-folder":""}${S?" dragging":""}${i?" on":""}`,"data-id":t.id,"data-over":s||void 0,"aria-label":I,title:I,...c,...x,onClick:N=>{S||(t.kind==="folder"?(N.stopPropagation(),d(N,t.id)):l(t.space.id))},onContextMenu:t.kind==="folder"?N=>o(N,t.id):void 0,children:e.jsx($,{tile:t})})}function Vs({member:t,onLaunch:s,onMenu:i}){const d=`space:${t.id}`,{attributes:l,listeners:o,setNodeRef:c,transform:x,transition:u,isDragging:m}=on({id:d});return e.jsxs("button",{ref:c,type:"button",className:`hp-folder-app${m?" dragging":""}`,style:{transform:Ce.Transform.toString(x),transition:u},"data-id":d,title:O(t.name),...l,...o,onClick:()=>{m||s(t.id)},onContextMenu:f=>i(f,d),children:[e.jsx("span",{className:"hp-folder-app-icon",children:t.icon&&e.jsx(t.icon,{size:24})}),e.jsx("span",{children:O(t.name)})]})}function qs(t){const s=()=>{const l=new Date;return{time:ss(l),date:ns(l,{locale:t}),hour:l.getHours()}},[i,d]=g.useState(s);return g.useEffect(()=>{const l=()=>d(c=>{const x=s();return x.time===c.time&&x.date===c.date?c:x});l();const o=setInterval(l,1e3);return()=>clearInterval(o)},[t]),i}function Gs(){const[t,s]=g.useState("");return g.useEffect(()=>{let i=!0;const d=()=>{window.tangu?.authStatus?.().then(o=>{i&&s(o?.loggedIn&&(o.nickname||o.username)||"")}).catch(()=>{})};d();const l=window.tangu?.onAuthChanged?.(d);return()=>{i=!1,l?.()}},[]),t}function Ks(){const t=ve(u=>u.spaces),s=ne(u=>u.order),d=ne(u=>u.folders).filter(u=>u.zone==="top"),l=u=>t.find(m=>`space:${m.id}`===u),o=new Set(d.flatMap(u=>u.items)),c=$n([...t.map(u=>`space:${u.id}`),...d.map(u=>u.id)],s).filter(u=>!o.has(u)),x=[];for(const u of c){if(u===`space:${te}`)continue;const m=d.find(S=>S.id===u);if(m){x.push({kind:"folder",id:u,folder:m,members:m.items.map(l).filter(S=>!!S)});continue}const f=l(u);f&&x.push({kind:"space",id:u,space:f})}return{tiles:x,topIds:c,order:s}}Dn({"home.folderMenu.renameTitle":{zh:"重命名收纳夹",en:"Rename folder"},"home.folderMenu.rename":{zh:"重命名",en:"Rename"},"home.folderMenu.dissolve":{zh:"解散收纳夹",en:"Dissolve folder"},"home.folderMenu.moveOut":{zh:"移出收纳夹",en:"Move out"},"home.pill":{zh:"问点什么…",en:"Ask anything…"},"home.card.continue":{zh:"继续:{title}",en:"Continue: {title}"},"home.card.claimable":{zh:"{n} 项可领取",en:"{n} to claim"},"home.card.earned":{zh:"已得 {n} 项",en:"{n} earned"},"home.card.installed":{zh:"已装 {n} 个插件",en:"{n} plugins installed"}});function Js({tiles:t,actions:s,onLaunch:i}){const d=Ys();return e.jsxs("section",{className:"hp-cards",children:[t.filter(l=>l.kind==="space").slice(0,2).map(l=>e.jsxs("button",{type:"button",className:"hp-card","data-space-id":l.space.id,onClick:o=>{o.stopPropagation(),i(l.space.id)},children:[e.jsx("span",{className:"hp-card-icon",children:l.space.icon&&e.jsx(l.space.icon,{})}),e.jsx("span",{className:"hp-card-name",children:O(l.space.name)}),e.jsx("span",{className:"hp-card-status",children:d(l.space.id)})]},l.id)),s.map(l=>e.jsxs("button",{type:"button",className:"hp-card","data-fixed-id":l.id,onClick:o=>{o.stopPropagation(),l.onClick?.()},children:[e.jsx("span",{className:"hp-card-icon",children:l.icon&&e.jsx(l.icon,{})}),e.jsx("span",{className:"hp-card-name",children:l.tooltip?O(l.tooltip):""}),e.jsx("span",{className:"hp-card-status",children:d(l.id)})]},l.id))]})}function Ys(){const{t}=en(),s=F(o=>o.sessions[0]),i=ts(o=>o.recents[0]),d=os(o=>o.plugins.filter(c=>!c.builtin&&!c.preinstalled).length),l=as(tn(o=>({counters:o.counters,claimed:o.claimed,pluginSeries:o.pluginSeries})));return o=>{if(o==="tangu")return s?t("home.card.continue",{title:xs(s.title,t)}):"";if(o==="amadeus")return i?(i.split("/").pop()??i).replace(/\.md$/i,""):"";if(o==="rb-market")return d?t("home.card.installed",{n:String(d)}):"";if(o==="rb-achievements"){const c=rs(l).flatMap(m=>m.achievements),x=c.filter(m=>!l.claimed[m.id]&&(l.counters[m.event]||0)>=m.goal).length,u=c.filter(m=>l.claimed[m.id]).length;return x?t("home.card.claimable",{n:String(x)}):u?t("home.card.earned",{n:String(u)}):""}return""}}function wt(t){const{t:s,locale:i}=en(),d=i==="zh",l=qs(i),o=Gs(),c=An(),x=ve(n=>n.spaces),u=ne(n=>n.items),{tiles:m,topIds:f,order:S}=Ks(),[I,v]=g.useState($s),[N,a]=g.useState(null),[w,q]=g.useState(null),[T,k]=g.useState(!1),[W,M]=g.useState(null),[E,y]=g.useState(null),[cn,Ne]=g.useState(!1),[oe,ae]=g.useState(!1),[G,B]=g.useState(!1),[h,re]=g.useState(Ms),[R,ie]=g.useState(null),[H,dn]=g.useState([]),[Me,Pe]=g.useState(!1),[Ee,K]=g.useState(""),[pn,un]=g.useState(0),J=g.useRef(null),le=g.useRef(null),L=g.useRef(null),Y=g.useRef(null),[De]=g.useState(()=>{try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}),ce=On(Ue(zn,{activationConstraint:{distance:6}}),Ue(Wn,{coordinateGetter:In}));g.useEffect(()=>{Ps(h)},[h]),g.useEffect(()=>{try{localStorage.setItem(ln,JSON.stringify(I))}catch{}},[I]),g.useEffect(()=>{let n=!0;return Is().then(r=>{if(n){if(!r){re(p=>p.source==="custom"?{...p,source:"theme"}:p);return}ie(URL.createObjectURL(r))}}).catch(()=>{}),()=>{n=!1}},[]),g.useEffect(()=>()=>{R&&URL.revokeObjectURL(R)},[R]),g.useEffect(()=>{if(h.source!=="bing")return;let n=!0;return Pe(!0),K(""),Ds(i).then(r=>{n&&(dn(r),r[0]&&re(p=>p.source==="bing"&&p.bingDaily&&p.bing?.id!==r[0].id?{...p,bing:r[0]}:p))}).catch(()=>{n&&K(s("home.wallpaper.bingError"))}).finally(()=>{n&&Pe(!1)}),()=>{n=!1}},[pn,i,s,h.source]),g.useEffect(()=>()=>{L.current&&(window.clearTimeout(L.current),L.current=null);const n=Y.current;Y.current=null,n?.()},[]);const de=n=>L.current?!1:De?(n(),!0):(Ne(!0),Y.current=n,L.current=window.setTimeout(()=>{L.current=null,Y.current=null,n(),Ne(!1)},Ts),!0),U=n=>{const r=cs?ds()?.openSpace:void 0;r?r(n):de(()=>we(n))},Z=x.some(n=>n.id==="tangu"),Ae=l.hour<5?"home.greet.night":l.hour<11?"home.greet.morning":l.hour<18?"home.greet.afternoon":"home.greet.evening",D=()=>ne.getState(),hn=()=>{M(null),k(!1),y(null)},X=h.source==="bing"?h.bing?.url||null:h.source==="custom"?R:null,A=n=>{re(r=>({...r,...n}))},mn=n=>{if(n==="custom"&&!R){le.current?.click();return}if(n==="bing"){A({source:n,bing:h.bing||H[0]||null});return}A({source:n})},gn=n=>{n&&(K(""),Ws(n).then(()=>{ie(URL.createObjectURL(n)),A({source:"custom"})}).catch(r=>{K(s(r instanceof Error&&r.message==="TOO_LARGE"?"home.wallpaper.tooLarge":"home.wallpaper.invalid"))}))},fn=()=>{zs().catch(()=>{}),ie(null),A({source:"theme"})},xn=(n,r)=>{if(!n||n===r)return;const p=is(S,f),j=p.indexOf(r);D().setZoneOrder("top",Ge(p,n,j>=0?j:p.length))},jn=(n,r)=>{!n||n===r||n.startsWith("folder:")||(D().moveIntoFolder(r,n),D().setZoneOrder("top",Je(S,f,n)))},wn=n=>{D().moveOutOfFolder(n),D().setZoneOrder("top",[...Je(S,f,n),n]),k(!0)},bn=()=>{y(null),qe(d?"新建收纳夹":"New folder",d?"收纳夹":"Folder").then(n=>{const r=n?.trim();r&&(D().addFolder("top",r),k(!0))})},Oe=()=>{a(null),q(null)},Ie=n=>{M(null),y(null),a(String(n.active.id))},We=n=>q(n.over?String(n.over.id):null),ze=n=>Oe(),Te=n=>{const r=String(n.active.id),p=n.over?String(n.over.id):null;if(Oe(),r.startsWith(V)){if(p!==be){const b=r.slice(V.length);v(P=>P.filter(He=>He!==b))}return}if(p===be){const b=m.find(P=>P.id===r);b?.kind==="space"&&b.space.id!==te&&v(P=>P.includes(b.space.id)?P:[...P,b.space.id]);return}if(!p||r===p)return;const j=m.find(b=>b.id===p);!r.startsWith("folder:")&&j?.kind==="folder"?jn(r,p):xn(r,p)},pe=(n,r,p)=>{n.preventDefault(),n.stopPropagation(),M(null),y({x:n.clientX,y:n.clientY,kind:r,id:p})},Re=(n,r)=>{const p=n.currentTarget.getBoundingClientRect(),j=J.current?.getBoundingClientRect();y(null),k(!1),M(b=>b?.id===r?null:{id:r,dx:j?p.left+p.width/2-(j.left+j.width/2):0,dy:j?p.top+p.height/2-(j.top+j.height/2):0})},C=W?m.find(n=>n.id===W.id):void 0,Q=C?.kind==="folder"?C.members:[],ee=m.slice(0,Rs),Le=Math.max(0,m.length-ee.length),_=N?m.find(n=>n.id===N):void 0,ue=N?.startsWith(V)?x.find(n=>n.id===N.slice(V.length)):void 0,vn=I.map(n=>x.find(r=>r.id===n)).filter(n=>!!n),_e=Ls.map(n=>u.find(r=>r.id===n)).filter(n=>!!n),Cn=Math.max(0,x.length-(x.some(n=>n.id===te)?1:0)),Sn=n=>{if(!C||C.kind!=="folder"||!n.over)return;const r=String(n.active.id),p=String(n.over.id);if(r===p)return;const j=C.folder.items.indexOf(p);D().setFolderItems(C.id,Ge(C.folder.items,r,j<0?C.folder.items.length:j))},kn=(n,r,p,j,b)=>Z?new Promise(P=>{de(()=>{we("tangu"),Ke.getState().openView("chat",{followActive:!0,reuseKey:"primary"},"main"),P(F.getState().send(n,r,p,j,b,null))})||P(!1)}):Promise.resolve(!1),yn=()=>Z?new Promise(n=>{de(()=>{we("tangu"),Ke.getState().openView("chat",{followActive:!0,reuseKey:"primary"},"main");const p=F.getState().activeId;F.getState().newSession().then(()=>{const j=F.getState().activeId;n(j&&j!==p?j:null)},()=>n(null))})||n(null)}):Promise.resolve(null),he=()=>{const n=document.activeElement;n instanceof HTMLTextAreaElement&&n.matches(".hp-composer .t2c-ta")&&n.blur(),ae(!1)},Nn=(n=!1)=>{Zn.flushSync(()=>ae(!0));const r=J.current?.querySelector(".hp-composer");n?r?.querySelector(".t2c-mic-control")?.click():r?.querySelector(".t2c-ta")?.focus()},[Fe,Mn]=g.useState("");g.useEffect(()=>{c&&!oe&&Mn(J.current?.querySelector(".hp-composer .t2c-ta")?.value.trim()??"")},[c,oe]);const $e=()=>{he(),B(!1),M(null),y(null),k(!0)},Pn=n=>{n.target.closest('button, input, textarea, [contenteditable="true"], .hp-composer, .ctx-menu, .hp-wallpaper-sheet')||(n.preventDefault(),n.stopPropagation(),y(null),W?M(null):T?k(!1):G?B(!1):$e())},Be=n=>n.kind==="member"?[{id:"move-out",label:s("home.folderMenu.moveOut"),icon:e.jsx(bs,{size:13}),run:()=>{wn(n.id),y(null),M(null)}}]:[{id:"rename",label:s("home.folderMenu.rename"),icon:e.jsx(vs,{size:13}),run:()=>{const r=n.id,p=m.find(j=>j.id===r);y(null),qe(s("home.folderMenu.renameTitle"),p?.kind==="folder"?p.folder.name:"").then(j=>{const b=j?.trim();b&&D().renameFolder(r,b)})}},{id:"dissolve",label:s("home.folderMenu.dissolve"),icon:e.jsx(Ss,{size:13}),run:()=>{D().removeFolder(n.id),y(null)}}],En=ps(E,()=>{if(!E)return null;const n=E.kind==="folder"?m.find(r=>r.id===E.id):void 0;return{...n?.kind==="folder"?{title:n.folder.name}:{},sections:[{items:Be(E)}]}},()=>y(null));return e.jsxs("div",{ref:J,className:`hp-root${c?" hp-phone":""}${De?" hp-still":""}${oe?" hp-composer-focused":""}${G?" hp-layer-focused":""}${W||T?" hp-secondary-open":""}`,"data-wallpaper":X||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")||he()},onContextMenu:Pn,onClick:hn,children:[e.jsx("div",{className:"hp-wallpaper",style:X?{backgroundImage:`url(${JSON.stringify(X)})`}: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${G?" on":""}`,"aria-label":s("home.wallpaper.open"),title:s("home.wallpaper.open"),onClick:n=>{n.stopPropagation(),he(),y(null),M(null),k(!1),B(r=>!r)},children:e.jsx(Tn,{size:16})}),e.jsxs("div",{className:`hp-stack${cn?" 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:l.time}),e.jsx("div",{className:"hp-date",children:l.date}),e.jsx("div",{className:"hp-greet",children:o?s(Ae+".named",{name:o}):s(Ae)})]}),Z&&e.jsx(Fs,{onDispatch:kn,onStartCall:yn,onInputModeChange:ae}),c&&Z&&e.jsxs("button",{type:"button",className:"hp-pill","data-act":"home-pill",onClick:n=>{n.stopPropagation(),Nn(!!n.target.closest(".hp-pill-mic"))},children:[e.jsx("span",{className:"hp-pill-text","data-draft":Fe?"":void 0,children:Fe||s("home.pill")}),e.jsx("span",{className:"hp-pill-mic","aria-hidden":!0,children:e.jsx(Rn,{})}),e.jsx("span",{className:"hp-pill-send","aria-hidden":!0,children:e.jsx(Ln,{})})]}),c&&e.jsx(Js,{tiles:m,actions:_e,onLaunch:U}),!c&&e.jsx("section",{className:"hp-spaces","data-total":m.length,children:e.jsxs(me,{sensors:ce,collisionDetection:Xe,onDragStart:Ie,onDragOver:We,onDragCancel:ze,onDragEnd:Te,children:[e.jsxs("div",{className:"hp-space-row",children:[e.jsx(Us,{actions:_e,spaces:vn,labelText:s("home.pinnedSpaces"),onLaunch:U}),e.jsx("span",{className:"hp-space-divider","aria-hidden":!0}),e.jsx("div",{className:"hp-space-main",children:ee.length>0?e.jsx(ge,{items:ee.map(n=>n.id),strategy:fe,children:e.jsxs("div",{className:"hp-dock",children:[ee.map(n=>e.jsx(Qe,{tile:n,over:w===n.id,open:W?.id===n.id,onOpen:Re,onLaunch:U,onMenu:(r,p)=>pe(r,"folder",p)},n.id)),Le>0&&e.jsxs("button",{type:"button",className:"hp-tile hp-more",onClick:n=>{n.stopPropagation(),$e()},title:s("home.showAll"),children:[e.jsx("span",{className:"hp-tile-icon",children:e.jsx(Ye,{size:20})}),e.jsx("span",{className:"hp-tile-name",children:s("home.showAll")}),e.jsxs("span",{className:"hp-more-count",children:["+",Le]})]})]})}):e.jsx("div",{className:"hp-spaces-empty",children:s("home.noSpaces")})})]}),e.jsxs(Ve,{dropAnimation:null,children:[_&&!T&&e.jsx("div",{className:`hp-tile hp-drag-overlay${_.kind==="folder"?" hp-folder":""}`,children:e.jsx($,{tile:_})}),ue&&!T&&e.jsx("div",{className:"hp-tile hp-drag-overlay hp-pinned-space",children:e.jsx($,{tile:{kind:"space",id:`space:${ue.id}`,space:ue}})})]})]})})]}),e.jsx("input",{ref:le,className:"hp-wallpaper-file",type:"file",accept:"image/*",onChange:n=>{gn(n.currentTarget.files?.[0]),n.currentTarget.value=""}}),X&&h.source==="bing"&&h.bing?.copyright&&e.jsx("div",{className:"hp-wallpaper-credit",title:h.bing.copyright,children:h.bing.copyright}),G&&e.jsx("div",{className:"hp-wallpaper-stage",onClick:()=>B(!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:()=>B(!1),"aria-label":s("common.close"),children:e.jsx(xe,{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:()=>mn(n),children:[h.source===n&&e.jsx(je,{size:12}),s(`home.wallpaper.${n}`)]},n))}),Ee&&e.jsx("div",{className:"hp-wallpaper-error",children:Ee}),h.source==="theme"&&e.jsxs("div",{className:"hp-theme-presets",children:[e.jsx("p",{children:s("home.wallpaper.themeHint")}),e.jsx("div",{children:_s.map(n=>e.jsxs("button",{type:"button",className:h.themePreset===n?"on":"","data-preset":n,"aria-pressed":h.themePreset===n,onClick:()=>A({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(je,{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;A({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:Me,onClick:()=>un(n=>n+1),children:[e.jsx(_n,{size:13})," ",s("home.wallpaper.refresh")]})]}),Me&&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:()=>A({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(je,{size:12})})]},n.id))})]}),h.source==="custom"&&e.jsxs("div",{className:"hp-wallpaper-custom",children:[e.jsx("div",{className:"hp-wallpaper-custom-preview",style:R?{backgroundImage:`url(${JSON.stringify(R)})`}: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:()=>le.current?.click(),children:[e.jsx(js,{size:13})," ",s("home.wallpaper.replace")]}),e.jsx("button",{type:"button",onClick:fn,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:()=>A({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:()=>A({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})]})]})]})}),T&&e.jsx("div",{className:"hp-organizer-stage",onClick:()=>k(!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(Ye,{size:16})}),e.jsxs("span",{children:[e.jsx("strong",{children:s("home.organizer.title")}),e.jsx("small",{children:s("home.spaceCount",{n:Cn})})]})]}),e.jsx("button",{type:"button",onClick:()=>k(!1),"aria-label":s("common.close"),children:e.jsx(xe,{size:16})})]}),e.jsxs(me,{sensors:ce,collisionDetection:Xe,onDragStart:Ie,onDragOver:We,onDragCancel:ze,onDragEnd:Te,children:[e.jsx(ge,{items:m.map(n=>n.id),strategy:fe,children:e.jsxs("div",{className:"hp-organizer-grid",children:[m.map(n=>e.jsx(Qe,{tile:n,over:w===n.id,open:!1,onOpen:Re,onLaunch:r=>{k(!1),U(r)},onMenu:(r,p)=>pe(r,"folder",p)},n.id)),e.jsxs("button",{type:"button",className:"hp-organizer-new",onClick:bn,children:[e.jsx("span",{children:e.jsx(ws,{size:22})}),e.jsx("small",{children:s("home.newFolder")})]})]})}),e.jsx(Ve,{dropAnimation:null,children:_&&e.jsx("div",{className:`hp-tile hp-drag-overlay${_.kind==="folder"?" hp-folder":""}`,children:e.jsx($,{tile:_})})})]}),e.jsx("footer",{children:s("home.organizer.hint")})]})}),W&&C?.kind==="folder"&&e.jsx("div",{className:"hp-folder-stage",onClick:()=>M(null),children:e.jsxs("section",{className:"hp-folder-panel",style:{"--hp-folder-dx":`${W.dx}px`,"--hp-folder-dy":`${W.dy}px`},"aria-label":C.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($,{tile:C})}),e.jsxs("span",{children:[e.jsx("strong",{children:C.folder.name}),e.jsx("small",{children:s("home.folderCount",{n:Q.length})})]})]}),e.jsx("button",{type:"button",onClick:()=>M(null),"aria-label":s("common.close"),children:e.jsx(xe,{size:16})})]}),Q.length===0&&e.jsx("div",{className:"hp-folder-empty",children:s("home.folderEmpty")}),Q.length>0&&e.jsx(me,{sensors:ce,collisionDetection:sn,onDragEnd:Sn,children:e.jsx(ge,{items:C.folder.items,strategy:fe,children:e.jsx("div",{className:"hp-folder-grid",children:Q.map(n=>e.jsx(Vs,{member:n,onLaunch:r=>{M(null),U(r)},onMenu:(r,p)=>pe(r,"member",p)},n.id))})})}),e.jsx("footer",{children:s("home.folderHint")})]})}),E&&En&&e.jsx(Fn,{className:"ctx-menu",x:E.x,y:E.y,onClick:n=>n.stopPropagation(),children:e.jsx(us,{items:Be(E)})})]})}export{wt as HomepageView};
1
+ import{u as en,d as g,j as e,r as Dn}from"./index-BYUntVIZ.js";import{G as nn,l as An,a6 as ve,m as ne,fO as On,kx as Ue,ky as In,kz as Wn,kA as zn,Z as Tn,cQ as Rn,bI as Ln,fS as me,kB as ge,kC as fe,kD as Ve,aF as xe,aK as je,aP as _n,kE as sn,ai as Fn,aj as $n,b as Bn,u as F,aT as tn,hA as Hn,kF as Un,kG as Vn,kH as qn,ia as Gn,kI as Kn,ib as Jn,kJ as Yn,bq as Zn,ap as O,kK as Xn,kL as Qn,kM as on,kN as Ce,a5 as es,fV as qe,am as Ge,e2 as ns,dY as ss,ab as we,q as Ke,fC as ts,cW as os,fq as as,kO as rs,an as Je,al as is,kP as ls,a$ as cs,af as ds}from"./appStore-affnJoin.js";import"./client-BqhpYbYL.js";import{a as ps,d as us}from"./phoneList-DHUia6HT.js";import{a5 as hs,a6 as ms,a7 as gs,C as fs,H as xs}from"./RunLocationPicker-CadYiE7C.js";import{U as js}from"./upload-D20PZHXc.js";import{F as ws}from"./folder-plus-BJKT1Pqg.js";import{L as bs}from"./log-out-B5gEP0tF.js";import{P as vs}from"./pencil-DGiTRzW1.js";import"./nativeDownload-Udrv_tmU.js";import"./ipc-D7yENkjV.js";import"./codeStudioStore-Dq5i8nbE.js";import"./RightPanel-BRexwQ3W.js";import"./book-open-CcXCToyx.js";import"./folder-CCZqnwRc.js";import"./ModelPill-ChzAM3z1.js";import"./create-BgJN5qsj.js";import"./approvalText-Cy2UAUAQ.js";import"./message-square-plus-DxBPIhPS.js";import"./hand-DRu7IJdU.js";import"./pageChrome-D-9npbUE.js";import"./emoji-BPdA62d7.js";const Cs=[["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=nn("folder-minus",Cs);const ks=[["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"}]],Ye=nn("grid-2x2",ks),an="forsion.homepage.wallpaper.v1",ys=32*1024*1024,rn={source:"theme",themePreset:"rings",bingDaily:!0,focusBlur:!0,vignette:!0,bing:null},z=t=>typeof t=="string"?t:"";function Ze(t){const s=z(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 Se(t){if(!t||typeof t!="object")return null;const s=t,i=Ze(s.url);if(!i)return null;const d=Ze(s.thumbnailUrl)||i,l=z(s.startDate);return{id:z(s.id)||l||i,url:i,thumbnailUrl:d,title:z(s.title),copyright:z(s.copyright),startDate:l}}function Ns(t){if(!t||typeof t!="object")return{...rn};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:Se(s.bing)}}function Ms(){try{return Ns(JSON.parse(localStorage.getItem(an)||"null"))}catch{return{...rn}}}function Ps(t){try{localStorage.setItem(an,JSON.stringify(t))}catch{}}function Es(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,l=z(d.urlbase),o=z(d.url),c=l?`https://www.bing.com${l}_UHD.jpg`:o.startsWith("/")?`https://www.bing.com${o}`:o,x=l?`https://www.bing.com${l}_400x240.jpg`:c,u=Se({id:z(d.startdate)||l||c,url:c,thumbnailUrl:x,title:d.title,copyright:d.copyright,startDate:d.startdate});return u?[u]:[]})}async function Ds(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(Se).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 Es(await s.json())}const As="forsion-homepage",se="wallpaper",ke="custom";function Os(){return new Promise((t,s)=>{const i=indexedDB.open(As,1);i.onupgradeneeded=()=>{i.result.objectStoreNames.contains(se)||i.result.createObjectStore(se)},i.onsuccess=()=>t(i.result),i.onerror=()=>s(i.error||new Error("IndexedDB unavailable"))})}async function ye(t,s){const i=await Os();try{return await new Promise((d,l)=>{const o=i.transaction(se,t),c=s(o.objectStore(se));let x;c.onsuccess=()=>{x=c.result},c.onerror=()=>l(c.error||o.error||new Error("Wallpaper storage failed")),o.oncomplete=()=>d(x),o.onerror=()=>l(o.error||new Error("Wallpaper storage failed")),o.onabort=()=>l(o.error||new Error("Wallpaper storage aborted"))})}finally{i.close()}}async function Is(){const t=await ye("readonly",s=>s.get(ke));return t instanceof Blob&&t.type.startsWith("image/")?t:null}async function Ws(t){if(!t.type.startsWith("image/"))throw new Error("NOT_IMAGE");if(t.size>ys)throw new Error("TOO_LARGE");await ye("readwrite",s=>s.put(t,ke))}async function zs(){await ye("readwrite",t=>t.delete(ke))}const te="home",Ts=140,Rs=6,ln="forsion.homepage.pinned-spaces.v1",be="homepage:pinned-spaces",V="homepage:pinned:",Ls=["rb-market","rb-achievements"],_s=["rings","topography","weave","hack2gate"],Xe=t=>{const s=Xn(t);return s.length?s:sn(t)};function Fs({onDispatch:t,onStartCall:s,onInputModeChange:i}){const d=Bn(a=>a.vaultRoot),l=ve(a=>a.activeSpaceId),o=F(tn(a=>({cfg:a.cfg,desktopConfig:a.desktopConfig,desktopMode:a.desktopMode,homeDir:a.homeDir,defaultWsDir:a.defaultWsDir,modelsResp:a.modelsResp,newChatWs:a.newChatWs,newChatCfg:a.newChatCfg,newChatModel:a.newChatModel,sessionMode:a.sessionMode,setSessionMode:a.setSessionMode,engines:a.engines,engineCaps:a.engineCaps,agentDefs:a.agentDefs,defaultAgentSlug:a.defaultAgentSlug,skillsList:a.skillsList,connState:a.connState,voiceOnByAgent:a.voiceOnByAgent,ensureEngineCaps:a.ensureEngineCaps,refreshVoiceMode:a.refreshVoiceMode,setSessionModel:a.setSessionModel,setNewChatCfg:a.setNewChatCfg,setSessionThinking:a.setSessionThinking,setDefaultModel:a.setDefaultModel,setModelContextWindow:a.setModelContextWindow,setVoiceMode:a.setVoiceMode,setExecConfig:a.setExecConfig,openSettings:a.openSettings,setNewChatWs:a.setNewChatWs,addLocalWorkspace:a.addLocalWorkspace,addCloudProject:a.addCloudProject,workspaces:a.workspaces,sessions:a.sessions,archivedSessions:a.archivedSessions,cloudProjects:a.cloudProjects,channelWorkspaces:a.channelWorkspaces,tr:a.tr})));Hn();const c=Un(o),x=g.useMemo(()=>o.workspaces(),[o.workspaces,o.sessions,o.archivedSessions,o.cloudProjects,o.channelWorkspaces,o.defaultWsDir,o.homeDir,o.tr,d]),u=Vn(o.sessionMode,c),m=u==="chat"||c.kind==="cloud"||c.kind==="rootless",f=g.useMemo(()=>qn(Gn(Kn({execMode:m?"sandbox":"host",...Jn(o.desktopConfig,!m,u),cwd:m?void 0:c.path||void 0,...o.newChatCfg},u),d)),[m,u,o.desktopConfig,o.newChatCfg,c.path,d]),S=Yn(o)||"",I=o.modelsResp?.models?o.modelsResp.models.filter(a=>(a.modelType||"llm")==="llm"&&(!m||a.source==="forsion")):null,v=f.agentSlug||o.defaultAgentSlug,N=v?!!o.voiceOnByAgent[v]:!1;return g.useEffect(()=>{o.ensureEngineCaps(f.engineId||void 0)},[f.engineId,o.ensureEngineCaps]),g.useEffect(()=>{v&&o.refreshVoiceMode(v)},[v,o.refreshVoiceMode]),e.jsxs("div",{className:"hp-composer",onClick:a=>a.stopPropagation(),onPointerDownCapture:()=>i(!0),onPointerDown:a=>a.stopPropagation(),onFocusCapture:()=>i(!0),onBlurCapture:a=>{a.relatedTarget instanceof Node&&!a.currentTarget.contains(a.relatedTarget)&&i(!1)},onKeyDownCapture:a=>{a.key==="Escape"&&a.target.matches?.(".t2c-ta")&&(a.target.blur(),i(!1))},children:[e.jsx("div",{className:"newchat-pickers",children:e.jsx(hs,{sessionId:null,cfg:f})}),e.jsxs("div",{className:"hp-projectbar",children:[e.jsx(ms,{}),e.jsx(gs,{workspaces:x,value:c.key,onChange:o.setNewChatWs,onAddProject:window.tangu?.pickDirectory?()=>{o.addLocalWorkspace()}:void 0,onAddCloudProject:a=>{o.addCloudProject(a)}})]}),e.jsx(fs,{sessionId:null,liveOwner:l==="home",prepareLiveSession:s,autoFocus:!1,disabled:o.connState!=="ok",running:!1,execConfig:f,models:I,modelsResponse:o.modelsResp,modelId:S,onModelChange:a=>o.setSessionModel(a,null),engines:o.engines,engineId:f.engineId,engineModels:f.engineId?o.engineCaps[f.engineId]?.models??[]:void 0,engineModelId:f.engineModelId,onEngineModelChange:a=>o.setNewChatCfg(w=>({...w,engineModelId:a||void 0})),engineCommands:f.engineId?o.engineCaps[f.engineId]?.commands??[]:void 0,thinkingLevel:f.thinkingLevel,ultra:f.ultra,onThinkingChange:(a,w)=>o.setSessionThinking(a,null,void 0,w),defaultModelIds:{backgroundModelId:o.desktopConfig?.backgroundModelId||"",imageModelId:o.cfg.imageModelId||"",visionModelId:o.cfg.visionModelId||""},onDefaultModelChange:o.setDefaultModel,onContextWindowChange:(a,w)=>{o.setModelContextWindow(a,w)},maxIterations:f.maxIterations,onMaxIterationsChange:a=>o.setNewChatCfg(w=>({...w,maxIterations:a})),verifyCommand:f.verifyCommand,onVerifyCommandChange:a=>o.setNewChatCfg(w=>({...w,verifyCommand:a||void 0})),planMode:f.planMode,onPlanModeChange:a=>o.setNewChatCfg(w=>({...w,planMode:a})),preset:f.preset,onPresetChange:a=>o.setSessionMode(a),voiceMode:N,onVoiceModeChange:v?a=>{o.setVoiceMode(v,a)}:void 0,groupChat:f.groupChat,groupAgents:f.groupAgents,groupTempAgents:f.groupTempAgents,onGroupChange:a=>o.setNewChatCfg(w=>({...w,...a})),skills:o.skillsList,agents:o.agentDefs,currentAgentSlug:v,onOpenSettings:()=>o.openSettings("skills"),onExecConfigChange:a=>o.setExecConfig(a,null),onSend:(a,w,q,T,k)=>t(a,w,q,T,k),onStop:()=>{},autoRefFromMain:!1})]})}function $({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:O(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(es,{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 $s(){try{const t=JSON.parse(localStorage.getItem(ln)||"[]");return Array.isArray(t)?[...new Set(t.filter(s=>typeof s=="string"&&s!==te))]:[]}catch{return[]}}function Bs({item:t}){const s=t.icon,i=t.tooltip?O(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 Hs({space:t,onLaunch:s}){const i=`${V}${t.id}`,{attributes:d,listeners:l,setNodeRef:o,transform:c,isDragging:x}=ls({id:i}),u={kind:"space",id:`space:${t.id}`,space:t};return e.jsx("button",{ref:o,type:"button",className:`hp-tile hp-pinned-space${x?" dragging":""}`,"data-space-id":t.id,style:{transform:Ce.Transform.toString(c)},"aria-label":O(t.name),title:O(t.name),...d,...l,onClick:()=>{x||s(t.id)},children:e.jsx($,{tile:u})})}function Us({actions:t,spaces:s,onLaunch:i,labelText:d}){const{isOver:l,setNodeRef:o}=Qn({id:be});return e.jsxs("div",{ref:o,className:"hp-pinned-zone","data-over":l||void 0,"aria-label":d,children:[t.map(c=>e.jsx(Bs,{item:c},c.id)),s.map(c=>e.jsx(Hs,{space:c,onLaunch:i},c.id))]})}function Qe({tile:t,over:s,open:i,onOpen:d,onLaunch:l,onMenu:o}){const{attributes:c,listeners:x,setNodeRef:u,transform:m,transition:f,isDragging:S}=on({id:t.id}),I=t.kind==="space"?O(t.space.name):t.folder.name,v={transform:Ce.Transform.toString(m),transition:f?`${f}, color var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out)`:void 0};return e.jsx("button",{ref:u,type:"button",style:v,className:`hp-tile${t.kind==="folder"?" hp-folder":""}${S?" dragging":""}${i?" on":""}`,"data-id":t.id,"data-over":s||void 0,"aria-label":I,title:I,...c,...x,onClick:N=>{S||(t.kind==="folder"?(N.stopPropagation(),d(N,t.id)):l(t.space.id))},onContextMenu:t.kind==="folder"?N=>o(N,t.id):void 0,children:e.jsx($,{tile:t})})}function Vs({member:t,onLaunch:s,onMenu:i}){const d=`space:${t.id}`,{attributes:l,listeners:o,setNodeRef:c,transform:x,transition:u,isDragging:m}=on({id:d});return e.jsxs("button",{ref:c,type:"button",className:`hp-folder-app${m?" dragging":""}`,style:{transform:Ce.Transform.toString(x),transition:u},"data-id":d,title:O(t.name),...l,...o,onClick:()=>{m||s(t.id)},onContextMenu:f=>i(f,d),children:[e.jsx("span",{className:"hp-folder-app-icon",children:t.icon&&e.jsx(t.icon,{size:24})}),e.jsx("span",{children:O(t.name)})]})}function qs(t){const s=()=>{const l=new Date;return{time:ss(l),date:ns(l,{locale:t}),hour:l.getHours()}},[i,d]=g.useState(s);return g.useEffect(()=>{const l=()=>d(c=>{const x=s();return x.time===c.time&&x.date===c.date?c:x});l();const o=setInterval(l,1e3);return()=>clearInterval(o)},[t]),i}function Gs(){const[t,s]=g.useState("");return g.useEffect(()=>{let i=!0;const d=()=>{window.tangu?.authStatus?.().then(o=>{i&&s(o?.loggedIn&&(o.nickname||o.username)||"")}).catch(()=>{})};d();const l=window.tangu?.onAuthChanged?.(d);return()=>{i=!1,l?.()}},[]),t}function Ks(){const t=ve(u=>u.spaces),s=ne(u=>u.order),d=ne(u=>u.folders).filter(u=>u.zone==="top"),l=u=>t.find(m=>`space:${m.id}`===u),o=new Set(d.flatMap(u=>u.items)),c=$n([...t.map(u=>`space:${u.id}`),...d.map(u=>u.id)],s).filter(u=>!o.has(u)),x=[];for(const u of c){if(u===`space:${te}`)continue;const m=d.find(S=>S.id===u);if(m){x.push({kind:"folder",id:u,folder:m,members:m.items.map(l).filter(S=>!!S)});continue}const f=l(u);f&&x.push({kind:"space",id:u,space:f})}return{tiles:x,topIds:c,order:s}}Dn({"home.folderMenu.renameTitle":{zh:"重命名收纳夹",en:"Rename folder"},"home.folderMenu.rename":{zh:"重命名",en:"Rename"},"home.folderMenu.dissolve":{zh:"解散收纳夹",en:"Dissolve folder"},"home.folderMenu.moveOut":{zh:"移出收纳夹",en:"Move out"},"home.pill":{zh:"问点什么…",en:"Ask anything…"},"home.card.continue":{zh:"继续:{title}",en:"Continue: {title}"},"home.card.claimable":{zh:"{n} 项可领取",en:"{n} to claim"},"home.card.earned":{zh:"已得 {n} 项",en:"{n} earned"},"home.card.installed":{zh:"已装 {n} 个插件",en:"{n} plugins installed"}});function Js({tiles:t,actions:s,onLaunch:i}){const d=Ys();return e.jsxs("section",{className:"hp-cards",children:[t.filter(l=>l.kind==="space").slice(0,2).map(l=>e.jsxs("button",{type:"button",className:"hp-card","data-space-id":l.space.id,onClick:o=>{o.stopPropagation(),i(l.space.id)},children:[e.jsx("span",{className:"hp-card-icon",children:l.space.icon&&e.jsx(l.space.icon,{})}),e.jsx("span",{className:"hp-card-name",children:O(l.space.name)}),e.jsx("span",{className:"hp-card-status",children:d(l.space.id)})]},l.id)),s.map(l=>e.jsxs("button",{type:"button",className:"hp-card","data-fixed-id":l.id,onClick:o=>{o.stopPropagation(),l.onClick?.()},children:[e.jsx("span",{className:"hp-card-icon",children:l.icon&&e.jsx(l.icon,{})}),e.jsx("span",{className:"hp-card-name",children:l.tooltip?O(l.tooltip):""}),e.jsx("span",{className:"hp-card-status",children:d(l.id)})]},l.id))]})}function Ys(){const{t}=en(),s=F(o=>o.sessions[0]),i=ts(o=>o.recents[0]),d=os(o=>o.plugins.filter(c=>!c.builtin&&!c.preinstalled).length),l=as(tn(o=>({counters:o.counters,claimed:o.claimed,pluginSeries:o.pluginSeries})));return o=>{if(o==="tangu")return s?t("home.card.continue",{title:xs(s.title,t)}):"";if(o==="amadeus")return i?(i.split("/").pop()??i).replace(/\.md$/i,""):"";if(o==="rb-market")return d?t("home.card.installed",{n:String(d)}):"";if(o==="rb-achievements"){const c=rs(l).flatMap(m=>m.achievements),x=c.filter(m=>!l.claimed[m.id]&&(l.counters[m.event]||0)>=m.goal).length,u=c.filter(m=>l.claimed[m.id]).length;return x?t("home.card.claimable",{n:String(x)}):u?t("home.card.earned",{n:String(u)}):""}return""}}function wt(t){const{t:s,locale:i}=en(),d=i==="zh",l=qs(i),o=Gs(),c=An(),x=ve(n=>n.spaces),u=ne(n=>n.items),{tiles:m,topIds:f,order:S}=Ks(),[I,v]=g.useState($s),[N,a]=g.useState(null),[w,q]=g.useState(null),[T,k]=g.useState(!1),[W,M]=g.useState(null),[E,y]=g.useState(null),[cn,Ne]=g.useState(!1),[oe,ae]=g.useState(!1),[G,B]=g.useState(!1),[h,re]=g.useState(Ms),[R,ie]=g.useState(null),[H,dn]=g.useState([]),[Me,Pe]=g.useState(!1),[Ee,K]=g.useState(""),[pn,un]=g.useState(0),J=g.useRef(null),le=g.useRef(null),L=g.useRef(null),Y=g.useRef(null),[De]=g.useState(()=>{try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}),ce=On(Ue(zn,{activationConstraint:{distance:6}}),Ue(Wn,{coordinateGetter:In}));g.useEffect(()=>{Ps(h)},[h]),g.useEffect(()=>{try{localStorage.setItem(ln,JSON.stringify(I))}catch{}},[I]),g.useEffect(()=>{let n=!0;return Is().then(r=>{if(n){if(!r){re(p=>p.source==="custom"?{...p,source:"theme"}:p);return}ie(URL.createObjectURL(r))}}).catch(()=>{}),()=>{n=!1}},[]),g.useEffect(()=>()=>{R&&URL.revokeObjectURL(R)},[R]),g.useEffect(()=>{if(h.source!=="bing")return;let n=!0;return Pe(!0),K(""),Ds(i).then(r=>{n&&(dn(r),r[0]&&re(p=>p.source==="bing"&&p.bingDaily&&p.bing?.id!==r[0].id?{...p,bing:r[0]}:p))}).catch(()=>{n&&K(s("home.wallpaper.bingError"))}).finally(()=>{n&&Pe(!1)}),()=>{n=!1}},[pn,i,s,h.source]),g.useEffect(()=>()=>{L.current&&(window.clearTimeout(L.current),L.current=null);const n=Y.current;Y.current=null,n?.()},[]);const de=n=>L.current?!1:De?(n(),!0):(Ne(!0),Y.current=n,L.current=window.setTimeout(()=>{L.current=null,Y.current=null,n(),Ne(!1)},Ts),!0),U=n=>{const r=cs?ds()?.openSpace:void 0;r?r(n):de(()=>we(n))},Z=x.some(n=>n.id==="tangu"),Ae=l.hour<5?"home.greet.night":l.hour<11?"home.greet.morning":l.hour<18?"home.greet.afternoon":"home.greet.evening",D=()=>ne.getState(),hn=()=>{M(null),k(!1),y(null)},X=h.source==="bing"?h.bing?.url||null:h.source==="custom"?R:null,A=n=>{re(r=>({...r,...n}))},mn=n=>{if(n==="custom"&&!R){le.current?.click();return}if(n==="bing"){A({source:n,bing:h.bing||H[0]||null});return}A({source:n})},gn=n=>{n&&(K(""),Ws(n).then(()=>{ie(URL.createObjectURL(n)),A({source:"custom"})}).catch(r=>{K(s(r instanceof Error&&r.message==="TOO_LARGE"?"home.wallpaper.tooLarge":"home.wallpaper.invalid"))}))},fn=()=>{zs().catch(()=>{}),ie(null),A({source:"theme"})},xn=(n,r)=>{if(!n||n===r)return;const p=is(S,f),j=p.indexOf(r);D().setZoneOrder("top",Ge(p,n,j>=0?j:p.length))},jn=(n,r)=>{!n||n===r||n.startsWith("folder:")||(D().moveIntoFolder(r,n),D().setZoneOrder("top",Je(S,f,n)))},wn=n=>{D().moveOutOfFolder(n),D().setZoneOrder("top",[...Je(S,f,n),n]),k(!0)},bn=()=>{y(null),qe(d?"新建收纳夹":"New folder",d?"收纳夹":"Folder").then(n=>{const r=n?.trim();r&&(D().addFolder("top",r),k(!0))})},Oe=()=>{a(null),q(null)},Ie=n=>{M(null),y(null),a(String(n.active.id))},We=n=>q(n.over?String(n.over.id):null),ze=n=>Oe(),Te=n=>{const r=String(n.active.id),p=n.over?String(n.over.id):null;if(Oe(),r.startsWith(V)){if(p!==be){const b=r.slice(V.length);v(P=>P.filter(He=>He!==b))}return}if(p===be){const b=m.find(P=>P.id===r);b?.kind==="space"&&b.space.id!==te&&v(P=>P.includes(b.space.id)?P:[...P,b.space.id]);return}if(!p||r===p)return;const j=m.find(b=>b.id===p);!r.startsWith("folder:")&&j?.kind==="folder"?jn(r,p):xn(r,p)},pe=(n,r,p)=>{n.preventDefault(),n.stopPropagation(),M(null),y({x:n.clientX,y:n.clientY,kind:r,id:p})},Re=(n,r)=>{const p=n.currentTarget.getBoundingClientRect(),j=J.current?.getBoundingClientRect();y(null),k(!1),M(b=>b?.id===r?null:{id:r,dx:j?p.left+p.width/2-(j.left+j.width/2):0,dy:j?p.top+p.height/2-(j.top+j.height/2):0})},C=W?m.find(n=>n.id===W.id):void 0,Q=C?.kind==="folder"?C.members:[],ee=m.slice(0,Rs),Le=Math.max(0,m.length-ee.length),_=N?m.find(n=>n.id===N):void 0,ue=N?.startsWith(V)?x.find(n=>n.id===N.slice(V.length)):void 0,vn=I.map(n=>x.find(r=>r.id===n)).filter(n=>!!n),_e=Ls.map(n=>u.find(r=>r.id===n)).filter(n=>!!n),Cn=Math.max(0,x.length-(x.some(n=>n.id===te)?1:0)),Sn=n=>{if(!C||C.kind!=="folder"||!n.over)return;const r=String(n.active.id),p=String(n.over.id);if(r===p)return;const j=C.folder.items.indexOf(p);D().setFolderItems(C.id,Ge(C.folder.items,r,j<0?C.folder.items.length:j))},kn=(n,r,p,j,b)=>Z?new Promise(P=>{de(()=>{we("tangu"),Ke.getState().openView("chat",{followActive:!0,reuseKey:"primary"},"main"),P(F.getState().send(n,r,p,j,b,null))})||P(!1)}):Promise.resolve(!1),yn=()=>Z?new Promise(n=>{de(()=>{we("tangu"),Ke.getState().openView("chat",{followActive:!0,reuseKey:"primary"},"main");const p=F.getState().activeId;F.getState().newSession().then(()=>{const j=F.getState().activeId;n(j&&j!==p?j:null)},()=>n(null))})||n(null)}):Promise.resolve(null),he=()=>{const n=document.activeElement;n instanceof HTMLTextAreaElement&&n.matches(".hp-composer .t2c-ta")&&n.blur(),ae(!1)},Nn=(n=!1)=>{Zn.flushSync(()=>ae(!0));const r=J.current?.querySelector(".hp-composer");n?r?.querySelector(".t2c-mic-control")?.click():r?.querySelector(".t2c-ta")?.focus()},[Fe,Mn]=g.useState("");g.useEffect(()=>{c&&!oe&&Mn(J.current?.querySelector(".hp-composer .t2c-ta")?.value.trim()??"")},[c,oe]);const $e=()=>{he(),B(!1),M(null),y(null),k(!0)},Pn=n=>{n.target.closest('button, input, textarea, [contenteditable="true"], .hp-composer, .ctx-menu, .hp-wallpaper-sheet')||(n.preventDefault(),n.stopPropagation(),y(null),W?M(null):T?k(!1):G?B(!1):$e())},Be=n=>n.kind==="member"?[{id:"move-out",label:s("home.folderMenu.moveOut"),icon:e.jsx(bs,{size:13}),run:()=>{wn(n.id),y(null),M(null)}}]:[{id:"rename",label:s("home.folderMenu.rename"),icon:e.jsx(vs,{size:13}),run:()=>{const r=n.id,p=m.find(j=>j.id===r);y(null),qe(s("home.folderMenu.renameTitle"),p?.kind==="folder"?p.folder.name:"").then(j=>{const b=j?.trim();b&&D().renameFolder(r,b)})}},{id:"dissolve",label:s("home.folderMenu.dissolve"),icon:e.jsx(Ss,{size:13}),run:()=>{D().removeFolder(n.id),y(null)}}],En=ps(E,()=>{if(!E)return null;const n=E.kind==="folder"?m.find(r=>r.id===E.id):void 0;return{...n?.kind==="folder"?{title:n.folder.name}:{},sections:[{items:Be(E)}]}},()=>y(null));return e.jsxs("div",{ref:J,className:`hp-root${c?" hp-phone":""}${De?" hp-still":""}${oe?" hp-composer-focused":""}${G?" hp-layer-focused":""}${W||T?" hp-secondary-open":""}`,"data-wallpaper":X||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")||he()},onContextMenu:Pn,onClick:hn,children:[e.jsx("div",{className:"hp-wallpaper",style:X?{backgroundImage:`url(${JSON.stringify(X)})`}: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${G?" on":""}`,"aria-label":s("home.wallpaper.open"),title:s("home.wallpaper.open"),onClick:n=>{n.stopPropagation(),he(),y(null),M(null),k(!1),B(r=>!r)},children:e.jsx(Tn,{size:16})}),e.jsxs("div",{className:`hp-stack${cn?" 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:l.time}),e.jsx("div",{className:"hp-date",children:l.date}),e.jsx("div",{className:"hp-greet",children:o?s(Ae+".named",{name:o}):s(Ae)})]}),Z&&e.jsx(Fs,{onDispatch:kn,onStartCall:yn,onInputModeChange:ae}),c&&Z&&e.jsxs("button",{type:"button",className:"hp-pill","data-act":"home-pill",onClick:n=>{n.stopPropagation(),Nn(!!n.target.closest(".hp-pill-mic"))},children:[e.jsx("span",{className:"hp-pill-text","data-draft":Fe?"":void 0,children:Fe||s("home.pill")}),e.jsx("span",{className:"hp-pill-mic","aria-hidden":!0,children:e.jsx(Rn,{})}),e.jsx("span",{className:"hp-pill-send","aria-hidden":!0,children:e.jsx(Ln,{})})]}),c&&e.jsx(Js,{tiles:m,actions:_e,onLaunch:U}),!c&&e.jsx("section",{className:"hp-spaces","data-total":m.length,children:e.jsxs(me,{sensors:ce,collisionDetection:Xe,onDragStart:Ie,onDragOver:We,onDragCancel:ze,onDragEnd:Te,children:[e.jsxs("div",{className:"hp-space-row",children:[e.jsx(Us,{actions:_e,spaces:vn,labelText:s("home.pinnedSpaces"),onLaunch:U}),e.jsx("span",{className:"hp-space-divider","aria-hidden":!0}),e.jsx("div",{className:"hp-space-main",children:ee.length>0?e.jsx(ge,{items:ee.map(n=>n.id),strategy:fe,children:e.jsxs("div",{className:"hp-dock",children:[ee.map(n=>e.jsx(Qe,{tile:n,over:w===n.id,open:W?.id===n.id,onOpen:Re,onLaunch:U,onMenu:(r,p)=>pe(r,"folder",p)},n.id)),Le>0&&e.jsxs("button",{type:"button",className:"hp-tile hp-more",onClick:n=>{n.stopPropagation(),$e()},title:s("home.showAll"),children:[e.jsx("span",{className:"hp-tile-icon",children:e.jsx(Ye,{size:20})}),e.jsx("span",{className:"hp-tile-name",children:s("home.showAll")}),e.jsxs("span",{className:"hp-more-count",children:["+",Le]})]})]})}):e.jsx("div",{className:"hp-spaces-empty",children:s("home.noSpaces")})})]}),e.jsxs(Ve,{dropAnimation:null,children:[_&&!T&&e.jsx("div",{className:`hp-tile hp-drag-overlay${_.kind==="folder"?" hp-folder":""}`,children:e.jsx($,{tile:_})}),ue&&!T&&e.jsx("div",{className:"hp-tile hp-drag-overlay hp-pinned-space",children:e.jsx($,{tile:{kind:"space",id:`space:${ue.id}`,space:ue}})})]})]})})]}),e.jsx("input",{ref:le,className:"hp-wallpaper-file",type:"file",accept:"image/*",onChange:n=>{gn(n.currentTarget.files?.[0]),n.currentTarget.value=""}}),X&&h.source==="bing"&&h.bing?.copyright&&e.jsx("div",{className:"hp-wallpaper-credit",title:h.bing.copyright,children:h.bing.copyright}),G&&e.jsx("div",{className:"hp-wallpaper-stage",onClick:()=>B(!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:()=>B(!1),"aria-label":s("common.close"),children:e.jsx(xe,{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:()=>mn(n),children:[h.source===n&&e.jsx(je,{size:12}),s(`home.wallpaper.${n}`)]},n))}),Ee&&e.jsx("div",{className:"hp-wallpaper-error",children:Ee}),h.source==="theme"&&e.jsxs("div",{className:"hp-theme-presets",children:[e.jsx("p",{children:s("home.wallpaper.themeHint")}),e.jsx("div",{children:_s.map(n=>e.jsxs("button",{type:"button",className:h.themePreset===n?"on":"","data-preset":n,"aria-pressed":h.themePreset===n,onClick:()=>A({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(je,{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;A({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:Me,onClick:()=>un(n=>n+1),children:[e.jsx(_n,{size:13})," ",s("home.wallpaper.refresh")]})]}),Me&&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:()=>A({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(je,{size:12})})]},n.id))})]}),h.source==="custom"&&e.jsxs("div",{className:"hp-wallpaper-custom",children:[e.jsx("div",{className:"hp-wallpaper-custom-preview",style:R?{backgroundImage:`url(${JSON.stringify(R)})`}: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:()=>le.current?.click(),children:[e.jsx(js,{size:13})," ",s("home.wallpaper.replace")]}),e.jsx("button",{type:"button",onClick:fn,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:()=>A({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:()=>A({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})]})]})]})}),T&&e.jsx("div",{className:"hp-organizer-stage",onClick:()=>k(!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(Ye,{size:16})}),e.jsxs("span",{children:[e.jsx("strong",{children:s("home.organizer.title")}),e.jsx("small",{children:s("home.spaceCount",{n:Cn})})]})]}),e.jsx("button",{type:"button",onClick:()=>k(!1),"aria-label":s("common.close"),children:e.jsx(xe,{size:16})})]}),e.jsxs(me,{sensors:ce,collisionDetection:Xe,onDragStart:Ie,onDragOver:We,onDragCancel:ze,onDragEnd:Te,children:[e.jsx(ge,{items:m.map(n=>n.id),strategy:fe,children:e.jsxs("div",{className:"hp-organizer-grid",children:[m.map(n=>e.jsx(Qe,{tile:n,over:w===n.id,open:!1,onOpen:Re,onLaunch:r=>{k(!1),U(r)},onMenu:(r,p)=>pe(r,"folder",p)},n.id)),e.jsxs("button",{type:"button",className:"hp-organizer-new",onClick:bn,children:[e.jsx("span",{children:e.jsx(ws,{size:22})}),e.jsx("small",{children:s("home.newFolder")})]})]})}),e.jsx(Ve,{dropAnimation:null,children:_&&e.jsx("div",{className:`hp-tile hp-drag-overlay${_.kind==="folder"?" hp-folder":""}`,children:e.jsx($,{tile:_})})})]}),e.jsx("footer",{children:s("home.organizer.hint")})]})}),W&&C?.kind==="folder"&&e.jsx("div",{className:"hp-folder-stage",onClick:()=>M(null),children:e.jsxs("section",{className:"hp-folder-panel",style:{"--hp-folder-dx":`${W.dx}px`,"--hp-folder-dy":`${W.dy}px`},"aria-label":C.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($,{tile:C})}),e.jsxs("span",{children:[e.jsx("strong",{children:C.folder.name}),e.jsx("small",{children:s("home.folderCount",{n:Q.length})})]})]}),e.jsx("button",{type:"button",onClick:()=>M(null),"aria-label":s("common.close"),children:e.jsx(xe,{size:16})})]}),Q.length===0&&e.jsx("div",{className:"hp-folder-empty",children:s("home.folderEmpty")}),Q.length>0&&e.jsx(me,{sensors:ce,collisionDetection:sn,onDragEnd:Sn,children:e.jsx(ge,{items:C.folder.items,strategy:fe,children:e.jsx("div",{className:"hp-folder-grid",children:Q.map(n=>e.jsx(Vs,{member:n,onLaunch:r=>{M(null),U(r)},onMenu:(r,p)=>pe(r,"member",p)},n.id))})})}),e.jsx("footer",{children:s("home.folderHint")})]})}),E&&En&&e.jsx(Fn,{className:"ctx-menu",x:E.x,y:E.y,onClick:n=>n.stopPropagation(),children:e.jsx(us,{items:Be(E)})})]})}export{wt as HomepageView};
@@ -1,3 +1,3 @@
1
- import{u as M,d as j,j as e,t as E}from"./index-B5UW6SaE.js";import{G as P,u as $,N as q,kU as Y,ct as K,kR as R,V as B,aN as W,ar as L,hx as Q,bI as J,bJ as Z,bK as ee,bV as ie,aO as te,hq as ae,q as se}from"./appStore-CidPWYa0.js";import"./client-CPUljePZ.js";import{L as ne}from"./phoneList-DrxIwJxQ.js";import{v as oe,E as re,o as le,u as S,b as D,i as k,r as T,c as de,m as H,d as ce,f as me,t as ue}from"./RightPanel-BgSeCLnw.js";import{C as he,G as pe}from"./codingNavigation-CCjs1kon.js";import{q as ge,t as xe,a as _,v as je,w as Se,x as V,L as G,y as fe,z as be,e as ve,p as ye,I as we,b as Ne,d as Ce}from"./imageStudio-Dgl1wZNB.js";import{L as ke}from"./lock-TSDKuCod.js";import{L as Ie}from"./InlineFiles-BIfsx3R-.js";import{R as Me}from"./rotate-ccw-xgT_0UN9.js";import{L as ze}from"./layout-grid-DFmwM9NU.js";import"./nativeDownload-B3JGkABw.js";import"./ipc-CNlIRMtU.js";import"./book-open-CBeNsIpo.js";import"./folder-plus-d5MwIMlf.js";import"./folder-CoOsfQ64.js";import"./upload-CrbEAW8C.js";import"./pencil-CJsJD7M_.js";import"./RunLocationPicker-M1UoJyjf.js";import"./codeStudioStore-DXMQwRzG.js";import"./ModelPill-DveHcLqq.js";import"./create-C19zqt5N.js";import"./approvalText-Cy2UAUAQ.js";import"./message-square-plus-3wFslIMY.js";import"./hand-fuehbnkI.js";import"./pageChrome-DFi9zs6F.js";import"./emoji-DczIG8SO.js";import"./pdf.worker.min-CGb3BKV9.js";import"./code-xml-n9mgGgkv.js";import"./zoom-in-BcuPvIYd.js";import"./undo-2-BOUt5qks.js";import"./arrow-up-right-KPFbRA41.js";import"./minus-BBdfT_sc.js";import"./SketchCard-DAD0jR0i.js";import"./terminal-DPZazOQ2.js";import"./circle-x-Szwop5L_.js";import"./circle-question-mark-M8QUJJYk.js";import"./FloatingToc-ldOYWe2C.js";import"./MarkdownBlock-wYEaBBOr.js";import"./index-BqGpbntz.js";import"./linkFollow-iP2zfbA3.js";import"./listFold-Aea6I0Sa.js";const Ee=[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]],$e=P("crop",Ee);const Le=[["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"}]],Pe=P("flip-horizontal-2",Le);const Re=[["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"}]],Fe=P("flip-vertical-2",Re);function Ae({image:i,onApply:l,onCancel:n}){const{t:r}=M(),a=ge(i.blob),[c,p]=j.useState(i.crop||{x:0,y:0,w:i.width,h:i.height}),s=j.useRef(null),d=j.useRef(null),f=o=>{const m=Math.max(0,Math.min(i.width-1,Math.round(o.x))),b=Math.max(0,Math.min(i.height-1,Math.round(o.y)));return{x:m,y:b,w:Math.max(1,Math.min(i.width-m,Math.round(o.w))),h:Math.max(1,Math.min(i.height-b,Math.round(o.h)))}};return e.jsxs("div",{className:"ims-crop",onKeyDown:o=>{o.key==="Escape"&&(o.stopPropagation(),n())},children:[e.jsx("h4",{children:r("imageStudio.crop")}),e.jsx("p",{children:r("imageStudio.cropHint")}),e.jsxs("div",{ref:d,className:"ims-crop-stage",style:{aspectRatio:i.width/i.height},onPointerDown:o=>{const m=o.currentTarget.getBoundingClientRect(),b=o.target.dataset.edge||"move";s.current={pointer:o.pointerId,x:o.clientX,y:o.clientY,base:c,edge:b,sx:i.width/m.width,sy:i.height/m.height},o.currentTarget.setPointerCapture(o.pointerId),o.preventDefault()},onPointerMove:o=>{const m=s.current;if(!m||m.pointer!==o.pointerId)return;const b=(o.clientX-m.x)*m.sx,g=(o.clientY-m.y)*m.sy,h=m.base;if(m.edge==="move")p(f({...h,x:Math.max(0,Math.min(i.width-h.w,h.x+b)),y:Math.max(0,Math.min(i.height-h.h,h.y+g))}));else{const y=m.edge.includes("w")?Math.max(0,Math.min(h.x+h.w-1,h.x+b)):h.x,t=m.edge.includes("n")?Math.max(0,Math.min(h.y+h.h-1,h.y+g)):h.y,x=m.edge.includes("e")?Math.min(i.width,Math.max(h.x+1,h.x+h.w+b)):h.x+h.w,v=m.edge.includes("s")?Math.min(i.height,Math.max(h.y+1,h.y+h.h+g)):h.y+h.h;p(f({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":r("imageStudio.cropRatio"),defaultValue:"",onChange:o=>{const m=Number(o.target.value)||i.width/i.height,b=Math.min(i.width,i.height*m),g=b/m;p(f({x:(i.width-b)/2,y:(i.height-g)/2,w:b,h:g}))},children:[e.jsx("option",{value:"",disabled:!0,children:r("imageStudio.cropRatio")}),e.jsx("option",{value:"0",children:r("imageStudio.original")}),[[1,"1:1"],[.8,"4:5"],[2/3,"2:3"],[16/9,"16:9"],[9/16,"9:16"]].map(([o,m])=>e.jsx("option",{value:o,children:m},m))]}),e.jsx("div",{className:"ims-fields",children:["x","y","w","h"].map(o=>e.jsxs("label",{children:[r(`imageStudio.${o}`),e.jsx("input",{type:"number","aria-label":r(`imageStudio.crop.${o}`),value:c[o],min:o==="x"||o==="y"?0:1,max:o==="x"||o==="w"?i.width:i.height,onChange:m=>p(f({...c,[o]:Number(m.target.value)||0}))})]},o))}),e.jsxs("div",{className:"ims-button-row",children:[e.jsx("button",{onClick:n,children:r("imageStudio.cancel")}),e.jsx("button",{className:"ims-primary",disabled:!oe(c,i.width,i.height),onClick:()=>l(c),children:r("imageStudio.applyCrop")})]})]})}const qe=re,Te=["low","medium","high","xhigh","max"];function Be(i,l,n,r){const[a,c]=n.split(":").map(Number),p=1+Math.max(.1,Math.min(1,r)),s=Math.ceil(Math.max(i*p,l*p*a/c)),d=Math.ceil(s*c/a);return{w:s,h:d,x:Math.floor((s-i)/2),y:Math.floor((d-l)/2)}}async function De(i,l,n,r,a){if(!i.length||i.length>8)throw new Error(E("imageStudio.ai.referenceLimit"));if(l!=="expand")return Promise.all(i.map(s=>xe(s,a)));const c=await _([i[0]],!0,1024),p=await je(c);try{const s=Be(p.width,p.height,n,r),d=Math.min(1,1536/Math.max(s.w,s.h)),f=document.createElement("canvas");f.width=Math.round(s.w*d),f.height=Math.round(s.h*d);const o=f.getContext("2d");if(!o)throw new Error("Canvas unavailable");o.drawImage(p,s.x*d,s.y*d,p.width*d,p.height*d);const m=await new Promise((g,h)=>f.toBlob(y=>y?g(y):h(new Error("PNG encoding failed")),"image/png")),b=await Se(m);return[{name:"expand-reference.png",mimeType:"image/png",size:m.size,data:b.split(",")[1]}]}finally{p.close()}}function He(i,l,n,r,a,c=""){return[E(`imageStudio.ai.prompt.${i}`),E(`imageStudio.ai.sourcePrompt.${i==="expand"?"current":a}`),l.trim(),E("imageStudio.ai.outputPrompt",{ratio:n.requested,engineRatio:n.engine,count:r}),c?E("imageStudio.ai.qualityPrompt",{quality:c}):""].filter(Boolean).join(`
1
+ import{u as M,d as j,j as e,t as E}from"./index-BYUntVIZ.js";import{G as P,u as $,N as q,kU as Y,ct as K,kR as R,V as B,aN as W,ar as L,hx as Q,bI as J,bJ as Z,bK as ee,bV as ie,aO as te,hq as ae,q as se}from"./appStore-affnJoin.js";import"./client-BqhpYbYL.js";import{L as ne}from"./phoneList-DHUia6HT.js";import{v as oe,E as re,o as le,u as S,b as D,i as k,r as T,c as de,m as H,d as ce,f as me,t as ue}from"./RightPanel-BRexwQ3W.js";import{C as he,G as pe}from"./codingNavigation-CxdCK78-.js";import{q as ge,t as xe,a as _,v as je,w as Se,x as V,L as G,y as fe,z as be,e as ve,p as ye,I as we,b as Ne,d as Ce}from"./imageStudio-Axwmd4GW.js";import{L as ke}from"./lock-kffGfeHt.js";import{L as Ie}from"./InlineFiles-DKPH5JHz.js";import{R as Me}from"./rotate-ccw-BLoH5er1.js";import{L as ze}from"./layout-grid-Hs3eDA07.js";import"./nativeDownload-Udrv_tmU.js";import"./ipc-D7yENkjV.js";import"./book-open-CcXCToyx.js";import"./folder-plus-BJKT1Pqg.js";import"./folder-CCZqnwRc.js";import"./upload-D20PZHXc.js";import"./pencil-DGiTRzW1.js";import"./RunLocationPicker-CadYiE7C.js";import"./codeStudioStore-Dq5i8nbE.js";import"./ModelPill-ChzAM3z1.js";import"./create-BgJN5qsj.js";import"./approvalText-Cy2UAUAQ.js";import"./message-square-plus-DxBPIhPS.js";import"./hand-DRu7IJdU.js";import"./pageChrome-D-9npbUE.js";import"./emoji-BPdA62d7.js";import"./pdf.worker.min-CGb3BKV9.js";import"./code-xml-DdR58F83.js";import"./zoom-in-_TgFOpyv.js";import"./undo-2-yMeXc8Wi.js";import"./arrow-up-right-R4P9Mmxz.js";import"./minus-CfoZ4oxr.js";import"./SketchCard-BcXCdBAs.js";import"./terminal-BlmA_Z1C.js";import"./circle-x-AV2ZWulM.js";import"./circle-question-mark-O8AhUz35.js";import"./FloatingToc-B1d4-5EL.js";import"./MarkdownBlock-BHpDy2qQ.js";import"./index-Y2kzYlZq.js";import"./linkFollow-Msu1XH9v.js";import"./listFold-CKxjyY5_.js";const Ee=[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]],$e=P("crop",Ee);const Le=[["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"}]],Pe=P("flip-horizontal-2",Le);const Re=[["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"}]],Fe=P("flip-vertical-2",Re);function Ae({image:i,onApply:l,onCancel:n}){const{t:r}=M(),a=ge(i.blob),[c,p]=j.useState(i.crop||{x:0,y:0,w:i.width,h:i.height}),s=j.useRef(null),d=j.useRef(null),f=o=>{const m=Math.max(0,Math.min(i.width-1,Math.round(o.x))),b=Math.max(0,Math.min(i.height-1,Math.round(o.y)));return{x:m,y:b,w:Math.max(1,Math.min(i.width-m,Math.round(o.w))),h:Math.max(1,Math.min(i.height-b,Math.round(o.h)))}};return e.jsxs("div",{className:"ims-crop",onKeyDown:o=>{o.key==="Escape"&&(o.stopPropagation(),n())},children:[e.jsx("h4",{children:r("imageStudio.crop")}),e.jsx("p",{children:r("imageStudio.cropHint")}),e.jsxs("div",{ref:d,className:"ims-crop-stage",style:{aspectRatio:i.width/i.height},onPointerDown:o=>{const m=o.currentTarget.getBoundingClientRect(),b=o.target.dataset.edge||"move";s.current={pointer:o.pointerId,x:o.clientX,y:o.clientY,base:c,edge:b,sx:i.width/m.width,sy:i.height/m.height},o.currentTarget.setPointerCapture(o.pointerId),o.preventDefault()},onPointerMove:o=>{const m=s.current;if(!m||m.pointer!==o.pointerId)return;const b=(o.clientX-m.x)*m.sx,g=(o.clientY-m.y)*m.sy,h=m.base;if(m.edge==="move")p(f({...h,x:Math.max(0,Math.min(i.width-h.w,h.x+b)),y:Math.max(0,Math.min(i.height-h.h,h.y+g))}));else{const y=m.edge.includes("w")?Math.max(0,Math.min(h.x+h.w-1,h.x+b)):h.x,t=m.edge.includes("n")?Math.max(0,Math.min(h.y+h.h-1,h.y+g)):h.y,x=m.edge.includes("e")?Math.min(i.width,Math.max(h.x+1,h.x+h.w+b)):h.x+h.w,v=m.edge.includes("s")?Math.min(i.height,Math.max(h.y+1,h.y+h.h+g)):h.y+h.h;p(f({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":r("imageStudio.cropRatio"),defaultValue:"",onChange:o=>{const m=Number(o.target.value)||i.width/i.height,b=Math.min(i.width,i.height*m),g=b/m;p(f({x:(i.width-b)/2,y:(i.height-g)/2,w:b,h:g}))},children:[e.jsx("option",{value:"",disabled:!0,children:r("imageStudio.cropRatio")}),e.jsx("option",{value:"0",children:r("imageStudio.original")}),[[1,"1:1"],[.8,"4:5"],[2/3,"2:3"],[16/9,"16:9"],[9/16,"9:16"]].map(([o,m])=>e.jsx("option",{value:o,children:m},m))]}),e.jsx("div",{className:"ims-fields",children:["x","y","w","h"].map(o=>e.jsxs("label",{children:[r(`imageStudio.${o}`),e.jsx("input",{type:"number","aria-label":r(`imageStudio.crop.${o}`),value:c[o],min:o==="x"||o==="y"?0:1,max:o==="x"||o==="w"?i.width:i.height,onChange:m=>p(f({...c,[o]:Number(m.target.value)||0}))})]},o))}),e.jsxs("div",{className:"ims-button-row",children:[e.jsx("button",{onClick:n,children:r("imageStudio.cancel")}),e.jsx("button",{className:"ims-primary",disabled:!oe(c,i.width,i.height),onClick:()=>l(c),children:r("imageStudio.applyCrop")})]})]})}const qe=re,Te=["low","medium","high","xhigh","max"];function Be(i,l,n,r){const[a,c]=n.split(":").map(Number),p=1+Math.max(.1,Math.min(1,r)),s=Math.ceil(Math.max(i*p,l*p*a/c)),d=Math.ceil(s*c/a);return{w:s,h:d,x:Math.floor((s-i)/2),y:Math.floor((d-l)/2)}}async function De(i,l,n,r,a){if(!i.length||i.length>8)throw new Error(E("imageStudio.ai.referenceLimit"));if(l!=="expand")return Promise.all(i.map(s=>xe(s,a)));const c=await _([i[0]],!0,1024),p=await je(c);try{const s=Be(p.width,p.height,n,r),d=Math.min(1,1536/Math.max(s.w,s.h)),f=document.createElement("canvas");f.width=Math.round(s.w*d),f.height=Math.round(s.h*d);const o=f.getContext("2d");if(!o)throw new Error("Canvas unavailable");o.drawImage(p,s.x*d,s.y*d,p.width*d,p.height*d);const m=await new Promise((g,h)=>f.toBlob(y=>y?g(y):h(new Error("PNG encoding failed")),"image/png")),b=await Se(m);return[{name:"expand-reference.png",mimeType:"image/png",size:m.size,data:b.split(",")[1]}]}finally{p.close()}}function He(i,l,n,r,a,c=""){return[E(`imageStudio.ai.prompt.${i}`),E(`imageStudio.ai.sourcePrompt.${i==="expand"?"current":a}`),l.trim(),E("imageStudio.ai.outputPrompt",{ratio:n.requested,engineRatio:n.engine,count:r}),c?E("imageStudio.ai.qualityPrompt",{quality:c}):""].filter(Boolean).join(`
2
2
 
3
3
  `)}function _e({board:i,images:l}){const{t:n}=M(),[r,a]=j.useState("edit"),[c,p]=j.useState(""),[s,d]=j.useState("original"),[f,o]=j.useState("current"),[m,b]=j.useState(1),[g,h]=j.useState(.5),[y,t]=j.useState(""),[x,v]=j.useState(!1),[w,F]=j.useState(""),C=$(u=>!!(i.sessionId&&u.runningBySession[i.sessionId])),N=le(l[0],s),U=async()=>{v(!0),F("");let u=[];try{const I=await V(i.id);if(S.getState().activeId!==i.id)return;if($.getState().runningBySession[I])throw new Error(n("imageStudio.ai.wait"));u=S.getState().beginGeneration(i.id,I,{count:m,aspect:N.aspect,ratio:N.requested,kind:"edit",sourceIds:l.map(X=>X.id)});const A=r==="expand"?"current":f,O=await De(l,r,N.requested,g,A);if(!await $.getState().send(He(r,c,N,m,A,y),O,void 0,void 0,void 0,I))throw new Error(n("imageStudio.ai.sendFailed"));S.getState().activateGeneration(u)}catch(I){u.length&&S.getState().failGeneration(i.id,{ids:u}),F(I instanceof Error?I.message:String(I))}finally{v(!1)}};return e.jsxs("details",{className:"ims-ai",open:!0,children:[e.jsxs("summary",{children:[e.jsx(q,{size:15}),n("imageStudio.ai.title"),e.jsxs("span",{children:[l.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(u=>e.jsx("button",{"aria-pressed":r===u,disabled:C||x||u!=="edit"&&l.length!==1,onClick:()=>a(u),children:n(`imageStudio.ai.${u}`)},u))}),e.jsx("p",{className:"ims-caption",children:n(`imageStudio.ai.hint.${r}`)}),e.jsx("textarea",{"aria-label":n("imageStudio.ai.instruction"),placeholder:n("imageStudio.ai.placeholder"),value:c,onChange:u=>p(u.target.value),maxLength:8e3,rows:3,disabled:x||C}),e.jsxs("label",{className:"ims-ai-source",children:[n("imageStudio.ai.source"),e.jsxs("select",{"aria-label":n("imageStudio.ai.source"),value:r==="expand"?"current":f,onChange:u=>o(u.target.value),disabled:x||C||r==="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:u=>d(u.target.value),disabled:x||C,children:[e.jsx("option",{value:"original",children:n("imageStudio.ai.ratio.original",{ratio:N.originalLabel})}),qe.map(u=>e.jsx("option",{value:u,children:u},u))]})]}),e.jsxs("label",{children:[n("imageStudio.ai.count"),e.jsx("select",{"aria-label":n("imageStudio.ai.count"),value:m,onChange:u=>b(Number(u.target.value)),disabled:x||C,children:[1,2,3,4].map(u=>e.jsx("option",{children:u},u))})]}),e.jsxs("label",{children:[n("imageStudio.ai.quality"),e.jsxs("select",{"aria-label":n("imageStudio.ai.quality"),value:y,onChange:u=>t(u.target.value),disabled:x||C,children:[e.jsx("option",{value:"",children:n("imageStudio.ai.quality.default")}),Te.map(u=>e.jsx("option",{value:u,children:n(`imageStudio.ai.quality.${u}`)},u))]})]})]}),N.requested!==N.engine&&e.jsx("p",{className:"ims-caption ims-ai-ratio-note",children:n("imageStudio.ai.ratioFit",{ratio:N.requested,engineRatio:N.engine})}),(y==="xhigh"||y==="max")&&e.jsx("p",{className:"ims-caption",children:n("imageStudio.ai.qualityNote")}),r==="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:u=>h(Number(u.target.value))}),e.jsxs("output",{children:[Math.round(g*100),"%"]})]}),e.jsxs("button",{className:"ims-primary",disabled:x||C||!l.length||l.length>8||r==="edit"&&!c.trim(),onClick:()=>{U()},children:[e.jsx(q,{size:15}),n(C||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 Li(){const{t:i}=M(),l=S(d=>d.boards),n=S(d=>d.activeId),r=S(d=>d.ready);j.useEffect(()=>{S.getState().hydrate()},[]);const a=j.useMemo(()=>Object.values(l).sort((d,f)=>f.updatedAt-d.updatedAt).slice(0,12),[l]),c=d=>{d(),se.getState().openView("image-studio",{},"main")},p=()=>c(()=>S.getState().create(i("imageStudio.untitled"))),s=ae();return e.jsxs("nav",{className:`csn ims-nav${s?" pl-fab-room":""}`,"aria-label":i("imageStudio.title"),children:[e.jsxs("div",{className:"csn-section",children:[!s&&e.jsx("span",{className:"csn-heading",children:i("imageStudio.nav.create")}),!s&&e.jsxs("button",{type:"button",className:"csn-item",disabled:!r,onClick:p,children:[e.jsx(L,{size:16}),i("imageStudio.new")]}),e.jsxs("button",{type:"button",className:"csn-item","aria-current":r&&!n?"page":void 0,onClick:()=>c(()=>S.getState().close()),children:[e.jsx(ze,{size:16}),i("imageStudio.projects")]})]}),a.length>0&&e.jsxs("div",{className:"csn-section",children:[e.jsx("span",{className:"csn-heading",children:i("imageStudio.nav.recent")}),a.map(d=>{const f=de(d,1)[0];return e.jsxs("button",{type:"button",className:"csn-item",title:d.name,"aria-current":d.id===n?"page":void 0,onClick:()=>c(()=>S.getState().open(d.id)),children:[f?e.jsx("span",{className:"ims-nav-thumb",children:e.jsx(we,{image:f})}):e.jsx(R,{size:16}),e.jsx("span",{className:"ims-nav-name",children:d.name})]},d.id)})]}),s&&r&&e.jsx(ne,{label:i("imageStudio.new"),icon:e.jsx(L,{}),onClick:p})]})}function Pi(i){const{t:l}=M(),n=S(s=>s.activeId?s.boards[s.activeId]:void 0),[r,a]=j.useState(!1),[c,p]=j.useState("");return j.useEffect(()=>{S.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(he,{...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(B,{size:26,strokeWidth:1.3}),e.jsx("h3",{children:l("imageStudio.chat")}),e.jsx("p",{children:l(n?"imageStudio.chatHint":"imageStudio.choose")}),n&&e.jsxs("button",{className:"ims-primary",disabled:r,onClick:async()=>{a(!0),p("");try{await V(n.id)}catch(s){p(String(s))}finally{a(!1)}},children:[r?e.jsx(W,{size:15,className:"ims-spin"}):e.jsx(L,{size:15}),l("imageStudio.connect")]}),c&&e.jsx("p",{role:"alert",children:l("imageStudio.error",{error:c})})]})}function Ri(){const{t:i}=M(),l=S(s=>s.activeId?s.boards[s.activeId]:void 0),n=S(s=>s.selection),[r,a]=j.useState(""),c=l?D(l).reverse().filter(s=>s.name.toLocaleLowerCase().includes(r.toLocaleLowerCase())):[],p=(s,d)=>l&&S.getState().update(l.id,f=>H(f,o=>o.id===s?{...o,...d}: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:r,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:d=>S.setState({selection:d.shiftKey?n.includes(s.id)?n.filter(f=>f!==s.id):[...n,s.id]:[s.id]}),children:[e.jsx("div",{className:"ims-layer-thumb",children:e.jsx(G,{item:s})}),e.jsxs("span",{children:[e.jsx("strong",{children:s.name}),e.jsx("small",{children:i(`imageStudio.kind.${fe(s)}`)})]})]}),e.jsx("button",{"aria-label":i(s.hidden?"imageStudio.show":"imageStudio.hide"),title:i(s.hidden?"imageStudio.show":"imageStudio.hide"),onClick:()=>p(s.id,{hidden:!s.hidden}),children:s.hidden?e.jsx(Y,{size:14}):e.jsx(K,{size:14})}),e.jsx("button",{"aria-label":i(s.locked?"imageStudio.unlock":"imageStudio.lock"),title:i(s.locked?"imageStudio.unlock":"imageStudio.lock"),onClick:()=>p(s.id,{locked:!s.locked}),children:s.locked?e.jsx(ke,{size:14}):e.jsx(Ie,{size:14})})]},s.id))}),!c.length&&e.jsxs("div",{className:"ims-panel-empty",children:[e.jsx(R,{size:26}),e.jsx("p",{children:i(r.trim()?"imageStudio.noLayers":"imageStudio.layersEmpty")})]}),e.jsx("p",{className:"ims-caption",children:i("imageStudio.layersHint")})]})}function z({label:i,value:l,onChange:n,min:r=-1e5,max:a=1e5}){const[c,p]=j.useState(String(Math.round(l*100)/100));j.useEffect(()=>p(String(Math.round(l*100)/100)),[l]);const s=()=>{const d=Number(c);c.trim()&&Number.isFinite(d)?n(Math.max(r,Math.min(a,d))):p(String(l))};return e.jsxs("label",{children:[i,e.jsx("input",{type:"number","aria-label":i,value:c,min:r,max:a,onChange:d=>p(d.target.value),onBlur:s,onKeyDown:d=>{d.key==="Enter"&&d.currentTarget.blur()}})]})}function Fi(){const{t:i}=M(),l=S(t=>t.activeId?t.boards[t.activeId]:void 0),n=S(t=>t.selection),r=l?D(l).filter(t=>n.includes(t.id)):[],a=r[0],c=a&&k(a)&&a.parentId?l?.images.find(t=>t.id===a.parentId):void 0,[p,s]=j.useState(""),[d,f]=j.useState(!1),[o,m]=j.useState(!1);j.useEffect(()=>{m(!1),s("")},[l?.id,a?.id]);const b=async t=>{f(!0),s("");try{await t()}catch(x){s(String(x))}finally{f(!1)}};if(!l||!a)return e.jsxs("div",{className:"ims-panel ims-panel-empty",children:[e.jsx(R,{size:26}),e.jsx("p",{children:i("imageStudio.select")})]});const g=t=>S.getState().update(l.id,x=>H(x,v=>v.id===a.id&&!v.locked?{...v,...t}:v)),h=t=>{k(a)&&g(ue(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=ce(a);v={...v,...t==="w"?{h:x*w.h/w.w}:{w:x*w.w/w.h}}}S.getState().update(l.id,w=>me(w,new Map([[a.id,v]])))};return e.jsxs("section",{className:"ims-panel ims-inspector",children:[e.jsx("h3",{children:i(r.length>1?"imageStudio.selection":"imageStudio.inspector")}),r.every(k)&&e.jsx(_e,{board:l,images:r.filter(k)},`${l.id}:${n.join(",")}`),r.length===1?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"ims-preview",style:{aspectRatio:a.w/a.h},children:e.jsx(G,{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(z,{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:()=>S.setState({selection:[c.id]}),children:[e.jsx(pe,{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:()=>m(!o),children:e.jsx($e,{size:16})}),e.jsx("button",{title:i("imageStudio.rotate"),"aria-label":i("imageStudio.rotate"),onClick:()=>h({rotation:((a.rotation||0)+90)%360}),children:e.jsx(Q,{size:16})}),e.jsx("button",{title:i("imageStudio.flipX"),"aria-label":i("imageStudio.flipX"),onClick:()=>h({flipX:!a.flipX}),children:e.jsx(Pe,{size:16})}),e.jsx("button",{title:i("imageStudio.flipY"),"aria-label":i("imageStudio.flipY"),onClick:()=>h({flipY:!a.flipY}),children:e.jsx(Fe,{size:16})})]}),o&&e.jsx(Ae,{image:a,onCancel:()=>m(!1),onApply:t=>{h({crop:t}),m(!1)}},a.id),e.jsx(z,{label:i("imageStudio.angle"),value:a.rotation||0,min:0,max:359,onChange:t=>h({rotation:t})}),e.jsx("button",{onClick:()=>h({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(Me,{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(z,{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(z,{label:i("imageStudio.strokeWidth"),value:a.strokeWidth,min:0,max:100,onChange:t=>g({strokeWidth:t})}),e.jsx(z,{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:r.length})}),e.jsx("div",{className:"ims-align",children:["left","center","right","top","middle","bottom"].map(t=>e.jsx("button",{onClick:()=>S.getState().update(l.id,x=>be(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:()=>S.getState().update(l.id,t=>T(t,n,"up")),children:e.jsx(J,{size:15})}),e.jsx("button",{title:i("imageStudio.layerDown"),"aria-label":i("imageStudio.layerDown"),onClick:()=>S.getState().update(l.id,t=>T(t,n,"down")),children:e.jsx(Z,{size:15})}),e.jsx("button",{title:i("imageStudio.remove"),"aria-label":i("imageStudio.remove"),onClick:ve,children:e.jsx(ee,{size:15})})]}),e.jsxs("div",{className:"ims-panel-actions",children:[e.jsxs("button",{disabled:d||r.every(t=>t.hidden),onClick:()=>{b(Ne)},children:[e.jsx(B,{size:14}),i("imageStudio.reference")]}),e.jsxs("button",{onClick:()=>ye(!0),children:[e.jsx(ie,{size:14}),i("imageStudio.duplicate")]}),r.length===1&&k(a)&&e.jsxs("button",{className:"ims-primary",disabled:d,onClick:()=>{b(async()=>Ce(await _([a],!0),a.name.replace(/\.[^.]+$/,"")+".png"))},children:[e.jsx(te,{size:14}),i("imageStudio.export")]})]}),p&&e.jsx("p",{role:"alert",children:i("imageStudio.error",{error:p})})]})}export{Ri as ImageStudioAssets,Pi as ImageStudioChat,Fi as ImageStudioInspector,Li as ImageStudioNav,z as NumberField};
@@ -1 +1 @@
1
- import{u as F,d as o,j as t}from"./index-B5UW6SaE.js";import{G as xe,aF as fe,aN as te,aO as R,V as Z,kQ as Se,bV as je,bI as $e,bJ as Re,bK as ve,a5 as Ae,ar as Be,T as Fe,e3 as Ue,kR as He,a6 as Ve,b2 as _e,u as qe,fK as Ke,fX as q,aL as We,L as Ye,kS as Ge,N as Xe,d$ as Qe,cP as Je,kT as Ze,fT as et}from"./appStore-CidPWYa0.js";import"./client-CPUljePZ.js";import{u as tt}from"./gestures-CXFaEydn.js";import{C as st,a as it}from"./Chrome-BvpbCvo1.js";import{b as M,i as be,u as r,a as at,C as nt,r as ce,m as rt,c as ot,d as ye,e as ue,f as me,g as lt,n as dt,h as ct}from"./RightPanel-BgSeCLnw.js";import{s as ut,d as ee,r as mt,h as gt,a as pt,b as Ce,c as we,p as B,e as ke,I as ht,i as xt,f as ft,l as St,u as jt,g as A,S as ge,j as vt,k as K,L as bt,m as yt,n as Ct,o as wt}from"./imageStudio-Dgl1wZNB.js";import{L as kt}from"./lock-TSDKuCod.js";import{L as zt}from"./InlineFiles-BIfsx3R-.js";import{U as W}from"./upload-CrbEAW8C.js";/* empty css */import{F as Nt,R as It}from"./redo-2-CI57sDFr.js";import{U as Et}from"./undo-2-BOUt5qks.js";import{L as Lt}from"./layout-grid-DFmwM9NU.js";import{A as Pt}from"./arrow-up-right-KPFbRA41.js";import{H as Tt}from"./hand-fuehbnkI.js";import{T as Mt,F as Ot}from"./type-C5J875vb.js";import"./nativeDownload-B3JGkABw.js";import"./ipc-CNlIRMtU.js";import"./minus-BBdfT_sc.js";import"./book-open-CBeNsIpo.js";import"./folder-plus-d5MwIMlf.js";import"./folder-CoOsfQ64.js";import"./pencil-CJsJD7M_.js";const Dt=[["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"}]],$t=xe("clipboard-paste",Dt);const Rt=[["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"}]],At=xe("copy-plus",Rt);function Bt({board:s,selection:i,onClose:j}){const{t:c}=F(),[g,v]=o.useState("png"),[b,w]=o.useState(1),[l,p]=o.useState("transparent"),[S,y]=o.useState(.92),[N,C]=o.useState(!1),[u,d]=o.useState(""),z=ut(s,i),L=z?.bounds,P=Math.round((L?.w||0)*b),O=Math.round((L?.h||0)*b),D=!L||P<1||O<1||P*O>4e7||Math.max(P,O)>16384;return t.jsxs("section",{className:"ims-export ims-panel","aria-label":c("imageStudio.exportOptions"),children:[t.jsxs("div",{className:"ims-section-head",children:[t.jsx("h3",{children:c("imageStudio.exportOptions")}),t.jsx("button",{"aria-label":c("imageStudio.close"),onClick:j,children:t.jsx(fe,{size:15})})]}),t.jsxs("div",{className:"ims-fields",children:[t.jsxs("label",{children:[c("imageStudio.format"),t.jsx("select",{"aria-label":c("imageStudio.format"),value:g,onChange:h=>v(h.target.value),children:["png","jpeg","webp","svg"].map(h=>t.jsx("option",{value:h,children:h.toUpperCase()},h))})]}),t.jsxs("label",{children:[c("imageStudio.scale"),t.jsx("select",{"aria-label":c("imageStudio.scale"),value:b,onChange:h=>w(Number(h.target.value)),children:[.5,1,2,3].map(h=>t.jsxs("option",{value:h,children:[h,"×"]},h))})]}),t.jsxs("label",{children:[c("imageStudio.background"),t.jsxs("select",{"aria-label":c("imageStudio.background"),value:l,onChange:h=>p(h.target.value),children:[t.jsx("option",{value:"transparent",children:c("imageStudio.transparent")}),t.jsx("option",{value:"#ffffff",children:c("imageStudio.white")}),t.jsx("option",{value:"#000000",children:c("imageStudio.black")})]})]}),(g==="jpeg"||g==="webp")&&t.jsxs("label",{children:[c("imageStudio.quality"),t.jsx("input",{"aria-label":c("imageStudio.quality"),type:"range",min:".1",max:"1",step:".05",value:S,onChange:h=>y(Number(h.target.value))})]})]}),t.jsxs("p",{children:[P," × ",O," px · ",c(i.length?"imageStudio.selectedOnly":"imageStudio.allVisible")]}),g==="svg"&&t.jsx("p",{children:c("imageStudio.svgHint")}),g==="jpeg"&&l==="transparent"&&t.jsx("p",{children:c("imageStudio.jpegHint")}),D&&t.jsx("p",{role:"alert",children:c("imageStudio.exportLimit")}),t.jsxs("button",{className:"ims-primary",disabled:N||D,onClick:async()=>{C(!0),d("");try{ee(await mt(s,i,{format:g,scale:b,background:l,quality:S}),`${s.name}.${g==="jpeg"?"jpg":g}`)}catch(h){d(String(h))}finally{C(!1)}},children:[N?t.jsx(te,{className:"ims-spin",size:15}):t.jsx(R,{size:15}),c("imageStudio.download")]}),u&&t.jsx("p",{role:"alert",children:c("imageStudio.error",{error:u})})]})}function Ft({target:s,board:i,busy:j,onClose:c,onImport:g,onExport:v,onInspect:b,run:w}){const{t:l}=F(),p=i?M(i).filter(d=>s.ids.includes(d.id)):[],S=p.length===1&&be(p[0])?p[0]:void 0,y=p.filter(d=>!d.locked).map(d=>d.id),N=/Mac|iPhone|iPad/.test(navigator.platform)?"⌘":"Ctrl+",C=d=>()=>{i&&r.getState().activeId!==i.id||(r.setState({selection:p.map(z=>z.id)}),d())},u=[];return S&&u.push({label:l("imageStudio.downloadImage"),icon:t.jsx(R,{size:14}),disabled:j,run:C(()=>{w(async()=>ee(await pt([S],!0),S.name.replace(/\.[^.]+$/,"")+".png"))})},{label:l("imageStudio.downloadOriginal"),icon:t.jsx(R,{size:14}),run:C(()=>{const d={"image/png":"png","image/jpeg":"jpg","image/webp":"webp","image/gif":"gif"}[S.blob.type]||"png";ee(S.blob,S.name.replace(/\.[^.]+$/,"")+"-original."+d)})}),p.length&&i?u.push({label:l("imageStudio.exportSelection"),icon:t.jsx(R,{size:14}),disabled:j,run:C(v)},{label:l("imageStudio.reference"),icon:t.jsx(Z,{size:14}),separatorBefore:!0,disabled:j||p.length>8,run:C(()=>{w(Ce)})},{label:l("imageStudio.inspector"),icon:t.jsx(Se,{size:14}),run:C(b)},{label:l("imageStudio.copyObjects"),icon:t.jsx(je,{size:14}),shortcut:`${N}C`,separatorBefore:!0,run:C(we)},{label:l("imageStudio.duplicate"),icon:t.jsx(At,{size:14}),shortcut:`${N}D`,run:C(()=>B(!0))},{label:l("imageStudio.layerUp"),icon:t.jsx($e,{size:14}),separatorBefore:!0,disabled:!y.length,run:C(()=>r.getState().update(i.id,d=>ce(d,y,"up")))},{label:l("imageStudio.layerDown"),icon:t.jsx(Re,{size:14}),disabled:!y.length,run:C(()=>r.getState().update(i.id,d=>ce(d,y,"down")))},{label:l(y.length?"imageStudio.lock":"imageStudio.unlock"),icon:y.length?t.jsx(kt,{size:14}):t.jsx(zt,{size:14}),run:C(()=>r.getState().update(i.id,d=>rt(d,z=>s.ids.includes(z.id)?{...z,locked:!!y.length}:z)))},{label:l("imageStudio.remove"),icon:t.jsx(ve,{size:14}),shortcut:"⌫",separatorBefore:!0,danger:!0,disabled:!y.length,run:C(ke)}):u.push({label:l("imageStudio.import"),icon:t.jsx(W,{size:14}),disabled:j,run:g},{label:l("imageStudio.pasteObjects"),icon:t.jsx($t,{size:14}),shortcut:`${N}V`,disabled:!i||!gt(),run:C(()=>B())},{label:l("imageStudio.selectAll"),icon:t.jsx(at,{size:14}),disabled:!i?.images.length&&!i?.elements?.length,run:()=>r.setState({selection:i?M(i).filter(d=>!d.hidden).map(d=>d.id):[]})},{label:l("imageStudio.exportBoard"),icon:t.jsx(R,{size:14}),separatorBefore:!0,disabled:j||!i||!M(i).some(d=>!d.hidden),run:C(v)}),t.jsx(nt,{menu:{x:s.x,y:s.y,items:u},onClose:c,autoFocus:!0})}const pe=4/3,Ut=.05;function Ht({board:s}){const i=ot(s,2);if(!i.length)return t.jsx("span",{className:"ims-cover is-empty",children:t.jsx("span",{className:"ims-cover-in",children:t.jsx(He,{size:22,strokeWidth:1.4})})});const j=i.map(g=>{const v=ye(g);return v.w/v.h}),c=Math.min(1,(1-Ut*(i.length-1))*pe/j.reduce((g,v)=>g+v,0));return t.jsx("span",{className:"ims-cover",children:t.jsx("span",{className:"ims-cover-in",children:i.map((g,v)=>t.jsx("span",{className:"ims-cover-img",style:{width:`${j[v]*c/pe*100}%`,aspectRatio:String(j[v])},children:t.jsx(ht,{image:g})},g.id))})})}function Vt(){const{t:s,locale:i}=F(),j=r(u=>u.boards),[c,g]=o.useState(""),[v,b]=o.useState(!1),[w,l]=o.useState(""),p=o.useRef(null),S=o.useMemo(()=>Object.values(j).sort((u,d)=>d.updatedAt-u.updatedAt),[j]),y=c.trim().toLocaleLowerCase(),N=y?S.filter(u=>u.name.toLocaleLowerCase().includes(y)):S,C=async u=>{b(!0),l("");try{const d=await xt(u),z=r.getState().create(d.name);r.getState().update(z,L=>({...d,id:L.id}))}catch(d){l(String(d))}finally{b(!1)}};return t.jsx("div",{className:"csl-launchpad ims-launch",children:t.jsx("div",{className:"csl-inner",children:t.jsxs("main",{className:"csl-catalog",children:[t.jsxs("header",{className:"csl-catalog-header",children:[t.jsxs("div",{children:[t.jsx("h1",{children:s("imageStudio.projects")}),t.jsx("p",{children:s("imageStudio.launch.subtitle")})]}),t.jsxs("div",{className:"csl-catalog-actions",children:[t.jsxs("button",{type:"button",className:"csl-import",disabled:v,onClick:()=>p.current?.click(),children:[t.jsx(Ae,{size:15}),s("imageStudio.restore")]}),t.jsxs("button",{type:"button",className:"csl-new",onClick:()=>r.getState().create(s("imageStudio.untitled")),children:[t.jsx(Be,{size:16}),s("imageStudio.new")]})]})]}),w&&t.jsx("div",{className:"ims-error",role:"alert",children:s("imageStudio.error",{error:w})}),S.length>0&&t.jsx("div",{className:"csl-catalog-toolbar",children:t.jsxs("label",{className:"csl-search",children:[t.jsx(Fe,{size:15}),t.jsx("input",{type:"search","aria-label":s("imageStudio.launch.search"),placeholder:s("imageStudio.launch.search"),value:c,onChange:u=>g(u.target.value)})]})}),N.length?t.jsx("div",{className:"ims-launch-grid",role:"group","aria-label":s("imageStudio.projects"),children:N.map(u=>t.jsxs("button",{type:"button",className:"ims-launch-card","data-project-id":u.id,onClick:()=>r.getState().open(u.id),children:[t.jsx(Ht,{board:u}),t.jsxs("span",{className:"ims-launch-meta",children:[t.jsx("strong",{children:u.name}),t.jsxs("small",{children:[s("imageStudio.itemCount",{count:M(u).length})," · ",Ue(u.updatedAt,{locale:i})]})]})]},u.id))}):t.jsxs("div",{className:"csl-empty",children:[t.jsx("strong",{children:s(S.length?"imageStudio.launch.noMatch":"imageStudio.launch.empty")}),!S.length&&t.jsx("p",{children:s("imageStudio.launch.emptyHint")})]}),t.jsx("input",{ref:p,type:"file",accept:".json",hidden:!0,onChange:u=>{const d=u.target.files?.[0];u.target.value="",d&&C(d)}})]})})})}const he=[];function xs(s){const{t:i}=F(),j=r(l=>l.ready),c=r(l=>l.error),g=r(l=>l.activeId);o.useEffect(()=>{r.getState().hydrate();const l=()=>{r.getState().flush()},p=S=>{const y=r.getState();(y.saving||y.ready&&y.error)&&(l(),S.preventDefault(),S.returnValue="")};return window.addEventListener("pagehide",l),window.addEventListener("beforeunload",p),()=>{window.removeEventListener("pagehide",l),window.removeEventListener("beforeunload",p),l()}},[]);const v=Ve(l=>l.activeSpaceId==="image-studio")&&_e()==="main",b=!!g,w=o.useRef(!1);return o.useEffect(()=>{!j||!v||(b?ft():St(w.current),w.current=b)},[j,v,b]),j?g?t.jsx(_t,{},g):t.jsx(Vt,{}):t.jsx("div",{className:"ims-panel ims-panel-empty",children:c?t.jsxs(t.Fragment,{children:[t.jsx("p",{role:"alert",children:i("imageStudio.error",{error:c})}),t.jsx("button",{onClick:()=>{r.getState().hydrate()},children:i("imageStudio.retry")})]}):t.jsx(te,{className:"ims-spin"})})}function _t(){const{t:s}=F(),i=r(e=>e.activeId?e.boards[e.activeId]:void 0),j=r(e=>e.saving),c=r(e=>e.error),g=r(e=>i&&e.past[i.id]?.length||0),v=r(e=>i&&e.future[i.id]?.length||0),b=r(e=>e.selection),w=r(e=>i&&e.placeholders[i.id]||he),l=qe(e=>!!(i?.sessionId&&e.runningBySession[i.sessionId])),[p,S]=o.useState(!1),[y,N]=o.useState(""),[C,u]=o.useState(0),[d,z]=o.useState(!1),[L,P]=o.useState(!1),[O,D]=o.useState(!1),h=o.useRef(null),[se,ze]=o.useState(!0),[ie,Ne]=o.useState(!1),[Ie,Y]=o.useState(!1),I=o.useRef(null),U=o.useRef(null),[ae,ne]=o.useState(null),Ee=o.useCallback(()=>{ne(null),I.current?.focus({preventScroll:!0})},[]),m=Ke(I,`image-studio:${i?.id||""}`,void 0,{x:56,y:64,z:1}),H=i?.images||[],T=i?M(i):[],V=T.filter(e=>!e.hidden),Le=!T.length&&!g&&!v,G=[...V,...w],_=o.useRef(!0);o.useEffect(()=>(_.current=!0,()=>{_.current=!1}),[]);const re=o.useCallback(e=>{_.current&&N(e)},[]);jt(i||qt,re,C);const x=tt(I,m,{boxes:()=>new Map(V.map(e=>[e.id,e])),identity:()=>i?.id,commit:e=>{i&&r.getState().update(i.id,a=>me(a,e))},constrain:(e,a)=>{if(a.kind!=="resize")return e;const n=H.find(De=>De.id===a.key),f=e.get(a.key);if(!n||!f)return e;const k=ye(n),E=Math.max(48,f.w),Oe=E*k.h/k.w;return new Map(e).set(a.key,{...f,w:E,h:Oe})},hitKey:e=>e.closest("[data-image-id]")?.dataset.imageId||null,isEditing:e=>!!T.find(a=>a.id===e)?.locked,hitEdge:e=>e.dataset.resize||null,onDelete:e=>{i&&r.getState().update(i.id,a=>ue(a,M(a).filter(n=>n.locked||!e.includes(n.id))))},onDoubleClick:e=>{e&&(r.setState({selection:[e]}),A(K))},onContextMenu:(e,a)=>{const n=e?x.sel.includes(e)?x.sel:[e]:[];x.setSel(n),r.setState({selection:n}),ne({x:a.clientX,y:a.clientY,ids:n})},minW:48,minH:48,repel:!1},se);o.useEffect(()=>x.bind(I.current),[x.bind]),o.useEffect(()=>m.bindWheel(I.current),[m.bindWheel]),o.useEffect(()=>{const e=()=>{D(!1),h.current=null};return window.addEventListener("blur",e),()=>window.removeEventListener("blur",e)},[]);const oe=o.useRef(x.sel);o.useEffect(()=>{oe.current!==x.sel&&(oe.current=x.sel,r.setState({selection:x.sel}))},[x.sel]),o.useEffect(()=>{if(b.join("|")!==x.sel.join("|")){x.setSel(b);const e=T.find(a=>a.id===b[0]);if(e){const{w:a,h:n}=q(I.current),f=m.vpRef.current,k=(e.x+e.w/2)*f.z+f.x,E=(e.y+e.h/2)*f.z+f.y;(k<0||k>a||E<0||E>n)&&m.centerOn(e.x+e.w/2,e.y+e.h/2)}}},[b,x.setSel]);const le=o.useRef(0);o.useEffect(()=>{const e=T.length+w.length;e>le.current&&m.fitTo(G,64),le.current=e},[T,w,m.fitTo]);const $=async e=>{S(!0),N("");try{await e()}catch(a){re(String(a))}finally{_.current&&S(!1)}},X=()=>i?.id||r.getState().create(s("imageStudio.untitled")),de=async e=>{const a=await Promise.all(e.map(f=>wt(f,f.name,"import")));if(!a.length)return;const n=X();r.getState().update(n,f=>{const k=[...f.images];for(const E of a)k.push({...E,...ct(E.width,E.height,k)});return{...f,images:k}})},Pe=e=>{$(async()=>{const a=X();await yt(a,s(e))})},Q=T.filter(e=>b.includes(e.id)),Te=i&&x.live?M(me(i,x.live)):T,J=e=>{const a=X(),{w:n,h:f}=q(I.current),k=dt(e,s(`imageStudio.new.${e}`),(n/2-m.vp.x)/m.vp.z,(f/2-m.vp.y)/m.vp.z);k.x-=k.w/2,k.y-=k.h/2,r.getState().update(a,E=>ue(E,[...M(E),k])),r.setState({selection:[k.id]}),A(K)},Me=e=>{const{w:a,h:n}=q(I.current);m.setVp(et(m.vp,m.vp.z*e,a/2,n/2))};return t.jsxs("div",{className:"ims",onKeyDownCapture:e=>{if(e.target.closest('input, select, textarea, button, [contenteditable="true"]'))return;const a=e.metaKey||e.ctrlKey,n=e.key.toLowerCase();let f=!0;a&&n==="z"&&i?r.getState().undo(i.id,e.shiftKey):a&&n==="c"?we():a&&n==="v"?B():a&&n==="d"?B(!0):a&&n==="e"?z(!0):!a&&n==="t"?J("text"):!a&&n==="f"?J("frame"):!a&&n==="h"?P(!0):!a&&n==="v"?P(!1):n===" "?D(!0):(n==="escape"&&(P(!1),z(!1)),f=!1),f&&(e.preventDefault(),e.stopPropagation())},onKeyUpCapture:e=>{e.key===" "&&(D(!1),e.preventDefault(),e.stopPropagation())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(D(!1),h.current=null)},children:[t.jsxs("header",{className:"ims-header",children:[t.jsxs("button",{className:"ims-back",title:s("imageStudio.back"),onClick:()=>r.getState().close(),children:[t.jsx(We,{size:15}),t.jsx("span",{children:i?.name})]}),t.jsxs("div",{className:"ims-head-actions",children:[i&&t.jsx("button",{disabled:p,title:s("imageStudio.backup"),"aria-label":s("imageStudio.backup"),onClick:()=>{$(()=>Ct(i))},children:t.jsx(Nt,{size:16})}),t.jsxs("button",{className:"ims-primary",disabled:!V.length||p,onClick:()=>z(!d),children:[t.jsx(R,{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:p,onClick:()=>U.current?.click(),children:[t.jsx(W,{size:15}),t.jsx("span",{children:s("imageStudio.import")})]}),!Le&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"ims-divider"}),t.jsx("button",{disabled:!g,title:s("imageStudio.undo"),"aria-label":s("imageStudio.undo"),onClick:()=>i&&r.getState().undo(i.id),children:t.jsx(Et,{size:15})}),t.jsx("button",{disabled:!v,title:s("imageStudio.redo"),"aria-label":s("imageStudio.redo"),onClick:()=>i&&r.getState().undo(i.id,!0),children:t.jsx(It,{size:15})}),t.jsx("button",{disabled:!H.some(e=>!e.locked&&!e.hidden),title:s("imageStudio.arrange"),"aria-label":s("imageStudio.arrange"),onClick:()=>{if(i){const e=lt(H.filter(a=>!a.locked&&!a.hidden));r.getState().update(i.id,a=>({...a,images:a.images.map(n=>e.find(f=>f.id===n.id)||n)})),m.fitTo(e)}},children:t.jsx(Lt,{size:15})}),t.jsx("button",{disabled:!Q.length,title:s("imageStudio.remove"),"aria-label":s("imageStudio.remove"),onClick:ke,children:t.jsx(ve,{size:15})}),t.jsx("button",{disabled:!Q.length,title:s("imageStudio.duplicate"),"aria-label":s("imageStudio.duplicate"),onClick:()=>B(!0),children:t.jsx(je,{size:15})}),t.jsx("button",{disabled:!Q.length||p,title:s("imageStudio.reference"),"aria-label":s("imageStudio.reference"),onClick:()=>{$(Ce)},children:t.jsx(Z,{size:15})})]}),t.jsx("span",{className:"ims-toolbar-space"}),[[ge,Z,"imageStudio.chat"],[vt,Ye,"imageStudio.layers"],[K,Se,"imageStudio.inspector"]].map(([e,a,n])=>t.jsx("button",{title:s(n),"aria-label":s(n),onClick:()=>A(e),children:t.jsx(a,{size:16})},e))]}),d&&i&&t.jsx(Bt,{board:i,selection:b,onClose:()=>z(!1)}),c&&t.jsxs("div",{className:"ims-error",role:"alert",children:[s("imageStudio.saveError"),t.jsx("button",{onClick:()=>{r.getState().flush()},children:s("imageStudio.retry")})]}),y&&t.jsxs("div",{className:"ims-error",role:"alert",children:[s("imageStudio.error",{error:y}),t.jsx("button",{onClick:()=>{N(""),u(e=>e+1)},children:s("imageStudio.retry")})]}),t.jsxs("div",{ref:I,className:`ims-stage${L||O?" is-panning":""}`,tabIndex:0,onContextMenu:e=>e.stopPropagation(),onPointerDownCapture:e=>{e.button===2||!(L||O)||e.target.closest(".amx-stage-tools, .amx-stage-hud, .amx-stage-minimap")||(e.stopPropagation(),e.preventDefault(),e.currentTarget.focus(),e.currentTarget.setPointerCapture(e.pointerId),h.current={id:e.pointerId,x:e.clientX,y:e.clientY,vx:m.vp.x,vy:m.vp.y})},onPointerMoveCapture:e=>{const a=h.current;if(!a||a.id!==e.pointerId)return;e.stopPropagation();const{u:n}=q(I.current);m.setVp({...m.vp,x:a.vx+(e.clientX-a.x)/n,y:a.vy+(e.clientY-a.y)/n})},onPointerUpCapture:e=>{h.current?.id===e.pointerId&&(e.stopPropagation(),h.current=null)},onPointerCancel:()=>{h.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),p||$(()=>de(Array.from(e.dataTransfer.files)))},children:[t.jsx("div",{className:"ims-grid",style:Ge(m.vp)}),t.jsxs("div",{className:"ims-world",style:{transform:`translate(${m.vp.x}px, ${m.vp.y}px) scale(${m.vp.z})`},children:[V.map(e=>{const a=Te.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}`}${x.sel.includes(e.id)?" is-selected":""}${e.locked?" is-locked":""}`,style:{left:a.x,top:a.y,width:a.w,height:a.h},children:[t.jsx(bt,{item:e}),t.jsx("div",{className:"ims-image-label",children:e.name}),x.sel.includes(e.id)&&!e.locked&&t.jsx("div",{className:"ims-resize","data-resize":"se"})]},e.id)}),w.map(e=>{const a=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(Xe,{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")}),a&&t.jsx("small",{children:s("imageStudio.generation.versionOf",{name:a.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:()=>A(ge),children:s("imageStudio.generation.openChat")}),t.jsx("button",{title:s("imageStudio.generation.dismiss"),"aria-label":s("imageStudio.generation.dismiss"),onClick:()=>r.getState().removeGeneration(i.id,e.id),children:t.jsx(fe,{size:14})})]})]},e.id)}),x.marquee&&t.jsx("div",{className:"ims-marquee",style:{left:x.marquee.x,top:x.marquee.y,width:x.marquee.w,height:x.marquee.h}})]}),!T.length&&!w.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:p,onClick:()=>Pe(`imageStudio.${e}Prompt`),children:[t.jsx("span",{children:s(`imageStudio.${e}`)}),t.jsx(Pt,{size:14})]},e))}),t.jsxs("button",{className:"ims-empty-import",disabled:p,onClick:()=>U.current?.click(),children:[t.jsx(W,{size:16}),s("imageStudio.import")]}),t.jsx("small",{children:s("imageStudio.importLimit")})]}),!w.length&&(l||p)&&t.jsxs("div",{className:"ims-progress amx-stage-tools",role:"status",children:[t.jsx(te,{size:15,className:"ims-spin"}),s(l?"imageStudio.generating":"imageStudio.busy")]}),Ie&&t.jsxs("div",{className:"ims-drop",children:[t.jsx(W,{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":!L,onClick:()=>{P(!1),I.current?.focus()},children:t.jsx(Qe,{size:17})}),t.jsx("button",{title:s("imageStudio.handTool"),"aria-label":s("imageStudio.handTool"),"aria-pressed":L,onClick:()=>{P(!0),I.current?.focus()},children:t.jsx(Tt,{size:17})}),t.jsx("span",{}),[["text",Mt],["rectangle",Je],["ellipse",Ze],["frame",Ot]].map(([e,a])=>t.jsx("button",{title:s(`imageStudio.add.${e}`),"aria-label":s(`imageStudio.add.${e}`),onClick:()=>J(e),children:t.jsx(a,{size:17})},e))]}),ie&&t.jsx(st,{hostRef:I,vp:m.vp,items:G.map(e=>({key:e.id,kind:"card",box:e})),onCenter:m.centerOn}),t.jsx(it,{zoom:m.vp.z,onZoomBy:Me,onFit:()=>m.fitTo(G),snap:se,onSnap:ze,mini:ie,onMini:Ne})]}),t.jsxs("footer",{className:"ims-footer",children:[t.jsx("span",{title:s("imageStudio.hint"),children:s(i?c?"imageStudio.unsaved":j?"imageStudio.saving":"imageStudio.local":"imageStudio.empty")}),i&&t.jsx("input",{"aria-label":s("imageStudio.name"),value:i.name,onChange:e=>r.getState().update(i.id,a=>({...a,name:e.target.value}),!1)}),t.jsx("span",{children:s("imageStudio.itemCount",{count:T.length})})]}),ae&&t.jsx(Ft,{target:ae,board:i,busy:p,onClose:Ee,onImport:()=>U.current?.click(),onExport:()=>z(!0),onInspect:()=>A(K),run:$}),t.jsx("input",{ref:U,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",multiple:!0,hidden:!0,onChange:e=>{const a=Array.from(e.target.files||[]);e.target.value="",$(()=>de(a))}})]})}const qt={version:1,id:"",name:"",updatedAt:0,sessionId:null,images:[],collected:[]};export{xs as ImageStudioView};
1
+ import{u as F,d as o,j as t}from"./index-BYUntVIZ.js";import{G as xe,aF as fe,aN as te,aO as R,V as Z,kQ as Se,bV as je,bI as $e,bJ as Re,bK as ve,a5 as Ae,ar as Be,T as Fe,e3 as Ue,kR as He,a6 as Ve,b2 as _e,u as qe,fK as Ke,fX as q,aL as We,L as Ye,kS as Ge,N as Xe,d$ as Qe,cP as Je,kT as Ze,fT as et}from"./appStore-affnJoin.js";import"./client-BqhpYbYL.js";import{u as tt}from"./gestures-BwPbZDkU.js";import{C as st,a as it}from"./Chrome-amTcZNE4.js";import{b as M,i as be,u as r,a as at,C as nt,r as ce,m as rt,c as ot,d as ye,e as ue,f as me,g as lt,n as dt,h as ct}from"./RightPanel-BRexwQ3W.js";import{s as ut,d as ee,r as mt,h as gt,a as pt,b as Ce,c as we,p as B,e as ke,I as ht,i as xt,f as ft,l as St,u as jt,g as A,S as ge,j as vt,k as K,L as bt,m as yt,n as Ct,o as wt}from"./imageStudio-Axwmd4GW.js";import{L as kt}from"./lock-kffGfeHt.js";import{L as zt}from"./InlineFiles-DKPH5JHz.js";import{U as W}from"./upload-D20PZHXc.js";/* empty css */import{F as Nt,R as It}from"./redo-2-QgiKEg9T.js";import{U as Et}from"./undo-2-yMeXc8Wi.js";import{L as Lt}from"./layout-grid-Hs3eDA07.js";import{A as Pt}from"./arrow-up-right-R4P9Mmxz.js";import{H as Tt}from"./hand-DRu7IJdU.js";import{T as Mt,F as Ot}from"./type-DmIL6FB-.js";import"./nativeDownload-Udrv_tmU.js";import"./ipc-D7yENkjV.js";import"./minus-CfoZ4oxr.js";import"./book-open-CcXCToyx.js";import"./folder-plus-BJKT1Pqg.js";import"./folder-CCZqnwRc.js";import"./pencil-DGiTRzW1.js";const Dt=[["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"}]],$t=xe("clipboard-paste",Dt);const Rt=[["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"}]],At=xe("copy-plus",Rt);function Bt({board:s,selection:i,onClose:j}){const{t:c}=F(),[g,v]=o.useState("png"),[b,w]=o.useState(1),[l,p]=o.useState("transparent"),[S,y]=o.useState(.92),[N,C]=o.useState(!1),[u,d]=o.useState(""),z=ut(s,i),L=z?.bounds,P=Math.round((L?.w||0)*b),O=Math.round((L?.h||0)*b),D=!L||P<1||O<1||P*O>4e7||Math.max(P,O)>16384;return t.jsxs("section",{className:"ims-export ims-panel","aria-label":c("imageStudio.exportOptions"),children:[t.jsxs("div",{className:"ims-section-head",children:[t.jsx("h3",{children:c("imageStudio.exportOptions")}),t.jsx("button",{"aria-label":c("imageStudio.close"),onClick:j,children:t.jsx(fe,{size:15})})]}),t.jsxs("div",{className:"ims-fields",children:[t.jsxs("label",{children:[c("imageStudio.format"),t.jsx("select",{"aria-label":c("imageStudio.format"),value:g,onChange:h=>v(h.target.value),children:["png","jpeg","webp","svg"].map(h=>t.jsx("option",{value:h,children:h.toUpperCase()},h))})]}),t.jsxs("label",{children:[c("imageStudio.scale"),t.jsx("select",{"aria-label":c("imageStudio.scale"),value:b,onChange:h=>w(Number(h.target.value)),children:[.5,1,2,3].map(h=>t.jsxs("option",{value:h,children:[h,"×"]},h))})]}),t.jsxs("label",{children:[c("imageStudio.background"),t.jsxs("select",{"aria-label":c("imageStudio.background"),value:l,onChange:h=>p(h.target.value),children:[t.jsx("option",{value:"transparent",children:c("imageStudio.transparent")}),t.jsx("option",{value:"#ffffff",children:c("imageStudio.white")}),t.jsx("option",{value:"#000000",children:c("imageStudio.black")})]})]}),(g==="jpeg"||g==="webp")&&t.jsxs("label",{children:[c("imageStudio.quality"),t.jsx("input",{"aria-label":c("imageStudio.quality"),type:"range",min:".1",max:"1",step:".05",value:S,onChange:h=>y(Number(h.target.value))})]})]}),t.jsxs("p",{children:[P," × ",O," px · ",c(i.length?"imageStudio.selectedOnly":"imageStudio.allVisible")]}),g==="svg"&&t.jsx("p",{children:c("imageStudio.svgHint")}),g==="jpeg"&&l==="transparent"&&t.jsx("p",{children:c("imageStudio.jpegHint")}),D&&t.jsx("p",{role:"alert",children:c("imageStudio.exportLimit")}),t.jsxs("button",{className:"ims-primary",disabled:N||D,onClick:async()=>{C(!0),d("");try{ee(await mt(s,i,{format:g,scale:b,background:l,quality:S}),`${s.name}.${g==="jpeg"?"jpg":g}`)}catch(h){d(String(h))}finally{C(!1)}},children:[N?t.jsx(te,{className:"ims-spin",size:15}):t.jsx(R,{size:15}),c("imageStudio.download")]}),u&&t.jsx("p",{role:"alert",children:c("imageStudio.error",{error:u})})]})}function Ft({target:s,board:i,busy:j,onClose:c,onImport:g,onExport:v,onInspect:b,run:w}){const{t:l}=F(),p=i?M(i).filter(d=>s.ids.includes(d.id)):[],S=p.length===1&&be(p[0])?p[0]:void 0,y=p.filter(d=>!d.locked).map(d=>d.id),N=/Mac|iPhone|iPad/.test(navigator.platform)?"⌘":"Ctrl+",C=d=>()=>{i&&r.getState().activeId!==i.id||(r.setState({selection:p.map(z=>z.id)}),d())},u=[];return S&&u.push({label:l("imageStudio.downloadImage"),icon:t.jsx(R,{size:14}),disabled:j,run:C(()=>{w(async()=>ee(await pt([S],!0),S.name.replace(/\.[^.]+$/,"")+".png"))})},{label:l("imageStudio.downloadOriginal"),icon:t.jsx(R,{size:14}),run:C(()=>{const d={"image/png":"png","image/jpeg":"jpg","image/webp":"webp","image/gif":"gif"}[S.blob.type]||"png";ee(S.blob,S.name.replace(/\.[^.]+$/,"")+"-original."+d)})}),p.length&&i?u.push({label:l("imageStudio.exportSelection"),icon:t.jsx(R,{size:14}),disabled:j,run:C(v)},{label:l("imageStudio.reference"),icon:t.jsx(Z,{size:14}),separatorBefore:!0,disabled:j||p.length>8,run:C(()=>{w(Ce)})},{label:l("imageStudio.inspector"),icon:t.jsx(Se,{size:14}),run:C(b)},{label:l("imageStudio.copyObjects"),icon:t.jsx(je,{size:14}),shortcut:`${N}C`,separatorBefore:!0,run:C(we)},{label:l("imageStudio.duplicate"),icon:t.jsx(At,{size:14}),shortcut:`${N}D`,run:C(()=>B(!0))},{label:l("imageStudio.layerUp"),icon:t.jsx($e,{size:14}),separatorBefore:!0,disabled:!y.length,run:C(()=>r.getState().update(i.id,d=>ce(d,y,"up")))},{label:l("imageStudio.layerDown"),icon:t.jsx(Re,{size:14}),disabled:!y.length,run:C(()=>r.getState().update(i.id,d=>ce(d,y,"down")))},{label:l(y.length?"imageStudio.lock":"imageStudio.unlock"),icon:y.length?t.jsx(kt,{size:14}):t.jsx(zt,{size:14}),run:C(()=>r.getState().update(i.id,d=>rt(d,z=>s.ids.includes(z.id)?{...z,locked:!!y.length}:z)))},{label:l("imageStudio.remove"),icon:t.jsx(ve,{size:14}),shortcut:"⌫",separatorBefore:!0,danger:!0,disabled:!y.length,run:C(ke)}):u.push({label:l("imageStudio.import"),icon:t.jsx(W,{size:14}),disabled:j,run:g},{label:l("imageStudio.pasteObjects"),icon:t.jsx($t,{size:14}),shortcut:`${N}V`,disabled:!i||!gt(),run:C(()=>B())},{label:l("imageStudio.selectAll"),icon:t.jsx(at,{size:14}),disabled:!i?.images.length&&!i?.elements?.length,run:()=>r.setState({selection:i?M(i).filter(d=>!d.hidden).map(d=>d.id):[]})},{label:l("imageStudio.exportBoard"),icon:t.jsx(R,{size:14}),separatorBefore:!0,disabled:j||!i||!M(i).some(d=>!d.hidden),run:C(v)}),t.jsx(nt,{menu:{x:s.x,y:s.y,items:u},onClose:c,autoFocus:!0})}const pe=4/3,Ut=.05;function Ht({board:s}){const i=ot(s,2);if(!i.length)return t.jsx("span",{className:"ims-cover is-empty",children:t.jsx("span",{className:"ims-cover-in",children:t.jsx(He,{size:22,strokeWidth:1.4})})});const j=i.map(g=>{const v=ye(g);return v.w/v.h}),c=Math.min(1,(1-Ut*(i.length-1))*pe/j.reduce((g,v)=>g+v,0));return t.jsx("span",{className:"ims-cover",children:t.jsx("span",{className:"ims-cover-in",children:i.map((g,v)=>t.jsx("span",{className:"ims-cover-img",style:{width:`${j[v]*c/pe*100}%`,aspectRatio:String(j[v])},children:t.jsx(ht,{image:g})},g.id))})})}function Vt(){const{t:s,locale:i}=F(),j=r(u=>u.boards),[c,g]=o.useState(""),[v,b]=o.useState(!1),[w,l]=o.useState(""),p=o.useRef(null),S=o.useMemo(()=>Object.values(j).sort((u,d)=>d.updatedAt-u.updatedAt),[j]),y=c.trim().toLocaleLowerCase(),N=y?S.filter(u=>u.name.toLocaleLowerCase().includes(y)):S,C=async u=>{b(!0),l("");try{const d=await xt(u),z=r.getState().create(d.name);r.getState().update(z,L=>({...d,id:L.id}))}catch(d){l(String(d))}finally{b(!1)}};return t.jsx("div",{className:"csl-launchpad ims-launch",children:t.jsx("div",{className:"csl-inner",children:t.jsxs("main",{className:"csl-catalog",children:[t.jsxs("header",{className:"csl-catalog-header",children:[t.jsxs("div",{children:[t.jsx("h1",{children:s("imageStudio.projects")}),t.jsx("p",{children:s("imageStudio.launch.subtitle")})]}),t.jsxs("div",{className:"csl-catalog-actions",children:[t.jsxs("button",{type:"button",className:"csl-import",disabled:v,onClick:()=>p.current?.click(),children:[t.jsx(Ae,{size:15}),s("imageStudio.restore")]}),t.jsxs("button",{type:"button",className:"csl-new",onClick:()=>r.getState().create(s("imageStudio.untitled")),children:[t.jsx(Be,{size:16}),s("imageStudio.new")]})]})]}),w&&t.jsx("div",{className:"ims-error",role:"alert",children:s("imageStudio.error",{error:w})}),S.length>0&&t.jsx("div",{className:"csl-catalog-toolbar",children:t.jsxs("label",{className:"csl-search",children:[t.jsx(Fe,{size:15}),t.jsx("input",{type:"search","aria-label":s("imageStudio.launch.search"),placeholder:s("imageStudio.launch.search"),value:c,onChange:u=>g(u.target.value)})]})}),N.length?t.jsx("div",{className:"ims-launch-grid",role:"group","aria-label":s("imageStudio.projects"),children:N.map(u=>t.jsxs("button",{type:"button",className:"ims-launch-card","data-project-id":u.id,onClick:()=>r.getState().open(u.id),children:[t.jsx(Ht,{board:u}),t.jsxs("span",{className:"ims-launch-meta",children:[t.jsx("strong",{children:u.name}),t.jsxs("small",{children:[s("imageStudio.itemCount",{count:M(u).length})," · ",Ue(u.updatedAt,{locale:i})]})]})]},u.id))}):t.jsxs("div",{className:"csl-empty",children:[t.jsx("strong",{children:s(S.length?"imageStudio.launch.noMatch":"imageStudio.launch.empty")}),!S.length&&t.jsx("p",{children:s("imageStudio.launch.emptyHint")})]}),t.jsx("input",{ref:p,type:"file",accept:".json",hidden:!0,onChange:u=>{const d=u.target.files?.[0];u.target.value="",d&&C(d)}})]})})})}const he=[];function xs(s){const{t:i}=F(),j=r(l=>l.ready),c=r(l=>l.error),g=r(l=>l.activeId);o.useEffect(()=>{r.getState().hydrate();const l=()=>{r.getState().flush()},p=S=>{const y=r.getState();(y.saving||y.ready&&y.error)&&(l(),S.preventDefault(),S.returnValue="")};return window.addEventListener("pagehide",l),window.addEventListener("beforeunload",p),()=>{window.removeEventListener("pagehide",l),window.removeEventListener("beforeunload",p),l()}},[]);const v=Ve(l=>l.activeSpaceId==="image-studio")&&_e()==="main",b=!!g,w=o.useRef(!1);return o.useEffect(()=>{!j||!v||(b?ft():St(w.current),w.current=b)},[j,v,b]),j?g?t.jsx(_t,{},g):t.jsx(Vt,{}):t.jsx("div",{className:"ims-panel ims-panel-empty",children:c?t.jsxs(t.Fragment,{children:[t.jsx("p",{role:"alert",children:i("imageStudio.error",{error:c})}),t.jsx("button",{onClick:()=>{r.getState().hydrate()},children:i("imageStudio.retry")})]}):t.jsx(te,{className:"ims-spin"})})}function _t(){const{t:s}=F(),i=r(e=>e.activeId?e.boards[e.activeId]:void 0),j=r(e=>e.saving),c=r(e=>e.error),g=r(e=>i&&e.past[i.id]?.length||0),v=r(e=>i&&e.future[i.id]?.length||0),b=r(e=>e.selection),w=r(e=>i&&e.placeholders[i.id]||he),l=qe(e=>!!(i?.sessionId&&e.runningBySession[i.sessionId])),[p,S]=o.useState(!1),[y,N]=o.useState(""),[C,u]=o.useState(0),[d,z]=o.useState(!1),[L,P]=o.useState(!1),[O,D]=o.useState(!1),h=o.useRef(null),[se,ze]=o.useState(!0),[ie,Ne]=o.useState(!1),[Ie,Y]=o.useState(!1),I=o.useRef(null),U=o.useRef(null),[ae,ne]=o.useState(null),Ee=o.useCallback(()=>{ne(null),I.current?.focus({preventScroll:!0})},[]),m=Ke(I,`image-studio:${i?.id||""}`,void 0,{x:56,y:64,z:1}),H=i?.images||[],T=i?M(i):[],V=T.filter(e=>!e.hidden),Le=!T.length&&!g&&!v,G=[...V,...w],_=o.useRef(!0);o.useEffect(()=>(_.current=!0,()=>{_.current=!1}),[]);const re=o.useCallback(e=>{_.current&&N(e)},[]);jt(i||qt,re,C);const x=tt(I,m,{boxes:()=>new Map(V.map(e=>[e.id,e])),identity:()=>i?.id,commit:e=>{i&&r.getState().update(i.id,a=>me(a,e))},constrain:(e,a)=>{if(a.kind!=="resize")return e;const n=H.find(De=>De.id===a.key),f=e.get(a.key);if(!n||!f)return e;const k=ye(n),E=Math.max(48,f.w),Oe=E*k.h/k.w;return new Map(e).set(a.key,{...f,w:E,h:Oe})},hitKey:e=>e.closest("[data-image-id]")?.dataset.imageId||null,isEditing:e=>!!T.find(a=>a.id===e)?.locked,hitEdge:e=>e.dataset.resize||null,onDelete:e=>{i&&r.getState().update(i.id,a=>ue(a,M(a).filter(n=>n.locked||!e.includes(n.id))))},onDoubleClick:e=>{e&&(r.setState({selection:[e]}),A(K))},onContextMenu:(e,a)=>{const n=e?x.sel.includes(e)?x.sel:[e]:[];x.setSel(n),r.setState({selection:n}),ne({x:a.clientX,y:a.clientY,ids:n})},minW:48,minH:48,repel:!1},se);o.useEffect(()=>x.bind(I.current),[x.bind]),o.useEffect(()=>m.bindWheel(I.current),[m.bindWheel]),o.useEffect(()=>{const e=()=>{D(!1),h.current=null};return window.addEventListener("blur",e),()=>window.removeEventListener("blur",e)},[]);const oe=o.useRef(x.sel);o.useEffect(()=>{oe.current!==x.sel&&(oe.current=x.sel,r.setState({selection:x.sel}))},[x.sel]),o.useEffect(()=>{if(b.join("|")!==x.sel.join("|")){x.setSel(b);const e=T.find(a=>a.id===b[0]);if(e){const{w:a,h:n}=q(I.current),f=m.vpRef.current,k=(e.x+e.w/2)*f.z+f.x,E=(e.y+e.h/2)*f.z+f.y;(k<0||k>a||E<0||E>n)&&m.centerOn(e.x+e.w/2,e.y+e.h/2)}}},[b,x.setSel]);const le=o.useRef(0);o.useEffect(()=>{const e=T.length+w.length;e>le.current&&m.fitTo(G,64),le.current=e},[T,w,m.fitTo]);const $=async e=>{S(!0),N("");try{await e()}catch(a){re(String(a))}finally{_.current&&S(!1)}},X=()=>i?.id||r.getState().create(s("imageStudio.untitled")),de=async e=>{const a=await Promise.all(e.map(f=>wt(f,f.name,"import")));if(!a.length)return;const n=X();r.getState().update(n,f=>{const k=[...f.images];for(const E of a)k.push({...E,...ct(E.width,E.height,k)});return{...f,images:k}})},Pe=e=>{$(async()=>{const a=X();await yt(a,s(e))})},Q=T.filter(e=>b.includes(e.id)),Te=i&&x.live?M(me(i,x.live)):T,J=e=>{const a=X(),{w:n,h:f}=q(I.current),k=dt(e,s(`imageStudio.new.${e}`),(n/2-m.vp.x)/m.vp.z,(f/2-m.vp.y)/m.vp.z);k.x-=k.w/2,k.y-=k.h/2,r.getState().update(a,E=>ue(E,[...M(E),k])),r.setState({selection:[k.id]}),A(K)},Me=e=>{const{w:a,h:n}=q(I.current);m.setVp(et(m.vp,m.vp.z*e,a/2,n/2))};return t.jsxs("div",{className:"ims",onKeyDownCapture:e=>{if(e.target.closest('input, select, textarea, button, [contenteditable="true"]'))return;const a=e.metaKey||e.ctrlKey,n=e.key.toLowerCase();let f=!0;a&&n==="z"&&i?r.getState().undo(i.id,e.shiftKey):a&&n==="c"?we():a&&n==="v"?B():a&&n==="d"?B(!0):a&&n==="e"?z(!0):!a&&n==="t"?J("text"):!a&&n==="f"?J("frame"):!a&&n==="h"?P(!0):!a&&n==="v"?P(!1):n===" "?D(!0):(n==="escape"&&(P(!1),z(!1)),f=!1),f&&(e.preventDefault(),e.stopPropagation())},onKeyUpCapture:e=>{e.key===" "&&(D(!1),e.preventDefault(),e.stopPropagation())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(D(!1),h.current=null)},children:[t.jsxs("header",{className:"ims-header",children:[t.jsxs("button",{className:"ims-back",title:s("imageStudio.back"),onClick:()=>r.getState().close(),children:[t.jsx(We,{size:15}),t.jsx("span",{children:i?.name})]}),t.jsxs("div",{className:"ims-head-actions",children:[i&&t.jsx("button",{disabled:p,title:s("imageStudio.backup"),"aria-label":s("imageStudio.backup"),onClick:()=>{$(()=>Ct(i))},children:t.jsx(Nt,{size:16})}),t.jsxs("button",{className:"ims-primary",disabled:!V.length||p,onClick:()=>z(!d),children:[t.jsx(R,{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:p,onClick:()=>U.current?.click(),children:[t.jsx(W,{size:15}),t.jsx("span",{children:s("imageStudio.import")})]}),!Le&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"ims-divider"}),t.jsx("button",{disabled:!g,title:s("imageStudio.undo"),"aria-label":s("imageStudio.undo"),onClick:()=>i&&r.getState().undo(i.id),children:t.jsx(Et,{size:15})}),t.jsx("button",{disabled:!v,title:s("imageStudio.redo"),"aria-label":s("imageStudio.redo"),onClick:()=>i&&r.getState().undo(i.id,!0),children:t.jsx(It,{size:15})}),t.jsx("button",{disabled:!H.some(e=>!e.locked&&!e.hidden),title:s("imageStudio.arrange"),"aria-label":s("imageStudio.arrange"),onClick:()=>{if(i){const e=lt(H.filter(a=>!a.locked&&!a.hidden));r.getState().update(i.id,a=>({...a,images:a.images.map(n=>e.find(f=>f.id===n.id)||n)})),m.fitTo(e)}},children:t.jsx(Lt,{size:15})}),t.jsx("button",{disabled:!Q.length,title:s("imageStudio.remove"),"aria-label":s("imageStudio.remove"),onClick:ke,children:t.jsx(ve,{size:15})}),t.jsx("button",{disabled:!Q.length,title:s("imageStudio.duplicate"),"aria-label":s("imageStudio.duplicate"),onClick:()=>B(!0),children:t.jsx(je,{size:15})}),t.jsx("button",{disabled:!Q.length||p,title:s("imageStudio.reference"),"aria-label":s("imageStudio.reference"),onClick:()=>{$(Ce)},children:t.jsx(Z,{size:15})})]}),t.jsx("span",{className:"ims-toolbar-space"}),[[ge,Z,"imageStudio.chat"],[vt,Ye,"imageStudio.layers"],[K,Se,"imageStudio.inspector"]].map(([e,a,n])=>t.jsx("button",{title:s(n),"aria-label":s(n),onClick:()=>A(e),children:t.jsx(a,{size:16})},e))]}),d&&i&&t.jsx(Bt,{board:i,selection:b,onClose:()=>z(!1)}),c&&t.jsxs("div",{className:"ims-error",role:"alert",children:[s("imageStudio.saveError"),t.jsx("button",{onClick:()=>{r.getState().flush()},children:s("imageStudio.retry")})]}),y&&t.jsxs("div",{className:"ims-error",role:"alert",children:[s("imageStudio.error",{error:y}),t.jsx("button",{onClick:()=>{N(""),u(e=>e+1)},children:s("imageStudio.retry")})]}),t.jsxs("div",{ref:I,className:`ims-stage${L||O?" is-panning":""}`,tabIndex:0,onContextMenu:e=>e.stopPropagation(),onPointerDownCapture:e=>{e.button===2||!(L||O)||e.target.closest(".amx-stage-tools, .amx-stage-hud, .amx-stage-minimap")||(e.stopPropagation(),e.preventDefault(),e.currentTarget.focus(),e.currentTarget.setPointerCapture(e.pointerId),h.current={id:e.pointerId,x:e.clientX,y:e.clientY,vx:m.vp.x,vy:m.vp.y})},onPointerMoveCapture:e=>{const a=h.current;if(!a||a.id!==e.pointerId)return;e.stopPropagation();const{u:n}=q(I.current);m.setVp({...m.vp,x:a.vx+(e.clientX-a.x)/n,y:a.vy+(e.clientY-a.y)/n})},onPointerUpCapture:e=>{h.current?.id===e.pointerId&&(e.stopPropagation(),h.current=null)},onPointerCancel:()=>{h.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),p||$(()=>de(Array.from(e.dataTransfer.files)))},children:[t.jsx("div",{className:"ims-grid",style:Ge(m.vp)}),t.jsxs("div",{className:"ims-world",style:{transform:`translate(${m.vp.x}px, ${m.vp.y}px) scale(${m.vp.z})`},children:[V.map(e=>{const a=Te.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}`}${x.sel.includes(e.id)?" is-selected":""}${e.locked?" is-locked":""}`,style:{left:a.x,top:a.y,width:a.w,height:a.h},children:[t.jsx(bt,{item:e}),t.jsx("div",{className:"ims-image-label",children:e.name}),x.sel.includes(e.id)&&!e.locked&&t.jsx("div",{className:"ims-resize","data-resize":"se"})]},e.id)}),w.map(e=>{const a=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(Xe,{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")}),a&&t.jsx("small",{children:s("imageStudio.generation.versionOf",{name:a.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:()=>A(ge),children:s("imageStudio.generation.openChat")}),t.jsx("button",{title:s("imageStudio.generation.dismiss"),"aria-label":s("imageStudio.generation.dismiss"),onClick:()=>r.getState().removeGeneration(i.id,e.id),children:t.jsx(fe,{size:14})})]})]},e.id)}),x.marquee&&t.jsx("div",{className:"ims-marquee",style:{left:x.marquee.x,top:x.marquee.y,width:x.marquee.w,height:x.marquee.h}})]}),!T.length&&!w.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:p,onClick:()=>Pe(`imageStudio.${e}Prompt`),children:[t.jsx("span",{children:s(`imageStudio.${e}`)}),t.jsx(Pt,{size:14})]},e))}),t.jsxs("button",{className:"ims-empty-import",disabled:p,onClick:()=>U.current?.click(),children:[t.jsx(W,{size:16}),s("imageStudio.import")]}),t.jsx("small",{children:s("imageStudio.importLimit")})]}),!w.length&&(l||p)&&t.jsxs("div",{className:"ims-progress amx-stage-tools",role:"status",children:[t.jsx(te,{size:15,className:"ims-spin"}),s(l?"imageStudio.generating":"imageStudio.busy")]}),Ie&&t.jsxs("div",{className:"ims-drop",children:[t.jsx(W,{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":!L,onClick:()=>{P(!1),I.current?.focus()},children:t.jsx(Qe,{size:17})}),t.jsx("button",{title:s("imageStudio.handTool"),"aria-label":s("imageStudio.handTool"),"aria-pressed":L,onClick:()=>{P(!0),I.current?.focus()},children:t.jsx(Tt,{size:17})}),t.jsx("span",{}),[["text",Mt],["rectangle",Je],["ellipse",Ze],["frame",Ot]].map(([e,a])=>t.jsx("button",{title:s(`imageStudio.add.${e}`),"aria-label":s(`imageStudio.add.${e}`),onClick:()=>J(e),children:t.jsx(a,{size:17})},e))]}),ie&&t.jsx(st,{hostRef:I,vp:m.vp,items:G.map(e=>({key:e.id,kind:"card",box:e})),onCenter:m.centerOn}),t.jsx(it,{zoom:m.vp.z,onZoomBy:Me,onFit:()=>m.fitTo(G),snap:se,onSnap:ze,mini:ie,onMini:Ne})]}),t.jsxs("footer",{className:"ims-footer",children:[t.jsx("span",{title:s("imageStudio.hint"),children:s(i?c?"imageStudio.unsaved":j?"imageStudio.saving":"imageStudio.local":"imageStudio.empty")}),i&&t.jsx("input",{"aria-label":s("imageStudio.name"),value:i.name,onChange:e=>r.getState().update(i.id,a=>({...a,name:e.target.value}),!1)}),t.jsx("span",{children:s("imageStudio.itemCount",{count:T.length})})]}),ae&&t.jsx(Ft,{target:ae,board:i,busy:p,onClose:Ee,onImport:()=>U.current?.click(),onExport:()=>z(!0),onInspect:()=>A(K),run:$}),t.jsx("input",{ref:U,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",multiple:!0,hidden:!0,onChange:e=>{const a=Array.from(e.target.files||[]);e.target.value="",$(()=>de(a))}})]})}const qt={version:1,id:"",name:"",updatedAt:0,sessionId:null,images:[],collected:[]};export{xs as ImageStudioView};
@@ -1 +1 @@
1
- import{G as z,mW as x,ly as L,cj as w,lA as p,lz as k,mX as U,k$ as f}from"./appStore-CidPWYa0.js";import{j as s,d as y}from"./index-B5UW6SaE.js";import{n as T}from"./nativeDownload-B3JGkABw.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"}]],O=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"?x(e):null,l=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 k(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(l)}:void 0:()=>{L(w(e),e,t.path).catch(l)}:void 0}}const v=({f:t,onClick:n})=>{const e=f(t.mime||"",t.name);return s.jsxs("button",{className:"inline-file-card",title:t.name,onClick:n,children:[s.jsx(e,{size:15}),s.jsx("span",{className:"inline-file-name",children:t.name})]})},W=({f:t,cfg:n,sessionId:e,execMode:i,onClick:o})=>{e=t.sourceSessionId||e;const l=t.dataUrl||(t.path&&i!=="host"?U(w(e),e,t.path):null),[a,r]=y.useState(l),[c,h]=y.useState(!1),d=y.useRef(null);return y.useEffect(()=>{if(h(!1),l){r(l);return}let u=!1;return(async()=>{if(!t.path)return;const j=i==="host"?x(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 k(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?s.jsx(v,{f:t,onClick:o}):a?s.jsx("img",{className:"inline-file-img",src:a,alt:t.name,title:t.name,onClick:o,draggable:!1,onError:()=>h(!0)}):null},$=({files:t,cfg:n,sessionId:e,execMode:i,onOpenPreview:o})=>{if(!t.length)return null;const l=a=>o?.(E(a,n,e,i));return s.jsx("div",{className:"inline-file-grid",children:t.map((a,r)=>R(a)?s.jsx(W,{f:a,cfg:n,sessionId:e,execMode:i,onClick:()=>l(a)},r):s.jsx(v,{f:a,onClick:()=>l(a)},r))})};export{$ as I,O as L,E as t};
1
+ import{G as z,mX as x,ly as L,cj as w,lA as p,lz as k,mY as U,k$ as f}from"./appStore-affnJoin.js";import{j as s,d as y}from"./index-BYUntVIZ.js";import{n as T}from"./nativeDownload-Udrv_tmU.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"}]],W=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"?x(e):null,l=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 k(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(l)}:void 0:()=>{L(w(e),e,t.path).catch(l)}:void 0}}const v=({f:t,onClick:n})=>{const e=f(t.mime||"",t.name);return s.jsxs("button",{className:"inline-file-card",title:t.name,onClick:n,children:[s.jsx(e,{size:15}),s.jsx("span",{className:"inline-file-name",children:t.name})]})},A=({f:t,cfg:n,sessionId:e,execMode:i,onClick:o})=>{e=t.sourceSessionId||e;const l=t.dataUrl||(t.path&&i!=="host"?U(w(e),e,t.path):null),[a,r]=y.useState(l),[c,h]=y.useState(!1),d=y.useRef(null);return y.useEffect(()=>{if(h(!1),l){r(l);return}let u=!1;return(async()=>{if(!t.path)return;const j=i==="host"?x(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 k(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?s.jsx(v,{f:t,onClick:o}):a?s.jsx("img",{className:"inline-file-img",src:a,alt:t.name,title:t.name,onClick:o,draggable:!1,onError:()=>h(!0)}):null},$=({files:t,cfg:n,sessionId:e,execMode:i,onOpenPreview:o})=>{if(!t.length)return null;const l=a=>o?.(E(a,n,e,i));return s.jsx("div",{className:"inline-file-grid",children:t.map((a,r)=>R(a)?s.jsx(A,{f:a,cfg:n,sessionId:e,execMode:i,onClick:()=>l(a)},r):s.jsx(v,{f:a,onClick:()=>l(a)},r))})};export{$ as I,W as L,E as t};