@organizaone/o1-code 0.21.2 → 0.21.5

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 (264) hide show
  1. package/chunks/{MaxSizedBox-BDVXDUGY.js → MaxSizedBox-SU4HCQSJ.js} +17 -17
  2. package/chunks/{StandaloneSessionPicker-TVOJJUHC.js → StandaloneSessionPicker-TP4U5KWK.js} +33 -33
  3. package/chunks/{acp-subagent-executor-WWYSUVDL.js → acp-subagent-executor-VN5UYKRV.js} +19 -19
  4. package/chunks/{acpAgent-33UXJPQP.js → acpAgent-HHY5HU4M.js} +59 -59
  5. package/chunks/{agent-FMHCYV5R.js → agent-ULHGN4TH.js} +9 -9
  6. package/chunks/{agent-headless-W5YX7TBY.js → agent-headless-XHN5VUEO.js} +9 -9
  7. package/chunks/{all-providers-DWY3CUMS.js → all-providers-Q32X3OAQ.js} +2 -2
  8. package/chunks/{anthropicContentGenerator-YYGTZUGF.js → anthropicContentGenerator-QDRGYQDB.js} +5 -5
  9. package/chunks/{bridge-BZBBRX5Y.js → bridge-HAM6W2PR.js} +19 -19
  10. package/chunks/{chunk-USU55VZU.js → chunk-2FOOVYBF.js} +2 -2
  11. package/chunks/{chunk-MR6QBWSU.js → chunk-2WDPNP36.js} +1 -1
  12. package/chunks/{chunk-HZTDCVG5.js → chunk-2YKAXZ2Z.js} +2 -2
  13. package/chunks/{chunk-CFUJXVRB.js → chunk-34FJNONT.js} +3 -3
  14. package/chunks/{chunk-DZZBQ24V.js → chunk-3WC3PWGH.js} +3 -3
  15. package/chunks/{chunk-OOLBYOKF.js → chunk-4IYK3VTX.js} +1 -1
  16. package/chunks/{chunk-AVKRSELA.js → chunk-4TOOWZCQ.js} +1 -1
  17. package/chunks/{chunk-JCD2ECGQ.js → chunk-4ZQ3UJON.js} +4 -4
  18. package/chunks/{chunk-5LV5NUUX.js → chunk-573HRXBN.js} +1 -1
  19. package/chunks/{chunk-PYVCGJFV.js → chunk-5DD4XDIO.js} +1 -1
  20. package/chunks/{chunk-4VGQKFTJ.js → chunk-5JMHQIDF.js} +2 -2
  21. package/chunks/{chunk-BW4XNKSR.js → chunk-5KX7XCGS.js} +13 -13
  22. package/chunks/{chunk-6KOVYWMV.js → chunk-6F3T6GCN.js} +5 -5
  23. package/chunks/{chunk-MOTACAIQ.js → chunk-6P4PKI7C.js} +1 -1
  24. package/chunks/{chunk-2EFFEOP5.js → chunk-6VF7EU56.js} +20 -12
  25. package/chunks/{chunk-N4TE7U5S.js → chunk-7NUQOGKE.js} +1 -1
  26. package/chunks/{chunk-EOCJTIO2.js → chunk-7QQ4CFWY.js} +5 -5
  27. package/chunks/{chunk-JJH3H37Q.js → chunk-7SCZ63M6.js} +2 -2
  28. package/chunks/{chunk-2MX5WB7I.js → chunk-A6DDWLZ5.js} +5 -5
  29. package/chunks/{chunk-6OZIC33H.js → chunk-ATQGDGVO.js} +2 -2
  30. package/chunks/{chunk-A3IITA3Y.js → chunk-B32I6PBY.js} +719 -668
  31. package/chunks/{chunk-LVCMQBPV.js → chunk-BN4QAFGN.js} +3 -3
  32. package/chunks/{chunk-WFOB5XRW.js → chunk-BP2EX2GK.js} +2 -2
  33. package/chunks/{chunk-Q4J6VZNO.js → chunk-BULRILP2.js} +4 -4
  34. package/chunks/{chunk-5352FLO6.js → chunk-BVGND6XL.js} +2 -2
  35. package/chunks/{chunk-ANBZIZRJ.js → chunk-CWNKBQK7.js} +1 -1
  36. package/chunks/{chunk-EFJLBHZ4.js → chunk-DH6EN3DQ.js} +1 -1
  37. package/chunks/{chunk-65C47VHT.js → chunk-DS2266LD.js} +3 -3
  38. package/chunks/{chunk-VLARQWWT.js → chunk-EDPS3FF2.js} +13 -13
  39. package/chunks/{chunk-7OIDYCHT.js → chunk-EZXKUGDV.js} +1 -1
  40. package/chunks/{chunk-6HUYUVVW.js → chunk-FFVBQAOI.js} +48 -48
  41. package/chunks/{chunk-SYGSIMBB.js → chunk-FN2PCMQU.js} +8 -8
  42. package/chunks/{chunk-TN3RCPTP.js → chunk-FWDUYDO3.js} +3 -3
  43. package/chunks/{chunk-7NKAI5NF.js → chunk-G5FN6A3O.js} +7 -7
  44. package/chunks/{chunk-SHOK4JXO.js → chunk-GCP7RBQU.js} +2 -2
  45. package/chunks/{chunk-7L4J4WZM.js → chunk-GMKBSHSE.js} +4 -4
  46. package/chunks/{chunk-RGOISHNS.js → chunk-GPE7USUE.js} +1 -1
  47. package/chunks/{chunk-VDSY3ODQ.js → chunk-HIMOZPLA.js} +1 -1
  48. package/chunks/{chunk-KX5A3ZL7.js → chunk-HINYEUDQ.js} +3 -3
  49. package/chunks/{chunk-FKDTCJEB.js → chunk-HIZP2HEY.js} +1 -1
  50. package/chunks/{chunk-FVXCJ7O5.js → chunk-HU6ONUSW.js} +10 -10
  51. package/chunks/{chunk-CUIEW2DO.js → chunk-HY6XQBQP.js} +5 -5
  52. package/chunks/{chunk-53I775WU.js → chunk-I5G3FFPK.js} +1 -1
  53. package/chunks/{chunk-5LEDICGK.js → chunk-IFQBI2KG.js} +2 -2
  54. package/chunks/{chunk-R5DTGEJC.js → chunk-J3IOXMRN.js} +7 -7
  55. package/chunks/{chunk-MQCDSDGS.js → chunk-J5B2Y7OM.js} +1 -1
  56. package/chunks/{chunk-JX6KBOLC.js → chunk-JC5KPPBA.js} +1 -1
  57. package/chunks/{chunk-YYK7LIW3.js → chunk-JLTEULJU.js} +1 -1
  58. package/chunks/{chunk-4U6DXSYR.js → chunk-KXD2AJZC.js} +3 -3
  59. package/chunks/{chunk-BBS5EK3G.js → chunk-KZGLPXWQ.js} +2 -2
  60. package/chunks/{chunk-4RMUJ4EW.js → chunk-L6B62OHV.js} +2 -2
  61. package/chunks/{chunk-X5TVKUTT.js → chunk-L72OGYSB.js} +3 -3
  62. package/chunks/{chunk-QXPDXX7R.js → chunk-LGJHDSPM.js} +3 -3
  63. package/chunks/{chunk-7VMW7TZU.js → chunk-LGMJPCDH.js} +2 -2
  64. package/chunks/{chunk-XW2PY5FF.js → chunk-MHDULU2E.js} +1 -1
  65. package/chunks/{chunk-67ALOILQ.js → chunk-MKA7BWMJ.js} +2 -2
  66. package/chunks/{chunk-XF26RRKO.js → chunk-OFLC6D2X.js} +1 -1
  67. package/chunks/{chunk-2AVSJ6YM.js → chunk-OQKXVSEF.js} +1 -1
  68. package/chunks/{chunk-H5A66Y7N.js → chunk-PCNTHGKA.js} +1 -1
  69. package/chunks/{chunk-CCOAJ47J.js → chunk-PM5SLRCF.js} +7 -7
  70. package/chunks/{chunk-ZSKV65PM.js → chunk-QEEO7JQ5.js} +2 -2
  71. package/chunks/{chunk-B6CUAZPB.js → chunk-QGEQIPZH.js} +3 -3
  72. package/chunks/{chunk-I4TPYOCC.js → chunk-QWHAOOJN.js} +2 -2
  73. package/chunks/{chunk-Y7PM2TUS.js → chunk-QZ4M352N.js} +5 -5
  74. package/chunks/{chunk-Y5APYUGL.js → chunk-RCBEU2XC.js} +2 -2
  75. package/chunks/{chunk-B3HD37FG.js → chunk-S32RVOL2.js} +1 -1
  76. package/chunks/{chunk-ZG6EFU5F.js → chunk-SENOCQJJ.js} +2 -2
  77. package/chunks/{chunk-42SRSP6X.js → chunk-SPC5HVSD.js} +1 -1
  78. package/chunks/{chunk-IJZCC6FB.js → chunk-T6H47EQY.js} +4 -4
  79. package/chunks/{chunk-WFU7YVXW.js → chunk-T775SAII.js} +2 -2
  80. package/chunks/{chunk-VPHE2AYS.js → chunk-TADRPMGC.js} +3 -3
  81. package/chunks/{chunk-T74KQREN.js → chunk-TBQZYPU2.js} +1 -1
  82. package/chunks/{chunk-ZWZG7LCJ.js → chunk-TFJG3BJ2.js} +5 -5
  83. package/chunks/{chunk-7VJCP57S.js → chunk-UMC3TRX3.js} +1 -1
  84. package/chunks/{chunk-ZUKNLRKN.js → chunk-UN4MXFDP.js} +1 -1
  85. package/chunks/{chunk-4UBPNICF.js → chunk-UVWX7EN3.js} +30 -30
  86. package/chunks/{chunk-AG4TACE2.js → chunk-V5KWWBKF.js} +1 -1
  87. package/chunks/{chunk-5UCRRIQI.js → chunk-VJXSMATF.js} +2 -2
  88. package/chunks/{chunk-Z6AUHEOD.js → chunk-VN7625CN.js} +2 -2
  89. package/chunks/{chunk-LRHUT6ZW.js → chunk-VUIDKECZ.js} +5 -5
  90. package/chunks/{chunk-PFPAR6H6.js → chunk-VXM4ULU3.js} +3 -3
  91. package/chunks/{chunk-U6YNAORX.js → chunk-WC5NJRJO.js} +4 -4
  92. package/chunks/{chunk-KUSJLQ36.js → chunk-XI7IFJGO.js} +1 -1
  93. package/chunks/{chunk-4FUZP37P.js → chunk-YSOP3ENC.js} +1 -1
  94. package/chunks/{chunk-LQEJNY2D.js → chunk-YZRATKOH.js} +2 -2
  95. package/chunks/{chunk-JMUY4N4N.js → chunk-ZKRYMA6W.js} +3 -3
  96. package/chunks/{chunk-AU23HO76.js → chunk-ZXBRMXUR.js} +2 -2
  97. package/chunks/{codex-subagent-executor-22DCCKLS.js → codex-subagent-executor-VZ75NQUI.js} +19 -19
  98. package/chunks/{contextCommand-3Y7UYNLA.js → contextCommand-PZ2HTQXJ.js} +19 -19
  99. package/chunks/{core-runtime-QX46OTID.js → core-runtime-JK5F3OZ4.js} +17 -17
  100. package/chunks/{create-sub-session-QIPYII3U.js → create-sub-session-5OTPBP5T.js} +18 -18
  101. package/chunks/{daemon-git-worktree-guard-EER7IXJR.js → daemon-git-worktree-guard-UE2OZNJD.js} +17 -17
  102. package/chunks/{daemon-status-provider-6B2INSNO.js → daemon-status-provider-WGAOUGXF.js} +23 -23
  103. package/chunks/{daemon-trust-policy-YFED56MX.js → daemon-trust-policy-RLODA6A7.js} +23 -23
  104. package/chunks/{daemon-trust-policy-monitor-TDJXPHDQ.js → daemon-trust-policy-monitor-BCFOZORR.js} +23 -23
  105. package/chunks/{deferred-core-runtime-EAGMS7UC.js → deferred-core-runtime-B2NSLFG6.js} +17 -17
  106. package/chunks/{edit-IZNYORSW.js → edit-7KIKQCOH.js} +11 -11
  107. package/chunks/{enterPlanMode-PLUMR72A.js → enterPlanMode-S7FPV7PD.js} +9 -9
  108. package/chunks/{environment-RCU5YMO4.js → environment-XQLH4MFD.js} +19 -19
  109. package/chunks/{errors-6F6NCTEJ.js → errors-PKCA5AAQ.js} +19 -19
  110. package/chunks/{execution-tool-KLZJR3ZW.js → execution-tool-6HRTHHHK.js} +11 -11
  111. package/chunks/{execution-worker-AHXOJ2QU.js → execution-worker-PUS2RQOO.js} +14 -14
  112. package/chunks/{exitPlanMode-2QS7S74N.js → exitPlanMode-ZTWWF3WU.js} +9 -9
  113. package/chunks/{fast-path-547GJHU2.js → fast-path-JP7DLLHZ.js} +2 -2
  114. package/chunks/{foreground-runner-666PD6TD.js → foreground-runner-ESOCFK2K.js} +29 -43
  115. package/chunks/{glob-VE4ZHGHR.js → glob-3R52EFHF.js} +9 -9
  116. package/chunks/{goal-tools-WDCBGRVN.js → goal-tools-SUXI6WFI.js} +9 -9
  117. package/chunks/{handleAutoUpdate-4DCUM7XB.js → handleAutoUpdate-H4BPM23B.js} +20 -20
  118. package/chunks/{i18n-RU6ORTDJ.js → i18n-3SOJHV2H.js} +18 -18
  119. package/chunks/{initializer-JAA34CRP.js → initializer-ICVRJ72L.js} +23 -23
  120. package/chunks/{installationInfo-AFGMNVLD.js → installationInfo-N7VCBNOK.js} +17 -17
  121. package/chunks/{list-JSG6PCP3.js → list-K6HV6EIW.js} +25 -25
  122. package/chunks/{llm-KSWOKF5B.js → llm-PI6CNWOJ.js} +48 -48
  123. package/chunks/{llm-content-generator-6KI5CFTE.js → llm-content-generator-E3N6JKGZ.js} +4 -4
  124. package/chunks/{loadedSettingsAdapter-ATW225PB.js → loadedSettingsAdapter-2YGQHZRC.js} +23 -23
  125. package/chunks/{local-execution-environment-IDDT2M2C.js → local-execution-environment-3YOJ24ZO.js} +14 -14
  126. package/chunks/{loggingContentGenerator-TGNGGLS2.js → loggingContentGenerator-KPMS7XOB.js} +9 -9
  127. package/chunks/{managed-npm-update-554JTDGH.js → managed-npm-update-WFP4CL46.js} +17 -17
  128. package/chunks/{mcp-D66PPBKT.js → mcp-KBSACFAE.js} +23 -23
  129. package/chunks/{model-call-collection-XDGQVFED.js → model-call-collection-Q26R7CSH.js} +1 -1
  130. package/chunks/{model-configuration-QQUX3222.js → model-configuration-3OFIEDKK.js} +24 -24
  131. package/chunks/{modelConfigUtils-LE5NFCQV.js → modelConfigUtils-PKMMDRV2.js} +19 -19
  132. package/chunks/{monitor-TUTPBOGA.js → monitor-7L6OWATQ.js} +9 -9
  133. package/chunks/{nonInteractiveCli-LH2M5UYM.js → nonInteractiveCli-YHWASKJD.js} +51 -51
  134. package/chunks/{nonInteractiveToolExecutor-HP6LCWIS.js → nonInteractiveToolExecutor-U4XEH4P3.js} +10 -10
  135. package/chunks/{notebook-edit-X5RH7X2W.js → notebook-edit-FZAEAM5W.js} +10 -10
  136. package/chunks/{omni-UDBV6XJ2.js → omni-UUFRQ6W6.js} +9 -9
  137. package/chunks/{openaiContentGenerator-BIMPREY2.js → openaiContentGenerator-3ZHSZ5K5.js} +6 -6
  138. package/chunks/{openaiResponsesContentGenerator-2UWE4XZ7.js → openaiResponsesContentGenerator-VEE4KFHW.js} +4 -4
  139. package/chunks/{processUtils-LNTMNIJA.js → processUtils-7JBYCJWE.js} +2 -2
  140. package/chunks/{prompt-terminal-ledger-ZOB4EXRB.js → prompt-terminal-ledger-ZI5BAXFX.js} +18 -18
  141. package/chunks/{pt-QYD5TZDW.js → pt-F7AYPRBY.js} +9 -0
  142. package/chunks/{pty-host-process-PKCVFICX.js → pty-host-process-Y4BPXZFM.js} +2 -2
  143. package/chunks/{reactive-degrade-WA37W6WX.js → reactive-degrade-BLSKXWLX.js} +8 -8
  144. package/chunks/{read-file-ODAOIZD6.js → read-file-W3UB2SUO.js} +1 -1
  145. package/chunks/{resumeHistoryUtils-OP3JIR3F.js → resumeHistoryUtils-H3HSHGMD.js} +21 -21
  146. package/chunks/{ripGrep-4QTNX2IT.js → ripGrep-4PTAFGVR.js} +1 -1
  147. package/chunks/{run-o1-code-serve-PUAAKWTZ.js → run-o1-code-serve-SK2TQYXR.js} +32 -32
  148. package/chunks/{sandboxConfig-6EWR3CLN.js → sandboxConfig-37DZKHCS.js} +17 -17
  149. package/chunks/{scheduled-tasks-O73N6IJA.js → scheduled-tasks-GUU5IH3A.js} +22 -22
  150. package/chunks/{scheduler-UDQCSRWR.js → scheduler-2F7WEPGI.js} +19 -19
  151. package/chunks/{serve-HGGL7PBN.js → serve-ZFWGOSBJ.js} +23 -23
  152. package/chunks/{server-XTQCFLTQ.js → server-JNBE7EGZ.js} +51 -48
  153. package/chunks/{session-GXW3LDFK.js → session-CZZ5Z6PW.js} +1 -1
  154. package/chunks/{session-6QQUOQAH.js → session-JKVOQRIV.js} +52 -52
  155. package/chunks/{session-attachments-root-CSOMMMGL.js → session-attachments-root-7VASYVDZ.js} +17 -17
  156. package/chunks/{session-pr-refresh-4CWA54NA.js → session-pr-refresh-Z55XVZMX.js} +21 -21
  157. package/chunks/{settings-3XT77TC7.js → settings-R47G25MX.js} +22 -22
  158. package/chunks/{shell-OXJHBBMB.js → shell-FQZMP2TR.js} +9 -9
  159. package/chunks/{skill-FN5NE57Y.js → skill-4JQIMS5G.js} +1 -1
  160. package/chunks/{skill-settings-FOQDR37K.js → skill-settings-E6PPIUXT.js} +22 -22
  161. package/chunks/{spawnChannel-R5RSYYFA.js → spawnChannel-JSRLL75N.js} +18 -18
  162. package/chunks/{standalone-update-2I2ODBQN.js → standalone-update-TPZ5YNRK.js} +19 -19
  163. package/chunks/{startInteractiveUI-UJDIVINO.js → startInteractiveUI-CQ2K6W4T.js} +241 -108
  164. package/chunks/{supervisor-runner-JHRQ2FCR.js → supervisor-runner-YD27MXSJ.js} +3 -3
  165. package/chunks/{team-create-JHA7AAPL.js → team-create-7AHL54RG.js} +9 -9
  166. package/chunks/{team-plan-approval-MWCNUWY6.js → team-plan-approval-Q4A2RPY7.js} +9 -9
  167. package/chunks/{terminal-image-renderer-HC6LQQRR.js → terminal-image-renderer-M2ZQZLCI.js} +17 -17
  168. package/chunks/{theme-manager-4KVHVCEL.js → theme-manager-Q7I4UYHB.js} +17 -17
  169. package/chunks/{tool-result-media-6HYDHZAI.js → tool-result-media-D3Y7O4WE.js} +9 -9
  170. package/chunks/{tool-search-OXGLO7JL.js → tool-search-4OLCMSWT.js} +1 -1
  171. package/chunks/{total-session-admission-NQGBNMS7.js → total-session-admission-ZCQEVNTK.js} +19 -19
  172. package/chunks/{trustedFolders-HMPVVJF3.js → trustedFolders-QPF3XHXU.js} +18 -18
  173. package/chunks/{update-relaunch-UYXPY4RH.js → update-relaunch-IH2H5PCU.js} +5 -5
  174. package/chunks/{updateCheck-5XOYJ2D2.js → updateCheck-YCNS54E6.js} +19 -19
  175. package/chunks/{upload-config-DKWZLTOV.js → upload-config-R4VMYGOB.js} +6 -6
  176. package/chunks/{useAutoAcceptIndicator-ACE36D5U.js → useAutoAcceptIndicator-4HP3J7A4.js} +25 -25
  177. package/chunks/{validateNonInterActiveAuth-JKEPMGWI.js → validateNonInterActiveAuth-JBTTVPTP.js} +48 -48
  178. package/chunks/{version-Z7S2XBUO.js → version-LLKOCQSH.js} +1 -1
  179. package/chunks/{web-fetch-NLTFPQUA.js → web-fetch-IUGELNYW.js} +1 -1
  180. package/chunks/{web-search-TQVLTY4C.js → web-search-K5RJ3JF2.js} +7 -7
  181. package/chunks/{workflow-SURVTPFI.js → workflow-BA5LLVP3.js} +10 -10
  182. package/chunks/{workspace-providers-status-RKOC7JVY.js → workspace-providers-status-APHSM3KW.js} +27 -27
  183. package/chunks/{workspace-registration-store-O2JTIXOI.js → workspace-registration-store-ABVFM3W3.js} +1 -1
  184. package/chunks/{workspace-registry-4VQA2AR5.js → workspace-registry-JBSKGAAH.js} +19 -19
  185. package/chunks/{workspace-runtime-coordinator-R4ETFSMB.js → workspace-runtime-coordinator-JRENHSVA.js} +19 -19
  186. package/chunks/{workspace-service-6N5JXBSK.js → workspace-service-6FYIPCVT.js} +26 -26
  187. package/chunks/{workspace-skills-status-Z4ZPGQGU.js → workspace-skills-status-KATMXIQ4.js} +23 -23
  188. package/chunks/{workspace-trust-reconciler-3OIA6XMY.js → workspace-trust-reconciler-3VWEKO73.js} +25 -25
  189. package/chunks/{write-file-AEMWOQLT.js → write-file-FLNYRCBW.js} +11 -11
  190. package/chunks/{zh-TW-O23FCREL.js → zh-TW-EGHYQY24.js} +1 -0
  191. package/chunks/{zh-6TC2VRKR.js → zh-U2XVEBDV.js} +1 -0
  192. package/chunks/{zoom-image-2YB7O452.js → zoom-image-7RRE7WBP.js} +1 -1
  193. package/cli.js +23 -20
  194. package/execution-worker.js +1 -1
  195. package/export-transcript-document.js +1 -1
  196. package/locales/pt.js +12 -0
  197. package/locales/zh-TW.js +1 -0
  198. package/locales/zh.js +1 -0
  199. package/package.json +2 -2
  200. package/release-notes.json +15 -0
  201. package/web-shell/assets/{abnfDiagram-VCTEODGH-GfpzcpVT.js → abnfDiagram-VCTEODGH-COCQodLs.js} +1 -1
  202. package/web-shell/assets/{arc-ErguBx-Q.js → arc-BiH5E4LU.js} +1 -1
  203. package/web-shell/assets/{architectureDiagram-5GKGNRK7-DiKJO95i.js → architectureDiagram-5GKGNRK7-BSJprUk9.js} +1 -1
  204. package/web-shell/assets/{blockDiagram-NRAW4CY4-CdWP9NSQ.js → blockDiagram-NRAW4CY4-K2tLOCqY.js} +1 -1
  205. package/web-shell/assets/{c4Diagram-UCG6FXSJ-C3cpgGGt.js → c4Diagram-UCG6FXSJ-Xh-UK8N1.js} +1 -1
  206. package/web-shell/assets/channel-Do1XLStu.js +1 -0
  207. package/web-shell/assets/{chunk-2Q5K7J3B-o4MSKYwx.js → chunk-2Q5K7J3B-rz6DsNnX.js} +1 -1
  208. package/web-shell/assets/{chunk-5VM5RSS4-B9zWEEyQ.js → chunk-5VM5RSS4-GhCUOtdy.js} +1 -1
  209. package/web-shell/assets/{chunk-F27PBJKO-C3DMZjvh.js → chunk-F27PBJKO-CKuit_56.js} +1 -1
  210. package/web-shell/assets/{chunk-G27WJ6UU-5jtIqDsJ.js → chunk-G27WJ6UU-D0U2R9R1.js} +1 -1
  211. package/web-shell/assets/{chunk-JWPE2WC7-CRzclnDb.js → chunk-JWPE2WC7-DqTl2VmR.js} +1 -1
  212. package/web-shell/assets/{chunk-LCL6LL3I-DB2DGYlA.js → chunk-LCL6LL3I-7ayhcfK7.js} +1 -1
  213. package/web-shell/assets/{chunk-POPQ4Y6H-BYeXEqzE.js → chunk-POPQ4Y6H-DKK-l9pm.js} +1 -1
  214. package/web-shell/assets/{chunk-SVP7TREG-CRnQIqFY.js → chunk-SVP7TREG-BQ5-wOF0.js} +1 -1
  215. package/web-shell/assets/{chunk-XXDRQBXY-77fC2yhO.js → chunk-XXDRQBXY-B_cd7BPx.js} +1 -1
  216. package/web-shell/assets/classDiagram-DTDB5LWJ-Ddllt15z.js +1 -0
  217. package/web-shell/assets/classDiagram-v2-JRS7N3AN-Ddllt15z.js +1 -0
  218. package/web-shell/assets/{cose-bilkent-JH36ORCC-D8wAcp8A.js → cose-bilkent-JH36ORCC-CAiLiU7V.js} +1 -1
  219. package/web-shell/assets/{cynefin-OW5HDTMX-BJ8GE9ke.js → cynefin-OW5HDTMX-BHVuDWAy.js} +1 -1
  220. package/web-shell/assets/{cynefinDiagram-5FMLGOSQ-GkGs0eKI.js → cynefinDiagram-5FMLGOSQ-B7RgCVNb.js} +1 -1
  221. package/web-shell/assets/{dagre-3AP2YEHR-BpEWEW5z.js → dagre-3AP2YEHR-D9FS6luN.js} +1 -1
  222. package/web-shell/assets/{diagram-S7CK7UJ4-BlxnlgRc.js → diagram-S7CK7UJ4-zEeuJGre.js} +1 -1
  223. package/web-shell/assets/{diagram-UQ7AKVKN-C7GHsWL9.js → diagram-UQ7AKVKN-Cpr5Jk4R.js} +1 -1
  224. package/web-shell/assets/{diagram-VSXAHHWV-D3hpKVLF.js → diagram-VSXAHHWV-uJPNDDma.js} +1 -1
  225. package/web-shell/assets/{diagram-VX7I27RA-BC6MiCDD.js → diagram-VX7I27RA-C0-lIAbw.js} +1 -1
  226. package/web-shell/assets/{diagram-Z3DM3KII-CZa3Bkqs.js → diagram-Z3DM3KII-D_WiclBf.js} +1 -1
  227. package/web-shell/assets/{ebnfDiagram-PWID7BFC-CLsllB3m.js → ebnfDiagram-PWID7BFC-yi7C0Q-9.js} +1 -1
  228. package/web-shell/assets/{erDiagram-SSCWMZ5O-CQddqNTI.js → erDiagram-SSCWMZ5O-C3zZTYcc.js} +1 -1
  229. package/web-shell/assets/{flowDiagram-A5DVABFB-BmiG6_Vf.js → flowDiagram-A5DVABFB-CH7vBrxS.js} +1 -1
  230. package/web-shell/assets/{ganttDiagram-EL5Y4UJY-DG4Kk0LH.js → ganttDiagram-EL5Y4UJY-BUbOBENO.js} +1 -1
  231. package/web-shell/assets/{gitGraphDiagram-WWUBYQGX-D-OhJSqn.js → gitGraphDiagram-WWUBYQGX-rHWuYy3s.js} +1 -1
  232. package/web-shell/assets/{index-sGrLT23x.js → index-CP-3n0KK.js} +4 -4
  233. package/web-shell/assets/{index-B0JFcQN6.js → index-DX6oSKFm.js} +1 -1
  234. package/web-shell/assets/{infoDiagram-RXCK75RN-Bt2IvCvf.js → infoDiagram-RXCK75RN-Da23wWox.js} +1 -1
  235. package/web-shell/assets/{ishikawaDiagram-5VMMS53U-WmAboGRg.js → ishikawaDiagram-5VMMS53U-D3bWeABP.js} +1 -1
  236. package/web-shell/assets/{journeyDiagram-EYS64GPL-0a2T4kXU.js → journeyDiagram-EYS64GPL-D8_rYtJN.js} +1 -1
  237. package/web-shell/assets/{kanban-definition-3QL26DDD-DODBMpgZ.js → kanban-definition-3QL26DDD-D-RCJhRc.js} +1 -1
  238. package/web-shell/assets/{layout-B_JdvI-u.js → layout-BR5uC2Yl.js} +1 -1
  239. package/web-shell/assets/{linear-xHqgirig.js → linear--2gekFRI.js} +1 -1
  240. package/web-shell/assets/{mermaid.core-C5Wiyd_A.js → mermaid.core-BXiRaLkg.js} +6 -6
  241. package/web-shell/assets/{mindmap-definition-FBJOCRG2-82b9AN-1.js → mindmap-definition-FBJOCRG2-Ca2xMIbh.js} +1 -1
  242. package/web-shell/assets/{pegDiagram-XKGWAZYB-DwWPrcnw.js → pegDiagram-XKGWAZYB-tFZsMAqF.js} +1 -1
  243. package/web-shell/assets/{pieDiagram-E7YTZNPT-DejgyGjA.js → pieDiagram-E7YTZNPT-DMuoAkC8.js} +1 -1
  244. package/web-shell/assets/{quadrantDiagram-AXDQQJYC-B9FLrff9.js → quadrantDiagram-AXDQQJYC-d04LyzUm.js} +1 -1
  245. package/web-shell/assets/{railroadDiagram-O6MQD6OU-Cn1LIRoy.js → railroadDiagram-O6MQD6OU-DkPIBPIK.js} +1 -1
  246. package/web-shell/assets/{requirementDiagram-EFPCY7ZU-6y8h-taP.js → requirementDiagram-EFPCY7ZU-DRqcud--.js} +1 -1
  247. package/web-shell/assets/{sankeyDiagram-P5KCCOFB-CyQ6-9X9.js → sankeyDiagram-P5KCCOFB-CkCaa1Gw.js} +1 -1
  248. package/web-shell/assets/{sequenceDiagram-WJ2MYXX4-JvE1JsEt.js → sequenceDiagram-WJ2MYXX4-Cbu6abLm.js} +1 -1
  249. package/web-shell/assets/{sizeCapture-X5ZJPWSS-DBoI4pWa.js → sizeCapture-X5ZJPWSS-9VhGitc0.js} +1 -1
  250. package/web-shell/assets/{stateDiagram-HBIQ2CUA-BARN0L2r.js → stateDiagram-HBIQ2CUA-aNQhzPd0.js} +1 -1
  251. package/web-shell/assets/stateDiagram-v2-4QOOHH4V-6ss-fTD3.js +1 -0
  252. package/web-shell/assets/{swimlanes-XN3QIQJK-CifCu0R8.js → swimlanes-XN3QIQJK-nPL9Zzrp.js} +1 -1
  253. package/web-shell/assets/swimlanesDiagram-VK2B7HYN-B4fn5O6-.js +8 -0
  254. package/web-shell/assets/{timeline-definition-24CTP7MA-DdyCazJx.js → timeline-definition-24CTP7MA-B_9JC2QK.js} +1 -1
  255. package/web-shell/assets/{vennDiagram-4TSXK5OY-DzC5W58T.js → vennDiagram-4TSXK5OY-DDOYzZme.js} +1 -1
  256. package/web-shell/assets/{wardleyDiagram-VM6X3IG4-eoAJEsbS.js → wardleyDiagram-VM6X3IG4-JhSGxhg5.js} +1 -1
  257. package/web-shell/assets/{xychartDiagram-S5SC5T6Z-DuBAVjyu.js → xychartDiagram-S5SC5T6Z-DmRpSXqq.js} +1 -1
  258. package/web-shell/index.html +1 -1
  259. package/web-shell/sw.js +1 -1
  260. package/web-shell/assets/channel-Cg-ZeYBO.js +0 -1
  261. package/web-shell/assets/classDiagram-DTDB5LWJ-BD8WT9JD.js +0 -1
  262. package/web-shell/assets/classDiagram-v2-JRS7N3AN-BD8WT9JD.js +0 -1
  263. package/web-shell/assets/stateDiagram-v2-4QOOHH4V-CVlfiijp.js +0 -1
  264. package/web-shell/assets/swimlanesDiagram-VK2B7HYN-DXpMpp5w.js +0 -8
@@ -1091,7 +1091,7 @@ ${n}`:n}function xQ(e){const t=e.data.indexOf(","),n=e.data.startsWith("data:")&
1091
1091
  </head><body><iframe title="${G3(t)}" src="${G3(e.href)}" sandbox="allow-scripts allow-same-origin allow-forms" referrerpolicy="no-referrer"></iframe></body></html>`}function GG(e,t){const n=qP(t);if(KG.has(n))return"Audio";switch(n){case".htm":case".html":return"HTML";case".md":case".markdown":case".mdx":return"Markdown";case".pdf":return"PDF";case".avif":case".bmp":case".gif":case".ico":case".jpeg":case".jpg":case".png":case".svg":case".webp":return"Image";case".mov":case".mp4":case".webm":return"Video";case".doc":case".docx":case".docm":case".dotx":case".odt":return"Word";case".xls":case".xlsx":case".xlsm":case".xlsb":case".ods":return"Excel";case".ppt":case".pptx":case".pptm":case".odp":return"PowerPoint";case".csv":return"CSV"}switch(e){case"html":return"HTML";case"pdf":return"PDF";case"notebook":return"Notebook";case"document":return"Document";default:return e||"artifact"}}const rVe=new Set([".doc",".docx",".docm",".dotx",".xls",".xlsx",".xlsm",".xlsb",".ppt",".pptx",".pptm",".odt",".ods",".odp"]),KG=new Set([".m4a",".mp3",".ogg",".wav"]),oVe=new Set([...rVe,...KG,".pdf",".mp4",".mov",".webm"]);function swe(e){const t=qP(e.workspacePath),n=ub(e.mimeType);return t===".svg"||n==="image/svg+xml"||oVe.has(t)?!0:owe(e)||t===".md"||t===".markdown"||t===".html"||t===".htm"||n==="text/markdown"||n==="text/html"?!1:e.kind==="image"||e.kind==="document"||e.kind==="pdf"||e.kind==="video"||e.kind==="audio"}function qP(e){const n=(e??"").split(/[?#]/,1)[0].split(/[/\\]/).pop()??"",s=n.lastIndexOf(".");return s>=0?n.slice(s).toLowerCase():""}function iVe(e,t){return KG.has(qP(e))||ub(t).startsWith("audio/")}const aVe="o1code.workspace.sha256";function xte(e){const t=e.metadata?.[aVe],n=typeof t=="string"?t:"";return`${e.status}:${e.updatedAt}:${n}`}function lVe(e){const t=e.metadata?.artifactType;return typeof t=="string"&&t?t:GG(e.kind,e.workspacePath??e.url??e.title)}function VP(e){return e===void 0?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}const rwe={avif:"image/avif",bmp:"image/bmp",gif:"image/gif",ico:"image/x-icon",jpeg:"image/jpeg",jpg:"image/jpeg",png:"image/png",webp:"image/webp"},cVe=100*1024*1024,uVe=256*1024;function ub(e){return e?.split(";",1)[0]?.trim().toLowerCase()??""}function owe(e){const t=ub(e.mimeType);return t.startsWith("image/")?t==="image/jpg"?"image/jpeg":Object.values(rwe).includes(t)?t:void 0:FS(e.workspacePath??"")}function FS(e){const t=e.toLowerCase(),n=t.includes(".")?t.split(".").pop():void 0;return n?rwe[n]:void 0}function dVe(e){return/\.html?$/i.test(e)?"text/html":"text/markdown"}async function _4(e,t,n,s){const r=[],o=s.maxBytes??cVe,i=await s.statFile(t);if(s.isCancelled?.())throw new Error("File loading was cancelled.");if(i.type==="directory")throw new Error("Directories cannot be opened or downloaded as artifacts.");if(i.sizeBytes>o)throw new Error("File is too large to preview or download.");let l=0;for(;;){if(s.isCancelled?.())throw new Error("File loading was cancelled.");const c=await e(t,{offset:l,maxBytes:uVe});if(s.isCancelled?.())throw new Error("File loading was cancelled.");if(c.sizeBytes!==i.sizeBytes)throw new Error("File changed while loading. Please retry.");if(c.returnedBytes<=0&&l<i.sizeBytes)throw new Error("File loading made no progress.");const u=atob(c.contentBase64),h=new Uint8Array(u.length);for(let f=0;f<u.length;f++)h[f]=u.charCodeAt(f);if(r.push(h),l=c.offset+c.returnedBytes,l>=i.sizeBytes){const f=await s.statFile(t);if(s.isCancelled?.())throw new Error("File loading was cancelled.");if(f.sizeBytes!==i.sizeBytes||f.modifiedMs!==i.modifiedMs)throw new Error("File changed while loading. Please retry.");return new Blob(r,{type:n})}}}async function GP(e,t,n="application/octet-stream",s){const r=await _4((i,l)=>e.readFileBytes(i,l),t,n,{statFile:i=>e.stat(i),isCancelled:s}),o=URL.createObjectURL(r);try{const i=document.createElement("a");i.href=o,i.download=db(t).split("/").at(-1)??t,document.body.appendChild(i),i.click(),i.remove()}finally{URL.revokeObjectURL(o)}}function iwe(e){return e.workspacePath??e.url??e.managedId??""}function db(e){const t=(e??"").replaceAll("\\","/").replace(/^\.\//,"").replace(/\/+$/,""),n=t.startsWith("/"),s=[];for(const o of t.split("/"))if(!(!o||o===".")){if(o===".."){s.length>0&&s.at(-1)!==".."?s.pop():n||s.push(o);continue}s.push(o)}const r=s.join("/");return n?`/${r}`:r}function $E(e,t){const n=db(e),s=db(t);if(!s)return n;if(n===s)return n.split("/").pop()??n;const r=`${s}/`;return n.startsWith(r)?n.slice(r.length):n}function YG(e,t,n){const s=$E(e??"",n),r=$E(t??"",n);return!!s&&s===r}const xH="default-src 'none'; base-uri 'none'; form-action 'none'; script-src 'unsafe-inline' data:; style-src 'unsafe-inline' data:; img-src data: blob:; font-src data:; media-src data:;";function awe(e,t){return kH(_H(e),t)}function kH(e,t){return`<!doctype html><html><head>
1092
1092
  <meta http-equiv="Content-Security-Policy" content="${xH} frame-src 'none';">
1093
1093
  <style>html,body,iframe{width:100%;height:100%;margin:0;border:0;display:block;overflow:hidden}</style>
1094
- </head><body><iframe title="${G3(t)}" sandbox="allow-scripts" referrerpolicy="no-referrer" srcdoc="${G3(e)}"></iframe></body></html>`}let Mj;async function hVe(e,t,n){if(Mj?.content===e&&Mj.title===t)return Mj.document;const s=await fVe(e,t,n);return Mj={content:e,title:t,document:s},s}async function fVe(e,t,n){if(typeof DOMParser>"u")return awe(e,t);const s=new DOMParser().parseFromString(e,"text/html");if(!s.querySelector('script#transcript-document[type="application/json"]'))return kH(_H(s),t);const r=new AbortController,o=()=>r.abort();n.addEventListener("abort",o,{once:!0}),n.aborted&&r.abort();try{await Promise.all([["script#transcript-renderer","src","js","text/javascript"],['link#transcript-stylesheet[rel="stylesheet"]',"href","css","text/css"]].map(async([i,l,c,u])=>{const h=s.querySelector(i),f=h?.getAttribute(l)??"",m=h?.getAttribute("integrity")??"";if(!h)return;const g=`https://unpkg.com/@organizaone/o1-code@0.21.2/export-transcript-document.${c}`;if(f!==g||!/^sha384-[A-Za-z0-9+/]{64}$/.test(m))throw new Error("Unsupported export preview resource; use an export matching the current Web Shell version.");const w=await fetch(f,{integrity:m,signal:r.signal,credentials:"omit",referrerPolicy:"no-referrer",redirect:"error"});if(!w.ok)throw new Error(`Could not load export renderer (${w.status}).`);const y=new Blob([await w.arrayBuffer()],{type:u}),x=await new Promise((k,_)=>{const S=new FileReader;S.onload=()=>k(S.result),S.onerror=()=>_(S.error),S.readAsDataURL(y)});h.setAttribute(l,x),h.removeAttribute("integrity"),h.removeAttribute("crossorigin")}))}finally{n.removeEventListener("abort",o),r.abort()}return kH(_H(s),t)}function _H(e){if(typeof e=="string"&&typeof DOMParser>"u")return`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="${xH}"></head><body>${pVe(e)}</body></html>`;const t=typeof e=="string"?new DOMParser().parseFromString(e,"text/html"):e;t.querySelectorAll('noscript, meta[http-equiv="refresh" i], meta[http-equiv="Content-Security-Policy" i]').forEach(s=>s.remove());const n=t.createElement("meta");return n.httpEquiv="Content-Security-Policy",n.content=xH,t.head.prepend(n),`<!doctype html>${t.documentElement.outerHTML}`}function pVe(e){return e.replace(/<noscript\b[^>]*>[\s\S]*?<\/noscript>/gi,"").replace(/<meta\b(?=[^>]*\bhttp-equiv\s*=\s*["']?refresh["']?)[^>]*>/gi,"").replace(/<meta\b(?=[^>]*\bhttp-equiv\s*=\s*["']?Content-Security-Policy["']?)[^>]*>/gi,"")}const lwe={csv:Gqe,file:Kqe,html:Yqe,image:Xqe,link:Zqe,md:Jqe,pdf:Qqe,spreadsheet:eVe,video:tVe,word:nVe},mVe={csv:"csv",html:"html",image:"image",link:"link",markdown:"md",md:"md",pdf:"pdf",spreadsheet:"spreadsheet",video:"video",word:"word"},gVe={audio:HG,document:k4,notebook:_We},kte={avif:"image",bmp:"image",csv:"csv",doc:"word",docm:"word",docx:"word",dotx:"word",gif:"image",htm:"html",html:"html",ico:"image",jpeg:"image",jpg:"image",md:"md",markdown:"md",mdx:"md",mov:"video",mp4:"video",ods:"spreadsheet",odt:"word",pdf:"pdf",png:"image",svg:"image",webm:"video",webp:"image",xls:"spreadsheet",xlsb:"spreadsheet",xlsm:"spreadsheet",xlsx:"spreadsheet"};function cwe(e){if(!e)return"file";const t=e.workspacePath??e.url??e.title,n=qP(t).slice(1);if(n&&kte[n])return kte[n];const s=ub(e.mimeType);return s==="application/pdf"?"pdf":s.startsWith("image/")?"image":s.startsWith("video/")?"video":s==="text/csv"?"csv":s.includes("spreadsheet")||s.includes("ms-excel")?"spreadsheet":s.includes("wordprocessingml")||s==="application/msword"?"word":s==="text/html"?"html":s==="text/markdown"?"md":mVe[e.kind]??"file"}function uwe({artifact:e,className:t}){const{artifact:n}=Th(),s=e?n?.renderImage?.(e):void 0;if(s!=null&&s!==!1)return s;const r=cwe(e),o=e?e.workspacePath??e.url??e.title:void 0,i=r==="file"&&e?iVe(o,e.mimeType)?"audio":e.kind:void 0,l=i?gVe[i]:void 0;return l?a.jsx(l,{className:t,"data-artifact-icon":i,"aria-hidden":"true"}):a.jsx("img",{className:t,src:lwe[r],"data-artifact-icon":r,alt:""})}const vVe=[[new Set(["json","jsonl","geojson"]),tHe],[new Set(["js","jsx","ts","tsx","mjs","cjs","css","html","htm","xml","svg","py","rb","go","rs","java","c","cc","cpp","h","hpp","sh","sql","yaml","yml","toml"]),Q8],[new Set(["zip","tar","gz","tgz","bz2","xz","7z","rar"]),eUe],[new Set(["csv","tsv","xls","xlsx","ods"]),aUe],[new Set(["ppt","pptx","odp"]),zWe],[new Set(["png","jpg","jpeg","gif","webp","bmp","ico","tif","tiff"]),Dve],[new Set(["mp3","wav","ogg","m4a","aac","flac"]),HG],[new Set(["mp4","mov","webm","avi","mkv"]),Ove],[new Set(["txt","md","mdx","log","pdf","doc","docx","rtf"]),k4]];function wVe(e,t){const n=e.split(".").pop()?.toLowerCase()??"";for(const[s,r]of vVe)if(s.has(n))return r;return t?.startsWith("image/")?Dve:t?.startsWith("audio/")?HG:t?.startsWith("video/")?Ove:t?.startsWith("text/")?k4:$ve}function U0({name:e,mimeType:t,size:n=24,absoluteStrokeWidth:s,...r}){const o=wVe(e,t),i=cwe({kind:"file",title:e.replace(/[?#]/g,"_"),mimeType:t});return i!=="file"||o===$ve?a.jsx("svg",{width:n,height:n,...r,"data-file-type-icon":i,children:a.jsx("image",{href:lwe[i],width:"100%",height:"100%"})}):a.jsx(o,{size:n,absoluteStrokeWidth:s,...r})}const yVe="_panel_19vsn_1",bVe="_floating_19vsn_16",xVe="_section_19vsn_26",kVe="_sectionHeader_19vsn_40",_Ve="_sectionHeaderRow_19vsn_59",SVe="_sectionAction_19vsn_70",CVe="_sectionContent_19vsn_111",TVe="_row_19vsn_115",IVe="_workspaceIcon_19vsn_158",RVe="_rowActionIcon_19vsn_162",EVe="_label_19vsn_168",AVe="_branchName_19vsn_173",jVe="_value_19vsn_181",NVe="_tasks_19vsn_191",MVe="_task_19vsn_191",PVe="_taskIcon_19vsn_229",LVe="_taskLabel_19vsn_240",DVe="_agentName_19vsn_248",OVe="_taskName_19vsn_249",$Ve="_agentColor_19vsn_260",BVe="_agentTag_19vsn_269",FVe="_taskStatus_19vsn_280",zVe="_statusRunning_19vsn_301",HVe="_attachmentFiles_19vsn_311",UVe="_attachmentFile_19vsn_311",WVe="_attachmentFileIcon_19vsn_344",qVe="_attachmentFileName_19vsn_348",VVe="_emptyDescription_19vsn_356",GVe="_sourceTitle_19vsn_363",Hr={panel:yVe,floating:bVe,section:xVe,sectionHeader:kVe,sectionHeaderRow:_Ve,sectionAction:SVe,sectionContent:CVe,row:TVe,workspaceIcon:IVe,rowActionIcon:RVe,label:EVe,branchName:AVe,value:jVe,tasks:NVe,task:MVe,taskIcon:PVe,taskLabel:LVe,agentName:DVe,taskName:OVe,agentColor:$Ve,agentTag:BVe,taskStatus:FVe,statusRunning:zVe,attachmentFiles:HVe,attachmentFile:UVe,attachmentFileIcon:WVe,attachmentFileName:qVe,emptyDescription:VVe,sourceTitle:GVe};function dwe({entries:e,onOpen:t}){const{t:n}=Ct();return a.jsx("ul",{className:Hr.attachmentFiles,children:e.map(s=>a.jsx("li",{children:a.jsxs("button",{type:"button",className:Hr.attachmentFile,title:wte(s),"aria-label":s.type==="source"?`${n("sources.open")} ${vte(s)}`:void 0,disabled:!t,onClick:()=>t?.(s),children:[s.type==="source"&&s.source.kind==="link"?a.jsx(Fve,{size:16,strokeWidth:1.7,className:Hr.attachmentFileIcon}):a.jsx(U0,{name:wte(s),mimeType:s.type==="attachment"?s.attachment.mimeType:void 0,size:16,strokeWidth:1.7,className:Hr.attachmentFileIcon,"aria-hidden":"true"}),a.jsx("span",{className:Hr.attachmentFileName,children:vte(s)})]})},AM(s)))})}function ow({className:e,...t}){return a.jsx("div",{"data-slot":"skeleton",className:cs("animate-pulse rounded-md bg-muted",e),...t})}function KVe(){return typeof window>"u"?!1:new URLSearchParams(window.location.search).get("addSource")==="1"}function YVe({hidden:e=!1,state:t,attachments:n=[],attachmentsLoading:s=!1,attachmentsError:r,onRetryAttachments:o,onOpen:i,retryRegistration:l,onDialogOpenChange:c,onReadImage:u,onImagePreview:h,onAttachmentPreview:f,onAttachmentPreviewError:m}){const{t:g}=Ct(),[w,y]=d.useState(!1),[x,k]=d.useState(!1);d.useEffect(()=>{e&&k(!1)},[e]),d.useEffect(()=>{k(!1),y(!1)},[t?.owner,t?.supported]),d.useEffect(()=>(c?.(x&&t?.supported===!0),()=>c?.(!1)),[x,c,t?.supported]);const _=t?.supported?t.sources:[],S=Qve(_,n);if(!t?.supported&&!S.length&&!s&&!r)return null;const I=s||t?.supported&&t.loading;return a.jsxs("section",{className:Hr.section,"aria-label":g("sources.title"),"data-testid":"sources-section",children:[a.jsxs("div",{className:Hr.sectionHeaderRow,children:[a.jsxs("h3",{className:`${Hr.sectionHeader} ${Hr.sourceTitle}`,children:[g("sources.title")," ",a.jsx("span",{className:"text-muted-foreground",children:S.length})]}),t?.supported&&KVe()&&a.jsx("button",{type:"button",className:Hr.sectionAction,"aria-label":g("sources.add"),onClick:()=>k(!0),children:a.jsx(Qf,{})})]}),l&&a.jsxs("div",{className:Hr.emptyDescription,role:"alert",children:[g("sources.registrationFailed")," ",a.jsx(Wt,{size:"sm",variant:"link",onClick:()=>void l(),children:g("common.retry")})]}),t?.supported&&t.error&&a.jsxs("div",{className:"mt-2 text-xs text-destructive",role:"alert",children:[t.error," ",a.jsx(Wt,{size:"sm",variant:"link",onClick:()=>void t.refresh(),children:g("common.retry")})]}),r&&a.jsxs("div",{className:"mt-2 text-xs text-destructive",role:"alert",children:[g("sources.attachmentsLoadFailed",{error:r})," ",a.jsx(Wt,{size:"sm",variant:"link",onClick:o,children:g("common.retry")})]}),a.jsx(dwe,{entries:w?S:S.slice(0,3),onOpen:E=>hwe(E,{onOpen:i,onReadImage:u,onImagePreview:h,onAttachmentPreview:f,onAttachmentPreviewError:m})}),I&&!S.length&&a.jsx("ul",{className:Hr.attachmentFiles,"data-testid":"environment-file-list-skeleton",role:"status","aria-label":g("common.loading"),children:[72,88,64].map(E=>a.jsxs("li",{className:Hr.attachmentFile,children:[a.jsx(ow,{className:"size-4 shrink-0 rounded-sm"}),a.jsx(ow,{className:"h-4",style:{width:`${E}%`}})]},E))}),!I&&!S.length&&t?.hydrated&&!t.error&&!r&&a.jsx("p",{className:Hr.emptyDescription,children:g("sources.empty")}),S.length>3&&a.jsx("button",{type:"button",className:Hr.attachmentFile,"aria-expanded":w,onClick:()=>y(E=>!E),children:g(w?"common.collapse":"sources.viewAll")}),x&&t?.supported&&a.jsx(XVe,{state:t,onClose:()=>k(!1)})]})}function XVe({state:e,onClose:t}){const{t:n}=Ct(),[s,r]=d.useState("workspace_file"),[o,i]=d.useState(""),[l,c]=d.useState(""),[u,h]=d.useState(""),[f,m]=d.useState(),[g,w]=d.useState(!1),y=async()=>{w(!0),m(void 0);try{const x=s==="url"?new URL(o).hostname:o.split(/[\\/]/).at(-1)||o,k=s==="workspace_file"?{type:s,workspacePath:o}:{type:s,url:o};await e.upsert({title:l.trim()||x.trim().slice(0,200),locator:k,...u?{description:u}:{}}),e.owner.isCurrent()&&t()}catch(x){e.owner.isCurrent()&&m(x instanceof Error?x.message:String(x))}finally{e.owner.isCurrent()&&w(!1)}};return a.jsx(Wa,{title:n("sources.add"),subtitle:n("sources.explanation"),onClose:t,size:"sm",children:a.jsxs("form",{className:"flex flex-col gap-3",onSubmit:x=>{x.preventDefault(),y()},children:[a.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[n("sources.type"),a.jsxs("select",{className:"h-8 rounded-lg border border-input bg-background px-2",value:s,onChange:x=>{r(x.target.value),i(""),m(void 0)},children:[a.jsx("option",{value:"workspace_file",children:n("sources.workspaceFile")}),a.jsx("option",{value:"url",children:n("sources.link")})]})]}),a.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[n("sources.location"),a.jsx(hi,{value:o,onChange:x=>i(x.target.value),required:!0,maxLength:s==="url"?2048:500,placeholder:s==="url"?"https://example.com":"docs/requirements.md"})]}),a.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[n("sources.name"),a.jsx(hi,{value:l,maxLength:200,onChange:x=>c(x.target.value)})]}),a.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[n("sources.description"),a.jsx(hi,{value:u,maxLength:1e3,onChange:x=>h(x.target.value)})]}),f&&a.jsx("div",{role:"alert",className:"text-xs text-destructive",children:f}),a.jsx(Wt,{type:"submit",disabled:g||!o,children:n("sources.add")})]})})}function hwe(e,t){if(e.type==="source"){t.onOpen?.(e.source);return}const n=e.attachment;if(n.type==="image"){t.onReadImage?.(n.attachmentId).then(s=>t.onImagePreview?.(s,n.attachmentId,{kind:"attachment",attachmentId:n.attachmentId})).catch(s=>t.onAttachmentPreviewError?.(s));return}t.onAttachmentPreview?.({name:n.attachmentId,mimeType:n.mimeType,attachmentId:n.attachmentId})}/**
1094
+ </head><body><iframe title="${G3(t)}" sandbox="allow-scripts" referrerpolicy="no-referrer" srcdoc="${G3(e)}"></iframe></body></html>`}let Mj;async function hVe(e,t,n){if(Mj?.content===e&&Mj.title===t)return Mj.document;const s=await fVe(e,t,n);return Mj={content:e,title:t,document:s},s}async function fVe(e,t,n){if(typeof DOMParser>"u")return awe(e,t);const s=new DOMParser().parseFromString(e,"text/html");if(!s.querySelector('script#transcript-document[type="application/json"]'))return kH(_H(s),t);const r=new AbortController,o=()=>r.abort();n.addEventListener("abort",o,{once:!0}),n.aborted&&r.abort();try{await Promise.all([["script#transcript-renderer","src","js","text/javascript"],['link#transcript-stylesheet[rel="stylesheet"]',"href","css","text/css"]].map(async([i,l,c,u])=>{const h=s.querySelector(i),f=h?.getAttribute(l)??"",m=h?.getAttribute("integrity")??"";if(!h)return;const g=`https://unpkg.com/@organizaone/o1-code@0.21.5/export-transcript-document.${c}`;if(f!==g||!/^sha384-[A-Za-z0-9+/]{64}$/.test(m))throw new Error("Unsupported export preview resource; use an export matching the current Web Shell version.");const w=await fetch(f,{integrity:m,signal:r.signal,credentials:"omit",referrerPolicy:"no-referrer",redirect:"error"});if(!w.ok)throw new Error(`Could not load export renderer (${w.status}).`);const y=new Blob([await w.arrayBuffer()],{type:u}),x=await new Promise((k,_)=>{const S=new FileReader;S.onload=()=>k(S.result),S.onerror=()=>_(S.error),S.readAsDataURL(y)});h.setAttribute(l,x),h.removeAttribute("integrity"),h.removeAttribute("crossorigin")}))}finally{n.removeEventListener("abort",o),r.abort()}return kH(_H(s),t)}function _H(e){if(typeof e=="string"&&typeof DOMParser>"u")return`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="${xH}"></head><body>${pVe(e)}</body></html>`;const t=typeof e=="string"?new DOMParser().parseFromString(e,"text/html"):e;t.querySelectorAll('noscript, meta[http-equiv="refresh" i], meta[http-equiv="Content-Security-Policy" i]').forEach(s=>s.remove());const n=t.createElement("meta");return n.httpEquiv="Content-Security-Policy",n.content=xH,t.head.prepend(n),`<!doctype html>${t.documentElement.outerHTML}`}function pVe(e){return e.replace(/<noscript\b[^>]*>[\s\S]*?<\/noscript>/gi,"").replace(/<meta\b(?=[^>]*\bhttp-equiv\s*=\s*["']?refresh["']?)[^>]*>/gi,"").replace(/<meta\b(?=[^>]*\bhttp-equiv\s*=\s*["']?Content-Security-Policy["']?)[^>]*>/gi,"")}const lwe={csv:Gqe,file:Kqe,html:Yqe,image:Xqe,link:Zqe,md:Jqe,pdf:Qqe,spreadsheet:eVe,video:tVe,word:nVe},mVe={csv:"csv",html:"html",image:"image",link:"link",markdown:"md",md:"md",pdf:"pdf",spreadsheet:"spreadsheet",video:"video",word:"word"},gVe={audio:HG,document:k4,notebook:_We},kte={avif:"image",bmp:"image",csv:"csv",doc:"word",docm:"word",docx:"word",dotx:"word",gif:"image",htm:"html",html:"html",ico:"image",jpeg:"image",jpg:"image",md:"md",markdown:"md",mdx:"md",mov:"video",mp4:"video",ods:"spreadsheet",odt:"word",pdf:"pdf",png:"image",svg:"image",webm:"video",webp:"image",xls:"spreadsheet",xlsb:"spreadsheet",xlsm:"spreadsheet",xlsx:"spreadsheet"};function cwe(e){if(!e)return"file";const t=e.workspacePath??e.url??e.title,n=qP(t).slice(1);if(n&&kte[n])return kte[n];const s=ub(e.mimeType);return s==="application/pdf"?"pdf":s.startsWith("image/")?"image":s.startsWith("video/")?"video":s==="text/csv"?"csv":s.includes("spreadsheet")||s.includes("ms-excel")?"spreadsheet":s.includes("wordprocessingml")||s==="application/msword"?"word":s==="text/html"?"html":s==="text/markdown"?"md":mVe[e.kind]??"file"}function uwe({artifact:e,className:t}){const{artifact:n}=Th(),s=e?n?.renderImage?.(e):void 0;if(s!=null&&s!==!1)return s;const r=cwe(e),o=e?e.workspacePath??e.url??e.title:void 0,i=r==="file"&&e?iVe(o,e.mimeType)?"audio":e.kind:void 0,l=i?gVe[i]:void 0;return l?a.jsx(l,{className:t,"data-artifact-icon":i,"aria-hidden":"true"}):a.jsx("img",{className:t,src:lwe[r],"data-artifact-icon":r,alt:""})}const vVe=[[new Set(["json","jsonl","geojson"]),tHe],[new Set(["js","jsx","ts","tsx","mjs","cjs","css","html","htm","xml","svg","py","rb","go","rs","java","c","cc","cpp","h","hpp","sh","sql","yaml","yml","toml"]),Q8],[new Set(["zip","tar","gz","tgz","bz2","xz","7z","rar"]),eUe],[new Set(["csv","tsv","xls","xlsx","ods"]),aUe],[new Set(["ppt","pptx","odp"]),zWe],[new Set(["png","jpg","jpeg","gif","webp","bmp","ico","tif","tiff"]),Dve],[new Set(["mp3","wav","ogg","m4a","aac","flac"]),HG],[new Set(["mp4","mov","webm","avi","mkv"]),Ove],[new Set(["txt","md","mdx","log","pdf","doc","docx","rtf"]),k4]];function wVe(e,t){const n=e.split(".").pop()?.toLowerCase()??"";for(const[s,r]of vVe)if(s.has(n))return r;return t?.startsWith("image/")?Dve:t?.startsWith("audio/")?HG:t?.startsWith("video/")?Ove:t?.startsWith("text/")?k4:$ve}function U0({name:e,mimeType:t,size:n=24,absoluteStrokeWidth:s,...r}){const o=wVe(e,t),i=cwe({kind:"file",title:e.replace(/[?#]/g,"_"),mimeType:t});return i!=="file"||o===$ve?a.jsx("svg",{width:n,height:n,...r,"data-file-type-icon":i,children:a.jsx("image",{href:lwe[i],width:"100%",height:"100%"})}):a.jsx(o,{size:n,absoluteStrokeWidth:s,...r})}const yVe="_panel_19vsn_1",bVe="_floating_19vsn_16",xVe="_section_19vsn_26",kVe="_sectionHeader_19vsn_40",_Ve="_sectionHeaderRow_19vsn_59",SVe="_sectionAction_19vsn_70",CVe="_sectionContent_19vsn_111",TVe="_row_19vsn_115",IVe="_workspaceIcon_19vsn_158",RVe="_rowActionIcon_19vsn_162",EVe="_label_19vsn_168",AVe="_branchName_19vsn_173",jVe="_value_19vsn_181",NVe="_tasks_19vsn_191",MVe="_task_19vsn_191",PVe="_taskIcon_19vsn_229",LVe="_taskLabel_19vsn_240",DVe="_agentName_19vsn_248",OVe="_taskName_19vsn_249",$Ve="_agentColor_19vsn_260",BVe="_agentTag_19vsn_269",FVe="_taskStatus_19vsn_280",zVe="_statusRunning_19vsn_301",HVe="_attachmentFiles_19vsn_311",UVe="_attachmentFile_19vsn_311",WVe="_attachmentFileIcon_19vsn_344",qVe="_attachmentFileName_19vsn_348",VVe="_emptyDescription_19vsn_356",GVe="_sourceTitle_19vsn_363",Hr={panel:yVe,floating:bVe,section:xVe,sectionHeader:kVe,sectionHeaderRow:_Ve,sectionAction:SVe,sectionContent:CVe,row:TVe,workspaceIcon:IVe,rowActionIcon:RVe,label:EVe,branchName:AVe,value:jVe,tasks:NVe,task:MVe,taskIcon:PVe,taskLabel:LVe,agentName:DVe,taskName:OVe,agentColor:$Ve,agentTag:BVe,taskStatus:FVe,statusRunning:zVe,attachmentFiles:HVe,attachmentFile:UVe,attachmentFileIcon:WVe,attachmentFileName:qVe,emptyDescription:VVe,sourceTitle:GVe};function dwe({entries:e,onOpen:t}){const{t:n}=Ct();return a.jsx("ul",{className:Hr.attachmentFiles,children:e.map(s=>a.jsx("li",{children:a.jsxs("button",{type:"button",className:Hr.attachmentFile,title:wte(s),"aria-label":s.type==="source"?`${n("sources.open")} ${vte(s)}`:void 0,disabled:!t,onClick:()=>t?.(s),children:[s.type==="source"&&s.source.kind==="link"?a.jsx(Fve,{size:16,strokeWidth:1.7,className:Hr.attachmentFileIcon}):a.jsx(U0,{name:wte(s),mimeType:s.type==="attachment"?s.attachment.mimeType:void 0,size:16,strokeWidth:1.7,className:Hr.attachmentFileIcon,"aria-hidden":"true"}),a.jsx("span",{className:Hr.attachmentFileName,children:vte(s)})]})},AM(s)))})}function ow({className:e,...t}){return a.jsx("div",{"data-slot":"skeleton",className:cs("animate-pulse rounded-md bg-muted",e),...t})}function KVe(){return typeof window>"u"?!1:new URLSearchParams(window.location.search).get("addSource")==="1"}function YVe({hidden:e=!1,state:t,attachments:n=[],attachmentsLoading:s=!1,attachmentsError:r,onRetryAttachments:o,onOpen:i,retryRegistration:l,onDialogOpenChange:c,onReadImage:u,onImagePreview:h,onAttachmentPreview:f,onAttachmentPreviewError:m}){const{t:g}=Ct(),[w,y]=d.useState(!1),[x,k]=d.useState(!1);d.useEffect(()=>{e&&k(!1)},[e]),d.useEffect(()=>{k(!1),y(!1)},[t?.owner,t?.supported]),d.useEffect(()=>(c?.(x&&t?.supported===!0),()=>c?.(!1)),[x,c,t?.supported]);const _=t?.supported?t.sources:[],S=Qve(_,n);if(!t?.supported&&!S.length&&!s&&!r)return null;const I=s||t?.supported&&t.loading;return a.jsxs("section",{className:Hr.section,"aria-label":g("sources.title"),"data-testid":"sources-section",children:[a.jsxs("div",{className:Hr.sectionHeaderRow,children:[a.jsxs("h3",{className:`${Hr.sectionHeader} ${Hr.sourceTitle}`,children:[g("sources.title")," ",a.jsx("span",{className:"text-muted-foreground",children:S.length})]}),t?.supported&&KVe()&&a.jsx("button",{type:"button",className:Hr.sectionAction,"aria-label":g("sources.add"),onClick:()=>k(!0),children:a.jsx(Qf,{})})]}),l&&a.jsxs("div",{className:Hr.emptyDescription,role:"alert",children:[g("sources.registrationFailed")," ",a.jsx(Wt,{size:"sm",variant:"link",onClick:()=>void l(),children:g("common.retry")})]}),t?.supported&&t.error&&a.jsxs("div",{className:"mt-2 text-xs text-destructive",role:"alert",children:[t.error," ",a.jsx(Wt,{size:"sm",variant:"link",onClick:()=>void t.refresh(),children:g("common.retry")})]}),r&&a.jsxs("div",{className:"mt-2 text-xs text-destructive",role:"alert",children:[g("sources.attachmentsLoadFailed",{error:r})," ",a.jsx(Wt,{size:"sm",variant:"link",onClick:o,children:g("common.retry")})]}),a.jsx(dwe,{entries:w?S:S.slice(0,3),onOpen:E=>hwe(E,{onOpen:i,onReadImage:u,onImagePreview:h,onAttachmentPreview:f,onAttachmentPreviewError:m})}),I&&!S.length&&a.jsx("ul",{className:Hr.attachmentFiles,"data-testid":"environment-file-list-skeleton",role:"status","aria-label":g("common.loading"),children:[72,88,64].map(E=>a.jsxs("li",{className:Hr.attachmentFile,children:[a.jsx(ow,{className:"size-4 shrink-0 rounded-sm"}),a.jsx(ow,{className:"h-4",style:{width:`${E}%`}})]},E))}),!I&&!S.length&&t?.hydrated&&!t.error&&!r&&a.jsx("p",{className:Hr.emptyDescription,children:g("sources.empty")}),S.length>3&&a.jsx("button",{type:"button",className:Hr.attachmentFile,"aria-expanded":w,onClick:()=>y(E=>!E),children:g(w?"common.collapse":"sources.viewAll")}),x&&t?.supported&&a.jsx(XVe,{state:t,onClose:()=>k(!1)})]})}function XVe({state:e,onClose:t}){const{t:n}=Ct(),[s,r]=d.useState("workspace_file"),[o,i]=d.useState(""),[l,c]=d.useState(""),[u,h]=d.useState(""),[f,m]=d.useState(),[g,w]=d.useState(!1),y=async()=>{w(!0),m(void 0);try{const x=s==="url"?new URL(o).hostname:o.split(/[\\/]/).at(-1)||o,k=s==="workspace_file"?{type:s,workspacePath:o}:{type:s,url:o};await e.upsert({title:l.trim()||x.trim().slice(0,200),locator:k,...u?{description:u}:{}}),e.owner.isCurrent()&&t()}catch(x){e.owner.isCurrent()&&m(x instanceof Error?x.message:String(x))}finally{e.owner.isCurrent()&&w(!1)}};return a.jsx(Wa,{title:n("sources.add"),subtitle:n("sources.explanation"),onClose:t,size:"sm",children:a.jsxs("form",{className:"flex flex-col gap-3",onSubmit:x=>{x.preventDefault(),y()},children:[a.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[n("sources.type"),a.jsxs("select",{className:"h-8 rounded-lg border border-input bg-background px-2",value:s,onChange:x=>{r(x.target.value),i(""),m(void 0)},children:[a.jsx("option",{value:"workspace_file",children:n("sources.workspaceFile")}),a.jsx("option",{value:"url",children:n("sources.link")})]})]}),a.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[n("sources.location"),a.jsx(hi,{value:o,onChange:x=>i(x.target.value),required:!0,maxLength:s==="url"?2048:500,placeholder:s==="url"?"https://example.com":"docs/requirements.md"})]}),a.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[n("sources.name"),a.jsx(hi,{value:l,maxLength:200,onChange:x=>c(x.target.value)})]}),a.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[n("sources.description"),a.jsx(hi,{value:u,maxLength:1e3,onChange:x=>h(x.target.value)})]}),f&&a.jsx("div",{role:"alert",className:"text-xs text-destructive",children:f}),a.jsx(Wt,{type:"submit",disabled:g||!o,children:n("sources.add")})]})})}function hwe(e,t){if(e.type==="source"){t.onOpen?.(e.source);return}const n=e.attachment;if(n.type==="image"){t.onReadImage?.(n.attachmentId).then(s=>t.onImagePreview?.(s,n.attachmentId,{kind:"attachment",attachmentId:n.attachmentId})).catch(s=>t.onAttachmentPreviewError?.(s));return}t.onAttachmentPreview?.({name:n.attachmentId,mimeType:n.mimeType,attachmentId:n.attachmentId})}/**
1095
1095
  * @license
1096
1096
  * Copyright 2026 Qwen Team
1097
1097
  * SPDX-License-Identifier: Apache-2.0
@@ -1615,7 +1615,7 @@ License: MIT
1615
1615
  })();`,qct=`<!doctype html>
1616
1616
  <html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="${Hct}"></head>
1617
1617
  <body><script>${Wct}<\/script></body></html>`;function Vct(){const e=globalThis.crypto;if(!e?.getRandomValues)throw new sr("LEGACY_SANDBOX_UNAVAILABLE","Secure random values are required by the temporary legacy sandbox");const t=new Uint32Array(4);return e.getRandomValues(t),Array.from(t,n=>n.toString(16).padStart(8,"0")).join("")}function Zse(){return new DOMException("The temporary legacy chart operation was aborted","AbortError")}function Gct(e){if(e.signal.aborted)return Promise.reject(Zse());if(!Number.isSafeInteger(e.timeoutMs)||e.timeoutMs<=0)return Promise.reject(new sr("SCHEMA_INVALID","Legacy sandbox timeout must be a positive safe integer"));if(typeof document>"u"||!document.body)return Promise.reject(new sr("LEGACY_SANDBOX_UNAVAILABLE","The temporary legacy sandbox requires a browser document body"));const t=Vct(),n=document.createElement("iframe");return n.hidden=!0,n.setAttribute("aria-hidden","true"),n.setAttribute("title","Temporary chart sandbox"),n.setAttribute("sandbox","allow-scripts"),n.srcdoc=qct,new Promise((s,r)=>{let o=!1,i=!1,l;const c=()=>{window.removeEventListener("message",m),e.signal.removeEventListener("abort",f),n.onload=null,n.onerror=null,l!==void 0&&clearTimeout(l),n.remove()},u=(g,w)=>{o||(o=!0,c(),g(w))},h=g=>{o||(o=!0,c(),r(g))},f=()=>h(Zse()),m=g=>{if(!(g.source!==n.contentWindow||!ja(g.data))&&!(g.data.channel!==xU||g.data.requestId!==t)){if(g.data.type==="error"){h(new sr("LEGACY_SANDBOX_EXECUTION_FAILED","Temporary legacy chart source failed in the isolated worker"));return}if(g.data.type==="result")try{const w=hye(g.data.option);if(!ja(w))throw new sr("SCHEMA_INVALID","Temporary legacy chart source must produce a JSON object option");u(s,w)}catch(w){h(w)}}};window.addEventListener("message",m),e.signal.addEventListener("abort",f,{once:!0}),n.onerror=()=>h(new sr("LEGACY_SANDBOX_EXECUTION_FAILED","Temporary legacy chart sandbox failed to load")),n.onload=()=>{if(!i){if(i=!0,n.onload=null,o||e.signal.aborted){f();return}n.contentWindow?.postMessage({channel:xU,type:"execute",requestId:t,source:e.source,inputData:e.inputData},"*")}},l=setTimeout(()=>h(new sr("LEGACY_SANDBOX_TIMEOUT",`Temporary legacy chart sandbox exceeded ${e.timeoutMs}ms`)),e.timeoutMs),document.body.append(n)})}var X1e=class extends Error{constructor(t,n,s){super(n,s&&"cause"in s?{cause:s.cause}:void 0);rt(this,"code");rt(this,"cause");this.name="LegacySandboxError",this.code=t,this.cause=s?.cause}},Kct=Object.freeze({maxArtifactContentBytes:5*1024*1024,maxRows:2e3,maxColumns:200,maxCells:4e4,executionTimeoutMs:5e3});function Yct(e,t){const n={...Kct,...e,...t};for(const[s,r]of Object.entries(n))if(!Number.isSafeInteger(r)||r<=0)throw new sr("SCHEMA_INVALID",`legacyArtifactLimits.${s} must be a positive safe integer`);return n}async function Z1e(e){let t;try{t=await e.resolveContent()}catch(o){throw e.signal.aborted||e.preserveLegacySandboxError&&o instanceof X1e?o:new sr("REF_RESOLUTION_FAILED",e.resolutionError,{cause:o})}if(typeof t!="string")throw new sr("SCHEMA_INVALID",e.returnTypeError);if(e.signal.aborted)throw new DOMException("The temporary legacy chart operation was aborted","AbortError");const n=$ct(t,e.limits),s=zct(e.source);if(!s)throw new sr("SCHEMA_INVALID","Temporary legacy chart source is empty after sanitization");const r=await Gct({source:s,inputData:n.source,signal:e.signal,timeoutMs:e.limits.executionTimeoutMs});return{data:n,spec:r}}async function Xct(e){return Z1e({source:e.block.source,signal:e.signal,limits:e.limits,resolveContent:()=>e.resolveArtifactContent({language:e.block.language,jobId:e.block.jobId,index:e.block.index,signal:e.signal}),resolutionError:"The temporary ChatBI ArtifactContent could not be resolved",returnTypeError:"resolveLegacyArtifactContent must return the raw CSV ArtifactContent string",preserveLegacySandboxError:e.preserveLegacySandboxError===!0})}async function Zct(e){return Z1e({source:e.block.source,signal:e.signal,limits:e.limits,resolveContent:()=>e.resolveSandboxFileContent({language:e.block.language,filePath:e.block.filePath,signal:e.signal}),resolutionError:"The temporary ChatBI sandbox file could not be resolved",returnTypeError:"resolveLegacySandboxFileContent must return a raw CSV string",preserveLegacySandboxError:e.preserveLegacySandboxError===!0})}var Jct=Object.freeze({maxRows:2e3,maxCells:4e4,maxSeries:100,maxDepth:40,maxNodes:1e5}),Qct=new Set(["angleAxis","aria","animation","animationDelay","animationDelayUpdate","animationDuration","animationDurationUpdate","animationEasing","animationEasingUpdate","animationThreshold","axisPointer","backgroundColor","blendMode","brush","calendar","color","darkMode","dataset","dataZoom","geo","grid","hoverLayerThreshold","legend","parallel","parallelAxis","polar","progressive","progressiveChunkMode","progressiveThreshold","radar","radiusAxis","series","singleAxis","stateAnimation","textStyle","title","tooltip","useUTC","visualMap","xAxis","yAxis"]),eut=new Set(["__proto__","prototype","constructor","extracsstext","renderitem","graphic","image","toolbox","dataview","transform","link","sublink","href","src","url"]),tut=/(?:url|uri|href|src|link)$/i,nut=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/,Jse=/(?:^|[\s("'=])(?:https?:|file:|ftp:|blob:|data:|javascript:|vbscript:|\/\/|image:\/\/)/i,sut=/\burl\s*\(/i,rut=/<\s*\/?\s*[a-z][^>]*>/i,out=/&(?:#\d+|#x[\da-f]+|[a-z][\da-z]+);/i,iut=/^[A-Za-z_][A-Za-z0-9_]*$/;function Ka(e){throw new sr("SCHEMA_INVALID",e)}function kU(e,t,n){for(const s of Object.keys(e))t.has(s)||Ka(`${n}.${s} is not allowed`)}function Qse(e,t){if(!Array.isArray(e)||e.length===0)return Ka(`${t} must be a non-empty array`);const n=e.map((s,r)=>typeof s!="string"||!iut.test(s)?Ka(`${t}[${r}] must be a stable ASCII identifier`):s);return new Set(n).size!==n.length?Ka(`${t} must not contain duplicate dimensions`):n}function aut(e,t){if(!ja(e)||typeof e.kind!="string")return Ka("echarts-fulldata.data must be an inline or ref dataset object");if(e.kind==="inline"){kU(e,new Set(["kind","dimensions","source"]),"echarts-fulldata.data");const n=Qse(e.dimensions,"echarts-fulldata.data.dimensions");if(!Array.isArray(e.source))return Ka("echarts-fulldata.data.source must be an array");e.source.forEach((r,o)=>{Array.isArray(r)||Ka(`echarts-fulldata.data.source[${o}] must be an array`),r.length!==n.length&&Ka(`echarts-fulldata.data.source[${o}] must contain ${n.length} cells`)});const s=wL(e.source,t,"echarts-fulldata.data.source");return{kind:"inline",dimensions:n,source:s}}if(e.kind==="ref"){if(kU(e,new Set(["kind","ref","format","dimensions"]),"echarts-fulldata.data"),typeof e.ref!="string"||e.ref.trim().length===0)return Ka("echarts-fulldata.data.ref must be a non-empty string");if(e.format!=="csv"&&e.format!=="json")return Ka("echarts-fulldata.data.format must be csv or json");const n=Qse(e.dimensions,"echarts-fulldata.data.dimensions");return{kind:"ref",ref:e.ref,format:e.format,dimensions:n}}return Ka(`Unsupported echarts-fulldata.data.kind: ${e.kind}`)}function J1e(e){const t=Array.isArray(e.title),n=t?e.title:[e.title];for(const[s,r]of n.entries()){if(!ja(r)||typeof r.text!="string")continue;const o=r.text.trim();if(o)return{index:s,isArray:t,title:r,text:o}}}function lut(e){return J1e(e)?.text}function cut(e,t){const n=J1e(e);if(!(!n||n.text!==t.trim())){if(Object.prototype.hasOwnProperty.call(n.title,"subtext")){delete n.title.text;return}if(n.isArray){e.title.splice(n.index,1);return}delete e.title}}function fb(e){return Array.isArray(e)?e.map(t=>fb(t)):ja(e)?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,fb(n)])):e}function Q1e(e,t){if(e!==void 0)return(!Array.isArray(e)||e.some(n=>typeof n!="string"||n.length===0))&&Ka(`${t} must be an array of non-empty strings`),[...e]}function wL(e,t,n){if(Array.isArray(e)||Ka(`${n} must be an array`),e.length>t.maxRows)throw new sr("LIMIT_EXCEEDED",`${n} exceeds the ${t.maxRows} row limit`);let s=0;const r=e.map((o,i)=>{if(Array.isArray(o)){const l=o.map((c,u)=>(c!==null&&!["string","number","boolean"].includes(typeof c)&&Ka(`${n}[${i}][${u}] must be a JSON scalar`),c));return s+=l.length,l}if(ja(o)){const l={};for(const[c,u]of Object.entries(o))u!==null&&!["string","number","boolean"].includes(typeof u)&&Ka(`${n}[${i}].${c} must be a JSON scalar`),l[c]=u,s+=1;return l}return Ka(`${n}[${i}] must be an array or object`)});if(s>t.maxCells)throw new sr("LIMIT_EXCEEDED",`${n} exceeds the ${t.maxCells} cell limit`);return r}function uut(e,t){if(!ja(e)||typeof e.kind!="string")return Ka("echarts.data must be an inline or ref dataset object");const n=Q1e(e.dimensions,"echarts.data.dimensions");if(e.kind==="inline"){const s=wL(e.source,t,"echarts.data.source");return n?{kind:"inline",dimensions:n,source:s}:{kind:"inline",source:s}}return e.kind==="ref"?typeof e.ref!="string"||e.ref.length===0?Ka("echarts.data.ref must be a non-empty string"):e.format!==void 0&&e.format!=="csv"&&e.format!=="json"?Ka("echarts.data.format must be csv or json"):{kind:"ref",ref:e.ref,...e.format?{format:e.format}:{},...n?{dimensions:n}:{}}:Ka(`Unsupported echarts.data.kind: ${e.kind}`)}function ere(e,t){if(nut.test(e))throw new sr("UNSAFE_SPEC",`${t} contains an ASCII control character`);const n=e.replace(/[\n\r\t]/g,""),s=e.trim();if(Jse.test(s)||Jse.test(n.trim())||sut.test(e)||rut.test(e)||out.test(e))throw new sr("UNSAFE_SPEC",`${t} contains a URL, CSS URL, or unsafe markup`)}function dut(e,t){for(const r of Object.keys(e))if(!Qct.has(r))throw new sr("UNSAFE_SPEC",`echarts.option.${r} is not allowed`);let n=0;const s=(r,o,i)=>{if(n+=1,n>t.maxNodes)throw new sr("LIMIT_EXCEEDED",`ECharts option exceeds the ${t.maxNodes} node limit`);if(i>t.maxDepth)throw new sr("LIMIT_EXCEEDED",`ECharts option exceeds the ${t.maxDepth} depth limit`);if(typeof r=="string"){ere(r,o);return}if(Array.isArray(r)){r.forEach((l,c)=>s(l,`${o}[${c}]`,i+1));return}if(ja(r))for(const[l,c]of Object.entries(r)){const u=l.toLowerCase();if(u==="formatter"){if(typeof c!="string")throw new sr("UNSAFE_SPEC",`${o}.${l} must be a string`);ere(c,`${o}.${l}`);continue}if(eut.has(u)||tut.test(l))throw new sr("UNSAFE_SPEC",`${o}.${l} is not allowed`);if(l==="type"&&c==="custom")throw new sr("UNSAFE_SPEC","Custom ECharts series are not allowed");s(c,`${o}.${l}`,i+1)}};if(s(e,"echarts.option",0),Array.isArray(e.series)&&e.series.length>t.maxSeries)throw new sr("LIMIT_EXCEEDED",`ECharts option exceeds the ${t.maxSeries} series limit`);e.dataset!==void 0&&(Array.isArray(e.dataset)?e.dataset:[e.dataset]).forEach((o,i)=>{ja(o)||Ka(`echarts.option.dataset[${i}] must be an object`),o.source!==void 0&&wL(o.source,t,`echarts.option.dataset[${i}].source`)})}function _U(e,t,n){if(!ja(e))return Ka("ECharts specification must be an object");if(Object.prototype.hasOwnProperty.call(e,"option")||Object.prototype.hasOwnProperty.call(e,"data"))return Ka("Canonical markdown-chart data must be a sibling of spec; spec must contain the ECharts option directly");const s=fb(e),r=t===void 0?void 0:uut(t,n);return r&&Object.prototype.hasOwnProperty.call(s,"dataset")?Ka("echarts.option.dataset cannot be combined with echarts.data"):(dut(s,n),{option:s,data:r})}function hut(e,t){if(!ja(e))return Ka("echarts-fulldata must contain an object");if(kU(e,new Set(["version","data","option"]),"echarts-fulldata"),e.version!==1)throw new sr("UNSUPPORTED_VERSION","Only echarts-fulldata version 1 is supported");if(!Object.prototype.hasOwnProperty.call(e,"data"))return Ka("echarts-fulldata.data is required");if(!ja(e.option))return Ka("echarts-fulldata.option must be an object");const n=aut(e.data,t);return _U(e.option,n,t)}function fut(e){const t="default"in e?e.default:e;if(!t||typeof t.init!="function")throw new sr("RUNTIME_LOAD_FAILED","The supplied ECharts runtime has no init function");return t}function tre(e,t){const n=wL(e.source,t,"resolvedDataset.source"),s=e.dimensions?Q1e(e.dimensions,"resolvedDataset.dimensions"):void 0;return s?{data:{kind:"inline",dimensions:s,source:n},option:{dimensions:s,source:n}}:{data:{kind:"inline",source:n},option:{source:n}}}var put={light:{background:"#ffffff",foreground:"#343434",legendText:"#555555",titleText:"#343434",subtext:"#aaaaaa",axisLine:"#5d666f",valueAxisLine:"#6E7079",axisLabel:"#838d95",splitLine:"#e0e6f1",splitAreaA:"rgba(250,250,250,0.2)",splitAreaB:"rgba(210,219,238,0.2)",seriesBorder:"#ffffff",pointer:"#7c8a96",tooltipBg:"#ffffff",primary:"#6250f9",palette:["#6250F9","#33AFA9","#AB7BFF","#5F99F9","#A9AFFF","#60CCC5","#C2A5FF","#8EB8FE","#E0E3FE","#98E3DD","#E8E1FA","#D7E6FF"]},dark:{background:"#0d0d0d",foreground:"#f4f7ff",legendText:"#c8cad0",titleText:"#e0e2e8",subtext:"#8a8d93",axisLine:"#555a63",valueAxisLine:"#555a63",axisLabel:"#9da1a8",splitLine:"#3a3e47",splitAreaA:"rgba(60,60,70,0.2)",splitAreaB:"rgba(80,80,90,0.2)",seriesBorder:"#2a2d35",pointer:"#6a707a",tooltipBg:"rgba(30, 32, 40, 0.95)",primary:"#8aa0ff",palette:["#8EA0FF","#61D6D1","#C8A7FF","#8EB8FE","#C7CCFF","#8DE7E2","#D8C5FF","#B8D2FF","#EEF0FF","#C2F0ED","#F0EAFE","#E8F1FF"]}};function B0(e,t){const n={...fb(e),...t};for(const[s,r]of Object.entries(e)){const o=t[s];ja(r)&&ja(o)&&(n[s]=B0(r,o))}return n}function k3(e,t){return Array.isArray(e)?e.map(n=>ja(n)?B0(t,n):n):ja(e)?B0(t,e):e??fb(t)}function exe(e){const t=n=>ja(n)?{...n,appendToBody:!1,confine:!0,enterable:!1,renderMode:"richText"}:n;return Array.isArray(e)?e.map(t):t(e)}function ZE(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function mut(e,t){const n=s=>{if(!ZE(s,"top")&&!ZE(s,"bottom"))return B0(t,s);const r=fb(t);return delete r.top,delete r.bottom,B0(r,s)};return Array.isArray(e)?e.map(s=>ja(s)?n(s):s):ja(e)?n(e):e??fb(t)}var gut=740,txe=10,nre=gut*txe/100,vut=24,wut=24,sre=16,yut=24;function nxe(e){if(typeof e=="number")return Number.isFinite(e)&&e>=0&&e<=nre?e:null;if(typeof e!="string")return null;const t=e.trim();if(t==="top")return 0;const n=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+))%$/.exec(t);if(!n)return null;const s=Number(n[1]);return Number.isFinite(s)&&s>=0&&s<=txe?nre:null}function but(e){return["text","subtext"].some(t=>typeof e[t]=="string"&&e[t].trim().length>0)}function xut(e){return e.show===!1||!but(e)?null:ZE(e,"top")?nxe(e.top):ZE(e,"bottom")?null:0}function kut(e){return e.show===!1||!ZE(e,"top")?null:nxe(e.top)}function rre(e){return Array.isArray(e)?e.filter(ja):ja(e)?[e]:[]}function _ut(e,t){const n=rre(e).flatMap(r=>{const o=xut(r);return o===null?[]:[o+vut+sre]}),s=rre(t).flatMap(r=>{const o=kut(r);return o===null?[]:[o+wut+sre]});return Math.max(yut,...n,...s)}function ore(e,t){return Array.isArray(e)?e.map((n,s)=>ja(n)?B0(t(s),n):n):ja(e)?B0(t(0),e):e}function ire(e,t){const n=typeof e.type=="string"?e.type:void 0;let s={emphasis:{focus:"series",itemStyle:{borderColor:t.seriesBorder,borderWidth:2}},labelLayout:{hideOverlap:!0}};n==="line"?s=B0(s,{lineStyle:{width:2},itemStyle:{borderWidth:1},symbol:"circle",symbolSize:4}):n==="bar"?s=B0(s,{barCategoryGap:"48%",barMaxWidth:42,itemStyle:{borderRadius:[3,3,0,0]}}):n==="pie"&&(s=B0(s,{itemStyle:{borderColor:t.seriesBorder,borderWidth:2}}));const r=B0(s,e);return Object.prototype.hasOwnProperty.call(e,"tooltip")&&(r.tooltip=exe(k3(e.tooltip,{appendToBody:!1,confine:!0,enterable:!1,renderMode:"richText"}))),r}var sxe=new Set(["pie","funnel","gauge","radar","treemap"]),Sut=new Set([...sxe,"graph","chord","themeRiver"]);function rxe(e){return Array.isArray(e.series)?e.series.filter(ja):ja(e.series)?[e.series]:[]}function Cut(e){if(Object.prototype.hasOwnProperty.call(e,"legend"))return!0;const t=rxe(e);return t.some(n=>typeof n.type=="string"&&Sut.has(n.type))?!0:t.filter(n=>typeof n.name=="string"&&n.name.trim().length>0).length>1}function Tut(e){if(!Object.prototype.hasOwnProperty.call(e,"xAxis")&&!Object.prototype.hasOwnProperty.call(e,"yAxis"))return"item";const t=rxe(e);return t.length>0&&t.every(n=>typeof n.type=="string"&&sxe.has(n.type))?"item":"axis"}function Iut(e){return e==null||e==="light"?"light":e==="dark"?"dark":void 0}function Rut(e,t="light"){const n=put[t],s=fb(e);return s.backgroundColor??=n.background,s.color??=[...n.palette],s.textStyle=k3(s.textStyle,{color:n.foreground,fontFamily:"'pingfang SC', 'helvetica neue', arial, 'hiragino sans gb', 'microsoft yahei ui', 'microsoft yahei', sans-serif"}),s.title!==void 0&&(s.title=k3(s.title,{textStyle:{color:n.titleText},subtextStyle:{color:n.subtext}})),s.tooltip=exe(k3(s.tooltip,{trigger:Tut(e),appendToBody:!1,confine:!0,enterable:!1,renderMode:"richText",backgroundColor:n.tooltipBg,borderColor:n.splitLine,borderWidth:1,padding:[8,10],textStyle:{color:n.titleText,fontSize:12},axisPointer:{lineStyle:{color:n.pointer,width:1},crossStyle:{color:n.pointer,width:1}}})),Cut(e)&&(s.legend=mut(s.legend,{type:"scroll",bottom:8,padding:[4,16],textStyle:{color:n.legendText,fontSize:12},pageIconColor:n.primary,pageIconInactiveColor:n.splitLine,pageTextStyle:{color:n.legendText}})),s.grid=k3(s.grid,{top:_ut(s.title,s.legend),right:36,bottom:48,left:24,containLabel:!0}),s.xAxis!==void 0&&(s.xAxis=ore(s.xAxis,()=>({axisLine:{show:!0,lineStyle:{color:n.axisLine}},axisTick:{show:!0,lineStyle:{color:n.axisLine}},axisLabel:{color:n.axisLabel,fontSize:12,hideOverlap:!0},splitLine:{show:!1,lineStyle:{color:n.splitLine}},splitArea:{show:!1,areaStyle:{color:[n.splitAreaA,n.splitAreaB]}},nameTextStyle:{color:n.axisLabel}}))),s.yAxis!==void 0&&(s.yAxis=ore(s.yAxis,r=>({alignTicks:!0,axisLine:{show:!1,lineStyle:{color:n.valueAxisLine}},axisTick:{show:!1,lineStyle:{color:n.valueAxisLine}},axisLabel:{color:n.axisLabel,fontSize:12,hideOverlap:!0},splitLine:{show:r===0,lineStyle:{color:n.splitLine}},splitArea:{show:!1,areaStyle:{color:[n.splitAreaA,n.splitAreaB]}},nameGap:12,nameTextStyle:{color:n.axisLabel,align:r===0?"left":"right"}}))),Array.isArray(s.series)?s.series=s.series.map(r=>ja(r)?ire(r,n):r):ja(s.series)&&(s.series=ire(s.series,n)),s}var G$={dispose(){}};function Eut(e={}){const t={...Jct,...e.limits},n=e.legacySandbox?.resolveLegacyArtifactContent,s=e.legacySandbox?.resolveLegacySandboxFileContent,r=e.legacySandbox?Yct({maxRows:t.maxRows,maxCells:t.maxCells},void 0):void 0,o=e.loadECharts??(async()=>await Je(()=>import("./index-CL4z8Fsq.js"),[])),i=async(l,c)=>{if(e.validateDataRef&&!e.validateDataRef(l.ref))throw new sr("REF_REJECTED","The host rejected the chart data reference");if(!e.resolveDataRef)throw new sr("REF_RESOLVER_MISSING","A resolveDataRef callback is required");let u;try{u=await e.resolveDataRef(l.ref,{format:l.format,dimensions:l.dimensions,signal:c})}catch(f){if(c.aborted)return;throw new sr("REF_RESOLUTION_FAILED","The chart dataset could not be resolved",{cause:f})}if(c.aborted)return;const h=u.dimensions||!l.dimensions?u:{...u,dimensions:l.dimensions};return tre(h,t).data};return{id:"echarts",aliases:["echarts-fulldata"],matchLanguage:Pct,parse(l,c){return c.language==="echarts-fulldata"?hut(l,t):_U(l,c.data,t)},parseSource(l,c){return Y1e(c.language)?{option:{},data:void 0,legacyEChartSandboxFile:Dct(c.rawLanguage??c.language,l)}:{option:{},data:void 0,legacyEChartQuery:Lct(c.language,l)}},getTitle(l){return lut(l.option)},async materialize(l,c){if(!l.legacyEChartQuery&&!l.legacyEChartSandboxFile){if(l.data?.kind==="ref"){const m=await i(l.data,c.signal);return m?{parsed:{...l,data:m},data:m}:{parsed:l,data:c.data}}return{parsed:l,data:l.data}}if(l.legacyEChartQuery&&!n)throw new sr("REF_RESOLVER_MISSING","legacySandbox is required for this temporary ChatBI query fence");if(l.legacyEChartSandboxFile&&!s)throw new sr("REF_RESOLVER_MISSING","legacySandbox is required for this temporary ChatBI sandbox-file fence");let u;try{l.legacyEChartSandboxFile?u=await Zct({block:l.legacyEChartSandboxFile,signal:c.signal,resolveSandboxFileContent:s,limits:r,preserveLegacySandboxError:e.legacySandbox!==void 0}):u=await Xct({block:l.legacyEChartQuery,signal:c.signal,resolveArtifactContent:n,limits:r,preserveLegacySandboxError:!0})}catch(m){if(c.signal.aborted)return{parsed:l,data:c.data};throw m instanceof sr||m instanceof X1e?m:new sr("REF_RESOLUTION_FAILED","The temporary ChatBI chart could not be resolved",{cause:m})}if(c.signal.aborted)return{parsed:l,data:c.data};let h;try{h=hye(u,{maxDepth:t.maxDepth,maxNodes:t.maxNodes})}catch(m){throw m instanceof sr?m:new sr("SCHEMA_INVALID","Temporary ChatBI resolver returned a non-JSON result",{cause:m})}if(!ja(h))return Ka("Temporary ChatBI resolver must return an object");if(!Object.prototype.hasOwnProperty.call(h,"data")||!Object.prototype.hasOwnProperty.call(h,"spec"))return Ka("Temporary ChatBI resolver must return data and spec");const f=_U(h.spec,h.data,t);return f.data?.kind!=="inline"?Ka("Temporary ChatBI resolver must return inline data"):{parsed:f,data:f.data}},async mount(l,c,u){if(c.legacyEChartQuery||c.legacyEChartSandboxFile)return Ka("Temporary ChatBI charts must be materialized before mounting");const h=fb(c.option);if(u.externalizedTitle&&cut(h,u.externalizedTitle),c.data){let x;if(c.data.kind==="inline")x=c.data;else{const _=await i(c.data,u.signal);if(!_)return G$;x=_}const k=tre(x,t);h.dataset=k.option}if(u.signal.aborted)return G$;let f;try{f=fut(await o())}catch(x){throw x instanceof sr?x:new sr("RUNTIME_LOAD_FAILED","The ECharts runtime could not be loaded",{cause:x})}if(u.signal.aborted)return G$;let m,g;try{const x=typeof u.theme=="string"||ja(u.theme)?u.theme:void 0;m=f.init(l,x);const k=Iut(u.theme),_=e.defaultStyle===!1||!k?h:Rut(h,k);m.setOption(_,{notMerge:!0,lazyUpdate:!1}),e.resizeObserver!==!1&&typeof ResizeObserver<"u"&&(g=new ResizeObserver(()=>m?.resize()),g.observe(l))}catch(x){try{g?.disconnect()}catch{}try{m?.dispose()}catch{}throw new sr("RENDER_FAILED","ECharts failed to render the chart",{cause:x})}const w=m;let y=!1;return{resize:()=>w.resize(),dispose(){y||(y=!0,g?.disconnect(),w.dispose())}}}}}var eY=d.createContext(null);function Aut(e){if(d.isValidElement(e))return typeof e.props.children=="string"?e.props.children:void 0}function jut(e){const t=e.source??Aut(e.children),n=d.useMemo(()=>({registry:e.registry,theme:e.theme,streaming:e.streaming??!1,source:t,loadingLabel:e.loadingLabel,labels:e.labels,onError:e.onError}),[e.registry,e.theme,e.streaming,t,e.loadingLabel,e.labels,e.onError]);return d.createElement(eY.Provider,{value:n},e.children)}function Nut(e){const t=d.useContext(eY);if(!t)throw new Error("MarkdownChartBlock must be rendered inside MarkdownChartProvider");const n=d.useRef(null),s=e.streaming??t.streaming,r=e.loadingLabel??t.loadingLabel,o=e.labels??t.labels,i=d.useMemo(()=>pye(o),[o]);d.useEffect(()=>{const c=n.current;if(!c)return;const u=new zJe(t.registry);let h=!1;return u.render(c,{language:e.language,source:e.source,theme:t.theme,streaming:s,...r!==void 0?{loadingLabel:r}:{},...o!==void 0?{labels:o}:{}}).catch(f=>{h||(c.classList.add("markdown-chart-error"),c.setAttribute("role","alert"),c.textContent=i.chartUnavailable,t.onError?.(f,{language:e.language,source:e.source}))}),()=>{h=!0,u.dispose()}},[t.registry,t.theme,t.onError,r,o,i,e.language,e.source,s]);const l=["markdown-chart-placeholder",s?"markdown-chart-streaming":void 0,e.className].filter(Boolean).join(" ");return d.createElement("div",{ref:n,className:l,style:e.style,"aria-label":i.chart,"aria-busy":s||void 0,"data-markdown-chart-complete":String(!s)})}function Mut(e,t){const n=t?.position?.start?.offset,s=t?.position?.end?.offset;if(e===void 0||n===void 0||s===void 0)return!1;const r=e.lastIndexOf(`
1618
- `,Math.max(0,n-1))+1,o=e.slice(r,n),i=/^(?: {0,3}>[ \t]?)+$/.test(o)?r:n;return gye(e.slice(i,s))||e.slice(s).trim().length>0}function oxe(e,t){return e===NM||t?.has(e)===!0}function Put(e={}){return{code({node:n,...s}){return d.createElement("code",s)},pre:function({node:s,children:r,...o}){const i=d.useContext(eY);if(d.isValidElement(r)){const l=r,u=/(?:^|\s)language-([^\s]+)/.exec(l.props.className??"")?.[1],h=u?.toLowerCase();if(u&&h&&oxe(h,i?.registry)){const f=d.Children.toArray(l.props.children).map(m=>typeof m=="string"||typeof m=="number"?String(m):"").join("");return d.createElement(Nut,{language:u,source:f,streaming:i?.streaming===!0&&!Mut(i.source,s),...e.chartClassName?{className:e.chartClassName}:{},...e.chartStyle?{style:e.chartStyle}:{}})}}return d.createElement("pre",o,r)}}}const Lut=3e4,Dut=["artifact://","session-file://"],Out=/^[a-z]:/i;function $ut(e={}){const{resolveDataRef:t,validateDataRef:n=Uut,...s}=e,r=e.validateDataRef===void 0,o=t?async(i,l)=>{const c=r?ixe(i):i;if(!c)throw new Error("Chart data reference is not supported.");return Wut(Promise.resolve(t(c,l)),"Chart data reference resolution")}:void 0;return new CJe().register(Eut({...s,resolveDataRef:o,validateDataRef:n}))}const But={registry:$ut()};function Fut(e,t={}){const n=Put(t).pre;if(!n)throw new Error("markdown-chart React adapter did not provide a pre renderer");return function({children:r,...o}){if(d.isValidElement(r)){const i=r,c=/(?:^|\s)language-([^\s]+)/.exec(i.props.className??"")?.[1]?.toLowerCase();if(c&&oxe(c,e))return d.createElement(n,o,r)}return d.createElement(d.Fragment,null,r)}}function zut({customization:e,source:t,streaming:n,theme:s,children:r}){const o=Hut(e.labels),{t:i}=Ct();return a.jsx(jut,{registry:e.registry,source:t,streaming:n,theme:s,loadingLabel:e.loadingLabel??i("echartsChart.rendering"),labels:o,onError:e.onError,children:r})}function Hut(e){const{t}=Ct();return d.useMemo(()=>({chartUnavailable:t("echartsChart.renderFailed"),viewMode:t("echartsChart.viewMode"),chart:t("echartsChart.chart"),data:t("echartsChart.data"),showChart:t("echartsChart.showChart"),showData:t("echartsChart.showData"),noData:t("echartsChart.noData"),tableNotice:({visibleRows:n,totalRows:s,visibleColumns:r,totalColumns:o})=>t("echartsChart.tableNotice",{visibleRows:n,totalRows:s,visibleColumns:r,totalColumns:o,omittedRows:s-n,omittedColumns:o-r}),...e}),[e,t])}function are(e){return/\s/.test(e)||Array.from(e).some(t=>{const n=t.codePointAt(0);return n!==void 0&&(n<=31||n===127)})}function ixe(e){if(e.trim()!==e||!e||are(e))return;const t=e.toLowerCase(),n=Dut.find(i=>t.startsWith(i));if(!n)return;const s=e.slice(n.length);if(!s||/[?#\\]/.test(s))return;let r;try{r=decodeURIComponent(s)}catch{return}if(/[%?#\\]/.test(r)||are(r))return;const o=r.split("/");if(!o.some(i=>i.length===0||i==="."||i===".."||Out.test(i)))return`${n}${o.join("/")}`}function Uut(e){return ixe(e)!==void 0}function Wut(e,t){return new Promise((n,s)=>{const r=globalThis.setTimeout(()=>s(new Error(`${t} timed out.`)),Lut);e.then(n,s).finally(()=>globalThis.clearTimeout(r))})}const qut="_content_1ns4y_1",Vut="_streamingPlainText_1ns4y_11",Gut="_inlineCode_1ns4y_135",Kut="_link_1ns4y_147",Yut="_tableWrapper_1ns4y_157",Xut="_table_1ns4y_157",Zut="_image_1ns4y_187",Jut="_codeBlock_1ns4y_195",Qut="_codeBlockHeader_1ns4y_204",edt="_codeBlockLang_1ns4y_213",tdt="_codeBlockCopy_1ns4y_221",ndt="_codeBlockContent_1ns4y_244",sdt="_codeBlockPlain_1ns4y_264",rdt="_mermaidBlock_1ns4y_282",odt="_mermaidInline_1ns4y_294",idt="_mermaidStage_1ns4y_308",adt="_mermaidLoading_1ns4y_331",ldt="_mermaidActions_1ns4y_338",cdt="_mermaidZoomWrapper_1ns4y_343",udt="_mermaidPannable_1ns4y_358",ddt="_mermaidDragging_1ns4y_362",ri={content:qut,streamingPlainText:Vut,inlineCode:Gut,link:Kut,tableWrapper:Yut,table:Xut,image:Zut,codeBlock:Jut,codeBlockHeader:Qut,codeBlockLang:edt,codeBlockCopy:tdt,codeBlockContent:ndt,codeBlockPlain:sdt,mermaidBlock:rdt,mermaidInline:odt,mermaidStage:idt,mermaidLoading:adt,mermaidActions:ldt,mermaidZoomWrapper:cdt,mermaidPannable:udt,mermaidDragging:ddt},hdt=32e3,fdt=new Set(["javascript","typescript","python","rust","go","java","c","cpp","csharp","fsharp","ruby","php","swift","kotlin","scala","bash","fish","powershell","sql","html","css","scss","json","yaml","toml","xml","markdown","dockerfile","graphql","lua","r","matlab","perl","haskell","elixir","erlang","clojure","dart","vue","svelte","astro","tsx","jsx","diff"]),lre={"c++":"cpp","c#":"csharp","f#":"fsharp",ts:"typescript",js:"javascript",py:"python",rb:"ruby",rs:"rust",kt:"kotlin",cs:"csharp",sh:"bash",zsh:"bash",shell:"bash",yml:"yaml",md:"markdown",golang:"go",ps1:"powershell",docker:"dockerfile"};function tY(e){const t=(e||"").toLowerCase(),n=Object.hasOwn(lre,t)?lre[t]:t,s=fdt.has(n)?n:"text";return{label:(e||"").trim()||"text",lang:n,resolvedLang:s}}const axe=/^(https?:|mailto:)/i,pdt=/^data:image\/(png|jpeg|gif|webp|bmp);base64,/i,lxe=/^data:image\/(png|jpeg|gif|webp);base64,[A-Za-z0-9+/]*={0,2}$/i;function N4(e){if(!e)return!1;const t=e.trim();return t?t.startsWith("#")||t.startsWith("/")&&!t.startsWith("//")?!0:axe.test(t):!1}function Ow(e,t=!1){if(!e)return!1;const n=e.trim();return n?t?lxe.test(n):n.startsWith("#")||n.startsWith("/")&&!n.startsWith("//")||pdt.test(n)?!0:axe.test(n):!1}let cre,ure=Promise.resolve(),mdt=0;const gdt=5e4,vdt=500,wdt=1e4,dre=16;function ydt({code:e}){const{t}=Ct(),n=yb(),s=Vl()!=="interactive",[r,o]=d.useState(null),[i,l]=d.useState(null),[c,u]=d.useState("diagram"),[h,f]=bx(),[m,g]=d.useState(1),[w,y]=d.useState(!1),x=d.useRef(null),[k,_]=d.useState(!1),[S,I]=d.useState(!1),[E,A]=d.useState(null),j=d.useRef(null),L=d.useRef(null),R=n==="light"?"default":"dark",N=.5,M=3,O=.25,P=()=>{g(V=>Math.min(M,Math.round((V+O)*100)/100))},F=()=>{g(V=>Math.max(N,Math.round((V-O)*100)/100))},H=d.useCallback(()=>{L.current=null,y(!1),g(1);const V=x.current;V&&(V.scrollLeft=0,V.scrollTop=0),_(!1)},[]),$=d.useCallback(V=>{const J=x.current;J&&(V.preventDefault(),y(!0),L.current={startX:V.clientX,startY:V.clientY,startLeft:J.scrollLeft,startTop:J.scrollTop})},[]),Y=d.useCallback(V=>{const{scrollLeft:J,scrollTop:q}=V.currentTarget;_(J!==0||q!==0)},[]),Z=d.useCallback(()=>{const V=x.current;V&&(I(V.scrollWidth>V.clientWidth||V.scrollHeight>V.clientHeight),_(V.scrollLeft!==0||V.scrollTop!==0))},[]),K=d.useCallback(()=>{const V=x.current,J=j.current?.querySelector("svg");if(!V||!J)return;const[,,q,te]=(J.getAttribute("viewBox")??"").split(/[\s,]+/).map(Number),ie=(J.getAttribute("width")??"").trim(),ge=Number.parseFloat(J.getAttribute("height")??""),re=q>0&&te>0,G=re?q:Number.parseFloat(ie),Q=re?te:ge;if(!(G>0)||!(Q>0)){A(null);return}const he=V.clientWidth-dre*2,ve=ie.endsWith("%")&&he>0?Math.min(G,he):G,ye=Math.max(0,V.offsetHeight-V.clientHeight);A({stageWidth:ve,canvasHeight:ve*Q/G+dre*2+ye})},[]);d.useEffect(()=>{if(!w)return;const V=q=>{const te=x.current,ie=L.current;!te||!ie||(te.scrollLeft=ie.startLeft-(q.clientX-ie.startX),te.scrollTop=ie.startTop-(q.clientY-ie.startY),_(te.scrollLeft!==0||te.scrollTop!==0))},J=()=>{L.current=null,y(!1)};return window.addEventListener("mousemove",V),window.addEventListener("mouseup",J),window.addEventListener("blur",J),()=>{window.removeEventListener("mousemove",V),window.removeEventListener("mouseup",J),window.removeEventListener("blur",J)}},[w]),d.useEffect(()=>{H()},[e,H]),d.useLayoutEffect(()=>{K(),Z()},[r,m,c,K,Z]),d.useEffect(()=>{const V=x.current;if(!V)return;const J=new ResizeObserver(()=>{K(),Z()});return J.observe(V),()=>J.disconnect()},[r,c,K,Z]),d.useEffect(()=>{let V=!1;o(null),l(null);const J=setTimeout(()=>{Je(()=>import("./mermaid.core-C5Wiyd_A.js").then(q=>q.cb),[]).then(async q=>{if(V)return;const te=q.default,ie=`${R}:${s?"hardened":"runtime"}`,ge=ure.then(async()=>{if(V)throw new Error("Mermaid render skipped");cre!==ie&&(te.initialize({startOnLoad:!1,theme:R,securityLevel:"strict",suppressErrorRendering:!0,...s?{maxTextSize:gdt,maxEdges:vdt}:{},flowchart:{wrappingWidth:300,useMaxWidth:!1}}),cre=ie);const G=`mermaid-${++mdt}`;if(!s)return te.render(G,e.trim());let Q;try{return await Promise.race([te.render(G,e.trim()),new Promise((he,ve)=>{Q=setTimeout(()=>ve(new Error("Mermaid render timed out")),wdt)})])}finally{Q!==void 0&&clearTimeout(Q)}});ure=ge.then(()=>{},()=>{});const{svg:re}=await ge;V||o(re)}).catch(q=>{V||l(q instanceof Error?q.message:"Mermaid render failed")})},150);return()=>{V=!0,clearTimeout(J)}},[e,s,R]);const B=()=>{Yf(e).then(()=>{f()}).catch(W0)};return i?a.jsxs("div",{className:ri.codeBlock,children:[a.jsx("div",{className:ri.codeBlockHeader,children:a.jsx("span",{className:ri.codeBlockLang,children:t("mermaid.errorLabel")})}),a.jsx("pre",{className:`${ri.codeBlockContent} ${ri.codeBlockPlain}`,children:a.jsx("code",{children:e})})]}):a.jsxs("div",{className:ri.codeBlock,children:[a.jsxs("div",{className:ri.codeBlockHeader,children:[a.jsx("span",{className:ri.codeBlockLang,children:t("mermaid.label")}),a.jsxs("span",{className:ri.mermaidActions,children:[c==="diagram"&&a.jsxs(a.Fragment,{children:[a.jsx("button",{className:ri.codeBlockCopy,onClick:F,title:t("mermaid.zoomOut"),disabled:m<=N,children:t("mermaid.zoomOut")}),a.jsx("button",{className:ri.codeBlockCopy,onClick:H,title:t("mermaid.zoomReset"),disabled:m===1&&!k,children:t("mermaid.zoomReset")}),a.jsx("button",{className:ri.codeBlockCopy,onClick:P,title:t("mermaid.zoomIn"),disabled:m>=M,children:t("mermaid.zoomIn")})]}),a.jsx("button",{className:ri.codeBlockCopy,onClick:()=>u(c==="diagram"?"code":"diagram"),children:t(c==="diagram"?"mermaid.viewCode":"mermaid.viewDiagram")}),a.jsx("button",{className:ri.codeBlockCopy,onClick:B,children:t(h?"code.copied":"code.copy")})]})]}),c==="code"?a.jsx("pre",{className:`${ri.codeBlockContent} ${ri.codeBlockPlain}`,children:a.jsx("code",{children:e})}):r?a.jsx("div",{className:`${ri.mermaidZoomWrapper} ${S?ri.mermaidPannable:""} ${S&&w?ri.mermaidDragging:""}`,ref:x,style:E?{height:E.canvasHeight}:void 0,onMouseDown:$,onDoubleClick:H,onScroll:Y,children:a.jsx("div",{className:`${ri.mermaidBlock} ${ri.mermaidStage}`,ref:j,style:{...E?{width:E.stageWidth}:{},...m===1?{}:{zoom:m}},dangerouslySetInnerHTML:{__html:r}})}):a.jsx("div",{className:`${ri.mermaidBlock} ${ri.mermaidLoading} ${ri.mermaidInline}`,children:a.jsx("span",{children:t("mermaid.rendering")})})]})}function bdt({className:e,children:t,isStreaming:n}){const{t:s}=Ct(),r=yb(),o=Vl()==="document",[i,l]=d.useState(null),[c,u]=bx(),{label:h,lang:f,resolvedLang:m}=tY(cxe(e)),g=String(t).replace(/\n$/,""),w=r==="light"?"github-light-default":"github-dark-default";d.useEffect(()=>{if(o||n||f==="mermaid"||m==="text"||vU(g)){l(null);return}const x=pat(g,m,w);if(x!==null){l(x);return}const k=zse(g,m,w,!0);if(k!==null){l(k);return}l(null);let _=!1;return N1e(m).then(()=>{if(_)return;const S=zse(g,m,w,!0);S!==null&&l(S)}).catch(S=>{_||(console.warn("[web-shell] highlight failed for lang=%s",m,S),l(null))}),()=>{_=!0}},[g,o,f,m,w,n]);const y=()=>{Yf(g).then(()=>{u()}).catch(W0)};return f==="mermaid"&&!n&&!o?a.jsx(ydt,{code:g}):a.jsxs("div",{className:ri.codeBlock,children:[a.jsxs("div",{className:ri.codeBlockHeader,children:[a.jsx("span",{className:ri.codeBlockLang,children:h}),a.jsx("button",{className:ri.codeBlockCopy,onClick:y,children:s(c?"code.copied":"code.copy")})]}),!o&&!n&&i!==null?a.jsx("div",{className:ri.codeBlockContent,dangerouslySetInnerHTML:{__html:i}}):a.jsx("pre",{className:`${ri.codeBlockContent} ${ri.codeBlockPlain}`,children:a.jsx("code",{children:g})})]})}function cxe(e){const t=e?.match(/(?:^|\s)language-([^\s]+)/)?.[1]??"",n=t.match(/^([\w+.#-]+)/);if(!n)return"";const s=n[1]??"",r=t[s.length];return!r||r==="{"||r===":"?s:""}function xdt({children:e}){return a.jsx("code",{className:ri.inlineCode,children:e})}function hre({children:e}){return a.jsx("div",{className:ri.tableWrapper,children:a.jsx("table",{className:ri.table,children:e})})}const uxe=d.createContext(!1),dxe=d.createContext(void 0),hxe=d.createContext(void 0);function kdt(e,t,n){if(!n||e===void 0)return!1;const s=t?.position?.start.offset,r=t?.position?.end.offset;return s===void 0||r===void 0?!1:!gye(e.slice(s,r))&&e.slice(r).trim().length===0}function _dt({className:e,children:t,node:n}){const s=d.useContext(uxe),r=d.useContext(hxe);return e?.startsWith("language-")||typeof t=="string"&&t.includes(`
1618
+ `,Math.max(0,n-1))+1,o=e.slice(r,n),i=/^(?: {0,3}>[ \t]?)+$/.test(o)?r:n;return gye(e.slice(i,s))||e.slice(s).trim().length>0}function oxe(e,t){return e===NM||t?.has(e)===!0}function Put(e={}){return{code({node:n,...s}){return d.createElement("code",s)},pre:function({node:s,children:r,...o}){const i=d.useContext(eY);if(d.isValidElement(r)){const l=r,u=/(?:^|\s)language-([^\s]+)/.exec(l.props.className??"")?.[1],h=u?.toLowerCase();if(u&&h&&oxe(h,i?.registry)){const f=d.Children.toArray(l.props.children).map(m=>typeof m=="string"||typeof m=="number"?String(m):"").join("");return d.createElement(Nut,{language:u,source:f,streaming:i?.streaming===!0&&!Mut(i.source,s),...e.chartClassName?{className:e.chartClassName}:{},...e.chartStyle?{style:e.chartStyle}:{}})}}return d.createElement("pre",o,r)}}}const Lut=3e4,Dut=["artifact://","session-file://"],Out=/^[a-z]:/i;function $ut(e={}){const{resolveDataRef:t,validateDataRef:n=Uut,...s}=e,r=e.validateDataRef===void 0,o=t?async(i,l)=>{const c=r?ixe(i):i;if(!c)throw new Error("Chart data reference is not supported.");return Wut(Promise.resolve(t(c,l)),"Chart data reference resolution")}:void 0;return new CJe().register(Eut({...s,resolveDataRef:o,validateDataRef:n}))}const But={registry:$ut()};function Fut(e,t={}){const n=Put(t).pre;if(!n)throw new Error("markdown-chart React adapter did not provide a pre renderer");return function({children:r,...o}){if(d.isValidElement(r)){const i=r,c=/(?:^|\s)language-([^\s]+)/.exec(i.props.className??"")?.[1]?.toLowerCase();if(c&&oxe(c,e))return d.createElement(n,o,r)}return d.createElement(d.Fragment,null,r)}}function zut({customization:e,source:t,streaming:n,theme:s,children:r}){const o=Hut(e.labels),{t:i}=Ct();return a.jsx(jut,{registry:e.registry,source:t,streaming:n,theme:s,loadingLabel:e.loadingLabel??i("echartsChart.rendering"),labels:o,onError:e.onError,children:r})}function Hut(e){const{t}=Ct();return d.useMemo(()=>({chartUnavailable:t("echartsChart.renderFailed"),viewMode:t("echartsChart.viewMode"),chart:t("echartsChart.chart"),data:t("echartsChart.data"),showChart:t("echartsChart.showChart"),showData:t("echartsChart.showData"),noData:t("echartsChart.noData"),tableNotice:({visibleRows:n,totalRows:s,visibleColumns:r,totalColumns:o})=>t("echartsChart.tableNotice",{visibleRows:n,totalRows:s,visibleColumns:r,totalColumns:o,omittedRows:s-n,omittedColumns:o-r}),...e}),[e,t])}function are(e){return/\s/.test(e)||Array.from(e).some(t=>{const n=t.codePointAt(0);return n!==void 0&&(n<=31||n===127)})}function ixe(e){if(e.trim()!==e||!e||are(e))return;const t=e.toLowerCase(),n=Dut.find(i=>t.startsWith(i));if(!n)return;const s=e.slice(n.length);if(!s||/[?#\\]/.test(s))return;let r;try{r=decodeURIComponent(s)}catch{return}if(/[%?#\\]/.test(r)||are(r))return;const o=r.split("/");if(!o.some(i=>i.length===0||i==="."||i===".."||Out.test(i)))return`${n}${o.join("/")}`}function Uut(e){return ixe(e)!==void 0}function Wut(e,t){return new Promise((n,s)=>{const r=globalThis.setTimeout(()=>s(new Error(`${t} timed out.`)),Lut);e.then(n,s).finally(()=>globalThis.clearTimeout(r))})}const qut="_content_1ns4y_1",Vut="_streamingPlainText_1ns4y_11",Gut="_inlineCode_1ns4y_135",Kut="_link_1ns4y_147",Yut="_tableWrapper_1ns4y_157",Xut="_table_1ns4y_157",Zut="_image_1ns4y_187",Jut="_codeBlock_1ns4y_195",Qut="_codeBlockHeader_1ns4y_204",edt="_codeBlockLang_1ns4y_213",tdt="_codeBlockCopy_1ns4y_221",ndt="_codeBlockContent_1ns4y_244",sdt="_codeBlockPlain_1ns4y_264",rdt="_mermaidBlock_1ns4y_282",odt="_mermaidInline_1ns4y_294",idt="_mermaidStage_1ns4y_308",adt="_mermaidLoading_1ns4y_331",ldt="_mermaidActions_1ns4y_338",cdt="_mermaidZoomWrapper_1ns4y_343",udt="_mermaidPannable_1ns4y_358",ddt="_mermaidDragging_1ns4y_362",ri={content:qut,streamingPlainText:Vut,inlineCode:Gut,link:Kut,tableWrapper:Yut,table:Xut,image:Zut,codeBlock:Jut,codeBlockHeader:Qut,codeBlockLang:edt,codeBlockCopy:tdt,codeBlockContent:ndt,codeBlockPlain:sdt,mermaidBlock:rdt,mermaidInline:odt,mermaidStage:idt,mermaidLoading:adt,mermaidActions:ldt,mermaidZoomWrapper:cdt,mermaidPannable:udt,mermaidDragging:ddt},hdt=32e3,fdt=new Set(["javascript","typescript","python","rust","go","java","c","cpp","csharp","fsharp","ruby","php","swift","kotlin","scala","bash","fish","powershell","sql","html","css","scss","json","yaml","toml","xml","markdown","dockerfile","graphql","lua","r","matlab","perl","haskell","elixir","erlang","clojure","dart","vue","svelte","astro","tsx","jsx","diff"]),lre={"c++":"cpp","c#":"csharp","f#":"fsharp",ts:"typescript",js:"javascript",py:"python",rb:"ruby",rs:"rust",kt:"kotlin",cs:"csharp",sh:"bash",zsh:"bash",shell:"bash",yml:"yaml",md:"markdown",golang:"go",ps1:"powershell",docker:"dockerfile"};function tY(e){const t=(e||"").toLowerCase(),n=Object.hasOwn(lre,t)?lre[t]:t,s=fdt.has(n)?n:"text";return{label:(e||"").trim()||"text",lang:n,resolvedLang:s}}const axe=/^(https?:|mailto:)/i,pdt=/^data:image\/(png|jpeg|gif|webp|bmp);base64,/i,lxe=/^data:image\/(png|jpeg|gif|webp);base64,[A-Za-z0-9+/]*={0,2}$/i;function N4(e){if(!e)return!1;const t=e.trim();return t?t.startsWith("#")||t.startsWith("/")&&!t.startsWith("//")?!0:axe.test(t):!1}function Ow(e,t=!1){if(!e)return!1;const n=e.trim();return n?t?lxe.test(n):n.startsWith("#")||n.startsWith("/")&&!n.startsWith("//")||pdt.test(n)?!0:axe.test(n):!1}let cre,ure=Promise.resolve(),mdt=0;const gdt=5e4,vdt=500,wdt=1e4,dre=16;function ydt({code:e}){const{t}=Ct(),n=yb(),s=Vl()!=="interactive",[r,o]=d.useState(null),[i,l]=d.useState(null),[c,u]=d.useState("diagram"),[h,f]=bx(),[m,g]=d.useState(1),[w,y]=d.useState(!1),x=d.useRef(null),[k,_]=d.useState(!1),[S,I]=d.useState(!1),[E,A]=d.useState(null),j=d.useRef(null),L=d.useRef(null),R=n==="light"?"default":"dark",N=.5,M=3,O=.25,P=()=>{g(V=>Math.min(M,Math.round((V+O)*100)/100))},F=()=>{g(V=>Math.max(N,Math.round((V-O)*100)/100))},H=d.useCallback(()=>{L.current=null,y(!1),g(1);const V=x.current;V&&(V.scrollLeft=0,V.scrollTop=0),_(!1)},[]),$=d.useCallback(V=>{const J=x.current;J&&(V.preventDefault(),y(!0),L.current={startX:V.clientX,startY:V.clientY,startLeft:J.scrollLeft,startTop:J.scrollTop})},[]),Y=d.useCallback(V=>{const{scrollLeft:J,scrollTop:q}=V.currentTarget;_(J!==0||q!==0)},[]),Z=d.useCallback(()=>{const V=x.current;V&&(I(V.scrollWidth>V.clientWidth||V.scrollHeight>V.clientHeight),_(V.scrollLeft!==0||V.scrollTop!==0))},[]),K=d.useCallback(()=>{const V=x.current,J=j.current?.querySelector("svg");if(!V||!J)return;const[,,q,te]=(J.getAttribute("viewBox")??"").split(/[\s,]+/).map(Number),ie=(J.getAttribute("width")??"").trim(),ge=Number.parseFloat(J.getAttribute("height")??""),re=q>0&&te>0,G=re?q:Number.parseFloat(ie),Q=re?te:ge;if(!(G>0)||!(Q>0)){A(null);return}const he=V.clientWidth-dre*2,ve=ie.endsWith("%")&&he>0?Math.min(G,he):G,ye=Math.max(0,V.offsetHeight-V.clientHeight);A({stageWidth:ve,canvasHeight:ve*Q/G+dre*2+ye})},[]);d.useEffect(()=>{if(!w)return;const V=q=>{const te=x.current,ie=L.current;!te||!ie||(te.scrollLeft=ie.startLeft-(q.clientX-ie.startX),te.scrollTop=ie.startTop-(q.clientY-ie.startY),_(te.scrollLeft!==0||te.scrollTop!==0))},J=()=>{L.current=null,y(!1)};return window.addEventListener("mousemove",V),window.addEventListener("mouseup",J),window.addEventListener("blur",J),()=>{window.removeEventListener("mousemove",V),window.removeEventListener("mouseup",J),window.removeEventListener("blur",J)}},[w]),d.useEffect(()=>{H()},[e,H]),d.useLayoutEffect(()=>{K(),Z()},[r,m,c,K,Z]),d.useEffect(()=>{const V=x.current;if(!V)return;const J=new ResizeObserver(()=>{K(),Z()});return J.observe(V),()=>J.disconnect()},[r,c,K,Z]),d.useEffect(()=>{let V=!1;o(null),l(null);const J=setTimeout(()=>{Je(()=>import("./mermaid.core-BXiRaLkg.js").then(q=>q.cb),[]).then(async q=>{if(V)return;const te=q.default,ie=`${R}:${s?"hardened":"runtime"}`,ge=ure.then(async()=>{if(V)throw new Error("Mermaid render skipped");cre!==ie&&(te.initialize({startOnLoad:!1,theme:R,securityLevel:"strict",suppressErrorRendering:!0,...s?{maxTextSize:gdt,maxEdges:vdt}:{},flowchart:{wrappingWidth:300,useMaxWidth:!1}}),cre=ie);const G=`mermaid-${++mdt}`;if(!s)return te.render(G,e.trim());let Q;try{return await Promise.race([te.render(G,e.trim()),new Promise((he,ve)=>{Q=setTimeout(()=>ve(new Error("Mermaid render timed out")),wdt)})])}finally{Q!==void 0&&clearTimeout(Q)}});ure=ge.then(()=>{},()=>{});const{svg:re}=await ge;V||o(re)}).catch(q=>{V||l(q instanceof Error?q.message:"Mermaid render failed")})},150);return()=>{V=!0,clearTimeout(J)}},[e,s,R]);const B=()=>{Yf(e).then(()=>{f()}).catch(W0)};return i?a.jsxs("div",{className:ri.codeBlock,children:[a.jsx("div",{className:ri.codeBlockHeader,children:a.jsx("span",{className:ri.codeBlockLang,children:t("mermaid.errorLabel")})}),a.jsx("pre",{className:`${ri.codeBlockContent} ${ri.codeBlockPlain}`,children:a.jsx("code",{children:e})})]}):a.jsxs("div",{className:ri.codeBlock,children:[a.jsxs("div",{className:ri.codeBlockHeader,children:[a.jsx("span",{className:ri.codeBlockLang,children:t("mermaid.label")}),a.jsxs("span",{className:ri.mermaidActions,children:[c==="diagram"&&a.jsxs(a.Fragment,{children:[a.jsx("button",{className:ri.codeBlockCopy,onClick:F,title:t("mermaid.zoomOut"),disabled:m<=N,children:t("mermaid.zoomOut")}),a.jsx("button",{className:ri.codeBlockCopy,onClick:H,title:t("mermaid.zoomReset"),disabled:m===1&&!k,children:t("mermaid.zoomReset")}),a.jsx("button",{className:ri.codeBlockCopy,onClick:P,title:t("mermaid.zoomIn"),disabled:m>=M,children:t("mermaid.zoomIn")})]}),a.jsx("button",{className:ri.codeBlockCopy,onClick:()=>u(c==="diagram"?"code":"diagram"),children:t(c==="diagram"?"mermaid.viewCode":"mermaid.viewDiagram")}),a.jsx("button",{className:ri.codeBlockCopy,onClick:B,children:t(h?"code.copied":"code.copy")})]})]}),c==="code"?a.jsx("pre",{className:`${ri.codeBlockContent} ${ri.codeBlockPlain}`,children:a.jsx("code",{children:e})}):r?a.jsx("div",{className:`${ri.mermaidZoomWrapper} ${S?ri.mermaidPannable:""} ${S&&w?ri.mermaidDragging:""}`,ref:x,style:E?{height:E.canvasHeight}:void 0,onMouseDown:$,onDoubleClick:H,onScroll:Y,children:a.jsx("div",{className:`${ri.mermaidBlock} ${ri.mermaidStage}`,ref:j,style:{...E?{width:E.stageWidth}:{},...m===1?{}:{zoom:m}},dangerouslySetInnerHTML:{__html:r}})}):a.jsx("div",{className:`${ri.mermaidBlock} ${ri.mermaidLoading} ${ri.mermaidInline}`,children:a.jsx("span",{children:t("mermaid.rendering")})})]})}function bdt({className:e,children:t,isStreaming:n}){const{t:s}=Ct(),r=yb(),o=Vl()==="document",[i,l]=d.useState(null),[c,u]=bx(),{label:h,lang:f,resolvedLang:m}=tY(cxe(e)),g=String(t).replace(/\n$/,""),w=r==="light"?"github-light-default":"github-dark-default";d.useEffect(()=>{if(o||n||f==="mermaid"||m==="text"||vU(g)){l(null);return}const x=pat(g,m,w);if(x!==null){l(x);return}const k=zse(g,m,w,!0);if(k!==null){l(k);return}l(null);let _=!1;return N1e(m).then(()=>{if(_)return;const S=zse(g,m,w,!0);S!==null&&l(S)}).catch(S=>{_||(console.warn("[web-shell] highlight failed for lang=%s",m,S),l(null))}),()=>{_=!0}},[g,o,f,m,w,n]);const y=()=>{Yf(g).then(()=>{u()}).catch(W0)};return f==="mermaid"&&!n&&!o?a.jsx(ydt,{code:g}):a.jsxs("div",{className:ri.codeBlock,children:[a.jsxs("div",{className:ri.codeBlockHeader,children:[a.jsx("span",{className:ri.codeBlockLang,children:h}),a.jsx("button",{className:ri.codeBlockCopy,onClick:y,children:s(c?"code.copied":"code.copy")})]}),!o&&!n&&i!==null?a.jsx("div",{className:ri.codeBlockContent,dangerouslySetInnerHTML:{__html:i}}):a.jsx("pre",{className:`${ri.codeBlockContent} ${ri.codeBlockPlain}`,children:a.jsx("code",{children:g})})]})}function cxe(e){const t=e?.match(/(?:^|\s)language-([^\s]+)/)?.[1]??"",n=t.match(/^([\w+.#-]+)/);if(!n)return"";const s=n[1]??"",r=t[s.length];return!r||r==="{"||r===":"?s:""}function xdt({children:e}){return a.jsx("code",{className:ri.inlineCode,children:e})}function hre({children:e}){return a.jsx("div",{className:ri.tableWrapper,children:a.jsx("table",{className:ri.table,children:e})})}const uxe=d.createContext(!1),dxe=d.createContext(void 0),hxe=d.createContext(void 0);function kdt(e,t,n){if(!n||e===void 0)return!1;const s=t?.position?.start.offset,r=t?.position?.end.offset;return s===void 0||r===void 0?!1:!gye(e.slice(s,r))&&e.slice(r).trim().length===0}function _dt({className:e,children:t,node:n}){const s=d.useContext(uxe),r=d.useContext(hxe);return e?.startsWith("language-")||typeof t=="string"&&t.includes(`
1619
1619
  `)?a.jsx(Sdt,{className:e,isStreaming:s,isIncomplete:kdt(r,n,s),children:t}):a.jsx(xdt,{children:t})}function Sdt({className:e,children:t,isStreaming:n,isIncomplete:s}){const r=d.useContext(dxe),o=yb(),{markdown:i}=Th(),l=String(t),c=l.replace(/\n$/,""),u=a.jsx(bdt,{className:e,isStreaming:n,children:l}),h=cxe(e),{resolvedLang:f}=tY(h);if(!!r&&!!e&&!!h)try{const g=i?.renderCodeBlock?.({language:h,resolvedLanguage:f,className:e,code:c,isStreaming:!!n,isIncomplete:!!s,source:r,theme:o});if(g!=null&&typeof g!="boolean")return a.jsx(K0,{fallback:u,label:`custom code block component render (lang=${h})`,resetKeys:[h,r,o,n?"streaming":"settled",s?"incomplete":"complete",c],children:g})}catch(g){console.error("[web-shell] custom code block renderer call failed (lang=%s):",h,g)}return u}function Cdt({children:e}){return a.jsx(a.Fragment,{children:e})}const SU=/^o1-code-session:\/\//i;function fre(e,t=!1){return t&&lxe.test(e.trim())||SU.test(e.trim())?e:uye(e)}function fxe({href:e,children:t,node:n,id:s,"aria-label":r,"aria-describedby":o}){const i=Vl(),l=Hp();if((n?.properties.dataFootnoteRef!==void 0||n?.properties.dataFootnoteBackref!==void 0)&&e?.startsWith("#"))return a.jsx("a",{id:s,href:e,className:ri.link,"aria-label":r,"aria-describedby":o,"data-footnote-ref":n?.properties.dataFootnoteRef!==void 0?"":void 0,"data-footnote-backref":n?.properties.dataFootnoteBackref!==void 0?"":void 0,onClick:h=>{const m=h.currentTarget.getRootNode().getElementById(e.slice(1));m&&(h.preventDefault(),m.scrollIntoView({block:"nearest"}),!m.hasAttribute("tabindex")&&m.tagName!=="BUTTON"&&(m.tabIndex=-1),m.focus({preventScroll:!0}))},children:t});if(e&&SU.test(e.trim())){if(i!=="interactive")return a.jsx("span",{className:ri.link,children:t});const h=e.trim().replace(SU,"");return a.jsx("a",{href:"#",role:"button",className:ri.link,onClick:f=>{f.preventDefault(),f.stopPropagation(),window.dispatchEvent(new CustomEvent("o1-code:open-session",{detail:h}))},children:t})}const u=N4(e)?e:void 0;return a.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:ri.link,onClick:h=>l(h,u),children:t})}function Tdt({src:e,alt:t}){const n=Vl(),s=Ow(e,n==="document")?e:void 0;return a.jsx("img",{src:s,alt:t||"",className:ri.image})}function Idt(e,t,n=80){const[s,r]=d.useState(e),o=d.useRef(s);o.current=s;const i=d.useRef(0),l=d.useRef(null),c=d.useRef(e);return c.current=e,d.useEffect(()=>{if(!t){l.current&&(clearTimeout(l.current),l.current=null),o.current!==e&&r(e);return}const u=Date.now(),h=u-i.current;h>=n?(i.current=u,r(c.current)):l.current||(l.current=setTimeout(()=>{i.current=Date.now(),l.current=null,r(c.current)},n-h))},[e,t,n]),d.useEffect(()=>()=>{l.current&&(clearTimeout(l.current),l.current=null)},[]),!t||typeof e=="string"&&typeof s=="string"&&!e.startsWith(s)?e:s}function pxe(e="basic",t=""){return{code:_dt,pre:Cdt,a:fxe,img:Tdt,sup:q1e,section:V1e,table({children:n}){if(e==="advanced"){const s=a.jsx(hre,{children:n});return a.jsx(K0,{fallback:s,label:"enhanced markdown table",resetKeys:[t],children:a.jsx(bct,{fallback:s,children:n})})}return a.jsx(hre,{children:n})}}}const Rdt=pxe(),Edt=d.memo(function({content:t,components:n,remarkPlugins:s,rehypePlugins:r,urlTransform:o}){return a.jsx(mJe,{components:n,remarkPlugins:s,rehypePlugins:r,urlTransform:o,children:t})}),Im=d.memo(function({content:t,source:n,isStreaming:s,tableMode:r}){const{markdown:o,markdownTableMode:i}=Th(),l=yb(),c=Vl()==="document",u=`footnote-${d.useId()}-`,h=n?o:void 0,f=Idt(t??"",s),m=s===!0&&f.length>hdt,g=d.useMemo(()=>f&&n&&h?.transformMarkdown?h.transformMarkdown(f,{source:n,isStreaming:s===!0}):f,[n,h,f,s]),w=s?"basic":r??i??"basic",y=d.useMemo(()=>w==="advanced"?pxe("advanced",g):Rdt,[w,g]),x=h?.components,k=h?.getInlineFootnoteIcon,_=h?.mountFootnotePreview,S=d.useMemo(()=>{if(!x&&!k&&!_)return y;const O={...y,...x,...w==="advanced"?{table:y.table}:{}},P=x?.a;return x&&(O.a=F=>{if(F.node?.properties.dataFootnoteRef!==void 0||F.node?.properties.dataFootnoteBackref!==void 0||!P)return a.jsx(fxe,{...F});if(typeof P!="string")return d.createElement(P,F);const{node:$,...Y}=F;return d.createElement(P,Y)}),x?.sup||(O.sup=F=>a.jsx(q1e,{...F,linkComponent:P,iconResolver:k,mountPreview:_}),O.section=F=>a.jsx(V1e,{...F,sectionComponent:x?.section})),O},[y,w,x,k,_]),I=!c&&n==="assistant"&&!x?.code&&!x?.pre?h?.chart??(h?.renderCodeBlock?void 0:But):void 0,E=d.useMemo(()=>I?Fut(I.registry,{chartClassName:I.chartClassName,chartStyle:{minHeight:360,...I.chartStyle}}):void 0,[I]),A=d.useMemo(()=>E?{...S,pre:E}:S,[E,S]),j=d.useMemo(()=>h?.remarkPlugins?[_ne,cse,kse,...h.remarkPlugins]:[_ne,cse,kse],[h?.remarkPlugins]),L=d.useMemo(()=>[Ast,...h?.rehypePlugins??[],[Rct,{prefix:u,group:!c&&!x?.sup,safeHref:N4,safeImage:Ow,transformUrl:fre}]],[h?.rehypePlugins,u,c,x?.sup]),R=d.useMemo(()=>O=>fre(O,c),[c]);if(!t)return null;if(m)return a.jsx("div",{className:n!=="thinking"?ri.content:void 0,"data-markdown-source":n,"data-markdown-streaming-plain-text":"true",children:a.jsx("pre",{className:ri.streamingPlainText,children:g})});const N=a.jsx(Edt,{content:g,components:A,remarkPlugins:j,rehypePlugins:L,urlTransform:R}),M=I?a.jsx(zut,{customization:I,source:g,streaming:!!s,theme:l,children:N}):N;return a.jsx("div",{className:n!=="thinking"?ri.content:void 0,"data-markdown-source":n,children:a.jsx(uxe.Provider,{value:!!s,children:a.jsx(dxe.Provider,{value:n,children:a.jsx(hxe.Provider,{value:g,children:M})})})})}),K$=/https?:\/\/[A-Za-z0-9\-._~:/?#[\]{}@!$&'()*+,;=%]+/gi,Adt=new Set([...".,;:!?'*_~"]),jdt={")":"(","]":"[","}":"{"},Ndt=/^https?:\/\/./i;function pre(e,t){let n=0;for(const s of e)s===t&&(n+=1);return n}function Mdt(e){const t={};for(const[s,r]of Object.entries(jdt))t[s]=pre(e,s)-pre(e,r);let n=e.length;for(;n>0;){const s=e.charAt(n-1);if(Object.hasOwn(t,s)){if(t[s]<=0)break;t[s]--,n--;continue}if(!Adt.has(s))break;n--}return e.slice(0,n)}function Pdt(e){const t=[];let n=0;K$.lastIndex=0;for(let s=K$.exec(e);s!==null;s=K$.exec(e)){const r=Mdt(s[0]);if(!Ndt.test(r))continue;const o=s.index;o>n&&t.push({type:"text",value:e.slice(n,o)}),t.push({type:"url",value:r}),n=o+r.length}return n<e.length&&t.push({type:"text",value:e.slice(n)}),t}const M9=d.memo(function({text:t}){const n=Hp(),s=d.useMemo(()=>Pdt(t),[t]);return s.every(r=>r.type==="text")?t:s.map((r,o)=>{if(r.type==="text")return r.value;const i=r.value.replace(/%(?![0-9A-Za-z]{2})/g,"%25"),l=N4(i)?i:void 0;return a.jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",className:ri.link,onClick:c=>n(c,l),children:r.value},o)})}),Ldt="_flash_96ig5_1",pb={flash:Ldt},Ddt="_chatMessageRow_qnd03_41",Odt="_chatMessageColumn_qnd03_48",$dt="_chatBubble_qnd03_55",Bdt="_scheduledTaskBubble_qnd03_68",Fdt="_scheduledTaskRun_qnd03_76",zdt="_scheduledTaskHeader_qnd03_83",Hdt="_scheduledTaskIcon_qnd03_90",Udt="_scheduledTaskHeading_qnd03_108",Wdt="_scheduledTaskEyebrow_qnd03_115",qdt="_scheduledTaskName_qnd03_122",Vdt="_scheduledTaskMeta_qnd03_131",Gdt="_scheduledTaskMetaItem_qnd03_138",Kdt="_scheduledTaskBadge_qnd03_158",Ydt="_scheduledTaskId_qnd03_170",Xdt="_scheduledTaskPrompt_qnd03_181",Zdt="_sendFailure_qnd03_191",Jdt="_retryButton_qnd03_201",Qdt="_editArea_qnd03_229",eht="_editInput_qnd03_237",tht="_editActions_qnd03_258",nht="_editCancel_qnd03_264",sht="_editSubmit_qnd03_265",rht="_chatContent_qnd03_294",oht="_messageTag_qnd03_299",iht="_messageTagTooltip_qnd03_317",aht="_messageTagClickable_qnd03_351",lht="_messageTagIcon_qnd03_364",cht="_messageTagLabel_qnd03_376",uht="_messageTagValue_qnd03_377",dht="_chatContentCollapsed_qnd03_400",hht="_toggleButton_qnd03_405",fht="_toggleIcon_qnd03_426",pht="_toggleIconExpanded_qnd03_433",mht="_chatImages_qnd03_437",ght="_chatImageThumb_qnd03_445",vht="_chatImageThumbInteractive_qnd03_453",wht="_chatFiles_qnd03_462",yht="_chatFileChip_qnd03_470",bht="_chatFileChipPreviewable_qnd03_483",xht="_fileTagIcon_qnd03_492",Uo={chatMessageRow:Ddt,chatMessageColumn:Odt,chatBubble:$dt,scheduledTaskBubble:Bdt,scheduledTaskRun:Fdt,scheduledTaskHeader:zdt,scheduledTaskIcon:Hdt,scheduledTaskHeading:Udt,scheduledTaskEyebrow:Wdt,scheduledTaskName:qdt,scheduledTaskMeta:Vdt,scheduledTaskMetaItem:Gdt,scheduledTaskBadge:Kdt,scheduledTaskId:Ydt,scheduledTaskPrompt:Xdt,sendFailure:Zdt,retryButton:Jdt,editArea:Qdt,editInput:eht,editActions:tht,editCancel:nht,editSubmit:sht,chatContent:rht,messageTag:oht,messageTagTooltip:iht,messageTagClickable:aht,messageTagIcon:lht,messageTagLabel:cht,messageTagValue:uht,chatContentCollapsed:dht,toggleButton:hht,toggleIcon:fht,toggleIconExpanded:pht,chatImages:mht,chatImageThumb:ght,chatImageThumbInteractive:vht,chatFiles:wht,chatFileChip:yht,chatFileChipPreviewable:bht,fileTagIcon:xht},kht="This is a scheduled task run. Execute the instructions below now. Do not create or modify a schedule unless the instructions explicitly ask you to.";function _ht(e){const t=`
1620
1620
 
1621
1621
  ${kht}
@@ -2213,7 +2213,7 @@ ${i("terminal.notice.protocolMismatch")}`),ie.close(4002,"Terminal protocol mism
2213
2213
  * Copyright 2025 Qwen Team
2214
2214
  * SPDX-License-Identifier: Apache-2.0
2215
2215
  */const agn=250,VF={truncated:!1,status:"idle"};function lgn(e){if(e instanceof Error&&e.message)return e.message;const t=String(e??"");return t.length>0?t:"Unknown error"}function cgn(e){return e.replayError?{kind:"unreadable",message:e.replayError}:e.partial?{kind:"partial"}:void 0}function ugn(e,t={}){const n=t.pageSize??agn,[s,r]=d.useState(VF),o=d.useRef(0),i=d.useCallback(()=>{if(!e)return;const u=++o.current;r(h=>({...h,status:"loading",error:void 0})),e({limit:n}).then(h=>{if(o.current!==u)return;const f=cgn(h);if(f!==void 0){r(m=>({...m,status:"error",error:f}));return}r({events:h.events,truncated:h.hasMore,status:"ready"})},h=>{o.current===u&&r(f=>({...f,status:"error",error:{kind:"unreadable",message:lgn(h)}}))})},[e,n]);d.useEffect(()=>{if(!e){o.current+=1,r(VF);return}return r(VF),i(),()=>{o.current+=1}},[e,i]);const l=s.events;return{trajectory:d.useMemo(()=>l===void 0?void 0:sgn(ign(l)),[l]),status:s.status,...s.error!==void 0?{error:s.error}:{},truncated:s.truncated,refresh:i}}const dgn="_panel_1ploj_1",hgn="_header_1ploj_8",fgn="_summary_1ploj_17",pgn="_headerActions_1ploj_26",mgn="_headerButton_1ploj_33",ggn="_iconButton_1ploj_54",vgn="_error_1ploj_78",wgn="_notice_1ploj_91",ygn="_tableWrap_1ploj_100",bgn="_placeholder_1ploj_107",xgn="_scroll_1ploj_114",kgn="_olderBar_1ploj_126",_gn="_olderNotice_1ploj_132",Sgn="_virtualBody_1ploj_137",Cgn="_virtualRow_1ploj_142",Tgn="_turnHeader_1ploj_151",Ign="_turnTitle_1ploj_167",Rgn="_turnSummary_1ploj_171",Egn="_record_1ploj_179",Agn="_nestMarker_1ploj_198",jgn="_selected_1ploj_203",Ngn="_badge_1ploj_208",Mgn="_text_1ploj_221",Pgn="_faint_1ploj_230",Lgn="_metrics_1ploj_235",Dgn="_toneError_1ploj_244",Ogn="_toneMuted_1ploj_248",Ua={panel:dgn,header:hgn,summary:fgn,headerActions:pgn,headerButton:mgn,iconButton:ggn,error:vgn,notice:wgn,tableWrap:ygn,placeholder:bgn,scroll:xgn,olderBar:kgn,olderNotice:_gn,virtualBody:Sgn,virtualRow:Cgn,turnHeader:Tgn,turnTitle:Ign,turnSummary:Rgn,record:Egn,nestMarker:Agn,selected:jgn,badge:Ngn,text:Mgn,faint:Pgn,metrics:Lgn,toneError:Dgn,toneMuted:Ogn},vue=34;function wue(e){return e>=999950?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function $gn(e){return`${wue(e.inputTokens)} → ${wue(e.outputTokens)}`}const Bgn=/-call_[A-Za-z0-9]+$/;function Fgn(e){const{subagentId:t,parentToolCallId:n}=e;if(t!==void 0)return n!==void 0&&t.endsWith(`-${n}`)?t.slice(0,-(n.length+1)):t.replace(Bgn,"")}function yE(e){const t=e.trim(),n=t.indexOf(`
2216
- `);return n===-1?t:t.slice(0,n)}function zgn(e,t){if(e.kind==="request"){const n=[kh(e.timing.durationMs)];return e.timing.ttftMs!==void 0&&n.push(t("trajectory.ttft",{duration:kh(e.timing.ttftMs)})),e.usage&&n.push($gn(e.usage)),n}if(e.kind==="tool"){const n=[];if(e.timing&&n.push(kh(e.timing.durationMs)),e.subagentSummary){const{requests:s,tools:r,requestMs:o}=e.subagentSummary;n.push(t("trajectory.subagentRollup",{requests:s,tools:r,duration:kh(o)}))}return n}return[]}function yue(e){const t=e.toolStatus??e.block.status;if(t==="error"||t==="failed")return Ua.toneError;if(t==="cancelled")return Ua.toneMuted}function Hgn(e,t){switch(e.kind){case"user":return{badge:t("trajectory.badge.user"),text:yE(e.block.text)};case"request":{const n=Fgn(e),s=e.status==="error",r=n!==void 0?`${n}${e.model?` · ${e.model}`:""}`:e.model??t("trajectory.request");return{badge:n!==void 0?t("trajectory.badge.subagent"):`#${e.requestIndex??"?"}`,...s?{badgeTone:Ua.toneError}:{},text:s?`${r} · ${t("trajectory.requestFailed")}`:r}}case"message":return{badge:e.thought?t("trajectory.badge.thought"):t("trajectory.badge.message"),text:yE(e.block.text),faint:e.thought};case"tool":return{badge:e.block.toolName??t("trajectory.badge.tool"),...yue(e)?{badgeTone:yue(e)}:{},text:e.block.title||(e.block.toolName??"")};default:return Ugn(e.block,t)}}function Ugn(e,t){switch(e.kind){case"shell":return{badge:t("trajectory.badge.shell"),text:yE(e.text)};case"user_shell":return{badge:t("trajectory.badge.shell"),text:yE(e.command||e.text)};case"permission":return{badge:t("trajectory.badge.permission"),text:e.title||e.toolName||""};case"status":case"error":case"debug":return{badge:t("trajectory.badge.status"),...e.kind==="error"?{badgeTone:Ua.toneError}:{},text:yE(e.text),faint:e.kind!=="error"};case"prompt_cancelled":return{badge:t("trajectory.badge.cancelled"),badgeTone:Ua.toneMuted,text:e.reason??t("trajectory.cancelled"),faint:!0};default:return{badge:t("trajectory.badge.other"),text:""}}}function Wgn(e){return e.rows.some(t=>t.kind==="request"||t.kind==="tool"&&t.timing!==void 0)}function qgn({loadPage:e}){const{t}=Ct(),{trajectory:n,status:s,error:r,truncated:o,refresh:i}=ugn(e),[l,c]=d.useState(void 0),u=d.useRef(null),h=d.useRef(!1),f=d.useRef(0),m=d.useId(),g=d.useCallback(R=>`${m}-row-${R}`,[m]),w=d.useCallback((R,N)=>{R.scrollTop=N,f.current=R.scrollTop},[]),y=d.useMemo(()=>{if(!n)return[];const R=new Map(n.rows.map(M=>[M.key,M])),N=[];for(const M of n.turns){const O=M.userRowKey??`ordinal:${M.index}`;N.push({kind:"turn",key:`turn:${O}`,turn:M});for(const P of M.rowKeys){const F=R.get(P);F&&N.push({kind:"row",key:P,row:F})}}return N},[n]),x=wwe({count:y.length,getScrollElement:()=>u.current,getItemKey:R=>y[R]?.key??R,estimateSize:()=>vue,overscan:12}),k=y.length>0;d.useLayoutEffect(()=>{const R=u.current;if(!R||typeof ResizeObserver>"u")return;let N=0;const M=()=>{R.scrollTop===0&&f.current>0&&(R.scrollTop=f.current)},O=new ResizeObserver(()=>{M(),N=requestAnimationFrame(M)});return O.observe(R),()=>{O.disconnect(),N!==0&&cancelAnimationFrame(N)}},[k]),d.useEffect(()=>{if(s!=="ready"||h.current||y.length===0)return;h.current=!0;const R=u.current;R&&w(R,R.scrollHeight)},[w,s,y.length]);const _=d.useMemo(()=>l===void 0?-1:y.findIndex(R=>R.key===l),[l,y]),S=d.useCallback(R=>{if(y.length===0)return;const N=Math.min(Math.max(R,0),y.length-1);c(y[N].key),x.scrollToIndex(N,{align:"auto"})},[x,y]),I=d.useCallback(R=>{c(R),u.current?.focus({preventScroll:!0})},[]),E=d.useCallback(R=>{if(y.length===0)return;const N=_<0?-1:_;R.key==="ArrowDown"?(R.preventDefault(),S(N+1)):R.key==="ArrowUp"?(R.preventDefault(),S(N<=0?0:N-1)):R.key==="Home"?(R.preventDefault(),S(0)):R.key==="End"&&(R.preventDefault(),S(y.length-1))},[S,_,y]),A=d.useMemo(()=>{if(!n)return;let R=0,N=0,M=0;for(const O of n.turns)R+=O.requestCount,N+=O.toolCount,M+=O.requestMs;return{turns:n.turns.length,requests:R,tools:N,durationMs:M}},[n]),j=s==="ready"&&y.length===0,L=n!==void 0&&y.length>0&&!Wgn(n);return a.jsxs("div",{className:Ua.panel,"data-testid":"trajectory-panel",children:[a.jsxs("div",{className:Ua.header,children:[a.jsx("div",{className:Ua.summary,children:A?a.jsx("span",{"data-testid":"trajectory-totals",children:t("trajectory.totals",{turns:A.turns,requests:A.requests,tools:A.tools,duration:A.durationMs>0?kh(A.durationMs):"—"})}):a.jsx("span",{children:t("trajectory.title")})}),a.jsx("div",{className:Ua.headerActions,children:a.jsx("button",{type:"button",className:Ua.iconButton,onClick:i,disabled:!e||s==="loading",title:t("common.refresh"),"aria-label":t("common.refresh"),children:a.jsx(Hg,{size:14,strokeWidth:1.6})})})]}),r!==void 0&&a.jsxs("div",{className:Ua.error,role:"alert",children:[a.jsx("span",{children:r.kind==="partial"?t("trajectory.partial"):t("trajectory.loadFailed",{message:r.message})}),a.jsx("button",{type:"button",className:Ua.headerButton,onClick:i,disabled:s==="loading",children:t("common.retry")})]}),L&&a.jsx("div",{className:Ua.notice,role:"status",children:t("trajectory.noTiming")}),a.jsx("div",{className:Ua.tableWrap,children:y.length===0?s==="error"?null:a.jsx("div",{className:Ua.placeholder,role:"status",children:t(j?"trajectory.empty":"common.loading")}):a.jsxs(a.Fragment,{children:[o&&a.jsx("div",{className:Ua.olderBar,children:a.jsx("span",{className:Ua.olderNotice,"data-testid":"trajectory-truncated",children:t("trajectory.truncated")})}),a.jsx("div",{ref:u,className:Ua.scroll,role:"grid",tabIndex:0,"aria-label":t("trajectory.title"),"aria-rowcount":y.length,"aria-activedescendant":_>=0?g(_):void 0,onKeyDown:E,onScroll:R=>{f.current=R.currentTarget.scrollTop},"data-testid":"trajectory-rows",children:a.jsx("div",{className:Ua.virtualBody,style:{height:`${x.getTotalSize()}px`},children:x.getVirtualItems().map(R=>{const N=y[R.index];return a.jsx("div",{id:g(R.index),className:Ua.virtualRow,style:{height:`${vue}px`,transform:`translateY(${R.start}px)`},role:"row","aria-rowindex":R.index+1,children:N.kind==="turn"?a.jsx(Vgn,{turn:N.turn,selected:N.key===l,onSelect:()=>I(N.key)}):a.jsx(Ggn,{row:N.row,selected:N.key===l,onSelect:()=>I(N.key)})},R.key)})})})]})})]})}function Vgn({turn:e,selected:t,onSelect:n}){const{t:s}=Ct();return a.jsxs("div",{className:`${Ua.turnHeader} ${t?Ua.selected:""}`,onClick:n,"aria-selected":t,"data-selected":t?"true":void 0,role:"gridcell","data-testid":"trajectory-turn",children:[a.jsx("span",{className:Ua.turnTitle,children:e.partial?s("trajectory.turnPartial",{index:e.index}):s("trajectory.turn",{index:e.index})}),a.jsx("span",{className:Ua.turnSummary,children:s("trajectory.turnSummary",{requests:e.requestCount,tools:e.toolCount,duration:e.requestMs>0?kh(e.requestMs):"—"})})]})}function Ggn({row:e,selected:t,onSelect:n}){const{t:s}=Ct(),r=Hgn(e,s),o=zgn(e,s);return a.jsxs("div",{className:`${Ua.record} ${t?Ua.selected:""}`,role:"gridcell","aria-selected":t,"data-selected":t?"true":void 0,onClick:n,"data-testid":`trajectory-row-${e.kind}`,"data-depth":e.depth,children:[e.depth>0&&a.jsx(zHe,{size:12,strokeWidth:1.6,className:Ua.nestMarker,"aria-hidden":"true"}),a.jsx("span",{className:`${Ua.badge} ${r.badgeTone??""}`,children:r.badge}),a.jsx("span",{className:`${Ua.text} ${r.faint?Ua.faint:""}`,children:r.text}),a.jsx("span",{className:Ua.metrics,"data-testid":"trajectory-row-metrics",children:o.length>0?o.join(" · "):"—"})]})}const Kgn="_panel_pwtdr_1",Ygn="_toolbar_pwtdr_5",Xgn="_actions_pwtdr_15",Zgn="_feedback_pwtdr_21",Jgn="_state_pwtdr_31",ky={panel:Kgn,toolbar:Ygn,actions:Xgn,feedback:Zgn,state:Jgn};function Qgn({sessionActions:e,sessionId:t,controls:n}){const{t:s}=Ct(),[r,o]=d.useState(null),[i,l]=d.useState(!0),[c,u]=d.useState(!1),h=d.useRef(0),f=d.useRef(()=>{}),m=d.useRef(null),g=n?.sessionId===t?n:void 0,w=g?.getContextUsage??e?.getContextUsage,y=d.useRef(g);y.current=g;const x=g?.result,[k,_]=d.useState(x),S=!!(x&&x!==k&&(x.kind!=="completed"||!c));d.useEffect(()=>{x?.kind==="completed"&&(h.current++,o(x.usage),u(!1))},[x]),d.useEffect(()=>{let A=!0,j=!1;const L=y.current?.result;o(N=>N?.sessionId===t?N:L?.kind==="completed"?L.usage:null),u(!1),l(!!w);const R=async()=>{if(!A||j||!w)return;j=!0,l(!0),u(!1);const N=h.current,M=m.current,O=M&&M.getContextUsage===w&&M.sessionId===t?M:{getContextUsage:w,sessionId:t,promise:w({detail:!0,silent:!0,...y.current?.result?{syncCounters:!0}:{}})};m.current=O;try{const P=await O.promise;if(!A||N!==h.current)return;o(P.sessionId===t&&P.usage.contextWindowSize>0?P:null)}catch(P){if(!A||N!==h.current)return;u(DV(P)?"transient":"hard")}finally{j=!1,m.current===O&&(m.current=null),A&&l(!1)}};return f.current=()=>void R(),R(),()=>{A=!1}},[w,t]);const I=!w||i||g?.compressing,E=()=>{_(x),f.current()};return a.jsxs("div",{className:ky.panel,"aria-busy":i,children:[a.jsxs("div",{className:ky.toolbar,children:[a.jsx("span",{children:s("contextUsage.title")}),a.jsxs("div",{className:ky.actions,children:[a.jsx(Wt,{type:"button",variant:"ghost",size:"icon-sm","aria-label":s("contextUsage.refresh"),title:s("contextUsage.refresh"),disabled:I,onClick:E,children:a.jsx(Hg,{"aria-hidden":"true"})}),a.jsx("span",{title:g?.compressing?void 0:g?.canCompress?i?s("common.loading"):void 0:s("contextUsage.compressUnavailable"),children:a.jsx(Wt,{type:"button",variant:"outline",size:"sm",disabled:!g?.canCompress||i,onClick:()=>void g?.compress(),children:s(g?.compressing?"contextUsage.compressing":"contextUsage.compress")})})]})]}),(g?.compressing||S)&&a.jsx(i4e,{controls:g,className:ky.feedback}),c==="transient"&&r&&a.jsx("div",{className:ky.feedback,role:"status",children:s("contextUsage.previousReading")}),c==="hard"?a.jsxs("div",{className:ky.state,role:"alert",children:[a.jsx("span",{children:s("contextUsage.loadError")}),a.jsx(Wt,{type:"button",variant:"outline",size:"sm",disabled:I,onClick:E,children:s("contextUsage.retry")})]}):w?i&&!r?a.jsx("div",{className:ky.state,role:"status",children:s("common.loading")}):r?a.jsx(Sxe,{status:r,compact:!0}):a.jsx("div",{className:ky.state,children:s("contextUsage.unavailable")}):a.jsx("div",{className:ky.state,children:s("contextUsage.unavailable")})]})}const e0n=700,t0n=["daily","weekdays","weekly","hourly","minutes","custom"],n0n=[1,2,3,4,5,6,10,12,15,20,30],s0n=(e,t)=>{},r0n=(e,t,n)=>{},o0n=()=>Promise.reject(new Error("Side-task session creation is unavailable"));function bue(e){return e.kind==="review"||e.kind==="file"||e.kind==="artifact"||e.kind==="scheduled_task"}function _y(e){return e.kind==="pending"?e.targetKind:e.kind}function i0n(e){return`image.${(e.match(/^data:image\/([a-z0-9+.+-]+)/i)?.[1]??"png").split("+")[0].toLowerCase()}`}const a0n=["review","sideTask"];function xue({contextUsageControls:e,artifacts:t,tabs:n,activeTabId:s,reviewChanges:r,selectedReviewPath:o,panelWidth:i,workspaceCwd:l,loading:c,restoring:u=!1,error:h,onSelectTab:f,onCloseTab:m,onOpenFilePreview:g,latestReviewAvailable:w=!1,onOpenLatestReview:y,onOpenTerminal:x,onOpenTrajectory:k,trajectoryTabId:_,onOpenWebPreview:S,onWebPreviewChange:I,items:E=a0n,sideTaskAvailable:A=!1,sideTasks:j=[],sideTasksLoading:L=!1,onCreateSideTask:R,onOpenSideTask:N,onCreateSideTaskSession:M,onSideTaskCreated:O,onSideTaskTitleChange:P,onNestedRightPanelOpen:F,onNestedArtifactsChange:H,onOpenNestedSubagent:$,agentTasks:Y=[],agentTraceLoading:Z=!1,agentTraceError:K,onOpenWorkflowAgent:B,onError:V,sessionWorkflowEnabled:J,workflow:q,onImageIngestionNotice:te,deferSubagentMount:ie=!1,onClose:ge,variant:re="docked",fullscreen:G=!1,onToggleFullscreen:Q}){const{t:he}=Ct(),[ve,ye]=d.useState(!1),[_e,ae]=d.useState(),Se=d.useRef(null),Te=d.useCallback(()=>{Se.current&&(clearTimeout(Se.current),Se.current=null),ye(!0)},[]),Ne=d.useCallback(()=>{Se.current&&clearTimeout(Se.current),Se.current=setTimeout(()=>{ye(!1),Se.current=null},120)},[]);d.useEffect(()=>()=>{Se.current&&clearTimeout(Se.current)},[]);const Ae=n.find(ke=>ke.id===s)??n[0],Ve=Ae?.kind==="file"&&Ae.sourcePreview&&(/\.html?$/i.test(Ae.workspacePath)||ub(Ae.previewMimeType||Ae.previewData?.type)==="text/html"),Ze=Ae?.kind==="file"&&Ae.previewOnly===!0&&!Ve&&/\.(?:html?|md|markdown)$/i.test(Ae.workspacePath)&&(Ae.previewContent!==void 0||!Ae.previewData||!!i4(Ae.previewMimeType||Ae.previewData.type,Ae.workspacePath)),Tt=_e===Ae?.id,je=E.includes("review")&&!n.some(ke=>_y(ke)==="review"),ot=E.includes("sideTask")&&A&&!!R,Ie=!!x,ue=E.includes("webPreview")&&!!S,W=E.includes("trajectory")&&!!k&&!n.some(ke=>ke.id===_),ne=!!Ae&&(je||ot||Ie||ue||W),me=Ae&&bue(Ae)?{workspaceCwd:Ae.workspaceCwd,workspaceId:Ae.workspaceId}:void 0,Me=O4(me?.workspaceCwd),Ke=Me?.workspaceId===me?.workspaceId?Me?.actions:void 0,be=Ae?.kind==="artifact"?t.find(ke=>ke.id===Ae.artifactId):void 0;return a.jsxs("aside",{className:`${pt.panel} ${re==="drawer"?pt.panelDrawer:""} ${G?pt.panelFullscreen:""}`,style:re==="docked"&&i&&!G?{flexBasis:i,width:i}:void 0,"aria-label":"Right panel",children:[a.jsxs("div",{className:pt.header,children:[n.length>0&&a.jsx("div",{className:pt.tabs,role:"tablist","aria-label":"Right panel",children:n.map(ke=>a.jsxs("div",{className:[pt.tabItem,ke.id===Ae?.id?pt.tabActive:""].filter(Boolean).join(" "),children:[a.jsxs("button",{type:"button",role:"tab","aria-selected":ke.id===Ae?.id,className:pt.tab,onClick:()=>f(ke.id),onMouseEnter:Pe=>yT(Pe.currentTarget),onFocus:Pe=>yT(Pe.currentTarget),title:ke.title,children:[a.jsx("span",{className:`${pt.tabIcon} ${_y(ke)==="artifact"?pt.tabArtifactIcon:""}`,"aria-hidden":"true",children:_y(ke)==="review"?a.jsx(GF,{}):ke.kind==="workflow"?a.jsx(zve,{className:pt.tabIconSvg,strokeWidth:1.6}):ke.kind==="file"?a.jsx(U0,{name:ke.workspacePath,className:pt.tabIconSvg,strokeWidth:1.6}):_y(ke)==="artifact"?a.jsx(uwe,{artifact:t.find(Pe=>"artifactId"in ke&&Pe.id===ke.artifactId),className:pt.tabIconSvg}):_y(ke)==="subagent"?a.jsx(l0n,{}):_y(ke)==="monitor"?a.jsx(Yve,{className:pt.tabIconSvg,strokeWidth:1.6}):_y(ke)==="shell"?a.jsx(Y2,{className:pt.tabIconSvg,strokeWidth:1.6}):_y(ke)==="side_task"?a.jsx(Aj,{className:pt.tabIconSvg,strokeWidth:1.6}):ke.kind==="web_preview"?a.jsx(hT,{className:pt.tabIconSvg}):ke.kind==="terminal"?a.jsx(Y2,{className:pt.tabIconSvg,strokeWidth:1.6}):_y(ke)==="image"?a.jsx(UUe,{className:pt.tabIconSvg,strokeWidth:1.6}):ke.kind==="context_usage"?a.jsx(WP,{className:pt.tabIconSvg,strokeWidth:1.6}):ke.kind==="token_usage"?a.jsx(UG,{className:pt.tabIconSvg,strokeWidth:1.6}):ke.kind==="trajectory"?a.jsx(GO,{className:pt.tabIconSvg,strokeWidth:1.6}):a.jsx(u0n,{})}),a.jsx("span",{className:pt.tabTitle,"data-web-shell-session-title":!0,children:a.jsx("span",{className:pt.tabTitleInner,children:ke.title})})]}),a.jsx("button",{type:"button",className:pt.tabCloseButton,onClick:()=>m(ke.id),"aria-label":`Close ${ke.title}`,title:"Close",children:a.jsx(c0n,{})})]},ke.id))}),a.jsxs("div",{className:pt.headerActions,children:[ne&&a.jsxs(Z0,{modal:!1,children:[a.jsx(Vg,{asChild:!0,children:a.jsx("button",{type:"button",className:`${pt.iconButton} ${pt.addButton}`,"aria-label":he("rightPanel.add"),title:he("rightPanel.add"),children:a.jsx(Qf,{className:pt.toolbarIcon})})}),a.jsxs(Gg,{align:"end",className:"w-64",children:[je&&a.jsxs(yi,{disabled:!w||!y,onSelect:y,children:[a.jsx(GF,{}),a.jsx("span",{className:pt.sideTaskListTitle,children:he("turnOutputs.review")})]}),je&&ot&&a.jsx(ax,{}),ot&&a.jsxs(yi,{disabled:L,onSelect:R,children:[a.jsx(Aj,{className:pt.sideTaskNewIcon,strokeWidth:1.6,"aria-hidden":"true"}),a.jsx("span",{className:pt.sideTaskListTitle,children:he("sideTask.create")})]}),Ie&&(je||ot)&&a.jsx(ax,{}),Ie&&a.jsxs(yi,{onSelect:()=>x?.(),children:[a.jsx(Y2,{className:pt.sideTaskNewIcon,strokeWidth:1.6,"aria-hidden":"true"}),a.jsx("span",{className:pt.sideTaskListTitle,children:he("terminal.title")})]}),ue&&a.jsxs(yi,{onSelect:S,children:[a.jsx(hT,{className:pt.sideTaskNewIcon}),a.jsx("span",{className:pt.sideTaskListTitle,children:he("webPreview.title")})]}),W&&a.jsxs(yi,{onSelect:()=>k?.(),children:[a.jsx(GO,{className:pt.sideTaskNewIcon,strokeWidth:1.6,"aria-hidden":"true"}),a.jsx("span",{className:pt.sideTaskListTitle,children:he("trajectory.title")})]})]})]}),Q&&a.jsx("button",{type:"button",className:`${pt.iconButton} ${pt.fullscreenButton} ${G?pt.iconButtonActive:""}`,onClick:Q,"aria-label":he(G?"common.exitFullscreen":"common.fullscreen"),"aria-pressed":G,title:he(G?"common.exitFullscreen":"common.fullscreen"),children:G?a.jsx(qG,{className:pt.toolbarIcon,"aria-hidden":!0}):a.jsx(zG,{className:pt.toolbarIcon,"aria-hidden":!0})}),a.jsx("button",{type:"button",className:`${pt.iconButton} ${pt.panelToggleButton}`,onClick:ge,"aria-label":he("chatHeader.toggleRightPanel"),"aria-pressed":"true",title:he("chatHeader.toggleRightPanel"),children:a.jsx(Hve,{className:pt.panelToggleIcon})})]})]}),a.jsxs("div",{className:`${pt.body} ${Ae?.kind==="side_task"?pt.bodySideTask:""}`.trim(),children:[n.filter(ke=>ke.kind==="web_preview").map(ke=>a.jsx("div",{className:"h-full",hidden:ke.id!==Ae?.id,children:a.jsx(lmn,{state:ke,onChange:Pe=>I?.(ke.id,Pe)})},ke.id)),n.filter(ke=>ke.kind==="terminal").map(ke=>a.jsx("div",{className:`${pt.terminalPane} ${ke.id===Ae?.id?"":pt.terminalPaneHidden}`.trim(),"aria-hidden":ke.id===Ae?.id?void 0:!0,children:a.jsx(amn,{terminalId:ke.id,cwd:ke.workspaceCwd??l,active:ke.id===Ae?.id,enabled:ke.initialized!==!1})},ke.id)),Ze&&a.jsxs("button",{type:"button",className:pt.attachmentPreviewButton,onClick:()=>ae(Tt?void 0:Ae?.id),"aria-label":he(Tt?"attachment.showSource":"attachment.showPreview"),"aria-pressed":Tt,children:[Tt?a.jsx(PHe,{"aria-hidden":!0}):a.jsx(Pve,{"aria-hidden":!0}),he(Tt?"attachment.showSource":"attachment.showPreview")]}),u&&!Ae?a.jsxs("div",{className:"flex flex-col gap-4 p-5","data-testid":"right-panel-loading-skeleton",role:"status","aria-label":he("common.loading"),children:[a.jsx(ow,{className:"h-5 w-2/5"}),a.jsx(ow,{className:"h-32 w-full"}),a.jsx(ow,{className:"h-4 w-4/5"}),a.jsx(ow,{className:"h-4 w-3/5"})]}):Ae?.kind==="terminal"||Ae?.kind==="web_preview"?null:Ae?Ae.kind==="pending"?a.jsx("div",{className:pt.empty,role:Ae.loadError?"alert":"status",children:Ae.loadError??he("common.loading")}):Ae.kind==="workflow"?Ae.sessionId?a.jsx(tdn,{tasks:Y,loading:Z,error:K,onOpenAgent:B}):q?a.jsx(Udn,{...q}):a.jsx("div",{className:pt.empty,children:he("workflow.empty.title")}):bue(Ae)&&(Ae.kind!=="scheduled_task"||Ae.task.durable)&&(Ae.kind!=="file"||!Ae.previewOnly)&&(Ae.kind!=="artifact"||be?.metadata?.artifactType!=="web_preview_snapshot")&&!Ke?a.jsx("div",{className:pt.empty,role:"alert",children:he("workspace.notFoundDescription")}):Ae.kind==="review"?a.jsx(f0n,{changes:Ae.changes??r,selectedPath:Ae.selectedPath??o,workspaceCwd:Ae.workspaceCwd??l,onOpenFilePreview:ke=>g(ke,Ae.workspaceCwd??l,Ae.workspaceId),onDownloadFile:(ke,Pe)=>GP(Ke,ke.path,dVe(ke.path),Pe),onDownloadError:ke=>{const Pe=he("common.downloadFailed",{message:Iu(ke)});V?V(new Error(Pe,{cause:ke}),Pe):console.error(Pe,ke)}}):Ae.kind==="file"?Ae.attachmentId&&!Ae.previewData&&Ae.previewContent===void 0?a.jsx("div",{className:pt.empty,role:Ae.loadError?"alert":"status",children:Ae.loadError??he("common.loading")}):Ae.sourcePreview&&Ae.previewData&&ub(Ae.previewMimeType||Ae.previewData.type)!=="application/pdf"&&!i4(Ae.previewMimeType||Ae.previewData.type,Ae.workspacePath)?a.jsx(SRe,{data:Ae.previewData,title:Ae.title,image:!!FS(Ae.workspacePath)&&Ae.previewData.type.startsWith("image/")}):a.jsx(oD,{workspacePath:Ae.workspacePath,artifactVersion:String(Ae.previewVersion??0),workspaceActions:Ke,previewContent:Ae.previewContent,previewData:Ae.previewData,previewMimeType:Ae.previewMimeType,previewOnly:Ae.previewOnly,previewKind:Ve||Ae.previewOnly&&!Tt?"source":void 0},Ae.id):Ae.kind==="source"?a.jsx(A0n,{tab:Ae},Ae.id):Ae.kind==="artifact"?a.jsx(d0n,{artifacts:t,artifactId:Ae.artifactId,sourceSessionId:Ae.sourceSessionId,workspaceActions:Ke,previewContent:Ae.previewContent,loading:c,error:h},Ae.id):Ae.kind==="subagent"?ie?null:a.jsx(Oun,{sessionId:Ae.sessionId,rootToolCallId:Ae.rootToolCallId,initialRootTool:Ae.rootTool,workspaceCwd:Ae.workspaceCwd??l,onRightPanelOpen:F,onArtifactsChange:H,onOpenSubagent:$,onError:V}):Ae.kind==="monitor"?a.jsx(Owt,{task:Ae.task,actions:Ae.sessionActions},Ae.id):Ae.kind==="shell"?a.jsx($wt,{task:Ae.task,actions:Ae.sessionActions},Ae.id):Ae.kind==="side_task"?a.jsx(sdn,{tabId:Ae.id,sessionId:Ae.sessionId,parentSessionId:Ae.parentSessionId,workspaceCwd:Ae.workspaceCwd??l,title:Ae.title,shouldNameFromFirstPrompt:Ae.nameFromFirstPrompt,initialPrompt:Ae.initialPrompt,createSession:M??o0n,onCreated:O??s0n,onTitleChange:P??r0n,onRightPanelOpen:F,onArtifactsChange:H,onError:V,sessionWorkflowEnabled:J,onImageIngestionNotice:te},Ae.id):Ae.kind==="image"?Ae.src?a.jsxs("div",{className:pt.imagePreviewWrap,children:[a.jsx("img",{src:Ae.src,alt:Ae.alt??Ae.title,className:pt.imagePreview}),a.jsx("a",{className:pt.imageDownloadButton,href:Ae.src,download:i0n(Ae.src),"aria-label":he("common.download"),title:he("common.download"),children:a.jsx(Vy,{size:16,strokeWidth:1.8})})]}):a.jsx("div",{className:pt.empty,role:Ae.loadError?"alert":"status",children:Ae.loadError??he("common.loading")}):Ae.kind==="context_usage"?a.jsx(Qgn,{controls:e?.[Ae.sessionId],sessionActions:Ae.sessionActions,sessionId:Ae.sessionId},Ae.id):Ae.kind==="trajectory"?a.jsx(qgn,{loadPage:Ae.loadPage},Ae.id):Ae.kind==="token_usage"?a.jsx(Ymn,{sessionActions:Ae.sessionActions,sessionId:Ae.sessionId},Ae.id):a.jsx(h0n,{task:Ae.task,actions:Ke},Ae.id):a.jsxs("div",{className:pt.emptyActions,"data-testid":"right-panel-empty-actions",children:[E.includes("review")&&a.jsxs("button",{type:"button",className:pt.emptyAction,disabled:!w||!y,onClick:y,children:[a.jsx("span",{className:pt.emptyActionIcon,"aria-hidden":"true",children:a.jsx(GF,{})}),a.jsx("span",{className:pt.emptyActionTitle,children:he("turnOutputs.review")}),a.jsx("span",{className:pt.emptyActionHint,children:he("turnOutputs.reviewLatest")}),a.jsx(Bl,{className:pt.emptyActionChevron,strokeWidth:1.6,"aria-hidden":"true"})]}),E.includes("sideTask")&&A&&R&&(j.length===0?a.jsxs("button",{type:"button",className:pt.emptyAction,disabled:L,"aria-busy":L,onClick:R,children:[a.jsx("span",{className:pt.emptyActionIcon,"aria-hidden":"true",children:a.jsx(Aj,{strokeWidth:1.6})}),a.jsx("span",{className:pt.emptyActionTitle,children:he("sideTask.title")}),a.jsx("span",{className:pt.emptyActionHint,children:he("sideTask.description")}),a.jsx(Bl,{className:pt.emptyActionChevron,strokeWidth:1.6,"aria-hidden":"true"})]}):a.jsxs(Z0,{open:ve,onOpenChange:ye,modal:!1,children:[a.jsx(Vg,{asChild:!0,children:a.jsxs("button",{type:"button",className:pt.emptyAction,"aria-expanded":ve,onMouseEnter:Te,onMouseLeave:Ne,children:[a.jsx("span",{className:pt.emptyActionIcon,"aria-hidden":"true",children:a.jsx(Aj,{strokeWidth:1.6})}),a.jsx("span",{className:pt.emptyActionTitle,children:he("sideTask.title")}),a.jsx("span",{className:pt.emptyActionHint,children:he("sideTask.description")}),a.jsx(Bl,{className:pt.emptyActionChevron,strokeWidth:1.6,"aria-hidden":"true"})]})}),a.jsxs(Gg,{align:"end",className:"w-80",onMouseEnter:Te,onMouseLeave:Ne,children:[j.map(ke=>a.jsxs(yi,{onSelect:()=>N?.(ke),children:[a.jsx("span",{className:pt.sideTaskListTitle,children:ke.title}),ke.updatedAt&&a.jsx("span",{className:pt.sideTaskListTime,children:EA(ke.updatedAt,he)})]},ke.sessionId)),a.jsx(ax,{}),a.jsxs(yi,{onSelect:R,children:[a.jsx(kHe,{className:pt.sideTaskNewIcon,strokeWidth:1.6,"aria-hidden":"true"}),a.jsx("span",{className:pt.sideTaskListTitle,children:he("sideTask.new")})]})]})]})),ue&&a.jsxs("button",{type:"button",className:pt.emptyAction,onClick:S,children:[a.jsx("span",{className:pt.emptyActionIcon,"aria-hidden":"true",children:a.jsx(hT,{strokeWidth:1.6})}),a.jsx("span",{className:pt.emptyActionTitle,children:he("webPreview.title")}),a.jsx("span",{className:pt.emptyActionHint,children:he("webPreview.openHint")}),a.jsx(Bl,{className:pt.emptyActionChevron,"aria-hidden":"true"})]}),W&&a.jsxs("button",{type:"button",className:pt.emptyAction,onClick:()=>k?.(),"data-testid":"right-panel-open-trajectory",children:[a.jsx("span",{className:pt.emptyActionIcon,"aria-hidden":"true",children:a.jsx(GO,{strokeWidth:1.6})}),a.jsx("span",{className:pt.emptyActionTitle,children:he("trajectory.title")}),a.jsx("span",{className:pt.emptyActionHint,children:he("trajectory.description")}),a.jsx(Bl,{className:pt.emptyActionChevron,"aria-hidden":"true"})]}),x&&a.jsxs("button",{type:"button",className:pt.emptyAction,onClick:()=>x(),children:[a.jsx("span",{className:pt.emptyActionIcon,"aria-hidden":"true",children:a.jsx(Y2,{strokeWidth:1.6})}),a.jsx("span",{className:pt.emptyActionTitle,children:he("terminal.title")}),a.jsx("span",{className:pt.emptyActionHint,children:he("terminal.open")}),a.jsx(Bl,{className:pt.emptyActionChevron,strokeWidth:1.6,"aria-hidden":"true"})]})]})]})]})}function l0n(){return a.jsxs("svg",{className:pt.tabIconSvg,viewBox:"0 0 24 24",fill:"none",focusable:"false","aria-hidden":"true",children:[a.jsx("circle",{cx:"12",cy:"8",r:"3",stroke:"currentColor",strokeWidth:"1.6"}),a.jsx("path",{d:"M6.5 19c.7-3.1 2.5-4.7 5.5-4.7s4.8 1.6 5.5 4.7",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})}function c0n(){return a.jsx("svg",{className:pt.tabCloseIcon,viewBox:"0 0 16 16",fill:"none",focusable:"false","aria-hidden":"true",children:a.jsx("path",{d:"m4.5 4.5 7 7M11.5 4.5l-7 7",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})})}function GF(){return a.jsxs("svg",{className:pt.tabIconSvg,viewBox:"0 0 24 24",fill:"none",focusable:"false",children:[a.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"1.6"}),a.jsx("path",{d:"M9 9.5h6M12 6.5v6",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),a.jsx("path",{d:"M9 16h6",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})]})}function u0n(){return a.jsxs("svg",{className:pt.tabIconSvg,viewBox:"0 0 24 24",fill:"none",focusable:"false",children:[a.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"3",stroke:"currentColor",strokeWidth:"1.8"}),a.jsx("path",{d:"M12 8v4l3 2",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})}function d0n({artifacts:e,artifactId:t,sourceSessionId:n,workspaceActions:s,previewContent:r,loading:o,error:i}){const l=e.find(c=>c.id===t);return l?a.jsx(S0n,{artifact:l,sourceSessionId:n,workspaceActions:s,previewContent:r}):o?a.jsx("div",{className:pt.empty,children:"Loading artifact..."}):i?a.jsx("div",{className:pt.empty,children:i}):a.jsx("div",{className:pt.empty,children:"Artifact not found."})}function h0n({task:e,actions:t}){const{t:n}=Ct(),[s,r]=d.useState(null),[o,i]=d.useState(!0),[l,c]=d.useState(null),[u,h]=d.useState(""),[f,m]=d.useState(e.prompt),[g,w]=d.useState(()=>M1(e.cron)),[y,x]=d.useState(!1),[k,_]=d.useState(!1),[S,I]=d.useState(!1),[E,A]=d.useState(!1),[j,L]=d.useState(null),R=d.useRef(0),N=d.useRef(0),M=d.useRef({actions:t,taskId:e.id,workspaceId:e.workspaceId});M.current={actions:t,taskId:e.id,workspaceId:e.workspaceId};const O=d.useCallback((he,ve,ye,_e)=>{const ae=M.current;return he===R.current&&ae.actions===ve&&ae.taskId===ye&&ae.workspaceId===_e},[]),P=d.useCallback((he,ve,ye,_e)=>{const ae=M.current;return he===N.current&&ae.actions===ve&&ae.taskId===ye&&ae.workspaceId===_e},[]);d.useEffect(()=>()=>{R.current+=1,N.current+=1},[]),d.useEffect(()=>{I(!1),A(!1),L(null)},[t,e.id,e.workspaceId]);const F=d.useCallback(async()=>{const he=++R.current,ve=++N.current,ye=e.id,_e=e.workspaceId;if(!e.durable||!t){r(null),h(""),m(e.prompt),w(M1(e.cron)),c(null),i(!1);return}i(!0),c(null);try{const ae=await t.listScheduledTasks(_e);if(!O(he,t,ye,_e))return;const Se=ae.find(Te=>Te.id===e.id)??null;r(Se),Se?(h(Se.name??""),m(Se.prompt),w(M1(Se.cron))):(h(""),m(e.prompt),w(M1(e.cron)))}catch(ae){P(ve,t,ye,_e)&&c(ae instanceof Error?ae.message:String(ae))}finally{P(ve,t,ye,_e)&&i(!1)}},[t,P,O,e.cron,e.durable,e.id,e.prompt,e.workspaceId]);d.useEffect(()=>{F()},[F]);const H=!e.durable,$=e.durable&&!o&&!l&&!s,Y=!!s,Z=s?.name||s?.prompt||e.title,K=s?.prompt??e.prompt,B=s?.cron??e.cron,V=s?.recurring??e.recurring,J=s?.enabled,q=d.useCallback(()=>{s&&(h(s.name??""),m(s.prompt),w(M1(s.cron)),L(null),x(!0))},[s]),te=d.useCallback(()=>{x(!1),L(null),s&&(h(s.name??""),m(s.prompt),w(M1(s.cron)))},[s]),ie=d.useCallback(async()=>{if(!s||!t)return;const he=i9(g);if(!he){L(n("scheduledTasks.error.invalidSchedule"));return}if(f.trim().length===0){L(n("scheduledTasks.error.emptyPrompt"));return}const ve=++R.current,ye=e.id,_e=e.workspaceId;A(!0),L(null);try{const ae=await t.updateScheduledTask(s.id,{cron:he,prompt:f.trim(),name:u.trim()||null},_e);if(!O(ve,t,ye,_e))return;r(ae),h(ae.name??""),m(ae.prompt),w(M1(ae.cron)),x(!1)}catch(ae){O(ve,t,ye,_e)&&L(ae instanceof Error?ae.message:String(ae))}finally{O(ve,t,ye,_e)&&A(!1)}},[t,g,O,s,u,f,n,e.id,e.workspaceId]),ge=d.useCallback(async()=>{if(!s||!t)return;const he=++R.current,ve=e.id,ye=e.workspaceId;I(!0),L(null);try{const _e=await t.updateScheduledTask(s.id,{enabled:!s.enabled},ye);if(!O(he,t,ve,ye))return;r(_e)}catch(_e){O(he,t,ve,ye)&&L(_e instanceof Error?_e.message:String(_e))}finally{O(he,t,ve,ye)&&I(!1)}},[t,O,s,e.id,e.workspaceId]),re=d.useCallback(async()=>{if(!s||!t)return;const he=++R.current,ve=e.id,ye=e.workspaceId;I(!0),L(null);try{if(await t.deleteScheduledTask(s.id,ye),!O(he,t,ve,ye))return;r(null),_(!1)}catch(_e){O(he,t,ve,ye)&&L(_e instanceof Error?_e.message:String(_e))}finally{O(he,t,ve,ye)&&I(!1)}},[t,O,s,e.id,e.workspaceId]),G=i9(g),Q=G?BT(G,n):null;return a.jsxs("div",{className:pt.detail,children:[o&&a.jsx("div",{className:pt.empty,children:n("scheduledTasks.loading")}),l&&a.jsx("div",{className:rn.loadError,children:l}),$&&a.jsx("div",{className:pt.empty,children:n("scheduledTasks.deletedSnapshot")}),H&&a.jsx("div",{className:pt.empty,children:n("scheduledTasks.sessionScopedSnapshot")}),!$&&a.jsx("div",{className:pt.section,children:a.jsxs("div",{className:pt.fieldGrid,children:[a.jsx("span",{className:pt.fieldLabel,children:n("scheduledTasks.name")}),a.jsx("span",{className:pt.fieldValue,children:Z}),a.jsx("span",{className:pt.fieldLabel,children:n("scheduledTasks.taskId")}),a.jsx("span",{className:pt.fieldValue,children:e.id}),a.jsx("span",{className:pt.fieldLabel,children:n("scheduledTasks.schedule")}),a.jsx("span",{className:pt.fieldValue,children:BT(B,n)}),a.jsx("span",{className:pt.fieldLabel,children:"Cron"}),a.jsx("span",{className:pt.fieldValue,children:B}),a.jsx("span",{className:pt.fieldLabel,children:n("scheduledTasks.type")}),a.jsx("span",{className:pt.fieldValue,children:n(V?"scheduledTasks.repeats":"scheduledTasks.runsOnce")}),J!==void 0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:pt.fieldLabel,children:n("scheduledTasks.status")}),a.jsx("span",{className:pt.fieldValue,children:n(J?"scheduledTasks.enable":"scheduledTasks.disable")})]})]})}),!$&&a.jsxs("div",{className:pt.section,children:[a.jsx("div",{className:pt.sectionTitle,children:"Prompt"}),a.jsx("div",{className:pt.description,children:K})]}),j&&a.jsx("div",{className:rn.formError,children:j}),a.jsxs("div",{className:pt.actionsRow,children:[a.jsx("button",{type:"button",className:rn.primaryButton,disabled:!Y||S,onClick:q,children:n("scheduledTasks.edit")}),a.jsx("button",{type:"button",className:rn.secondaryButton,disabled:!Y||S,onClick:()=>void ge(),children:s?.enabled?n("scheduledTasks.disable"):n("scheduledTasks.enable")}),a.jsx("button",{type:"button",className:rn.secondaryButton,disabled:!Y||S,onClick:()=>_(!0),children:n("scheduledTasks.delete")})]}),k&&s&&a.jsx(Wa,{title:n("scheduledTasks.deleteConfirmTitle"),size:"sm",onClose:()=>_(!1),children:a.jsxs("div",{className:rn.formFields,children:[a.jsx("div",{className:pt.description,children:n("scheduledTasks.deleteConfirm",{name:s.name||s.prompt})}),j&&a.jsx("div",{className:rn.formError,children:j}),a.jsxs("div",{className:rn.formActions,children:[a.jsx("button",{type:"button",className:rn.secondaryButton,onClick:()=>_(!1),disabled:S,children:n("scheduledTasks.cancel")}),a.jsx("button",{type:"button",className:rn.primaryButton,onClick:()=>void re(),disabled:S,children:n("scheduledTasks.delete")})]})]})}),y&&a.jsx(Wa,{title:n("scheduledTasks.editTitle"),size:"md",onClose:te,children:a.jsxs("div",{className:rn.formFields,children:[a.jsxs("label",{className:rn.field,children:[a.jsx("span",{className:rn.fieldLabel,children:n("scheduledTasks.name")}),a.jsx("input",{className:rn.input,type:"text",value:u,maxLength:200,placeholder:n("scheduledTasks.namePlaceholder"),onChange:he=>h(he.target.value)})]}),a.jsxs("label",{className:rn.field,children:[a.jsxs("span",{className:rn.fieldLabel,children:[n("scheduledTasks.prompt"),a.jsx("span",{className:rn.required,children:"*"})]}),a.jsx("textarea",{className:rn.textarea,value:f,rows:4,maxLength:1e5,placeholder:n("scheduledTasks.promptPlaceholder"),onChange:he=>m(he.target.value)})]}),a.jsxs("div",{className:rn.scheduleRow,children:[a.jsxs("label",{className:rn.field,children:[a.jsx("span",{className:rn.fieldLabel,children:n("scheduledTasks.frequency")}),a.jsx("select",{className:rn.select,value:g.frequency,onChange:he=>{const ve=he.target.value;w(ye=>({...ye,frequency:ve,...ve==="hourly"?{time:"00:00"}:{}}))},children:t0n.map(he=>a.jsx("option",{value:he,children:n(`scheduledTasks.freq.${he}`)},he))})]}),(g.frequency==="daily"||g.frequency==="weekdays"||g.frequency==="weekly")&&a.jsxs("label",{className:rn.field,children:[a.jsx("span",{className:rn.fieldLabel,children:n("scheduledTasks.time")}),a.jsx("input",{className:rn.input,type:"time",value:g.time,onChange:he=>w(ve=>({...ve,time:he.target.value}))})]}),g.frequency==="weekly"&&a.jsxs("label",{className:rn.field,children:[a.jsx("span",{className:rn.fieldLabel,children:n("scheduledTasks.weekday")}),a.jsx("select",{className:rn.select,value:g.weekday,onChange:he=>w(ve=>({...ve,weekday:Number(he.target.value)})),children:n("scheduledTasks.weekdayNames").split(",").map((he,ve)=>a.jsx("option",{value:ve,children:he},ve))})]}),g.frequency==="minutes"&&a.jsxs("label",{className:rn.field,children:[a.jsx("span",{className:rn.fieldLabel,children:n("scheduledTasks.interval")}),a.jsx("select",{className:rn.select,value:g.minuteInterval,onChange:he=>w(ve=>({...ve,minuteInterval:Number(he.target.value)})),children:n0n.map(he=>a.jsx("option",{value:he,children:he},he))})]}),g.frequency==="custom"&&a.jsxs("label",{className:`${rn.field} ${rn.fieldGrow}`,children:[a.jsx("span",{className:rn.fieldLabel,children:n("scheduledTasks.cron")}),a.jsx("input",{className:rn.input,type:"text",value:g.customCron,spellCheck:!1,placeholder:"0 9 * * 1-5",onChange:he=>w(ve=>({...ve,customCron:he.target.value}))})]})]}),a.jsx("div",{className:rn.preview,children:Q?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:rn.previewLabel,children:Q}),a.jsx("code",{className:rn.previewCron,children:G})]}):a.jsx("span",{className:rn.previewInvalid,children:n("scheduledTasks.error.invalidSchedule")})}),j&&a.jsx("div",{className:rn.formError,children:j}),a.jsxs("div",{className:rn.formActions,children:[a.jsx("button",{type:"button",className:rn.secondaryButton,onClick:te,disabled:E,children:n("scheduledTasks.cancel")}),a.jsx("button",{type:"button",className:rn.primaryButton,onClick:()=>void ie(),disabled:E,children:n(E?"scheduledTasks.saving":"scheduledTasks.save")})]})]})})]})}function f0n({changes:e,selectedPath:t,workspaceCwd:n,onOpenFilePreview:s,onDownloadFile:r,onDownloadError:o}){const{t:i}=Ct(),[l,c]=d.useState(!1),[u,h]=d.useState(!0),[f,m]=d.useState(!1),[g,w]=d.useState(520),y=d.useRef(g),x=d.useRef(null),k=d.useRef(null),[_,S]=d.useState(null),[I,E]=d.useState(()=>new Set),A=d.useRef(!0);d.useEffect(()=>(A.current=!0,()=>{A.current=!1}),[]);const j=l,L=d.useMemo(()=>_0n(e,n),[e,n]);d.useEffect(()=>{S(t)},[t]),d.useEffect(()=>{y.current=g},[g]),d.useEffect(()=>{const P=x.current;if(!P)return;const F=()=>{m(P.clientWidth<e0n)};F();const H=new ResizeObserver(F);return H.observe(P),()=>H.disconnect()},[u]),d.useEffect(()=>()=>k.current?.(),[]);const R=d.useCallback(P=>{const F=x.current;if(!F)return;P.preventDefault();const H=P.currentTarget;H.setPointerCapture(P.pointerId);const $=P.clientX,Y=y.current,Z=F.getBoundingClientRect().width,K=Math.max(180,Z-180),B=document.body.style.cursor,V=document.body.style.userSelect;let J=Y,q=null;document.body.style.cursor="col-resize",document.body.style.userSelect="none";const te=()=>{q=null,w(J)},ie=G=>{J=Math.min(K,Math.max(180,Y+(G.clientX-$))),q===null&&(q=window.requestAnimationFrame(te))};let ge=()=>{};const re=G=>{k.current=null,q!==null&&(window.cancelAnimationFrame(q),q=null),G&&w(J),H.hasPointerCapture(P.pointerId)&&H.releasePointerCapture(P.pointerId),document.body.style.cursor=B,document.body.style.userSelect=V,window.removeEventListener("pointermove",ie),window.removeEventListener("pointerup",ge),window.removeEventListener("pointercancel",ge)};ge=()=>re(!0),k.current=()=>re(!1),window.addEventListener("pointermove",ie),window.addEventListener("pointerup",ge),window.addEventListener("pointercancel",ge)},[]);if(e.length===0)return a.jsx("div",{className:pt.empty,children:"No file changes to review."});const N=T_e(e),M=P=>{S(F=>F===P?null:P)},O=async P=>{if(!I.has(P.path)){E(F=>new Set(F).add(P.path));try{await r(P,()=>!A.current)}catch(F){A.current&&o(F)}finally{E(F=>{const H=new Set(F);return H.delete(P.path),H})}}};return a.jsxs("div",{className:pt.review,children:[a.jsxs("div",{className:pt.reviewToolbar,children:[a.jsxs("div",{className:pt.reviewToolbarTitle,children:[a.jsx("span",{children:i("turnOutputs.previousTurn")}),a.jsx(Y9,{additions:N?.additions,deletions:N?.deletions,className:pt.lineStats,additionsClassName:pt.additions,deletionsClassName:pt.deletions})]}),a.jsxs("div",{className:pt.reviewToolbarActions,children:[a.jsxs("button",{type:"button",className:pt.reviewTotalsButton,onClick:()=>h(P=>!P),"aria-expanded":u,children:[a.jsx("span",{children:i("turnOutputs.fileCount",{count:e.length})}),a.jsx("span",{className:[pt.chevron,u?pt.chevronOpen:""].filter(Boolean).join(" "),"aria-hidden":"true",children:a.jsx(_ue,{})})]}),a.jsx("button",{type:"button",className:[pt.iconButton,l?pt.iconButtonActive:""].filter(Boolean).join(" "),onClick:()=>c(P=>!P),"aria-label":i(l?"turnOutputs.closeFileTree":"turnOutputs.openFileTree"),title:i(l?"turnOutputs.closeFileTree":"turnOutputs.openFileTree"),children:l?a.jsx(x0n,{}):a.jsx(b0n,{})})]})]}),u&&a.jsxs("div",{ref:x,className:[pt.reviewContent,j?"":pt.reviewContentListOnly,j&&f?pt.reviewContentStacked:""].filter(Boolean).join(" "),style:{"--review-list-width":`${g}px`},children:[a.jsx("div",{className:[pt.reviewList,_?pt.reviewListWithExpanded:""].filter(Boolean).join(" "),children:e.map(P=>{const F=_===P.path,H=E_e(P.path),$=YIt(P.path);return a.jsxs("div",{className:[pt.reviewItem,F?pt.reviewItemExpanded:""].filter(Boolean).join(" "),children:[a.jsxs("div",{className:pt.reviewRow,"data-selected":P.path===t||void 0,children:[a.jsx("button",{type:"button",className:pt.reviewRowToggle,onClick:()=>M(P.path),"aria-label":P.path,"aria-expanded":F}),a.jsx("span",{className:pt.fileIcon,children:_Re(P.path)}),a.jsxs("span",{className:pt.reviewFileName,children:[a.jsx(v0n,{path:AL(P.path,n),title:P.path}),H&&a.jsx("button",{type:"button",className:pt.reviewOpenButton,onClick:()=>s(P),title:`${i("turnOutputs.preview")} ${P.path}`,children:i("turnOutputs.preview")}),$&&a.jsx("button",{type:"button",className:pt.reviewOpenButton,onClick:()=>void O(P),title:`${i("common.download")} ${P.path}`,disabled:I.has(P.path),children:i(I.has(P.path)?"common.downloading":"common.download")})]}),a.jsx(Y9,{additions:P.additions,deletions:P.deletions,className:pt.lineStats,additionsClassName:pt.additions,deletionsClassName:pt.deletions}),a.jsx("span",{className:[pt.chevron,F?pt.chevronOpen:""].filter(Boolean).join(" "),"aria-hidden":"true",children:a.jsx(_ue,{})})]}),F&&a.jsx(p0n,{change:P})]},`${P.toolCallId}:${P.path}`)})}),j&&!f&&a.jsx("div",{className:pt.reviewSplitHandle,role:"separator","aria-orientation":"vertical",onPointerDown:R}),j&&a.jsx("div",{className:pt.tree,children:L.children.map(P=>a.jsx(bRe,{node:P,depth:0,selectedPath:t},P.path))})]})]})}function p0n({change:e}){if(e.diffs.length===0)return a.jsx("div",{className:pt.diffEmpty,children:"No diff available."});const t=m0n(e.diffs);return a.jsx("div",{className:pt.diffPreview,children:t.map((n,s)=>n.fileDiff&&!n.fullContent?a.jsx(gY,{diff:n.fileDiff},s):a.jsx(g0n,{oldText:n.oldText,newText:n.newText},s))})}function m0n(e){for(let t=e.length-1;t>=0;t--)if(e[t]?.fullContent)return e.slice(t);return e}function g0n({oldText:e,newText:t}){const n=d.useRef(null),[s,r]=d.useState(null),[o,i]=d.useState(null);return d.useEffect(()=>{const l=n.current;if(!l)return;const c=()=>r(l.clientWidth>=720);c();const u=new ResizeObserver(c);return u.observe(l),()=>u.disconnect()},[]),d.useEffect(()=>{const l=n.current;if(!l||s===null)return;l.replaceChildren(),i(null);let c=!1,u=null;const h=[vTe,js.editable.of(!1),ua.readOnly.of(!0),js.lineWrapping],f={scanLimit:1e3,timeout:500},m={margin:3,minSize:8};return Je(async()=>{const{MergeView:g,unifiedMergeView:w}=await import("./index-B0JFcQN6.js");return{MergeView:g,unifiedMergeView:w}},[]).then(({MergeView:g,unifiedMergeView:w})=>{if(!c)try{if(s){u=new g({a:{doc:e,extensions:h},b:{doc:t,extensions:h},parent:l,highlightChanges:!0,gutter:!0,revertControls:void 0,collapseUnchanged:m,diffConfig:f});return}u=new js({doc:t,extensions:[...h,w({original:e,highlightChanges:!0,gutter:!0,mergeControls:!1,allowInlineDiffs:!0,collapseUnchanged:m,diffConfig:f})],parent:l})}catch(y){c||i(y instanceof Error?y.message:String(y))}}).catch(g=>{c||i(g instanceof Error?g.message:String(g))}),()=>{c=!0,u?.destroy()}},[s,t,e]),a.jsxs("div",{className:pt.codeMirrorDiffWrap,children:[a.jsx("div",{ref:n,className:pt.codeMirrorDiff}),o&&a.jsxs("div",{className:pt.diffError,children:["Diff unavailable: ",o]})]})}function bRe({node:e,depth:t,selectedPath:n}){const s=!!e.file,[r,o]=d.useState(!0),i=[pt.treeRow,s?pt.treeFile:pt.treeFolder].filter(Boolean).join(" "),l={paddingLeft:10+t*18,"--tree-row-line-left":`${19+Math.max(0,t-1)*18}px`},c={"--tree-children-line-left":`${19+t*18}px`},u=a.jsxs(a.Fragment,{children:[a.jsx("span",{className:pt.treeTwisty,children:!s&&a.jsx("span",{className:[pt.treeChevron,r?"":pt.treeChevronClosed].filter(Boolean).join(" "),children:a.jsx(k0n,{})})}),a.jsxs("span",{className:pt.treeContent,children:[s&&a.jsx("span",{className:pt.fileIcon,children:_Re(e.path)}),a.jsx("span",{className:pt.treeName,children:e.name})]}),e.file?.isArtifact&&a.jsx("span",{className:pt.reviewBadge,children:"artifact"})]});return a.jsxs("div",{className:pt.treeNode,children:[s?a.jsx("div",{className:i,"data-selected":e.file?.path===n||void 0,"data-depth":t,style:l,title:e.path,children:u}):a.jsx("button",{type:"button",className:i,"data-depth":t,style:l,title:e.path,"aria-expanded":r,onClick:()=>o(h=>!h),children:u}),!s&&r&&e.children.length>0&&a.jsx("div",{className:pt.treeChildren,style:c,children:e.children.map(h=>a.jsx(bRe,{node:h,depth:t+1,selectedPath:n},h.path))})]})}function v0n({path:e,title:t}){const n=d.useRef(null),[s,r]=d.useState(()=>xRe(e));return d.useLayoutEffect(()=>{const o=n.current;if(!o)return;const i=()=>r(w0n(e,o));i();const l=new ResizeObserver(i);return l.observe(o),()=>l.disconnect()},[e]),a.jsxs("span",{ref:n,className:pt.reviewPath,title:t??e,children:[s.prefix&&a.jsx("span",{className:pt.pathPrefix,children:s.prefix}),a.jsx("span",{className:pt.pathFileName,children:s.leaf})]})}function xRe(e){const t=e.lastIndexOf("/");return t<0?{prefix:"",leaf:e}:{prefix:e.slice(0,t+1),leaf:e.slice(t+1)}}let kue=null;function w0n(e,t){const n=xRe(e),s=t.clientWidth;if(s<=0)return n;const r=y0n(t);if(r(e)<=s)return n;const o=e.split("/").filter(Boolean),i=o.at(-1)??e,l=r(i);if(o.length<=1||l+r(".../")>s)return{prefix:"",leaf:i};let c=".../";for(let u=1;u<o.length;u++){const f=`.../${o.slice(o.length-1-u,-1).join("/")}/`;if(r(f)+l>s)break;c=f}return{prefix:c,leaf:i}}function y0n(e){kue??=document.createElement("canvas");const t=kue.getContext("2d"),n=window.getComputedStyle(e);return t&&(t.font=[n.fontStyle,n.fontVariant,n.fontWeight,n.fontSize,n.fontFamily].join(" ")),s=>t?.measureText(s).width??s.length*8}function b0n(){return a.jsxs("svg",{className:pt.toolbarIcon,viewBox:"0 0 24 24",fill:"none",focusable:"false","aria-hidden":"true",children:[a.jsx("path",{d:"M3.5 7.5h6l1.6 2h9.4v8.2a2 2 0 0 1-2 2h-13a2 2 0 0 1-2-2V7.5Z",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round"}),a.jsx("path",{d:"M3.5 7.5V5.8a1.5 1.5 0 0 1 1.5-1.5h4l1.8 2.1h7.2a1.5 1.5 0 0 1 1.5 1.5v1.6",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round"})]})}function x0n(){return a.jsxs("svg",{className:pt.toolbarIcon,viewBox:"0 0 24 24",fill:"none",focusable:"false","aria-hidden":"true",children:[a.jsx("path",{d:"M3.5 8.2V5.8A1.5 1.5 0 0 1 5 4.3h4l1.8 2.1h7.2a1.5 1.5 0 0 1 1.5 1.5v1.4",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round"}),a.jsx("path",{d:"M4.8 19.7h12.9a2 2 0 0 0 1.9-1.4l2-7H6.4l-2.8 7.1a.9.9 0 0 0 1.2 1.3Z",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round"})]})}function _ue(){return a.jsx("svg",{className:pt.chevronIcon,viewBox:"0 0 16 16",fill:"none",focusable:"false","aria-hidden":"true",children:a.jsx("path",{d:"m6 4 4 4-4 4",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}function k0n(){return a.jsx("svg",{className:pt.treeChevronIcon,viewBox:"0 0 16 16",fill:"none",focusable:"false","aria-hidden":"true",children:a.jsx("path",{d:"m4 6 4 4 4-4",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}function _0n(e,t){const n={name:"",path:"",children:[]};for(const s of e){const r=AL(s.path,t).split("/").filter(Boolean);let o=n;for(let i=0;i<r.length;i++){const l=r[i],c=r.slice(0,i+1).join("/");let u=o.children.find(h=>h.name===l);u||(u={name:l,path:c,children:[]},o.children.push(u)),i===r.length-1&&(u.file=s),o=u}}return kRe(n),n}function kRe(e){e.children.sort((t,n)=>!!t.file!=!!n.file?t.file?1:-1:t.name.localeCompare(n.name));for(const t of e.children)kRe(t)}function y8(e){return db(e).split("/").filter(Boolean).at(-1)??e}function _Re(e){const t=y8(e),n=t.includes(".")?t.split(".").pop()?.toLowerCase():"";return n?{css:"CSS",html:"HTML",js:"JS",json:"JSON",jsx:"JSX",md:"MD",ts:"TS",tsx:"TSX"}[n]??n.slice(0,3).toUpperCase():"FILE"}function S0n({artifact:e,sourceSessionId:t,workspaceActions:n,previewContent:s}){const{t:r}=Ct(),o=Hp(),i=iwe(e),l=N4(e.url)?e.url:void 0,c=e.metadata?.artifactType==="automation_snapshot",u=e.metadata?.artifactType==="code_review",h=e.storage==="workspace"&&!!e.workspacePath,f=owe(e);return e.metadata?.artifactType==="web_preview_snapshot"?a.jsx(cmn,{artifact:e,sourceSessionId:t}):u?e.status!=="available"?a.jsx(C0n,{status:e.status}):!h||!e.workspacePath?a.jsx(T0n,{}):a.jsx(bun,{workspacePath:e.workspacePath,artifactVersion:xte(e),workspaceActions:n}):h&&e.workspacePath?swe(e)?a.jsx(E0n,{artifact:e,workspaceActions:n}):a.jsx(oD,{workspacePath:e.workspacePath,artifactVersion:xte(e),workspaceActions:n,previewContent:s,previewSizeBytes:e.sizeBytes,imageMimeType:f,previewKind:I0n(e)?"html":R0n(e)?"markdown":f?"image":"source"}):a.jsxs("div",{className:pt.detail,children:[a.jsxs("div",{className:pt.section,children:[a.jsx("div",{className:pt.sectionTitle,children:c?"Automation Snapshot":"Artifact"}),a.jsxs("div",{className:pt.fieldGrid,children:[a.jsx(kp,{label:"Type",value:GG(e.kind,e.workspacePath)}),a.jsx(kp,{label:"Storage",value:e.storage}),a.jsx(kp,{label:"Status",value:e.status}),a.jsx(kp,{label:"Source",value:e.source}),a.jsx(kp,{label:"Size",value:VP(e.sizeBytes)}),a.jsx(kp,{label:"Created",value:e.createdAt}),a.jsx(kp,{label:"Updated",value:e.updatedAt}),e.toolName&&a.jsx(kp,{label:"Tool",value:e.toolName}),e.toolCallId&&a.jsx(kp,{label:"Tool call",value:e.toolCallId})]})]}),e.description&&a.jsxs("div",{className:pt.section,children:[a.jsx("div",{className:pt.sectionTitle,children:"Description"}),a.jsx("div",{className:pt.description,children:e.description})]}),c&&e.metadata&&a.jsxs("div",{className:pt.section,children:[a.jsx("div",{className:pt.sectionTitle,children:"Details"}),a.jsxs("div",{className:pt.fieldGrid,children:[C2(e.metadata,"automationId","Automation ID"),C2(e.metadata,"schedule","Schedule"),C2(e.metadata,"timezone","Timezone"),C2(e.metadata,"status","Status"),C2(e.metadata,"nextRunAt","Next run"),C2(e.metadata,"prompt","Prompt")]})]}),(i||l)&&a.jsxs("div",{className:pt.section,children:[a.jsx("div",{className:pt.sectionTitle,children:"Location"}),l?a.jsxs("div",{className:pt.locationRow,children:[a.jsx("a",{className:pt.link,href:l,target:"_blank",rel:"noopener noreferrer",onClick:m=>o(m,l),children:l}),a.jsx("a",{className:pt.openButton,href:l,target:"_blank",rel:"noopener noreferrer",onClick:m=>o(m,l),children:r("artifact.openLink")})]}):a.jsx("div",{className:pt.meta,children:i})]})]})}function C0n({status:e}){const{t}=Ct();return a.jsx("div",{className:pt.previewError,role:"alert",children:t("codeReview.unavailable",{status:e})})}function T0n(){const{t:e}=Ct();return a.jsx("div",{className:pt.previewError,role:"alert",children:e("codeReview.workspaceRequired")})}function I0n(e){const t=e.workspacePath?.toLowerCase()??"",n=ub(e.mimeType);return e.kind==="html"||t.endsWith(".html")||t.endsWith(".htm")||n==="text/html"}function R0n(e){const t=e.workspacePath?.toLowerCase()??"",n=ub(e.mimeType);return t.endsWith(".md")||t.endsWith(".markdown")||n==="text/markdown"}function E0n({artifact:e,workspaceActions:t}){const{t:n}=Ct(),[s,r]=d.useState(null),[o,i]=d.useState(!1),l=d.useRef(!0),c=iwe(e);d.useEffect(()=>(l.current=!0,()=>{l.current=!1}),[]);const u=async()=>{if(e.workspacePath){i(!0),r(null);try{await GP(t,e.workspacePath,e.mimeType,()=>!l.current)}catch(h){if(!l.current)return;r(h instanceof Error?h.message:String(h))}finally{l.current&&i(!1)}}};return a.jsx("div",{className:pt.detail,children:a.jsxs("div",{className:pt.section,children:[a.jsx("div",{className:pt.sectionTitle,children:n("common.download")}),a.jsxs("div",{className:pt.fieldGrid,children:[a.jsx(kp,{label:"Type",value:GG(e.kind,e.workspacePath)}),a.jsx(kp,{label:"Size",value:VP(e.sizeBytes)}),c?a.jsx(kp,{label:"Location",value:c}):null,e.status!=="available"&&e.status!=="changed"?a.jsx(kp,{label:"Status",value:e.status??"missing"}):null]}),a.jsx("div",{className:pt.downloadRow,children:a.jsx("button",{type:"button",className:pt.downloadButton,onClick:()=>{u()},disabled:o||e.status!=="available"&&e.status!=="changed",children:n(o?"common.downloading":"common.download")})}),s&&a.jsx("div",{className:pt.previewError,children:s})]})})}function A0n({tab:e}){const{t}=Ct(),n=el(),s=O4(e.workspaceCwd),r=s?.actions,o=Hp(),[i,l]=d.useState(0),[c,u]=d.useState(),[h,f]=d.useState(),[m,g]=d.useState(),w=e.source,y=w.locator,x=e.owner.isCurrent()&&n.sessionId===e.sourceSessionId&&n.capabilities?.features.includes("session_sources")&&s?.workspaceId===e.workspaceId&&(!!s||e.workspaceCwd===void 0&&y.type!=="workspace_file")&&(y.type!=="workspace_file"||w.workspaceCwd===n.workspaceCwd),k=y.type==="workspace_file"?y.workspacePath:y.type==="attachment"?y.attachmentId:"",_=/\.pdf$/i.test(k);if(d.useEffect(()=>{let I=!1;return u(void 0),f(void 0),g(void 0),!x||y.type==="url"?void 0:((async()=>{if(y.type==="attachment"){const A=await e.sessionActions.readAttachment(y.attachmentId);if(I||!e.owner.isCurrent())return;const j=Uint8Array.from(atob(A.data),L=>L.charCodeAt(0));u(new Blob([j],{type:A.mimeType}))}else if(_&&r){const A=await _4(r.readFileBytes,k,"application/pdf",{statFile:r.stat,isCancelled:()=>I||!e.owner.isCurrent()});!I&&e.owner.isCurrent()&&u(A)}})().catch(A=>{!I&&e.owner.isCurrent()&&f(Iu(A))}),()=>{I=!0})},[i,x,y,k,_,e.owner,e.sessionActions,r]),x&&y.type==="url")return a.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[a.jsx("h3",{children:w.title}),w.description&&a.jsx("p",{children:w.description}),a.jsx("p",{className:"break-all text-sm text-muted-foreground",children:y.url}),N4(y.url)&&a.jsx("a",{className:"text-primary underline",href:y.url,target:"_blank",rel:"noopener noreferrer",onClick:I=>o(I,y.url),children:t("sources.openOriginal")})]});if(!x||!s&&y.type!=="attachment")return a.jsx("div",{className:pt.empty,role:"alert",children:t("sources.unavailable")});const S=y.type==="workspace_file"&&!_&&swe({workspacePath:k});return a.jsxs("div",{className:"flex h-full min-h-0 flex-1 flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border px-3 py-2",children:[a.jsx("span",{className:"truncate text-xs text-muted-foreground",title:k,children:k}),a.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[m&&a.jsx(Wt,{variant:"ghost",size:"icon-sm",asChild:!0,children:a.jsx("a",{href:m,download:w.title,"aria-label":`Download ${w.title}`,title:t("common.download"),children:a.jsx(Vy,{})})}),h&&a.jsx(Wt,{variant:"ghost",size:"sm",onClick:()=>l(I=>I+1),children:t("common.retry")})]})]}),h?a.jsx("div",{className:pt.previewError,role:"alert",children:h}):S?a.jsxs("div",{className:"p-4",children:[a.jsx("p",{children:t("attachment.previewUnsupported")}),a.jsx(Wt,{onClick:()=>void GP(r,k,"application/octet-stream",()=>!e.owner.isCurrent()).catch(I=>{e.owner.isCurrent()&&f(Iu(I))}),children:t("common.download")})]}):(y.type==="attachment"||_)&&!c?a.jsx("div",{className:pt.empty,role:"status",children:t("common.loading")}):c&&c.type!=="application/pdf"&&!i4(c.type,k)?a.jsx(SRe,{data:c,title:w.title,onDownloadUrl:g,showDownload:!1,image:!!FS(k)&&c.type.startsWith("image/")}):a.jsx("div",{className:"relative min-h-0 flex-1 overflow-auto",children:a.jsx(oD,{workspacePath:k,workspaceActions:r,onLoadError:f,previewData:c,previewOnly:y.type==="attachment",previewMimeType:c?.type,previewKind:/\.html?$/i.test(k)||ub(c?.type)==="text/html"?"source":void 0},i)})]})}function SRe({data:e,title:t,image:n,onDownloadUrl:s,showDownload:r=!0}){const[o,i]=d.useState();return d.useEffect(()=>{const l=URL.createObjectURL(e);return i(l),s?.(l),()=>URL.revokeObjectURL(l)},[e,s]),o?a.jsxs("div",{className:pt.imagePreviewWrap,children:[n?a.jsx("img",{className:pt.imagePreview,src:o,alt:t}):a.jsx(CRe,{name:t,mimeType:e.type,size:e.size}),r&&a.jsx("a",{href:o,download:t,"aria-label":`Download ${t}`,children:a.jsx(Vy,{})})]}):null}function oD({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewSizeBytes:r,previewData:o,previewMimeType:i,imageMimeType:l,previewKind:c,previewOnly:u,onLoadError:h}){if(o)return a.jsx(j0n,{workspacePath:e,workspaceActions:n,data:o,mimeType:i,previewKind:c,onLoadError:h});const f=e.toLowerCase(),m=l??FS(e),g=c??(f.endsWith(".html")||f.endsWith(".htm")?"html":f.endsWith(".md")||f.endsWith(".markdown")?"markdown":m?"image":"source");return g==="html"?a.jsx(L0n,{workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewSizeBytes:r,previewOnly:u,onLoadError:h}):g==="markdown"?a.jsx(O0n,{workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewSizeBytes:r,previewOnly:u,onLoadError:h}):g==="image"&&m?a.jsx(P0n,{workspacePath:e,artifactVersion:t,workspaceActions:n,mimeType:m,onLoadError:h}):a.jsx(TRe,{workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:u,onLoadError:h})}function j0n({workspacePath:e,workspaceActions:t,data:n,mimeType:s,previewKind:r,onLoadError:o}){const i=(s||n.type||"application/octet-stream").split(";",1)[0].trim().toLowerCase();return i==="application/pdf"?a.jsx(M0n,{data:n,mimeType:i,title:e}):i4(i,e)?a.jsx(N0n,{workspacePath:e,workspaceActions:t,data:n,previewKind:r,onLoadError:o}):a.jsx(CRe,{name:e,mimeType:i,size:n.size})}function N0n({workspacePath:e,workspaceActions:t,data:n,previewKind:s,onLoadError:r}){const{t:o}=Ct(),[i,l]=d.useState(),[c,u]=d.useState();return d.useEffect(()=>{const h=new FileReader;return l(void 0),u(void 0),h.onload=()=>l(String(h.result??"")),h.onerror=()=>{const f=o("attachment.readFailed");u(f),r?.(f)},h.readAsText(n),()=>{h.readyState===FileReader.LOADING&&h.abort()}},[n,r,o]),c?a.jsx("div",{className:pt.previewError,children:c}):i===void 0?a.jsx("div",{className:pt.empty,children:o("attachment.loadingFile")}):a.jsx(oD,{workspacePath:e,workspaceActions:t,previewContent:i,previewSizeBytes:n.size,previewOnly:!0,previewKind:s})}function M0n({data:e,mimeType:t,title:n}){const{t:s}=Ct(),[r,o]=d.useState();return d.useEffect(()=>{const i=URL.createObjectURL(e.type===t?e:new Blob([e],{type:t}));return o(i),()=>URL.revokeObjectURL(i)},[e,t]),r?a.jsx("iframe",{className:pt.pdfAttachmentPreview,src:r,title:`Preview ${n}`}):a.jsx("div",{className:pt.empty,children:s("attachment.loadingPreview")})}function CRe({name:e,mimeType:t,size:n}){const{t:s}=Ct();return a.jsxs("div",{className:pt.unsupportedAttachmentPreview,children:[a.jsx(U0,{name:e,mimeType:t,"aria-hidden":"true"}),a.jsx("div",{children:s("attachment.previewUnsupported")}),a.jsxs("div",{className:pt.unsupportedAttachmentMeta,children:[t," · ",VP(n)]})]})}function P0n({workspacePath:e,artifactVersion:t,workspaceActions:n,mimeType:s,onLoadError:r}){const[o,i]=d.useState(null),[l,c]=d.useState(null);return d.useEffect(()=>{let u=!1,h;return i(null),c(null),_4((f,m)=>n.readFileBytes(f,m),e,s,{statFile:f=>n.stat(f),isCancelled:()=>u}).then(f=>{u||(h=URL.createObjectURL(f),i(h))}).catch(f=>{if(u)return;const m=f instanceof Error?f.message:String(f);c(m),r?.(m)}),()=>{u=!0,h&&URL.revokeObjectURL(h)}},[t,s,r,n,e]),a.jsxs("div",{className:pt.imagePreviewWrap,children:[o?a.jsxs(a.Fragment,{children:[a.jsx("img",{className:pt.imagePreview,src:o,alt:y8(e)}),a.jsx("a",{className:pt.imageDownloadButton,href:o,download:y8(e),"aria-label":`Download ${y8(e)}`,title:"Download",children:a.jsx(Vy,{size:16,strokeWidth:1.8})})]}):l?null:a.jsx("div",{className:pt.empty,children:"Loading image..."}),l&&a.jsx("div",{className:pt.previewError,children:l})]})}function SZ({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:r,onLoadError:o}){const[i,l]=d.useState(s??null),[c,u]=d.useState(),[h,f]=d.useState(null);return d.useEffect(()=>{let m=!1;if(l(s??null),f(null),u(void 0),!r)return n.stat(e).then(g=>{if(!m){if(g.type==="directory")throw new Error("Directories cannot be opened as artifacts.");return n.readWorkspaceFile(e,{maxBytes:256*1024})}}).then(async g=>{if(m||!g||!g.truncated)return g;const w=await _4((y,x)=>n.readFileBytes(y,x),e,"application/octet-stream",{statFile:y=>n.stat(y),isCancelled:()=>m});return{sizeBytes:w.size,content:new TextDecoder(g.encoding||"utf-8").decode(await w.arrayBuffer())}}).then(g=>{m||!g||(u(g.sizeBytes),l(g.content))}).catch(g=>{if(m)return;const w=g instanceof Error?g.message:String(g);f(w),o?.(w)}),()=>{m=!0}},[t,s,r,o,n,e]),{content:i,error:h,sizeBytes:c}}function L0n({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewSizeBytes:r,previewOnly:o,onLoadError:i}){const{content:l,error:c,sizeBytes:u}=SZ({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:o,onLoadError:i});return a.jsxs("div",{className:pt.htmlPreviewWrap,children:[l===null?!c&&a.jsx("div",{className:pt.empty,children:"Loading preview..."}):a.jsx(IRe,{content:l,sizeBytes:u??r,workspacePath:e,workspaceActions:n,children:()=>a.jsx(D0n,{content:l,workspacePath:e})}),c&&a.jsx("div",{className:pt.previewError,children:c})]})}function D0n({content:e,workspacePath:t}){const n=`Preview ${t}`,{t:s}=Ct(),[r,o]=d.useState(null),[i,l]=d.useState(null);return d.useEffect(()=>{const c=new AbortController;return o(null),l(null),hVe(e,n,c.signal).then(u=>{c.signal.aborted||o(u)},u=>{c.signal.aborted||l(Iu(u))}),()=>c.abort()},[e,n]),i?a.jsx("div",{className:pt.previewError,children:s("artifact.previewFailed",{message:i})}):r===null?a.jsx("div",{className:pt.empty,children:s("attachment.loadingPreview")}):a.jsx("iframe",{className:pt.htmlPreview,referrerPolicy:"no-referrer",sandbox:"allow-scripts",srcDoc:r,title:n})}function TRe({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:r,onLoadError:o}){const i=d.useRef(null),[l,c]=d.useState(null),{content:u,error:h}=SZ({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:r,onLoadError:o});return d.useEffect(()=>{const f=i.current;if(!f||u===null)return;f.replaceChildren(),c(null);let m;try{m=new js({doc:u,extensions:[vTe,js.editable.of(!1),ua.readOnly.of(!0),js.lineWrapping],parent:f})}catch(g){c(g instanceof Error?g.message:String(g));return}return()=>m.destroy()},[u]),a.jsxs("div",{className:pt.filePreviewWrap,children:[u===null?!h&&a.jsx("div",{className:pt.empty,children:"Loading file..."}):a.jsx("div",{ref:i,className:pt.codeMirrorFile}),(h||l)&&a.jsx("div",{className:pt.previewError,children:h||l})]})}function IRe({content:e,sizeBytes:t,workspacePath:n,workspaceActions:s,children:r}){const{t:o}=Ct(),[i,l]=d.useState(null);if(!d.useMemo(()=>(t??new TextEncoder().encode(e).byteLength)>1024*1024,[e,t]))return r();const u=i===e;return a.jsxs("div",{className:"absolute inset-3 flex min-h-0 flex-col gap-2",children:[a.jsxs("div",{className:"flex shrink-0 items-center gap-2 text-sm text-muted-foreground",children:[a.jsx("span",{children:o("artifact.longDocument")}),a.jsx(Wt,{className:"ml-auto shrink-0",variant:"outline",size:"sm",onClick:()=>l(u?null:e),children:o(u?"artifact.showSource":"artifact.renderFullPreview")})]}),a.jsx("div",{className:"relative min-h-0 flex-1 overflow-auto",children:u?r():a.jsx(TRe,{workspacePath:n,workspaceActions:s,previewContent:e,previewOnly:!0})})]})}function O0n({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewSizeBytes:r,previewOnly:o,onLoadError:i}){const{content:l,error:c,sizeBytes:u}=SZ({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:o,onLoadError:i});return a.jsxs("div",{className:pt.htmlPreviewWrap,children:[l===null?!c&&a.jsx("div",{className:pt.empty,children:"Loading preview..."}):a.jsx(IRe,{content:l,sizeBytes:u??r,workspacePath:e,workspaceActions:n,children:()=>a.jsx("div",{className:pt.markdownPreviewWrap,children:a.jsx(Im,{content:l})})}),c&&a.jsx("div",{className:pt.previewError,children:c})]})}function kp({label:e,value:t}){return t?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:pt.fieldLabel,children:e}),a.jsx("span",{className:pt.fieldValue,children:t})]}):null}function C2(e,t,n){const s=e[t];return s==null||s===""?null:a.jsx(kp,{label:n,value:String(s)},t)}/**
2216
+ `);return n===-1?t:t.slice(0,n)}function zgn(e,t){if(e.kind==="request"){const n=[kh(e.timing.durationMs)];return e.timing.ttftMs!==void 0&&n.push(t("trajectory.ttft",{duration:kh(e.timing.ttftMs)})),e.usage&&n.push($gn(e.usage)),n}if(e.kind==="tool"){const n=[];if(e.timing&&n.push(kh(e.timing.durationMs)),e.subagentSummary){const{requests:s,tools:r,requestMs:o}=e.subagentSummary;n.push(t("trajectory.subagentRollup",{requests:s,tools:r,duration:kh(o)}))}return n}return[]}function yue(e){const t=e.toolStatus??e.block.status;if(t==="error"||t==="failed")return Ua.toneError;if(t==="cancelled")return Ua.toneMuted}function Hgn(e,t){switch(e.kind){case"user":return{badge:t("trajectory.badge.user"),text:yE(e.block.text)};case"request":{const n=Fgn(e),s=e.status==="error",r=n!==void 0?`${n}${e.model?` · ${e.model}`:""}`:e.model??t("trajectory.request");return{badge:n!==void 0?t("trajectory.badge.subagent"):`#${e.requestIndex??"?"}`,...s?{badgeTone:Ua.toneError}:{},text:s?`${r} · ${t("trajectory.requestFailed")}`:r}}case"message":return{badge:e.thought?t("trajectory.badge.thought"):t("trajectory.badge.message"),text:yE(e.block.text),faint:e.thought};case"tool":return{badge:e.block.toolName??t("trajectory.badge.tool"),...yue(e)?{badgeTone:yue(e)}:{},text:e.block.title||(e.block.toolName??"")};default:return Ugn(e.block,t)}}function Ugn(e,t){switch(e.kind){case"shell":return{badge:t("trajectory.badge.shell"),text:yE(e.text)};case"user_shell":return{badge:t("trajectory.badge.shell"),text:yE(e.command||e.text)};case"permission":return{badge:t("trajectory.badge.permission"),text:e.title||e.toolName||""};case"status":case"error":case"debug":return{badge:t("trajectory.badge.status"),...e.kind==="error"?{badgeTone:Ua.toneError}:{},text:yE(e.text),faint:e.kind!=="error"};case"prompt_cancelled":return{badge:t("trajectory.badge.cancelled"),badgeTone:Ua.toneMuted,text:e.reason??t("trajectory.cancelled"),faint:!0};default:return{badge:t("trajectory.badge.other"),text:""}}}function Wgn(e){return e.rows.some(t=>t.kind==="request"||t.kind==="tool"&&t.timing!==void 0)}function qgn({loadPage:e}){const{t}=Ct(),{trajectory:n,status:s,error:r,truncated:o,refresh:i}=ugn(e),[l,c]=d.useState(void 0),u=d.useRef(null),h=d.useRef(!1),f=d.useRef(0),m=d.useId(),g=d.useCallback(R=>`${m}-row-${R}`,[m]),w=d.useCallback((R,N)=>{R.scrollTop=N,f.current=R.scrollTop},[]),y=d.useMemo(()=>{if(!n)return[];const R=new Map(n.rows.map(M=>[M.key,M])),N=[];for(const M of n.turns){const O=M.userRowKey??`ordinal:${M.index}`;N.push({kind:"turn",key:`turn:${O}`,turn:M});for(const P of M.rowKeys){const F=R.get(P);F&&N.push({kind:"row",key:P,row:F})}}return N},[n]),x=wwe({count:y.length,getScrollElement:()=>u.current,getItemKey:R=>y[R]?.key??R,estimateSize:()=>vue,overscan:12}),k=y.length>0;d.useLayoutEffect(()=>{const R=u.current;if(!R||typeof ResizeObserver>"u")return;let N=0;const M=()=>{R.scrollTop===0&&f.current>0&&(R.scrollTop=f.current)},O=new ResizeObserver(()=>{M(),N=requestAnimationFrame(M)});return O.observe(R),()=>{O.disconnect(),N!==0&&cancelAnimationFrame(N)}},[k]),d.useEffect(()=>{if(s!=="ready"||h.current||y.length===0)return;h.current=!0;const R=u.current;R&&w(R,R.scrollHeight)},[w,s,y.length]);const _=d.useMemo(()=>l===void 0?-1:y.findIndex(R=>R.key===l),[l,y]),S=d.useCallback(R=>{if(y.length===0)return;const N=Math.min(Math.max(R,0),y.length-1);c(y[N].key),x.scrollToIndex(N,{align:"auto"})},[x,y]),I=d.useCallback(R=>{c(R),u.current?.focus({preventScroll:!0})},[]),E=d.useCallback(R=>{if(y.length===0)return;const N=_<0?-1:_;R.key==="ArrowDown"?(R.preventDefault(),S(N+1)):R.key==="ArrowUp"?(R.preventDefault(),S(N<=0?0:N-1)):R.key==="Home"?(R.preventDefault(),S(0)):R.key==="End"&&(R.preventDefault(),S(y.length-1))},[S,_,y]),A=d.useMemo(()=>{if(!n)return;let R=0,N=0,M=0;for(const O of n.turns)R+=O.requestCount,N+=O.toolCount,M+=O.requestMs;return{turns:n.turns.length,requests:R,tools:N,durationMs:M}},[n]),j=s==="ready"&&y.length===0,L=n!==void 0&&y.length>0&&!Wgn(n);return a.jsxs("div",{className:Ua.panel,"data-testid":"trajectory-panel",children:[a.jsxs("div",{className:Ua.header,children:[a.jsx("div",{className:Ua.summary,children:A?a.jsx("span",{"data-testid":"trajectory-totals",children:t("trajectory.totals",{turns:A.turns,requests:A.requests,tools:A.tools,duration:A.durationMs>0?kh(A.durationMs):"—"})}):a.jsx("span",{children:t("trajectory.title")})}),a.jsx("div",{className:Ua.headerActions,children:a.jsx("button",{type:"button",className:Ua.iconButton,onClick:i,disabled:!e||s==="loading",title:t("common.refresh"),"aria-label":t("common.refresh"),children:a.jsx(Hg,{size:14,strokeWidth:1.6})})})]}),r!==void 0&&a.jsxs("div",{className:Ua.error,role:"alert",children:[a.jsx("span",{children:r.kind==="partial"?t("trajectory.partial"):t("trajectory.loadFailed",{message:r.message})}),a.jsx("button",{type:"button",className:Ua.headerButton,onClick:i,disabled:s==="loading",children:t("common.retry")})]}),L&&a.jsx("div",{className:Ua.notice,role:"status",children:t("trajectory.noTiming")}),a.jsx("div",{className:Ua.tableWrap,children:y.length===0?s==="error"?null:a.jsx("div",{className:Ua.placeholder,role:"status",children:t(j?"trajectory.empty":"common.loading")}):a.jsxs(a.Fragment,{children:[o&&a.jsx("div",{className:Ua.olderBar,children:a.jsx("span",{className:Ua.olderNotice,"data-testid":"trajectory-truncated",children:t("trajectory.truncated")})}),a.jsx("div",{ref:u,className:Ua.scroll,role:"grid",tabIndex:0,"aria-label":t("trajectory.title"),"aria-rowcount":y.length,"aria-activedescendant":_>=0?g(_):void 0,onKeyDown:E,onScroll:R=>{f.current=R.currentTarget.scrollTop},"data-testid":"trajectory-rows",children:a.jsx("div",{className:Ua.virtualBody,style:{height:`${x.getTotalSize()}px`},children:x.getVirtualItems().map(R=>{const N=y[R.index];return a.jsx("div",{id:g(R.index),className:Ua.virtualRow,style:{height:`${vue}px`,transform:`translateY(${R.start}px)`},role:"row","aria-rowindex":R.index+1,children:N.kind==="turn"?a.jsx(Vgn,{turn:N.turn,selected:N.key===l,onSelect:()=>I(N.key)}):a.jsx(Ggn,{row:N.row,selected:N.key===l,onSelect:()=>I(N.key)})},R.key)})})})]})})]})}function Vgn({turn:e,selected:t,onSelect:n}){const{t:s}=Ct();return a.jsxs("div",{className:`${Ua.turnHeader} ${t?Ua.selected:""}`,onClick:n,"aria-selected":t,"data-selected":t?"true":void 0,role:"gridcell","data-testid":"trajectory-turn",children:[a.jsx("span",{className:Ua.turnTitle,children:e.partial?s("trajectory.turnPartial",{index:e.index}):s("trajectory.turn",{index:e.index})}),a.jsx("span",{className:Ua.turnSummary,children:s("trajectory.turnSummary",{requests:e.requestCount,tools:e.toolCount,duration:e.requestMs>0?kh(e.requestMs):"—"})})]})}function Ggn({row:e,selected:t,onSelect:n}){const{t:s}=Ct(),r=Hgn(e,s),o=zgn(e,s);return a.jsxs("div",{className:`${Ua.record} ${t?Ua.selected:""}`,role:"gridcell","aria-selected":t,"data-selected":t?"true":void 0,onClick:n,"data-testid":`trajectory-row-${e.kind}`,"data-depth":e.depth,children:[e.depth>0&&a.jsx(zHe,{size:12,strokeWidth:1.6,className:Ua.nestMarker,"aria-hidden":"true"}),a.jsx("span",{className:`${Ua.badge} ${r.badgeTone??""}`,children:r.badge}),a.jsx("span",{className:`${Ua.text} ${r.faint?Ua.faint:""}`,children:r.text}),a.jsx("span",{className:Ua.metrics,"data-testid":"trajectory-row-metrics",children:o.length>0?o.join(" · "):"—"})]})}const Kgn="_panel_pwtdr_1",Ygn="_toolbar_pwtdr_5",Xgn="_actions_pwtdr_15",Zgn="_feedback_pwtdr_21",Jgn="_state_pwtdr_31",ky={panel:Kgn,toolbar:Ygn,actions:Xgn,feedback:Zgn,state:Jgn};function Qgn({sessionActions:e,sessionId:t,controls:n}){const{t:s}=Ct(),[r,o]=d.useState(null),[i,l]=d.useState(!0),[c,u]=d.useState(!1),h=d.useRef(0),f=d.useRef(()=>{}),m=d.useRef(null),g=n?.sessionId===t?n:void 0,w=g?.getContextUsage??e?.getContextUsage,y=d.useRef(g);y.current=g;const x=g?.result,[k,_]=d.useState(x),S=!!(x&&x!==k&&(x.kind!=="completed"||!c));d.useEffect(()=>{x?.kind==="completed"&&(h.current++,o(x.usage),u(!1))},[x]),d.useEffect(()=>{let A=!0,j=!1;const L=y.current?.result;o(N=>N?.sessionId===t?N:L?.kind==="completed"?L.usage:null),u(!1),l(!!w);const R=async()=>{if(!A||j||!w)return;j=!0,l(!0),u(!1);const N=h.current,M=m.current,O=M&&M.getContextUsage===w&&M.sessionId===t?M:{getContextUsage:w,sessionId:t,promise:w({detail:!0,silent:!0,...y.current?.result?{syncCounters:!0}:{}})};m.current=O;try{const P=await O.promise;if(!A||N!==h.current)return;o(P.sessionId===t&&P.usage.contextWindowSize>0?P:null)}catch(P){if(!A||N!==h.current)return;u(DV(P)?"transient":"hard")}finally{j=!1,m.current===O&&(m.current=null),A&&l(!1)}};return f.current=()=>void R(),R(),()=>{A=!1}},[w,t]);const I=!w||i||g?.compressing,E=()=>{_(x),f.current()};return a.jsxs("div",{className:ky.panel,"aria-busy":i,children:[a.jsxs("div",{className:ky.toolbar,children:[a.jsx("span",{children:s("contextUsage.title")}),a.jsxs("div",{className:ky.actions,children:[a.jsx(Wt,{type:"button",variant:"ghost",size:"icon-sm","aria-label":s("contextUsage.refresh"),title:s("contextUsage.refresh"),disabled:I,onClick:E,children:a.jsx(Hg,{"aria-hidden":"true"})}),a.jsx("span",{title:g?.compressing?void 0:g?.canCompress?i?s("common.loading"):void 0:s("contextUsage.compressUnavailable"),children:a.jsx(Wt,{type:"button",variant:"outline",size:"sm",disabled:!g?.canCompress||i,onClick:()=>void g?.compress(),children:s(g?.compressing?"contextUsage.compressing":"contextUsage.compress")})})]})]}),(g?.compressing||S)&&a.jsx(i4e,{controls:g,className:ky.feedback}),c==="transient"&&r&&a.jsx("div",{className:ky.feedback,role:"status",children:s("contextUsage.previousReading")}),c==="hard"?a.jsxs("div",{className:ky.state,role:"alert",children:[a.jsx("span",{children:s("contextUsage.loadError")}),a.jsx(Wt,{type:"button",variant:"outline",size:"sm",disabled:I,onClick:E,children:s("contextUsage.retry")})]}):w?i&&!r?a.jsx("div",{className:ky.state,role:"status",children:s("common.loading")}):r?a.jsx(Sxe,{status:r,compact:!0}):a.jsx("div",{className:ky.state,children:s("contextUsage.unavailable")}):a.jsx("div",{className:ky.state,children:s("contextUsage.unavailable")})]})}const e0n=700,t0n=["daily","weekdays","weekly","hourly","minutes","custom"],n0n=[1,2,3,4,5,6,10,12,15,20,30],s0n=(e,t)=>{},r0n=(e,t,n)=>{},o0n=()=>Promise.reject(new Error("Side-task session creation is unavailable"));function bue(e){return e.kind==="review"||e.kind==="file"||e.kind==="artifact"||e.kind==="scheduled_task"}function _y(e){return e.kind==="pending"?e.targetKind:e.kind}function i0n(e){return`image.${(e.match(/^data:image\/([a-z0-9+.+-]+)/i)?.[1]??"png").split("+")[0].toLowerCase()}`}const a0n=["review","sideTask"];function xue({contextUsageControls:e,artifacts:t,tabs:n,activeTabId:s,reviewChanges:r,selectedReviewPath:o,panelWidth:i,workspaceCwd:l,loading:c,restoring:u=!1,error:h,onSelectTab:f,onCloseTab:m,onOpenFilePreview:g,latestReviewAvailable:w=!1,onOpenLatestReview:y,onOpenTerminal:x,onOpenTrajectory:k,trajectoryTabId:_,onOpenWebPreview:S,onWebPreviewChange:I,items:E=a0n,sideTaskAvailable:A=!1,sideTasks:j=[],sideTasksLoading:L=!1,onCreateSideTask:R,onOpenSideTask:N,onCreateSideTaskSession:M,onSideTaskCreated:O,onSideTaskTitleChange:P,onNestedRightPanelOpen:F,onNestedArtifactsChange:H,onOpenNestedSubagent:$,agentTasks:Y=[],agentTraceLoading:Z=!1,agentTraceError:K,onOpenWorkflowAgent:B,onError:V,sessionWorkflowEnabled:J,workflow:q,onImageIngestionNotice:te,deferSubagentMount:ie=!1,onClose:ge,variant:re="docked",fullscreen:G=!1,onToggleFullscreen:Q}){const{t:he}=Ct(),[ve,ye]=d.useState(!1),[_e,ae]=d.useState(),Se=d.useRef(null),Te=d.useCallback(()=>{Se.current&&(clearTimeout(Se.current),Se.current=null),ye(!0)},[]),Ne=d.useCallback(()=>{Se.current&&clearTimeout(Se.current),Se.current=setTimeout(()=>{ye(!1),Se.current=null},120)},[]);d.useEffect(()=>()=>{Se.current&&clearTimeout(Se.current)},[]);const Ae=n.find(ke=>ke.id===s)??n[0],Ve=Ae?.kind==="file"&&Ae.sourcePreview&&(/\.html?$/i.test(Ae.workspacePath)||ub(Ae.previewMimeType||Ae.previewData?.type)==="text/html"),Ze=Ae?.kind==="file"&&Ae.previewOnly===!0&&!Ve&&/\.(?:html?|md|markdown)$/i.test(Ae.workspacePath)&&(Ae.previewContent!==void 0||!Ae.previewData||!!i4(Ae.previewMimeType||Ae.previewData.type,Ae.workspacePath)),Tt=_e===Ae?.id,je=E.includes("review")&&!n.some(ke=>_y(ke)==="review"),ot=E.includes("sideTask")&&A&&!!R,Ie=!!x,ue=E.includes("webPreview")&&!!S,W=E.includes("trajectory")&&!!k&&!n.some(ke=>ke.id===_),ne=!!Ae&&(je||ot||Ie||ue||W),me=Ae&&bue(Ae)?{workspaceCwd:Ae.workspaceCwd,workspaceId:Ae.workspaceId}:void 0,Me=O4(me?.workspaceCwd),Ke=Me?.workspaceId===me?.workspaceId?Me?.actions:void 0,be=Ae?.kind==="artifact"?t.find(ke=>ke.id===Ae.artifactId):void 0;return a.jsxs("aside",{className:`${pt.panel} ${re==="drawer"?pt.panelDrawer:""} ${G?pt.panelFullscreen:""}`,style:re==="docked"&&i&&!G?{flexBasis:i,width:i}:void 0,"aria-label":"Right panel",children:[a.jsxs("div",{className:pt.header,children:[n.length>0&&a.jsx("div",{className:pt.tabs,role:"tablist","aria-label":"Right panel",children:n.map(ke=>a.jsxs("div",{className:[pt.tabItem,ke.id===Ae?.id?pt.tabActive:""].filter(Boolean).join(" "),children:[a.jsxs("button",{type:"button",role:"tab","aria-selected":ke.id===Ae?.id,className:pt.tab,onClick:()=>f(ke.id),onMouseEnter:Pe=>yT(Pe.currentTarget),onFocus:Pe=>yT(Pe.currentTarget),title:ke.title,children:[a.jsx("span",{className:`${pt.tabIcon} ${_y(ke)==="artifact"?pt.tabArtifactIcon:""}`,"aria-hidden":"true",children:_y(ke)==="review"?a.jsx(GF,{}):ke.kind==="workflow"?a.jsx(zve,{className:pt.tabIconSvg,strokeWidth:1.6}):ke.kind==="file"?a.jsx(U0,{name:ke.workspacePath,className:pt.tabIconSvg,strokeWidth:1.6}):_y(ke)==="artifact"?a.jsx(uwe,{artifact:t.find(Pe=>"artifactId"in ke&&Pe.id===ke.artifactId),className:pt.tabIconSvg}):_y(ke)==="subagent"?a.jsx(l0n,{}):_y(ke)==="monitor"?a.jsx(Yve,{className:pt.tabIconSvg,strokeWidth:1.6}):_y(ke)==="shell"?a.jsx(Y2,{className:pt.tabIconSvg,strokeWidth:1.6}):_y(ke)==="side_task"?a.jsx(Aj,{className:pt.tabIconSvg,strokeWidth:1.6}):ke.kind==="web_preview"?a.jsx(hT,{className:pt.tabIconSvg}):ke.kind==="terminal"?a.jsx(Y2,{className:pt.tabIconSvg,strokeWidth:1.6}):_y(ke)==="image"?a.jsx(UUe,{className:pt.tabIconSvg,strokeWidth:1.6}):ke.kind==="context_usage"?a.jsx(WP,{className:pt.tabIconSvg,strokeWidth:1.6}):ke.kind==="token_usage"?a.jsx(UG,{className:pt.tabIconSvg,strokeWidth:1.6}):ke.kind==="trajectory"?a.jsx(GO,{className:pt.tabIconSvg,strokeWidth:1.6}):a.jsx(u0n,{})}),a.jsx("span",{className:pt.tabTitle,"data-web-shell-session-title":!0,children:a.jsx("span",{className:pt.tabTitleInner,children:ke.title})})]}),a.jsx("button",{type:"button",className:pt.tabCloseButton,onClick:()=>m(ke.id),"aria-label":`Close ${ke.title}`,title:"Close",children:a.jsx(c0n,{})})]},ke.id))}),a.jsxs("div",{className:pt.headerActions,children:[ne&&a.jsxs(Z0,{modal:!1,children:[a.jsx(Vg,{asChild:!0,children:a.jsx("button",{type:"button",className:`${pt.iconButton} ${pt.addButton}`,"aria-label":he("rightPanel.add"),title:he("rightPanel.add"),children:a.jsx(Qf,{className:pt.toolbarIcon})})}),a.jsxs(Gg,{align:"end",className:"w-64",children:[je&&a.jsxs(yi,{disabled:!w||!y,onSelect:y,children:[a.jsx(GF,{}),a.jsx("span",{className:pt.sideTaskListTitle,children:he("turnOutputs.review")})]}),je&&ot&&a.jsx(ax,{}),ot&&a.jsxs(yi,{disabled:L,onSelect:R,children:[a.jsx(Aj,{className:pt.sideTaskNewIcon,strokeWidth:1.6,"aria-hidden":"true"}),a.jsx("span",{className:pt.sideTaskListTitle,children:he("sideTask.create")})]}),Ie&&(je||ot)&&a.jsx(ax,{}),Ie&&a.jsxs(yi,{onSelect:()=>x?.(),children:[a.jsx(Y2,{className:pt.sideTaskNewIcon,strokeWidth:1.6,"aria-hidden":"true"}),a.jsx("span",{className:pt.sideTaskListTitle,children:he("terminal.title")})]}),ue&&a.jsxs(yi,{onSelect:S,children:[a.jsx(hT,{className:pt.sideTaskNewIcon}),a.jsx("span",{className:pt.sideTaskListTitle,children:he("webPreview.title")})]}),W&&a.jsxs(yi,{onSelect:()=>k?.(),children:[a.jsx(GO,{className:pt.sideTaskNewIcon,strokeWidth:1.6,"aria-hidden":"true"}),a.jsx("span",{className:pt.sideTaskListTitle,children:he("trajectory.title")})]})]})]}),Q&&a.jsx("button",{type:"button",className:`${pt.iconButton} ${pt.fullscreenButton} ${G?pt.iconButtonActive:""}`,onClick:Q,"aria-label":he(G?"common.exitFullscreen":"common.fullscreen"),"aria-pressed":G,title:he(G?"common.exitFullscreen":"common.fullscreen"),children:G?a.jsx(qG,{className:pt.toolbarIcon,"aria-hidden":!0}):a.jsx(zG,{className:pt.toolbarIcon,"aria-hidden":!0})}),a.jsx("button",{type:"button",className:`${pt.iconButton} ${pt.panelToggleButton}`,onClick:ge,"aria-label":he("chatHeader.toggleRightPanel"),"aria-pressed":"true",title:he("chatHeader.toggleRightPanel"),children:a.jsx(Hve,{className:pt.panelToggleIcon})})]})]}),a.jsxs("div",{className:`${pt.body} ${Ae?.kind==="side_task"?pt.bodySideTask:""}`.trim(),children:[n.filter(ke=>ke.kind==="web_preview").map(ke=>a.jsx("div",{className:"h-full",hidden:ke.id!==Ae?.id,children:a.jsx(lmn,{state:ke,onChange:Pe=>I?.(ke.id,Pe)})},ke.id)),n.filter(ke=>ke.kind==="terminal").map(ke=>a.jsx("div",{className:`${pt.terminalPane} ${ke.id===Ae?.id?"":pt.terminalPaneHidden}`.trim(),"aria-hidden":ke.id===Ae?.id?void 0:!0,children:a.jsx(amn,{terminalId:ke.id,cwd:ke.workspaceCwd??l,active:ke.id===Ae?.id,enabled:ke.initialized!==!1})},ke.id)),Ze&&a.jsxs("button",{type:"button",className:pt.attachmentPreviewButton,onClick:()=>ae(Tt?void 0:Ae?.id),"aria-label":he(Tt?"attachment.showSource":"attachment.showPreview"),"aria-pressed":Tt,children:[Tt?a.jsx(PHe,{"aria-hidden":!0}):a.jsx(Pve,{"aria-hidden":!0}),he(Tt?"attachment.showSource":"attachment.showPreview")]}),u&&!Ae?a.jsxs("div",{className:"flex flex-col gap-4 p-5","data-testid":"right-panel-loading-skeleton",role:"status","aria-label":he("common.loading"),children:[a.jsx(ow,{className:"h-5 w-2/5"}),a.jsx(ow,{className:"h-32 w-full"}),a.jsx(ow,{className:"h-4 w-4/5"}),a.jsx(ow,{className:"h-4 w-3/5"})]}):Ae?.kind==="terminal"||Ae?.kind==="web_preview"?null:Ae?Ae.kind==="pending"?a.jsx("div",{className:pt.empty,role:Ae.loadError?"alert":"status",children:Ae.loadError??he("common.loading")}):Ae.kind==="workflow"?Ae.sessionId?a.jsx(tdn,{tasks:Y,loading:Z,error:K,onOpenAgent:B}):q?a.jsx(Udn,{...q}):a.jsx("div",{className:pt.empty,children:he("workflow.empty.title")}):bue(Ae)&&(Ae.kind!=="scheduled_task"||Ae.task.durable)&&(Ae.kind!=="file"||!Ae.previewOnly)&&(Ae.kind!=="artifact"||be?.metadata?.artifactType!=="web_preview_snapshot")&&!Ke?a.jsx("div",{className:pt.empty,role:"alert",children:he("workspace.notFoundDescription")}):Ae.kind==="review"?a.jsx(f0n,{changes:Ae.changes??r,selectedPath:Ae.selectedPath??o,workspaceCwd:Ae.workspaceCwd??l,onOpenFilePreview:ke=>g(ke,Ae.workspaceCwd??l,Ae.workspaceId),onDownloadFile:(ke,Pe)=>GP(Ke,ke.path,dVe(ke.path),Pe),onDownloadError:ke=>{const Pe=he("common.downloadFailed",{message:Iu(ke)});V?V(new Error(Pe,{cause:ke}),Pe):console.error(Pe,ke)}}):Ae.kind==="file"?Ae.attachmentId&&!Ae.previewData&&Ae.previewContent===void 0?a.jsx("div",{className:pt.empty,role:Ae.loadError?"alert":"status",children:Ae.loadError??he("common.loading")}):Ae.sourcePreview&&Ae.previewData&&ub(Ae.previewMimeType||Ae.previewData.type)!=="application/pdf"&&!i4(Ae.previewMimeType||Ae.previewData.type,Ae.workspacePath)?a.jsx(SRe,{data:Ae.previewData,title:Ae.title,image:!!FS(Ae.workspacePath)&&Ae.previewData.type.startsWith("image/")}):a.jsx(oD,{workspacePath:Ae.workspacePath,artifactVersion:String(Ae.previewVersion??0),workspaceActions:Ke,previewContent:Ae.previewContent,previewData:Ae.previewData,previewMimeType:Ae.previewMimeType,previewOnly:Ae.previewOnly,previewKind:Ve||Ae.previewOnly&&!Tt?"source":void 0},Ae.id):Ae.kind==="source"?a.jsx(A0n,{tab:Ae},Ae.id):Ae.kind==="artifact"?a.jsx(d0n,{artifacts:t,artifactId:Ae.artifactId,sourceSessionId:Ae.sourceSessionId,workspaceActions:Ke,previewContent:Ae.previewContent,loading:c,error:h},Ae.id):Ae.kind==="subagent"?ie?null:a.jsx(Oun,{sessionId:Ae.sessionId,rootToolCallId:Ae.rootToolCallId,initialRootTool:Ae.rootTool,workspaceCwd:Ae.workspaceCwd??l,onRightPanelOpen:F,onArtifactsChange:H,onOpenSubagent:$,onError:V}):Ae.kind==="monitor"?a.jsx(Owt,{task:Ae.task,actions:Ae.sessionActions},Ae.id):Ae.kind==="shell"?a.jsx($wt,{task:Ae.task,actions:Ae.sessionActions},Ae.id):Ae.kind==="side_task"?a.jsx(sdn,{tabId:Ae.id,sessionId:Ae.sessionId,parentSessionId:Ae.parentSessionId,workspaceCwd:Ae.workspaceCwd??l,title:Ae.title,shouldNameFromFirstPrompt:Ae.nameFromFirstPrompt,initialPrompt:Ae.initialPrompt,createSession:M??o0n,onCreated:O??s0n,onTitleChange:P??r0n,onRightPanelOpen:F,onArtifactsChange:H,onError:V,sessionWorkflowEnabled:J,onImageIngestionNotice:te},Ae.id):Ae.kind==="image"?Ae.src?a.jsxs("div",{className:pt.imagePreviewWrap,children:[a.jsx("img",{src:Ae.src,alt:Ae.alt??Ae.title,className:pt.imagePreview}),a.jsx("a",{className:pt.imageDownloadButton,href:Ae.src,download:i0n(Ae.src),"aria-label":he("common.download"),title:he("common.download"),children:a.jsx(Vy,{size:16,strokeWidth:1.8})})]}):a.jsx("div",{className:pt.empty,role:Ae.loadError?"alert":"status",children:Ae.loadError??he("common.loading")}):Ae.kind==="context_usage"?a.jsx(Qgn,{controls:e?.[Ae.sessionId],sessionActions:Ae.sessionActions,sessionId:Ae.sessionId},Ae.id):Ae.kind==="trajectory"?a.jsx(qgn,{loadPage:Ae.loadPage},Ae.id):Ae.kind==="token_usage"?a.jsx(Ymn,{sessionActions:Ae.sessionActions,sessionId:Ae.sessionId},Ae.id):a.jsx(h0n,{task:Ae.task,actions:Ke},Ae.id):a.jsxs("div",{className:pt.emptyActions,"data-testid":"right-panel-empty-actions",children:[E.includes("review")&&a.jsxs("button",{type:"button",className:pt.emptyAction,disabled:!w||!y,onClick:y,children:[a.jsx("span",{className:pt.emptyActionIcon,"aria-hidden":"true",children:a.jsx(GF,{})}),a.jsx("span",{className:pt.emptyActionTitle,children:he("turnOutputs.review")}),a.jsx("span",{className:pt.emptyActionHint,children:he("turnOutputs.reviewLatest")}),a.jsx(Bl,{className:pt.emptyActionChevron,strokeWidth:1.6,"aria-hidden":"true"})]}),E.includes("sideTask")&&A&&R&&(j.length===0?a.jsxs("button",{type:"button",className:pt.emptyAction,disabled:L,"aria-busy":L,onClick:R,children:[a.jsx("span",{className:pt.emptyActionIcon,"aria-hidden":"true",children:a.jsx(Aj,{strokeWidth:1.6})}),a.jsx("span",{className:pt.emptyActionTitle,children:he("sideTask.title")}),a.jsx("span",{className:pt.emptyActionHint,children:he("sideTask.description")}),a.jsx(Bl,{className:pt.emptyActionChevron,strokeWidth:1.6,"aria-hidden":"true"})]}):a.jsxs(Z0,{open:ve,onOpenChange:ye,modal:!1,children:[a.jsx(Vg,{asChild:!0,children:a.jsxs("button",{type:"button",className:pt.emptyAction,"aria-expanded":ve,onMouseEnter:Te,onMouseLeave:Ne,children:[a.jsx("span",{className:pt.emptyActionIcon,"aria-hidden":"true",children:a.jsx(Aj,{strokeWidth:1.6})}),a.jsx("span",{className:pt.emptyActionTitle,children:he("sideTask.title")}),a.jsx("span",{className:pt.emptyActionHint,children:he("sideTask.description")}),a.jsx(Bl,{className:pt.emptyActionChevron,strokeWidth:1.6,"aria-hidden":"true"})]})}),a.jsxs(Gg,{align:"end",className:"w-80",onMouseEnter:Te,onMouseLeave:Ne,children:[j.map(ke=>a.jsxs(yi,{onSelect:()=>N?.(ke),children:[a.jsx("span",{className:pt.sideTaskListTitle,children:ke.title}),ke.updatedAt&&a.jsx("span",{className:pt.sideTaskListTime,children:EA(ke.updatedAt,he)})]},ke.sessionId)),a.jsx(ax,{}),a.jsxs(yi,{onSelect:R,children:[a.jsx(kHe,{className:pt.sideTaskNewIcon,strokeWidth:1.6,"aria-hidden":"true"}),a.jsx("span",{className:pt.sideTaskListTitle,children:he("sideTask.new")})]})]})]})),ue&&a.jsxs("button",{type:"button",className:pt.emptyAction,onClick:S,children:[a.jsx("span",{className:pt.emptyActionIcon,"aria-hidden":"true",children:a.jsx(hT,{strokeWidth:1.6})}),a.jsx("span",{className:pt.emptyActionTitle,children:he("webPreview.title")}),a.jsx("span",{className:pt.emptyActionHint,children:he("webPreview.openHint")}),a.jsx(Bl,{className:pt.emptyActionChevron,"aria-hidden":"true"})]}),W&&a.jsxs("button",{type:"button",className:pt.emptyAction,onClick:()=>k?.(),"data-testid":"right-panel-open-trajectory",children:[a.jsx("span",{className:pt.emptyActionIcon,"aria-hidden":"true",children:a.jsx(GO,{strokeWidth:1.6})}),a.jsx("span",{className:pt.emptyActionTitle,children:he("trajectory.title")}),a.jsx("span",{className:pt.emptyActionHint,children:he("trajectory.description")}),a.jsx(Bl,{className:pt.emptyActionChevron,"aria-hidden":"true"})]}),x&&a.jsxs("button",{type:"button",className:pt.emptyAction,onClick:()=>x(),children:[a.jsx("span",{className:pt.emptyActionIcon,"aria-hidden":"true",children:a.jsx(Y2,{strokeWidth:1.6})}),a.jsx("span",{className:pt.emptyActionTitle,children:he("terminal.title")}),a.jsx("span",{className:pt.emptyActionHint,children:he("terminal.open")}),a.jsx(Bl,{className:pt.emptyActionChevron,strokeWidth:1.6,"aria-hidden":"true"})]})]})]})]})}function l0n(){return a.jsxs("svg",{className:pt.tabIconSvg,viewBox:"0 0 24 24",fill:"none",focusable:"false","aria-hidden":"true",children:[a.jsx("circle",{cx:"12",cy:"8",r:"3",stroke:"currentColor",strokeWidth:"1.6"}),a.jsx("path",{d:"M6.5 19c.7-3.1 2.5-4.7 5.5-4.7s4.8 1.6 5.5 4.7",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})}function c0n(){return a.jsx("svg",{className:pt.tabCloseIcon,viewBox:"0 0 16 16",fill:"none",focusable:"false","aria-hidden":"true",children:a.jsx("path",{d:"m4.5 4.5 7 7M11.5 4.5l-7 7",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})})}function GF(){return a.jsxs("svg",{className:pt.tabIconSvg,viewBox:"0 0 24 24",fill:"none",focusable:"false",children:[a.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"1.6"}),a.jsx("path",{d:"M9 9.5h6M12 6.5v6",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),a.jsx("path",{d:"M9 16h6",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})]})}function u0n(){return a.jsxs("svg",{className:pt.tabIconSvg,viewBox:"0 0 24 24",fill:"none",focusable:"false",children:[a.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"3",stroke:"currentColor",strokeWidth:"1.8"}),a.jsx("path",{d:"M12 8v4l3 2",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})}function d0n({artifacts:e,artifactId:t,sourceSessionId:n,workspaceActions:s,previewContent:r,loading:o,error:i}){const l=e.find(c=>c.id===t);return l?a.jsx(S0n,{artifact:l,sourceSessionId:n,workspaceActions:s,previewContent:r}):o?a.jsx("div",{className:pt.empty,children:"Loading artifact..."}):i?a.jsx("div",{className:pt.empty,children:i}):a.jsx("div",{className:pt.empty,children:"Artifact not found."})}function h0n({task:e,actions:t}){const{t:n}=Ct(),[s,r]=d.useState(null),[o,i]=d.useState(!0),[l,c]=d.useState(null),[u,h]=d.useState(""),[f,m]=d.useState(e.prompt),[g,w]=d.useState(()=>M1(e.cron)),[y,x]=d.useState(!1),[k,_]=d.useState(!1),[S,I]=d.useState(!1),[E,A]=d.useState(!1),[j,L]=d.useState(null),R=d.useRef(0),N=d.useRef(0),M=d.useRef({actions:t,taskId:e.id,workspaceId:e.workspaceId});M.current={actions:t,taskId:e.id,workspaceId:e.workspaceId};const O=d.useCallback((he,ve,ye,_e)=>{const ae=M.current;return he===R.current&&ae.actions===ve&&ae.taskId===ye&&ae.workspaceId===_e},[]),P=d.useCallback((he,ve,ye,_e)=>{const ae=M.current;return he===N.current&&ae.actions===ve&&ae.taskId===ye&&ae.workspaceId===_e},[]);d.useEffect(()=>()=>{R.current+=1,N.current+=1},[]),d.useEffect(()=>{I(!1),A(!1),L(null)},[t,e.id,e.workspaceId]);const F=d.useCallback(async()=>{const he=++R.current,ve=++N.current,ye=e.id,_e=e.workspaceId;if(!e.durable||!t){r(null),h(""),m(e.prompt),w(M1(e.cron)),c(null),i(!1);return}i(!0),c(null);try{const ae=await t.listScheduledTasks(_e);if(!O(he,t,ye,_e))return;const Se=ae.find(Te=>Te.id===e.id)??null;r(Se),Se?(h(Se.name??""),m(Se.prompt),w(M1(Se.cron))):(h(""),m(e.prompt),w(M1(e.cron)))}catch(ae){P(ve,t,ye,_e)&&c(ae instanceof Error?ae.message:String(ae))}finally{P(ve,t,ye,_e)&&i(!1)}},[t,P,O,e.cron,e.durable,e.id,e.prompt,e.workspaceId]);d.useEffect(()=>{F()},[F]);const H=!e.durable,$=e.durable&&!o&&!l&&!s,Y=!!s,Z=s?.name||s?.prompt||e.title,K=s?.prompt??e.prompt,B=s?.cron??e.cron,V=s?.recurring??e.recurring,J=s?.enabled,q=d.useCallback(()=>{s&&(h(s.name??""),m(s.prompt),w(M1(s.cron)),L(null),x(!0))},[s]),te=d.useCallback(()=>{x(!1),L(null),s&&(h(s.name??""),m(s.prompt),w(M1(s.cron)))},[s]),ie=d.useCallback(async()=>{if(!s||!t)return;const he=i9(g);if(!he){L(n("scheduledTasks.error.invalidSchedule"));return}if(f.trim().length===0){L(n("scheduledTasks.error.emptyPrompt"));return}const ve=++R.current,ye=e.id,_e=e.workspaceId;A(!0),L(null);try{const ae=await t.updateScheduledTask(s.id,{cron:he,prompt:f.trim(),name:u.trim()||null},_e);if(!O(ve,t,ye,_e))return;r(ae),h(ae.name??""),m(ae.prompt),w(M1(ae.cron)),x(!1)}catch(ae){O(ve,t,ye,_e)&&L(ae instanceof Error?ae.message:String(ae))}finally{O(ve,t,ye,_e)&&A(!1)}},[t,g,O,s,u,f,n,e.id,e.workspaceId]),ge=d.useCallback(async()=>{if(!s||!t)return;const he=++R.current,ve=e.id,ye=e.workspaceId;I(!0),L(null);try{const _e=await t.updateScheduledTask(s.id,{enabled:!s.enabled},ye);if(!O(he,t,ve,ye))return;r(_e)}catch(_e){O(he,t,ve,ye)&&L(_e instanceof Error?_e.message:String(_e))}finally{O(he,t,ve,ye)&&I(!1)}},[t,O,s,e.id,e.workspaceId]),re=d.useCallback(async()=>{if(!s||!t)return;const he=++R.current,ve=e.id,ye=e.workspaceId;I(!0),L(null);try{if(await t.deleteScheduledTask(s.id,ye),!O(he,t,ve,ye))return;r(null),_(!1)}catch(_e){O(he,t,ve,ye)&&L(_e instanceof Error?_e.message:String(_e))}finally{O(he,t,ve,ye)&&I(!1)}},[t,O,s,e.id,e.workspaceId]),G=i9(g),Q=G?BT(G,n):null;return a.jsxs("div",{className:pt.detail,children:[o&&a.jsx("div",{className:pt.empty,children:n("scheduledTasks.loading")}),l&&a.jsx("div",{className:rn.loadError,children:l}),$&&a.jsx("div",{className:pt.empty,children:n("scheduledTasks.deletedSnapshot")}),H&&a.jsx("div",{className:pt.empty,children:n("scheduledTasks.sessionScopedSnapshot")}),!$&&a.jsx("div",{className:pt.section,children:a.jsxs("div",{className:pt.fieldGrid,children:[a.jsx("span",{className:pt.fieldLabel,children:n("scheduledTasks.name")}),a.jsx("span",{className:pt.fieldValue,children:Z}),a.jsx("span",{className:pt.fieldLabel,children:n("scheduledTasks.taskId")}),a.jsx("span",{className:pt.fieldValue,children:e.id}),a.jsx("span",{className:pt.fieldLabel,children:n("scheduledTasks.schedule")}),a.jsx("span",{className:pt.fieldValue,children:BT(B,n)}),a.jsx("span",{className:pt.fieldLabel,children:"Cron"}),a.jsx("span",{className:pt.fieldValue,children:B}),a.jsx("span",{className:pt.fieldLabel,children:n("scheduledTasks.type")}),a.jsx("span",{className:pt.fieldValue,children:n(V?"scheduledTasks.repeats":"scheduledTasks.runsOnce")}),J!==void 0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:pt.fieldLabel,children:n("scheduledTasks.status")}),a.jsx("span",{className:pt.fieldValue,children:n(J?"scheduledTasks.enable":"scheduledTasks.disable")})]})]})}),!$&&a.jsxs("div",{className:pt.section,children:[a.jsx("div",{className:pt.sectionTitle,children:"Prompt"}),a.jsx("div",{className:pt.description,children:K})]}),j&&a.jsx("div",{className:rn.formError,children:j}),a.jsxs("div",{className:pt.actionsRow,children:[a.jsx("button",{type:"button",className:rn.primaryButton,disabled:!Y||S,onClick:q,children:n("scheduledTasks.edit")}),a.jsx("button",{type:"button",className:rn.secondaryButton,disabled:!Y||S,onClick:()=>void ge(),children:s?.enabled?n("scheduledTasks.disable"):n("scheduledTasks.enable")}),a.jsx("button",{type:"button",className:rn.secondaryButton,disabled:!Y||S,onClick:()=>_(!0),children:n("scheduledTasks.delete")})]}),k&&s&&a.jsx(Wa,{title:n("scheduledTasks.deleteConfirmTitle"),size:"sm",onClose:()=>_(!1),children:a.jsxs("div",{className:rn.formFields,children:[a.jsx("div",{className:pt.description,children:n("scheduledTasks.deleteConfirm",{name:s.name||s.prompt})}),j&&a.jsx("div",{className:rn.formError,children:j}),a.jsxs("div",{className:rn.formActions,children:[a.jsx("button",{type:"button",className:rn.secondaryButton,onClick:()=>_(!1),disabled:S,children:n("scheduledTasks.cancel")}),a.jsx("button",{type:"button",className:rn.primaryButton,onClick:()=>void re(),disabled:S,children:n("scheduledTasks.delete")})]})]})}),y&&a.jsx(Wa,{title:n("scheduledTasks.editTitle"),size:"md",onClose:te,children:a.jsxs("div",{className:rn.formFields,children:[a.jsxs("label",{className:rn.field,children:[a.jsx("span",{className:rn.fieldLabel,children:n("scheduledTasks.name")}),a.jsx("input",{className:rn.input,type:"text",value:u,maxLength:200,placeholder:n("scheduledTasks.namePlaceholder"),onChange:he=>h(he.target.value)})]}),a.jsxs("label",{className:rn.field,children:[a.jsxs("span",{className:rn.fieldLabel,children:[n("scheduledTasks.prompt"),a.jsx("span",{className:rn.required,children:"*"})]}),a.jsx("textarea",{className:rn.textarea,value:f,rows:4,maxLength:1e5,placeholder:n("scheduledTasks.promptPlaceholder"),onChange:he=>m(he.target.value)})]}),a.jsxs("div",{className:rn.scheduleRow,children:[a.jsxs("label",{className:rn.field,children:[a.jsx("span",{className:rn.fieldLabel,children:n("scheduledTasks.frequency")}),a.jsx("select",{className:rn.select,value:g.frequency,onChange:he=>{const ve=he.target.value;w(ye=>({...ye,frequency:ve,...ve==="hourly"?{time:"00:00"}:{}}))},children:t0n.map(he=>a.jsx("option",{value:he,children:n(`scheduledTasks.freq.${he}`)},he))})]}),(g.frequency==="daily"||g.frequency==="weekdays"||g.frequency==="weekly")&&a.jsxs("label",{className:rn.field,children:[a.jsx("span",{className:rn.fieldLabel,children:n("scheduledTasks.time")}),a.jsx("input",{className:rn.input,type:"time",value:g.time,onChange:he=>w(ve=>({...ve,time:he.target.value}))})]}),g.frequency==="weekly"&&a.jsxs("label",{className:rn.field,children:[a.jsx("span",{className:rn.fieldLabel,children:n("scheduledTasks.weekday")}),a.jsx("select",{className:rn.select,value:g.weekday,onChange:he=>w(ve=>({...ve,weekday:Number(he.target.value)})),children:n("scheduledTasks.weekdayNames").split(",").map((he,ve)=>a.jsx("option",{value:ve,children:he},ve))})]}),g.frequency==="minutes"&&a.jsxs("label",{className:rn.field,children:[a.jsx("span",{className:rn.fieldLabel,children:n("scheduledTasks.interval")}),a.jsx("select",{className:rn.select,value:g.minuteInterval,onChange:he=>w(ve=>({...ve,minuteInterval:Number(he.target.value)})),children:n0n.map(he=>a.jsx("option",{value:he,children:he},he))})]}),g.frequency==="custom"&&a.jsxs("label",{className:`${rn.field} ${rn.fieldGrow}`,children:[a.jsx("span",{className:rn.fieldLabel,children:n("scheduledTasks.cron")}),a.jsx("input",{className:rn.input,type:"text",value:g.customCron,spellCheck:!1,placeholder:"0 9 * * 1-5",onChange:he=>w(ve=>({...ve,customCron:he.target.value}))})]})]}),a.jsx("div",{className:rn.preview,children:Q?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:rn.previewLabel,children:Q}),a.jsx("code",{className:rn.previewCron,children:G})]}):a.jsx("span",{className:rn.previewInvalid,children:n("scheduledTasks.error.invalidSchedule")})}),j&&a.jsx("div",{className:rn.formError,children:j}),a.jsxs("div",{className:rn.formActions,children:[a.jsx("button",{type:"button",className:rn.secondaryButton,onClick:te,disabled:E,children:n("scheduledTasks.cancel")}),a.jsx("button",{type:"button",className:rn.primaryButton,onClick:()=>void ie(),disabled:E,children:n(E?"scheduledTasks.saving":"scheduledTasks.save")})]})]})})]})}function f0n({changes:e,selectedPath:t,workspaceCwd:n,onOpenFilePreview:s,onDownloadFile:r,onDownloadError:o}){const{t:i}=Ct(),[l,c]=d.useState(!1),[u,h]=d.useState(!0),[f,m]=d.useState(!1),[g,w]=d.useState(520),y=d.useRef(g),x=d.useRef(null),k=d.useRef(null),[_,S]=d.useState(null),[I,E]=d.useState(()=>new Set),A=d.useRef(!0);d.useEffect(()=>(A.current=!0,()=>{A.current=!1}),[]);const j=l,L=d.useMemo(()=>_0n(e,n),[e,n]);d.useEffect(()=>{S(t)},[t]),d.useEffect(()=>{y.current=g},[g]),d.useEffect(()=>{const P=x.current;if(!P)return;const F=()=>{m(P.clientWidth<e0n)};F();const H=new ResizeObserver(F);return H.observe(P),()=>H.disconnect()},[u]),d.useEffect(()=>()=>k.current?.(),[]);const R=d.useCallback(P=>{const F=x.current;if(!F)return;P.preventDefault();const H=P.currentTarget;H.setPointerCapture(P.pointerId);const $=P.clientX,Y=y.current,Z=F.getBoundingClientRect().width,K=Math.max(180,Z-180),B=document.body.style.cursor,V=document.body.style.userSelect;let J=Y,q=null;document.body.style.cursor="col-resize",document.body.style.userSelect="none";const te=()=>{q=null,w(J)},ie=G=>{J=Math.min(K,Math.max(180,Y+(G.clientX-$))),q===null&&(q=window.requestAnimationFrame(te))};let ge=()=>{};const re=G=>{k.current=null,q!==null&&(window.cancelAnimationFrame(q),q=null),G&&w(J),H.hasPointerCapture(P.pointerId)&&H.releasePointerCapture(P.pointerId),document.body.style.cursor=B,document.body.style.userSelect=V,window.removeEventListener("pointermove",ie),window.removeEventListener("pointerup",ge),window.removeEventListener("pointercancel",ge)};ge=()=>re(!0),k.current=()=>re(!1),window.addEventListener("pointermove",ie),window.addEventListener("pointerup",ge),window.addEventListener("pointercancel",ge)},[]);if(e.length===0)return a.jsx("div",{className:pt.empty,children:"No file changes to review."});const N=T_e(e),M=P=>{S(F=>F===P?null:P)},O=async P=>{if(!I.has(P.path)){E(F=>new Set(F).add(P.path));try{await r(P,()=>!A.current)}catch(F){A.current&&o(F)}finally{E(F=>{const H=new Set(F);return H.delete(P.path),H})}}};return a.jsxs("div",{className:pt.review,children:[a.jsxs("div",{className:pt.reviewToolbar,children:[a.jsxs("div",{className:pt.reviewToolbarTitle,children:[a.jsx("span",{children:i("turnOutputs.previousTurn")}),a.jsx(Y9,{additions:N?.additions,deletions:N?.deletions,className:pt.lineStats,additionsClassName:pt.additions,deletionsClassName:pt.deletions})]}),a.jsxs("div",{className:pt.reviewToolbarActions,children:[a.jsxs("button",{type:"button",className:pt.reviewTotalsButton,onClick:()=>h(P=>!P),"aria-expanded":u,children:[a.jsx("span",{children:i("turnOutputs.fileCount",{count:e.length})}),a.jsx("span",{className:[pt.chevron,u?pt.chevronOpen:""].filter(Boolean).join(" "),"aria-hidden":"true",children:a.jsx(_ue,{})})]}),a.jsx("button",{type:"button",className:[pt.iconButton,l?pt.iconButtonActive:""].filter(Boolean).join(" "),onClick:()=>c(P=>!P),"aria-label":i(l?"turnOutputs.closeFileTree":"turnOutputs.openFileTree"),title:i(l?"turnOutputs.closeFileTree":"turnOutputs.openFileTree"),children:l?a.jsx(x0n,{}):a.jsx(b0n,{})})]})]}),u&&a.jsxs("div",{ref:x,className:[pt.reviewContent,j?"":pt.reviewContentListOnly,j&&f?pt.reviewContentStacked:""].filter(Boolean).join(" "),style:{"--review-list-width":`${g}px`},children:[a.jsx("div",{className:[pt.reviewList,_?pt.reviewListWithExpanded:""].filter(Boolean).join(" "),children:e.map(P=>{const F=_===P.path,H=E_e(P.path),$=YIt(P.path);return a.jsxs("div",{className:[pt.reviewItem,F?pt.reviewItemExpanded:""].filter(Boolean).join(" "),children:[a.jsxs("div",{className:pt.reviewRow,"data-selected":P.path===t||void 0,children:[a.jsx("button",{type:"button",className:pt.reviewRowToggle,onClick:()=>M(P.path),"aria-label":P.path,"aria-expanded":F}),a.jsx("span",{className:pt.fileIcon,children:_Re(P.path)}),a.jsxs("span",{className:pt.reviewFileName,children:[a.jsx(v0n,{path:AL(P.path,n),title:P.path}),H&&a.jsx("button",{type:"button",className:pt.reviewOpenButton,onClick:()=>s(P),title:`${i("turnOutputs.preview")} ${P.path}`,children:i("turnOutputs.preview")}),$&&a.jsx("button",{type:"button",className:pt.reviewOpenButton,onClick:()=>void O(P),title:`${i("common.download")} ${P.path}`,disabled:I.has(P.path),children:i(I.has(P.path)?"common.downloading":"common.download")})]}),a.jsx(Y9,{additions:P.additions,deletions:P.deletions,className:pt.lineStats,additionsClassName:pt.additions,deletionsClassName:pt.deletions}),a.jsx("span",{className:[pt.chevron,F?pt.chevronOpen:""].filter(Boolean).join(" "),"aria-hidden":"true",children:a.jsx(_ue,{})})]}),F&&a.jsx(p0n,{change:P})]},`${P.toolCallId}:${P.path}`)})}),j&&!f&&a.jsx("div",{className:pt.reviewSplitHandle,role:"separator","aria-orientation":"vertical",onPointerDown:R}),j&&a.jsx("div",{className:pt.tree,children:L.children.map(P=>a.jsx(bRe,{node:P,depth:0,selectedPath:t},P.path))})]})]})}function p0n({change:e}){if(e.diffs.length===0)return a.jsx("div",{className:pt.diffEmpty,children:"No diff available."});const t=m0n(e.diffs);return a.jsx("div",{className:pt.diffPreview,children:t.map((n,s)=>n.fileDiff&&!n.fullContent?a.jsx(gY,{diff:n.fileDiff},s):a.jsx(g0n,{oldText:n.oldText,newText:n.newText},s))})}function m0n(e){for(let t=e.length-1;t>=0;t--)if(e[t]?.fullContent)return e.slice(t);return e}function g0n({oldText:e,newText:t}){const n=d.useRef(null),[s,r]=d.useState(null),[o,i]=d.useState(null);return d.useEffect(()=>{const l=n.current;if(!l)return;const c=()=>r(l.clientWidth>=720);c();const u=new ResizeObserver(c);return u.observe(l),()=>u.disconnect()},[]),d.useEffect(()=>{const l=n.current;if(!l||s===null)return;l.replaceChildren(),i(null);let c=!1,u=null;const h=[vTe,js.editable.of(!1),ua.readOnly.of(!0),js.lineWrapping],f={scanLimit:1e3,timeout:500},m={margin:3,minSize:8};return Je(async()=>{const{MergeView:g,unifiedMergeView:w}=await import("./index-DX6oSKFm.js");return{MergeView:g,unifiedMergeView:w}},[]).then(({MergeView:g,unifiedMergeView:w})=>{if(!c)try{if(s){u=new g({a:{doc:e,extensions:h},b:{doc:t,extensions:h},parent:l,highlightChanges:!0,gutter:!0,revertControls:void 0,collapseUnchanged:m,diffConfig:f});return}u=new js({doc:t,extensions:[...h,w({original:e,highlightChanges:!0,gutter:!0,mergeControls:!1,allowInlineDiffs:!0,collapseUnchanged:m,diffConfig:f})],parent:l})}catch(y){c||i(y instanceof Error?y.message:String(y))}}).catch(g=>{c||i(g instanceof Error?g.message:String(g))}),()=>{c=!0,u?.destroy()}},[s,t,e]),a.jsxs("div",{className:pt.codeMirrorDiffWrap,children:[a.jsx("div",{ref:n,className:pt.codeMirrorDiff}),o&&a.jsxs("div",{className:pt.diffError,children:["Diff unavailable: ",o]})]})}function bRe({node:e,depth:t,selectedPath:n}){const s=!!e.file,[r,o]=d.useState(!0),i=[pt.treeRow,s?pt.treeFile:pt.treeFolder].filter(Boolean).join(" "),l={paddingLeft:10+t*18,"--tree-row-line-left":`${19+Math.max(0,t-1)*18}px`},c={"--tree-children-line-left":`${19+t*18}px`},u=a.jsxs(a.Fragment,{children:[a.jsx("span",{className:pt.treeTwisty,children:!s&&a.jsx("span",{className:[pt.treeChevron,r?"":pt.treeChevronClosed].filter(Boolean).join(" "),children:a.jsx(k0n,{})})}),a.jsxs("span",{className:pt.treeContent,children:[s&&a.jsx("span",{className:pt.fileIcon,children:_Re(e.path)}),a.jsx("span",{className:pt.treeName,children:e.name})]}),e.file?.isArtifact&&a.jsx("span",{className:pt.reviewBadge,children:"artifact"})]});return a.jsxs("div",{className:pt.treeNode,children:[s?a.jsx("div",{className:i,"data-selected":e.file?.path===n||void 0,"data-depth":t,style:l,title:e.path,children:u}):a.jsx("button",{type:"button",className:i,"data-depth":t,style:l,title:e.path,"aria-expanded":r,onClick:()=>o(h=>!h),children:u}),!s&&r&&e.children.length>0&&a.jsx("div",{className:pt.treeChildren,style:c,children:e.children.map(h=>a.jsx(bRe,{node:h,depth:t+1,selectedPath:n},h.path))})]})}function v0n({path:e,title:t}){const n=d.useRef(null),[s,r]=d.useState(()=>xRe(e));return d.useLayoutEffect(()=>{const o=n.current;if(!o)return;const i=()=>r(w0n(e,o));i();const l=new ResizeObserver(i);return l.observe(o),()=>l.disconnect()},[e]),a.jsxs("span",{ref:n,className:pt.reviewPath,title:t??e,children:[s.prefix&&a.jsx("span",{className:pt.pathPrefix,children:s.prefix}),a.jsx("span",{className:pt.pathFileName,children:s.leaf})]})}function xRe(e){const t=e.lastIndexOf("/");return t<0?{prefix:"",leaf:e}:{prefix:e.slice(0,t+1),leaf:e.slice(t+1)}}let kue=null;function w0n(e,t){const n=xRe(e),s=t.clientWidth;if(s<=0)return n;const r=y0n(t);if(r(e)<=s)return n;const o=e.split("/").filter(Boolean),i=o.at(-1)??e,l=r(i);if(o.length<=1||l+r(".../")>s)return{prefix:"",leaf:i};let c=".../";for(let u=1;u<o.length;u++){const f=`.../${o.slice(o.length-1-u,-1).join("/")}/`;if(r(f)+l>s)break;c=f}return{prefix:c,leaf:i}}function y0n(e){kue??=document.createElement("canvas");const t=kue.getContext("2d"),n=window.getComputedStyle(e);return t&&(t.font=[n.fontStyle,n.fontVariant,n.fontWeight,n.fontSize,n.fontFamily].join(" ")),s=>t?.measureText(s).width??s.length*8}function b0n(){return a.jsxs("svg",{className:pt.toolbarIcon,viewBox:"0 0 24 24",fill:"none",focusable:"false","aria-hidden":"true",children:[a.jsx("path",{d:"M3.5 7.5h6l1.6 2h9.4v8.2a2 2 0 0 1-2 2h-13a2 2 0 0 1-2-2V7.5Z",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round"}),a.jsx("path",{d:"M3.5 7.5V5.8a1.5 1.5 0 0 1 1.5-1.5h4l1.8 2.1h7.2a1.5 1.5 0 0 1 1.5 1.5v1.6",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round"})]})}function x0n(){return a.jsxs("svg",{className:pt.toolbarIcon,viewBox:"0 0 24 24",fill:"none",focusable:"false","aria-hidden":"true",children:[a.jsx("path",{d:"M3.5 8.2V5.8A1.5 1.5 0 0 1 5 4.3h4l1.8 2.1h7.2a1.5 1.5 0 0 1 1.5 1.5v1.4",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round"}),a.jsx("path",{d:"M4.8 19.7h12.9a2 2 0 0 0 1.9-1.4l2-7H6.4l-2.8 7.1a.9.9 0 0 0 1.2 1.3Z",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round"})]})}function _ue(){return a.jsx("svg",{className:pt.chevronIcon,viewBox:"0 0 16 16",fill:"none",focusable:"false","aria-hidden":"true",children:a.jsx("path",{d:"m6 4 4 4-4 4",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}function k0n(){return a.jsx("svg",{className:pt.treeChevronIcon,viewBox:"0 0 16 16",fill:"none",focusable:"false","aria-hidden":"true",children:a.jsx("path",{d:"m4 6 4 4 4-4",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}function _0n(e,t){const n={name:"",path:"",children:[]};for(const s of e){const r=AL(s.path,t).split("/").filter(Boolean);let o=n;for(let i=0;i<r.length;i++){const l=r[i],c=r.slice(0,i+1).join("/");let u=o.children.find(h=>h.name===l);u||(u={name:l,path:c,children:[]},o.children.push(u)),i===r.length-1&&(u.file=s),o=u}}return kRe(n),n}function kRe(e){e.children.sort((t,n)=>!!t.file!=!!n.file?t.file?1:-1:t.name.localeCompare(n.name));for(const t of e.children)kRe(t)}function y8(e){return db(e).split("/").filter(Boolean).at(-1)??e}function _Re(e){const t=y8(e),n=t.includes(".")?t.split(".").pop()?.toLowerCase():"";return n?{css:"CSS",html:"HTML",js:"JS",json:"JSON",jsx:"JSX",md:"MD",ts:"TS",tsx:"TSX"}[n]??n.slice(0,3).toUpperCase():"FILE"}function S0n({artifact:e,sourceSessionId:t,workspaceActions:n,previewContent:s}){const{t:r}=Ct(),o=Hp(),i=iwe(e),l=N4(e.url)?e.url:void 0,c=e.metadata?.artifactType==="automation_snapshot",u=e.metadata?.artifactType==="code_review",h=e.storage==="workspace"&&!!e.workspacePath,f=owe(e);return e.metadata?.artifactType==="web_preview_snapshot"?a.jsx(cmn,{artifact:e,sourceSessionId:t}):u?e.status!=="available"?a.jsx(C0n,{status:e.status}):!h||!e.workspacePath?a.jsx(T0n,{}):a.jsx(bun,{workspacePath:e.workspacePath,artifactVersion:xte(e),workspaceActions:n}):h&&e.workspacePath?swe(e)?a.jsx(E0n,{artifact:e,workspaceActions:n}):a.jsx(oD,{workspacePath:e.workspacePath,artifactVersion:xte(e),workspaceActions:n,previewContent:s,previewSizeBytes:e.sizeBytes,imageMimeType:f,previewKind:I0n(e)?"html":R0n(e)?"markdown":f?"image":"source"}):a.jsxs("div",{className:pt.detail,children:[a.jsxs("div",{className:pt.section,children:[a.jsx("div",{className:pt.sectionTitle,children:c?"Automation Snapshot":"Artifact"}),a.jsxs("div",{className:pt.fieldGrid,children:[a.jsx(kp,{label:"Type",value:GG(e.kind,e.workspacePath)}),a.jsx(kp,{label:"Storage",value:e.storage}),a.jsx(kp,{label:"Status",value:e.status}),a.jsx(kp,{label:"Source",value:e.source}),a.jsx(kp,{label:"Size",value:VP(e.sizeBytes)}),a.jsx(kp,{label:"Created",value:e.createdAt}),a.jsx(kp,{label:"Updated",value:e.updatedAt}),e.toolName&&a.jsx(kp,{label:"Tool",value:e.toolName}),e.toolCallId&&a.jsx(kp,{label:"Tool call",value:e.toolCallId})]})]}),e.description&&a.jsxs("div",{className:pt.section,children:[a.jsx("div",{className:pt.sectionTitle,children:"Description"}),a.jsx("div",{className:pt.description,children:e.description})]}),c&&e.metadata&&a.jsxs("div",{className:pt.section,children:[a.jsx("div",{className:pt.sectionTitle,children:"Details"}),a.jsxs("div",{className:pt.fieldGrid,children:[C2(e.metadata,"automationId","Automation ID"),C2(e.metadata,"schedule","Schedule"),C2(e.metadata,"timezone","Timezone"),C2(e.metadata,"status","Status"),C2(e.metadata,"nextRunAt","Next run"),C2(e.metadata,"prompt","Prompt")]})]}),(i||l)&&a.jsxs("div",{className:pt.section,children:[a.jsx("div",{className:pt.sectionTitle,children:"Location"}),l?a.jsxs("div",{className:pt.locationRow,children:[a.jsx("a",{className:pt.link,href:l,target:"_blank",rel:"noopener noreferrer",onClick:m=>o(m,l),children:l}),a.jsx("a",{className:pt.openButton,href:l,target:"_blank",rel:"noopener noreferrer",onClick:m=>o(m,l),children:r("artifact.openLink")})]}):a.jsx("div",{className:pt.meta,children:i})]})]})}function C0n({status:e}){const{t}=Ct();return a.jsx("div",{className:pt.previewError,role:"alert",children:t("codeReview.unavailable",{status:e})})}function T0n(){const{t:e}=Ct();return a.jsx("div",{className:pt.previewError,role:"alert",children:e("codeReview.workspaceRequired")})}function I0n(e){const t=e.workspacePath?.toLowerCase()??"",n=ub(e.mimeType);return e.kind==="html"||t.endsWith(".html")||t.endsWith(".htm")||n==="text/html"}function R0n(e){const t=e.workspacePath?.toLowerCase()??"",n=ub(e.mimeType);return t.endsWith(".md")||t.endsWith(".markdown")||n==="text/markdown"}function E0n({artifact:e,workspaceActions:t}){const{t:n}=Ct(),[s,r]=d.useState(null),[o,i]=d.useState(!1),l=d.useRef(!0),c=iwe(e);d.useEffect(()=>(l.current=!0,()=>{l.current=!1}),[]);const u=async()=>{if(e.workspacePath){i(!0),r(null);try{await GP(t,e.workspacePath,e.mimeType,()=>!l.current)}catch(h){if(!l.current)return;r(h instanceof Error?h.message:String(h))}finally{l.current&&i(!1)}}};return a.jsx("div",{className:pt.detail,children:a.jsxs("div",{className:pt.section,children:[a.jsx("div",{className:pt.sectionTitle,children:n("common.download")}),a.jsxs("div",{className:pt.fieldGrid,children:[a.jsx(kp,{label:"Type",value:GG(e.kind,e.workspacePath)}),a.jsx(kp,{label:"Size",value:VP(e.sizeBytes)}),c?a.jsx(kp,{label:"Location",value:c}):null,e.status!=="available"&&e.status!=="changed"?a.jsx(kp,{label:"Status",value:e.status??"missing"}):null]}),a.jsx("div",{className:pt.downloadRow,children:a.jsx("button",{type:"button",className:pt.downloadButton,onClick:()=>{u()},disabled:o||e.status!=="available"&&e.status!=="changed",children:n(o?"common.downloading":"common.download")})}),s&&a.jsx("div",{className:pt.previewError,children:s})]})})}function A0n({tab:e}){const{t}=Ct(),n=el(),s=O4(e.workspaceCwd),r=s?.actions,o=Hp(),[i,l]=d.useState(0),[c,u]=d.useState(),[h,f]=d.useState(),[m,g]=d.useState(),w=e.source,y=w.locator,x=e.owner.isCurrent()&&n.sessionId===e.sourceSessionId&&n.capabilities?.features.includes("session_sources")&&s?.workspaceId===e.workspaceId&&(!!s||e.workspaceCwd===void 0&&y.type!=="workspace_file")&&(y.type!=="workspace_file"||w.workspaceCwd===n.workspaceCwd),k=y.type==="workspace_file"?y.workspacePath:y.type==="attachment"?y.attachmentId:"",_=/\.pdf$/i.test(k);if(d.useEffect(()=>{let I=!1;return u(void 0),f(void 0),g(void 0),!x||y.type==="url"?void 0:((async()=>{if(y.type==="attachment"){const A=await e.sessionActions.readAttachment(y.attachmentId);if(I||!e.owner.isCurrent())return;const j=Uint8Array.from(atob(A.data),L=>L.charCodeAt(0));u(new Blob([j],{type:A.mimeType}))}else if(_&&r){const A=await _4(r.readFileBytes,k,"application/pdf",{statFile:r.stat,isCancelled:()=>I||!e.owner.isCurrent()});!I&&e.owner.isCurrent()&&u(A)}})().catch(A=>{!I&&e.owner.isCurrent()&&f(Iu(A))}),()=>{I=!0})},[i,x,y,k,_,e.owner,e.sessionActions,r]),x&&y.type==="url")return a.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[a.jsx("h3",{children:w.title}),w.description&&a.jsx("p",{children:w.description}),a.jsx("p",{className:"break-all text-sm text-muted-foreground",children:y.url}),N4(y.url)&&a.jsx("a",{className:"text-primary underline",href:y.url,target:"_blank",rel:"noopener noreferrer",onClick:I=>o(I,y.url),children:t("sources.openOriginal")})]});if(!x||!s&&y.type!=="attachment")return a.jsx("div",{className:pt.empty,role:"alert",children:t("sources.unavailable")});const S=y.type==="workspace_file"&&!_&&swe({workspacePath:k});return a.jsxs("div",{className:"flex h-full min-h-0 flex-1 flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border px-3 py-2",children:[a.jsx("span",{className:"truncate text-xs text-muted-foreground",title:k,children:k}),a.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[m&&a.jsx(Wt,{variant:"ghost",size:"icon-sm",asChild:!0,children:a.jsx("a",{href:m,download:w.title,"aria-label":`Download ${w.title}`,title:t("common.download"),children:a.jsx(Vy,{})})}),h&&a.jsx(Wt,{variant:"ghost",size:"sm",onClick:()=>l(I=>I+1),children:t("common.retry")})]})]}),h?a.jsx("div",{className:pt.previewError,role:"alert",children:h}):S?a.jsxs("div",{className:"p-4",children:[a.jsx("p",{children:t("attachment.previewUnsupported")}),a.jsx(Wt,{onClick:()=>void GP(r,k,"application/octet-stream",()=>!e.owner.isCurrent()).catch(I=>{e.owner.isCurrent()&&f(Iu(I))}),children:t("common.download")})]}):(y.type==="attachment"||_)&&!c?a.jsx("div",{className:pt.empty,role:"status",children:t("common.loading")}):c&&c.type!=="application/pdf"&&!i4(c.type,k)?a.jsx(SRe,{data:c,title:w.title,onDownloadUrl:g,showDownload:!1,image:!!FS(k)&&c.type.startsWith("image/")}):a.jsx("div",{className:"relative min-h-0 flex-1 overflow-auto",children:a.jsx(oD,{workspacePath:k,workspaceActions:r,onLoadError:f,previewData:c,previewOnly:y.type==="attachment",previewMimeType:c?.type,previewKind:/\.html?$/i.test(k)||ub(c?.type)==="text/html"?"source":void 0},i)})]})}function SRe({data:e,title:t,image:n,onDownloadUrl:s,showDownload:r=!0}){const[o,i]=d.useState();return d.useEffect(()=>{const l=URL.createObjectURL(e);return i(l),s?.(l),()=>URL.revokeObjectURL(l)},[e,s]),o?a.jsxs("div",{className:pt.imagePreviewWrap,children:[n?a.jsx("img",{className:pt.imagePreview,src:o,alt:t}):a.jsx(CRe,{name:t,mimeType:e.type,size:e.size}),r&&a.jsx("a",{href:o,download:t,"aria-label":`Download ${t}`,children:a.jsx(Vy,{})})]}):null}function oD({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewSizeBytes:r,previewData:o,previewMimeType:i,imageMimeType:l,previewKind:c,previewOnly:u,onLoadError:h}){if(o)return a.jsx(j0n,{workspacePath:e,workspaceActions:n,data:o,mimeType:i,previewKind:c,onLoadError:h});const f=e.toLowerCase(),m=l??FS(e),g=c??(f.endsWith(".html")||f.endsWith(".htm")?"html":f.endsWith(".md")||f.endsWith(".markdown")?"markdown":m?"image":"source");return g==="html"?a.jsx(L0n,{workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewSizeBytes:r,previewOnly:u,onLoadError:h}):g==="markdown"?a.jsx(O0n,{workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewSizeBytes:r,previewOnly:u,onLoadError:h}):g==="image"&&m?a.jsx(P0n,{workspacePath:e,artifactVersion:t,workspaceActions:n,mimeType:m,onLoadError:h}):a.jsx(TRe,{workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:u,onLoadError:h})}function j0n({workspacePath:e,workspaceActions:t,data:n,mimeType:s,previewKind:r,onLoadError:o}){const i=(s||n.type||"application/octet-stream").split(";",1)[0].trim().toLowerCase();return i==="application/pdf"?a.jsx(M0n,{data:n,mimeType:i,title:e}):i4(i,e)?a.jsx(N0n,{workspacePath:e,workspaceActions:t,data:n,previewKind:r,onLoadError:o}):a.jsx(CRe,{name:e,mimeType:i,size:n.size})}function N0n({workspacePath:e,workspaceActions:t,data:n,previewKind:s,onLoadError:r}){const{t:o}=Ct(),[i,l]=d.useState(),[c,u]=d.useState();return d.useEffect(()=>{const h=new FileReader;return l(void 0),u(void 0),h.onload=()=>l(String(h.result??"")),h.onerror=()=>{const f=o("attachment.readFailed");u(f),r?.(f)},h.readAsText(n),()=>{h.readyState===FileReader.LOADING&&h.abort()}},[n,r,o]),c?a.jsx("div",{className:pt.previewError,children:c}):i===void 0?a.jsx("div",{className:pt.empty,children:o("attachment.loadingFile")}):a.jsx(oD,{workspacePath:e,workspaceActions:t,previewContent:i,previewSizeBytes:n.size,previewOnly:!0,previewKind:s})}function M0n({data:e,mimeType:t,title:n}){const{t:s}=Ct(),[r,o]=d.useState();return d.useEffect(()=>{const i=URL.createObjectURL(e.type===t?e:new Blob([e],{type:t}));return o(i),()=>URL.revokeObjectURL(i)},[e,t]),r?a.jsx("iframe",{className:pt.pdfAttachmentPreview,src:r,title:`Preview ${n}`}):a.jsx("div",{className:pt.empty,children:s("attachment.loadingPreview")})}function CRe({name:e,mimeType:t,size:n}){const{t:s}=Ct();return a.jsxs("div",{className:pt.unsupportedAttachmentPreview,children:[a.jsx(U0,{name:e,mimeType:t,"aria-hidden":"true"}),a.jsx("div",{children:s("attachment.previewUnsupported")}),a.jsxs("div",{className:pt.unsupportedAttachmentMeta,children:[t," · ",VP(n)]})]})}function P0n({workspacePath:e,artifactVersion:t,workspaceActions:n,mimeType:s,onLoadError:r}){const[o,i]=d.useState(null),[l,c]=d.useState(null);return d.useEffect(()=>{let u=!1,h;return i(null),c(null),_4((f,m)=>n.readFileBytes(f,m),e,s,{statFile:f=>n.stat(f),isCancelled:()=>u}).then(f=>{u||(h=URL.createObjectURL(f),i(h))}).catch(f=>{if(u)return;const m=f instanceof Error?f.message:String(f);c(m),r?.(m)}),()=>{u=!0,h&&URL.revokeObjectURL(h)}},[t,s,r,n,e]),a.jsxs("div",{className:pt.imagePreviewWrap,children:[o?a.jsxs(a.Fragment,{children:[a.jsx("img",{className:pt.imagePreview,src:o,alt:y8(e)}),a.jsx("a",{className:pt.imageDownloadButton,href:o,download:y8(e),"aria-label":`Download ${y8(e)}`,title:"Download",children:a.jsx(Vy,{size:16,strokeWidth:1.8})})]}):l?null:a.jsx("div",{className:pt.empty,children:"Loading image..."}),l&&a.jsx("div",{className:pt.previewError,children:l})]})}function SZ({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:r,onLoadError:o}){const[i,l]=d.useState(s??null),[c,u]=d.useState(),[h,f]=d.useState(null);return d.useEffect(()=>{let m=!1;if(l(s??null),f(null),u(void 0),!r)return n.stat(e).then(g=>{if(!m){if(g.type==="directory")throw new Error("Directories cannot be opened as artifacts.");return n.readWorkspaceFile(e,{maxBytes:256*1024})}}).then(async g=>{if(m||!g||!g.truncated)return g;const w=await _4((y,x)=>n.readFileBytes(y,x),e,"application/octet-stream",{statFile:y=>n.stat(y),isCancelled:()=>m});return{sizeBytes:w.size,content:new TextDecoder(g.encoding||"utf-8").decode(await w.arrayBuffer())}}).then(g=>{m||!g||(u(g.sizeBytes),l(g.content))}).catch(g=>{if(m)return;const w=g instanceof Error?g.message:String(g);f(w),o?.(w)}),()=>{m=!0}},[t,s,r,o,n,e]),{content:i,error:h,sizeBytes:c}}function L0n({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewSizeBytes:r,previewOnly:o,onLoadError:i}){const{content:l,error:c,sizeBytes:u}=SZ({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:o,onLoadError:i});return a.jsxs("div",{className:pt.htmlPreviewWrap,children:[l===null?!c&&a.jsx("div",{className:pt.empty,children:"Loading preview..."}):a.jsx(IRe,{content:l,sizeBytes:u??r,workspacePath:e,workspaceActions:n,children:()=>a.jsx(D0n,{content:l,workspacePath:e})}),c&&a.jsx("div",{className:pt.previewError,children:c})]})}function D0n({content:e,workspacePath:t}){const n=`Preview ${t}`,{t:s}=Ct(),[r,o]=d.useState(null),[i,l]=d.useState(null);return d.useEffect(()=>{const c=new AbortController;return o(null),l(null),hVe(e,n,c.signal).then(u=>{c.signal.aborted||o(u)},u=>{c.signal.aborted||l(Iu(u))}),()=>c.abort()},[e,n]),i?a.jsx("div",{className:pt.previewError,children:s("artifact.previewFailed",{message:i})}):r===null?a.jsx("div",{className:pt.empty,children:s("attachment.loadingPreview")}):a.jsx("iframe",{className:pt.htmlPreview,referrerPolicy:"no-referrer",sandbox:"allow-scripts",srcDoc:r,title:n})}function TRe({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:r,onLoadError:o}){const i=d.useRef(null),[l,c]=d.useState(null),{content:u,error:h}=SZ({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:r,onLoadError:o});return d.useEffect(()=>{const f=i.current;if(!f||u===null)return;f.replaceChildren(),c(null);let m;try{m=new js({doc:u,extensions:[vTe,js.editable.of(!1),ua.readOnly.of(!0),js.lineWrapping],parent:f})}catch(g){c(g instanceof Error?g.message:String(g));return}return()=>m.destroy()},[u]),a.jsxs("div",{className:pt.filePreviewWrap,children:[u===null?!h&&a.jsx("div",{className:pt.empty,children:"Loading file..."}):a.jsx("div",{ref:i,className:pt.codeMirrorFile}),(h||l)&&a.jsx("div",{className:pt.previewError,children:h||l})]})}function IRe({content:e,sizeBytes:t,workspacePath:n,workspaceActions:s,children:r}){const{t:o}=Ct(),[i,l]=d.useState(null);if(!d.useMemo(()=>(t??new TextEncoder().encode(e).byteLength)>1024*1024,[e,t]))return r();const u=i===e;return a.jsxs("div",{className:"absolute inset-3 flex min-h-0 flex-col gap-2",children:[a.jsxs("div",{className:"flex shrink-0 items-center gap-2 text-sm text-muted-foreground",children:[a.jsx("span",{children:o("artifact.longDocument")}),a.jsx(Wt,{className:"ml-auto shrink-0",variant:"outline",size:"sm",onClick:()=>l(u?null:e),children:o(u?"artifact.showSource":"artifact.renderFullPreview")})]}),a.jsx("div",{className:"relative min-h-0 flex-1 overflow-auto",children:u?r():a.jsx(TRe,{workspacePath:n,workspaceActions:s,previewContent:e,previewOnly:!0})})]})}function O0n({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewSizeBytes:r,previewOnly:o,onLoadError:i}){const{content:l,error:c,sizeBytes:u}=SZ({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:o,onLoadError:i});return a.jsxs("div",{className:pt.htmlPreviewWrap,children:[l===null?!c&&a.jsx("div",{className:pt.empty,children:"Loading preview..."}):a.jsx(IRe,{content:l,sizeBytes:u??r,workspacePath:e,workspaceActions:n,children:()=>a.jsx("div",{className:pt.markdownPreviewWrap,children:a.jsx(Im,{content:l})})}),c&&a.jsx("div",{className:pt.previewError,children:c})]})}function kp({label:e,value:t}){return t?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:pt.fieldLabel,children:e}),a.jsx("span",{className:pt.fieldValue,children:t})]}):null}function C2(e,t,n){const s=e[t];return s==null||s===""?null:a.jsx(kp,{label:n,value:String(s)},t)}/**
2217
2217
  * @license
2218
2218
  * Copyright 2025 Qwen Team
2219
2219
  * SPDX-License-Identifier: Apache-2.0
@@ -2230,7 +2230,7 @@ ${e.replace(/\n?$/,`
2230
2230
  `),error:!0}),!1;if(Yt.discoveryState==="completed")return We&&Te(null),!0;if(Yt.initialized&&Yt.discoveryState==="not_started"&&Yt.servers.length===0)return $t&&h(Yt),We&&Te({text:o("mcp.discovery.empty")}),!0;if(!await je())return!1}return We&&Te({text:o("mcp.discovery.timeout"),error:!0}),!1},[Ie,o,je]);d.useEffect(()=>{Ze.current||(Ze.current=!0,F(!0),(async()=>{c?.status.source==="live"&&c.status.runtimeEpoch!==void 0&&c.status.discoveryState==="completed"&&(await ot())?.runtimeEpoch===c.status.runtimeEpoch||(await l.ensureRuntime(),Tt.current&&await ue())})().catch(We=>{Tt.current&&Te({text:kg(We)?o("daemon.capacity.exhausted"):Iu(We),error:!0})}).finally(()=>{Tt.current&&F(!1)}))},[c,ot,l,ue,o]);const W=d.useMemo(()=>(u.servers??[]).filter(rwn),[u.servers]),ne=W.find(We=>We.name===y)??null,me=ne?f[ne.name]?.tools??[]:[],Me=ne?g[ne.name]?.resources??[]:[],Ke=me.find(We=>We.name===k)??null,be=Me.find(We=>We.uri===S)??null;d.useEffect(()=>{n?.onDetailChange(!!ne)},[n,ne]);const ke=d.useMemo(()=>{const We=j.trim().toLowerCase();return W.filter($t=>{const pn=R==="all"||rV($t)===R,Yt=!We||$t.name.toLowerCase().includes(We)||$t.description?.toLowerCase().includes(We)||$t.extensionName?.toLowerCase().includes(We);return pn&&!!Yt})},[j,W,R]),Pe=d.useCallback(async We=>{const $t=await ot();if(!$t)throw new Error(o("mcp.discovery.timeout"));const pn=[],[Yt,an]=await Promise.allSettled([l.loadTools(We.name),We.resourceCount?l.loadResources(We.name):Promise.resolve(null)]);if(Yt.status==="fulfilled"){if(Yt.value.runtimeEpoch!==$t.runtimeEpoch)throw new Error(o("mcp.discovery.timeout"));m(jn=>({...jn,[We.name]:Yt.value})),Ve(jn=>({...jn,[We.name]:{...jn[We.name],tools:void 0}}))}else{pn.push(Yt.reason);const jn=Iu(Yt.reason);Ve(St=>({...St,[We.name]:{...St[We.name],tools:jn}}))}if(an.status==="fulfilled"&&an.value!==null){const jn=an.value;if(jn.runtimeEpoch!==$t.runtimeEpoch)throw new Error(o("mcp.discovery.timeout"));w(St=>({...St,[We.name]:jn})),Ve(St=>({...St,[We.name]:{...St[We.name],resources:void 0}}))}else if(an.status==="rejected"){pn.push(an.reason);const jn=Iu(an.reason);Ve(St=>({...St,[We.name]:{...St[We.name],resources:jn}}))}else w(jn=>{if(!(We.name in jn))return jn;const St={...jn};return delete St[We.name],St}),Ve(jn=>({...jn,[We.name]:{...jn[We.name],resources:void 0}}));if(pn.length>0)throw new AggregateError(pn,`${We.name}: ${pn.map(Iu).join("; ")}`)},[ot,l,o]),qe=d.useCallback(async()=>{if(!H){$(!0),Te(null);try{if(await l.ensureRuntime(),!await ue(!1))throw new Error(o("mcp.discovery.timeout"))}catch(We){Te({text:kg(We)?o("daemon.capacity.exhausted"):Iu(We),error:!0})}finally{$(!1)}}},[l,ue,H,o]),tt=d.useCallback(async()=>{const We=V.trim(),$t=K!==null;if(!We){ye(o("mcp.add.nameRequired"));return}let pn;try{const Yt=JSON.parse(re);if(!Yt||typeof Yt!="object"||Array.isArray(Yt))throw new Error(o("mcp.add.configInvalid"));const an=q.trim();pn={...Yt,...an?{description:an}:{}}}catch(Yt){ye(kg(Yt)?o("daemon.capacity.exhausted"):Iu(Yt));return}ye(null),he(!0);try{const Yt=await l.setConfigServer(We,ie,pn);Te(null);const an=Yt.activation!=="deferred"&&await ue(!1).catch(()=>!1);Te({...$t?{serverName:We}:{},text:an?o($t?"mcp.edit.done":"mcp.add.done",{name:We}):o("mcp.runtime.notUpdated"),error:!an,success:an}),Z(!1),B(null),J(""),te(""),G(tz)}catch(Yt){ye(kg(Yt)?o("daemon.capacity.exhausted"):Iu(Yt))}finally{he(!1)}},[l,K,re,q,V,ie,ue,o]),ut=d.useCallback(async()=>{if(_e){O(_e.name);try{const We=Mue(_e),$t=await l.removeConfigServer(_e.name,We);ae(null),Te({serverName:_e.name,text:o("mcp.action.running",{action:o("mcp.action.remove")}),progress:!0}),$t.activation!=="deferred"&&await ue(!1,!0).catch(()=>!1)?(x(null),_(null),I(null),Te(null)):Te({serverName:_e.name,text:o("mcp.runtime.removeNotUpdated"),error:!0})}catch(We){Te({serverName:_e.name,text:o("mcp.action.failed",{error:kg(We)?o("daemon.capacity.exhausted"):Iu(We)}),error:!0})}finally{O(null)}}},[l,ue,_e,o]),It=d.useCallback(async We=>{if(M)return;const $t=F5(We);if($t!=="user_settings"&&$t!=="workspace_settings")return;const pn=$t==="workspace_settings"?"workspace":"user";O(We.name),Te(null);try{const an=(await l.loadConfig())[pn][We.name];if(!an||typeof an!="object"||Array.isArray(an))throw new Error(o("mcp.edit.notFound"));const jn={...an},St=jn.description;delete jn.description,B(We),J(We.name),ge(pn),te(typeof St=="string"?St:""),G(JSON.stringify(jn,null,2)),ye(null),Z(!0)}catch(Yt){Te({serverName:We.name,text:o("mcp.action.failed",{error:kg(Yt)?o("daemon.capacity.exhausted"):Iu(Yt)}),error:!0})}finally{O(null)}},[M,l,o]),lt=d.useCallback(async(We,$t)=>{if(!M){if($t.id==="remove"){ae(We);return}if($t.id==="edit"){await It(We);return}O(We.name),Te({serverName:We.name,text:$t.id==="authenticate"?nz(We.name,o):o("mcp.action.running",{action:$t.label}),progress:!0});try{let pn="",Yt,an=!1;if($t.id==="reconnect"){const St=await l.restartServer(We.name);if(!Tt.current)return;if("restarted"in St&&!St.restarted)throw St.reason==="authentication_required"?new Error(o("mcp.reconnect.authenticationRequired")):new Error(o("mcp.reconnect.skipped",{reason:St.reason}));if("entries"in St&&(St.entries.length===0||St.entries.every(zt=>!zt.restarted)))throw new Error(o("mcp.reconnect.skipped",{reason:St.entries.map(zt=>zt.reason).filter(Boolean).join(", ")||"not connected"}))}else if($t.id==="enable"||$t.id==="disable"){const St=$t.id==="enable"?["user","workspace"]:[Mue(We)];let zt="deferred";for(const In of St){const En=await l.setConfigServerEnabled(We.name,In,$t.id==="enable");En.activation!=="deferred"&&(zt=En.activation)}if(!Tt.current)return;if(zt==="deferred"){Te({serverName:We.name,text:o("mcp.runtime.notUpdated"),error:!0});return}const ln=await ue(!1);if(!Tt.current)return;if(!ln){Te({serverName:We.name,text:o("mcp.runtime.notUpdated"),error:!0});return}}else{const St=await l.manageServer(We.name,$t.id);if(!Tt.current)return;Yt=St.authUrl,pn=[...St.messages??[]].join(`
2231
2231
  `),an=$t.id==="authenticate"&&St.pending===!0,an&&Te({serverName:We.name,text:nz(We.name,o,pn),progress:!0,...Yt?{authUrl:Yt}:{}})}let jn;if(an){for(let St=0;St<400;St+=1){if(!await je())return;const zt=await Ie();if(!Tt.current)return;if(!zt)continue;h(zt);const ln=zt.errors?.[0];if(ln)throw new Error(ln.error||ln.hint||o("mcp.oauth.statusFailed"));const In=zt.servers?.find(En=>En.name===We.name);if(!In)throw new Error(o("mcp.oauth.serverRemoved"));if(In.authenticationState==="failed")throw new Error(In.authenticationError||o("mcp.oauth.authenticationFailed"));if(In.authenticationState==="succeeded"||In.authenticationState===void 0&&In.mcpStatus==="connected"){jn=zt;break}}if(!jn)throw new Error(o("mcp.oauth.timeout"))}else{if(jn=await Ie(),!Tt.current)return;for(let St=0;jn?.discoveryState!==void 0&&jn.discoveryState!=="completed"&&!jn.errors?.length&&St<40;St+=1){if(!await je())return;const zt=await Ie();if(!Tt.current)return;zt&&(jn=zt,h(zt))}}if(jn){h(jn);const St=jn.servers?.find(zt=>zt.name===We.name);if(St&&(jn.discoveryState===void 0||jn.discoveryState==="completed")){try{await Pe(St)}catch{}if(!Tt.current)return}}Te({serverName:We.name,text:an?o("mcp.action.done",{action:$t.label}):$t.id==="authenticate"&&pn?nz(We.name,o,pn):pn||o("mcp.action.done",{action:$t.label}),success:!0,...!an&&Yt?{authUrl:Yt}:{}})}catch(pn){Tt.current&&Te({serverName:We.name,text:o("mcp.action.failed",{error:kg(pn)?o("daemon.capacity.exhausted"):Iu(pn)}),error:!0})}finally{Tt.current&&O(null)}}},[M,Ie,Pe,l,It,ue,o,je]),ft=We=>{x(We.name),A("overview"),_(null),I(null),Te(null),!We.approvalState&&Pe(We).catch($t=>{Te({serverName:We.name,text:o("mcp.action.failed",{error:kg($t)?o("daemon.capacity.exhausted"):Iu($t)}),error:!0})})},dt=()=>{M===null&&(x(null),_(null),I(null),qe())},ht=()=>{_(null),I(null)},qt=a.jsx(Bx,{className:"sticky -top-4 z-10 -mx-5 -mt-4 border-b bg-background px-5 py-3",children:a.jsxs(Fx,{className:"text-base",children:[a.jsx(eu,{children:a.jsx(Wt,{variant:"ghost",size:"icon",disabled:M!==null,onClick:t,"aria-label":o("common.back"),children:a.jsx(ek,{})})}),a.jsx(eu,{children:ne?a.jsx(hw,{asChild:!0,children:a.jsx("button",{type:"button",disabled:M!==null,onClick:dt,children:o("mcp.title")})}):a.jsx(Bf,{children:o("mcp.title")})}),ne?a.jsx(fw,{}):null,ne?a.jsx(eu,{children:Ke||be?a.jsx(hw,{asChild:!0,children:a.jsx("button",{type:"button",onClick:ht,children:ne.name})}):a.jsx(Bf,{children:ne.name})}):null,Ke||be?a.jsx(fw,{}):null,Ke?a.jsx(eu,{children:a.jsx(Bf,{children:Ke.name})}):null,be?a.jsx(eu,{children:a.jsx(Bf,{children:be.title||be.name||be.uri})}):null]})}),Vt=Ke?Ke.name:be?be.title||be.name||be.uri:ne?.name,gn=n?ne?a.jsxs("div",{className:"sticky -top-4 z-10 -mx-5 -mt-4 flex items-center gap-3 border-b bg-background px-5 py-3",children:[a.jsx(Bx,{className:"min-w-0 flex-1",children:a.jsxs(Fx,{className:"h-8 text-sm",children:[a.jsx(eu,{children:a.jsx(hw,{asChild:!0,children:a.jsx("button",{type:"button",disabled:M!==null,onClick:dt,children:o("mcp.title")})})}),a.jsx(fw,{}),a.jsx(eu,{children:Ke||be?a.jsx(hw,{asChild:!0,children:a.jsx("button",{type:"button",onClick:ht,children:ne.name})}):a.jsx(Bf,{children:ne.name})}),Ke||be?a.jsx(fw,{}):null,Ke||be?a.jsx(eu,{children:a.jsx(Bf,{children:Vt})}):null]})}),r]}):null:qt,tn=a.jsx(ab,{open:_e!==null,onOpenChange:We=>!We&&ae(null),children:a.jsxs(lb,{showCloseButton:!1,children:[a.jsxs(wx,{children:[a.jsx(cb,{children:o("mcp.remove.title")}),a.jsx(bS,{children:o(_e&&rV(_e)==="workspace"?"mcp.remove.description":"mcp.remove.description.global",{name:_e?.name??""})})]}),a.jsxs(yx,{children:[a.jsx(Wt,{variant:"outline",onClick:()=>ae(null),disabled:M!==null,children:o("common.cancel")}),a.jsxs(Wt,{variant:"destructive",onClick:()=>void ut(),disabled:M!==null,children:[M?a.jsx(ea,{"data-icon":"inline-start"}):a.jsx(_m,{"data-icon":"inline-start"}),o("mcp.action.remove")]})]})]})}),qn=a.jsx(ab,{open:Y,onOpenChange:We=>{Q||(Z(We),We||B(null))},children:a.jsxs(lb,{className:"sm:max-w-lg",showCloseButton:!1,children:[a.jsxs(wx,{children:[a.jsx(cb,{children:o(K?"mcp.edit.title":"mcp.add.title")}),a.jsx(bS,{children:o(K?"mcp.edit.description":"mcp.add.description")})]}),a.jsxs("div",{className:"grid gap-4",children:[ve?a.jsxs(qf,{variant:"destructive",children:[a.jsx(Hf,{}),a.jsx(Vf,{children:ve})]}):null,a.jsxs("label",{className:"grid gap-2 text-sm font-medium",children:[o("mcp.add.name"),a.jsx(hi,{value:V,onChange:We=>J(We.target.value),placeholder:"my-mcp-server",disabled:Q||K!==null})]}),a.jsxs("label",{className:"grid gap-2 text-sm font-medium",children:[o("mcp.add.serverDescription"),a.jsx(hi,{value:q,onChange:We=>te(We.target.value),placeholder:o("mcp.add.serverDescriptionPlaceholder"),disabled:Q})]}),a.jsxs("label",{className:"grid gap-2 text-sm font-medium",children:[o("mcp.add.scope"),a.jsxs(Yu,{value:ie,onValueChange:We=>ge(We),disabled:Q||K!==null,children:[a.jsx(Zu,{className:"w-full",children:a.jsx(Xu,{})}),a.jsxs(Ju,{children:[a.jsx(sl,{value:"workspace",children:o("settings.scope.workspace")}),a.jsx(sl,{value:"user",children:o("mcp.add.scope.global")})]})]})]}),a.jsxs("label",{className:"grid gap-2 text-sm font-medium",children:[o("mcp.add.config"),a.jsx(j_,{className:"min-h-44 font-mono text-xs",value:re,onChange:We=>G(We.target.value),disabled:Q})]})]}),a.jsxs(yx,{children:[a.jsx(Wt,{variant:"outline",onClick:()=>{Z(!1),B(null)},disabled:Q,children:o("common.cancel")}),a.jsxs(Wt,{onClick:()=>void tt(),disabled:Q,children:[Q?a.jsx(ea,{"data-icon":"inline-start"}):null,o(Q?K?"mcp.edit.saving":"mcp.add.adding":K?"mcp.edit.save":"mcp.add.button")]})]})]})});if(Ke&&ne)return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex w-full flex-col gap-6 pb-8",children:[gn,a.jsxs("div",{className:"flex w-full flex-col gap-6",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("div",{className:"flex size-11 shrink-0 items-center justify-center rounded-xl bg-muted",children:a.jsx(wH,{})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("h1",{className:"break-words text-xl font-semibold",children:Ke.name}),a.jsx("p",{className:"text-sm text-muted-foreground",children:Ke.serverToolName||ne.name})]})]}),a.jsx(qu,{children:a.jsx(Cp,{children:a.jsx(cwn,{tool:Ke,t:o})})})]})]}),qn]});if(be&&ne)return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex w-full flex-col gap-6 pb-8",children:[gn,a.jsxs("div",{className:"flex w-full flex-col gap-6",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("div",{className:"flex size-11 shrink-0 items-center justify-center rounded-xl bg-muted",children:a.jsx(vH,{})}),a.jsx("h1",{className:"min-w-0 break-words text-xl font-semibold",children:be.title||be.name||be.uri})]}),a.jsx(qu,{children:a.jsx(Cp,{children:a.jsx(uwn,{resource:be,t:o})})})]})]}),qn]});if(ne){const We=me,$t=Me,pn=Ae[ne.name],Yt=iwn(ne,o);return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex w-full flex-col gap-6 pb-8",children:[gn,a.jsxs("div",{className:"flex w-full flex-col gap-6",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("div",{className:"flex size-12 shrink-0 items-center justify-center rounded-xl bg-muted",children:a.jsx(fT,{})}),a.jsx("div",{className:"min-w-0 flex-1",children:a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("h1",{className:"break-words text-xl font-semibold",children:ne.name}),a.jsx(_a,{variant:"secondary",className:Due(ne),children:Lue(ne,o)}),a.jsx(_a,{variant:"outline",children:Pue(ne,o)})]})}),a.jsxs(Z0,{children:[a.jsx(Vg,{asChild:!0,children:a.jsx(Wt,{variant:"ghost",size:"icon",disabled:M!==null,"aria-label":o("mcp.actions"),"data-testid":"mcp-server-actions",children:M===ne.name?a.jsx(ea,{}):a.jsx(yS,{})})}),a.jsx(Gg,{align:"end",onCloseAutoFocus:an=>an.preventDefault(),children:a.jsx($x,{children:Yt.map(an=>a.jsx(yi,{"data-testid":`mcp-server-action-${an.id}`,variant:an.id==="remove"?"destructive":"default",disabled:M!==null,onSelect:()=>void lt(ne,an),children:an.label},an.id))})})]})]}),Se?.serverName===ne.name?a.jsxs(Np,{tone:Ne,noticeKey:Se.text,closeLabel:o("common.close"),onDismiss:()=>Te(null),className:"whitespace-pre-wrap break-words",children:[a.jsx("p",{children:Se.text}),Se.authUrl&&awn(Se.authUrl)?a.jsx("a",{className:"mt-2 inline-block underline underline-offset-3",href:Se.authUrl,target:"_blank",rel:"noreferrer",onClick:an=>i(an,Se.authUrl),children:o("mcp.oauth.open")}):null]}):null,a.jsxs(Ew,{value:E,onValueChange:A,children:[a.jsxs(Aw,{children:[a.jsx(da,{value:"overview",children:o("mcp.basicInfo")}),a.jsxs(da,{value:"tools",children:[o("mcp.tools")," ",We.length]}),a.jsxs(da,{value:"resources",children:[o("mcp.resources")," ",ne.resourceCount??$t.length]})]}),a.jsx(Ga,{value:"overview",className:"pt-4",children:a.jsxs(qu,{children:[a.jsxs(Ff,{children:[a.jsx(zf,{className:"text-sm",children:o("mcp.descriptionTitle")}),a.jsx(Eg,{children:ne.description?.trim()||"-"})]}),a.jsxs(Cp,{className:"grid gap-6 sm:grid-cols-2",children:[a.jsx(bm,{label:o("mcp.source"),value:Pue(ne,o)}),a.jsx(bm,{label:o("mcp.transport"),value:ne.transport}),a.jsx(bm,{label:o("mcp.command"),value:own(ne,o)}),a.jsx(bm,{label:o("mcp.workingDirectory"),value:ne.config?.cwd||u.workspaceCwd}),ne.error?a.jsx(bm,{label:o("mcp.invalidReasonLabel"),value:ne.error}):null,ne.hint?a.jsx(bm,{label:o("mcp.description"),value:ne.hint}):null]})]})}),a.jsx(Ga,{value:"tools",className:"pt-4",children:pn?.tools?a.jsxs(qf,{variant:"destructive",children:[a.jsx(Hf,{}),a.jsx(a8,{children:o("mcp.loadingTools")}),a.jsx(Vf,{children:pn.tools})]}):We.length?a.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:We.map(an=>a.jsx(qu,{size:"sm",role:"button",tabIndex:0,className:"cursor-pointer transition-colors hover:bg-accent/50",onClick:()=>_(an.name),onKeyDown:jn=>{(jn.key==="Enter"||jn.key===" ")&&(jn.preventDefault(),_(an.name))},children:a.jsxs(Ff,{children:[a.jsx(zf,{className:"break-words",children:an.name}),a.jsx(Eg,{className:"line-clamp-2 text-xs",children:an.description||o("mcp.noDescription")}),an.isValid?null:a.jsx(pze,{children:a.jsx(_a,{variant:"destructive",children:o("mcp.status.blocked")})})]})},an.name))}):a.jsx(Qy,{className:"rounded-xl border border-dashed",children:a.jsxs(eb,{children:[a.jsx(tb,{variant:"icon",children:a.jsx(wH,{})}),a.jsx(nb,{children:o("mcp.emptyTools")})]})})}),a.jsx(Ga,{value:"resources",className:"pt-4",children:pn?.resources?a.jsxs(qf,{variant:"destructive",children:[a.jsx(Hf,{}),a.jsx(a8,{children:o("mcp.resourcesUnavailable")}),a.jsx(Vf,{children:pn.resources})]}):$t.length?a.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:$t.map(an=>a.jsx(qu,{size:"sm",role:"button",tabIndex:0,className:"cursor-pointer transition-colors hover:bg-accent/50",onClick:()=>I(an.uri),onKeyDown:jn=>{(jn.key==="Enter"||jn.key===" ")&&(jn.preventDefault(),I(an.uri))},children:a.jsxs(Ff,{children:[a.jsx(zf,{className:"break-words",children:an.title||an.name||an.uri}),a.jsx(Eg,{className:"break-all",children:an.uri})]})},an.uri))}):a.jsx(Qy,{className:"rounded-xl border border-dashed",children:a.jsxs(eb,{children:[a.jsx(tb,{variant:"icon",children:a.jsx(vH,{})}),a.jsx(nb,{children:o("mcp.noResources")})]})})})]})]})]}),tn,qn]})}const us=W.filter(We=>!We.disabled&&We.mcpStatus==="connecting").length,Wn=[{value:"all",label:o("mcp.source.all")},{value:"user",label:o("mcp.source.user")},{value:"workspace",label:o("mcp.source.workspace")},{value:"extension",label:o("mcp.source.extension")}];return a.jsxs("div",{className:"flex w-full flex-col gap-6 pb-8",children:[gn,a.jsxs("div",{className:"flex w-full flex-col gap-6",children:[a.jsxs("div",{className:"flex items-start justify-between gap-4",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-xl font-semibold text-balance",children:o("mcp.title")}),a.jsx("p",{className:"mt-1 text-sm text-muted-foreground tabular-nums",children:o("mcp.servers",{count:W.length})})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Wt,{variant:"outline",onClick:()=>void qe(),disabled:H,children:[H?a.jsx(ea,{"data-icon":"inline-start"}):a.jsx(Hg,{"data-icon":"inline-start"}),o("common.refresh")]}),a.jsxs(Wt,{onClick:()=>{B(null),J(""),te(""),ge("workspace"),G(tz),ye(null),Z(!0)},disabled:Q,children:[a.jsx(Qf,{"data-icon":"inline-start"}),o("mcp.add.button")]})]})]}),us>0?a.jsx(Np,{tone:"progress",noticeKey:`mcp-connecting-${us}`,closeLabel:o("common.close"),onDismiss:()=>{},children:a.jsxs("span",{className:"grid gap-1",children:[a.jsx("span",{className:"font-medium",children:o("mcp.starting",{count:us})}),a.jsx("span",{children:o("mcp.startingNote")})]})}):null,Se&&!Se.serverName?a.jsx(Np,{tone:Ne,noticeKey:Se.text,closeLabel:o("common.close"),onDismiss:()=>Te(null),children:Se.text}):null,(u.errors??[]).map((We,$t)=>a.jsxs(qf,{variant:"destructive",children:[a.jsx(Hf,{}),a.jsx(a8,{children:We.kind}),a.jsx(Vf,{children:We.error||We.hint||o("mcp.status.unknown")})]},`${We.kind}-${$t}`)),u.budgetMode&&u.budgetMode!=="off"?a.jsxs(qf,{children:[a.jsx(Hf,{}),a.jsx(Vf,{children:o("mcp.clientBudget",{count:u.clientCount??0,budget:u.clientBudget??"∞"})})]}):null,a.jsxs("div",{className:"relative",children:[a.jsx($p,{className:"pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground"}),a.jsx(hi,{className:"pl-9",value:j,onChange:We=>L(We.target.value),placeholder:`${o("common.search")} MCP…`})]}),a.jsx(oZ,{type:"single",value:R,onValueChange:We=>{We&&N(We)},variant:"outline",size:"sm","aria-label":o("mcp.source"),children:Wn.map(We=>a.jsx(iZ,{value:We.value,children:We.label},We.value))}),P&&us===0?a.jsxs("div",{className:"flex flex-col items-center gap-2 py-6 text-muted-foreground",children:[a.jsx(ea,{className:"size-6"}),a.jsx("span",{className:"text-sm",children:o("mcp.loadingStatus")})]}):ke.length?a.jsx("div",{className:DRe.serverGrid,"data-column-count":Math.min(ke.length,4),children:ke.map(We=>a.jsx(qu,{size:"sm",role:"button",tabIndex:0,"aria-label":We.name,className:"cursor-pointer transition-colors hover:bg-accent/30 focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-none",onClick:()=>ft(We),onKeyDown:$t=>{($t.key==="Enter"||$t.key===" ")&&($t.preventDefault(),ft(We))},children:a.jsx(Ff,{className:"block",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-lg bg-muted",children:a.jsx(fT,{className:"size-5"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-2",children:[a.jsx(zf,{className:"min-w-0 flex-1 truncate",children:We.name}),a.jsx(_a,{variant:"secondary",className:`${Due(We)} shrink-0 text-[10px]`,children:Lue(We,o)})]}),a.jsx(Eg,{className:"mt-1 min-w-0 text-xs",children:a.jsx(Yd,{delayDuration:300,children:a.jsxs(Xd,{children:[a.jsx(Zd,{asChild:!0,children:a.jsx("span",{className:"block truncate",children:We.description?.trim()||"-"})}),a.jsx(Jd,{children:We.description?.trim()||"-"})]})})})]})]})})},We.name))}):a.jsx(Qy,{className:"border",children:a.jsxs(eb,{children:[a.jsx(tb,{variant:"icon",children:j||R!=="all"?a.jsx($p,{}):a.jsx(fT,{})}),a.jsx(nb,{children:o(j||R!=="all"?"mcp.noMatches":"mcp.empty")}),!j&&R==="all"?a.jsx(rZ,{children:o("mcp.emptyDescription")}):null]})})]}),qn]})}function dwn({onClose:e,onUseSkill:t,initialFocusRef:n}){const{t:s}=Ct(),r=fi(),o=d.useMemo(()=>{const I=(r.capabilities?.workspaces??[]).filter(E=>E.kind!=="live");return I.length>0?I:r.workspaceCwd?[{id:"primary",cwd:r.workspaceCwd,primary:!0,trusted:!0}]:[]},[r.capabilities?.workspaces,r.workspaceCwd]),i=o.find(I=>I.cwd===r.workspaceCwd&&I.trusted)?.cwd??o.find(I=>I.primary&&I.trusted)?.cwd??o.find(I=>I.trusted)?.cwd,l=r.capabilities?.features?.includes("workspace_skills_config_runtime")===!0,[c,u]=d.useState(()=>i),[h,f]=d.useState("extensions"),[m,g]=d.useState(!1),[w,y]=d.useState(0);d.useEffect(()=>{c&&o.some(I=>I.cwd===c&&I.trusted)||u(i)},[i,c,o]);const x=d.useCallback(()=>{g(!1),y(I=>I+1)},[]),k=d.useMemo(()=>({onRoot:x,onDetailChange:g}),[x]),_=I=>{f(I),g(!1),y(A=>A+1)},S=I=>(h==="mcp"||h==="skills"&&l)&&o.length>1?a.jsxs(Yu,{value:c,disabled:I,onValueChange:E=>{u(E),g(!1),y(A=>A+1)},children:[a.jsx(Zu,{className:"h-8 w-48","aria-label":s("sidebar.workspaceSelectLabel"),children:a.jsx(Xu,{})}),a.jsx(Ju,{children:o.map(E=>a.jsx(sl,{value:E.cwd,disabled:!E.trusted,children:Rx(E)},E.id))})]}):null;return a.jsxs(Ew,{value:h,onValueChange:_,className:"w-full",children:[m?null:a.jsxs("div",{className:"sticky -top-4 z-10 -mx-5 -mt-4 flex items-center justify-between gap-3 border-b bg-background px-5 py-3",children:[a.jsxs(Aw,{className:"h-8","aria-label":s("plugins.sections"),children:[a.jsx(da,{ref:n,value:"extensions",children:s("plugins.extensions")}),a.jsx(da,{value:"mcp",children:s("plugins.mcp")}),a.jsx(da,{value:"skills",children:s("plugins.skills")}),a.jsx(da,{value:"agents",children:s("plugins.agents")})]}),S(!1)]}),a.jsx(Ga,{value:h,className:"mt-0",children:h==="extensions"?a.jsx(LRe,{onClose:e,embedded:k},`extensions-${w}`):h==="skills"?a.jsx(C4e,{onClose:e,onUseSkill:t,embedded:k,workspaceCwd:l?c:r.workspaceCwd,workspaceControl:S(!0)},`skills-${w}-${c??""}`):h==="agents"?a.jsx(x4e,{onClose:e,embedded:k},`agents-${w}`):a.jsx(ORe,{onClose:e,embedded:k,workspaceCwd:c,workspaceControl:S(!0)},`mcp-${w}-${c??""}`)})]})}const hwn=new Set(["plugins","extensions","mcp","skills","agents"]);function fwn(e){return e!==null&&hwn.has(e)}function pwn(e){return typeof e=="boolean"?{plugins:e,portals:e}:{plugins:e?.plugins??!1,portals:e?.portals??!1,styles:e?.styles}}const Oue=new WeakMap;function mwn(e){const t=Array.from(e.querySelectorAll('style[data-o1-code-web-shell="component"]')).map(n=>n.textContent??"").filter(Boolean).join(`
2232
2232
  `);return t||Array.from(e.querySelectorAll("style[data-vite-dev-id]")).filter(n=>{const s=n.dataset.viteDevId??"";return s.includes("/packages/web-shell/")||s.includes("/web-shell/client/")}).map(n=>n.textContent??"").filter(Boolean).join(`
2233
- `)}function $Re(e,t){const n=e.defaultView?.CSSStyleSheet;if(!n||typeof n.prototype.replaceSync!="function")return null;const s=new n;return s.replaceSync(t),s}function gwn(e,t){const n=Oue.get(e);if(n?.css===t)return n.sheet;const s=$Re(e,t);return s&&Oue.set(e,{css:t,sheet:s}),s}function BRe(e,t){const n=mwn(e.ownerDocument),s=[n,t].filter(o=>!!o);try{const o=n?gwn(e.ownerDocument,n):null,i=t?$Re(e.ownerDocument,t):null,l=[o,i].filter(c=>!!c);if(l.length===s.length&&l.length>0)return e.adoptedStyleSheets=[...e.adoptedStyleSheets,...l],()=>{e.adoptedStyleSheets=e.adoptedStyleSheets.filter(c=>!l.includes(c))}}catch{}const r=s.map(o=>{const i=e.ownerDocument.createElement("style");return i.dataset.o1CodeWebShellShadow="",i.textContent=o,e.appendChild(i),i});return()=>{for(const o of r)o.remove()}}function vwn({children:e,enabled:t,language:n,themeClassName:s,styles:r,initialFocusRef:o}){const i=d.useRef(null),[l,c]=d.useState(null);return d.useLayoutEffect(()=>{if(!t||!i.current)return;i.current.style.setProperty("all","initial","important"),i.current.style.setProperty("display","block","important"),i.current.style.setProperty("min-width","0","important"),i.current.style.setProperty("width","100%","important");const u=i.current.shadowRoot??i.current.attachShadow({mode:"open"}),h=u.ownerDocument.createElement("div");h.dataset.webShellRoot="",h.dataset.webShellShadcn="",h.dataset.webShellShadowRoot="plugins";const f=BRe(u,r);return u.appendChild(h),c(h),()=>{h.remove(),f(),c(null)}},[t,r]),d.useLayoutEffect(()=>{l&&(l.className=s,l.lang=n)},[n,l,s]),d.useLayoutEffect(()=>{l&&o?.current?.focus()},[o,l]),t?a.jsx("div",{ref:i,"data-web-shell-shadow-host":"plugins",children:l?Am.createPortal(e,l):null}):e}const oV={"setting:auto-update":"general.enableAutoUpdate","setting:session-recap":"general.showSessionRecap","setting:session-recap-away-threshold":"general.sessionRecapAwayThresholdMinutes","setting:cleanup-period":"general.cleanupPeriodDays","setting:git-commit-co-author":"general.gitCoAuthor.commit","setting:git-pr-co-author":"general.gitCoAuthor.pr","setting:language":"general.language","setting:prevent-system-sleep":"general.preventSystemSleep","setting:review-attribution":"review.attribution","setting:review-sandbox":"review.sandbox","setting:review-effort":"review.effort","setting:review-comment":"review.comment","setting:review-severity-floor":"review.severityFloor","setting:review-reverse-audit-rounds":"review.reverseAuditRounds","setting:review-approach-rounds":"review.approachRounds","setting:timestamps":"output.showTimestamps","setting:theme":"ui.theme","setting:workflow-keyword-trigger":"ui.disableWorkflowKeywordTrigger","setting:status-in-title":"ui.showStatusInTitle","setting:response-speed":"ui.showResponseTokensPerSecond","setting:followup-suggestions":"ui.enableFollowupSuggestions","setting:tool-call-details":"ui.showToolCallDetails","setting:shell-output-limit":"ui.shellOutputMaxLines","setting:usage-statistics":"privacy.usageStatisticsEnabled","setting:fast-model":"fastModel","setting:advisor-model":"advisorModel","setting:vision-model":"visionModel","setting:model-fallbacks":"modelFallbacks","setting:respect-git-ignore":"context.fileFiltering.respectGitIgnore","setting:respect-o1code-ignore":"context.fileFiltering.respectO1CodeIgnore","setting:fuzzy-file-search":"context.fileFiltering.enableFuzzySearch","setting:code-mode-only":"tools.codeModeOnly","setting:web-search":"tools.webSearch.enabled","setting:web-search-model":"tools.webSearch.model","setting:web-extractor":"tools.webSearch.webExtractor","setting:web-search-timeout":"tools.webSearch.timeoutMs","setting:web-search-limit":"tools.webSearch.maxPerSession","setting:tool-search":"tools.toolSearch.enabled","setting:tool-search-threshold":"tools.toolSearch.threshold","setting:list-directory":"tools.listDirectory.enabled","setting:todo-write":"tools.todoWrite.enabled","setting:interactive-shell":"tools.shell.enableInteractiveShell","setting:workflows":"tools.workflowsEnabled","setting:workflow-size":"tools.workflowSizeGuideline","setting:workflow-name-only":"tools.workflowNameOnly","setting:permission-strategy":"policy.permissionStrategy","setting:model-proposed-goals":"goals.modelProposed","setting:arena-artifacts":"agents.arena.preserveArtifacts","setting:session-workflow":"experimental.sessionWorkflow","setting:scheduled-tasks":"experimental.cron","setting:session-writer-lease":"experimental.sessionWriterLease","setting:agent-team":"experimental.agentTeam","setting:omni-media-delivery":"omni.enabled","setting:artifacts":"experimental.artifact","setting:tool-use-summaries":"experimental.emitToolUseSummaries","setting:voice-model":"voiceModel","setting:image-model":"imageModel"},wwn=["builtin:chat-width","builtin:browser-notifications","builtin:local-control","builtin:connections","builtin:model-management"],ywn=[...Object.keys(oV),...wwn],$ue=new Set;function FRe(e){if(e)for(const t of[...e.includeItems??[],...e.excludeItems??[]])ywn.includes(t)||$ue.has(t)||($ue.add(t),console.warn(`[web-shell] settings presentation: "${t}" matches no published item id and is ignored; the published ids are exported as WEB_SHELL_SETTING_ITEM_IDS.`))}function iV(e,t){return FRe(t),(t?.includeItems?.includes(e)??!0)&&!t?.excludeItems?.includes(e)}function b8(e,t){FRe(t);const n=Object.keys(oV).filter(r=>oV[r]===e);if(n.length===0)return t?.includeItems===void 0;if(n.some(r=>t?.excludeItems?.includes(r)))return!1;const s=t?.includeItems;return s===void 0?!0:n.some(r=>s.includes(r))}const bwn="_section_iwuxi_1",xwn="_header_iwuxi_12",kwn="_title_iwuxi_19",_wn="_addButton_iwuxi_24",Swn="_hint_iwuxi_38",Cwn="_empty_iwuxi_39",Twn="_provider_iwuxi_45",Iwn="_providerName_iwuxi_51",Rwn="_modelRow_iwuxi_59",Ewn="_modelInfo_iwuxi_70",Awn="_modelName_iwuxi_78",jwn="_modelBaseUrl_iwuxi_84",Nwn="_modelId_iwuxi_91",Mwn="_modelDescription_iwuxi_98",Pwn="_modelDetails_iwuxi_99",Lwn="_capability_iwuxi_113",Dwn="_currentBadge_iwuxi_119",Own="_runtimeBadge_iwuxi_127",$wn="_modelActions_iwuxi_135",Bwn="_actionButton_iwuxi_142",Fwn="_deleteButton_iwuxi_143",zwn="_confirmButton_iwuxi_144",Dl={section:bwn,header:xwn,title:kwn,addButton:_wn,hint:Swn,empty:Cwn,provider:Twn,providerName:Iwn,modelRow:Rwn,modelInfo:Ewn,modelName:Awn,modelBaseUrl:jwn,modelId:Nwn,modelDescription:Mwn,modelDetails:Pwn,capability:Lwn,currentBadge:Dwn,runtimeBadge:Own,modelActions:$wn,actionButton:Bwn,deleteButton:Fwn,confirmButton:zwn};function x8(e,t){return`${e.authType}:${t.modelId}:${t.baseUrl??""}`}function Hwn(e,t){const n=e.flatMap(r=>r.models.map(o=>({provider:r,model:o})));if(t){const r=n.find(({model:i})=>i.modelId===t);if(r)return x8(r.provider,r.model);const o=n.filter(({model:i})=>i.baseModelId===t);if(o.length===1)return x8(o[0].provider,o[0].model)}const s=n.find(({model:r})=>r.isCurrent);return s?x8(s.provider,s.model):void 0}function Uwn({providers:e,configurations:t=[],onUpdateContextWindow:n,currentModelId:s,loading:r,error:o,busy:i,onSelectModel:l,onDeleteModel:c,onAddModel:u}){const{t:h}=Ct(),[f,m]=d.useState(null);d.useEffect(()=>{if(f===null)return;const _=S=>{S.key==="Escape"&&m(null)};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[f]);const g=e.map(_=>({..._,models:[..._.models]})),y=[...new Map(t.map(_=>[_.key,_])).values()].filter(_=>!e.some(S=>S.models.some(I=>I.configurationKey===_.key)));for(const _ of y){let S=g.find(I=>I.authType===_.authType);S||(S={kind:"model_provider",status:"ok",authType:_.authType,current:!1,models:[]},g.push(S)),S.models.push({configurationKey:_.key,modelId:_.key,baseModelId:_.modelId,name:_.name||_.modelId,baseUrl:_.baseUrl,envKey:_.envKey,contextLimit:_.contextWindowSize,isCurrent:!1,isRuntime:!1})}const x=g.some(_=>_.models.length>0),k=Hwn(e,s);return a.jsxs("div",{className:Dl.section,"data-testid":"model-management",children:[a.jsxs("div",{className:Dl.header,children:[a.jsx("span",{className:Dl.title,children:h("settings.models.title")}),a.jsx("button",{type:"button",className:Dl.addButton,disabled:i,onClick:u,children:h("settings.models.add")})]}),o&&a.jsx("div",{className:Dl.hint,children:o.message}),r&&!x&&a.jsx("div",{className:Dl.hint,children:h("settings.models.loading")}),!r&&!x&&!o&&a.jsx("div",{className:Dl.empty,children:h("settings.models.empty")}),g.map((_,S)=>_.models.length===0?null:a.jsxs("div",{className:Dl.provider,children:[a.jsx("div",{className:Dl.providerName,children:_.authType}),_.models.map(I=>{const E=t.filter(O=>O.key===I.configurationKey),A=E.length===1?E[0]:void 0,j=e.some(O=>O.models.includes(I)),L=x8(_,I),R=L===k,N=f===L,M=I.name||I.baseModelId;return a.jsxs("div",{className:Dl.modelRow,children:[a.jsxs("div",{className:Dl.modelInfo,children:[a.jsx("span",{className:Dl.modelName,children:I.name||I.baseModelId}),R&&a.jsx("span",{className:Dl.currentBadge,children:h("settings.models.current")}),I.isRuntime&&a.jsx("span",{className:Dl.runtimeBadge,children:h("settings.models.runtime")}),!j&&a.jsx("span",{className:Dl.runtimeBadge,children:h("settings.models.savedConfiguration")}),I.name&&I.name!==I.baseModelId&&a.jsx("span",{className:Dl.modelId,children:I.baseModelId}),I.description&&a.jsx("div",{className:Dl.modelDescription,children:I.description}),I.baseUrl&&a.jsx("span",{className:Dl.modelBaseUrl,children:I.baseUrl.split(/[?#]/)[0]}),(I.contextLimit||I.modalities||I.envKey)&&a.jsxs("div",{className:Dl.modelDetails,children:[I.contextLimit!==void 0&&I.contextLimit>0&&a.jsx("span",{children:h("settings.models.context",{tokens:I.contextLimit.toLocaleString()})}),[["image","auth.advanced.modalityImage"],["video","auth.advanced.modalityVideo"],["audio","auth.advanced.modalityAudio"],["pdf","auth.advanced.modalityPdf"]].map(([O,P])=>I.modalities?.[O]?a.jsx("span",{className:Dl.capability,children:h(P)},O):null),I.envKey&&a.jsxs("span",{children:[h("settings.models.credentialEnv"),":"," ",a.jsx("code",{children:I.envKey})]})]}),A&&a.jsxs(a.Fragment,{children:[A.purpose!=="chat"&&a.jsx("span",{className:Dl.capability,children:h(`auth.purpose.${A.purpose}`)}),A.canEditContextWindow===!1&&a.jsx("div",{className:Dl.modelDescription,children:h("settings.models.ambiguousWindow")}),n&&A.canEditContextWindow!==!1&&a.jsx(Wwn,{configuration:A,busy:i,onSave:n})]})]}),a.jsxs("div",{className:Dl.modelActions,children:[!R&&j&&a.jsx("button",{type:"button",className:Dl.actionButton,disabled:i,"aria-label":`${h("settings.models.setCurrent")} ${M}`,onClick:()=>l(I.modelId),children:h("settings.models.setCurrent")}),!I.isRuntime&&(N?a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:Dl.confirmButton,disabled:i,"aria-label":`${h("settings.models.confirmDelete")} ${M}`,onClick:()=>{m(null),c({...I.configurationKey?{key:I.configurationKey}:{},authType:_.authType,modelId:I.baseModelId,...I.baseUrl?{baseUrl:I.baseUrl}:{}})},children:h("settings.models.confirmDelete")}),a.jsx("button",{type:"button",className:Dl.actionButton,disabled:i,"aria-label":`${h("settings.models.cancel")} ${M}`,onClick:()=>m(null),children:h("settings.models.cancel")})]}):a.jsx("button",{type:"button",className:Dl.deleteButton,disabled:i,"aria-label":`${h("settings.models.delete")} ${M}`,onClick:()=>m(L),children:h("settings.models.delete")}))]})]},L)})]},`${_.authType}:${S}`))]})}function Wwn({configuration:e,busy:t,onSave:n}){const{t:s}=Ct(),r=d.useId(),[o,i]=d.useState(!1),[l,c]=d.useState(""),[u,h]=d.useState(!1),[f,m]=d.useState(""),[g,w]=d.useState(""),y=!l.trim()||/^\d+$/.test(l.trim())&&Number(l)>=1&&Number(l)<=1e7;return o?a.jsxs("form",{className:"mt-3 flex max-w-md flex-col gap-2",onSubmit:x=>{x.preventDefault(),!(!y||u||t)&&(h(!0),m(""),n(e.key,l.trim()?Number(l):null).then(k=>{i(!1),w(k.runtimeSync?.status==="failed"?s("settings.models.runtimeSyncFailed"):k.requiresRestart?s("settings.models.windowSaved"):s("settings.models.saved"))}).catch(k=>m(k instanceof Error?k.message:String(k))).finally(()=>h(!1)))},children:[a.jsxs(vl,{children:[a.jsx(lc,{htmlFor:r,children:s("auth.advanced.contextWindow")}),a.jsx(hi,{id:r,value:l,inputMode:"numeric",placeholder:s("common.auto"),disabled:u||t,"aria-invalid":!y,"aria-describedby":`${r}-hint`,onChange:x=>c(x.target.value)}),a.jsx(Df,{id:`${r}-hint`,children:y?s("settings.models.windowHint"):s("auth.advanced.tokenLimitInvalid",{field:s("auth.advanced.contextWindow")})})]}),f&&a.jsx("p",{role:"alert",className:"text-sm text-destructive",children:f}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Wt,{type:"submit",size:"sm","aria-label":`${s("common.save")} ${e.name||e.modelId}`,disabled:!y||u||t,children:s("common.save")}),a.jsx(Wt,{type:"button",variant:"outline",size:"sm",disabled:u||t,"aria-label":`${s("settings.models.cancel")} ${e.name||e.modelId}`,onClick:()=>i(!1),children:s("settings.models.cancel")})]})]}):a.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[a.jsx(Wt,{size:"sm",variant:"outline",disabled:t,"aria-label":`${s("settings.models.editWindow")} ${e.name||e.modelId}`,onClick:()=>{c(e.contextWindowSize?.toString()??""),m(""),w(""),i(!0)},children:s("settings.models.editWindow")}),g&&a.jsx("span",{role:"status",className:"text-xs text-muted-foreground",children:g})]})}function qwn(){const e=new URL(window.location.href);return e.searchParams.delete("daemon"),e.searchParams.delete("token"),`${e.pathname}${e.search}`}function sz(e,t){return e?e.length===1?e[0].address:t&&!e.some(n=>n.address===t)?"":t:t}function Vwn(){const{t:e}=Ct(),{baseUrl:t,token:n}=fi(),[s,r]=d.useState(),[o,i]=d.useState(""),[l,c]=d.useState(!1),[u,h]=d.useState("");d.useEffect(()=>{let g=!1;return h(""),r9(t,n,"GET","/workspace/local-control").then(w=>{g||(r(w),i(y=>sz(w.interfaces,y)))}).catch(w=>{g||h(w instanceof Error?w.message:String(w))}),()=>{g=!0}},[t,n]);const f=async()=>{if(s){c(!0),h("");try{const g=s.active?"/workspace/local-control/disable":"/workspace/local-control/enable",w=s.active?void 0:{address:o||void 0,target:qwn()},y=await r9(t,n,"POST",g,w);r(y),i(x=>sz(y.interfaces,x))}catch(g){h(g instanceof Error?g.message:String(g));const w=g instanceof XG?g.payload?.interfaces:void 0;w&&(r(y=>y&&{...y,interfaces:w}),i(y=>sz(w,y)))}finally{c(!1)}}},m=(s?.interfaces?.length??0)>1;return a.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4 max-md:px-4","aria-live":"polite",children:[a.jsxs("div",{className:"flex items-start justify-between gap-4",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[a.jsx(Pqe,{className:"size-4","aria-hidden":"true"}),e("settings.localControl.title"),a.jsx(_a,{variant:s?.active?"default":"secondary",children:s?.active?e("settings.localControl.on"):e("settings.localControl.off")})]}),a.jsx("p",{className:"mt-1 max-w-3xl text-sm text-muted-foreground",children:e("settings.localControl.description")})]}),!s&&!u&&a.jsx(ea,{})]}),!s?.active&&m&&a.jsxs(Yu,{value:o,onValueChange:i,children:[a.jsx(Zu,{className:"w-full max-w-sm","aria-label":e("settings.localControl.network"),children:a.jsx(Xu,{placeholder:e("settings.localControl.selectNetwork")})}),a.jsx(Ju,{children:(s?.interfaces??[]).map(g=>a.jsxs(sl,{value:g.address,children:[g.interfaceName," · ",g.address]},g.address))})]}),s?.active&&s.url&&a.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[s.qrText&&a.jsx("pre",{"aria-label":e("settings.localControl.qr"),className:"w-fit overflow-hidden rounded-lg bg-white p-3 font-mono text-[7px] leading-[7px] tracking-normal text-black select-none",children:s.qrText}),a.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[a.jsx("div",{className:"break-all rounded-md bg-muted px-3 py-2 font-mono text-xs",children:s.url}),a.jsxs(Wt,{type:"button",variant:"outline",size:"sm",onClick:()=>void Yf(s.url).catch(W0),children:[a.jsx(ib,{"aria-hidden":"true"}),e("common.copy")]}),a.jsxs("p",{className:"text-xs text-muted-foreground",children:[s.encrypted?e("settings.localControl.encrypted"):e("settings.localControl.unencrypted")," ","·"," ",s.sleepInhibited?e("settings.localControl.awake"):e("settings.localControl.maySleep")]})]})]}),s?.active&&!s.url&&s.urlRedacted&&a.jsx("p",{className:"max-w-3xl text-sm text-muted-foreground",children:e("settings.localControl.urlRedacted")}),u&&a.jsx("p",{className:"text-sm text-destructive",role:"alert",children:u}),a.jsxs(Wt,{type:"button",variant:s?.active?"destructive":"default",className:"w-fit",disabled:l||!s||!s.active&&m&&!o,onClick:f,children:[l&&a.jsx(ea,{}),s?.active?e("settings.localControl.disable"):e("settings.localControl.enable")]})]})}const Gwn=new Set(["advisorModel","imageModel","fastModel","visionModel","voiceModel","modelFallbacks"]),Kwn=new Set(["ui.hideTips","ui.enableUserFeedback","ui.showSessionSummary","ui.keepSessionSummaryOpen","ui.sessionSummaryTimeoutSeconds","ui.incrementalRendering","ui.compactMode","mcpServers","model.reasoningEffort"]);function aD(e,t,n){const s=e(t);return s===t?n:s}function o3(e,t){return aD(t,`settings.category.${e}`,e)}function I2(e,t){return aD(t,`settings.label.${e.key}`,e.label)}function Ywn(e,t){if(e.description)return aD(t,`settings.description.${e.key}`,e.description)}function zRe(e,t,n,s){return aD(s,`settings.option.${e.key}.${String(t)}`,n)}function Xwn(e,t,n){const s=URe(e,t);if(s==null)return"";if(e.key==="advisorModel"&&s==="")return n("model.useMain");if(e.key==="imageModel"&&s==="")return n("model.disabled");if(e.key===q_){const o=nG(s,Ya.Dark);return n(`theme.${o}`)}if(e.key===H8){const o=BV(s);return o?FV(o):String(s)}if(e.type==="boolean")return n(s===!0?"settings.value.on":"settings.value.off");if(e.type==="enum"&&e.options){const o=e.options.find(i=>i.value===s);return o?zRe(e,o.value,o.label,n):String(s)}const r=String(s).replaceAll("\0"," · ");return r.length>24?`${r.slice(0,21)}…`:r}function HRe(e,t){return(t==="user"?e.values.user:e.values.workspace)!==void 0}function Zwn(e,t){if(t==="workspace"?e.values.user!==void 0:e.values.workspace!==void 0)return HRe(e,t)?"settings.alsoModifiedIn":"settings.modifiedIn"}function URe(e,t){const n=t==="user"?e.values.user:e.values.workspace;return n!==void 0?n:e.values.effective}function Jwn(e){const t=new Map;for(const n of e){let s=t.get(n.category);s||(s=[],t.set(n.category,s)),s.push(n)}return Array.from(t.entries()).map(([n,s])=>({category:n,items:s}))}function Bue({category:e}){const t=e.toLowerCase(),n=t.includes("ui")?TWe:t.includes("tool")?wH:t.includes("context")?vH:t.includes("privacy")?nqe:t.includes("model")?rx:t.includes("connection")?sHe:t.includes("daemon")?fT:t.includes("advanced")?iqe:t.includes("experimental")?dUe:Vve;return a.jsx(n,{"data-icon":"inline-start","aria-hidden":"true"})}function rz({title:e,description:t,metadata:n,control:s}){return a.jsxs(vl,{orientation:"responsive",className:"min-h-20 gap-6 px-5 py-4 max-md:px-4",children:[a.jsxs(sZ,{className:"min-w-0",children:[a.jsxs(fKt,{children:[e,n]}),t&&a.jsx(Df,{className:"max-w-3xl",children:t})]}),a.jsx("div",{className:"flex min-w-0 justify-end max-md:justify-start",children:s})]})}function Qwn({name:e,label:t,type:n,value:s,disabled:r,onCommit:o,onInvalid:i}){const l=String(s??""),[c,u]=d.useState(l);d.useEffect(()=>u(l),[l]);const h=()=>{if(n==="number"){const f=c.trim(),m=Number(f);if(!f||!Number.isFinite(m)){u(l),i();return}m!==s&&o(m);return}c!==l&&o(c)};return a.jsx(hi,{type:n,name:e,autoComplete:"off","aria-label":t,value:c,disabled:r,className:"w-[min(80px,50vw)] max-md:w-full",onChange:f=>u(f.target.value),onBlur:h,onKeyDown:f=>{f.key==="Enter"&&f.currentTarget.blur(),f.key==="Escape"&&(u(l),f.currentTarget.blur())}})}function eyn({settingsState:e,presentation:t,onLanguageChange:n,onSubDialog:s,onThemeChange:r,chatWidthMode:o,onChatWidthModeChange:i,modelManagement:l,connections:c,embedded:u=!1,initialCategory:h}){const{language:f,t:m}=Ct(),g=yb(),w=lpe(),y=w?.refreshPermission;d.useEffect(()=>{y?.()},[y]);const{status:x,settings:k,loading:_,error:S,reload:I,setValue:E}=e,[A,j]=d.useState("workspace"),[L,R]=d.useState(""),[N,M]=d.useState(null),[O,P]=d.useState(null),[F,H]=d.useState(!1),$=w!==void 0,Y=_&&!x,Z=d.useMemo(()=>{const ge=k.filter(ve=>!Kwn.has(ve.key)),re=Jwn(ge).map(ve=>({id:ve.category,label:o3(ve.category,m),items:ve.items.map(ye=>({type:"setting",setting:ye}))})),G={type:"local",localKey:"chatWidth"},Q=re.find(ve=>ve.items.some(ye=>ye.type==="setting"&&ye.setting.key===q_));if(Q){const ve=Q.items.findIndex(ye=>ye.type==="setting"&&ye.setting.key===q_);Q.items.splice(ve+1,0,G)}else re.push({id:"UI",label:o3("UI",m),items:[G]});$&&re.find(ye=>ye.items.includes(G))?.items.push({type:"local",localKey:"browserNotifications"});const he=re.find(ve=>ve.id==="Daemon");if(he?he.items.unshift({type:"local-control"}):re.push({id:"Daemon",label:o3("Daemon",m),items:[{type:"local-control"}]}),l&&!Y){const ve=re.find(ye=>ye.id==="Model");ve?ve.items.push({type:"model-management"}):re.push({id:"Model",label:o3("Model",m),items:[{type:"model-management"}]})}return c&&re.push({id:"Connections",label:o3("Connections",m),items:[{type:"connections"}]}),re.map(ve=>({...ve,items:ve.items.filter(ye=>{if(ye.type==="setting")return b8(ye.setting.key,t);const _e=ye.type==="local"?ye.localKey==="chatWidth"?"builtin:chat-width":"builtin:browser-notifications":ye.type==="local-control"?"builtin:local-control":ye.type==="connections"?"builtin:connections":"builtin:model-management";return iV(_e,t)})})).filter(ve=>ve.items.length>0)},[k,m,$,l,c,t,Y]);d.useEffect(()=>{if(Z.length!==0&&!Z.some(ge=>ge.id===L)){const ge=h&&Z.some(re=>re.id===h)?h:Z[0].id;R(ge)}},[L,Z,h]),d.useEffect(()=>{S?P(S.message):x?.warnings?.length?P(x.warnings.map(ge=>m("settings.corrupted",{recovered:ge.recovered?"true":"false"})).join("; ")):k.length>0&&P(null)},[S,k,x,m]);const K=d.useCallback((ge,re,G)=>{F||P(null),M(ge),E(A,ge,re).then(async Q=>{G?.();try{await I()}catch{}Q?.requiresRestart&&ge!==H8&&H(!0)}).catch(Q=>{P(Q instanceof Error?Q.message:String(Q))}).finally(()=>M(null))},[I,F,A,E]),B=Z.find(ge=>ge.id===L)??Z[0],V=B?.items.filter(ge=>ge.type!=="model-management"&&ge.type!=="connections")??[],J=B?.items.some(ge=>ge.type==="model-management"),q=B?.items.some(ge=>ge.type==="connections"),te=(ge,re,G,Q,he=!1)=>a.jsxs(Yu,{value:ge,disabled:he,onValueChange:re,children:[a.jsx(Zu,{size:"sm","aria-label":Q,className:"w-[min(160px,50vw)] bg-background max-md:w-full",children:a.jsx(Xu,{})}),a.jsx(Ju,{position:"popper",align:"end",children:a.jsx(B1e,{children:G.map(ve=>a.jsx(sl,{value:ve.value,children:ve.label},ve.value))})})]}),ie=ge=>{const re=URe(ge,A),Q=N===ge.key;if(ge.key===q_)return te(nG(re)??g,he=>{const ve=he;K(q_,mpe(ve),A==="user"?()=>r(ve):void 0)},fpe.map(he=>({value:he,label:m(`theme.${he}`)})),I2(ge,m),Q);if(ge.key===H8)return te(BV(re)??f,he=>n(he,A),PNe.map(he=>({value:he,label:FV(he)})),I2(ge,m),Q);if(Gwn.has(ge.key))return a.jsx(Wt,{type:"button",variant:"outline",size:"sm",disabled:Q,className:"max-w-[260px] truncate",onClick:()=>s(ge.key,A),children:Xwn(ge,A,m)||m("settings.action.select")});if(ge.type==="boolean"){const he=re===!0;return a.jsx(lx,{checked:he,disabled:Q,onCheckedChange:ve=>K(ge.key,ve),"aria-label":I2(ge,m)})}if(ge.type==="enum"&&ge.options?.length){const he=ge.options.findIndex(ve=>ve.value===re);return te(he>=0?String(he):"",ve=>{const ye=ge.options?.[Number(ve)];ye&&K(ge.key,ye.value)},ge.options.map((ve,ye)=>({value:String(ye),label:zRe(ge,ve.value,ve.label,m)})),I2(ge,m),Q)}return a.jsx(Qwn,{name:ge.key,label:I2(ge,m),type:ge.type==="number"||ge.type==="integer"?"number":"text",value:re,disabled:Q,onCommit:he=>K(ge.key,he),onInvalid:()=>P(m("settings.invalidNumber"))})};return a.jsxs("div",{className:u?"flex min-h-0 flex-1 flex-col text-sm text-foreground":"flex max-w-[min(var(--chat-regular-content-width,1000px),calc(100vw-64px))] flex-col overflow-hidden rounded-xl border border-border bg-background text-sm text-foreground","data-keyboard-scope":!0,children:[!u&&a.jsx("div",{className:"flex items-center justify-between border-b border-border px-5 py-4",children:a.jsxs("div",{children:[a.jsx("h2",{className:"text-base font-semibold text-balance",children:m("settings.title")}),a.jsx("div",{className:"mt-0.5 text-xs text-muted-foreground",children:m("settings.scope.workspace")})]})}),(O||Y)&&a.jsxs(qf,{className:"mx-4 mt-3 w-auto",children:[Y&&a.jsx(ea,{}),a.jsx(Vf,{children:O||m("settings.loading")})]}),a.jsxs(Ew,{value:A,className:"flex min-h-0 flex-1 flex-col gap-0",onValueChange:ge=>{j(ge)},children:[B?.id!=="Connections"&&a.jsxs("div",{className:"flex items-center justify-between gap-4 border-b border-border px-3 py-2",children:[a.jsxs(Aw,{className:"p-0",children:[a.jsx(da,{value:"workspace",children:m("settings.scope.workspace")}),a.jsx(da,{value:"user",children:m("settings.scope.user")})]}),F&&a.jsx(_a,{variant:"secondary",children:m("settings.requiresRestart")})]}),a.jsxs(Ga,{value:A,forceMount:!0,className:"grid min-h-0 flex-1 grid-cols-[190px_minmax(0,1fr)] outline-none max-md:grid-cols-1",children:[a.jsx("nav",{className:"flex min-h-0 flex-col gap-1 overflow-y-auto border-r border-border bg-muted/20 p-3 max-md:flex-row max-md:overflow-x-auto max-md:border-r-0 max-md:border-b","aria-label":m("settings.title"),children:Z.map(ge=>a.jsxs(Wt,{type:"button",variant:ge.id===L?"secondary":"ghost",size:"sm","aria-current":ge.id===L?"page":void 0,className:"w-full justify-start gap-2 px-2.5 max-md:w-auto max-md:shrink-0",onClick:()=>R(ge.id),children:[a.jsx(Bue,{category:ge.id}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:ge.label}),a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:Math.max(1,ge.items.filter(re=>re.type!=="model-management").length)})]},ge.id))}),a.jsxs("section",{className:"min-h-0 min-w-0 overflow-y-auto bg-background p-5 max-md:p-3",children:[!_&&!B&&a.jsx(Qy,{className:"min-h-60",children:a.jsxs(eb,{children:[a.jsx(tb,{variant:"icon",children:a.jsx(Vve,{})}),a.jsx(nb,{children:m("settings.empty")})]})}),B&&a.jsxs("div",{className:"mx-auto w-full max-w-5xl",children:[V.length>0&&a.jsxs(qu,{children:[a.jsx(Ff,{children:a.jsxs(zf,{className:"flex items-center gap-2",children:[a.jsx(Bue,{category:B.id}),B.label]})}),a.jsx(Cp,{className:"-mb-(--card-spacing) p-0",children:a.jsx(cx,{className:"gap-0",children:V.map((ge,re)=>{const G=re>0&&a.jsx(nZ,{className:"mx-5 w-auto max-md:mx-4"});if(ge.type==="local"&&ge.localKey==="browserNotifications"&&w){const ae=w.permission==="unavailable",Se=ae?"unavailable":w.pending?"requesting":w.permission==="denied"?"denied":w.error?"error":w.enabled?w.permission==="granted"?"enabled":"waiting":"disabled";return a.jsxs("div",{children:[G,a.jsx(rz,{title:m("browserNotifications.label"),description:[m("browserNotifications.description"),m(`browserNotifications.${Se}`),...w.persistent?[]:[m("browserNotifications.temporary")]].join(" "),control:a.jsxs("div",{className:"flex items-center gap-2",children:[w.enabled&&w.permission==="default"&&a.jsx(Wt,{variant:"outline",size:"sm",disabled:w.pending,onClick:()=>void w.setEnabled(!0),children:m("browserNotifications.allow")}),a.jsx(lx,{"aria-label":m("browserNotifications.label"),checked:w.enabled,disabled:w.pending||ae&&!w.enabled,onCheckedChange:Te=>void w.setEnabled(Te)})]})})]},ge.localKey)}if(ge.type==="local")return a.jsxs("div",{children:[G,a.jsx(rz,{title:m("settings.label.ui.chatWidth"),description:m("settings.description.ui.chatWidth"),control:te(o,ae=>i(ae),[{value:"1000",label:m("settings.option.ui.chatWidth.1000")},{value:"wide",label:m("settings.option.ui.chatWidth.wide")}],m("settings.label.ui.chatWidth"),!1)})]},ge.localKey);if(ge.type==="local-control")return a.jsxs("div",{children:[G,a.jsx(Vwn,{})]},"local-control");const Q=ge.setting,he=Ywn(Q,m),ve=Zwn(Q,A),ye=HRe(Q,A),_e=ve?m(ve,{scope:m(A==="workspace"?"settings.scope.user":"settings.scope.workspace")}):void 0;return a.jsxs("div",{children:[G,a.jsx(rz,{title:I2(Q,m),description:[he,_e].filter(Boolean).join(" · ")||void 0,metadata:ye?a.jsx(_a,{variant:"secondary",children:m(A==="workspace"?"settings.scope.workspace":"settings.scope.user")}):void 0,control:N===Q.key?a.jsx(ea,{}):ie(Q)})]},Q.key)})})})]}),J&&l&&a.jsx("div",{className:V.length>0?"mt-4":void 0,children:a.jsx(Uwn,{...l})}),q&&c]})]})]})]}),!u&&a.jsx("div",{className:"border-t border-border px-5 py-3 text-xs text-muted-foreground",children:m("settings.footer")})]})}const tyn="_dialog_1ymqd_1",nyn="_toolbar_1ymqd_12",syn="_tabs_1ymqd_21",ryn="_tab_1ymqd_21",oyn="_tabActive_1ymqd_39",iyn="_search_1ymqd_48",ayn="_general_1ymqd_60",lyn="_shortcuts_1ymqd_67",cyn="_shortcut_1ymqd_67",uyn="_shortcutKey_1ymqd_87",dyn="_shortcutDesc_1ymqd_95",hyn="_commandList_1ymqd_101",fyn="_commandCard_1ymqd_108",pyn="_commandCardExpanded_1ymqd_115",myn="_commandRow_1ymqd_119",gyn="_commandName_1ymqd_135",vyn="_commandTag_1ymqd_142",wyn="_chevron_1ymqd_152",yyn="_chevronExpanded_1ymqd_160",byn="_commandDetail_1ymqd_164",xyn="_commandDescription_1ymqd_174",kyn="_commandSubcommands_1ymqd_175",_yn="_empty_1ymqd_182",Jc={dialog:tyn,toolbar:nyn,tabs:syn,tab:ryn,tabActive:oyn,search:iyn,general:ayn,shortcuts:lyn,shortcut:cyn,shortcutKey:uyn,shortcutDesc:dyn,commandList:hyn,commandCard:fyn,commandCardExpanded:pyn,commandRow:myn,commandName:gyn,commandTag:vyn,chevron:wyn,chevronExpanded:yyn,commandDetail:byn,commandDescription:xyn,commandSubcommands:kyn,empty:_yn},Syn=[{id:"general",labelKey:"help.tab.general"},{id:"commands",labelKey:"help.tab.commands"},{id:"custom-commands",labelKey:"help.tab.custom"}],Cyn=new Set(["about","agents","approval-mode","arena","auth","branch","btw","bug","clear","compress","context","copy","release","diff","directory","docs","doctor","dream","editor","export","extensions","forget","goal","help","hooks","ide","init","insight","language","lsp","mcp","memory","model","new","permissions","plan","quit","recap","remember","rename","reset","restore","resume","rewind","settings","skills","stats","status","statusline","summary","tasks","terminal-setup","theme","tools","trust","vim"]),Tyn=[["@","help.shortcut.addContext"],["!","help.shortcut.shell"],["/","help.shortcut.commandMenu"],["Tab","help.shortcut.completion"],["Esc","help.shortcut.cancel"],["Ctrl+J","help.shortcut.newline"],["Ctrl+L","help.shortcut.clear"],["Ctrl+Y","help.shortcut.retry"],["Shift+Tab","help.shortcut.approvals"],["Alt+Left/Right","help.shortcut.altWords"],["Up/Down","help.shortcut.history"]];function Iyn(e){return[`/${e.name}`,e.argumentHint].filter(Boolean).join(" ")}function aV(e){return!Cyn.has(e.name)}function Ryn(e,t){return aV(e)?t("help.commandMeta.custom"):t("help.commandMeta.builtIn")}function Eyn(e,t,n){const s=n.trim().toLowerCase();return e.filter(r=>r.name&&r.description!==void 0).filter(r=>t==="commands"?!aV(r):t==="custom-commands"?aV(r):!0).filter(r=>s?r.name.toLowerCase().includes(s)||(r.description??"").toLowerCase().includes(s)||(r.argumentHint??"").toLowerCase().includes(s):!0).sort((r,o)=>r.name.localeCompare(o.name))}function Ayn(){const{t:e}=Ct();return a.jsx("div",{className:Jc.general,children:a.jsx("div",{className:Jc.shortcuts,children:Tyn.map(([t,n])=>a.jsxs("div",{className:Jc.shortcut,children:[a.jsx("span",{className:Jc.shortcutDesc,children:e(n)}),a.jsx("span",{className:Jc.shortcutKey,children:t})]},t))})})}function jyn({commands:e,tab:t,query:n}){const{t:s}=Ct(),[r,o]=d.useState(null),i=d.useMemo(()=>Eyn(e,t,n),[e,n,t]);return i.length===0?a.jsx("div",{className:Jc.empty,children:s(t==="custom-commands"?"help.emptyCustom":"help.empty")}):a.jsx("div",{className:Jc.commandList,children:i.map(l=>{const c=r===l.name;return a.jsxs("article",{className:`${Jc.commandCard} ${c?Jc.commandCardExpanded:""}`,children:[a.jsxs("button",{type:"button",className:Jc.commandRow,onClick:()=>o(c?null:l.name),"aria-expanded":c,children:[a.jsx("span",{className:Jc.commandName,children:Iyn(l)}),a.jsx("span",{className:Jc.commandTag,children:Ryn(l,s)}),a.jsx("svg",{className:`${Jc.chevron} ${c?Jc.chevronExpanded:""}`,viewBox:"0 0 16 16","aria-hidden":"true",children:a.jsx("path",{d:"M6 4.5 9.5 8 6 11.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})})]}),c&&a.jsxs("div",{className:Jc.commandDetail,children:[l.description&&a.jsx("div",{className:Jc.commandDescription,children:l.description}),!!l.subcommands?.length&&a.jsxs("div",{className:Jc.commandSubcommands,children:[s("help.subcommands"),": ",l.subcommands.join(", ")]})]})]},l.name)})})}function Nyn({commands:e}){const{t}=Ct(),[n,s]=d.useState("general"),{filterValue:r,inputProps:o}=JL(),i=n!=="general";return a.jsxs("div",{className:Jc.dialog,children:[a.jsxs("div",{className:Jc.toolbar,children:[a.jsx("div",{className:Jc.tabs,children:Syn.map(l=>a.jsx("button",{type:"button",className:`${Jc.tab} ${l.id===n?Jc.tabActive:""}`,onClick:()=>s(l.id),children:t(l.labelKey)},l.id))}),i&&a.jsx("input",{className:Jc.search,...o,placeholder:t("help.search")})]}),n==="general"?a.jsx(Ayn,{}):a.jsx(jyn,{commands:e,tab:n,query:r})]})}function Myn({currentTheme:e,onSelect:t,onClose:n}){const{t:s}=Ct(),r=fpe.map(h=>({id:h,label:s(`theme.${h}`),description:s(`theme.${h}.desc`)})),[o,i]=d.useState(()=>{const h=r.findIndex(f=>f.id===e);return h>=0?h:0}),l=d.useRef(null),c=h=>{const f=r[h];f&&(t(f.id),n())},{keyboardMode:u}=ak({itemCount:r.length,activeIndex:o,onActiveIndexChange:i,onConfirm:c});return d.useEffect(()=>{l.current?.children[o]?.scrollIntoView({block:"nearest"})},[o]),a.jsx("div",{className:pr("picker-list","picker-list-compact",u?"picker-keyboard-only":void 0),ref:l,role:"listbox","aria-label":s("theme.title"),tabIndex:0,"aria-activedescendant":r.length>0?`theme-opt-${o}`:void 0,"data-web-shell-theme-dialog":!0,children:r.map((h,f)=>{const m=h.id===e;return a.jsxs("div",{id:`theme-opt-${f}`,role:"option","aria-selected":m,className:pr("picker-item","picker-session-item",f===o?"selected":void 0,m?"dialog-current":void 0),"data-web-shell-theme-option":!0,"data-theme-id":h.id,onClick:()=>c(f),onMouseMove:()=>i(f),children:[a.jsx("div",{className:pr("picker-item-row"),children:a.jsx("span",{className:pr("picker-item-title"),children:h.label})}),a.jsx("div",{className:pr("picker-item-meta"),children:h.description})]},h.id)})})}const lV="delete-session-list",Fue=e=>`${lV}-opt-${e}`;function Pyn({onDeleted:e,onError:t,onClose:n,workspaceCwd:s}){const{t:r}=Ct(),o=el(),{sessions:i,loading:l,error:c,deleteSession:u,deleteSessions:h}=L5(s,{autoLoad:!0,maxAgeMs:1e3}),f=o.sessionId,[m,g]=d.useState(!1),[w,y]=d.useState(-1),[x,k]=d.useState(new Set),{filterValue:_,inputProps:S}=JL(()=>{y(-1),k(new Set)}),[I,E]=d.useState(null),A=d.useRef(null),j=d.useRef(null);d.useEffect(()=>{c&&E(c.message)},[c]);const L=d.useMemo(()=>i.filter(F=>{if(F.sourceType==="o1-code-live")return!1;const H=_.toLowerCase();return!H||(F.displayName||"").toLowerCase().includes(H)||F.sessionId.toLowerCase().includes(H)||S5(F,H)}),[i,_]),R=d.useCallback(F=>{F!==f&&k(H=>{const $=new Set(H);return $.has(F)?$.delete(F):$.add(F),$})},[f]);d.useEffect(()=>{if(x.size===0)return;const F=new Set(L.map(H=>H.sessionId));k(H=>{const $=new Set([...H].filter(Y=>F.has(Y)));return $.size===H.size?H:$})},[L,x.size]),d.useEffect(()=>{w>=L.length&&L.length>0&&y(L.length-1)},[L.length,w]),d.useEffect(()=>{A.current?.children[w]?.scrollIntoView({block:"nearest"})},[w]),d.useEffect(()=>{j.current?.focus()},[]);const{keyboardMode:N}=ak({itemCount:L.length,activeIndex:w,onActiveIndexChange:y,onConfirm:F=>{const H=L[F];H&&R(H.sessionId)}}),M=d.useCallback(()=>{if(m)return;if(x.size>0){const H=new Set(L.map(Y=>Y.sessionId)),$=Array.from(x).filter(Y=>H.has(Y));if($.length===0)return;g(!0),h($).then(Y=>{const Z=Y.removed.length+Y.notFound.length,K=Y.errors.length;if(K>0&&Z>0){t(new Error(r("delete.partialFail",{removed:Z,failed:K,detail:Y.errors[0].error}))),n();return}if(K>0){E(r("delete.allFailed",{count:K,reason:Y.errors[0].error})),g(!1),k(new Set);return}if(Z===0){E(r("delete.nonRemoved")),g(!1),k(new Set);return}e([...Y.removed,...Y.notFound]),n()}).catch(Y=>{t(Y),g(!1)});return}const F=L[w];if(F){if(F.sessionId===f){E(r("delete.cannotCurrent"));return}g(!0),u(F.sessionId).then(H=>{if(!H){E(r("delete.notFound")),g(!1);return}e([F.sessionId]),n()}).catch(H=>{t(H),g(!1)})}},[f,u,h,m,L,n,e,t,w,x,r]),O=x.size>0,P=!m&&!l&&O;return a.jsxs("div",{className:pr("picker","picker-in-shell"),children:[a.jsxs("div",{className:pr("picker-search"),children:[a.jsxs("span",{className:pr("picker-search-label"),children:[r("resume.search"),":"," "]}),a.jsx("input",{ref:j,className:pr("picker-search-input"),"aria-label":r("resume.search"),role:"combobox","aria-autocomplete":"list","aria-expanded":"true","aria-controls":lV,"aria-activedescendant":w>=0&&w<L.length?Fue(w):void 0,...S,placeholder:""}),a.jsx("span",{className:pr("picker-search-hint"),children:I||(m?r("delete.deleting"):l?r("common.loading"):O?r("delete.selected",{count:x.size}):_?r("delete.matches",{count:L.length}):"")})]}),a.jsx("div",{className:pr("picker-sep")}),a.jsxs("div",{id:lV,role:"listbox","aria-multiselectable":"true",className:pr("picker-list",N?"picker-keyboard-only":void 0),ref:A,children:[l&&a.jsx("div",{className:pr("picker-empty"),children:r("common.loading")}),!l&&c&&a.jsx("div",{className:pr("picker-empty"),children:c.message}),!l&&!c&&L.length===0&&a.jsx("div",{className:pr("picker-empty"),children:_?r("delete.noMatch",{query:_}):r("delete.none")}),!l&&L.map((F,H)=>{const $=F.sessionId===f,Y=x.has(F.sessionId);return a.jsx(tZ,{session:F,optionId:Fue(H),active:H===w,ariaSelected:Y,current:!1,disabled:$,leading:a.jsx("span",{className:pr("picker-item-checkbox",Y?"picker-item-checkbox-checked":void 0),children:Y?"[x] ":"[ ] "}),trailing:$?a.jsx("span",{className:pr("picker-item-badge"),children:r("resume.current")}):void 0,onClick:()=>{y(H),$||R(F.sessionId)},onActivate:()=>y(H)},F.sessionId)})]}),a.jsx("div",{className:pr("picker-sep")}),a.jsxs("div",{className:pr("dialog-footer-actions"),children:[a.jsx("button",{type:"button",className:pr("dialog-inline-button"),onClick:n,disabled:m,children:r("common.cancel")}),a.jsx("button",{type:"button",className:pr("dialog-danger-button"),onClick:M,disabled:!P,children:r(m?"delete.deleting":"delete.action")})]})]})}const cV="release-session-list",zue=e=>`${cV}-opt-${e}`;function Lyn({onReleased:e,onError:t,onClose:n,workspaceCwd:s}){const{t:r}=Ct(),o=el(),{sessions:i,loading:l,error:c,releaseSession:u}=L5(s,{autoLoad:!0,maxAgeMs:1e3}),h=o.sessionId,[f,m]=d.useState(!1),[g,w]=d.useState(-1),[y,x]=d.useState(null),{filterValue:k,inputProps:_}=JL(()=>{w(-1),x(null)}),[S,I]=d.useState(null),E=d.useRef(null),A=d.useRef(null);d.useEffect(()=>{c&&I(c.message)},[c]);const j=k?i.filter(F=>{const H=k.toLowerCase();return(F.displayName||"").toLowerCase().includes(H)||F.sessionId.toLowerCase().includes(H)||S5(F,H)}):i,L=F=>{const H=j[F];if(!H)return;const $=H.sessionId===h,Y=(H.clientCount??0)>0||H.hasActivePrompt===!0;$||!Y||(w(F),x(H.sessionId))};d.useEffect(()=>{g>=j.length&&j.length>0&&w(j.length-1)},[j.length,g]),d.useEffect(()=>{E.current?.children[g]?.scrollIntoView({block:"nearest"})},[g]),d.useEffect(()=>{A.current?.focus()},[]);const{keyboardMode:R}=ak({itemCount:j.length,activeIndex:g,onActiveIndexChange:w,onConfirm:L}),N=d.useCallback(F=>{const H=F??j.find(Y=>Y.sessionId===y)??void 0;if(!H||f)return;if(!((H.clientCount??0)>0||H.hasActivePrompt===!0)){I(r("release.inactive"));return}if(H.sessionId===h){I(r("release.cannotCurrent"));return}u&&(m(!0),u(H.sessionId).then(()=>{e(H.sessionId),n()}).catch(Y=>{t(Y),m(!1)}))},[h,f,j,n,t,e,u,y,r]),M=j.find(F=>F.sessionId===y)??void 0,O=M&&((M.clientCount??0)>0||M.hasActivePrompt===!0),P=!f&&!l&&!!M&&M.sessionId!==h&&!!O;return a.jsxs("div",{className:pr("picker","picker-in-shell"),children:[a.jsxs("div",{className:pr("picker-search"),children:[a.jsxs("span",{className:pr("picker-search-label"),children:[r("resume.search"),":"," "]}),a.jsx("input",{ref:A,className:pr("picker-search-input"),"aria-label":r("resume.search"),role:"combobox","aria-autocomplete":"list","aria-expanded":"true","aria-controls":cV,"aria-activedescendant":g>=0&&g<j.length?zue(g):void 0,..._,placeholder:""}),a.jsx("span",{className:pr("picker-search-hint"),children:S||(f?r("release.releasing"):l?r("common.loading"):k?r("release.matches",{count:j.length}):"")})]}),a.jsx("div",{className:pr("picker-sep")}),a.jsxs("div",{id:cV,role:"listbox",className:pr("picker-list",R?"picker-keyboard-only":void 0),ref:E,children:[l&&a.jsx("div",{className:pr("picker-empty"),children:r("common.loading")}),!l&&j.length===0&&a.jsx("div",{className:pr("picker-empty"),children:k?r("release.noMatch",{query:k}):r("release.none")}),!l&&j.map((F,H)=>{const $=F.sessionId===h,Y=(F.clientCount??0)>0||F.hasActivePrompt===!0,Z=$||!Y;return a.jsx(tZ,{session:F,optionId:zue(H),active:H===g,confirmed:F.sessionId===y,ariaSelected:F.sessionId===y,current:!1,disabled:Z,trailing:$?a.jsx("span",{className:pr("picker-item-badge"),children:r("resume.current")}):Y?void 0:a.jsx("span",{className:pr("picker-item-badge"),children:r("release.inactiveBadge")}),onClick:()=>L(H),onActivate:()=>w(H)},F.sessionId)})]}),a.jsx("div",{className:pr("picker-sep")}),a.jsxs("div",{className:pr("dialog-footer-actions"),children:[a.jsx("button",{type:"button",className:pr("dialog-inline-button"),onClick:n,disabled:f,children:r("common.cancel")}),a.jsx("button",{type:"button",className:pr("dialog-danger-button"),onClick:()=>N(),disabled:!P,children:r(f?"release.releasing":"release.action")})]})]})}const Dyn="_root_ieg2d_1",Oyn="_list_ieg2d_8",$yn="_item_ieg2d_21",Byn="_itemCursor_ieg2d_42",Fyn="_itemSelected_ieg2d_49",zyn="_prompt_ieg2d_61",Hyn="_keyboardOnly_ieg2d_68",Uyn="_itemDisabled_ieg2d_77",Wyn="_turn_ieg2d_91",qyn="_time_ieg2d_96",Vyn="_footer_ieg2d_102",Gyn="_footerMessage_ieg2d_112",Kyn="_dangerButton_ieg2d_118",fm={root:Dyn,list:Oyn,item:$yn,itemCursor:Byn,itemSelected:Fyn,prompt:zyn,keyboardOnly:Hyn,itemDisabled:Uyn,turn:Wyn,time:qyn,footer:Vyn,footerMessage:Gyn,dangerButton:Kyn},Yyn="rewind-snapshot-list",Hue=e=>`${Yyn}-opt-${e}`;function Xyn(e,t){let n=0;for(const s of e)if(s.kind==="user"){if(n===t)return s.text.trim();n+=1}return""}function Zyn(e){const t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleString():e}function Jyn({blocks:e,loadSnapshots:t,rewind:n,onError:s,onClose:r}){const{t:o}=Ct(),[i,l]=d.useState([]),[c,u]=d.useState(!0),[h,f]=d.useState(null),[m,g]=d.useState(0),[w,y]=d.useState(null),[x,k]=d.useState(null);d.useEffect(()=>{let L=!0;return u(!0),t().then(R=>{L&&l(R.snapshots)}).catch(R=>{L&&s(R)}).finally(()=>{L&&u(!1)}),()=>{L=!1}},[t,s]);const _=d.useMemo(()=>i.map(L=>({snapshot:L,promptText:Xyn(e,L.turnIndex)})).sort((L,R)=>L.snapshot.turnIndex-R.snapshot.turnIndex),[e,i]);d.useEffect(()=>{m>=_.length&&_.length>0&&g(_.length-1)},[_.length,m]);const S=d.useRef(null),I=h!==null,E=L=>{!L||h||(f(L),k(null),n(L).then(()=>{r()}).catch(R=>{s(R),k(o("rewind.failed",{reason:R instanceof Error?R.message:String(R)})),f(null)}))},A=L=>{const R=_[L];R&&(g(L),y(R.snapshot.promptId))},{keyboardMode:j}=ak({itemCount:_.length,activeIndex:m,onActiveIndexChange:g,onConfirm:A,enabled:!I});return d.useEffect(()=>{S.current?.children[m]?.scrollIntoView({block:"nearest"})},[m]),d.useEffect(()=>{if(c||_.length===0)return;document.activeElement?.getAttribute("role")==="dialog"&&S.current?.focus()},[c,_.length]),c?a.jsx("div",{className:pr("picker-empty"),children:o("rewind.loading")}):_.length===0?a.jsx("div",{className:pr("picker-empty"),children:o("rewind.empty")}):a.jsxs("div",{className:fm.root,children:[a.jsx("div",{className:`${fm.list} ${j?fm.keyboardOnly:""}`,ref:S,role:"listbox","aria-label":o("rewind.title"),tabIndex:0,"aria-activedescendant":_.length>0?Hue(m):void 0,children:_.map(({snapshot:L,promptText:R},N)=>{const M=N===m,O=w===L.promptId,P=R||o("rewind.promptFallback",{id:L.promptId.slice(-8)});return a.jsxs("div",{id:Hue(N),role:"option","aria-selected":O,"aria-disabled":I||void 0,className:`${fm.item} ${M?fm.itemCursor:""} ${O?fm.itemSelected:""} ${I?fm.itemDisabled:""}`,onClick:()=>{I||A(N)},onMouseMove:()=>g(N),children:[a.jsxs("div",{className:fm.prompt,title:P,children:[a.jsxs("span",{className:fm.turn,children:["#",L.turnIndex+1]})," ",P]}),a.jsx("div",{className:fm.time,children:Zyn(L.timestamp)})]},L.promptId)})}),a.jsxs("div",{className:fm.footer,children:[x&&a.jsx("span",{className:fm.footerMessage,role:"alert",children:x}),a.jsx("button",{type:"button",className:pr("dialog-inline-button"),onClick:r,disabled:h!==null,children:o("common.cancel")}),a.jsx("button",{type:"button",className:`${pr("dialog-danger-button")} ${fm.dangerButton}`,onClick:()=>E(w),disabled:!w||h!==null,children:o(h?"rewind.rewinding":"rewind.confirm")})]})]})}const uM="add-workspace-hint",Uue="add-workspace-display-name-hint",Wue="add-workspace-error",dM="add-workspace-suggestions",Qyn=150;function oz(e){return e.startsWith("/")||/^[A-Za-z]:[\\/]/.test(e)||e.startsWith("ssh://")}function ebn({browseDirectories:e=!1,initialPath:t="",onClose:n,onAdd:s,displayNameEnabled:r=!1,locations:o,selectedLocation:i,onLocationChange:l,onSuggest:c,onPick:u,persistenceSupported:h=!0}){const{t:f}=Ct(),[m,g]=d.useState(t),[w,y]=d.useState(""),[x,k]=d.useState(null),[_,S]=d.useState(!1),[I,E]=d.useState(!0),[A,j]=d.useState([]),[L,R]=d.useState(!1),[N,M]=d.useState(!1),[O,P]=d.useState(!1),[F,H]=d.useState(-1),[$,Y]=d.useState("/"),[Z,K]=d.useState(!1),B=d.useRef(null),V=d.useRef(!1);V.current=O&&A.length>0;const J=d.useRef(0),q=d.useRef(!1),te=d.useRef(void 0);d.useEffect(()=>{B.current?.focus()},[]);const ie=d.useCallback(()=>{te.current!==void 0&&(clearTimeout(te.current),te.current=void 0)},[]);d.useEffect(()=>()=>ie(),[ie]);const ge=d.useCallback(()=>{P(!1),H(-1)},[]),re=d.useRef(i);d.useEffect(()=>{re.current!==i&&(re.current=i,g(t||"/"),k(null),j([]),R(!1),M(!1),ge())},[i,t,ge]),d.useEffect(()=>{if(!c)return;if(!oz(m)||m.trim().startsWith("ssh://")){++J.current,j([]),R(!1),M(!1),ge();return}const _e=++J.current;e&&j([]),R(!1),M(!1);const ae=!q.current;q.current=!1;const Se=setTimeout(()=>{c(m).then(Te=>{if(_e!==J.current)return;j(Te.suggestions),R(!0),M(!1),Y(Te.sep||"/"),H(-1);const Ne=B.current;(e||Ne!==null&&Xy(Ne)===Ne&&(ae||V.current))&&P(Te.suggestions.length>0)},()=>{_e===J.current&&(j([]),R(!0),M(e),ge())})},Qyn);return()=>clearTimeout(Se)},[e,m,c,ge]),d.useEffect(()=>{const _e=ae=>{e||ae.key!=="Escape"||!V.current||ae.isComposing||ae.keyCode===229||(ae.preventDefault(),ge())};return window.addEventListener("keydown",_e,{capture:!0}),()=>window.removeEventListener("keydown",_e,{capture:!0})},[e,ge]);const G=d.useCallback(_e=>{q.current=!1,g(_e.path+$),k(null),ge(),B.current?.focus()},[$,ge]),Q=d.useCallback(async()=>{if(!u)return;B.current?.blur(),ie(),ge(),q.current=!0,K(!0),k(null);let _e;try{_e=await u(),_e&&_e!==m?(++J.current,g(_e),j([])):(_e&&++J.current,q.current=!1)}catch{q.current=!1,k(f("sidebar.addWorkspaceBrowseError"))}finally{K(!1)}},[u,m,ge,ie,f]),he=d.useCallback(_e=>{const ae=O&&A.length>0;if(_e.key==="ArrowDown"){if(_e.preventDefault(),!ae){A.length>0&&P(!0);return}H(Se=>(Se+1)%A.length);return}if(_e.key==="ArrowUp"){if(!ae)return;_e.preventDefault(),H(Se=>(Se<=0?A.length:Se)-1);return}if(_e.key==="Tab"&&ae&&!_e.shiftKey){const Se=F>=0?A[F]:A.length===1?A[0]:void 0;Se&&(_e.preventDefault(),G(Se));return}if(_e.key==="Enter"&&ae&&F>=0){_e.preventDefault(),G(A[F]);return}if(_e.key==="Enter"&&e&&!m.trim().startsWith("ssh://")&&!_e.nativeEvent.isComposing){_e.preventDefault();const Se=m.trim();if(!oz(Se)){k(f("sidebar.addWorkspaceAbsError"));return}if(!/[\\/]$/.test(Se)){g(Se+$);return}A.length>0&&H(0)}},[O,A,F,G,e,m,$,f]),ve=d.useCallback(async _e=>{_e.preventDefault();const ae=m.trim();if(ae){if(!oz(ae)){k(f("sidebar.addWorkspaceAbsError"));return}k(null),S(!0),ge();try{const Se=h?I:!1,Te=r?w.trim():"";Te?await s(ae,Se,Te):await s(ae,Se),n()}catch(Se){k(Se instanceof Error?Se.message:f("sidebar.addWorkspaceError"))}finally{S(!1)}}},[m,w,r,I,h,s,n,ge,f]),ye=(e||O)&&A.length>0;return a.jsx(Wa,{title:f("sidebar.addWorkspaceTitle"),size:"md",dismissible:!_,onClose:n,children:a.jsxs("form",{className:"flex flex-col gap-6",onSubmit:ve,children:[a.jsxs(cx,{children:[e&&o&&o.length>0&&i&&l&&a.jsxs(vl,{children:[a.jsx(lc,{id:"workspace-location-label",children:f("workspaceHost.source")}),a.jsxs(Yu,{value:i,disabled:_,onValueChange:_e=>{_e!==i&&l(_e)===!1&&k(f("workspaceHost.navigationUnavailable"))},children:[a.jsx(Zu,{className:"w-full","aria-labelledby":"workspace-location-label",children:a.jsx(Xu,{})}),a.jsx(Ju,{children:o.map(_e=>{const ae=_e.remote?fT:GUe;return a.jsxs(sl,{value:_e.origin,children:[a.jsx(ae,{"aria-hidden":"true"}),_e.label]},_e.origin)})})]})]}),a.jsxs(vl,{"data-invalid":x?!0:void 0,children:[a.jsx(lc,{htmlFor:"add-workspace-path",children:f("sidebar.addWorkspacePath")}),a.jsxs("div",{className:"relative",children:[a.jsxs("div",{className:"flex gap-2",children:[a.jsx(hi,{ref:B,id:"add-workspace-path",type:"text",placeholder:"/absolute/path or ssh://user@host/project",value:m,onChange:_e=>{g(_e.target.value),x&&k(null)},onKeyDown:he,onFocus:ie,onBlur:()=>{e||(ie(),te.current=setTimeout(()=>{te.current=void 0,++J.current,j([]),ge()},100))},disabled:_||Z,autoCapitalize:"off",autoCorrect:"off",autoComplete:"off",spellCheck:!1,role:"combobox","aria-expanded":ye,"aria-controls":ye?dM:void 0,"aria-activedescendant":ye&&F>=0?`${dM}-${F}`:void 0,"aria-describedby":x?`${Wue} ${uM}`:uM,"aria-invalid":x?!0:void 0}),e&&!m.trim().startsWith("ssh://")&&a.jsx(Wt,{type:"button",size:"icon",variant:"outline",title:f("workspaceHost.parent"),"aria-label":f("workspaceHost.parent"),disabled:_,onMouseDown:_e=>_e.preventDefault(),onClick:()=>{const _e=m.replace(/[\\/]+$/,"");if(/^[A-Za-z]:$/.test(_e)){g(`${_e}\\`);return}const ae=Math.max(_e.lastIndexOf("/"),_e.lastIndexOf("\\"));g(ae>=0?_e.slice(0,ae+1):$)},children:a.jsx(UHe,{"aria-hidden":"true"})}),u&&a.jsxs(Wt,{type:"button",variant:"outline",onMouseDown:_e=>_e.preventDefault(),onClick:()=>void Q(),disabled:_||Z,children:[a.jsx($T,{"aria-hidden":"true"}),f("sidebar.addWorkspaceBrowse")]})]}),e&&a.jsx("p",{id:uM,className:"mt-2 text-sm leading-normal text-muted-foreground",children:f("workspaceHost.browseHint")}),ye&&a.jsx("ul",{id:dM,role:"listbox","aria-label":f("sidebar.addWorkspaceSuggestions"),className:`${e?"relative":"absolute inset-x-0 top-full z-50"} mt-1 max-h-56 overflow-y-auto rounded-md border bg-popover py-1 text-popover-foreground shadow-md`,children:A.map((_e,ae)=>a.jsxs("li",{id:`${dM}-${ae}`,role:"option","aria-selected":ae===F,className:`cursor-pointer truncate px-3 py-1.5 ${ae===F?"bg-accent text-accent-foreground":"hover:bg-accent/50"}`,onMouseDown:Se=>{Se.preventDefault(),G(_e)},onMouseEnter:()=>H(ae),children:[e&&a.jsx($T,{className:"mr-2 inline size-4","aria-hidden":"true"}),_e.name,a.jsx("span",{className:"text-muted-foreground",children:$})]},_e.path))}),e&&L&&!ye&&a.jsx("div",{role:N?"alert":"status",className:"mt-1 rounded-md border px-3 py-3 text-sm text-muted-foreground",children:f(N?"workspaceHost.folderListError":"workspaceHost.noFolders")})]}),a.jsx(Df,{id:e?void 0:uM,children:f("sidebar.addWorkspaceHint")}),x&&a.jsx(pKt,{id:Wue,children:x})]}),r&&a.jsxs(vl,{children:[a.jsx(lc,{htmlFor:"add-workspace-display-name",children:f("sidebar.addWorkspaceDisplayName")}),a.jsx(hi,{id:"add-workspace-display-name",type:"text",value:w,placeholder:e?m.split(/[\\/]/).filter(Boolean).pop():void 0,onChange:_e=>y(_e.target.value),disabled:_,maxLength:256,autoComplete:"off","aria-describedby":Uue}),a.jsx(Df,{id:Uue,children:f("sidebar.addWorkspaceDisplayNameHint")})]}),h&&a.jsxs(vl,{orientation:"horizontal",children:[a.jsxs(sZ,{children:[a.jsx(lc,{htmlFor:"add-workspace-persist",children:f("sidebar.addWorkspacePersist")}),a.jsx(Df,{children:f("sidebar.addWorkspacePersistHint")})]}),a.jsx(lx,{id:"add-workspace-persist",checked:I,onCheckedChange:E,disabled:_})]})]}),a.jsxs("div",{className:"flex w-full justify-end gap-2",children:[a.jsx(Wt,{type:"button",variant:"outline",className:"flex-1 sm:flex-none",onClick:n,disabled:_,children:f("sidebar.addWorkspaceCancel")}),a.jsx(Wt,{type:"submit",className:"flex-1 sm:flex-none",disabled:_||!m.trim(),children:f(_?"sidebar.addWorkspaceAdding":e?"workspaceHost.addFolder":"sidebar.addWorkspaceRegister")})]})]})})}function que({message:e,tone:t,subtitle:n,onClose:s}){const{t:r}=Ct();return a.jsx(Wa,{title:r("sidebar.addWorkspaceTitle"),subtitle:n,size:"md",onClose:s,children:a.jsxs("div",{className:"flex flex-col gap-5",children:[a.jsx("p",{role:t,children:e}),a.jsx("div",{className:"flex justify-end gap-2",children:a.jsx(Wt,{type:"button",variant:"outline",onClick:s,children:r("sidebar.addWorkspaceCancel")})})]})})}const tbn=[{target:"mcp",Icon:Wve},{target:"skills",Icon:ox},{target:"extensions",Icon:FG},{target:"settings",Icon:Gve}];function nbn(e){return Object.values(e).some(Boolean)}function sbn({workspace:e,actions:t,overview:n,disabled:s=!1,triggerClassName:r,contentStyle:o,onOpenChange:i,onPointerDownOutside:l,onCloseAutoFocus:c}){const{t:u}=Ct(),h=d.useRef(!1),f=d.useRef(i);if(f.current=i,d.useEffect(()=>()=>{h.current&&f.current?.(!1)},[]),!nbn(t))return null;const m=[],g=[];t.rename&&g.push(a.jsxs(yi,{onSelect:t.rename,children:[a.jsx(vw,{}),u("sidebar.renameWorkspace")]},"rename")),t.copyPath&&g.push(a.jsxs(yi,{onSelect:t.copyPath,children:[a.jsx(ib,{}),u("sidebar.copyWorkspacePath")]},"copy")),t.openFolder&&g.push(a.jsxs(yi,{onSelect:t.openFolder,children:[a.jsx($T,{}),u("sidebar.openWorkspaceFolder")]},"open-folder")),t.openTerminal&&g.push(a.jsxs(yi,{onSelect:t.openTerminal,children:[a.jsx(xqe,{}),u("sidebar.openWorkspaceTerminal")]},"open-terminal")),t.newSession&&g.push(a.jsxs(yi,{onSelect:t.newSession,children:[a.jsx(t9,{}),u("sidebar.newTask")]},"new")),t.newWorktreeSession&&g.push(a.jsxs(yi,{onSelect:t.newWorktreeSession,children:[a.jsx(OE,{}),u("sidebar.newWorktreeTask")]},"worktree")),g.length>0&&m.push(g);const w=t.openManagement;return w&&m.push([a.jsx(o4e,{children:u("sidebar.manageWorkspace")},"manage-label"),...tbn.map(({target:y,Icon:x})=>{const k=y==="settings"?void 0:mSe(n,y);return a.jsxs(yi,{onSelect:()=>w(y),children:[a.jsx(x,{}),u(`sidebar.overview.${y==="settings"?"settings":y}`),k!==void 0&&a.jsx("span",{className:"text-muted-foreground ml-auto pl-3 text-xs tabular-nums",children:k})]},y)})]),t.reload&&m.push([a.jsxs(yi,{onSelect:t.reload,children:[a.jsx(Hg,{}),u("sidebar.reloadWorkspace")]},"reload")]),t.remove&&m.push([a.jsxs(yi,{variant:"destructive","aria-label":`${u("sidebar.removeWorkspace")}: ${e.cwd}`,onSelect:t.remove,children:[a.jsx(_m,{}),u("sidebar.removeWorkspace")]},"remove")]),a.jsxs(Z0,{onOpenChange:y=>{h.current=y,i?.(y)},children:[a.jsx(Vg,{asChild:!0,children:a.jsx("button",{className:r,type:"button","aria-label":u("sidebar.workspaceActions"),title:u("sidebar.workspaceActions"),disabled:s,children:a.jsx(yS,{size:16,strokeWidth:1.2})})}),a.jsx(Gg,{align:"end",className:"w-auto min-w-40",style:o,onPointerDownOutside:l,onCloseAutoFocus:c,children:m.map((y,x)=>a.jsxs($x,{children:[x>0&&a.jsx(ax,{}),y]},x))})]})}const rbn=256,obn=/[\u0000-\u001f\u007f]/;function ibn(e){return!obn.test(e)}function abn({workspace:e,busy:t,onSubmit:n,onClose:s}){const{t:r}=Ct(),[o,i]=d.useState(e.displayName??""),l=o.trim(),c=l===(e.displayName?.trim()??""),u=!ibn(l);return a.jsx(Wa,{title:r("sidebar.renameWorkspaceTitle"),subtitle:e.cwd,size:"sm",onClose:()=>{t||s()},children:a.jsxs("form",{className:_t.confirmContent,onSubmit:h=>{h.preventDefault(),!(t||c||u)&&n(l===""?null:l)},children:[a.jsx(cx,{children:a.jsxs(vl,{children:[a.jsx(lc,{htmlFor:"workspace-display-name",children:r("sidebar.workspaceNamePrompt")}),a.jsx(hi,{id:"workspace-display-name",value:o,autoFocus:!0,maxLength:rbn,placeholder:tX(e.cwd),disabled:t,onChange:h=>i(h.target.value)})]})}),a.jsx("p",{className:_t.confirmDescription,role:u?"alert":void 0,children:r(u?"sidebar.workspaceNameInvalid":"sidebar.workspaceNameHint")}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Wt,{type:"button",variant:"outline",disabled:t,onClick:s,children:r("common.cancel")}),a.jsx(Wt,{type:"submit",disabled:t||c||u,children:r("common.save")})]})]})})}const iz=50;function Vue(e){return e.displayName?.trim()||e.sessionId.slice(0,8)}function az(e){return e.filter(t=>!t.parentSessionId)}function Gue(e,t){const n=new Set(e.map(s=>s.sessionId));return[...e,...t.filter(s=>!n.has(s.sessionId))]}function lbn(e){const t=URL.createObjectURL(new Blob([e.content],{type:e.mimeType||"text/html"}));try{const n=document.createElement("a");n.href=t,n.download=e.filename,document.body.appendChild(n),n.click(),n.remove()}finally{URL.revokeObjectURL(t)}}function Kue({archiveState:e,currentSessionId:t,currentSessionReady:n=!1,refreshKey:s,searchQuery:r="",onNewSession:o,renderSession:i,onLoadSession:l,onRenameSession:c,onMutated:u,onStatusChange:h,onError:f,onNotice:m}){const g=fi(),w=el(),y=m4(),x=d.useRef(y),k=d.useRef(0),_=d.useRef(!1),S=d.useRef(s),I=d.useRef(void 0),E=d.useRef(0),A=d.useRef(void 0),{t:j}=Ct(),[L,R]=d.useState([]),N=d.useRef(L);N.current=L;const[M,O]=d.useState(),[P,F]=d.useState(!0),[H,$]=d.useState(!1),[Y,Z]=d.useState(!1),[K,B]=d.useState(!1),[V,J]=d.useState(),[q,te]=d.useState(),[ie,ge]=d.useState(),[re,G]=d.useState(),[Q,he]=d.useState(""),[ve,ye]=d.useState(),_e=g.capabilities?.features?.includes(nw)===!0,ae=d.useCallback(async(W=!1)=>{if(!_e)return;const ne=k.current+1;k.current=ne,B(!1),Z(!0);try{const me=W?N.current.length:0;let Me=await g.client.listStandaloneSessionsPage({archiveState:e,pageSize:iz});if(k.current!==ne)return;let Ke=az(Me.sessions);for(;Me.nextCursor&&Ke.length<me;){if(Me=await g.client.listStandaloneSessionsPage({archiveState:e,cursor:Me.nextCursor,pageSize:iz}),k.current!==ne)return;Ke=Gue(Ke,az(Me.sessions))}_.current=!0,R(Ke),O(Me.nextCursor),J(void 0)}catch(me){if(k.current!==ne)return;console.warn("[web-shell] standalone session list failed:",me),J({})}finally{k.current===ne&&Z(!1)}},[e,_e,g.client]);d.useEffect(()=>{ge(W=>W?.kind==="open"?void 0:W),A.current!==t&&++E.current},[t]),d.useEffect(()=>{n&&ge(W=>W?.kind==="open"&&W.sessionId===t?void 0:W)},[t,n]),d.useEffect(()=>{const W=S.current!==s;S.current=s,(!_.current||W)&&ae(!0)},[ae,s]),d.useEffect(()=>{const W=x.current;x.current=y,e==="active"&&w.sessionContext?.kind==="standalone"&&W!=="idle"&&y==="idle"&&ae(!0)},[e,w.sessionContext?.kind,ae,y]),d.useEffect(()=>{h?.({count:L.length,loading:Y,error:!!V})},[V,Y,h,L.length]),d.useEffect(()=>{P||$(!1)},[P]);const Se=d.useCallback(async()=>{if(!M||K)return;const W=k.current;B(!0);try{const ne=await g.client.listStandaloneSessionsPage({archiveState:e,cursor:M,pageSize:iz});if(k.current!==W)return;R(me=>Gue(me,az(ne.sessions))),O(ne.nextCursor),J(void 0)}catch(ne){k.current===W&&(console.warn("[web-shell] standalone session page failed:",ne),J({cursor:M}))}finally{k.current===W&&B(!1)}},[e,M,K,g.client]),Te=d.useCallback(async(W,ne)=>{if(I.current)return!1;I.current=W,te(W),ge(void 0);try{return await ne(),!0}catch(me){return L8(O0(me))?(console.warn("[web-shell] standalone session action blocked by writer fence:",me),G(Me=>Me?.sessionId===W?void 0:Me),ye(Me=>Me?.sessionId===W?void 0:Me),ge({sessionId:W,kind:"action",messageKey:"session.writerBlocked",retry:()=>{Te(W,ne)}})):f(me,j("sidebar.standaloneActionFailed")),!1}finally{I.current=void 0,te(void 0)}},[f,j]),Ne=d.useCallback(W=>{R(ne=>ne.filter(me=>me.sessionId!==W)),u?.()},[u]),Ae=d.useCallback(async W=>{await Te(W.sessionId,async()=>{const ne=await g.client.archiveStandaloneSessions([W.sessionId]);if(ne.archived.includes(W.sessionId)||ne.alreadyArchived.includes(W.sessionId)||ne.notFound?.includes(W.sessionId)){Ne(W.sessionId);return}const me=ne.errors.find(Me=>Me.sessionId===W.sessionId);throw Object.assign(new Error(me?.message??j("sidebar.standaloneActionFailed")),{body:me})})},[Ne,Te,j,g.client]),Ve=d.useCallback(async W=>{await Te(W.sessionId,async()=>{const ne=await g.client.unarchiveStandaloneSessions([W.sessionId]);if(ne.unarchived.includes(W.sessionId)||ne.alreadyActive.includes(W.sessionId)||ne.notFound?.includes(W.sessionId)){Ne(W.sessionId);return}const me=ne.errors.find(Me=>Me.sessionId===W.sessionId);throw Object.assign(new Error(me?.message??j("sidebar.standaloneActionFailed")),{body:me})})},[Ne,Te,j,g.client]),Ze=d.useCallback(async W=>await Te(W.sessionId,async()=>{const me=await g.client.deleteStandaloneSessions([W.sessionId]);if(!me.removed.includes(W.sessionId)&&!me.notFound.includes(W.sessionId)){const Me=me.errors.find(Ke=>Ke.sessionId===W.sessionId);throw Object.assign(new Error(Me?.message??j("sidebar.standaloneActionFailed")),{body:Me})}me.fileCleanupPending.includes(W.sessionId)&&m(j("sidebar.standaloneCleanupPending")),Ne(W.sessionId)}),[m,Ne,Te,j,g.client]),Tt=d.useCallback(async W=>{const ne=++E.current;A.current=W,ge(void 0);try{await l(W)}catch(me){if(ne!==E.current||L8(O0(me)))return;console.warn("[web-shell] standalone session load failed:",me),ge({sessionId:W,kind:"open",messageKey:"session.loadFailed",retry:()=>{Tt(W)}})}},[l]);if(!_e||e==="archived"&&!V&&!ie&&!Y&&L.length===0&&!M)return null;const je=r.trim().toLowerCase(),ot=je?L.filter(W=>Vue(W).toLowerCase().includes(je)||W.sessionId.toLowerCase().includes(je)):L,Ie=!je&&!H&&ot.length>fx,ue=Ie?ot.slice(0,fx):ot;return a.jsxs(a.Fragment,{children:[a.jsxs("section",{className:`${ac.section} mb-3`,"aria-label":e==="active"?j("sidebar.noWorkspaceSessions"):`${j("sidebar.archivedTitle")}: ${j("sidebar.noWorkspaceSessions")}`,"data-testid":`standalone-${e}-group`,children:[a.jsxs("div",{className:`${ac.headerRow} group`,children:[a.jsxs("button",{type:"button",className:ac.header,"aria-expanded":P,onClick:W=>{F(ne=>!ne),W.detail>0&&W.currentTarget.blur()},children:[a.jsx(Ave,{className:ac.folderIcon,size:14,strokeWidth:1.4,"aria-hidden":"true"}),a.jsx("span",{className:ac.headerContent,children:a.jsx("span",{className:ac.name,children:j("sidebar.noWorkspaceSessions")})})]}),e==="active"&&o&&a.jsx("div",{className:`${_t.workspaceHeaderActions} invisible group-hover:visible group-focus-within:visible`,children:a.jsx("button",{className:_t.workspaceHeaderAction,type:"button",title:j("sidebar.newTask"),"aria-label":j("sidebar.newTask"),onClick:o,children:a.jsx(t9,{size:16,strokeWidth:1.2})})})]}),ie&&a.jsxs("div",{role:"alert",className:"px-2 py-1 text-xs text-muted-foreground",children:[a.jsxs("span",{children:[ie.sessionId.slice(0,8),": ",j(ie.messageKey)]}),a.jsx(Wt,{variant:"ghost",size:"sm",disabled:!!q,onClick:ie.retry,children:j("common.retry")})]}),V&&a.jsxs("div",{role:"alert",className:"px-2 py-1 text-xs text-muted-foreground",children:[j("sidebar.standaloneLoadFailed"),a.jsx(Wt,{variant:"ghost",size:"sm",disabled:Y||K,onClick:()=>{V.cursor?Se():ae(!0)},children:j("common.retry")})]}),(P||!!je)&&a.jsxs("div",{className:"flex flex-col gap-0.5",children:[ue.map(W=>{const ne=W.sessionId===t;return i(W,{active:ne,busy:q===W.sessionId,isArchived:e==="archived",onOpen:()=>void Tt(W.sessionId),onRename:()=>{G(W),he(Vue(W))},onExport:()=>{Te(W.sessionId,async()=>{lbn(await g.client.exportStandaloneSession(W.sessionId,{format:"html"}))})},onArchive:e==="active"?()=>void Ae(W):void 0,onUnarchive:e==="archived"?()=>void Ve(W):void 0,onDelete:()=>ye(W)})}),!Y&&!V&&ot.length===0&&a.jsx("div",{className:ac.empty,children:j(e==="active"?"sidebar.noSessions":"sidebar.archivedEmpty")}),Ie&&a.jsx("button",{type:"button",className:_t.showAllSessions,onClick:()=>$(!0),children:j("sidebar.showAllSessions")}),M&&!Ie&&a.jsx(Wt,{type:"button",variant:"ghost",size:"sm",className:"w-full",disabled:K,onClick:()=>void Se(),children:j("sidebar.showAllSessions")})]})]}),re&&a.jsx(Wa,{title:j("sidebar.rename"),size:"sm",onClose:()=>G(void 0),children:a.jsxs("form",{className:"flex flex-col gap-4",onSubmit:W=>{W.preventDefault();const ne=Q.trim();ne&&Te(re.sessionId,async()=>{await g.client.renameStandaloneSession(re.sessionId,ne),R(me=>me.map(Me=>Me.sessionId===re.sessionId?{...Me,displayName:ne}:Me)),c?.(re.sessionId,ne)}).then(me=>{me&&G(void 0)})},children:[a.jsx(hi,{autoFocus:!0,value:Q,onChange:W=>he(W.target.value)}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Wt,{type:"button",variant:"outline",onClick:()=>G(void 0),children:j("common.cancel")}),a.jsx(Wt,{type:"submit",disabled:!Q.trim(),children:j("common.save")})]})]})}),ve&&a.jsx(Wa,{title:j("sidebar.delete"),size:"sm",onClose:()=>ye(void 0),children:a.jsxs("div",{className:"flex flex-col gap-4",children:[a.jsx("p",{className:"text-sm text-muted-foreground",children:j("sidebar.standaloneDeleteConfirm")}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Wt,{type:"button",variant:"outline",onClick:()=>ye(void 0),children:j("common.cancel")}),a.jsx(Wt,{type:"button",variant:"destructive",onClick:()=>{Ze(ve).then(W=>{W&&ye(void 0)})},children:j("sidebar.delete")})]})]})})]})}class Tc extends Error{constructor(t,n){super(n),this.code=t,this.name="LocalDirectoryError"}}const cbn={maxListEntries:500,maxReadBytes:1e6,maxWriteBytes:1e7,maxSearchFiles:2e3,maxSearchBytes:2e7,maxSearchHits:200,maxSearchDirs:1e4},Yue=400;function Xue(e){return e?.kind==="directory"}function Zue(e){return e?.kind==="file"}function hM(e){if(typeof e!="string")throw new Tc("invalid_path","`path` must be a string.");const t=e;if(t===""||t===".")return[];if(t.includes("\\"))throw new Tc("invalid_path","Backslashes are not allowed; use forward slashes.");if(t.startsWith("/"))throw new Tc("invalid_path","Absolute paths are not allowed; paths are relative to the granted directory.");if(/^[a-zA-Z]:[\\/]/.test(t))throw new Tc("invalid_path","Windows drive paths are not allowed; paths are relative to the granted directory.");const n=[];for(const s of t.split("/"))if(!(s===""||s===".")){if(s==="..")throw new Tc("invalid_path","`..` is not allowed; paths must stay inside the granted directory.");if(/[\u0000-\u001f]/.test(s))throw new Tc("invalid_path","C0 control characters (U+0000-U+001F) are not allowed in a path.");n.push(s)}return n}function B3(e,t){if(e instanceof Tc)return e;const n=e?.name,s=e instanceof Error?e.message:String(e);return n==="NotFoundError"?new Tc("not_found",`No such file or directory: ${t}`):n==="NotAllowedError"||n==="SecurityError"?new Tc("permission_denied",`Permission denied for ${t} (${s}). The directory grant may have been revoked; reconnect it.`):n==="TypeMismatchError"?new Tc("not_a_directory",`Not a directory: ${t}`):new Tc("failed",`${t}: ${s}`)}function Jue(e,t){return e?.name==="TypeMismatchError"?new Tc("not_a_file",`${t} is a directory, not a file.`):B3(e,t)}class ubn{constructor(t,n=cbn){this.root=t,this.limits=n}get name(){return this.root.name}async resolveDirectory(t,n,s){let r=this.root;for(const o of t)try{r=await r.getDirectoryHandle(o,{create:s})}catch(i){throw B3(i,n)}return r}async list(t,n){const s=hM(t),r=await this.resolveDirectory(s,t,!1),o=typeof n=="number"&&Number.isFinite(n)&&n>0?Math.max(1,Math.trunc(n)):this.limits.maxListEntries,i=Math.min(o,this.limits.maxListEntries),l=[];let c=!1;try{for await(const u of r.values()){if(l.length>=i){c=!0;break}if(Xue(u))l.push({name:u.name,path:lz(s,u.name),kind:"directory"});else if(Zue(u)){const h=lz(s,u.name);try{const f=await u.getFile();l.push({name:u.name,path:h,kind:"file",size:f.size,lastModified:f.lastModified})}catch{l.push({name:u.name,path:h,kind:"file"})}}}}catch(u){throw B3(u,t)}return l.sort((u,h)=>u.path<h.path?-1:u.path>h.path?1:0),{entries:l,truncated:c,limit:i}}async read(t,n=0,s){const r=hM(t);if(r.length===0)throw new Tc("invalid_path","`path` must name a file.");const o=r[r.length-1],i=await this.resolveDirectory(r.slice(0,-1),Que(t),!1);let l;try{l=await(await i.getFileHandle(o)).getFile()}catch(g){throw Jue(g,t)}if(l.size>this.limits.maxReadBytes)throw new Tc("too_large",`${t} is ${l.size} bytes, over the ${this.limits.maxReadBytes}-byte read limit. Narrow the request or handle this file another way.`);let c;try{c=new TextDecoder("utf-8",{fatal:!0}).decode(await l.arrayBuffer())}catch(g){throw g instanceof TypeError?new Tc("binary_content",`${t} is not valid UTF-8 text; it cannot be returned as text.`):B3(g,t)}if(c.includes("\0"))throw new Tc("binary_content",`${t} looks like a binary file (NUL byte); it cannot be returned as text.`);const u=c.split(`
2233
+ `)}function $Re(e,t){const n=e.defaultView?.CSSStyleSheet;if(!n||typeof n.prototype.replaceSync!="function")return null;const s=new n;return s.replaceSync(t),s}function gwn(e,t){const n=Oue.get(e);if(n?.css===t)return n.sheet;const s=$Re(e,t);return s&&Oue.set(e,{css:t,sheet:s}),s}function BRe(e,t){const n=mwn(e.ownerDocument),s=[n,t].filter(o=>!!o);try{const o=n?gwn(e.ownerDocument,n):null,i=t?$Re(e.ownerDocument,t):null,l=[o,i].filter(c=>!!c);if(l.length===s.length&&l.length>0)return e.adoptedStyleSheets=[...e.adoptedStyleSheets,...l],()=>{e.adoptedStyleSheets=e.adoptedStyleSheets.filter(c=>!l.includes(c))}}catch{}const r=s.map(o=>{const i=e.ownerDocument.createElement("style");return i.dataset.o1CodeWebShellShadow="",i.textContent=o,e.appendChild(i),i});return()=>{for(const o of r)o.remove()}}function vwn({children:e,enabled:t,language:n,themeClassName:s,styles:r,initialFocusRef:o}){const i=d.useRef(null),[l,c]=d.useState(null);return d.useLayoutEffect(()=>{if(!t||!i.current)return;i.current.style.setProperty("all","initial","important"),i.current.style.setProperty("display","block","important"),i.current.style.setProperty("min-width","0","important"),i.current.style.setProperty("width","100%","important");const u=i.current.shadowRoot??i.current.attachShadow({mode:"open"}),h=u.ownerDocument.createElement("div");h.dataset.webShellRoot="",h.dataset.webShellShadcn="",h.dataset.webShellShadowRoot="plugins";const f=BRe(u,r);return u.appendChild(h),c(h),()=>{h.remove(),f(),c(null)}},[t,r]),d.useLayoutEffect(()=>{l&&(l.className=s,l.lang=n)},[n,l,s]),d.useLayoutEffect(()=>{l&&o?.current?.focus()},[o,l]),t?a.jsx("div",{ref:i,"data-web-shell-shadow-host":"plugins",children:l?Am.createPortal(e,l):null}):e}const oV={"setting:auto-update":"general.enableAutoUpdate","setting:session-recap":"general.showSessionRecap","setting:session-recap-away-threshold":"general.sessionRecapAwayThresholdMinutes","setting:cleanup-period":"general.cleanupPeriodDays","setting:git-commit-co-author":"general.gitCoAuthor.commit","setting:git-pr-co-author":"general.gitCoAuthor.pr","setting:language":"general.language","setting:prevent-system-sleep":"general.preventSystemSleep","setting:review-attribution":"review.attribution","setting:review-sandbox":"review.sandbox","setting:review-effort":"review.effort","setting:review-comment":"review.comment","setting:review-severity-floor":"review.severityFloor","setting:review-reverse-audit-rounds":"review.reverseAuditRounds","setting:review-approach-rounds":"review.approachRounds","setting:timestamps":"output.showTimestamps","setting:theme":"ui.theme","setting:workflow-keyword-trigger":"ui.disableWorkflowKeywordTrigger","setting:status-in-title":"ui.showStatusInTitle","setting:response-speed":"ui.showResponseTokensPerSecond","setting:followup-suggestions":"ui.enableFollowupSuggestions","setting:tool-call-details":"ui.showToolCallDetails","setting:shell-output-limit":"ui.shellOutputMaxLines","setting:usage-statistics":"privacy.usageStatisticsEnabled","setting:fast-model":"fastModel","setting:advisor-model":"advisorModel","setting:vision-model":"visionModel","setting:model-fallbacks":"modelFallbacks","setting:respect-git-ignore":"context.fileFiltering.respectGitIgnore","setting:respect-o1code-ignore":"context.fileFiltering.respectO1CodeIgnore","setting:fuzzy-file-search":"context.fileFiltering.enableFuzzySearch","setting:code-mode-only":"tools.codeModeOnly","setting:web-search":"tools.webSearch.enabled","setting:web-search-model":"tools.webSearch.model","setting:web-extractor":"tools.webSearch.webExtractor","setting:web-search-timeout":"tools.webSearch.timeoutMs","setting:web-search-limit":"tools.webSearch.maxPerSession","setting:tool-search":"tools.toolSearch.enabled","setting:tool-search-threshold":"tools.toolSearch.threshold","setting:list-directory":"tools.listDirectory.enabled","setting:todo-write":"tools.todoWrite.enabled","setting:interactive-shell":"tools.shell.enableInteractiveShell","setting:shell-type":"tools.shell.type","setting:shell-executable":"tools.shell.executable","setting:workflows":"tools.workflowsEnabled","setting:workflow-size":"tools.workflowSizeGuideline","setting:workflow-name-only":"tools.workflowNameOnly","setting:permission-strategy":"policy.permissionStrategy","setting:model-proposed-goals":"goals.modelProposed","setting:arena-artifacts":"agents.arena.preserveArtifacts","setting:session-workflow":"experimental.sessionWorkflow","setting:scheduled-tasks":"experimental.cron","setting:session-writer-lease":"experimental.sessionWriterLease","setting:agent-team":"experimental.agentTeam","setting:omni-media-delivery":"omni.enabled","setting:artifacts":"experimental.artifact","setting:tool-use-summaries":"experimental.emitToolUseSummaries","setting:voice-model":"voiceModel","setting:image-model":"imageModel"},wwn=["builtin:chat-width","builtin:browser-notifications","builtin:local-control","builtin:connections","builtin:model-management"],ywn=[...Object.keys(oV),...wwn],$ue=new Set;function FRe(e){if(e)for(const t of[...e.includeItems??[],...e.excludeItems??[]])ywn.includes(t)||$ue.has(t)||($ue.add(t),console.warn(`[web-shell] settings presentation: "${t}" matches no published item id and is ignored; the published ids are exported as WEB_SHELL_SETTING_ITEM_IDS.`))}function iV(e,t){return FRe(t),(t?.includeItems?.includes(e)??!0)&&!t?.excludeItems?.includes(e)}function b8(e,t){FRe(t);const n=Object.keys(oV).filter(r=>oV[r]===e);if(n.length===0)return t?.includeItems===void 0;if(n.some(r=>t?.excludeItems?.includes(r)))return!1;const s=t?.includeItems;return s===void 0?!0:n.some(r=>s.includes(r))}const bwn="_section_iwuxi_1",xwn="_header_iwuxi_12",kwn="_title_iwuxi_19",_wn="_addButton_iwuxi_24",Swn="_hint_iwuxi_38",Cwn="_empty_iwuxi_39",Twn="_provider_iwuxi_45",Iwn="_providerName_iwuxi_51",Rwn="_modelRow_iwuxi_59",Ewn="_modelInfo_iwuxi_70",Awn="_modelName_iwuxi_78",jwn="_modelBaseUrl_iwuxi_84",Nwn="_modelId_iwuxi_91",Mwn="_modelDescription_iwuxi_98",Pwn="_modelDetails_iwuxi_99",Lwn="_capability_iwuxi_113",Dwn="_currentBadge_iwuxi_119",Own="_runtimeBadge_iwuxi_127",$wn="_modelActions_iwuxi_135",Bwn="_actionButton_iwuxi_142",Fwn="_deleteButton_iwuxi_143",zwn="_confirmButton_iwuxi_144",Dl={section:bwn,header:xwn,title:kwn,addButton:_wn,hint:Swn,empty:Cwn,provider:Twn,providerName:Iwn,modelRow:Rwn,modelInfo:Ewn,modelName:Awn,modelBaseUrl:jwn,modelId:Nwn,modelDescription:Mwn,modelDetails:Pwn,capability:Lwn,currentBadge:Dwn,runtimeBadge:Own,modelActions:$wn,actionButton:Bwn,deleteButton:Fwn,confirmButton:zwn};function x8(e,t){return`${e.authType}:${t.modelId}:${t.baseUrl??""}`}function Hwn(e,t){const n=e.flatMap(r=>r.models.map(o=>({provider:r,model:o})));if(t){const r=n.find(({model:i})=>i.modelId===t);if(r)return x8(r.provider,r.model);const o=n.filter(({model:i})=>i.baseModelId===t);if(o.length===1)return x8(o[0].provider,o[0].model)}const s=n.find(({model:r})=>r.isCurrent);return s?x8(s.provider,s.model):void 0}function Uwn({providers:e,configurations:t=[],onUpdateContextWindow:n,currentModelId:s,loading:r,error:o,busy:i,onSelectModel:l,onDeleteModel:c,onAddModel:u}){const{t:h}=Ct(),[f,m]=d.useState(null);d.useEffect(()=>{if(f===null)return;const _=S=>{S.key==="Escape"&&m(null)};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[f]);const g=e.map(_=>({..._,models:[..._.models]})),y=[...new Map(t.map(_=>[_.key,_])).values()].filter(_=>!e.some(S=>S.models.some(I=>I.configurationKey===_.key)));for(const _ of y){let S=g.find(I=>I.authType===_.authType);S||(S={kind:"model_provider",status:"ok",authType:_.authType,current:!1,models:[]},g.push(S)),S.models.push({configurationKey:_.key,modelId:_.key,baseModelId:_.modelId,name:_.name||_.modelId,baseUrl:_.baseUrl,envKey:_.envKey,contextLimit:_.contextWindowSize,isCurrent:!1,isRuntime:!1})}const x=g.some(_=>_.models.length>0),k=Hwn(e,s);return a.jsxs("div",{className:Dl.section,"data-testid":"model-management",children:[a.jsxs("div",{className:Dl.header,children:[a.jsx("span",{className:Dl.title,children:h("settings.models.title")}),a.jsx("button",{type:"button",className:Dl.addButton,disabled:i,onClick:u,children:h("settings.models.add")})]}),o&&a.jsx("div",{className:Dl.hint,children:o.message}),r&&!x&&a.jsx("div",{className:Dl.hint,children:h("settings.models.loading")}),!r&&!x&&!o&&a.jsx("div",{className:Dl.empty,children:h("settings.models.empty")}),g.map((_,S)=>_.models.length===0?null:a.jsxs("div",{className:Dl.provider,children:[a.jsx("div",{className:Dl.providerName,children:_.authType}),_.models.map(I=>{const E=t.filter(O=>O.key===I.configurationKey),A=E.length===1?E[0]:void 0,j=e.some(O=>O.models.includes(I)),L=x8(_,I),R=L===k,N=f===L,M=I.name||I.baseModelId;return a.jsxs("div",{className:Dl.modelRow,children:[a.jsxs("div",{className:Dl.modelInfo,children:[a.jsx("span",{className:Dl.modelName,children:I.name||I.baseModelId}),R&&a.jsx("span",{className:Dl.currentBadge,children:h("settings.models.current")}),I.isRuntime&&a.jsx("span",{className:Dl.runtimeBadge,children:h("settings.models.runtime")}),!j&&a.jsx("span",{className:Dl.runtimeBadge,children:h("settings.models.savedConfiguration")}),I.name&&I.name!==I.baseModelId&&a.jsx("span",{className:Dl.modelId,children:I.baseModelId}),I.description&&a.jsx("div",{className:Dl.modelDescription,children:I.description}),I.baseUrl&&a.jsx("span",{className:Dl.modelBaseUrl,children:I.baseUrl.split(/[?#]/)[0]}),(I.contextLimit||I.modalities||I.envKey)&&a.jsxs("div",{className:Dl.modelDetails,children:[I.contextLimit!==void 0&&I.contextLimit>0&&a.jsx("span",{children:h("settings.models.context",{tokens:I.contextLimit.toLocaleString()})}),[["image","auth.advanced.modalityImage"],["video","auth.advanced.modalityVideo"],["audio","auth.advanced.modalityAudio"],["pdf","auth.advanced.modalityPdf"]].map(([O,P])=>I.modalities?.[O]?a.jsx("span",{className:Dl.capability,children:h(P)},O):null),I.envKey&&a.jsxs("span",{children:[h("settings.models.credentialEnv"),":"," ",a.jsx("code",{children:I.envKey})]})]}),A&&a.jsxs(a.Fragment,{children:[A.purpose!=="chat"&&a.jsx("span",{className:Dl.capability,children:h(`auth.purpose.${A.purpose}`)}),A.canEditContextWindow===!1&&a.jsx("div",{className:Dl.modelDescription,children:h("settings.models.ambiguousWindow")}),n&&A.canEditContextWindow!==!1&&a.jsx(Wwn,{configuration:A,busy:i,onSave:n})]})]}),a.jsxs("div",{className:Dl.modelActions,children:[!R&&j&&a.jsx("button",{type:"button",className:Dl.actionButton,disabled:i,"aria-label":`${h("settings.models.setCurrent")} ${M}`,onClick:()=>l(I.modelId),children:h("settings.models.setCurrent")}),!I.isRuntime&&(N?a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:Dl.confirmButton,disabled:i,"aria-label":`${h("settings.models.confirmDelete")} ${M}`,onClick:()=>{m(null),c({...I.configurationKey?{key:I.configurationKey}:{},authType:_.authType,modelId:I.baseModelId,...I.baseUrl?{baseUrl:I.baseUrl}:{}})},children:h("settings.models.confirmDelete")}),a.jsx("button",{type:"button",className:Dl.actionButton,disabled:i,"aria-label":`${h("settings.models.cancel")} ${M}`,onClick:()=>m(null),children:h("settings.models.cancel")})]}):a.jsx("button",{type:"button",className:Dl.deleteButton,disabled:i,"aria-label":`${h("settings.models.delete")} ${M}`,onClick:()=>m(L),children:h("settings.models.delete")}))]})]},L)})]},`${_.authType}:${S}`))]})}function Wwn({configuration:e,busy:t,onSave:n}){const{t:s}=Ct(),r=d.useId(),[o,i]=d.useState(!1),[l,c]=d.useState(""),[u,h]=d.useState(!1),[f,m]=d.useState(""),[g,w]=d.useState(""),y=!l.trim()||/^\d+$/.test(l.trim())&&Number(l)>=1&&Number(l)<=1e7;return o?a.jsxs("form",{className:"mt-3 flex max-w-md flex-col gap-2",onSubmit:x=>{x.preventDefault(),!(!y||u||t)&&(h(!0),m(""),n(e.key,l.trim()?Number(l):null).then(k=>{i(!1),w(k.runtimeSync?.status==="failed"?s("settings.models.runtimeSyncFailed"):k.requiresRestart?s("settings.models.windowSaved"):s("settings.models.saved"))}).catch(k=>m(k instanceof Error?k.message:String(k))).finally(()=>h(!1)))},children:[a.jsxs(vl,{children:[a.jsx(lc,{htmlFor:r,children:s("auth.advanced.contextWindow")}),a.jsx(hi,{id:r,value:l,inputMode:"numeric",placeholder:s("common.auto"),disabled:u||t,"aria-invalid":!y,"aria-describedby":`${r}-hint`,onChange:x=>c(x.target.value)}),a.jsx(Df,{id:`${r}-hint`,children:y?s("settings.models.windowHint"):s("auth.advanced.tokenLimitInvalid",{field:s("auth.advanced.contextWindow")})})]}),f&&a.jsx("p",{role:"alert",className:"text-sm text-destructive",children:f}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Wt,{type:"submit",size:"sm","aria-label":`${s("common.save")} ${e.name||e.modelId}`,disabled:!y||u||t,children:s("common.save")}),a.jsx(Wt,{type:"button",variant:"outline",size:"sm",disabled:u||t,"aria-label":`${s("settings.models.cancel")} ${e.name||e.modelId}`,onClick:()=>i(!1),children:s("settings.models.cancel")})]})]}):a.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[a.jsx(Wt,{size:"sm",variant:"outline",disabled:t,"aria-label":`${s("settings.models.editWindow")} ${e.name||e.modelId}`,onClick:()=>{c(e.contextWindowSize?.toString()??""),m(""),w(""),i(!0)},children:s("settings.models.editWindow")}),g&&a.jsx("span",{role:"status",className:"text-xs text-muted-foreground",children:g})]})}function qwn(){const e=new URL(window.location.href);return e.searchParams.delete("daemon"),e.searchParams.delete("token"),`${e.pathname}${e.search}`}function sz(e,t){return e?e.length===1?e[0].address:t&&!e.some(n=>n.address===t)?"":t:t}function Vwn(){const{t:e}=Ct(),{baseUrl:t,token:n}=fi(),[s,r]=d.useState(),[o,i]=d.useState(""),[l,c]=d.useState(!1),[u,h]=d.useState("");d.useEffect(()=>{let g=!1;return h(""),r9(t,n,"GET","/workspace/local-control").then(w=>{g||(r(w),i(y=>sz(w.interfaces,y)))}).catch(w=>{g||h(w instanceof Error?w.message:String(w))}),()=>{g=!0}},[t,n]);const f=async()=>{if(s){c(!0),h("");try{const g=s.active?"/workspace/local-control/disable":"/workspace/local-control/enable",w=s.active?void 0:{address:o||void 0,target:qwn()},y=await r9(t,n,"POST",g,w);r(y),i(x=>sz(y.interfaces,x))}catch(g){h(g instanceof Error?g.message:String(g));const w=g instanceof XG?g.payload?.interfaces:void 0;w&&(r(y=>y&&{...y,interfaces:w}),i(y=>sz(w,y)))}finally{c(!1)}}},m=(s?.interfaces?.length??0)>1;return a.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4 max-md:px-4","aria-live":"polite",children:[a.jsxs("div",{className:"flex items-start justify-between gap-4",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[a.jsx(Pqe,{className:"size-4","aria-hidden":"true"}),e("settings.localControl.title"),a.jsx(_a,{variant:s?.active?"default":"secondary",children:s?.active?e("settings.localControl.on"):e("settings.localControl.off")})]}),a.jsx("p",{className:"mt-1 max-w-3xl text-sm text-muted-foreground",children:e("settings.localControl.description")})]}),!s&&!u&&a.jsx(ea,{})]}),!s?.active&&m&&a.jsxs(Yu,{value:o,onValueChange:i,children:[a.jsx(Zu,{className:"w-full max-w-sm","aria-label":e("settings.localControl.network"),children:a.jsx(Xu,{placeholder:e("settings.localControl.selectNetwork")})}),a.jsx(Ju,{children:(s?.interfaces??[]).map(g=>a.jsxs(sl,{value:g.address,children:[g.interfaceName," · ",g.address]},g.address))})]}),s?.active&&s.url&&a.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[s.qrText&&a.jsx("pre",{"aria-label":e("settings.localControl.qr"),className:"w-fit overflow-hidden rounded-lg bg-white p-3 font-mono text-[7px] leading-[7px] tracking-normal text-black select-none",children:s.qrText}),a.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[a.jsx("div",{className:"break-all rounded-md bg-muted px-3 py-2 font-mono text-xs",children:s.url}),a.jsxs(Wt,{type:"button",variant:"outline",size:"sm",onClick:()=>void Yf(s.url).catch(W0),children:[a.jsx(ib,{"aria-hidden":"true"}),e("common.copy")]}),a.jsxs("p",{className:"text-xs text-muted-foreground",children:[s.encrypted?e("settings.localControl.encrypted"):e("settings.localControl.unencrypted")," ","·"," ",s.sleepInhibited?e("settings.localControl.awake"):e("settings.localControl.maySleep")]})]})]}),s?.active&&!s.url&&s.urlRedacted&&a.jsx("p",{className:"max-w-3xl text-sm text-muted-foreground",children:e("settings.localControl.urlRedacted")}),u&&a.jsx("p",{className:"text-sm text-destructive",role:"alert",children:u}),a.jsxs(Wt,{type:"button",variant:s?.active?"destructive":"default",className:"w-fit",disabled:l||!s||!s.active&&m&&!o,onClick:f,children:[l&&a.jsx(ea,{}),s?.active?e("settings.localControl.disable"):e("settings.localControl.enable")]})]})}const Gwn=new Set(["advisorModel","imageModel","fastModel","visionModel","voiceModel","modelFallbacks"]),Kwn=new Set(["ui.hideTips","ui.enableUserFeedback","ui.showSessionSummary","ui.keepSessionSummaryOpen","ui.sessionSummaryTimeoutSeconds","ui.incrementalRendering","ui.compactMode","mcpServers","model.reasoningEffort"]);function aD(e,t,n){const s=e(t);return s===t?n:s}function o3(e,t){return aD(t,`settings.category.${e}`,e)}function I2(e,t){return aD(t,`settings.label.${e.key}`,e.label)}function Ywn(e,t){if(e.description)return aD(t,`settings.description.${e.key}`,e.description)}function zRe(e,t,n,s){return aD(s,`settings.option.${e.key}.${String(t)}`,n)}function Xwn(e,t,n){const s=URe(e,t);if(s==null)return"";if(e.key==="advisorModel"&&s==="")return n("model.useMain");if(e.key==="imageModel"&&s==="")return n("model.disabled");if(e.key===q_){const o=nG(s,Ya.Dark);return n(`theme.${o}`)}if(e.key===H8){const o=BV(s);return o?FV(o):String(s)}if(e.type==="boolean")return n(s===!0?"settings.value.on":"settings.value.off");if(e.type==="enum"&&e.options){const o=e.options.find(i=>i.value===s);return o?zRe(e,o.value,o.label,n):String(s)}const r=String(s).replaceAll("\0"," · ");return r.length>24?`${r.slice(0,21)}…`:r}function HRe(e,t){return(t==="user"?e.values.user:e.values.workspace)!==void 0}function Zwn(e,t){if(t==="workspace"?e.values.user!==void 0:e.values.workspace!==void 0)return HRe(e,t)?"settings.alsoModifiedIn":"settings.modifiedIn"}function URe(e,t){const n=t==="user"?e.values.user:e.values.workspace;return n!==void 0?n:e.values.effective}function Jwn(e){const t=new Map;for(const n of e){let s=t.get(n.category);s||(s=[],t.set(n.category,s)),s.push(n)}return Array.from(t.entries()).map(([n,s])=>({category:n,items:s}))}function Bue({category:e}){const t=e.toLowerCase(),n=t.includes("ui")?TWe:t.includes("tool")?wH:t.includes("context")?vH:t.includes("privacy")?nqe:t.includes("model")?rx:t.includes("connection")?sHe:t.includes("daemon")?fT:t.includes("advanced")?iqe:t.includes("experimental")?dUe:Vve;return a.jsx(n,{"data-icon":"inline-start","aria-hidden":"true"})}function rz({title:e,description:t,metadata:n,control:s}){return a.jsxs(vl,{orientation:"responsive",className:"min-h-20 gap-6 px-5 py-4 max-md:px-4",children:[a.jsxs(sZ,{className:"min-w-0",children:[a.jsxs(fKt,{children:[e,n]}),t&&a.jsx(Df,{className:"max-w-3xl",children:t})]}),a.jsx("div",{className:"flex min-w-0 justify-end max-md:justify-start",children:s})]})}function Qwn({name:e,label:t,type:n,value:s,disabled:r,onCommit:o,onInvalid:i}){const l=String(s??""),[c,u]=d.useState(l);d.useEffect(()=>u(l),[l]);const h=()=>{if(n==="number"){const f=c.trim(),m=Number(f);if(!f||!Number.isFinite(m)){u(l),i();return}m!==s&&o(m);return}c!==l&&o(c)};return a.jsx(hi,{type:n,name:e,autoComplete:"off","aria-label":t,value:c,disabled:r,className:"w-[min(80px,50vw)] max-md:w-full",onChange:f=>u(f.target.value),onBlur:h,onKeyDown:f=>{f.key==="Enter"&&f.currentTarget.blur(),f.key==="Escape"&&(u(l),f.currentTarget.blur())}})}function eyn({settingsState:e,presentation:t,onLanguageChange:n,onSubDialog:s,onThemeChange:r,chatWidthMode:o,onChatWidthModeChange:i,modelManagement:l,connections:c,embedded:u=!1,initialCategory:h}){const{language:f,t:m}=Ct(),g=yb(),w=lpe(),y=w?.refreshPermission;d.useEffect(()=>{y?.()},[y]);const{status:x,settings:k,loading:_,error:S,reload:I,setValue:E}=e,[A,j]=d.useState("workspace"),[L,R]=d.useState(""),[N,M]=d.useState(null),[O,P]=d.useState(null),[F,H]=d.useState(!1),$=w!==void 0,Y=_&&!x,Z=d.useMemo(()=>{const ge=k.filter(ve=>!Kwn.has(ve.key)),re=Jwn(ge).map(ve=>({id:ve.category,label:o3(ve.category,m),items:ve.items.map(ye=>({type:"setting",setting:ye}))})),G={type:"local",localKey:"chatWidth"},Q=re.find(ve=>ve.items.some(ye=>ye.type==="setting"&&ye.setting.key===q_));if(Q){const ve=Q.items.findIndex(ye=>ye.type==="setting"&&ye.setting.key===q_);Q.items.splice(ve+1,0,G)}else re.push({id:"UI",label:o3("UI",m),items:[G]});$&&re.find(ye=>ye.items.includes(G))?.items.push({type:"local",localKey:"browserNotifications"});const he=re.find(ve=>ve.id==="Daemon");if(he?he.items.unshift({type:"local-control"}):re.push({id:"Daemon",label:o3("Daemon",m),items:[{type:"local-control"}]}),l&&!Y){const ve=re.find(ye=>ye.id==="Model");ve?ve.items.push({type:"model-management"}):re.push({id:"Model",label:o3("Model",m),items:[{type:"model-management"}]})}return c&&re.push({id:"Connections",label:o3("Connections",m),items:[{type:"connections"}]}),re.map(ve=>({...ve,items:ve.items.filter(ye=>{if(ye.type==="setting")return b8(ye.setting.key,t);const _e=ye.type==="local"?ye.localKey==="chatWidth"?"builtin:chat-width":"builtin:browser-notifications":ye.type==="local-control"?"builtin:local-control":ye.type==="connections"?"builtin:connections":"builtin:model-management";return iV(_e,t)})})).filter(ve=>ve.items.length>0)},[k,m,$,l,c,t,Y]);d.useEffect(()=>{if(Z.length!==0&&!Z.some(ge=>ge.id===L)){const ge=h&&Z.some(re=>re.id===h)?h:Z[0].id;R(ge)}},[L,Z,h]),d.useEffect(()=>{S?P(S.message):x?.warnings?.length?P(x.warnings.map(ge=>m("settings.corrupted",{recovered:ge.recovered?"true":"false"})).join("; ")):k.length>0&&P(null)},[S,k,x,m]);const K=d.useCallback((ge,re,G)=>{F||P(null),M(ge),E(A,ge,re).then(async Q=>{G?.();try{await I()}catch{}Q?.requiresRestart&&ge!==H8&&H(!0)}).catch(Q=>{P(Q instanceof Error?Q.message:String(Q))}).finally(()=>M(null))},[I,F,A,E]),B=Z.find(ge=>ge.id===L)??Z[0],V=B?.items.filter(ge=>ge.type!=="model-management"&&ge.type!=="connections")??[],J=B?.items.some(ge=>ge.type==="model-management"),q=B?.items.some(ge=>ge.type==="connections"),te=(ge,re,G,Q,he=!1)=>a.jsxs(Yu,{value:ge,disabled:he,onValueChange:re,children:[a.jsx(Zu,{size:"sm","aria-label":Q,className:"w-[min(160px,50vw)] bg-background max-md:w-full",children:a.jsx(Xu,{})}),a.jsx(Ju,{position:"popper",align:"end",children:a.jsx(B1e,{children:G.map(ve=>a.jsx(sl,{value:ve.value,children:ve.label},ve.value))})})]}),ie=ge=>{const re=URe(ge,A),Q=N===ge.key;if(ge.key===q_)return te(nG(re)??g,he=>{const ve=he;K(q_,mpe(ve),A==="user"?()=>r(ve):void 0)},fpe.map(he=>({value:he,label:m(`theme.${he}`)})),I2(ge,m),Q);if(ge.key===H8)return te(BV(re)??f,he=>n(he,A),PNe.map(he=>({value:he,label:FV(he)})),I2(ge,m),Q);if(Gwn.has(ge.key))return a.jsx(Wt,{type:"button",variant:"outline",size:"sm",disabled:Q,className:"max-w-[260px] truncate",onClick:()=>s(ge.key,A),children:Xwn(ge,A,m)||m("settings.action.select")});if(ge.type==="boolean"){const he=re===!0;return a.jsx(lx,{checked:he,disabled:Q,onCheckedChange:ve=>K(ge.key,ve),"aria-label":I2(ge,m)})}if(ge.type==="enum"&&ge.options?.length){const he=ge.options.findIndex(ve=>ve.value===re);return te(he>=0?String(he):"",ve=>{const ye=ge.options?.[Number(ve)];ye&&K(ge.key,ye.value)},ge.options.map((ve,ye)=>({value:String(ye),label:zRe(ge,ve.value,ve.label,m)})),I2(ge,m),Q)}return a.jsx(Qwn,{name:ge.key,label:I2(ge,m),type:ge.type==="number"||ge.type==="integer"?"number":"text",value:re,disabled:Q,onCommit:he=>K(ge.key,he),onInvalid:()=>P(m("settings.invalidNumber"))})};return a.jsxs("div",{className:u?"flex min-h-0 flex-1 flex-col text-sm text-foreground":"flex max-w-[min(var(--chat-regular-content-width,1000px),calc(100vw-64px))] flex-col overflow-hidden rounded-xl border border-border bg-background text-sm text-foreground","data-keyboard-scope":!0,children:[!u&&a.jsx("div",{className:"flex items-center justify-between border-b border-border px-5 py-4",children:a.jsxs("div",{children:[a.jsx("h2",{className:"text-base font-semibold text-balance",children:m("settings.title")}),a.jsx("div",{className:"mt-0.5 text-xs text-muted-foreground",children:m("settings.scope.workspace")})]})}),(O||Y)&&a.jsxs(qf,{className:"mx-4 mt-3 w-auto",children:[Y&&a.jsx(ea,{}),a.jsx(Vf,{children:O||m("settings.loading")})]}),a.jsxs(Ew,{value:A,className:"flex min-h-0 flex-1 flex-col gap-0",onValueChange:ge=>{j(ge)},children:[B?.id!=="Connections"&&a.jsxs("div",{className:"flex items-center justify-between gap-4 border-b border-border px-3 py-2",children:[a.jsxs(Aw,{className:"p-0",children:[a.jsx(da,{value:"workspace",children:m("settings.scope.workspace")}),a.jsx(da,{value:"user",children:m("settings.scope.user")})]}),F&&a.jsx(_a,{variant:"secondary",children:m("settings.requiresRestart")})]}),a.jsxs(Ga,{value:A,forceMount:!0,className:"grid min-h-0 flex-1 grid-cols-[190px_minmax(0,1fr)] outline-none max-md:grid-cols-1",children:[a.jsx("nav",{className:"flex min-h-0 flex-col gap-1 overflow-y-auto border-r border-border bg-muted/20 p-3 max-md:flex-row max-md:overflow-x-auto max-md:border-r-0 max-md:border-b","aria-label":m("settings.title"),children:Z.map(ge=>a.jsxs(Wt,{type:"button",variant:ge.id===L?"secondary":"ghost",size:"sm","aria-current":ge.id===L?"page":void 0,className:"w-full justify-start gap-2 px-2.5 max-md:w-auto max-md:shrink-0",onClick:()=>R(ge.id),children:[a.jsx(Bue,{category:ge.id}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:ge.label}),a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:Math.max(1,ge.items.filter(re=>re.type!=="model-management").length)})]},ge.id))}),a.jsxs("section",{className:"min-h-0 min-w-0 overflow-y-auto bg-background p-5 max-md:p-3",children:[!_&&!B&&a.jsx(Qy,{className:"min-h-60",children:a.jsxs(eb,{children:[a.jsx(tb,{variant:"icon",children:a.jsx(Vve,{})}),a.jsx(nb,{children:m("settings.empty")})]})}),B&&a.jsxs("div",{className:"mx-auto w-full max-w-5xl",children:[V.length>0&&a.jsxs(qu,{children:[a.jsx(Ff,{children:a.jsxs(zf,{className:"flex items-center gap-2",children:[a.jsx(Bue,{category:B.id}),B.label]})}),a.jsx(Cp,{className:"-mb-(--card-spacing) p-0",children:a.jsx(cx,{className:"gap-0",children:V.map((ge,re)=>{const G=re>0&&a.jsx(nZ,{className:"mx-5 w-auto max-md:mx-4"});if(ge.type==="local"&&ge.localKey==="browserNotifications"&&w){const ae=w.permission==="unavailable",Se=ae?"unavailable":w.pending?"requesting":w.permission==="denied"?"denied":w.error?"error":w.enabled?w.permission==="granted"?"enabled":"waiting":"disabled";return a.jsxs("div",{children:[G,a.jsx(rz,{title:m("browserNotifications.label"),description:[m("browserNotifications.description"),m(`browserNotifications.${Se}`),...w.persistent?[]:[m("browserNotifications.temporary")]].join(" "),control:a.jsxs("div",{className:"flex items-center gap-2",children:[w.enabled&&w.permission==="default"&&a.jsx(Wt,{variant:"outline",size:"sm",disabled:w.pending,onClick:()=>void w.setEnabled(!0),children:m("browserNotifications.allow")}),a.jsx(lx,{"aria-label":m("browserNotifications.label"),checked:w.enabled,disabled:w.pending||ae&&!w.enabled,onCheckedChange:Te=>void w.setEnabled(Te)})]})})]},ge.localKey)}if(ge.type==="local")return a.jsxs("div",{children:[G,a.jsx(rz,{title:m("settings.label.ui.chatWidth"),description:m("settings.description.ui.chatWidth"),control:te(o,ae=>i(ae),[{value:"1000",label:m("settings.option.ui.chatWidth.1000")},{value:"wide",label:m("settings.option.ui.chatWidth.wide")}],m("settings.label.ui.chatWidth"),!1)})]},ge.localKey);if(ge.type==="local-control")return a.jsxs("div",{children:[G,a.jsx(Vwn,{})]},"local-control");const Q=ge.setting,he=Ywn(Q,m),ve=Zwn(Q,A),ye=HRe(Q,A),_e=ve?m(ve,{scope:m(A==="workspace"?"settings.scope.user":"settings.scope.workspace")}):void 0;return a.jsxs("div",{children:[G,a.jsx(rz,{title:I2(Q,m),description:[he,_e].filter(Boolean).join(" · ")||void 0,metadata:ye?a.jsx(_a,{variant:"secondary",children:m(A==="workspace"?"settings.scope.workspace":"settings.scope.user")}):void 0,control:N===Q.key?a.jsx(ea,{}):ie(Q)})]},Q.key)})})})]}),J&&l&&a.jsx("div",{className:V.length>0?"mt-4":void 0,children:a.jsx(Uwn,{...l})}),q&&c]})]})]})]}),!u&&a.jsx("div",{className:"border-t border-border px-5 py-3 text-xs text-muted-foreground",children:m("settings.footer")})]})}const tyn="_dialog_1ymqd_1",nyn="_toolbar_1ymqd_12",syn="_tabs_1ymqd_21",ryn="_tab_1ymqd_21",oyn="_tabActive_1ymqd_39",iyn="_search_1ymqd_48",ayn="_general_1ymqd_60",lyn="_shortcuts_1ymqd_67",cyn="_shortcut_1ymqd_67",uyn="_shortcutKey_1ymqd_87",dyn="_shortcutDesc_1ymqd_95",hyn="_commandList_1ymqd_101",fyn="_commandCard_1ymqd_108",pyn="_commandCardExpanded_1ymqd_115",myn="_commandRow_1ymqd_119",gyn="_commandName_1ymqd_135",vyn="_commandTag_1ymqd_142",wyn="_chevron_1ymqd_152",yyn="_chevronExpanded_1ymqd_160",byn="_commandDetail_1ymqd_164",xyn="_commandDescription_1ymqd_174",kyn="_commandSubcommands_1ymqd_175",_yn="_empty_1ymqd_182",Jc={dialog:tyn,toolbar:nyn,tabs:syn,tab:ryn,tabActive:oyn,search:iyn,general:ayn,shortcuts:lyn,shortcut:cyn,shortcutKey:uyn,shortcutDesc:dyn,commandList:hyn,commandCard:fyn,commandCardExpanded:pyn,commandRow:myn,commandName:gyn,commandTag:vyn,chevron:wyn,chevronExpanded:yyn,commandDetail:byn,commandDescription:xyn,commandSubcommands:kyn,empty:_yn},Syn=[{id:"general",labelKey:"help.tab.general"},{id:"commands",labelKey:"help.tab.commands"},{id:"custom-commands",labelKey:"help.tab.custom"}],Cyn=new Set(["about","agents","approval-mode","arena","auth","branch","btw","bug","clear","compress","context","copy","release","diff","directory","docs","doctor","dream","editor","export","extensions","forget","goal","help","hooks","ide","init","insight","language","lsp","mcp","memory","model","new","permissions","plan","quit","recap","remember","rename","reset","restore","resume","rewind","settings","skills","stats","status","statusline","summary","tasks","terminal-setup","theme","tools","trust","vim"]),Tyn=[["@","help.shortcut.addContext"],["!","help.shortcut.shell"],["/","help.shortcut.commandMenu"],["Tab","help.shortcut.completion"],["Esc","help.shortcut.cancel"],["Ctrl+J","help.shortcut.newline"],["Ctrl+L","help.shortcut.clear"],["Ctrl+Y","help.shortcut.retry"],["Shift+Tab","help.shortcut.approvals"],["Alt+Left/Right","help.shortcut.altWords"],["Up/Down","help.shortcut.history"]];function Iyn(e){return[`/${e.name}`,e.argumentHint].filter(Boolean).join(" ")}function aV(e){return!Cyn.has(e.name)}function Ryn(e,t){return aV(e)?t("help.commandMeta.custom"):t("help.commandMeta.builtIn")}function Eyn(e,t,n){const s=n.trim().toLowerCase();return e.filter(r=>r.name&&r.description!==void 0).filter(r=>t==="commands"?!aV(r):t==="custom-commands"?aV(r):!0).filter(r=>s?r.name.toLowerCase().includes(s)||(r.description??"").toLowerCase().includes(s)||(r.argumentHint??"").toLowerCase().includes(s):!0).sort((r,o)=>r.name.localeCompare(o.name))}function Ayn(){const{t:e}=Ct();return a.jsx("div",{className:Jc.general,children:a.jsx("div",{className:Jc.shortcuts,children:Tyn.map(([t,n])=>a.jsxs("div",{className:Jc.shortcut,children:[a.jsx("span",{className:Jc.shortcutDesc,children:e(n)}),a.jsx("span",{className:Jc.shortcutKey,children:t})]},t))})})}function jyn({commands:e,tab:t,query:n}){const{t:s}=Ct(),[r,o]=d.useState(null),i=d.useMemo(()=>Eyn(e,t,n),[e,n,t]);return i.length===0?a.jsx("div",{className:Jc.empty,children:s(t==="custom-commands"?"help.emptyCustom":"help.empty")}):a.jsx("div",{className:Jc.commandList,children:i.map(l=>{const c=r===l.name;return a.jsxs("article",{className:`${Jc.commandCard} ${c?Jc.commandCardExpanded:""}`,children:[a.jsxs("button",{type:"button",className:Jc.commandRow,onClick:()=>o(c?null:l.name),"aria-expanded":c,children:[a.jsx("span",{className:Jc.commandName,children:Iyn(l)}),a.jsx("span",{className:Jc.commandTag,children:Ryn(l,s)}),a.jsx("svg",{className:`${Jc.chevron} ${c?Jc.chevronExpanded:""}`,viewBox:"0 0 16 16","aria-hidden":"true",children:a.jsx("path",{d:"M6 4.5 9.5 8 6 11.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})})]}),c&&a.jsxs("div",{className:Jc.commandDetail,children:[l.description&&a.jsx("div",{className:Jc.commandDescription,children:l.description}),!!l.subcommands?.length&&a.jsxs("div",{className:Jc.commandSubcommands,children:[s("help.subcommands"),": ",l.subcommands.join(", ")]})]})]},l.name)})})}function Nyn({commands:e}){const{t}=Ct(),[n,s]=d.useState("general"),{filterValue:r,inputProps:o}=JL(),i=n!=="general";return a.jsxs("div",{className:Jc.dialog,children:[a.jsxs("div",{className:Jc.toolbar,children:[a.jsx("div",{className:Jc.tabs,children:Syn.map(l=>a.jsx("button",{type:"button",className:`${Jc.tab} ${l.id===n?Jc.tabActive:""}`,onClick:()=>s(l.id),children:t(l.labelKey)},l.id))}),i&&a.jsx("input",{className:Jc.search,...o,placeholder:t("help.search")})]}),n==="general"?a.jsx(Ayn,{}):a.jsx(jyn,{commands:e,tab:n,query:r})]})}function Myn({currentTheme:e,onSelect:t,onClose:n}){const{t:s}=Ct(),r=fpe.map(h=>({id:h,label:s(`theme.${h}`),description:s(`theme.${h}.desc`)})),[o,i]=d.useState(()=>{const h=r.findIndex(f=>f.id===e);return h>=0?h:0}),l=d.useRef(null),c=h=>{const f=r[h];f&&(t(f.id),n())},{keyboardMode:u}=ak({itemCount:r.length,activeIndex:o,onActiveIndexChange:i,onConfirm:c});return d.useEffect(()=>{l.current?.children[o]?.scrollIntoView({block:"nearest"})},[o]),a.jsx("div",{className:pr("picker-list","picker-list-compact",u?"picker-keyboard-only":void 0),ref:l,role:"listbox","aria-label":s("theme.title"),tabIndex:0,"aria-activedescendant":r.length>0?`theme-opt-${o}`:void 0,"data-web-shell-theme-dialog":!0,children:r.map((h,f)=>{const m=h.id===e;return a.jsxs("div",{id:`theme-opt-${f}`,role:"option","aria-selected":m,className:pr("picker-item","picker-session-item",f===o?"selected":void 0,m?"dialog-current":void 0),"data-web-shell-theme-option":!0,"data-theme-id":h.id,onClick:()=>c(f),onMouseMove:()=>i(f),children:[a.jsx("div",{className:pr("picker-item-row"),children:a.jsx("span",{className:pr("picker-item-title"),children:h.label})}),a.jsx("div",{className:pr("picker-item-meta"),children:h.description})]},h.id)})})}const lV="delete-session-list",Fue=e=>`${lV}-opt-${e}`;function Pyn({onDeleted:e,onError:t,onClose:n,workspaceCwd:s}){const{t:r}=Ct(),o=el(),{sessions:i,loading:l,error:c,deleteSession:u,deleteSessions:h}=L5(s,{autoLoad:!0,maxAgeMs:1e3}),f=o.sessionId,[m,g]=d.useState(!1),[w,y]=d.useState(-1),[x,k]=d.useState(new Set),{filterValue:_,inputProps:S}=JL(()=>{y(-1),k(new Set)}),[I,E]=d.useState(null),A=d.useRef(null),j=d.useRef(null);d.useEffect(()=>{c&&E(c.message)},[c]);const L=d.useMemo(()=>i.filter(F=>{if(F.sourceType==="o1-code-live")return!1;const H=_.toLowerCase();return!H||(F.displayName||"").toLowerCase().includes(H)||F.sessionId.toLowerCase().includes(H)||S5(F,H)}),[i,_]),R=d.useCallback(F=>{F!==f&&k(H=>{const $=new Set(H);return $.has(F)?$.delete(F):$.add(F),$})},[f]);d.useEffect(()=>{if(x.size===0)return;const F=new Set(L.map(H=>H.sessionId));k(H=>{const $=new Set([...H].filter(Y=>F.has(Y)));return $.size===H.size?H:$})},[L,x.size]),d.useEffect(()=>{w>=L.length&&L.length>0&&y(L.length-1)},[L.length,w]),d.useEffect(()=>{A.current?.children[w]?.scrollIntoView({block:"nearest"})},[w]),d.useEffect(()=>{j.current?.focus()},[]);const{keyboardMode:N}=ak({itemCount:L.length,activeIndex:w,onActiveIndexChange:y,onConfirm:F=>{const H=L[F];H&&R(H.sessionId)}}),M=d.useCallback(()=>{if(m)return;if(x.size>0){const H=new Set(L.map(Y=>Y.sessionId)),$=Array.from(x).filter(Y=>H.has(Y));if($.length===0)return;g(!0),h($).then(Y=>{const Z=Y.removed.length+Y.notFound.length,K=Y.errors.length;if(K>0&&Z>0){t(new Error(r("delete.partialFail",{removed:Z,failed:K,detail:Y.errors[0].error}))),n();return}if(K>0){E(r("delete.allFailed",{count:K,reason:Y.errors[0].error})),g(!1),k(new Set);return}if(Z===0){E(r("delete.nonRemoved")),g(!1),k(new Set);return}e([...Y.removed,...Y.notFound]),n()}).catch(Y=>{t(Y),g(!1)});return}const F=L[w];if(F){if(F.sessionId===f){E(r("delete.cannotCurrent"));return}g(!0),u(F.sessionId).then(H=>{if(!H){E(r("delete.notFound")),g(!1);return}e([F.sessionId]),n()}).catch(H=>{t(H),g(!1)})}},[f,u,h,m,L,n,e,t,w,x,r]),O=x.size>0,P=!m&&!l&&O;return a.jsxs("div",{className:pr("picker","picker-in-shell"),children:[a.jsxs("div",{className:pr("picker-search"),children:[a.jsxs("span",{className:pr("picker-search-label"),children:[r("resume.search"),":"," "]}),a.jsx("input",{ref:j,className:pr("picker-search-input"),"aria-label":r("resume.search"),role:"combobox","aria-autocomplete":"list","aria-expanded":"true","aria-controls":lV,"aria-activedescendant":w>=0&&w<L.length?Fue(w):void 0,...S,placeholder:""}),a.jsx("span",{className:pr("picker-search-hint"),children:I||(m?r("delete.deleting"):l?r("common.loading"):O?r("delete.selected",{count:x.size}):_?r("delete.matches",{count:L.length}):"")})]}),a.jsx("div",{className:pr("picker-sep")}),a.jsxs("div",{id:lV,role:"listbox","aria-multiselectable":"true",className:pr("picker-list",N?"picker-keyboard-only":void 0),ref:A,children:[l&&a.jsx("div",{className:pr("picker-empty"),children:r("common.loading")}),!l&&c&&a.jsx("div",{className:pr("picker-empty"),children:c.message}),!l&&!c&&L.length===0&&a.jsx("div",{className:pr("picker-empty"),children:_?r("delete.noMatch",{query:_}):r("delete.none")}),!l&&L.map((F,H)=>{const $=F.sessionId===f,Y=x.has(F.sessionId);return a.jsx(tZ,{session:F,optionId:Fue(H),active:H===w,ariaSelected:Y,current:!1,disabled:$,leading:a.jsx("span",{className:pr("picker-item-checkbox",Y?"picker-item-checkbox-checked":void 0),children:Y?"[x] ":"[ ] "}),trailing:$?a.jsx("span",{className:pr("picker-item-badge"),children:r("resume.current")}):void 0,onClick:()=>{y(H),$||R(F.sessionId)},onActivate:()=>y(H)},F.sessionId)})]}),a.jsx("div",{className:pr("picker-sep")}),a.jsxs("div",{className:pr("dialog-footer-actions"),children:[a.jsx("button",{type:"button",className:pr("dialog-inline-button"),onClick:n,disabled:m,children:r("common.cancel")}),a.jsx("button",{type:"button",className:pr("dialog-danger-button"),onClick:M,disabled:!P,children:r(m?"delete.deleting":"delete.action")})]})]})}const cV="release-session-list",zue=e=>`${cV}-opt-${e}`;function Lyn({onReleased:e,onError:t,onClose:n,workspaceCwd:s}){const{t:r}=Ct(),o=el(),{sessions:i,loading:l,error:c,releaseSession:u}=L5(s,{autoLoad:!0,maxAgeMs:1e3}),h=o.sessionId,[f,m]=d.useState(!1),[g,w]=d.useState(-1),[y,x]=d.useState(null),{filterValue:k,inputProps:_}=JL(()=>{w(-1),x(null)}),[S,I]=d.useState(null),E=d.useRef(null),A=d.useRef(null);d.useEffect(()=>{c&&I(c.message)},[c]);const j=k?i.filter(F=>{const H=k.toLowerCase();return(F.displayName||"").toLowerCase().includes(H)||F.sessionId.toLowerCase().includes(H)||S5(F,H)}):i,L=F=>{const H=j[F];if(!H)return;const $=H.sessionId===h,Y=(H.clientCount??0)>0||H.hasActivePrompt===!0;$||!Y||(w(F),x(H.sessionId))};d.useEffect(()=>{g>=j.length&&j.length>0&&w(j.length-1)},[j.length,g]),d.useEffect(()=>{E.current?.children[g]?.scrollIntoView({block:"nearest"})},[g]),d.useEffect(()=>{A.current?.focus()},[]);const{keyboardMode:R}=ak({itemCount:j.length,activeIndex:g,onActiveIndexChange:w,onConfirm:L}),N=d.useCallback(F=>{const H=F??j.find(Y=>Y.sessionId===y)??void 0;if(!H||f)return;if(!((H.clientCount??0)>0||H.hasActivePrompt===!0)){I(r("release.inactive"));return}if(H.sessionId===h){I(r("release.cannotCurrent"));return}u&&(m(!0),u(H.sessionId).then(()=>{e(H.sessionId),n()}).catch(Y=>{t(Y),m(!1)}))},[h,f,j,n,t,e,u,y,r]),M=j.find(F=>F.sessionId===y)??void 0,O=M&&((M.clientCount??0)>0||M.hasActivePrompt===!0),P=!f&&!l&&!!M&&M.sessionId!==h&&!!O;return a.jsxs("div",{className:pr("picker","picker-in-shell"),children:[a.jsxs("div",{className:pr("picker-search"),children:[a.jsxs("span",{className:pr("picker-search-label"),children:[r("resume.search"),":"," "]}),a.jsx("input",{ref:A,className:pr("picker-search-input"),"aria-label":r("resume.search"),role:"combobox","aria-autocomplete":"list","aria-expanded":"true","aria-controls":cV,"aria-activedescendant":g>=0&&g<j.length?zue(g):void 0,..._,placeholder:""}),a.jsx("span",{className:pr("picker-search-hint"),children:S||(f?r("release.releasing"):l?r("common.loading"):k?r("release.matches",{count:j.length}):"")})]}),a.jsx("div",{className:pr("picker-sep")}),a.jsxs("div",{id:cV,role:"listbox",className:pr("picker-list",R?"picker-keyboard-only":void 0),ref:E,children:[l&&a.jsx("div",{className:pr("picker-empty"),children:r("common.loading")}),!l&&j.length===0&&a.jsx("div",{className:pr("picker-empty"),children:k?r("release.noMatch",{query:k}):r("release.none")}),!l&&j.map((F,H)=>{const $=F.sessionId===h,Y=(F.clientCount??0)>0||F.hasActivePrompt===!0,Z=$||!Y;return a.jsx(tZ,{session:F,optionId:zue(H),active:H===g,confirmed:F.sessionId===y,ariaSelected:F.sessionId===y,current:!1,disabled:Z,trailing:$?a.jsx("span",{className:pr("picker-item-badge"),children:r("resume.current")}):Y?void 0:a.jsx("span",{className:pr("picker-item-badge"),children:r("release.inactiveBadge")}),onClick:()=>L(H),onActivate:()=>w(H)},F.sessionId)})]}),a.jsx("div",{className:pr("picker-sep")}),a.jsxs("div",{className:pr("dialog-footer-actions"),children:[a.jsx("button",{type:"button",className:pr("dialog-inline-button"),onClick:n,disabled:f,children:r("common.cancel")}),a.jsx("button",{type:"button",className:pr("dialog-danger-button"),onClick:()=>N(),disabled:!P,children:r(f?"release.releasing":"release.action")})]})]})}const Dyn="_root_ieg2d_1",Oyn="_list_ieg2d_8",$yn="_item_ieg2d_21",Byn="_itemCursor_ieg2d_42",Fyn="_itemSelected_ieg2d_49",zyn="_prompt_ieg2d_61",Hyn="_keyboardOnly_ieg2d_68",Uyn="_itemDisabled_ieg2d_77",Wyn="_turn_ieg2d_91",qyn="_time_ieg2d_96",Vyn="_footer_ieg2d_102",Gyn="_footerMessage_ieg2d_112",Kyn="_dangerButton_ieg2d_118",fm={root:Dyn,list:Oyn,item:$yn,itemCursor:Byn,itemSelected:Fyn,prompt:zyn,keyboardOnly:Hyn,itemDisabled:Uyn,turn:Wyn,time:qyn,footer:Vyn,footerMessage:Gyn,dangerButton:Kyn},Yyn="rewind-snapshot-list",Hue=e=>`${Yyn}-opt-${e}`;function Xyn(e,t){let n=0;for(const s of e)if(s.kind==="user"){if(n===t)return s.text.trim();n+=1}return""}function Zyn(e){const t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleString():e}function Jyn({blocks:e,loadSnapshots:t,rewind:n,onError:s,onClose:r}){const{t:o}=Ct(),[i,l]=d.useState([]),[c,u]=d.useState(!0),[h,f]=d.useState(null),[m,g]=d.useState(0),[w,y]=d.useState(null),[x,k]=d.useState(null);d.useEffect(()=>{let L=!0;return u(!0),t().then(R=>{L&&l(R.snapshots)}).catch(R=>{L&&s(R)}).finally(()=>{L&&u(!1)}),()=>{L=!1}},[t,s]);const _=d.useMemo(()=>i.map(L=>({snapshot:L,promptText:Xyn(e,L.turnIndex)})).sort((L,R)=>L.snapshot.turnIndex-R.snapshot.turnIndex),[e,i]);d.useEffect(()=>{m>=_.length&&_.length>0&&g(_.length-1)},[_.length,m]);const S=d.useRef(null),I=h!==null,E=L=>{!L||h||(f(L),k(null),n(L).then(()=>{r()}).catch(R=>{s(R),k(o("rewind.failed",{reason:R instanceof Error?R.message:String(R)})),f(null)}))},A=L=>{const R=_[L];R&&(g(L),y(R.snapshot.promptId))},{keyboardMode:j}=ak({itemCount:_.length,activeIndex:m,onActiveIndexChange:g,onConfirm:A,enabled:!I});return d.useEffect(()=>{S.current?.children[m]?.scrollIntoView({block:"nearest"})},[m]),d.useEffect(()=>{if(c||_.length===0)return;document.activeElement?.getAttribute("role")==="dialog"&&S.current?.focus()},[c,_.length]),c?a.jsx("div",{className:pr("picker-empty"),children:o("rewind.loading")}):_.length===0?a.jsx("div",{className:pr("picker-empty"),children:o("rewind.empty")}):a.jsxs("div",{className:fm.root,children:[a.jsx("div",{className:`${fm.list} ${j?fm.keyboardOnly:""}`,ref:S,role:"listbox","aria-label":o("rewind.title"),tabIndex:0,"aria-activedescendant":_.length>0?Hue(m):void 0,children:_.map(({snapshot:L,promptText:R},N)=>{const M=N===m,O=w===L.promptId,P=R||o("rewind.promptFallback",{id:L.promptId.slice(-8)});return a.jsxs("div",{id:Hue(N),role:"option","aria-selected":O,"aria-disabled":I||void 0,className:`${fm.item} ${M?fm.itemCursor:""} ${O?fm.itemSelected:""} ${I?fm.itemDisabled:""}`,onClick:()=>{I||A(N)},onMouseMove:()=>g(N),children:[a.jsxs("div",{className:fm.prompt,title:P,children:[a.jsxs("span",{className:fm.turn,children:["#",L.turnIndex+1]})," ",P]}),a.jsx("div",{className:fm.time,children:Zyn(L.timestamp)})]},L.promptId)})}),a.jsxs("div",{className:fm.footer,children:[x&&a.jsx("span",{className:fm.footerMessage,role:"alert",children:x}),a.jsx("button",{type:"button",className:pr("dialog-inline-button"),onClick:r,disabled:h!==null,children:o("common.cancel")}),a.jsx("button",{type:"button",className:`${pr("dialog-danger-button")} ${fm.dangerButton}`,onClick:()=>E(w),disabled:!w||h!==null,children:o(h?"rewind.rewinding":"rewind.confirm")})]})]})}const uM="add-workspace-hint",Uue="add-workspace-display-name-hint",Wue="add-workspace-error",dM="add-workspace-suggestions",Qyn=150;function oz(e){return e.startsWith("/")||/^[A-Za-z]:[\\/]/.test(e)||e.startsWith("ssh://")}function ebn({browseDirectories:e=!1,initialPath:t="",onClose:n,onAdd:s,displayNameEnabled:r=!1,locations:o,selectedLocation:i,onLocationChange:l,onSuggest:c,onPick:u,persistenceSupported:h=!0}){const{t:f}=Ct(),[m,g]=d.useState(t),[w,y]=d.useState(""),[x,k]=d.useState(null),[_,S]=d.useState(!1),[I,E]=d.useState(!0),[A,j]=d.useState([]),[L,R]=d.useState(!1),[N,M]=d.useState(!1),[O,P]=d.useState(!1),[F,H]=d.useState(-1),[$,Y]=d.useState("/"),[Z,K]=d.useState(!1),B=d.useRef(null),V=d.useRef(!1);V.current=O&&A.length>0;const J=d.useRef(0),q=d.useRef(!1),te=d.useRef(void 0);d.useEffect(()=>{B.current?.focus()},[]);const ie=d.useCallback(()=>{te.current!==void 0&&(clearTimeout(te.current),te.current=void 0)},[]);d.useEffect(()=>()=>ie(),[ie]);const ge=d.useCallback(()=>{P(!1),H(-1)},[]),re=d.useRef(i);d.useEffect(()=>{re.current!==i&&(re.current=i,g(t||"/"),k(null),j([]),R(!1),M(!1),ge())},[i,t,ge]),d.useEffect(()=>{if(!c)return;if(!oz(m)||m.trim().startsWith("ssh://")){++J.current,j([]),R(!1),M(!1),ge();return}const _e=++J.current;e&&j([]),R(!1),M(!1);const ae=!q.current;q.current=!1;const Se=setTimeout(()=>{c(m).then(Te=>{if(_e!==J.current)return;j(Te.suggestions),R(!0),M(!1),Y(Te.sep||"/"),H(-1);const Ne=B.current;(e||Ne!==null&&Xy(Ne)===Ne&&(ae||V.current))&&P(Te.suggestions.length>0)},()=>{_e===J.current&&(j([]),R(!0),M(e),ge())})},Qyn);return()=>clearTimeout(Se)},[e,m,c,ge]),d.useEffect(()=>{const _e=ae=>{e||ae.key!=="Escape"||!V.current||ae.isComposing||ae.keyCode===229||(ae.preventDefault(),ge())};return window.addEventListener("keydown",_e,{capture:!0}),()=>window.removeEventListener("keydown",_e,{capture:!0})},[e,ge]);const G=d.useCallback(_e=>{q.current=!1,g(_e.path+$),k(null),ge(),B.current?.focus()},[$,ge]),Q=d.useCallback(async()=>{if(!u)return;B.current?.blur(),ie(),ge(),q.current=!0,K(!0),k(null);let _e;try{_e=await u(),_e&&_e!==m?(++J.current,g(_e),j([])):(_e&&++J.current,q.current=!1)}catch{q.current=!1,k(f("sidebar.addWorkspaceBrowseError"))}finally{K(!1)}},[u,m,ge,ie,f]),he=d.useCallback(_e=>{const ae=O&&A.length>0;if(_e.key==="ArrowDown"){if(_e.preventDefault(),!ae){A.length>0&&P(!0);return}H(Se=>(Se+1)%A.length);return}if(_e.key==="ArrowUp"){if(!ae)return;_e.preventDefault(),H(Se=>(Se<=0?A.length:Se)-1);return}if(_e.key==="Tab"&&ae&&!_e.shiftKey){const Se=F>=0?A[F]:A.length===1?A[0]:void 0;Se&&(_e.preventDefault(),G(Se));return}if(_e.key==="Enter"&&ae&&F>=0){_e.preventDefault(),G(A[F]);return}if(_e.key==="Enter"&&e&&!m.trim().startsWith("ssh://")&&!_e.nativeEvent.isComposing){_e.preventDefault();const Se=m.trim();if(!oz(Se)){k(f("sidebar.addWorkspaceAbsError"));return}if(!/[\\/]$/.test(Se)){g(Se+$);return}A.length>0&&H(0)}},[O,A,F,G,e,m,$,f]),ve=d.useCallback(async _e=>{_e.preventDefault();const ae=m.trim();if(ae){if(!oz(ae)){k(f("sidebar.addWorkspaceAbsError"));return}k(null),S(!0),ge();try{const Se=h?I:!1,Te=r?w.trim():"";Te?await s(ae,Se,Te):await s(ae,Se),n()}catch(Se){k(Se instanceof Error?Se.message:f("sidebar.addWorkspaceError"))}finally{S(!1)}}},[m,w,r,I,h,s,n,ge,f]),ye=(e||O)&&A.length>0;return a.jsx(Wa,{title:f("sidebar.addWorkspaceTitle"),size:"md",dismissible:!_,onClose:n,children:a.jsxs("form",{className:"flex flex-col gap-6",onSubmit:ve,children:[a.jsxs(cx,{children:[e&&o&&o.length>0&&i&&l&&a.jsxs(vl,{children:[a.jsx(lc,{id:"workspace-location-label",children:f("workspaceHost.source")}),a.jsxs(Yu,{value:i,disabled:_,onValueChange:_e=>{_e!==i&&l(_e)===!1&&k(f("workspaceHost.navigationUnavailable"))},children:[a.jsx(Zu,{className:"w-full","aria-labelledby":"workspace-location-label",children:a.jsx(Xu,{})}),a.jsx(Ju,{children:o.map(_e=>{const ae=_e.remote?fT:GUe;return a.jsxs(sl,{value:_e.origin,children:[a.jsx(ae,{"aria-hidden":"true"}),_e.label]},_e.origin)})})]})]}),a.jsxs(vl,{"data-invalid":x?!0:void 0,children:[a.jsx(lc,{htmlFor:"add-workspace-path",children:f("sidebar.addWorkspacePath")}),a.jsxs("div",{className:"relative",children:[a.jsxs("div",{className:"flex gap-2",children:[a.jsx(hi,{ref:B,id:"add-workspace-path",type:"text",placeholder:"/absolute/path or ssh://user@host/project",value:m,onChange:_e=>{g(_e.target.value),x&&k(null)},onKeyDown:he,onFocus:ie,onBlur:()=>{e||(ie(),te.current=setTimeout(()=>{te.current=void 0,++J.current,j([]),ge()},100))},disabled:_||Z,autoCapitalize:"off",autoCorrect:"off",autoComplete:"off",spellCheck:!1,role:"combobox","aria-expanded":ye,"aria-controls":ye?dM:void 0,"aria-activedescendant":ye&&F>=0?`${dM}-${F}`:void 0,"aria-describedby":x?`${Wue} ${uM}`:uM,"aria-invalid":x?!0:void 0}),e&&!m.trim().startsWith("ssh://")&&a.jsx(Wt,{type:"button",size:"icon",variant:"outline",title:f("workspaceHost.parent"),"aria-label":f("workspaceHost.parent"),disabled:_,onMouseDown:_e=>_e.preventDefault(),onClick:()=>{const _e=m.replace(/[\\/]+$/,"");if(/^[A-Za-z]:$/.test(_e)){g(`${_e}\\`);return}const ae=Math.max(_e.lastIndexOf("/"),_e.lastIndexOf("\\"));g(ae>=0?_e.slice(0,ae+1):$)},children:a.jsx(UHe,{"aria-hidden":"true"})}),u&&a.jsxs(Wt,{type:"button",variant:"outline",onMouseDown:_e=>_e.preventDefault(),onClick:()=>void Q(),disabled:_||Z,children:[a.jsx($T,{"aria-hidden":"true"}),f("sidebar.addWorkspaceBrowse")]})]}),e&&a.jsx("p",{id:uM,className:"mt-2 text-sm leading-normal text-muted-foreground",children:f("workspaceHost.browseHint")}),ye&&a.jsx("ul",{id:dM,role:"listbox","aria-label":f("sidebar.addWorkspaceSuggestions"),className:`${e?"relative":"absolute inset-x-0 top-full z-50"} mt-1 max-h-56 overflow-y-auto rounded-md border bg-popover py-1 text-popover-foreground shadow-md`,children:A.map((_e,ae)=>a.jsxs("li",{id:`${dM}-${ae}`,role:"option","aria-selected":ae===F,className:`cursor-pointer truncate px-3 py-1.5 ${ae===F?"bg-accent text-accent-foreground":"hover:bg-accent/50"}`,onMouseDown:Se=>{Se.preventDefault(),G(_e)},onMouseEnter:()=>H(ae),children:[e&&a.jsx($T,{className:"mr-2 inline size-4","aria-hidden":"true"}),_e.name,a.jsx("span",{className:"text-muted-foreground",children:$})]},_e.path))}),e&&L&&!ye&&a.jsx("div",{role:N?"alert":"status",className:"mt-1 rounded-md border px-3 py-3 text-sm text-muted-foreground",children:f(N?"workspaceHost.folderListError":"workspaceHost.noFolders")})]}),a.jsx(Df,{id:e?void 0:uM,children:f("sidebar.addWorkspaceHint")}),x&&a.jsx(pKt,{id:Wue,children:x})]}),r&&a.jsxs(vl,{children:[a.jsx(lc,{htmlFor:"add-workspace-display-name",children:f("sidebar.addWorkspaceDisplayName")}),a.jsx(hi,{id:"add-workspace-display-name",type:"text",value:w,placeholder:e?m.split(/[\\/]/).filter(Boolean).pop():void 0,onChange:_e=>y(_e.target.value),disabled:_,maxLength:256,autoComplete:"off","aria-describedby":Uue}),a.jsx(Df,{id:Uue,children:f("sidebar.addWorkspaceDisplayNameHint")})]}),h&&a.jsxs(vl,{orientation:"horizontal",children:[a.jsxs(sZ,{children:[a.jsx(lc,{htmlFor:"add-workspace-persist",children:f("sidebar.addWorkspacePersist")}),a.jsx(Df,{children:f("sidebar.addWorkspacePersistHint")})]}),a.jsx(lx,{id:"add-workspace-persist",checked:I,onCheckedChange:E,disabled:_})]})]}),a.jsxs("div",{className:"flex w-full justify-end gap-2",children:[a.jsx(Wt,{type:"button",variant:"outline",className:"flex-1 sm:flex-none",onClick:n,disabled:_,children:f("sidebar.addWorkspaceCancel")}),a.jsx(Wt,{type:"submit",className:"flex-1 sm:flex-none",disabled:_||!m.trim(),children:f(_?"sidebar.addWorkspaceAdding":e?"workspaceHost.addFolder":"sidebar.addWorkspaceRegister")})]})]})})}function que({message:e,tone:t,subtitle:n,onClose:s}){const{t:r}=Ct();return a.jsx(Wa,{title:r("sidebar.addWorkspaceTitle"),subtitle:n,size:"md",onClose:s,children:a.jsxs("div",{className:"flex flex-col gap-5",children:[a.jsx("p",{role:t,children:e}),a.jsx("div",{className:"flex justify-end gap-2",children:a.jsx(Wt,{type:"button",variant:"outline",onClick:s,children:r("sidebar.addWorkspaceCancel")})})]})})}const tbn=[{target:"mcp",Icon:Wve},{target:"skills",Icon:ox},{target:"extensions",Icon:FG},{target:"settings",Icon:Gve}];function nbn(e){return Object.values(e).some(Boolean)}function sbn({workspace:e,actions:t,overview:n,disabled:s=!1,triggerClassName:r,contentStyle:o,onOpenChange:i,onPointerDownOutside:l,onCloseAutoFocus:c}){const{t:u}=Ct(),h=d.useRef(!1),f=d.useRef(i);if(f.current=i,d.useEffect(()=>()=>{h.current&&f.current?.(!1)},[]),!nbn(t))return null;const m=[],g=[];t.rename&&g.push(a.jsxs(yi,{onSelect:t.rename,children:[a.jsx(vw,{}),u("sidebar.renameWorkspace")]},"rename")),t.copyPath&&g.push(a.jsxs(yi,{onSelect:t.copyPath,children:[a.jsx(ib,{}),u("sidebar.copyWorkspacePath")]},"copy")),t.openFolder&&g.push(a.jsxs(yi,{onSelect:t.openFolder,children:[a.jsx($T,{}),u("sidebar.openWorkspaceFolder")]},"open-folder")),t.openTerminal&&g.push(a.jsxs(yi,{onSelect:t.openTerminal,children:[a.jsx(xqe,{}),u("sidebar.openWorkspaceTerminal")]},"open-terminal")),t.newSession&&g.push(a.jsxs(yi,{onSelect:t.newSession,children:[a.jsx(t9,{}),u("sidebar.newTask")]},"new")),t.newWorktreeSession&&g.push(a.jsxs(yi,{onSelect:t.newWorktreeSession,children:[a.jsx(OE,{}),u("sidebar.newWorktreeTask")]},"worktree")),g.length>0&&m.push(g);const w=t.openManagement;return w&&m.push([a.jsx(o4e,{children:u("sidebar.manageWorkspace")},"manage-label"),...tbn.map(({target:y,Icon:x})=>{const k=y==="settings"?void 0:mSe(n,y);return a.jsxs(yi,{onSelect:()=>w(y),children:[a.jsx(x,{}),u(`sidebar.overview.${y==="settings"?"settings":y}`),k!==void 0&&a.jsx("span",{className:"text-muted-foreground ml-auto pl-3 text-xs tabular-nums",children:k})]},y)})]),t.reload&&m.push([a.jsxs(yi,{onSelect:t.reload,children:[a.jsx(Hg,{}),u("sidebar.reloadWorkspace")]},"reload")]),t.remove&&m.push([a.jsxs(yi,{variant:"destructive","aria-label":`${u("sidebar.removeWorkspace")}: ${e.cwd}`,onSelect:t.remove,children:[a.jsx(_m,{}),u("sidebar.removeWorkspace")]},"remove")]),a.jsxs(Z0,{onOpenChange:y=>{h.current=y,i?.(y)},children:[a.jsx(Vg,{asChild:!0,children:a.jsx("button",{className:r,type:"button","aria-label":u("sidebar.workspaceActions"),title:u("sidebar.workspaceActions"),disabled:s,children:a.jsx(yS,{size:16,strokeWidth:1.2})})}),a.jsx(Gg,{align:"end",className:"w-auto min-w-40",style:o,onPointerDownOutside:l,onCloseAutoFocus:c,children:m.map((y,x)=>a.jsxs($x,{children:[x>0&&a.jsx(ax,{}),y]},x))})]})}const rbn=256,obn=/[\u0000-\u001f\u007f]/;function ibn(e){return!obn.test(e)}function abn({workspace:e,busy:t,onSubmit:n,onClose:s}){const{t:r}=Ct(),[o,i]=d.useState(e.displayName??""),l=o.trim(),c=l===(e.displayName?.trim()??""),u=!ibn(l);return a.jsx(Wa,{title:r("sidebar.renameWorkspaceTitle"),subtitle:e.cwd,size:"sm",onClose:()=>{t||s()},children:a.jsxs("form",{className:_t.confirmContent,onSubmit:h=>{h.preventDefault(),!(t||c||u)&&n(l===""?null:l)},children:[a.jsx(cx,{children:a.jsxs(vl,{children:[a.jsx(lc,{htmlFor:"workspace-display-name",children:r("sidebar.workspaceNamePrompt")}),a.jsx(hi,{id:"workspace-display-name",value:o,autoFocus:!0,maxLength:rbn,placeholder:tX(e.cwd),disabled:t,onChange:h=>i(h.target.value)})]})}),a.jsx("p",{className:_t.confirmDescription,role:u?"alert":void 0,children:r(u?"sidebar.workspaceNameInvalid":"sidebar.workspaceNameHint")}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Wt,{type:"button",variant:"outline",disabled:t,onClick:s,children:r("common.cancel")}),a.jsx(Wt,{type:"submit",disabled:t||c||u,children:r("common.save")})]})]})})}const iz=50;function Vue(e){return e.displayName?.trim()||e.sessionId.slice(0,8)}function az(e){return e.filter(t=>!t.parentSessionId)}function Gue(e,t){const n=new Set(e.map(s=>s.sessionId));return[...e,...t.filter(s=>!n.has(s.sessionId))]}function lbn(e){const t=URL.createObjectURL(new Blob([e.content],{type:e.mimeType||"text/html"}));try{const n=document.createElement("a");n.href=t,n.download=e.filename,document.body.appendChild(n),n.click(),n.remove()}finally{URL.revokeObjectURL(t)}}function Kue({archiveState:e,currentSessionId:t,currentSessionReady:n=!1,refreshKey:s,searchQuery:r="",onNewSession:o,renderSession:i,onLoadSession:l,onRenameSession:c,onMutated:u,onStatusChange:h,onError:f,onNotice:m}){const g=fi(),w=el(),y=m4(),x=d.useRef(y),k=d.useRef(0),_=d.useRef(!1),S=d.useRef(s),I=d.useRef(void 0),E=d.useRef(0),A=d.useRef(void 0),{t:j}=Ct(),[L,R]=d.useState([]),N=d.useRef(L);N.current=L;const[M,O]=d.useState(),[P,F]=d.useState(!0),[H,$]=d.useState(!1),[Y,Z]=d.useState(!1),[K,B]=d.useState(!1),[V,J]=d.useState(),[q,te]=d.useState(),[ie,ge]=d.useState(),[re,G]=d.useState(),[Q,he]=d.useState(""),[ve,ye]=d.useState(),_e=g.capabilities?.features?.includes(nw)===!0,ae=d.useCallback(async(W=!1)=>{if(!_e)return;const ne=k.current+1;k.current=ne,B(!1),Z(!0);try{const me=W?N.current.length:0;let Me=await g.client.listStandaloneSessionsPage({archiveState:e,pageSize:iz});if(k.current!==ne)return;let Ke=az(Me.sessions);for(;Me.nextCursor&&Ke.length<me;){if(Me=await g.client.listStandaloneSessionsPage({archiveState:e,cursor:Me.nextCursor,pageSize:iz}),k.current!==ne)return;Ke=Gue(Ke,az(Me.sessions))}_.current=!0,R(Ke),O(Me.nextCursor),J(void 0)}catch(me){if(k.current!==ne)return;console.warn("[web-shell] standalone session list failed:",me),J({})}finally{k.current===ne&&Z(!1)}},[e,_e,g.client]);d.useEffect(()=>{ge(W=>W?.kind==="open"?void 0:W),A.current!==t&&++E.current},[t]),d.useEffect(()=>{n&&ge(W=>W?.kind==="open"&&W.sessionId===t?void 0:W)},[t,n]),d.useEffect(()=>{const W=S.current!==s;S.current=s,(!_.current||W)&&ae(!0)},[ae,s]),d.useEffect(()=>{const W=x.current;x.current=y,e==="active"&&w.sessionContext?.kind==="standalone"&&W!=="idle"&&y==="idle"&&ae(!0)},[e,w.sessionContext?.kind,ae,y]),d.useEffect(()=>{h?.({count:L.length,loading:Y,error:!!V})},[V,Y,h,L.length]),d.useEffect(()=>{P||$(!1)},[P]);const Se=d.useCallback(async()=>{if(!M||K)return;const W=k.current;B(!0);try{const ne=await g.client.listStandaloneSessionsPage({archiveState:e,cursor:M,pageSize:iz});if(k.current!==W)return;R(me=>Gue(me,az(ne.sessions))),O(ne.nextCursor),J(void 0)}catch(ne){k.current===W&&(console.warn("[web-shell] standalone session page failed:",ne),J({cursor:M}))}finally{k.current===W&&B(!1)}},[e,M,K,g.client]),Te=d.useCallback(async(W,ne)=>{if(I.current)return!1;I.current=W,te(W),ge(void 0);try{return await ne(),!0}catch(me){return L8(O0(me))?(console.warn("[web-shell] standalone session action blocked by writer fence:",me),G(Me=>Me?.sessionId===W?void 0:Me),ye(Me=>Me?.sessionId===W?void 0:Me),ge({sessionId:W,kind:"action",messageKey:"session.writerBlocked",retry:()=>{Te(W,ne)}})):f(me,j("sidebar.standaloneActionFailed")),!1}finally{I.current=void 0,te(void 0)}},[f,j]),Ne=d.useCallback(W=>{R(ne=>ne.filter(me=>me.sessionId!==W)),u?.()},[u]),Ae=d.useCallback(async W=>{await Te(W.sessionId,async()=>{const ne=await g.client.archiveStandaloneSessions([W.sessionId]);if(ne.archived.includes(W.sessionId)||ne.alreadyArchived.includes(W.sessionId)||ne.notFound?.includes(W.sessionId)){Ne(W.sessionId);return}const me=ne.errors.find(Me=>Me.sessionId===W.sessionId);throw Object.assign(new Error(me?.message??j("sidebar.standaloneActionFailed")),{body:me})})},[Ne,Te,j,g.client]),Ve=d.useCallback(async W=>{await Te(W.sessionId,async()=>{const ne=await g.client.unarchiveStandaloneSessions([W.sessionId]);if(ne.unarchived.includes(W.sessionId)||ne.alreadyActive.includes(W.sessionId)||ne.notFound?.includes(W.sessionId)){Ne(W.sessionId);return}const me=ne.errors.find(Me=>Me.sessionId===W.sessionId);throw Object.assign(new Error(me?.message??j("sidebar.standaloneActionFailed")),{body:me})})},[Ne,Te,j,g.client]),Ze=d.useCallback(async W=>await Te(W.sessionId,async()=>{const me=await g.client.deleteStandaloneSessions([W.sessionId]);if(!me.removed.includes(W.sessionId)&&!me.notFound.includes(W.sessionId)){const Me=me.errors.find(Ke=>Ke.sessionId===W.sessionId);throw Object.assign(new Error(Me?.message??j("sidebar.standaloneActionFailed")),{body:Me})}me.fileCleanupPending.includes(W.sessionId)&&m(j("sidebar.standaloneCleanupPending")),Ne(W.sessionId)}),[m,Ne,Te,j,g.client]),Tt=d.useCallback(async W=>{const ne=++E.current;A.current=W,ge(void 0);try{await l(W)}catch(me){if(ne!==E.current||L8(O0(me)))return;console.warn("[web-shell] standalone session load failed:",me),ge({sessionId:W,kind:"open",messageKey:"session.loadFailed",retry:()=>{Tt(W)}})}},[l]);if(!_e||e==="archived"&&!V&&!ie&&!Y&&L.length===0&&!M)return null;const je=r.trim().toLowerCase(),ot=je?L.filter(W=>Vue(W).toLowerCase().includes(je)||W.sessionId.toLowerCase().includes(je)):L,Ie=!je&&!H&&ot.length>fx,ue=Ie?ot.slice(0,fx):ot;return a.jsxs(a.Fragment,{children:[a.jsxs("section",{className:`${ac.section} mb-3`,"aria-label":e==="active"?j("sidebar.noWorkspaceSessions"):`${j("sidebar.archivedTitle")}: ${j("sidebar.noWorkspaceSessions")}`,"data-testid":`standalone-${e}-group`,children:[a.jsxs("div",{className:`${ac.headerRow} group`,children:[a.jsxs("button",{type:"button",className:ac.header,"aria-expanded":P,onClick:W=>{F(ne=>!ne),W.detail>0&&W.currentTarget.blur()},children:[a.jsx(Ave,{className:ac.folderIcon,size:14,strokeWidth:1.4,"aria-hidden":"true"}),a.jsx("span",{className:ac.headerContent,children:a.jsx("span",{className:ac.name,children:j("sidebar.noWorkspaceSessions")})})]}),e==="active"&&o&&a.jsx("div",{className:`${_t.workspaceHeaderActions} invisible group-hover:visible group-focus-within:visible`,children:a.jsx("button",{className:_t.workspaceHeaderAction,type:"button",title:j("sidebar.newTask"),"aria-label":j("sidebar.newTask"),onClick:o,children:a.jsx(t9,{size:16,strokeWidth:1.2})})})]}),ie&&a.jsxs("div",{role:"alert",className:"px-2 py-1 text-xs text-muted-foreground",children:[a.jsxs("span",{children:[ie.sessionId.slice(0,8),": ",j(ie.messageKey)]}),a.jsx(Wt,{variant:"ghost",size:"sm",disabled:!!q,onClick:ie.retry,children:j("common.retry")})]}),V&&a.jsxs("div",{role:"alert",className:"px-2 py-1 text-xs text-muted-foreground",children:[j("sidebar.standaloneLoadFailed"),a.jsx(Wt,{variant:"ghost",size:"sm",disabled:Y||K,onClick:()=>{V.cursor?Se():ae(!0)},children:j("common.retry")})]}),(P||!!je)&&a.jsxs("div",{className:"flex flex-col gap-0.5",children:[ue.map(W=>{const ne=W.sessionId===t;return i(W,{active:ne,busy:q===W.sessionId,isArchived:e==="archived",onOpen:()=>void Tt(W.sessionId),onRename:()=>{G(W),he(Vue(W))},onExport:()=>{Te(W.sessionId,async()=>{lbn(await g.client.exportStandaloneSession(W.sessionId,{format:"html"}))})},onArchive:e==="active"?()=>void Ae(W):void 0,onUnarchive:e==="archived"?()=>void Ve(W):void 0,onDelete:()=>ye(W)})}),!Y&&!V&&ot.length===0&&a.jsx("div",{className:ac.empty,children:j(e==="active"?"sidebar.noSessions":"sidebar.archivedEmpty")}),Ie&&a.jsx("button",{type:"button",className:_t.showAllSessions,onClick:()=>$(!0),children:j("sidebar.showAllSessions")}),M&&!Ie&&a.jsx(Wt,{type:"button",variant:"ghost",size:"sm",className:"w-full",disabled:K,onClick:()=>void Se(),children:j("sidebar.showAllSessions")})]})]}),re&&a.jsx(Wa,{title:j("sidebar.rename"),size:"sm",onClose:()=>G(void 0),children:a.jsxs("form",{className:"flex flex-col gap-4",onSubmit:W=>{W.preventDefault();const ne=Q.trim();ne&&Te(re.sessionId,async()=>{await g.client.renameStandaloneSession(re.sessionId,ne),R(me=>me.map(Me=>Me.sessionId===re.sessionId?{...Me,displayName:ne}:Me)),c?.(re.sessionId,ne)}).then(me=>{me&&G(void 0)})},children:[a.jsx(hi,{autoFocus:!0,value:Q,onChange:W=>he(W.target.value)}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Wt,{type:"button",variant:"outline",onClick:()=>G(void 0),children:j("common.cancel")}),a.jsx(Wt,{type:"submit",disabled:!Q.trim(),children:j("common.save")})]})]})}),ve&&a.jsx(Wa,{title:j("sidebar.delete"),size:"sm",onClose:()=>ye(void 0),children:a.jsxs("div",{className:"flex flex-col gap-4",children:[a.jsx("p",{className:"text-sm text-muted-foreground",children:j("sidebar.standaloneDeleteConfirm")}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Wt,{type:"button",variant:"outline",onClick:()=>ye(void 0),children:j("common.cancel")}),a.jsx(Wt,{type:"button",variant:"destructive",onClick:()=>{Ze(ve).then(W=>{W&&ye(void 0)})},children:j("sidebar.delete")})]})]})})]})}class Tc extends Error{constructor(t,n){super(n),this.code=t,this.name="LocalDirectoryError"}}const cbn={maxListEntries:500,maxReadBytes:1e6,maxWriteBytes:1e7,maxSearchFiles:2e3,maxSearchBytes:2e7,maxSearchHits:200,maxSearchDirs:1e4},Yue=400;function Xue(e){return e?.kind==="directory"}function Zue(e){return e?.kind==="file"}function hM(e){if(typeof e!="string")throw new Tc("invalid_path","`path` must be a string.");const t=e;if(t===""||t===".")return[];if(t.includes("\\"))throw new Tc("invalid_path","Backslashes are not allowed; use forward slashes.");if(t.startsWith("/"))throw new Tc("invalid_path","Absolute paths are not allowed; paths are relative to the granted directory.");if(/^[a-zA-Z]:[\\/]/.test(t))throw new Tc("invalid_path","Windows drive paths are not allowed; paths are relative to the granted directory.");const n=[];for(const s of t.split("/"))if(!(s===""||s===".")){if(s==="..")throw new Tc("invalid_path","`..` is not allowed; paths must stay inside the granted directory.");if(/[\u0000-\u001f]/.test(s))throw new Tc("invalid_path","C0 control characters (U+0000-U+001F) are not allowed in a path.");n.push(s)}return n}function B3(e,t){if(e instanceof Tc)return e;const n=e?.name,s=e instanceof Error?e.message:String(e);return n==="NotFoundError"?new Tc("not_found",`No such file or directory: ${t}`):n==="NotAllowedError"||n==="SecurityError"?new Tc("permission_denied",`Permission denied for ${t} (${s}). The directory grant may have been revoked; reconnect it.`):n==="TypeMismatchError"?new Tc("not_a_directory",`Not a directory: ${t}`):new Tc("failed",`${t}: ${s}`)}function Jue(e,t){return e?.name==="TypeMismatchError"?new Tc("not_a_file",`${t} is a directory, not a file.`):B3(e,t)}class ubn{constructor(t,n=cbn){this.root=t,this.limits=n}get name(){return this.root.name}async resolveDirectory(t,n,s){let r=this.root;for(const o of t)try{r=await r.getDirectoryHandle(o,{create:s})}catch(i){throw B3(i,n)}return r}async list(t,n){const s=hM(t),r=await this.resolveDirectory(s,t,!1),o=typeof n=="number"&&Number.isFinite(n)&&n>0?Math.max(1,Math.trunc(n)):this.limits.maxListEntries,i=Math.min(o,this.limits.maxListEntries),l=[];let c=!1;try{for await(const u of r.values()){if(l.length>=i){c=!0;break}if(Xue(u))l.push({name:u.name,path:lz(s,u.name),kind:"directory"});else if(Zue(u)){const h=lz(s,u.name);try{const f=await u.getFile();l.push({name:u.name,path:h,kind:"file",size:f.size,lastModified:f.lastModified})}catch{l.push({name:u.name,path:h,kind:"file"})}}}}catch(u){throw B3(u,t)}return l.sort((u,h)=>u.path<h.path?-1:u.path>h.path?1:0),{entries:l,truncated:c,limit:i}}async read(t,n=0,s){const r=hM(t);if(r.length===0)throw new Tc("invalid_path","`path` must name a file.");const o=r[r.length-1],i=await this.resolveDirectory(r.slice(0,-1),Que(t),!1);let l;try{l=await(await i.getFileHandle(o)).getFile()}catch(g){throw Jue(g,t)}if(l.size>this.limits.maxReadBytes)throw new Tc("too_large",`${t} is ${l.size} bytes, over the ${this.limits.maxReadBytes}-byte read limit. Narrow the request or handle this file another way.`);let c;try{c=new TextDecoder("utf-8",{fatal:!0}).decode(await l.arrayBuffer())}catch(g){throw g instanceof TypeError?new Tc("binary_content",`${t} is not valid UTF-8 text; it cannot be returned as text.`):B3(g,t)}if(c.includes("\0"))throw new Tc("binary_content",`${t} looks like a binary file (NUL byte); it cannot be returned as text.`);const u=c.split(`
2234
2234
  `),h=Math.max(0,Math.trunc(n)||0),f=s===void 0||!Number.isFinite(s)||s<=0?u.length:Math.max(1,Math.trunc(s)),m=u.slice(h,h+f);return{path:t,content:m.join(`
2235
2235
  `),totalLines:u.length,returnedLines:m.length,truncated:h+m.length<u.length}}async write(t,n){const s=hM(t);if(s.length===0)throw new Tc("invalid_path","`path` must name a file.");if(typeof n!="string")throw new Tc("invalid_path","`content` must be a string.");const r=new TextEncoder().encode(n);if(new TextDecoder("utf-8",{fatal:!0}).decode(r)!==n)throw new Tc("invalid_path",`${t} content contains unpaired surrogates; it cannot be written as UTF-8 text.`);const o=r.length;if(o>this.limits.maxWriteBytes)throw new Tc("too_large",`${t} would write ${o} bytes, over the ${this.limits.maxWriteBytes}-byte write limit.`);const i=s[s.length-1],l=await this.resolveDirectory(s.slice(0,-1),Que(t),!0);let c=!0;try{await l.getFileHandle(i),c=!1}catch{}let u;try{return u=await(await l.getFileHandle(i,{create:!0})).createWritable(),await u.write(n),await u.close(),u=void 0,{path:t,bytes:o,created:c}}catch(h){throw Jue(h,t)}finally{await u?.close().catch(()=>{})}}async search(t,n={}){if(typeof t!="string"||t==="")throw new Tc("invalid_path","`pattern` must be a non-empty string.");if(t.includes(`
2236
2236
  `)||t.includes("\0"))throw new Tc("invalid_path","Multi-line or NUL-bearing patterns are not supported: search matches one line at a time and never opens binary files.");const s=hM(n.path??""),r=await this.resolveDirectory(s,n.path??"",!1),o=Math.min(n.maxFiles??this.limits.maxSearchFiles,this.limits.maxSearchFiles),i=Math.min(n.maxBytes??this.limits.maxSearchBytes,this.limits.maxSearchBytes),l=[];let c=0,u=0,h=0,f=0,m=0,g=null;const w=[{dir:r,prefix:s}];try{for(;w.length>0&&g===null;){const{dir:y,prefix:x}=w.shift();for await(const k of y.values()){if(g!==null)break;if(Xue(k)){if(h>=this.limits.maxSearchDirs){g="directories";break}h+=1,w.push({dir:k,prefix:[...x,k.name]});continue}if(!Zue(k))continue;if(u>=o){g="files";break}const _=lz(x,k.name);u+=1;let S;try{S=await k.getFile()}catch{m+=1;continue}if(S.size>this.limits.maxReadBytes){m+=1;continue}if(f+S.size>i){g="bytes";break}f+=S.size;let I;try{I=new TextDecoder("utf-8",{fatal:!0}).decode(await S.arrayBuffer())}catch{m+=1;continue}if(I.includes("\0")){m+=1;continue}c+=1;const E=I.split(`