@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,53 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CodeView-CB4kG7Y6.js","./index-B5UW6SaE.js","./appStore-CidPWYa0.js","./nativeDownload-B3JGkABw.js","./ipc-CNlIRMtU.js","./client-CPUljePZ.js","./appStore-DeaC1U32.css","./create-C19zqt5N.js","./create-BgE3edmZ.css","./docx-preview-Bi7wekSM.js","./jszip.min-tyV0GaJg.js"])))=>i.map(i=>d[i]);
2
- import{R as Xs,j as e,d as l,t as we,r as te,u as U,_ as gt,x as ea,E as Zs,F as ta,G as na,H as sa,I as oa,J as eo,K as ia,M as aa}from"./index-B5UW6SaE.js";import{N as to,a7 as Ge,a8 as ra,a9 as la,aa as ca,ab as no,ac as da,ad as ua,ae as ha,af as pa,ag as ma,H as fa,a4 as ga,a5 as va,a6 as ya,C as ja}from"./RunLocationPicker-M1UoJyjf.js";import{G as ae,ab as vn,q as He,b2 as so,u as M,cj as de,bC as oo,cp as xa,i8 as wa,kV as ba,kW as rs,kX as ka,kY as Sa,kZ as za,d0 as Na,k_ as on,b as rt,jZ as Ca,jp as Pa,k$ as Ht,l0 as io,l1 as Lt,l2 as Wt,l3 as Vt,aO as Be,cC as Ke,l4 as ao,l5 as Ta,ct as Gt,aP as vt,iV as ro,fP as Ln,aF as lt,iN as Ea,iO as Aa,aN as Ye,gl as Ra,U as Ma,bK as Ct,g_ as Ia,t as Ne,l6 as _a,gZ as $a,gY as Da,hE as Fa,l7 as La,i3 as Oa,io as lo,kv as qa,l8 as Ba,bo as Ua,c6 as xe,gF as On,gG as co,gw as uo,h2 as ho,a2 as Ha,gB as Wa,hd as Va,iX as Ga,c8 as po,_ as qn,l9 as Ka,la as Ya,lb as Ja,lc as Qa,az as yn,aC as jn,cW as Kt,d8 as Xa,cX as Za,T as mo,hP as er,ld as tr,le as nr,aK as Bn,lf as yt,aE as pt,bV as st,a3 as fo,at as ct,ar as go,lg as sr,hX as Un,lh as Yt,cP as vo,ce as yo,N as ot,b1 as or,li as ir,lj as ar,lk as rr,ay as xn,ll as lr,lm as ls,cL as Pt,iC as cs,ln as cr,lo as dr,lp as ur,cq as hr,fD as pr,eq as mr,lq as jo,lr as fr,aJ as gr,ls as vr,gH as yr,he as jr,c4 as xr,lt as wr,a5 as jt,X as br,lu as Jt,lv as kr,lw as xo,lx as Sr,ly as zr,lz as Nr,lA as Cr,hR as an,lB as ds,lC as wo,lD as us,lE as Pr,gf as Hn,j as Tr,lF as Er,fi as Ar,lG as hs,lH as bo,i6 as Rr,lI as ko,fw as So,h as Mr,lJ as Ir,lK as _r,ih as Le,gs as zo,lL as $r,ig as wn,aT as No,I as Co,lM as Dr,lN as Fr,kt as Lr,lO as Or,lP as qr,lQ as Br,bq as Ur,is as bn,ir as Hr,iv as rn,cM as Wr,lR as Vr,it as Gr,lS as Kr,lT as Yr,er as Jr,lU as kn,lV as Po,lW as To,lX as Eo,lY as Qr,lZ as Xr,ea as ps,ew as Zr,l_ as el,l$ as tl,m0 as nl,a6 as sl,ia as ol,kG as il,hA as al,kH as rl,kI as ll,ib as cl,ii as dl,i7 as ul,m1 as hl,m2 as pl,m3 as ml,bD as fl,bt as gl,g as vl,bJ as yl,hI as ms,m4 as jl,m5 as xl,ah as wl,m6 as fs,m7 as bl,m8 as kl,m9 as Sl}from"./appStore-CidPWYa0.js";import{D as Wn}from"./create-C19zqt5N.js";import{p as zl}from"./pdf.worker.min-CGb3BKV9.js";import{m as Nl,i as Cl,g as Ao,n as Qt,r as Vn,t as Ro,j as Mo,C as Pl,A as Tl}from"./phoneList-DrxIwJxQ.js";import{C as Ot}from"./code-xml-n9mgGgkv.js";import{Z as Io,a as _o}from"./zoom-in-BcuPvIYd.js";import{I as El,t as Al}from"./InlineFiles-BIfsx3R-.js";import{c as Rl}from"./client-CPUljePZ.js";import{c as $o,n as ve}from"./nativeDownload-B3JGkABw.js";import{B as gs}from"./book-open-CBeNsIpo.js";import{U as Et}from"./undo-2-BOUt5qks.js";import{L as Ml}from"./layout-grid-DFmwM9NU.js";import{A as Do}from"./arrow-up-right-KPFbRA41.js";import{R as At}from"./rotate-ccw-xgT_0UN9.js";import{M as Il}from"./minus-BBdfT_sc.js";import{S as _l,s as $l,a as vs,F as Dl}from"./SketchCard-DAD0jR0i.js";import{T as Fl}from"./terminal-DPZazOQ2.js";import{C as Xt}from"./circle-x-Szwop5L_.js";import{C as Gn}from"./circle-question-mark-M8QUJJYk.js";import{P as xt}from"./pencil-CJsJD7M_.js";import{n as Mt,u as Sn,b as Ll}from"./codeStudioStore-DXMQwRzG.js";import{M as Fo}from"./message-square-plus-3wFslIMY.js";import{F as Ol}from"./FloatingToc-ldOYWe2C.js";import{P as ql}from"./MarkdownBlock-wYEaBBOr.js";import{C as Lo,j as Nt}from"./RightPanel-BgSeCLnw.js";import"./pageChrome-DFi9zs6F.js";import{F as Zt}from"./folder-CoOsfQ64.js";import{F as ln}from"./folder-plus-d5MwIMlf.js";import{e as Bl}from"./ipc-CNlIRMtU.js";const Ul=[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]],Hl=ae("arrow-left-right",Ul);const Wl=[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.35 2.69A10 10 0 0 1 21.3 15.65",key:"1pfsoa"}],["path",{d:"M19.08 19.08A10 10 0 1 1 4.92 4.92",key:"1ablyi"}]],Vl=ae("circle-off",Wl);const Gl=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]],zn=ae("circle-pause",Gl);const Kl=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],Yl=ae("circle-stop",Kl);const Jl=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],Ql=ae("file-code-corner",Jl);const Xl=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Ue=ae("file-exclamation-point",Xl);const Zl=[["path",{d:"M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35",key:"17jvcc"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M14 19h6",key:"bvotb8"}],["path",{d:"M17 16v6",key:"18yu1i"}]],cn=ae("file-plus-corner",Zl);const ec=[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]],ys=ae("folder-input",ec);const tc=[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]],Nn=ae("folder-search",tc);const nc=[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]],sc=ae("git-branch",nc);const oc=[["path",{d:"M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21",key:"9csbqa"}],["path",{d:"m14 19.5 3-3 3 3",key:"9vmjn0"}],["path",{d:"M17 22v-5.5",key:"1aa6fl"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],ic=ae("image-up",oc);const ac=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],Oo=ae("maximize",ac);const rc=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],lc=ae("message-circle-question-mark",rc);const cc=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],Kn=ae("minimize-2",cc);const dc=[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],uc=ae("power-off",dc);const hc=[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]],pc=ae("quote",hc);const mc=[["path",{d:"M14 9.536V7a4 4 0 0 1 4-4h1.5a.5.5 0 0 1 .5.5V5a4 4 0 0 1-4 4 4 4 0 0 0-4 4c0 2 1 3 1 5a5 5 0 0 1-1 3",key:"139s4v"}],["path",{d:"M4 9a5 5 0 0 1 8 4 5 5 0 0 1-8-4",key:"1dlkgp"}],["path",{d:"M5 21h14",key:"11awu3"}]],qo=ae("sprout",mc);const fc=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],gc=ae("square-check-big",fc);const vc=[["path",{d:"M3 5h18",key:"1u36vt"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 19h18",key:"awlh7x"}]],Bo=ae("text-align-justify",vc);const yc=[["path",{d:"m16 16-3 3 3 3",key:"117b85"}],["path",{d:"M3 12h14.5a1 1 0 0 1 0 7H13",key:"18xa6z"}],["path",{d:"M3 19h6",key:"1ygdsz"}],["path",{d:"M3 5h18",key:"1u36vt"}]],Uo=ae("text-wrap",yc);const jc=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],xc=ae("timer",jc);const wc=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Ho=ae("triangle-alert",wc);const bc=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],kc=ae("volume-2",bc);const Sc=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Cn=ae("wifi-off",Sc);class zc extends Xs.Component{state={error:null};static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,s){console.error("[tangu] render crash:",n,s?.componentStack)}render(){const{error:n}=this.state;if(!n)return this.props.children;const s=(document.documentElement.lang||"").startsWith("zh"),o=`${n.message}
3
-
4
- ${n.stack||""}`.trim();return e.jsxs("div",{"data-error-boundary":!0,style:{padding:24,maxWidth:720,margin:"0 auto",overflow:"auto",height:"100%",boxSizing:"border-box"},children:[e.jsx("h3",{style:{margin:"8px 0"},children:s?"界面渲染出错":"Something broke while rendering"}),e.jsx("p",{style:{opacity:.8,fontSize:"var(--ui-font-body, 13px)",margin:"4px 0 12px"},children:s?"这一部分崩溃了。可重试、或切换/新建会话避开它;请把下面的错误发给开发者。":"This view crashed. Retry, or switch/start a new chat to avoid it; send the error below to the developer."}),e.jsx("pre",{style:{whiteSpace:"pre-wrap",fontSize:12,background:"var(--danger-light)",color:"var(--danger)",padding:12,borderRadius:8,maxHeight:280,overflow:"auto"},children:o}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:12},children:[e.jsx("button",{style:{padding:"6px 12px"},onClick:()=>this.setState({error:null}),children:s?"重试":"Retry"}),e.jsx("button",{style:{padding:"6px 12px"},onClick:()=>{try{navigator.clipboard.writeText(o)}catch{}},children:s?"复制错误":"Copy error"}),e.jsx("button",{style:{padding:"6px 12px"},onClick:()=>location.reload(),children:s?"重新加载":"Reload"})]})]})}}function Yn(t,n){vn("agents"),He.getState().openView("agent-profile",{reuseKey:"primary",agentSlug:t,creating:!1,...n?{section:n,sectionAt:Date.now()}:{}},"main")}const Jn="forsion_chat_wait_details",Pn="forsion:chat-wait-details";function Nc(){try{return localStorage.getItem(Jn)==="1"}catch{return!1}}function xp(t){try{localStorage.setItem(Jn,t?"1":"0")}catch{}try{window.dispatchEvent(new Event(Pn))}catch{}}function Cc(t){if(typeof window>"u")return()=>{};const n=s=>{s.key===Jn&&t()};return window.addEventListener(Pn,t),window.addEventListener("storage",n),()=>{window.removeEventListener(Pn,t),window.removeEventListener("storage",n)}}function Pc(){return l.useSyncExternalStore(Cc,Nc,()=>!1)}const Qn="forsion_chat_avatars";function Tc(){try{return localStorage.getItem(Qn)!=="0"}catch{return!0}}function Tn(){Tc()?delete document.documentElement.dataset.chatAvatars:document.documentElement.dataset.chatAvatars="off"}function wp(t){try{localStorage.setItem(Qn,t?"1":"0")}catch{}Tn()}typeof document<"u"&&(Tn(),window.addEventListener("storage",t=>{t.key===Qn&&Tn()}));te({"btw.title":{zh:"顺便问",en:"By the way"},"btw.windowTitle":{zh:"顺便问 · {title}",en:"By the way · {title}"},"btw.context":{zh:"当前对话",en:"Conversation"},"btw.hint":{zh:"带着本会话上下文提问,不会加入对话,也不打断正在跑的任务",en:"Uses this conversation as context. Not added to it, and never interrupts a running task."},"btw.empty":{zh:"问点与当前对话有关的事:概念、代码、刚才那步为什么这么做……",en:"Ask about anything in this conversation: a concept, some code, why a step was taken…"},"btw.placeholder":{zh:"顺便问点什么…",en:"Ask a side question…"},"btw.defaultQuestion":{zh:"解释一下这段",en:"Explain this"},"btw.send":{zh:"发送",en:"Send"},"btw.stop":{zh:"停止",en:"Stop"},"btw.clear":{zh:"清空旁聊",en:"Clear side chat"},"btw.copy":{zh:"复制",en:"Copy"},"btw.copied":{zh:"已复制",en:"Copied"},"btw.quoteToChat":{zh:"引用到对话",en:"Quote in chat"},"btw.quoted":{zh:"已引用到输入框",en:"Quoted in the chat box"},"btw.removeQuote":{zh:"移除引用",en:"Remove quote"},"btw.thinking":{zh:"思考中…",en:"Thinking…"},"btw.stopped":{zh:"已停止",en:"Stopped"},"btw.noTools":{zh:"旁聊不能用工具,上面提到的操作都没有执行。",en:"Side chats have no tools. Nothing mentioned above was run."},"btw.errCut":{zh:"连接中断,回答不完整",en:"The connection dropped before the answer finished"},"btw.errUnsupported":{zh:"当前引擎还不支持旁聊,请更新 Forsion",en:"This engine does not support side questions yet. Update Forsion."},"btw.close":{zh:"关闭",en:"Close"},"btw.selectionAction":{zh:"顺便问",en:"Ask aside"},"btw.cmd":{zh:"顺便问(旁聊)",en:"Ask a side question"}});const Xe=new Map,js=new Set;let Ec=0;function bp(t){return js.has(t.nonce)?!1:(js.add(t.nonce),!0)}function kp(t,n){return!!t&&(!t.scope||t.scope===n)}function Sp(t){const n=i=>typeof t?.[i]=="string"&&t[i]?t[i]:void 0,s=n("sessionId"),o=n("nonce");return s&&o?{sessionId:s,nonce:o,scope:n("scope"),title:n("title"),quote:n("quote"),question:n("question"),modelId:n("modelId")}:null}const Ac=$o((t,n)=>({threads:{},webOpen:null,ask:async(s,o,i,a)=>{if(!o.trim()||Xe.has(s))return;const r=n().threads[s]||[],d=`btw-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`,u=j=>t(y=>({threads:{...y.threads,[s]:(y.threads[s]||[]).map(p=>p.id===d?{...p,...j(p)}:p)}}));t(j=>({threads:{...j.threads,[s]:[...r,{id:d,question:o,quote:i,answer:"",status:"streaming"}]}}));const v=new AbortController;Xe.set(s,v);const f=r.filter(j=>j.status==="done"&&j.answer).slice(-20).map(j=>({question:j.question,quote:j.quote,answer:j.answer}));try{await Rc(s,{question:o,quote:i,thread:f,model_id:a||void 0},j=>{j.type==="delta"?u(y=>({answer:y.answer+String(j.text??"")})):j.type==="done"?u(y=>({answer:String(j.content||y.answer),status:"done",toolCallText:!!j.toolCallText})):j.type==="error"&&u(()=>({status:"error",error:xs(String(j.error||""))}))},v.signal),u(j=>j.status==="streaming"?{status:"error",error:we("btw.errCut")}:{})}catch(j){u(y=>y.status!=="streaming"?{}:v.signal.aborted?{status:"stopped"}:{status:"error",error:xs(String(j?.message||j))})}finally{Xe.get(s)===v&&Xe.delete(s)}},stop:s=>Xe.get(s)?.abort(),clear:s=>{Xe.get(s)?.abort(),Xe.delete(s),t(o=>({threads:{...o.threads,[s]:[]}}))},closeWeb:()=>t({webOpen:null})})),xs=t=>/token_quota_exceeded/i.test(t)?we("chat.err.quota"):t;async function Rc(t,n,s,o){const i=de(t);let a;try{a=await oo(i,`/agent/sessions/${encodeURIComponent(t)}/aside`,{method:"POST",signal:o,body:JSON.stringify({...n,app_id:wa,client:xa()})})}catch(v){if(i.via==="unit"&&!o.aborted){const f=ba(v);throw new Error(rs(i,f,v?.code)||String(v?.message||v))}throw v}if(!a.ok||!a.body){const v=await a.text().catch(()=>"");let f="",j,y=null;try{y=JSON.parse(v),f=String(y?.detail||"");const p=y?.code;j=typeof p=="string"?p:void 0}catch{}if(i.via==="unit"){const p=ka(a.status,{code:j});Sa(i.key,p,za(y));const w=rs(i,p,j,y);if(w&&p!=="fatal")throw new Error(w)}throw new Error(f||(a.status===404?we("btw.errUnsupported"):`HTTP ${a.status}`))}const r=a.body.getReader(),d=new TextDecoder;let u="";for(;;){const{done:v,value:f}=await r.read();if(v)break;u+=d.decode(f,{stream:!0});const j=u.split(`
5
- `);u=j.pop()||"";for(const y of j)if(y.startsWith("data:"))try{s(JSON.parse(y.slice(5)))}catch{}}}function ws(t){const n=so()==="main"?M.getState().activeId:null,s={...t,title:t.title||void 0,scope:n,nonce:`${Date.now().toString(36)}-${++Ec}`},o=window.tangu;if(o?.openFloatingPanel){o.openFloatingPanel({id:`btw:${t.sessionId}`,title:we("btw.windowTitle",{title:t.title||we("btw.title")}),builtin:"btw",params:{...s},...n?{sessionId:n}:{}});return}Ac.setState({webOpen:s})}function zp(t){const n=t.trim().slice(0,2e4);if(!n)return;if(so()!=="main"&&window.tangu?.requestMainAction){window.tangu.requestMainAction("chat-quote",n);return}const s=He.getState(),o=s.rightVisible&&s.rightTabs.some(i=>i.type==="chat-panel"&&i.active);M.getState().setPendingChatQuote(o?"chat-panel":"chat",n),o||s.openView("chat",{followActive:!0,reuseKey:"primary"},"main")}const Wo="forsion.noteRemind.fired",Mc=168*36e5,Ic=24*36e5;function _c(){try{const t=JSON.parse(localStorage.getItem(Wo)||"{}"),n=Date.now();return Object.fromEntries(Object.entries(t).filter(([,s])=>n-s<Mc))}catch{return{}}}const Vo=(t,n)=>`${t}|${n.path}|${n.remind}|${n.text}`;function $c(t,n,s,o){return t.filter(i=>{if(!i.remind)return!1;const a=Pa(i.remind.split("/")[0]).getTime();return a<=n&&n-a<Ic&&!s[Vo(o,i)]})}const Dc=new Set(["harness_candidates","harness_adopted","harness_confirm","project_memory_candidates","project_memory_compacted"]);function Fc(t,n){const s=n?t.filter(i=>Dc.has(i.action)&&!n.has(i.id)):[],o=new Set(n??[]);for(const i of t)o.add(i.id);return{fresh:s,seen:o}}const Re=(t,n)=>M.getState().tr(t,n);let bs=!1;function Np(){if(bs)return;bs=!0;const t={};window.amadeusSync?.onStatus?.(r=>{const d=r,u=d.binding?`entry:${d.binding}`:`mirror:${d.side??"own"}`,v=t[u];t[u]=d.state,!(!d.enabled||v===d.state)&&(d.state==="error"||d.state==="auth-required"?ve({event:"sync.error",level:"error",text:Re("ntf.syncError",{e:d.error?Na(d.error):d.state}),dedupeKey:`sync.error:${u}`}):v==="syncing"&&d.state==="idle"&&ve({event:"sync.doneOnline",level:"success",text:Re("ntf.syncDone"),dedupeKey:"sync.done"}))});let n=!1;window.remoteSync?.onStatus?.(r=>{if(n&&!r.running&&r.lastReport){const d=r.lastReport;if(!d.ok||d.errors?.length)ve({event:"sync.error",level:"error",text:Re("ntf.remoteSyncFail",{e:d.errors?.[0]||""}),dedupeKey:"remotesync.error"});else{d.conflicts>0&&ve({event:"sync.error",level:"warning",text:Re("ntf.remoteSyncConflicts",{n:d.conflicts}),dedupeKey:"remotesync.conflict"}),d.pendingDeletions>0&&ve({event:"sync.error",level:"warning",text:Re("ntf.remoteSyncPendingDel",{n:d.pendingDeletions}),dedupeKey:"remotesync.pendingDel",action:{label:Re("ntf.actionReview"),run:()=>M.getState().openSettings("sync")}});const u=d.pushed+d.pulled+d.deletedLocal+d.deletedRemote;u>0&&ve({event:"sync.done",level:"success",text:Re("ntf.remoteSyncDone",{n:u}),dedupeKey:"remotesync.done"})}}n=r.running});let s=M.getState().runningBySession;M.subscribe(r=>{if(r.runningBySession===s)return;const d=s;s=r.runningBySession;for(const u of Object.keys(d)){if(r.runningBySession[u]||u===r.activeId)continue;const f=[...r.messagesBySession[u]||[]].reverse().find(p=>p.role==="assistant");if(f?.status!=="done"&&f?.status!=="error")continue;const j=f.status==="error",y=r.sessions.find(p=>p.id===u)||r.archivedSessions.find(p=>p.id===u);ve({event:"agent.done",level:j?"error":"success",text:Re(j?"ntf.agentFail":"ntf.agentDone",{name:y?.title||"Agent"})})}});let o=_c();const i=()=>{const r=Date.now(),d=rt.getState().vaultRoot??"";for(const u of $c(on.getState().marks,r,o,d)){o={...o,[Vo(d,u)]:r};try{localStorage.setItem(Wo,JSON.stringify(o))}catch{}ve({event:"note.reminder",level:"info",sticky:!0,title:Re("ntf.noteReminder",{src:u.title}),text:u.text,action:{label:Re("ntf.view"),run:()=>{Ca(u.path,u.heading)}}})}},a=async()=>{await on.getState().load(),i()};on.subscribe(i),a(),setInterval(()=>{a()},6e4)}const Lc=Ra(()=>gt(()=>import("./CodeView-CB4kG7Y6.js").then(t=>t.K),__vite__mapDeps([0,1,2,3,4,5,6,7,8]),import.meta.url)),Go=({path:t,text:n,title:s,nonce:o})=>{const i=!!(t?window.tangu?.codePreviewServePath:window.tangu?.codePreviewServeHtml),[a,r]=l.useState(null),[d,u]=l.useState(!1);if(l.useEffect(()=>{if(!i)return;let v=!1;return u(!1),r(null),(t?window.tangu.codePreviewServePath(t):window.tangu.codePreviewServeHtml(n)).then(j=>{v||r(j.url)}).catch(()=>{v||u(!0)}),()=>{v=!0}},[t,i,t?"":n]),i&&!d){if(!a)return e.jsx("div",{className:"wsfile-frame"});const v=o?`${a}?n=${o}`:a;return e.jsx(Ea,{className:"wsfile-frame",src:v,partition:Aa,allowpopups:"true",style:{display:"flex",background:"#fff"}},`${a}#${o}`)}return e.jsx("iframe",{className:"wsfile-frame",srcDoc:n,sandbox:"allow-scripts allow-popups allow-forms allow-modals",title:s},o)},Ko=new Set(["html","code","markdown","csv","json","text","diff"]),Yo=new Set(["image","video","audio"]),mt=500,Oc={type:"spring",stiffness:300,damping:26,mass:.9},En=t=>Math.min(8,Math.max(.1,t)),it=()=>e.jsx("div",{className:"wsfile-center",children:e.jsx(Ye,{size:20,className:"spin"})});function qc(t){return t.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;|&apos;/g,"'").replace(/&amp;/g,"&")}const Se=t=>e.jsx("div",{className:"wsfile-cmwrap",children:e.jsx(l.Suspense,{fallback:e.jsx(it,{}),children:e.jsx(Lc,{...t})})}),en=({t,download:n})=>e.jsxs("div",{className:"wsfile-center wsfile-fallback",children:[e.jsx(Ue,{size:26}),e.jsx("div",{children:t("preview.loadFailed")}),n&&e.jsxs("button",{className:"btn ghost sm",onClick:n,children:[e.jsx(Be,{size:13})," ",t("preview.download")]})]}),Jo=({src:t,alt:n,view:s,setView:o})=>{const i=l.useRef(null);return e.jsx("div",{className:"wsfile-imgwrap",onWheel:a=>{const r=a.currentTarget.getBoundingClientRect(),d=a.clientX-r.left-r.width/2,u=a.clientY-r.top-r.height/2,v=a.deltaY<0?1.12:1/1.12;o(f=>{const j=En(f.s*v),y=j/f.s;return{s:j,x:d-(d-f.x)*y,y:u-(u-f.y)*y}})},onPointerDown:a=>{i.current={x:a.clientX,y:a.clientY,sx:s.x,sy:s.y},a.currentTarget.setPointerCapture(a.pointerId)},onPointerMove:a=>{const r=i.current;r&&o(d=>({...d,x:r.sx+(a.clientX-r.x),y:r.sy+(a.clientY-r.y)}))},onPointerUp:()=>{i.current=null},onDoubleClick:()=>o({s:1,x:0,y:0}),children:e.jsx("img",{src:t,alt:n,draggable:!1,style:{transform:`translate(${s.x}px, ${s.y}px) scale(${s.s})`}})})},Qo=({bytes:t,download:n})=>{const{t:s}=U(),o=l.useRef(null),[i,a]=l.useState(!1),[r,d]=l.useState(!0);return l.useEffect(()=>{let u=!1;return a(!1),d(!0),(async()=>{try{const v=await gt(()=>import("./docx-preview-Bi7wekSM.js"),__vite__mapDeps([9,10,1]),import.meta.url);if(u||!o.current)return;o.current.innerHTML="",await v.renderAsync(t,o.current,void 0,{className:"docx",inWrapper:!0,breakPages:!0,ignoreLastRenderedPageBreak:!0}),u||d(!1)}catch{u||(a(!0),d(!1))}})(),()=>{u=!0}},[t]),i?e.jsx(en,{t:s,download:n}):e.jsxs("div",{className:"wsfile-doc wsfile-docx",children:[e.jsx("div",{ref:o}),r&&e.jsx(it,{})]})},Bc=100,Xo=({bytes:t,download:n})=>{const{t:s}=U(),o=l.useRef(null),[i,a]=l.useState(!1),[r,d]=l.useState(!0),[u,v]=l.useState(null);return l.useEffect(()=>{let f=!1,j=null;return a(!1),d(!0),v(null),(async()=>{try{const y=await gt(()=>import("./pdf-C2_sJa3b.js"),[],import.meta.url);if(y.GlobalWorkerOptions.workerSrc=zl,j=await y.getDocument({data:t.slice()}).promise,f||!o.current)return;o.current.innerHTML="";const p=Math.min(window.devicePixelRatio||1,2),w=Math.min(j.numPages,Bc);for(let N=1;N<=w&&!f;N++){const b=await j.getPage(N),x=b.getViewport({scale:1.3*p}),c=document.createElement("canvas");c.className="wsfile-pdf-page",c.width=x.width,c.height=x.height,c.style.width=`${x.width/p}px`,o.current?.appendChild(c),await b.render({canvasContext:c.getContext("2d"),viewport:x}).promise}f||(d(!1),j.numPages>w&&v({shown:w,total:j.numPages}))}catch{f||(a(!0),d(!1))}})(),()=>{if(f=!0,j)try{j.destroy()}catch{}}},[t]),i?e.jsx(en,{t:s,download:n}):e.jsxs("div",{className:"wsfile-doc wsfile-pdf",children:[e.jsx("div",{ref:o}),r&&e.jsx(it,{}),u&&e.jsx("div",{className:"panel-note",children:s("preview.pdfPages",{n:String(u.shown),total:String(u.total)})})]})};async function Zo(t,n){if(n==="xlsx"){const u=await gt(()=>import("./xlsx-CNerDvZX.js"),[],import.meta.url),v=u.read?u:u.default,f=v.read(t,{type:"array"});return{kind:"xlsx",sheets:f.SheetNames.map(j=>({name:j,html:v.utils.sheet_to_html(f.Sheets[j])}))}}const s=await gt(()=>import("./jszip.min-tyV0GaJg.js").then(u=>u.j),__vite__mapDeps([10,1]),import.meta.url),i=await(s.loadAsync?s:s.default??s).loadAsync(t),a=u=>parseInt(u.match(/(\d+)\.xml$/)?.[1]||"0",10),r=Object.keys(i.files).filter(u=>/^ppt\/slides\/slide\d+\.xml$/.test(u)).sort((u,v)=>a(u)-a(v)),d=[];for(const u of r){const v=await i.files[u].async("text");d.push([...v.matchAll(/<a:t>([^<]*)<\/a:t>/g)].map(f=>qc(f[1])).join(`
6
- `))}return{kind:"pptx",slides:d}}const Uc=({target:t,onClose:n})=>{const{t:s}=U(),[o,i]=l.useState(!0),[a,r]=l.useState(null),[d,u]=l.useState(null),[v,f]=l.useState(null),[j,y]=l.useState(null),[p,w]=l.useState(!1),[N,b]=l.useState("preview"),[x,c]=l.useState(0),[C,m]=l.useState(!1),[k,z]=l.useState(!0),[g,A]=l.useState({s:1,x:0,y:0}),P=Ht(d?.mimeType||"",t.name),B=io(t.name),_=d?Lt(d.mimeType,t.name):"binary";l.useEffect(()=>{let W=!1,K=null;return i(!0),r(null),u(null),f(null),y(null),b("preview"),A({s:1,x:0,y:0}),(async()=>{try{const F=await t.load();if(W)return;if(!F){r("not-found"),i(!1);return}if("tooLarge"in F){f(F.size),i(!1);return}if(Yo.has(Lt(F.mimeType,t.name))){const X=Wt(t.name)||F.mimeType||"application/octet-stream";K=URL.createObjectURL(new Blob([F.bytes],{type:X})),y(K)}u(F),i(!1)}catch(F){W||(r(F?.message||"error"),i(!1))}})(),()=>{W=!0,K&&URL.revokeObjectURL(K)}},[t]),l.useEffect(()=>{const W=K=>{K.key==="Escape"&&(p?w(!1):n())};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[p,n]);const V=l.useMemo(()=>d&&Ko.has(_)?new TextDecoder("utf-8",{fatal:!1}).decode(d.bytes):"",[d,_]),[$,q]=l.useState(null),[T,L]=l.useState(!1),[G,ee]=l.useState(0);l.useEffect(()=>{if(!d||_!=="xlsx"&&_!=="pptx"){q(null),L(!1);return}let W=!1;return q(null),L(!1),ee(0),Zo(d.bytes,_).then(K=>{W||q(K)}).catch(()=>{W||L(!0)}),()=>{W=!0}},[d,_]);const re=()=>{if(T)return e.jsx(en,{t:s,download:t.download});if(!$)return e.jsx(it,{});if($.kind==="xlsx"){const W=$.sheets[G]??$.sheets[0];return e.jsxs("div",{className:"wsfile-sheetwrap",children:[$.sheets.length>1&&e.jsx("div",{className:"wsfile-seg wsfile-sheet-tabs",children:$.sheets.map((K,F)=>e.jsx("button",{className:F===G?"active":"",onClick:()=>ee(F),children:K.name},F))}),e.jsx("div",{className:"wsfile-doc wsfile-sheet",dangerouslySetInnerHTML:{__html:W?.html??""}})]})}return e.jsx("div",{className:"wsfile-doc wsfile-pptx",children:$.slides.map((W,K)=>{const F=W.split(`
7
- `);return e.jsxs("div",{className:"wsfile-slide",children:[e.jsx("div",{className:"wsfile-slide-no",children:s("preview.slide",{n:String(K+1)})}),F[0]&&e.jsx("div",{className:"wsfile-slide-title",children:F[0]}),e.jsx("pre",{children:F.slice(1).join(`
8
- `)||(F[0]?"":"—")})]},K)})})};let Z;if(o)Z=e.jsx(it,{});else if(v!==null)Z=e.jsxs("div",{className:"wsfile-center wsfile-fallback",children:[e.jsx(Ue,{size:26}),e.jsx("div",{children:s("preview.tooLarge",{size:Vt(v)})}),t.download&&e.jsxs("button",{className:"btn ghost sm",onClick:t.download,children:[e.jsx(Be,{size:13})," ",s("preview.download")]})]});else if(a||!d)Z=e.jsxs("div",{className:"wsfile-center wsfile-fallback",children:[e.jsx(Ue,{size:26}),e.jsx("div",{children:s(a==="not-found"?"preview.notFound":"preview.loadFailed")}),t.download&&e.jsxs("button",{className:"btn ghost sm",onClick:t.download,children:[e.jsx(Be,{size:13})," ",s("preview.download")]})]});else if(_==="image")Z=j?e.jsx(Jo,{src:j,alt:t.name,view:g,setView:A}):null;else if(_==="pdf")Z=e.jsx(Xo,{bytes:d.bytes,download:t.download});else if(_==="video")Z=e.jsx("div",{className:"wsfile-media",children:j&&e.jsx("video",{src:j,controls:!0})});else if(_==="audio")Z=e.jsx("div",{className:"wsfile-media wsfile-audio",children:j&&e.jsx("audio",{src:j,controls:!0})});else if(_==="markdown")Z=N==="preview"?e.jsx("div",{className:"wsfile-doc msg-content",children:e.jsx(Ke,{content:V})}):Se({value:V,fileName:t.name,wrap:C});else if(_==="json"){let W=V;try{W=JSON.stringify(JSON.parse(V),null,2)}catch{}Z=Se({value:W,fileName:"x.json",language:"json",wrap:C})}else if(_==="code")Z=Se({value:V,fileName:t.name,wrap:C});else if(_==="text")Z=Se({value:V,fileName:t.name,wrap:C});else if(_==="diff")Z=e.jsx(Wn,{text:V,side:k});else if(_==="csv"){const W=ao(V,B==="tsv"?" ":","),K=W.slice(0,mt),F=K[0]??[];Z=e.jsxs("div",{className:"wsfile-doc",children:[e.jsxs("table",{className:"wsfile-table",children:[e.jsx("thead",{children:e.jsx("tr",{children:F.map((X,oe)=>e.jsx("th",{children:X},oe))})}),e.jsx("tbody",{children:K.slice(1).map((X,oe)=>e.jsx("tr",{children:F.map((pe,D)=>e.jsx("td",{children:X[D]??""},D))},oe))})]}),W.length>mt&&e.jsx("div",{className:"panel-note",children:s("preview.csvTruncated",{shown:String(mt),total:String(W.length)})})]})}else _==="html"?Z=N==="preview"?e.jsx(Go,{path:t.path,text:V,title:t.name,nonce:x}):Se({value:V,language:"html",wrap:C}):_==="docx"?Z=e.jsx(Qo,{bytes:d.bytes,download:t.download}):_==="xlsx"||_==="pptx"?Z=re():Z=e.jsxs("div",{className:"wsfile-center wsfile-fallback",children:[e.jsx(Ue,{size:26}),e.jsx("div",{children:s("preview.notAvailable")}),t.download&&e.jsxs("button",{className:"btn ghost sm",onClick:t.download,children:[e.jsx(Be,{size:13})," ",s("preview.download")]})]});const H=!o&&!a&&v===null&&!!d,he=_==="markdown"||_==="html",le=_==="code"||_==="json"||_==="text"||he&&N==="source";return e.jsx(Nl.div,{className:"wsfile-overlay",initial:{opacity:0,y:24,scale:.92},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:16,scale:.94},transition:Oc,style:{transformOrigin:"bottom center"},children:e.jsxs("div",{className:`wsfile-panel${p?" expanded":""}${_==="html"&&N==="preview"&&H?" fill":""}`,children:[e.jsxs("div",{className:"wsfile-head",children:[e.jsx(P,{size:14,className:"wsfile-head-icon"}),e.jsxs("div",{className:"wsfile-title",title:t.name,children:[e.jsx("span",{className:"wsfile-name",children:Ta(t.name)}),B&&e.jsx("span",{className:"wsfile-ext",children:B})]}),H&&he&&e.jsxs("div",{className:"wsfile-seg",children:[e.jsx("button",{className:N==="preview"?"active":"",title:s("preview.htmlPreview"),onClick:()=>b("preview"),children:e.jsx(Gt,{size:13})}),e.jsx("button",{className:N==="source"?"active":"",title:s("preview.htmlCode"),onClick:()=>b("source"),children:e.jsx(Ot,{size:13})}),_==="html"&&N==="preview"&&e.jsx("button",{title:s("preview.reload"),onClick:()=>c(W=>W+1),children:e.jsx(vt,{size:12})})]}),H&&_==="diff"&&e.jsxs("div",{className:"wsfile-seg",children:[e.jsx("button",{className:k?"active":"",title:s("preview.diffSideBySide"),onClick:()=>z(!0),children:e.jsx(ro,{size:13})}),e.jsx("button",{className:k?"":"active",title:s("preview.diffLineByLine"),onClick:()=>z(!1),children:e.jsx(Bo,{size:13})})]}),H&&le&&e.jsx("button",{className:`icon-btn${C?" active":""}`,title:s("preview.wrap"),onClick:()=>m(W=>!W),children:e.jsx(Uo,{size:14})}),H&&_==="image"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"icon-btn",title:s("preview.zoomOut"),onClick:()=>A(W=>({...W,s:En(W.s*.8)})),children:e.jsx(Io,{size:14})}),e.jsx("button",{className:"icon-btn",title:s("preview.zoomIn"),onClick:()=>A(W=>({...W,s:En(W.s*1.25)})),children:e.jsx(_o,{size:14})}),e.jsx("button",{className:"icon-btn",title:s("preview.fit"),onClick:()=>A({s:1,x:0,y:0}),children:e.jsx(Oo,{size:14})})]}),t.download&&e.jsx("button",{className:"icon-btn",title:s("preview.download"),onClick:t.download,children:e.jsx(Be,{size:14})}),e.jsx("button",{className:"icon-btn",title:s(p?"preview.collapse":"preview.expand"),onClick:()=>w(W=>!W),children:p?e.jsx(Kn,{size:14}):e.jsx(Ln,{size:14})}),e.jsx("button",{className:"icon-btn",title:s("preview.close"),onClick:n,children:e.jsx(lt,{size:15})})]}),e.jsx("div",{className:"wsfile-body",children:Z})]})})};te({"team.editor.titleNew":{zh:"新建团队",en:"New team"},"team.editor.titleEdit":{zh:"编辑团队",en:"Edit team"},"team.editor.name":{zh:"团队名称(可空)",en:"Team name (optional)"},"team.editor.namePlaceholder":{zh:"留空 = 按成员名自动命名",en:"Leave empty to name it after the members"},"team.editor.avatar":{zh:"团队头像",en:"Team avatar"},"team.editor.avatarImage":{zh:"上传图片",en:"Upload image"},"team.editor.avatarRemove":{zh:"移除图片",en:"Remove image"},"team.editor.avatarEmoji":{zh:"Emoji 标识",en:"Emoji emblem"},"team.editor.avatarHint":{zh:"支持 PNG、JPEG、GIF、WebP(不超过 1 MB);也可使用 Emoji,留空显示成员组合头像。",en:"PNG, JPEG, GIF or WebP up to 1 MB. You can also use an emoji, or leave it empty for the member avatar stack."},"team.editor.avatarTooLarge":{zh:"头像不能超过 1 MB",en:"The avatar must be no larger than 1 MB"},"team.editor.avatarReadFailed":{zh:"读取团队头像失败",en:"Could not read the team avatar"},"team.editor.members":{zh:"成员(勾选顺序 = 发言顺序)",en:"Members (pick order = speaking order)"},"team.editor.rolePlaceholder":{zh:"角色 / 分工(可选)",en:"Role (optional)"},"team.editor.doc":{zh:"TEAM.md(团队约定,模型读取,建议英文)",en:"TEAM.md (team charter read by the models; English recommended)"},"team.editor.docPlaceholder":{zh:`# Team
9
- ## Mission
10
- ## Roles
11
- ## Workflow
12
- ## Protocol`,en:`# Team
13
- ## Mission
14
- ## Roles
15
- ## Workflow
16
- ## Protocol`},"team.editor.needTwo":{zh:"至少选择 2 名在册成员",en:"Pick at least 2 members that still exist"},"team.editor.missing":{zh:"已不存在",en:"missing"},"team.editor.save":{zh:"保存",en:"Save"},"team.editor.create":{zh:"创建团队",en:"Create team"},"team.editor.cancel":{zh:"取消",en:"Cancel"},"team.editor.saved":{zh:"团队已保存",en:"Team saved"},"team.editor.failed":{zh:"保存失败:{e}",en:"Save failed: {e}"}});const Hc=({agents:t,team:n,initialMembers:s,onSaved:o,onClose:i})=>{const{t:a}=U(),r=l.useMemo(()=>t.filter(T=>T.createdBy!=="system"),[t]),d=l.useMemo(()=>new Set(r.map(T=>T.slug)),[r]),[u,v]=l.useState(n?.name||""),[f,j]=l.useState(n?.avatar||""),[y,p]=l.useState(null),[w,N]=l.useState(!1),[b,x]=l.useState(()=>n?n.members.map(T=>({...T})):(s||[]).filter(T=>r.some(L=>L.slug===T)).map(T=>({slug:T,role:""}))),[c,C]=l.useState(n?.doc||""),[m,k]=l.useState(!1),z=b.filter(T=>d.has(T.slug)).length,g=b.map(T=>r.find(L=>L.slug===T.slug)?.name||T.slug).join(" & "),A=n?n.name:g||a("team.editor.namePlaceholder"),P=z>=2&&!m,B=T=>x(L=>L.some(G=>G.slug===T)?L.filter(G=>G.slug!==T):[...L,{slug:T,role:""}]),_=(T,L)=>x(G=>G.map(ee=>ee.slug===T?{...ee,role:L}:ee)),V=ea(f),$=T=>{const L=T.target.files?.[0];if(T.target.value="",!!L){if(L.size>1048576){M.getState().toast(a("team.editor.avatarTooLarge"),!0);return}p(L),j(""),N(!1)}},q=async()=>{if(!P)return;k(!0);const T=M.getState();try{const L={name:u.trim(),avatar:w?"":f.trim(),members:b,doc:c};let G=n?await Ia(Ne(),n.slug,L):await _a(Ne(),L);if(w&&n&&(await $a(Ne(),G.slug),G={...G,avatar:""}),y){const ee=await new Promise((Z,H)=>{const he=new FileReader;he.onload=()=>Z(String(he.result)),he.onerror=()=>H(new Error(a("team.editor.avatarReadFailed"))),he.readAsDataURL(y)}),re=await Da(Ne(),G.slug,ee,y.type);G={...G,avatar:re.avatar}}await T.refreshTeams(),T.toast(a("team.editor.saved")),o(G)}catch(L){T.toast(a("team.editor.failed",{e:L?.message||String(L)}),!0)}finally{k(!1)}};return e.jsx("div",{onClick:i,style:{position:"fixed",inset:0,background:"var(--overlay-scrim)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},children:e.jsxs("div",{className:"team-editor",onClick:T=>T.stopPropagation(),style:{width:520,maxWidth:"92vw",maxHeight:"86vh",overflow:"auto",borderRadius:"var(--radius-md, 12px)",background:"var(--bg)",color:"var(--text)",border:"1px solid var(--border)",boxShadow:"var(--card-shadow)",padding:18},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[e.jsx(Ma,{size:18}),e.jsx("strong",{style:{fontSize:"var(--ui-font-heading, 14px)",flex:1},children:a(n?"team.editor.titleEdit":"team.editor.titleNew")}),e.jsx("button",{className:"icon-btn",onClick:i,title:a("team.editor.cancel"),children:e.jsx(lt,{size:16})})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("team.editor.name")}),e.jsx("input",{type:"text",value:u,placeholder:A,onChange:T=>v(T.target.value),autoFocus:!0})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("team.editor.avatar")}),e.jsxs("div",{className:"agent-avatar-actions",children:[e.jsxs("label",{className:"btn sm",children:[e.jsx(ic,{size:13}),a("team.editor.avatarImage"),e.jsx("input",{type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",disabled:m,onChange:$})]}),(V||y)&&e.jsxs("button",{type:"button",className:"btn ghost sm",disabled:m,onClick:()=>{p(null),j(""),N(!!n&&V)},children:[e.jsx(Ct,{size:13}),a("team.editor.avatarRemove")]}),y&&e.jsx("small",{children:y.name})]}),e.jsx("input",{type:"text","aria-label":a("team.editor.avatarEmoji"),value:V?"":f,disabled:V||!!y,maxLength:16,placeholder:"🧭",onChange:T=>{j(T.target.value),N(!1)}}),e.jsx("small",{children:a("team.editor.avatarHint")})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("team.editor.members")}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,maxHeight:220,overflow:"auto"},children:[...r,...b.filter(T=>!d.has(T.slug)).map(T=>({slug:T.slug,name:`${T.slug} (${a("team.editor.missing")})`}))].map(T=>{const L=b.findIndex(ee=>ee.slug===T.slug),G=L>=0;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,minWidth:160,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:G,onChange:()=>B(T.slug)}),G&&e.jsx("span",{style:{fontSize:"var(--ui-font-caption, 11px)",color:"var(--text-muted)",minWidth:14},children:L+1}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:T.name})]}),G&&e.jsx("input",{type:"text",value:b[L].role,placeholder:a("team.editor.rolePlaceholder"),style:{flex:1},onChange:ee=>_(T.slug,ee.target.value)})]},T.slug)})}),z<2&&e.jsx("div",{style:{fontSize:"var(--ui-font-caption, 11px)",color:"var(--danger)",marginTop:4},children:a("team.editor.needTwo")})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("team.editor.doc")}),e.jsx("textarea",{rows:7,value:c,placeholder:a("team.editor.docPlaceholder"),onChange:T=>C(T.target.value)})]}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx("button",{className:"btn sm",onClick:i,children:a("team.editor.cancel")}),e.jsx("button",{className:"btn primary sm",onClick:()=>{q()},disabled:!P,children:a(n?"team.editor.save":"team.editor.create")})]})]})})};function Wc(t){const n=s=>String(s).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}const Vc=4e3,Gc="Track this task; report to the user only when something changed, and remove this entry when it is done. ";async function ks(t,n){const s=M.getState();try{return await lo(Ne(),t,n,"pending"),!0}catch(o){return s.toast(o?.code==="todo_not_pending"?s.tr("chat.task.doneTodo"):s.tr("chat.task.todoSyncFail",{e:o?.message||String(o)}),!0),!1}}async function Kc(t){const n=M.getState();await lo(Ne(),t,"pending","injected").catch(s=>{n.toast(n.tr("chat.task.todoSyncFail",{e:s?.message||String(s)}),!0)})}async function Yc(t,n,s){const o=M.getState(),i=r=>{qa(Ne(),r).catch(()=>{})},a=`task-card "${t.title.slice(0,80)}"`;if(n==="here"||n==="new"){if(t.todo&&!await ks(t.todo,"injected"))return!1;let r=!1;try{n==="new"&&Fa(),r=!!await M.getState().send(t.prompt,[],void 0,void 0,void 0,n==="here"?s:null)}finally{!r&&t.todo&&await Kc(t.todo)}return r&&i(`${a} accepted: ${n==="here"?"run here":"run in a new session"}`),r}if(n==="muse"&&t.todo)try{return await La(Ne(),t.todo),o.toast(o.tr("chat.task.handedDo")),!0}catch(r){return o.toast(r?.code==="muse_disabled"?o.tr("chat.task.museOff"):r?.code==="todo_not_pending"?o.tr("chat.task.doneTodo"):o.tr("chat.task.trackFail",{e:r?.message||String(r)}),!0),!1}if(n==="muse"){const r=Gc+t.prompt;if(r.length>Vc)return o.toast(o.tr("chat.task.tooLong"),!0),!1;try{return await Oa(Ne(),"muse",{name:t.title.slice(0,120),date:Wc(new Date(Date.now()+36e5)),repeat:"1d",auto:!0,prompt:r,description:`${t.tldr?`${t.tldr} · `:""}source session ${s||"-"}`.slice(0,500),todo:!0}),o.toast(o.tr("chat.task.tracked")),i(`${a} handed to Muse for tracking`),!0}catch(d){return o.toast(o.tr("chat.task.trackFail",{e:d?.message||String(d)}),!0),!1}}return t.todo?ks(t.todo,"dismissed"):(i(`${a} ignored`),!0)}function Jc(t){if(!t.trim())return;M.getState().setPendingChatQuote("chat-panel",t);const n=He.getState();n.rightVisible&&n.rightTabs.some(o=>o.type==="chat-panel"&&o.active)||n.showSideView("right","chat-panel")}te({"chat.action.insertNote":{zh:"插入笔记",en:"Insert into note"},"chat.insertNote.none":{zh:"没有可写入的笔记:开着的笔记是只读或已锁定",en:"No writable note: the open notes are read-only or locked"},"chat.insertNote.done":{zh:"已插入「{name}」",en:"Inserted into “{name}”"},"chat.insertNote.failed":{zh:"没能插入:笔记是只读、已锁定或处在源码模式",en:"Couldn’t insert: the note is read-only, locked, or in source mode"},"chat.insertNote.undo":{zh:"撤销",en:"Undo"},"chat.insertNote.undoStale":{zh:"笔记之后又有改动,请在笔记里撤销",en:"The note has changed since — undo it in the note"}});const Qc=/^> — \[\[([^\]|#\n]+)(?:#([^\]|\n]+))?\]\]\s*$/;function Xc(t){const n=t.split(`
17
- `);for(let s=n.length-1;s>=0;s--){const o=Qc.exec(n[s]);if(!o)continue;const i=[];for(let d=s-1;d>=0&&n[d].startsWith(">");d--)i.unshift(n[d].replace(/^> ?/,""));const a=o[2]?.trim(),r=i.join(`
18
- `).trim();return{path:o[1].trim(),anchor:{...a?{heading:a}:{},...r?{text:r}:{}}}}return null}function Zc(t,n){const s=t.findIndex(o=>o.id===n);for(let o=(s<0?t.length:s)-1;o>=0;o--){const i=t[o];if(i.role!=="user")continue;const a=Xc(i.content);if(a)return a}return null}function ed(t){return Ba(t).trim()}function td(t){return(t.split("/").pop()||t).replace(/\.md$/i,"")}function nd(t,n){const s=ed(t);if(!s)return!1;if(!Zs())return ve({text:we("chat.insertNote.none"),level:"info",inAppOnly:!0}),!1;const o=ta(s,n);return o?(ve({text:we("chat.insertNote.done",{name:td(o.path)}),level:"success",receipt:!0,durationMs:8e3,action:{label:we("chat.insertNote.undo"),run:()=>{o.undo()||ve({text:we("chat.insertNote.undoStale"),level:"info",inAppOnly:!0})}}}),!0):(ve({text:we("chat.insertNote.failed"),level:"warning",inAppOnly:!0}),!1)}const sd=()=>sa()?Zs()?"ready":"disabled":"hidden";function od(){return l.useSyncExternalStore(na,sd)}const An=$o(()=>({subject:null}));function ei(){const t=He.getState(),n=t.api?.panels||[],o=(t.api?Ua(t.api):n.find(i=>i.id===t.focusedChatLeafId&&i.params?.__loc==="main"))?.params;return o?.followActive===!1&&typeof o.sessionId=="string"?o.sessionId:M.getState().activeId}const Ss=()=>{const t=An.getState().subject;t&&t.from!==ei()&&An.setState({subject:null})};let zs=!1;function at(t){zs||(zs=!0,M.subscribe(Ss),He.subscribe(Ss)),An.setState({subject:{...t,from:ei()}}),ti(5)}function ti(t){const n=He.getState();if(!n.rightVisible&&!!n.api?.panels.some(o=>o.params?.__loc==="right")&&t>0){setTimeout(()=>ti(t-1),120);return}n.rightVisible||n.toggleSidebar("right"),He.getState().openView("tangu-details",{},"right")}const Cp=t=>!!t.content.trim()&&t.history.length>0&&t.history[0].afterVersion===t.version&&t.history.every(n=>n.actor==="agent"&&!n.rules),Pp=t=>!!t&&t.execMode==="host"&&!t.planMode&&!t.groupChat&&!t.teamSlug&&!t.engineId&&!t.soloEngineId,qt="forsion:human-changed",Tp=t=>t.kind==="agent"?`agent:${t.slug}`:`project:${t.sessionId}`,id=t=>t.kind==="agent"?`/agent/agents/${encodeURIComponent(t.slug)}/human`:"/agent/project-context/human";async function Xn(t,n,s,o="",i){const a=n.kind==="project"?{sessionId:n.sessionId}:{},r=s==="GET"&&n.kind==="project"?`?sessionId=${encodeURIComponent(n.sessionId)}`:"",d=await oo(t,`${id(n)}${o}${r}`,{method:s,...s==="GET"?{}:{body:JSON.stringify({...i,...a})}}),u=await d.json();if(!d.ok)throw Object.assign(new Error(u.detail||`HTTP ${d.status}`),{status:d.status,code:u.error});return s!=="GET"&&window.dispatchEvent(new CustomEvent(qt)),u}const ad=(t,n)=>Xn(t,n,"GET"),Ep=(t,n,s,o,i)=>Xn(t,n,"PUT","",{content:s,expectedVersion:o,summary:i}),rd=(t,n,s)=>Xn(t,n,"POST","/undo",{changeId:s.id,expectedVersion:s.afterVersion});function ni(t=[]){const n=new Map;for(const s of t)if(!(s.name!=="manage_human"||!s.done||s.isError||!s.result))try{const o=JSON.parse(s.result),i=o.change;if(o.kind!=="human_update"||!i||typeof i.id!="string"||!/^[a-f0-9-]{36}$/.test(i.id)||typeof i.summary!="string"||typeof i.evidence!="string"||typeof i.at!="string"||i.actor!=="agent"||!/^[a-f0-9]{64}$/.test(i.beforeVersion)||!/^[a-f0-9]{64}$/.test(i.afterVersion)||!(i.scope?.kind==="agent"&&typeof i.scope.slug=="string"&&/^[a-z0-9][a-z0-9-]*$/.test(i.scope.slug)||i.scope?.kind==="project"&&typeof i.scope.cwd=="string"&&i.scope.cwd.length>0))continue;n.set(i.id,i)}catch{}return[...n.values()]}te({"agentProfile.human":{zh:"协作",en:"Collaboration"},"projectProfile.tab.human":{zh:"协作",en:"Collaboration"},"human.title":{zh:"协作说明",en:"Collaboration handbook"},"human.agentScope":{zh:"与 {name} 的长期协作",en:"Long-term collaboration with {name}"},"human.projectScope":{zh:"在这个项目中如何配合",en:"How we work together on this project"},"human.empty":{zh:"还没有协作说明。你可以自己写下,也可以在对话中让 Agent 根据实际合作逐步整理。",en:"No collaboration handbook yet. Write one yourself, or let your agent build it from your work together."},"human.edit":{zh:"编辑",en:"Edit"},"human.editLabel":{zh:"编辑协作说明",en:"Edit collaboration handbook"},"human.save":{zh:"保存",en:"Save"},"human.cancel":{zh:"放弃修改",en:"Discard changes"},"human.saved":{zh:"已保存,后续对话会读取这份说明。",en:"Saved. Subsequent turns will read this handbook."},"human.userEdit":{zh:"你修改了协作说明",en:"You edited the collaboration handbook"},"human.more":{zh:"更多操作",en:"More actions"},"human.source":{zh:"查看原文",en:"View source"},"human.preview":{zh:"阅读视图",en:"Reading view"},"human.history":{zh:"修改历史",en:"Change history"},"human.noHistory":{zh:"此设备还没有修改记录。",en:"No changes recorded on this device yet."},"human.path":{zh:"文件位置",en:"File location"},"human.updatedAt":{zh:"更新于 {time}",en:"Updated {time}"},"human.updated":{zh:"协作说明已更新",en:"Collaboration handbook updated"},"human.applied":{zh:"已生效",en:"Applied"},"human.view":{zh:"查看说明",en:"View handbook"},"human.revise":{zh:"修改",en:"Revise"},"human.undo":{zh:"撤销本次更新",en:"Undo this update"},"human.undone":{zh:"本次更新已撤销",en:"This update was undone"},"human.evidence":{zh:"更新依据",en:"Reason for this update"},"human.project":{zh:"项目协作",en:"Project collaboration"},"human.agent":{zh:"长期协作",en:"Long-term collaboration"},"human.inherited":{zh:"同时适用:与 {name} 的长期协作",en:"Also applies: collaboration with {name}"},"human.loading":{zh:"正在读取协作说明…",en:"Loading the collaboration handbook…"},"human.retry":{zh:"重试",en:"Retry"},"human.conflict":{zh:"说明已在别处修改。你的草稿仍保留,请查看最新内容后再合并修改。",en:"The handbook changed elsewhere. Your draft is preserved; review the latest version before merging your changes."},"human.undoConflict":{zh:"已有后续修改。请打开说明调整,避免覆盖新的内容。",en:"Newer changes exist. Open the handbook to revise it without overwriting them."},"human.latest":{zh:"查看最新内容",en:"Review latest version"},"human.merge":{zh:"已合并,使用最新版本保存",en:"Merged; save against the latest version"},"human.localOnly":{zh:"协作说明需要连接本地引擎。",en:"Connect to a local engine to use collaboration handbooks."},"human.remoteDenied":{zh:"请在宿主设备上查看和修改协作说明。",en:"View and edit collaboration handbooks on the host device."},"human.template":{zh:`# 怎么和我配合
19
-
20
- ## 开始前请先告诉我
21
-
22
- ## 需要你来定的事
23
-
24
- ## 做完后请你看一眼
25
- `,en:`# Working with me
26
-
27
- ## Tell me before I start
28
-
29
- ## Decisions I need from you
30
-
31
- ## What to check when I am done
32
- `},"human.legacy":{zh:"这份说明是旧版本写的,里面可能混着 Agent 自己要做的事,也可能有不好懂的词。",en:"This handbook was written by an earlier version. It may mix in things the agent itself should do, or wording that is hard to follow."},"human.rewrite":{zh:"让 Agent 重写",en:"Ask the agent to rewrite"},"human.rewrite.unavailable":{zh:"在和它的本机对话里打开这一页才能用(计划模式下不行)",en:"Open this page from a local chat with it to use this (not in plan mode)"},"human.rewrite.sent":{zh:"已发到对话里。改完会出一张更新卡,不满意可以撤销。",en:"Sent to the chat. A change card appears when it is done, and you can undo it."},"human.rewrite.agentPrompt":{zh:"请把协作说明按现在的写法重写一遍。这份说明是你写给我看的:里面的「我」指你(Agent),「你」指我(用户)。重写后只留需要我做的事,用平常话写;原来写的那些你自己要做的事不要丢,挪到你的记忆里,也不要改成让我去做的事。只改你自己这一份,不要另外给这个项目写一份。",en:'Please rewrite the collaboration handbook the way it should be written now. You wrote it for me: in it, "I" means you (the agent) and "you" means me (the user). Keep only what I need to do, in plain words. Do not lose the things it says you will do: move them to your memory, and do not turn them into tasks for me. Change only your own handbook and do not write a separate one for this project.'},"human.rewrite.projectPrompt":{zh:"请把这个项目的协作说明按现在的写法重写一遍。这份说明是你写给我看的:里面的「我」指你(Agent),「你」指我(用户)。重写后只留需要我做的事,用平常话写;原来写的那些你自己要做的事不要丢,挪到记忆里,也不要改成让我去做的事。只改这个项目的这一份,不要动你自己的那份。",en:'Please rewrite the collaboration handbook of this project the way it should be written now. You wrote it for me: in it, "I" means you (the agent) and "you" means me (the user). Keep only what I need to do, in plain words. Do not lose the things it says you will do: move them to memory, and do not turn them into tasks for me. Change only the handbook of this project and leave your own untouched.'},"human.changed":{zh:"有新的协作说明,打开后可查看。",en:"The collaboration handbook has changed. Open it to see the latest version."}});te({"human.ask.title":{zh:"{name} 想请你配合 {n} 件事",en:"Requests from {name}: {n}"},"human.ask.titleAnon":{zh:"想请你配合 {n} 件事",en:"Requests for you: {n}"},"human.ask.saved":{zh:"已写进协作说明",en:"Saved to the collaboration handbook"},"human.ask.why":{zh:"为什么:{text}",en:"Why: {text}"},"human.ask.ack":{zh:"知道了",en:"Got it"},"human.ask.acked":{zh:"协作请求 {n} 条 · 已知道",en:"Handbook requests: {n} · acknowledged"}});const si="forsion.humanAck",Ns=()=>{try{const t=JSON.parse(localStorage.getItem(si)||"[]");return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}},ld=t=>{try{localStorage.setItem(si,JSON.stringify([...new Set(t)].slice(-200)))}catch{}};function cd({changes:t,cfg:n,sessionId:s,agentName:o}){const{t:i}=U(),a=t.map(w=>w.id).join(","),r=de(s),[d,u]=l.useState(""),[v,f]=l.useState(!1),y=l.useMemo(()=>{const w=new Set(Ns());return t.every(N=>w.has(N.id))},[a])||d===a;if(l.useEffect(()=>{a&&window.dispatchEvent(new CustomEvent(qt))},[a]),!t.length)return null;if(y&&!v)return e.jsxs("button",{type:"button",className:"human-acked","data-human-updates":!0,"data-human-acked":!0,onClick:()=>f(!0),children:[e.jsx(gs,{size:15}),i("human.ask.acked",{n:t.length}),e.jsx(xe,{size:12})]});const p=()=>{ld([...Ns(),...t.map(w=>w.id)]),f(!1),u(a)};return e.jsxs("section",{className:"human-update-card","data-human-updates":!0,children:[e.jsxs("div",{className:"human-update-head",children:[e.jsx(gs,{size:15}),e.jsx("strong",{children:o?i("human.ask.title",{name:o,n:t.length}):i("human.ask.titleAnon",{n:t.length})}),e.jsx("span",{className:"human-ask-saved",children:i("human.ask.saved")})]}),t.map(w=>e.jsx(dd,{change:w,engine:r,cfg:n,sessionId:s},JSON.stringify([r.key,r.base,n.token,w.id]))),e.jsx("div",{className:"human-ask-foot",children:e.jsx("button",{type:"button",className:"btn sm",onClick:p,children:i("human.ask.ack")})})]})}function dd({change:t,engine:n,cfg:s,sessionId:o}){const{t:i}=U(),a=t.scope,r=M(m=>a.kind==="agent"?m.agentDefs.find(k=>k.slug===a.slug)?.name||a.slug:a.cwd.split(/[\\/]/).filter(Boolean).at(-1)),d=M(m=>[...m.sessions,...m.archivedSessions].find(k=>k.id===o)?.project_path),[u,v]=l.useState(null),[f,j]=l.useState(""),[y,p]=l.useState(!1),w=t.scope.kind==="agent"?t.scope:{kind:"project",sessionId:o},N=m=>m.scope.kind===a.kind&&(m.scope.kind==="agent"&&a.kind==="agent"?m.scope.slug===a.slug:m.scope.kind==="project"&&a.kind==="project"&&m.scope.cwd===a.cwd);l.useEffect(()=>{let m=!0;const k=()=>{ad(n,w).then(z=>{m&&N(z)&&v(z)}).catch(()=>{})};return k(),window.addEventListener(qt,k),()=>{m=!1,window.removeEventListener(qt,k)}},[n.key,n.base,s.token,t.id,o]);const b=!!u?.history.some(m=>m.undoOf===t.id),x=!!u?.history.some(m=>m.id===t.id&&m.canUndo),c=(m=!1)=>at({...t.scope.kind==="agent"?{kind:"agent",slug:t.scope.slug}:{kind:"project",path:d||t.scope.cwd},human:{at:Date.now(),edit:m,changeId:t.id}}),C=async()=>{if(!y){p(!0),j("");try{const m=await rd(n,w,t);v(m.document)}catch(m){j(m?.status===409?i("human.undoConflict"):String(m?.message||m))}finally{p(!1)}}};return e.jsxs("article",{"data-human-update":t.id,children:[e.jsxs("div",{className:"human-scope",children:[r," · ",i(t.scope.kind==="agent"?"human.agent":"human.project")," · ",e.jsx("span",{className:"human-applied",children:i(b?"human.undone":"human.applied")})]}),e.jsx("p",{className:"human-say",children:t.summary}),t.evidence&&e.jsx("p",{className:"human-why",children:i("human.ask.why",{text:t.evidence})}),e.jsxs("div",{className:"human-actions",children:[e.jsx("button",{type:"button",className:"profile-text-action",onClick:()=>c(),children:i("human.view")}),e.jsx("button",{type:"button",className:"profile-text-action",onClick:()=>c(!0),children:i("human.revise")}),!b&&e.jsxs("button",{type:"button",className:"profile-text-action",disabled:y||!x,title:!x&&u?i("human.undoConflict"):void 0,onClick:()=>{C()},children:[e.jsx(Et,{size:12}),i("human.undo")]})]}),f&&e.jsx("p",{className:"agent-profile-error",role:"alert",children:f})]})}const Ve="forsion:harness-changed",ud=new Set(["create","revise","delete","rollback"]),Cs=t=>t===void 0||Array.isArray(t)&&t.every(n=>typeof n=="string");function oi(t=[]){const n=new Map;for(const s of t)if(!(s.name!=="manage_harness"||!s.done||s.isError||!s.result))try{const o=JSON.parse(s.result),i=o.change;if(o.kind!=="harness_update"||!i||typeof i.rev!="string"||!/^[a-f0-9-]{36}$/.test(i.rev)||typeof i.agent!="string"||!/^[a-z0-9][a-z0-9-]*$/.test(i.agent)||typeof i.entryId!="string"||!/^[A-Za-z0-9_-]{1,64}$/.test(i.entryId)||!ud.has(i.action)||typeof i.title!="string"||typeof i.body!="string"||typeof i.evidence!="string"||typeof i.kind!="string"||typeof i.at!="string"||typeof i.version!="number"||!Cs(i.tools)||!Cs(i.skills))continue;n.set(i.rev,i)}catch{}return[...n.values()]}function ii(t,n){const s=t.filter(i=>i.entryId===n.entryId),o=s.findIndex(i=>i.rev===n.rev);return o<0?"superseded":o===s.length-1?"current":o===s.length-2&&s[o+1].action==="rollback"?"undone":"superseded"}const hd=new Set(["add","update","forget"]);function ai(t=[]){const n=new Map;for(const s of t)if(!(s.name!=="remember"&&s.name!=="manage_human"||!s.done||s.isError||!s.result))try{const o=JSON.parse(s.result);if(s.name==="manage_human"){(o?.kind==="human_update"&&Array.isArray(o.moved)?o.moved:[]).forEach((r,d)=>{const u=r?.memory;u?.scope!=="agent"&&u?.scope!=="project"||typeof u.entryId!="string"||!u.entryId||typeof u.content!="string"||!u.content||n.set(`${s.id}:${d}`,{callId:`${s.id}:${d}`,action:"add",scope:u.scope,...typeof u.project=="string"?{project:u.project}:{},entryId:u.entryId,content:u.content})});continue}if(o?.ok!==!0||!hd.has(o.action)||o.scope!=="agent"&&o.scope!=="project"||o.duplicate)continue;const i=typeof o.entry?.id=="string"?o.entry.id:typeof o.id=="string"?o.id:void 0,a=typeof o.entry?.content=="string"?o.entry.content:"";if(o.action!=="forget"&&(!i||!a))continue;n.set(s.id,{callId:s.id,action:o.action,scope:o.scope,...typeof o.project=="string"?{project:o.project}:{},...i?{entryId:i}:{},content:a})}catch{}return[...n.values()]}function pd(t){return t.name!=="remember"&&t.name!=="manage_harness"&&t.name!=="manage_human"?!1:ai([t]).length+oi([t]).length+ni([t]).length>0}const md=t=>Date.parse(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(t)?`${t.replace(" ","T")}Z`:t),fd=new Set(["harness_adopted","harness_confirm","project_memory_added","project_memory_candidates","project_memory_compacted"]);function gd(t){const n=t.match(/^-\s*\[(\d{4}-\d{2}-\d{2})(?:\s+s:([A-Za-z0-9-]*))?\]\s*(.*)$/);return n?{date:n[1],session:n[2]||"",text:n[3]}:{date:"",session:"",text:t.replace(/^-\s*/,"")}}const vd=t=>t.replace(/[^A-Za-z0-9-]/g,"").slice(0,8),Ps=12e4;function Ts(t,n=[],s="",o={}){const i=[],a=n.filter(u=>u.by==="historian"&&u.action==="upsert"&&!!u.rev&&!!s&&u.sessionId===s);for(const u of t){if(!fd.has(u.action))continue;const v=md(u.created_at);if(!Number.isFinite(v))continue;const f=u.action,j=f==="project_memory_compacted"?[]:(u.detail||"").split(" | ").map(N=>N.trim()).filter(Boolean);if(f!=="harness_adopted"){i.push({id:u.id,kind:f,at:v,items:j});continue}const y=a.filter(N=>Math.abs(Date.parse(N.ts)-v)<=Ps),p=j.map(N=>y.filter(b=>b.after?.title===N)),w=y.length===j.length&&p.every(N=>N.length===1);j.forEach((N,b)=>{const x=w?p[b][0]:void 0;i.push({id:`${u.id}:${b}`,kind:f,at:v,items:[N],...x?{undo:{entryId:x.entryId,rev:x.rev,state:ii(n,{entryId:x.entryId,rev:x.rev})}}:{}})})}i.sort((u,v)=>u.at-v.at);const r=vd(s),d=[...i].reverse().find(u=>u.kind==="harness_confirm");if(d&&o.harness&&r&&(d.pending=o.harness.filter(u=>u.needsUser).map(u=>({c:u,parsed:gd(u.line)})).filter(u=>u.parsed.session===r).map(u=>({key:u.c.line,text:u.parsed.text,adoptable:u.c.adoptable,target:{kind:"harness",line:u.c.line}}))),o.project){const u=new Set;for(const v of i)v.kind==="project_memory_candidates"&&(v.pending=o.project.filter(f=>!u.has(f.id)&&Math.abs(f.at-v.at)<=Ps).map(f=>(u.add(f.id),{key:f.id,text:f.content,adoptable:!0,target:{kind:"project",id:f.id}})))}return i}function yd(t,n){const s=new Map,o=t.filter(i=>i.role!=="user");for(const i of n){let a;for(const r of o)Math.floor(r.timestamp/1e3)*1e3<=i.at&&(a=r.id);a&&s.set(a,[...s.get(a)||[],i])}return s}const jd=new Set(["historian","dream"]),xd=new Set(["historian","muse"]);function wd(t,n,s){const o=(r,d)=>!!r&&!!d&&r.title===d.title&&(r.body||"")===(d.body||""),i=new Map;for(const r of s)i.set(r.entryId,r.after);const a=new Set(s.filter(r=>r.action==="upsert"&&xd.has(r.by||"")&&Date.parse(r.ts)>t&&o(r.after,i.get(r.entryId))).map(r=>r.entryId));return{remembered:n.filter(r=>r.createdAt>t&&jd.has(r.source?.kind||"")).length,evolved:a.size}}te({"harness.act.create":{zh:"新增",en:"Added"},"harness.act.revise":{zh:"修订",en:"Revised"},"harness.act.delete":{zh:"删除",en:"Removed"},"harness.act.rollback":{zh:"恢复上一版",en:"Restored previous version"},"harness.applied":{zh:"已生效",en:"Applied"},"harness.undone":{zh:"本次更新已撤销",en:"This update was undone"},"harness.evidence":{zh:"更新依据",en:"Reason for this update"},"harness.view":{zh:"查看进化记录",en:"View evolution record"},"harness.undo":{zh:"撤销本次更新",en:"Undo this update"},"harness.viewShort":{zh:"查看",en:"View"},"harness.undoShort":{zh:"撤销",en:"Undo"},"harness.undoConflict":{zh:"这条记录后来又改过。请打开进化记录调整,避免覆盖新的内容。",en:"This entry changed again later. Open the evolution record to revise it without overwriting newer changes."}});function bd({changes:t,sessionId:n}){const{t:s,locale:o}=U(),i=o==="zh"?"、":", ",a=de(n),r=[...new Set(t.map(b=>b.agent))].join(","),d=t.map(b=>b.rev).join(","),[u,v]=l.useState({}),[f,j]=l.useState(""),[y,p]=l.useState({}),w=M(b=>b.agentDefs);if(l.useEffect(()=>{if(!r)return;let b=!0;const x=()=>{for(const c of r.split(","))On(a,c).then(C=>{b&&v(m=>({...m,[c]:C.journal}))}).catch(()=>{})};return x(),window.addEventListener(Ve,x),()=>{b=!1,window.removeEventListener(Ve,x)}},[a.key,a.base,r,d]),!t.length)return null;const N=async b=>{if(!f){j(b.rev),p(x=>({...x,[b.rev]:""}));try{await co(a,b.agent,b.entryId,b.rev)}catch(x){p(c=>({...c,[b.rev]:x?.status===409?s("harness.undoConflict"):String(x?.message||x)}))}finally{j(""),window.dispatchEvent(new CustomEvent(Ve))}}};return e.jsx("div",{"data-harness-updates":!0,children:t.map(b=>{const x=u[b.agent],c=x?ii(x,b):null;return e.jsxs("article",{className:"self-row","data-harness-update":b.rev,"data-harness-state":c||void 0,children:[e.jsx(to,{size:15,className:"self-row-ic"}),e.jsxs("div",{className:"self-row-kind human-scope",children:[w.find(C=>C.slug===b.agent)?.name||b.agent," · ",s(`harness.act.${b.action}`)," · ",s(c==="undone"?"harness.undone":"harness.applied")]}),e.jsxs("div",{className:"self-row-main",children:[e.jsx("p",{children:e.jsx("strong",{children:b.title})}),e.jsx("p",{children:b.body}),!!b.tools?.length&&e.jsx("p",{children:s("settings.agents.harnessShelvedTools",{names:b.tools.join(i)})}),!!b.skills?.length&&e.jsx("p",{children:s("settings.agents.harnessShelvedSkills",{names:b.skills.join(i)})}),b.evidence&&e.jsxs("details",{children:[e.jsx("summary",{children:s("harness.evidence")}),e.jsx("p",{children:b.evidence})]})]}),e.jsxs("div",{className:"self-row-ops",children:[e.jsx("button",{type:"button",className:"self-act","aria-label":s("harness.view"),onClick:()=>at({kind:"agent",slug:b.agent,evolution:Date.now()}),children:s("harness.viewShort")}),c!=="undone"&&e.jsxs("button",{type:"button",className:"self-act","aria-label":s("harness.undo"),disabled:!!f||c!=="current",title:c==="superseded"?s("harness.undoConflict"):void 0,onClick:()=>{N(b)},children:[e.jsx(Et,{size:12}),s("harness.undoShort")]})]}),y[b.rev]&&e.jsx("p",{className:"self-row-note agent-profile-error",role:"alert",children:y[b.rev]})]},b.rev)})})}te({"selfUpdate.remembered":{zh:"记住了 {n} 件事",en:"Saved to memory: {n}"},"selfUpdate.forgot":{zh:"忘掉了 {n} 件事",en:"Removed from memory: {n}"},"selfUpdate.learned":{zh:"学到 {n} 个做法",en:"New in evolution record: {n}"},"selfUpdate.evolved":{zh:"进化记录更新 {n} 处",en:"Evolution record changes: {n}"},"selfUpdate.mem.agent":{zh:"记忆",en:"Memory"},"selfUpdate.mem.project":{zh:"项目记忆 · {name}",en:"Project memory · {name}"},"selfUpdate.mem.updated":{zh:"改写",en:"Rewritten"},"selfUpdate.mem.forgotten":{zh:"忘掉了一条记忆",en:"Removed one entry"},"selfUpdate.mem.undo":{zh:"撤销",en:"Undo"},"selfUpdate.mem.undoHint":{zh:"从记忆里删掉这一条,之后也不会被自动记回来",en:"Removes this entry from memory and keeps it from being saved again automatically"},"selfUpdate.mem.undone":{zh:"已撤销",en:"Undone"},"selfUpdate.mem.gone":{zh:"已不在记忆里",en:"No longer in memory"},"selfUpdate.mem.changed":{zh:"后来又改过",en:"Changed since"},"selfUpdate.mem.conflict":{zh:"这条记忆后来又改过,没有撤销。请到记忆里调整。",en:"This entry changed later, so it was not removed. Adjust it in memory instead."}});function kd(t,n){const s=n[t.scope];if(!s||!t.entryId)return"unknown";const o=s.find(i=>i.id===t.entryId);return o?o.content===t.content?"current":"changed":"gone"}function Sd({changes:t,sessionId:n,agentSlug:s}){const{t:o}=U(),i=de(n),[a,r]=l.useState({}),[d,u]=l.useState(new Set),[v,f]=l.useState(""),[j,y]=l.useState({}),p=t.some(m=>m.scope==="agent"),w=t.some(m=>m.scope==="project"),N=t.map(m=>m.callId).join(","),b=l.useCallback(()=>uo(i,s),[i.key,i.base,s]),x=l.useCallback(()=>ho(i,n).then(m=>m.memory),[i.key,i.base,n]),c=l.useCallback(async()=>{const[m,k]=await Promise.all([p?b().then(z=>z.entries,()=>{}):void 0,w?x().then(z=>z?.entries,()=>{}):void 0]);return{agent:m,project:k}},[p,w,b,x]);l.useEffect(()=>{let m=!0;return c().then(k=>{m&&r(k)}),()=>{m=!1}},[c,N]);const C=async m=>{if(!(v||!m.entryId)){f(m.callId),y(k=>({...k,[m.callId]:""}));try{const k=m.scope==="agent"?await b():await x(),z=k?.entries.find(g=>g.id===m.entryId);if(!k?.version||!z||z.content!==m.content)throw Object.assign(new Error("changed"),{status:409});m.scope==="agent"?await Wa(i,s,{action:"forget",id:m.entryId,expectedVersion:k.version}):await Va(i,n,m.entryId,k.version),u(g=>new Set(g).add(m.callId))}catch(k){y(z=>({...z,[m.callId]:k?.status===409?o("selfUpdate.mem.conflict"):String(k?.message||k)}))}finally{f(""),c().then(r)}}};return e.jsx("div",{"data-memory-updates":!0,children:t.map(m=>{const z=d.has(m.callId)?"undone":m.action==="forget"?"unknown":kd(m,a),g=z==="undone"?o("selfUpdate.mem.undone"):z==="gone"?o("selfUpdate.mem.gone"):z==="changed"?o("selfUpdate.mem.changed"):m.action==="update"?o("selfUpdate.mem.updated"):"";return e.jsxs("article",{className:"self-row","data-memory-update":m.entryId||m.callId,"data-memory-state":z,children:[e.jsx(Ha,{size:15,className:"self-row-ic"}),e.jsxs("div",{className:"self-row-kind",children:[m.scope==="project"?o("selfUpdate.mem.project",{name:m.project||""}):o("selfUpdate.mem.agent"),g&&e.jsxs(e.Fragment,{children:[" · ",g]})]}),e.jsx("div",{className:"self-row-main",children:e.jsx("p",{children:m.action==="forget"?o("selfUpdate.mem.forgotten"):m.content})}),m.action==="add"&&z==="current"&&e.jsx("div",{className:"self-row-ops",children:e.jsxs("button",{type:"button",className:"self-act",disabled:!!v,title:o("selfUpdate.mem.undoHint"),onClick:()=>{C(m)},children:[e.jsx(Et,{size:12}),o("selfUpdate.mem.undo")]})}),j[m.callId]&&e.jsx("p",{className:"self-row-note agent-profile-error",role:"alert",children:j[m.callId]})]},m.callId)})})}function zd({events:t,sessionId:n,agentSlug:s}){const{t:o}=U(),i=l.useMemo(()=>ai(t),[t]),a=l.useMemo(()=>oi(t),[t]),[r,d]=l.useState(!1),u=M(p=>(s&&s!=="__host__"?s:p.configBySession[n]?.agentSlug)||p.defaultAgentSlug),v=a.map(p=>p.rev).join(",");if(l.useEffect(()=>{v&&window.dispatchEvent(new CustomEvent(Ve))},[v]),!i.length&&!a.length)return null;const f=i.filter(p=>p.action==="forget").length,j=a.filter(p=>p.action==="create"&&p.kind!=="equip").length,y=[i.length-f?o("selfUpdate.remembered",{n:i.length-f}):"",f?o("selfUpdate.forgot",{n:f}):"",j?o("selfUpdate.learned",{n:j}):"",a.length-j?o("selfUpdate.evolved",{n:a.length-j}):""].filter(Boolean);return e.jsxs("details",{className:"self-receipt","data-self-receipt":!0,onToggle:p=>d(p.currentTarget.open),children:[e.jsxs("summary",{children:[e.jsx(qo,{size:15,className:"self-receipt-ic"}),e.jsxs("span",{children:[e.jsx("span",{className:"self-receipt-first",children:y[0]}),y.slice(1).map(p=>e.jsxs("span",{children:[" · ",p]},p))]}),e.jsx(xe,{size:12,className:"self-receipt-chev"})]}),r&&e.jsxs("div",{className:"self-rows",children:[!!i.length&&e.jsx(Sd,{changes:i,sessionId:n,agentSlug:u}),!!a.length&&e.jsx(bd,{changes:a,sessionId:n})]})]})}const Nd=({text:t,stored:n,anchorPrefix:s})=>{const{t:o}=U(),i=l.useRef(null),a=l.useRef(null),[r,d]=l.useState(!1),[u,v]=l.useState(!1),[f,j]=l.useState(0),[y,p]=l.useState(0),[w,N]=l.useState(!1),[b,x]=l.useState(null);l.useEffect(()=>()=>{i.current?.pause(),a.current&&URL.revokeObjectURL(a.current)},[]);const c=async()=>{if(i.current)return i.current;d(!0),x(null);try{const z=await Ka(Ne(),n,t);a.current=z;const g=new Audio(z);return g.onloadedmetadata=()=>j(g.duration||0),g.ontimeupdate=()=>p(g.currentTime||0),g.onended=()=>{v(!1),p(0)},g.onpause=()=>v(!1),g.onplay=()=>v(!0),i.current=g,g}catch(z){return x(z?.message==="EMPTY"||z?.message==="NO_MODEL"?o("tts.noText"):o("tts.failed",{e:z?.message||z})),null}finally{d(!1)}},C=async()=>{const z=await c();z&&(z.paused?z.play():z.pause())},m=f?Math.max(1,Math.round(f)):0,k=f?Math.min(100,y/f*100):0;return e.jsxs("div",{className:"t2-voice",children:[e.jsxs("div",{className:"t2-voice-bar",children:[e.jsx("button",{className:"t2-voice-play",onClick:C,title:o(u?"voice.pause":"voice.play"),children:r?e.jsx(Ye,{size:15,className:"spin"}):u?e.jsx(Ga,{size:15}):e.jsx(po,{size:15})}),e.jsx("div",{className:"t2-voice-track",children:e.jsx("span",{style:{width:`${k}%`}})}),e.jsx("span",{className:"t2-voice-dur",children:m?`${m}″`:o("voice.label")}),e.jsx("button",{className:"t2-voice-txt",onClick:()=>N(z=>!z),title:o("voice.toText"),children:e.jsx(qn,{size:13})})]}),b&&e.jsx("div",{className:"t2-dim",style:{marginTop:4},children:b}),w&&e.jsx("div",{className:"t2-content",style:{marginTop:6},children:e.jsx(Ke,{content:t,anchorPrefix:s})})]})},Cd=65536,ri=t=>new TextEncoder().encode(t).length>Cd,Pd=/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$/,Td=new Set(["__proto__","constructor","prototype"]);function se(t,n){throw new Error(`${t}: ${n}`)}function Me(t,n){return(!t||typeof t!="object"||Array.isArray(t))&&se(n,"expected object"),t}function ue(t,n,s=4e3){return(typeof t!="string"||!t.trim()||t.length>s)&&se(n,`expected nonempty string (max ${s})`),t}function je(t,n){const s=ue(t,n,80);return(!Pd.test(s)||Td.has(s))&&se(n,"invalid ID"),s}function ut(t,n,s=0,o=1e9){return(typeof t!="number"||!Number.isFinite(t)||t<s||t>o)&&se(n,`expected number in ${s}…${o}`),t}function Ie(t,n,s,o){return(!Array.isArray(t)||t.length>s)&&se(n,`expected array (max ${s})`),t.map((i,a)=>o(i,`${n}[${a}]`))}function Ze(t,n){return new Set(t.map(s=>s.id)).size!==t.length&&se(n,"duplicate IDs"),t}function li(t){if(typeof t!="string"||t.length>2048)return!1;try{const n=new URL(t),s=n.hostname.toLowerCase().replace(/\.+$/,"");return n.protocol==="https:"&&!n.username&&!n.password&&(!n.port||n.port==="443")&&s.includes(".")&&!s.endsWith(".local")&&!s.endsWith(".localhost")&&!s.endsWith(".internal")&&!/^[\d.]+$/.test(s)&&!s.includes(":")}catch{return!1}}function ci(t,n={}){ri(JSON.stringify(t)||"")&&se("document","too large");const s=Me(t,"document");s.version!==1&&se("version","expected 1");const o=Ze(Ie(s.inputs,"inputs",8,(y,p)=>{const w=Me(y,p),N={id:je(w.id,`${p}.id`),label:ue(w.label,`${p}.label`,160)};if(w.kind==="number"){const b=ut(w.min,`${p}.min`),x=ut(w.max,`${p}.max`,b),c=ut(w.step,`${p}.step`,.001),C=ut(w.initial,`${p}.initial`,b,x),m=(C-b)/c;return(Math.abs(m-Math.round(m))>1e-6||c>Math.max(x-b,1))&&se(p,"initial must align to step"),{...N,kind:"number",min:b,max:x,step:c,initial:C}}if(w.kind==="choice"){const b=Ze(Ie(w.options,`${p}.options`,8,(c,C)=>{const m=Me(c,C);return{id:je(m.id,`${C}.id`),label:ue(m.label,`${C}.label`,160),...m.description===void 0?{}:{description:ue(m.description,`${C}.description`,400)},...m.imageId===void 0?{}:{imageId:je(m.imageId,`${C}.imageId`)}}}),`${p}.options`);b.some(c=>c.imageId)&&!b.every(c=>c.imageId)&&se(p,"imageId must be set on every option or none");const x=je(w.initial,`${p}.initial`);return b.some(c=>c.id===x)||se(p,"initial must reference an option"),{...N,kind:"choice",options:b,initial:x}}return se(p,"unknown input kind")}),"inputs"),i=new Map(o.map(y=>[y.id,y])),a=(y,p)=>{if(y===void 0)return;const w=Me(y,p),N=je(w.input,`${p}.input`),b=i.get(N);return b||se(p,"unknown input"),(b.kind==="choice"?!b.options.some(x=>x.id===w.equals):typeof w.equals!="number"||w.equals<b.min||w.equals>b.max)&&se(p,"invalid condition value"),{input:N,equals:w.equals}},r=Ze(Ie(s.resources,"resources",24,(y,p)=>{const w=Me(y,p),N={id:je(w.id,`${p}.id`),url:ue(w.url,`${p}.url`,2048)};return li(N.url)||se(p,"expected public HTTPS URL without credentials"),w.kind==="image"?{...N,kind:"image",alt:ue(w.alt,`${p}.alt`,400),...w.sourceId===void 0?{}:{sourceId:je(w.sourceId,`${p}.sourceId`)}}:w.kind==="source"?{...N,kind:"source",title:ue(w.title,`${p}.title`,200),...w.description===void 0?{}:{description:ue(w.description,`${p}.description`)}}:se(p,"unknown resource kind")}),"resources"),d=new Map(r.map(y=>[y.id,y])),u=(y,p,w)=>{const N=je(y,p);return d.get(N)?.kind!==w&&se(p,`expected ${w} resource reference`),N};for(const y of r)y.kind==="image"&&y.sourceId&&u(y.sourceId,`${y.id}.sourceId`,"source");for(const y of o)if(y.kind==="choice")for(const p of y.options)p.imageId&&u(p.imageId,`${y.id}.${p.id}.imageId`,"image");const v=Ze(Ie(s.blocks,"blocks",40,(y,p)=>{const w=Me(y,p),N={id:je(w.id,`${p}.id`),...w.title===void 0?{}:{title:ue(w.title,`${p}.title`,200)},when:a(w.when,`${p}.when`)};switch(w.kind){case"app-card":return Ya(w.cardId)||se(p,"invalid registered card ID"),{...N,kind:"app-card",cardId:w.cardId,...w.query===void 0?{}:{query:ue(w.query,`${p}.query`,200)}};case"text":case"disclosure":return w.kind==="disclosure"&&!N.title&&se(p,"disclosure requires title"),{...N,kind:w.kind,markdown:ue(w.markdown,`${p}.markdown`,1e4)};case"controls":return{...N,kind:"controls",inputIds:Ie(w.inputIds,`${p}.inputIds`,8,(b,x)=>{const c=je(b,x);return i.has(c)||se(x,"unknown input"),c})};case"gallery":case"sources":return{...N,kind:w.kind,resourceIds:Ie(w.resourceIds,`${p}.resourceIds`,12,(b,x)=>u(b,x,w.kind==="gallery"?"image":"source"))};case"comparison":return{...N,kind:"comparison",items:Ze(Ie(w.items,`${p}.items`,6,(b,x)=>{const c=Me(b,x);return{id:je(c.id,`${x}.id`),title:ue(c.title,`${x}.title`,200),description:ue(c.description,`${x}.description`,1e3),facts:Ie(c.facts,`${x}.facts`,8,(C,m)=>ue(C,m,400)),...c.imageId===void 0?{}:{imageId:u(c.imageId,`${x}.imageId`,"image")}}}),`${p}.items`)};case"checklist":return{...N,kind:"checklist",items:Ze(Ie(w.items,`${p}.items`,100,(b,x)=>{const c=Me(b,x);let C;if(c.quantity!==void 0){const m=Me(c.quantity,`${x}.quantity`);C={value:ut(m.value,`${x}.quantity.value`),unit:ue(m.unit,`${x}.quantity.unit`,32)},m.scaleBy!==void 0&&(C.scaleBy=je(m.scaleBy,`${x}.quantity.scaleBy`),i.get(C.scaleBy)?.kind!=="number"&&se(x,"scaleBy must reference number input"),C.base=ut(m.base,`${x}.quantity.base`,.001))}return{id:je(c.id,`${x}.id`),label:ue(c.label,`${x}.label`,300),...c.itemKey===void 0?{}:{itemKey:je(c.itemKey,`${x}.itemKey`)},quantity:C,when:a(c.when,`${x}.when`)}}),`${p}.items`)};case"actions":return{...N,kind:"actions",items:Ze(Ie(w.items,`${p}.items`,6,(b,x)=>{const c=Me(b,x),C={id:je(c.id,`${x}.id`),label:ue(c.label,`${x}.label`,160)};return c.kind==="model"?{...C,kind:"model",prompt:ue(c.prompt,`${x}.prompt`,2e3)}:c.kind==="copy"?{...C,kind:"copy",text:ue(c.text,`${x}.text`,1e4)}:c.kind==="open"?{...C,kind:"open",resourceId:u(c.resourceId,`${x}.resourceId`,"source")}:se(x,"unknown action kind")}),`${p}.items`)};default:return se(p,"unknown block kind")}}),"blocks"),f=v.filter(y=>y.kind==="controls");v.reduce((y,p)=>y+(p.kind==="checklist"?p.items.length:0),0)>200&&se("checklist","max 200 items per document");const j=f.flatMap(y=>y.inputIds);return new Set(j).size!==j.length&&se("controls","each input must appear once"),f.some(y=>y.when)&&se("controls","controls must remain visible (no when)"),!n.draft&&o.some(y=>!j.includes(y.id))&&se("controls","every declared input must be included in a controls block"),{version:1,id:je(s.id,"id"),title:ue(s.title,"title",200),inputs:o,resources:r,blocks:v}}function Ed(t){if(ri(t))return;let n=!1,s=!1,o=0,i=-1;const a=[];for(let r=0;r<t.length;r++){const d=t[r];if(n){s?s=!1:d==="\\"?s=!0:d==='"'&&(n=!1);continue}if(d==='"'){n=!0;continue}if(d==="{"||d==="[")d==="["&&o===1&&/"blocks"\s*:\s*$/.test(t.slice(0,r))&&(i=r),o++;else if((d==="}"||d==="]")&&(o--,i>=0&&o===2&&d==="}"&&a.push(r),i>=0&&o===1))break}if(!(i<0))for(const r of[...a.reverse(),i])try{return ci(JSON.parse(t.slice(0,r+1)+"]}"),{draft:!0})}catch{}}function Rn(t,n){const s=Math.floor((n.max-n.min)/n.step+1e-6),o=Math.max(0,Math.min(s,Math.round((t-n.min)/n.step)));return Number((n.min+o*n.step).toPrecision(15))}function Ad(t,n){let s="",o=n+1;for(;o<t.length;){const i=t[o];if(i==='"')return s;if(i==="\\"){const a=t[o+1];if(a===void 0)break;switch(a){case"n":s+=`
33
- `;break;case"t":s+=" ";break;case"r":s+="\r";break;case"b":s+="\b";break;case"f":s+="\f";break;case"/":s+="/";break;case'"':s+='"';break;case"\\":s+="\\";break;case"u":{const r=t.slice(o+2,o+6);if(r.length<4||/[^0-9a-fA-F]/.test(r))return s;s+=String.fromCharCode(parseInt(r,16)),o+=4;break}default:s+=a}o+=2}else s+=i,o++}return s}const Es=new Map;function Rd(t){let n=Es.get(t);return n||(n=new RegExp(`"${t}"\\s*:\\s*"`),Es.set(t,n)),n}function Mn(t,n){for(const s of n){const o=Rd(s).exec(t);if(o)return Ad(t,o.index+o[0].length-1)}}const Md=["path","file_path","filename"],Id=["content","file_text","text","new_str","new_string"];function In(t,n){return t?Mn(t,[n]):void 0}function Ap(t){return t?{path:Mn(t,Md),content:Mn(t,Id)}:{}}const Zn=()=>({values:{},purchased:{},expanded:{}}),di="forsion_intelligent_ui_v1",ui=65536,As=(t,n,s)=>JSON.stringify([t,n,s,1]),_e=(t,n,s)=>JSON.stringify([t,n,s||null]);function _d(t){const n=Zn();if(!t||typeof t!="object")return n;for(const s of["values","purchased","expanded"]){const o=t[s];if(!(!o||typeof o!="object"||Array.isArray(o)))for(const[i,a]of Object.entries(o))i==="__proto__"||i==="constructor"||i==="prototype"||i.length>240||(s==="values"&&(typeof a=="string"&&a.length<=80||typeof a=="number"&&Number.isFinite(a))&&(n.values[i]=a),s==="purchased"&&(a===!0||typeof a=="number"&&Number.isFinite(a)&&a>=0)&&(n.purchased[i]=a),s==="expanded"&&typeof a=="boolean"&&(n.expanded[i]=a))}return n}function hi(t){const n=t.getItem(di);if(!n||n.length>ui*48)return[];let s;try{s=JSON.parse(n)}catch{return[]}return Array.isArray(s)?s.filter(o=>!!o&&typeof o.key=="string"&&o.key.length<1e3).slice(-48):[]}function $d(t,n){try{return _d(hi(n??localStorage).find(s=>s.key===t)?.state)}catch{return Zn()}}function Dd(t,n,s){try{if(new TextEncoder().encode(JSON.stringify(n)).length>ui)return;const o=s??localStorage;o.setItem(di,JSON.stringify([...hi(o).filter(i=>i.key!==t).slice(-47),{key:t,state:n}]))}catch{}}function Fd(t,n){return Object.fromEntries(t.inputs.map(s=>{const o=n.values[s.id];return[s.id,s.kind==="choice"?s.options.some(i=>i.id===o)?o:s.initial:typeof o=="number"&&Number.isFinite(o)?Rn(o,s):s.initial]}))}function _n(t,n){return!t||n[t.input]===t.equals}function Ld(t,n,s){const o=new Map;for(const i of t.items){if(!_n(i.when,n))continue;const a=i.quantity,r=JSON.stringify([t.id,i.itemKey||i.id,a?.unit||null]),d=a?a.value*(a.scaleBy?Number(n[a.scaleBy])/a.base:1):void 0,u=o.get(r);o.set(r,{key:r,label:u?.label||i.label,amount:d===void 0?void 0:d+(u?.amount||0),unit:a?.unit,checked:!1})}return[...o.values()].map(i=>{const a=s.purchased[i.key],r=i.amount===void 0?a===!0:typeof a=="number"&&a+1e-8>=i.amount;return{...i,checked:r,shortfall:!r&&typeof a=="number"&&a>0&&i.amount!==void 0?Math.max(0,i.amount-a):void 0}})}function It(t){return new Intl.NumberFormat(void 0,{maximumFractionDigits:2}).format(t)}te({"iui.cardLive":{zh:"实时",en:"Live"},"iui.cardUnavailable":{zh:"此卡片暂不可用,请启用对应功能或插件。",en:"This card is unavailable. Enable its feature or plugin."},"iui.cardFailed":{zh:"卡片加载失败,请重试。",en:"Card failed to load. Try again."},"iui.cardRetry":{zh:"重试",en:"Retry"},"iui.cardOpen":{zh:"打开完整视图",en:"Open full view"},"iui.cardEmpty":{zh:"没有匹配的条目",en:"No matching items"},"iui.cardSearch":{zh:"搜索此列表",en:"Search this list"},"iui.cardMore":{zh:"还有 {n} 项,可在完整视图中查看",en:"{n} more in the full view"}});class Od extends Xs.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?e.jsxs("div",{role:"status",children:[we("iui.cardFailed")," ",e.jsx("button",{onClick:()=>this.setState({failed:!1}),children:we("iui.cardRetry")})]}):this.props.children}}function qd({render:t}){const[n,s]=l.useState(!1),[o,i]=l.useState(!1);if(l.useEffect(()=>{let a=!0;return gt(()=>import("./appStore-CidPWYa0.js").then(r=>r.sq),__vite__mapDeps([2,1,3,4,5,6]),import.meta.url).then(r=>r.ensureAmadeusReady()).then(()=>{a&&s(!0)},()=>{a&&i(!0)}),()=>{a=!1}},[]),o)throw new Error("Native data source unavailable");return n?t():e.jsx("div",{role:"status",children:we("dashcompact.loading")})}function Bd({row:t}){const[n,s]=l.useState(!1);return e.jsx("span",{className:"iui-app-row-icon",children:t.iconUrl&&!n?e.jsx("img",{src:t.iconUrl,alt:"",onError:()=>s(!0)}):er(t.icon,e.jsx(tr,{}))})}function Ud({source:t,initialQuery:n}){const{t:s}=U(),{item:o,pluginId:i}=t,a=rt(p=>p.vaultRoot),[r,d]=l.useState(n||""),[,u]=l.useState(0),[v,f]=l.useState(!1);l.useEffect(()=>{const p=o.subscribe(()=>u(w=>w+1));return u(w=>w+1),p},[o,a]);const j=o.items(o.search?{query:r}:void 0),y=(p,w)=>{w&&nr(i),f(!1);try{Promise.resolve(o.open(p)).catch(()=>f(!0))}catch{f(!0)}};return e.jsxs("div",{className:"iui-app-list",children:[o.search&&e.jsxs("label",{className:"iui-app-search",children:[e.jsx(mo,{size:14}),e.jsx("input",{"aria-label":s("iui.cardSearch"),placeholder:s("iui.cardSearch"),value:r,onChange:p=>d(p.target.value)})]}),j.slice(0,6).map(p=>e.jsxs("button",{type:"button",className:"iui-app-row",onClick:w=>y(p,w.isTrusted),children:[e.jsx(Bd,{row:p},p.iconUrl??""),e.jsx("span",{children:p.title}),e.jsx("small",{children:p.hint})]},p.key)),!j.length&&e.jsx("p",{className:"iui-app-empty",children:s("iui.cardEmpty")}),j.length>6&&e.jsx("p",{className:"iui-app-empty",children:s("iui.cardMore",{n:j.length-6})}),v&&e.jsx("p",{role:"status",children:s("iui.cardFailed")})]})}function Hd({cardId:t,query:n}){const{t:s,locale:o}=U(),i=l.useSyncExternalStore(Ja,Qa),a=l.useSyncExternalStore(yn,()=>t.startsWith("native:")?jn(t.slice(7)):void 0),r=i.find(w=>`plugin:${w.pluginId}:${w.item.id}`===t),d=a?.intelligent?a.type:r?`plugin:${r.pluginId}:${r.item.intelligent.viewId}`:"",u=l.useSyncExternalStore(yn,()=>jn(d)),v=Kt(w=>r?w.plugins.find(N=>N.id===r.pluginId):void 0);if(!a?.intelligent&&!r||n!==void 0&&!r?.item.search)return e.jsx("div",{className:"iui-status","data-card-unavailable":t,role:"status",children:s("iui.cardUnavailable")});const f=v&&Xa(v,o),j=r?.item.title||"",y=a?typeof a.displayName=="function"?a.displayName():a.displayName:!f||j.includes(f)?j:f.includes(j)?f:`${f} · ${j}`,p=(a??u)?.icon??Ml;return e.jsxs("section",{className:"iui-app-card","data-app-card":t,"aria-label":y,children:[e.jsxs("header",{children:[v?.iconUrl?e.jsx(Za,{url:v.iconUrl,size:16}):e.jsx(p,{size:15,className:"iui-app-icon","aria-hidden":"true"}),e.jsx("strong",{children:y}),e.jsxs("span",{className:"iui-live",children:[e.jsx("i",{}),s("iui.cardLive")]}),u&&e.jsx("button",{type:"button",className:"iui-app-open","aria-label":s("iui.cardOpen"),title:s("iui.cardOpen"),onClick:()=>He.getState().openView(d,{},"main",{newTab:!0}),children:e.jsx(Do,{size:15})})]}),e.jsx(Od,{children:e.jsx("div",{className:"iui-app-body",children:e.jsx(qd,{render:()=>a?.intelligent?a.intelligent.render():e.jsx(Ud,{source:r,initialQuery:n})})})})]})}te({"iui.loading":{zh:"正在组织内容…",en:"Composing…"},"iui.incomplete":{zh:"内容尚未完整,已保留可用部分。",en:"This answer is incomplete. Available content is preserved."},"iui.invalid":{zh:"这部分界面未能生成,请查看工具结果或重新提问。",en:"This view could not be generated. Check the tool result or try again."},"iui.copy":{zh:"复制清单",en:"Copy list"},"iui.copied":{zh:"已复制",en:"Copied"},"iui.copyFailed":{zh:"复制失败,请重试",en:"Copy failed. Try again."},"iui.reset":{zh:"清空勾选",en:"Clear checks"},"iui.progress":{zh:"已完成 {done}/{total} 项",en:"{done} of {total} complete"},"iui.remaining":{zh:"还需 {quantity}",en:"{quantity} still needed"},"iui.expand":{zh:"展开原图",en:"View full image"},"iui.collapse":{zh:"收起原图",en:"Collapse image"},"iui.retry":{zh:"重新加载图片",en:"Retry image"},"iui.failedImage":{zh:"图片暂时无法加载",en:"Image unavailable"},"iui.current":{zh:"当前选择",en:"Current selections"},"iui.modelAction":{zh:"继续提问",en:"Ask a follow-up"}});function Wd(t,n){if(t.name!=="intelligent_ui"||!t.arguments)return{complete:!1};if(t.done&&!t.isError&&typeof t.result=="string"&&!/^Error[:\s]/i.test(t.result))try{return{doc:ci(JSON.parse(JSON.parse(t.arguments).document)),complete:!0}}catch{}const o=In(t.arguments,"document");return{doc:o?Ed(o):void 0,complete:!1}}function Rs({event:t,live:n,stateScope:s,onAsk:o}){const{t:i}=U(),a=l.useMemo(()=>Wd(t),[t.arguments,t.done,t.isError,t.result,n]),r=l.useRef(void 0);a.doc&&(r.current=a.doc);const d=a.doc||r.current;return d?e.jsx(Yd,{doc:d,complete:a.complete,live:n&&!t.done,stateKey:s?As(s,t.id,d.id):void 0,onAsk:o},As(s||"",t.id,d.id)):n&&!t.done?e.jsx("div",{className:"intelligent-ui",children:e.jsx($n,{})}):e.jsx("div",{className:"iui-status",role:"status",children:i("iui.invalid")})}function Ms({text:t}){return e.jsx(sr,{remarkPlugins:[oa],skipHtml:!0,disallowedElements:["img","input"],components:{a:({href:n,children:s})=>li(n)?e.jsx(yt,{href:n,children:s}):e.jsx("span",{children:s})},children:t})}function Is({resource:t,sources:n,expanded:s,onExpand:o}){const{t:i}=U(),[a,r]=l.useState(!1),[d,u]=l.useState(0),v=t.sourceId?n.get(t.sourceId):void 0;return e.jsxs("figure",{className:"iui-picture","data-expanded":s||void 0,children:[a?e.jsxs("div",{className:"iui-image-error",children:[e.jsx("span",{children:t.alt}),e.jsx("small",{children:i("iui.failedImage")}),e.jsx("button",{type:"button",onClick:()=>{r(!1),u(f=>f+1)},children:i("iui.retry")})]}):e.jsx("button",{type:"button",className:"iui-image-toggle","aria-label":i(s?"iui.collapse":"iui.expand"),"aria-expanded":s,onClick:()=>o(!s),children:e.jsx("img",{src:t.url,alt:t.alt,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>r(!0)},`${t.url}:${d}`)}),e.jsxs("figcaption",{children:[t.alt,v?.kind==="source"&&e.jsx(yt,{href:v.url,quote:"",children:new URL(v.url).hostname})]})]})}const Vd=new Set(["disclosure","checklist","app-card"]);function $n(){const{t}=U();return e.jsxs("div",{className:"iui-skeleton",role:"status","aria-label":t("iui.loading"),children:[e.jsx("i",{}),e.jsx("i",{}),e.jsx("i",{})]})}function Gd({name:t,option:n,resource:s,source:o,selected:i,onSelect:a,expanded:r,onExpand:d}){const{t:u}=U(),[v,f]=l.useState(!1),[j,y]=l.useState(0);return e.jsxs("div",{className:"iui-pick-card","data-selected":i||void 0,"data-expanded":r||void 0,children:[e.jsxs("label",{children:[e.jsx("input",{type:"radio",name:t,value:n.id,checked:i,onChange:a}),v?e.jsxs("span",{className:"iui-image-error",children:[e.jsx("span",{children:s.alt}),e.jsx("small",{children:u("iui.failedImage")})]}):e.jsx("img",{src:s.url,alt:s.alt,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>f(!0)},`${s.url}:${j}`),e.jsxs("span",{className:"iui-pick-text",children:[e.jsx("strong",{children:n.label}),n.description&&e.jsx("small",{children:n.description})]})]}),v?e.jsx("button",{type:"button",className:"iui-pick-tool",onClick:()=>{f(!1),y(p=>p+1)},children:u("iui.retry")}):e.jsx("button",{type:"button",className:"iui-pick-tool","aria-label":u(r?"iui.collapse":"iui.expand"),title:u(r?"iui.collapse":"iui.expand"),"aria-expanded":r,onClick:()=>d(!r),children:r?e.jsx(Kn,{size:13}):e.jsx(Ln,{size:13})}),o?.kind==="source"&&e.jsx(yt,{href:o.url,quote:"",children:new URL(o.url).hostname})]})}const Kd=t=>t.options.length<=4&&t.options.every(n=>!n.description)&&t.options.reduce((n,s)=>n+[...s.label].reduce((o,i)=>o+(i>"⹿"?2:1),0),0)<=36;function Yd({doc:t,complete:n,live:s,stateKey:o,onAsk:i}){const{t:a}=U(),[r,d]=l.useState(()=>o?$d(o):Zn()),[u,v]=l.useState(""),f=l.useRef(s).current,j=Fd(t,r),y=new Map(t.resources.map(C=>[C.id,C])),p=new Set(t.blocks.flatMap(C=>C.kind==="sources"&&_n(C.when,j)?C.resourceIds:[])),w=new Set(t.blocks.flatMap(C=>C.kind==="controls"?C.inputIds:[]).flatMap(C=>{const m=t.inputs.find(k=>k.id===C);return m?.kind==="choice"?m.options.flatMap(k=>k.imageId??[]):[]})),N=C=>d(m=>{const k=C(m);return o&&Dd(o,k),k}),b=async C=>{try{await navigator.clipboard.writeText(C),v(a("iui.copied"))}catch{v(a("iui.copyFailed"))}},x=(C,m)=>N(k=>k.expanded[C]===m?k:{...k,expanded:{...k.expanded,[C]:m}}),c=C=>{switch(C.kind){case"text":return e.jsx("div",{className:"iui-prose",children:e.jsx(Ms,{text:C.markdown})});case"controls":return e.jsx("div",{className:"iui-controls",children:C.inputIds.map(m=>{const k=t.inputs.find(B=>B.id===m),z=B=>N(_=>({..._,values:{..._.values,[m]:B}}));if(k.kind==="number")return e.jsxs("div",{className:"iui-number",role:"group","aria-label":k.label,children:[e.jsx("span",{children:k.label}),e.jsxs("div",{className:"iui-stepper",children:[e.jsx("button",{type:"button","aria-label":`${k.label} −`,disabled:Number(j[m])<=k.min,onClick:()=>z(Rn(Number(j[m])-k.step,k)),children:e.jsx(Il,{size:16})}),e.jsx("output",{"aria-live":"polite",children:It(Number(j[m]))}),e.jsx("button",{type:"button","aria-label":`${k.label} +`,disabled:Number(j[m])>=k.max,onClick:()=>z(Rn(Number(j[m])+k.step,k)),children:e.jsx(go,{size:16})})]})]},m);const g=`${o||t.id}:${m}`,A=!!k.options[0]?.imageId,P=A&&k.options.length===4?2:Math.min(3,k.options.length);return e.jsxs("fieldset",{className:`iui-choice${A?" iui-pick":Kd(k)?" iui-seg":""}`,children:[e.jsx("legend",{children:k.label}),e.jsx("div",{className:"iui-parallel","data-columns":P,children:k.options.map(B=>{const _=j[m]===B.id,V=B.imageId&&y.get(B.imageId);return V?e.jsx(Gd,{name:g,option:B,resource:V,source:V.sourceId&&!p.has(V.sourceId)?y.get(V.sourceId):void 0,selected:_,onSelect:()=>z(B.id),expanded:!!r.expanded[_e("image",C.id,B.imageId)],onExpand:$=>x(_e("image",C.id,B.imageId),$)},B.id):e.jsxs("label",{"data-selected":_||void 0,children:[e.jsx("input",{type:"radio",name:g,value:B.id,checked:_,onChange:()=>z(B.id)}),e.jsxs("span",{children:[e.jsx("strong",{children:B.label}),B.description&&e.jsx("small",{children:B.description})]})]},B.id)})})]},m)})});case"gallery":return e.jsx("div",{className:"iui-gallery",children:C.resourceIds.filter(m=>!w.has(m)).map(m=>e.jsx(Is,{resource:y.get(m),sources:y,expanded:!!r.expanded[_e("image",C.id,m)],onExpand:k=>x(_e("image",C.id,m),k)},m))});case"sources":return e.jsx("div",{className:"iui-sources",children:C.resourceIds.map(m=>{const k=y.get(m);return e.jsxs("div",{className:"iui-source",children:[e.jsxs(yt,{href:k.url,quote:"",children:[e.jsx("span",{children:k.title}),e.jsx("small",{children:new URL(k.url).hostname}),e.jsx(pt,{size:14})]}),k.description&&e.jsx("details",{open:!!r.expanded[_e("source",C.id,m)],onToggle:z=>x(_e("source",C.id,m),z.currentTarget.open),children:e.jsx("summary",{children:e.jsx("span",{children:k.description})})})]},m)})});case"app-card":return n?e.jsx(Hd,{cardId:C.cardId,query:C.query}):s?e.jsx($n,{}):e.jsx("div",{className:"iui-status",children:a("iui.incomplete")});case"comparison":return e.jsx("div",{className:"iui-parallel iui-comparison","data-columns":Math.min(3,C.items.length),children:C.items.map(m=>e.jsxs("article",{children:[m.imageId&&!w.has(m.imageId)&&e.jsx(Is,{resource:y.get(m.imageId),sources:y,expanded:!!r.expanded[_e("image",C.id,m.imageId)],onExpand:k=>x(_e("image",C.id,m.imageId),k)}),e.jsx("strong",{children:m.title}),e.jsx("p",{children:m.description}),e.jsx("ul",{children:m.facts.map((k,z)=>e.jsx("li",{children:k},z))})]},m.id))});case"checklist":{const m=Ld(C,j,r),k=m.filter(g=>g.checked).length,z=m.some(g=>g.amount===void 0||g.label.length>80);return e.jsxs("div",{className:"iui-checklist",children:[e.jsxs("div",{className:"iui-list-head",children:[C.title&&e.jsx("h4",{children:C.title}),e.jsx("span",{className:"iui-count","aria-live":"polite",children:C.title?`${k}/${m.length}`:a("iui.progress",{done:k,total:m.length})}),e.jsxs("div",{children:[e.jsx("button",{type:"button","aria-label":a("iui.copy"),title:a("iui.copy"),onClick:()=>{b(m.map(g=>`${g.checked?"☑":"☐"} ${g.label}${g.amount===void 0?"":` ${It(g.amount)} ${g.unit}`}`).join(`
34
- `))},children:e.jsx(st,{size:14})}),e.jsx("button",{type:"button","aria-label":a("iui.reset"),title:a("iui.reset"),disabled:!m.some(g=>r.purchased[g.key]!==void 0),onClick:()=>N(g=>({...g,purchased:Object.fromEntries(Object.entries(g.purchased).filter(([A])=>!m.some(P=>P.key===A)))})),children:e.jsx(At,{size:14})})]})]}),e.jsx("progress",{value:k,max:Math.max(1,m.length),"aria-label":a("iui.progress",{done:k,total:m.length})}),e.jsx("div",{className:z?"iui-check-rows iui-prose":"iui-check-rows",children:m.map(g=>e.jsxs("label",{"data-checked":g.checked||void 0,children:[e.jsx("input",{type:"checkbox",checked:g.checked,ref:A=>{A&&(A.indeterminate=!!g.shortfall)},onChange:()=>N(A=>{const P={...A.purchased};return g.checked?delete P[g.key]:P[g.key]=g.amount??!0,{...A,purchased:P}})}),e.jsxs("span",{children:[g.label,g.shortfall!==void 0&&e.jsx("small",{children:a("iui.remaining",{quantity:`${It(g.shortfall)} ${g.unit}`})})]}),g.amount!==void 0&&e.jsxs("span",{className:"iui-quantity",children:[It(g.amount)," ",g.unit]})]},g.key))})]})}case"disclosure":return e.jsxs("details",{open:!!r.expanded[_e("disclosure",C.id)],onToggle:m=>x(_e("disclosure",C.id),m.currentTarget.open),children:[e.jsxs("summary",{children:[C.title,e.jsx(ct,{size:16})]}),e.jsx("div",{className:"iui-detail-content iui-prose",children:e.jsx(Ms,{text:C.markdown})})]});case"actions":return e.jsx("div",{className:"iui-actions",children:C.items.map(m=>m.kind==="open"?e.jsxs(yt,{href:y.get(m.resourceId).url,quote:"",children:[m.label,e.jsx(pt,{size:14})]},m.id):m.kind==="copy"?e.jsxs("button",{type:"button",onClick:()=>{b(m.text)},children:[m.label,e.jsx(st,{size:14})]},m.id):e.jsxs("button",{type:"button",className:"t2-suggest-chip",disabled:!n||!i||s,title:a("iui.modelAction"),onClick:()=>{i?.(`${m.prompt}
35
-
36
- ${a("iui.current")} (${t.title}):
37
- ${t.inputs.map(k=>`${k.label}: ${k.kind==="choice"?k.options.find(z=>z.id===j[k.id])?.label:j[k.id]}`).join(`
38
- `)}`)},children:[e.jsx(fo,{size:13}),m.label]},m.id))})}};return e.jsxs("section",{className:"intelligent-ui","aria-label":t.title,"data-document-id":t.id,"data-complete":n,"data-streamed":f||void 0,children:[e.jsx("h3",{className:"iui-title",children:t.title}),t.blocks.filter(C=>_n(C.when,j)&&!(C.kind==="gallery"&&C.resourceIds.length&&C.resourceIds.every(m=>w.has(m)))).map(C=>e.jsxs("div",{className:`iui-block iui-block-${C.kind}`,"data-block-id":C.id,children:[C.title&&!Vd.has(C.kind)&&e.jsx("h4",{children:C.title}),c(C)]},C.id)),!n&&(s?e.jsx($n,{}):e.jsx("div",{className:"iui-status",role:"status",children:a("iui.incomplete")})),u&&e.jsxs("div",{className:"iui-notice",role:"status",children:[e.jsx(Bn,{size:14}),u]})]})}const Jd=({content:t})=>{const{t:n}=U(),[s,o]=l.useState(!1);return t?e.jsxs("div",{className:"thinking-block",children:[e.jsxs("button",{className:"thinking-toggle",onClick:()=>o(!s),children:[s?e.jsx(ct,{size:13}):e.jsx(xe,{size:13}),e.jsx(_l,{size:12}),n("chat.systemPrompt"),e.jsx("span",{style:{opacity:.7},children:n("thinking.charCount",{count:t.length})})]}),e.jsx(Ge,{open:s,children:e.jsx("pre",{className:"thinking-content",style:{whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:360,overflow:"auto",fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:"var(--ui-font-meta, 12px)",margin:0},children:t})})]}):null},be=23,Qd={up:{x:0,y:-1},right:{x:1,y:0},down:{x:0,y:1},left:{x:-1,y:0}},Xd={up:"down",right:"left",down:"up",left:"right"},_s=(t,n)=>t.x===n.x&&t.y===n.y;function pi(t,n){const s=[];for(let o=0;o<be;o++)for(let i=0;i<be;i++)t.some(a=>a.x===i&&a.y===o)||s.push({x:i,y:o});return s[Math.min(s.length-1,Math.floor(n()*s.length))]||{x:0,y:0}}function dn(t=Math.random){const n=Math.floor(be/2),s=Math.floor(be/2)+2,o=Array.from({length:5},(i,a)=>({x:s-a,y:n}));return{body:o,direction:"right",queuedDirection:"right",food:pi(o,t),score:0,alive:!0}}function Zd(t,n){return!t.alive||t.queuedDirection!==t.direction||Xd[t.direction]===n?t:{...t,queuedDirection:n}}function eu(t,n=Math.random){if(!t.alive)return t;const s=t.queuedDirection,o=Qd[s],i=t.body[0],r={x:(i.x+o.x+be)%be,y:i.y+o.y},d=_s(r,t.food),u=d?t.body:t.body.slice(0,-1),v=r.y<0||r.y>=be,f=u.some(y=>_s(y,r));if(v||f)return{...t,direction:s,queuedDirection:s,alive:!1};const j=[r,...t.body];return d||j.pop(),{body:j,direction:s,queuedDirection:s,food:d?pi(j,n):t.food,score:t.score+(d?1:0),alive:!0}}te({"imageGeneration.loading":{zh:"正在生成图片…",en:"Generating image…"},"imageGeneration.play":{zh:"点击点阵开启贪吃蛇彩蛋",en:"Click the dot grid to play Snake"},"imageGeneration.controls":{zh:"贪吃蛇:方向键、WASD 或滑动控制,再次点击退出",en:"Snake: use arrow keys, WASD, or swipe to steer; click again to exit"},"imageGeneration.snake":{zh:"贪吃蛇 · {score}",en:"Snake · {score}"},"imageGeneration.retry":{zh:"撞到了,马上再来一局…",en:"Game over — restarting…"}});const Dt=276,mi=12,tt=(Dt-mi*2)/(be-1);function ht(t,n,s){return getComputedStyle(t).getPropertyValue(n).trim()||s}function fi(t){const n=Math.min(window.devicePixelRatio||1,2),s=Math.round(Dt*n);(t.width!==s||t.height!==s)&&(t.width=s,t.height=s);const o=t.getContext("2d");return o?(o.setTransform(n,0,0,n,0,0),o.clearRect(0,0,Dt,Dt),o):null}function De(t){return mi+t*tt}function tu(t,n){const s=fi(t);if(!s)return;const o=ht(t,"--accent-ink","#4d7ff0"),i=ht(t,"--text-faint","#777"),a=n*42e-5,r=.5+Math.cos(a*1.13)*.2,d=.5+Math.sin(a*.91)*.2;for(let u=0;u<be;u++)for(let v=0;v<be;v++){const f=v/(be-1),j=u/(be-1),y=f-r,p=j-d,w=Math.exp(-(y*y/.055+p*p/.08)),N=.5+Math.sin(f*5.7+a*2.2)*.17,b=Math.exp(-Math.pow(j-N,2)/.024)*(.35+.3*Math.sin(a+f*3.4)),x=Math.max(0,Math.min(1,w*.92+b*.42));s.beginPath(),s.arc(De(v),De(u),1+x*2.05,0,Math.PI*2),s.fillStyle=x>.16?o:i,s.globalAlpha=.16+x*.78,s.fill()}s.globalAlpha=1}function un(t,n){const s=fi(t);if(!s)return;const o=ht(t,"--accent-ink","#4d7ff0"),i=ht(t,"--text-faint","#777"),a=ht(t,"--bg","#fff"),r=ht(t,"--danger","#b85848");for(let N=0;N<be;N++)for(let b=0;b<be;b++)s.beginPath(),s.arc(De(b),De(N),1,0,Math.PI*2),s.fillStyle=i,s.globalAlpha=.2,s.fill();s.globalAlpha=1,s.beginPath(),s.arc(De(n.food.x),De(n.food.y),tt*.42,0,Math.PI*2),s.fillStyle=r,s.fill(),n.body.forEach((N,b)=>{s.beginPath(),s.arc(De(N.x),De(N.y),tt*(b===0?.47:.4),0,Math.PI*2),s.fillStyle=n.alive?o:r,s.globalAlpha=b===0?1:Math.max(.48,.94-b*.035),s.fill()}),s.globalAlpha=1;const d=n.body[0];if(!d)return;const u={up:[0,-1],right:[1,0],down:[0,1],left:[-1,0]},[v,f]=u[n.direction],j=-f*tt*.14,y=v*tt*.14,p=v*tt*.15,w=f*tt*.15;for(const N of[-1,1])s.beginPath(),s.arc(De(d.x)+p+j*N,De(d.y)+w+y*N,.85,0,Math.PI*2),s.fillStyle=a,s.fill()}const nu=t=>({ArrowUp:"up",w:"up",W:"up",ArrowRight:"right",d:"right",D:"right",ArrowDown:"down",s:"down",S:"down",ArrowLeft:"left",a:"left",A:"left"})[t]||null;function su(){const{t}=U(),n=l.useRef(null),s=l.useRef(dn()),o=l.useRef(!1),i=l.useRef(null),a=l.useRef(!1),[r,d]=l.useState(!1),[u,v]=l.useState(0),[f,j]=l.useState(!1);l.useEffect(()=>{if(r)return;const m=n.current;if(!m)return;const k=window.matchMedia("(prefers-reduced-motion: reduce)");let z=0,g=-1/0;const A=_=>{_-g>=32&&(tu(m,k.matches?0:_),g=_),k.matches||(z=requestAnimationFrame(A))};A(0);const P=()=>{cancelAnimationFrame(z),g=-1/0,A(performance.now())};k.addEventListener?.("change",P);const B=new MutationObserver(P);return B.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-mode","data-skin","data-bg","data-theme"]}),()=>{cancelAnimationFrame(z),k.removeEventListener?.("change",P),B.disconnect()}},[r]),l.useEffect(()=>{if(!r)return;const m=n.current;if(!m)return;un(m,s.current);let k=0;const z=window.setInterval(()=>{if(o.current)return;const g=eu(s.current);s.current=g,v(g.score),un(m,g),g.alive||(o.current=!0,j(!0),k=window.setTimeout(()=>{const A=dn();s.current=A,o.current=!1,j(!1),v(0),un(m,A)},900))},118);return()=>{window.clearInterval(z),window.clearTimeout(k)}},[r]);const y=l.useCallback(()=>{if(r)return;const m=dn();s.current=m,o.current=!1,v(0),j(!1),d(!0)},[r]),p=l.useCallback(()=>{if(!r){y();return}o.current=!1,j(!1),d(!1)},[r,y]),w=l.useCallback(m=>{s.current=Zd(s.current,m)},[]),N=m=>{const k=nu(m.key);k&&(m.preventDefault(),r||y(),w(k))},b=m=>{a.current=!1,i.current={x:m.clientX,y:m.clientY},m.currentTarget.setPointerCapture?.(m.pointerId)},x=m=>{const k=i.current;if(i.current=null,!k||!r)return;const z=m.clientX-k.x,g=m.clientY-k.y;Math.max(Math.abs(z),Math.abs(g))<18||(a.current=!0,w(Math.abs(z)>Math.abs(g)?z>0?"right":"left":g>0?"down":"up"))},c=()=>{if(a.current){a.current=!1;return}p()},C=f?t("imageGeneration.retry"):r?t("imageGeneration.snake",{score:u}):t("imageGeneration.loading");return e.jsxs("div",{className:`image-generation-loader${r?" playing":""}`,"data-image-generation":r?"snake":"ambient",children:[e.jsx("div",{className:"image-generation-status",role:"status","aria-live":"polite",children:C}),e.jsx("button",{type:"button",className:"image-generation-stage","aria-label":t(r?"imageGeneration.controls":"imageGeneration.play"),title:t(r?"imageGeneration.controls":"imageGeneration.play"),onClick:c,onKeyDown:N,onPointerDown:b,onPointerUp:x,children:e.jsx("canvas",{ref:n,className:"image-generation-canvas","aria-hidden":"true"})})]})}te({"tool.parked.waiting":{zh:"已挂起,等你在输入框上方批准。Agent 先做别的,拍板后结果会补在这里。",en:"Parked until you approve it above the input box. The agent carries on meanwhile; the result lands here once you decide."},"tool.parked.past":{zh:"当时挂起等你批准,结局见后面的审批结果。",en:"This call was parked for your approval; see the approval result further down."},"tool.waitingYou":{zh:"等你回复",en:"Waiting for your reply"},"tool.verb.readComputerHistory":{zh:"读取电脑历史",en:"Read computer history"},"tool.computerHistory.notSaved":{zh:"电脑历史摘录已交给模型,不会保存在对话记录里。",en:"The computer history excerpt was passed to the model and isn’t saved in the conversation."}});const gi="read_computer_history";function ou(t,n){return t.name===gi&&!t.isError?n("tool.computerHistory.notSaved"):t.result||n("tool.empty")}const iu=new Set(["ask_user","exit_plan_mode"]);function zt(t){if(!t)return 0;const n=t.split(`
39
- `).length;return t.endsWith(`
40
- `)?n-1:n}function au(t){let n=0,s=0;for(const o of t.split(`
41
- `))/^\+(?!\+\+)/.test(o)?n++:/^-(?!--)/.test(o)&&s++;return{adds:n,dels:s}}const et=t=>t.split(/[/\\]/).filter(Boolean).pop()||t;function vi(t){let n={};try{n=t.arguments?JSON.parse(t.arguments):{}}catch{}const s=typeof n.path=="string"?n.path:"";switch(t.name){case"write_file":return{kind:"write",verbKey:"tool.verb.wrote",target:et(s),adds:zt(String(n.content??"")),dels:0,isFile:!0};case"edit_file":return{kind:"edit",verbKey:"tool.verb.edited",target:et(s),adds:zt(String(n.new_string??"")),dels:zt(String(n.old_string??"")),isFile:!0};case"multi_edit":{let o=0,i=0;if(Array.isArray(n.edits))for(const a of n.edits)o+=zt(String(a?.new_string??"")),i+=zt(String(a?.old_string??""));return{kind:"edit",verbKey:"tool.verb.edited",target:et(s),adds:o,dels:i,isFile:!0}}case"apply_patch":{const o=String(n.patch??n.input??n.diff??t.arguments??""),{adds:i,dels:a}=au(o),r=o.match(/(?:\*\*\* (?:Update|Add|Delete) File: |\+\+\+ |--- )([^\n]+)/);return{kind:"edit",verbKey:"tool.verb.edited",target:r?et(r[1].trim()):"patch",adds:i,dels:a,isFile:!0}}case"run_bash":case"run_background":return{kind:"run",verbKey:"tool.verb.ran",target:String(n.command??n.cmd??"").split(`
42
- `)[0],isFile:!1};case"run_python":return{kind:"run",verbKey:"tool.verb.ran",target:"python: "+String(n.code??"").split(`
43
- `)[0],isFile:!1};case"read_file":case"read_document":case"read_log":case"view_image":case"display_file":return{kind:"read",verbKey:"tool.verb.read",target:et(s||String(n.name??n.file??"")),isFile:!0};case"intelligent_ui":return{kind:"other",verbKey:"tool.verb.sketched",target:"Intelligent UI",isFile:!1};case"sketch":return{kind:"other",verbKey:"tool.verb.sketched",target:String(n.title??"")||"sketch",isFile:!1};case"desk_present":return{kind:"read",verbKey:"tool.verb.presented",target:(Array.isArray(n.views)?n.views:[]).map(a=>et(String(a?.path||""))).filter(Boolean).join(", ")||"Agent Desk",isFile:!0};case"list_dir":case"list_files":return{kind:"read",verbKey:"tool.verb.listed",target:et(s||"."),isFile:!0};case"search_files":case"glob_files":return{kind:"search",verbKey:"tool.verb.searched",target:String(n.query??n.pattern??n.glob??""),isFile:!1};case"web_search":return{kind:"search",verbKey:"tool.verb.searched",target:String(n.query??""),isFile:!1};case"web_fetch":return{kind:"browse",verbKey:"tool.verb.browsed",target:String(n.url??""),isFile:!1};case gi:return{kind:"read",verbKey:"tool.verb.readComputerHistory",target:String(n.query??n.app??""),isFile:!1};default:return t.name.startsWith("browser_")?{kind:"browse",verbKey:"tool.verb.browsed",target:String(n.url??n.text??t.name.replace("browser_","")),isFile:!1}:{kind:"other",verbKey:"",target:typeof n.command=="string"?n.command:typeof n.path=="string"?n.path:typeof n.query=="string"?n.query:(t.arguments||"").slice(0,80),isFile:!1}}}const $s=t=>{try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}},ru=({d:t})=>t.adds||t.dels?e.jsxs("span",{className:"tool-row-stat",children:[t.adds?e.jsxs("span",{className:"add",children:["+",t.adds]}):null,t.dels?e.jsxs("span",{className:"del",children:["-",t.dels]}):null]}):null,lu=({ev:t,desc:n,running:s,waiting:o,asking:i})=>{const{t:a}=U(),[r,d]=l.useState(!1),u=l.useMemo(()=>r?ra(t.name,t.arguments):null,[r,t.name,t.arguments]),v=n.verbKey?a(n.verbKey):t.name,f=s&&!t.done&&!i;return e.jsxs("div",{className:"tool-row",children:[e.jsxs("button",{className:"tool-row-head","aria-busy":f,onClick:()=>d(j=>!j),children:[r?e.jsx(ct,{size:12}):e.jsx(xe,{size:12}),e.jsx("span",{className:"tool-row-copy",children:e.jsxs("span",{className:`tool-row-copy-text${f?" chat-run-shimmer-text":""}`,children:[e.jsx("span",{className:"tool-row-verb",children:v}),e.jsx("span",{className:`tool-row-target${n.isFile?" file":""}`,children:n.target})]})}),e.jsx(ru,{d:n}),e.jsx("span",{className:"tool-row-status",children:i?e.jsx(zn,{size:11,style:{color:"var(--accent-ink)"},"data-waiting-you":"1","aria-label":a("tool.waitingYou"),children:e.jsx("title",{children:a("tool.waitingYou")})}):t.parked?e.jsx(zn,{size:11,style:{color:o?"var(--accent-ink)":"var(--text-faint)"}}):t.done&&t.isError?e.jsx(Xt,{size:11,style:{color:"var(--danger)"}}):null})]}),e.jsx(Ge,{open:r,children:e.jsxs("div",{className:"tool-card-body",children:[u?e.jsxs(e.Fragment,{children:[e.jsx(Wn,{text:u,side:!1}),t.arguments&&e.jsxs("details",{className:"tool-raw-args",children:[e.jsx("summary",{children:a("tool.argsLabel")}),$s(t.arguments)]})]}):t.arguments?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"label",children:a("tool.argsLabel")}),$s(t.arguments)]}):null,t.parked?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"label",children:a("tool.resultLabel")}),a(o?"tool.parked.waiting":"tool.parked.past")]}):t.result!==void 0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"label",children:a("tool.resultLabel")}),ou(t,a)]})]})})]})},Ds=({events:t,running:n,approvals:s,awaitingAnswer:o})=>{const{t:i}=U(),[a,r]=l.useState(!1),d=t.filter(P=>!pd(P));if(!d.length)return null;const u=n?d.filter(P=>(P.name==="generate_image"||P.name==="edit_image")&&!P.done):[],v=u.length?d.filter(P=>!u.includes(P)):d,f=v.map(vi),j={write:0,edit:0,run:0,read:0,search:0,browse:0,other:0};f.forEach(P=>{j[P.kind]++});const y={write:"tool.sum.wrote",edit:"tool.sum.edited",run:"tool.sum.ran",read:"tool.sum.read",search:"tool.sum.searched",browse:"tool.sum.browsed",other:"tool.sum.other"},w=["write","edit","run","read","search","browse","other"].filter(P=>j[P]>0).map(P=>i(y[P],{n:j[P]})).join(" · "),N=P=>!!o&&!!n&&!P.done&&iu.has(P.name),b=v.every(P=>P.done),x=v.some(P=>P.isError),c=new Set((s||[]).filter(P=>P.status==="pending"&&P.toolCallId).map(P=>P.toolCallId)),C=v.some(P=>P.parked),m=n?v.findIndex(P=>!P.done):-1,k=m>=0&&N(v[m]),z=!!n&&v.length>0&&!b&&!k,g=m>=0?f[m]:null,A=g?g.verbKey?i(g.verbKey):v[m].name:"";return e.jsxs(e.Fragment,{children:[!!v.length&&e.jsxs("div",{className:"tool-group",children:[e.jsxs("button",{className:"tool-group-head","aria-busy":z,onClick:()=>r(P=>!P),children:[a?e.jsx(ct,{size:13}):e.jsx(xe,{size:13}),e.jsx(Fl,{size:12,className:"tool-group-ic"}),!a&&k?e.jsx("span",{className:"tool-group-cur","data-waiting-you":"1",children:e.jsx("span",{className:"tool-group-cur-copy",children:i("tool.waitingYou")})}):!a&&g?e.jsx("span",{className:"tool-group-cur",children:e.jsxs("span",{className:"tool-group-cur-copy chat-run-shimmer-text",children:[A," ",e.jsx("span",{className:g.isFile?"file":void 0,children:g.target}),"…"]})}):e.jsx("span",{className:`tool-group-sum${z?" chat-run-shimmer-text":""}`,children:w}),e.jsx("span",{className:"tool-group-status",children:C?e.jsx(zn,{size:13,style:{color:v.some(P=>P.parked&&c.has(P.id))?"var(--accent-ink)":"var(--text-faint)"}}):b?x?e.jsx(Xt,{size:13,style:{color:"var(--danger)"}}):e.jsx(Un,{size:13,style:{color:"var(--green)"}}):null})]}),e.jsx(Ge,{open:a,children:e.jsx("div",{className:"tool-group-list",children:v.map((P,B)=>e.jsx(lu,{ev:P,desc:f[B],running:!!n,waiting:c.has(P.id),asking:N(P)},P.id))})})]}),!!u.length&&e.jsx("div",{className:"image-generation-jobs","aria-busy":"true",children:u.map(P=>e.jsx(su,{},P.id))})]})};function cu(t){const[n,s]=l.useState({id:"",at:0,count:1/0}),o=t.revealAt||0,i=!!o&&Date.now()-o<2e3&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches,a=n.id===t.id&&n.at===o?n.count:i?0:1/0;if(l.useLayoutEffect(()=>{if(!i||!t.content)return;const d=Array.from(t.content),u=Math.min(900,Math.max(180,d.length*3)),v=performance.now();let f=0;const j=()=>{const y=Math.min(1,(performance.now()-v)/u);s({id:t.id,at:o,count:y===1?1/0:Math.ceil(d.length*y)}),y<1&&(f=requestAnimationFrame(j))};return f=requestAnimationFrame(j),()=>cancelAnimationFrame(f)},[t.id,o,t.content]),!Number.isFinite(a))return t;const r=Array.from(t.content).slice(0,a).join("");return{...t,content:r,segments:r?[{t:"text",text:r}]:[],teamDone:!1}}te({"plan.approveGo":{zh:"批准并开始执行",en:"Approve & start"},"plan.approveEditedGo":{zh:"按我改的批准并执行",en:"Approve my edits & start"},"plan.approveManual":{zh:"批准,手动开始",en:"Approve, start manually"},"plan.edit":{zh:"编辑计划",en:"Edit plan"},"plan.sendBack":{zh:"打回",en:"Request changes"},"plan.reject":{zh:"拒绝",en:"Reject"},"plan.feedbackPlaceholder":{zh:"要改哪里?(反馈会发给 Agent 重做计划)",en:"What should change? (sent to the agent to revise the plan)"},"plan.sendFeedback":{zh:"发送反馈",en:"Send feedback"},"plan.doneApproved":{zh:"已批准",en:"Approved"},"plan.doneRevised":{zh:"已批准(按你修订的版本)",en:"Approved (your revised version)"},"plan.doneRejected":{zh:"已打回:{answer}",en:"Sent back: {answer}"},"plan.pointer":{zh:"等你拍板 · 在输入框上方",en:"Waiting for your decision · above the input box"},"plan.decisionTitle":{zh:"计划等你拍板(正文见对话里的计划卡)",en:"The plan needs your decision (full text in the plan card above)"}});const yi=({req:t,onAnswer:n})=>{const{t:s}=U(),[o,i]=l.useState(""),a=t.status==="pending";return e.jsxs("div",{className:`inquiry-card${a?"":" resolved"}`,children:[e.jsxs("div",{className:"inquiry-q",children:[e.jsx(Gn,{size:14}),t.question]}),a?e.jsxs(e.Fragment,{children:[t.options.length>0&&e.jsx("div",{className:"inquiry-opts",children:t.options.map((r,d)=>e.jsxs("button",{className:"btn ghost sm",style:{justifyContent:"flex-start"},onClick:()=>n(r),children:[d+1,". ",r]},d))}),e.jsxs("div",{className:"inquiry-input",children:[e.jsx("input",{type:"text",className:"inline-input",value:o,placeholder:t.options.length?s("inquiry.placeholderOrFree"):s("inquiry.placeholderAnswer"),onChange:r=>i(r.target.value),onKeyDown:r=>{r.key==="Enter"&&o.trim()&&!r.nativeEvent.isComposing&&(r.preventDefault(),n(o.trim()))}}),e.jsxs("button",{className:"btn primary sm",disabled:!o.trim(),onClick:()=>o.trim()&&n(o.trim()),children:[e.jsx(yo,{size:12})," ",s("inquiry.answer")]})]})]}):e.jsx("div",{className:"inquiry-resolved",children:t.status==="answered"?s("inquiry.answered",{answer:t.answer??""}):s("inquiry.expired")})]})},ji="批准,自动开始执行",xi="批准,退出计划模式(手动开始)",du="拒绝,保持计划模式",Dn=`
44
- <<<REVISED_PLAN>>>
45
- `,uu=/^(批准|同意|approve|approved|ok|yes|y)[!!。.]?$/i;function hu(t){const n=t.trim();return n===ji||n===xi||uu.test(n)}function pu(t){const n=t.indexOf(Dn);return n<0?{head:t.trim()}:{head:t.slice(0,n).trim(),revised:t.slice(n+Dn.length).trim()}}const mu=({plan:t,req:n})=>{const{t:s}=U(),o=n?.status==="answered"?pu(n.answer||""):null,i=o?.revised||t;return e.jsxs("div",{className:"plan-card",children:[e.jsxs("div",{className:"tg-card-title",children:["📋 ",s("inquiry.planProposal"),o&&e.jsx("span",{className:"plan-verdict",children:hu(o.head)?o.revised?s("plan.doneRevised"):s("plan.doneApproved"):s("plan.doneRejected",{answer:o.head.slice(0,60)})}),n?.status==="expired"&&e.jsx("span",{className:"plan-verdict",children:s("inquiry.expired")})]}),e.jsx("div",{className:"plan-body",children:e.jsx(Ke,{content:i})}),n?.status==="pending"&&e.jsxs("div",{className:"t2-dim t2-apv-pointer","data-plan-pointer":n.inquiryId,children:[e.jsx(Yt,{size:12})," ",s("plan.pointer")]})]})},fu=({plan:t,req:n,busy:s,onAnswer:o})=>{const{t:i}=U(),[a,r]=l.useState(t),[d,u]=l.useState(!1),[v,f]=l.useState(""),[j,y]=l.useState(!1),p=n.status==="pending"&&!s,w=b=>{p&&o(b)},N=b=>{if(!p)return;const x=b?ji:xi,c=d&&a.trim()&&a!==t?a.trim():"";w(c?`${x}${Dn}${c}`:x)};return e.jsxs("div",{className:"plan-decision","data-plan-decision":n.inquiryId,children:[e.jsxs("div",{className:"plan-decision-title",children:[e.jsx(Yt,{size:15})," ",i("plan.decisionTitle")]}),d&&e.jsx("textarea",{className:"approval-edit plan-edit",value:a,onChange:b=>r(b.target.value),spellCheck:!1,autoFocus:!0}),e.jsxs("div",{className:"approval-actions",children:[e.jsxs("button",{className:"btn primary sm",disabled:!p,onClick:()=>N(!0),children:[e.jsx(Bn,{size:13})," ",i(d&&a!==t?"plan.approveEditedGo":"plan.approveGo")]}),e.jsx("button",{className:"btn ghost sm",disabled:!p,onClick:()=>N(!1),children:i("plan.approveManual")}),e.jsxs("button",{className:"btn ghost sm",disabled:!p,onClick:()=>{u(b=>!b),r(t)},children:[e.jsx(xt,{size:13})," ",i(d?"common.cancel":"plan.edit")]}),e.jsxs("button",{className:"btn ghost sm",disabled:!p,onClick:()=>y(b=>!b),children:[e.jsx(Et,{size:13})," ",i("plan.sendBack")]}),e.jsx("button",{className:"btn danger sm",disabled:!p,onClick:()=>w(du),children:i("plan.reject")})]}),j&&e.jsxs("div",{className:"inquiry-input",children:[e.jsx("input",{type:"text",className:"inline-input",value:v,placeholder:i("plan.feedbackPlaceholder"),onChange:b=>f(b.target.value),onKeyDown:b=>{b.key==="Enter"&&v.trim()&&p&&!b.nativeEvent.isComposing&&(b.preventDefault(),w(v.trim()))}}),e.jsxs("button",{className:"btn primary sm",disabled:!v.trim()||!p,onClick:()=>v.trim()&&w(v.trim()),children:[e.jsx(yo,{size:12})," ",i("plan.sendFeedback")]})]})]})},gu=({todos:t})=>{const{t:n}=U(),s=t.filter(o=>o.status==="completed").length;return e.jsxs("div",{className:"todo-card",children:[e.jsxs("div",{className:"tg-card-title",children:["✓ ",n("inquiry.todoList")," ",e.jsxs("span",{className:"tg-count",children:["(",s,"/",t.length,")"]})]}),e.jsx("div",{className:"todo-rows",children:t.map((o,i)=>e.jsxs("div",{className:`todo-row ${o.status}`,children:[e.jsx("span",{className:`todo-mark ${o.status}`,children:o.status==="completed"?e.jsx(gc,{size:14}):o.status==="in_progress"?e.jsx(Ye,{size:14,className:"spin"}):e.jsx(vo,{size:14})}),e.jsx("span",{className:"todo-text",children:o.content})]},i))})]})};function vu(t,n,s){const o=p=>p.replace(/\\/g,"/"),i=o(t||"").replace(/\/+$/,""),a=o((n||"").trim());if(!i||!a)return null;const r=/^[a-zA-Z]:/.exec(i)?.[0]??"",u=/^([a-zA-Z]:)?\//.test(a)?a:`${i}/${a}`,v=/^[a-zA-Z]:/.exec(u)?.[0]??"",f=[];for(const p of u.slice(v.length).split("/"))if(!(!p||p===".")){if(p===".."){if(!f.length)return null;f.pop();continue}f.push(p)}const j=`${v}/${f.join("/")}`,y=p=>r?p.toLowerCase():p;return y(j)===y(i)?s?j:null:y(j).startsWith(`${y(i)}/`)?j:null}te({"creation.card.createTitle":{zh:"做成作品:{name}",en:"Make it a creation: {name}"},"creation.card.createBody":{zh:"在「造物」里给它建一个文件夹,把这条对话的工作目录切过去,接着在里面做。之后它会出现在造物里,有稳定的预览、桌面快捷方式和版本历史。",en:"Creates a folder for it in Creations, moves this conversation into that folder and keeps building there. It then shows up in Creations with a stable preview, a desktop shortcut and version history."},"creation.card.addTitle":{zh:"加入造物:{name}",en:"Add to Creations: {name}"},"creation.card.addBody":{zh:"把「{path}」原地加入造物,不复制也不移动。这条对话之后在它里面继续,它会出现在造物里,有稳定的预览和桌面快捷方式。",en:"Adds “{path}” to Creations where it is, without copying or moving it. This conversation continues in it, and it shows up in Creations with a stable preview and a desktop shortcut."},"creation.card.create":{zh:"做成作品",en:"Make it a creation"},"creation.card.add":{zh:"加入造物",en:"Add to Creations"},"creation.card.done":{zh:"已在造物里:{name}",en:"In Creations: {name}"},"creation.card.doneNewChat":{zh:"已在造物里建好「{name}」。这条对话没有挪过去,已切到在它里面新建对话。",en:"Created “{name}” in Creations. This conversation was not moved there, so a new conversation in it is ready."},"creation.card.openStudio":{zh:"在编码工作室中打开",en:"Open in Coding Studio"},"creation.card.openCreations":{zh:"在造物中查看",en:"View in Creations"},"creation.continuePrompt":{zh:"作品文件夹「{name}」已经建好,这条对话的工作目录已经切过去了。请在这里接着做。",en:"The creation folder “{name}” is ready and this conversation now works in it. Please continue building here."},"creation.err.running":{zh:"这条对话还在运行,等这一轮结束再点。",en:"This conversation is still running. Try again when this turn has finished."},"creation.err.outside":{zh:"卡片里的文件夹不在这条对话的工作目录里,不能从这里加入。",en:"The folder in this card is outside this conversation’s working folder, so it cannot be added from here."},"creation.err.invalid_source":{zh:"找不到要加入的文件夹。",en:"The folder to add was not found."},"creation.err.forbidden_source":{zh:"这个文件夹不能加入造物(比如家目录、造物自己的文件夹这类位置)。",en:"This folder cannot be added to Creations (for example your home folder or the Creations folder itself)."},"creation.err.nested":{zh:"这个文件夹在另一个造物里面,或者里面已经有造物了,不能再单独加入。",en:"This folder is inside another creation, or already contains one, so it cannot be added on its own."}});async function yu(t,n,s){const o=await window.tangu.productsRegister(t,n,s);if(!o.ok)throw new Error(we(`creation.err.${o.code}`));return{dir:o.dir,name:o.name}}function ju({cards:t,sessionId:n}){return!t.length||!window.tangu?.productsCreate||!window.tangu?.productsRegister?null:e.jsx("div",{className:"t2-tasks",children:t.map((s,o)=>e.jsx(xu,{card:s,sessionId:n},`${o}:${s.name}:${s.path||""}`))})}function xu({card:t,sessionId:n}){const{t:s}=U(),o=M(k=>n?k.sessions.find(z=>z.id===n):void 0),i=M(k=>n?k.configBySession[n]?.cwd:void 0),a=M(k=>k.defaultWsDir),r=i||o?.project_path||"",[d,u]=l.useState(!1);l.useEffect(()=>{let k=!0;return u(!1),r&&window.tangu?.productsIsCreation?.(r).then(z=>{k&&u(!!z)}).catch(()=>{}),()=>{k=!1}},[r]);const[v,f]=l.useState(!1),[j,y]=l.useState(""),[p,w]=l.useState(null),N=!!t.path,b=!!r&&Mt(r)!==Mt(a||""),x=N?vu(r,t.path,b):null,c=p??(d?{dir:r,name:o?.project_name||t.name,moved:!0}:null),C=async()=>{const k=window.tangu;if(!k?.productsCreate||!k.productsRegister||v)return;if(f(!0),y(""),n&&(M.getState().runningBySession[n]||!ir(n))){y(s("creation.err.running")),f(!1);return}let z=!1,g="";try{let A,P;if(N){if(!x)throw new Error(s("creation.err.outside"));({dir:A,name:P}=await yu(x,r,!b))}else{const V=await k.productsCreate(t.name);A=V.dir,P=V.name}const B=M.getState();z=!!r&&Mt(A)===Mt(r)||(n?await B.moveSessionToProject(n,A,P)==="moved":!1),z||(B.setNewChatWs({key:A,name:P,kind:"local",path:A}),B.setActiveId(null)),w({dir:A,name:P,moved:z}),g=P}catch(A){y(String(A?.message||A))}finally{n&&ar(n),f(!1)}z&&!N&&n&&M.getState().send(s("creation.continuePrompt",{name:g}),[],void 0,void 0,void 0,n)},m=()=>{c&&(vn("coding"),requestAnimationFrame(()=>{Sn.getState().openProject(c.dir,c.name)}))};return e.jsxs("div",{className:`t2-taskcard t2-creationcard${c?" done":""}${v?" busy":""}`,"data-creation-card":N?"add":"create",children:[e.jsxs("div",{className:"t2-taskcard-head",children:[N?e.jsx(ys,{size:13}):e.jsx(ot,{size:13})," ",e.jsx("b",{children:s(N?"creation.card.addTitle":"creation.card.createTitle",{name:t.name})})]}),e.jsx("div",{className:"t2-taskcard-tldr",children:s(N?"creation.card.addBody":"creation.card.createBody",{path:t.path||""})}),c?e.jsxs("div",{className:"t2-taskcard-done","data-creation-done":!0,children:[s(c.moved?"creation.card.done":"creation.card.doneNewChat",{name:c.name}),e.jsxs("div",{className:"t2-taskcard-actions",children:[e.jsxs("button",{onClick:m,children:[e.jsx(Ot,{size:12})," ",s("creation.card.openStudio")]}),e.jsxs("button",{onClick:()=>vn("artificial"),children:[e.jsx(or,{size:12})," ",s("creation.card.openCreations")]})]})]}):N&&!x?e.jsx("div",{className:"t2-taskcard-done",role:"alert",children:s("creation.err.outside")}):e.jsx("div",{className:"t2-taskcard-actions",children:e.jsxs("button",{className:"primary",disabled:v,onClick:()=>{C()},"data-creation-accept":!0,children:[v?e.jsx(Ye,{size:12,className:"spin"}):N?e.jsx(ys,{size:12}):e.jsx(ot,{size:12})," ",s(N?"creation.card.add":"creation.card.create")]})}),j&&e.jsx("div",{className:"t2-taskcard-done",role:"alert","data-creation-error":!0,children:j})]})}const hn=new Map,pn=new Set;function wu(t){let n=5381;for(let s=0;s<t.length;s++)n=(n<<5)+n+t.charCodeAt(s)|0;return(n>>>0).toString(36)}function bu(t,n,s){return`${t}:${n}:${wu(`${s.title}|${s.prompt}`)}`}function ku({tasks:t,ownerId:n,onTask:s,noHere:o=!1,todoStatus:i,onTodoRetry:a}){const{t:r}=U(),[d,u]=l.useState({}),[v,f]=l.useState(null),[j,y]=l.useState({});return t.length?e.jsx("div",{className:"t2-tasks",children:t.map((p,w)=>{const N=bu(n,w,p),b=d[N]??hn.get(N),x=!b&&p.todo&&i?i[p.todo]??"checking":"pending",c=x!=="pending",C=v===N,m=!!j[N],k=!!window.tangu?.backendStatus,z=async $=>{if(C||b||c||pn.has(N)||hn.has(N))return;pn.add(N),f(N);let q=!1;try{q=await s?.(p,$)!==!1}catch{q=!1}pn.delete(N),f(T=>T===N?null:T),q&&(hn.set(N,$),u(T=>({...T,[N]:$})))},g=($,q,T,L=!1)=>e.jsxs("button",{className:L?"primary":"",disabled:C,onClick:()=>{z($)},children:[q," ",T]},$),A=!!(p.track||p.todo)&&k,P=o?null:g("here",e.jsx(po,{size:12}),r("chat.task.here"),!A),B=g("new",e.jsx(Fo,{size:12}),r("chat.task.new"),o&&!A),_=k?g("muse",e.jsx(ot,{size:12}),r(p.todo?"chat.task.museDo":"chat.task.muse"),A):null,V=b==="here"?"chat.task.doneHere":b==="new"?"chat.task.doneNew":b==="muse"?p.todo?"chat.task.doneMuseDo":"chat.task.doneMuse":"chat.task.doneIgnore";return e.jsxs("div",{className:`t2-taskcard${b||c?" done":""}${C?" busy":""}`,children:[e.jsxs("div",{className:"t2-taskcard-head",children:[e.jsx(Yt,{size:13})," ",e.jsx("b",{children:p.title}),p.track&&e.jsx("span",{className:"t2-taskcard-tag",children:r("chat.task.trackTag")})]}),p.tldr&&e.jsx("div",{className:"t2-taskcard-tldr",children:p.tldr}),e.jsxs("button",{className:"t2-taskcard-toggle",onClick:()=>y($=>({...$,[N]:!m})),"aria-expanded":m,children:[m?e.jsx(ct,{size:12}):e.jsx(xe,{size:12})," ",r(m?"chat.task.hidePrompt":"chat.task.showPrompt")]}),m&&e.jsx("pre",{className:"t2-taskcard-prompt",children:p.prompt}),b?e.jsx("div",{className:"t2-taskcard-done",children:r(V)}):c?e.jsxs("div",{className:"t2-taskcard-done",children:[r(x==="checking"?"chat.task.todoChecking":x==="error"?"chat.task.todoCheckFail":x==="missing"?"chat.task.todoMissing":"chat.task.doneTodo"),x==="error"&&a&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{className:"t2-taskcard-toggle",onClick:a,children:r("inbox.approval.retry")})]})]}):e.jsxs("div",{className:"t2-taskcard-actions",children:[A?[_,P,B]:[P,B,_],g("ignore",e.jsx(lt,{size:12}),r("chat.task.ignore"))]})]},N)})}):null}function wi(t){if(!t.planProposal)return;const n=(t.inquiries||[]).filter(s=>s.kind==="plan");return n.find(s=>s.status==="pending")||n[n.length-1]}function Su(t){const n=[];for(const s of t||[]){const o=s.work&&s.agentName?{agentName:s.agentName}:{};for(const a of s.approvals||[])a.status==="pending"&&n.push({kind:"approval",id:a.approvalId,messageId:s.id,req:a,...o});const i=wi(s);for(const a of s.inquiries||[])a.status==="pending"&&(a===i&&s.planProposal?n.push({kind:"plan",id:a.inquiryId,messageId:s.id,req:a,plan:s.planProposal,...o}):n.push({kind:"inquiry",id:a.inquiryId,messageId:s.id,req:a,...o}))}return n}const bi="<approval_update>";function zu(t){return[...t.matchAll(/^\[(approved|rejected|failed)\] (\S+) \(call ([^)]*)\) — (.*)$/gm)].map(n=>({status:n[1],name:n[2],callId:n[3],preview:n[4]}))}function Nu(t,n){if(!n)return;let s;for(const o of t||[])for(const i of o.approvals||[])i.toolCallId===n&&(s=i);return s}te({"chat.team.working":{zh:"工作中 · {activity}",en:"Working · {activity}"},"chat.team.workingIdle":{zh:"工作中",en:"Working"},"chat.team.waiting":{zh:"等待你的审批",en:"Waiting for your approval"},"chat.team.waitingAnswer":{zh:"等你回答 · 在输入框上方",en:"Waiting for your answer · above the input box"},"chat.team.done":{zh:"已完成",en:"Done"},"chat.approval.pointer":{zh:"{name} 等你批准 · 在输入框上方",en:"{name} is waiting for your approval · above the input box"},"chat.approval.pointerN":{zh:"{n} 项操作等你批准 · 在输入框上方",en:"{n} actions are waiting for your approval · above the input box"},"chat.inquiry.pointer":{zh:"有问题等你回答 · 在输入框上方",en:"A question is waiting for your answer · above the input box"},"chat.inquiry.pointerN":{zh:"{n} 个问题等你回答 · 在输入框上方",en:"{n} questions are waiting for your answer · above the input box"},"chat.approval.update.approved":{zh:"已批准并执行 {name}",en:"Approved and ran {name}"},"chat.approval.update.failed":{zh:"已批准,{name} 执行出错",en:"Approved; {name} ran with an error"},"chat.approval.update.rejected":{zh:"已拒绝 {name}(没有执行)",en:"Rejected {name} (not run)"},"chat.approval.update.byApproved":{zh:"{where}批准",en:"Approved {where}"},"chat.approval.update.byRejected":{zh:"{where}拒绝",en:"Rejected {where}"}});const Cu={approved:"chat.approval.update.approved",failed:"chat.approval.update.failed",rejected:"chat.approval.update.rejected"};function Pu(t){if(t.name!=="sketch"||t.done||!t.arguments)return;const n=In(t.arguments,"html");if(!n||!n.trim())return;const s=In(t.arguments,"title");return{callId:t.id,html:n,...s?{title:s}:{},draft:!0}}function Tu(t,n,s=!1){const o=new Map((n||[]).map(d=>[d.callId,d])),i=[];let a=[];const r=()=>{a.length&&i.push({t:"tools",events:a}),a=[]};for(const d of t){if(a.push(d),d.name==="intelligent_ui"){r(),i.push({t:"intelligent",event:d});continue}const u=o.get(d.id)??(s?Pu(d):void 0);u&&(r(),i.push({t:"sketch",item:u}))}return r(),i}function Fs(t){const n=(t||"").trim();return n?Array.from(n)[0].toUpperCase():"?"}const ki=/provided authentication token is expired|try signing in again/i,Eu=[[ki,"chat.err.subExpired"],[/token_quota_exceeded/i,"chat.err.quota"],[/engine_unavailable_remote/i,"chat.err.engineRemote"],[/run_cost_exceeded/i,"chat.err.runCost"],[/input_too_large/i,"chat.err.inputTooLarge"],[/group_needs_2_agents/i,"chat.err.groupAgents"],[/^orphaned$|stale: process restarted/i,"chat.err.orphaned"],[/fetch failed|ECONNREFUSED|ENOTFOUND|EAI_AGAIN/i,"chat.err.network"],[/terminated|ECONNRESET|socket hang up|premature close/i,"chat.err.dropped"],[/ETIMEDOUT|timed? ?out/i,"chat.err.timeout"],[/(^|\D)(401|403)(\D|$)|unauthorized|invalid[ _-]?api[ _-]?key/i,"chat.err.auth"],[/(^|\D)429(\D|$)|rate[ _-]?limit|insufficient[ _-]?quota/i,"chat.err.rate"],[/(^|\D)5\d\d(\D|$)|bad gateway|overloaded/i,"chat.err.server"]];function Si(t,n){if(!t)return n("chat.error");const s=Eu.find(([o])=>o.test(t));return s?`${n(s[1])}(${t})`:t}te({"chat.err.subExpired":{zh:"直连账号的登录已过期,需要重新登录",en:"Your direct-connection sign-in has expired — please sign in again"},"chat.err.relogin":{zh:"重新登录 {provider}",en:"Sign in to {provider} again"},"rewind.title":{zh:"回退到这条消息",en:"Rewind to this message"},"rewind.counting":{zh:"正在统计改动…",en:"Counting changes…"},"rewind.codeOnly":{zh:"仅回退代码({n} 个文件)",en:"Code only ({n} file(s))"},"rewind.convOnly":{zh:"仅回退对话(原文回输入框)",en:"Conversation only (prompt back in the box)"},"rewind.both":{zh:"代码 + 对话都回退",en:"Both code and conversation"},"rewind.scopeNote":{zh:"只覆盖 Agent 经内置写文件工具(write/edit/multi_edit/apply_patch)改过的文件;终端命令与插件/MCP 工具改的不在内。",en:"Covers only files changed through the built-in file-writing tools (write/edit/multi_edit/apply_patch); changes made by shell commands or plugin/MCP tools are not included."},"rewind.skippedNote":{zh:"另有 {n} 个文件当时太大未存快照,恢复不了。",en:"{n} file(s) were too large to snapshot and cannot be restored."},"rewind.keepNote":{zh:"Agent 新建、之后又被改动过的文件会原样保留,不会被删。",en:"Files the agent created that changed afterwards are kept as-is, never deleted."}});function Au(t,n){if(!t||!ki.test(t))return null;const s=(n||"").split("/")[0];return s&&s in jo?s:null}function zi({error:t,modelId:n}){const{t:s}=U(),o=Au(t,n);return!o||!window.tangu?.providerLogin?null:e.jsxs("button",{className:"t2-relogin",onClick:()=>M.getState().openSettings("model/m-providers"),children:[e.jsx(mr,{size:12})," ",s("chat.err.relogin",{provider:jo[o]})]})}function Ru({reasoning:t}){const{t:n}=U(),[s,o]=l.useState(!1);return e.jsxs("div",{className:"t2-think",children:[e.jsxs("button",{className:"t2-think-head",onClick:()=>o(i=>!i),children:[s?e.jsx(ct,{size:13}):e.jsx(xe,{size:13})," ✦ ",n("thinking.process")," ",e.jsxs("span",{className:"t2-dim",children:["· ",n("thinking.charCount",{count:t.length})]})]}),e.jsx(Ge,{open:s,children:e.jsx("div",{className:"t2-think-body",children:t})})]})}function Ni(t,n){return!n?.sessionId||!t?Promise.resolve({files:0,skipped:0}):fr(de(n.sessionId),n.sessionId).then(s=>{const o=new Set,i=new Set;for(const a of s)a.at<t||(a.files.forEach(r=>o.add(r)),a.skipped.forEach(r=>i.add(r)));return i.forEach(a=>o.delete(a)),{files:o.size,skipped:i.size}}).catch(()=>({files:0,skipped:0}))}function Mu(t,n,s){const o=t?.files??0;return[{id:"code",label:t?n("rewind.codeOnly",{n:o}):n("rewind.counting"),icon:e.jsx(Ql,{size:14}),disabled:!o,run:()=>s("code")},{id:"conversation",label:n("rewind.convOnly"),icon:e.jsx(gr,{size:14}),run:()=>s("conversation")},{id:"both",label:n("rewind.both"),icon:e.jsx(Pt,{size:14}),disabled:!o,run:()=>s("both")}]}function Iu(t,n,s,o,i,a,r=Ni){return!1}const _u=({at:t,ctx:n,onPick:s})=>{const{t:o}=U(),[i,a]=l.useState(null),[r,d]=l.useState(!1),u=l.useRef(null),v=pr(!0,{boundary:".t2-chat-view"});return l.useEffect(()=>{let f=!0;return Ni(t,n).then(j=>{f&&a(j)}),()=>{f=!1}},[t,n?.sessionId,n?.cfg]),l.useLayoutEffect(()=>{const f=u.current;if(!f)return;const j=document.querySelector(".composer-anchor")?.getBoundingClientRect().top??window.innerHeight;f.getBoundingClientRect().bottom>j-4&&d(!0)},[i]),e.jsxs("div",{ref:f=>{u.current=f,v.ref.current=f},className:`composer-menu rewind-menu left${r?" up":""}`,style:v.style,children:[e.jsx("div",{className:"menu-section",children:o("rewind.title")}),Mu(i,o,s).map(f=>e.jsxs("button",{className:"menu-item",disabled:f.disabled,onClick:f.run,children:[f.icon,e.jsx("span",{className:"grow",children:f.label})]},f.id)),e.jsxs("div",{className:"menu-section rewind-note",children:[o("rewind.scopeNote")," ",o("rewind.keepNote"),!!i?.skipped&&e.jsxs(e.Fragment,{children:[" ",o("rewind.skippedNote",{n:i.skipped})]})]})]})};function $u({sessionId:t,callId:n,status:s}){const{t:o}=U(),i=M(d=>t?Nu(d.messagesBySession[t],n):void 0),a=cr(t);if(!i?.answeredBy)return null;const r=dr(i.answeredBy,{remotePage:ua(t),answeredHere:da(i.approvalId),hostName:a},o);return r?e.jsx("div",{className:"t2-apv-update-by","data-answered-by":!0,children:o(s==="rejected"?"chat.approval.update.byRejected":"chat.approval.update.byApproved",{where:r})}):null}function Ls({onInsert:t}){const{t:n}=U(),s=od();if(s==="hidden")return null;const o=s==="ready";return e.jsx("button",{className:"t2-iconbtn","data-act":"insert-note","aria-disabled":o?void 0:!0,title:n(o?"chat.action.insertNote":"chat.insertNote.none"),"aria-label":n("chat.action.insertNote"),onClick:t,children:e.jsx(Dl,{size:14})})}function Du({msg:t,avatarUrl:n,agentNameFallback:s,userName:o,userAvatar:i,handlers:a,fileCtx:r,rootRef:d,speakState:u,voice:v,modelId:f,showWaitDetails:j=!1,footer:y}){const p=r?.sessionId,w=l.useMemo(()=>p?{cwd:M.getState().configBySession[p]?.cwd||M.getState().sessions.find(F=>F.id===p)?.project_path||void 0,onRun:F=>{M.getState().send(rr(F),[],void 0,void 0,void 0,p)}}:void 0,[p]),N=r?.execMode,b=l.useMemo(()=>p&&xn!=="mobile"&&window.tangu?.readHostFile?{execMode:N}:void 0,[p,N]),{t:x}=U();t=cu(t);const[c,C]=l.useState(!1),[m,k]=l.useState(!1),[z,g]=l.useState(!1),A=l.useRef(null);if(l.useEffect(()=>()=>{A.current?.abort(),A.current=null},[t.id,p]),l.useEffect(()=>{if(!m)return;const F=oe=>{oe.target?.closest?.("[data-cmenu]")||k(!1)},X=oe=>{oe.key==="Escape"&&k(!1)};return document.addEventListener("mousedown",F),document.addEventListener("keydown",X),()=>{document.removeEventListener("mousedown",F),document.removeEventListener("keydown",X)}},[m]),t.role==="system"){if(t.groupVote){const F=t.groupVote;return e.jsxs("div",{ref:d,className:"t2-sys",children:[e.jsx("span",{className:"t2-dim",children:x("group.vote.round",{round:F.round})})," ",e.jsx("b",{children:x("group.vote.tally",{end:F.endCount,total:F.total})})]})}return t.content?e.jsx("div",{ref:d,className:"t2-sys",children:t.content}):null}if(t.role==="user"){if(t.content.startsWith("<turn_interrupted>"))return e.jsxs("div",{ref:d,className:"t2-sys t2-interrupted",children:["⏹ ",x("msg.interrupted")]});if(t.content.startsWith(bi)){const Q=zu(t.content);return e.jsx("div",{ref:d,className:"t2-sys t2-apv-update","data-approval-update":Q.length,children:Q.map(J=>e.jsxs(l.Fragment,{children:[e.jsxs("div",{className:"t2-apv-update-row","data-status":J.status,children:[J.status==="approved"?e.jsx(Un,{size:12}):e.jsx(Xt,{size:12}),e.jsx("span",{className:"t2-apv-update-what",children:x(Cu[J.status],{name:J.name})}),e.jsx("span",{className:"t2-apv-update-preview",title:J.preview,children:J.preview})]}),e.jsx($u,{sessionId:p,callId:J.callId,status:J.status})]},J.callId))})}const F=o||x("chat.you"),X=la(t.content),oe=X?X.body.trim()||X.refs.map(Q=>Q.name).join(" "):t.content,pe=()=>{if(!m){A.current?.abort();const Q=new AbortController;if(A.current=Q,Iu(t.timestamp,r,x,J=>a?.onRewind?.(J),()=>k(!0),Q.signal))return;A.current=null}k(Q=>!Q)},D=Q=>{[...a?.onCopy?[{label:x("chat.action.copy"),icon:e.jsx(st,{size:14}),run:()=>a.onCopy?.(t.content)}]:[],...a?.onEdit?[{label:x("chat.action.edit"),icon:e.jsx(xt,{size:14}),run:()=>a.onEdit?.()}]:[],...a?.onRewind?[{label:x("rewind.title"),icon:e.jsx(Pt,{size:14}),run:pe}]:[]]};return e.jsxs("div",{ref:d,className:`t2-userwrap${z?" t2-userwrap--inline":""}`,id:`tocmsg-${t.id}`,"data-toc-msg-role":"user","data-toc-title":oe,children:[e.jsxs("div",{className:"t2-user-col",children:[e.jsx("div",{className:"t2-username",children:F}),e.jsxs("div",{className:"t2-user",onContextMenu:D,children:[!!t.attachments?.length&&e.jsx("div",{className:"msg-attach-grid",children:t.attachments.map((Q,J)=>Q.mimeType?.startsWith("image/")&&Q.data?e.jsx("img",{className:"msg-attach-img",src:`data:${Q.mimeType};base64,${Q.data}`,alt:Q.name,title:Q.name},`${Q.name}-${J}`):e.jsxs("span",{className:"msg-attach-file",title:Q.name,children:["📎 ",Q.name]},`${Q.name}-${J}`))}),X&&e.jsx("div",{className:"t2-user-refs",children:X.refs.map((Q,J)=>e.jsx(ca,{chip:Q,children:Q.wiki?e.jsx(lr,{inner:Q.wiki}):void 0},`${Q.token}-${J}`))}),X?X.body&&e.jsx(ls,{text:X.body}):e.jsx(ls,{text:t.content})]}),e.jsxs("div",{className:"t2-actions",children:[e.jsx(Os,{at:t.timestamp}),e.jsx("button",{className:"t2-iconbtn",title:x("chat.action.copy"),onClick:()=>a?.onCopy?.(t.content),children:e.jsx(st,{size:14})}),e.jsx("button",{className:"t2-iconbtn",title:x("chat.action.edit"),onClick:()=>a?.onEdit?.(),children:e.jsx(xt,{size:14})}),a?.onRewind&&e.jsxs("span",{style:{position:"relative",display:"inline-flex"},"data-cmenu":!0,children:[e.jsx("button",{className:"t2-iconbtn","data-act":"rewind",title:x("rewind.title"),onClick:pe,children:e.jsx(Pt,{size:14})}),m&&e.jsx(_u,{at:t.timestamp,ctx:r,onPick:Q=>{k(!1),a.onRewind?.(Q)}})]})]})]}),e.jsx("div",{className:"t2-avatar t2-user-avatar",style:i?void 0:{background:"color-mix(in srgb, var(--text-muted) 22%, transparent)"},children:i?e.jsx("img",{src:i,alt:""}):Fs(F)})]})}const P=t.status==="streaming",B=window.tangu?.productsRegister?["suggest","task","creation"]:["suggest","task"],{text:_,items:V,tasks:$,creations:q}=cs(t.content,{streaming:P,kinds:B}),T=a?.onInsertNote?F=>e.jsx(Ls,{onInsert:()=>a.onInsertNote?.($l(F.html))}):void 0,L=wi(t),G=(t.approvals||[]).filter(F=>F.status==="pending"),ee=(t.inquiries||[]).filter(F=>F!==L&&F.status==="pending"),re=ee.length>0||L?.status==="pending",Z=!!v?.on&&(t.status==="done"||t.status==="stopped"),H=new Set((t.sketches||[]).map(F=>F.callId)),he=new Set;if(!Z){for(const F of t.segments||[])if(F.t==="tools")for(const X of F.ids)H.has(X)&&he.add(X)}const le=new Set(Z?[]:(t.segments||[]).flatMap(F=>F.t==="tools"?F.ids:[])),W=(t.toolEvents||[]).filter(F=>F.name==="intelligent_ui"&&!le.has(F.id)),K=(t.sketches||[]).filter(F=>!he.has(F.callId));return e.jsxs("div",{ref:d,className:"t2-asst",id:`tocmsg-${t.id}`,children:[e.jsx("div",{className:"t2-avatar",style:!n&&t.agentColor?{background:t.agentColor,color:"#fff"}:void 0,children:n?e.jsx("img",{src:n,alt:""}):Fs(t.agentName||s||"Tangu")}),e.jsxs("div",{className:"t2-asst-col",children:[e.jsxs("div",{className:"t2-name",style:t.agentColor?{color:t.agentColor}:void 0,children:[t.agentName||s||"Tangu",t.status==="streaming"&&e.jsx("span",{className:"t2-dot"})]}),t.systemPrompt&&e.jsx(Jd,{content:t.systemPrompt}),t.reasoning&&e.jsx(Ru,{reasoning:t.reasoning}),(()=>{if(t.segments?.length&&!Z){let F;const X=t.segments.reduce((oe,pe,D)=>pe.t==="text"?D:oe,-1);return t.segments.map((oe,pe)=>{if(oe.t==="text"){const J=cs(oe.text,{streaming:P||pe!==X,state:F,kinds:B});F=J.state;const fe=J.text;return fe?e.jsx("div",{className:"t2-content",children:e.jsx(Ke,{content:fe,anchorPrefix:`toc-${t.id}`,run:w,embeds:b})},pe):null}const D=oe.ids.map(J=>t.toolEvents?.find(fe=>fe.id===J)).filter(Boolean),Q=Tu(D,t.sketches,P);return Q.length?e.jsx(l.Fragment,{children:Q.map((J,fe)=>J.t==="tools"?e.jsx(Ds,{events:J.events,running:t.status==="streaming",approvals:t.approvals,awaitingAnswer:re},`tools-${J.events.map(Ce=>Ce.id).join("-")}-${fe}`):J.t==="intelligent"?e.jsx(Rs,{event:J.event,live:P,stateScope:p?`${p}:${t.id}`:void 0,onAsk:a?.onSuggest},`intelligent-${J.event.id}`):e.jsx(vs,{items:[J.item],actions:T,stateScope:p?`${p}:${t.id}`:void 0,onAsk:a?.onSuggest},`sketch-${J.item.callId}`))},pe):null})}return e.jsxs(e.Fragment,{children:[!!t.toolEvents?.length&&e.jsx(Ds,{events:t.toolEvents,running:t.status==="streaming",approvals:t.approvals,awaitingAnswer:re}),_&&(Z?e.jsx(Nd,{text:_,stored:v.stored,anchorPrefix:`toc-${t.id}`}):e.jsx("div",{className:"t2-content",children:e.jsx(Ke,{content:_,anchorPrefix:`toc-${t.id}`,run:w,embeds:b})}))]})})(),!!V.length&&t.status==="done"&&e.jsx("div",{className:"t2-suggest",children:V.map((F,X)=>e.jsxs("button",{className:"t2-suggest-chip",disabled:c,onClick:()=>{C(!0),a?.onSuggest?.(F)},children:[e.jsx(fo,{size:13})," ",F]},X))}),!!$.length&&t.status==="done"&&e.jsx(ku,{tasks:$,ownerId:t.id,onTask:a?.onTask}),!!q.length&&t.status==="done"&&e.jsx(ju,{cards:q,sessionId:p}),r&&e.jsx(zd,{events:t.toolEvents,sessionId:r.sessionId,agentSlug:t.agentId}),r&&e.jsx(cd,{changes:ni(t.toolEvents),cfg:r.cfg,sessionId:r.sessionId,agentName:t.agentName||s}),t.planProposal&&e.jsx(mu,{plan:t.planProposal,req:L},L?.inquiryId||"plan"),!!t.todos?.length&&e.jsx(gu,{todos:t.todos}),t.status==="streaming"&&t.live&&(j||t.live.phase==="describing")&&e.jsx(Lu,{live:t.live}),t.status==="streaming"&&t.work&&e.jsx("div",{className:"t2-dim chat-thinking-live",role:"status","aria-live":"polite","data-team-work":t.work.waiting?"waiting":"working",children:e.jsx("span",{className:t.work.waiting?void 0:"chat-run-shimmer-text",children:t.work.waiting?x(!G.length&&re?"chat.team.waitingAnswer":"chat.team.waiting"):t.work.activity?x("chat.team.working",{activity:t.work.activity}):x("chat.team.workingIdle")})}),!_&&t.status==="streaming"&&!t.work&&!t.toolEvents?.length&&!t.reasoning&&(!t.live||!j&&t.live.phase!=="describing")&&e.jsx("div",{className:"t2-dim chat-thinking-live chat-run-shimmer-text",role:"status","aria-live":"polite",children:x("chat.thinking")}),t.teamDone&&t.status!=="streaming"&&e.jsxs("div",{className:"t2-dim t2-team-done","data-team-done":"1",children:["✓ ",x("chat.team.done")]}),!!t.displayFiles?.length&&r&&e.jsx(El,{files:t.displayFiles,cfg:r.cfg,sessionId:r.sessionId,execMode:r.execMode,onOpenPreview:r.onOpenPreview}),W.map(F=>e.jsx(Rs,{event:F,live:P,stateScope:p?`${p}:${t.id}`:void 0,onAsk:a?.onSuggest},F.id)),!!K.length&&e.jsx(vs,{items:K,actions:T,stateScope:p?`${p}:${t.id}`:void 0,onAsk:a?.onSuggest}),!t.work&&G.length>0&&e.jsxs("div",{className:"t2-dim t2-apv-pointer","data-approval-pointer":G.length,children:[e.jsx(no,{size:12}),G.length===1?x("chat.approval.pointer",{name:G[0].name}):x("chat.approval.pointerN",{n:G.length})]}),!t.work&&ee.length>0&&e.jsxs("div",{className:"t2-dim t2-apv-pointer","data-inquiry-pointer":ee.length,children:[e.jsx(Gn,{size:12}),ee.length===1?x("chat.inquiry.pointer"):x("chat.inquiry.pointerN",{n:ee.length})]}),t.inquiries?.filter(F=>F!==L&&F.status!=="pending").map(F=>e.jsx(yi,{req:F,onAnswer:()=>{}},F.inquiryId)),t.status==="error"&&e.jsxs("div",{className:"t2-tool err",children:[e.jsxs("span",{className:"t2-status-err",children:["✕ ",Si(t.error,x)]}),e.jsx(zi,{error:t.error,modelId:f})]}),t.status==="stopped"&&e.jsxs("div",{className:"t2-dim",children:["⏹ ",x("chat.aborted")]}),y,(t.status==="done"||t.status==="stopped")&&e.jsxs("div",{className:"t2-actions",children:[e.jsx("button",{className:"t2-iconbtn",title:x("chat.action.copy"),onClick:()=>a?.onCopy?.(_),children:e.jsx(st,{size:14})}),a?.onSpeak&&!!_&&e.jsx("button",{className:"t2-iconbtn",title:x(u?"chat.action.stopSpeak":"chat.action.speak"),onClick:()=>a.onSpeak?.(_),children:u==="loading"?e.jsx(Ye,{size:14,className:"spin"}):u==="playing"?e.jsx(vo,{size:14}):e.jsx(kc,{size:14})}),a?.onInsertNote&&!!_&&e.jsx(Ls,{onInsert:()=>a.onInsertNote?.(_)}),e.jsx("button",{className:"t2-iconbtn",title:x("chat.action.regenerate"),onClick:()=>a?.onRegenerate?.(),children:e.jsx(At,{size:14})}),e.jsx("button",{className:"t2-iconbtn",title:x("chat.action.branch"),onClick:()=>a?.onBranch?.(),children:e.jsx(sc,{size:14})}),e.jsx(Os,{at:t.timestamp})]})]})]})}function Os({at:t}){return t>0?e.jsx("span",{className:"t2-msgtime",title:hr(t,{year:"always"}),children:ur(t)}):null}function Fu(t){const[n,s]=l.useState(Date.now());return l.useEffect(()=>{s(Date.now());const o=setInterval(()=>s(Date.now()),1e3);return()=>clearInterval(o)},[t]),Math.max(0,Math.floor((n-t)/1e3))}function Lu({live:t}){const{t:n}=U(),s=Fu(t.since),o=Math.max(1,Math.round((t.bytes||0)/1024)),i=t.phase==="describing"?n("chat.wait.describing",{n:t.images||1}):t.phase==="sending"&&t.bytes?n("chat.wait.sending",{kb:o}):n("chat.wait.firstToken");return e.jsxs("div",{className:"t2-dim chat-thinking-live",role:"status","aria-live":"polite",children:[e.jsx("span",{className:"chat-run-shimmer-text",children:i}),s>=2&&e.jsxs("span",{className:"chat-wait-elapsed",children:[" · ",n("chat.wait.elapsed",{s})]})]})}te({"approval.tray.title":{zh:"等你批准 · {n}",en:"Waiting for your approval · {n}"},"approval.tray.titleAny":{zh:"等你处理 · {n}",en:"Waiting for you · {n}"},"approval.tray.label":{zh:"等你处理的事项",en:"Items waiting for you"},"approval.tray.planRow":{zh:"计划等你拍板",en:"Plan waiting for your decision"}});const Ou=350;function qu({items:t,onDecide:n,onAnswer:s,sessionId:o}){const{t:i}=U(),[a,r]=l.useState(null),[d,u]=l.useState(!1),v=t.find(c=>c.id===a)??t[0],f=v?.id;l.useEffect(()=>{f&&f!==a&&r(f)},[f,a]);const[j,y]=l.useState(void 0);l.useEffect(()=>{const c=setTimeout(()=>y(f),Ou);return()=>clearTimeout(c)},[f]);const p=l.useRef(new Set),[,w]=l.useState(0);l.useEffect(()=>{for(const c of p.current)t.some(C=>C.id===c)||p.current.delete(c)},[t]);const N=(c,C)=>{if(j!==c||p.current.has(c))return;p.current.add(c),w(k=>k+1);const m=()=>{p.current.delete(c),w(k=>k+1)};Promise.resolve().then(C).then(k=>{k===!1&&m()},m)};if(!v)return null;const b=p.current.has(v.id),x=t.every(c=>c.kind==="approval")?"approval.tray.title":"approval.tray.titleAny";return e.jsxs("div",{className:"t2c-apv",role:"region","aria-label":i("approval.tray.label"),"data-approval-tray":t.length,children:[e.jsxs("button",{type:"button",className:"t2c-apv-head","aria-expanded":!d,onClick:()=>u(c=>!c),children:[e.jsx(no,{size:13,className:"t2c-apv-ic"}),e.jsx("span",{className:"t2c-apv-title",children:i(x,{n:t.length})}),e.jsx(ct,{size:13,className:`t2c-apv-chev${d?" is-collapsed":""}`})]}),!d&&t.length>1&&e.jsx("div",{className:"t2c-apv-rest",children:t.filter(c=>c!==v).map(c=>e.jsxs("button",{type:"button",className:"t2c-apv-row","data-tray-kind":c.kind,"data-tray-msg":c.messageId,title:qs(c,i),onClick:()=>r(c.id),children:[c.agentName&&e.jsx("span",{className:"t2c-apv-row-from",children:c.agentName}),c.kind==="approval"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"t2c-apv-row-name",children:c.req.name}),e.jsx("span",{className:"t2c-apv-row-preview",children:c.req.preview})]}):e.jsxs(e.Fragment,{children:[c.kind==="plan"?e.jsx(Yt,{size:12,className:"t2c-apv-row-ic"}):e.jsx(Gn,{size:12,className:"t2c-apv-row-ic"}),e.jsx("span",{className:"t2c-apv-row-text",children:qs(c,i)})]})]},c.id))}),!d&&e.jsxs("div",{className:`t2c-apv-body${j===f?"":" is-arming"}${b?" is-sent":""}`,"data-tray-kind":v.kind,"data-tray-msg":v.messageId,children:[v.agentName&&e.jsx("div",{className:"t2c-apv-from",children:v.agentName}),v.kind==="approval"?e.jsx(ha,{req:v.req,sessionId:o,onDecide:(c,C)=>N(v.id,()=>n(v.messageId,v.id,c,C))},v.id):v.kind==="plan"?e.jsx(fu,{plan:v.plan,req:v.req,busy:b,onAnswer:c=>N(v.id,()=>s(v.messageId,v.id,c))},v.id):e.jsx(yi,{req:v.req,onAnswer:c=>N(v.id,()=>s(v.messageId,v.id,c))},v.id)]})]})}function qs(t,n){return t.kind==="approval"?t.req.preview:t.kind==="plan"?n("approval.tray.planRow"):t.req.question}te({"chat.runStats.tokens":{zh:"{n} tokens",en:"{n} tokens"},"chat.runStats.thinking":{zh:"思考中 {t}",en:"Thinking {t}"},"chat.runStats.thought":{zh:"思考 {t}",en:"Thought for {t}"}});const Bs=t=>{const n=Math.max(0,Math.floor(t/1e3));return n<60?`${n}s`:n<3600?`${Math.floor(n/60)}m ${n%60}s`:`${Math.floor(n/3600)}h ${String(Math.floor(n/60)%60).padStart(2,"0")}m`};function Us({stats:t}){const{t:n}=U(),s=t.finishedAt==null,[o,i]=l.useState(Date.now);l.useEffect(()=>{if(!s)return;i(Date.now());const u=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(u)},[s]);const a=t.finishedAt??o,r=t.thinkMs+(t.thinkSince!=null?Math.max(0,a-t.thinkSince):0),d=[Bs(a-t.startedAt)];return t.tokens>0&&d.push(n("chat.runStats.tokens",{n:pa(t.tokens)})),t.thinkTracked&&r>=1e3&&d.push(n(t.thinkSince!=null?"chat.runStats.thinking":"chat.runStats.thought",{t:Bs(r)})),e.jsx("div",{className:"t2-dim t2-runstats","data-run-stats":s?"live":"done",children:d.join(" · ")})}te({"projectProfile.kind":{zh:"项目",en:"Project"},"projectProfile.navigation":{zh:"项目详情",en:"Project details"},"projectProfile.tab.agents":{zh:"Agent",en:"Agents"},"projectProfile.tab.settings":{zh:"配置",en:"Settings"},"projectProfile.tab.git":{zh:"Git",en:"Git"},"projectProfile.open":{zh:"在项目页中打开",en:"Open project page"},"projectProfile.name":{zh:"项目名称",en:"Project name"},"projectProfile.iconChange":{zh:"导入图片作为项目图标",en:"Import an image as the project icon"},"projectProfile.iconImageHint":{zh:"点击导入图片(存进项目的 {dir}/ 目录)",en:"Click to import an image (saved in the project's {dir}/ folder)"},"projectProfile.iconEmoji":{zh:"设置 Emoji 图标",en:"Set an emoji icon"},"projectProfile.iconSaved":{zh:"图标已更新",en:"Icon updated"},"projectProfile.iconRemoved":{zh:"已恢复默认图标",en:"Default icon restored"},"projectProfile.iconTooLarge":{zh:"图标图片不能超过 1 MB。",en:"The icon image must be no larger than 1 MB."},"projectProfile.sessions":{zh:"{count} 个会话",en:"Sessions: {count}"},"projectProfile.reveal":{zh:"在文件管理器中显示",en:"Show in file manager"},"projectProfile.copyPath":{zh:"复制路径",en:"Copy path"},"projectProfile.copied":{zh:"路径已复制",en:"Path copied"},"projectProfile.terminal":{zh:"在终端打开",en:"Open in terminal"},"projectProfile.refresh":{zh:"刷新",en:"Refresh"},"projectProfile.loading":{zh:"正在读取项目…",en:"Loading project…"},"projectProfile.retry":{zh:"重新加载",en:"Reload"},"projectProfile.localOnly":{zh:"项目详情只在本地引擎上可用。",en:"Project details are available on the local engine only."},"projectProfile.status.idle":{zh:"待命",en:"Standby"},"projectProfile.status.working":{zh:"工作中",en:"Working"},"projectProfile.agentsHint":{zh:"在这个项目里工作过的 Agent 与团队。点击查看,或用它开一个新会话。",en:"Agents and teams that have worked in this project. Select one to inspect it, or start a new conversation with it."},"projectProfile.current":{zh:"当前会话",en:"Current conversation"},"projectProfile.party":{zh:"临时配队",en:"Ad hoc party"},"projectProfile.engine":{zh:"外部引擎",en:"External engine"},"projectProfile.lastActive":{zh:"最近 {time}",en:"Last active {time}"},"projectProfile.startWith":{zh:"用它开新会话",en:"New conversation with it"},"projectProfile.setDefault":{zh:"设为项目默认",en:"Set as project default"},"projectProfile.isDefault":{zh:"项目默认",en:"Project default"},"projectProfile.add":{zh:"添加",en:"Add"},"projectProfile.addHint":{zh:"选一个 Agent 或团队,在这个项目里开一个新会话。",en:"Pick an agent or team to start a new conversation in this project."},"projectProfile.noCandidates":{zh:"没有可选的 Agent",en:"No agents to choose from"},"projectProfile.closePicker":{zh:"关闭选择",en:"Close picker"},"projectProfile.teams":{zh:"团队",en:"Teams"},"projectProfile.agents":{zh:"Agent",en:"Agents"},"projectProfile.inspect":{zh:"查看",en:"Inspect"},"projectProfile.back":{zh:"返回项目",en:"Back to project"},"projectProfile.instructions":{zh:"项目指令",en:"Project instructions"},"projectProfile.docActive":{zh:"已生效",en:"In effect"},"projectProfile.docMissing":{zh:"尚未创建",en:"Not created yet"},"projectProfile.docTruncated":{zh:"超过 32 KB,已截断",en:"Over 32 KB, truncated"},"projectProfile.docTooLarge":{zh:"这份文件太大,无法在这里编辑。",en:"This file is too large to edit here."},"projectProfile.docHint":{zh:"每次运行开始时注入。引擎从项目根到工作目录逐层读取 {names},每层只取首个命中的文件。",en:"Injected at the start of every run. Tangu reads {names} from the repository root down to the working directory, taking the first match on each level."},"projectProfile.docOthers":{zh:"另有 {count} 份沿路径生效的文件",en:"{count} more files apply along the path"},"projectProfile.docEmpty":{zh:"这个项目还没有项目级指令。创建一份,或让 Tangu 分析仓库后生成。",en:"This project has no instructions yet. Create one, or let Tangu analyze the repository and write it."},"projectProfile.init":{zh:"创建 {file}",en:"Create {file}"},"projectProfile.generate":{zh:"让 Tangu 生成",en:"Let Tangu write it"},"projectProfile.generateBusy":{zh:"会话运行中,等这轮结束再生成",en:"The conversation is busy; try again after this run"},"projectProfile.generatePrompt":{zh:"请分析这个仓库,然后在 {file} 写一份给 AI Agent 看的项目指令文件(目录不存在就创建;如果该文件已有内容,请在原基础上改进而不是推翻)。内容包括:这个项目是什么、如何构建、运行和测试、目录结构、代码约定,以及 Agent 绝不能做的事。只写你在文件里核实过的事实,控制在 150 行以内。",en:"Analyze this repository, then write a project instruction file for AI agents at {file} (create the directory if needed; if the file already has content, improve it in place instead of replacing it). Cover what the project is, how to build, run and test it, the directory layout, code conventions, and things an agent must never do. State only facts you verified in the files and keep it under 150 lines."},"projectProfile.generateSent":{zh:"已交给 Tangu,这一轮结束后这里会自动刷新。",en:"Handed to Tangu. This panel refreshes when the run finishes."},"projectProfile.initialized":{zh:"已创建 {dir}",en:"Created {dir}"},"projectProfile.skills":{zh:"项目技能",en:"Project skills"},"projectProfile.skillsHint":{zh:"放在 {dir} 里的技能只对这个项目可用,随仓库一起提交。",en:"Skills in {dir} are available only in this project and travel with the repository."},"projectProfile.noSkills":{zh:"还没有项目技能。",en:"No project skills yet."},"projectProfile.legacySkill":{zh:"旧位置 .forsion/skills",en:"Legacy location .forsion/skills"},"projectProfile.newSkill":{zh:"新建技能",en:"New skill"},"projectProfile.openSkills":{zh:"打开技能文件夹",en:"Open skills folder"},"projectProfile.skillFolder":{zh:"文件夹名",en:"Folder name"},"projectProfile.skillCreated":{zh:"项目技能已创建",en:"Project skill created"},"projectProfile.memory":{zh:"项目记忆",en:"Project memory"},"projectProfile.memoryHint":{zh:"只在这个项目里成立的事:命令、约定、你针对这个项目提的要求。在这里工作的 Agent 共用,保存在本机,不写进项目文件夹。",en:"What holds only inside this project: commands, conventions, what you asked for here. Shared by the agents working in it and kept on this computer, outside the project folder."},"projectProfile.memoryEmpty":{zh:"还没有项目记忆。在这个项目的对话里提到只对它成立的要求时,Agent 会记在这里。",en:"No project memory yet. When you state something that holds only for this project in a conversation here, the agent saves it in this list."},"projectProfile.memoryUsage":{zh:"{count} 条 · {chars}/{limit} 字",en:"Entries: {count} · {chars}/{limit} characters"},"projectProfile.memoryForget":{zh:"删除这条记忆",en:"Delete this entry"},"projectProfile.memoryForgotten":{zh:"已删除",en:"Entry deleted"},"projectProfile.memoryConflict":{zh:"项目记忆刚被改过,已重新载入;请再删一次。",en:"Project memory just changed and was reloaded. Delete the entry again."},"projectProfile.memoryCandidates":{zh:"等你确认:{count} 条",en:"Awaiting your decision: {count}"},"projectProfile.memoryCandidatesHint":{zh:"后台从这个项目的对话里记下、但带网址、命令或权限字眼的事实。采纳后才进项目记忆;在那之前 Agent 读不到。",en:"Facts noted in the background from conversations in this project that carry a URL, a command or wording about permissions. They join project memory only after you adopt them; until then agents cannot read them."},"projectProfile.memoryAdopt":{zh:"采纳",en:"Adopt"},"projectProfile.memoryDismiss":{zh:"丢弃",en:"Dismiss"},"projectProfile.memoryAdopted":{zh:"已采纳,记进了项目记忆",en:"Adopted into project memory"},"projectProfile.memoryDismissed":{zh:"已丢弃",en:"Candidate dismissed"},"projectProfile.memoryCandidateGone":{zh:"这条候选已经不在了,已重新载入。",en:"That candidate is no longer waiting. The list was reloaded."},"projectProfile.memoryFull":{zh:"项目记忆已满。先删几条,再采纳。",en:"Project memory is full. Delete a few entries before adopting."},"projectProfile.memoryBusy":{zh:"项目记忆正被别处改动,已重新载入;请再点一次。",en:"Project memory is being changed elsewhere and was reloaded. Try again."},"projectProfile.memoryCompacted":{zh:"写满时压缩过({when}):{before} 条 → {after} 条。可恢复的原句:{count} 条",en:"Compacted when full ({when}): {before} entries → {after}. Originals you can restore: {count}"},"projectProfile.memoryCompactedHint":{zh:"项目记忆写满时,Agent 会先把整份压缩一遍,再记下新的那一条:重复的合并,被后来的说法取代的去掉。上面是被合并或去掉的原句;恢复会把它原样记回去,之后的压缩不再改它。",en:"When project memory fills up, the agent compacts it before saving the new entry: duplicates are merged and entries replaced by later ones are removed. These are the original sentences that were merged or removed. Restoring one saves it back as written, and later compactions leave it unchanged."},"projectProfile.memoryRestore":{zh:"恢复",en:"Restore"},"projectProfile.memoryRestored":{zh:"已恢复,记回了项目记忆",en:"Restored to project memory"},"projectProfile.memoryRemovedGone":{zh:"这一句已经不在记录里了,已重新载入。",en:"That sentence is no longer in the record. The list was reloaded."},"projectProfile.memoryFullRestore":{zh:"项目记忆已满。先删几条,再恢复。",en:"Project memory is full. Delete a few entries before restoring."},"projectProfile.plans":{zh:"已批准的计划",en:"Approved plans"},"projectProfile.plansHint":{zh:"计划模式里批准过的计划存档在 {dir},点击打开。",en:"Plans approved in plan mode are archived in {dir}. Select one to open it."},"projectProfile.defaults":{zh:"项目默认",en:"Project defaults"},"projectProfile.defaultsHint":{zh:"在这个项目里新建会话时预填;只保存在本机,会话里随时可改。",en:"Prefilled when you start a conversation in this project. Stored on this device only; change it in any conversation."},"projectProfile.defaultExecutor":{zh:"默认执行者",en:"Default executor"},"projectProfile.defaultNone":{zh:"不指定",en:"Not set"},"projectProfile.inherit":{zh:"沿用",en:"Inherit"},"projectProfile.saved":{zh:"已保存",en:"Saved"},"projectProfile.save":{zh:"保存",en:"Save"},"projectProfile.saveScope":{zh:"指令文件写入项目目录;默认项只保存在本机。",en:"The instruction file is written into the project. Defaults are stored on this device only."},"projectProfile.docConflict":{zh:"指令文件已在别处修改;请先复制你的改动,重新加载后再保存。",en:"The instruction file changed elsewhere. Copy your edits, reload, then save again."},"projectProfile.git.none":{zh:"这个目录不是 git 仓库。",en:"This folder is not a git repository."},"projectProfile.git.unavailable":{zh:"未找到 git,无法读取仓库状态。",en:"git was not found, so repository state is unavailable."},"projectProfile.git.branch":{zh:"分支",en:"Branch"},"projectProfile.git.detached":{zh:"游离 HEAD",en:"Detached HEAD"},"projectProfile.git.upstream":{zh:"上游",en:"Upstream"},"projectProfile.git.noUpstream":{zh:"没有上游分支",en:"No upstream branch"},"projectProfile.git.ahead":{zh:"领先 {count}",en:"{count} ahead"},"projectProfile.git.behind":{zh:"落后 {count}",en:"{count} behind"},"projectProfile.git.inSync":{zh:"与上游一致",en:"Up to date"},"projectProfile.git.nested":{zh:"项目位于更大的仓库中",en:"The project sits inside a larger repository"},"projectProfile.git.changes":{zh:"改动",en:"Changes"},"projectProfile.git.clean":{zh:"工作区干净",en:"Working tree clean"},"projectProfile.git.changeCount":{zh:"{count} 处改动",en:"{count} changed"},"projectProfile.git.staged":{zh:"已暂存 {count}",en:"{count} staged"},"projectProfile.git.unstaged":{zh:"未暂存 {count}",en:"{count} unstaged"},"projectProfile.git.untracked":{zh:"未跟踪 {count}",en:"{count} untracked"},"projectProfile.git.more":{zh:"还有 {count} 项",en:"{count} more"},"projectProfile.git.commits":{zh:"最近提交",en:"Recent commits"},"projectProfile.git.remote":{zh:"远端",en:"Remote"},"projectProfile.git.init":{zh:"创建 Git 仓库",en:"Create Git repository"},"projectProfile.git.initHint":{zh:"会在这个文件夹里新建 .git;没有 .gitignore 时顺手写一份常用的忽略规则。之后可以在这里提交、建分支和推送。",en:"This creates .git in this folder and, if there is no .gitignore yet, adds one with common ignore rules. You can then commit, branch and push from here."},"projectProfile.git.initDone":{zh:"已创建 Git 仓库。",en:"Git repository created."},"projectProfile.git.initDoneIgnore":{zh:"已创建 Git 仓库,并写入了 .gitignore。",en:"Git repository created, with a .gitignore."},"projectProfile.git.commit":{zh:"提交…",en:"Commit…"},"projectProfile.git.newBranch":{zh:"新建分支…",en:"New branch…"},"projectProfile.git.push":{zh:"推送",en:"Push"},"projectProfile.git.pushCount":{zh:"推送({count})",en:"Push ({count})"},"projectProfile.git.pull":{zh:"拉取",en:"Pull"},"projectProfile.git.pullCount":{zh:"拉取({count})",en:"Pull ({count})"},"projectProfile.git.pulled":{zh:"已从 {upstream} 拉取 {count} 个提交",en:"Pulled from {upstream}. New commits: {count}"},"projectProfile.git.pullNothing":{zh:"{upstream} 上没有新的提交。",en:"No new commits on {upstream}."},"projectProfile.git.openForsionGit":{zh:"打开 Forsion Git",en:"Open Forsion Git"},"projectProfile.git.publish":{zh:"发布到 Forsion Git…",en:"Publish to Forsion Git…"},"projectProfile.git.publishTitle":{zh:"发布到 Forsion Git",en:"Publish to Forsion Git"},"projectProfile.git.publishLabel":{zh:"仓库名(英文字母、数字、- _ .)。会在 {site} 上你的账号下新建一个私有仓库,并把当前分支推送上去。",en:"Repository name (letters, digits, - _ .). A private repository is created under your account on {site}, and the current branch is pushed to it."},"projectProfile.git.publishConfirm":{zh:"发布",en:"Publish"},"projectProfile.git.published":{zh:"已发布到 {url}",en:"Published to {url}"},"projectProfile.git.commitTitle":{zh:"提交改动({count})",en:"Commit changes ({count})"},"projectProfile.git.commitHint":{zh:"提交信息由这条会话的模型生成,可以改。常见的密码、密钥类文件会被拦下。",en:"The message is written by this conversation’s model, and you can edit it. Files that usually hold passwords or keys are blocked."},"projectProfile.git.filesAll":{zh:"会提交这 {count} 项改动(包括新文件):",en:"These {count} changes will be committed, including new files:"},"projectProfile.git.filesStaged":{zh:"只提交已暂存的这 {count} 项,没暂存的改动留着不动:",en:"Only these {count} staged changes will be committed; unstaged changes stay as they are:"},"projectProfile.git.committedStaged":{zh:"已提交已暂存的改动:{subject}",en:"Committed the staged changes: {subject}"},"projectProfile.git.unread":{zh:"未读取",en:"Not read"},"projectProfile.git.untrustedNote":{zh:"这个仓库自带会在你电脑上执行程序的 Git 配置(下面列出),没信任之前不读改动。确认它来自可信的地方,再信任它。",en:"This repository has its own git configuration that runs programs on your computer (listed below), so its changes are not read until you trust it. Trust it only if you trust where it came from."},"projectProfile.git.trust":{zh:"信任这个仓库",en:"Trust this repository"},"projectProfile.git.trustRetry":{zh:"信任这个仓库并继续",en:"Trust this repository and continue"},"projectProfile.git.trustedNotice":{zh:"已信任这个仓库。",en:"Repository trusted."},"projectProfile.git.nestedNote":{zh:"这个项目在一个更大的 Git 仓库里,这里只显示状态;提交、建分支和推送请在仓库根目录的项目里做。",en:"This project is inside a larger git repository, so this page only shows its state. Commit, branch and push from a project opened at the repository root."},"projectProfile.git.unconfirmed":{zh:"没能确认这次操作的结果,已经重新读取仓库状态。先看一眼,再决定要不要重试。",en:"The result of this action could not be confirmed, so the repository state has been reloaded. Check it before trying again."},"projectProfile.git.err.unsupported":{zh:"当前连接的引擎不支持这个操作,更新后再试。",en:"The connected engine does not support this action yet. Update it and try again."},"projectProfile.git.err.nested_repo":{zh:"这个项目在一个更大的 Git 仓库里,提交、建分支和推送请在仓库根目录的项目里做。",en:"This project is inside a larger git repository. Commit, branch and push from a project opened at the repository root."},"projectProfile.git.err.untrusted_config":{zh:"这个仓库自带会在你电脑上执行程序的 Git 配置(下面列出)。确认它来自可信的地方,再继续。",en:"This repository has its own git configuration that runs programs on your computer (listed below). Continue only if you trust where it came from."},"projectProfile.git.err.credential_files":{zh:"这次提交里有通常存放密码或密钥的文件(下面列出),已经拦下。把它们加进 .gitignore,或者在终端里自己处理。",en:"This commit contains files that usually hold passwords or keys (listed below), so it was stopped. Add them to .gitignore, or handle them yourself in a terminal."},"projectProfile.git.err.changes_changed":{zh:"你看过清单之后,改动又变了。下面是最新的清单,确认后再点一次提交。",en:"The changes are different from the list you reviewed. The list below is up to date; review it and commit again."},"projectProfile.git.err.hook_changed_commit":{zh:"提交已完成,但仓库的提交钩子往里加了清单之外的改动(下面列出),没有撤回。推送之前请先检查一下。",en:"The commit was made, but a commit hook added changes that were not in the list (shown below). Nothing was undone; check it before you push."},"projectProfile.git.tooManyToList":{zh:"改动太多,清单列不全,这里不能提交。先把生成的文件加进 .gitignore,或者在终端里提交。",en:"There are too many changes to list in full, so they cannot be committed from here. Add generated files to .gitignore first, or commit from a terminal."},"projectProfile.git.err.commit_unverified":{zh:"提交过程中仓库被别的东西改动了(比如钩子又提交了一次,或者切了分支),没法确认结果。已经重新读取状态,请先检查一下仓库。",en:"The repository changed while committing (for example a hook made another commit or switched branches), so the result could not be verified. The state has been reloaded; check the repository first."},"projectProfile.git.err.git_too_old":{zh:"你的 git 版本太旧,不支持安全地改写远端历史(需要 2.30 以上)。请升级 git,或者在设置里关掉这一项。",en:"Your git is too old to rewrite remote history safely (2.30 or later is needed). Update git or turn this off in Settings."},"projectProfile.git.messageLabel":{zh:"提交信息",en:"Commit message"},"projectProfile.git.messagePlaceholder":{zh:"写一句话说明这次改了什么",en:"Describe what this change does"},"projectProfile.git.generating":{zh:"正在生成提交信息…",en:"Writing a commit message…"},"projectProfile.creation.addHint":{zh:"原地加入造物,不复制也不移动这个文件夹。",en:"Adds this project to Creations where it is, without copying or moving the folder."},"projectProfile.creation.added":{zh:"已加入造物:{name}",en:"Added to Creations: {name}"},"projectProfile.git.regenerate":{zh:"重新生成",en:"Regenerate"},"projectProfile.git.commitConfirm":{zh:"提交",en:"Commit"},"projectProfile.git.committed":{zh:"已提交:{subject}",en:"Committed: {subject}"},"projectProfile.git.newBranchTitle":{zh:"新建分支",en:"New branch"},"projectProfile.git.newBranchLabel":{zh:"从当前位置新建分支并切换过去,未提交的改动会一起带过去。",en:"Creates a branch from here and switches to it. Uncommitted changes come along."},"projectProfile.git.newBranchConfirm":{zh:"创建并切换",en:"Create and switch"},"projectProfile.git.branched":{zh:"已切换到新分支 {branch}",en:"Switched to new branch {branch}"},"projectProfile.git.pushed":{zh:"已推送到 {target}",en:"Pushed to {target}"},"projectProfile.git.sharedNote":{zh:"这是所有不在项目里的对话共用的默认文件夹,这里不建仓,也不提交。需要版本管理时,把东西放进一个单独的项目文件夹。",en:"This is the default folder shared by every conversation that is not in a project, so no repository is created or committed here. For version control, put the work in its own project folder."},"projectProfile.git.managedNote":{zh:"这个项目的版本由编码工作室管理,请在编码工作室的「版本」里保存和恢复。",en:"Versions of this project are managed by Coding Studio. Save and restore them from Versions in Coding Studio."},"projectProfile.git.err.shared_workspace":{zh:"默认文件夹是所有不在项目里的对话共用的,这里不建仓,也不提交。",en:"The default folder is shared by every conversation outside a project, so it is not used for version control."},"projectProfile.git.err.git_unavailable":{zh:"这台电脑上找不到 git。",en:"git was not found on this computer."},"projectProfile.git.err.git_timeout":{zh:"git 太久没有响应,已经停止。",en:"git took too long to respond and was stopped."},"projectProfile.git.err.git_failed":{zh:"git 执行失败,输出如下。",en:"git reported an error. Its output is below."},"projectProfile.git.err.not_repo":{zh:"这个目录不是 git 仓库。",en:"This folder is not a git repository."},"projectProfile.git.err.already_repo":{zh:"这个目录已经在一个 git 仓库里了。",en:"This folder is already inside a git repository."},"projectProfile.git.err.nothing_to_commit":{zh:"没有需要提交的改动。",en:"There is nothing to commit."},"projectProfile.git.err.empty_message":{zh:"提交信息不能为空。",en:"The commit message is empty."},"projectProfile.git.err.message_too_long":{zh:"提交信息太长了,最多 5000 个字符。",en:"The commit message is too long. The limit is 5,000 characters."},"projectProfile.git.err.embedded_repo":{zh:"这个文件夹里还有别的 git 仓库,直接提交会把它记成一个空的子模块。请把它加进 .gitignore,或者移出这个文件夹。",en:"This folder contains another git repository, which would be committed as an empty submodule. Add it to .gitignore or move it out of this folder."},"projectProfile.git.err.too_many_files":{zh:"要新加入的文件太多了,多半是 .gitignore 漏了什么(比如 node_modules 或构建产物)。先把下面这些目录加进 .gitignore 再提交。",en:"Too many new files would be added, which usually means .gitignore is missing something such as node_modules or build output. Add the folders below to .gitignore, then commit."},"projectProfile.git.err.large_files":{zh:"有新文件超过 50 MB,放进 git 会让仓库很难推送。请把它们加进 .gitignore,或者改用 Git LFS。",en:"Some new files are larger than 50 MB and would make the repository hard to push. Add them to .gitignore or use Git LFS."},"projectProfile.git.err.no_identity":{zh:'git 还不知道你的名字和邮箱。请在终端里运行 git config --global user.name "你的名字" 和 git config --global user.email "你的邮箱",然后再提交。',en:'git does not know your name and email yet. Run git config --global user.name "Your Name" and git config --global user.email "you@example.com" in a terminal, then commit again.'},"projectProfile.git.err.invalid_branch":{zh:"这不是一个合法的分支名。",en:"That is not a valid branch name."},"projectProfile.git.err.detached":{zh:"当前不在任何分支上(游离 HEAD),请先切换到一个分支再推送或拉取。",en:"You are not on a branch (detached HEAD). Switch to a branch before pushing or pulling."},"projectProfile.git.err.no_upstream":{zh:"当前分支还没有上游分支,没有可以拉取的来源。先推送一次,或者在终端里给它设置上游。",en:"This branch has no upstream branch to pull from. Push it once, or set an upstream in a terminal."},"projectProfile.git.err.diverged":{zh:"本地和远端各有新的提交(数量见下)。这里只做快进,没有替你合并或变基,本地什么都没动。请在终端里处理之后再回来。",en:"This branch and its upstream each have new commits (counts below). Only fast-forward updates are made here, so nothing was merged or rebased and nothing changed locally. Resolve it in a terminal, then come back."},"projectProfile.git.err.dirty_worktree":{zh:"远端的更新会改到你还没提交的文件(下面列出),所以没有拉取,文件也没有动。先提交这些改动或把它们放到一边,再拉取。",en:"The update would change files you have not committed (listed below), so nothing was pulled and no file was changed. Commit those changes or set them aside, then pull again."},"projectProfile.git.err.untrusted_transport":{zh:"这个仓库自带网络配置(下面列出),会改变这次连接经过哪里。推送和拉取要带上你的登录凭据,所以先确认这个仓库来自可信的地方,再继续。",en:"This repository has its own network configuration (listed below), which changes where this connection goes. Pushing and pulling send your sign-in credentials, so continue only if you trust where the repository came from."},"projectProfile.git.err.forsion_git_needs_setup":{zh:"你的 Forsion 账号还没有开通 Forsion Git。先在网页上登录一次 Forsion Git,再回来重试。",en:"Your Forsion account is not set up on Forsion Git yet. Sign in to Forsion Git on the web once, then try again."},"projectProfile.git.err.forsion_git_rate_limited":{zh:"这个账号领取 Forsion Git 凭据的次数太多了,这一次没能带上凭据。过几分钟再试。",en:"Forsion Git credentials were requested too many times for this account, so this attempt went without them. Try again in a few minutes."},"projectProfile.git.err.forsion_git_unavailable":{zh:"暂时领不到 Forsion Git 的凭据,这一次没能带上凭据。确认已登录 Forsion 并且网络正常,稍后再试。",en:"Forsion Git credentials are unavailable right now, so this attempt went without them. Check that you are signed in to Forsion and online, then try again."},"projectProfile.git.err.has_remote":{zh:"这个仓库已经配置了远端,直接用「推送」。",en:"This repository already has a remote. Use Push instead."},"projectProfile.git.err.invalid_repo_name":{zh:"仓库名只能用英文字母、数字、- _ .,不能以 - 或 . 开头或结尾。",en:"A repository name can only use letters, digits, - _ . and cannot start or end with - or ."},"projectProfile.git.err.no_commits":{zh:"这个仓库还没有任何提交,没有可以发布的内容。先提交一次。",en:"This repository has no commits to publish yet. Make a commit first."},"projectProfile.git.err.no_remote":{zh:"这个仓库还没有配置远端,推送不了。",en:"This repository has no remote to push to."},"projectProfile.git.err.ambiguous_remote":{zh:"配置了多个远端,但没有叫 origin 的,不知道该推到哪里。请先在终端里给当前分支设置上游。",en:"Several remotes are configured and none is called origin. Set an upstream for this branch in a terminal first."},"projectProfile.git.err.no_model":{zh:"这条会话还没有选定模型,没法生成提交信息。可以直接手写。",en:"This conversation has no model yet, so no message can be written for you. You can type one yourself."},"projectProfile.git.err.quota_exceeded":{zh:"额度不足,没法生成提交信息。可以直接手写。",en:"You are out of quota, so no message can be written for you. You can type one yourself."}});te({"selfTrace.adopted":{zh:"复盘时学到一个做法:",en:"Learned in review:"},"selfTrace.confirm":{zh:"复盘时有 {n} 条做法留给你确认",en:"Evolution record: {n} for you to confirm"},"selfTrace.projectAdded":{zh:"复盘时记进项目记忆:",en:"Saved to project memory in review:"},"selfTrace.projectConfirm":{zh:"复盘时有 {n} 条项目事实留给你确认",en:"Project memory: {n} for you to confirm"},"selfTrace.projectCompacted":{zh:"项目记忆写满,压缩了一遍;被合并的原句可以恢复",en:"Project memory was full and has been compacted; merged sentences can be restored"},"selfTrace.view":{zh:"查看",en:"View"},"selfTrace.undo":{zh:"撤销",en:"Undo"},"selfTrace.resolved":{zh:"已处理",en:"Resolved"}});const Bt="forsion:session-traces-changed";function Bu(t,n,s=!0){const[o,i]=l.useState(null),a=M(f=>t?f.configBySession[t]?.agentSlug||f.defaultAgentSlug:""),r=M(f=>!!(t&&f.runningBySession[t])),d=M(f=>f.connState==="ok"),u=l.useRef(!1);l.useEffect(()=>{const f=u.current&&!r;if(u.current=r,!t||!s||!d){i(null);return}let j=!0;const y=de(t);let p=0;const w=async()=>{const c=++p;try{const C=await vr(y,t),m=g=>C.some(A=>A.action===g),[k,z]=await Promise.all([a&&(m("harness_adopted")||m("harness_confirm"))?On(y,a).catch(()=>null):null,m("project_memory_candidates")?ho(y,t).then(g=>g.memory?.candidates,()=>{}):void 0]);j&&c===p&&i({sid:t,slug:a,activity:C,journal:k?.journal||[],pending:{harness:k?.candidateItems,project:z}})}catch{}};let N;const b=()=>{clearTimeout(N),N=setTimeout(()=>{w()},300)};b();const x=f?[5e3,15e3,4e4].map(c=>setTimeout(()=>{w()},c)):[];return window.addEventListener(Bt,b),window.addEventListener(Ve,b),()=>{j=!1,clearTimeout(N),x.forEach(clearTimeout),window.removeEventListener(Bt,b),window.removeEventListener(Ve,b)}},[t,s,d,a,r]);const v=n.map(f=>f.role==="user"?"":`${f.id}:${f.timestamp}`).join("|");return l.useMemo(()=>o&&o.sid===t?yd(n,o.slug===a?Ts(o.activity,o.journal,o.sid,o.pending):Ts(o.activity)):new Map,[o,t,a,v])}function Uu({traces:t,sessionId:n}){const{t:s,locale:o}=U(),i=M(x=>x.configBySession[n]?.agentSlug||x.defaultAgentSlug),a=M(x=>[...x.sessions,...x.archivedSessions].find(c=>c.id===n)?.project_path||""),[r,d]=l.useState(""),[u,v]=l.useState({}),[f,j]=l.useState({}),y=async x=>{if(!(r||!x.undo)){d(x.id),v(c=>({...c,[x.id]:""}));try{await co(de(n),i,x.undo.entryId,x.undo.rev)}catch(c){v(C=>({...C,[x.id]:c?.status===409?s("harness.undoConflict"):String(c?.message||c)}))}finally{d(""),window.dispatchEvent(new CustomEvent(Ve))}}},p=async(x,c,C)=>{if(r)return;d(x.id),v(k=>({...k,[x.id]:""})),j(k=>({...k,[x.id]:""}));const m=de(n);try{c.target.kind==="harness"?await yr(m,i,c.target.line,C):await jr(m,n,c.target.id,C);const k=c.target.kind==="harness"?C==="adopt"?"settings.agents.harnessCandidateAdopted":"settings.agents.harnessCandidateDismissed":C==="adopt"?"projectProfile.memoryAdopted":"projectProfile.memoryDismissed";j(z=>({...z,[x.id]:s(k)}))}catch(k){const z=c.target.kind==="harness"?{HARNESS_CANDIDATE_GONE:"settings.agents.harnessCandidateGone",HARNESS_CANDIDATE_FULL:"settings.agents.harnessCandidateFull",HARNESS_CANDIDATE_TOO_LONG:"settings.agents.harnessCandidateTooLong"}[k?.code]:k?.status===404?"projectProfile.memoryCandidateGone":k?.status===409?"projectProfile.memoryBusy":k?.code==="MEMORY_FULL"?"projectProfile.memoryFull":"";v(g=>({...g,[x.id]:z?s(z,{max:30}):String(k?.message||k)}))}finally{d(""),window.dispatchEvent(new CustomEvent(c.target.kind==="harness"?Ve:Bt))}},w=()=>at({kind:"agent",slug:i,evolution:Date.now()}),N=a?()=>at({kind:"project",path:a}):void 0,b=o==="zh"?";":"; ";return e.jsx(e.Fragment,{children:t.map(x=>{const c=x.items.length||1,m=x.kind==="harness_adopted"||x.kind==="harness_confirm"?w:N,k=x.undo?.state==="undone",z=x.pending?x.pending.length:c,g=!!x.pending&&!x.pending.length;return e.jsxs(l.Fragment,{children:[e.jsxs("div",{className:"self-trace","data-self-trace":x.kind,"data-trace-state":x.undo?.state||(g?"resolved":void 0),children:[e.jsx(Pt,{size:15,className:"self-trace-ic"}),e.jsxs("span",{className:"self-trace-text",children:[x.kind==="harness_adopted"&&e.jsxs(e.Fragment,{children:[s("selfTrace.adopted"),e.jsx("b",{children:x.items[0]}),k&&e.jsxs(e.Fragment,{children:[" · ",s("harness.undone")]})]}),x.kind==="harness_confirm"&&(g?e.jsxs(e.Fragment,{children:[s("selfTrace.confirm",{n:c})," · ",s("selfTrace.resolved")]}):s("selfTrace.confirm",{n:z})),x.kind==="project_memory_added"&&e.jsxs(e.Fragment,{children:[s("selfTrace.projectAdded"),e.jsx("b",{children:x.items.join(b)})]}),x.kind==="project_memory_candidates"&&(g?e.jsxs(e.Fragment,{children:[s("selfTrace.projectConfirm",{n:c})," · ",s("selfTrace.resolved")]}):s("selfTrace.projectConfirm",{n:z})),x.kind==="project_memory_compacted"&&s("selfTrace.projectCompacted")]}),e.jsxs("span",{className:"self-trace-ops",children:[m&&e.jsx("button",{type:"button",className:"self-act",onClick:m,children:s("selfTrace.view")}),x.undo?.state==="current"&&e.jsxs("button",{type:"button",className:"self-act",disabled:!!r,onClick:()=>{y(x)},children:[e.jsx(Et,{size:12}),s("selfTrace.undo")]})]})]}),!!x.pending?.length&&e.jsx("div",{className:"self-trace-rows","data-trace-candidates":x.kind,children:x.pending.map(A=>e.jsxs("div",{className:"self-trace-row","data-trace-candidate":!0,children:[e.jsx("span",{className:"self-trace-row-text",children:A.text}),e.jsxs("span",{className:"self-trace-ops",children:[A.adoptable&&e.jsx("button",{type:"button",className:"self-act",disabled:!!r,onClick:()=>{p(x,A,"adopt")},children:s("settings.agents.harnessCandidateAdopt")}),e.jsx("button",{type:"button",className:"self-act",disabled:!!r,onClick:()=>{p(x,A,"dismiss")},children:s("settings.agents.harnessCandidateDismiss")})]})]},A.key))}),u[x.id]&&e.jsx("p",{className:"self-trace-note agent-profile-error",role:"alert",children:u[x.id]}),f[x.id]&&e.jsx("p",{className:"self-trace-note",role:"status",children:f[x.id]})]},x.id)})})}te({"selfOpening.line":{zh:"上次之后,{name} 在后台{parts}",en:"Since last time, {name} worked in the background — {parts}"},"selfOpening.view":{zh:"查看",en:"View"}});const Ci="forsion.selfSeen",Pi={},Ti=()=>{let t={};try{const n=JSON.parse(localStorage.getItem(Ci)||"{}");n&&typeof n=="object"&&(t=n)}catch{}return{...t,...Pi}},mn=t=>{Pi[t]=Date.now();try{localStorage.setItem(Ci,JSON.stringify(Ti()))}catch{}};function Hu({slug:t}){const{t:n}=U(),s=M(u=>u.agentDefs.find(v=>v.slug===t)?.name||t),[o,i]=l.useState(null),a=l.useRef(!1);if(l.useEffect(()=>{if(i(null),a.current=!1,!t)return;const u=Ti()[t];if(typeof u!="number"){mn(t);return}let v=!0;const f=Ne();return Promise.all([uo(f,t),On(f,t)]).then(([j,y])=>{const p=wd(u,j.entries||[],y.journal||[]);v&&p.remembered+p.evolved>0&&i(p)},()=>{}),()=>{v=!1,a.current&&mn(t)}},[t]),l.useLayoutEffect(()=>{o&&(a.current=!0)},[o]),!o)return null;const r=[o.remembered?n("selfUpdate.remembered",{n:o.remembered}):"",o.evolved?n("selfUpdate.evolved",{n:o.evolved}):""].filter(Boolean).join(" · "),d=()=>{mn(t),a.current=!1,i(null),at({kind:"agent",slug:t,evolution:Date.now()})};return e.jsx("div",{className:"self-opening","data-self-opening":t,children:e.jsxs("div",{className:"self-opening-inner",children:[e.jsx(qo,{size:15,className:"self-receipt-ic"}),e.jsx("span",{className:"self-opening-text",children:n("selfOpening.line",{name:s,parts:r})}),e.jsx("button",{type:"button",className:"self-act",onClick:d,children:n("selfOpening.view")})]})})}function Wu({title:t,subtitle:n,compact:s=!1}){const{t:o}=U(),i=l.useRef(null);return l.useLayoutEffect(()=>{const a=i.current,r=a?.parentElement;if(!a||!r?.classList.contains("t2-chat-col"))return;const d=r.querySelector(":scope > .composer-anchor");if(!d)return;const u=()=>{a.style.bottom="auto";const f=Math.max(0,r.clientHeight-d.offsetHeight-40),j=f<100?["minimal"]:f<200?["compact","minimal"]:["full","compact","minimal"];let y=0;for(const p of j)if(a.dataset.density=p,y=a.offsetHeight,y<=f)break;a.style.visibility=y>f?"hidden":"",a.style.top=`${Math.max(16,Math.min((r.clientHeight-y)/2,16+f-y))}px`};u();const v=new ResizeObserver(u);return v.observe(r),v.observe(d),v.observe(a),()=>v.disconnect()},[]),e.jsx("div",{className:"t2-empty",ref:i,children:s?t:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"t2-empty-mark",children:e.jsx(xr,{size:64})}),e.jsx("div",{className:"t2-empty-title",children:t||o("chat.emptyTitle")}),e.jsx("div",{className:"t2-empty-sub",children:n||o("chat.emptyHint")})]})})}te({"ftoc.label":{zh:"目录",en:"Table of contents"}});const Vu=t=>{if(t.dataset.tocMsgRole==="user"){const s=(t.dataset.tocTitle||t.textContent||"").trim();return s?{text:s,level:0,primary:!0}:null}const n=(t.textContent||"").trim();return!n||!t.dataset.tocLevel?null:{text:n,level:Number(t.dataset.tocLevel)||1}};function Gu({scrollContainerRef:t,scanTrigger:n}){const{t:s}=U();return e.jsx(Ol,{scrollContainer:t,selector:"[data-toc-msg-role='user'], [data-toc-level]",itemFromElement:Vu,label:s("ftoc.label"),scanTrigger:n})}const Ku={read_file:"file",read_document:"file",read_log:"file",view_image:"file",list_dir:"dir",list_files:"dir",search_files:"search",glob_files:"search",web_search:"search",web_fetch:"web"},Yu=new Set(["write_file","edit_file","multi_edit"]),Ju=/^\*\*\* (?:Add|Update) File: (.+)$/gm,Qu=/^([/~]|[A-Za-z]:[\\/])/,Ei=t=>t.split(/[/\\]/).filter(Boolean).pop()||t,Xu=t=>{try{return new URL(t).hostname.replace(/^www\./,"")}catch{return t}},Fn=(t,n)=>!n||Qu.test(t)?t:n.replace(/[/\\]+$/,"")+"/"+t,Ai=t=>!!t.done&&!t.isError;function Ri(t){try{return t.arguments?JSON.parse(t.arguments):{}}catch{return null}}function Zu(t,n){if(!Ai(t))return null;const s=Ku[t.name]||(t.name.startsWith("browser_")?"web":null);if(!s)return null;const o=Ri(t);if(!o)return null;const i=s==="web"?o.url:s==="search"?o.query??o.pattern??o.glob:o.path;let a=typeof i=="string"?i.trim():"";return a?((s==="file"||s==="dir")&&(a=Fn(a,n)),{kind:s,id:a,label:s==="web"?Xu(a):s==="search"?a:Ei(a),hits:1}):null}function eh(t,n){if(!Ai(t))return[];const s=Ri(t);if(!s)return[];if(Yu.has(t.name)){const i=typeof s.path=="string"?s.path.trim():"";return i?[Fn(i,n)]:[]}return t.name!=="apply_patch"?[]:[...(typeof s.patch=="string"?s.patch:typeof s.input=="string"?s.input:"").matchAll(Ju)].map(i=>Fn(i[1].trim(),n)).filter(Boolean)}function th(t,n,s){const o=[],i=new Map,a=new Map;let r=[],d=null,u=null,v=null,f=!1;for(const j of t){j.role==="user"&&(u=j.timestamp,d=null);for(const y of j.approvals||[])y.status==="pending"&&o.push({kind:"approval",text:y.name});for(const y of j.inquiries||[])y.status==="pending"&&o.push({kind:"inquiry",text:y.question});j.todos&&(r=j.todos);for(const y of j.displayFiles||[]){const p=y.path||y.name;a.delete(p),a.set(p,y)}for(const y of j.toolEvents||[]){y.done||(d=y);for(const b of eh(y,s)){const x=a.get(b);a.delete(b),a.set(b,x||{name:Ei(b),path:b})}const p=Zu(y,s);if(!p)continue;const w=`${p.kind}:${p.id}`,N=i.get(w);N&&(N.hits++,i.delete(w)),i.set(w,N||p)}j.role==="assistant"&&(v=j.status==="error"?j.error||"":null,f=j.status==="stopped")}return{state:o.length?"attention":n?"running":v!==null?"error":f?"stopped":t.length?"done":"idle",attention:o,todos:r,action:n?d:null,sources:[...i.values()].reverse(),outputs:[...a.values()].reverse(),startedAt:u,error:v}}const Hs=t=>t.state!=="idle";te({"tsum.title":{zh:"任务概览",en:"Task overview"},"tsum.state.running":{zh:"正在运行",en:"Running"},"tsum.state.attention":{zh:"等待你处理",en:"Waiting for you"},"tsum.state.error":{zh:"已失败",en:"Failed"},"tsum.state.stopped":{zh:"已停止",en:"Stopped"},"tsum.state.done":{zh:"已完成",en:"Done"},"tsum.elapsed":{zh:"已运行 {t}",en:"Running {t}"},"tsum.attention.approval":{zh:"需要批准:{name}",en:"Approval needed: {name}"},"tsum.attention.inquiry":{zh:"需要你回答",en:"Needs your answer"},"tsum.plan":{zh:"计划",en:"Plan"},"tsum.scope":{zh:"工作范围",en:"Scope"},"tsum.scope.default":{zh:"默认目录",en:"Default folder"},"tsum.scope.add":{zh:"添加工作文件夹",en:"Add working folder"},"tsum.scope.remove":{zh:"移出工作范围",en:"Remove from scope"},"tsum.scope.hint":{zh:"加进来的文件夹 Agent 可直接读写、不再逐次弹审批;相对路径仍只相对默认目录解析。",en:"Added folders are readable/writable without per-call approval; relative paths still resolve against the default folder."},"tsum.sources":{zh:"来源",en:"Sources"},"tsum.outputs":{zh:"产物",en:"Outputs"},"tsum.openFile":{zh:"打开",en:"Open"},"tsum.openWeb":{zh:"在浏览器中打开",en:"Open in browser"},"tsum.editing":{zh:"正在编辑",en:"Editing"},"tsum.editingTip":{zh:"在 Agent Desk 中查看",en:"Show in Agent Desk"},"tsum.viewAll":{zh:"显示全部 {n} 项",en:"View all {n}"}});const nh={file:qn,dir:jt,web:br,search:mo},Ws=3;function _t({title:t,count:n,action:s,items:o,children:i}){const{t:a}=U(),[r,d]=l.useState(!0),[u,v]=l.useState(!1);return e.jsxs("details",{className:"t2-tsum-sec",open:r,onToggle:f=>{const j=f.currentTarget.open;d(j),j||v(!1)},children:[e.jsxs("summary",{className:"t2-tsum-sectitle",children:[e.jsx("span",{children:t}),n!==void 0&&e.jsx("span",{className:"t2-tsum-count",children:n}),s&&e.jsx("button",{type:"button",className:"t2-tsum-secact",title:s.label,"aria-label":s.label,onClick:f=>{f.preventDefault(),f.stopPropagation(),s.run()},children:s.icon}),e.jsx(xe,{size:12,className:"t2-tsum-chev"})]}),o?e.jsxs("div",{className:"t2-tsum-scroll",children:[u?o:o.slice(0,Ws),!u&&o.length>Ws&&e.jsx("button",{type:"button",className:"t2-tsum-more",onClick:()=>v(!0),children:a("tsum.viewAll",{n:o.length})})]}):i]})}const sh=t=>{const n=Math.floor(t/1e3);return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`},$t=t=>t.split(/[/\\]/).filter(Boolean).pop()||t;function oh({messages:t,running:n,cwd:s,hostCwd:o,onJumpToAttention:i,onShowEditing:a,onOpenFile:r,extraRoots:d=[],lockedRoots:u=[],onAddRoot:v,onRemoveRoot:f,modelId:j,teamStatus:y}){const{t:p}=U(),w=l.useMemo(()=>th(t,n,o),[t,n,o]),N=l.useMemo(()=>n&&a?wr(t,s):null,[t,n,s,a]),[b,x]=l.useState(()=>Date.now());l.useEffect(()=>{if(!n)return;x(Date.now());const z=window.setInterval(()=>x(Date.now()),1e3);return()=>window.clearInterval(z)},[n]);const c=n&&w.startedAt?b-w.startedAt:0,C=w.todos.filter(z=>z.status==="completed").length,m=w.action?vi(w.action):null,k=w.state==="attention"?Ho:w.state==="error"?Xt:w.state==="stopped"?Yl:w.state==="running"?null:Un;return e.jsx("aside",{className:`t2-tsum${Hs(w)||y?" show":""}`,"aria-hidden":!Hs(w)&&!y,"aria-busy":w.state==="running","aria-label":p("tsum.title"),children:e.jsxs("div",{className:"t2-tsum-in",children:[!((w.state==="idle"||w.state==="done")&&!t.some(z=>z.role==="assistant"))&&e.jsxs("div",{className:`t2-tsum-state ${w.state}`,role:"status","aria-live":"polite",children:[k&&e.jsx(k,{size:14}),e.jsx("span",{className:`t2-tsum-state-tx${w.state==="running"?" chat-run-shimmer-text":""}`,children:p(`tsum.state.${w.state==="idle"?"done":w.state}`)}),w.todos.length>0&&e.jsxs("span",{className:"t2-tsum-count",children:[C,"/",w.todos.length]})]}),y,c>=3e4&&e.jsx("div",{className:"t2-tsum-sub",children:p("tsum.elapsed",{t:sh(c)})}),m&&e.jsxs("div",{className:"t2-tsum-sub",title:m.target,children:[m.verbKey?p(m.verbKey):w.action.name," ",m.target]}),N&&a&&e.jsxs("button",{className:"t2-tsum-edit",title:`${p("tsum.editingTip")}:${N.path}`,onClick:()=>a(N.path),children:[e.jsx(xt,{size:11}),e.jsxs("span",{className:"t2-tsum-edit-tx",children:[p("tsum.editing")," ",N.name]})]}),w.state==="error"&&w.error&&e.jsx("div",{className:"t2-tsum-sub err",title:w.error,children:Si(w.error,p)}),w.state==="error"&&e.jsx(zi,{error:w.error??void 0,modelId:j}),w.attention.length>0&&e.jsxs("button",{className:"t2-tsum-attn",onClick:i,children:[w.attention[0].kind==="approval"?p("tsum.attention.approval",{name:w.attention[0].text}):p("tsum.attention.inquiry"),w.attention.length>1&&e.jsxs("span",{className:"t2-tsum-count",children:["+",w.attention.length-1]})]}),w.todos.length>0&&e.jsx(_t,{title:p("tsum.plan"),items:w.todos.map((z,g)=>e.jsxs("div",{className:`t2-tsum-todo ${z.status}`,children:[e.jsx("span",{className:"t2-tsum-todo-mark",children:z.status==="completed"?"✓":z.status==="in_progress"?"●":"○"}),e.jsx("span",{className:"t2-tsum-todo-tx",children:z.content})]},g))}),s&&e.jsx(_t,{title:p("tsum.scope"),action:v?{icon:e.jsx(go,{size:13}),label:`${p("tsum.scope.add")} — ${p("tsum.scope.hint")}`,run:v}:void 0,items:[e.jsxs("div",{className:"t2-tsum-row",title:`${p("tsum.scope.default")}:${s}`,children:[e.jsx(jt,{size:14}),e.jsx("span",{className:"t2-tsum-row-tx",children:$t(s)}),e.jsx("span",{className:"t2-tsum-hits",children:p("tsum.scope.default")})]},"__cwd"),...d.map(z=>e.jsxs("div",{className:"t2-tsum-row t2-tsum-root",title:z,children:[e.jsx(jt,{size:14}),e.jsx("span",{className:"t2-tsum-row-tx",children:$t(z)}),f&&!u.includes(z)&&e.jsx("button",{type:"button",className:"t2-tsum-x",title:p("tsum.scope.remove"),"aria-label":`${p("tsum.scope.remove")}:${$t(z)}`,onClick:()=>f(z),children:e.jsx(lt,{size:12})})]},z))]}),w.sources.length>0&&e.jsx(_t,{title:p("tsum.sources"),count:w.sources.length,items:w.sources.map(z=>{const g=nh[z.kind],A=`${z.kind}:${z.id}`,P=e.jsxs(e.Fragment,{children:[e.jsx(g,{size:14}),e.jsx("span",{className:"t2-tsum-row-tx",children:z.label}),z.hits>1&&e.jsxs("span",{className:"t2-tsum-hits",children:["×",z.hits]})]});return z.kind==="web"?e.jsx(yt,{className:"t2-tsum-row act",href:z.id,quote:"",title:`${p("tsum.openWeb")}:${z.id}`,children:P},A):z.kind!=="file"||!r?e.jsx("div",{className:"t2-tsum-row",title:z.id,children:P},A):e.jsx("button",{type:"button",className:"t2-tsum-row act",title:z.id,"aria-label":`${p("tsum.openFile")}:${z.label}`,onClick:()=>r({name:z.label,path:z.id}),children:P},A)})}),w.outputs.length>0&&e.jsx(_t,{title:p("tsum.outputs"),count:w.outputs.length,items:w.outputs.map(z=>{const g=$t(z.name||z.path||""),A=e.jsxs(e.Fragment,{children:[e.jsx(qn,{size:14}),e.jsx("span",{className:"t2-tsum-row-tx",children:g})]});return r?e.jsx("button",{type:"button",className:"t2-tsum-row act",title:z.path||z.name,"aria-label":`${p("tsum.openFile")}:${g}`,onClick:()=>r(z),children:A},z.path||z.name):e.jsx("div",{className:"t2-tsum-row",title:z.path||z.name,children:A},z.path||z.name)})})]})})}te({"panel.files.showAllWs":{zh:"显示全部项目",en:"Show all projects"},"panel.files.sessionFiles":{zh:"本会话的文件",en:"Session files"},"panel.files.sessionEmpty":{zh:"还没有附件或产物",en:"No attachments or outputs yet"}});const Mi=t=>[...t].sort((n,s)=>n.isDir===s.isDir?n.name.localeCompare(s.name):n.isDir?-1:1),nt=t=>t.slice(0,Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"))),ih=t=>!!t&&t.length<256&&!/[\\/]/.test(t)&&!t.includes("\0")&&t!=="."&&t!=="..",Fe=()=>!!window.tangu?.mkdirHost,Vs=()=>!!window.tangu?.revealHostPath,Tt=new EventTarget,$e=t=>{Tt.dispatchEvent(new CustomEvent("fs-bump",{detail:t}))};function Ut({initial:t,depth:n,onCommit:s,onCancel:o}){const[i,a]=l.useState(t),r=l.useRef(!1),d=()=>{r.current||(r.current=!0,s(i.trim()))};return e.jsx("input",{className:"t2sf-input",style:{marginLeft:Qt(n+1)},value:i,autoFocus:!0,spellCheck:!1,onFocus:u=>u.currentTarget.select(),onChange:u=>a(u.target.value),onKeyDown:u=>{u.key==="Enter"?d():u.key==="Escape"&&(r.current=!0,o())},onBlur:d})}function Ii({entry:t,depth:n,ctx:s}){const o=Ht(Wt(t.path)||"",t.path);return s.renaming===t.path?e.jsx(Ut,{initial:t.name,depth:n,onCommit:i=>s.commitRename(t,i),onCancel:s.cancelEdit}):e.jsxs("div",{className:`t2sf-row t2sf-file${s.isSel(t.path)?" sel":""}`,"data-sel-id":t.path,style:{paddingLeft:Vn(n+1)},...Ro(()=>Mo(t.path,t.name)),draggable:Fe(),onDragStart:i=>s.rowDragStart(i,t),onDragEnd:s.dragEnd,onDragOver:i=>s.dragOverDir(i,nt(t.path)),onDragLeave:()=>s.dragLeaveDir(nt(t.path)),onDrop:i=>s.dropOnDir(i,nt(t.path)),onClick:i=>s.rowClick(i,t),onDoubleClick:()=>s.openFile(t),onContextMenu:i=>s.onMenu(i,t),children:[e.jsx("span",{className:"t2s-lead",children:e.jsx(o,{className:"t2s-lead-icon t2sf-fic"})}),e.jsx("span",{className:"t2sf-name",children:t.name}),t.size>0&&e.jsx("span",{className:"t2sf-size",children:Vt(t.size)})]})}function _i({entry:t,depth:n,ctx:s,forceOpen:o}){const i=!!o&&(o===t.path||o.startsWith(t.path+"/")||o.startsWith(t.path+"\\")),[a,r]=l.useState(i),[d,u]=l.useState(null);l.useEffect(()=>{i&&r(!0)},[i,o]),l.useEffect(()=>{const f=j=>{const y=j.detail;(y==="*"||y===t.path)&&u(null)};return Tt.addEventListener("fs-bump",f),()=>Tt.removeEventListener("fs-bump",f)},[t.path]);const v=s.creating?.dir===t.path;return l.useEffect(()=>{v&&r(!0)},[v]),l.useEffect(()=>{if(!a||d)return;let f=!0;return window.tangu?.listDir?.(t.path).then(j=>{f&&u(Mi(j))}).catch(()=>{f&&u([])}),()=>{f=!1}},[a,d,t.path]),e.jsxs(e.Fragment,{children:[s.renaming===t.path?e.jsx(Ut,{initial:t.name,depth:n,onCommit:f=>s.commitRename(t,f),onCancel:s.cancelEdit}):e.jsxs("div",{className:`t2sf-row${s.isSel(t.path)?" sel":""}${s.dropDir===t.path?" drop":""}`,"data-sel-id":t.path,style:{paddingLeft:Vn(n+1)},...Ro(()=>Mo(t.path,t.name)),draggable:Fe(),onDragStart:f=>s.rowDragStart(f,t),onDragEnd:s.dragEnd,onDragOver:f=>s.dragOverDir(f,t.path),onDragLeave:()=>s.dragLeaveDir(t.path),onDrop:f=>s.dropOnDir(f,t.path),onClick:f=>{s.rowClick(f,t).open!=="none"&&f.detail===1&&r(y=>!y)},onContextMenu:f=>s.onMenu(f,t),children:[e.jsxs("span",{className:"t2s-lead",children:[a?e.jsx(jt,{className:"t2s-lead-icon t2sf-fic"}):e.jsx(Zt,{className:"t2s-lead-icon t2sf-fic"}),e.jsx("span",{className:`t2s-chev t2s-lead-chev${a?" open":""}`,children:e.jsx(xe,{size:12})})]}),e.jsx("span",{className:"t2sf-name",children:t.name})]}),e.jsxs(Ge,{open:a,children:[v&&s.creating&&e.jsx(Ut,{initial:"",depth:n+1,onCommit:f=>s.commitCreate(t.path,s.creating.kind,f),onCancel:s.cancelEdit}),d===null?e.jsx("div",{className:"t2sf-loading",style:{paddingLeft:Qt(n+2)},children:"…"}):e.jsx(e.Fragment,{children:d.map(f=>f.isDir?e.jsx(_i,{entry:f,depth:n+1,ctx:s,forceOpen:i?o:null},f.path):e.jsx(Ii,{entry:f,depth:n+1,ctx:s},f.path))})]})]})}function Gs({label:t,title:n,scope:s,kind:o,open:i,onToggle:a,onOpenPreview:r,sel:d,rowDownload:u=!1,emptyText:v}){const{t:f}=U(),j=M($=>$.cfg),{sessionId:y,project:p}=s,w=M($=>p?Object.keys($.runningBySession).length>0:!!$.runningBySession[y]),[N,b]=l.useState(null),[x,c]=l.useState(null),C=kr(xo(y)).workspaceDelete,m=`${y}
46
- ${p??""}`,k=l.useRef(m);k.current=m,l.useEffect(()=>{b(null)},[m]);const z=l.useCallback(()=>{const $=m;Sr(de(y),y,p).then(q=>{k.current===$&&b([...q].sort((T,L)=>T.path.localeCompare(L.path)))}).catch(()=>{k.current===$&&b([])})},[j,y,p,m]);l.useEffect(()=>{i&&N===null&&z()},[i,N,z]);const g=l.useRef(w);l.useEffect(()=>{g.current&&!w&&i&&z(),g.current=w},[w,i,z]);const A=$=>{zr(de(y),y,$.path,p).catch(q=>M.getState().toast(q?.message||String(q),!0))},P=($,q)=>{r({name:$.path,load:async()=>{const T=await Nr(de(y),y,$.path,p);return{mimeType:T.mimeType,bytes:Cr(T.content),size:T.size}},download:()=>A($)},q?{newTab:!0}:void 0)},B=async $=>{if(window.confirm(f("panel.confirm.delete",{name:$.path})))try{await us(de(y),y,$.path,p),z()}catch(q){M.getState().toast(q?.message||String(q),!0)}},_=async $=>{if(!(!$.length||!window.confirm(f("panel.confirm.deleteN",{n:String($.length)})))){try{for(const q of $)await us(de(y),y,q.path,p)}catch(q){M.getState().toast(q?.message||String(q),!0)}d.clear(),z()}},V=($,q)=>{$.preventDefault(),$.stopPropagation();const T=d.batch(q.path);if(T.length===1&&d.only(q.path),T.length>1){if(!C)return;const G=(N??[]).filter(re=>T.includes(re.path)),ee=[{label:f("panel.action.deleteN",{n:String(G.length)}),icon:e.jsx(Ct,{size:13}),danger:!0,run:()=>{_(G)}}];c({...Nt($,ee.length),items:ee});return}const L=[{label:f("panel.action.preview"),icon:e.jsx(Gt,{size:13}),run:()=>P(q)},{label:f("panel.action.download"),icon:e.jsx(Be,{size:13}),run:()=>A(q)},...C?[{label:f("panel.action.delete"),icon:e.jsx(Ct,{size:13}),danger:!0,run:()=>{B(q)}}]:[]];c({...Nt($,L.length),items:L})};return e.jsxs("div",{"data-ws-scope":o,children:[e.jsxs("div",{className:"t2s-group",style:{paddingLeft:Ao(0)},children:[e.jsxs("button",{className:"t2s-group-toggle t2s-folder-row",onClick:a,title:n,children:[e.jsxs("span",{className:"t2s-lead",children:[i?e.jsx(jt,{className:"t2s-lead-icon"}):e.jsx(Zt,{className:"t2s-lead-icon"}),e.jsx("span",{className:`t2s-chev t2s-lead-chev${i?" open":""}`,children:e.jsx(xe,{size:12})})]}),e.jsx("span",{className:"t2s-group-label",children:t})]}),e.jsx("button",{className:"t2s-group-add",title:f("panel.files.refresh"),onClick:z,children:e.jsx(vt,{size:13})})]}),e.jsx(Ge,{open:i,children:e.jsx("div",{className:"t2sf-tree",children:N==null?e.jsx("div",{className:"t2sf-loading",style:{paddingLeft:Qt(1)},children:"…"}):N.length===0?e.jsx("div",{className:"t2sf-empty",children:v||f("panel.files.empty")}):N.map($=>{const q=Ht(Wt($.path)||"",$.path);return e.jsxs("div",{className:`t2sf-row t2sf-file${d.has($.path)?" sel":""}`,"data-sel-id":$.path,"data-ws-file":$.path,style:{paddingLeft:Vn(1)},onClick:T=>{const L=d.click($.path,T);L.open!=="none"&&P($,L.open==="new")},onDoubleClick:()=>P($),onContextMenu:T=>V(T,$),children:[e.jsx("span",{className:"t2s-lead",children:e.jsx(q,{className:"t2s-lead-icon t2sf-fic"})}),e.jsx("span",{className:"t2sf-name",children:$.path.replace(/^\//,"")}),$.size>0&&e.jsx("span",{className:"t2sf-size",children:Vt($.size)}),u&&e.jsx("button",{className:"t2sf-row-act","data-download":!0,"aria-label":f("panel.action.download"),title:f("panel.action.download"),onClick:T=>{T.stopPropagation(),A($)},onDoubleClick:T=>T.stopPropagation(),children:e.jsx(Be,{size:14})})]},$.path)})})}),x&&e.jsx(Lo,{menu:x,onClose:()=>c(null)})]})}function Rp({workspaces:t,onOpenPreview:n,activeWorkspaceKey:s,onEnterWorkspace:o,expandToPath:i,pinnedWorkspaceKey:a}){const{t:r}=U(),d=M(S=>Object.keys(S.runningBySession).length>0),u=M(S=>S.openWorkspaceKeys),v=M(S=>S.toggleOpenWorkspace),f=t.filter(S=>S.kind==="local"&&!!S.path),j=t.filter(S=>S.kind==="cloud"&&!!S.project),y=M(S=>S.activeId),p=Jt(y).kind==="unit"?y:null,[w,N]=l.useState(!0),[b,x]=l.useState({}),c=l.useRef(null),C=Cl(c),[m,k]=l.useState(null),[z,g]=l.useState(null),[A,P]=l.useState(null),[B,_]=l.useState(null),[V,$]=l.useState(!1),q=l.useRef(null),T=(S,R)=>M.getState().toast(S,R),L=(S,R)=>{S.isDir||n(wo(S.path,S.name),R?{newTab:!0}:void 0)},G=(S,R)=>{const E=C.click(R.path,S);return E.open!=="none"&&!R.isDir&&L(R,E.open==="new"),E},ee=l.useCallback((S,R)=>{x(E=>({...E,[S]:E[S]??null})),window.tangu?.listDir?.(R).then(E=>x(O=>({...O,[S]:Mi(E)}))).catch(()=>x(E=>({...E,[S]:[]})))},[]),re=f.map(S=>`${S.key}
47
- ${S.path}`).join("\0");l.useEffect(()=>{const S=re?re.split("\0").map(E=>E.split(`
48
- `)):[],R=E=>{const O=E.detail;for(const[ce,Pe]of S)Pe&&(O==="*"||O===Pe)&&ee(ce,Pe)};return Tt.addEventListener("fs-bump",R),()=>Tt.removeEventListener("fs-bump",R)},[re,ee]);const Z=l.useRef(d);l.useEffect(()=>{Z.current&&!d&&$e("*"),Z.current=d},[d]);const H=async(S,R)=>{if(k(null),!(!R||R===S.name||!window.tangu?.renameHostPath)){try{await window.tangu.renameHostPath(S.path,R)}catch(E){T(r("panel.toast.renameFail",{err:E?.message||E}),!0)}$e(nt(S.path))}},he=async(S,R,E)=>{if(g(null),!!E){if(!ih(E)){T(r("panel.toast.invalidName",{name:E}),!0);return}try{R==="folder"?await window.tangu?.mkdirHost?.(S,E):await window.tangu?.writeHostFile?.(`${S}/${E}`,"",void 0,!0)}catch(O){T(r("panel.toast.mkdirFail",{err:O?.message||O}),!0)}$e(S)}},le=async S=>{if(!(!S.length||!window.tangu?.trashHostPath||!window.confirm(S.length===1?r("panel.confirm.trash",{name:S[0].split(/[/\\]/).pop()||""}):r("panel.confirm.trashN",{n:String(S.length)})))){try{for(const E of S)await window.tangu.trashHostPath(E)}catch(E){T(r("panel.toast.deleteFail",{err:E?.message||E}),!0)}C.clear();for(const E of S)$e(nt(E))}},W=async(S,R)=>{if(!window.tangu?.moveHostPath)return;const E=R.filter(O=>O!==S&&!S.startsWith(O+"/")&&!S.startsWith(O+"\\"));try{for(const O of E)await window.tangu.moveHostPath(O,S),$e(nt(O))}catch(O){T(r("panel.toast.moveFail",{err:O?.message||O}),!0)}E.length&&$e(S)},K=async(S,R)=>{if(!(!window.tangu?.copyHostFiles||!S.length)){try{const E=await window.tangu.copyHostFiles(S,R);T(r("panel.toast.copied",{n:String(E.copied)}))}catch(E){T(r("panel.toast.copyFail",{err:E?.message||E}),!0)}$e(R)}},F=async(S,R)=>{const E=window.tangu?.copyNoteBundles;if(!E)return K(S,R);const O=new Set(S),ce=ie=>ie.replace(/\.md$/i,".fd"),Pe=S.filter(ie=>/\.md$/i.test(ie)).map(ie=>({md:ie,fd:O.has(ce(ie))?ce(ie):void 0})),Je=new Set(Pe.flatMap(ie=>ie.fd?[ie.md,ie.fd]:[ie.md])),qe=S.filter(ie=>!Je.has(ie)&&!Pe.some(Rt=>Rt.fd&&ie.startsWith(`${Rt.fd}/`)));try{let ie=0;Pe.length&&(ie+=(await E(Pe,R)).copied),qe.length&&window.tangu?.copyHostFiles&&(ie+=(await window.tangu.copyHostFiles(qe,R)).copied),T(r("panel.toast.copied",{n:String(ie)}))}catch(ie){T(r("panel.toast.copyFail",{err:ie?.message||ie}),!0)}$e(R)},X=async(S,R)=>{window.tangu?.getPathForFile&&await K(Array.from(S).map(E=>{try{return window.tangu.getPathForFile(E)}catch{return""}}).filter(Boolean),R)},oe=(S,R)=>{S.preventDefault(),S.stopPropagation();const E=C.batch(R.path);if(E.length===1&&C.only(R.path),E.length>1){const ce=[{label:r("panel.action.copyPath"),icon:e.jsx(st,{size:13}),run:()=>{navigator.clipboard.writeText(E.join(`
49
- `))}}];Fe()&&ce.push({label:r("panel.action.deleteN",{n:String(E.length)}),icon:e.jsx(Ct,{size:13}),danger:!0,run:()=>{le(E)}}),P({...Nt(S,ce.length),items:ce});return}const O=[];R.isDir?Fe()&&(O.push({label:r("panel.action.newFile"),icon:e.jsx(cn,{size:13}),run:()=>g({dir:R.path,kind:"file"})}),O.push({label:r("panel.action.newFolder"),icon:e.jsx(ln,{size:13}),run:()=>g({dir:R.path,kind:"folder"})})):(O.push({label:r("panel.action.open"),icon:e.jsx(Gt,{size:13}),run:()=>L(R)}),window.tangu?.openHostPath&&O.push({label:r("preview.openWithDefault"),icon:e.jsx(pt,{size:13}),run:()=>{window.tangu?.openHostPath?.(R.path).then(ce=>{ce&&!ce.ok&&T(ce.error||"open failed",!0)})}})),Fe()&&O.push({label:r("panel.action.rename"),icon:e.jsx(xt,{size:13}),run:()=>k(R.path)}),O.push({label:r("panel.action.copyPath"),icon:e.jsx(st,{size:13}),run:()=>{navigator.clipboard.writeText(R.path)}}),Vs()&&O.push({label:r("panel.action.revealInFileManager"),icon:e.jsx(Nn,{size:13}),run:()=>{window.tangu?.revealHostPath?.(R.path)}}),Fe()&&O.push({label:r("panel.action.moveToTrash"),icon:e.jsx(Ct,{size:13}),danger:!0,run:()=>{le([R.path])}}),P({...Nt(S,O.length),items:O})},pe=(S,R)=>{if(!R.path)return;S.preventDefault(),S.stopPropagation();const E=R.path,O=[];Fe()&&(O.push({label:r("panel.action.newFile"),icon:e.jsx(cn,{size:13}),run:()=>{o?.(R.key),g({dir:E,kind:"file"})}}),O.push({label:r("panel.action.newFolder"),icon:e.jsx(ln,{size:13}),run:()=>{o?.(R.key),g({dir:E,kind:"folder"})}})),Vs()&&O.push({label:r("panel.action.revealInFileManager"),icon:e.jsx(Nn,{size:13}),run:()=>{window.tangu?.revealHostPath?.(E)}}),O.push({label:r("panel.files.refresh"),icon:e.jsx(vt,{size:13}),run:()=>$e(E)}),P({...Nt(S,O.length),items:O})},D=(S,R)=>{if(S.altKey&&window.tangu?.startHostDrag){S.preventDefault(),window.tangu.startHostDrag(R.path);return}const E=C.batch(R.path);q.current=E,S.dataTransfer.setData(an,JSON.stringify(E)),S.dataTransfer.effectAllowed="copyMove"},Q=()=>{q.current=null,_(null)},J=(S,R)=>{const E=Fe()&&S.dataTransfer.types.includes("Files");!(q.current||S.dataTransfer.types.includes(an))&&!E||q.current?.includes(R)||!E&&q.current?.every(ce=>nt(ce)===R)||(S.preventDefault(),S.stopPropagation(),S.dataTransfer.dropEffect=E||S.dataTransfer.types.includes(ds)?"copy":"move",_(R))},fe=S=>{_(R=>R===S?null:R)},Ce=(S,R)=>{S.preventDefault(),S.stopPropagation();const E=S.dataTransfer.files;let O=q.current;if(!O)try{O=JSON.parse(S.dataTransfer.getData(an)||"null")}catch{O=null}const ce=S.dataTransfer.types.includes(ds);_(null),q.current=null,E?.length?X(E,R):O?.length&&(ce?F(O,R):W(R,O))},ke={isSel:C.has,rowClick:G,openFile:L,onMenu:oe,renaming:m,commitRename:H,creating:z,commitCreate:he,cancelEdit:()=>{k(null),g(null)},dropDir:B,rowDragStart:D,dragEnd:Q,dragOverDir:J,dragLeaveDir:fe,dropOnDir:Ce},We=S=>{const R=!u.includes(S.key);v(S.key,R),R&&o?.(S.key)};l.useEffect(()=>{s&&(v(s,!0),s!==a&&$(!0))},[s,a,v]),l.useEffect(()=>{for(const S of u){const R=f.find(E=>E.key===S);R?.path&&b[S]===void 0&&ee(S,R.path)}},[u,f,b,ee]);const ge=p?e.jsx(Gs,{label:r("panel.files.sessionFiles"),scope:{sessionId:p},kind:"session",open:w,onToggle:()=>N(S=>!S),onOpenPreview:n,sel:C,rowDownload:!0,emptyText:r("panel.files.sessionEmpty")},`session:${p}`):null;if(!f.length&&!j.length)return ge?e.jsx("aside",{className:"t2s-side",children:e.jsx("div",{ref:c,className:"t2s-scroll",children:ge})}):e.jsx("div",{className:"t2s-hint",style:{padding:"18px 12px"},children:r("panel.files.noLocalWs")});const Oe=S=>{if(S.kind==="cloud")return e.jsx(Gs,{label:S.name,title:S.project,scope:{sessionId:"__project__",project:S.project},kind:"project",open:u.includes(S.key),onToggle:()=>We(S),onOpenPreview:n,sel:C},S.key);const R=u.includes(S.key),E=b[S.key];return e.jsxs("div",{children:[e.jsxs("div",{className:`t2s-group${B===S.path?" drop":""}`,style:{paddingLeft:Ao(0)},onContextMenu:O=>pe(O,S),onDragOver:O=>{S.path&&R&&J(O,S.path)},onDragLeave:()=>{S.path&&fe(S.path)},onDrop:O=>{S.path&&Ce(O,S.path)},children:[e.jsxs("button",{className:"t2s-group-toggle t2s-folder-row",onClick:()=>We(S),title:S.path||void 0,children:[e.jsxs("span",{className:"t2s-lead",children:[R?e.jsx(jt,{className:"t2s-lead-icon"}):e.jsx(Zt,{className:"t2s-lead-icon"}),e.jsx("span",{className:`t2s-chev t2s-lead-chev${R?" open":""}`,children:e.jsx(xe,{size:12})})]}),e.jsx("span",{className:"t2s-group-label",children:S.name})]}),R&&Fe()&&e.jsx("button",{className:"t2s-group-add",title:r("panel.action.newFile"),onClick:()=>{S.path&&g({dir:S.path,kind:"file"})},children:e.jsx(cn,{size:13})}),R&&Fe()&&e.jsx("button",{className:"t2s-group-add",title:r("panel.action.newFolder"),onClick:()=>{S.path&&g({dir:S.path,kind:"folder"})},children:e.jsx(ln,{size:13})}),e.jsx("button",{className:"t2s-group-add",title:r("panel.files.refresh"),onClick:()=>{S.path&&ee(S.key,S.path)},children:e.jsx(vt,{size:13})})]}),e.jsx(Ge,{open:R,children:e.jsxs("div",{className:"t2sf-tree",children:[z&&S.path&&z.dir===S.path&&e.jsx(Ut,{initial:"",depth:1,onCommit:O=>he(S.path,z.kind,O),onCancel:()=>g(null)}),E==null?e.jsx("div",{className:"t2sf-loading",style:{paddingLeft:Qt(1)},children:"…"}):E.length===0?e.jsx("div",{className:"t2sf-empty",children:r("panel.files.empty")}):E.map(O=>O.isDir?e.jsx(_i,{entry:O,depth:1,ctx:ke,forceOpen:R?i:null},O.path):e.jsx(Ii,{entry:O,depth:1,ctx:ke},O.path))]})})]},S.key)},ne=[...j,...f],Ae=[a,s,ne[0]?.key].find(S=>S&&ne.some(R=>R.key===S))??null,me=ne.filter(S=>S.key!==Ae);return e.jsxs("aside",{className:"t2s-side",children:[e.jsxs("div",{ref:c,className:"t2s-scroll",onClick:S=>{S.target===S.currentTarget&&C.clear()},children:[ge,ne.filter(S=>S.key===Ae).map(Oe),me.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"t2sf-showall",onClick:()=>$(S=>!S),children:[e.jsx("span",{className:`t2s-chev${V?" open":""}`,children:e.jsx(xe,{size:12})}),r("panel.files.showAllWs"),e.jsx("span",{className:"t2sf-showall-n",children:me.length})]}),e.jsx(Ge,{open:V,children:me.map(Oe)})]})]}),A&&e.jsx(Lo,{menu:A,onClose:()=>P(null)})]})}async function ah(t,n){const s=M.getState().toast,o=t.replace(/(\.[^./\\]+)?$/,`.本地未保存-${Date.now()}$1`);try{await window.tangu?.writeHostFile?.(o,n,void 0,!0),$e(o.slice(0,Math.max(o.lastIndexOf("/"),o.lastIndexOf("\\")))),s(M.getState().tr("preview.mdSalvaged",{file:o.split(/[/\\]/).pop()||o}),!0)}catch{s(M.getState().tr("preview.mdSaveFail",{err:t}),!0)}}const Ks=({src:t,kind:n,seek:s})=>{const o=l.useRef(null);l.useEffect(()=>{const a=o.current;if(!a||!s)return;const r=()=>{try{a.currentTime=s.t}catch{}};if(a.readyState>=1){r();return}return a.addEventListener("loadedmetadata",r,{once:!0}),()=>a.removeEventListener("loadedmetadata",r)},[t,s?.t,s?.nonce]),l.useEffect(()=>{const a=o.current,r=s?.to;if(!a||!r)return;const d=()=>{a.currentTime>=r&&a.pause()};return a.addEventListener("timeupdate",d),()=>a.removeEventListener("timeupdate",d)},[s?.to]);const i={ref:a=>{o.current=a},src:t,controls:!0,preload:"metadata"};return n==="video"?e.jsx("video",{...i}):e.jsx("audio",{...i})},rh=({path:t,text:n,mtimeMs:s,view:o,onReload:i,focusLine:a})=>{const{t:r}=U(),d=Tr(m=>m.mode),u=l.useMemo(()=>Er(n).fm,[n]),v=l.useRef(n.slice(u.length)),f=l.useRef(s),j=l.useRef(!1),y=l.useRef(null),[p,w]=l.useState(!1),[N,b]=l.useState(null),x=async m=>{if(!j.current||!window.tangu?.writeHostFile)return{};const k=v.current,z=window.tangu.writeHostFile(t,u+k,m?void 0:f.current);hs.set(t,z.catch(()=>{}));try{const g=await z;return g.conflict?(w(!0),{conflict:!0}):(f.current=g.mtimeMs,j.current=v.current!==k,w(!1),b(null),{})}catch(g){return b(g?.message||String(g)),{failed:!0}}finally{hs.delete(t)}},c=l.useRef(x);c.current=x;const C=m=>{v.current=m,j.current=!0,y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{c.current()},800)};return l.useEffect(()=>()=>{y.current&&clearTimeout(y.current);const m=u+v.current,k=j.current;c.current().then(z=>{k&&(z.conflict||z.failed)&&ah(t,m)})},[]),e.jsxs("div",{className:"wsmd-edit",children:[p&&e.jsxs("div",{className:"wsmd-banner",children:[e.jsx(Pl,{size:13}),e.jsx("span",{children:r("preview.mdConflict")}),e.jsx("button",{className:"btn ghost sm",onClick:i,children:r("preview.mdReload")}),e.jsx("button",{className:"btn ghost sm",onClick:()=>{x(!0)},children:r("preview.mdOverwrite")})]}),N&&e.jsxs("div",{className:"wsmd-banner danger",children:[e.jsx(Ue,{size:13}),e.jsx("span",{children:r("preview.mdSaveFail",{err:N})})]}),o==="source"?Se({value:u+v.current,fileName:t,wrap:!1,focusLine:a}):e.jsx("div",{className:"am-app tangu-lovable wsmd-scope","data-mode":d,children:e.jsx(ql,{initial:v.current,onChange:C})})]})};function lh({leaf:t}){const{t:n}=U(),s=typeof t.params.path=="string"?t.params.path:null,o=typeof t.params.tkey=="string"?t.params.tkey:null,i=typeof t.params.name=="string"&&t.params.name?t.params.name:s?s.split(/[/\\]/).pop()||s:"",a=typeof t.params.line=="number"&&t.params.line>=1?Math.trunc(t.params.line):null,r=typeof t.params.endLine=="number"&&t.params.endLine>=1?Math.trunc(t.params.endLine):void 0,[d,u]=l.useState(a?{line:a,end:r,nonce:0}:null),v=typeof t.params.t=="number"&&t.params.t>=0?t.params.t:null,f=typeof t.params.tTo=="number"&&t.params.tTo>(v??0)?t.params.tTo:void 0,[j,y]=l.useState(v!=null?{t:v,to:f,nonce:0}:null),p=l.useMemo(()=>s?wo(s,i):o?Pr(o)??null:null,[s,o,i]);l.useEffect(()=>{i&&t.setTitle(i)},[i]);const[w,N]=l.useState(!0),[b,x]=l.useState(null),[c,C]=l.useState(null),[m,k]=l.useState(null),[z,g]=l.useState(null),[A,P]=l.useState(a?"source":"preview"),[B,_]=l.useState(a?"source":"edit");l.useEffect(()=>{if(!s)return;const S=R=>{const E=R.detail;if(!(!E||E.path!==s)){if(E.clear){u(null),y(null),t.setParams({line:void 0,endLine:void 0,t:void 0,tTo:void 0});return}if(typeof E.t=="number"&&E.t>=0){y(O=>({t:E.t,to:typeof E.tTo=="number"&&E.tTo>E.t?E.tTo:void 0,nonce:(O?.nonce??0)+1}));return}typeof E.line!="number"||E.line<1||(u(O=>({line:Math.trunc(E.line),end:typeof E.endLine=="number"&&E.endLine>=1?Math.trunc(E.endLine):void 0,nonce:(O?.nonce??0)+1})),_("source"),P("source"))}};return window.addEventListener("amadeus:wsfile-goto",S),()=>window.removeEventListener("amadeus:wsfile-goto",S)},[s]);const[V,$]=l.useState(0),[q,T]=l.useState(!1),[L,G]=l.useState(!0),[ee,re]=l.useState({s:1,x:0,y:0}),Z=io(i),H=c?Lt(c.mimeType,i):"binary",he=Ht(c?.mimeType||"",i);l.useEffect(()=>{if(!p){N(!1);return}let S=!1,R=null;return N(!0),x(null),C(null),k(null),g(null),re({s:1,x:0,y:0}),(async()=>{try{const E=await p.load();if(S)return;if(!E){x("not-found"),N(!1);return}if("tooLarge"in E){k(E.size),N(!1);return}if(Yo.has(Lt(E.mimeType,i))){const O=Wt(i)||E.mimeType||"application/octet-stream";R=URL.createObjectURL(new Blob([E.bytes],{type:O})),g(R)}C(E),N(!1)}catch(E){S||(x(E?.message||"error"),N(!1))}})(),()=>{S=!0,R&&URL.revokeObjectURL(R)}},[p,V]);const le=l.useMemo(()=>c&&Ko.has(H)?new TextDecoder("utf-8",{fatal:!1}).decode(c.bytes):"",[c,H]),[W,K]=l.useState(null),[F,X]=l.useState(!1),[oe,pe]=l.useState(0);l.useEffect(()=>{if(!c||H!=="xlsx"&&H!=="pptx"){K(null),X(!1);return}let S=!1;return K(null),X(!1),pe(0),Zo(c.bytes,H).then(R=>{S||K(R)}).catch(()=>{S||X(!0)}),()=>{S=!0}},[c,H]);const D=()=>{s&&window.tangu?.openHostPath?.(s).then(S=>{S&&!S.ok&&M.getState().toast(S.error||"open failed",!0)})},Q=()=>{s&&window.tangu?.revealHostPath?.(s)},J=s&&window.tangu?.openHostPath?e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn ghost sm",onClick:D,children:[e.jsx(pt,{size:13})," ",n("preview.openWithDefault")]}),e.jsxs("button",{className:"btn ghost sm",onClick:Q,children:[e.jsx(Nn,{size:13})," ",n("panel.action.revealInFileManager")]})]}):p?.download?e.jsxs("button",{className:"btn ghost sm",onClick:p.download,children:[e.jsx(Be,{size:13})," ",n("preview.download")]}):null,fe=Kt(S=>S.fileTypes),Ce=!!s&&(/\.(excalidraw|mindmap)\.md$/i.test(s)||!!Hn(fe,s)),ke=H==="markdown"&&!!s&&!!window.tangu?.writeHostFile&&!Ce,We=rt(S=>S.vaultRoot),ge=l.useMemo(()=>{if(!s||!We)return null;const S=O=>O.replace(/\\/g,"/").replace(/\/+$/,""),R=S(We),E=S(s);return E.startsWith(R+"/")?E.slice(R.length+1):null},[s,We]),Oe=ge&&/\.md$/i.test(ge)?()=>{Ar(ge)}:void 0;let ne;if(!p)ne=e.jsxs("div",{className:"wsfile-center wsfile-fallback",children:[e.jsx(Ue,{size:26}),e.jsx("div",{children:n("preview.expired")})]});else if(w)ne=e.jsx(it,{});else if(m!==null)ne=e.jsxs("div",{className:"wsfile-center wsfile-fallback",children:[e.jsx(Ue,{size:26}),e.jsx("div",{children:n("preview.tooLarge",{size:Vt(m)})}),e.jsx("div",{className:"wsfile-ask-actions",children:J})]});else if(b||!c)ne=e.jsxs("div",{className:"wsfile-center wsfile-fallback",children:[e.jsx(Ue,{size:26}),e.jsx("div",{children:n(b==="not-found"?"preview.notFound":"preview.loadFailed")}),J&&e.jsx("div",{className:"wsfile-ask-actions",children:J})]});else if(H==="image")ne=z?e.jsx(Jo,{src:z,alt:i,view:ee,setView:re}):null;else if(H==="pdf")ne=e.jsx(Xo,{bytes:c.bytes,download:p.download});else if(H==="video")ne=e.jsx("div",{className:"wsfile-media",children:z&&e.jsx(Ks,{src:z,kind:"video",seek:j})});else if(H==="audio")ne=e.jsx("div",{className:"wsfile-media wsfile-audio",children:z&&e.jsx(Ks,{src:z,kind:"audio",seek:j})});else if(H==="markdown")ke?ne=e.jsx(rh,{path:s,text:le,mtimeMs:c.mtimeMs,view:B,onReload:()=>$(S=>S+1),focusLine:d},`${s}:${c.mtimeMs??0}:${V}`):Ce||A==="source"?ne=Se({value:le,fileName:i,wrap:q,focusLine:d}):ne=e.jsx("div",{className:"wsfile-doc msg-content",children:e.jsx(Ke,{content:le})});else if(H==="json"){let S=le;if(!d)try{S=JSON.stringify(JSON.parse(le),null,2)}catch{}ne=Se({value:S,fileName:"x.json",language:"json",wrap:q,focusLine:d})}else if(H==="code")ne=Se({value:le,fileName:i,wrap:q,focusLine:d});else if(H==="text")ne=Se({value:le,fileName:i,wrap:q,focusLine:d});else if(H==="diff")ne=d?Se({value:le,fileName:i,wrap:q,focusLine:d}):e.jsx(Wn,{text:le,side:L});else if(H==="csv"&&d)ne=Se({value:le,fileName:i,wrap:q,focusLine:d});else if(H==="csv"){const S=ao(le,Z==="tsv"?" ":","),R=S.slice(0,mt),E=R[0]??[];ne=e.jsxs("div",{className:"wsfile-doc",children:[e.jsxs("table",{className:"wsfile-table",children:[e.jsx("thead",{children:e.jsx("tr",{children:E.map((O,ce)=>e.jsx("th",{children:O},ce))})}),e.jsx("tbody",{children:R.slice(1).map((O,ce)=>e.jsx("tr",{children:E.map((Pe,Je)=>e.jsx("td",{children:O[Je]??""},Je))},ce))})]}),S.length>mt&&e.jsx("div",{className:"panel-note",children:n("preview.csvTruncated",{shown:String(mt),total:String(S.length)})})]})}else H==="html"?ne=A==="preview"?e.jsx(Go,{path:s??p.path,text:le,title:i,nonce:V}):Se({value:le,language:"html",wrap:q,focusLine:d}):H==="docx"?ne=e.jsx(Qo,{bytes:c.bytes,download:p.download}):H==="xlsx"||H==="pptx"?ne=F?e.jsx(en,{t:n,download:p.download}):W?W.kind==="xlsx"?e.jsxs("div",{className:"wsfile-sheetwrap",children:[W.sheets.length>1&&e.jsx("div",{className:"wsfile-seg wsfile-sheet-tabs",children:W.sheets.map((S,R)=>e.jsx("button",{className:R===oe?"active":"",onClick:()=>pe(R),children:S.name},R))}),e.jsx("div",{className:"wsfile-doc wsfile-sheet",dangerouslySetInnerHTML:{__html:W.sheets[oe]?.html??W.sheets[0]?.html??""}})]}):e.jsx("div",{className:"wsfile-doc wsfile-pptx",children:W.slides.map((S,R)=>{const E=S.split(`
50
- `);return e.jsxs("div",{className:"wsfile-slide",children:[e.jsx("div",{className:"wsfile-slide-no",children:n("preview.slide",{n:String(R+1)})}),E[0]&&e.jsx("div",{className:"wsfile-slide-title",children:E[0]}),e.jsx("pre",{children:E.slice(1).join(`
51
- `)||(E[0]?"":"—")})]},R)})}):e.jsx(it,{}):ne=e.jsxs("div",{className:"wsfile-center wsfile-fallback",children:[e.jsx(Ue,{size:26}),e.jsx("div",{children:n(s?"preview.unsupportedAsk":"preview.notAvailable")}),e.jsx("div",{className:"wsfile-ask-actions",children:J})]});const Ae=!w&&!b&&m===null&&!!c,me=Ae&&(H==="code"||H==="json"||H==="text"||H==="html"&&A==="source"||H==="markdown"&&!ke&&(A==="source"||Ce));return e.jsxs("div",{className:"wsfile-tab",children:[e.jsxs("div",{className:"wsfile-head",children:[e.jsx(he,{size:14,className:"wsfile-head-icon"}),e.jsxs("div",{className:"wsfile-title",title:s??i,children:[e.jsx("span",{className:"wsfile-name",children:s??i}),Z&&e.jsx("span",{className:"wsfile-ext",children:Z})]}),Ae&&ke&&e.jsxs("div",{className:"wsfile-seg",children:[e.jsx("button",{className:B==="edit"?"active":"",title:n("preview.mdEdit"),onClick:()=>_("edit"),children:e.jsx(xt,{size:13})}),e.jsx("button",{className:B==="source"?"active":"",title:n("preview.htmlCode"),onClick:()=>_("source"),children:e.jsx(Ot,{size:13})})]}),Ae&&!ke&&!Ce&&(H==="markdown"||H==="html")&&e.jsxs("div",{className:"wsfile-seg",children:[e.jsx("button",{className:A==="preview"?"active":"",title:n("preview.htmlPreview"),onClick:()=>P("preview"),children:e.jsx(Gt,{size:13})}),e.jsx("button",{className:A==="source"?"active":"",title:n("preview.htmlCode"),onClick:()=>P("source"),children:e.jsx(Ot,{size:13})}),H==="html"&&A==="preview"&&e.jsx("button",{title:n("preview.reload"),onClick:()=>$(S=>S+1),children:e.jsx(vt,{size:12})}),H==="html"&&A==="preview"&&!!(s??p?.path)&&!!window.tangu?.codePreviewServePath&&!!window.tangu?.openExternal&&e.jsx("button",{title:n("preview.openInBrowser"),onClick:()=>{window.tangu.codePreviewServePath(s??p.path).then(S=>window.tangu.openExternal(S.url)).catch(()=>{})},children:e.jsx(pt,{size:12})})]}),Ae&&H==="diff"&&e.jsxs("div",{className:"wsfile-seg",children:[e.jsx("button",{className:L?"active":"",title:n("preview.diffSideBySide"),onClick:()=>G(!0),children:e.jsx(ro,{size:13})}),e.jsx("button",{className:L?"":"active",title:n("preview.diffLineByLine"),onClick:()=>G(!1),children:e.jsx(Bo,{size:13})})]}),me&&e.jsx("button",{className:`icon-btn${q?" active":""}`,title:n("preview.wrap"),onClick:()=>T(S=>!S),children:e.jsx(Uo,{size:14})}),Ae&&H==="image"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"icon-btn",title:n("preview.zoomOut"),onClick:()=>re(S=>({...S,s:Math.min(8,Math.max(.1,S.s*.8))})),children:e.jsx(Io,{size:14})}),e.jsx("button",{className:"icon-btn",title:n("preview.zoomIn"),onClick:()=>re(S=>({...S,s:Math.min(8,Math.max(.1,S.s*1.25))})),children:e.jsx(_o,{size:14})}),e.jsx("button",{className:"icon-btn",title:n("preview.fit"),onClick:()=>re({s:1,x:0,y:0}),children:e.jsx(Oo,{size:14})})]}),Oe&&e.jsx("button",{className:"icon-btn",title:n("preview.openInAmadeus"),onClick:Oe,children:e.jsx(to,{size:14})}),s&&e.jsx("button",{className:"icon-btn",title:n("preview.openWithDefault"),onClick:D,children:e.jsx(pt,{size:14})}),p?.download&&e.jsx("button",{className:"icon-btn",title:n(s?"panel.action.revealInFileManager":"preview.download"),onClick:p.download,children:e.jsx(Be,{size:14})}),e.jsx("button",{className:"icon-btn",title:n("preview.reload"),onClick:()=>$(S=>S+1),children:e.jsx(vt,{size:14})})]}),e.jsx("div",{className:"wsfile-body",children:ne})]})}const Ys=t=>bo()?.agentStatus?.(t)??Rr(t);function $i({entry:t,surface:n,sessionId:s}){const o=l.useRef(null),i=l.useRef(s);i.current=s;const a=l.useRef(new Set),r=u=>{for(const v of[...a.current])try{v(u)}catch(f){console.error("[desk-companion] onStatus callback failed",t.key,f)}};l.useEffect(()=>{const u=o.current;if(!u)return;const v=a.current,f={surface:n,sessionId:()=>i.current,status:()=>Ys(i.current),onStatus:y=>(v.add(y),()=>{v.delete(y)})};let j;try{j=t.mount(u,f)}catch(y){console.error("[desk-companion] mount failed",t.key,y)}return()=>{try{typeof j=="function"&&j()}catch(y){console.error("[desk-companion] dispose failed",t.key,y)}v.clear(),u.replaceChildren()}},[t.key,t.mount,n]);const d=l.useRef(s);return l.useEffect(()=>{const u=bo()?.subscribeAgentStatus?.(r,s);return d.current!==s&&(d.current=s,r(Ys(s))),()=>{try{u?.()}catch(v){console.error("[desk-companion] unsubscribe failed",v)}}},[s]),e.jsx("div",{ref:o,className:"agent-desk-companion-slot","data-companion":t.key,"data-surface":n,style:{position:"relative",flex:"1 1 0",minHeight:0,minWidth:0,overflow:"hidden"}})}te({"desk.writing":{zh:"正在编辑 {name}",en:"Editing {name}"},"desk.drafting":{zh:"正在起草…",en:"Drafting…"},"desk.expand":{zh:"展开",en:"Expand"},"desk.collapse":{zh:"收起为卡片",en:"Collapse to card"},"desk.empty":{zh:"Agent 会在这里展示成果",en:"Agent will present work here"},"desk.clear":{zh:"清空 Desk",en:"Clear Desk"}});const Di=t=>M.getState().patchDesk(t,{items:[],mode:void 0,note:void 0}),Fi=(t,n,s)=>({id:t,type:n,loc:"main",params:s,setTitle:()=>{},setParams:()=>{},close:()=>{}});function Ft({item:t}){const n=l.useMemo(()=>Fi(`desk:${t.key}`,"wsfile",{path:t.path,name:t.name}),[t.key,t.path,t.name]);return e.jsx(lh,{leaf:n,params:n.params})}function ft({type:t,params:n,k:s}){const[,o]=l.useReducer(r=>r+1,0);l.useEffect(()=>yn(o),[]);const i=t==="chat"?void 0:jn(t),a=l.useMemo(()=>Fi(s,t,n),[s,t]);return i?e.jsx("div",{className:"desk-note-wrap",children:i.factory({leaf:a,params:a.params})}):e.jsxs("div",{className:"agent-desk-card-empty",children:[e.jsx(ot,{size:18}),e.jsx("span",{children:t})]})}function Li(t,n){if(!n||!t)return null;const s=a=>a.replace(/\\/g,"/").replace(/\/+$/,""),o=s(n),i=s(t);return i.startsWith(o+"/")?i.slice(o.length+1):null}const Oi=(t,n)=>eo(t)||Hn(n,t)?null:/\.md$/i.test(t)?"note":null;function ch(t){const[n,s]=l.useState(!1);return l.useEffect(()=>{let o=!0;const i=()=>rt.getState(),a=d=>d.replace(/\\/g,"/"),r=()=>i().files.some(d=>a(d)===t)||i().pages.some(d=>a(d)===t);return(async()=>{if(i().activePage!==t){if(!r()){if(await i().refreshStructure(),!o)return;if(!r()){s(!0);return}}s(!1),i().loadPage(t)}})(),()=>{o=!1}},[t]),n}function dh({item:t,rel:n}){return ch(n)?e.jsx(Ft,{item:t}):e.jsx(ft,{type:"amadeus-editor",params:{notePath:n},k:`desk-note:${n}`})}function qi({item:t,allowNative:n}){const s=rt(r=>r.vaultRoot),o=Kt(r=>r.fileTypes),i=Li(t.path,s);return i?Oi(i,o)?n?e.jsx(dh,{item:t,rel:i}):e.jsx(Ft,{item:t}):eo(i)?e.jsx(ft,{type:"amadeus-drawing",params:{drawingPath:i},k:`desk-draw:${i}`}):Hn(o,i)?e.jsx(ft,{type:"amadeus-plugin-file",params:{filePath:i},k:`desk-ft:${i}`}):/\.db$/i.test(i)?e.jsx(ft,{type:"amadeus-db",params:{dbPath:i},k:`desk-db:${i}`}):e.jsx(Ft,{item:t}):e.jsx(Ft,{item:t})}function Bi(t){l.useEffect(()=>{Mr()},[]);const n=rt(o=>o.vaultRoot),s=Kt(o=>o.fileTypes);return t.find(o=>{if(o.live||o.view)return!1;const i=Li(o.path,n);return!!i&&Oi(i,s)!==null})?.key}function Ui({sessionId:t,item:n}){const{t:s}=U(),o=n.live,i=M(d=>d.messagesBySession[t]?.find(v=>v.id===o.msgId)?.toolEvents?.find(v=>v.id===o.toolId)?.arguments||""),a=l.useMemo(()=>_r(i,o.tool),[i,o.tool]),r=l.useRef(null);return l.useEffect(()=>{const d=r.current;d&&(d.scrollTop=d.scrollHeight)},[a]),e.jsxs("div",{className:"agent-desk-livepane",children:[e.jsxs("div",{className:"agent-desk-livehead",children:[e.jsx(Ye,{size:12,className:"spin"}),e.jsx("span",{className:"agent-desk-livehead-tx",title:n.path||void 0,children:n.path?s("desk.writing",{name:n.name}):s("desk.drafting")})]}),e.jsx("pre",{ref:r,className:"agent-desk-livebody",children:a})]})}function Hi(t,n){return l.useCallback(s=>{const o=n.current?.parentElement;if(!o)return;s.preventDefault();const i=s.currentTarget;i.setPointerCapture(s.pointerId),n.current?.classList.add("no-anim");const a=o.getBoundingClientRect(),r=u=>{const v=Math.min(.72,Math.max(.25,(a.right-u.clientX)/a.width));M.getState().patchDesk(t,{fraction:v,userResized:!0})},d=()=>{n.current?.classList.remove("no-anim"),i.removeEventListener("pointermove",r),i.removeEventListener("pointerup",d),i.removeEventListener("pointercancel",d),i.removeEventListener("lostpointercapture",d)};i.addEventListener("pointermove",r),i.addEventListener("pointerup",d),i.addEventListener("pointercancel",d),i.addEventListener("lostpointercapture",d)},[t,n])}function uh({sessionId:t}){const{t:n}=U(),s=M(y=>y.deskBySession[t]),o=Bi(s?.items?.slice(0,2)??[]),i=l.useRef(null),a=Hi(t,i),r=ko(),d=r?.mode==="always";if(!s?.items.length&&!d)return null;const u=s?.mode==="open",v=s?.fraction??(s?.size==="wide"?.62:.46),f=s?.items.slice(0,2)??[],j=r?.mode==="idle"&&f.length>0;return e.jsx("div",{ref:i,"data-desk-session":t,className:`agent-desk${u?" open":""}`,style:{"--desk-w":`${(v*100).toFixed(2)}%`},children:u&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"agent-desk-grip",onPointerDown:a}),e.jsxs("div",{className:"agent-desk-inner",children:[e.jsxs("div",{className:"agent-desk-head",children:[e.jsx(ot,{size:13,className:"agent-desk-spark"}),e.jsx("span",{className:"agent-desk-title",children:n("desk.title")}),!d&&s?.note?e.jsx("span",{className:"agent-desk-note",title:s.note,children:s.note}):e.jsx("span",{className:"agent-desk-note"}),j&&e.jsx("button",{className:"icon-btn",title:n("desk.clear"),onClick:()=>Di(t),children:e.jsx(So,{size:14})}),e.jsx("button",{className:"icon-btn",title:n("desk.collapse"),onClick:()=>M.getState().patchDesk(t,{mode:void 0}),children:e.jsx(Kn,{size:14})})]}),e.jsx("div",{className:"agent-desk-body",children:d&&r?e.jsx("div",{className:"agent-desk-pane agent-desk-companion",children:e.jsx($i,{entry:r,surface:"desk-panel",sessionId:t},r.key)}):f.map(y=>e.jsx("div",{className:"agent-desk-pane",children:y.live?e.jsx(Ui,{sessionId:t,item:y}):y.view?e.jsx(ft,{type:y.view.type,params:y.view.params??{},k:`desk-view:${y.key}`}):e.jsx(qi,{item:y,allowNative:y.key===o})},y.key))})]})]})})}const hh=(t,n)=>t==="open"&&n;function ph(t){const n=t.companion==="always",s=hh(t.mode,n?!t.draft:t.itemCount>0);return{gone:s,showCompanion:n||t.companion==="idle"&&t.itemCount===0,expandable:!s&&!t.draft&&(n||t.itemCount>0),clearable:t.companion==="idle"&&t.itemCount>0}}function mh({sessionId:t}){const{t:n}=U(),s=M(j=>j.deskBySession[t]),o=ko(),i=s?.items?.slice(0,2)??[],a=Bi(i),r=t===Ir,d=ph({mode:s?.mode,itemCount:i.length,companion:o?.mode??null,draft:r}),u=d.gone,v=d.expandable?()=>M.getState().patchDesk(t,{mode:"open"}):void 0,f=d.showCompanion?o:null;return e.jsxs("div",{"data-desk-session":t,className:`agent-desk-card${v?" act":""}${u?" gone":""}`,onClick:v,title:v?n("desk.expand"):void 0,children:[e.jsxs("div",{className:"agent-desk-card-head",children:[e.jsx(ot,{size:12,className:"agent-desk-spark"}),e.jsx("span",{className:"agent-desk-card-title",children:f?n("desk.title"):i[0]?.name||n("desk.title")}),d.clearable&&e.jsx("button",{className:"icon-btn",title:n("desk.clear"),onClick:j=>{j.stopPropagation(),Di(t)},children:e.jsx(So,{size:13})}),v&&e.jsx("button",{className:"icon-btn",title:n("desk.expand"),onClick:j=>{j.stopPropagation(),v()},children:e.jsx(Ln,{size:13})})]}),e.jsx("div",{className:`agent-desk-card-body${f?" companion":""}`,children:u?null:f?e.jsx("div",{className:"agent-desk-pane agent-desk-companion",children:e.jsx($i,{entry:f,surface:"desk-card",sessionId:r?null:t},f.key)}):i.length?i.map(j=>e.jsx("div",{className:"agent-desk-pane",children:j.live?e.jsx(Ui,{sessionId:t,item:j}):j.view?e.jsx(ft,{type:j.view.type,params:j.view.params??{},k:`desk-view:${j.key}`}):e.jsx(qi,{item:j,allowNative:j.key===a})},j.key)):e.jsxs("div",{className:"agent-desk-card-empty",children:[e.jsx(ot,{size:18}),e.jsx("span",{children:n("desk.empty")})]})})]})}te({"historian.status.ready":{zh:"待命",en:"Ready"},"historian.status.working":{zh:"整理会话中",en:"Reviewing conversation"},"historian.status.empty":{zh:"本会话还没有 Historian 工作记录",en:"No Historian activity in this conversation yet"},"historian.status.unavailable":{zh:"状态暂不可用",en:"Status unavailable"},"historian.status.viewTranscript":{zh:"查看完整记录",en:"View full transcript"}});const fh=3e3;function gh(t){try{const n=JSON.parse(t.replace(/^```(?:json)?\s*|\s*```$/g,""));return[n.summary,n.title,n.log,...Array.isArray(n.memory_candidates)?n.memory_candidates.map(s=>typeof s=="string"?s:s.text||s.content||""):[]].filter(s=>typeof s=="string"&&s.trim()).join(`
52
-
53
- `)}catch{return t}}function vh(t,n){const s=M.getState(),o=s.configBySession[t]?.agentSlug||s.defaultAgentSlug,i=s.sessions.find(a=>a.id===t)?.title||o;ve({event:"harness.candidates",level:"info",sticky:!0,dedupeKey:`harness.candidates:${n}`,text:s.tr("ntf.harnessCandidates",{name:i}),action:{label:s.tr("ntf.actionRefine"),run:()=>{const a=M.getState(),r=a.configBySession[t];!(r?.execMode==="host"&&!r?.planMode)||a.runningBySession[t]?Yn(o,"evolution"):a.send("/refine",[],void 0,void 0,void 0,t)}}})}function yh(t,n,s){const o=M.getState(),i=o.configBySession[t]?.agentSlug||o.defaultAgentSlug,a=o.agentDefs.find(r=>r.slug===i)?.name||i;ve({event:"harness.candidates",level:"info",sticky:!0,dedupeKey:`harness.adopted:${n}`,text:o.tr("ntf.harnessAdopted",{name:a,titles:s.split(" | ").join(ia()==="zh"?"、":", ")}),action:{label:o.tr("ntf.actionView"),run:()=>Yn(i,"evolution")}})}function jh(t,n){const s=M.getState(),o=s.configBySession[t]?.agentSlug||s.defaultAgentSlug;ve({event:"harness.candidates",level:"info",sticky:!0,dedupeKey:`harness.confirm:${n}`,text:s.tr("ntf.harnessConfirm",{name:s.agentDefs.find(i=>i.slug===o)?.name||o}),action:{label:s.tr("ntf.actionView"),run:()=>Yn(o,"evolution")}})}function xh(t,n){const s=M.getState(),o=s.sessions.find(i=>i.id===t)?.project_path||"";ve({event:"memory.projectCandidates",level:"info",sticky:!0,dedupeKey:`memory.projectCandidates:${n}`,text:s.tr("ntf.projectCandidates",{name:o.split(/[\\/]/).filter(Boolean).pop()||""}),...o?{action:{label:s.tr("ntf.actionView"),run:()=>at({kind:"project",path:o})}}:{}})}function wh(t,n){const s=M.getState(),o=s.sessions.find(i=>i.id===t)?.project_path||"";ve({event:"memory.projectCompacted",level:"info",dedupeKey:`memory.projectCompacted:${n}`,text:s.tr("ntf.projectCompacted",{name:o.split(/[\\/]/).filter(Boolean).pop()||""}),...o?{action:{label:s.tr("ntf.actionView"),run:()=>at({kind:"project",path:o})}}:{}})}function bh({sessionId:t}){const{t:n}=U(),s=M(x=>x.cfg),o=M(x=>x.connState==="ok"),[i,a]=l.useState(!1),[r,d]=l.useState(null),[u,v]=l.useState(!1),f=l.useRef(null),j=l.useRef(""),y=l.useRef(null),[p,w]=l.useState(null);l.useEffect(()=>{a(!1),d(null),v(!1),w(null),f.current=null,j.current="",y.current=null},[t]),l.useEffect(()=>{if(!i||!o||p)return;let x=!1,c;const C=()=>{zo(de(t),t,"historian").then(m=>m.find(k=>k.kind==="historian")?.sessionId??null,()=>null).then(m=>{x||(m?w(m):c=setTimeout(C,fh))})};return C(),()=>{x=!0,clearTimeout(c)}},[s,t,i,o,p]),l.useEffect(()=>{if(!o)return;let x=!1,c;const C=async()=>{try{const m=await $r(de(t),t,i);if(!x){d(m),v(!1);const{fresh:k,seen:z}=Fc(m.activity||[],f.current);f.current=z;const g=(m.activity||[]).map(P=>P.id).join(",");g!==j.current&&(j.current=g,window.dispatchEvent(new CustomEvent(Bt)));for(const P of k)P.action==="harness_adopted"?yh(t,P.id,P.detail||""):P.action==="harness_confirm"?jh(t,P.id):P.action==="project_memory_candidates"?xh(t,P.id):P.action==="project_memory_compacted"?wh(t,P.id):vh(t,P.id);const A=m.activity?.find(P=>P.action==="icon_updated");A&&A.id!==y.current&&(y.current=A.id,wn(de(t),t).then(P=>{x||P.id!==t||M.setState(B=>({sessions:B.sessions.map(_=>_.id===t?{..._,emoji:P.emoji}:_),archivedSessions:B.archivedSessions.map(_=>_.id===t?{..._,emoji:P.emoji}:_)}))}).catch(()=>{x||(y.current=null)}))}}catch{x||v(!0)}x||(c=setTimeout(C,2500))};return C(),()=>{x=!0,clearTimeout(c)}},[s,t,i,o]);const N=r?.running?"working":"idle",b=(r?.records||[]).map(x=>({...x,content:gh(x.content)})).filter(x=>x.content);return e.jsxs("div",{className:"t2o-team-status","data-historian-status":u?"unavailable":N,children:[e.jsxs("button",{type:"button",className:"t2o-desk-row","aria-expanded":i,onClick:()=>a(!i),children:[e.jsx(Pt,{size:18,className:r?.running?"historian-working":void 0}),e.jsx("span",{className:"t2o-desk-name",children:"Historian"}),e.jsx("span",{className:"t2o-desk-dot","data-status":N}),e.jsx("span",{className:"t2o-desk-activity",children:n(u?"historian.status.unavailable":r?.running?"historian.status.working":"historian.status.ready")}),e.jsx(xe,{size:12,style:{transform:i?"rotate(90deg)":void 0}})]}),i&&e.jsxs("div",{className:"t2o-desk-work","data-historian-work":!0,children:[b.map(x=>e.jsx(Ke,{content:x.content},x.id)),(r?.activity||[]).map(x=>e.jsx("div",{className:"t2o-historian-event",children:x.detail},x.id)),!b.length&&!r?.activity.length&&e.jsx("div",{className:"panel-note",children:n("historian.status.empty")}),p&&e.jsx("button",{type:"button",className:"t2-tsum-more","data-historian-transcript":!0,onClick:()=>Le.getState().open(t,{id:p,title:"Historian",sessionId:p}),children:n("historian.status.viewTranscript")})]})]})}te({"teamdesk.title":{zh:"团队工作台",en:"Team Desk"},"teamdesk.summary":{zh:"{n} 人 · {k} 工作中",en:"{n} members · {k} working"},"teamdesk.status.idle":{zh:"空闲",en:"Idle"},"teamdesk.status.working":{zh:"工作中",en:"Working"},"teamdesk.status.waiting":{zh:"等待审批",en:"Waiting for approval"},"teamdesk.status.done":{zh:"已完成",en:"Done"},"teamdesk.status.failed":{zh:"失败",en:"Failed"},"teamdesk.thinking":{zh:"思考中",en:"Thinking"},"teamdesk.noWork":{zh:"还没有工作记录",en:"No work yet"},"teamdesk.task":{zh:"任务:{task}",en:"Task: {task}"},"teamdesk.live":{zh:"直播中",en:"Live"},"teamdesk.connecting":{zh:"连接中",en:"Connecting"},"teamdesk.expand":{zh:"展开团队工作台",en:"Expand Team Desk"},"teamdesk.collapse":{zh:"收起",en:"Collapse"}});function kh(t){const n=M(No(s=>({cfg:s.configBySession[t],work:s.teamWorkBySession[t],agentDefs:s.agentDefs,running:s.runningBySession[t],childRuns:s.runningBySession})));return l.useMemo(()=>(Array.isArray(n.cfg?.groupAgents)?n.cfg.groupAgents.map(String):[]).map(o=>{const i=n.work?.[o],a=n.agentDefs.find(u=>u.slug===o)?.name||i?.name||o,d=i?.sessionId&&n.childRuns[i.sessionId]?i?.status==="waiting"?"waiting":"working":i?!n.running&&(i.status==="working"||i.status==="waiting")?"idle":i.status:"idle";return{...i||{since:0},slug:o,name:a,status:d}}),[n.cfg,n.work,n.agentDefs,n.running,n.childRuns])}function Sh({slug:t,name:n,status:s}){const o=M(a=>a.agentAvatars[t]),i=`t2o-bar-avatar${s==="working"?" is-working":s==="waiting"?" is-waiting":""}`;return o?e.jsx("img",{src:o,width:18,height:18,alt:"",className:i}):e.jsx("span",{className:`${i} t2o-bar-avatar-text`,children:[...n][0]||"?"})}function zh(t,n){return t.status==="working"?t.activity||(t.task?t.task:n("teamdesk.thinking")):t.status==="waiting"?n("teamdesk.status.waiting"):t.status==="failed"?n("teamdesk.status.failed"):t.status==="done"?t.task||n("teamdesk.status.done"):n("teamdesk.status.idle")}function Nh({sessionId:t}){const{t:n}=U(),s=kh(t),o=M(a=>a.hydrateTeamWork),i=Le(a=>a.selected[t]?.id);return l.useEffect(()=>{o(t)},[t,o]),e.jsx("div",{className:"t2o-team-status","data-team-desk":"status",children:s.map(a=>e.jsx("div",{children:e.jsxs("button",{type:"button",className:"t2o-desk-row","data-slug":a.slug,"data-status":a.status,"aria-pressed":i===a.slug,onClick:()=>Le.getState().open(t,{id:a.slug,title:a.name,slug:a.slug,sessionId:a.sessionId,runId:a.runId,task:a.task}),children:[e.jsx(Sh,{slug:a.slug,name:a.name,status:a.status}),e.jsx("span",{className:"t2o-desk-name",children:a.name}),e.jsx("span",{className:"t2o-desk-dot","data-status":a.status,title:n(`teamdesk.status.${a.status}`)}),e.jsx("span",{className:"t2o-desk-activity",children:zh(a,n)}),e.jsx(xe,{size:12})]})},a.slug))})}function Ch(t,n,s){const o=t.filter(a=>s&&a.kind==="historian"),i=t.filter(a=>a.kind!=="teamwork"&&!o.includes(a)).map(a=>({id:a.sessionId,title:a.title||a.kind,sessionId:a.sessionId,runId:a.runId||void 0,streaming:a.runStatus==="running"||a.runStatus==="queued"}));for(const a of n||[])o.some(r=>r.sessionId===a.sessionId||!!r.runId&&r.runId===a.runId)||s&&a.bgKind==="historian"||i.some(r=>r.sessionId===a.sessionId||r.runId&&r.runId===a.runId)||i.push({id:a.id,title:a.title,sessionId:a.sessionId,runId:a.runId,streaming:a.streaming});return i}te({"childchat.title":{zh:"子会话",en:"Child conversation"},"childchat.hint":{zh:"消息仅发送给这个子会话,保留与主会话的关联。",en:"Messages stay in this child conversation, linked to the main conversation."},"childchat.notStarted":{zh:"正在打开成员子会话…",en:"Opening the member’s conversation…"},"childchat.legacy":{zh:"这条旧子任务没有保存独立会话。新任务会保留完整记录。",en:"This older task has no saved child conversation. New tasks retain their full history."},"childchat.retry":{zh:"重新载入",en:"Reload"}});function Ph({sessionId:t}){const{t:n}=U(),s=M(u=>u.cfg),o=M(u=>u.subChatsBySession[t]),i=M(u=>!!u.specialEnabled.historian),[a,r]=l.useState([]);l.useEffect(()=>{let u=!1;r([]);const v=()=>{zo(de(t),t).then(j=>{const y=Br(j,t);u||r(y)}).catch(()=>{})};v();const f=setInterval(v,xo(t).kind==="unit"?12e3:4e3);return()=>{u=!0,clearInterval(f)}},[s,t]);const d=Ch(a,o,i);return d.length?e.jsx("div",{className:"t2o-team-status","data-subchat-status":!0,children:d.map(u=>e.jsxs("button",{type:"button",className:"t2o-desk-row",onClick:()=>Le.getState().open(t,u),children:[e.jsx(Co,{size:16}),e.jsx("span",{className:"t2o-desk-name",children:u.title}),e.jsx("span",{className:"t2o-desk-activity",children:n(u.streaming?"teamdesk.status.working":"teamdesk.status.done")}),e.jsx(xe,{size:12})]},u.id))}):null}function Th({parentId:t}){const n=Le(m=>m.selected[t]),s=M(m=>n?.slug?m.teamWorkBySession[t]?.[n.slug]:void 0),o=s?.sessionId||n?.sessionId,i=s?.runId||n?.runId,a=M(m=>(m.subChatsBySession[t]||[]).some(k=>k.sessionId===o&&k.streaming)&&!!m.runningBySession[t]),r=M(m=>m.cfg),d=M(m=>m.deskBySession[t]?.fraction??.52),u=l.useRef(null),v=Hi(t,u),{t:f}=U(),[j,y]=l.useState(""),[p,w]=l.useState(""),[N,b]=l.useState(0),[x,c]=l.useState(!1);l.useEffect(()=>{if(!n?.slug||o)return;let m=!1;return w(""),Dr(de(t),t,n.slug).then(k=>{if(Fr(k.id,t)==="conflict")throw new Error(f("app.cannotCreateSession"));m||(Le.getState().open(t,{...n,sessionId:k.id}),M.getState().hydrateTeamWork(t))}).catch(k=>{m||w(String(k.message||k))}),()=>{m=!0}},[r,t,n?.slug,o,N]),l.useEffect(()=>{if(y(""),w(""),c(!1),!o)return;let m=!1;return wn(de(o),o).then(async k=>{m||(c(!!k.delegate_running),Le.getState().remember(k),M.setState(z=>({configBySession:{...z.configBySession,[o]:{...k.agent_config,...z.configBySession[o]}}})),await M.getState().loadSessionHistory(o),m||y(o))}).catch(k=>{m||w(String(k.message||k))}),()=>{m=!0}},[r,o,N]),l.useEffect(()=>{if(!o||!x)return;let m=!1;const k=setInterval(()=>{wn(de(o),o).then(z=>{!m&&!z.delegate_running&&Lr(de(o),o).then(g=>{m||(M.setState(A=>{const P=g.map(_=>Or(_,void 0,V=>A.agentDefs.find($=>$.slug===V)?.name)),B=new Set(P.map(_=>_.id));return{messagesBySession:{...A.messagesBySession,[o]:[...P,...(A.messagesBySession[o]||[]).filter(_=>!B.has(_.id))].sort((_,V)=>_.timestamp-V.timestamp)}}}),c(!1))}).catch(()=>{})}).catch(()=>{})},1500);return()=>{m=!0,clearInterval(k)}},[r,o,x]),l.useEffect(()=>{if(!o||!i||j!==o)return;let m=!1;return qr(de(o),o).then(k=>{if(m)return;const z=k.find(A=>A.id===i&&(A.status==="running"||A.status==="queued"));if(!z?.assistant_message_id)return;const g=z.assistant_message_id;M.setState(A=>{const P=A.messagesBySession[o]||[];return P.some(B=>B.id===g)?{}:{messagesBySession:{...A.messagesBySession,[o]:[...P,{id:g,role:"assistant",content:"",status:"streaming",timestamp:Date.now()}]}}}),M.getState().subscribeRun(o,i,g)}).catch(()=>{}),()=>{m=!0}},[r,o,i,j]);const C=l.useMemo(()=>({id:`child-chat:${t}:${o}`,type:"child-chat",loc:"right",params:{},setTitle:()=>{},setParams:()=>{},close:()=>Le.getState().close(t)}),[t,o]);return n?e.jsxs("div",{ref:u,className:"agent-desk open child-chat-panel","data-team-desk":"panel",style:{"--desk-w":`${d*100}%`},children:[e.jsx("div",{className:"agent-desk-grip",onPointerDown:v}),e.jsxs("div",{className:"agent-desk-inner",children:[e.jsxs("div",{className:"agent-desk-head",children:[e.jsx(Co,{size:15}),e.jsx("strong",{className:"agent-desk-title",children:n.title}),e.jsx("span",{className:"agent-desk-note",children:f("childchat.title")}),e.jsx("button",{className:"icon-btn","aria-label":f("teamdesk.collapse"),onClick:C.close,children:e.jsx(lt,{size:16})})]}),e.jsx("div",{className:"child-chat-hint",children:f("childchat.hint")}),p?e.jsxs("div",{className:"child-chat-placeholder",role:"alert",children:[p,e.jsx("button",{onClick:()=>b(m=>m+1),children:f("childchat.retry")})]}):o?j!==o?e.jsx("div",{className:"child-chat-placeholder",children:e.jsx(Ye,{className:"spin",size:18})}):e.jsx(Gi,{leaf:C,params:{followActive:!1,sessionId:o,childSurface:!0,readOnly:a||x,teamSessionId:n.slug?t:void 0}},o):e.jsx("div",{className:"child-chat-placeholder",children:f(n.slug?"childchat.notStarted":"childchat.legacy")})]})]}):null}te({"team.summary":{zh:"Historian · 团队总结",en:"Historian · Team summary"}});function Eh({message:t}){const{t:n}=U();return e.jsxs("details",{className:"t2-team-summary","data-team-summary":!0,children:[e.jsx("summary",{children:n("team.summary")}),e.jsx(Ke,{content:t.content})]})}te({"studio.openTool":{zh:"编码工作室 · 打开项目工具",en:"Coding Studio · Open project tool"},"studio.projectTools":{zh:"项目工具",en:"Project tools"},"studio.panelPosition":{zh:"面板位置",en:"Panel position"},"studio.move.left":{zh:"移至左侧面板",en:"Move to left panel"},"studio.move.right":{zh:"移至右侧面板",en:"Move to right panel"},"studio.move.bottom":{zh:"移至底部面板",en:"Move to bottom panel"},"studio.inspectShort":{zh:"点选修改",en:"Select to edit"},"studio.filesShort":{zh:"文件",en:"Files"},"studio.chatTitle":{zh:"一起把想法做出来",en:"Build your idea together"},"studio.chatHint":{zh:"描述目标,或在预览中点选要修改的地方。",en:"Describe your goal, or select something in the preview to change."},"studio.chooseProject":{zh:"先在工作台创建或打开一个项目。",en:"Create or open a project in the studio first."},"studio.split":{zh:"并排",en:"Split"},"studio.desktop":{zh:"自适应",en:"Responsive"},"studio.tablet":{zh:"平板 · 768",en:"Tablet · 768"},"studio.phone":{zh:"手机 · 390",en:"Phone · 390"},"studio.inspect":{zh:"选择页面元素",en:"Select an element"},"studio.inspectHint":{zh:"点击预览中的元素,再描述你想怎样修改。Esc 取消。",en:"Click an element in the preview, then describe your change. Esc cancels."},"studio.selection":{zh:"定向修改",en:"Focused edit"},"studio.changePlaceholder":{zh:"例如:放大标题,保留现有配色",en:"For example: enlarge the heading and keep the colors"},"studio.addToChat":{zh:"加入对话",en:"Add to chat"},"studio.close":{zh:"关闭",en:"Close"},"studio.loading":{zh:"正在加载预览…",en:"Loading preview…"},"studio.previewFailed":{zh:"预览未能加载",en:"Preview could not load"},"studio.previewReady":{zh:"预览已加载",en:"Preview loaded"},"studio.previewIdle":{zh:"等待首个可运行页面",en:"Waiting for a runnable page"},"studio.sandbox.statusIdle":{zh:"插件项目 · 在 Sandbox 里加载试用",en:"Plugin project · load it from the Sandbox to try it"},"studio.building":{zh:"正在构建",en:"Building"},"studio.waiting":{zh:"等待你的回复",en:"Waiting for your input"},"studio.stopped":{zh:"停止生成",en:"Stop generation"},"studio.filesChanged":{zh:"{count} 个文件有改动",en:"{count} files changed"},"studio.autoRefresh":{zh:"实时刷新",en:"Live updates"},"studio.pendingChanges":{zh:"有新改动,点击刷新",en:"Changes ready. Reload to view."},"studio.files":{zh:"项目文件",en:"Project files"},"studio.terminal":{zh:"打开项目终端",en:"Open project terminal"},"studio.reveal":{zh:"在文件管理器中显示",en:"Show project folder"},"studio.project":{zh:"项目简报",en:"Project brief"},"studio.history":{zh:"版本",en:"Versions"},"studio.issues":{zh:"问题",en:"Issues"},"studio.checks":{zh:"验收",en:"Checks"},"studio.setup":{zh:"预览设置",en:"Preview settings"},"studio.sandbox":{zh:"Sandbox",en:"Sandbox"},"studio.pluginPreview":{zh:"插件没有页面预览",en:"A plugin has no page preview"},"studio.pluginPreviewHint":{zh:"插件不是网页,它加载进 Forsion 本身运行。打开 Sandbox,把这个项目加载进来试用。",en:"A plugin is not a web page: it is loaded into Forsion itself. Open the Sandbox to load this project and try it."},"studio.openSandbox":{zh:"打开 Sandbox",en:"Open Sandbox"},"studio.sandbox.notPlugin":{zh:"这个项目不是 Forsion 插件。项目根有 manifest.json(含 id、apiVersion 与 main)时,才能从这里加载。",en:"This project is not a Forsion plugin. It can be loaded here once the project root has a manifest.json with id, apiVersion and main."},"studio.sandbox.unavailable":{zh:"当前版本的应用还不支持从项目文件夹加载插件。",en:"This app version cannot load a plugin from a project folder yet."},"studio.sandbox.stateUnloaded":{zh:"未加载",en:"Not loaded"},"studio.sandbox.stateActive":{zh:"已加载,正在运行",en:"Loaded and running"},"studio.sandbox.stateBlocked":{zh:"不能从这里加载",en:"Cannot be loaded from here"},"studio.sandbox.stateFailed":{zh:"启动失败",en:"Failed to start"},"studio.sandbox.unloadedHint":{zh:"这个插件还没有加载进 Forsion。",en:"This plugin is not loaded into Forsion yet."},"studio.sandbox.activeHint":{zh:"项目开在编码工作室期间,保存即重载;关掉这个项目就不再重载。",en:"While this project is open in Coding Studio, saving reloads the plugin. Closing the project stops that."},"studio.sandbox.failedHint":{zh:"插件的 setup(ctx) 抛了错,这一次没能起来。改完保存会自动重试。",en:"The plugin threw from setup(ctx) and did not start. Saving a fix reloads it automatically."},"studio.sandbox.blockedFileext":{zh:"这个插件声明了自定义文件类型。宿主的防线只覆盖已安装目录,所以这类插件必须先安装再测。",en:"This plugin declares custom file types. The host safeguards only cover installed plugins, so install it to test custom file types."},"studio.sandbox.blockedApi":{zh:"宿主拒绝加载:manifest.json 的 apiVersion 不是这个版本的 Forsion 支持的值(目前为 1)。",en:"The host refused to load it: the apiVersion in manifest.json is not supported by this version of Forsion (currently 1)."},"studio.sandbox.blockedMinApp":{zh:"宿主拒绝加载:manifest.json 的 minAppVersion 高于当前 Forsion 的版本。",en:"The host refused to load it: the minAppVersion in manifest.json is newer than this version of Forsion."},"studio.sandbox.blockedOther":{zh:"宿主拒绝加载:{reason}",en:"The host refused to load it: {reason}"},"studio.sandbox.trust":{zh:"这不是隔离沙箱:开发副本就跑在这个真应用、你的真智库上,与已安装插件同权。试验期间别写、挪、删你的数据;定时器与监听必须在 disposer 里清掉——每次保存都会重跑一遍 setup,漏清一次就叠一层。",en:"This is not an isolated sandbox: the dev copy runs in this real app, on your real notes, with the same privileges as an installed plugin. Do not write, move or delete your data while experimenting, and release every timer and listener in the disposer, because each save runs setup again and anything left behind stacks up."},"studio.sandbox.staleGrant":{zh:"之前的加载授权已失效(项目文件夹被重建或移动过,或是旧版本 Forsion 记下的授权)。确认这是你的项目后,再点一次「加载」。",en:"The earlier permission to load this project no longer applies (the folder was recreated or moved, or the permission was saved by an older Forsion version). If this is your project, choose Load again."},"studio.sandbox.shadow":{zh:"这个插件已安装的副本在开发副本加载期间被顶替;期间它的「卸载」不可用。",en:"The installed copy of this plugin is replaced while the dev copy is loaded, and Uninstall is unavailable meanwhile."},"studio.sandbox.load":{zh:"在 Forsion 中加载",en:"Load into Forsion"},"studio.sandbox.loading":{zh:"正在加载…",en:"Loading…"},"studio.sandbox.unload":{zh:"卸载开发副本",en:"Unload"},"studio.sandbox.unloading":{zh:"正在卸载…",en:"Unloading…"},"studio.sandbox.reload":{zh:"立即重载",en:"Reload now"},"studio.sandbox.reloading":{zh:"正在重载…",en:"Reloading…"},"studio.sandbox.retry":{zh:"重试重载",en:"Retry reload"},"studio.sandbox.halfDone":{zh:"这个项目已标记为开发插件源,但这次重载没成功。重试重载即可。",en:"This project is marked as a dev plugin source, but the reload did not finish. Try the reload again."},"studio.sandbox.setupError":{zh:"setup(ctx) 抛出的错误",en:"Error thrown by setup(ctx)"},"studio.sandbox.mountErrors":{zh:"视图加载错误",en:"View mount errors"},"studio.sandbox.console":{zh:"这个插件的控制台输出",en:"Console output from this plugin"},"studio.sandbox.noEvidence":{zh:"还没有任何输出。在应用里操作这个插件,报错和 console 输出会出现在这里。",en:"Nothing captured yet. Use the plugin in the app and its errors and console output appear here."},"studio.sandbox.clear":{zh:"清空输出",en:"Clear output"},"studio.sandbox.note":{zh:"发生了什么?(可选)",en:"What happened? (optional)"},"studio.sandbox.send":{zh:"带上证据发回对话",en:"Send evidence to chat"},"studio.noIssues":{zh:"暂未捕获运行错误。仍需实际操作,确认流程和视觉效果。",en:"No runtime errors captured. Try the flows and check the visual result."},"studio.issueDescription":{zh:"发生了什么?你期待怎样的结果?",en:"What happened, and what did you expect?"},"studio.diagnose":{zh:"带上证据修复",en:"Fix with evidence"},"studio.clearIssues":{zh:"清空记录",en:"Clear captured issues"},"studio.errorCount":{zh:"{count} 条运行问题",en:"{count} runtime issues"},"studio.noBrief":{zh:"为已有项目补一份简报,后续修改都能沿用。",en:"Add a brief to keep future changes aligned with this project."},"studio.idea":{zh:"项目目标",en:"Project goal"},"studio.audience":{zh:"给谁使用",en:"Audience"},"studio.constraints":{zh:"必须保留的要求",en:"Requirements to preserve"},"studio.briefSaved":{zh:"简报已保存到项目文件。",en:"Brief saved to the project file."},"studio.saveBrief":{zh:"保存简报",en:"Save brief"},"studio.plan":{zh:"先做计划",en:"Plan first"},"studio.build":{zh:"开始构建",en:"Start building"},"studio.promptReady":{zh:"已加入左侧草稿,可继续编辑后发送。",en:"Added to the chat draft. Edit it before sending."},"studio.firstPage":{zh:"把想法变成第一个可运行版本",en:"Turn your idea into a working first version"},"studio.firstPageHint":{zh:"从项目简报开始,或在左侧描述需求。代码写好后,预览会自动出现在这里。",en:"Start with your brief, or describe what you need in chat. Your app will appear here as files are created."},"studio.staticPreview":{zh:"即时预览",en:"Instant preview"},"studio.devServer":{zh:"本地开发服务",en:"Local dev server"},"studio.devHint":{zh:"已有 Vite、Next.js 等项目:先在项目终端启动,再填入本机地址。发布功能适用于即时预览的静态项目。",en:"For Vite, Next.js or an existing app, start its server in the project terminal and enter the local URL. Publishing supports static projects using instant preview."},"studio.devUrl":{zh:"本机预览地址",en:"Local preview URL"},"studio.invalidUrl":{zh:"请输入 localhost、127.0.0.1 或 [::1] 的 HTTP(S) 地址。",en:"Use an HTTP(S) URL on localhost, 127.0.0.1 or [::1]."},"studio.apply":{zh:"应用",en:"Apply"},"studio.useStatic":{zh:"使用即时预览",en:"Use instant preview"},"studio.entry":{zh:"入口页面",en:"Entry page"},"studio.loadError":{zh:"无法读取项目:{error}",en:"Could not read project: {error}"},"studio.retry":{zh:"重新加载",en:"Try again"},"studio.versionName":{zh:"例如:首页布局定稿",en:"For example: approved home layout"},"studio.saveVersion":{zh:"保存版本",en:"Save version"},"studio.noVersions":{zh:"还没有版本。满意当前效果时,保存一个版本再继续尝试。",en:"No versions yet. Save a version you like before trying something new."},"studio.restore":{zh:"恢复源码",en:"Restore source"},"studio.confirmRestore":{zh:"确认恢复此版本?当前源码会先自动备份。",en:"Restore this version? Current source will be backed up first."},"studio.cancel":{zh:"取消",en:"Cancel"},"studio.versionSaved":{zh:"源码版本已保存。",en:"Source version saved."},"studio.restored":{zh:"已恢复 {restored} 个文件,移除 {deleted} 个新增文件;当前版本已备份。",en:"Restored {restored} files and removed {deleted} added files. Previous source was backed up."},"studio.restoreConflicts":{zh:"{count} 个文件在恢复期间被修改,已保留,请检查。",en:"{count} files changed during restore and were preserved. Please review them."},"studio.saveFirst":{zh:"请先处理未保存的修改,并等待生成结束。",en:"Resolve unsaved edits and wait for generation to finish first."},"studio.manualChecks":{zh:"亲自验证后再勾选。预览能打开不等于功能已通过;项目有新改动时勾选会重置。",en:"Check these only after testing. A loaded preview is not a verified app. New project changes reset these checks."},"studio.checkMain":{zh:"主要流程可完整操作",en:"The main user flow works end to end"},"studio.checkPhone":{zh:"手机宽度下可读、可点",en:"Readable and usable at phone width"},"studio.checkFailure":{zh:"空数据、加载和失败都有提示",en:"Empty, loading and failure states are clear"},"studio.checkData":{zh:"刷新后的数据行为符合预期",en:"Data behaves as expected after reload"},"studio.checkAccess":{zh:"键盘操作与颜色对比可用",en:"Keyboard access and text contrast are usable"},"studio.askVerify":{zh:"让 AI 帮我检查",en:"Ask AI to check"},"studio.publishStaticOnly":{zh:"当前使用开发服务,请先构建可发布的静态页面。",en:"This project uses a dev server. Build a static page before publishing."},"studio.publishImported":{zh:"发布前请将项目复制到 Forsion 的 Project 文件夹。",en:"Copy this project into the Forsion Project folder before publishing."},"studio.streaming":{zh:"正在写入 · {file}",en:"Writing · {file}"},"studio.watchError":{zh:"文件监听不可用,可手动刷新。{error}",en:"File watching is unavailable. Reload manually. {error}"},"studio.history.showInstall":{zh:"查看安装方式",en:"Show how to install"},"studio.history.gitWhy":{zh:"编码工作室用 Git 记录项目版本:装好之后,每轮 AI 改动都会自动存一版,你也可以随时保存命名版本。编码工作室的其他功能都不需要它。",en:"Coding Studio uses git to keep project versions: once it is installed, every agent run is saved automatically and you can save named versions yourself. Nothing else in Coding Studio needs it."},"studio.history.firstVersionNote":{zh:"保存第一个版本会在项目文件夹里创建 Git 仓库(.git)。",en:"Saving the first version creates a git repository (.git) in the project folder."},"studio.history.enableNote":{zh:"这个文件夹还没有版本历史。保存第一个版本会在里面创建 Git 仓库(.git),之后每轮 AI 改动都会自动存一版。",en:"This folder has no version history yet. Saving the first version creates a git repository (.git) in it; after that, every AI turn is saved as a version automatically."},"studio.history.readonlyForeign":{zh:"这个项目用的是它自己的 Git 仓库;Forsion 只展示历史,不做任何改动。",en:"This project uses its own git repository; Forsion shows its history but does not change it."},"studio.history.readonlyNested":{zh:"这个项目位于另一个 Git 仓库内部。",en:"This project lives inside another git repository."},"studio.history.readonlyOutside":{zh:"只有加入造物的项目,版本才由 Forsion 管理。",en:"Version history is only managed for projects in Creations."},"studio.history.readonlyBridge":{zh:"当前版本的应用只能查看版本历史;保存与恢复需要更新到新版本。",en:"This app version can only show version history; saving and restoring need a newer version."},"studio.history.untitled":{zh:"未命名版本",en:"Untitled version"},"studio.history.backupName":{zh:"恢复前的备份",en:"Backup before restore"},"studio.history.restorePrefix":{zh:"恢复到:",en:"Restore:"},"studio.history.noChanges":{zh:"与上一个版本相比没有改动。",en:"No changes since the last version."},"studio.history.files":{zh:"{count} 个文件",en:"{count} files"},"studio.history.auto":{zh:"自动",en:"Auto"},"studio.history.autoFallback":{zh:"AI 改动",en:"Agent changes"},"studio.history.autoFooter":{zh:"这个项目在编码工作室里打开时,每轮 AI 改动结束后都会自动存一个版本。",en:"Automatic versions are created after each agent run while this project is open in Coding Studio."},"studio.history.confirmRestore":{zh:"恢复到这个版本?当前状态会先存成一个备份版本,所以这次恢复本身也能撤销。",en:"Restore this version? The current state is saved as a backup version first, so restoring is itself undoable."},"studio.history.restored":{zh:"已恢复到该版本;恢复前的状态已存为备份版本。",en:"Restored. The previous state was saved as a backup version."},"studio.history.restoredClean":{zh:"已恢复到该版本。",en:"Restored to this version."},"studio.history.empty":{zh:"这个仓库还没有提交。",en:"This repository has no commits yet."},"studio.history.legacy":{zh:"更早的快照(只读)",en:"Earlier snapshots (read-only)"},"studio.history.legacyHint":{zh:"这些是启用 Git 之前保存的快照,可以恢复,但不再新增。",en:"These snapshots were saved before git was used here. They can be restored, but no new ones are created."}});function Ah(t){return t.filter(n=>(n.modelType||"llm")==="llm")}te({"reset.ceremony.eyebrow":{zh:"FORSION · 额度重置卡",en:"FORSION · Quota reset card"},"reset.ceremony.title":{zh:"额度已焕新",en:"Quota restored"},"reset.ceremony.both":{zh:"今日与本周额度已恢复",en:"Today's and this week's quota has been restored"},"reset.ceremony.dailyLabel":{zh:"今日",en:"Today"},"reset.ceremony.weeklyLabel":{zh:"本周",en:"This week"},"reset.ceremony.remaining":{zh:"额度重置卡剩余 {n} 张",en:"{n} quota reset cards remaining"},"reset.ceremony.continue":{zh:"继续使用",en:"Continue"},"reset.ceremony.close":{zh:"关闭",en:"Close"}});const Js=(t,n)=>Hr(t[`${n}Limit`],t[`${n}Remaining`],t[`${n}Percent`]);function Wi({result:t,onClose:n,returnFocusSelector:s}){const{t:o}=U(),i=l.useRef(null),a=l.useRef(null),r=l.useRef(n);r.current=n;const d=l.useMemo(()=>["daily","weekly"].map(u=>({period:u,before:Js(t.before,u),after:Js(t.after,u)})).filter(u=>u.after!==null),[t]);return l.useEffect(()=>{const u=document.activeElement instanceof HTMLElement?document.activeElement:null;i.current?.focus();const v=f=>{if(f.key==="Escape"){f.preventDefault(),r.current();return}if(f.key!=="Tab")return;const j=i.current,y=a.current;if(!(!j||!y)){if(getComputedStyle(y).visibility==="hidden"){f.preventDefault(),j.focus();return}f.shiftKey&&document.activeElement===j?(f.preventDefault(),y.focus()):!f.shiftKey&&document.activeElement===y&&(f.preventDefault(),j.focus())}};return window.addEventListener("keydown",v),()=>{window.removeEventListener("keydown",v),u?.isConnected?u.focus():document.querySelector(s)?.focus()}},[s]),Ur.createPortal(e.jsx("div",{className:"reset-ceremony-backdrop",children:e.jsxs("section",{className:"reset-ceremony",role:"dialog","aria-modal":"true","aria-labelledby":"reset-ceremony-title","aria-describedby":"reset-ceremony-description",children:[e.jsx("button",{ref:i,className:"reset-ceremony-close","aria-label":o("reset.ceremony.close"),onClick:n,children:e.jsx(lt,{size:16,"aria-hidden":"true"})}),e.jsxs("div",{className:"reset-ceremony-scene","aria-hidden":"true",children:[e.jsx("span",{className:"reset-ceremony-halo"}),e.jsxs("div",{className:"reset-ceremony-card",children:[e.jsxs("div",{className:"reset-ceremony-card-top",children:[e.jsx("span",{children:"FORSION"}),e.jsx(At,{size:19,strokeWidth:1.5})]}),e.jsx("span",{className:"reset-ceremony-card-mark",children:"F"}),e.jsx("span",{className:"reset-ceremony-card-bottom",children:"QUOTA RESET"}),e.jsx("span",{className:"reset-ceremony-card-sheen"})]}),e.jsx("span",{className:"reset-ceremony-seal",children:e.jsx(Bn,{size:21,strokeWidth:2.2})})]}),e.jsx("div",{className:"reset-ceremony-eyebrow",children:o("reset.ceremony.eyebrow")}),e.jsx("h2",{id:"reset-ceremony-title",children:o("reset.ceremony.title")}),e.jsx("p",{id:"reset-ceremony-description",children:o("reset.ceremony.both")}),d.length>0&&e.jsx("div",{className:"reset-ceremony-quotas",children:d.map(({period:u,before:v,after:f})=>e.jsxs("div",{className:"reset-ceremony-quota",children:[e.jsxs("div",{className:"reset-ceremony-quota-copy",children:[e.jsx("span",{children:o(`reset.ceremony.${u}Label`)}),e.jsxs("span",{className:"reset-ceremony-values",children:[e.jsx("span",{children:v==null?"—":bn(v,"—")}),e.jsx("span",{"aria-hidden":"true",children:"→"}),e.jsx("strong",{children:bn(f,"—")})]})]}),e.jsx("div",{className:"reset-ceremony-track","aria-hidden":"true",children:e.jsx("span",{style:{"--reset-before":`${v??0}%`,"--reset-after":`${f}%`}})})]},u))}),e.jsxs("div",{className:"reset-ceremony-footer",children:[t.remainingCards!=null&&e.jsx("span",{children:o("reset.ceremony.remaining",{n:String(t.remainingCards)})}),e.jsx("button",{ref:a,className:"reset-ceremony-continue",onClick:n,children:o("reset.ceremony.continue")})]})]})}),document.body)}function Mp(t,n=".ribbon-account, .account-card"){const s=document.createElement("div");document.body.appendChild(s);const o=Rl.createRoot(s);let i=!1;const a=()=>{i||(i=!0,queueMicrotask(()=>{o.unmount(),s.remove()}))};o.render(e.jsx(aa,{children:e.jsx(Wi,{result:t,onClose:a,returnFocusSelector:n})}))}const fn=10;te({"quota.banner.period.daily":{zh:"今日 AI 额度",en:"Today's AI quota"},"quota.banner.period.weekly":{zh:"本周 AI 额度",en:"This week's AI quota"},"quota.banner.low":{zh:"{period}剩余 {percent}",en:"{period} has {percent} remaining"},"quota.banner.near":{zh:"{period}即将用尽,仅剩 {percent}",en:"{period} is almost used up, with {percent} remaining"},"quota.banner.critical":{zh:"{period}严重不足,仅剩 {percent}",en:"{period} is critically low, with {percent} remaining"},"quota.banner.exhausted":{zh:"{period}已用尽",en:"{period} is exhausted"},"quota.banner.upgrade":{zh:"升级会员",en:"Upgrade membership"},"quota.banner.useReset":{zh:"使用额度重置卡({n})",en:"Use a quota reset card ({n})"},"quota.banner.noReset":{zh:"暂无额度重置卡",en:"No quota reset card"},"quota.banner.confirmReset":{zh:"再次点击确认",en:"Click again to confirm"},"quota.banner.resetFail":{zh:"重置额度失败",en:"Failed to reset quota"},"quota.banner.close":{zh:"关闭额度提示",en:"Dismiss quota notice"},"quota.banner.bg.period.daily":{zh:"今日后台额度",en:"Today's background quota"},"quota.banner.bg.period.weekly":{zh:"本周后台额度",en:"This week's background quota"},"quota.banner.bg.exhausted":{zh:"{period}已用尽,Muse 与自动化已暂停",en:"{period} is exhausted; Muse and automations are paused"},"quota.banner.bg.autoMain":{zh:"{period}已用尽,正在用 AI 额度继续",en:"{period} is exhausted; continuing on your AI quota"},"quota.banner.bg.convert":{zh:"从 AI 额度转入 {percent}%",en:"Move {percent}% from AI quota"},"quota.banner.bg.convertDone":{zh:"已从 AI 额度转入 {percent}%,本周期有效",en:"Moved {percent}% from your AI quota for this period"},"quota.banner.bg.convertFail":{zh:"转入失败",en:"Failed to move quota"},"quota.banner.bg.noMain":{zh:"AI 额度已用完,没有可转入的额度",en:"Your AI quota is used up; there is nothing to move"},"quota.banner.bg.settings":{zh:"后台额度设置",en:"Background quota settings"}});function Rh({loggedIn:t,onToast:n}){const{t:s}=U(),[o,i]=l.useState(null),[a,r]=l.useState(null),[d,u]=l.useState(!1),[v,f]=l.useState(!1),[j,y]=l.useState(null),[p,w]=l.useState(!1),[N,b]=l.useState(!1),x=l.useRef(0),c=l.useRef(0),C=l.useCallback(()=>{if(!t||!window.tangu?.accountQuota){i(null);return}const T=++x.current;window.tangu.accountQuota().then(L=>{if(T!==x.current)return;const G=L?.status===200&&L.json?L.json:null;i(G),G&&rn(G)}).catch(()=>{T===x.current&&i(null)})},[t]);l.useEffect(()=>{if(!t){++x.current,++c.current,i(null),f(!1),u(!1),b(!1),w(!1),y(null);return}C();const T=()=>C();return window.addEventListener("focus",T),()=>{++x.current,++c.current,window.removeEventListener("focus",T)}},[t,C]),l.useEffect(()=>Wr(T=>{t&&i(T)}),[t]);const m=l.useMemo(()=>Vr(Yr(o),Gr()?Kr(o):null),[o]),k=m?.advisory??null,z=m?.bucket==="background",g=m?`${m.bucket}:${m.advisory.period}:${m.advisory.threshold}`:null;l.useEffect(()=>{u(!1),w(!1),g||r(null)},[g]);const A=j&&e.jsx(Wi,{result:j,onClose:()=>y(null),returnFocusSelector:".t2c-ta"});if(!t||!o||!k||a===g)return A;const P=s(z?`quota.banner.bg.period.${k.period}`:`quota.banner.period.${k.period}`),B=bn(k.remainingPercent,""),_=k.exhausted?z?o.background?.autoMain?"quota.banner.bg.autoMain":"quota.banner.bg.exhausted":"quota.banner.exhausted":k.threshold===5?"quota.banner.critical":k.threshold===10?"quota.banner.near":"quota.banner.low",V=Math.max(0,Number(o.resetCards)||0),$=async()=>{if(!V||v||!window.tangu?.accountUseResetCard)return;if(!d){u(!0);return}f(!0);const T=++c.current;try{const L=await window.tangu.accountUseResetCard("both");if(T!==c.current)return;if(L?.status===200&&L.json?.success){const G={...L.json.quota||{},resetCards:L.json.resetCards};i(G),rn(G),y({scope:"both",before:o,after:G,remainingCards:L.json.resetCards})}else n?.(String(L?.json?.detail||s("quota.banner.resetFail")),!0)}catch(L){T===c.current&&n?.(String(L?.message||L||s("quota.banner.resetFail")),!0)}finally{T===c.current&&(f(!1),u(!1))}},q=async()=>{if(N||!window.tangu?.accountBgConvert)return;if(!p){w(!0);return}b(!0);const T=++c.current;try{const L=await window.tangu.accountBgConvert(fn);if(T!==c.current)return;if(L?.status===200&&L.json?.success){const G={...L.json.quota||{},resetCards:o.resetCards};i(G),rn(G),n?.(s("quota.banner.bg.convertDone",{percent:String(fn)}))}else n?.(L?.json?.error==="insufficient_main_quota"?s("quota.banner.bg.noMain"):String(L?.json?.detail||s("quota.banner.bg.convertFail")),!0)}catch(L){T===c.current&&n?.(String(L?.message||L||s("quota.banner.bg.convertFail")),!0)}finally{T===c.current&&(b(!1),w(!1))}};return e.jsxs(e.Fragment,{children:[A,e.jsxs("div",{className:"t2-quota-advisory","data-level":k.critical?"critical":k.threshold===10?"near":"low","data-bucket":z?"background":"main",role:"status","aria-live":"polite",children:[e.jsxs("span",{className:"t2-quota-advisory-copy",children:[e.jsx(Ho,{size:14,"aria-hidden":"true"}),e.jsx("span",{children:s(_,{period:P,percent:B})})]}),z?e.jsxs("span",{className:"t2-quota-advisory-actions",children:[!!window.tangu?.accountBgConvert&&e.jsxs("button",{className:"t2-quota-action convert",disabled:N,onClick:()=>{q()},children:[e.jsx(Hl,{size:12,className:N?"spin":void 0,"aria-hidden":"true"}),p?s("quota.banner.confirmReset"):s("quota.banner.bg.convert",{percent:String(fn)})]}),e.jsxs("button",{className:"t2-quota-action settings",onClick:()=>M.getState().openSettings("forsion/fx:forsion-extend:quota"),children:[e.jsx(Jr,{size:12,"aria-hidden":"true"})," ",s("quota.banner.bg.settings")]})]}):e.jsxs("span",{className:"t2-quota-advisory-actions",children:[!!window.tangu?.openPayCenter&&e.jsxs("button",{className:"t2-quota-action upgrade",onClick:()=>{window.tangu?.openPayCenter?.()},children:[s("quota.banner.upgrade")," ",e.jsx(Do,{size:12,"aria-hidden":"true"})]}),!!window.tangu?.accountUseResetCard&&e.jsxs("button",{className:"t2-quota-action reset",disabled:!V||v,title:V?void 0:s("quota.banner.noReset"),onClick:()=>{$()},children:[e.jsx(At,{size:12,className:v?"spin":void 0,"aria-hidden":"true"}),d?s("quota.banner.confirmReset"):V?s("quota.banner.useReset",{n:String(V)}):s("quota.banner.noReset")]})]}),e.jsx("button",{className:"t2-quota-dismiss",title:s("quota.banner.close"),"aria-label":s("quota.banner.close"),onClick:()=>r(g),children:e.jsx(lt,{size:13,"aria-hidden":"true"})})]})]})}te({"engine.target.retry":{zh:"重试",en:"Retry"}});const Mh={offline:Cn,"engine-unavailable":uc,"engine-auth":Zr,"caller-unavailable":ps,refused:ps,"rate-limited":xc,gone:Vl,connecting:Ye,failed:Cn},Qs={offline:"engine.target.offline","engine-unavailable":"engine.target.engineUnavailable","engine-auth":"engine.target.engineAuth","caller-unavailable":"engine.target.callerUnavailable",refused:"engine.target.refused","rate-limited":"engine.target.rateLimited",gone:"engine.target.gone"},Ih=new Set(["offline","engine-unavailable","rate-limited","failed","caller-unavailable","engine-auth","refused"]);function Vi(t){const n=Jt(t),s=M(o=>o.connState);return To(o=>n.kind==="unit"?o.byKey[Eo(n)]:void 0),Qr({connState:s},t)}function _h(t){const{t:n}=U(),s=Jt(t),o=Vi(t);if(kn(i=>i.name),!(s.kind!=="unit"||o))return n("engine.target.composerWaiting",{name:Po(s)||n("engine.target.defaultName")})}function $h({fallback:t,sessionId:n}){const{t:s}=U(),o=Jt(n),i=kn(b=>b.ref);kn(b=>b.name);const a=Xr(o,i),r=Po(o),d=o.kind==="unit"?Eo(o):null,u=To(b=>d?b.byKey[d]:void 0),v=M(b=>b.connState),f=M(b=>b.connMessage);if(!d)return e.jsx(e.Fragment,{children:t});const j=r||s("engine.target.defaultName");let y=null,p="";if(u&&Qs[u.state]){y=u.state;const b="code"in u?u.code:void 0,x="refusal"in u?u.refusal:void 0;p=Bl(b,x)||s(Qs[u.state],{name:j})}else a&&v==="idle"?(y="connecting",p=s("engine.target.connecting",{name:j})):a&&v==="err"&&(y="failed",p=f||s("engine.target.offline",{name:j}));if(!y)return e.jsx(e.Fragment,{children:t});const w=Mh[y]??Cn,N=()=>{if(a){el().catch(()=>{});return}const b=tl(o);b&&nl(b).catch(()=>{})};return e.jsxs("div",{className:"t2-quota-advisory t2-target-health","data-target-health":y,role:"status","aria-live":"polite",children:[e.jsxs("span",{className:"t2-quota-advisory-copy",children:[e.jsx(w,{size:14,"aria-hidden":"true",className:y==="connecting"?"spin":void 0}),e.jsx("span",{children:p})]}),Ih.has(y)&&e.jsx("span",{className:"t2-quota-advisory-actions",children:e.jsxs("button",{className:"t2-quota-action reset",onClick:N,children:[e.jsx(At,{size:12,"aria-hidden":"true"})," ",s("engine.target.retry")]})})]})}const Dh=[],Fh={},Lh={ctx:0,base:0,live:0},Oh=[],qh=[],gn=t=>!!t.teamSummary||!!t.work&&!t.content&&!t.error&&!t.approvals?.length&&!t.inquiries?.length;function Bh(t){const n=t&&typeof t=="object"?t:null;return!n||typeof n.pid!="number"||typeof n.windowId!="number"?null:{app:String(n.app??""),bundleId:typeof n.bundleId=="string"?n.bundleId:void 0,pid:n.pid,windowId:n.windowId,title:String(n.title??"")}}function Gi({leaf:t,params:n}){const{t:s}=U(),o=Pc(),i=Le(h=>h.selected),[a,r]=l.useState(!1),d=l.useRef(null),u=l.useRef(null),v=l.useRef(null),f=l.useRef(!0),j=l.useRef(0),y=M(h=>h.activeId),p=n.followActive!==!1,w=sl(h=>h.activeSpaceId==="coding"),N=p&&(!!n.studio||w),b=Sn(h=>h.activeProject),x=typeof n.sessionId=="string"?n.sessionId:null,c=p?y:x,C=_h(c),m=Vi(c),k=ma(),z=M(h=>!!(c&&h.historyLoading[c])),g=M(No(h=>({activeSession:h.sessions.find(I=>I.id===c)||h.archivedSessions.find(I=>I.id===c)||null,activeMessages:c&&h.messagesBySession[c]||Dh,running:!!(c&&h.runningBySession[c]),runStats:c&&h.runStatsBySession[c]||null,historianEnabled:h.specialEnabled.historian,execConfig:c&&h.configBySession[c]||Fh,activeUsage:c&&h.usageBySession[c]||Lh,activeCtxInfo:c&&h.ctxInfoBySession[c]||null,isGroupVoting:!!(c&&h.groupVoting[c]),llmRetry:c&&h.llmRetryBySession[c]||null,compacting:c?h.compactingBySession[c]:void 0,cfg:h.cfg,authInfo:h.authInfo,desktopConfig:h.desktopConfig,modelsResp:h.modelsResp,newChatWs:h.newChatWs,newChatCfg:h.newChatCfg,newChatModel:h.newChatModel,sessionMode:h.sessionMode,setSessionMode:h.setSessionMode,pendingDraft:h.pendingDraft,setPendingDraft:h.setPendingDraft,pendingShare:h.pendingShare,takePendingShare:h.takePendingShare,pendingChatQuote:h.pendingChatQuote,clearPendingChatQuote:h.clearPendingChatQuote,draftRefs:h.draftRefs,appendRefs:h.appendRefs,clearDraftRefs:h.clearDraftRefs,steerPending:c&&h.steerPendingBySession[c]||Oh,steerSent:c&&h.steerSentBySession[c]||qh,steerRestore:c&&h.steerRestoreBySession[c]||null,jumpTarget:h.jumpTarget,clearJumpTarget:h.clearJumpTarget,withdrawSteer:h.withdrawSteer,steerNow:h.steerNow,clearSteerRestore:h.clearSteerRestore,engines:h.engines,engineCaps:h.engineCaps,agentDefs:h.agentDefs,agentAvatars:h.agentAvatars,defaultAgentSlug:h.defaultAgentSlug,skillsList:h.skillsList,connState:h.connState,connMessage:h.connMessage,filePreview:h.filePreview,openFeedback:h.openFeedback,toast:h.toast,editUserMessage:h.editUserMessage,regenerate:h.regenerate,branchFromMessage:h.branchFromMessage,rewindTo:h.rewindTo,decideApproval:h.decideApproval,answerInquiry:h.answerInquiry,setFilePreview:h.setFilePreview,setSessionEngine:h.setSessionEngine,setNewChatCfg:h.setNewChatCfg,selectSessionAgent:h.selectSessionAgent,selectNewChatAgent:h.selectNewChatAgent,workspaces:h.workspaces,setNewChatWs:h.setNewChatWs,addLocalWorkspace:h.addLocalWorkspace,addCloudProject:h.addCloudProject,setSessionModel:h.setSessionModel,setNewChatModel:h.setNewChatModel,setSessionEngineModel:h.setSessionEngineModel,setSessionThinking:h.setSessionThinking,setDefaultModel:h.setDefaultModel,setModelContextWindow:h.setModelContextWindow,setSessionMaxIterations:h.setSessionMaxIterations,setSessionPlanMode:h.setSessionPlanMode,voiceOnByAgent:h.voiceOnByAgent,setVoiceMode:h.setVoiceMode,setSessionGroup:h.setSessionGroup,newSession:h.newSession,openSettings:h.openSettings,setExecConfig:h.setExecConfig,send:h.send,stop:h.stop,compact:h.compact}))),[A,P]=l.useState(null),[B,_]=l.useState(""),[V,$]=l.useState(!1),[q,T]=l.useState(null),[L,G]=l.useState(""),[ee,re]=l.useState(!1),Z=Le(h=>c?h.sessions[c]:void 0),H=g.activeSession||Z,he=(g.modelsResp?.models||[]).find(h=>h.id===(H?.model_id||g.cfg.modelId||g.modelsResp?.defaultModelId||""))||null,le=g.activeCtxInfo&&(!g.activeCtxInfo.modelId||!he||g.activeCtxInfo.modelId===he.id)?g.activeCtxInfo:null,W=g.activeUsage,K=g.activeMessages,F=l.useMemo(()=>Su(K),[K]),X=g.running,oe=g.execConfig,pe=rt(h=>h.vaultRoot);l.useEffect(()=>{const h=g.pendingChatQuote;!h||h.targetType!==t.type||(G(h.text),g.clearPendingChatQuote(h.seq))},[t.type,g.pendingChatQuote,g.clearPendingChatQuote]);const D=ol(c?oe.execMode?oe:{execMode:H?.project_path?"host":"sandbox",approvalMode:"auto-edit",cwd:H?.project_path||void 0,...oe}:(()=>{const h=il(g.sessionMode,g.newChatWs,al()),I=h==="chat"||g.newChatWs?.kind==="cloud"||g.newChatWs?.kind==="rootless";return rl(ll({execMode:I?"sandbox":"host",...cl(g.desktopConfig,!I,h),cwd:I?void 0:g.newChatWs?.path||void 0,...g.newChatCfg},h))})(),pe),Q=typeof n.teamSessionId=="string"&&n.teamSessionId===D.teamMember?.teamSessionId?n.teamSessionId:void 0,J=M(h=>Q?h.configBySession[Q]:void 0),fe=dl({...g,activeId:c}),Ce=g.modelsResp?.models?Ah(g.modelsResp.models):null,ke=c?oe.engineId:g.newChatCfg.engineId,We=l.useMemo(()=>K.find(h=>h.status==="streaming")?.id??null,[K]),ge=g.runStats,Oe=l.useMemo(()=>{if(!ge)return null;for(let h=K.length-1;h>=0;h--){const I=K[h];if(I.role==="assistant"&&!gn(I))return ul(ge,I.timestamp)?I.id:null}return null},[K,ge]),ne=Bu(c,l.useMemo(()=>K.filter(h=>h.role==="assistant"&&!gn(h)),[K]),!n.childSurface),Ae=l.useMemo(()=>{const h=K.filter(Y=>Y.role==="user"&&!Y.content.startsWith("<turn_interrupted>")&&!Y.content.startsWith(bi)).map(Y=>Y.content),I=new Set(h);return[...h,...g.steerSent.filter(Y=>!I.has(Y))]},[K,g.steerSent]),me=D.agentSlug||g.defaultAgentSlug,S=me?g.agentAvatars[me]:void 0,R=ke?g.engines.find(h=>h.id===ke)?.name:me?g.agentDefs.find(h=>h.slug===me)?.name:void 0,E=g.authInfo?.nickname||g.authInfo?.username||void 0,O=g.authInfo?.avatar||void 0,ce=me?!!g.voiceOnByAgent[me]:!1;l.useEffect(()=>{M.getState().ensureEngineCaps(ke||void 0)},[ke]),l.useEffect(()=>{me&&M.getState().refreshVoiceMode(me)},[me]);const Pe=l.useCallback(h=>{d.current=h,He.getState().registerChatSurface(t.id,h)},[t.id]),Je=l.useRef(null);l.useEffect(()=>{const h=Je.current;if(!h||typeof ResizeObserver>"u")return;const I=h.parentElement,Y=()=>I?.style.setProperty("--t2-composer-h",`${h.offsetHeight}px`);Y();const ye=new ResizeObserver(Y);return ye.observe(h),()=>ye.disconnect()},[]),l.useEffect(()=>{c&&M.getState().loadSessionHistory(c)},[c]),l.useEffect(()=>{t.setTitle(H?.title?fa(H.title,s):c?"Tangu Agent":s("sidebar.newChat"))},[c,H?.title,t,s]),l.useEffect(()=>{const h=g.jumpTarget;if(!h||h.sessionId!==c||z)return;const I=document.getElementById(`tocmsg-${h.messageId}`);if(!I){K.length&&(g.toast(s("search.jumpOutOfWindow"),!0),g.clearJumpTarget());return}const Y=d.current;if(Y){const Te=I.getBoundingClientRect().top-Y.getBoundingClientRect().top+Y.scrollTop;Y.scrollTo({top:Math.max(0,Te-24),behavior:"smooth"}),f.current=!1}I.classList.add("t2-jump-flash");const ye=window.setTimeout(()=>I.classList.remove("t2-jump-flash"),1600);return g.clearJumpTarget(),()=>window.clearTimeout(ye)},[g.jumpTarget?.seq,c,z,K.length]);const qe=l.useCallback((h=!1)=>{const I=d.current;I&&(I.scrollTo({top:I.scrollHeight,behavior:h?"smooth":"auto"}),f.current=!0,$(!1))},[]);l.useLayoutEffect(()=>{f.current=!g.jumpTarget,j.current=0},[c]),l.useEffect(()=>{const h=d.current,I=h?.querySelector(".t2-stream-inner");if(!h||!I)return;let Y=0,ye=h.scrollTop,Te=!1;const Ee=()=>{const ze=h.scrollHeight-h.scrollTop-h.clientHeight<40;ze?f.current=!0:Te&&h.scrollTop<ye&&(f.current=!1),ye=h.scrollTop,$(!ze&&!f.current)},dt=()=>{f.current=!1,$(!0)},wt=ze=>{ze.deltaY<0&&dt()};let bt=0;const kt=ze=>{bt=ze.touches[0]?.clientY||0},St=ze=>{(ze.touches[0]?.clientY||0)>bt&&dt()},ss=()=>{Te=!0},os=()=>{Te=!1},is=ze=>{["ArrowUp","PageUp","Home"].includes(ze.key)&&!(ze.target instanceof HTMLTextAreaElement||ze.target instanceof HTMLInputElement)&&dt()},as=()=>{f.current&&(h.scrollTop=h.scrollHeight,ye=h.scrollTop,$(!1))},sn=new ResizeObserver(()=>{cancelAnimationFrame(Y),Y=requestAnimationFrame(as)});return sn.observe(I),sn.observe(h),as(),h.addEventListener("scroll",Ee,{passive:!0}),h.addEventListener("wheel",wt,{passive:!0}),h.addEventListener("touchstart",kt,{passive:!0}),h.addEventListener("touchmove",St,{passive:!0}),h.addEventListener("pointerdown",ss),h.addEventListener("keydown",is),window.addEventListener("pointerup",os),()=>{sn.disconnect(),cancelAnimationFrame(Y),h.removeEventListener("scroll",Ee),h.removeEventListener("wheel",wt),h.removeEventListener("touchstart",kt),h.removeEventListener("touchmove",St),h.removeEventListener("pointerdown",ss),h.removeEventListener("keydown",is),window.removeEventListener("pointerup",os)}},[c]);const ie=g.compacting!==void 0;l.useLayoutEffect(()=>{f.current&&!g.jumpTarget&&qe()},[K,z,qe,ie]),l.useEffect(()=>{let h=0;for(const I of K)h+=I.planProposal&&I.inquiries?.filter(Y=>Y.status==="pending"&&Y.kind==="plan").length||0;h>j.current&&qe(!0),j.current=h},[K,qe]),l.useEffect(()=>{const h=d.current,I=u.current;if(!h||!I)return;const Y=()=>{const Ee=window.getSelection();if(!Ee||Ee.isCollapsed||!Ee.rangeCount){T(null);return}const dt=Ee.toString().trim(),wt=Ee.getRangeAt(0);if(!dt||!h.contains(wt.commonAncestorContainer)){T(null);return}const bt=wt.getBoundingClientRect(),kt=I.getBoundingClientRect(),St=wl(I);T({x:(bt.right-kt.left)/St,y:(bt.bottom-kt.top)/St+6,text:dt})},ye=()=>{window.getSelection()?.isCollapsed&&T(null)},Te=()=>T(null);return h.addEventListener("mouseup",Y),document.addEventListener("selectionchange",ye),h.addEventListener("scroll",Te,{passive:!0}),()=>{h.removeEventListener("mouseup",Y),document.removeEventListener("selectionchange",ye),h.removeEventListener("scroll",Te)}},[c,K.length]);const Rt=h=>{try{navigator.clipboard.writeText(h)}catch{}},[tn,Ki]=l.useState(hl());l.useEffect(()=>pl(Ki),[]);const es=!!g.desktopConfig?.ttsModelId?.trim(),Yi=(h,I)=>{if(tn?.msgId===h){kl();return}Sl(Ne(),g.desktopConfig,h,I).catch(Y=>{g.toast(Y?.message==="EMPTY"?s("tts.noText"):s("tts.failed",{e:Y?.message||Y}),!0)})},Ji=(h,I)=>{P(h),_(I)},ts=()=>{A&&B.trim()&&g.editUserMessage(A,B.trim(),c),P(null)},Qe=K.length>0,nn=!!c&&Qe&&!n.childSurface&&!N&&xn!=="mobile"&&!!g.desktopConfig?.agentDeskEnabled,ns=ml(nn),Qi=!n.childSurface&&!N&&xn!=="mobile"&&!!D.groupChat&&(D.groupAgents?.length||0)>=2,Xi=h=>{fs(h.dataTransfer)&&(h.preventDefault(),h.dataTransfer.dropEffect="copy",ee||re(!0))},Zi=h=>{if(re(!1),!fs(h.dataTransfer))return;h.preventDefault(),h.stopPropagation();const I=bl(h.dataTransfer);I.length&&g.appendRefs(I)};return e.jsxs("div",{className:`t2-chat-view${ee?" refdrop":""}`,"data-chat-surface":t.type,"data-session-id":c||void 0,style:{flex:1,minHeight:0,display:"flex",flexDirection:"row",minWidth:0},onDragOver:Xi,onDragLeave:h=>{h.currentTarget.contains(h.relatedTarget)||re(!1)},onDrop:Zi,children:[a&&D.soloAgentSlug&&c&&e.jsx(Hc,{agents:g.agentDefs.filter(h=>h.createdBy!=="system"&&!!h.libraryDir),team:null,initialMembers:[D.soloAgentSlug],onClose:()=>r(!1),onSaved:h=>{r(!1);const I=c;M.getState().ensureTeamSession(h.slug).then(Y=>{Y&&(M.getState().setSeedOnce(Y.id,I),fl(Y.id,{newTab:!0}))})}}),e.jsxs("div",{className:"t2-chat-col",children:[e.jsx(zc,{children:e.jsxs("div",{className:"t2-chat-body",ref:u,children:[Qe&&e.jsx(Gu,{scrollContainerRef:d,scanTrigger:K.length}),e.jsx("div",{className:"t2-stream",ref:Pe,children:e.jsxs("div",{className:"t2-stream-inner",children:[Qe?K.map(h=>gn(h)?null:h.role==="user"&&h.id===A?e.jsx("div",{className:"t2-userwrap",children:e.jsxs("div",{className:"t2-edit",children:[e.jsx("textarea",{className:"t2-edit-ta",value:B,autoFocus:!0,onChange:I=>_(I.target.value),onKeyDown:I=>{I.key==="Enter"&&(I.metaKey||I.ctrlKey)&&ts(),I.key==="Escape"&&P(null)}}),e.jsxs("div",{className:"t2-btnrow",children:[e.jsx("button",{className:"t2-btn primary",onClick:ts,children:s("chat.edit.saveResend")}),e.jsx("button",{className:"t2-btn ghost",onClick:()=>P(null),children:s("common.cancel")})]})]})},h.id):e.jsx(Du,{msg:h,showWaitDetails:o,rootRef:h.id===We?v:void 0,footer:h.id===Oe&&ge||ne.has(h.id)?e.jsxs(e.Fragment,{children:[h.id===Oe&&ge&&e.jsx(Us,{stats:ge}),ne.has(h.id)&&e.jsx(Uu,{traces:ne.get(h.id),sessionId:c||""})]}):void 0,avatarUrl:h.role!=="assistant"?void 0:(()=>{const I=h.agentId||(h.agentName?g.agentDefs.find(Y=>Y.name===h.agentName)?.slug:void 0);if(I)return g.agentAvatars[I];if(!h.agentName)return ke?void 0:S})(),agentNameFallback:R,userName:E,userAvatar:O,fileCtx:{cfg:g.cfg,sessionId:c||"",execMode:D.execMode,onOpenPreview:g.setFilePreview},modelId:fe,speakState:tn?.msgId===h.id?tn.phase:void 0,voice:es?{on:ce,cfg:g.cfg,stored:g.desktopConfig}:void 0,handlers:{onCopy:Rt,onRegenerate:n.readOnly?void 0:()=>g.regenerate(h.id,c),onBranch:n.childSurface?void 0:()=>{g.branchFromMessage(h.id,c)},onEdit:n.readOnly?void 0:()=>Ji(h.id,h.content),onRewind:n.readOnly?void 0:I=>{g.rewindTo(h.id,I,c)},onSuggest:n.readOnly?void 0:I=>{g.send(I,[],void 0,void 0,void 0,c)},onTask:(I,Y)=>Yc(I,Y,c),onInsertNote:vl()?I=>{nd(I,Zc(K,h.id))}:void 0,...es?{onSpeak:I=>Yi(h.id,I)}:{}}},h.id)):z?e.jsx(gl,{variant:"chat"}):null,X&&ge&&!Oe&&ge.finishedAt==null&&e.jsx("div",{className:"t2-runstats-solo",children:e.jsx(Us,{stats:ge})}),K.filter(h=>h.teamSummary).slice(-1).map(h=>e.jsx(Eh,{message:h},h.id)),X&&c&&g.isGroupVoting&&e.jsxs("div",{className:"t2-sys",children:[e.jsx("span",{className:"t2-dot"})," ",s("group.voting.inProgress")]}),X&&c&&g.llmRetry&&e.jsxs("div",{className:"t2-sys t2-retry",title:g.llmRetry.error,children:["⟳ ",s("chat.llmRetrying",{s:(g.llmRetry.waitMs/1e3).toFixed(1),n:g.llmRetry.attempt,max:g.llmRetry.max||"?"}),g.llmRetry.error?e.jsx("span",{className:"t2-retry-err",children:g.llmRetry.error}):null]}),g.compacting!==void 0&&e.jsxs("div",{className:"t2-compact",role:"status","aria-live":"polite",children:[e.jsxs("div",{className:"t2-compact-head",children:[e.jsx("span",{children:s("input.compacting")}),e.jsxs("span",{className:"t2-compact-pct",children:[g.compacting,"%"]})]}),e.jsx("div",{className:"t2-compact-track",children:e.jsx("div",{className:"t2-compact-fill",style:{width:`${g.compacting}%`}})})]})]})}),V&&e.jsx("button",{className:"jump-bottom t2-jump",title:s("chat.jumpToBottom"),onClick:()=>qe(!0),children:e.jsx(yl,{size:16})}),q&&e.jsxs("div",{className:"quote-float t2-quote-menu",role:"toolbar","aria-label":s("chat.selection.actions"),onMouseDown:h=>h.preventDefault(),style:{left:q.x,top:q.y,"--quote-x":`${q.x}px`},children:[e.jsxs("button",{className:"t2-quote-action","data-testid":"selection-quote",onClick:()=>{G(q.text),T(null),window.getSelection()?.removeAllRanges()},children:[e.jsx(pc,{size:13})," ",s("chat.action.quote")]}),t.type!=="chat-panel"&&e.jsxs("button",{className:"t2-quote-action","data-testid":"selection-ask-in-panel",onClick:()=>{Jc(q.text),T(null),window.getSelection()?.removeAllRanges()},children:[e.jsx(Fo,{size:13})," ",s("chat.action.askInPanel")]}),c&&e.jsxs("button",{className:"t2-quote-action","data-testid":"selection-btw",onClick:()=>{ws({sessionId:c,title:H?.title,quote:q.text,modelId:fe||void 0}),T(null),window.getSelection()?.removeAllRanges()},children:[e.jsx(lc,{size:13})," ",s("btw.selectionAction")]})]})]})},c||"none"),!Qe&&!z&&e.jsx(Wu,{compact:!!n.miniSurface,title:n.miniSurface?s("mini.chatHint"):N?s("studio.chatTitle"):void 0,subtitle:N?s(b?"studio.chatHint":"studio.chooseProject"):void 0}),e.jsxs("div",{className:"composer-anchor",ref:Je,children:[!n.miniSurface&&!n.childSurface&&!Qe&&D.preset!=="chat"&&!D.soloAgentSlug&&!D.soloEngineId&&!D.teamSlug&&e.jsx("div",{className:"newchat-pickers",children:e.jsx(ga,{sessionId:c,cfg:D})}),!c&&(!N||b)&&(D.preset!=="chat"||k&&!N)&&e.jsx("div",{className:"newchat-projectbar",children:e.jsxs("div",{className:"newchat-projectbar-inner",children:[k&&!N&&e.jsx(va,{}),D.preset!=="chat"&&(N&&b?e.jsxs("div",{className:"project-pill",title:b,"data-studio-project":b,children:[e.jsx(Zt,{size:13}),e.jsx("span",{className:"project-pill-name",children:Ll(b)})]}):e.jsx(ya,{workspaces:g.workspaces(),value:g.newChatWs?.key??null,onChange:h=>g.setNewChatWs(h),onAddProject:window.tangu?.pickDirectory?()=>{g.addLocalWorkspace()}:void 0,onAddCloudProject:h=>{g.addCloudProject(h)}}))]})}),!Qe&&!z&&!n.miniSurface&&!n.childSurface&&!D.teamSlug&&!D.groupChat&&!D.teamMember&&!D.soloEngineId&&!D.engineId&&g.connState==="ok"&&e.jsx(Hu,{slug:me}),e.jsx(Tl,{children:g.filePreview&&e.jsx(Uc,{target:g.filePreview,onClose:()=>g.setFilePreview(null)},g.filePreview.name)}),e.jsx(ja,{sessionId:c,approvalTray:F.length?e.jsx(qu,{sessionId:c??void 0,items:F,onDecide:(h,I,Y,ye)=>g.decideApproval(h,I,Y,ye,c),onAnswer:(h,I,Y)=>g.answerInquiry(h,I,Y,c)},c??""):void 0,advisory:n.childSurface?void 0:e.jsx($h,{sessionId:c,fallback:e.jsx(Rh,{loggedIn:!!g.authInfo?.loggedIn&&g.authInfo.tokenValid!==!1,onToast:g.toast})}),liveOwner:p&&t.loc==="main",liveSessionKey:c,disabled:!!n.readOnly||!m||N&&!b,disabledPlaceholder:N&&!b?s("studio.chooseProject"):C,running:X,execConfig:J?{...D,approvalMode:J.approvalMode||D.approvalMode}:D,teamApproval:!!J,models:Ce,modelsResponse:g.modelsResp,modelId:fe,onModelChange:h=>g.setSessionModel(h,c,!n.childSurface),engines:g.engines,engineId:D.engineId,engineModels:D.engineId?g.engineCaps[D.engineId]?.models??[]:void 0,engineModelId:D.engineModelId,onEngineModelChange:c?h=>g.setSessionEngineModel(h,c):h=>g.setNewChatCfg(I=>({...I,engineModelId:h||void 0})),engineCommands:D.engineId?g.engineCaps[D.engineId]?.commands??[]:void 0,thinkingLevel:D.thinkingLevel,ultra:D.ultra,onThinkingChange:(h,I)=>g.setSessionThinking(h,c,!n.childSurface,I),defaultModelIds:{backgroundModelId:g.desktopConfig?.backgroundModelId||"",imageModelId:g.cfg.imageModelId||"",visionModelId:g.cfg.visionModelId||""},onDefaultModelChange:g.setDefaultModel,onContextWindowChange:(h,I)=>{g.setModelContextWindow(h,I)},maxIterations:D.maxIterations,onMaxIterationsChange:c?h=>g.setSessionMaxIterations(h,c):h=>g.setNewChatCfg(I=>({...I,maxIterations:h})),verifyCommand:D.verifyCommand,onVerifyCommandChange:c?h=>g.setExecConfig({verifyCommand:h||void 0},c):h=>g.setNewChatCfg(I=>({...I,verifyCommand:h||void 0})),planMode:D.planMode,onPlanModeChange:J?void 0:c?h=>g.setSessionPlanMode(h,c):h=>g.setNewChatCfg(I=>({...I,planMode:h})),preset:D.preset,onPresetChange:c?void 0:h=>g.setSessionMode(h),voiceMode:ce,onVoiceModeChange:me?h=>{g.setVoiceMode(me,h)}:void 0,groupChat:D.groupChat,groupAgents:D.groupAgents,groupTempAgents:D.groupTempAgents,onGroupChange:n.childSurface||D.soloAgentSlug||D.soloEngineId?void 0:c?h=>g.setSessionGroup(h,c):h=>g.setNewChatCfg(I=>({...I,...h})),onAddAgent:D.soloAgentSlug?()=>r(!0):void 0,onNormalWork:J?void 0:()=>{const h={planMode:!1,groupChat:!1,approvalMode:"auto-edit"};D.teamSlug&&!D.agentSlug&&(h.agentSlug=D.groupAgents?.[0]||g.defaultAgentSlug),c?g.setExecConfig(h,c):(g.setSessionMode("work"),g.setNewChatCfg(I=>({...I,...h})))},skills:g.skillsList,agents:g.agentDefs,onAgentSwitch:!n.childSurface&&c&&Qe&&!D.groupChat&&!D.soloAgentSlug&&!D.soloEngineId&&!D.teamSlug&&!D.engineId?h=>g.selectSessionAgent(h,c):void 0,currentAgentSlug:D.agentSlug||g.defaultAgentSlug,mentionProjects:D.soloAgentSlug?g.workspaces().filter(h=>h.kind==="local"&&!!h.path).map(h=>({name:h.name,path:h.path})):void 0,onNewSession:n.childSurface?void 0:()=>{D.soloAgentSlug?X||ms("agent",D.soloAgentSlug):D.soloEngineId?X||ms("engine",D.soloEngineId):g.newSession()},onBranch:!n.childSurface&&c?()=>{g.branchFromMessage(void 0,c)}:void 0,onOpenSettings:()=>g.openSettings("skills"),onExecConfigChange:Q&&J?h=>{h.approvalMode&&g.setExecConfig({approvalMode:h.approvalMode},Q)}:h=>g.setExecConfig(h,c),onSend:async(h,I,Y,ye,Te)=>{if(N){const Ee=Sn.getState().prepareRun();return Ee?M.getState().send(h,I,Y,ye,Te,Ee.sessionId):!1}return g.send(h,I,Y,ye,Te,c)},onStop:()=>g.stop(c),quotedText:L,onClearQuote:()=>G(""),onBtw:c?(h,I)=>ws({sessionId:c,title:H?.title,question:h,quote:I,modelId:fe||void 0}):void 0,contextWindow:le?.ctxWindow||he?.contextWindow||0,ctxInfo:le,ctxTokens:W.ctx,sessionTokens:W.base+W.live,runCost:W.runCost,costLimit:W.costLimit,onCompact:h=>{g.compact(c,h)},seedText:g.steerRestore??(n.childSurface?null:g.pendingDraft),seedShare:n.childSurface||t.type==="chat-panel"?null:g.pendingShare,takeSeedShare:g.takePendingShare,appendRefs:n.childSurface?null:g.draftRefs,onAppendRefsConsumed:g.clearDraftRefs,autoRefFromMain:!n.childSurface&&(t.loc!=="main"||n.autoRefFromMain===!0),appRef:n.childSurface?null:Bh(n.appRef),onSeedConsumed:()=>{g.steerRestore&&c?g.clearSteerRestore(c):n.childSurface||g.setPendingDraft(null)},sentHistory:Ae,pendingSteer:g.steerPending,onCancelSteer:c?h=>{g.withdrawSteer(c,h)}:void 0,onWithdrawSteer:c?h=>g.withdrawSteer(c,h):void 0,onSteerNow:c?()=>{g.steerNow(c)}:void 0})]}),!n.childSurface&&e.jsxs("div",{className:"t2-rail",children:[e.jsx(oh,{teamStatus:c?e.jsxs(e.Fragment,{children:[Qi&&e.jsx(Nh,{sessionId:c}),e.jsx(Ph,{sessionId:c}),g.historianEnabled&&e.jsx(bh,{sessionId:c},c)]}):void 0,messages:K,running:X,cwd:D.cwd,modelId:fe,hostCwd:D.execMode==="host"?D.cwd:void 0,extraRoots:D.extraRoots,lockedRoots:D.execMode==="host"&&pe?[pe]:[],onAddRoot:D.execMode==="host"&&c?()=>{window.tangu?.pickDirectory?.().then(h=>{if(!h)return;const I=M.getState().configBySession[c]?.extraRoots||[];h===D.cwd||I.includes(h)||M.getState().setExecConfig({extraRoots:[...I,h]},c)})}:void 0,onRemoveRoot:D.execMode==="host"&&c?h=>{if(h===pe)return;const I=M.getState().configBySession[c]?.extraRoots||[];M.getState().setExecConfig({extraRoots:I.filter(Y=>Y!==h)},c)}:void 0,onJumpToAttention:()=>qe(!0),onShowEditing:ns&&c?h=>M.getState().deskShowFile(c,h):void 0,onOpenFile:h=>{const I=h.path?jl(h.path,D.cwd):null;if(ns&&c&&I&&g.desktopConfig?.summaryOpenIn==="desk"){M.getState().deskShowFile(c,I);return}xl(Al(h,g.cfg,c||"",D.execMode))}}),nn&&c?e.jsx(mh,{sessionId:c}):null]})]}),nn&&c&&!i[c]?e.jsx(uh,{sessionId:c}):null,!n.childSurface&&c?e.jsx(Th,{parentId:c},c):null]})}const Ip=Object.freeze(Object.defineProperty({__proto__:null,ChatView:Gi},Symbol.toStringTag,{value:"Module"}));export{qu as A,Hc as B,Gi as C,Rp as D,zc as E,ys as F,sc as G,Ve as H,ic as I,Jc as J,Mp as K,ku as L,Yc as M,Ue as N,Uo as O,Ap as P,pc as Q,gc as R,qo as S,Ho as T,ws as U,kc as V,lh as W,Ip as X,Wu as a,kp as b,Du as c,Sp as d,Pc as e,Tc as f,xp as g,bp as h,Np as i,gd as j,Tp as k,ad as l,qt as m,Ql as n,Yn as o,Su as p,zp as q,Cp as r,wp as s,Ep as t,Ac as u,rd as v,yu as w,Pp as x,An as y,at as z};