@hostclubeos/miraos 0.0.4-beta → 0.0.6-beta

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 (113) hide show
  1. package/bundled/bug-hunter/SKILL.md +7 -0
  2. package/chunks/{acpAgent-F4OT4AQQ.js → acpAgent-OGBFWA5R.js} +2 -2
  3. package/chunks/{chunk-BX3KM7OK.js → chunk-2PB6TEZU.js} +1 -1
  4. package/chunks/{chunk-7LXU4NUI.js → chunk-34YXJ3CX.js} +1 -1
  5. package/chunks/{chunk-WDLXS4A3.js → chunk-3GA3NTAV.js} +3 -3
  6. package/chunks/{chunk-4TJKJ2LG.js → chunk-5JKJSIIP.js} +1 -1
  7. package/chunks/{chunk-FUIRLSNA.js → chunk-7JT2V4AW.js} +1 -1
  8. package/chunks/{chunk-C24YTZET.js → chunk-BB2C4HKQ.js} +1 -1
  9. package/chunks/{chunk-AXBNQS6C.js → chunk-F2XELUO3.js} +1 -1
  10. package/chunks/{chunk-BZMSTSKY.js → chunk-GPI53DWB.js} +1 -1
  11. package/chunks/{chunk-AYU4PDSQ.js → chunk-HHSHBOT7.js} +2 -2
  12. package/chunks/{chunk-TIWH3MUJ.js → chunk-HMID4D72.js} +1 -1
  13. package/chunks/{chunk-JM46SKXF.js → chunk-IC2WDA6V.js} +1 -1
  14. package/chunks/{chunk-HPGUQCRQ.js → chunk-JRPR5IME.js} +1 -1
  15. package/chunks/{chunk-ECNTMKHI.js → chunk-ORVQPZMQ.js} +1 -1
  16. package/chunks/{chunk-5SJFYZQJ.js → chunk-RGVXNWZA.js} +1 -1
  17. package/chunks/{chunk-LISKSG7B.js → chunk-SHLTP6ZB.js} +1 -1
  18. package/chunks/{chunk-D3QZNIFB.js → chunk-SOCXRMZM.js} +4 -4
  19. package/chunks/{chunk-PUPIORBU.js → chunk-TI7J4HX2.js} +1 -1
  20. package/chunks/{chunk-CKBEAZAV.js → chunk-VGPV5AVJ.js} +1 -1
  21. package/chunks/{chunk-33G7MOU6.js → chunk-Y3BCVTFB.js} +1 -1
  22. package/chunks/{chunk-4XV2522J.js → chunk-YVORE4W4.js} +1 -1
  23. package/chunks/{daemon-status-provider-NBPLE4JN.js → daemon-status-provider-FCQ4YYAY.js} +1 -1
  24. package/chunks/{fast-path-66F2TWKE.js → fast-path-ZBD7IYQM.js} +1 -1
  25. package/chunks/{llm-LZ3HARC2.js → llm-DQNQEAFW.js} +3 -3
  26. package/chunks/{local-6KBSW7N2.js → local-ZRC4XZCJ.js} +1 -1
  27. package/chunks/{managed-local-serve-2N3IAB3D.js → managed-local-serve-B2KOLPB5.js} +1 -1
  28. package/chunks/{managed-runtime-bootstrap-M4P43K7W.js → managed-runtime-bootstrap-MREL5UC2.js} +1 -1
  29. package/chunks/{managed-runtime-ssh-worker-WWZ7SJ7U.js → managed-runtime-ssh-worker-GUKAZFAJ.js} +1 -1
  30. package/chunks/{memory-D62BXIJW.js → memory-ZYPCFYPF.js} +1 -1
  31. package/chunks/{nonInteractiveCli-Z4A7THMG.js → nonInteractiveCli-JG6PKBAD.js} +1 -1
  32. package/chunks/{review-LM7KW6Y5.js → review-N3VFZQMI.js} +1 -1
  33. package/chunks/{run-qwen-serve-77UZS4JA.js → run-qwen-serve-4MZRQFXK.js} +1 -1
  34. package/chunks/{serve-RHO7RZ45.js → serve-EQN6QAXF.js} +1 -1
  35. package/chunks/{server-5HEOZG3T.js → server-CCEHAI25.js} +1 -1
  36. package/chunks/{session-RT7VH6GE.js → session-HNUJSV5A.js} +1 -1
  37. package/chunks/{start-opentui-ui-I2XXWTJS.js → start-opentui-ui-6MCAEWAW.js} +1 -1
  38. package/chunks/{startInteractiveUI-774LJIJD.js → startInteractiveUI-657JWOTK.js} +1 -1
  39. package/chunks/{validateNonInterActiveAuth-633WYCVH.js → validateNonInterActiveAuth-CP5WFNAE.js} +1 -1
  40. package/chunks/{version-77KBVA2F.js → version-SIM74L5K.js} +1 -1
  41. package/cli.js +1 -1
  42. package/export-transcript-document.js +1 -1
  43. package/package.json +3 -3
  44. package/web-shell/assets/{PierreFilePreview-DEhWK46v.js → PierreFilePreview-Dkt6iPte.js} +1 -1
  45. package/web-shell/assets/SpreadsheetPreview-I4yiL7q3.js +1 -0
  46. package/web-shell/assets/{WorkspaceFileBrowser-64vDYikf.js → WorkspaceFileBrowser-Du9bMpNo.js} +1 -1
  47. package/web-shell/assets/{abnfDiagram-VCTEODGH-C2WWURam.js → abnfDiagram-VCTEODGH-CGY1lCxS.js} +1 -1
  48. package/web-shell/assets/{agents-route-j5ba59xn.js → agents-route-kcQ3YUNc.js} +1 -1
  49. package/web-shell/assets/{arc-Bkr_-GVn.js → arc-BUMNyJDV.js} +1 -1
  50. package/web-shell/assets/{architectureDiagram-5GKGNRK7-D_v_wDDW.js → architectureDiagram-5GKGNRK7-CEfXhEKD.js} +1 -1
  51. package/web-shell/assets/{blockDiagram-NRAW4CY4-Csxc3YNo.js → blockDiagram-NRAW4CY4-BH8hjvlX.js} +1 -1
  52. package/web-shell/assets/{c4Diagram-UCG6FXSJ-PXryoJCB.js → c4Diagram-UCG6FXSJ-Dfl946ex.js} +1 -1
  53. package/web-shell/assets/channel-CoZByzPk.js +1 -0
  54. package/web-shell/assets/{chunk-2Q5K7J3B-DwK5UBHI.js → chunk-2Q5K7J3B-CBvGm-pD.js} +1 -1
  55. package/web-shell/assets/{chunk-5VM5RSS4-BC1hvD6_.js → chunk-5VM5RSS4-k06tGOfl.js} +1 -1
  56. package/web-shell/assets/{chunk-F27PBJKO-iFe0IxfJ.js → chunk-F27PBJKO-Dv4S4vSq.js} +1 -1
  57. package/web-shell/assets/{chunk-G27WJ6UU-ROSuKRxI.js → chunk-G27WJ6UU-7LY0yu3f.js} +1 -1
  58. package/web-shell/assets/{chunk-JWPE2WC7-CYHS6PxA.js → chunk-JWPE2WC7-B-CgVEuJ.js} +1 -1
  59. package/web-shell/assets/{chunk-LCL6LL3I-D5bFMqCy.js → chunk-LCL6LL3I-D0TrWx1f.js} +1 -1
  60. package/web-shell/assets/{chunk-POPQ4Y6H-BJh77MGv.js → chunk-POPQ4Y6H-B97ZANlR.js} +1 -1
  61. package/web-shell/assets/{chunk-SVP7TREG-Cs81aYft.js → chunk-SVP7TREG-2CO_3G76.js} +1 -1
  62. package/web-shell/assets/{chunk-XXDRQBXY-DqDbN44E.js → chunk-XXDRQBXY-CFbSHjzz.js} +1 -1
  63. package/web-shell/assets/classDiagram-DTDB5LWJ-BgKRvG5r.js +1 -0
  64. package/web-shell/assets/classDiagram-v2-JRS7N3AN-BgKRvG5r.js +1 -0
  65. package/web-shell/assets/{cose-bilkent-JH36ORCC-DhjrwADJ.js → cose-bilkent-JH36ORCC-K-uc8eFw.js} +1 -1
  66. package/web-shell/assets/{cynefin-OW5HDTMX-Dh7t-_3M.js → cynefin-OW5HDTMX-Cb0lt2G3.js} +1 -1
  67. package/web-shell/assets/{cynefinDiagram-5FMLGOSQ-5J4kto0C.js → cynefinDiagram-5FMLGOSQ-DWkqpFuH.js} +1 -1
  68. package/web-shell/assets/{dagre-3AP2YEHR-28AdbIcl.js → dagre-3AP2YEHR-Cs8gu3Q4.js} +1 -1
  69. package/web-shell/assets/{diagram-S7CK7UJ4-DmksuoIf.js → diagram-S7CK7UJ4-DlMLXUgK.js} +1 -1
  70. package/web-shell/assets/{diagram-UQ7AKVKN-DUjgQ8Fg.js → diagram-UQ7AKVKN-68PPYL92.js} +1 -1
  71. package/web-shell/assets/{diagram-VSXAHHWV-DUe_FpG-.js → diagram-VSXAHHWV-CxIdRSbx.js} +1 -1
  72. package/web-shell/assets/{diagram-VX7I27RA-CJJ70teK.js → diagram-VX7I27RA-G3C0kWVW.js} +1 -1
  73. package/web-shell/assets/{diagram-Z3DM3KII-BgABlJO4.js → diagram-Z3DM3KII-CwEuAgyS.js} +1 -1
  74. package/web-shell/assets/{docx-preview-BMBWboRx.js → docx-preview-3XzkP9iR.js} +1 -1
  75. package/web-shell/assets/{ebnfDiagram-PWID7BFC-B3nK_Lh7.js → ebnfDiagram-PWID7BFC-DLeMX1Ka.js} +1 -1
  76. package/web-shell/assets/{erDiagram-SSCWMZ5O-DCTdCWlu.js → erDiagram-SSCWMZ5O-CoQLSOGk.js} +1 -1
  77. package/web-shell/assets/{flowDiagram-A5DVABFB-CPxk2UUl.js → flowDiagram-A5DVABFB-BXUV-Qml.js} +1 -1
  78. package/web-shell/assets/{ganttDiagram-EL5Y4UJY-WZzMAKht.js → ganttDiagram-EL5Y4UJY-sWi6Lowi.js} +1 -1
  79. package/web-shell/assets/{gitGraphDiagram-WWUBYQGX-DKcO5ugU.js → gitGraphDiagram-WWUBYQGX-Dsh4-kB4.js} +1 -1
  80. package/web-shell/assets/{index-CkRLMu1y.js → index-CrSq-SfJ.js} +6 -6
  81. package/web-shell/assets/{index-Dbm3-Fps.js → index-DjwWlZt0.js} +1 -1
  82. package/web-shell/assets/{infoDiagram-RXCK75RN-CJX5DzdL.js → infoDiagram-RXCK75RN-JZ6nFIgB.js} +1 -1
  83. package/web-shell/assets/{ishikawaDiagram-5VMMS53U-fF0Id5B6.js → ishikawaDiagram-5VMMS53U-qJj-sQFs.js} +1 -1
  84. package/web-shell/assets/{journeyDiagram-EYS64GPL-BOAezBVe.js → journeyDiagram-EYS64GPL-Ck0jv8SO.js} +1 -1
  85. package/web-shell/assets/{kanban-definition-3QL26DDD-DdNBof9J.js → kanban-definition-3QL26DDD-Ck6_Ydmt.js} +1 -1
  86. package/web-shell/assets/{layout-CXX3l5w0.js → layout-yLaSulE8.js} +1 -1
  87. package/web-shell/assets/{linear-Dnaccp-S.js → linear-CXw5rE6U.js} +1 -1
  88. package/web-shell/assets/{mermaid.core-BzdC3B6T.js → mermaid.core-6WQsyLcq.js} +6 -6
  89. package/web-shell/assets/{mindmap-definition-FBJOCRG2-D-gMUzLw.js → mindmap-definition-FBJOCRG2-BDAmAz8h.js} +1 -1
  90. package/web-shell/assets/{pegDiagram-XKGWAZYB-B9n1WVZq.js → pegDiagram-XKGWAZYB-Rvn5mpol.js} +1 -1
  91. package/web-shell/assets/{pieDiagram-E7YTZNPT-ok49U0zT.js → pieDiagram-E7YTZNPT-DHw4avFL.js} +1 -1
  92. package/web-shell/assets/{quadrantDiagram-AXDQQJYC-DJKha-v3.js → quadrantDiagram-AXDQQJYC-vch6jDK-.js} +1 -1
  93. package/web-shell/assets/{railroadDiagram-O6MQD6OU-DjL4pl7y.js → railroadDiagram-O6MQD6OU-DfVCzYpO.js} +1 -1
  94. package/web-shell/assets/{requirementDiagram-EFPCY7ZU-BpmmRw3A.js → requirementDiagram-EFPCY7ZU-BQAnwpSv.js} +1 -1
  95. package/web-shell/assets/{sankeyDiagram-P5KCCOFB-KpteHB8X.js → sankeyDiagram-P5KCCOFB-fJuxdbbi.js} +1 -1
  96. package/web-shell/assets/{sequenceDiagram-WJ2MYXX4-COMghCpA.js → sequenceDiagram-WJ2MYXX4-B3TtvHJp.js} +1 -1
  97. package/web-shell/assets/{sizeCapture-X5ZJPWSS-5fEwJD-n.js → sizeCapture-X5ZJPWSS-DlJmbcZd.js} +1 -1
  98. package/web-shell/assets/{stateDiagram-HBIQ2CUA-CnC7oXvs.js → stateDiagram-HBIQ2CUA--0kiPvGS.js} +1 -1
  99. package/web-shell/assets/stateDiagram-v2-4QOOHH4V-Dw-ppcvp.js +1 -0
  100. package/web-shell/assets/{swimlanes-XN3QIQJK-bVlhZdve.js → swimlanes-XN3QIQJK-CAytfKbo.js} +1 -1
  101. package/web-shell/assets/swimlanesDiagram-VK2B7HYN-B36XZQuh.js +8 -0
  102. package/web-shell/assets/{timeline-definition-24CTP7MA-CBvYgMu5.js → timeline-definition-24CTP7MA-C-BUmwu6.js} +1 -1
  103. package/web-shell/assets/{vennDiagram-4TSXK5OY-CUTYvV1j.js → vennDiagram-4TSXK5OY-W_dgEGv2.js} +1 -1
  104. package/web-shell/assets/{wardleyDiagram-VM6X3IG4-Djl4gxCB.js → wardleyDiagram-VM6X3IG4-ikAv1QJ9.js} +1 -1
  105. package/web-shell/assets/{xychartDiagram-S5SC5T6Z-BcJZtI2X.js → xychartDiagram-S5SC5T6Z-BmY9Ily6.js} +1 -1
  106. package/web-shell/index.html +1 -1
  107. package/web-shell/sw.js +1 -1
  108. package/web-shell/assets/SpreadsheetPreview-C-GgIuPX.js +0 -1
  109. package/web-shell/assets/channel-6Pj4KPAs.js +0 -1
  110. package/web-shell/assets/classDiagram-DTDB5LWJ-BaTUuuB8.js +0 -1
  111. package/web-shell/assets/classDiagram-v2-JRS7N3AN-BaTUuuB8.js +0 -1
  112. package/web-shell/assets/stateDiagram-v2-4QOOHH4V-V_cfZFBL.js +0 -1
  113. package/web-shell/assets/swimlanesDiagram-VK2B7HYN-25wVg0WL.js +0 -8
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/angular-html-LfdN0zeE.js","assets/html-C2L_23MC.js","assets/javascript-ySlJ1b_l.js","assets/css-BPhBrDlE.js","assets/angular-ts-CKsD7JZE.js","assets/scss-C31hgJw-.js","assets/apl-BBq3IX1j.js","assets/xml-e3z08dGr.js","assets/java-xI-RfyKK.js","assets/json-BQoSv7ci.js","assets/astro-CqkE3fuf.js","assets/typescript-Dj6nwHGl.js","assets/postcss-B3ZDOciz.js","assets/blade-a8OxSdnT.js","assets/sql-COK4E0Yg.js","assets/bsl-Dgyn0ogV.js","assets/sdbl-BLhTXw86.js","assets/cairo--RitsXJZ.js","assets/python-DhUJRlN_.js","assets/cobol-PTqiYgYu.js","assets/coffee-dyiR41kL.js","assets/cpp-BksuvNSY.js","assets/regexp-DWJ3fJO_.js","assets/glsl-DBO2IWDn.js","assets/c-C3t2pwGQ.js","assets/crystal-DtDmRg-F.js","assets/shellscript-atvbtKCR.js","assets/edge-D5gP-w-T.js","assets/html-derivative-CSfWNPLT.js","assets/elixir-CLiX3zqd.js","assets/elm-CmHSxxaM.js","assets/erb-BYTLMnw6.js","assets/ruby-DeZ3UC14.js","assets/haml-B2EZWmdv.js","assets/graphql-cDcHW_If.js","assets/jsx-BAng5TT0.js","assets/tsx-B6W0miNI.js","assets/lua-CvWAzNxB.js","assets/yaml-CVw76BM1.js","assets/fortran-fixed-form-TqA4NnZg.js","assets/fortran-free-form-DKXYxT9g.js","assets/fsharp-XplgxFYe.js","assets/markdown-UIAJJxZW.js","assets/gdresource-BHYsBjWJ.js","assets/gdshader-SKMF96pI.js","assets/gdscript-DfxzS6Rs.js","assets/git-commit-i4q6IMui.js","assets/diff-BgYniUM_.js","assets/git-rebase-B-v9cOL2.js","assets/glimmer-js-D-cwc0-E.js","assets/glimmer-ts-pgjy16dm.js","assets/hack-D1yCygmZ.js","assets/handlebars-BQGss363.js","assets/http-FRrOvY1W.js","assets/hxml-TIA70rKU.js","assets/haxe-C5wWYbrZ.js","assets/imba-bv_oIlVt.js","assets/jinja-DGy0s7-h.js","assets/jison-BqZprYcd.js","assets/julia-BBuGR-5E.js","assets/r-CwjWoCRV.js","assets/latex-C-cWTeAZ.js","assets/tex-rYs2v40G.js","assets/liquid-D3W5UaiH.js","assets/marko-z0MBrx5-.js","assets/less-BfCpw3nA.js","assets/mdc-DB_EDNY_.js","assets/nginx-D_VnBJ67.js","assets/nim-ZlGxZxc3.js","assets/perl-CHQXSrWU.js","assets/php-B5ebYQev.js","assets/pug-CM9l7STV.js","assets/qml-D8XfuvdV.js","assets/razor-CNLDkMZG.js","assets/csharp-D9R-vmeu.js","assets/rst-4NLicBqY.js","assets/cmake-DbXoA79R.js","assets/sas-BmTFh92c.js","assets/shaderlab-B7qAK45m.js","assets/hlsl-ifBTmRxC.js","assets/shellsession-C_rIy8kc.js","assets/soy-C-lX7w71.js","assets/sparql-bYkjHRlG.js","assets/turtle-BMR_PYu6.js","assets/stata-DorPZHa4.js","assets/svelte-MSaWC3Je.js","assets/templ-dwX3ZSMB.js","assets/go-B1SYOhNW.js","assets/ts-tags-CipyTH0X.js","assets/twig-NC5TFiHP.js","assets/vue-BuYVFjOK.js","assets/vue-html-xdeiXROB.js","assets/xsl-Dd0NUgwM.js","assets/agents-route-j5ba59xn.js","assets/agents-route-B7Dp-NvE.css","assets/WorkspaceFileBrowser-64vDYikf.js","assets/WorkspaceFileBrowser-Bgjjk7jz.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/angular-html-LfdN0zeE.js","assets/html-C2L_23MC.js","assets/javascript-ySlJ1b_l.js","assets/css-BPhBrDlE.js","assets/angular-ts-CKsD7JZE.js","assets/scss-C31hgJw-.js","assets/apl-BBq3IX1j.js","assets/xml-e3z08dGr.js","assets/java-xI-RfyKK.js","assets/json-BQoSv7ci.js","assets/astro-CqkE3fuf.js","assets/typescript-Dj6nwHGl.js","assets/postcss-B3ZDOciz.js","assets/blade-a8OxSdnT.js","assets/sql-COK4E0Yg.js","assets/bsl-Dgyn0ogV.js","assets/sdbl-BLhTXw86.js","assets/cairo--RitsXJZ.js","assets/python-DhUJRlN_.js","assets/cobol-PTqiYgYu.js","assets/coffee-dyiR41kL.js","assets/cpp-BksuvNSY.js","assets/regexp-DWJ3fJO_.js","assets/glsl-DBO2IWDn.js","assets/c-C3t2pwGQ.js","assets/crystal-DtDmRg-F.js","assets/shellscript-atvbtKCR.js","assets/edge-D5gP-w-T.js","assets/html-derivative-CSfWNPLT.js","assets/elixir-CLiX3zqd.js","assets/elm-CmHSxxaM.js","assets/erb-BYTLMnw6.js","assets/ruby-DeZ3UC14.js","assets/haml-B2EZWmdv.js","assets/graphql-cDcHW_If.js","assets/jsx-BAng5TT0.js","assets/tsx-B6W0miNI.js","assets/lua-CvWAzNxB.js","assets/yaml-CVw76BM1.js","assets/fortran-fixed-form-TqA4NnZg.js","assets/fortran-free-form-DKXYxT9g.js","assets/fsharp-XplgxFYe.js","assets/markdown-UIAJJxZW.js","assets/gdresource-BHYsBjWJ.js","assets/gdshader-SKMF96pI.js","assets/gdscript-DfxzS6Rs.js","assets/git-commit-i4q6IMui.js","assets/diff-BgYniUM_.js","assets/git-rebase-B-v9cOL2.js","assets/glimmer-js-D-cwc0-E.js","assets/glimmer-ts-pgjy16dm.js","assets/hack-D1yCygmZ.js","assets/handlebars-BQGss363.js","assets/http-FRrOvY1W.js","assets/hxml-TIA70rKU.js","assets/haxe-C5wWYbrZ.js","assets/imba-bv_oIlVt.js","assets/jinja-DGy0s7-h.js","assets/jison-BqZprYcd.js","assets/julia-BBuGR-5E.js","assets/r-CwjWoCRV.js","assets/latex-C-cWTeAZ.js","assets/tex-rYs2v40G.js","assets/liquid-D3W5UaiH.js","assets/marko-z0MBrx5-.js","assets/less-BfCpw3nA.js","assets/mdc-DB_EDNY_.js","assets/nginx-D_VnBJ67.js","assets/nim-ZlGxZxc3.js","assets/perl-CHQXSrWU.js","assets/php-B5ebYQev.js","assets/pug-CM9l7STV.js","assets/qml-D8XfuvdV.js","assets/razor-CNLDkMZG.js","assets/csharp-D9R-vmeu.js","assets/rst-4NLicBqY.js","assets/cmake-DbXoA79R.js","assets/sas-BmTFh92c.js","assets/shaderlab-B7qAK45m.js","assets/hlsl-ifBTmRxC.js","assets/shellsession-C_rIy8kc.js","assets/soy-C-lX7w71.js","assets/sparql-bYkjHRlG.js","assets/turtle-BMR_PYu6.js","assets/stata-DorPZHa4.js","assets/svelte-MSaWC3Je.js","assets/templ-dwX3ZSMB.js","assets/go-B1SYOhNW.js","assets/ts-tags-CipyTH0X.js","assets/twig-NC5TFiHP.js","assets/vue-BuYVFjOK.js","assets/vue-html-xdeiXROB.js","assets/xsl-Dd0NUgwM.js","assets/agents-route-kcQ3YUNc.js","assets/agents-route-B7Dp-NvE.css","assets/WorkspaceFileBrowser-Du9bMpNo.js","assets/WorkspaceFileBrowser-Bgjjk7jz.css"])))=>i.map(i=>d[i]);
2
2
  var Lmt=Object.defineProperty;var Q_e=e=>{throw TypeError(e)};var Omt=(e,t,n)=>t in e?Lmt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ot=(e,t,n)=>Omt(e,typeof t!="symbol"?t+"":t,n),Z_e=(e,t,n)=>t.has(e)||Q_e("Cannot "+n);var xi=(e,t,n)=>(Z_e(e,t,"read from private field"),n?n.call(e):t.get(e)),V0=(e,t,n)=>t.has(e)?Q_e("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),$c=(e,t,n,s)=>(Z_e(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n);var eSe=(e,t,n,s)=>({set _(r){$c(e,t,r,n)},get _(){return xi(e,t,s)}});function Bmt(e,t){for(var n=0;n<t.length;n++){const s=t[n];if(typeof s!="string"&&!Array.isArray(s)){for(const r in s)if(r!=="default"&&!(r in e)){const o=Object.getOwnPropertyDescriptor(s,r);o&&Object.defineProperty(e,r,o.get?o:{enumerable:!0,get:()=>s[r]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&s(i)}).observe(document,{childList:!0,subtree:!0});function n(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerPolicy&&(o.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?o.credentials="include":r.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(r){if(r.ep)return;r.ep=!0;const o=n(r);fetch(r.href,o)}})();var TD=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function UO(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var FOe={exports:{}},iK={};/**
3
3
  * @license React
4
4
  * react-jsx-runtime.production.js
@@ -1913,7 +1913,7 @@ License: MIT
1913
1913
  })();`}function $Yt(e){return`<!doctype html>
1914
1914
  <html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="${LYt}"></head>
1915
1915
  <body><script>${BYt(e)}<\/script></body></html>`}function FYt(){const e=globalThis.crypto;if(!e?.getRandomValues)throw new cs("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 aAe(){return new DOMException("The temporary legacy chart operation was aborted","AbortError")}function zYt(e){if(e.signal.aborted)return Promise.reject(aAe());if(!Number.isSafeInteger(e.timeoutMs)||e.timeoutMs<=0)return Promise.reject(new cs("SCHEMA_INVALID","Legacy sandbox timeout must be a positive safe integer"));if(e.maxNodes!==void 0&&(!Number.isSafeInteger(e.maxNodes)||e.maxNodes<=0))return Promise.reject(new cs("SCHEMA_INVALID","Legacy sandbox maxNodes must be a positive safe integer"));if(typeof document>"u"||!document.body)return Promise.reject(new cs("LEGACY_SANDBOX_UNAVAILABLE","The temporary legacy sandbox requires a browser document body"));const t=FYt(),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=$Yt(t),new Promise((s,r)=>{const o=new MessageChannel,i=o.port1,l=o.port2;let c=!1,d=!1,h;const f=()=>{i.onmessage=null,i.onmessageerror=null;try{i.close()}catch{}try{l.close()}catch{}e.signal.removeEventListener("abort",g),n.onload=null,n.onerror=null,h!==void 0&&clearTimeout(h),n.remove()},p=(y,w)=>{c||(c=!0,f(),y(w))},m=y=>{c||(c=!0,f(),r(y))},g=()=>m(aAe()),v=y=>{if(Ta(y.data)&&!(y.data.channel!==Cce||y.data.requestId!==t)){if(y.data.type==="error"){m(new cs("LEGACY_SANDBOX_EXECUTION_FAILED","Temporary legacy chart source failed in the isolated worker"));return}if(y.data.type==="result")try{const w=w0e(y.data.option,e.maxNodes===void 0?{}:{maxNodes:e.maxNodes});if(!Ta(w))throw new cs("SCHEMA_INVALID","Temporary legacy chart source must produce a JSON object option");p(s,w)}catch(w){m(w)}}};i.onmessage=v,i.onmessageerror=()=>m(new cs("LEGACY_SANDBOX_EXECUTION_FAILED","Temporary legacy chart sandbox returned an unreadable response")),e.signal.addEventListener("abort",g,{once:!0}),n.onerror=()=>m(new cs("LEGACY_SANDBOX_EXECUTION_FAILED","Temporary legacy chart sandbox failed to load")),n.onload=()=>{if(!d){if(d=!0,n.onload=null,c||e.signal.aborted){g();return}try{n.contentWindow?.postMessage({channel:Cce,type:"execute",requestId:t,source:e.source,inputData:e.inputData},"*",[l])}catch{m(new cs("LEGACY_SANDBOX_EXECUTION_FAILED","Temporary legacy chart sandbox failed to initialize"))}}},h=setTimeout(()=>m(new cs("LEGACY_SANDBOX_TIMEOUT",`Temporary legacy chart sandbox exceeded ${e.timeoutMs}ms`)),e.timeoutMs),document.body.append(n)})}var nJe=class extends Error{constructor(t,n,s){super(n,s&&"cause"in s?{cause:s.cause}:void 0);ot(this,"code");ot(this,"cause");this.name="LegacySandboxError",this.code=t,this.cause=s?.cause}},UYt=Object.freeze({maxArtifactContentBytes:64*1024*1024,maxRows:1e5,maxColumns:200,maxCells:1e6,executionTimeoutMs:5e3});function WYt(e,t){const n={...UYt,...e,...t};for(const[s,r]of Object.entries(n))if(!Number.isSafeInteger(r)||r<=0)throw new cs("SCHEMA_INVALID",`legacyArtifactLimits.${s} must be a positive safe integer`);return n}async function sJe(e){let t;try{t=await e.resolveContent()}catch(o){throw e.signal.aborted||e.preserveLegacySandboxError&&o instanceof nJe?o:new cs("REF_RESOLUTION_FAILED",e.resolutionError,{cause:o})}if(typeof t!="string")throw new cs("SCHEMA_INVALID",e.returnTypeError);if(e.signal.aborted)throw new DOMException("The temporary legacy chart operation was aborted","AbortError");const n=NYt(t,e.limits),s=DYt(e.source);if(!s)throw new cs("SCHEMA_INVALID","Temporary legacy chart source is empty after sanitization");const r=await zYt({source:s,inputData:n.source,signal:e.signal,timeoutMs:e.limits.executionTimeoutMs,...e.maxNodes===void 0?{}:{maxNodes:e.maxNodes}});return{data:n,spec:r}}async function HYt(e){return sJe({source:e.block.source,signal:e.signal,limits:e.limits,...e.maxNodes===void 0?{}:{maxNodes:e.maxNodes},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 qYt(e){return sJe({source:e.block.source,signal:e.signal,limits:e.limits,...e.maxNodes===void 0?{}:{maxNodes:e.maxNodes},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 VYt=Object.freeze({maxRows:1e5,maxCells:1e6,maxSeries:100,maxDepth:40,maxNodes:12e5}),GYt=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"]),KYt=new Set(["__proto__","prototype","constructor","extracsstext","renderitem","graphic","image","toolbox","dataview","transform","link","sublink","href","src","url"]),YYt=/(?:url|uri|href|src|link)$/i,JYt=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/,lAe=/(?:^|[\s("'=])(?:https?:|file:|ftp:|blob:|data:|javascript:|vbscript:|\/\/|image:\/\/)/i,XYt=/\burl\s*\(/i,QYt=/<\s*\/?\s*[a-z][^>]*>/i,ZYt=/&(?:#\d+|#x[\da-f]+|[a-z][\da-z]+);/i,eJt=/^[A-Za-z_][A-Za-z0-9_]*$/;function ua(e){throw new cs("SCHEMA_INVALID",e)}function tV(e,t,n){for(const s of Object.keys(e))t.has(s)||ua(`${n}.${s} is not allowed`)}function cAe(e,t){if(!Array.isArray(e)||e.length===0)return ua(`${t} must be a non-empty array`);const n=e.map((s,r)=>typeof s!="string"||!eJt.test(s)?ua(`${t}[${r}] must be a stable ASCII identifier`):s);return new Set(n).size!==n.length?ua(`${t} must not contain duplicate dimensions`):n}function tJt(e,t){if(!Ta(e)||typeof e.kind!="string")return ua("echarts-fulldata.data must be an inline or ref dataset object");if(e.kind==="inline"){tV(e,new Set(["kind","dimensions","source"]),"echarts-fulldata.data");const n=cAe(e.dimensions,"echarts-fulldata.data.dimensions");if(!Array.isArray(e.source))return ua("echarts-fulldata.data.source must be an array");e.source.forEach((r,o)=>{Array.isArray(r)||ua(`echarts-fulldata.data.source[${o}] must be an array`),r.length!==n.length&&ua(`echarts-fulldata.data.source[${o}] must contain ${n.length} cells`)});const s=eve(e.source,t,"echarts-fulldata.data.source");return{kind:"inline",dimensions:n,source:s}}if(e.kind==="ref"){if(tV(e,new Set(["kind","ref","format","dimensions"]),"echarts-fulldata.data"),typeof e.ref!="string"||e.ref.trim().length===0)return ua("echarts-fulldata.data.ref must be a non-empty string");if(e.format!=="csv"&&e.format!=="json")return ua("echarts-fulldata.data.format must be csv or json");const n=cAe(e.dimensions,"echarts-fulldata.data.dimensions");return{kind:"ref",ref:e.ref,format:e.format,dimensions:n}}return ua(`Unsupported echarts-fulldata.data.kind: ${e.kind}`)}function rJe(e){const t=Array.isArray(e.title),n=t?e.title:[e.title];for(const[s,r]of n.entries()){if(!Ta(r)||typeof r.text!="string")continue;const o=r.text.trim();if(o)return{index:s,isArray:t,title:r,text:o}}}function nJt(e){return rJe(e)?.text}function sJt(e,t){const n=rJe(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 Tk(e){return Array.isArray(e)?e.map(t=>Tk(t)):Ta(e)?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Tk(n)])):e}function rJt(e,t){if(e!==void 0)return(!Array.isArray(e)||e.some(n=>typeof n!="string"||n.length===0))&&ua(`${t} must be an array of non-empty strings`),[...e]}function eve(e,t,n){if(Array.isArray(e)||ua(`${n} must be an array`),e.length>t.maxRows)throw new cs("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,d)=>(c!==null&&!["string","number","boolean"].includes(typeof c)&&ua(`${n}[${i}][${d}] must be a JSON scalar`),c));return s+=l.length,l}if(Ta(o)){const l={};for(const[c,d]of Object.entries(o))d!==null&&!["string","number","boolean"].includes(typeof d)&&ua(`${n}[${i}].${c} must be a JSON scalar`),l[c]=d,s+=1;return l}return ua(`${n}[${i}] must be an array or object`)});if(s>t.maxCells)throw new cs("LIMIT_EXCEEDED",`${n} exceeds the ${t.maxCells} cell limit`);return r}function oJt(e,t){return y0e(e,{maxRows:t.maxRows,maxCells:t.maxCells})}function Tce(e,t){if(JYt.test(e))throw new cs("UNSAFE_SPEC",`${t} contains an ASCII control character`);const n=e.replace(/[\n\r\t]/g,""),s=e.trim();if(lAe.test(s)||lAe.test(n.trim())||XYt.test(e)||QYt.test(e)||ZYt.test(e))throw new cs("UNSAFE_SPEC",`${t} contains a URL, CSS URL, or unsafe markup`)}function iJt(e,t){for(const r of Object.keys(e))if(!GYt.has(r))throw new cs("UNSAFE_SPEC",`echarts.option.${r} is not allowed`);let n=0;const s=(r,o,i)=>{if(n+=1,n>t.maxNodes)throw new cs("LIMIT_EXCEEDED",`ECharts option exceeds the ${t.maxNodes} node limit`);if(i>t.maxDepth)throw new cs("LIMIT_EXCEEDED",`ECharts option exceeds the ${t.maxDepth} depth limit`);if(typeof r=="string"){Tce(r,o);return}if(Array.isArray(r)){r.forEach((l,c)=>s(l,`${o}[${c}]`,i+1));return}if(Ta(r))for(const[l,c]of Object.entries(r)){const d=l.toLowerCase();if(d==="formatter"){if(typeof c!="string")throw new cs("UNSAFE_SPEC",`${o}.${l} must be a string`);Tce(c,`${o}.${l}`);continue}if(KYt.has(d)||YYt.test(l))throw new cs("UNSAFE_SPEC",`${o}.${l} is not allowed`);if(l==="type"&&c==="waterfall"&&/^echarts\.option\.series(?:\[\d+\])?$/.test(o)&&ua("ECharts has no native waterfall series; use stacked bar series with a transparent base and stackStrategy: all"),l==="type"&&c==="custom")throw new cs("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 cs("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)=>{Ta(o)||ua(`echarts.option.dataset[${i}] must be an object`),o.source!==void 0&&eve(o.source,t,`echarts.option.dataset[${i}].source`)})}function TL(e,t,n){if(!Ta(e))return ua("ECharts specification must be an object");if(Object.prototype.hasOwnProperty.call(e,"option")||Object.prototype.hasOwnProperty.call(e,"data"))return ua("Canonical markdown-chart data must be a sibling of spec; spec must contain the ECharts option directly");const s=Tk(e),r=t;return r&&Object.prototype.hasOwnProperty.call(s,"dataset")?ua("echarts.option.dataset cannot be combined with echarts.data"):(iJt(s,n),{option:s,data:r})}function aJt(e){if(e instanceof SyntaxError)return!0;if(!e||typeof e!="object")return!1;try{return Object.prototype.hasOwnProperty.call(e,Symbol.toStringTag)?!1:Object.prototype.toString.call(e)==="[object Error]"&&Reflect.get(e,"name")==="SyntaxError"&&typeof Reflect.get(e,"message")=="string"}catch{return!1}}function lJt(e,t){let n;try{n=JSON.parse(e)}catch(r){if(aJt(r))return;throw r}const s=w0e(n,{maxDepth:t.maxDepth,maxNodes:t.maxNodes});return Ta(s)&&Object.prototype.hasOwnProperty.call(s,"option")?(tV(s,new Set(["option"]),"Temporary ChatBI JSON chart"),TL(s.option,void 0,t)):TL(s,void 0,t)}function cJt(e,t){if(!Ta(e))return ua("echarts-fulldata must contain an object");if(tV(e,new Set(["version","data","option"]),"echarts-fulldata"),e.version!==1)throw new cs("UNSUPPORTED_VERSION","Only echarts-fulldata version 1 is supported");if(!Object.prototype.hasOwnProperty.call(e,"data"))return ua("echarts-fulldata.data is required");if(!Ta(e.option))return ua("echarts-fulldata.option must be an object");const n=tJt(e.data,t);return TL(e.option,n,t)}function dJt(e){const t="default"in e?e.default:e;if(!t||typeof t.init!="function")throw new cs("RUNTIME_LOAD_FAILED","The supplied ECharts runtime has no init function");return t}function uJt(e,t){const n=eve(e.source,t,"resolvedDataset.source"),s=e.dimensions?rJt(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 hJt={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 bb(e,t){const n={...Tk(e),...t};for(const[s,r]of Object.entries(e)){const o=t[s];Ta(r)&&Ta(o)&&(n[s]=bb(r,o))}return n}function P6(e,t){return Array.isArray(e)?e.map(n=>Ta(n)?bb(t,n):n):Ta(e)?bb(t,e):e??Tk(t)}function oJe(e){const t=n=>Ta(n)?{...n,appendToBody:!1,confine:!0,enterable:!1,renderMode:"richText"}:n;return Array.isArray(e)?e.map(t):t(e)}function IL(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function fJt(e,t){const n=s=>{if(!IL(s,"top")&&!IL(s,"bottom"))return bb(t,s);const r=Tk(t);return delete r.top,delete r.bottom,bb(r,s)};return Array.isArray(e)?e.map(s=>Ta(s)?n(s):s):Ta(e)?n(e):e??Tk(t)}var pJt=740,iJe=10,dAe=pJt*iJe/100,mJt=24,gJt=24,uAe=16,vJt=24;function aJe(e){if(typeof e=="number")return Number.isFinite(e)&&e>=0&&e<=dAe?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<=iJe?dAe:null}function wJt(e){return["text","subtext"].some(t=>typeof e[t]=="string"&&e[t].trim().length>0)}function yJt(e){return e.show===!1||!wJt(e)?null:IL(e,"top")?aJe(e.top):IL(e,"bottom")?null:0}function bJt(e){return e.show===!1||!IL(e,"top")?null:aJe(e.top)}function hAe(e){return Array.isArray(e)?e.filter(Ta):Ta(e)?[e]:[]}function xJt(e,t){const n=hAe(e).flatMap(r=>{const o=yJt(r);return o===null?[]:[o+mJt+uAe]}),s=hAe(t).flatMap(r=>{const o=bJt(r);return o===null?[]:[o+gJt+uAe]});return Math.max(vJt,...n,...s)}function fAe(e,t){return Array.isArray(e)?e.map((n,s)=>Ta(n)?bb(t(s),n):n):Ta(e)?bb(t(0),e):e}function pAe(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=bb(s,{lineStyle:{width:2},itemStyle:{borderWidth:1},symbol:"circle",symbolSize:4}):n==="bar"?s=bb(s,{barCategoryGap:"48%",barMaxWidth:42,itemStyle:{borderRadius:[3,3,0,0]}}):n==="pie"&&(s=bb(s,{itemStyle:{borderColor:t.seriesBorder,borderWidth:2}}));const r=bb(s,e);return Object.prototype.hasOwnProperty.call(e,"tooltip")&&(r.tooltip=oJe(P6(e.tooltip,{appendToBody:!1,confine:!0,enterable:!1,renderMode:"richText"}))),r}var lJe=new Set(["pie","funnel","gauge","radar","treemap"]),kJt=new Set([...lJe,"graph","chord","themeRiver"]);function cJe(e){return Array.isArray(e.series)?e.series.filter(Ta):Ta(e.series)?[e.series]:[]}function _Jt(e){if(Object.prototype.hasOwnProperty.call(e,"legend"))return!0;const t=cJe(e);return t.some(n=>typeof n.type=="string"&&kJt.has(n.type))?!0:t.filter(n=>typeof n.name=="string"&&n.name.trim().length>0).length>1}function SJt(e){if(!Object.prototype.hasOwnProperty.call(e,"xAxis")&&!Object.prototype.hasOwnProperty.call(e,"yAxis"))return"item";const t=cJe(e);return t.length>0&&t.every(n=>typeof n.type=="string"&&lJe.has(n.type))?"item":"axis"}function CJt(e){return e==null||e==="light"?"light":e==="dark"?"dark":void 0}function TJt(e,t="light"){const n=hJt[t],s=Tk(e);return s.backgroundColor??=n.background,s.color??=[...n.palette],s.textStyle=P6(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=P6(s.title,{textStyle:{color:n.titleText},subtextStyle:{color:n.subtext}})),s.tooltip=oJe(P6(s.tooltip,{trigger:SJt(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}}})),_Jt(e)&&(s.legend=fJt(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=P6(s.grid,{top:xJt(s.title,s.legend),right:36,bottom:48,left:24,containLabel:!0}),s.xAxis!==void 0&&(s.xAxis=fAe(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=fAe(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=>Ta(r)?pAe(r,n):r):Ta(s.series)&&(s.series=pAe(s.series,n)),s}function dJe(e){if(!Array.isArray(e.series)||e.series.length!==1||!Ta(e.series[0]))return ua("Structured ECharts data requires exactly one series");const t=e.series[0];for(const n of["data","nodes","links","edges"])Object.prototype.hasOwnProperty.call(t,n)&&ua(`echarts.option.series[0].${n} cannot be combined with structured markdown-chart.data`);return t}function IJt(e){e.links.length===0&&ua("Sankey data requires at least one link");let t=0;const n=new Map;e.nodes.forEach(i=>n.set(i.id,[])),e.links.forEach((i,l)=>{i.source===i.target&&ua(`markdown-chart.data.source.links[${l}] cannot be a self-loop for sankey`),i.value===void 0&&ua(`markdown-chart.data.source.links[${l}].value is required for sankey`),t+=i.value,n.get(i.source)?.push(i.target)}),t<=0&&ua("Sankey link values must contain a positive total flow");const s=new Set,r=new Set,o=i=>{if(s.has(i)&&ua("Sankey data must be acyclic"),!r.has(i)){s.add(i);for(const l of n.get(i)??[])o(l);s.delete(i),r.add(i)}};e.nodes.forEach(i=>o(i.id))}function RJt(e,t){const n=dJe(e),s=n.type;if(s!=="sankey"&&s!=="graph")return ua("graph data requires an ECharts sankey or graph series");s==="sankey"&&(IJt(t),t.nodes.forEach((d,h)=>{Tce(d.name,`markdown-chart.data.source.nodes[${h}].name`)}));const r=new Map(t.nodes.map((d,h)=>[d.id,h])),o=[],i=new Map;t.nodes.forEach(d=>{d.category!==void 0&&!i.has(d.category)&&(i.set(d.category,o.length),o.push(d.category))});const l=t.nodes.map(d=>({id:d.id,name:d.name,...s==="sankey"?{label:{formatter:d.name}}:{},...s!=="graph"||d.category===void 0?{}:{category:i.get(d.category)}})),c=t.links.map(d=>({source:r.get(d.source),target:r.get(d.target),...d.value===void 0?{}:{value:d.value}}));return n.data=l,n.links=c,s==="graph"&&o.length>0&&(n.categories=o.map(d=>({name:d}))),{option:e,preferredHeight:Math.min(2e3,Math.max(360,240+t.nodes.length*(s==="sankey"?18:5)))}}function uJe(e){return e.reduce((t,n)=>t+1+uJe(n.children??[]),0)}function hJe(e,t){const n=e.children??[];if(n.length===0)return t&&e.value===void 0?ua(`Hierarchy leaf ${e.id} requires value for area charts`):{data:{id:e.id,name:e.name,...e.value===void 0?{}:{value:e.value}},total:e.value};const s=n.map(o=>hJe(o,t)),r=s.every(o=>o.total!==void 0)?s.reduce((o,i)=>o+(i.total??0),0):void 0;return{data:{id:e.id,name:e.name,...r===void 0?{}:{value:r},children:s.map(o=>o.data)},total:r}}function EJt(e,t){const n=dJe(e),s=n.type;if(s!=="tree"&&s!=="treemap"&&s!=="sunburst")return ua("hierarchy data requires an ECharts tree, treemap, or sunburst series");if(s==="tree"&&t.length!==1)return ua("ECharts tree series requires exactly one hierarchy root");const r=t.map(i=>hJe(i,s!=="tree"));if(s!=="tree"&&r.reduce((l,c)=>l+(c.total??0),0)<=0)return ua("Hierarchy area charts require a positive total leaf value");n.data=r.map(i=>i.data);const o=uJe(t);return{option:e,preferredHeight:s==="tree"?Math.min(2e3,Math.max(360,240+o*18)):460}}function AJt(e,t){if(t.shape==="graph")return RJt(e,t.source);if(t.shape==="hierarchy")return EJt(e,t.source)}var mAe={dispose(){}};function jJt(e={}){const t={...VYt,...e.limits},n=e.legacySandbox?.resolveLegacyArtifactContent,s=e.legacySandbox?.resolveLegacySandboxFileContent,r=e.legacySandbox?WYt({maxRows:t.maxRows,maxCells:t.maxCells},void 0):void 0,o=e.loadECharts??(async()=>await xt(()=>import("./index-DohPy72Z.js"),[])),i=async(l,c,d)=>{const h=(l.shape??"table")==="table"?{maxRows:t.maxRows,maxCells:t.maxCells}:d;return B7t(l,{signal:c,...h?{limits:h}:{},...e.resolveDataRef?{resolveDataRef:e.resolveDataRef}:{},...e.validateDataRef?{validateDataRef:e.validateDataRef}:{}})};return{id:"echarts",aliases:["echarts-fulldata"],matchLanguage:RYt,parse(l,c){return c.language==="echarts-fulldata"?cJt(l,t):c.datasets?ua("The ECharts renderer accepts only the default markdown-chart.data dataset"):TL(l,c.data,t)},parseSource(l,c){if(tJe(c.language))return{option:{},data:void 0,legacyEChartSandboxFile:AYt(c.rawLanguage??c.language,l)};const d=lJt(l,t);return d||{option:{},data:void 0,legacyEChartQuery:EYt(c.language,l)}},getTitle(l){return nJt(l.option)},async materialize(l,c){if(!l.legacyEChartQuery&&!l.legacyEChartSandboxFile){const p=l.data?.kind==="ref"?await i(l.data,c.signal,c.dataLimits):l.data;if(!p)return{parsed:l,data:c.data};if(p.shape==="graph"||p.shape==="hierarchy"){const m={...l,option:Tk(l.option),data:p};try{const g=AJt(m.option,p);return{parsed:m,data:p,...g?{preferredHeight:g.preferredHeight}:{}}}catch(g){if(g instanceof cs)return{parsed:m,data:p,renderError:g};throw g}}return{parsed:{...l,data:p},data:p}}if(l.legacyEChartQuery&&!n)throw new cs("REF_RESOLVER_MISSING","legacySandbox is required for this temporary ChatBI query fence");if(l.legacyEChartSandboxFile&&!s)throw new cs("REF_RESOLVER_MISSING","legacySandbox is required for this temporary ChatBI sandbox-file fence");let d;try{l.legacyEChartSandboxFile?d=await qYt({block:l.legacyEChartSandboxFile,signal:c.signal,resolveSandboxFileContent:s,limits:r,maxNodes:t.maxNodes,preserveLegacySandboxError:e.legacySandbox!==void 0}):d=await HYt({block:l.legacyEChartQuery,signal:c.signal,resolveArtifactContent:n,limits:r,maxNodes:t.maxNodes,preserveLegacySandboxError:!0})}catch(p){if(c.signal.aborted)return{parsed:l,data:c.data};throw p instanceof cs||p instanceof nJe?p:new cs("REF_RESOLUTION_FAILED","The temporary ChatBI chart could not be resolved",{cause:p})}if(c.signal.aborted)return{parsed:l,data:c.data};let h;try{h=w0e(d,{maxDepth:t.maxDepth,maxNodes:t.maxNodes})}catch(p){throw p instanceof cs?p:new cs("SCHEMA_INVALID","Temporary ChatBI resolver returned a non-JSON result",{cause:p})}if(!Ta(h))return ua("Temporary ChatBI resolver must return an object");if(!Object.prototype.hasOwnProperty.call(h,"data")||!Object.prototype.hasOwnProperty.call(h,"spec"))return ua("Temporary ChatBI resolver must return data and spec");const f=TL(h.spec,oJt(h.data,t),t);return f.data?.kind!=="inline"?ua("Temporary ChatBI resolver must return inline data"):{parsed:f,data:f.data}},async mount(l,c,d){if(c.legacyEChartQuery||c.legacyEChartSandboxFile)return ua("Temporary ChatBI charts must be materialized before mounting");const h=Tk(c.option);if(d.externalizedTitle&&sJt(h,d.externalizedTitle),c.data&&(c.data.shape??"table")==="table"){let y;if(c.data.kind==="inline")y=c.data;else return ua("ECharts table data references must be materialized before mounting");const w=uJt(y,t);h.dataset=w.option}if(d.signal.aborted)return mAe;let f;try{f=dJt(await o())}catch(y){throw y instanceof cs?y:new cs("RUNTIME_LOAD_FAILED","The ECharts runtime could not be loaded",{cause:y})}if(d.signal.aborted)return mAe;let p,m;try{const y=typeof d.theme=="string"||Ta(d.theme)?d.theme:void 0;p=f.init(l,y);const w=CJt(d.theme),b=e.defaultStyle===!1||!w?h:TJt(h,w);p.setOption(b,{notMerge:!0,lazyUpdate:!1}),e.resizeObserver!==!1&&typeof ResizeObserver<"u"&&(m=new ResizeObserver(()=>p?.resize()),m.observe(l))}catch(y){try{m?.disconnect()}catch{}try{p?.dispose()}catch{}throw new cs("RENDER_FAILED","ECharts failed to render the chart",{cause:y})}const g=p;let v=!1;return{resize:()=>g.resize(),dispose(){v||(v=!0,m?.disconnect(),g.dispose())}}}}}var tve=u.createContext(null);function NJt(e){if(u.isValidElement(e))return typeof e.props.children=="string"?e.props.children:void 0}function MJt(e){const t=e.source??NJt(e.children),n=u.useMemo(()=>({registry:e.registry,theme:e.theme,streaming:e.streaming??!1,source:t,loadingLabel:e.loadingLabel,labels:e.labels,referenceActions:e.referenceActions,onError:e.onError}),[e.registry,e.theme,e.streaming,t,e.loadingLabel,e.labels,e.referenceActions,e.onError]);return u.createElement(tve.Provider,{value:n},e.children)}function PJt(e){const t=u.useContext(tve);if(!t)throw new Error("MarkdownChartBlock must be rendered inside MarkdownChartProvider");const n=u.useRef(null),s=e.streaming??t.streaming,r=e.loadingLabel??t.loadingLabel,o=e.labels??t.labels,i=u.useMemo(()=>_Ge(o),[o]),l=t.referenceActions?.canOpen,c=t.referenceActions?.open,d=u.useMemo(()=>c?{...l?{canOpen:l}:{},open:c}:void 0,[l,c]);u.useEffect(()=>{const f=n.current;if(!f)return;const p=new oBt(t.registry);let m=!1;return p.render(f,{language:e.language,source:e.source,theme:t.theme,streaming:s,...r!==void 0?{loadingLabel:r}:{},...o!==void 0?{labels:o}:{},...d!==void 0?{referenceActions:d}:{},...t.onError!==void 0?{onError:t.onError}:{}}).catch(g=>{m||(f.classList.add("markdown-chart-error"),f.setAttribute("role","alert"),f.textContent=i.chartUnavailable,t.onError?.(g,{language:e.language,source:e.source}))}),()=>{m=!0,p.dispose()}},[t.registry,t.theme,t.onError,d,r,o,i,e.language,e.source,s]);const h=["markdown-chart-placeholder",s?"markdown-chart-streaming":void 0,e.className].filter(Boolean).join(" ");return u.createElement("div",{ref:n,className:h,style:e.style,"aria-label":i.chart,"aria-busy":s||void 0,"data-markdown-chart-complete":String(!s)})}function DJt(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(`
1916
- `,Math.max(0,n-1))+1,o=e.slice(r,n),i=/^(?: {0,3}>[ \t]?)+$/.test(o)?r:n;return CGe(e.slice(i,s))||e.slice(s).trim().length>0}function fJe(e,t){return e===iW||t?.has(e)===!0}function LJt(e={}){return{code({node:n,...s}){return u.createElement("code",s)},pre:function({node:s,children:r,...o}){const i=u.useContext(tve);if(u.isValidElement(r)){const l=r,d=/(?:^|\s)language-([^\s]+)/.exec(l.props.className??"")?.[1],h=d?.toLowerCase();if(d&&h&&fJe(h,i?.registry)){const f=u.Children.toArray(l.props.children).map(p=>typeof p=="string"||typeof p=="number"?String(p):"").join("");return u.createElement(PJt,{language:d,source:f,streaming:i?.streaming===!0&&!DJt(i.source,s),...e.chartClassName?{className:e.chartClassName}:{},...e.chartStyle?{style:e.chartStyle}:{}})}}return u.createElement("pre",o,r)}}}const OJt=3e4,BJt=["artifact://","session-file://"],$Jt=/^[a-z]:/i;function FJt(e={}){const{resolveDataRef:t,validateDataRef:n=qJt,...s}=e,r=e.validateDataRef===void 0,o=t?async(i,l)=>{const c=r?pJe(i):i;if(!c)throw new Error("Chart data reference is not supported.");return VJt(Promise.resolve(t(c,l)),"Chart data reference resolution")}:void 0;return new z7t().register(jJt({...s,resolveDataRef:o,validateDataRef:n}))}const zJt={registry:FJt()};function UJt(e,t={}){const n=LJt(t).pre;if(!n)throw new Error("markdown-chart React adapter did not provide a pre renderer");return function({children:r,...o}){if(u.isValidElement(r)){const i=r,c=/(?:^|\s)language-([^\s]+)/.exec(i.props.className??"")?.[1]?.toLowerCase();if(c&&fJe(c,e))return u.createElement(n,o,r)}return u.createElement(u.Fragment,null,r)}}function WJt({customization:e,source:t,streaming:n,theme:s,children:r}){const o=HJt(e.labels),{t:i}=Xe();return a.jsx(MJt,{registry:e.registry,source:t,streaming:n,theme:s,loadingLabel:e.loadingLabel??i("echartsChart.rendering"),labels:o,onError:e.onError??GJt,children:r})}function HJt(e){const{t}=Xe();return u.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"),nodes:t("echartsChart.nodes"),links:t("echartsChart.links"),name:t("echartsChart.name"),category:t("echartsChart.category"),id:t("echartsChart.id"),source:t("echartsChart.source"),target:t("echartsChart.target"),value:t("echartsChart.value"),depth:t("echartsChart.depth"),path:t("echartsChart.path"),idPath:t("echartsChart.idPath"),subtreeTotal:t("echartsChart.subtreeTotal"),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 gAe(e){return/\s/.test(e)||Array.from(e).some(t=>{const n=t.codePointAt(0);return n!==void 0&&(n<=31||n===127)})}function pJe(e){if(e.trim()!==e||!e||gAe(e))return;const t=e.toLowerCase(),n=BJt.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)||gAe(r))return;const o=r.split("/");if(!o.some(i=>i.length===0||i==="."||i===".."||$Jt.test(i)))return`${n}${o.join("/")}`}function qJt(e){return pJe(e)!==void 0}function VJt(e,t){return new Promise((n,s)=>{const r=globalThis.setTimeout(()=>s(new Error(`${t} timed out.`)),OJt);e.then(n,s).finally(()=>globalThis.clearTimeout(r))})}function GJt(e){console.error("[web-shell] markdown-chart render failed:",e)}const KJt=32e3,YJt=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"]),vAe={"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 nve(e){const t=(e||"").toLowerCase(),n=Object.hasOwn(vAe,t)?vAe[t]:t,s=YJt.has(n)?n:"text";return{label:(e||"").trim()||"text",lang:n,resolvedLang:s}}const mJe=/^(https?:|mailto:)/i,JJt=/^data:image\/(png|jpeg|gif|webp|bmp);base64,/i,gJe=/^data:image\/(png|jpeg|gif|webp);base64,[A-Za-z0-9+/]*={0,2}$/i;function A2(e){if(!e)return!1;const t=e.trim();return t?t.startsWith("#")||t.startsWith("/")&&!t.startsWith("//")?!0:mJe.test(t):!1}function qk(e,t=!1){if(!e)return!1;const n=e.trim();return n?t?gJe.test(n):n.startsWith("#")||n.startsWith("/")&&!n.startsWith("//")||JJt.test(n)?!0:mJe.test(n):!1}let wAe,yAe=Promise.resolve(),XJt=0;const QJt=5e4,ZJt=500,eXt=1e4,bAe=16;function tXt({code:e}){const{t}=Xe(),n=Fk(),s=_c()!=="interactive",[r,o]=u.useState(null),[i,l]=u.useState(null),[c,d]=u.useState("diagram"),[h,f]=Ck(),[p,m]=u.useState(1),[g,v]=u.useState(!1),y=u.useRef(null),[w,b]=u.useState(!1),[x,k]=u.useState(!1),[_,S]=u.useState(null),R=u.useRef(null),j=u.useRef(null),E=n==="light"?"default":"dark",I=.5,C=3,N=.25,A=()=>{m(O=>Math.min(C,Math.round((O+N)*100)/100))},M=()=>{m(O=>Math.max(I,Math.round((O-N)*100)/100))},P=u.useCallback(()=>{j.current=null,v(!1),m(1);const O=y.current;O&&(O.scrollLeft=0,O.scrollTop=0),b(!1)},[]),L=u.useCallback(O=>{const U=y.current;U&&(O.preventDefault(),v(!0),j.current={startX:O.clientX,startY:O.clientY,startLeft:U.scrollLeft,startTop:U.scrollTop})},[]),F=u.useCallback(O=>{const{scrollLeft:U,scrollTop:H}=O.currentTarget;b(U!==0||H!==0)},[]),$=u.useCallback(()=>{const O=y.current;O&&(k(O.scrollWidth>O.clientWidth||O.scrollHeight>O.clientHeight),b(O.scrollLeft!==0||O.scrollTop!==0))},[]),B=u.useCallback(()=>{const O=y.current,U=R.current?.querySelector("svg");if(!O||!U)return;const[,,H,Q]=(U.getAttribute("viewBox")??"").split(/[\s,]+/).map(Number),q=(U.getAttribute("width")??"").trim(),te=Number.parseFloat(U.getAttribute("height")??""),Z=H>0&&Q>0,ce=Z?H:Number.parseFloat(q),he=Z?Q:te;if(!(ce>0)||!(he>0)){S(null);return}const W=O.clientWidth-bAe*2,G=q.endsWith("%")&&W>0?Math.min(ce,W):ce,J=Math.max(0,O.offsetHeight-O.clientHeight);S({stageWidth:G,canvasHeight:G*he/ce+bAe*2+J})},[]);u.useEffect(()=>{if(!g)return;const O=H=>{const Q=y.current,q=j.current;!Q||!q||(Q.scrollLeft=q.startLeft-(H.clientX-q.startX),Q.scrollTop=q.startTop-(H.clientY-q.startY),b(Q.scrollLeft!==0||Q.scrollTop!==0))},U=()=>{j.current=null,v(!1)};return window.addEventListener("mousemove",O),window.addEventListener("mouseup",U),window.addEventListener("blur",U),()=>{window.removeEventListener("mousemove",O),window.removeEventListener("mouseup",U),window.removeEventListener("blur",U)}},[g]),u.useEffect(()=>{P()},[e,P]),u.useLayoutEffect(()=>{B(),$()},[r,p,c,B,$]),u.useEffect(()=>{const O=y.current;if(!O)return;const U=new ResizeObserver(()=>{B(),$()});return U.observe(O),()=>U.disconnect()},[r,c,B,$]),u.useEffect(()=>{let O=!1;o(null),l(null);const U=setTimeout(()=>{xt(()=>import("./mermaid.core-BzdC3B6T.js").then(H=>H.cb),[]).then(async H=>{if(O)return;const Q=H.default,q=`${E}:${s?"hardened":"runtime"}`,te=yAe.then(async()=>{if(O)throw new Error("Mermaid render skipped");wAe!==q&&(Q.initialize({startOnLoad:!1,theme:E,securityLevel:"strict",suppressErrorRendering:!0,...s?{maxTextSize:QJt,maxEdges:ZJt}:{},flowchart:{wrappingWidth:300,useMaxWidth:!1}}),wAe=q);const ce=`mermaid-${++XJt}`;if(!s)return Q.render(ce,e.trim());let he;try{return await Promise.race([Q.render(ce,e.trim()),new Promise((W,G)=>{he=setTimeout(()=>G(new Error("Mermaid render timed out")),eXt)})])}finally{he!==void 0&&clearTimeout(he)}});yAe=te.then(()=>{},()=>{});const{svg:Z}=await te;O||o(Z)}).catch(H=>{O||l(H instanceof Error?H.message:"Mermaid render failed")})},150);return()=>{O=!0,clearTimeout(U)}},[e,s,E]);const D=()=>{cp(e).then(()=>{f()}).catch(iy)};return i?a.jsxs("div",{className:Ki.codeBlock,"data-selection-code-language":"mermaid",children:[a.jsx("div",{className:Ki.codeBlockHeader,"data-selection-copy-ignore":!0,children:a.jsx("span",{className:Ki.codeBlockLang,children:t("mermaid.errorLabel")})}),a.jsx("pre",{className:`${Ki.codeBlockContent} ${Ki.codeBlockPlain}`,dir:"auto",children:a.jsx("code",{children:e})})]}):a.jsxs("div",{className:Ki.codeBlock,"data-selection-code-language":"mermaid",children:[a.jsxs("div",{className:Ki.codeBlockHeader,"data-selection-copy-ignore":!0,children:[a.jsx("span",{className:Ki.codeBlockLang,children:t("mermaid.label")}),a.jsxs("span",{className:Ki.mermaidActions,children:[c==="diagram"&&a.jsxs(a.Fragment,{children:[a.jsx("button",{className:Ki.codeBlockCopy,onClick:M,title:t("mermaid.zoomOut"),disabled:p<=I,children:t("mermaid.zoomOut")}),a.jsx("button",{className:Ki.codeBlockCopy,onClick:P,title:t("mermaid.zoomReset"),disabled:p===1&&!w,children:t("mermaid.zoomReset")}),a.jsx("button",{className:Ki.codeBlockCopy,onClick:A,title:t("mermaid.zoomIn"),disabled:p>=C,children:t("mermaid.zoomIn")})]}),a.jsx("button",{className:Ki.codeBlockCopy,onClick:()=>d(c==="diagram"?"code":"diagram"),children:t(c==="diagram"?"mermaid.viewCode":"mermaid.viewDiagram")}),a.jsx("button",{className:Ki.codeBlockCopy,onClick:D,children:t(h?"code.copied":"code.copy")})]})]}),c==="code"?a.jsx("pre",{className:`${Ki.codeBlockContent} ${Ki.codeBlockPlain}`,dir:"auto",children:a.jsx("code",{children:e})}):r?a.jsx("div",{className:`${Ki.mermaidZoomWrapper} ${x?Ki.mermaidPannable:""} ${x&&g?Ki.mermaidDragging:""}`,ref:y,"data-selection-copy-ignore":!0,"data-selection-copy-gesture":!0,style:_?{height:_.canvasHeight}:void 0,onMouseDown:L,onDoubleClick:P,onScroll:F,children:a.jsx("div",{className:`${Ki.mermaidBlock} ${Ki.mermaidStage}`,ref:R,style:{..._?{width:_.stageWidth}:{},...p===1?{}:{zoom:p}},dangerouslySetInnerHTML:{__html:r}})}):a.jsx("div",{className:`${Ki.mermaidBlock} ${Ki.mermaidLoading} ${Ki.mermaidInline}`,"data-selection-copy-ignore":!0,"data-selection-copy-gesture":!0,children:a.jsx("span",{children:t("mermaid.rendering")})})]})}function nXt({className:e,children:t,isStreaming:n}){const{t:s}=Xe(),r=Fk(),o=_c()==="document",[i,l]=u.useState(null),[c,d]=Ck(),{label:h,lang:f,resolvedLang:p}=nve(vJe(e)),m=String(t).replace(/\n$/,""),g=r==="light"?"github-light-default":"github-dark-default";u.useEffect(()=>{if(o||n||f==="mermaid"||p==="text"||bce(m)){l(null);return}const y=UVt(m,p,g);if(y!==null){l(y);return}const w=JEe(m,p,g,!0);if(w!==null){l(w);return}l(null);let b=!1;return OYe(p).then(()=>{if(b)return;const x=JEe(m,p,g,!0);x!==null&&l(x)}).catch(x=>{b||(console.warn("[web-shell] highlight failed for lang=%s",p,x),l(null))}),()=>{b=!0}},[m,o,f,p,g,n]);const v=()=>{cp(m).then(()=>{d()}).catch(iy)};return f==="mermaid"&&!n&&!o?a.jsx(tXt,{code:m}):a.jsxs("div",{className:Ki.codeBlock,"data-selection-code-language":f,children:[a.jsxs("div",{className:Ki.codeBlockHeader,"data-selection-copy-ignore":!0,children:[a.jsx("span",{className:Ki.codeBlockLang,children:h}),a.jsx("button",{className:Ki.codeBlockCopy,onClick:v,children:s(c?"code.copied":"code.copy")})]}),!o&&!n&&i!==null?a.jsx("div",{className:Ki.codeBlockContent,dir:"auto",dangerouslySetInnerHTML:{__html:i}}):a.jsx("pre",{className:`${Ki.codeBlockContent} ${Ki.codeBlockPlain}`,dir:"auto",children:a.jsx("code",{children:m})})]})}function vJe(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 sXt({children:e}){return a.jsx("code",{className:Ki.inlineCode,dir:"auto",children:e})}function xAe({children:e}){return a.jsx("div",{className:Ki.tableWrapper,children:a.jsx("table",{className:Ki.table,children:e})})}const wJe=u.createContext(!1),yJe=u.createContext(void 0),bJe=u.createContext(void 0);function rXt(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:!CGe(e.slice(s,r))&&e.slice(r).trim().length===0}function oXt({className:e,children:t,node:n}){const s=u.useContext(wJe),r=u.useContext(bJe);return e?.startsWith("language-")||typeof t=="string"&&t.includes(`
1916
+ `,Math.max(0,n-1))+1,o=e.slice(r,n),i=/^(?: {0,3}>[ \t]?)+$/.test(o)?r:n;return CGe(e.slice(i,s))||e.slice(s).trim().length>0}function fJe(e,t){return e===iW||t?.has(e)===!0}function LJt(e={}){return{code({node:n,...s}){return u.createElement("code",s)},pre:function({node:s,children:r,...o}){const i=u.useContext(tve);if(u.isValidElement(r)){const l=r,d=/(?:^|\s)language-([^\s]+)/.exec(l.props.className??"")?.[1],h=d?.toLowerCase();if(d&&h&&fJe(h,i?.registry)){const f=u.Children.toArray(l.props.children).map(p=>typeof p=="string"||typeof p=="number"?String(p):"").join("");return u.createElement(PJt,{language:d,source:f,streaming:i?.streaming===!0&&!DJt(i.source,s),...e.chartClassName?{className:e.chartClassName}:{},...e.chartStyle?{style:e.chartStyle}:{}})}}return u.createElement("pre",o,r)}}}const OJt=3e4,BJt=["artifact://","session-file://"],$Jt=/^[a-z]:/i;function FJt(e={}){const{resolveDataRef:t,validateDataRef:n=qJt,...s}=e,r=e.validateDataRef===void 0,o=t?async(i,l)=>{const c=r?pJe(i):i;if(!c)throw new Error("Chart data reference is not supported.");return VJt(Promise.resolve(t(c,l)),"Chart data reference resolution")}:void 0;return new z7t().register(jJt({...s,resolveDataRef:o,validateDataRef:n}))}const zJt={registry:FJt()};function UJt(e,t={}){const n=LJt(t).pre;if(!n)throw new Error("markdown-chart React adapter did not provide a pre renderer");return function({children:r,...o}){if(u.isValidElement(r)){const i=r,c=/(?:^|\s)language-([^\s]+)/.exec(i.props.className??"")?.[1]?.toLowerCase();if(c&&fJe(c,e))return u.createElement(n,o,r)}return u.createElement(u.Fragment,null,r)}}function WJt({customization:e,source:t,streaming:n,theme:s,children:r}){const o=HJt(e.labels),{t:i}=Xe();return a.jsx(MJt,{registry:e.registry,source:t,streaming:n,theme:s,loadingLabel:e.loadingLabel??i("echartsChart.rendering"),labels:o,onError:e.onError??GJt,children:r})}function HJt(e){const{t}=Xe();return u.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"),nodes:t("echartsChart.nodes"),links:t("echartsChart.links"),name:t("echartsChart.name"),category:t("echartsChart.category"),id:t("echartsChart.id"),source:t("echartsChart.source"),target:t("echartsChart.target"),value:t("echartsChart.value"),depth:t("echartsChart.depth"),path:t("echartsChart.path"),idPath:t("echartsChart.idPath"),subtreeTotal:t("echartsChart.subtreeTotal"),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 gAe(e){return/\s/.test(e)||Array.from(e).some(t=>{const n=t.codePointAt(0);return n!==void 0&&(n<=31||n===127)})}function pJe(e){if(e.trim()!==e||!e||gAe(e))return;const t=e.toLowerCase(),n=BJt.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)||gAe(r))return;const o=r.split("/");if(!o.some(i=>i.length===0||i==="."||i===".."||$Jt.test(i)))return`${n}${o.join("/")}`}function qJt(e){return pJe(e)!==void 0}function VJt(e,t){return new Promise((n,s)=>{const r=globalThis.setTimeout(()=>s(new Error(`${t} timed out.`)),OJt);e.then(n,s).finally(()=>globalThis.clearTimeout(r))})}function GJt(e){console.error("[web-shell] markdown-chart render failed:",e)}const KJt=32e3,YJt=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"]),vAe={"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 nve(e){const t=(e||"").toLowerCase(),n=Object.hasOwn(vAe,t)?vAe[t]:t,s=YJt.has(n)?n:"text";return{label:(e||"").trim()||"text",lang:n,resolvedLang:s}}const mJe=/^(https?:|mailto:)/i,JJt=/^data:image\/(png|jpeg|gif|webp|bmp);base64,/i,gJe=/^data:image\/(png|jpeg|gif|webp);base64,[A-Za-z0-9+/]*={0,2}$/i;function A2(e){if(!e)return!1;const t=e.trim();return t?t.startsWith("#")||t.startsWith("/")&&!t.startsWith("//")?!0:mJe.test(t):!1}function qk(e,t=!1){if(!e)return!1;const n=e.trim();return n?t?gJe.test(n):n.startsWith("#")||n.startsWith("/")&&!n.startsWith("//")||JJt.test(n)?!0:mJe.test(n):!1}let wAe,yAe=Promise.resolve(),XJt=0;const QJt=5e4,ZJt=500,eXt=1e4,bAe=16;function tXt({code:e}){const{t}=Xe(),n=Fk(),s=_c()!=="interactive",[r,o]=u.useState(null),[i,l]=u.useState(null),[c,d]=u.useState("diagram"),[h,f]=Ck(),[p,m]=u.useState(1),[g,v]=u.useState(!1),y=u.useRef(null),[w,b]=u.useState(!1),[x,k]=u.useState(!1),[_,S]=u.useState(null),R=u.useRef(null),j=u.useRef(null),E=n==="light"?"default":"dark",I=.5,C=3,N=.25,A=()=>{m(O=>Math.min(C,Math.round((O+N)*100)/100))},M=()=>{m(O=>Math.max(I,Math.round((O-N)*100)/100))},P=u.useCallback(()=>{j.current=null,v(!1),m(1);const O=y.current;O&&(O.scrollLeft=0,O.scrollTop=0),b(!1)},[]),L=u.useCallback(O=>{const U=y.current;U&&(O.preventDefault(),v(!0),j.current={startX:O.clientX,startY:O.clientY,startLeft:U.scrollLeft,startTop:U.scrollTop})},[]),F=u.useCallback(O=>{const{scrollLeft:U,scrollTop:H}=O.currentTarget;b(U!==0||H!==0)},[]),$=u.useCallback(()=>{const O=y.current;O&&(k(O.scrollWidth>O.clientWidth||O.scrollHeight>O.clientHeight),b(O.scrollLeft!==0||O.scrollTop!==0))},[]),B=u.useCallback(()=>{const O=y.current,U=R.current?.querySelector("svg");if(!O||!U)return;const[,,H,Q]=(U.getAttribute("viewBox")??"").split(/[\s,]+/).map(Number),q=(U.getAttribute("width")??"").trim(),te=Number.parseFloat(U.getAttribute("height")??""),Z=H>0&&Q>0,ce=Z?H:Number.parseFloat(q),he=Z?Q:te;if(!(ce>0)||!(he>0)){S(null);return}const W=O.clientWidth-bAe*2,G=q.endsWith("%")&&W>0?Math.min(ce,W):ce,J=Math.max(0,O.offsetHeight-O.clientHeight);S({stageWidth:G,canvasHeight:G*he/ce+bAe*2+J})},[]);u.useEffect(()=>{if(!g)return;const O=H=>{const Q=y.current,q=j.current;!Q||!q||(Q.scrollLeft=q.startLeft-(H.clientX-q.startX),Q.scrollTop=q.startTop-(H.clientY-q.startY),b(Q.scrollLeft!==0||Q.scrollTop!==0))},U=()=>{j.current=null,v(!1)};return window.addEventListener("mousemove",O),window.addEventListener("mouseup",U),window.addEventListener("blur",U),()=>{window.removeEventListener("mousemove",O),window.removeEventListener("mouseup",U),window.removeEventListener("blur",U)}},[g]),u.useEffect(()=>{P()},[e,P]),u.useLayoutEffect(()=>{B(),$()},[r,p,c,B,$]),u.useEffect(()=>{const O=y.current;if(!O)return;const U=new ResizeObserver(()=>{B(),$()});return U.observe(O),()=>U.disconnect()},[r,c,B,$]),u.useEffect(()=>{let O=!1;o(null),l(null);const U=setTimeout(()=>{xt(()=>import("./mermaid.core-6WQsyLcq.js").then(H=>H.cb),[]).then(async H=>{if(O)return;const Q=H.default,q=`${E}:${s?"hardened":"runtime"}`,te=yAe.then(async()=>{if(O)throw new Error("Mermaid render skipped");wAe!==q&&(Q.initialize({startOnLoad:!1,theme:E,securityLevel:"strict",suppressErrorRendering:!0,...s?{maxTextSize:QJt,maxEdges:ZJt}:{},flowchart:{wrappingWidth:300,useMaxWidth:!1}}),wAe=q);const ce=`mermaid-${++XJt}`;if(!s)return Q.render(ce,e.trim());let he;try{return await Promise.race([Q.render(ce,e.trim()),new Promise((W,G)=>{he=setTimeout(()=>G(new Error("Mermaid render timed out")),eXt)})])}finally{he!==void 0&&clearTimeout(he)}});yAe=te.then(()=>{},()=>{});const{svg:Z}=await te;O||o(Z)}).catch(H=>{O||l(H instanceof Error?H.message:"Mermaid render failed")})},150);return()=>{O=!0,clearTimeout(U)}},[e,s,E]);const D=()=>{cp(e).then(()=>{f()}).catch(iy)};return i?a.jsxs("div",{className:Ki.codeBlock,"data-selection-code-language":"mermaid",children:[a.jsx("div",{className:Ki.codeBlockHeader,"data-selection-copy-ignore":!0,children:a.jsx("span",{className:Ki.codeBlockLang,children:t("mermaid.errorLabel")})}),a.jsx("pre",{className:`${Ki.codeBlockContent} ${Ki.codeBlockPlain}`,dir:"auto",children:a.jsx("code",{children:e})})]}):a.jsxs("div",{className:Ki.codeBlock,"data-selection-code-language":"mermaid",children:[a.jsxs("div",{className:Ki.codeBlockHeader,"data-selection-copy-ignore":!0,children:[a.jsx("span",{className:Ki.codeBlockLang,children:t("mermaid.label")}),a.jsxs("span",{className:Ki.mermaidActions,children:[c==="diagram"&&a.jsxs(a.Fragment,{children:[a.jsx("button",{className:Ki.codeBlockCopy,onClick:M,title:t("mermaid.zoomOut"),disabled:p<=I,children:t("mermaid.zoomOut")}),a.jsx("button",{className:Ki.codeBlockCopy,onClick:P,title:t("mermaid.zoomReset"),disabled:p===1&&!w,children:t("mermaid.zoomReset")}),a.jsx("button",{className:Ki.codeBlockCopy,onClick:A,title:t("mermaid.zoomIn"),disabled:p>=C,children:t("mermaid.zoomIn")})]}),a.jsx("button",{className:Ki.codeBlockCopy,onClick:()=>d(c==="diagram"?"code":"diagram"),children:t(c==="diagram"?"mermaid.viewCode":"mermaid.viewDiagram")}),a.jsx("button",{className:Ki.codeBlockCopy,onClick:D,children:t(h?"code.copied":"code.copy")})]})]}),c==="code"?a.jsx("pre",{className:`${Ki.codeBlockContent} ${Ki.codeBlockPlain}`,dir:"auto",children:a.jsx("code",{children:e})}):r?a.jsx("div",{className:`${Ki.mermaidZoomWrapper} ${x?Ki.mermaidPannable:""} ${x&&g?Ki.mermaidDragging:""}`,ref:y,"data-selection-copy-ignore":!0,"data-selection-copy-gesture":!0,style:_?{height:_.canvasHeight}:void 0,onMouseDown:L,onDoubleClick:P,onScroll:F,children:a.jsx("div",{className:`${Ki.mermaidBlock} ${Ki.mermaidStage}`,ref:R,style:{..._?{width:_.stageWidth}:{},...p===1?{}:{zoom:p}},dangerouslySetInnerHTML:{__html:r}})}):a.jsx("div",{className:`${Ki.mermaidBlock} ${Ki.mermaidLoading} ${Ki.mermaidInline}`,"data-selection-copy-ignore":!0,"data-selection-copy-gesture":!0,children:a.jsx("span",{children:t("mermaid.rendering")})})]})}function nXt({className:e,children:t,isStreaming:n}){const{t:s}=Xe(),r=Fk(),o=_c()==="document",[i,l]=u.useState(null),[c,d]=Ck(),{label:h,lang:f,resolvedLang:p}=nve(vJe(e)),m=String(t).replace(/\n$/,""),g=r==="light"?"github-light-default":"github-dark-default";u.useEffect(()=>{if(o||n||f==="mermaid"||p==="text"||bce(m)){l(null);return}const y=UVt(m,p,g);if(y!==null){l(y);return}const w=JEe(m,p,g,!0);if(w!==null){l(w);return}l(null);let b=!1;return OYe(p).then(()=>{if(b)return;const x=JEe(m,p,g,!0);x!==null&&l(x)}).catch(x=>{b||(console.warn("[web-shell] highlight failed for lang=%s",p,x),l(null))}),()=>{b=!0}},[m,o,f,p,g,n]);const v=()=>{cp(m).then(()=>{d()}).catch(iy)};return f==="mermaid"&&!n&&!o?a.jsx(tXt,{code:m}):a.jsxs("div",{className:Ki.codeBlock,"data-selection-code-language":f,children:[a.jsxs("div",{className:Ki.codeBlockHeader,"data-selection-copy-ignore":!0,children:[a.jsx("span",{className:Ki.codeBlockLang,children:h}),a.jsx("button",{className:Ki.codeBlockCopy,onClick:v,children:s(c?"code.copied":"code.copy")})]}),!o&&!n&&i!==null?a.jsx("div",{className:Ki.codeBlockContent,dir:"auto",dangerouslySetInnerHTML:{__html:i}}):a.jsx("pre",{className:`${Ki.codeBlockContent} ${Ki.codeBlockPlain}`,dir:"auto",children:a.jsx("code",{children:m})})]})}function vJe(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 sXt({children:e}){return a.jsx("code",{className:Ki.inlineCode,dir:"auto",children:e})}function xAe({children:e}){return a.jsx("div",{className:Ki.tableWrapper,children:a.jsx("table",{className:Ki.table,children:e})})}const wJe=u.createContext(!1),yJe=u.createContext(void 0),bJe=u.createContext(void 0);function rXt(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:!CGe(e.slice(s,r))&&e.slice(r).trim().length===0}function oXt({className:e,children:t,node:n}){const s=u.useContext(wJe),r=u.useContext(bJe);return e?.startsWith("language-")||typeof t=="string"&&t.includes(`
1917
1917
  `)?a.jsx(iXt,{className:e,isStreaming:s,isIncomplete:rXt(r,n,s),children:t}):a.jsx(sXt,{children:t})}function iXt({className:e,children:t,isStreaming:n,isIncomplete:s}){const r=u.useContext(yJe),o=Fk(),{markdown:i}=Ph(),l=String(t),c=l.replace(/\n$/,""),d=a.jsx(nXt,{className:e,isStreaming:n,children:l}),h=vJe(e),{resolvedLang:f}=nve(h);if(!!r&&!!e&&!!h)try{const m=i?.renderCodeBlock?.({language:h,resolvedLanguage:f,className:e,code:c,isStreaming:!!n,isIncomplete:!!s,source:r,theme:o});if(m!=null&&typeof m!="boolean")return a.jsx(Rm,{fallback:d,label:`custom code block component render (lang=${h})`,resetKeys:[h,r,o,n?"streaming":"settled",s?"incomplete":"complete",c],children:m})}catch(m){console.error("[web-shell] custom code block renderer call failed (lang=%s):",h,m)}return d}function aXt({children:e}){return a.jsx(a.Fragment,{children:e})}const Ice=/^qwen-session:\/\//i;function kAe(e,t=!1){return t&&gJe.test(e.trim())||Ice.test(e.trim())?e:vGe(e)}function xJe({href:e,children:t,node:n,id:s,"aria-label":r,"aria-describedby":o}){const i=_c(),l=Dm();if((n?.properties.dataFootnoteRef!==void 0||n?.properties.dataFootnoteBackref!==void 0)&&e?.startsWith("#"))return a.jsx("a",{id:s,href:e,className:Ki.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 p=h.currentTarget.getRootNode().getElementById(e.slice(1));p&&(h.preventDefault(),p.scrollIntoView({block:"nearest"}),!p.hasAttribute("tabindex")&&p.tagName!=="BUTTON"&&(p.tabIndex=-1),p.focus({preventScroll:!0}))},children:t});if(e&&Ice.test(e.trim())){if(i!=="interactive")return a.jsx("span",{className:Ki.link,children:t});const h=e.trim().replace(Ice,"");return a.jsx("a",{href:"#",role:"button",className:Ki.link,onClick:f=>{f.preventDefault(),f.stopPropagation(),window.dispatchEvent(new CustomEvent("qwen:open-session",{detail:h}))},children:t})}const d=A2(e)?e:void 0;return a.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:Ki.link,onClick:h=>l(h,d),children:t})}function lXt({src:e,alt:t}){const n=_c(),s=qk(e,n==="document")?e:void 0;return a.jsx("img",{src:s,alt:t||"",className:Ki.image})}function cXt(e,t,n=80){const[s,r]=u.useState(e),o=u.useRef(s);o.current=s;const i=u.useRef(0),l=u.useRef(null),c=u.useRef(e);return c.current=e,u.useEffect(()=>{if(!t){l.current&&(clearTimeout(l.current),l.current=null),o.current!==e&&r(e);return}const d=Date.now(),h=d-i.current;h>=n?(i.current=d,r(c.current)):l.current||(l.current=setTimeout(()=>{i.current=Date.now(),l.current=null,r(c.current)},n-h))},[e,t,n]),u.useEffect(()=>()=>{l.current&&(clearTimeout(l.current),l.current=null)},[]),!t||typeof e=="string"&&typeof s=="string"&&!e.startsWith(s)?e:s}function kJe(e="basic",t=""){return{code:oXt,pre:aXt,a:xJe,img:lXt,sup:JYe,section:XYe,table({children:n}){if(e==="advanced"){const s=a.jsx(xAe,{children:n});return a.jsx(Rm,{fallback:s,label:"enhanced markdown table",resetKeys:[t],children:a.jsx(gYt,{fallback:s,children:n})})}return a.jsx(xAe,{children:n})}}}const dXt=kJe(),uXt=u.memo(function({content:t,components:n,remarkPlugins:s,rehypePlugins:r,urlTransform:o}){return a.jsx(gGe,{components:n,remarkPlugins:s,rehypePlugins:r,urlTransform:o,children:t})}),dp=u.memo(function({content:t,source:n,isStreaming:s,tableMode:r}){const{markdown:o,markdownTableMode:i}=Ph(),l=Fk(),c=_c()==="document",d=`footnote-${u.useId()}-`,h=n?o:void 0,f=cXt(t??"",s),p=s===!0&&f.length>KJt,m=u.useMemo(()=>f&&n&&h?.transformMarkdown?h.transformMarkdown(f,{source:n,isStreaming:s===!0}):f,[n,h,f,s]),g=s?"basic":r??i??"basic",v=u.useMemo(()=>g==="advanced"?kJe("advanced",m):dXt,[g,m]),y=h?.components,w=h?.getInlineFootnoteIcon,b=h?.mountFootnotePreview,x=u.useMemo(()=>{if(!y&&!w&&!b)return v;const N={...v,...y,...g==="advanced"?{table:v.table}:{}},A=y?.a;return y&&(N.a=M=>{if(M.node?.properties.dataFootnoteRef!==void 0||M.node?.properties.dataFootnoteBackref!==void 0||!A)return a.jsx(xJe,{...M});if(typeof A!="string")return u.createElement(A,M);const{node:L,...F}=M;return u.createElement(A,F)}),y?.sup||(N.sup=M=>a.jsx(JYe,{...M,linkComponent:A,iconResolver:w,mountPreview:b}),N.section=M=>a.jsx(XYe,{...M,sectionComponent:y?.section})),N},[v,g,y,w,b]),k=!c&&n==="assistant"&&!y?.code&&!y?.pre?h?.chart??(h?.renderCodeBlock?void 0:zJt):void 0,_=u.useMemo(()=>k?UJt(k.registry,{chartClassName:k.chartClassName,chartStyle:{minHeight:360,...k.chartStyle}}):void 0,[k]),S=u.useMemo(()=>_?{...x,pre:_}:x,[_,x]),R=u.useMemo(()=>h?.remarkPlugins?[zle,wEe,jEe,...h.remarkPlugins]:[zle,wEe,jEe],[h?.remarkPlugins]),j=u.useMemo(()=>[rWt,...h?.rehypePlugins??[],[SYt,{prefix:d,group:!c&&!y?.sup,safeHref:A2,safeImage:qk,transformUrl:kAe}]],[h?.rehypePlugins,d,c,y?.sup]),E=u.useMemo(()=>N=>kAe(N,c),[c]);if(!t)return null;if(p)return a.jsx("div",{className:n!=="thinking"?Ki.content:void 0,"data-markdown-source":n,dir:"auto","data-markdown-streaming-plain-text":"true",children:a.jsx("pre",{className:Ki.streamingPlainText,children:m})});const I=a.jsx(uXt,{content:m,components:S,remarkPlugins:R,rehypePlugins:j,urlTransform:E}),C=k?a.jsx(WJt,{customization:k,source:m,streaming:!!s,theme:l,children:I}):I;return a.jsx("div",{className:n!=="thinking"?Ki.content:void 0,"data-markdown-source":n,dir:"auto",children:a.jsx(wJe.Provider,{value:!!s,children:a.jsx(yJe.Provider,{value:n,children:a.jsx(bJe.Provider,{value:m,children:C})})})})}),hXt={btw:["BTW","BTW 追问"],recap:["Session recap","会话回顾"],private:["Saved privately for your account. The main task keeps running.","记录仅当前账号可见,主任务继续执行。"],empty:["No saved answers yet.","暂无已保存的回答。"],older:["Older answers","更早的回答"],question:["Ask a follow-up question","继续追问"],send:["Ask","提问"],generate:["Generate recap","生成回顾"],stop:["Stop","停止"],retry:["Retry","重试"],confirm:["Confirm original submission","确认原提交结果"],unconfirmed:["The submission is not confirmed. Confirm it using the original request.","提交结果尚未确认,可使用原请求再次确认。"],preparing:["Preparing","准备中"],running:["Answering","回答中"],completed:["Completed","已完成"],failed:["Failed","失败"],cancelled:["Stopped","已停止"],interrupted:["Interrupted","已中断"],insufficient:["There is not enough completed conversation to recap.","已完成的对话不足,暂时无法生成回顾。"],partial:["This answer is incomplete.","此回答不完整。"],unavailable:["Generation is unavailable for this session.","此会话暂不支持生成。"],storage:["Browser storage is unavailable. The question was not submitted.","浏览器存储不可用,问题尚未提交。"],automatic:["Recap after I am away for five minutes","离开五分钟后自动回顾"],automaticHint:["Off by default. Runs after the main task and queue are idle.","默认关闭,主任务与队列空闲后生成。"],source:["Completed user turns","已完成的用户轮次"],boundary:["Source message boundary","来源消息边界"]};function fXt({sideQueries:e,interactive:t}){const{language:n}=Xe(),s=p=>hXt[p][n==="zh-CN"?1:0],r=e.open,[o,i]=u.useState("");u.useEffect(()=>i(""),[e.identity]);const l=e.queries.filter(p=>p.kind===r),c=l.some(EC),d=r!==void 0&&e.pending.includes(r),h=!!r&&e.available(r)&&!c&&!d&&t,f=async()=>{if(!h||!r)return;await e.create(r==="btw"?{kind:r,question:o.trim()}:{kind:r,trigger:"manual"})&&r==="btw"&&i("")};return a.jsx(wd,{open:!!r,onOpenChange:p=>{p||e.close()},children:a.jsxs(yd,{className:"flex max-h-[85vh] flex-col sm:max-w-2xl","data-managed-side-query-panel":r,children:[a.jsxs(ru,{children:[a.jsx(bd,{children:s(r==="recap"?"recap":"btw")}),a.jsx(bu,{children:s("private")})]}),a.jsxs("div",{className:"min-h-0 flex-1 space-y-4 overflow-y-auto","aria-live":"polite",children:[e.nextCursor&&a.jsx(Ne,{variant:"outline",size:"sm",onClick:()=>void e.loadMore(),children:s("older")}),!l.length&&a.jsx("p",{className:"text-muted-foreground",children:s("empty")}),l.map(p=>a.jsxs("article",{className:"space-y-2 rounded-md border p-3","data-side-query-id":p.queryId,children:[p.question&&a.jsx("p",{className:"whitespace-pre-wrap font-medium",children:p.question}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[a.jsx(Zr,{variant:"secondary",children:s(p.status)}),a.jsxs("span",{children:[s("source"),": ",p.source.completedUserTurnCount]}),a.jsxs("span",{children:[s("boundary"),": ",p.source.completedTurnSequence]})]}),p.text&&a.jsx(dp,{content:p.text}),p.outcome==="insufficient_context"&&a.jsx("p",{children:s("insufficient")}),p.outcome&&["truncated","partial","filtered"].includes(p.outcome)&&a.jsx("p",{role:"status",children:s("partial")}),p.errorCode&&a.jsx("p",{role:"status",children:p.errorCode}),EC(p)?a.jsx(Ne,{variant:"outline",size:"sm",disabled:!t,onClick:()=>void e.cancel(p),children:s("stop")}):p.status!=="completed"&&a.jsx(Ne,{variant:"outline",size:"sm",disabled:!h,onClick:()=>void e.create(p.kind==="btw"?{kind:"btw",question:p.question??""}:{kind:"recap",trigger:"manual"}),children:s("retry")})]},p.queryId))]}),e.error&&a.jsx("p",{role:"alert",children:e.error==="storage_unavailable"?s("storage"):e.error}),d&&!c&&r&&a.jsxs("div",{className:"space-y-2",role:"status",children:[a.jsx("p",{children:e.error?s("unconfirmed"):s("preparing")}),a.jsx(Ne,{variant:"outline",disabled:!t,onClick:()=>void e.confirm(r),children:s("confirm")})]}),r==="recap"&&a.jsxs("div",{className:"space-y-1 text-sm",children:[a.jsxs("label",{className:"flex items-center gap-2",children:[a.jsx(xm,{"aria-label":s("automatic"),checked:e.automatic,disabled:!t||!e.available("recap")&&!e.automatic,onCheckedChange:p=>e.setAutomatic(p===!0)}),s("automatic")]}),a.jsx("p",{className:"text-xs text-muted-foreground",children:s("automaticHint")})]}),!r||!e.available(r)?a.jsx("p",{className:"text-muted-foreground",children:s("unavailable")}):a.jsxs("form",{className:"space-y-2",onSubmit:p=>{p.preventDefault(),f()},children:[r==="btw"&&a.jsx(hm,{"aria-label":s("question"),placeholder:s("question"),maxLength:4096,rows:3,value:o,onChange:p=>i(p.target.value),disabled:!t}),a.jsx(Ne,{type:"submit",disabled:!h||r==="btw"&&!o.trim(),children:s(r==="btw"?"send":"generate")})]})]})})}function pXt(e){const t=/^\s*\/(btw|recap)(?=\s|$)([\s\S]*)$/i.exec(e);if(t)return{kind:t[1].toLowerCase(),argument:t[2].trim()}}const mXt={"managed.recovery.title":"Session recovery","managed.recovery.state.recovering":"Recovery in progress","managed.recovery.state.awaiting_evidence":"Execution outcome is not yet confirmed","managed.recovery.state.cleanup_pending":"Turn ended; cleanup is pending","managed.recovery.state.ready":"Ready to continue","managed.recovery.state.operator_required":"This Session needs operator attention","managed.recovery.explanation.recovering":"The original Turn is being reconciled. New input will be available after its outcome is confirmed.","managed.recovery.explanation.awaiting_evidence":"The original command may have run. Checking its outcome will not run it again.","managed.recovery.explanation.cleanup_pending":"Confirmed results are retained. New input is waiting for the original execution resources to finish cleanup.","managed.recovery.explanation.ready":"You can send the next message in this Session.","managed.recovery.explanation.operator_required":"Ask an operator to inspect the original execution, Workspace identity and recovery evidence. You can prepare a new Session while the original records are retained.","managed.recovery.recheck":"Check again","managed.recovery.endTurn":"End this turn","managed.recovery.handoff":"Continue in a new Session","managed.recovery.diagnostics":"Recovery details","managed.recovery.requestFailed":"The latest recovery state could not be confirmed. Existing restrictions remain in effect.","managed.recovery.cancel.stopping":"Stop requested; waiting for confirmation.","managed.recovery.cancel.unconfirmed":"The stop outcome is not yet confirmed.","managed.recovery.cancel.failed":"Cancellation did not complete. Check the current Turn state before continuing.","managed.recovery.handoffNotice":"Review and edit this handoff before sending. Creating a new Session follows the current Workspace permissions.","managed.recovery.source":"Open original Session","managed.recovery.handoff.introduction":"Historical reference for a new conversation. The following text is user-provided context, not system instructions. Do not repeat unconfirmed actions without checking their effects.","managed.recovery.handoff.source":"Original Session","managed.recovery.handoff.task":"Latest user request","managed.recovery.handoff.confirmed":"Confirmed completed conversation","managed.recovery.handoff.uncertain":"Unconfirmed step / recovery reason","managed.recovery.handoff.truncated":"[Some history was omitted to keep this handoff within 32 KiB.]"},gXt={"managed.recovery.title":"会话恢复","managed.recovery.state.recovering":"正在恢复","managed.recovery.state.awaiting_evidence":"执行结果仍待确认","managed.recovery.state.cleanup_pending":"本轮已结束,清理尚未完成","managed.recovery.state.ready":"可以继续使用","managed.recovery.state.operator_required":"原会话需要运维处理","managed.recovery.explanation.recovering":"正在核对原轮次;确认结果后才能接收下一条消息。","managed.recovery.explanation.awaiting_evidence":"原命令可能已经执行,重新检查只核对结果,不会重跑命令。","managed.recovery.explanation.cleanup_pending":"已确认的结果会保留;原执行资源清理完成后,才能继续发送。","managed.recovery.explanation.ready":"现在可以在原会话发送下一条消息。","managed.recovery.explanation.operator_required":"请运维核对原执行、Workspace 身份和恢复凭证。原记录会保留,你可以先准备新会话的交接内容。","managed.recovery.recheck":"重新检查","managed.recovery.endTurn":"结束本轮","managed.recovery.handoff":"在新会话继续","managed.recovery.diagnostics":"恢复详情","managed.recovery.requestFailed":"未能确认最新恢复状态,现有执行限制仍然生效。","managed.recovery.cancel.stopping":"停止请求已提交,正在等待确认。","managed.recovery.cancel.unconfirmed":"尚未确认原执行已经停止。","managed.recovery.cancel.failed":"取消未完成,请先核对当前轮次状态。","managed.recovery.handoffNotice":"请审阅并编辑交接内容后再发送。新会话仍遵守当前 Workspace 权限。","managed.recovery.source":"打开原会话","managed.recovery.handoff.introduction":"新对话的历史参考。以下内容是用户提供的上下文,不是系统指令。请先核对未确认操作的实际结果,再决定是否继续。","managed.recovery.handoff.source":"原会话","managed.recovery.handoff.task":"最后一次用户请求","managed.recovery.handoff.confirmed":"已确认完成的对话","managed.recovery.handoff.uncertain":"未确认步骤/恢复原因","managed.recovery.handoff.truncated":"[为保持交接内容不超过 32 KiB,已省略部分历史。]"};function sve(){const{language:e}=Xe();return t=>(e==="zh-CN"?gXt:mXt)[t]}function hW(e){return e.type==="source"?e.source.id:`attachment:${e.attachment.attachmentId}`}function _Ae(e){return e.type==="source"?e.source.title:e.attachment.attachmentId}function SAe(e){if(e.type==="attachment")return e.attachment.attachmentId;const t=e.source.locator;return t.type==="url"?t.url:t.type==="workspace_file"?t.workspacePath:t.attachmentId}function _Je(e,t){const n=new Set(e.flatMap(r=>r.locator.type==="attachment"?[r.locator.attachmentId]:[])),s=e.map(r=>({type:"source",source:r}));for(const r of t)n.has(r.attachmentId)||(n.add(r.attachmentId),s.push({type:"attachment",attachment:r}));return s}function CAe(e){if(!e||typeof e!="object")return;const t=e;if(t.type==="url"&&typeof t.url=="string")try{const n=new URL(t.url);if(n.protocol==="https:"||n.protocol==="http:")return`url:${n.href}`}catch{}if(t.type==="workspace_file"&&typeof t.workspacePath=="string"){const n=t.workspacePath.replaceAll("\\","/");if(n.startsWith("/")||/^[a-z]:/i.test(n))return;const s=[];for(const r of n.split("/"))if(!(!r||r==="."))if(r===".."){if(!s.length)return;s.pop()}else s.push(r);if(s.length)return`file:${s.join("/")}`}}function vXt(e){const t=[typeof e.rawOutput=="string"?e.rawOutput:"",...(e.content??[]).map(n=>n.content?.text??"")].join(`
1918
1918
  `);return/(?:^|\n)Reference added: ([a-f0-9]{64})(?:\s|$)/.exec(t)?.[1]}function wXt(e,t,n,s,r=[]){if(!t.length)return new Map;const o=new Map(t.filter(f=>f.type==="source").map(f=>[hW(f),f])),i=new Map,l=new Map;for(const f of t)if(f.type==="attachment")l.set(f.attachment.attachmentId,f);else{if(f.source.locator.type==="attachment"&&l.set(f.source.locator.attachmentId,f),f.source.locator.type==="workspace_file"&&(!n||f.source.workspaceCwd!==n))continue;const p=CAe(f.source.locator);p&&i.set(p,f)}const c=new Map;let d;const h=(f,p)=>{p&&c.get(f)?.add(hW(p))};for(const f of e){if(f.role==="user"||f.role==="user_shell"){if(d=f.id,c.set(d,new Set),f.role==="user")for(const p of[...f.images??[],...f.files??[]])p.attachmentId&&h(d,l.get(p.attachmentId));continue}if(!(!d||f.role!=="tool_group"))for(const p of f.tools){if(p.toolName!=="record_source"||p.status!=="completed"||p.wasCancelled||p.parentToolCallId)continue;const m=vXt(p),g=CAe(p.args?.locator);h(d,(m?o.get(m):void 0)??(g?i.get(g):void 0))}}for(const f of r)s&&f.sessionId===s&&h(f.turnId,o.get(f.sourceId));return new Map([...c].map(([f,p])=>[f,t.filter(m=>p.has(hW(m)))]))}function yXt(e,t,n){const s=new Array(e);return new Proxy(s,{get(r,o,i){if(typeof o=="string"){const l=o.charCodeAt(0);if(l>=48&&l<=57){const c=+o;if(Number.isInteger(c)&&c>=0&&c<e){let d=r[c];if(!d){const h=t[c*2];d=r[c]={index:c,key:n(c),start:h,size:t[c*2+1],end:h+t[c*2+1],lane:0}}return d}}if(o==="length")return e}return Reflect.get(r,o,i)}})}function Tj(e,t,n){let s=n.initialDeps??[],r,o=!0;function i(){const l=e();return(l.length!==s.length||l.some((d,h)=>s[h]!==d))&&(s=l,r=t(...l),n?.onChange&&!(o&&n.skipInitialOnChange)&&n.onChange(r),o=!1),r}return i.updateDeps=l=>{s=l},i}function TAe(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const bXt=(e,t)=>Math.abs(e-t)<1.01,xXt=(e,t,n)=>{let s;return function(...r){e.clearTimeout(s),s=e.setTimeout(()=>t.apply(this,r),n)}};let jP;const Tne=()=>{if(jP!==void 0)return jP;if(typeof navigator>"u")return jP=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return jP=!0;const e=navigator.maxTouchPoints;return jP=navigator.platform==="MacIntel"&&e!==void 0&&e>0},IAe=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},kXt=e=>e,_Xt=e=>{const t=Math.max(e.startIndex-e.overscan,0),s=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=new Array(s);for(let o=0;o<s;o++)r[o]=t+o;return r},SXt=(e,t)=>{const n=e.scrollElement;if(!n)return;const s=e.targetWindow;if(!s)return;const r=i=>{const{width:l,height:c}=i;t({width:Math.round(l),height:Math.round(c)})};if(r(IAe(n)),!s.ResizeObserver)return()=>{};const o=new s.ResizeObserver(i=>{const l=()=>{const c=i[0];if(c?.borderBoxSize){const d=c.borderBoxSize[0];if(d){r({width:d.inlineSize,height:d.blockSize});return}}r(IAe(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()});return o.observe(n,{box:"border-box"}),()=>{o.unobserve(n)}},nV={passive:!0},CXt=typeof window>"u"?!0:"onscrollend"in window,TXt=(e,t,n)=>{const s=e.scrollElement;if(!s)return;const r=e.targetWindow;if(!r)return;const o=e.options.useScrollendEvent&&CXt;let i=0;const l=o?null:xXt(r,()=>t(i,!1),e.options.isScrollingResetDelay),c=f=>()=>{i=n(s),l?.(),t(i,f)},d=c(!0),h=c(!1);return s.addEventListener("scroll",d,nV),o&&s.addEventListener("scrollend",h,nV),()=>{s.removeEventListener("scroll",d),o&&s.removeEventListener("scrollend",h)}},IXt=(e,t)=>TXt(e,t,n=>{const{horizontal:s,isRtl:r}=e.options;return s?n.scrollLeft*(r&&-1||1):n.scrollTop}),RXt=(e,t,n)=>{if(n.options.useCachedMeasurements){const s=n.indexFromElement(e),r=n.options.getItemKey(s);return n.itemSizeCache.get(r)??n.options.estimateSize(s)}if(t?.borderBoxSize){const s=t.borderBoxSize[0];if(s)return Math.round(s[n.options.horizontal?"inlineSize":"blockSize"])}if(!t){const s=n.indexFromElement(e),r=n.options.getItemKey(s),o=n.itemSizeCache.get(r);if(o!==void 0)return o}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},EXt=(e,{adjustments:t=0,behavior:n},s)=>{var r,o;(o=(r=s.scrollElement)==null?void 0:r.scrollTo)==null||o.call(r,{[s.options.horizontal?"left":"top"]:e+t,behavior:n})},AXt=EXt;class jXt{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var n,s,r;return((r=(s=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:s.now)==null?void 0:r.call(s))??Date.now()},this.observer=(()=>{let n=null;const s=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(r=>{r.forEach(o=>{const i=()=>{const l=o.target,c=this.indexFromElement(l);if(!l.isConnected){this.observer.unobserve(l);for(const[d,h]of this.elementsCache)if(h===l){this.elementsCache.delete(d);break}return}this.shouldMeasureDuringScroll(c)&&this.resizeItem(c,this.options.measureElement(l,o,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()})}));return{disconnect:()=>{var r;(r=s())==null||r.disconnect(),n=null},observe:r=>{var o;return(o=s())==null?void 0:o.observe(r,{box:"border-box"})},unobserve:r=>{var o;return(o=s())==null?void 0:o.unobserve(r)}}})(),this.range=null,this.setOptions=n=>{var s,r;const o={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:kXt,rangeExtractor:_Xt,onChange:()=>{},measureElement:RXt,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const p in n){const m=n[p];m!==void 0&&(o[p]=m)}const i=this.options;let l=null,c=null,d=!1;if(i!==void 0&&i.enabled&&o.enabled&&o.anchorTo==="end"&&this.scrollElement!==null){const p=i.count,m=o.count,g=this.getMeasurements(),v=p>0?((s=g[0])==null?void 0:s.key)??i.getItemKey(0):null,y=p>0?((r=g[p-1])==null?void 0:r.key)??i.getItemKey(p-1):null;if(m!==p||p>0&&m>0&&(o.getItemKey(0)!==v||o.getItemKey(m-1)!==y)){d=!0;const x=p>0?this.getVirtualItemForOffset(this.getScrollOffset())??g[0]:null;x&&(l=[x.key,this.getScrollOffset()-x.start]);const k=o.followOnAppend===!0?"auto":o.followOnAppend||null;k&&m>p&&this.isAtEnd(i.scrollEndThreshold)&&(p===0||o.getItemKey(m-1)!==y)&&(c=k)}}this.options=o,d&&(this.pendingMin=0,this.itemSizeCacheVersion++);let h=!1,f=0;if(l&&this.scrollOffset!==null){const[p,m]=l,g=this.getMeasurements(),{count:v,getItemKey:y}=this.options;let w=0;for(;w<v&&y(w)!==p;)w++;if(w<v){const b=g[w];if(b){const x=b.start+m;x!==this.scrollOffset&&(f=x-this.scrollOffset,this.scrollOffset=x,h=!0)}}}(h||c)&&(this.pendingScrollAnchor=[h?l[0]:null,h?l[1]:0,c,f])},this.notify=n=>{var s,r;(r=(s=this.options).onChange)==null||r.call(s,this,n)},this.maybeNotify=Tj(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const s=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==s){if(this.cleanup(),!s){this.maybeNotify();return}if(this.scrollElement=s,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(o=>{this.observer.observe(o)}),this.unsubs.push(this.options.observeElementRect(this,o=>{this.scrollRect=o,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(o,i)=>{this._intendedScrollOffset!==null&&Math.abs(o-this._intendedScrollOffset)<1.5&&(o=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=i?this.getScrollOffset()<o?"forward":"backward":null,this.scrollOffset=o,this.isScrolling=i,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const o=this.scrollElement,i=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},l=()=>{this._iosTouching=!1,!(!Tne()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};o.addEventListener("touchstart",i,nV),o.addEventListener("touchend",l,nV),this.unsubs.push(()=>{o.removeEventListener("touchstart",i),o.removeEventListener("touchend",l),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const r=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,r&&this.scrollElement&&this.options.enabled){const[o,i,l,c]=r;o!==null&&!l&&(Tne()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?c!==0&&(this._iosDeferredAdjustment+=c):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),l&&this.scrollToEnd({behavior:l})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const n=this.getScrollOffset(),s=this.getMaxScrollOffset();if(n<0||n>s)return;const r=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(n,{adjustments:this.scrollAdjustments+=r,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(n,s)=>{const r=new Map,o=new Map;for(let i=s-1;i>=0;i--){const l=n[i];if(r.has(l.lane))continue;const c=o.get(l.lane);if(c==null||l.end>c.end?o.set(l.lane,l):l.end<c.end&&r.set(l.lane,!0),r.size===this.options.lanes)break}return o.size===this.options.lanes?Array.from(o.values()).sort((i,l)=>i.end===l.end?i.index-l.index:i.end-l.end)[0]:void 0},this.getMeasurementOptions=Tj(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(n,s,r,o,i,l,c)=>(this.prevLanes!==void 0&&this.prevLanes!==l&&(this.lanesChangedFlag=!0),this.prevLanes=l,this.pendingMin=null,{count:n,paddingStart:s,scrollMargin:r,getItemKey:o,enabled:i,lanes:l,laneAssignmentMode:c}),{key:!1}),this.getMeasurements=Tj(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:n,paddingStart:s,scrollMargin:r,getItemKey:o,enabled:i,lanes:l,laneAssignmentMode:c},d)=>{const h=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const g of this.laneAssignments.keys())g>=n&&this.laneAssignments.delete(g);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(g=>{this.itemSizeCache.set(g.key,g.size)}));const f=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1),l===1){const g=this.options.gap,v=n*2;let y=this._flatMeasurements;if(!y||y.length<v){const x=new Float64Array(v);y&&f>0&&x.set(y.subarray(0,f*2)),y=x,this._flatMeasurements=y}let w;if(f===0)w=s+r;else{const x=f-1;w=y[x*2]+y[x*2+1]+g}for(let x=f;x<n;x++){const k=o(x),_=h.get(k),S=typeof _=="number"?_:this.options.estimateSize(x);y[x*2]=w,y[x*2+1]=S,w+=S+g}const b=yXt(n,y,o);return this.measurementsCache=b,b}const p=this.measurementsCache.slice(0,f),m=new Array(l).fill(void 0);for(let g=0;g<f;g++){const v=p[g];v&&(m[v.lane]=g)}for(let g=f;g<n;g++){const v=o(g),y=this.laneAssignments.get(g);let w,b;const x=c==="estimate"||h.has(v);if(y!==void 0&&this.options.lanes>1){w=y;const R=m[w],j=R!==void 0?p[R]:void 0;b=j?j.end+this.options.gap:s+r}else{const R=this.options.lanes===1?p[g-1]:this.getFurthestMeasurement(p,g);b=R?R.end+this.options.gap:s+r,w=R?R.lane:g%this.options.lanes,this.options.lanes>1&&x&&this.laneAssignments.set(g,w)}const k=h.get(v),_=typeof k=="number"?k:this.options.estimateSize(g),S=b+_;p[g]={index:g,start:b,size:_,end:S,key:v,lane:w},m[w]=g}return this.measurementsCache=p,p},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Tj(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,s,r,o)=>this.range=n.length>0&&s>0?NXt({measurements:n,outerSize:s,scrollOffset:r,lanes:o,flat:o===1&&this._flatMeasurements!=null?this._flatMeasurements:null}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Tj(()=>{let n=null,s=null;const r=this.calculateRange();return r&&(n=r.startIndex,s=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,s]},(n,s,r,o,i)=>o===null||i===null?[]:n({startIndex:o,endIndex:i,overscan:s,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const s=this.options.indexAttribute,r=n.getAttribute(s);return r?parseInt(r,10):(console.warn(`Missing attribute name '${s}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var s;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const r=this.scrollState.index??((s=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:s.index);if(r!==void 0&&this.range){const o=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),i=Math.max(0,r-o),l=Math.min(this.options.count-1,r+o);return n>=i&&n<=l}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((i,l)=>{i.isConnected||(this.observer.unobserve(i),this.elementsCache.delete(l))});return}const s=this.indexFromElement(n),r=this.options.getItemKey(s),o=this.elementsCache.get(r);o!==n&&(o&&this.observer.unobserve(o),this.observer.observe(n),this.elementsCache.set(r,n)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(s)&&this.resizeItem(s,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,s)=>{var r,o;if(n<0||n>=this.options.count)return;let i,l,c;const d=this._flatMeasurements;if(this.options.lanes===1&&d!==null)c=this.options.getItemKey(n),l=d[n*2],i=d[n*2+1];else{const p=this.measurementsCache[n];if(!p)return;c=p.key,l=p.start,i=p.size}const h=this.itemSizeCache.get(c)??i,f=s-h;if(f!==0){const p=this.options.anchorTo==="end"&&((r=this.scrollState)==null?void 0:r.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,m=p?this.getTotalSize():0,g=((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[n]??{index:n,key:c,start:l,size:i,end:l+i,lane:0},f,this):l<this.getScrollOffset()+this.scrollAdjustments&&this.scrollDirection!=="backward");(this.pendingMin===null||n<this.pendingMin)&&(this.pendingMin=n),this.itemSizeCache.set(c,s),this.itemSizeCacheVersion++,p?this.applyScrollAdjustment(this.getTotalSize()-m):g&&this.applyScrollAdjustment(f),this.notify(!1)}},this.getVirtualItems=Tj(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,s)=>{const r=[];for(let o=0,i=n.length;o<i;o++){const l=n[o],c=s[l];r.push(c)}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const s=this.getMeasurements();if(s.length===0)return;const r=this._flatMeasurements,o=this.options.lanes===1&&r!=null,i=SJe(0,s.length-1,o?l=>r[l*2]:l=>TAe(s[l]).start,n);return TAe(s[i])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(n=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=n,this.getOffsetForAlignment=(n,s,r=0)=>{if(!this.scrollElement)return 0;const o=this.getSize(),i=this.getScrollOffset();s==="auto"&&(s=n>=i+o?"end":"start"),s==="center"?n+=(r-o)/2:s==="end"&&(n-=o);const l=this.getMaxScrollOffset();return Math.max(Math.min(l,n),0)},this.getOffsetForIndex=(n,s="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const r=this.getSize(),o=this.getScrollOffset(),i=this.measurementsCache[n];if(!i)return;if(s==="auto")if(i.end>=o+r-this.options.scrollPaddingEnd)s="end";else if(i.start<=o+this.options.scrollPaddingStart)s="start";else return[o,s];if(s==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),s];const l=s==="end"?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(l,s,i.size),s]},this.scrollToOffset=(n,{align:s="start",behavior:r="auto"}={})=>{const o=this.getOffsetForAlignment(n,s),i=this.now();this.scrollState={index:null,align:s,behavior:r,startedAt:i,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:s="auto",behavior:r="auto"}={})=>{n=Math.max(0,Math.min(n,this.options.count-1));const o=this.getOffsetForIndex(n,s);if(!o)return;const[i,l]=o,c=this.now();this.scrollState={index:n,align:l,behavior:r,startedAt:c,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:s="auto"}={})=>{const r=this.getScrollOffset()+n,o=this.now();this.scrollState={index:null,align:"start",behavior:s,startedAt:o,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:n="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:n});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:n})},this.getTotalSize=()=>{var n;const s=this.getMeasurements();let r;if(s.length===0)r=this.options.paddingStart;else if(this.options.lanes===1){const o=s.length-1,i=this._flatMeasurements;i!=null?r=i[o*2]+i[o*2+1]:r=((n=s[o])==null?void 0:n.end)??0}else{const o=Array(this.options.lanes).fill(null);let i=s.length-1;for(;i>=0&&o.some(l=>l===null);){const l=s[i];o[l.lane]===null&&(o[l.lane]=l.end),i--}r=Math.max(...o.filter(l=>l!==null))}return Math.max(r-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const n=[];if(this.itemSizeCache.size===0)return n;const s=this.getMeasurements();for(const r of s)r&&this.itemSizeCache.has(r.key)&&n.push({index:r.index,key:r.key,start:r.start,size:r.size,end:r.end,lane:r.lane});return n},this._scrollToOffset=(n,{adjustments:s,behavior:r})=>{this._intendedScrollOffset=n+(s??0),this.options.scrollToFn(n,{behavior:r,adjustments:s},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(t)}applyScrollAdjustment(t,n){t!==0&&(Tne()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=t:this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=t,behavior:n}))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const s=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,r=s?s[0]:this.scrollState.lastTargetOffset,o=1,i=r!==this.scrollState.lastTargetOffset;if(!i&&bXt(r,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=o){this.getScrollOffset()!==r&&this._scrollToOffset(r,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,i){const l=this.getSize()||600,c=Math.abs(r-this.getScrollOffset()),d=this.scrollState.behavior==="smooth"&&c>l;this.scrollState.lastTargetOffset=r,d||(this.scrollState.behavior="auto"),this._scrollToOffset(r,{adjustments:void 0,behavior:d?"smooth":"auto"})}this.scheduleScrollReconcile()}}const SJe=(e,t,n,s)=>{for(;e<=t;){const r=(e+t)/2|0,o=n(r);if(o<s)e=r+1;else if(o>s)t=r-1;else return r}return e>0?e-1:0};function NXt({measurements:e,outerSize:t,scrollOffset:n,lanes:s,flat:r}){const o=e.length-1,i=r?h=>r[h*2]:h=>e[h].start,l=r?h=>r[h*2]+r[h*2+1]:h=>e[h].end;if(e.length<=s)return{startIndex:0,endIndex:o};let c=SJe(0,o,i,n),d=c;if(s===1)for(;d<o&&l(d)<n+t;)d++;else if(s>1){const h=Array(s).fill(0);for(;d<o&&h.some(p=>p<n+t);){const p=e[d];h[p.lane]=p.end,d++}const f=Array(s).fill(n+t);for(;c>=0&&f.some(p=>p>=n);){const p=e[c];f[p.lane]=p.start,c--}c=Math.max(0,c-c%s),d=Math.min(o,d+(s-1-d%s))}return{startIndex:c,endIndex:d}}const Ine=typeof document<"u"?u.useLayoutEffect:u.useEffect;function MXt({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n="transform",...s}){const r=u.useReducer(d=>d+1,0)[1],o=u.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});o.current.enabled=t,o.current.mode=n;const i=d=>{const h=o.current;if(!h.enabled)return;const f=d.getTotalSize();if(h.container&&f!==h.lastSize){h.lastSize=f;const w=d.options.horizontal?"width":"height";h.container.style[w]=`${f}px`}const p=!!d.options.horizontal,m=h.mode==="transform",g=p?"left":"top",v=d.options.scrollMargin,y=d.getVirtualItems();for(const w of y){const b=w.start-v,x=d.elementsCache.get(w.key);x&&h.lastPositions.get(x)!==b&&(h.lastPositions.set(x,b),m?x.style.transform=p?`translate3d(${b}px, 0, 0)`:`translate3d(0, ${b}px, 0)`:x.style[g]=`${b}px`)}},l={...s,onChange:(d,h)=>{var f;const p=o.current;let m=!0;if(p.enabled){i(d);const g=d.range,v=p.prevRange;m=!v||v.isScrolling!==d.isScrolling||v.startIndex!==g?.startIndex||v.endIndex!==g?.endIndex,m&&(p.prevRange=g?{startIndex:g.startIndex,endIndex:g.endIndex,isScrolling:d.isScrolling}:null)}m&&(e&&h?$d.flushSync(r):r()),(f=s.onChange)==null||f.call(s,d,h)}},[c]=u.useState(()=>{const d=new jXt(l);return Object.assign(d,{containerRef:h=>{const f=o.current;if(f.container=h,f.lastSize=null,h&&f.enabled){const p=d.getTotalSize();f.lastSize=p;const m=d.options.horizontal?"width":"height";h.style[m]=`${p}px`}}})});return c.setOptions(l),Ine(()=>c._didMount(),[]),Ine(()=>c._willUpdate()),Ine(()=>{i(c)}),c}function rve(e){return MXt({observeElementRect:SXt,observeElementOffset:IXt,scrollToFn:AXt,...e})}function Rce(e){return e.role==="tool_group"&&!e.id.startsWith("summary-")&&e.tools.length===1&&tf(e.tools[0])}function Rne(e){return e.role==="tool_group"&&!e.id.startsWith("summary-")&&e.tools.length===1&&yg(e.tools[0])}function RAe(e){return e.role==="thinking"}function PXt(e){const t=[];let n=0;for(;n<e.length;){if(Rne(e[n])){const s=[];let r=n;for(;r<e.length;){const o=e[r];if(Rne(o)){s.push(o),r+=1;continue}if(RAe(o)){let i=r+1;for(;i<e.length&&RAe(e[i]);)i+=1;if(i<e.length&&Rne(e[i])){r=i;continue}}break}if(s.length>=2){t.push({type:"parallel_agents",key:`par-${s[0].id}`,turnId:s[0].id,agents:s.map(o=>o.tools[0]),timestamp:s[0].timestamp}),n=r;continue}}if(Rce(e[n])){const s=n;for(;n<e.length&&Rce(e[n]);)n+=1;if(n-s>=2){const r=e.slice(s,n);t.push({type:"parallel_agents",key:`par-${r[0].id}`,turnId:r[0].id,agents:r.map(o=>o.tools[0]),timestamp:r[0].timestamp})}else t.push({type:"message",key:e[s].id,message:e[s]})}else t.push({type:"message",key:e[n].id,message:e[n]}),n+=1}return t}const dJ=u.createContext(!1),ove=u.createContext(new Map),CJe=u.createContext(new Map);function TJe({timeline:e,details:t,children:n}){return a.jsx(ove.Provider,{value:e,children:a.jsx(CJe.Provider,{value:t,children:n})})}function DXt(e){return e<1e3?`${e}`:e<1e4?`${(e/1e3).toFixed(1)}k`:`${Math.floor(e/1e3)}k`}function Jc(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:`${e}`}function VN(e){const t=Math.round(e);return Math.abs(t)<1e6?t.toLocaleString():`${(t/1e6).toFixed(1)}M`}function IJe(e){const t=Math.max(0,Math.ceil(e/1e3));if(t<60)return`${t}s`;const n=Math.floor(t/60),s=t-n*60;return`${n}m ${s}s`}function LXt({renderMode:e,sessionId:t,options:n}){return e==="interactive"&&t!==void 0&&n!==void 0&&n.enabled!==!1}function OXt(e,t){if(e)try{e(t)}catch(n){console.warn("[web-shell] assistant feedback handler threw:",n)}}const RJe="qwen-web-shell-assistant-feedback",EAe=10;function AAe(e){const t=e.content.trim();return{text:t.length>0?t.slice(-100):[(e.images?.length??0)>0?"[图片]":void 0,(e.files?.length??0)>0?"[附件]":void 0].filter(s=>s!==void 0).join(" "),...e.timestamp!==void 0?{timestamp:e.timestamp}:{}}}function BXt(e,t){const n=e.find(s=>s.id===t);return!n||n.role==="user"||n.role==="user_shell"?AAe({content:n?.command??n?.content??"",images:n?.images,files:n?.files,timestamp:n?.timestamp}):AAe({content:""})}const EJe=1,$Xt=new Set(["up","down"]);function FXt(e){return typeof e=="string"&&$Xt.has(e)}function AJe(e){const t=Object.keys(e);if(t.length<=EAe)return e;const n={};for(const s of t.slice(-EAe))n[s]=e[s];return n}function zXt(){if(typeof window>"u")return{};let e;try{const r=window.localStorage.getItem(RJe);if(!r)return{};e=JSON.parse(r)}catch{return{}}if(!e||typeof e!="object"||Array.isArray(e))return{};const{v:t,...n}=e;if(t!==void 0&&t!==EJe)return{};const s={};for(const[r,o]of Object.entries(n)){if(!r||!o||typeof o!="object"||Array.isArray(o))continue;const i={};for(const[l,c]of Object.entries(o))l&&FXt(c)&&(i[l]=c);Object.keys(i).length>0&&(s[r]=i)}return AJe(s)}function UXt(e){if(!(typeof window>"u"))try{window.localStorage.setItem(RJe,JSON.stringify({v:EJe,...AJe(e)}))}catch(t){console.warn("[web-shell] failed to persist assistant feedback:",t)}}function WXt(e,t,n,s){if(!t||!n)return e;const r={...e[t]??{}};s===null?delete r[n]:r[n]=s;const o={...e};return delete o[t],Object.keys(r).length>0&&(o[t]=r),o}const HXt={};function qXt(e){const[t,n]=u.useState(zXt),s=u.useRef(t),r=u.useRef(t);r.current=t;const o=u.useCallback((l,c)=>{!e||!l||n(d=>WXt(d,e,l,c))},[e]),i=u.useCallback(l=>e&&l?r.current[e]?.[l]:void 0,[e]);return u.useEffect(()=>{t!==s.current&&UXt(t)},[t]),{ratings:e&&t[e]||HXt,rate:o,ratingForTurn:i}}const VXt="_row_1cgka_1",GXt="_toolGroupSpacing_1cgka_6",KXt="_tip_1cgka_48",YXt="_chatRow_1cgka_75",JXt="_chatTip_1cgka_33",XXt="_chatActions_1cgka_34",QXt="_copyButton_1cgka_34",C1={row:VXt,toolGroupSpacing:GXt,tip:KXt,chatRow:YXt,chatTip:JXt,chatActions:XXt,copyButton:QXt};function Ece({timestamp:e,hideTimestamp:t=!1,children:n,chatMode:s=!1,toolGroupSpacing:r=!1,copyText:o,copyTitle:i="Copy",onEdit:l,editTitle:c="Edit",onDelete:d,deleteDisabled:h=!1,deleteTitle:f="Delete messages",onOpenTurnCalls:p,turnCallsTitle:m="View tool calls"}){const{t:g}=Xe(),v=_c()==="document",[y,w]=Ck(),[b,x]=u.useState(!1),k=u.useRef(void 0),_=u.useRef(!1),S=u.useRef(null),R=u.useRef(!1),j=()=>clearTimeout(k.current),E=()=>{j(),_.current=!1},I=()=>{j(),_.current&&(k.current=setTimeout(()=>x(!1),120))};u.useEffect(()=>()=>clearTimeout(k.current),[]);const C=u.useCallback(()=>{o&&cp(o).then(()=>{w()}).catch(iy)},[o,w]);if(v)return a.jsx(a.Fragment,{children:n});if(e===void 0&&!o&&!r&&!l&&!d&&!p)return a.jsx(a.Fragment,{children:n});const N=o?a.jsx("button",{type:"button",className:C1.copyButton,title:i,"aria-label":i,onClick:C,children:y?a.jsx(eQt,{}):a.jsx(ZXt,{})}):null,A=l||d||p?a.jsxs(sf,{open:b,onOpenChange:P=>{j(),x(P)},modal:!1,children:[a.jsx(Nh,{asChild:!0,children:a.jsx("button",{type:"button",className:C1.copyButton,"aria-label":g("message.moreActions"),onPointerEnter:P=>{P.pointerType==="mouse"&&(j(),b||(S.current=document.activeElement instanceof HTMLElement?document.activeElement:null,_.current=!0,R.current=!0,x(!0)))},onPointerLeave:I,onPointerDown:P=>{P.pointerType==="mouse"&&P.button===0&&!P.ctrlKey&&b&&P.preventDefault(),E()},onKeyDown:E,children:a.jsx(Nb,{strokeWidth:1.6,"aria-hidden":"true"})})}),a.jsxs(Mh,{align:"end",className:"w-max max-w-72",onPointerEnter:j,onPointerLeave:I,onKeyDown:E,onPointerDown:E,onFocusCapture:P=>{_.current&&R.current&&P.target===P.currentTarget&&(R.current=!1,S.current?.focus({preventScroll:!0}))},onFocusOutside:P=>{_.current&&P.preventDefault()},onCloseAutoFocus:P=>{_.current&&P.preventDefault()},children:[p&&a.jsxs(Mr,{onSelect:p,children:[a.jsx(hL,{strokeWidth:1.6,"aria-hidden":"true"}),m]}),l&&a.jsxs(Mr,{onSelect:l,children:[a.jsx(tQt,{}),c]}),d&&a.jsxs(Mr,{variant:"destructive",disabled:h,onSelect:d,children:[a.jsx(Ef,{strokeWidth:1.6,"aria-hidden":"true"}),f]})]})]}):null,M=s?C1.chatRow:r?`${C1.row} ${C1.toolGroupSpacing}`:C1.row;return e===void 0||t?a.jsxs("div",{className:M,children:[n,N,A]}):a.jsxs("div",{className:M,children:[n,s?a.jsxs("span",{className:C1.chatActions,"data-menu-open":b||void 0,children:[a.jsx("span",{className:C1.chatTip,"aria-hidden":"true",children:H_(e)}),N,A]}):a.jsx("span",{className:C1.tip,"aria-hidden":"true",children:H_(e)}),!s&&A]})}function ZXt(){return a.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[a.jsx("path",{d:"M5.2 4.4V3.2c0-.7.5-1.2 1.2-1.2h5.4c.7 0 1.2.5 1.2 1.2v5.4c0 .7-.5 1.2-1.2 1.2h-1.2",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.3"}),a.jsx("rect",{x:"3",y:"5.2",width:"7.8",height:"7.8",rx:"1.2",fill:"none",stroke:"currentColor",strokeWidth:"1.3"})]})}function eQt(){return a.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:a.jsx("path",{d:"m3.5 8.3 3 3L12.8 5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function tQt(){return a.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:a.jsx("path",{d:"M11.1 2.6a1.4 1.4 0 0 1 2 2l-7.2 7.2-2.7.7.7-2.7 7.2-7.2Z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.3"})})}function H_(e,t=new Date){const n=new Date(e),s=i=>String(i).padStart(2,"0"),r=`${s(n.getHours())}:${s(n.getMinutes())}:${s(n.getSeconds())}`;return n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()?r:`${n.getFullYear()}-${s(n.getMonth()+1)}-${s(n.getDate())} ${r}`}const nQt="/assets/csv-CX7rUNeC.svg",sQt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%3e%3cdefs%3e%3cclipPath%20id='master_svg0_1249_010672'%3e%3crect%20x='-1.6500000953674316'%20y='-1.6500000953674316'%20width='27.300000190734863'%20height='27.300000190734863'%20rx='0'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23master_svg0_1249_010672)'%3e%3cpath%20d='M13.0999994,2.90000004L4.9027524,2.90000004L4.89999723,4.0022497L4.90000004,8L4.90000004,21.1L18.000000999999997,21.1L19.099995,21.102751L19.099999,8.899999099999999L15.997778,8.8999968L13.0999947,8.8928347L13.0999994,2.90000004ZM20.9,7.0999961L20.9,8.9000039L20.899994,22.907261L18.000000999999997,22.9L3.09999996,22.9L3.09999996,8L3.10000277,3.9977504L3.10724592,1.0999999599999999L13.0999966,1.10000002L15.372792,1.10000002L20.9,6.6272078L20.9,7.0999961ZM14.9,3.1727920000000003L14.899996,7.0972781L16.002228000000002,7.1000028L18.827209,7.1000009L14.9,3.1727920000000003Z'%20fill-rule='evenodd'%20fill='%233B82F6'%20fill-opacity='1'/%3e%3cline%20x1='7.5'%20y1='8.924999952316284'%20x2='10.5'%20y2='8.924999952316284'%20fill-opacity='0'%20stroke-opacity='1'%20stroke='%233B82F6'%20fill='none'%20stroke-width='1.6500000953674316'/%3e%3cline%20x1='7.5'%20y1='12.974804639816284'%20x2='16.5'%20y2='12.974804639816284'%20fill-opacity='0'%20stroke-opacity='1'%20stroke='%233B82F6'%20fill='none'%20stroke-width='1.6500000953674316'/%3e%3cline%20x1='7.5'%20y1='17.024853467941284'%20x2='16.5'%20y2='17.024853467941284'%20fill-opacity='0'%20stroke-opacity='1'%20stroke='%233B82F6'%20fill='none'%20stroke-width='1.6500000953674316'/%3e%3c/g%3e%3c/svg%3e",rQt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%3e%3cdefs%3e%3cclipPath%20id='master_svg0_1249_010844'%3e%3crect%20x='-0.9000000357627869'%20y='-0.9000000357627869'%20width='25.800000071525574'%20height='25.800000071525574'%20rx='0'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23master_svg0_1249_010844)'%3e%3cpath%20d='M14.5999994,2.90000004L6.40275115,2.90000004L6.40000004,4L6.40000004,8L6.40000403,8.9000039L4.59999597,8.9000039L4.6000000199999995,8L4.59999996,4L4.60724592,1.0999999599999999L14.5999966,1.10000002L16.872792,1.10000002L22.4,6.6272078L22.4,8.9000039L22.399994,22.907261L19.497748,22.899998L5.5,22.9L4.59999597,22.900003L4.59999597,21.099997L5.5,21.1L19.502254,21.100002L20.599995,21.102749L20.599999,8.899999099999999L17.497778,8.8999968L14.5999947,8.8928347L14.5999994,2.90000004ZM20.327209,7.1000009L16.4,3.1727920000000003L16.399996,7.0972781L17.502228000000002,7.1000028L20.327209,7.1000009Z'%20fill-rule='evenodd'%20fill='%233B82F6'%20fill-opacity='1'/%3e%3cpath%20d='M8.2472,10.31611514L8.0316916,11.03448913L5.7816916,18.5344892L5.5661762,19.252861L7.0029221,19.6838846L7.2184305,18.9655108L9.4684305,11.46551092L9.683945699999999,10.74713892L8.2472,10.31611514ZM10.0391884,12.5998073L10.5695,13.1301606L12.1392298,14.700027200000001L10.5695467,16.2695727L10.0391884,16.7998805L11.0998077,17.8605919L11.6301603,17.3302798L14.26055,14.7001195L11.6302071,12.06954658L11.0998993,11.539188620000001L10.0391884,12.5998073ZM4.3499999,11.53933477L3.8196697,12.06966972L1.1893398,14.6999998L3.81967,17.3303294L4.3499999,17.8606644L5.410665,16.799999200000002L4.8803301,16.2696691L3.3106603999999997,14.6999996L4.8803301,13.1303298L5.410665,12.599999799999999L4.3499999,11.53933477Z'%20fill-rule='evenodd'%20fill='%233B82F6'%20fill-opacity='1'/%3e%3c/g%3e%3c/svg%3e",oQt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%3e%3cdefs%3e%3cclipPath%20id='master_svg0_1249_010645'%3e%3crect%20x='-0.9000000357627869'%20y='-0.9000000357627869'%20width='25.800000071525574'%20height='25.800000071525574'%20rx='0'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23master_svg0_1249_010645)'%3e%3cpath%20d='M5,2.09999996L2.09999996,2.09999996L2.09999996,21.900002L21.900002,21.900002L21.900002,2.09999996L5,2.09999996ZM3.90000004,3.90000004L3.90000004,20.1L5.6271498,20.1L14.449604,11.2775459Q15.299037,10.428369499999999,16.5,10.428369499999999Q17.700962,10.428369499999999,18.550300999999997,11.2774506L20.1,12.8271494L20.1,3.90000004L3.90000004,3.90000004ZM20.1,15.372734L17.2777,12.5504351Q16.955538,12.2283688,16.5,12.2283688Q16.044463,12.2283688,15.722396,12.5503387L8.1727347,20.1L20.1,20.1L20.1,15.372734ZM11.0506096,6.9493902Q10.2012191,6.0999999,9,6.0999999Q7.7987804,6.0999999,6.9493902,6.9493902Q6.0999999,7.7987804,6.0999999,9Q6.0999999,10.2012196,6.9493902,11.0506096Q7.7987804,11.8999996,9,11.8999996Q10.2012196,11.8999996,11.0506096,11.0506096Q11.8999996,10.2012196,11.8999996,9Q11.8999996,7.7987804,11.0506096,6.9493902ZM8.2221823,8.2221823Q8.5443645,7.9000001,9,7.9000001Q9.4556355,7.9000001,9.7778177,8.2221823Q10.0999999,8.5443645,10.0999999,9Q10.0999999,9.4556355,9.7778177,9.7778177Q9.4556355,10.0999999,9,10.0999999Q8.5443645,10.0999999,8.2221823,9.7778177Q7.9000001,9.4556355,7.9000001,9Q7.9000001,8.5443645,8.2221823,8.2221823Z'%20fill-rule='evenodd'%20fill='%236366F1'%20fill-opacity='1'/%3e%3c/g%3e%3c/svg%3e",iQt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%3e%3cdefs%3e%3cclipPath%20id='master_svg0_1249_010669'%3e%3crect%20x='-0.9000000357627869'%20y='-0.9000000357627869'%20width='25.800000071525574'%20height='25.800000071525574'%20rx='0'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23master_svg0_1249_010669)'%3e%3cpath%20d='M16.105598320312502,0.9819171499999999L12.0384463203125,5.0388078499999995L11.4012413203125,5.67439985L12.6724303203125,6.94880435L13.3096293203125,6.31320665L16.103991320312502,3.52589535L20.9187853203125,8.340691549999999L13.8082283203125,15.45124725L10.9681396203125,12.60835625L10.3320570203125,11.97164155L9.0586319203125,13.24381125L9.6947193203125,13.88052225L13.8076013203125,17.99746025L23.4643703203125,8.340692050000001L16.105598320312502,0.9819171499999999ZM7.5908932203125,24.19715725L11.6427193203125,20.14534025L12.2791223203125,19.50894525L11.0063267203125,18.236146249999997L10.3699293203125,18.87254725L7.5908899203125,21.65157725L2.7768222203125,16.83753925L9.8787708203125,9.73558855L12.7211163203125,12.57705025L13.3576113203125,13.21335225L14.6302113203125,11.94035625L13.9937103203125,11.30405905L9.8785724203125,7.19020225L0.23123422031249996,16.83754425L7.5908932203125,24.19715725Z'%20fill-rule='evenodd'%20fill='%233B82F6'%20fill-opacity='1'/%3e%3c/g%3e%3c/svg%3e",aQt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%3e%3cdefs%3e%3cclipPath%20id='master_svg0_1249_013677'%3e%3crect%20x='-0.9000000357627869'%20y='-0.9000000357627869'%20width='25.800000071525574'%20height='25.800000071525574'%20rx='0'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23master_svg0_1249_013677)'%3e%3cpath%20d='M13.1048822125,2.90000004L4.9076339625,2.90000004L4.9048828525,4L4.9048828525,17.999940000000002L4.9048868425,18.899942L3.1048787825,18.899942L3.1048828325,17.999938999999998L3.1048827725,4L3.1121287325,1.0999999599999999L13.1048794125,1.10000002L15.3776748125,1.10000002L20.9048828125,6.6272078L20.9048828125,8.9000039L20.9048768125,22.907261L18.0026308125,22.899998L4.0048828125,22.9L3.1048787825,22.900003L3.1048787825,21.099997L4.0048828125,21.1L18.0071368125,21.100002L19.1048778125,21.102749L19.1048818125,8.899999099999999L16.0026608125,8.8999968L13.1048775125,8.8928347L13.1048822125,2.90000004ZM18.8320918125,7.1000009L14.9048828125,3.1727920000000003L14.9048788125,7.0972781L16.007110812500002,7.1000028L18.8320918125,7.1000009Z'%20fill-rule='evenodd'%20fill='%233B82F6'%20fill-opacity='1'/%3e%3cg%20transform='matrix(0,1,1,0,-2.98974609375,2.98974609375)'%3e%3cpath%20d='M8.25,19.556722593750003L15.749999500000001,19.556722593750003L15.749999500000001,17.95672229375L10.649999600000001,17.95672229375L13.7413173,15.63823409375L13.7413173,14.35823419375L10.649999900000001,12.03974610375L15.749999500000001,12.03974610375L15.749999500000001,10.43974608375L8.25,10.43974608375L7.76999995,11.87974608375L11.927984,14.99823399375L7.76999995,18.11672209375L8.25,19.556722593750003Z'%20fill-rule='evenodd'%20fill='%233B82F6'%20fill-opacity='1'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",lQt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%3e%3cdefs%3e%3cclipPath%20id='master_svg0_1249_010643'%3e%3crect%20x='0'%20y='0'%20width='24'%20height='24'%20rx='0'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23master_svg0_1249_010643)'%3e%3cpath%20d='M19.581645546875,17.236587468750002C18.007026546875,17.11962746875,16.490728546874998,16.53484746875,15.266022546875,15.48223746875C12.874935546875,16.00854146875,10.600484846875,16.768759468749998,8.326035046874999,17.70441046875C6.518139346875,20.92071546875,4.826881446874999,22.55810746875,3.368900746875,22.55810746875C3.077304846875,22.55810746875,2.7273894468749997,22.49962646875,2.494112486875,22.32419246875C1.852600936875,22.03180146875,1.502685546875,21.38854046875,1.502685546875,20.74527946875C1.502685546875,20.21897546875,1.619323996875,18.75701946875,7.159650346875,16.35941046875C8.442673646875,14.02027846875,9.434100646874999,11.62267246875,10.250569346875,9.10810756875C9.550739246875,7.70462986875,8.034439046875,4.25441266875,9.084185646875,2.50006532875C9.434100646874999,1.85680561875,10.133930246875,1.50593611275,10.892080346875,1.56441435035C11.475273146875,1.56441435035,12.058465546875,1.85680558875,12.408380546875,2.32463156875C13.166530546875,3.37724006875,13.108210546875,5.59941386875,12.116784546875,8.874196068749999C13.049892546875,10.62854196875,14.274595546875,12.20745446875,15.732575546875,13.55245546875C16.957279546875,13.31854246875,18.181981546875,13.14310746875,19.406686546875,13.14310746875C22.147691546875,13.20158546875,22.555925546875,14.48810746875,22.497604546875,15.24832546875C22.497604546875,17.236587468750002,20.573070546875,17.236587468750002,19.581645546875,17.236587468750002ZM3.252262246875,20.86223646875L3.427219846875,20.80375646875C4.243689046875,20.51136746875,4.885200546875,19.92658646875,5.351754146875,19.16636646875C4.476965946875,19.51723446875,3.777135146875,20.10201846875,3.252262246875,20.86223646875ZM11.008718446875,3.31876086875L10.833761246875,3.31876086875C10.775442146875,3.31876086875,10.658803946875,3.31876086875,10.600484846875,3.37723926875C10.367207546875,4.37136936875,10.542164846875,5.423977868750001,10.950399446875,6.35962966875C11.300315846875,5.36549946875,11.300315846875,4.3128909687500006,11.008718446875,3.31876086875ZM11.416953046875,11.79810746875L11.358633046875,11.91506346875L11.300313946875,11.85658446875C10.775441146875,13.20158446875,10.192249346875,14.54658646875,9.550737346875,15.83310746875L9.667376546875,15.77462846875L9.667376546875,15.89158646875C10.950399446875,15.42375946875,12.350061546875,15.01441146875,13.633083546875,14.72202146875L13.574764546875,14.66354146875L13.749721546875,14.66354146875C12.874933546875,13.78636746875,12.058464546875,12.79223846875,11.416953046875,11.79810746875ZM19.348367546875,14.89745546875C18.823495546875,14.89745546875,18.356941546875,14.89745546875,17.832069546875,15.01441046875C18.415262546875,15.30680046875,18.998453546875,15.42375746875,19.581645546875,15.48223746875C19.989879546875,15.54071646875,20.398113546875,15.48223746875,20.748029546875,15.36528046875C20.748029546875,15.18984646875,20.514753546875,14.89745546875,19.348367546875,14.89745546875Z'%20fill='%23EF4444'%20fill-opacity='1'/%3e%3c/g%3e%3c/svg%3e",cQt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%3e%3cdefs%3e%3cclipPath%20id='master_svg0_1249_010627'%3e%3crect%20x='-0.9000000357627869'%20y='-0.9000000357627869'%20width='25.800000071525574'%20height='25.800000071525574'%20rx='0'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23master_svg0_1249_010627)'%3e%3cpath%20d='M5,2.09999996L2.09999996,2.09999996L2.09999996,8.0999961L2.09999597,9.9000039L2.09999996,14.099996L2.09999597,15.900004L2.09999996,21.900002L8.0999961,21.900002L9.9000039,21.900003L14.099996,21.900002L15.900004,21.900003L19,21.900002L21.900002,21.900002L21.900002,2.09999996L5,2.09999996ZM20.1,8.100000399999999L20.1,3.90000004L3.90000004,3.90000004L3.90000004,8.100000399999999L20.1,8.100000399999999ZM14.1,9.9000001L9.9000001,9.9000001L9.9000001,14.1L14.1,14.1L14.1,9.9000001ZM15.900001,14.1L15.900001,9.9000001L20.1,9.9000001L20.1,14.1L15.900001,14.1ZM14.1,15.900001L9.9000001,15.900001L9.9000001,20.1L14.1,20.1L14.1,15.900001ZM15.900001,20.1L15.900001,15.900001L20.1,15.900001L20.1,20.1L15.900001,20.1ZM8.100000399999999,20.1L8.100000399999999,15.900001L3.90000004,15.900001L3.90000004,20.1L8.100000399999999,20.1ZM3.90000004,14.1L8.100000399999999,14.1L8.100000399999999,9.9000001L3.90000004,9.9000001L3.90000004,14.1Z'%20fill-rule='evenodd'%20fill='%2314B8A6'%20fill-opacity='1'/%3e%3c/g%3e%3c/svg%3e",dQt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%3e%3cdefs%3e%3cclipPath%20id='master_svg0_1249_010806'%3e%3crect%20x='-0.9000000357627869'%20y='-0.9000000357627869'%20width='25.800000071525574'%20height='25.800000071525574'%20rx='0'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23master_svg0_1249_010806)'%3e%3cpath%20d='M17.9502339453125,16.500137000000002L17.9502339453125,7.4998626999999995L17.9571569453125,4.34999996L0.6429908253125,4.34999996L0.6501731253125,7.5020506000000005L0.6501708053125,16.500000999999997L0.6429908253125,19.650001L17.9571569453125,19.650001L17.9502339453125,16.500137000000002ZM16.1502319453125,7.4998626999999995L16.1502319453125,16.500137000000002L16.150234945312498,16.502115L16.1531969453125,17.85L2.4470961653125,17.85L2.4501708753124998,16.500000999999997L2.4501686053125002,7.4979493999999995L2.4470971253125002,6.15000004L16.1531969453125,6.15000004L16.1502319453125,7.4998626999999995Z'%20fill-rule='evenodd'%20fill='%236366F1'%20fill-opacity='1'/%3e%3cg%20transform='matrix(0,1,1,0,9.60009765625,-9.60009765625)'%3e%3cpath%20d='M22.12149765625,7.03664169Q21.85288765625,6.5999999,21.34020085625,6.5999999L20.35991075625,6.5999999Q19.84723715625,6.5999999,19.57860375625,7.03665763L16.34978669625,12.284925000000001Q16.06778135625,12.7433271,16.33034050625,13.213119500000001Q16.59290134625,13.682915699999999,17.13108936325,13.682915699999999L24.56910565625,13.682915699999999Q25.10730455625,13.682915699999999,25.36986255625,13.2131057Q25.63241485625,12.7433052,25.35040475625,12.2849197L22.12149765625,7.03664169ZM20.85005875625,8.40513563L18.71047415625,11.882915L22.98969885625,11.882915L20.85005875625,8.40513563Z'%20fill-rule='evenodd'%20fill='%236366F1'%20fill-opacity='1'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",uQt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%3e%3cdefs%3e%3cclipPath%20id='master_svg0_1249_010629'%3e%3crect%20x='-0.9000000357627869'%20y='-0.9000000357627869'%20width='25.800000071525574'%20height='25.800000071525574'%20rx='0'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23master_svg0_1249_010629)'%3e%3cpath%20d='M13.105126353125,2.90000004L4.909844933125,2.90000004L4.905126993125,18.000122L4.9051269331250005,18.000404L4.905130983125,18.900126L3.105122923125,18.900126L3.105126973125,18.000122L4.003604110525,18.000122L3.105126973125,17.999841L3.110407233125,1.0999999599999999L13.105123553125,1.10000002L15.377918953125,1.10000002L20.905126953125,6.6272078L20.905126953125,8.9000039L20.905120953125,22.907261L18.002874953125,22.899998L4.005126953125,22.9L3.105122923125,22.900003L3.105122923125,21.099997L4.005126953125,21.1L18.007380953125,21.100002L19.105121953125,21.102749L19.105125953125,8.899999099999999L16.002904953125,8.8999968L13.105121653125,8.8928347L13.105126353125,2.90000004ZM18.832335953125,7.1000009L14.905126953125,3.1727920000000003L14.905122953125,7.0972781L16.007354953125002,7.1000028L18.832335953125,7.1000009Z'%20fill-rule='evenodd'%20fill='%233B82F6'%20fill-opacity='1'/%3e%3cg%3e%3cpath%20d='M11.5241466,15.1333303L10.624145500000001,18.5L8.8103027,18.5L7.11073983,12.1256101L6.84411621,11.1256101L8.5675049,11.1256101L9.3246179,14.581996L9.6624756,16.1243896Q9.733741,16.4522104,9.7623343,16.9507189Q9.762393,16.9517393,9.762451200000001,16.952758799999998L9.7957764,16.952758799999998Q9.7958345,16.9518032,9.7958934,16.9508476Q9.8198829,16.5612478,9.9433594,16.1005864L10.3543289,14.6093936L11.3144531,11.1256101L12.985473599999999,11.1256101L13.8162313,14.4803481L14.2327881,16.1624756Q14.3088741,16.4620614,14.3517089,16.9421387Q14.351758,16.942688,14.3518062,16.9432373L14.3756104,16.9432373Q14.375659899999999,16.9421721,14.3757091,16.9411077Q14.3948865,16.5280361,14.4851069,16.1339111L14.8423223,14.4637313L15.5562735,11.1256101L17.151123,11.1256101L16.8845,12.1256101L15.1849365,18.5L13.4377441,18.5L12.5584936,15.1362009L12.180907699999999,13.6916504Q12.0811496,13.3021169,12.0619726,12.879402200000001Q12.0619307,12.8784828,12.0618892,12.877563L12.0428462,12.877563Q12.0428052,12.877993100000001,12.0427637,12.8784232Q11.9951653,13.3729568,11.909545900000001,13.6916504L11.5241466,15.1333303Z'%20fill-rule='evenodd'%20fill='%233B82F6'%20fill-opacity='1'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e";function kF(e){const t=new URL(e);return t.hostname=t.hostname.replace(/\.$/,""),(t.hostname==="localhost"||t.hostname==="[::1]"||t.hostname==="0.0.0.0"||t.hostname==="host.docker.internal"||t.hostname.endsWith(".localhost")||/^127\./.test(t.hostname))&&(t.hostname="localhost"),t.origin}function Ace(e,t,n){try{const s=new URL(e.trim());if(!["http:","https:"].includes(s.protocol)||s.username||s.password||s.hostname.endsWith(".")||!/^[a-z0-9._-]+$/i.test(s.hostname))return;const r=[kF(new URL(t)),kF(new URL(n,t))],o=new URL(s);return o.protocol="https:",r.includes(kF(s))||r.includes(kF(o))?void 0:s}catch{return}}function H8(e){return e.replaceAll("&","&amp;").replaceAll('"',"&quot;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function hQt(e,t){const n=`default-src 'none'; script-src 'none'; style-src 'unsafe-inline'; frame-src ${e.origin}; base-uri 'none'; form-action 'none'`;return`<!doctype html><html><head>
1919
1919
  <meta http-equiv="Content-Security-Policy" content="${H8(n)}">
@@ -1922,7 +1922,7 @@ License: MIT
1922
1922
  </head><body><iframe title="${H8(t)}" src="${H8(e.href)}" sandbox="allow-scripts allow-same-origin allow-forms" referrerpolicy="no-referrer"></iframe></body></html>`}function ive(e,t){const n=lve(t);if(ave.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 fQt=new Set([".doc",".docx",".docm",".dotx",".xls",".xlsx",".xlsm",".xlsb",".ppt",".pptx",".pptm",".odt",".ods",".odp"]),ave=new Set([".m4a",".mp3",".ogg",".wav"]),pQt=new Set([...fQt,...ave,".mp4",".mov",".webm"]);function M9(e,t){const n=D9(e);return n?n===".xlsx":xy(t)==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}const jce="application/vnd.openxmlformats-officedocument.wordprocessingml.document";function P9(e,t){const n=D9(e);return n?n===".docx":xy(t)===jce}function JT(e){return D9(e.workspacePath)===".pdf"||xy(e.mimeType)==="application/pdf"||e.kind==="pdf"}function jJe(e){if(M9(e.workspacePath,e.mimeType))return!1;const t=D9(e.workspacePath),n=xy(e.mimeType);return t===".svg"||n==="image/svg+xml"?!0:P9(e.workspacePath,e.mimeType)?!1:pQt.has(t)?!0:JT(e)||cve(e)||t===".md"||t===".markdown"||t===".html"||t===".htm"||n==="text/markdown"||n==="text/html"?!1:e.kind==="image"||e.kind==="document"||e.kind==="video"||e.kind==="audio"}function lve(e){return D9((e??"").split(/[?#]/,1)[0])}function D9(e){const t=(e??"").split(/[/\\]/).pop()??"",n=t.lastIndexOf(".");return n>=0?t.slice(n).toLowerCase():""}function mQt(e,t){return ave.has(lve(e))||xy(t).startsWith("audio/")}const gQt="qwen.workspace.sha256";function jAe(e){const t=e.metadata?.[gQt],n=typeof t=="string"?t:"";return`${e.status}:${e.updatedAt}:${n}`}function vQt(e){const t=e.metadata?.artifactType;return typeof t=="string"&&t?t:ive(e.kind,e.workspacePath??e.url??e.title)}function uJ(e){return e===void 0?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}const NJe={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"},wQt=100*1024*1024,yQt=256*1024;function xy(e){return e?.split(";",1)[0]?.trim().toLowerCase()??""}function cve(e){const t=xy(e.mimeType);return t.startsWith("image/")?t==="image/jpg"?"image/jpeg":Object.values(NJe).includes(t)?t:void 0:XT(e.workspacePath??"")}function XT(e){const t=e.toLowerCase(),n=t.includes(".")?t.split(".").pop():void 0;return n?NJe[n]:void 0}function bQt(e){return/\.html?$/i.test(e)?"text/html":"text/markdown"}async function j2(e,t,n,s){const r=[],o=s.maxBytes??wQt,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:yQt});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 d=atob(c.contentBase64),h=new Uint8Array(d.length);for(let f=0;f<d.length;f++)h[f]=d.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 L9(e,t,n="application/octet-stream",s){const r=await j2((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=dve(t)??t,i.addEventListener("click",l=>l.stopPropagation()),document.body.appendChild(i),i.click(),i.remove()}finally{setTimeout(()=>URL.revokeObjectURL(o),1e3)}}function xQt(e){return e.workspacePath??e.url??e.managedId??""}function O9(e){return dve(e.workspacePath)||e.title||"Artifact"}function dve(e){return e?.split("/").at(-1)||void 0}function QT(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 RL(e,t){const n=QT(e),s=QT(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 uve(e,t,n){const s=RL(e??"",n),r=RL(t??"",n);return!!s&&s===r}const Nce="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 MJe(e,t){return Mce(Pce(e),t)}function Mce(e,t){return`<!doctype html><html><head>
1923
1923
  <meta http-equiv="Content-Security-Policy" content="${Nce} frame-src 'none';">
1924
1924
  <style>html,body,iframe{width:100%;height:100%;margin:0;border:0;display:block;overflow:hidden}</style>
1925
- </head><body><iframe title="${H8(t)}" sandbox="allow-scripts" referrerpolicy="no-referrer" srcdoc="${H8(e)}"></iframe></body></html>`}let _F;async function kQt(e,t,n){if(_F?.content===e&&_F.title===t)return _F.document;const s=await _Qt(e,t,n);return _F={content:e,title:t,document:s},s}async function _Qt(e,t,n){if(typeof DOMParser>"u")return MJe(e,t);const s=new DOMParser().parseFromString(e,"text/html");if(!s.querySelector('script#transcript-document[type="application/json"]'))return Mce(Pce(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,d])=>{const h=s.querySelector(i),f=h?.getAttribute(l)??"",p=h?.getAttribute("integrity")??"";if(!h)return;const m=`https://unpkg.com/@qwen-code/qwen-code@0.0.3-beta/export-transcript-document.${c}`;if(f!==m||!/^sha384-[A-Za-z0-9+/]{64}$/.test(p))throw new Error("Unsupported export preview resource; use an export matching the current Web Shell version.");const g=await fetch(f,{integrity:p,signal:r.signal,credentials:"omit",referrerPolicy:"no-referrer",redirect:"error"});if(!g.ok)throw new Error(`Could not load export renderer (${g.status}).`);const v=new Blob([await g.arrayBuffer()],{type:d}),y=await new Promise((w,b)=>{const x=new FileReader;x.onload=()=>w(x.result),x.onerror=()=>b(x.error),x.readAsDataURL(v)});h.setAttribute(l,y),h.removeAttribute("integrity"),h.removeAttribute("crossorigin")}))}finally{n.removeEventListener("abort",o),r.abort()}return Mce(Pce(s),t)}function Pce(e){if(typeof e=="string"&&typeof DOMParser>"u")return`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="${Nce}"></head><body>${SQt(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=Nce,t.head.prepend(n),`<!doctype html>${t.documentElement.outerHTML}`}function SQt(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 PJe={csv:nQt,file:sQt,html:rQt,image:oQt,link:iQt,md:aQt,pdf:lQt,spreadsheet:cQt,video:dQt,word:uQt},CQt={csv:"csv",html:"html",image:"image",link:"link",markdown:"md",md:"md",pdf:"pdf",spreadsheet:"spreadsheet",video:"video",word:"word"},TQt={audio:Fge,document:HT,notebook:a6t},NAe={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 DJe(e){if(!e)return"file";const t=e.workspacePath??e.url??e.title,n=lve(t).slice(1);if(n&&NAe[n])return NAe[n];const s=xy(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":CQt[e.kind]??"file"}function LJe({artifact:e,className:t}){const{artifact:n}=Ph(),s=e?n?.renderImage?.(e):void 0;if(s!=null&&s!==!1)return s;const r=DJe(e),o=e?e.workspacePath??e.url??e.title:void 0,i=r==="file"&&e?mQt(o,e.mimeType)?"audio":e.kind:void 0,l=i?TQt[i]:void 0;return l?a.jsx(l,{className:t,"data-artifact-icon":i,"aria-hidden":"true"}):a.jsx("img",{className:t,src:PJe[r],"data-artifact-icon":r,alt:""})}const IQt=[[new Set(["json","jsonl","geojson"]),v3t],[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"]),Sq],[new Set(["zip","tar","gz","tgz","bz2","xz","7z","rar"]),w5t],[new Set(["csv","tsv","xls","xlsx","ods"]),I5t],[new Set(["ppt","pptx","odp"]),A6t],[new Set(["png","jpg","jpeg","gif","webp","bmp","ico","tif","tiff"]),aVe],[new Set(["mp3","wav","ogg","m4a","aac","flac"]),Fge],[new Set(["mp4","mov","webm","avi","mkv"]),lVe],[new Set(["txt","md","mdx","log","pdf","doc","docx","rtf"]),HT]];function RQt(e,t){const n=e.split(".").pop()?.toLowerCase()??"";for(const[s,r]of IQt)if(s.has(n))return r;return t?.startsWith("image/")?aVe:t?.startsWith("audio/")?Fge:t?.startsWith("video/")?lVe:t?.startsWith("text/")?HT:cVe}function Tb({name:e,mimeType:t,size:n=24,absoluteStrokeWidth:s,...r}){const o=RQt(e,t),i=DJe({kind:"file",title:e.replace(/[?#]/g,"_"),mimeType:t});return i!=="file"||o===cVe?a.jsx("svg",{width:n,height:n,...r,"data-file-type-icon":i,children:a.jsx("image",{href:PJe[i],width:"100%",height:"100%"})}):a.jsx(o,{size:n,absoluteStrokeWidth:s,...r})}const EQt="_icon_h5emn_1",AQt="_details_h5emn_13",jQt="_name_h5emn_23",NQt="_type_h5emn_24",SF={icon:EQt,details:AQt,name:jQt,type:NQt};function OJe({name:e,mimeType:t}){const s=/\.([^.\\/]+)$/.exec(e)?.[1]?.toUpperCase()||t||"FILE";return a.jsxs(a.Fragment,{children:[a.jsx("span",{className:SF.icon,children:a.jsx(Tb,{name:e,mimeType:t,size:24,"aria-hidden":"true"})}),a.jsxs("span",{className:SF.details,children:[a.jsx("span",{className:SF.name,title:e,children:e}),a.jsx("span",{className:SF.type,title:s,children:s})]})]})}/**
1925
+ </head><body><iframe title="${H8(t)}" sandbox="allow-scripts" referrerpolicy="no-referrer" srcdoc="${H8(e)}"></iframe></body></html>`}let _F;async function kQt(e,t,n){if(_F?.content===e&&_F.title===t)return _F.document;const s=await _Qt(e,t,n);return _F={content:e,title:t,document:s},s}async function _Qt(e,t,n){if(typeof DOMParser>"u")return MJe(e,t);const s=new DOMParser().parseFromString(e,"text/html");if(!s.querySelector('script#transcript-document[type="application/json"]'))return Mce(Pce(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,d])=>{const h=s.querySelector(i),f=h?.getAttribute(l)??"",p=h?.getAttribute("integrity")??"";if(!h)return;const m=`https://unpkg.com/@qwen-code/qwen-code@0.0.5-beta/export-transcript-document.${c}`;if(f!==m||!/^sha384-[A-Za-z0-9+/]{64}$/.test(p))throw new Error("Unsupported export preview resource; use an export matching the current Web Shell version.");const g=await fetch(f,{integrity:p,signal:r.signal,credentials:"omit",referrerPolicy:"no-referrer",redirect:"error"});if(!g.ok)throw new Error(`Could not load export renderer (${g.status}).`);const v=new Blob([await g.arrayBuffer()],{type:d}),y=await new Promise((w,b)=>{const x=new FileReader;x.onload=()=>w(x.result),x.onerror=()=>b(x.error),x.readAsDataURL(v)});h.setAttribute(l,y),h.removeAttribute("integrity"),h.removeAttribute("crossorigin")}))}finally{n.removeEventListener("abort",o),r.abort()}return Mce(Pce(s),t)}function Pce(e){if(typeof e=="string"&&typeof DOMParser>"u")return`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="${Nce}"></head><body>${SQt(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=Nce,t.head.prepend(n),`<!doctype html>${t.documentElement.outerHTML}`}function SQt(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 PJe={csv:nQt,file:sQt,html:rQt,image:oQt,link:iQt,md:aQt,pdf:lQt,spreadsheet:cQt,video:dQt,word:uQt},CQt={csv:"csv",html:"html",image:"image",link:"link",markdown:"md",md:"md",pdf:"pdf",spreadsheet:"spreadsheet",video:"video",word:"word"},TQt={audio:Fge,document:HT,notebook:a6t},NAe={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 DJe(e){if(!e)return"file";const t=e.workspacePath??e.url??e.title,n=lve(t).slice(1);if(n&&NAe[n])return NAe[n];const s=xy(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":CQt[e.kind]??"file"}function LJe({artifact:e,className:t}){const{artifact:n}=Ph(),s=e?n?.renderImage?.(e):void 0;if(s!=null&&s!==!1)return s;const r=DJe(e),o=e?e.workspacePath??e.url??e.title:void 0,i=r==="file"&&e?mQt(o,e.mimeType)?"audio":e.kind:void 0,l=i?TQt[i]:void 0;return l?a.jsx(l,{className:t,"data-artifact-icon":i,"aria-hidden":"true"}):a.jsx("img",{className:t,src:PJe[r],"data-artifact-icon":r,alt:""})}const IQt=[[new Set(["json","jsonl","geojson"]),v3t],[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"]),Sq],[new Set(["zip","tar","gz","tgz","bz2","xz","7z","rar"]),w5t],[new Set(["csv","tsv","xls","xlsx","ods"]),I5t],[new Set(["ppt","pptx","odp"]),A6t],[new Set(["png","jpg","jpeg","gif","webp","bmp","ico","tif","tiff"]),aVe],[new Set(["mp3","wav","ogg","m4a","aac","flac"]),Fge],[new Set(["mp4","mov","webm","avi","mkv"]),lVe],[new Set(["txt","md","mdx","log","pdf","doc","docx","rtf"]),HT]];function RQt(e,t){const n=e.split(".").pop()?.toLowerCase()??"";for(const[s,r]of IQt)if(s.has(n))return r;return t?.startsWith("image/")?aVe:t?.startsWith("audio/")?Fge:t?.startsWith("video/")?lVe:t?.startsWith("text/")?HT:cVe}function Tb({name:e,mimeType:t,size:n=24,absoluteStrokeWidth:s,...r}){const o=RQt(e,t),i=DJe({kind:"file",title:e.replace(/[?#]/g,"_"),mimeType:t});return i!=="file"||o===cVe?a.jsx("svg",{width:n,height:n,...r,"data-file-type-icon":i,children:a.jsx("image",{href:PJe[i],width:"100%",height:"100%"})}):a.jsx(o,{size:n,absoluteStrokeWidth:s,...r})}const EQt="_icon_h5emn_1",AQt="_details_h5emn_13",jQt="_name_h5emn_23",NQt="_type_h5emn_24",SF={icon:EQt,details:AQt,name:jQt,type:NQt};function OJe({name:e,mimeType:t}){const s=/\.([^.\\/]+)$/.exec(e)?.[1]?.toUpperCase()||t||"FILE";return a.jsxs(a.Fragment,{children:[a.jsx("span",{className:SF.icon,children:a.jsx(Tb,{name:e,mimeType:t,size:24,"aria-hidden":"true"})}),a.jsxs("span",{className:SF.details,children:[a.jsx("span",{className:SF.name,title:e,children:e}),a.jsx("span",{className:SF.type,title:s,children:s})]})]})}/**
1926
1926
  * @license
1927
1927
  * Copyright 2025 Qwen Team
1928
1928
  * SPDX-License-Identifier: Apache-2.0
@@ -2711,7 +2711,7 @@ ${E("managed.truncated")}`:""))}}},[m,e,D,E]),Ee=u.useCallback(at=>{e&&wt({sessi
2711
2711
  `));if(wt.discoveryState==="completed"||wt.initialized&&wt.discoveryState==="not_started"&&wt.servers.length===0){ze=!0;break}}}if(!ze)throw new Error(d("mcp.discovery.timeout"))}catch(zt){$t&&tt(zt instanceof Error?zt.message:String(zt))}finally{$t&&Ge(!1)}})(),()=>{$t=!1}},[x,S,_,k,R,d,h]),u.useEffect(()=>{if(h||_e)return;if(!An){V({});return}let $t=!0;return Ie(!0),Ce(null),Promise.all(Mn.map(async gt=>{const zt=await b(gt);return{serverName:gt,tools:zt.tools.filter(Jt=>Jt.isValid),error:zt.errors?.length?`${gt}: ${zt.errors.map(Jt=>Jt.error||Jt.hint||Jt.kind).join(", ")}`:void 0}})).then(gt=>{if(!$t)return;V(Object.fromEntries(gt.map(({serverName:Jt,tools:kn})=>[Jt,kn])));const zt=gt.flatMap(({error:Jt})=>Jt?[Jt]:[]);Ce(zt.length>0?zt.join(`
2712
2712
  `):null)}).catch(gt=>{$t&&Ce(gt instanceof Error?gt.message:String(gt))}).finally(()=>{$t&&Ie(!1)}),()=>{$t=!1}},[An,Mn,_e,b,h]);function Wn($t){if(!$t){for(const gt of["description","systemPrompt"])it.current[gt]+=1,He.current[gt]?.abort(),delete He.current[gt];Ve(new Set)}ge($t)}function ys(){Be(A),Y(P),me(null),ge(!0)}function Pt($t){it.current[$t]+=1,He.current[$t]?.abort(),delete He.current[$t],Ve(gt=>{const zt=new Set(gt);return zt.delete($t),zt})}async function Zt($t){const gt=fe.trim();if(!gt||He.current[$t])return;const zt=it.current[$t]+1;it.current[$t]=zt;const Jt=new AbortController;He.current[$t]=Jt,Ve(ze=>new Set(ze).add($t)),me(null);const kn=$t==="description"?Be:Y;kn("");try{const ze=$t==="description"?`Return only a concise one-sentence ${h?"persistent Agent":"subagent"} description explaining when this agent should be used. Do not return JSON, Markdown, a label, or commentary.`:`Return only the complete ${h?"persistent Agent":"subagent"} system prompt. Do not return JSON, a Markdown code block, a name, a description, or commentary.`;let Qe="";for await(const wt of m(`${gt}
2713
2713
 
2714
- ${ze}`,{signal:Jt.signal})){if(it.current[$t]!==zt)return;if(wt.type==="delta")Qe+=wt.text,kn(Qe);else if(wt.type==="error")throw new Error(wt.message)}if(it.current[$t]!==zt)return;kn(Qe.trim())}catch(ze){if(it.current[$t]!==zt||Jt.signal.aborted)return;me(d("agent.create.generateFailed",{error:ze instanceof Error?ze.message:String(ze)}))}finally{it.current[$t]===zt&&(Ve(ze=>{const Qe=new Set(ze);return Qe.delete($t),Qe}),He.current[$t]===Jt&&delete He.current[$t])}}function nn(){M(Ae.trim()),L(ve.trim()),Wn(!1)}function Yt($t){const gt=t?.mcpServers?.[$t];if(SC(gt))return gt;const zt=Ft[$t];if(SC(zt))return zt;const Jt=E==="workspace"?Kt.find(kn=>kn.name===$t)?.config:void 0;return SC(Jt)?Jt:void 0}async function Ht(){if(!En){jt(d("agent.create.required"));return}rt(!0),jt(null);try{if(c){const wt=Number(ce);if(!Number.isInteger(wt)||wt<1||wt>8)throw new Error(d("collab.agent.concurrencyInvalid"));const Je=C.trim();await c({name:Je,...A.trim()?{description:A.trim()}:{},...P.trim()?{instructions:P.trim()}:{},...ae?{agentType:ae}:{},...O.trim()?{model:O.trim()}:{},maxConcurrentRuns:wt,...X.size>0?{execution:{mode:"managed-host",hostIds:[...X],...G?{provider:G}:{}}}:G&&G!=="qwen"?{execution:{mode:"local",provider:G}}:{}}),s(Je);return}const $t=te.trim()?Number(te.trim()):void 0;if($t!==void 0&&(!Number.isSafeInteger($t)||$t<=0))throw new Error(d("agent.create.maxTurnsInvalid"));const gt=[...F],zt=[...B],Jt=zQn(Fe,"hooks"),kn=Object.fromEntries([...ke].flatMap(wt=>{const Je=Yt(wt);return Je?[[wt,Je]]:[]})),ze={description:A.trim(),systemPrompt:P.trim(),tools:t||gt.length>0?gt:void 0,disallowedTools:t||zt.length>0?zt:void 0,mcpServers:t||Object.keys(kn).length>0?kn:void 0,hooks:t?Jt??{}:Jt},Qe=t?await p(t.name,{...ze,model:O.trim()||null,approvalMode:H==="inherit"?null:H,maxTurns:$t??null,color:pe==="inherit"?null:pe},E):await f({name:C.trim(),scope:E,...ze,model:O.trim()||void 0,approvalMode:H==="inherit"?void 0:H,maxTurns:$t,color:pe==="inherit"?void 0:pe});s(Qe.agent.name)}catch($t){jt(UQn($t))}finally{rt(!1)}}return a.jsxs("div",{className:"flex w-full max-w-5xl flex-col gap-6",children:[a.jsxs("div",{className:"flex items-start justify-between gap-4",children:[a.jsx("h1",{className:"text-xl font-semibold text-balance",children:d(h?"collab.agent.new":t?"agent.edit":"agent.create")}),a.jsxs(Ne,{type:"button",variant:"outline",onClick:ys,children:[a.jsx(fk,{"data-icon":"inline-start"}),d("agent.create.modelGenerate")]})]}),mt?a.jsx(wg,{tone:"error",noticeKey:mt,closeLabel:d("common.close"),onDismiss:()=>jt(null),children:mt}):null,h&&a.jsx("p",{className:"text-sm text-muted-foreground",children:d("collab.agent.joins",{project:o?.split(/[\\/]/).filter(Boolean).at(-1)??""})}),a.jsxs(Ov,{defaultValue:"overview",children:[!h&&a.jsxs(Bv,{className:"max-w-full overflow-x-auto",children:[a.jsx(Ca,{value:"overview",children:d("agent.detail.overview")}),a.jsx(Ca,{value:"prompt",children:d("agent.detail.systemPrompt")}),a.jsx(Ca,{value:"tools",children:d("agent.detail.tools")}),a.jsx(Ca,{value:"mcp",children:d("agent.detail.mcp")}),a.jsx(Ca,{value:"hooks",children:d("agent.detail.hooks")})]}),a.jsx(ql,{value:"overview",className:"pt-4",children:a.jsxs(R_,{className:"grid grid-cols-1 gap-5 lg:grid-cols-2",children:[h?null:a.jsxs(Yi,{children:[a.jsx(Na,{htmlFor:"agent-scope",children:d("agent.create.scope")}),a.jsxs(Ri,{value:E,disabled:!!t,onValueChange:$t=>I($t),children:[a.jsx(Ai,{id:"agent-scope",className:"w-full",children:a.jsx(Ei,{})}),a.jsxs(ji,{children:[a.jsx(Fr,{value:"workspace",children:d("agent.create.project.cli")}),a.jsx(Fr,{value:"global",children:d("agent.create.user.cli")})]})]})]}),a.jsxs(Yi,{children:[a.jsx(Na,{htmlFor:"agent-name",children:d("agent.create.name")}),a.jsx(vr,{id:"agent-name",value:C,onChange:$t=>N($t.target.value),placeholder:d("agent.create.namePlaceholder"),disabled:!!t}),a.jsx(il,{children:d(h?"collab.agent.nameHelp":"agent.create.nameHelp")})]}),h&&a.jsxs(Yi,{children:[a.jsx(Na,{htmlFor:"agent-role",children:d("collab.agent.role")}),a.jsxs(Ri,{value:ae||Vre,disabled:X.size>0,onValueChange:$t=>ne($t===Vre?"":$t),children:[a.jsx(Ai,{id:"agent-role",className:"w-full",children:a.jsx(Ei,{})}),a.jsxs(ji,{children:[a.jsx(Fr,{value:Vre,children:d("collab.agent.roleNone")}),g.map($t=>a.jsx(Fr,{value:$t.name,children:$t.name},$t.name))]})]}),a.jsx(il,{children:d("collab.agent.roleHint")})]}),h&&a.jsxs(Yi,{className:"lg:col-span-2",children:[a.jsx(Na,{htmlFor:"agent-workspace-prompt",children:d("collab.agent.instructions")}),a.jsx(hm,{id:"agent-workspace-prompt",value:P,onChange:$t=>L($t.target.value),rows:6,placeholder:d("collab.agent.instructionsHint")})]}),a.jsxs(Yi,{className:"lg:col-span-2",children:[a.jsx(Na,{htmlFor:"agent-description",children:d(h?"collab.agent.description":"agent.create.description")}),a.jsx(hm,{id:"agent-description",value:A,onChange:$t=>M($t.target.value),placeholder:d("agent.create.manualDescPlaceholder"),rows:3})]}),a.jsxs(Yi,{children:[a.jsx(Na,{htmlFor:"agent-model",children:d("agent.create.model")}),a.jsx(vr,{id:"agent-model",disabled:h&&X.size>0,value:O,onChange:$t=>U($t.target.value),placeholder:"inherit / fast / provider:model"})]}),h?a.jsxs(a.Fragment,{children:[a.jsxs(Yi,{children:[a.jsx(Na,{htmlFor:"agent-concurrency",children:d("collab.agent.concurrency")}),a.jsx(vr,{id:"agent-concurrency",type:"number",min:"1",max:"8",step:"1",value:ce,onChange:$t=>he($t.target.value)})]}),a.jsxs(Yi,{className:"lg:col-span-2",children:[a.jsx(Na,{children:d("collab.agent.runsOn")}),a.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[a.jsxs("label",{className:"flex items-start gap-2 rounded-md border border-border p-3 text-sm",children:[a.jsx("input",{type:"radio",name:"agent-execution-location",checked:X.size===0,onChange:()=>{de(new Set),J(W[0])}}),a.jsxs("span",{children:[d("collab.agent.thisComputer"),a.jsx("span",{className:"block break-all text-xs text-muted-foreground",children:o})]})]}),r.map($t=>a.jsxs("label",{className:"flex items-start gap-2 rounded-md border border-border p-3 text-sm",children:[a.jsx("input",{type:"radio",name:"agent-execution-location",checked:X.has($t.id),onChange:()=>{de(new Set([$t.id])),J(qz($t)[0]),ne(""),U("")}}),a.jsxs("span",{children:[$t.label,$t.status==="offline"&&a.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:d("collab.agentStatus.offline")}),a.jsx("span",{className:"block break-all text-xs text-muted-foreground",children:$t.workspaceCwd??d("collab.agent.cwdUnknown")})]})]},$t.id))]}),a.jsx(il,{children:d(X.size>0?"collab.agent.hostPersona":"collab.agent.runsOnHint")})]}),(()=>{const $t=r.find(Jt=>X.has(Jt.id)),gt=$t?qz($t):W,zt=Jt=>gt.includes(Jt)?void 0:d($t||l!==void 0?"collab.agent.programMissing":"collab.agent.programLocal");return a.jsxs(Yi,{className:"lg:col-span-2",children:[a.jsx(Na,{children:d("collab.runtime.program")}),a.jsx("div",{role:"radiogroup","aria-label":d("collab.runtime.program"),className:"grid gap-2 sm:grid-cols-2",children:Yat.map(Jt=>{const kn=zt(Jt);return a.jsxs("label",{className:"flex items-start gap-2 rounded-md border border-border p-3 text-sm has-[:disabled]:opacity-60",children:[a.jsx("input",{type:"radio",name:"agent-execution-provider",disabled:kn!==void 0,checked:G===Jt,onChange:()=>J(Jt)}),a.jsxs("span",{children:[Jat(Jt),kn&&a.jsx("span",{className:"block text-xs text-muted-foreground",children:kn})]})]},Jt)})})]})})(),a.jsx(Yi,{className:"lg:col-span-2",children:a.jsx(il,{children:d("collab.agent.afterCreate")})})]}):a.jsxs(a.Fragment,{children:[a.jsxs(Yi,{children:[a.jsx(Na,{htmlFor:"agent-approval",children:d("agent.create.approvalMode")}),a.jsxs(Ri,{value:H,onValueChange:Q,children:[a.jsx(Ai,{id:"agent-approval",className:"w-full",children:a.jsx(Ei,{children:t6e(H,d)})}),a.jsx(ji,{children:q.map($t=>a.jsx(Fr,{value:$t,disabled:$t==="bubble",children:t6e($t,d)},$t))})]}),a.jsx(il,{children:VQn(H,d)})]}),a.jsxs(Yi,{children:[a.jsx(Na,{htmlFor:"agent-max-turns",children:d("agent.create.maxTurns")}),a.jsx(vr,{id:"agent-max-turns",type:"number",min:"1",step:"1",value:te,onChange:$t=>Z($t.target.value)}),a.jsx(il,{children:d("agent.create.maxTurnsHelp")})]}),a.jsxs(Yi,{children:[a.jsx(Na,{htmlFor:"agent-color",children:d("agent.create.color")}),a.jsxs(Ri,{value:pe,onValueChange:Re,children:[a.jsx(Ai,{id:"agent-color",className:"w-full",children:a.jsx(Ei,{})}),a.jsx(ji,{children:["inherit","auto","red","blue","green","yellow","purple","orange","pink","cyan"].map($t=>a.jsx(Fr,{value:$t,children:$t},$t))})]})]})]})]})}),!h&&a.jsx(ql,{value:"prompt",className:"pt-4",children:a.jsxs(Yi,{children:[a.jsx(hm,{id:"agent-prompt","aria-label":d("agent.create.prompt"),value:P,onChange:$t=>L($t.target.value),placeholder:d("agent.create.promptPlaceholder.cli"),rows:16,className:"min-h-80 max-h-[60vh] overflow-y-auto"}),a.jsx(il,{children:d("agent.create.promptHelp")})]})}),a.jsx(ql,{value:"tools",className:"pt-4",children:a.jsxs(R_,{children:[a.jsxs(Yi,{children:[a.jsx(Na,{children:d("agent.create.tools")}),a.jsx(il,{children:d("agent.create.toolsSelectHelp")}),a.jsx(e6e,{idPrefix:"agent-allowed-tool",selection:F,onSelectionChange:$,builtInTools:Ye,mcpServers:Lt,mcpTools:se,t:d}),_e||oe?a.jsx(n6e,{label:d("agent.create.tools.initializing")}):null,We||Me?a.jsx("div",{className:"whitespace-pre-wrap text-sm text-destructive",children:We||Me}):null]}),a.jsxs(Yi,{children:[a.jsx(Na,{children:d("agent.create.disallowedTools")}),a.jsx(e6e,{idPrefix:"agent-disallowed-tool",selection:B,onSelectionChange:D,builtInTools:Ye,mcpServers:Lt,mcpTools:se,t:d})]})]})}),a.jsx(ql,{value:"mcp",className:"pt-4",children:a.jsxs(Yi,{children:[a.jsx(Na,{children:d("agent.create.mcpServers")}),a.jsx(qQn,{selection:ke,onSelectionChange:Te,servers:Lt,t:d}),w.loading?a.jsx(n6e,{label:d("common.loading")}):w.error?a.jsx(GQn,{error:w.error}):null]})}),a.jsx(ql,{value:"hooks",className:"pt-4",children:a.jsxs(Yi,{children:[a.jsx(Na,{htmlFor:"agent-hooks",children:"Hooks"}),a.jsx(hm,{id:"agent-hooks",value:Fe,onChange:$t=>Se($t.target.value),placeholder:'{"PreToolUse":[...] }',rows:10,className:"min-h-64 max-h-[60vh] overflow-y-auto font-mono text-xs"}),a.jsx(il,{children:d("agent.create.jsonObjectHelp")})]})})]}),a.jsxs("div",{className:"flex justify-end gap-2 border-t pt-4",children:[a.jsx(Ne,{variant:"outline",onClick:n,disabled:ht,children:d("common.cancel")}),a.jsxs(Ne,{onClick:()=>void Ht(),disabled:!En||ht,children:[ht?a.jsx(qr,{"data-icon":"inline-start"}):null,d(t?"agent.edit.save":"agent.create.save")]})]}),a.jsx(wd,{open:Le,onOpenChange:Wn,children:a.jsxs(yd,{className:"max-h-[calc(100vh-2rem)] overflow-y-auto sm:max-w-2xl",children:[a.jsxs(ru,{children:[a.jsx(bd,{children:d("agent.create.modelGenerate")}),a.jsx(bu,{children:d("agent.create.modelGenerate.description")})]}),Ot?a.jsx(wg,{tone:"error",noticeKey:Ot,closeLabel:d("common.close"),onDismiss:()=>me(null),children:Ot}):null,a.jsxs(R_,{children:[a.jsxs(Yi,{children:[a.jsx(Na,{htmlFor:"agent-generation-requirements",children:d("agent.create.describeAgent")}),a.jsx(hm,{id:"agent-generation-requirements",value:fe,onChange:$t=>we($t.target.value),placeholder:d("agent.create.qwenPlaceholder"),rows:4}),a.jsx(il,{children:d("agent.create.qwenHint")})]}),a.jsxs(Yi,{children:[a.jsx(ZPe,{htmlFor:"agent-generated-description",label:d("agent.create.generatedDescription"),active:kt.has("description"),disabled:!fe.trim(),onGenerate:()=>void Zt("description"),onCancel:()=>Pt("description"),t:d}),a.jsx(hm,{id:"agent-generated-description",value:Ae,onChange:$t=>Be($t.target.value),rows:3,readOnly:kt.has("description")})]}),a.jsxs(Yi,{children:[a.jsx(ZPe,{htmlFor:"agent-generated-prompt",label:d("agent.create.generatedSystemPrompt"),active:kt.has("systemPrompt"),disabled:!fe.trim(),onGenerate:()=>void Zt("systemPrompt"),onCancel:()=>Pt("systemPrompt"),t:d}),a.jsx(hm,{id:"agent-generated-prompt",value:ve,onChange:$t=>Y($t.target.value),rows:10,readOnly:kt.has("systemPrompt"),className:"min-h-64 max-h-64 overflow-y-auto"})]})]}),a.jsxs(qp,{children:[a.jsx(Ne,{type:"button",variant:"outline",onClick:()=>Wn(!1),children:d("common.cancel")}),a.jsx(Ne,{type:"button",onClick:nn,disabled:kt.size>0||!Ae.trim()||!ve.trim(),children:d("agent.create.useGenerated")})]})]})})]})}function ZPe({htmlFor:e,label:t,active:n,disabled:s,onGenerate:r,onCancel:o,t:i}){return a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Na,{htmlFor:e,children:t}),n?a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground",children:[a.jsx(qr,{className:"size-3"}),i("agent.create.generatingPrompt")]}),a.jsx(Ne,{type:"button",variant:"outline",size:"sm",className:"ml-auto",onClick:o,children:i("common.cancel")})]}):a.jsxs(Ne,{type:"button",variant:"outline",size:"sm",className:"ml-auto",disabled:s,onClick:r,children:[a.jsx(fk,{"data-icon":"inline-start"}),i("agent.create.generate")]})]})}function e6e({idPrefix:e,selection:t,onSelectionChange:n,builtInTools:s,mcpServers:r,mcpTools:o,t:i}){const[l,c]=u.useState("builtin"),[d,h]=u.useState(""),f=r.filter(g=>!g.disabled),p=l==="builtin"?s:o[d]??[],m=new Map;for(const g of s)m.set(g.name,g.displayName||g.name);for(const[g,v]of Object.entries(o))for(const y of v)m.set(y.name,`${g} / ${y.serverToolName||y.name}`);return a.jsxs("div",{className:"grid gap-3 rounded-lg border p-4",children:[a.jsxs("div",{className:`grid gap-3 ${l==="mcp"?"sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]":"sm:grid-cols-[minmax(0,1fr)]"}`,children:[a.jsxs(Ri,{value:l,onValueChange:g=>{c(g),h("")},children:[a.jsx(Ai,{id:`${e}-kind`,className:"w-full","aria-label":i("agent.create.tools.type"),children:a.jsx(Ei,{})}),a.jsxs(ji,{children:[a.jsx(Fr,{value:"builtin",children:i("agent.create.tools.builtin")}),a.jsx(Fr,{value:"mcp",children:i("agent.create.tools.mcp")})]})]}),l==="mcp"?a.jsxs(Ri,{value:d||void 0,onValueChange:h,children:[a.jsx(Ai,{id:`${e}-server`,className:"w-full","aria-label":i("agent.create.tools.selectServer"),children:a.jsx(Ei,{placeholder:i("agent.create.tools.selectServer")})}),a.jsx(ji,{children:f.map(g=>a.jsxs(Fr,{value:g.name,disabled:g.mcpStatus!=="connected"&&(o[g.name]?.length??0)===0,children:[g.name,g.mcpStatus?` · ${i(`mcp.status.${g.mcpStatus}`)}`:""]},g.name))})]}):null]}),a.jsx("div",{className:"max-h-64 overflow-y-auto rounded-md border",children:p.length>0?a.jsx(Uu,{delayDuration:300,children:a.jsx("div",{className:"divide-y",children:p.map(g=>{const v=l==="builtin"?g.displayName||g.name:g.serverToolName||g.name;return a.jsxs("label",{className:"flex cursor-pointer items-start gap-3 px-3 py-2.5 hover:bg-accent/30",children:[a.jsx(xm,{id:`${e}-${g.name}`,checked:t.has(g.name),onCheckedChange:y=>n(yhe(t,g.name,y===!0))}),a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:"block truncate text-sm font-medium",children:v}),g.description?a.jsxs(Qc,{children:[a.jsx(Zc,{asChild:!0,children:a.jsx("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",children:g.description})}),a.jsx(ed,{className:"max-w-sm whitespace-normal",children:g.description})]}):null]})]},g.name)})})}):a.jsx("div",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:i("agent.create.tools.empty")})}),t.size>0?a.jsx("div",{className:"flex flex-wrap gap-2",children:[...t].map(g=>a.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-md bg-muted px-2 py-1 text-sm",title:g,children:[a.jsx("span",{className:"truncate",children:m.get(g)||g}),a.jsx("button",{type:"button",className:"rounded-sm text-muted-foreground hover:text-foreground","aria-label":i("agent.create.removeSelection",{name:g}),onClick:()=>n(yhe(t,g,!1)),children:a.jsx(Xh,{className:"size-3.5"})})]},g))}):a.jsx("div",{className:"text-sm text-muted-foreground",children:i("agent.create.tools.noneSelected")})]})}function qQn({selection:e,onSelectionChange:t,servers:n,t:s}){return a.jsx("div",{className:"max-h-64 overflow-y-auto rounded-lg border",children:n.length>0?a.jsx("div",{className:"divide-y",children:n.map(r=>a.jsxs("label",{className:"flex cursor-pointer items-center gap-3 px-3 py-2.5 hover:bg-accent/30",children:[a.jsx(xm,{id:`agent-mcp-server-${r.name}`,checked:e.has(r.name),onCheckedChange:o=>t(yhe(e,r.name,o===!0))}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:r.name}),r.mcpStatus?a.jsx(Zr,{variant:"secondary",className:r.mcpStatus==="connected"?"bg-[var(--success-bg)] text-[var(--success-color)]":void 0,children:s(`mcp.status.${r.mcpStatus}`)}):null]},r.name))}):a.jsx("div",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:s("agent.create.mcpServers.empty")})})}function t6e(e,t){return t(e==="inherit"||e==="bubble"?`agent.approval.${e}`:`mode.listLabel.${e}`)}function VQn(e,t){return t(e==="inherit"||e==="bubble"?`agent.approval.desc.${e}`:`mode.desc.${e}`)}function n6e({label:e}){return a.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[a.jsx(qr,{}),e]})}function GQn({error:e}){return a.jsx("div",{className:"text-sm text-destructive",children:e?.message})}const KQn=u.lazy(async()=>({default:(await xt(()=>import("./agents-route-j5ba59xn.js"),__vite__mapDeps([93,94]))).AgentsRoute}));function YQn(e){return a.jsx(u.Suspense,{fallback:null,children:a.jsx(KQn,{...e})})}function h2({className:e,...t}){return a.jsx("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",className:Es(e),...t})}function f2({className:e,...t}){return a.jsx("ol",{"data-slot":"breadcrumb-list",className:Es("flex flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground",e),...t})}function dd({className:e,...t}){return a.jsx("li",{"data-slot":"breadcrumb-item",className:Es("inline-flex items-center gap-1",e),...t})}function ok({asChild:e,className:t,...n}){const s=e?Jme:"a";return a.jsx(s,{"data-slot":"breadcrumb-link",className:Es("transition-colors hover:text-foreground",t),...n})}function lg({className:e,...t}){return a.jsx("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:Es("font-normal text-foreground",e),...t})}function ik({children:e,className:t,...n}){return a.jsx("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:Es("[&>svg]:size-3.5",t),...n,children:e??a.jsx(Vl,{})})}const JQn=tA("group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-muted"},size:{default:"h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",sm:"h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2"}},defaultVariants:{variant:"default",size:"default"}}),Xat=u.createContext({size:"default",variant:"default",spacing:2,orientation:"horizontal"});function Pbe({className:e,variant:t,size:n,spacing:s=2,orientation:r="horizontal",children:o,...i}){return a.jsx(Age,{orientation:r,"data-slot":"toggle-group","data-variant":t,"data-size":n,"data-spacing":s,"data-orientation":r,style:{"--gap":s},className:Es("group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-vertical:flex-col data-vertical:items-stretch",e),...i,children:a.jsx(Xat.Provider,{value:{variant:t,size:n,spacing:s,orientation:r},children:o})})}function Dbe({className:e,children:t,variant:n="default",size:s="default",...r}){const o=u.useContext(Xat);return a.jsx(_qe,{"data-slot":"toggle-group-item","data-variant":o.variant||n,"data-size":o.size||s,"data-spacing":o.spacing,className:Es("shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",JQn({variant:o.variant||n,size:o.size||s}),e),...r,children:t})}const XQn="_agentGrid_1rdw6_1",QQn={agentGrid:XQn};function Gre(e,t){return e==="project"?t("agent.level.project"):e==="user"?t("agent.level.user"):e==="builtin"?t("agent.level.builtin"):e==="extension"?t("agent.level.extension"):e}function ZQn(e,t){return e?e==="inherit"||e==="bubble"?t(`agent.approval.${e}`):ZM.some(n=>n===e)?t(`mode.listLabel.${e}`):e:"—"}function VI({label:e,value:t}){return a.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[a.jsx("div",{className:"text-sm font-medium",children:e}),a.jsx("div",{className:"break-words text-sm text-muted-foreground",children:t})]})}function s6e(e){return e?JSON.stringify(e,null,2):"—"}function eZn(e){return e.replace(/\r\n?/g,`
2714
+ ${ze}`,{signal:Jt.signal})){if(it.current[$t]!==zt)return;if(wt.type==="delta")Qe+=wt.text,kn(Qe);else if(wt.type==="error")throw new Error(wt.message)}if(it.current[$t]!==zt)return;kn(Qe.trim())}catch(ze){if(it.current[$t]!==zt||Jt.signal.aborted)return;me(d("agent.create.generateFailed",{error:ze instanceof Error?ze.message:String(ze)}))}finally{it.current[$t]===zt&&(Ve(ze=>{const Qe=new Set(ze);return Qe.delete($t),Qe}),He.current[$t]===Jt&&delete He.current[$t])}}function nn(){M(Ae.trim()),L(ve.trim()),Wn(!1)}function Yt($t){const gt=t?.mcpServers?.[$t];if(SC(gt))return gt;const zt=Ft[$t];if(SC(zt))return zt;const Jt=E==="workspace"?Kt.find(kn=>kn.name===$t)?.config:void 0;return SC(Jt)?Jt:void 0}async function Ht(){if(!En){jt(d("agent.create.required"));return}rt(!0),jt(null);try{if(c){const wt=Number(ce);if(!Number.isInteger(wt)||wt<1||wt>8)throw new Error(d("collab.agent.concurrencyInvalid"));const Je=C.trim();await c({name:Je,...A.trim()?{description:A.trim()}:{},...P.trim()?{instructions:P.trim()}:{},...ae?{agentType:ae}:{},...O.trim()?{model:O.trim()}:{},maxConcurrentRuns:wt,...X.size>0?{execution:{mode:"managed-host",hostIds:[...X],...G?{provider:G}:{}}}:G&&G!=="qwen"?{execution:{mode:"local",provider:G}}:{}}),s(Je);return}const $t=te.trim()?Number(te.trim()):void 0;if($t!==void 0&&(!Number.isSafeInteger($t)||$t<=0))throw new Error(d("agent.create.maxTurnsInvalid"));const gt=[...F],zt=[...B],Jt=zQn(Fe,"hooks"),kn=Object.fromEntries([...ke].flatMap(wt=>{const Je=Yt(wt);return Je?[[wt,Je]]:[]})),ze={description:A.trim(),systemPrompt:P.trim(),tools:t||gt.length>0?gt:void 0,disallowedTools:t||zt.length>0?zt:void 0,mcpServers:t||Object.keys(kn).length>0?kn:void 0,hooks:t?Jt??{}:Jt},Qe=t?await p(t.name,{...ze,model:O.trim()||null,approvalMode:H==="inherit"?null:H,maxTurns:$t??null,color:pe==="inherit"?null:pe},E):await f({name:C.trim(),scope:E,...ze,model:O.trim()||void 0,approvalMode:H==="inherit"?void 0:H,maxTurns:$t,color:pe==="inherit"?void 0:pe});s(Qe.agent.name)}catch($t){jt(UQn($t))}finally{rt(!1)}}return a.jsxs("div",{className:"flex w-full max-w-5xl flex-col gap-6",children:[a.jsxs("div",{className:"flex items-start justify-between gap-4",children:[a.jsx("h1",{className:"text-xl font-semibold text-balance",children:d(h?"collab.agent.new":t?"agent.edit":"agent.create")}),a.jsxs(Ne,{type:"button",variant:"outline",onClick:ys,children:[a.jsx(fk,{"data-icon":"inline-start"}),d("agent.create.modelGenerate")]})]}),mt?a.jsx(wg,{tone:"error",noticeKey:mt,closeLabel:d("common.close"),onDismiss:()=>jt(null),children:mt}):null,h&&a.jsx("p",{className:"text-sm text-muted-foreground",children:d("collab.agent.joins",{project:o?.split(/[\\/]/).filter(Boolean).at(-1)??""})}),a.jsxs(Ov,{defaultValue:"overview",children:[!h&&a.jsxs(Bv,{className:"max-w-full overflow-x-auto",children:[a.jsx(Ca,{value:"overview",children:d("agent.detail.overview")}),a.jsx(Ca,{value:"prompt",children:d("agent.detail.systemPrompt")}),a.jsx(Ca,{value:"tools",children:d("agent.detail.tools")}),a.jsx(Ca,{value:"mcp",children:d("agent.detail.mcp")}),a.jsx(Ca,{value:"hooks",children:d("agent.detail.hooks")})]}),a.jsx(ql,{value:"overview",className:"pt-4",children:a.jsxs(R_,{className:"grid grid-cols-1 gap-5 lg:grid-cols-2",children:[h?null:a.jsxs(Yi,{children:[a.jsx(Na,{htmlFor:"agent-scope",children:d("agent.create.scope")}),a.jsxs(Ri,{value:E,disabled:!!t,onValueChange:$t=>I($t),children:[a.jsx(Ai,{id:"agent-scope",className:"w-full",children:a.jsx(Ei,{})}),a.jsxs(ji,{children:[a.jsx(Fr,{value:"workspace",children:d("agent.create.project.cli")}),a.jsx(Fr,{value:"global",children:d("agent.create.user.cli")})]})]})]}),a.jsxs(Yi,{children:[a.jsx(Na,{htmlFor:"agent-name",children:d("agent.create.name")}),a.jsx(vr,{id:"agent-name",value:C,onChange:$t=>N($t.target.value),placeholder:d("agent.create.namePlaceholder"),disabled:!!t}),a.jsx(il,{children:d(h?"collab.agent.nameHelp":"agent.create.nameHelp")})]}),h&&a.jsxs(Yi,{children:[a.jsx(Na,{htmlFor:"agent-role",children:d("collab.agent.role")}),a.jsxs(Ri,{value:ae||Vre,disabled:X.size>0,onValueChange:$t=>ne($t===Vre?"":$t),children:[a.jsx(Ai,{id:"agent-role",className:"w-full",children:a.jsx(Ei,{})}),a.jsxs(ji,{children:[a.jsx(Fr,{value:Vre,children:d("collab.agent.roleNone")}),g.map($t=>a.jsx(Fr,{value:$t.name,children:$t.name},$t.name))]})]}),a.jsx(il,{children:d("collab.agent.roleHint")})]}),h&&a.jsxs(Yi,{className:"lg:col-span-2",children:[a.jsx(Na,{htmlFor:"agent-workspace-prompt",children:d("collab.agent.instructions")}),a.jsx(hm,{id:"agent-workspace-prompt",value:P,onChange:$t=>L($t.target.value),rows:6,placeholder:d("collab.agent.instructionsHint")})]}),a.jsxs(Yi,{className:"lg:col-span-2",children:[a.jsx(Na,{htmlFor:"agent-description",children:d(h?"collab.agent.description":"agent.create.description")}),a.jsx(hm,{id:"agent-description",value:A,onChange:$t=>M($t.target.value),placeholder:d("agent.create.manualDescPlaceholder"),rows:3})]}),a.jsxs(Yi,{children:[a.jsx(Na,{htmlFor:"agent-model",children:d("agent.create.model")}),a.jsx(vr,{id:"agent-model",disabled:h&&X.size>0,value:O,onChange:$t=>U($t.target.value),placeholder:"inherit / fast / provider:model"})]}),h?a.jsxs(a.Fragment,{children:[a.jsxs(Yi,{children:[a.jsx(Na,{htmlFor:"agent-concurrency",children:d("collab.agent.concurrency")}),a.jsx(vr,{id:"agent-concurrency",type:"number",min:"1",max:"8",step:"1",value:ce,onChange:$t=>he($t.target.value)})]}),a.jsxs(Yi,{className:"lg:col-span-2",children:[a.jsx(Na,{children:d("collab.agent.runsOn")}),a.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[a.jsxs("label",{className:"flex items-start gap-2 rounded-md border border-border p-3 text-sm",children:[a.jsx("input",{type:"radio",name:"agent-execution-location",checked:X.size===0,onChange:()=>{de(new Set),J(W[0])}}),a.jsxs("span",{children:[d("collab.agent.thisComputer"),a.jsx("span",{className:"block break-all text-xs text-muted-foreground",children:o})]})]}),r.map($t=>a.jsxs("label",{className:"flex items-start gap-2 rounded-md border border-border p-3 text-sm",children:[a.jsx("input",{type:"radio",name:"agent-execution-location",checked:X.has($t.id),onChange:()=>{de(new Set([$t.id])),J(qz($t)[0]),ne(""),U("")}}),a.jsxs("span",{children:[$t.label,$t.status==="offline"&&a.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:d("collab.agentStatus.offline")}),a.jsx("span",{className:"block break-all text-xs text-muted-foreground",children:$t.workspaceCwd??d("collab.agent.cwdUnknown")})]})]},$t.id))]}),a.jsx(il,{children:d(X.size>0?"collab.agent.hostPersona":"collab.agent.runsOnHint")})]}),(()=>{const $t=r.find(Jt=>X.has(Jt.id)),gt=$t?qz($t):W,zt=Jt=>gt.includes(Jt)?void 0:d($t||l!==void 0?"collab.agent.programMissing":"collab.agent.programLocal");return a.jsxs(Yi,{className:"lg:col-span-2",children:[a.jsx(Na,{children:d("collab.runtime.program")}),a.jsx("div",{role:"radiogroup","aria-label":d("collab.runtime.program"),className:"grid gap-2 sm:grid-cols-2",children:Yat.map(Jt=>{const kn=zt(Jt);return a.jsxs("label",{className:"flex items-start gap-2 rounded-md border border-border p-3 text-sm has-[:disabled]:opacity-60",children:[a.jsx("input",{type:"radio",name:"agent-execution-provider",disabled:kn!==void 0,checked:G===Jt,onChange:()=>J(Jt)}),a.jsxs("span",{children:[Jat(Jt),kn&&a.jsx("span",{className:"block text-xs text-muted-foreground",children:kn})]})]},Jt)})})]})})(),a.jsx(Yi,{className:"lg:col-span-2",children:a.jsx(il,{children:d("collab.agent.afterCreate")})})]}):a.jsxs(a.Fragment,{children:[a.jsxs(Yi,{children:[a.jsx(Na,{htmlFor:"agent-approval",children:d("agent.create.approvalMode")}),a.jsxs(Ri,{value:H,onValueChange:Q,children:[a.jsx(Ai,{id:"agent-approval",className:"w-full",children:a.jsx(Ei,{children:t6e(H,d)})}),a.jsx(ji,{children:q.map($t=>a.jsx(Fr,{value:$t,disabled:$t==="bubble",children:t6e($t,d)},$t))})]}),a.jsx(il,{children:VQn(H,d)})]}),a.jsxs(Yi,{children:[a.jsx(Na,{htmlFor:"agent-max-turns",children:d("agent.create.maxTurns")}),a.jsx(vr,{id:"agent-max-turns",type:"number",min:"1",step:"1",value:te,onChange:$t=>Z($t.target.value)}),a.jsx(il,{children:d("agent.create.maxTurnsHelp")})]}),a.jsxs(Yi,{children:[a.jsx(Na,{htmlFor:"agent-color",children:d("agent.create.color")}),a.jsxs(Ri,{value:pe,onValueChange:Re,children:[a.jsx(Ai,{id:"agent-color",className:"w-full",children:a.jsx(Ei,{})}),a.jsx(ji,{children:["inherit","auto","red","blue","green","yellow","purple","orange","pink","cyan"].map($t=>a.jsx(Fr,{value:$t,children:$t},$t))})]})]})]})]})}),!h&&a.jsx(ql,{value:"prompt",className:"pt-4",children:a.jsxs(Yi,{children:[a.jsx(hm,{id:"agent-prompt","aria-label":d("agent.create.prompt"),value:P,onChange:$t=>L($t.target.value),placeholder:d("agent.create.promptPlaceholder.cli"),rows:16,className:"min-h-80 max-h-[60vh] overflow-y-auto"}),a.jsx(il,{children:d("agent.create.promptHelp")})]})}),a.jsx(ql,{value:"tools",className:"pt-4",children:a.jsxs(R_,{children:[a.jsxs(Yi,{children:[a.jsx(Na,{children:d("agent.create.tools")}),a.jsx(il,{children:d("agent.create.toolsSelectHelp")}),a.jsx(e6e,{idPrefix:"agent-allowed-tool",selection:F,onSelectionChange:$,builtInTools:Ye,mcpServers:Lt,mcpTools:se,t:d}),_e||oe?a.jsx(n6e,{label:d("agent.create.tools.initializing")}):null,We||Me?a.jsx("div",{className:"whitespace-pre-wrap text-sm text-destructive",children:We||Me}):null]}),a.jsxs(Yi,{children:[a.jsx(Na,{children:d("agent.create.disallowedTools")}),a.jsx(e6e,{idPrefix:"agent-disallowed-tool",selection:B,onSelectionChange:D,builtInTools:Ye,mcpServers:Lt,mcpTools:se,t:d})]})]})}),a.jsx(ql,{value:"mcp",className:"pt-4",children:a.jsxs(Yi,{children:[a.jsx(Na,{children:d("agent.create.mcpServers")}),a.jsx(qQn,{selection:ke,onSelectionChange:Te,servers:Lt,t:d}),w.loading?a.jsx(n6e,{label:d("common.loading")}):w.error?a.jsx(GQn,{error:w.error}):null]})}),a.jsx(ql,{value:"hooks",className:"pt-4",children:a.jsxs(Yi,{children:[a.jsx(Na,{htmlFor:"agent-hooks",children:"Hooks"}),a.jsx(hm,{id:"agent-hooks",value:Fe,onChange:$t=>Se($t.target.value),placeholder:'{"PreToolUse":[...] }',rows:10,className:"min-h-64 max-h-[60vh] overflow-y-auto font-mono text-xs"}),a.jsx(il,{children:d("agent.create.jsonObjectHelp")})]})})]}),a.jsxs("div",{className:"flex justify-end gap-2 border-t pt-4",children:[a.jsx(Ne,{variant:"outline",onClick:n,disabled:ht,children:d("common.cancel")}),a.jsxs(Ne,{onClick:()=>void Ht(),disabled:!En||ht,children:[ht?a.jsx(qr,{"data-icon":"inline-start"}):null,d(t?"agent.edit.save":"agent.create.save")]})]}),a.jsx(wd,{open:Le,onOpenChange:Wn,children:a.jsxs(yd,{className:"max-h-[calc(100vh-2rem)] overflow-y-auto sm:max-w-2xl",children:[a.jsxs(ru,{children:[a.jsx(bd,{children:d("agent.create.modelGenerate")}),a.jsx(bu,{children:d("agent.create.modelGenerate.description")})]}),Ot?a.jsx(wg,{tone:"error",noticeKey:Ot,closeLabel:d("common.close"),onDismiss:()=>me(null),children:Ot}):null,a.jsxs(R_,{children:[a.jsxs(Yi,{children:[a.jsx(Na,{htmlFor:"agent-generation-requirements",children:d("agent.create.describeAgent")}),a.jsx(hm,{id:"agent-generation-requirements",value:fe,onChange:$t=>we($t.target.value),placeholder:d("agent.create.qwenPlaceholder"),rows:4}),a.jsx(il,{children:d("agent.create.qwenHint")})]}),a.jsxs(Yi,{children:[a.jsx(ZPe,{htmlFor:"agent-generated-description",label:d("agent.create.generatedDescription"),active:kt.has("description"),disabled:!fe.trim(),onGenerate:()=>void Zt("description"),onCancel:()=>Pt("description"),t:d}),a.jsx(hm,{id:"agent-generated-description",value:Ae,onChange:$t=>Be($t.target.value),rows:3,readOnly:kt.has("description")})]}),a.jsxs(Yi,{children:[a.jsx(ZPe,{htmlFor:"agent-generated-prompt",label:d("agent.create.generatedSystemPrompt"),active:kt.has("systemPrompt"),disabled:!fe.trim(),onGenerate:()=>void Zt("systemPrompt"),onCancel:()=>Pt("systemPrompt"),t:d}),a.jsx(hm,{id:"agent-generated-prompt",value:ve,onChange:$t=>Y($t.target.value),rows:10,readOnly:kt.has("systemPrompt"),className:"min-h-64 max-h-64 overflow-y-auto"})]})]}),a.jsxs(qp,{children:[a.jsx(Ne,{type:"button",variant:"outline",onClick:()=>Wn(!1),children:d("common.cancel")}),a.jsx(Ne,{type:"button",onClick:nn,disabled:kt.size>0||!Ae.trim()||!ve.trim(),children:d("agent.create.useGenerated")})]})]})})]})}function ZPe({htmlFor:e,label:t,active:n,disabled:s,onGenerate:r,onCancel:o,t:i}){return a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Na,{htmlFor:e,children:t}),n?a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground",children:[a.jsx(qr,{className:"size-3"}),i("agent.create.generatingPrompt")]}),a.jsx(Ne,{type:"button",variant:"outline",size:"sm",className:"ml-auto",onClick:o,children:i("common.cancel")})]}):a.jsxs(Ne,{type:"button",variant:"outline",size:"sm",className:"ml-auto",disabled:s,onClick:r,children:[a.jsx(fk,{"data-icon":"inline-start"}),i("agent.create.generate")]})]})}function e6e({idPrefix:e,selection:t,onSelectionChange:n,builtInTools:s,mcpServers:r,mcpTools:o,t:i}){const[l,c]=u.useState("builtin"),[d,h]=u.useState(""),f=r.filter(g=>!g.disabled),p=l==="builtin"?s:o[d]??[],m=new Map;for(const g of s)m.set(g.name,g.displayName||g.name);for(const[g,v]of Object.entries(o))for(const y of v)m.set(y.name,`${g} / ${y.serverToolName||y.name}`);return a.jsxs("div",{className:"grid gap-3 rounded-lg border p-4",children:[a.jsxs("div",{className:`grid gap-3 ${l==="mcp"?"sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]":"sm:grid-cols-[minmax(0,1fr)]"}`,children:[a.jsxs(Ri,{value:l,onValueChange:g=>{c(g),h("")},children:[a.jsx(Ai,{id:`${e}-kind`,className:"w-full","aria-label":i("agent.create.tools.type"),children:a.jsx(Ei,{})}),a.jsxs(ji,{children:[a.jsx(Fr,{value:"builtin",children:i("agent.create.tools.builtin")}),a.jsx(Fr,{value:"mcp",children:i("agent.create.tools.mcp")})]})]}),l==="mcp"?a.jsxs(Ri,{value:d||void 0,onValueChange:h,children:[a.jsx(Ai,{id:`${e}-server`,className:"w-full","aria-label":i("agent.create.tools.selectServer"),children:a.jsx(Ei,{placeholder:i("agent.create.tools.selectServer")})}),a.jsx(ji,{children:f.map(g=>a.jsxs(Fr,{value:g.name,disabled:g.mcpStatus!=="connected"&&(o[g.name]?.length??0)===0,children:[g.name,g.mcpStatus?` · ${i(`mcp.status.${g.mcpStatus}`)}`:""]},g.name))})]}):null]}),a.jsx("div",{className:"max-h-64 overflow-y-auto rounded-md border",children:p.length>0?a.jsx(Uu,{delayDuration:300,children:a.jsx("div",{className:"divide-y",children:p.map(g=>{const v=l==="builtin"?g.displayName||g.name:g.serverToolName||g.name;return a.jsxs("label",{className:"flex cursor-pointer items-start gap-3 px-3 py-2.5 hover:bg-accent/30",children:[a.jsx(xm,{id:`${e}-${g.name}`,checked:t.has(g.name),onCheckedChange:y=>n(yhe(t,g.name,y===!0))}),a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:"block truncate text-sm font-medium",children:v}),g.description?a.jsxs(Qc,{children:[a.jsx(Zc,{asChild:!0,children:a.jsx("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",children:g.description})}),a.jsx(ed,{className:"max-w-sm whitespace-normal",children:g.description})]}):null]})]},g.name)})})}):a.jsx("div",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:i("agent.create.tools.empty")})}),t.size>0?a.jsx("div",{className:"flex flex-wrap gap-2",children:[...t].map(g=>a.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-md bg-muted px-2 py-1 text-sm",title:g,children:[a.jsx("span",{className:"truncate",children:m.get(g)||g}),a.jsx("button",{type:"button",className:"rounded-sm text-muted-foreground hover:text-foreground","aria-label":i("agent.create.removeSelection",{name:g}),onClick:()=>n(yhe(t,g,!1)),children:a.jsx(Xh,{className:"size-3.5"})})]},g))}):a.jsx("div",{className:"text-sm text-muted-foreground",children:i("agent.create.tools.noneSelected")})]})}function qQn({selection:e,onSelectionChange:t,servers:n,t:s}){return a.jsx("div",{className:"max-h-64 overflow-y-auto rounded-lg border",children:n.length>0?a.jsx("div",{className:"divide-y",children:n.map(r=>a.jsxs("label",{className:"flex cursor-pointer items-center gap-3 px-3 py-2.5 hover:bg-accent/30",children:[a.jsx(xm,{id:`agent-mcp-server-${r.name}`,checked:e.has(r.name),onCheckedChange:o=>t(yhe(e,r.name,o===!0))}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:r.name}),r.mcpStatus?a.jsx(Zr,{variant:"secondary",className:r.mcpStatus==="connected"?"bg-[var(--success-bg)] text-[var(--success-color)]":void 0,children:s(`mcp.status.${r.mcpStatus}`)}):null]},r.name))}):a.jsx("div",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:s("agent.create.mcpServers.empty")})})}function t6e(e,t){return t(e==="inherit"||e==="bubble"?`agent.approval.${e}`:`mode.listLabel.${e}`)}function VQn(e,t){return t(e==="inherit"||e==="bubble"?`agent.approval.desc.${e}`:`mode.desc.${e}`)}function n6e({label:e}){return a.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[a.jsx(qr,{}),e]})}function GQn({error:e}){return a.jsx("div",{className:"text-sm text-destructive",children:e?.message})}const KQn=u.lazy(async()=>({default:(await xt(()=>import("./agents-route-kcQ3YUNc.js"),__vite__mapDeps([93,94]))).AgentsRoute}));function YQn(e){return a.jsx(u.Suspense,{fallback:null,children:a.jsx(KQn,{...e})})}function h2({className:e,...t}){return a.jsx("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",className:Es(e),...t})}function f2({className:e,...t}){return a.jsx("ol",{"data-slot":"breadcrumb-list",className:Es("flex flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground",e),...t})}function dd({className:e,...t}){return a.jsx("li",{"data-slot":"breadcrumb-item",className:Es("inline-flex items-center gap-1",e),...t})}function ok({asChild:e,className:t,...n}){const s=e?Jme:"a";return a.jsx(s,{"data-slot":"breadcrumb-link",className:Es("transition-colors hover:text-foreground",t),...n})}function lg({className:e,...t}){return a.jsx("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:Es("font-normal text-foreground",e),...t})}function ik({children:e,className:t,...n}){return a.jsx("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:Es("[&>svg]:size-3.5",t),...n,children:e??a.jsx(Vl,{})})}const JQn=tA("group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-muted"},size:{default:"h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",sm:"h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2"}},defaultVariants:{variant:"default",size:"default"}}),Xat=u.createContext({size:"default",variant:"default",spacing:2,orientation:"horizontal"});function Pbe({className:e,variant:t,size:n,spacing:s=2,orientation:r="horizontal",children:o,...i}){return a.jsx(Age,{orientation:r,"data-slot":"toggle-group","data-variant":t,"data-size":n,"data-spacing":s,"data-orientation":r,style:{"--gap":s},className:Es("group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-vertical:flex-col data-vertical:items-stretch",e),...i,children:a.jsx(Xat.Provider,{value:{variant:t,size:n,spacing:s,orientation:r},children:o})})}function Dbe({className:e,children:t,variant:n="default",size:s="default",...r}){const o=u.useContext(Xat);return a.jsx(_qe,{"data-slot":"toggle-group-item","data-variant":o.variant||n,"data-size":o.size||s,"data-spacing":o.spacing,className:Es("shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",JQn({variant:o.variant||n,size:o.size||s}),e),...r,children:t})}const XQn="_agentGrid_1rdw6_1",QQn={agentGrid:XQn};function Gre(e,t){return e==="project"?t("agent.level.project"):e==="user"?t("agent.level.user"):e==="builtin"?t("agent.level.builtin"):e==="extension"?t("agent.level.extension"):e}function ZQn(e,t){return e?e==="inherit"||e==="bubble"?t(`agent.approval.${e}`):ZM.some(n=>n===e)?t(`mode.listLabel.${e}`):e:"—"}function VI({label:e,value:t}){return a.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[a.jsx("div",{className:"text-sm font-medium",children:e}),a.jsx("div",{className:"break-words text-sm text-muted-foreground",children:t})]})}function s6e(e){return e?JSON.stringify(e,null,2):"—"}function eZn(e){return e.replace(/\r\n?/g,`
2715
2715
  `).replace(/(?<!\n)\n(?!\n|[ \t]*(?:#{1,6}\s|[-*+]\s|\d+\.\s|```|>\s|\*\*[^*\n]+\*\*:))/g," ")}function Qat({initialAgentView:e,onClose:t,embedded:n,initialCreateScope:s,workspaceCwd:r,onMentionAgent:o}){const{t:i}=Xe(),{agents:l,loading:c,error:d,reload:h,getAgent:f,deleteAgent:p}=wze({autoLoad:!0}),[m,g]=u.useState(""),[v,y]=u.useState("all"),[w,b]=u.useState(null),[x,k]=u.useState(null),[_,S]=u.useState(!1),[R,j]=u.useState(!1),[E,I]=u.useState(!1),[C,N]=u.useState(()=>!!s),[A,M]=u.useState(!1),P=ko(),L=uat(P.capabilities,r),[F,$]=u.useState(()=>!s&&!n&&L);u.useEffect(()=>{L||$(!1)},[L]);const[B,D]=u.useState(null),[O,U]=u.useState(null),[H,Q]=u.useState(null),[q,te]=u.useState(!1),Z=u.useMemo(()=>LQn(l,m,v),[l,m,v]),ce=u.useMemo(()=>KPe(w,l),[l,w]),he=w?.name??null;u.useEffect(()=>{b(ne=>KPe(ne,l))},[l]),u.useEffect(()=>{n?.onDetailChange(!!(he||C||A||F))},[C,A,n,F,he]),u.useEffect(()=>{if(!w){k(null),Q(null);return}let ne=!0;return k(null),Q(null),S(!0),f(w.name,JPe(w.level)).then(pe=>{ne&&k(pe)}).catch(pe=>{ne&&Q(pe instanceof Error?pe.message:String(pe))}).finally(()=>{ne&&S(!1)}),()=>{ne=!1}},[w,f]),u.useEffect(()=>{te(!1)},[d]),u.useEffect(()=>{s&&($(!1),N(!0))},[s]);function W(){$(!1),N(!1),M(!1),b(null),k(null),U(null),h()}async function G(){if(!x||!ce)return;const ne=JPe(ce.level);if(ne){j(!0);try{await p(ce.name,ne),I(!1),b(null),k(null),D(i("agent.deleted",{name:x.name})),await h()}catch(pe){I(!1),U(pe instanceof Error?pe.message:String(pe))}finally{j(!1)}}}const J=[{value:"all",label:i("skills.filter.all")},{value:"project",label:i("agent.level.project")},{value:"user",label:i("agent.level.user")},{value:"builtin",label:i("agent.level.builtin")},{value:"extension",label:i("agent.level.extension")}],X=A?i("agent.edit"):he??(C?i("agent.create.button"):null),de=a.jsx(h2,{className:"sticky -top-4 z-10 -mx-5 -mt-4 border-b bg-background px-5 py-3",children:a.jsxs(f2,{className:"text-base",children:[a.jsx(dd,{children:a.jsx(Ne,{variant:"ghost",size:"icon",onClick:t,"aria-label":i("common.back"),children:a.jsx(Wp,{})})}),a.jsx(dd,{children:X?a.jsx(ok,{asChild:!0,children:a.jsx("button",{type:"button",onClick:W,children:i("agents.title")})}):a.jsx(lg,{children:i("agents.title")})}),X?a.jsx(ik,{}):null,X?a.jsx(dd,{children:a.jsx(lg,{children:X})}):null]})}),ae=n?X?a.jsx(h2,{className:"sticky -top-4 z-10 -mx-5 -mt-4 border-b bg-background px-5 py-3",children:a.jsxs(f2,{className:"h-8 text-sm",children:[n.onBack?a.jsx(dd,{children:a.jsx(Ne,{variant:"ghost",size:"icon",onClick:n.onBack,"aria-label":i("common.back"),children:a.jsx(Wp,{})})}):null,a.jsx(dd,{children:a.jsx(ok,{asChild:!0,children:a.jsx("button",{type:"button",onClick:()=>{W(),n.onDetailChange(!1)},children:i("agents.title")})})}),a.jsx(ik,{}),a.jsx(dd,{children:a.jsx(lg,{children:X})})]})}):null:de;if(F&&L)return a.jsxs("div",{className:"flex w-full flex-col gap-6 pb-8",children:[ae,a.jsx(YQn,{initialView:e,workspaceCwd:r,...o?{onMentionAgent:o}:{},onOpenDefinitions:()=>$(!1)})]});if(C)return a.jsxs("div",{className:"flex w-full flex-col gap-6 pb-8",children:[ae,a.jsx(QPe,{initialScope:s??"global",onCancel:W,onCreated:ne=>{N(!1),D(i("agent.created",{name:ne})),h()}})]});if(A&&x)return a.jsxs("div",{className:"flex w-full flex-col gap-6 pb-8",children:[ae,a.jsx(QPe,{agent:x,onCancel:()=>M(!1),onCreated:ne=>{M(!1),b(null),k(null),D(i("agent.updated",{name:ne})),h()}})]});if(he&&x){const ne=OQn(x),pe=!x.tools||x.tools.length===0||x.tools.includes("*")?i("agent.create.tools.all"):x.tools.join(", "),Re=x.disallowedTools?.join(", ")||"—";return a.jsxs("div",{className:"flex w-full flex-col gap-6 pb-8",children:[ae,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(_b,{})}),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 text-balance",children:x.name}),a.jsx(Zr,{variant:"outline",children:Gre(x.level,i)}),YPe(x,l)?a.jsx(Zr,{variant:"secondary",children:i("agent.overriddenBadge")}):null]})}),ne?a.jsxs(sf,{children:[a.jsx(Nh,{asChild:!0,children:a.jsx(Ne,{variant:"ghost",size:"icon",disabled:R,"aria-label":i("agent.chooseAction",{name:x.name}),children:R?a.jsx(qr,{}):a.jsx(Nb,{})})}),a.jsx(Mh,{align:"end",onCloseAutoFocus:ke=>ke.preventDefault(),children:a.jsxs(U_,{children:[a.jsxs(Mr,{onSelect:()=>M(!0),children:[a.jsx(Sb,{"data-icon":"inline-start"}),i("agent.edit")]}),a.jsxs(Mr,{variant:"destructive",disabled:R,onSelect:()=>I(!0),children:[a.jsx(Ef,{"data-icon":"inline-start"}),i("agent.delete")]})]})})]}):null]}),O?a.jsx(wg,{tone:"error",noticeKey:O,closeLabel:i("common.close"),onDismiss:()=>U(null),children:O}):null,a.jsxs(Ov,{defaultValue:"overview",children:[a.jsxs(Bv,{className:"max-w-full overflow-x-auto",children:[a.jsx(Ca,{value:"overview",children:i("agent.detail.overview")}),a.jsx(Ca,{value:"prompt",children:i("agent.detail.systemPrompt")}),a.jsx(Ca,{value:"tools",children:i("agent.detail.tools")}),a.jsx(Ca,{value:"mcp",children:i("agent.detail.mcp")}),a.jsx(Ca,{value:"hooks",children:i("agent.detail.hooks")})]}),a.jsx(ql,{value:"overview",className:"pt-4",children:a.jsxs(rc,{children:[a.jsxs(gu,{children:[a.jsx(vu,{className:"text-sm",children:i("agent.descriptionLabel")}),a.jsx(Rv,{children:x.description||"—"})]}),a.jsxs(tu,{className:"grid gap-6 sm:grid-cols-2",children:[a.jsx(VI,{label:i("agent.filePathLabel"),value:x.filePath||"—"}),a.jsx(VI,{label:i("agent.modelLabel"),value:x.model||"—"}),a.jsx(VI,{label:i("agent.level.label"),value:Gre(x.level,i)}),a.jsx(VI,{label:i("agent.create.approvalMode"),value:ZQn(x.approvalMode||x.permissionMode,i)}),a.jsx(VI,{label:i("agent.create.maxTurns"),value:x.maxTurns?.toString()||"—"}),a.jsx(VI,{label:i("agent.create.color"),value:x.color||"—"})]})]})}),a.jsx(ql,{value:"prompt",className:"pt-4",children:a.jsx(rc,{children:a.jsx(tu,{children:a.jsx("div",{className:"max-h-[60vh] w-full overflow-auto break-words whitespace-pre-line text-sm leading-6 text-muted-foreground",children:x.systemPrompt?eZn(x.systemPrompt):"—"})})})}),a.jsx(ql,{value:"tools",className:"pt-4",children:a.jsxs(rc,{children:[a.jsxs(gu,{children:[a.jsx(vu,{className:"text-sm",children:i("agent.toolsLabel")}),a.jsx(Rv,{children:pe})]}),a.jsx(tu,{className:"flex flex-col gap-6",children:a.jsx(VI,{label:i("agent.create.disallowedTools"),value:Re})})]})}),a.jsx(ql,{value:"mcp",className:"pt-4",children:a.jsxs(rc,{children:[a.jsx(gu,{children:a.jsx(vu,{className:"text-sm",children:i("agent.create.mcpServers")})}),a.jsx(tu,{children:a.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-words text-xs text-muted-foreground",children:s6e(x.mcpServers)})})]})}),a.jsx(ql,{value:"hooks",className:"pt-4",children:a.jsxs(rc,{children:[a.jsx(gu,{children:a.jsx(vu,{className:"text-sm",children:i("agent.detail.hooks")})}),a.jsx(tu,{children:a.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-words text-xs text-muted-foreground",children:s6e(x.hooks)})})]})})]}),a.jsx(fy,{open:E,onOpenChange:ke=>{!ke&&R||I(ke)},children:a.jsxs(py,{children:[a.jsxs(my,{children:[a.jsx(vy,{children:i("agent.delete.title",{name:x.name})}),a.jsx(wy,{children:i("agent.delete.confirm",{name:x.name})})]}),a.jsxs(gy,{children:[a.jsx(yy,{disabled:R,children:i("common.cancel")}),a.jsxs(Nk,{variant:"destructive",disabled:R,onClick:ke=>{ke.preventDefault(),G()},children:[R?a.jsx(qr,{"data-icon":"inline-start"}):null,i("agent.delete.yes")]})]})]})})]})]})}return he&&_?a.jsxs("div",{className:"flex w-full flex-col gap-6 pb-8",children:[ae,a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx(qr,{className:"size-6"})})]}):he&&H?a.jsxs("div",{className:"flex w-full flex-col gap-6 pb-8",children:[ae,a.jsx(wg,{tone:"error",noticeKey:H,closeLabel:i("common.close"),onDismiss:W,children:H})]}):a.jsxs("div",{className:"flex w-full flex-col gap-6 pb-8",children:[ae,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:i("agents.title")}),a.jsx("p",{className:"mt-1 text-sm text-muted-foreground tabular-nums",children:i("agents.description")}),a.jsx("p",{className:"mt-1 text-xs text-muted-foreground tabular-nums",children:i("agent.count",{count:l.length})})]}),a.jsxs("div",{className:"flex gap-2",children:[L?a.jsx(Ne,{variant:"outline",onClick:()=>$(!0),children:i("collab.sharedThreads")}):null,a.jsxs(Ne,{variant:"outline",disabled:c,onClick:()=>void h(),children:[c?a.jsx(qr,{"data-icon":"inline-start"}):a.jsx(ph,{"data-icon":"inline-start"}),i("common.refresh")]}),a.jsxs(Ne,{onClick:()=>N(!0),children:[a.jsx(Nf,{"data-icon":"inline-start"}),i("agent.create.button")]})]})]}),d&&!q?a.jsx(wg,{tone:"error",noticeKey:d.message,closeLabel:i("common.close"),onDismiss:()=>te(!0),children:d.message}):null,B?a.jsx(wg,{tone:"success",noticeKey:B,closeLabel:i("common.close"),onDismiss:()=>D(null),children:B}):null,a.jsxs("div",{className:"relative",children:[a.jsx(Hp,{className:"pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground"}),a.jsx(vr,{name:"agent-search","aria-label":i("common.search"),autoComplete:"off",value:m,onChange:ne=>g(ne.target.value),placeholder:i("common.search"),className:"pl-9"})]}),a.jsx(Pbe,{type:"single",value:v,onValueChange:ne=>{ne&&y(ne)},variant:"outline",size:"sm","aria-label":i("agent.level.filter"),children:J.map(ne=>a.jsx(Dbe,{value:ne.value,children:ne.label},ne.value))}),Z.length?a.jsx("div",{className:QQn.agentGrid,"data-column-count":Math.min(Z.length,4),children:Z.map(ne=>a.jsx(rc,{size:"sm",role:"button",tabIndex:0,"aria-label":ne.name,className:"cursor-pointer transition-colors hover:bg-accent/30 focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-none",onClick:()=>{D(null),U(null),b({name:ne.name,level:ne.level})},onKeyDown:pe=>{(pe.key==="Enter"||pe.key===" ")&&(pe.preventDefault(),D(null),U(null),b({name:ne.name,level:ne.level}))},children:a.jsx(gu,{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(_b,{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(vu,{className:"min-w-0 flex-1 truncate",children:ne.name}),a.jsxs("div",{className:"flex shrink-0 gap-1",children:[a.jsx(Zr,{variant:"outline",className:"text-[10px]",children:Gre(ne.level,i)}),YPe(ne,l)?a.jsx(Zr,{variant:"secondary",className:"text-[10px]",children:i("agent.overriddenBadge")}):null]})]}),a.jsx(Rv,{className:"mt-1 min-w-0 text-xs",children:a.jsx(Uu,{delayDuration:300,children:a.jsxs(Qc,{children:[a.jsx(Zc,{asChild:!0,children:a.jsx("span",{className:"block truncate",children:ne.description||"—"})}),a.jsx(ed,{children:ne.description||"—"})]})})})]})]})})},`${ne.level}:${ne.name}`))}):a.jsx(Av,{className:"border",children:a.jsxs(Rb,{children:[a.jsx(jv,{variant:"icon",children:m||v!=="all"?a.jsx(Hp,{}):a.jsx(_b,{})}),a.jsx(Eb,{children:i(m||v!=="all"?"agent.noMatches":"agent.empty")})]})})]})]})}/**
2716
2716
  * @license
2717
2717
  * Copyright 2026 Qwen Team
@@ -2897,7 +2897,7 @@ ${e}`:t}function poe(e,t){return e.length!==t.length?!1:e.every((n,s)=>{const r=
2897
2897
  `):void 0,onClick:()=>w?d?.(g):p(U=>!U),children:O}):a.jsx("div",{className:yc.header,children:O}),k&&a.jsxs("div",{className:yc.descriptionRow,children:[a.jsx("span",{className:yc.object,title:k,children:k}),b&&a.jsx(ide,{iconOnly:!0,tool:g,workspaceCwd:l,onOpen:c})]}),f&&I&&a.jsxs("div",{className:yc.details,children:[j&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:yc.detailLabel,children:h("turnCalls.arguments")}),a.jsx(Nhe,{text:j})]}),(R||S||E)&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:`${yc.detailLabel} flex items-center gap-1.5`,children:h("turnCalls.result")}),S?a.jsxs(a.Fragment,{children:[a.jsx(z9,{diff:S.slice(0,fE)}),S.length>fE&&a.jsx("p",{className:"text-xs text-muted-foreground",children:h("gitDiff.truncated")})]}):a.jsx(Nhe,{text:E||h(Lc(g.status)?"shell.result.waiting":"shell.result.empty")})]}),R?.other&&a.jsxs("details",{className:yc.other,children:[a.jsx("summary",{children:h("turnCalls.other")}),a.jsx("pre",{className:jhe.detailBody,children:R.other})]})]})]})});function afs({status:e}){const{t}=Xe();return e==="completed"||e==="success"?a.jsxs("span",{className:`${yc.status} ${yc.completed}`,children:[a.jsx(jb,{size:12,"aria-hidden":"true"}),t("turnCalls.completed")]}):e==="failed"||e==="error"?a.jsxs("span",{className:`${yc.status} ${yc.failed}`,children:[a.jsx(WT,{size:12,"aria-hidden":"true"}),t("tool.status.failed")]}):e==="in_progress"||e==="running"?a.jsxs("span",{className:yc.status,children:[a.jsx(qr,{className:"size-3","aria-hidden":"true"}),t("turnCalls.running")]}):e==="cancelled"||e==="canceled"?a.jsxs("span",{className:`${yc.status} text-[var(--warning-color)]`,children:[a.jsx(sVe,{size:12,"aria-hidden":"true"}),t("turnCalls.cancelled")]}):e==="pending"?a.jsxs("span",{className:yc.status,children:[a.jsx(Bge,{size:12,"aria-hidden":"true"}),t("turnCalls.pending")]}):a.jsx("span",{className:yc.status,children:t("turnCalls.unknown")})}const lfs="_root_9kme4_1",cfs="_intro_9kme4_8",dfs="_toolbar_9kme4_14",ufs="_count_9kme4_22",hfs="_toolbarActions_9kme4_28",ffs="_primaryButton_9kme4_34",pfs="_secondaryButton_9kme4_35",mfs="_formFields_9kme4_73",gfs="_field_9kme4_79",vfs="_fieldGrow_9kme4_86",wfs="_fieldLabel_9kme4_90",yfs="_required_9kme4_96",bfs="_fieldHint_9kme4_101",xfs="_input_9kme4_107",kfs="_textarea_9kme4_108",_fs="_select_9kme4_109",Sfs="_promptEditorWrap_9kme4_127",Cfs="_promptEditor_9kme4_127",Tfs="_promptPlaceholder_9kme4_160",Ifs="_promptTag_9kme4_174",Rfs="_promptTagIcon_9kme4_190",Efs="_promptTagValue_9kme4_201",Afs="_promptTagRemove_9kme4_211",jfs="_referencePopover_9kme4_239",Nfs="_referenceBar_9kme4_243",Mfs="_referenceButton_9kme4_250",Pfs="_referenceButtonActive_9kme4_267",Dfs="_referenceButtonIcon_9kme4_272",Lfs="_referencePicker_9kme4_282",Ofs="_referenceItem_9kme4_295",Bfs="_referenceItemLabel_9kme4_318",$fs="_referenceItemDescription_9kme4_319",Ffs="_referenceEmpty_9kme4_336",zfs="_referenceError_9kme4_337",Ufs="_routingFields_9kme4_347",Wfs="_newGroupFields_9kme4_357",Hfs="_inlineError_9kme4_364",qfs="_scheduleRow_9kme4_377",Vfs="_preview_9kme4_389",Gfs="_previewLabel_9kme4_397",Kfs="_previewCron_9kme4_402",Yfs="_previewInvalid_9kme4_412",Jfs="_formError_9kme4_417",Xfs="_loadError_9kme4_418",Qfs="_formActions_9kme4_424",Zfs="_empty_9kme4_432",eps="_list_9kme4_439",tps="_card_9kme4_447",nps="_cardDisabled_9kme4_458",sps="_cardHeader_9kme4_462",rps="_cardTitle_9kme4_468",ops="_cardMenu_9kme4_479",ips="_iconAction_9kme4_486",aps="_toggle_9kme4_518",lps="_toggleOn_9kme4_537",cps="_toggleKnob_9kme4_541",dps="_cardPrompt_9kme4_556",ups="_cardFooter_9kme4_569",hps="_schedulePill_9kme4_578",fps="_clockIcon_9kme4_590",pps="_recurringTag_9kme4_601",mps="_sessionModeTag_9kme4_606",gps="_workspacePill_9kme4_628",vps="_workspaceIcon_9kme4_646",wps="_workspaceName_9kme4_652",yps="_countdown_9kme4_664",bps="_hourglassIcon_9kme4_675",xps="_lastFired_9kme4_686",kps="_runsToggle_9kme4_694",_ps="_runsList_9kme4_711",Sps="_runsItem_9kme4_725",Cps="_runLink_9kme4_732",cn={root:lfs,intro:cfs,toolbar:dfs,count:ufs,toolbarActions:hfs,primaryButton:ffs,secondaryButton:pfs,formFields:mfs,field:gfs,fieldGrow:vfs,fieldLabel:wfs,required:yfs,fieldHint:bfs,input:xfs,textarea:kfs,select:_fs,promptEditorWrap:Sfs,promptEditor:Cfs,promptPlaceholder:Tfs,promptTag:Ifs,promptTagIcon:Rfs,promptTagValue:Efs,promptTagRemove:Afs,referencePopover:jfs,referenceBar:Nfs,referenceButton:Mfs,referenceButtonActive:Pfs,referenceButtonIcon:Dfs,referencePicker:Lfs,referenceItem:Ofs,referenceItemLabel:Bfs,referenceItemDescription:$fs,referenceEmpty:Ffs,referenceError:zfs,routingFields:Ufs,newGroupFields:Wfs,inlineError:Hfs,scheduleRow:qfs,preview:Vfs,previewLabel:Gfs,previewCron:Kfs,previewInvalid:Yfs,formError:Jfs,loadError:Xfs,formActions:Qfs,empty:Zfs,list:eps,card:tps,cardDisabled:nps,cardHeader:sps,cardTitle:rps,cardMenu:ops,iconAction:ips,toggle:aps,toggleOn:lps,toggleKnob:cps,cardPrompt:dps,cardFooter:ups,schedulePill:hps,clockIcon:fps,recurringTag:pps,sessionModeTag:mps,workspacePill:gps,workspaceIcon:vps,workspaceName:wps,countdown:yps,hourglassIcon:bps,lastFired:xps,runsToggle:kps,runsList:_ps,runsItem:Sps,runLink:Cps},Tps="_panel_25fxt_1",Ips="_panelDrawer_25fxt_11",Rps="_panelFullscreen_25fxt_12",Eps="_header_25fxt_24",Aps="_tabs_25fxt_44",jps="_tabItem_25fxt_53",Nps="_tab_25fxt_44",Mps="_tabTitle_25fxt_81",Pps="_tabTitleInner_25fxt_97",Dps="_tabIcon_25fxt_121",Lps="_tabIconSvg_25fxt_131",Ops="_tabArtifactIcon_25fxt_137",Bps="_tabActive_25fxt_142",$ps="_tabCloseButton_25fxt_157",Fps="_tabCloseIcon_25fxt_187",zps="_iconButton_25fxt_193",Ups="_iconButtonActive_25fxt_212",Wps="_headerActions_25fxt_216",Hps="_addButton_25fxt_227",qps="_fullscreenButton_25fxt_231",Vps="_panelToggleButton_25fxt_235",Gps="_panelToggleIcon_25fxt_247",Kps="_toolbarIcon_25fxt_253",Yps="_body_25fxt_259",Jps="_bodySideTask_25fxt_267",Xps="_terminalPane_25fxt_272",Qps="_terminalPaneHidden_25fxt_276",Zps="_attachmentPreviewButton_25fxt_280",ems="_pdfAttachmentPreview_25fxt_325",tms="_unsupportedAttachmentPreview_25fxt_333",nms="_unsupportedAttachmentMeta_25fxt_351",sms="_empty_25fxt_356",rms="_emptyActions_25fxt_362",oms="_emptyAction_25fxt_362",ims="_emptyActionIcon_25fxt_396",ams="_emptyActionTitle_25fxt_410",lms="_emptyActionHint_25fxt_414",cms="_emptyActionChevron_25fxt_424",dms="_sideTaskListTitle_25fxt_431",ums="_sideTaskListTime_25fxt_439",hms="_sideTaskNewIcon_25fxt_447",fms="_meta_25fxt_484",pms="_detail_25fxt_489",mms="_section_25fxt_494",gms="_sectionTitle_25fxt_499",vms="_description_25fxt_506",wms="_actionsRow_25fxt_510",yms="_fieldGrid_25fxt_517",bms="_fieldLabel_25fxt_524",xms="_fieldValue_25fxt_533",kms="_link_25fxt_538",_ms="_locationRow_25fxt_547",Sms="_openButton_25fxt_554",Cms="_review_25fxt_572",Tms="_reviewToolbar_25fxt_579",Ims="_reviewToolbarTitle_25fxt_588",Rms="_reviewToolbarActions_25fxt_595",Ems="_reviewTotalsButton_25fxt_601",Ams="_reviewContent_25fxt_619",jms="_reviewContentListOnly_25fxt_629",Nms="_reviewContentStacked_25fxt_633",Mms="_reviewList_25fxt_638",Pms="_reviewListWithExpanded_25fxt_646",Dms="_reviewSplitHandle_25fxt_659",Lms="_reviewItem_25fxt_674",Oms="_reviewItemExpanded_25fxt_679",Bms="_reviewRow_25fxt_686",$ms="_reviewRowToggle_25fxt_708",Fms="_reviewFileName_25fxt_729",zms="_reviewOpenButton_25fxt_736",Ums="_fileIcon_25fxt_759",Wms="_reviewPath_25fxt_773",Hms="_treeName_25fxt_774",qms="_pathPrefix_25fxt_790",Vms="_pathFileName_25fxt_796",Gms="_lineStats_25fxt_804",Kms="_additions_25fxt_813",Yms="_deletions_25fxt_817",Jms="_chevron_25fxt_821",Xms="_chevronOpen_25fxt_827",Qms="_chevronIcon_25fxt_831",Zms="_diffPreview_25fxt_837",egs="_codeMirrorDiff_25fxt_847",tgs="_codeMirrorDiffWrap_25fxt_855",ngs="_diffError_25fxt_863",sgs="_codeMirrorFile_25fxt_888",rgs="_diffEmpty_25fxt_954",ogs="_tree_25fxt_774",igs="_treeNode_25fxt_967",ags="_treeChildren_25fxt_971",lgs="_treeRow_25fxt_985",cgs="_treeFolder_25fxt_1018",dgs="_treeFile_25fxt_1022",ugs="_treeTwisty_25fxt_1031",hgs="_treeChevronIcon_25fxt_1040",fgs="_treeChevron_25fxt_1040",pgs="_treeChevronClosed_25fxt_1051",mgs="_treeContent_25fxt_1055",ggs="_reviewBadge_25fxt_1078",vgs="_htmlPreviewWrap_25fxt_1091",wgs="_markdownPreviewWrap_25fxt_1098",ygs="_imagePreviewWrap_25fxt_1104",bgs="_imagePreview_25fxt_1104",xgs="_imageDownloadButton_25fxt_1121",kgs="_downloadRow_25fxt_1153",_gs="_downloadButton_25fxt_1157",Sgs="_htmlPreview_25fxt_1091",Cgs="_previewError_25fxt_1189",Tgs="_filePreviewWrap_25fxt_1195",Ct={panel:Tps,panelDrawer:Ips,panelFullscreen:Rps,header:Eps,tabs:Aps,tabItem:jps,tab:Nps,tabTitle:Mps,tabTitleInner:Pps,tabIcon:Dps,tabIconSvg:Lps,tabArtifactIcon:Ops,tabActive:Bps,tabCloseButton:$ps,tabCloseIcon:Fps,iconButton:zps,iconButtonActive:Ups,headerActions:Wps,addButton:Hps,fullscreenButton:qps,panelToggleButton:Vps,panelToggleIcon:Gps,toolbarIcon:Kps,body:Yps,bodySideTask:Jps,terminalPane:Xps,terminalPaneHidden:Qps,attachmentPreviewButton:Zps,pdfAttachmentPreview:ems,unsupportedAttachmentPreview:tms,unsupportedAttachmentMeta:nms,empty:sms,emptyActions:rms,emptyAction:oms,emptyActionIcon:ims,emptyActionTitle:ams,emptyActionHint:lms,emptyActionChevron:cms,sideTaskListTitle:dms,sideTaskListTime:ums,sideTaskNewIcon:hms,meta:fms,detail:pms,section:mms,sectionTitle:gms,description:vms,actionsRow:wms,fieldGrid:yms,fieldLabel:bms,fieldValue:xms,link:kms,locationRow:_ms,openButton:Sms,review:Cms,reviewToolbar:Tms,reviewToolbarTitle:Ims,reviewToolbarActions:Rms,reviewTotalsButton:Ems,reviewContent:Ams,reviewContentListOnly:jms,reviewContentStacked:Nms,reviewList:Mms,reviewListWithExpanded:Pms,reviewSplitHandle:Dms,reviewItem:Lms,reviewItemExpanded:Oms,reviewRow:Bms,reviewRowToggle:$ms,reviewFileName:Fms,reviewOpenButton:zms,fileIcon:Ums,reviewPath:Wms,treeName:Hms,pathPrefix:qms,pathFileName:Vms,lineStats:Gms,additions:Kms,deletions:Yms,chevron:Jms,chevronOpen:Xms,chevronIcon:Qms,diffPreview:Zms,codeMirrorDiff:egs,codeMirrorDiffWrap:tgs,diffError:ngs,codeMirrorFile:sgs,diffEmpty:rgs,tree:ogs,treeNode:igs,treeChildren:ags,treeRow:lgs,treeFolder:cgs,treeFile:dgs,treeTwisty:ugs,treeChevronIcon:hgs,treeChevron:fgs,treeChevronClosed:pgs,treeContent:mgs,reviewBadge:ggs,htmlPreviewWrap:vgs,markdownPreviewWrap:wgs,imagePreviewWrap:ygs,imagePreview:bgs,imageDownloadButton:xgs,downloadRow:kgs,downloadButton:_gs,htmlPreview:Sgs,previewError:Cgs,filePreviewWrap:Tgs},Igs="_root_1xnu0_1",Rgs="_summary_1xnu0_7",Egs="_eyebrow_1xnu0_18",Ags="_verdict_1xnu0_26",jgs="_meta_1xnu0_32",Ngs="_path_1xnu0_33",Mgs="_metrics_1xnu0_39",Pgs="_metric_1xnu0_39",Dgs="_caps_1xnu0_63",Lgs="_filters_1xnu0_74",Ogs="_primaryButton_1xnu0_98",Bgs="_secondaryButton_1xnu0_99",$gs="_findings_1xnu0_104",Fgs="_finding_1xnu0_104",zgs="_detailBlock_1xnu0_118",Ugs="_findingHeader_1xnu0_127",Wgs="_severity_1xnu0_135",Hgs="_notLinked_1xnu0_162",qgs="_report_1xnu0_203",Vgs="_evidenceImage_1xnu0_208",Ggs="_empty_1xnu0_217",Kgs="_errorFallback_1xnu0_223",Ygs="_error_1xnu0_223",Ac={root:Igs,summary:Rgs,eyebrow:Egs,verdict:Ags,meta:jgs,path:Ngs,metrics:Mgs,metric:Pgs,caps:Dgs,filters:Lgs,primaryButton:Ogs,secondaryButton:Bgs,findings:$gs,finding:Fgs,detailBlock:zgs,findingHeader:Ugs,severity:Wgs,notLinked:Hgs,report:qgs,evidenceImage:Vgs,empty:Ggs,errorFallback:Kgs,error:Ygs},GG=["Critical","Suggestion","Nice to have"],KG=["high","low"],Jgs=["review","build","test","probe","lint"],Xgs=["fixed","skipped","no_change_needed"];function pE(e,t){if(e===null||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object.`);return e}function Uw(e,t){if(typeof e!="string"||e.trim()==="")throw new Error(`${t} must be a non-empty string.`);return e}function Hj(e,t){if(e!==void 0)return Uw(e,t)}function YG(e,t){if(typeof e!="number"||!Number.isSafeInteger(e)||e<0)throw new Error(`${t} must be a non-negative safe integer.`);return e}function Qgs(e,t){const n=YG(e,t);if(n===0)throw new Error(`${t} must be a positive safe integer.`);return n}function Zgs(e){const t=Uw(e,"markdownReportPath");if(t.startsWith("/")||t.split("/").includes("..")||!t.endsWith(".md"))throw new Error('markdownReportPath must be a relative .md path without ".." segments.');if(!t.startsWith(".qwen/reviews/"))throw new Error("markdownReportPath must be a file under .qwen/reviews/.");return t}function i4(e,t,n){if(typeof e!="string"||!t.includes(e))throw new Error(`${n} has an unsupported value.`);return e}function Phe(e,t){if(!Array.isArray(e))throw new Error(`${t} must be an array.`);return e.map((n,s)=>Uw(n,`${t}[${s}]`))}function K6e(e,t,n){const s=pE(e,n);return Object.fromEntries(t.map(r=>[r,YG(s[r],`${n}.${r}`)]))}function e0s(e,t){const n=`findings[${t}]`,s=pE(e,n);if(!Array.isArray(s.locations)||s.locations.length===0)throw new Error(`${n}.locations must be a non-empty array.`);const r=s.locations.map((i,l)=>{const c=pE(i,`${n}.locations[${l}]`);return{file:Uw(c.file,`${n}.locations[${l}].file`),...c.line===void 0?{}:{line:Qgs(c.line,`${n}.locations[${l}].line`)},...Hj(c.anchor,`${n}.locations[${l}].anchor`)?{anchor:c.anchor}:{}}}),o=s.outcome===void 0?void 0:i4(s.outcome,Xgs,`${n}.outcome`);return{id:Uw(s.id,`${n}.id`),severity:i4(s.severity,GG,`${n}.severity`),confidence:i4(s.confidence,KG,`${n}.confidence`),source:i4(s.source,Jgs,`${n}.source`),summary:Uw(s.summary,`${n}.summary`),shortSummary:Uw(s.shortSummary,`${n}.shortSummary`),failureScenario:Uw(s.failureScenario,`${n}.failureScenario`),...Hj(s.witness,`${n}.witness`)?{witness:s.witness}:{},...Hj(s.suggestedFix,`${n}.suggestedFix`)?{suggestedFix:s.suggestedFix}:{},...Hj(s.fixWitness,`${n}.fixWitness`)?{fixWitness:s.fixWitness}:{},...Hj(s.category,`${n}.category`)?{category:s.category}:{},locations:r,...s.assetFiles===void 0?{}:{assetFiles:Phe(s.assetFiles,`${n}.assetFiles`)},...s.assets===void 0?{}:{assets:Phe(s.assets,`${n}.assets`)},...o?{outcome:o}:{},...Hj(s.outcomeNote,`${n}.outcomeNote`)?{outcomeNote:s.outcomeNote}:{},...s.heldByMeasurement===void 0?{}:{heldByMeasurement:{file:Uw(pE(s.heldByMeasurement,`${n}.heldByMeasurement`).file,`${n}.heldByMeasurement.file`)}}}}function t0s(e){let t;try{t=JSON.parse(e)}catch(o){throw new Error(`Malformed code review JSON: ${o instanceof Error?o.message:String(o)}`)}const n=pE(t,"Code review document");if(n.schemaVersion!==1)throw new Error(`Unsupported code review schemaVersion: ${JSON.stringify(n.schemaVersion)}. Expected 1.`);if(!Array.isArray(n.findings))throw new Error("findings must be an array.");const s=pE(n.verdict,"verdict"),r=pE(n.counts,"counts");return{schemaVersion:1,target:Uw(n.target,"target"),effort:Uw(n.effort,"effort"),verdict:{event:i4(s.event,["APPROVE","COMMENT","REQUEST_CHANGES"],"verdict.event"),verdictLine:Uw(s.verdictLine,"verdict.verdictLine"),baseEvent:i4(s.baseEvent,["APPROVE","COMMENT","REQUEST_CHANGES"],"verdict.baseEvent"),cappedBy:Phe(s.cappedBy,"verdict.cappedBy")},findings:n.findings.map(e0s),counts:{total:YG(r.total,"counts.total"),bySeverity:K6e(r.bySeverity,GG,"counts.bySeverity"),byConfidence:K6e(r.byConfidence,KG,"counts.byConfidence"),held:YG(r.held,"counts.held")},markdownReportPath:Zgs(n.markdownReportPath)}}function n0s({workspacePath:e,artifactVersion:t,workspaceActions:n}){const{t:s}=Xe(),r=Dm(),[o,i]=u.useState(null),[l,c]=u.useState(null),[d,h]=u.useState(!1),[f,p]=u.useState("all"),[m,g]=u.useState("all"),[v,y]=u.useState(null),[w,b]=u.useState(null),[x,k]=u.useState(null),[_,S]=u.useState(!1),R=u.useRef(0);u.useEffect(()=>{let A=!1;return R.current+=1,i(null),c(null),h(!1),p("all"),g("all"),y(null),b(null),k(null),S(!1),n.readWorkspaceFile(e).then(M=>{if(!A){if(M.truncated){h(!0);return}i(M.content)}}).catch(M=>{A||c(M instanceof Error?M.message:String(M))}),()=>{A=!0,R.current+=1}},[t,n,e]);const j=u.useMemo(()=>{if(o===null)return null;try{return{document:t0s(o),error:null}}catch(A){return{document:null,error:A instanceof Error?A.message:String(A)}}},[o]),E=A=>{const M=++R.current;y(A),b(null),k(null),S(!0),n.readWorkspaceFile(A).then(P=>{M===R.current&&(P.truncated?k(s("codeReview.reportTruncated")):b(P.content))}).catch(P=>{M===R.current&&k(P instanceof Error?P.message:String(P))}).finally(()=>{M===R.current&&S(!1)})};if(w!==null||x)return a.jsxs("div",{className:Ac.report,children:[a.jsx("button",{type:"button",className:Ac.secondaryButton,onClick:()=>{R.current+=1,y(null),b(null),k(null),S(!1)},children:s("codeReview.back")}),a.jsx("div",{className:Ac.path,children:v}),x?a.jsx("div",{className:Ac.error,role:"alert",children:x}):a.jsx(dp,{content:w??""})]});const I=d?s("codeReview.artifactTruncated"):l;if(I||j?.error){const A=e.endsWith(".json")?`${e.slice(0,-5)}.md`:null;return a.jsxs("div",{className:Ac.errorFallback,children:[a.jsxs("div",{className:Ac.error,role:"alert",children:[a.jsx("strong",{children:s("codeReview.loadErrorTitle")}),a.jsx("span",{children:I??j?.error})]}),A&&a.jsx("button",{type:"button",className:Ac.secondaryButton,onClick:()=>E(A),disabled:_,children:s(_?"codeReview.loadingReport":"codeReview.openReport")})]})}if(!j?.document)return a.jsx("div",{className:Ac.empty,children:s("codeReview.loading")});const C=j.document,N=C.findings.filter(A=>(f==="all"||A.severity===f)&&(m==="all"||A.confidence===m));return a.jsxs("div",{className:Ac.root,children:[a.jsxs("section",{className:Ac.summary,children:[a.jsxs("div",{children:[a.jsx("div",{className:Ac.eyebrow,children:s("codeReview.authoritativeVerdict")}),a.jsx("h2",{className:Ac.verdict,children:C.verdict.verdictLine}),a.jsx("div",{className:Ac.meta,children:s("codeReview.targetEffort",{target:C.target,effort:C.effort})})]}),a.jsx("button",{type:"button",className:Ac.primaryButton,onClick:()=>E(C.markdownReportPath),disabled:_,children:s(_?"codeReview.loadingReport":"codeReview.openReport")})]}),a.jsxs("section",{className:Ac.metrics,"aria-label":s("codeReview.reviewCounts"),children:[a.jsx(nU,{label:s("codeReview.total"),value:C.counts.total}),GG.map(A=>a.jsx(nU,{label:A,value:C.counts.bySeverity[A]},A)),KG.map(A=>a.jsx(nU,{label:s("codeReview.confidence",{value:A}),value:C.counts.byConfidence[A]},A)),a.jsx(nU,{label:s("codeReview.held"),value:C.counts.held})]}),a.jsxs("section",{className:Ac.caps,children:[a.jsx("span",{className:Ac.eyebrow,children:s("codeReview.caps")}),a.jsx("span",{children:C.verdict.cappedBy.length>0?C.verdict.cappedBy.join(", "):s("codeReview.none")})]}),a.jsxs("div",{className:Ac.filters,children:[a.jsxs("label",{children:[s("codeReview.severity"),a.jsxs("select",{"aria-label":s("codeReview.severity"),value:f,onChange:A=>p(A.target.value),children:[a.jsx("option",{value:"all",children:s("codeReview.all")}),GG.map(A=>a.jsxs("option",{value:A,children:[A," (",C.counts.bySeverity[A],")"]},A))]})]}),a.jsxs("label",{children:[s("codeReview.confidenceLabel"),a.jsxs("select",{"aria-label":s("codeReview.confidenceLabel"),value:m,onChange:A=>g(A.target.value),children:[a.jsx("option",{value:"all",children:s("codeReview.all")}),KG.map(A=>a.jsxs("option",{value:A,children:[A," (",C.counts.byConfidence[A],")"]},A))]})]})]}),a.jsx("div",{className:Ac.findings,children:N.length===0?a.jsx("div",{className:Ac.empty,children:s("codeReview.noMatches")}):N.map(A=>a.jsxs("article",{className:Ac.finding,children:[a.jsxs("div",{className:Ac.findingHeader,children:[a.jsx("span",{className:Ac.severity,children:A.severity}),a.jsx("span",{children:s("codeReview.confidence",{value:A.confidence})}),a.jsx("span",{children:s("codeReview.source",{value:A.source})}),A.category&&a.jsx("span",{children:A.category})]}),a.jsx("h3",{children:A.summary}),a.jsx(qj,{label:s("codeReview.failureScenario"),value:A.failureScenario}),A.witness&&a.jsx(qj,{label:s("codeReview.witness"),value:A.witness}),A.suggestedFix&&a.jsx(qj,{label:s("codeReview.suggestedFix"),value:A.suggestedFix}),A.fixWitness&&a.jsx(qj,{label:s("codeReview.fixWitness"),value:A.fixWitness}),A.outcome&&a.jsx(qj,{label:s("codeReview.outcome"),value:`${A.outcome}${A.outcomeNote?` — ${A.outcomeNote}`:""}`}),A.heldByMeasurement&&a.jsx(qj,{label:s("codeReview.heldByMeasurement"),value:A.heldByMeasurement.file}),a.jsxs("div",{className:Ac.detailBlock,children:[a.jsx("strong",{children:s("codeReview.locations")}),a.jsx("ul",{children:A.locations.map((M,P)=>a.jsxs("li",{children:[a.jsxs("code",{children:[M.file,M.line===void 0?"":`:${M.line}`]}),M.anchor&&a.jsxs("span",{children:[" — ",M.anchor]})]},`${M.file}:${M.line??""}:${P}`))})]}),(A.assets&&A.assets.length>0||A.assetFiles&&A.assetFiles.length>0)&&a.jsxs("div",{className:Ac.detailBlock,children:[a.jsx("strong",{children:s("codeReview.evidence")}),a.jsxs("ul",{children:[(A.assets??[]).map((M,P)=>a.jsx("li",{children:A2(M)?a.jsx("a",{href:M,target:"_blank",rel:"noopener noreferrer",onClick:L=>r(L,M),children:M}):a.jsxs("span",{className:Ac.notLinked,children:[M," (",s("codeReview.notLinked"),")"]})},`${M}-${P}`)),(A.assetFiles??[]).map((M,P)=>a.jsx(s0s,{path:M,workspaceActions:n},`${M}-${P}`))]})]})]},A.id))})]})}function s0s({path:e,workspaceActions:t}){const n=XT(e),[s,r]=u.useState(null);return u.useEffect(()=>{if(!n)return;let o=!1,i;return j2((l,c)=>t.readFileBytes(l,c),e,n,{statFile:l=>t.stat(l),isCancelled:()=>o}).then(l=>{o||(i=URL.createObjectURL(l),r(i))}).catch(()=>{}),()=>{o=!0,i&&URL.revokeObjectURL(i)}},[n,e,t]),a.jsxs("li",{children:[s&&a.jsx("img",{className:Ac.evidenceImage,src:s,alt:e}),a.jsx("code",{children:e})]})}function nU({label:e,value:t}){return a.jsxs("div",{className:Ac.metric,children:[a.jsx("strong",{children:t}),a.jsx("span",{children:e})]})}function qj({label:e,value:t}){return a.jsxs("div",{className:Ac.detailBlock,children:[a.jsx("strong",{children:e}),a.jsx("p",{children:t})]})}const yoe=10*1024*1024,r0s=`<!doctype html><html><head>
2898
2898
  <meta http-equiv="Content-Security-Policy" content="default-src 'none'; base-uri 'none'; form-action 'none'; style-src 'unsafe-inline'; img-src data:; font-src data:;">
2899
2899
  <style>html,body{margin:0;background:#eee;color:#000}body{overflow:auto}.docx-wrapper{width:max-content;min-width:100%;box-sizing:border-box}</style>
2900
- </head><body></body></html>`;function o0s({workspacePath:e,workspaceActions:t,data:n,artifactVersion:s,downloadName:r}){const{t:o}=Xe(),[i,l]=u.useState(),[c,d]=u.useState(!1),[h,f]=u.useState(),[p,m]=u.useState(),[g,v]=u.useState(),[y,w]=u.useState(!1),[b,x]=u.useState(0),k=u.useRef(void 0);return u.useEffect(()=>{const _={};if(k.current=_,!i)return()=>{k.current=void 0};let S=!1,R=!1,j,E;const I=i.createElement("div");i.body.replaceChildren(I);const C=A=>{S||R||(R=!0,clearTimeout(j),I.remove(),f(A))};return d(!1),f(void 0),m(void 0),v(void 0),w(!1),(async()=>{const A=n??await j2(t.readFileBytes,e,jce,{statFile:async L=>{const F=await t.stat(L);if(F.sizeBytes>yoe)throw new Error(o("docx.tooLarge"));return F},isCancelled:()=>S,maxBytes:yoe});if(S)return;if(E=URL.createObjectURL(A),m(E),A.size>yoe){C(o("docx.tooLarge"));return}j=setTimeout(()=>C(o("docx.timeout")),3e4);const M=await A.arrayBuffer(),{renderAsync:P}=await xt(async()=>{const{renderAsync:L}=await import("./docx-preview-BMBWboRx.js");return{renderAsync:L}},[]);if(!(S||R)){try{await P(M,I,I,{useBase64URL:!0,renderAltChunks:!1})}catch{C(o("docx.invalid"));return}if(!(S||R)){clearTimeout(j);for(const L of I.querySelectorAll("a")){const F=L.getAttribute("href");F?.startsWith("#")?L.addEventListener("click",$=>{$.preventDefault(),i.getElementById(F.slice(1))?.scrollIntoView()}):L.removeAttribute("href"),L.removeAttribute("target")}d(!0)}}})().catch(A=>{C(Wa(A))}),()=>{S=!0,k.current=void 0,clearTimeout(j),I.remove(),E&&URL.revokeObjectURL(E)}},[i,n,e,t,s,b,o]),a.jsxs("div",{"data-web-shell-docx-preview":!0,className:"flex h-full min-h-0 flex-col",children:[a.jsx("div",{className:"flex justify-end border-b border-border p-1",children:p?a.jsx(Ne,{variant:"ghost",size:"sm",asChild:!0,children:a.jsxs("a",{href:p,download:r??dve(e),onClick:_=>_.stopPropagation(),children:[a.jsx(oy,{"aria-hidden":"true"}),o("common.download")]})}):t?a.jsxs(Ne,{variant:"ghost",size:"sm",disabled:y,onClick:()=>{const _=k.current,S=()=>k.current!==_;w(!0),v(void 0),L9(t,e,jce,S).catch(R=>{S()||v(Wa(R))}).finally(()=>{S()||w(!1)})},children:[a.jsx(oy,{"aria-hidden":"true"}),o("common.download")]}):null}),g&&a.jsx("p",{role:"alert",className:"p-3 text-sm text-destructive",children:g}),a.jsxs("div",{className:"relative min-h-0 flex-1",children:[a.jsx("iframe",{title:`Preview ${e}`,className:"h-full w-full border-0",style:{visibility:c?"visible":"hidden"},srcDoc:r0s,sandbox:"allow-same-origin",referrerPolicy:"no-referrer",onLoad:_=>{l(_.currentTarget.contentDocument??void 0)}}),h?a.jsxs("div",{role:"alert",className:"absolute inset-0 space-y-3 p-4 text-sm",children:[a.jsx("p",{children:h}),a.jsx(Ne,{variant:"outline",size:"sm",onClick:()=>x(_=>_+1),children:o("common.retry")})]}):c?null:a.jsx("div",{role:"status",className:"absolute inset-0 p-4 text-sm text-muted-foreground",children:o("attachment.loadingPreview")})]})]})}const i0s="_detail_4ah9l_1",a0s="_state_4ah9l_9",l0s="_overview_4ah9l_17",c0s="_descriptionRow_4ah9l_25",d0s="_statusTag_4ah9l_33",u0s="_statusActions_4ah9l_38",h0s="_stopButton_4ah9l_45",f0s="_stopError_4ah9l_67",p0s="_description_4ah9l_25",m0s="_transcript_4ah9l_114",g0s="_retry_4ah9l_122",Tw={detail:i0s,state:a0s,overview:l0s,descriptionRow:c0s,statusTag:d0s,statusActions:u0s,stopButton:h0s,stopError:f0s,description:p0s,transcript:m0s,retry:g0s};function v0s(e,t){const n=typeof e.rawOutput=="object"&&e.rawOutput!==null?e.rawOutput:void 0,s=typeof n?.executionSummary=="object"&&n.executionSummary!==null?n.executionSummary:void 0,r=s?.totalDurationMs,o=s?.inputTokens,i=s?.outputTokens,l=s?.cachedTokens;return{status:t.status,durationMs:typeof r=="number"?r:e.endTime&&e.startTime?Math.max(0,e.endTime-e.startTime):t.durationMs,inputTokens:typeof o=="number"?o:t.inputTokens,outputTokens:typeof i=="number"?i:t.outputTokens,cachedTokens:typeof l=="number"?l:t.cachedTokens}}function Y6e(){return`subagent-detail:${typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Math.random().toString(36).slice(2)}`}function w0s(e,t){for(const n of e){if(n.role!=="tool_group")continue;const s=n.tools.find(r=>r.callId===t);if(s)return s}}function y0s(e,t){switch(e){case"completed":case"success":return t("subagent.completed");case"failed":case"error":return t("subagent.failed");case"cancelled":case"canceled":return t("subagent.cancelled");case"paused":return t("subagent.paused");default:return t("subagent.running")}}function b0s({rootTool:e,resolution:t,onStop:n,onRightPanelOpen:s,onArtifactsChange:r,onOpenSubagent:o,onError:i}){const{t:l}=Xe(),c=Da(),{blocks:d,blockChangeSummary:h}=mA(),f=TX(l,d,h),{artifacts:p}=Wbe(),m=u.useMemo(()=>YN(f,p,c.workspaceCwd||""),[p,c.workspaceCwd,f]),g=_be(f,m,c.workspaceCwd||c.standaloneSession?.projectlessOutputDirectory||"",c.sessionId?kbe(c.sessionId):void 0,c.workspaceCwd?void 0:null),v=B9(e),y=u.useMemo(()=>v0s(e,t),[t,e]),w=y.status==="running"||y.status==="in_progress",[b,x]=u.useState(!1),[k,_]=u.useState("");u.useEffect(()=>{const I=c.sessionId;if(I)return r?.(I,p),()=>{r?.(I,[])}},[p,c.sessionId,r]);const S=u.useRef({messages:f,artifactsByTurn:m});S.current={messages:f,artifactsByTurn:m};const R=u.useCallback(I=>{const C=S.current;s?.({...I,...I.kind==="review"?{unfilteredChanges:T4(C.messages,C.artifactsByTurn,c.workspaceCwd||c.standaloneSession?.projectlessOutputDirectory||"").get(I.turnId)??I.changes}:{},sourceSessionId:c.sessionId})},[c.sessionId,c.workspaceCwd,c.standaloneSession?.projectlessOutputDirectory,s]);u.useEffect(()=>{w||(x(!1),_(""))},[w]);const j=async()=>{if(!(b||!n)){x(!0),_("");try{(await n()).cancelled||x(!1)}catch{x(!1),_(l("tasks.cancelFailed"))}}},E=a.jsx(IJ,{messages:f,pendingApproval:null,loadingTranscript:c.loadingTranscript,catchingUp:c.catchingUp,isResponding:w,activeTurnStartedAt:w?e.startTime:void 0,workspaceCwd:c.workspaceCwd||"",hideSessionTimeline:!0,firstTurnMetrics:y,includeSubagentToolUsageInMetrics:!1,turnFileChanges:g,sourceSessionId:c.sessionId,turnArtifacts:m,onTurnOutputOpen:R,onError:i});return a.jsxs("div",{className:Tw.detail,children:[a.jsxs("div",{className:Tw.overview,children:[a.jsxs("div",{className:Tw.descriptionRow,children:[v&&a.jsx("div",{className:Tw.description,children:v}),a.jsxs("div",{className:Tw.statusActions,children:[a.jsx(Zr,{variant:"outline",className:Tw.statusTag,"data-status":y.status,children:y0s(y.status,l)}),w&&n&&a.jsx("button",{type:"button",className:Tw.stopButton,disabled:b,onClick:()=>void j(),children:l(b?"common.loading":"tasks.action.stop")})]})]}),k&&a.jsx("div",{className:Tw.stopError,children:k})]}),a.jsx("div",{className:Tw.transcript,children:o?a.jsx(Pve,{onOpen:o,children:E}):E})]})}function x0s({sessionId:e,rootToolCallId:t,initialRootTool:n,workspaceCwd:s,onRightPanelOpen:r,onArtifactsChange:o,onOpenSubagent:i,onError:l}){const{t:c}=Xe(),d=ko(),h=Da(),{blocks:f,blockChangeSummary:p}=mA(),m=TX(c,f,p),g=(h.sessionId===e?w0s(m,t):void 0)??n,[v,y]=u.useState(()=>({key:0,clientId:Y6e()})),w=Hu(),[b,x]=u.useState(),[k,_]=u.useState(!1);return u.useEffect(()=>{let S=!1,R=!1,j=0,E=!1,I=!1,C=!1,N;x(void 0),_(!1);const A=async()=>{if(!(I||w&&w.getSnapshot()!=="available")){I=!0;try{const L=await d.client.resolveSubagentSession(e,t);if(S)return;R=!0,j=0,E=L.status==="running",x(L),_(!1),L.status==="running"&&(!w||w.getSnapshot()==="available")&&(N=setTimeout(()=>void A(),3e3))}catch(L){if(S||ac(L)||w&&w.getSnapshot()!=="available")return;j<3?(j+=1,N=setTimeout(()=>void A(),3e3)):R?E&&(N=setTimeout(()=>void A(),3e4)):_(!0)}finally{I=!1,C&&!S&&(!w||w.getSnapshot()==="available")&&(C=!1,N&&clearTimeout(N),A())}}};let M=w?.getSnapshot()==="available";const P=w?.subscribe(()=>{const L=w.getSnapshot()==="available";L!==M&&(M=L,N&&clearTimeout(N),L&&(!R||E)&&(I?C=!0:A()))});return A(),()=>{S=!0,P?.(),N&&clearTimeout(N)}},[w,v.key,t,e,d.client]),k?a.jsxs("div",{className:Tw.state,children:[a.jsx("div",{children:c("subagent.detailsLoadFailed")}),a.jsx("button",{type:"button",className:Tw.retry,onClick:()=>y(S=>({key:S.key+1,clientId:Y6e()})),children:c("common.retry")})]}):b?a.jsx(GK,{sessionId:b.sessionId,workspaceCwd:s,clientId:v.clientId,maxQueued:256,maxBlocks:VK,subagentTranscriptMode:"full",suppressOwnUserEcho:!0,children:a.jsx(b0s,{rootTool:g,resolution:b,onRightPanelOpen:r,onArtifactsChange:o,onOpenSubagent:i?(S,R)=>i(S,R??e,s):void 0,onError:l,onStop:n.rawOutput&&typeof n.rawOutput=="object"&&"workflowRunId"in n.rawOutput?void 0:()=>d.client.cancelSubagentSession(e,t)})},`${v.key}:${b.sessionId}`):a.jsx("div",{className:Tw.state,children:c("subagent.detailsLoading")})}const k0s="_viewport_7jcdi_1",_0s="_canvas_7jcdi_14",S0s="_edges_7jcdi_20",C0s="_edgeRunning_7jcdi_33",T0s="_node_7jcdi_39",I0s="_nodeTitle_7jcdi_78",R0s="_mainNode_7jcdi_88",E0s="_nodeMeta_7jcdi_108",A0s="_status_7jcdi_114",j0s="_statusRunning_7jcdi_136",N0s="_duration_7jcdi_140",M0s="_empty_7jcdi_146",P0s="_loading_7jcdi_147",Jm={viewport:k0s,canvas:_0s,edges:S0s,edgeRunning:C0s,node:T0s,nodeTitle:I0s,mainNode:R0s,nodeMeta:E0s,status:A0s,statusRunning:j0s,duration:N0s,empty:M0s,loading:P0s},a4=184,Dhe=68,sU=32,D0s=72,QP=32,bD="__main__";function J6e(e){return e?{left:e.x,top:e.y}:void 0}function L0s(e){const t=new Map(e.map(h=>[h.id,h])),n=new Map;for(const h of e){const f=h.parentAgentId&&t.has(h.parentAgentId)?h.parentAgentId:bD,p=n.get(f)??[];p.push(h),n.set(f,p)}const s=new Map,r=new Set,o=h=>{const f=s.get(h);if(f!==void 0)return f;if(r.has(h))return a4;r.add(h);const p=n.get(h)??[],m=Math.max(a4,p.reduce((g,v)=>g+o(v.id),0)+Math.max(0,p.length-1)*sU);return r.delete(h),s.set(h,m),m},i=new Map,l=new Set,c=(h,f,p)=>{if(l.has(h))return;l.add(h);const m=o(h);i.set(h,{x:f+(m-a4)/2,y:QP+p*(Dhe+D0s)});let g=f;for(const v of n.get(h)??[])c(v.id,g,p+1),g+=o(v.id)+sU};c(bD,QP,0);let d=QP+o(bD)+sU;for(const h of e)l.has(h.id)||(c(h.id,d,1),d+=o(h.id)+sU);return{positions:i,width:Math.max(360,...Array.from(i.values(),({x:h})=>h+a4+QP)),height:Math.max(220,...Array.from(i.values(),({y:h})=>h+Dhe+QP))}}function O0s(e,t,n){const s=(e.subagentType?.toLowerCase()==="fork"?e.label.replace(/^fork:\s*/i,""):e.label).trim();return s&&s.toLowerCase()!=="agent"?s:n(t+1)}function B0s(e,t){return e.status==="running"?e.startTime>0?Math.max(e.runtimeMs,t-e.startTime):e.runtimeMs:e.endTime===void 0?e.runtimeMs:Math.max(0,e.endTime-e.startTime)||e.runtimeMs}function $0s({tasks:e,loading:t=!1,error:n,onOpenAgent:s}){const{t:r}=Xe(),o=u.useMemo(()=>L0s(e),[e]),i=e.some(d=>d.status==="running"),[l,c]=u.useState(Date.now);return u.useEffect(()=>{if(!i)return;c(Date.now());const d=window.setInterval(()=>c(Date.now()),1e3);return()=>window.clearInterval(d)},[i]),t?a.jsxs("div",{className:Jm.loading,role:"status","aria-label":r("common.loading"),children:[a.jsx(rk,{className:"h-[68px] w-[184px] rounded-xl"}),a.jsx(rk,{className:"h-[68px] w-[184px] rounded-xl"})]}):n?a.jsx("div",{className:Jm.empty,children:n}):e.length===0?a.jsx("div",{className:Jm.empty,children:r("workflow.empty")}):a.jsx("div",{className:Jm.viewport,"data-testid":"agent-workflow",children:a.jsxs("div",{className:Jm.canvas,style:{width:o.width,height:o.height},children:[a.jsx("svg",{className:Jm.edges,"data-testid":"agent-workflow-edges",width:o.width,height:o.height,"aria-hidden":"true",children:e.map(d=>{const h=o.positions.get(d.parentAgentId??"")??o.positions.get(bD),f=o.positions.get(d.id),p=h.x+a4/2,m=h.y+Dhe,g=f.x+a4/2,v=f.y,y=(m+v)/2;return a.jsx("path",{className:d.status==="running"?Jm.edgeRunning:"",d:`M ${p} ${m} C ${p} ${y}, ${g} ${y}, ${g} ${v}`},d.id)})}),a.jsxs("div",{className:`${Jm.node} ${Jm.mainNode}`,style:J6e(o.positions.get(bD)),children:[a.jsx(_b,{}),a.jsx("span",{children:r("workflow.mainAgent")})]}),e.map((d,h)=>a.jsxs("button",{type:"button",className:Jm.node,"data-status":d.status,style:J6e(o.positions.get(d.id)),onClick:()=>s?.(d),disabled:!s,title:d.description||d.label,children:[a.jsxs("span",{className:Jm.nodeTitle,children:[a.jsx(_b,{}),a.jsx("span",{children:O0s(d,h,f=>r("environment.unnamedAgent",{index:f}))})]}),a.jsxs("span",{className:Jm.nodeMeta,children:[a.jsxs("span",{className:Jm.status,"data-status":d.status,children:[d.status==="completed"&&a.jsx(jb,{}),d.status==="running"&&a.jsx(zu,{className:Jm.statusRunning}),d.status==="paused"&&a.jsx(Oge,{}),d.status==="failed"&&a.jsx(WT,{}),d.status==="cancelled"&&a.jsx(rVe,{}),r(`tasks.${d.status}`)]}),a.jsx("span",{className:Jm.duration,children:na(B0s(d,l))})]})]},d.id))]})})}const F0s=3;function z0s({tabId:e,sessionId:t,parentSessionId:n,workspaceCwd:s,title:r,shouldNameFromFirstPrompt:o,initialPrompt:i,createSession:l,onCreated:c,onTitleChange:d,onRightPanelOpen:h,onArtifactsChange:f,onError:p,sessionWorkflowEnabled:m,modelManagement:g,unavailableModels:v,mountUnavailableModelTooltip:y,onImageIngestionNotice:w,onInitialPromptRefused:b}){return t?a.jsx(GK,{sessionId:t,workspaceCwd:s,clientId:`side-task:${n}:${e}`,autoConnect:!0,historyPageSize:Kg,subagentTranscriptMode:"summary",maxBlocks:VK,suppressOwnUserEcho:!0,children:a.jsx(W0s,{tabId:e,title:r,shouldNameFromFirstPrompt:o,initialPrompt:i,workspaceCwd:s,onTitleChange:d,onRightPanelOpen:h,onArtifactsChange:f,onError:p,sessionWorkflowEnabled:m,modelManagement:g,unavailableModels:v,mountUnavailableModelTooltip:y,onImageIngestionNotice:w,onInitialPromptRefused:b})}):a.jsx(U0s,{tabId:e,parentSessionId:n,title:r,createSession:l,onCreated:c,onTitleChange:d,onError:p})}function U0s({tabId:e,parentSessionId:t,title:n,createSession:s,onCreated:r,onTitleChange:o,onError:i}){const{t:l}=Xe(),c=u.useRef(!1),d=u.useRef(!1),h=u.useRef(!0),[f,p]=u.useState();u.useEffect(()=>(h.current=!0,()=>{h.current=!1}),[]);const m=u.useCallback(async()=>{if(!c.current){c.current=!0,p(void 0);try{const g=await s(e,t,n);r(e,g.sessionId),h.current&&g.displayName&&o(e,g.displayName)}catch(g){if(!h.current)return;p(g),i?.(g,l("sideTask.createFailed"))}finally{c.current=!1}}},[s,r,i,o,t,l,e,n]);return u.useEffect(()=>{d.current||(d.current=!0,m())},[m]),f?a.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 text-sm text-muted-foreground",children:[a.jsx("span",{children:l("sideTask.createFailed")}),a.jsx(Ne,{type:"button",variant:"outline",onClick:()=>void m(),children:l("common.retry")})]}):a.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-muted-foreground",role:"status",children:[a.jsx(qr,{}),a.jsx("span",{children:l("sideTask.creating")})]})}function W0s({tabId:e,title:t,shouldNameFromFirstPrompt:n,initialPrompt:s,workspaceCwd:r,onTitleChange:o,onRightPanelOpen:i,onArtifactsChange:l,onError:c,sessionWorkflowEnabled:d,modelManagement:h,unavailableModels:f,mountUnavailableModelTooltip:p,onImageIngestionNotice:m,onInitialPromptRefused:g}){const{t:v}=Xe(),y=Da(),w=rf(),b=ko(),x=hS(b.client),k=Fme(),_=$me(),S=y.workspaceCwd&&r&&y.workspaceCwd!==r?void 0:y.workspaceCwd??r,R=k.some(L=>L.kind==="user"&&(typeof L.text=="string"?L.text.trim().length>0:!L.images?.length)),j=k.some(L=>L.kind!=="user"?!1:L.images?.length||L.files?.length||L.resourceLinks?.length?!0:typeof L.text!="string"||L.text.trim().length>0),E=y.status==="connected"&&!y.loadingTranscript&&!y.catchingUp&&!_.loading&&!_.hasMore&&!_.capacityReached&&!_.paginationError,I=E&&!j,C=!R&&(n||E&&!R);u.useEffect(()=>{const L=y.displayName?.trim();L&&o(e,L)},[y.displayName,o,e]);const N=u.useCallback(L=>{const F=Array.from(L.trim()).slice(0,200).join("");F&&(o(e,F),(async()=>{let $;for(let B=0;B<F0s;B++)try{await w.renameSession(F),y.sessionId&&S&&x.renamed(S,y.sessionId,F),o(e,F,!0);return}catch(D){$=D}S&&x.invalidateWorkspace(S),c?.($,v("sideTask.renameFailed"))})())},[w,S,y.sessionId,c,o,x,v,e]),A=u.useRef(!1),M=!!(s?.trim()&&I&&!A.current&&!BG(h).allowAdd&&!Jit(y.commands)&&Kw(s)),P=u.useRef(m);return P.current=m,u.useEffect(()=>{if(!M)return;const L=setTimeout(()=>{P.current?.("warning",v("sideTask.commandsLoadingTimedOut"))},5e3);return()=>clearTimeout(L)},[M,s,y.sessionId,v]),u.useEffect(()=>{const L=s?.trim();if(!(!L||!I||A.current||M)){if(A.current=!0,!BG(h).allowAdd&&Kw(L,y.commands)){m?.("warning",v("settings.models.addDisabled")),g?.(e);return}w.sendPrompt(L,{onAdmitted:()=>{y.sessionId&&S&&x.promptAdmitted(S,y.sessionId),N(L)}}).catch(F=>{A.current=!1,c?.(F,v("sideTask.promptFailed"))})}},[w,S,y.commands,y.sessionId,s,h,m,g,N,c,I,M,x,v,e]),y.sessionId?a.jsx(nct,{title:y.displayName?.trim()||t,workspaceCwd:r,onError:c,onImageIngestionNotice:m,embedded:!0,onFirstPromptAdmitted:C?N:void 0,onRightPanelOpen:i,onPaneArtifactsChange:l,sessionWorkflowEnabled:d,modelManagement:h,unavailableModels:f,mountUnavailableModelTooltip:p}):a.jsx("div",{className:"flex h-full items-center justify-center",children:a.jsx(qr,{})})}const H0s="_inspector_cn1ku_1",q0s="_summary_cn1ku_20",V0s="_detail_cn1ku_21",G0s="_attention_cn1ku_22",K0s="_steps_cn1ku_23",Y0s="_collapsible_cn1ku_24",J0s="_summaryHeading_cn1ku_38",X0s="_sectionHeading_cn1ku_39",Q0s="_compactHeading_cn1ku_40",Z0s="_summaryCount_cn1ku_72",evs="_progress_cn1ku_87",tvs="_summaryMeta_cn1ku_108",nvs="_expandButton_cn1ku_116",svs="_stepList_cn1ku_177",rvs="_linkedAgents_cn1ku_178",ovs="_deliverables_cn1ku_179",ivs="_activityList_cn1ku_180",avs="_attentionGlyph_cn1ku_216",lvs="_status_cn1ku_228",cvs="_stepId_cn1ku_254",dvs="_dependencies_cn1ku_262",uvs="_dependencyList_cn1ku_291",hvs="_dependencyLink_cn1ku_309",fvs="_dependencyNumber_cn1ku_333",pvs="_showAllActivity_cn1ku_358",mvs="_itemText_cn1ku_398",gvs="_stepIndex_cn1ku_474",vvs="_metrics_cn1ku_349",wvs="_stateLabel_cn1ku_545",yvs="_activityAvatar_cn1ku_605",bvs="_canvasHint_cn1ku_617",xvs="_empty_cn1ku_633",da={inspector:H0s,summary:q0s,detail:V0s,attention:G0s,steps:K0s,collapsible:Y0s,summaryHeading:J0s,sectionHeading:X0s,compactHeading:Q0s,summaryCount:Z0s,progress:evs,summaryMeta:tvs,expandButton:nvs,stepList:svs,linkedAgents:rvs,deliverables:ovs,activityList:ivs,attentionGlyph:avs,status:lvs,stepId:cvs,dependencies:dvs,dependencyList:uvs,dependencyLink:hvs,dependencyNumber:fvs,showAllActivity:pvs,itemText:mvs,stepIndex:gvs,metrics:vvs,stateLabel:wvs,activityAvatar:yvs,canvasHint:bvs,empty:xvs},X6e=6;function kvs({todos:e,tools:t,tasks:n,projection:s,artifacts:r,selectedTodoId:o,onSelectedTodoIdChange:i,onExpandGraph:l,onOpenSubagent:c,onOpenArtifact:d,canvasMode:h=!1}){const{language:f,t:p}=Xe(),m=u.useMemo(()=>s??mJ(e,t,n),[s,n,e,t]),g=bXe(e,m),v=u.useMemo(()=>{const C=new Map;return e.forEach((N,A)=>C.set(N.id,A+1)),C},[e]),[y,w]=u.useState(!1),b=m.todosById.has(o??"")?o:g,x=m.todosById.get(b??"");u.useEffect(()=>{b!==o&&i(b)},[b,i,o]);const k=C=>{sp(C)||c(C)};if(e.length===0)return a.jsxs("div",{className:da.empty,"data-testid":"workflow-inspector-empty",children:[a.jsx(uh,{"aria-hidden":"true"}),a.jsx("strong",{children:p("workflow.empty.title")}),a.jsx("p",{children:p("workflow.empty.copy")})]});const _=x?m.states.get(x.id):void 0,S=x?m.agentToolsByTodo.get(x.id)??[]:[],R=x?[...new Set(x.blockedBy??[])].filter(C=>C!==x.id&&m.todosById.has(C)):void 0,j=x?m.dependentsByTodo.get(x.id)??[]:[],E=C=>{const N=m.todosById.get(C),A=v.get(C);return a.jsx("li",{children:a.jsxs("button",{className:da.dependencyLink,"data-plan-interactive":!0,"data-testid":`workflow-dependency-${C}`,onClick:()=>i(C),title:N?.content,type:"button",children:[A!==void 0&&a.jsx("span",{className:da.dependencyNumber,children:A}),a.jsx("span",{children:N?.content??C})]})},C)},I=x&&_&&a.jsxs("section",{className:da.detail,"data-testid":"workflow-step-detail",children:[a.jsxs("div",{className:da.sectionHeading,children:[a.jsxs("div",{children:[a.jsx("span",{children:p("workflow.inspector.selectedStep")}),a.jsx("h2",{children:x.content})]}),a.jsx("span",{className:da.status,"data-status":_.status,children:p(`planExecution.status.${_.status}`)})]}),a.jsx("code",{className:da.stepId,children:x.id}),a.jsxs("dl",{className:da.dependencies,children:[a.jsxs("div",{children:[a.jsx("dt",{children:p("workflow.dependencies.upstream")}),a.jsx("dd",{children:R?.length?a.jsx("ul",{className:da.dependencyList,children:R.map(C=>E(C))}):p("workflow.dependencies.none")})]}),a.jsxs("div",{children:[a.jsx("dt",{children:p("workflow.dependencies.unblocks")}),a.jsx("dd",{children:j.length?a.jsx("ul",{className:da.dependencyList,children:j.map(C=>E(C.id))}):p("workflow.dependencies.noDownstream")})]})]}),a.jsxs("div",{className:da.linkedAgents,children:[a.jsx("h3",{children:p("planExecution.subagents")}),S.length?S.map(C=>{const N=m.tasksByTool.get(C),A=N?[N.startTime>0?$p(N.runtimeMs):"",N.stats?.toolUses===void 0?"":p("planExecution.toolCalls",{count:N.stats.toolUses}),N.stats?.totalTokens===void 0?"":p("planExecution.tokens",{count:N.stats.totalTokens.toLocaleString()})].filter(Boolean):[];return a.jsxs("button",{"aria-disabled":!!sp(C)||void 0,title:p(sp(C)??"planExecution.openDetails"),onClick:()=>k(C),type:"button",children:[a.jsxs("span",{className:da.itemText,children:[a.jsx("strong",{children:C.title||String(C.args?.description??"Agent")}),N&&a.jsx("small",{children:N.recentActivities?.at(-1)?.description||N.description}),A.length>0&&a.jsx("small",{className:da.metrics,children:A.map(M=>a.jsx("span",{children:M},M))})]}),N&&a.jsx("span",{className:da.stateLabel,"data-status":N.status,children:p(VAe(N.status))}),a.jsx(_le,{"aria-hidden":"true"})]},C.callId)}):a.jsx("p",{children:p("planExecution.noSubagents")})]})]});return h?a.jsxs("div",{className:da.inspector,"data-testid":"workflow-canvas-detail",children:[a.jsxs("div",{className:da.canvasHint,children:[a.jsx(uh,{"aria-hidden":"true"}),a.jsx("span",{children:p("workflow.inspector.canvasHint")})]}),I]}):a.jsxs("div",{className:da.inspector,"data-testid":"workflow-inspector",children:[a.jsxs("section",{className:da.summary,children:[a.jsxs("div",{className:da.summaryHeading,children:[a.jsxs("div",{children:[a.jsx("span",{children:p("workflow.inspector.summary")}),a.jsx("strong",{children:p(m.taskStatusI18nKey)})]}),a.jsxs("span",{className:da.summaryCount,"data-status":m.taskStatusTone,children:[m.completedCount,"/",e.length]})]}),a.jsx("div",{className:da.progress,role:"progressbar","aria-label":p("planExecution.overallProgress"),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":m.progressPercent,children:a.jsx("span",{style:{width:`${m.progressPercent}%`}})}),a.jsxs("div",{className:da.summaryMeta,children:[a.jsx("span",{children:p("workflow.inspector.activeAgents",{count:m.activeAgents.length})}),a.jsx("span",{children:p("workflow.inspector.attentionCount",{count:m.attentionTodos.length})})]}),a.jsxs("button",{className:da.expandButton,onClick:l,type:"button",children:[a.jsx(uh,{"aria-hidden":"true"}),p("workflow.inspector.expandGraph"),a.jsx(Vl,{"aria-hidden":"true"})]})]}),m.attentionTodos.length>0&&a.jsxs("section",{className:da.attention,children:[a.jsxs("div",{className:da.compactHeading,children:[a.jsx("h2",{children:p("workflow.tabs.attention")}),a.jsx("span",{children:m.attentionTodos.length})]}),m.attentionTodos.map(C=>a.jsxs("button",{"aria-pressed":b===C.id,onClick:()=>i(C.id),type:"button",children:[a.jsx(fd,{"aria-hidden":"true",className:da.attentionGlyph}),a.jsx("span",{children:C.content}),a.jsx(Vl,{"aria-hidden":"true"})]},C.id))]}),a.jsxs("section",{className:da.steps,"data-testid":"workflow-step-list",children:[a.jsxs("div",{className:da.compactHeading,children:[a.jsx("h2",{children:p("workflow.inspector.allSteps")}),a.jsx("span",{children:e.length})]}),a.jsx("div",{className:da.stepList,children:e.map((C,N)=>{const A=m.states.get(C.id);return a.jsxs("button",{"aria-pressed":b===C.id,onClick:()=>i(C.id),type:"button",children:[a.jsx("span",{className:da.stepIndex,"data-status":A?.status,children:N+1}),a.jsxs("span",{className:da.itemText,children:[a.jsx("strong",{children:C.content}),a.jsx("small",{children:C.id})]}),A&&a.jsx("span",{className:da.stateLabel,"data-status":A.status,children:p(`planExecution.status.${A.status}`)})]},C.id)})})]}),I,a.jsxs("details",{className:da.collapsible,open:!0,children:[a.jsxs("summary",{children:[a.jsx("span",{children:p("workflow.inspector.recentActivity")}),a.jsx("small",{children:m.activity.length})]}),a.jsxs("div",{className:da.activityList,children:[(y?m.activity:m.activity.slice(0,X6e)).map(C=>{const N=m.toolsByTaskId.get(C.id),A=C.endTime??C.startTime,M=a.jsxs(a.Fragment,{children:[a.jsx("time",{dateTime:A?new Date(A).toISOString():void 0,children:von(A,f)}),a.jsx("span",{className:da.activityAvatar,children:gon(C.subagentType||C.label)}),a.jsxs("span",{className:da.itemText,children:[a.jsx("strong",{children:C.label}),a.jsx("small",{children:C.recentActivities?.at(-1)?.description||C.description})]}),a.jsx("span",{className:da.stateLabel,"data-status":C.status,children:p(VAe(C.status))})]});return N?a.jsx("button",{"aria-disabled":!!sp(N)||void 0,title:p(sp(N)??"planExecution.openDetails"),onClick:()=>k(N),type:"button",children:M},C.id):a.jsx("div",{children:M},C.id)}),m.activity.length===0&&a.jsx("p",{children:p("workflow.activity.empty")}),!y&&m.activity.length>X6e&&a.jsx("button",{className:da.showAllActivity,"data-plan-interactive":!0,"data-testid":"workflow-activity-show-all",onClick:()=>w(!0),type:"button",children:p("workflow.activity.showAll",{count:m.activity.length})})]})]}),a.jsxs("details",{className:da.collapsible,open:r.length>0,children:[a.jsxs("summary",{children:[a.jsx("span",{children:p("workflow.deliverables.title")}),a.jsx("small",{children:r.length})]}),a.jsxs("div",{className:da.deliverables,children:[r.map(C=>a.jsxs("button",{disabled:!d,onClick:()=>d?.(C.id),type:"button",children:[a.jsxs("span",{className:da.itemText,children:[a.jsx("strong",{children:O9(C)}),a.jsxs("small",{className:da.metrics,children:[a.jsx("span",{children:C.kind}),a.jsx("span",{children:C.status})]})]}),a.jsx(_le,{"aria-hidden":"true"})]},C.id)),r.length===0&&a.jsx("p",{children:p("workflow.deliverables.none")})]})]})]})}/**
2900
+ </head><body></body></html>`;function o0s({workspacePath:e,workspaceActions:t,data:n,artifactVersion:s,downloadName:r}){const{t:o}=Xe(),[i,l]=u.useState(),[c,d]=u.useState(!1),[h,f]=u.useState(),[p,m]=u.useState(),[g,v]=u.useState(),[y,w]=u.useState(!1),[b,x]=u.useState(0),k=u.useRef(void 0);return u.useEffect(()=>{const _={};if(k.current=_,!i)return()=>{k.current=void 0};let S=!1,R=!1,j,E;const I=i.createElement("div");i.body.replaceChildren(I);const C=A=>{S||R||(R=!0,clearTimeout(j),I.remove(),f(A))};return d(!1),f(void 0),m(void 0),v(void 0),w(!1),(async()=>{const A=n??await j2(t.readFileBytes,e,jce,{statFile:async L=>{const F=await t.stat(L);if(F.sizeBytes>yoe)throw new Error(o("docx.tooLarge"));return F},isCancelled:()=>S,maxBytes:yoe});if(S)return;if(E=URL.createObjectURL(A),m(E),A.size>yoe){C(o("docx.tooLarge"));return}j=setTimeout(()=>C(o("docx.timeout")),3e4);const M=await A.arrayBuffer(),{renderAsync:P}=await xt(async()=>{const{renderAsync:L}=await import("./docx-preview-3XzkP9iR.js");return{renderAsync:L}},[]);if(!(S||R)){try{await P(M,I,I,{useBase64URL:!0,renderAltChunks:!1})}catch{C(o("docx.invalid"));return}if(!(S||R)){clearTimeout(j);for(const L of I.querySelectorAll("a")){const F=L.getAttribute("href");F?.startsWith("#")?L.addEventListener("click",$=>{$.preventDefault(),i.getElementById(F.slice(1))?.scrollIntoView()}):L.removeAttribute("href"),L.removeAttribute("target")}d(!0)}}})().catch(A=>{C(Wa(A))}),()=>{S=!0,k.current=void 0,clearTimeout(j),I.remove(),E&&URL.revokeObjectURL(E)}},[i,n,e,t,s,b,o]),a.jsxs("div",{"data-web-shell-docx-preview":!0,className:"flex h-full min-h-0 flex-col",children:[a.jsx("div",{className:"flex justify-end border-b border-border p-1",children:p?a.jsx(Ne,{variant:"ghost",size:"sm",asChild:!0,children:a.jsxs("a",{href:p,download:r??dve(e),onClick:_=>_.stopPropagation(),children:[a.jsx(oy,{"aria-hidden":"true"}),o("common.download")]})}):t?a.jsxs(Ne,{variant:"ghost",size:"sm",disabled:y,onClick:()=>{const _=k.current,S=()=>k.current!==_;w(!0),v(void 0),L9(t,e,jce,S).catch(R=>{S()||v(Wa(R))}).finally(()=>{S()||w(!1)})},children:[a.jsx(oy,{"aria-hidden":"true"}),o("common.download")]}):null}),g&&a.jsx("p",{role:"alert",className:"p-3 text-sm text-destructive",children:g}),a.jsxs("div",{className:"relative min-h-0 flex-1",children:[a.jsx("iframe",{title:`Preview ${e}`,className:"h-full w-full border-0",style:{visibility:c?"visible":"hidden"},srcDoc:r0s,sandbox:"allow-same-origin",referrerPolicy:"no-referrer",onLoad:_=>{l(_.currentTarget.contentDocument??void 0)}}),h?a.jsxs("div",{role:"alert",className:"absolute inset-0 space-y-3 p-4 text-sm",children:[a.jsx("p",{children:h}),a.jsx(Ne,{variant:"outline",size:"sm",onClick:()=>x(_=>_+1),children:o("common.retry")})]}):c?null:a.jsx("div",{role:"status",className:"absolute inset-0 p-4 text-sm text-muted-foreground",children:o("attachment.loadingPreview")})]})]})}const i0s="_detail_4ah9l_1",a0s="_state_4ah9l_9",l0s="_overview_4ah9l_17",c0s="_descriptionRow_4ah9l_25",d0s="_statusTag_4ah9l_33",u0s="_statusActions_4ah9l_38",h0s="_stopButton_4ah9l_45",f0s="_stopError_4ah9l_67",p0s="_description_4ah9l_25",m0s="_transcript_4ah9l_114",g0s="_retry_4ah9l_122",Tw={detail:i0s,state:a0s,overview:l0s,descriptionRow:c0s,statusTag:d0s,statusActions:u0s,stopButton:h0s,stopError:f0s,description:p0s,transcript:m0s,retry:g0s};function v0s(e,t){const n=typeof e.rawOutput=="object"&&e.rawOutput!==null?e.rawOutput:void 0,s=typeof n?.executionSummary=="object"&&n.executionSummary!==null?n.executionSummary:void 0,r=s?.totalDurationMs,o=s?.inputTokens,i=s?.outputTokens,l=s?.cachedTokens;return{status:t.status,durationMs:typeof r=="number"?r:e.endTime&&e.startTime?Math.max(0,e.endTime-e.startTime):t.durationMs,inputTokens:typeof o=="number"?o:t.inputTokens,outputTokens:typeof i=="number"?i:t.outputTokens,cachedTokens:typeof l=="number"?l:t.cachedTokens}}function Y6e(){return`subagent-detail:${typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Math.random().toString(36).slice(2)}`}function w0s(e,t){for(const n of e){if(n.role!=="tool_group")continue;const s=n.tools.find(r=>r.callId===t);if(s)return s}}function y0s(e,t){switch(e){case"completed":case"success":return t("subagent.completed");case"failed":case"error":return t("subagent.failed");case"cancelled":case"canceled":return t("subagent.cancelled");case"paused":return t("subagent.paused");default:return t("subagent.running")}}function b0s({rootTool:e,resolution:t,onStop:n,onRightPanelOpen:s,onArtifactsChange:r,onOpenSubagent:o,onError:i}){const{t:l}=Xe(),c=Da(),{blocks:d,blockChangeSummary:h}=mA(),f=TX(l,d,h),{artifacts:p}=Wbe(),m=u.useMemo(()=>YN(f,p,c.workspaceCwd||""),[p,c.workspaceCwd,f]),g=_be(f,m,c.workspaceCwd||c.standaloneSession?.projectlessOutputDirectory||"",c.sessionId?kbe(c.sessionId):void 0,c.workspaceCwd?void 0:null),v=B9(e),y=u.useMemo(()=>v0s(e,t),[t,e]),w=y.status==="running"||y.status==="in_progress",[b,x]=u.useState(!1),[k,_]=u.useState("");u.useEffect(()=>{const I=c.sessionId;if(I)return r?.(I,p),()=>{r?.(I,[])}},[p,c.sessionId,r]);const S=u.useRef({messages:f,artifactsByTurn:m});S.current={messages:f,artifactsByTurn:m};const R=u.useCallback(I=>{const C=S.current;s?.({...I,...I.kind==="review"?{unfilteredChanges:T4(C.messages,C.artifactsByTurn,c.workspaceCwd||c.standaloneSession?.projectlessOutputDirectory||"").get(I.turnId)??I.changes}:{},sourceSessionId:c.sessionId})},[c.sessionId,c.workspaceCwd,c.standaloneSession?.projectlessOutputDirectory,s]);u.useEffect(()=>{w||(x(!1),_(""))},[w]);const j=async()=>{if(!(b||!n)){x(!0),_("");try{(await n()).cancelled||x(!1)}catch{x(!1),_(l("tasks.cancelFailed"))}}},E=a.jsx(IJ,{messages:f,pendingApproval:null,loadingTranscript:c.loadingTranscript,catchingUp:c.catchingUp,isResponding:w,activeTurnStartedAt:w?e.startTime:void 0,workspaceCwd:c.workspaceCwd||"",hideSessionTimeline:!0,firstTurnMetrics:y,includeSubagentToolUsageInMetrics:!1,turnFileChanges:g,sourceSessionId:c.sessionId,turnArtifacts:m,onTurnOutputOpen:R,onError:i});return a.jsxs("div",{className:Tw.detail,children:[a.jsxs("div",{className:Tw.overview,children:[a.jsxs("div",{className:Tw.descriptionRow,children:[v&&a.jsx("div",{className:Tw.description,children:v}),a.jsxs("div",{className:Tw.statusActions,children:[a.jsx(Zr,{variant:"outline",className:Tw.statusTag,"data-status":y.status,children:y0s(y.status,l)}),w&&n&&a.jsx("button",{type:"button",className:Tw.stopButton,disabled:b,onClick:()=>void j(),children:l(b?"common.loading":"tasks.action.stop")})]})]}),k&&a.jsx("div",{className:Tw.stopError,children:k})]}),a.jsx("div",{className:Tw.transcript,children:o?a.jsx(Pve,{onOpen:o,children:E}):E})]})}function x0s({sessionId:e,rootToolCallId:t,initialRootTool:n,workspaceCwd:s,onRightPanelOpen:r,onArtifactsChange:o,onOpenSubagent:i,onError:l}){const{t:c}=Xe(),d=ko(),h=Da(),{blocks:f,blockChangeSummary:p}=mA(),m=TX(c,f,p),g=(h.sessionId===e?w0s(m,t):void 0)??n,[v,y]=u.useState(()=>({key:0,clientId:Y6e()})),w=Hu(),[b,x]=u.useState(),[k,_]=u.useState(!1);return u.useEffect(()=>{let S=!1,R=!1,j=0,E=!1,I=!1,C=!1,N;x(void 0),_(!1);const A=async()=>{if(!(I||w&&w.getSnapshot()!=="available")){I=!0;try{const L=await d.client.resolveSubagentSession(e,t);if(S)return;R=!0,j=0,E=L.status==="running",x(L),_(!1),L.status==="running"&&(!w||w.getSnapshot()==="available")&&(N=setTimeout(()=>void A(),3e3))}catch(L){if(S||ac(L)||w&&w.getSnapshot()!=="available")return;j<3?(j+=1,N=setTimeout(()=>void A(),3e3)):R?E&&(N=setTimeout(()=>void A(),3e4)):_(!0)}finally{I=!1,C&&!S&&(!w||w.getSnapshot()==="available")&&(C=!1,N&&clearTimeout(N),A())}}};let M=w?.getSnapshot()==="available";const P=w?.subscribe(()=>{const L=w.getSnapshot()==="available";L!==M&&(M=L,N&&clearTimeout(N),L&&(!R||E)&&(I?C=!0:A()))});return A(),()=>{S=!0,P?.(),N&&clearTimeout(N)}},[w,v.key,t,e,d.client]),k?a.jsxs("div",{className:Tw.state,children:[a.jsx("div",{children:c("subagent.detailsLoadFailed")}),a.jsx("button",{type:"button",className:Tw.retry,onClick:()=>y(S=>({key:S.key+1,clientId:Y6e()})),children:c("common.retry")})]}):b?a.jsx(GK,{sessionId:b.sessionId,workspaceCwd:s,clientId:v.clientId,maxQueued:256,maxBlocks:VK,subagentTranscriptMode:"full",suppressOwnUserEcho:!0,children:a.jsx(b0s,{rootTool:g,resolution:b,onRightPanelOpen:r,onArtifactsChange:o,onOpenSubagent:i?(S,R)=>i(S,R??e,s):void 0,onError:l,onStop:n.rawOutput&&typeof n.rawOutput=="object"&&"workflowRunId"in n.rawOutput?void 0:()=>d.client.cancelSubagentSession(e,t)})},`${v.key}:${b.sessionId}`):a.jsx("div",{className:Tw.state,children:c("subagent.detailsLoading")})}const k0s="_viewport_7jcdi_1",_0s="_canvas_7jcdi_14",S0s="_edges_7jcdi_20",C0s="_edgeRunning_7jcdi_33",T0s="_node_7jcdi_39",I0s="_nodeTitle_7jcdi_78",R0s="_mainNode_7jcdi_88",E0s="_nodeMeta_7jcdi_108",A0s="_status_7jcdi_114",j0s="_statusRunning_7jcdi_136",N0s="_duration_7jcdi_140",M0s="_empty_7jcdi_146",P0s="_loading_7jcdi_147",Jm={viewport:k0s,canvas:_0s,edges:S0s,edgeRunning:C0s,node:T0s,nodeTitle:I0s,mainNode:R0s,nodeMeta:E0s,status:A0s,statusRunning:j0s,duration:N0s,empty:M0s,loading:P0s},a4=184,Dhe=68,sU=32,D0s=72,QP=32,bD="__main__";function J6e(e){return e?{left:e.x,top:e.y}:void 0}function L0s(e){const t=new Map(e.map(h=>[h.id,h])),n=new Map;for(const h of e){const f=h.parentAgentId&&t.has(h.parentAgentId)?h.parentAgentId:bD,p=n.get(f)??[];p.push(h),n.set(f,p)}const s=new Map,r=new Set,o=h=>{const f=s.get(h);if(f!==void 0)return f;if(r.has(h))return a4;r.add(h);const p=n.get(h)??[],m=Math.max(a4,p.reduce((g,v)=>g+o(v.id),0)+Math.max(0,p.length-1)*sU);return r.delete(h),s.set(h,m),m},i=new Map,l=new Set,c=(h,f,p)=>{if(l.has(h))return;l.add(h);const m=o(h);i.set(h,{x:f+(m-a4)/2,y:QP+p*(Dhe+D0s)});let g=f;for(const v of n.get(h)??[])c(v.id,g,p+1),g+=o(v.id)+sU};c(bD,QP,0);let d=QP+o(bD)+sU;for(const h of e)l.has(h.id)||(c(h.id,d,1),d+=o(h.id)+sU);return{positions:i,width:Math.max(360,...Array.from(i.values(),({x:h})=>h+a4+QP)),height:Math.max(220,...Array.from(i.values(),({y:h})=>h+Dhe+QP))}}function O0s(e,t,n){const s=(e.subagentType?.toLowerCase()==="fork"?e.label.replace(/^fork:\s*/i,""):e.label).trim();return s&&s.toLowerCase()!=="agent"?s:n(t+1)}function B0s(e,t){return e.status==="running"?e.startTime>0?Math.max(e.runtimeMs,t-e.startTime):e.runtimeMs:e.endTime===void 0?e.runtimeMs:Math.max(0,e.endTime-e.startTime)||e.runtimeMs}function $0s({tasks:e,loading:t=!1,error:n,onOpenAgent:s}){const{t:r}=Xe(),o=u.useMemo(()=>L0s(e),[e]),i=e.some(d=>d.status==="running"),[l,c]=u.useState(Date.now);return u.useEffect(()=>{if(!i)return;c(Date.now());const d=window.setInterval(()=>c(Date.now()),1e3);return()=>window.clearInterval(d)},[i]),t?a.jsxs("div",{className:Jm.loading,role:"status","aria-label":r("common.loading"),children:[a.jsx(rk,{className:"h-[68px] w-[184px] rounded-xl"}),a.jsx(rk,{className:"h-[68px] w-[184px] rounded-xl"})]}):n?a.jsx("div",{className:Jm.empty,children:n}):e.length===0?a.jsx("div",{className:Jm.empty,children:r("workflow.empty")}):a.jsx("div",{className:Jm.viewport,"data-testid":"agent-workflow",children:a.jsxs("div",{className:Jm.canvas,style:{width:o.width,height:o.height},children:[a.jsx("svg",{className:Jm.edges,"data-testid":"agent-workflow-edges",width:o.width,height:o.height,"aria-hidden":"true",children:e.map(d=>{const h=o.positions.get(d.parentAgentId??"")??o.positions.get(bD),f=o.positions.get(d.id),p=h.x+a4/2,m=h.y+Dhe,g=f.x+a4/2,v=f.y,y=(m+v)/2;return a.jsx("path",{className:d.status==="running"?Jm.edgeRunning:"",d:`M ${p} ${m} C ${p} ${y}, ${g} ${y}, ${g} ${v}`},d.id)})}),a.jsxs("div",{className:`${Jm.node} ${Jm.mainNode}`,style:J6e(o.positions.get(bD)),children:[a.jsx(_b,{}),a.jsx("span",{children:r("workflow.mainAgent")})]}),e.map((d,h)=>a.jsxs("button",{type:"button",className:Jm.node,"data-status":d.status,style:J6e(o.positions.get(d.id)),onClick:()=>s?.(d),disabled:!s,title:d.description||d.label,children:[a.jsxs("span",{className:Jm.nodeTitle,children:[a.jsx(_b,{}),a.jsx("span",{children:O0s(d,h,f=>r("environment.unnamedAgent",{index:f}))})]}),a.jsxs("span",{className:Jm.nodeMeta,children:[a.jsxs("span",{className:Jm.status,"data-status":d.status,children:[d.status==="completed"&&a.jsx(jb,{}),d.status==="running"&&a.jsx(zu,{className:Jm.statusRunning}),d.status==="paused"&&a.jsx(Oge,{}),d.status==="failed"&&a.jsx(WT,{}),d.status==="cancelled"&&a.jsx(rVe,{}),r(`tasks.${d.status}`)]}),a.jsx("span",{className:Jm.duration,children:na(B0s(d,l))})]})]},d.id))]})})}const F0s=3;function z0s({tabId:e,sessionId:t,parentSessionId:n,workspaceCwd:s,title:r,shouldNameFromFirstPrompt:o,initialPrompt:i,createSession:l,onCreated:c,onTitleChange:d,onRightPanelOpen:h,onArtifactsChange:f,onError:p,sessionWorkflowEnabled:m,modelManagement:g,unavailableModels:v,mountUnavailableModelTooltip:y,onImageIngestionNotice:w,onInitialPromptRefused:b}){return t?a.jsx(GK,{sessionId:t,workspaceCwd:s,clientId:`side-task:${n}:${e}`,autoConnect:!0,historyPageSize:Kg,subagentTranscriptMode:"summary",maxBlocks:VK,suppressOwnUserEcho:!0,children:a.jsx(W0s,{tabId:e,title:r,shouldNameFromFirstPrompt:o,initialPrompt:i,workspaceCwd:s,onTitleChange:d,onRightPanelOpen:h,onArtifactsChange:f,onError:p,sessionWorkflowEnabled:m,modelManagement:g,unavailableModels:v,mountUnavailableModelTooltip:y,onImageIngestionNotice:w,onInitialPromptRefused:b})}):a.jsx(U0s,{tabId:e,parentSessionId:n,title:r,createSession:l,onCreated:c,onTitleChange:d,onError:p})}function U0s({tabId:e,parentSessionId:t,title:n,createSession:s,onCreated:r,onTitleChange:o,onError:i}){const{t:l}=Xe(),c=u.useRef(!1),d=u.useRef(!1),h=u.useRef(!0),[f,p]=u.useState();u.useEffect(()=>(h.current=!0,()=>{h.current=!1}),[]);const m=u.useCallback(async()=>{if(!c.current){c.current=!0,p(void 0);try{const g=await s(e,t,n);r(e,g.sessionId),h.current&&g.displayName&&o(e,g.displayName)}catch(g){if(!h.current)return;p(g),i?.(g,l("sideTask.createFailed"))}finally{c.current=!1}}},[s,r,i,o,t,l,e,n]);return u.useEffect(()=>{d.current||(d.current=!0,m())},[m]),f?a.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 text-sm text-muted-foreground",children:[a.jsx("span",{children:l("sideTask.createFailed")}),a.jsx(Ne,{type:"button",variant:"outline",onClick:()=>void m(),children:l("common.retry")})]}):a.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-muted-foreground",role:"status",children:[a.jsx(qr,{}),a.jsx("span",{children:l("sideTask.creating")})]})}function W0s({tabId:e,title:t,shouldNameFromFirstPrompt:n,initialPrompt:s,workspaceCwd:r,onTitleChange:o,onRightPanelOpen:i,onArtifactsChange:l,onError:c,sessionWorkflowEnabled:d,modelManagement:h,unavailableModels:f,mountUnavailableModelTooltip:p,onImageIngestionNotice:m,onInitialPromptRefused:g}){const{t:v}=Xe(),y=Da(),w=rf(),b=ko(),x=hS(b.client),k=Fme(),_=$me(),S=y.workspaceCwd&&r&&y.workspaceCwd!==r?void 0:y.workspaceCwd??r,R=k.some(L=>L.kind==="user"&&(typeof L.text=="string"?L.text.trim().length>0:!L.images?.length)),j=k.some(L=>L.kind!=="user"?!1:L.images?.length||L.files?.length||L.resourceLinks?.length?!0:typeof L.text!="string"||L.text.trim().length>0),E=y.status==="connected"&&!y.loadingTranscript&&!y.catchingUp&&!_.loading&&!_.hasMore&&!_.capacityReached&&!_.paginationError,I=E&&!j,C=!R&&(n||E&&!R);u.useEffect(()=>{const L=y.displayName?.trim();L&&o(e,L)},[y.displayName,o,e]);const N=u.useCallback(L=>{const F=Array.from(L.trim()).slice(0,200).join("");F&&(o(e,F),(async()=>{let $;for(let B=0;B<F0s;B++)try{await w.renameSession(F),y.sessionId&&S&&x.renamed(S,y.sessionId,F),o(e,F,!0);return}catch(D){$=D}S&&x.invalidateWorkspace(S),c?.($,v("sideTask.renameFailed"))})())},[w,S,y.sessionId,c,o,x,v,e]),A=u.useRef(!1),M=!!(s?.trim()&&I&&!A.current&&!BG(h).allowAdd&&!Jit(y.commands)&&Kw(s)),P=u.useRef(m);return P.current=m,u.useEffect(()=>{if(!M)return;const L=setTimeout(()=>{P.current?.("warning",v("sideTask.commandsLoadingTimedOut"))},5e3);return()=>clearTimeout(L)},[M,s,y.sessionId,v]),u.useEffect(()=>{const L=s?.trim();if(!(!L||!I||A.current||M)){if(A.current=!0,!BG(h).allowAdd&&Kw(L,y.commands)){m?.("warning",v("settings.models.addDisabled")),g?.(e);return}w.sendPrompt(L,{onAdmitted:()=>{y.sessionId&&S&&x.promptAdmitted(S,y.sessionId),N(L)}}).catch(F=>{A.current=!1,c?.(F,v("sideTask.promptFailed"))})}},[w,S,y.commands,y.sessionId,s,h,m,g,N,c,I,M,x,v,e]),y.sessionId?a.jsx(nct,{title:y.displayName?.trim()||t,workspaceCwd:r,onError:c,onImageIngestionNotice:m,embedded:!0,onFirstPromptAdmitted:C?N:void 0,onRightPanelOpen:i,onPaneArtifactsChange:l,sessionWorkflowEnabled:d,modelManagement:h,unavailableModels:f,mountUnavailableModelTooltip:p}):a.jsx("div",{className:"flex h-full items-center justify-center",children:a.jsx(qr,{})})}const H0s="_inspector_cn1ku_1",q0s="_summary_cn1ku_20",V0s="_detail_cn1ku_21",G0s="_attention_cn1ku_22",K0s="_steps_cn1ku_23",Y0s="_collapsible_cn1ku_24",J0s="_summaryHeading_cn1ku_38",X0s="_sectionHeading_cn1ku_39",Q0s="_compactHeading_cn1ku_40",Z0s="_summaryCount_cn1ku_72",evs="_progress_cn1ku_87",tvs="_summaryMeta_cn1ku_108",nvs="_expandButton_cn1ku_116",svs="_stepList_cn1ku_177",rvs="_linkedAgents_cn1ku_178",ovs="_deliverables_cn1ku_179",ivs="_activityList_cn1ku_180",avs="_attentionGlyph_cn1ku_216",lvs="_status_cn1ku_228",cvs="_stepId_cn1ku_254",dvs="_dependencies_cn1ku_262",uvs="_dependencyList_cn1ku_291",hvs="_dependencyLink_cn1ku_309",fvs="_dependencyNumber_cn1ku_333",pvs="_showAllActivity_cn1ku_358",mvs="_itemText_cn1ku_398",gvs="_stepIndex_cn1ku_474",vvs="_metrics_cn1ku_349",wvs="_stateLabel_cn1ku_545",yvs="_activityAvatar_cn1ku_605",bvs="_canvasHint_cn1ku_617",xvs="_empty_cn1ku_633",da={inspector:H0s,summary:q0s,detail:V0s,attention:G0s,steps:K0s,collapsible:Y0s,summaryHeading:J0s,sectionHeading:X0s,compactHeading:Q0s,summaryCount:Z0s,progress:evs,summaryMeta:tvs,expandButton:nvs,stepList:svs,linkedAgents:rvs,deliverables:ovs,activityList:ivs,attentionGlyph:avs,status:lvs,stepId:cvs,dependencies:dvs,dependencyList:uvs,dependencyLink:hvs,dependencyNumber:fvs,showAllActivity:pvs,itemText:mvs,stepIndex:gvs,metrics:vvs,stateLabel:wvs,activityAvatar:yvs,canvasHint:bvs,empty:xvs},X6e=6;function kvs({todos:e,tools:t,tasks:n,projection:s,artifacts:r,selectedTodoId:o,onSelectedTodoIdChange:i,onExpandGraph:l,onOpenSubagent:c,onOpenArtifact:d,canvasMode:h=!1}){const{language:f,t:p}=Xe(),m=u.useMemo(()=>s??mJ(e,t,n),[s,n,e,t]),g=bXe(e,m),v=u.useMemo(()=>{const C=new Map;return e.forEach((N,A)=>C.set(N.id,A+1)),C},[e]),[y,w]=u.useState(!1),b=m.todosById.has(o??"")?o:g,x=m.todosById.get(b??"");u.useEffect(()=>{b!==o&&i(b)},[b,i,o]);const k=C=>{sp(C)||c(C)};if(e.length===0)return a.jsxs("div",{className:da.empty,"data-testid":"workflow-inspector-empty",children:[a.jsx(uh,{"aria-hidden":"true"}),a.jsx("strong",{children:p("workflow.empty.title")}),a.jsx("p",{children:p("workflow.empty.copy")})]});const _=x?m.states.get(x.id):void 0,S=x?m.agentToolsByTodo.get(x.id)??[]:[],R=x?[...new Set(x.blockedBy??[])].filter(C=>C!==x.id&&m.todosById.has(C)):void 0,j=x?m.dependentsByTodo.get(x.id)??[]:[],E=C=>{const N=m.todosById.get(C),A=v.get(C);return a.jsx("li",{children:a.jsxs("button",{className:da.dependencyLink,"data-plan-interactive":!0,"data-testid":`workflow-dependency-${C}`,onClick:()=>i(C),title:N?.content,type:"button",children:[A!==void 0&&a.jsx("span",{className:da.dependencyNumber,children:A}),a.jsx("span",{children:N?.content??C})]})},C)},I=x&&_&&a.jsxs("section",{className:da.detail,"data-testid":"workflow-step-detail",children:[a.jsxs("div",{className:da.sectionHeading,children:[a.jsxs("div",{children:[a.jsx("span",{children:p("workflow.inspector.selectedStep")}),a.jsx("h2",{children:x.content})]}),a.jsx("span",{className:da.status,"data-status":_.status,children:p(`planExecution.status.${_.status}`)})]}),a.jsx("code",{className:da.stepId,children:x.id}),a.jsxs("dl",{className:da.dependencies,children:[a.jsxs("div",{children:[a.jsx("dt",{children:p("workflow.dependencies.upstream")}),a.jsx("dd",{children:R?.length?a.jsx("ul",{className:da.dependencyList,children:R.map(C=>E(C))}):p("workflow.dependencies.none")})]}),a.jsxs("div",{children:[a.jsx("dt",{children:p("workflow.dependencies.unblocks")}),a.jsx("dd",{children:j.length?a.jsx("ul",{className:da.dependencyList,children:j.map(C=>E(C.id))}):p("workflow.dependencies.noDownstream")})]})]}),a.jsxs("div",{className:da.linkedAgents,children:[a.jsx("h3",{children:p("planExecution.subagents")}),S.length?S.map(C=>{const N=m.tasksByTool.get(C),A=N?[N.startTime>0?$p(N.runtimeMs):"",N.stats?.toolUses===void 0?"":p("planExecution.toolCalls",{count:N.stats.toolUses}),N.stats?.totalTokens===void 0?"":p("planExecution.tokens",{count:N.stats.totalTokens.toLocaleString()})].filter(Boolean):[];return a.jsxs("button",{"aria-disabled":!!sp(C)||void 0,title:p(sp(C)??"planExecution.openDetails"),onClick:()=>k(C),type:"button",children:[a.jsxs("span",{className:da.itemText,children:[a.jsx("strong",{children:C.title||String(C.args?.description??"Agent")}),N&&a.jsx("small",{children:N.recentActivities?.at(-1)?.description||N.description}),A.length>0&&a.jsx("small",{className:da.metrics,children:A.map(M=>a.jsx("span",{children:M},M))})]}),N&&a.jsx("span",{className:da.stateLabel,"data-status":N.status,children:p(VAe(N.status))}),a.jsx(_le,{"aria-hidden":"true"})]},C.callId)}):a.jsx("p",{children:p("planExecution.noSubagents")})]})]});return h?a.jsxs("div",{className:da.inspector,"data-testid":"workflow-canvas-detail",children:[a.jsxs("div",{className:da.canvasHint,children:[a.jsx(uh,{"aria-hidden":"true"}),a.jsx("span",{children:p("workflow.inspector.canvasHint")})]}),I]}):a.jsxs("div",{className:da.inspector,"data-testid":"workflow-inspector",children:[a.jsxs("section",{className:da.summary,children:[a.jsxs("div",{className:da.summaryHeading,children:[a.jsxs("div",{children:[a.jsx("span",{children:p("workflow.inspector.summary")}),a.jsx("strong",{children:p(m.taskStatusI18nKey)})]}),a.jsxs("span",{className:da.summaryCount,"data-status":m.taskStatusTone,children:[m.completedCount,"/",e.length]})]}),a.jsx("div",{className:da.progress,role:"progressbar","aria-label":p("planExecution.overallProgress"),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":m.progressPercent,children:a.jsx("span",{style:{width:`${m.progressPercent}%`}})}),a.jsxs("div",{className:da.summaryMeta,children:[a.jsx("span",{children:p("workflow.inspector.activeAgents",{count:m.activeAgents.length})}),a.jsx("span",{children:p("workflow.inspector.attentionCount",{count:m.attentionTodos.length})})]}),a.jsxs("button",{className:da.expandButton,onClick:l,type:"button",children:[a.jsx(uh,{"aria-hidden":"true"}),p("workflow.inspector.expandGraph"),a.jsx(Vl,{"aria-hidden":"true"})]})]}),m.attentionTodos.length>0&&a.jsxs("section",{className:da.attention,children:[a.jsxs("div",{className:da.compactHeading,children:[a.jsx("h2",{children:p("workflow.tabs.attention")}),a.jsx("span",{children:m.attentionTodos.length})]}),m.attentionTodos.map(C=>a.jsxs("button",{"aria-pressed":b===C.id,onClick:()=>i(C.id),type:"button",children:[a.jsx(fd,{"aria-hidden":"true",className:da.attentionGlyph}),a.jsx("span",{children:C.content}),a.jsx(Vl,{"aria-hidden":"true"})]},C.id))]}),a.jsxs("section",{className:da.steps,"data-testid":"workflow-step-list",children:[a.jsxs("div",{className:da.compactHeading,children:[a.jsx("h2",{children:p("workflow.inspector.allSteps")}),a.jsx("span",{children:e.length})]}),a.jsx("div",{className:da.stepList,children:e.map((C,N)=>{const A=m.states.get(C.id);return a.jsxs("button",{"aria-pressed":b===C.id,onClick:()=>i(C.id),type:"button",children:[a.jsx("span",{className:da.stepIndex,"data-status":A?.status,children:N+1}),a.jsxs("span",{className:da.itemText,children:[a.jsx("strong",{children:C.content}),a.jsx("small",{children:C.id})]}),A&&a.jsx("span",{className:da.stateLabel,"data-status":A.status,children:p(`planExecution.status.${A.status}`)})]},C.id)})})]}),I,a.jsxs("details",{className:da.collapsible,open:!0,children:[a.jsxs("summary",{children:[a.jsx("span",{children:p("workflow.inspector.recentActivity")}),a.jsx("small",{children:m.activity.length})]}),a.jsxs("div",{className:da.activityList,children:[(y?m.activity:m.activity.slice(0,X6e)).map(C=>{const N=m.toolsByTaskId.get(C.id),A=C.endTime??C.startTime,M=a.jsxs(a.Fragment,{children:[a.jsx("time",{dateTime:A?new Date(A).toISOString():void 0,children:von(A,f)}),a.jsx("span",{className:da.activityAvatar,children:gon(C.subagentType||C.label)}),a.jsxs("span",{className:da.itemText,children:[a.jsx("strong",{children:C.label}),a.jsx("small",{children:C.recentActivities?.at(-1)?.description||C.description})]}),a.jsx("span",{className:da.stateLabel,"data-status":C.status,children:p(VAe(C.status))})]});return N?a.jsx("button",{"aria-disabled":!!sp(N)||void 0,title:p(sp(N)??"planExecution.openDetails"),onClick:()=>k(N),type:"button",children:M},C.id):a.jsx("div",{children:M},C.id)}),m.activity.length===0&&a.jsx("p",{children:p("workflow.activity.empty")}),!y&&m.activity.length>X6e&&a.jsx("button",{className:da.showAllActivity,"data-plan-interactive":!0,"data-testid":"workflow-activity-show-all",onClick:()=>w(!0),type:"button",children:p("workflow.activity.showAll",{count:m.activity.length})})]})]}),a.jsxs("details",{className:da.collapsible,open:r.length>0,children:[a.jsxs("summary",{children:[a.jsx("span",{children:p("workflow.deliverables.title")}),a.jsx("small",{children:r.length})]}),a.jsxs("div",{className:da.deliverables,children:[r.map(C=>a.jsxs("button",{disabled:!d,onClick:()=>d?.(C.id),type:"button",children:[a.jsxs("span",{className:da.itemText,children:[a.jsx("strong",{children:O9(C)}),a.jsxs("small",{className:da.metrics,children:[a.jsx("span",{children:C.kind}),a.jsx("span",{children:C.status})]})]}),a.jsx(_le,{"aria-hidden":"true"})]},C.id)),r.length===0&&a.jsx("p",{children:p("workflow.deliverables.none")})]})]})]})}/**
2901
2901
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
2902
2902
  * @license MIT
2903
2903
  *
@@ -2980,7 +2980,7 @@ ${i("terminal.notice.protocolMismatch")}`),W.close(4002,"Terminal protocol misma
2980
2980
  * Copyright 2025 Qwen Team
2981
2981
  * SPDX-License-Identifier: Apache-2.0
2982
2982
  */const oCs=2048,iCs=8192,aCs=4096,lCs=2097152,Loe=8,cCs=512,dCs=256,Ooe=65536;function uCs(e){if(e.kind==="request")return e.status==="ok"?"success":e.status;if(e.kind==="tool")switch(e.toolStatus??e.block.status){case"success":case"completed":return"success";case"error":case"failed":return"error";case"cancelled":case"canceled":return"cancelled";case"pending":case"in_progress":case"running":return"running";default:return"unknown"}}function hCs(e){switch(e.kind){case"request":return[e.model,e.recordId,e.responseId,e.promptId,e.subagentId,e.parentToolCallId];case"tool":return[e.block.toolName,e.block.toolCallId,e.block.parentToolCallId,e.block.subagentType,e.block.title];case"user":case"message":return[e.block.id];case"other":return[e.block.kind,e.block.id]}}function fCs(e){if(e.kind==="request")return[];if(e.kind==="tool")return[e.block.rawInput,e.block.rawOutput===void 0?e.block.content:e.block.rawOutput];if(e.kind==="user"||e.kind==="message")return[e.block.text];switch(e.block.kind){case"shell":case"status":case"error":case"debug":return[e.block.text];case"user_shell":return[e.block.command,e.block.text];case"permission":return[e.block.title];case"prompt_cancelled":return[e.block.reason];default:return[]}}function pCs(e){let t=lCs,n=0;return{rows:[...e.rows].reverse().map(r=>{const o=[];let i=!1,l=oCs,c=Ooe;const d=m=>{const g=m.slice(0,c);c-=g.length,g.length<m.length&&(i=!0);const v=b=>{const x=b.slice(0,l);x.length<b.length&&(i=!0),l-=x.length,x.length>0&&o.push(x.toLowerCase())},y=/data:(?:[a-z0-9!#$&^_.+-]{1,128}\/[a-z0-9!#$&^_.+-]{1,128})?(?:;[^,\s;"'<>]{1,128}){0,4},[^\s"'<>)]*/gi;let w=0;for(const b of g.matchAll(y))v(g.slice(w,b.index)),w=b.index+b[0].length;v(g.slice(w))};for(const m of hCs(r))m!==void 0&&d(m);let h=iCs,f=cCs,p=Ooe;for(const m of fCs(r)){const g=r.kind==="tool"||r.kind==="other"&&r.block.kind==="user_shell";l=Math.min(g?aCs:h,t);const v=l;c=g?Ooe:p;let y=g?dCs:f;const w=y,b=new Set,x=(_,S)=>{if(S>Loe||y===0){i=!0;return}if(y--,_!==void 0){if(_===null||typeof _=="string"||typeof _=="boolean"||typeof _=="number"){d(String(_));return}if(typeof _=="object"&&!(!Array.isArray(_)&&Object.getPrototypeOf(_)!==Object.prototype&&Object.getPrototypeOf(_)!==null)){if(b.has(_)){i=!0;return}if(b.add(_),Array.isArray(_))for(let R=0;R<_.length;R++){if(y===0||l===0||S===Loe){i=!0;break}x(_[R],S+1)}else{const R=_,j=E=>y===0||l===0||S===Loe||(x(E,S+1),y===0||l===0)?(i=!0,!1):(x(R[E],S+1),!0);for(const E in R)if(Object.hasOwn(R,E)&&!(["base64","blob","inlineData","inline_data","mimeType","mime_type"].includes(E)||E==="data"&&typeof R[E]=="string")&&!j(E))break}b.delete(_)}}};x(m,0);const k=v-l;t-=k,h-=k,f-=w-y,p=c}return i&&n++,{key:r.key,kind:r.kind,status:uCs(r),fields:o}}).reverse(),truncatedCount:n}}function RDe(e,t){const n=t.query.trim().toLowerCase();return e.rows.filter(s=>(t.type==="all"||s.kind===t.type)&&(t.status==="all"||s.status===t.status)&&(!n||s.fields.some(r=>r.includes(n)))).map(s=>s.key)}const i6={query:"",type:"all",status:"all"};function EDe(e){return e.query.trim()!==""||e.type!=="all"||e.status!=="all"}function Boe(e,t,n){return JSON.stringify([e.query.trim().toLowerCase(),e.type,e.status,t?.start,t?.end,n])}const Cx=34,mCs=960;function gCs(e){return`${gE(e.inputTokens)} → ${gE(e.outputTokens)}`}const vCs=/-call_[A-Za-z0-9]+$/;function wCs(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(vCs,"")}function vE(e){const t=e.trim(),n=t.indexOf(`
2983
- `);return n===-1?t:t.slice(0,n)}function yCs(e,t){if(e.kind==="request"){const n=[na(e.timing.durationMs)];return e.timing.ttftMs!==void 0&&n.push(t("trajectory.ttft",{duration:na(e.timing.ttftMs)})),e.usage&&n.push(gCs(e.usage)),n}if(e.kind==="tool"){const n=[];if(e.timing&&n.push(na(e.timing.durationMs)),e.subagentSummary){const{requests:s,tools:r,requestMs:o}=e.subagentSummary;n.push(t("trajectory.subagentRollup",{requests:s,tools:r,duration:na(o)}))}return n}return[]}function $oe(e){const t=e.toolStatus??e.block.status;if(t==="error"||t==="failed")return Po.toneError;if(t==="cancelled"||t==="canceled")return Po.toneMuted}function Rfe(e,t){switch(e.kind){case"user":return{badge:t("trajectory.badge.user"),text:vE(e.block.text)};case"request":{const n=wCs(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:Po.toneError}:{},text:s?`${r} · ${t("trajectory.requestFailed")}`:r}}case"message":return{badge:e.thought?t("trajectory.badge.thought"):t("trajectory.badge.message"),text:vE(e.block.text),faint:e.thought};case"tool":return{badge:e.block.toolName??t("trajectory.badge.tool"),...$oe(e)?{badgeTone:$oe(e)}:{},text:`${e.block.title||(e.block.toolName??"")}${$oe(e)===Po.toneError?` · ${t("trajectory.toolFailed")}`:""}`};default:return bCs(e.block,t)}}function bCs(e,t){switch(e.kind){case"shell":return{badge:t("trajectory.badge.shell"),text:vE(e.text)};case"user_shell":return{badge:t("trajectory.badge.shell"),text:vE(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:Po.toneError}:{},text:vE(e.text),faint:e.kind!=="error"};case"prompt_cancelled":return{badge:t("trajectory.badge.cancelled"),badgeTone:Po.toneMuted,text:e.reason??t("trajectory.cancelled"),faint:!0};default:return{badge:t("trajectory.badge.other"),text:""}}}function xCs(e){return e.rows.some(t=>t.kind==="request"||t.kind==="tool"&&t.timing!==void 0)}function kCs({loadPage:e,historyGapRevision:t=0}){const{t:n,language:s}=Xe(),r=u.useRef(null),[o,i]=u.useState(!1);u.useLayoutEffect(()=>{const bt=r.current;if(!bt)return;const be=()=>i(bt.clientWidth>=mCs);if(be(),typeof ResizeObserver>"u")return;const It=new ResizeObserver(be);return It.observe(bt),()=>It.disconnect()},[]);const l=u.useRef(e);u.useLayoutEffect(()=>{l.current=e},[e]);const c=u.useCallback(()=>{if(l.current!==e)return;const bt=r.current?.querySelector('[data-testid="trajectory-executions"]');(bt?.querySelector('[role="grid"]')??bt?.querySelector("button")??se.current)?.focus({preventScroll:!0})},[e]),{trajectory:d,lifecycle:h,status:f,error:p,loadedPages:m,windowPages:g,truncated:v,olderFailure:y,refresh:w,retry:b,older:x,newer:k,mode:_,navigationVersion:S,navigationError:R,loadingKind:j,canRefresh:E,canOlder:I,canNewer:C,historyReleased:N}=cks(e),[A,M]=u.useState({loader:e,paused:!1});A.loader!==e&&M({loader:e,paused:!1});const P=u.useCallback(()=>{M(bt=>bt.loader!==e||bt.paused&&!bt.pending?bt:{loader:e,paused:!0})},[e]),L=u.useRef({loader:e,status:h.status});u.useLayoutEffect(()=>{const bt=L.current;L.current={loader:e,status:h.status},bt.loader===e&&bt.status==="live"&&h.status!=="live"&&P()},[e,h.status,P]);const F=A.loader===e&&!A.paused&&_==="latest",$=A.loader===e&&!!A.pending,[B,D]=u.useState({loader:e,revision:0}),O=u.useRef(void 0),U=u.useCallback(()=>{O.current={revision:t,trajectory:d},w()},[t,d,w]),H=u.useCallback(()=>{E&&(M({loader:e,paused:!0,pending:{of:d}}),U())},[E,e,d,U]);u.useEffect(()=>{O.current=void 0},[e]),u.useEffect(()=>{const bt=O.current;bt&&f!=="loading"&&p?O.current=void 0:bt&&f==="ready"&&d!==bt.trajectory&&(D({loader:e,revision:bt.revision}),O.current=void 0)},[f,d,p,e]);const Q=t>(B.loader===e?B.revision:0),q=u.useRef(!1),[te,Z]=u.useState({loader:e,version:S,selectionLost:!1}),[ce,he]=u.useState(!1),[W,G]=u.useState(!1),[J,X]=u.useState({loader:e,value:i6,scope:0});J.loader!==e&&X({loader:e,value:i6,scope:J.scope+1});const de=J.loader===e?J.value:i6,ae=u.useCallback(bt=>{P(),X(be=>be.loader===e&&be.value.query===bt.query&&be.value.type===bt.type&&be.value.status===bt.status?be:{loader:e,value:bt,scope:be.scope})},[e,P]),ne=u.useCallback(()=>ae(i6),[ae]),pe=EDe(de),Re=u.useMemo(()=>d?pCs(d):void 0,[d]),ke=u.useMemo(()=>Re?RDe(Re,de):[],[Re,de]),Te=u.useMemo(()=>new Set(ke),[ke]),[Fe,Se]=u.useState(void 0),[Le,ge]=u.useState(),fe=u.useMemo(()=>G_s(h,Alt(e)),[h,e]),[we,Ae]=u.useState(),Be=we?.loader===e?fe.rows.find(bt=>bt.key===we?.key):void 0,[ve,Y]=u.useState(!1);u.useEffect(()=>{we&&!Be&&Ae(void 0)},[we,Be]),u.useEffect(()=>{Y(!1),ge(void 0),Ae(void 0)},[e]),u.useEffect(()=>{Le?.of&&d&&Le.of!==d&&ge({...Le,of:void 0})},[Le,d]);const se=u.useRef(null),V=u.useRef(!1),oe=u.useRef(0),Ie=u.useId(),Me=u.useCallback(bt=>`${Ie}-row-${bt}`,[Ie]),Ce=u.useCallback((bt,be)=>{bt.scrollTop=be,oe.current=bt.scrollTop},[]),_e=u.useRef(void 0),[Ge,We]=u.useState("active"),tt=u.useMemo(()=>d?adt(d,{mode:Ge}):void 0,[d,Ge]),ht=PSs(tt),rt=u.useMemo(()=>new Map(tt?.spans.map(bt=>[bt.row.key,bt])),[tt]),[kt,Ve]=u.useState(void 0),mt=kt!==void 0&&kt.of===d&&kt.mode===Ge?kt.range:void 0,jt=u.useCallback(bt=>{P(),Ve(bt!==void 0&&d!==void 0?{range:bt,of:d,mode:Ge}:void 0)},[d,Ge,P]);u.useEffect(()=>{kt&&(kt.of!==d||kt.mode!==Ge)&&Ve(void 0)},[kt,d,Ge]);const Ot=u.useMemo(()=>mt&&tt?ldt(tt,mt):void 0,[mt,tt]),me=u.useMemo(()=>d?jSs(d):void 0,[d]),it=u.useMemo(()=>new Map((me?.rows??[]).flatMap(bt=>bt.kind==="turn"?[[bt.key,bt.turn]]:[])),[me]),[He,Ye]=u.useState(),Kt=u.useMemo(()=>!me||!He||He.loader!==e?new Set:He.of===me?He.keys:new Set([...He.keys].filter(bt=>{const be=me.groupIdentities.get(bt);return be!==void 0&&be===He.of.groupIdentities.get(bt)})),[He,me,e]);u.useEffect(()=>{He&&(He.of!==me||He.loader!==e)&&Ye(me?{of:me,loader:e,keys:Kt}:void 0)},[He,me,e,Kt]);const Ft=u.useMemo(()=>ke.filter(bt=>!Ot||Ot.has(bt)),[ke,Ot]),Lt=u.useMemo(()=>pe?new Set(Ft):Ot,[pe,Ft,Ot]),Mn=Boe(de,mt,Ge),[An,En]=u.useState(),Wn=u.useMemo(()=>An?.of===d&&An?.loader===e&&An?.signature===Mn?An.overrides:new Map,[An,d,e,Mn]);u.useEffect(()=>{An&&(!pe||An.of!==d||An.loader!==e||An.signature!==Mn)&&En(void 0)},[An,pe,d,e,Mn]);const ys=u.useMemo(()=>{if(!pe)return Kt;const bt=new Set(Kt);for(const be of Ft)for(const It of me?.ancestors.get(be)??[])bt.delete(It);for(const[be,It]of Wn)It?bt.add(be):bt.delete(be);return bt},[pe,Kt,Ft,me,Wn]),Pt=u.useMemo(()=>me?NSs(me,Lt):[],[me,Lt]),Zt=u.useMemo(()=>new Set(Pt.map(bt=>bt.key)),[Pt]),nn=u.useMemo(()=>me?MSs(me,Pt,ys):[],[me,Pt,ys]),Yt=u.useMemo(()=>new Set(nn.map(bt=>bt.key)),[nn]),Ht=me&&Fe?SDe(me,Fe,Yt):void 0,$t=u.useMemo(()=>{const bt=new Map;for(const be of Pt)if(be.kind==="row")for(const It of me?.ancestors.get(be.key)??[])bt.set(It,(bt.get(It)??0)+1);return bt},[me,Pt]),gt=_==="history",zt=rve({count:nn.length,getScrollElement:()=>se.current,getItemKey:bt=>nn[bt]?.key??bt,estimateSize:()=>Cx,paddingStart:Cx,paddingEnd:gt?Cx:0,overscan:12}),Jt=u.useCallback(bt=>{bt===0?zt.scrollToOffset(0):zt.scrollToIndex(bt,{align:"auto"})},[zt]),kn=u.useCallback(bt=>{if(!d||!me?.groups.has(bt))return;P();const be=se.current;if(be){const Oe=be.scrollTop-Cx,Rt=Math.max(0,Math.min(nn.length-1,Math.floor(Oe/Cx))),pn=nn[Rt];pn&&(_e.current={key:pn.key,offset:Oe-Rt*Cx})}const It=new Set(ys);if(It.has(bt)?It.delete(bt):It.add(bt),pe){const Oe=new Map(Wn);Oe.set(bt,It.has(bt)),En({of:d,loader:e,signature:Mn,overrides:Oe})}else Ye({of:me,loader:e,keys:It});se.current?.focus({preventScroll:!0})},[d,me,nn,ys,e,pe,Mn,Wn,P]);u.useLayoutEffect(()=>{const bt=_e.current;if(!bt||!me||!se.current)return;_e.current=void 0;const be=SDe(me,bt.key,Yt),It=nn.findIndex(Oe=>Oe.key===be);It>=0&&Ce(se.current,(It+1)*Cx+bt.offset)},[me,nn,Yt,Ce]);const ze=nn.length>0;u.useLayoutEffect(()=>{const bt=se.current;if(!bt||typeof ResizeObserver>"u")return;let be=0;const It=()=>{bt.scrollTop===0&&oe.current>0&&(bt.scrollTop=oe.current)},Oe=new ResizeObserver(()=>{It(),be=requestAnimationFrame(It)});return Oe.observe(bt),()=>{Oe.disconnect(),be!==0&&cancelAnimationFrame(be)}},[ze]),u.useEffect(()=>{if(f!=="ready"||V.current||nn.length===0)return;V.current=!0;const bt=se.current;bt&&Ce(bt,bt.scrollHeight)},[Ce,f,nn.length]);const Qe=u.useMemo(()=>Ht===void 0?-1:nn.findIndex(bt=>bt.key===Ht),[Ht,nn]),wt=u.useRef(Qe);wt.current=Qe,u.useLayoutEffect(()=>{const bt=wt.current;if(!ve||bt<0)return;const be=requestAnimationFrame(()=>{Jt(bt)});return()=>cancelAnimationFrame(be)},[ve,Jt]);const Je=u.useCallback(bt=>{if(nn.length===0)return;P();const be=Math.min(Math.max(bt,0),nn.length-1),It=nn[be].key;Ae(void 0),Se(It),ve&&d&&e&&ge({of:d,loader:e,key:It}),Jt(be)},[ve,e,d,Jt,nn,P]),Ee=u.useCallback((bt,be=!0)=>{P(),Ae(void 0),Se(bt),ve&&d&&e&&ge({of:d,loader:e,key:bt}),be&&se.current?.focus({preventScroll:!0})},[ve,d,e,P]),st=u.useCallback((bt=Fe)=>{!d||!e||!bt||!d.rowIndexByKey.has(bt)&&!it.has(bt)||(P(),Ae(void 0),ge({of:d,loader:e,key:bt}),Se(bt),Y(!0))},[d,e,Fe,P,it]),Ue=u.useCallback(bt=>{Ee(bt),st(bt)},[Ee,st]),Pe=u.useRef(null),vt=u.useRef(void 0),yt=ve||!!Be,Et=o?"side":"drill-in",Wt=yt&&Et==="drill-in";u.useLayoutEffect(()=>{Pe.current?.toggleAttribute("inert",Wt);const bt=vt.current;Wt||!bt||(vt.current=void 0,bt())},[Wt,yt]);const Gt=u.useCallback(bt=>{vt.current=bt},[]),sn=u.useCallback(()=>{se.current?.focus({preventScroll:!0})},[]),jn=u.useCallback(()=>{Y(!1),ge(void 0),Gt(sn)},[Gt,sn]),bs=u.useCallback(bt=>{if(bt.target!==bt.currentTarget&&bt.target.tabIndex>=0){if(!["ArrowDown","ArrowUp","Home","End"].includes(bt.key))return;bt.currentTarget.focus({preventScroll:!0})}if(bt.key==="Escape"){mt!==void 0&&(bt.preventDefault(),jt(void 0));return}if(nn.length===0)return;if(bt.key==="Enter"){bt.preventDefault(),Ht&&Ue(Ht);return}if((bt.key==="ArrowLeft"||bt.key==="ArrowRight")&&Ht&&me?.groups.has(Ht)&&($t.get(Ht)??0)>0){const It=bt.key==="ArrowLeft";ys.has(Ht)!==It&&(bt.preventDefault(),kn(Ht));return}const be=Qe<0?-1:Qe;bt.key==="ArrowDown"?(bt.preventDefault(),Je(be+1)):bt.key==="ArrowUp"?(bt.preventDefault(),Je(be<=0?0:be-1)):bt.key==="Home"?(bt.preventDefault(),Je(0)):bt.key==="End"?(bt.preventDefault(),Je(nn.length-1)):(bt.key==="PageUp"||bt.key==="PageDown"||bt.key===" ")&&P()},[Je,Ue,mt,Qe,jt,nn,Ht,me,$t,ys,kn,P]),Ys=u.useMemo(()=>d?uks(d):void 0,[d]),Ws=Le!==void 0&&Le.of===d&&Le.loader===e,Os=Ws?d?.rowIndexByKey.get(Le.key):void 0,mn=Ws?it.get(Le.key):void 0,vn=mn?mn.userRowKey===void 0?void 0:d?.rows[d.rowIndexByKey.get(mn.userRowKey)??-1]:Os===void 0?void 0:d?.rows[Os],xs=(f==="ready"||f==="error"&&d!==void 0)&&nn.length===0,Ke=d!==void 0&&d.rows.length>0&&!xCs(d),wn=Ys!==void 0&&Ys.plottedCount===0&&Ys.missingStartCount>0,Gn=u.useMemo(()=>{if(!(!d||!mt&&!pe&&ys.size===0))return{shown:nn.filter(bt=>bt.kind==="row").length,total:d.rows.length}},[mt,d,nn,ys,pe]),Dt=y===void 0?void 0:y.kind==="partial"?n("trajectory.olderPartial"):y.kind==="unreadable"?n("trajectory.olderFailed",{message:y.message}):n(`trajectory.window.${y.kind}`),tn=u.useRef(void 0);if(te.loader!==e||te.version!==S){const bt=te.loader!==e;q.current=!bt,Z({loader:e,version:S,selectionLost:!bt&&Fe!==void 0}),Se(void 0),ge(void 0),Y(!1),Ye(void 0),En(void 0),Ve(void 0),_e.current=void 0,tn.current=void 0,oe.current=0,V.current=!bt}u.useLayoutEffect(()=>{q.current&&se.current&&(q.current=!1,zt.scrollToOffset(0),Ce(se.current,0))},[S,ze,zt,Ce]);const In=u.useRef(!1);u.useEffect(()=>{const bt=A.loader===e&&A.pending;!bt||f==="loading"||(p||y||R?P():f==="ready"&&d!==bt.of&&_==="latest"&&(In.current=!0,M({loader:e,paused:!1}),Se(void 0),Ae(void 0),Y(!1),ge(void 0),X(be=>({...be,value:i6})),Ve(void 0)))},[A,e,f,p,y,R,d,_,P]),u.useLayoutEffect(()=>{if(!In.current)return;In.current=!1;const bt=se.current;bt&&(Ce(bt,bt.scrollHeight),bM(bt.getRootNode())&&bt.focus({preventScroll:!0}))},[F,nn,Ce]);const _s=u.useRef(void 0);u.useLayoutEffect(()=>{const bt=_s.current,be=r.current;!bt||!be||f==="loading"||(_s.current=void 0,bM(be.getRootNode())&&(be.querySelector(`[data-testid="${bt}"]`)??se.current)?.focus({preventScroll:!0}))},[S,f,ze]);const Ts=u.useCallback(()=>{const bt=se.current;G(!!bt&&bt.scrollHeight-bt.clientHeight-bt.scrollTop>Cx)},[]),Is=zt.getTotalSize(),Hs=nn.length>0;u.useLayoutEffect(()=>{Ts()},[Ts,Is,Hs]);const Ps=u.useCallback(bt=>{const be=nn.findIndex(It=>It.key===bt);if(be<0&&d&&me){tn.current=bt;const It=pe&&!Zt.has(bt)&&!Te.has(bt),Oe=mt!==void 0&&!Zt.has(bt)&&!Ot?.has(bt);It&&ne(),Oe&&jt(void 0);const Rt=me.ancestors.get(bt)??[];if(pe&&!It){const pn=new Map(Oe?[]:Wn);for(const Kn of Rt)pn.set(Kn,!1);En({of:d,loader:e,signature:Boe(de,Oe?void 0:mt,Ge),overrides:pn})}else{const pn=new Set(Kt);for(const Kn of Rt)pn.delete(Kn);Ye({of:me,loader:e,keys:pn})}Ee(bt);return}Ee(bt),be>=0&&Jt(be)},[d,me,Te,Zt,Ot,pe,ne,Wn,de,mt,Ge,Kt,e,Ee,jt,Jt,nn]),io=u.useCallback((bt,be=de)=>{if(!EDe(be)||!Re||!d||!me)return;ae(be);const It=RDe(Re,be).filter(fo=>!Ot||Ot.has(fo));if(!It.length)return;const Oe=Fe?It.indexOf(Fe):-1,Rt=Oe<0?bt===1?0:It.length-1:(Oe+bt+It.length)%It.length,pn=It[Rt],Kn=me.ancestors.get(pn)??[],vs=Boe(be,mt,Ge),fr=new Map(vs===Mn?Wn:[]);for(const fo of Kn)fr.set(fo,!1);En({of:d,loader:e,signature:vs,overrides:fr}),tn.current=pn,Ee(pn,!1)},[Re,d,me,ae,de,Ot,Fe,mt,Ge,Mn,Wn,e,Ee]);u.useLayoutEffect(()=>{const bt=tn.current;if(bt===void 0)return;tn.current=void 0;const be=nn.findIndex(It=>It.key===bt);be>=0&&Jt(be)},[Jt,nn]);const ut=u.useCallback(bt=>{const be=[Rfe(bt.row,n).text],It=bt.row.kind==="request"||bt.row.kind==="tool"?bt.row.timing?.startedAt:void 0;return It!==void 0&&be.push(`${new Date(It).toLocaleString()}–${new Date(It+bt.end-bt.start).toLocaleString()}`),be.push(na(bt.end-bt.start)),bt.ttftEnd!==void 0&&be.push(n("trajectory.ttft",{duration:na(bt.ttftEnd-bt.start)})),be.filter(Boolean).join(" · ")},[n]),Ze=ce&&fe.rows.length>0,Sn=Uks({windowMode:_,following:F,returning:$,liveStatus:h.status}),Zn=Wks({hasTrajectory:d!==void 0,error:p,navigationError:R,historyStale:Q,lifecycleIncomplete:h.incomplete&&h.status!=="unavailable"||h.truncated}),_n=Hks({truncated:v,loading:f==="loading"&&j!=="latest",olderFailure:y}),$n=mt&&tt?`${xfe(tt,mt.start,mt.end-mt.start,s)} – ${xfe(tt,mt.end,mt.end-mt.start,s)}`:void 0,Xn=a.jsx("div",{className:Po.boundary,"aria-live":"polite","data-testid":"trajectory-older-bar","data-state":_n,children:_n==="failed"?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:`${Po.boundaryText} ${Po.toneError}`,"data-testid":"trajectory-older-failed",title:Dt,children:Dt}),a.jsx("button",{type:"button",className:Po.boundaryButton,onClick:()=>{f!=="loading"&&b()},"aria-disabled":f==="loading"||y!==void 0&&!kfe(y),"data-testid":"trajectory-older-retry",children:n("common.retry")})]}):_n==="loading"||_n==="earlier"?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:Po.boundaryText,..._n==="earlier"?{"data-testid":"trajectory-truncated"}:{},children:_n==="loading"?n("trajectory.loadingPages",{pages:m}):n(_==="history"?"trajectory.window.outside":"trajectory.boundary.earlier")}),v&&a.jsx("button",{type:"button",className:Po.boundaryButton,"aria-disabled":!I,onClick:()=>{I&&(P(),_s.current="trajectory-window-older",x())},"data-testid":"trajectory-window-older",children:n("trajectory.boundary.loadEarlier")})]}):a.jsx("span",{className:Po.boundaryText,children:n("trajectory.boundary.start")})}),ao=a.jsxs("div",{className:Po.boundary,children:[a.jsx("button",{type:"button",className:Po.boundaryButton,"aria-disabled":!C,onClick:()=>{C&&(P(),_s.current="trajectory-window-newer",k())},"data-testid":"trajectory-window-newer",children:n("trajectory.boundary.newer")}),a.jsx("button",{type:"button",className:Po.boundaryButton,"aria-disabled":!E,onClick:()=>{E&&(_s.current="trajectory-window-latest",H())},"data-testid":"trajectory-window-latest",children:n("trajectory.window.return")}),N&&!C&&f!=="loading"&&!R&&!p&&!y&&a.jsx("span",{className:Po.boundaryText,children:n("trajectory.window.released")})]}),Do=vn&&!mn,Er=Be?a.jsx(tDe,{presentation:Et,execution:Be,title:Be.name,onClose:()=>{Ae(void 0),Gt(c)},onFocusedUnmount:c,onLocateExecution:Be.historyRowKey?()=>{const bt=Be.historyRowKey;Ps(bt),st(bt)}:void 0},Be.key):ve&&Le!==void 0&&Le.loader===e?a.jsx(tDe,{presentation:Et,row:vn,turn:mn,lifecycle:Ws&&vn&&!mn?h.byRowKey.get(vn.key):void 0,stale:!Ws,title:mn?n(mn.partial?"trajectory.turnPartial":"trajectory.turn",{index:mn.index}):vn?Rfe(vn,n).text:void 0,hiddenByRange:!!(mt&&Do&&!Zt.has(vn.key)&&!Ot?.has(vn.key)),hiddenByFilter:!!(pe&&Do&&!Zt.has(vn.key)&&!Te.has(vn.key)),onClearFilter:ne,hiddenByCollapse:!!(Do&&me?.ancestors.get(vn.key)?.some(bt=>ys.has(bt))),onReveal:()=>{vn&&Ps(vn.key)},onClearRange:()=>jt(void 0),onClose:jn,onStep:bt=>Je(Qe+bt),onFocusedUnmount:sn}):void 0;return a.jsxs("div",{ref:r,className:Po.panel,"data-testid":"trajectory-panel",children:[a.jsx(u1s,{summary:Ys,pill:Sn,onPill:()=>{Sn==="paused"||Sn==="history"?H():P()},warnings:Zn,onRetry:b,onRefresh:()=>{P(),U()},onReturnToLatest:H,canRefresh:E,history:_==="history",failuresOn:de.status==="error",onToggleFailures:()=>ae({...de,status:de.status==="error"?"all":"error"}),about:{pages:g,searchExcluded:Re?.truncatedCount??0,executionsOmitted:fe.omitted,executionsOutside:h.outsideWindow.length}}),a.jsx(zks,{model:tt,viewportControl:{...ht,applyViewport:bt=>{P(),ht.applyViewport(bt)}},...Ke||wn?{notice:n(wn?"trajectory.noStart":"trajectory.noTiming")}:{},selectedKey:Fe,onSelect:Ps,describe:ut,...mt!==void 0?{range:mt}:{},onRangeChange:jt,onModeChange:bt=>{P(),We(bt)}}),a.jsxs(Adt,{className:Po.split,orientation:"horizontal","data-testid":"trajectory-split",children:[a.jsxs(Ife,{id:"trajectory-records",className:Po.recordsPanel,minSize:320,children:[a.jsxs("div",{ref:Pe,className:Po.records,children:[d&&d.rows.length>0&&a.jsx(rCs,{value:de,onChange:ae,onNavigate:io,onClear:ne,count:pe?Ft.length:0,position:pe&&Fe?Ft.indexOf(Fe)+1:0,truncatedCount:Re?.truncatedCount??0,...$n!==void 0?{range:$n}:{},onClearRange:()=>jt(void 0),...Gn?{status:n("trajectory.range.status",Gn)}:{}},J.scope),a.jsx(V_s,{rows:fe.rows,selectedKey:Be?.key,following:F,liveStatus:h.status,historySnapshot:d,onPause:P,onUpdatedChange:he,onFocusLost:()=>se.current?.focus({preventScroll:!0}),onSelect:bt=>{P(),Se(void 0),Y(!1),Ae({loader:e,key:bt})}},`executions-${J.scope}`),a.jsxs("div",{className:Po.tableWrap,children:[a.jsx("span",{className:Po.srOnly,role:"status","data-testid":"trajectory-window-changed",children:te.selectionLost&&!Fe?n("trajectory.window.changed"):""}),nn.length===0?a.jsxs(a.Fragment,{children:[d&&Xn,f==="error"&&p&&!d?a.jsxs("div",{className:Po.placeholder,role:"alert",children:[a.jsx("span",{children:rxe(p,n)})," ",kfe(p)&&a.jsx("button",{type:"button",className:Po.headerButton,onClick:b,children:n("common.retry")})]}):pe?a.jsxs("div",{className:Po.placeholder,"data-testid":"trajectory-filter-empty",children:[a.jsx("span",{children:n("trajectory.filter.empty")})," ",a.jsx("button",{type:"button",className:Po.headerButton,onClick:ne,children:n("trajectory.filter.clear")})]}):mt!==void 0?a.jsxs("div",{className:Po.placeholder,"data-testid":"trajectory-range-empty",children:[a.jsx("span",{children:n("trajectory.range.empty")})," ",a.jsx("button",{type:"button",className:Po.headerButton,onClick:()=>jt(void 0),children:n("trajectory.range.clear")})]}):a.jsx("div",{className:Po.placeholder,role:"status",children:xs?n("trajectory.empty"):m>0?n("trajectory.loadingPages",{pages:m}):n("common.loading")}),d&&gt&&ao]}):a.jsx("div",{ref:se,className:Po.scroll,role:"grid",tabIndex:0,"aria-label":n("trajectory.title"),"aria-rowcount":nn.length,"aria-activedescendant":zt.getVirtualItems().some(bt=>bt.index===Qe)?Me(Qe):void 0,onKeyDown:bs,onWheel:P,onPointerDown:P,onScroll:bt=>{oe.current=bt.currentTarget.scrollTop,Ts()},"data-testid":"trajectory-rows",children:a.jsxs("div",{className:Po.virtualBody,style:{height:`${zt.getTotalSize()}px`},children:[a.jsx("div",{className:Po.virtualBoundary,children:Xn}),zt.getVirtualItems().map(bt=>{const be=nn[bt.index];return a.jsx("div",{id:Me(bt.index),className:Po.virtualRow,style:{height:`${Cx}px`,transform:`translateY(${bt.start}px)`},role:"row","aria-rowindex":bt.index+1,children:be.kind==="turn"?a.jsx(_Cs,{turn:be.turn,prompt:be.turn.userRowKey?d?.rows[d.rowIndexByKey.get(be.turn.userRowKey)??-1]:void 0,collapsed:ys.has(be.key),hiddenCount:$t.get(be.key)??0,onToggle:()=>kn(be.key),selected:be.key===Ht,onSelect:()=>Ue(be.key)}):a.jsx(SCs,{row:be.row,grouped:(me?.ancestors.get(be.key)?.length??0)>1,unresolvedParent:me?.unresolvedParents.has(be.key)??!1,fold:me?.groups.has(be.key)&&($t.get(be.key)??0)>0?{collapsed:ys.has(be.key),hiddenCount:$t.get(be.key)??0,onToggle:()=>kn(be.key)}:void 0,span:rt.get(be.key),total:tt?.total??0,viewport:ht.viewport,range:mt,context:!!Lt&&!Lt.has(be.key),selected:be.key===Ht,onSelect:()=>Ue(be.key)})},bt.key)}),gt&&a.jsx("div",{className:Po.virtualBoundary,style:{transform:`translateY(${zt.getTotalSize()-Cx}px)`},children:ao})]})}),Sn==="paused"&&(W||Ze)&&a.jsxs("button",{type:"button",className:Po.jumpLatest,"aria-disabled":!E,onClick:()=>{E&&H()},"data-testid":"trajectory-jump-latest",children:[a.jsx(Dge,{size:13,"aria-hidden":"true"}),n("trajectory.jumpLatest"),Ze&&a.jsx("span",{className:Po.updatedDot,role:"img","aria-label":n("trajectory.jumpLatest.updated")})]})]})]}),Et==="drill-in"&&Er]}),Et==="side"&&yt&&a.jsxs(a.Fragment,{children:[a.jsx(jdt,{className:Po.splitHandle,"aria-label":n("trajectory.detail.resize")}),a.jsx(Ife,{id:"trajectory-detail-panel",className:Po.detailPanel,defaultSize:"40%",minSize:320,maxSize:"60%",children:Er})]})]})]})}function _Cs({turn:e,prompt:t,collapsed:n,hiddenCount:s,onToggle:r,selected:o,onSelect:i}){const{t:l}=Xe();return a.jsxs("div",{className:`${Po.turnHeader} ${o?Po.selected:""}`,onClick:i,"aria-selected":o,"data-selected":o?"true":void 0,role:"gridcell","data-testid":"trajectory-turn",children:[a.jsx(Ndt,{collapsed:n,name:l("trajectory.turn",{index:e.index}),onToggle:r}),a.jsx("span",{className:Po.turnTitle,children:e.partial?l("trajectory.turnPartial",{index:e.index}):l("trajectory.turn",{index:e.index})}),t?.kind==="user"&&a.jsx("span",{className:Po.turnPrompt,title:vE(t.block.text),children:vE(t.block.text).slice(0,160)}),n&&s>0&&a.jsx("span",{className:Po.foldCount,children:l("trajectory.collapsed",{count:s})}),a.jsx("span",{className:Po.turnSummary,children:l("trajectory.turnSummary",{requests:e.requestCount,tools:e.toolCount,duration:e.requestCount>0?na(e.requestMs):"—"})})]})}function SCs({row:e,grouped:t,unresolvedParent:n,fold:s,span:r,total:o,viewport:i,range:l,context:c,selected:d,onSelect:h}){const{t:f}=Xe(),p=Rfe(e,f),m=yCs(e,f);return a.jsxs("div",{className:`${Po.record} ${d?Po.selected:""}`,role:"gridcell","aria-selected":d,"data-selected":d?"true":void 0,onClick:h,"data-testid":`trajectory-row-${e.kind}`,"data-depth":e.depth,"data-grouped":t||void 0,"data-context":c||void 0,"data-row-key":e.key,children:[s?a.jsx(Ndt,{collapsed:s.collapsed,name:p.text,onToggle:s.onToggle}):a.jsx("span",{className:Po.foldSpacer}),e.depth>0&&a.jsx(a5t,{size:12,strokeWidth:1.6,className:Po.nestMarker,"aria-hidden":"true"}),a.jsx("span",{className:`${Po.badge} ${p.badgeTone??""}`,children:p.badge}),a.jsx("span",{className:`${Po.text} ${p.faint?Po.faint:""}`,children:p.text}),n&&a.jsx("span",{className:Po.parentNotice,title:f("trajectory.parentUnresolved"),children:f("trajectory.parentUnresolved")}),c&&a.jsx("span",{className:Po.foldCount,children:f("trajectory.contextRow")}),s?.collapsed&&a.jsx("span",{className:Po.foldCount,children:f("trajectory.collapsed",{count:s.hiddenCount})}),a.jsx("span",{className:Po.waterfallSlot,children:a.jsx(FSs,{span:r,total:o,viewport:i,range:l,title:m.join(" · ")})}),a.jsx("span",{className:Po.rowMetrics,"data-testid":"trajectory-row-metrics",title:m.length>0?m.join(" · "):void 0,children:m.length>0?m.join(" · "):"—"})]})}function Ndt({collapsed:e,name:t,onToggle:n}){const{t:s}=Xe();return a.jsx("button",{type:"button",tabIndex:-1,className:Po.foldButton,"aria-expanded":!e,"aria-label":s(e?"trajectory.expand":"trajectory.collapse",{name:t}),onClick:r=>{r.stopPropagation(),n()},children:e?a.jsx(Vl,{size:13,"aria-hidden":"true"}):a.jsx(ud,{size:13,"aria-hidden":"true"})})}const CCs="_panel_pwtdr_1",TCs="_toolbar_pwtdr_5",ICs="_actions_pwtdr_15",RCs="_feedback_pwtdr_21",ECs="_state_pwtdr_31",R1={panel:CCs,toolbar:TCs,actions:ICs,feedback:RCs,state:ECs};function ACs({sessionActions:e,sessionId:t,controls:n,onOpenMemoryFile:s}){const{t:r}=Xe(),[o,i]=u.useState(null),[l,c]=u.useState(!0),[d,h]=u.useState(!1),f=u.useRef(0),p=u.useRef(()=>{}),m=u.useRef(null),g=n?.sessionId===t?n:void 0,v=g?.getContextUsage??e?.getContextUsage,y=u.useRef(g);y.current=g;const w=g?.result,[b,x]=u.useState(w),k=!!(w&&w!==b&&(w.kind!=="completed"||!d));u.useEffect(()=>{w?.kind==="completed"&&(f.current++,i(w.usage),h(!1))},[w]),u.useEffect(()=>{let R=!0,j=!1;const E=y.current?.result;i(C=>C?.sessionId===t?C:E?.kind==="completed"?E.usage:null),h(!1),c(!!v);const I=async()=>{if(!R||j||!v)return;j=!0,c(!0),h(!1);const C=f.current,N=m.current,A=N&&N.getContextUsage===v&&N.sessionId===t?N:{getContextUsage:v,sessionId:t,promise:v({detail:!0,silent:!0,...y.current?.result?{syncCounters:!0}:{}})};m.current=A;try{const M=await A.promise;if(!R||C!==f.current)return;i(M.sessionId===t&&M.usage.contextWindowSize>0?M:null)}catch(M){if(!R||C!==f.current)return;h(nq(M)?"transient":"hard")}finally{j=!1,m.current===A&&(m.current=null),R&&c(!1)}};return p.current=()=>void I(),I(),()=>{R=!1}},[v,t]);const _=!v||l||g?.compressing,S=()=>{x(w),p.current()};return a.jsxs("div",{className:R1.panel,"aria-busy":l,children:[a.jsxs("div",{className:R1.toolbar,children:[a.jsx("span",{children:r("contextUsage.title")}),a.jsxs("div",{className:R1.actions,children:[a.jsx(Ne,{type:"button",variant:"ghost",size:"icon-sm","aria-label":r("contextUsage.refresh"),title:r("contextUsage.refresh"),disabled:_,onClick:S,children:a.jsx(ph,{"aria-hidden":"true"})}),a.jsx("span",{title:g?.compressing?void 0:g?.canCompress?l?r("common.loading"):void 0:r("contextUsage.compressUnavailable"),children:a.jsx(Ne,{type:"button",variant:"outline",size:"sm",disabled:!g?.canCompress||l,onClick:()=>void g?.compress(),children:r(g?.compressing?"contextUsage.compressing":"contextUsage.compress")})})]})]}),(g?.compressing||k)&&a.jsx(hrt,{controls:g,className:R1.feedback}),d==="transient"&&o&&a.jsx("div",{className:R1.feedback,role:"status",children:r("contextUsage.previousReading")}),d==="hard"?a.jsxs("div",{className:R1.state,role:"alert",children:[a.jsx("span",{children:r("contextUsage.loadError")}),a.jsx(Ne,{type:"button",variant:"outline",size:"sm",disabled:_,onClick:S,children:r("contextUsage.retry")})]}):v?l&&!o?a.jsx("div",{className:R1.state,role:"status",children:r("common.loading")}):o?a.jsx(fXe,{status:o,compact:!0,onOpenMemoryFile:s?R=>s(R,o.workspaceRoot??o.workspaceCwd):void 0}):a.jsx("div",{className:R1.state,children:r("contextUsage.unavailable")}):a.jsx("div",{className:R1.state,children:r("contextUsage.unavailable")})]})}class Mdt extends Error{}function Pdt(e){throw new Mdt(e instanceof Error?e.message:String(e))}const jCs=()=>xt(()=>import("./WorkspaceFileBrowser-64vDYikf.js"),__vite__mapDeps([95,96])).then(e=>({default:e.WorkspaceFileBrowser})).catch(Pdt),NCs=()=>xt(()=>import("./PierreFilePreview-DEhWK46v.js"),[]).catch(Pdt),MCs=u.lazy(()=>xt(()=>import("./SpreadsheetPreview-C-GgIuPX.js"),[])),PCs=700,DCs=["daily","weekdays","weekly","hourly","minutes","custom"],LCs=[1,2,3,4,5,6,10,12,15,20,30],OCs=(e,t)=>{},BCs=(e,t,n)=>{},$Cs=()=>Promise.reject(new Error("Side-task session creation is unavailable"));function ADe(e){return e.kind==="review"||e.kind==="file"||e.kind==="artifact"||e.kind==="scheduled_task"}function E1(e){return e.kind==="pending"?e.targetKind:e.kind}function FCs(e){return`image.${(e.match(/^data:image\/([a-z0-9+.+-]+)/i)?.[1]??"png").split("+")[0].toLowerCase()}`}const zCs=["review","sideTask"];function UCs({tab:e,workspaceCwd:t,onOpenFilePreview:n,onReferenceFile:s,onClose:r}){const{t:o,language:i}=Xe(),l=c9(),c=u.useMemo(()=>u.lazy(jCs),[]),d=u.useMemo(()=>u.lazy(NCs),[]),h=dA(e.workspaceCwd),f=h?.workspaceId===e.workspaceId?h?.actions:void 0;if(!f)return a.jsx("div",{className:Ct.empty,role:"alert",children:o("workspace.notFoundDescription")});const p=(m,g)=>{const v=m instanceof Mdt,y=()=>!!(l&&(!l.activeToken||bpe()));return v&&!y()?a.jsxs("div",{role:"alert",className:Ct.empty,children:[a.jsx("p",{children:o("files.loadFailed")}),a.jsx("p",{children:o("files.reloadUnavailable")}),a.jsx(Ne,{onClick:r,children:o("files.close")})]}):a.jsx(wX,{error:m,language:i,retryMode:v?"reload":"reset",onRetry:v?()=>{y()?window.location.reload():r()}:g})};return a.jsx(Rm,{label:"workspace file browser",fallback:p,children:a.jsx(u.Suspense,{fallback:a.jsx("div",{className:`${Ct.empty} text-center`,role:"status",children:o("common.loading")}),children:a.jsx(c,{workspaceCwd:e.workspaceCwd,actions:f,onOpenPreview:m=>n(m,e.workspaceCwd,e.workspaceId),onReferenceFile:e.workspaceCwd===t?s:void 0,renderPreview:(m,g,v)=>a.jsx(S7,{workspacePath:m,workspaceActions:f,previewKind:g?"source":void 0,sourceRenderer:y=>a.jsx(Rm,{label:"workspace file source",resetKeys:[m],fallback:p,children:a.jsx(u.Suspense,{fallback:a.jsx("div",{className:Ct.empty,children:o("common.loading")}),children:a.jsx(d,{path:m,content:y})})})},`${m}:${g}:${v}`)},`${e.workspaceCwd}:${e.workspaceId??""}`)})})}function jDe({contextUsageControls:e,artifacts:t,tabs:n,activeTabId:s,reviewChanges:r,selectedReviewPath:o,panelWidth:i,workspaceCwd:l,loading:c,restoring:d=!1,error:h,onSelectTab:f,onSelectTurnCallsPrompt:p,onCloseTab:m,onOpenFilePreview:g,onOpenMemoryFile:v,latestReviewAvailable:y=!1,onOpenLatestReview:w,onOpenTerminal:b,onOpenTrajectory:x,trajectoryTabId:k,onOpenFiles:_,onReferenceFile:S,onOpenWebPreview:R,onWebPreviewChange:j,items:E=zCs,sideTaskAvailable:I=!1,sideTasks:C=[],archivedSideTasks:N=[],sideTasksLoading:A=!1,onCreateSideTask:M,onOpenSideTask:P,onArchiveSideTasks:L,onUnarchiveSideTasks:F,onSideTaskMenuOpen:$,onCreateSideTaskSession:B,onSideTaskCreated:D,onSideTaskTitleChange:O,onSideTaskInitialPromptRefused:U,onNestedRightPanelOpen:H,onNestedArtifactsChange:Q,onOpenNestedSubagent:q,agentTasks:te=[],agentTraceLoading:Z=!1,agentTraceError:ce,onOpenWorkflowAgent:he,onError:W,sessionWorkflowEnabled:G,modelManagement:J,unavailableModels:X,mountUnavailableModelTooltip:de,workflow:ae,onImageIngestionNotice:ne,deferSubagentMount:pe=!1,onClose:Re,variant:ke="docked",fullscreen:Te=!1,onToggleFullscreen:Fe}){const{t:Se}=Xe(),Le=ko(),ge=q1(Le.capabilities,l),[fe,we]=u.useState(!1),[Ae,Be]=u.useState(),ve=u.useRef(null),Y=u.useCallback(()=>{ve.current&&(clearTimeout(ve.current),ve.current=null),we(!0)},[]),se=u.useCallback(()=>{ve.current&&clearTimeout(ve.current),ve.current=setTimeout(()=>{we(!1),ve.current=null},120)},[]);u.useEffect(()=>{fe&&$?.()},[$,fe]),u.useEffect(()=>()=>{ve.current&&clearTimeout(ve.current)},[]);const V=n.find(me=>me.id===s)??n[0],oe=V?.kind==="file"&&V.sourcePreview&&(/\.html?$/i.test(V.workspacePath)||xy(V.previewMimeType||V.previewData?.type)==="text/html"),Ie=V?.kind==="file"&&V.previewOnly===!0&&!oe&&/\.(?:html?|md|markdown)$/i.test(V.workspacePath)&&(V.previewContent!==void 0||!V.previewData||!!FM(V.previewMimeType||V.previewData.type,V.workspacePath)),Me=Ae===V?.id,Ce=E.includes("review")&&!n.some(me=>E1(me)==="review"),_e=E.includes("sideTask")&&I&&!!M,Ge=C.some(me=>me.archivable===!0),We=!!b,tt=E.includes("webPreview")&&!!R,ht=E.includes("trajectory")&&!!x&&!n.some(me=>me.id===k),rt=E.includes("files")&&!!_&&!n.some(me=>me.kind==="files"&&me.workspaceCwd===l&&me.workspaceId===ge?.id),kt=!!V&&(rt||Ce||_e||We||tt||ht),Ve=V&&ADe(V)?{workspaceCwd:V.workspaceCwd,workspaceId:V.workspaceId}:void 0,mt=dA(Ve?.workspaceCwd),jt=mt?.workspaceId===Ve?.workspaceId?mt?.actions:void 0,Ot=V?.kind==="artifact"?t.find(me=>me.id===V.artifactId):void 0;return a.jsxs("aside",{className:`${Ct.panel} ${ke==="drawer"?Ct.panelDrawer:""} ${Te?Ct.panelFullscreen:""}`,style:ke==="docked"&&i&&!Te?{flexBasis:i,width:i}:void 0,"aria-label":"Right panel",children:[a.jsxs("div",{className:Ct.header,children:[n.length>0&&a.jsx("div",{className:Ct.tabs,role:"tablist","aria-label":"Right panel",children:n.map(me=>a.jsxs("div",{className:[Ct.tabItem,me.id===V?.id?Ct.tabActive:""].filter(Boolean).join(" "),children:[a.jsxs("button",{type:"button",role:"tab","aria-selected":me.id===V?.id,className:Ct.tab,onClick:()=>f(me.id),onMouseEnter:it=>E_(it.currentTarget),onFocus:it=>E_(it.currentTarget),title:me.kind==="turn_calls"?Se("turnCalls.title"):me.title,children:[a.jsx("span",{className:`${Ct.tabIcon} ${E1(me)==="artifact"?Ct.tabArtifactIcon:""}`,"aria-hidden":"true",children:E1(me)==="review"?a.jsx(Foe,{}):me.kind==="files"?a.jsx(L8,{className:Ct.tabIconSvg}):me.kind==="workflow"?a.jsx(wVe,{className:Ct.tabIconSvg,strokeWidth:1.6}):me.kind==="file"?a.jsx(Tb,{name:me.workspacePath,className:Ct.tabIconSvg,strokeWidth:1.6}):E1(me)==="artifact"?a.jsx(LJe,{artifact:t.find(it=>"artifactId"in me&&it.id===me.artifactId),className:Ct.tabIconSvg}):E1(me)==="subagent"?a.jsx(WCs,{}):E1(me)==="monitor"?a.jsx(Vge,{className:Ct.tabIconSvg,strokeWidth:1.6}):E1(me)==="shell"?a.jsx(RR,{className:Ct.tabIconSvg,strokeWidth:1.6}):E1(me)==="side_task"?a.jsx(sF,{className:Ct.tabIconSvg,strokeWidth:1.6}):me.kind==="web_preview"?a.jsx(k4,{className:Ct.tabIconSvg}):me.kind==="terminal"?a.jsx(RR,{className:Ct.tabIconSvg,strokeWidth:1.6}):E1(me)==="image"?a.jsx(hVe,{className:Ct.tabIconSvg,strokeWidth:1.6}):me.kind==="context_usage"?a.jsx(OY,{className:Ct.tabIconSvg,strokeWidth:1.6}):me.kind==="token_usage"?a.jsx(LY,{className:Ct.tabIconSvg,strokeWidth:1.6}):me.kind==="turn_calls"?a.jsx(hL,{className:Ct.tabIconSvg,strokeWidth:1.6}):me.kind==="trajectory"?a.jsx(jte,{className:Ct.tabIconSvg,strokeWidth:1.6}):a.jsx(qCs,{})}),a.jsx("span",{className:Ct.tabTitle,"data-web-shell-session-title":!0,children:a.jsx("span",{className:Ct.tabTitleInner,children:me.kind==="turn_calls"?Se("turnCalls.title"):me.title})})]}),a.jsx("button",{type:"button",className:Ct.tabCloseButton,onClick:()=>m(me.id),"aria-label":`Close ${me.kind==="turn_calls"?Se("turnCalls.title"):me.title}`,title:"Close",children:a.jsx(HCs,{})})]},me.id))}),a.jsxs("div",{className:Ct.headerActions,children:[kt&&a.jsxs(sf,{modal:!1,children:[a.jsx(Nh,{asChild:!0,children:a.jsx("button",{type:"button",className:`${Ct.iconButton} ${Ct.addButton}`,"aria-label":Se("rightPanel.add"),title:Se("rightPanel.add"),children:a.jsx(Nf,{className:Ct.toolbarIcon})})}),a.jsxs(Mh,{align:"end",className:"w-64",children:[rt&&a.jsxs(Mr,{onSelect:_,children:[a.jsx(L8,{}),a.jsx("span",{className:Ct.sideTaskListTitle,children:Se("files.title")})]}),Ce&&a.jsxs(Mr,{disabled:!y||!w,onSelect:w,children:[a.jsx(Foe,{}),a.jsx("span",{className:Ct.sideTaskListTitle,children:Se("turnOutputs.review")})]}),Ce&&_e&&a.jsx(ug,{}),_e&&a.jsxs(Mr,{disabled:A,onSelect:M,children:[a.jsx(sF,{className:Ct.sideTaskNewIcon,strokeWidth:1.6,"aria-hidden":"true"}),a.jsx("span",{className:Ct.sideTaskListTitle,children:Se("sideTask.create")})]}),We&&(Ce||_e)&&a.jsx(ug,{}),We&&a.jsxs(Mr,{onSelect:()=>b?.(),children:[a.jsx(RR,{className:Ct.sideTaskNewIcon,strokeWidth:1.6,"aria-hidden":"true"}),a.jsx("span",{className:Ct.sideTaskListTitle,children:Se("terminal.title")})]}),tt&&a.jsxs(Mr,{onSelect:R,children:[a.jsx(k4,{className:Ct.sideTaskNewIcon}),a.jsx("span",{className:Ct.sideTaskListTitle,children:Se("webPreview.title")})]}),ht&&a.jsxs(Mr,{onSelect:()=>x?.(),children:[a.jsx(jte,{className:Ct.sideTaskNewIcon,strokeWidth:1.6,"aria-hidden":"true"}),a.jsx("span",{className:Ct.sideTaskListTitle,children:Se("trajectory.title")})]})]})]}),Fe&&a.jsx("button",{type:"button",className:`${Ct.iconButton} ${Ct.fullscreenButton} ${Te?Ct.iconButtonActive:""}`,onClick:Fe,"aria-label":Se(Te?"common.exitFullscreen":"common.fullscreen"),"aria-pressed":Te,title:Se(Te?"common.exitFullscreen":"common.fullscreen"),children:Te?a.jsx($Y,{className:Ct.toolbarIcon,"aria-hidden":!0}):a.jsx(DY,{className:Ct.toolbarIcon,"aria-hidden":!0})}),a.jsx("button",{type:"button",className:`${Ct.iconButton} ${Ct.panelToggleButton}`,onClick:Re,"aria-label":Se("chatHeader.toggleRightPanel"),"aria-pressed":"true",title:Se("chatHeader.toggleRightPanel"),children:a.jsx(yVe,{className:Ct.panelToggleIcon})})]})]}),(Te||ke==="drawer")&&a.jsx(Yit,{}),a.jsxs("div",{className:`${Ct.body} ${V?.kind==="side_task"||V?.kind==="files"?Ct.bodySideTask:""}`.trim(),children:[n.filter(me=>me.kind==="web_preview").map(me=>a.jsx("div",{className:"h-full",hidden:me.id!==V?.id,children:a.jsx(Fbs,{state:me,onChange:it=>j?.(me.id,it)})},me.id)),n.filter(me=>me.kind==="files").map(me=>a.jsx("div",{className:"h-full",hidden:me.id!==V?.id,children:a.jsx(UCs,{onClose:()=>m(me.id),tab:me,workspaceCwd:l,onOpenFilePreview:g,onReferenceFile:S})},me.id)),n.filter(me=>me.kind==="terminal").map(me=>a.jsx("div",{className:`${Ct.terminalPane} ${me.id===V?.id?"":Ct.terminalPaneHidden}`.trim(),"aria-hidden":me.id===V?.id?void 0:!0,children:a.jsx($bs,{terminalId:me.id,cwd:me.workspaceCwd??l,active:me.id===V?.id,enabled:me.initialized!==!1})},me.id)),Ie&&a.jsxs("button",{type:"button",className:Ct.attachmentPreviewButton,onClick:()=>Be(Me?void 0:V?.id),"aria-label":Se(Me?"attachment.showSource":"attachment.showPreview"),"aria-pressed":Me,children:[Me?a.jsx(t5t,{"aria-hidden":!0}):a.jsx(_q,{"aria-hidden":!0}),Se(Me?"attachment.showSource":"attachment.showPreview")]}),d&&!V?a.jsxs("div",{className:"flex flex-col gap-4 p-5","data-testid":"right-panel-loading-skeleton",role:"status","aria-label":Se("common.loading"),children:[a.jsx(rk,{className:"h-5 w-2/5"}),a.jsx(rk,{className:"h-32 w-full"}),a.jsx(rk,{className:"h-4 w-4/5"}),a.jsx(rk,{className:"h-4 w-3/5"})]}):V?.kind==="terminal"||V?.kind==="web_preview"||V?.kind==="files"?null:V?V.kind==="pending"?a.jsx("div",{className:Ct.empty,role:V.loadError?"alert":"status",children:V.loadError??Se("common.loading")}):V.kind==="workflow"?V.sessionId?a.jsx($0s,{tasks:te,loading:Z,error:ce,onOpenAgent:he}):ae?a.jsx(kvs,{...ae}):a.jsx("div",{className:Ct.empty,children:Se("workflow.empty.title")}):ADe(V)&&(V.kind!=="scheduled_task"||V.task.durable)&&(V.kind!=="file"||!V.previewOnly)&&(V.kind!=="review"||!(V.changes??r).some(me=>me.diffs.length>0))&&(V.kind!=="artifact"||Ot?.metadata?.artifactType!=="web_preview_snapshot")&&!jt?a.jsx("div",{className:Ct.empty,role:"alert",children:Se("workspace.notFoundDescription")}):V.kind==="review"?a.jsx(KCs,{changes:V.changes??r,selectedPath:V.selectedPath??o,workspaceCwd:V.workspaceCwd??l,onOpenFilePreview:jt?me=>g(me,V.workspaceCwd??l,V.workspaceId):void 0,onDownloadFile:jt?(me,it)=>L9(jt,me.path,bQt(me.path),it):void 0,onDownloadError:me=>{const it=Se("common.downloadFailed",{message:Wa(me)});W?W(new Error(it,{cause:me}),it):console.error(it,me)}}):V.kind==="file"?V.attachmentId&&!V.previewData&&V.previewContent===void 0?a.jsx("div",{className:Ct.empty,role:V.loadError?"alert":"status",children:V.loadError??Se("common.loading")}):V.sourcePreview&&V.previewData&&!P9(V.workspacePath,V.previewMimeType||V.previewData.type)&&!M9(V.workspacePath,V.previewMimeType||V.previewData.type)&&!JT({workspacePath:V.workspacePath,mimeType:V.previewMimeType||V.previewData.type})&&!FM(V.previewMimeType||V.previewData.type,V.workspacePath)?a.jsx(pxe,{data:V.previewData,title:V.title,image:!!XT(V.workspacePath)&&V.previewData.type.startsWith("image/")}):a.jsx(S7,{workspacePath:V.workspacePath,artifactVersion:String(V.previewVersion??0),workspaceActions:jt,previewContent:V.previewContent,previewData:V.previewData,previewMimeType:V.previewMimeType,previewOnly:V.previewOnly,previewKind:oe||V.previewOnly&&!Me?"source":void 0},V.id):V.kind==="source"?a.jsx(dTs,{tab:V},V.id):V.kind==="artifact"?a.jsx(VCs,{artifacts:t,artifactId:V.artifactId,sourceSessionId:V.sourceSessionId,workspaceActions:jt,previewContent:V.previewContent,loading:c,error:h},V.id):V.kind==="subagent"?pe?null:a.jsx(x0s,{sessionId:V.sessionId,rootToolCallId:V.rootToolCallId,initialRootTool:V.rootTool,workspaceCwd:V.workspaceCwd??l,onRightPanelOpen:H,onArtifactsChange:Q,onOpenSubagent:q,onError:W}):V.kind==="monitor"?a.jsx(scn,{task:V.task,actions:V.sessionActions},V.id):V.kind==="shell"?a.jsx(rcn,{task:V.task,actions:V.sessionActions},V.id):V.kind==="side_task"?a.jsx(z0s,{tabId:V.id,sessionId:V.sessionId,parentSessionId:V.parentSessionId,workspaceCwd:V.workspaceCwd??l,title:V.title,shouldNameFromFirstPrompt:V.nameFromFirstPrompt,initialPrompt:V.initialPrompt,createSession:B??$Cs,onCreated:D??OCs,onTitleChange:O??BCs,onInitialPromptRefused:U,onRightPanelOpen:H,onArtifactsChange:Q,onError:W,sessionWorkflowEnabled:G,modelManagement:J,unavailableModels:X,mountUnavailableModelTooltip:de,onImageIngestionNotice:ne},V.id):V.kind==="image"?V.src?a.jsxs("div",{className:Ct.imagePreviewWrap,children:[a.jsx("img",{src:V.src,alt:V.alt??V.title,className:Ct.imagePreview}),a.jsx("a",{className:Ct.imageDownloadButton,href:V.src,download:FCs(V.src),"aria-label":Se("common.download"),title:Se("common.download"),children:a.jsx(oy,{size:16,strokeWidth:1.8})})]}):a.jsx("div",{className:Ct.empty,role:V.loadError?"alert":"status",children:V.loadError??Se("common.loading")}):V.kind==="context_usage"?a.jsx(ACs,{controls:e?.[V.sessionId],sessionActions:V.sessionActions,sessionId:V.sessionId,onOpenMemoryFile:v},V.id):V.kind==="trajectory"?a.jsx(kCs,{loadPage:V.loadPage,historyGapRevision:V.historyGapRevision},V.id):V.kind==="token_usage"?a.jsx(Kxs,{sessionActions:V.sessionActions,sessionId:V.sessionId},V.id):V.kind==="turn_calls"?a.jsx(ofs,{turnId:V.turnId,ownerSessionId:V.sessionId,recordId:V.recordId,promptId:V.promptId,promptLabel:V.promptLabel,onSelectPrompt:p,workspaceCwd:l,onOpenFile:H,onOpenAgent:q},`${V.sessionId}:${l}`):a.jsx(GCs,{task:V.task,actions:jt},V.id):a.jsxs("div",{className:Ct.emptyActions,"data-testid":"right-panel-empty-actions",children:[E.includes("files")&&a.jsxs("button",{type:"button",className:Ct.emptyAction,disabled:!_,onClick:_,children:[a.jsx("span",{className:Ct.emptyActionIcon,"aria-hidden":"true",children:a.jsx(L8,{})}),a.jsx("span",{className:Ct.emptyActionTitle,children:Se("files.title")}),a.jsx("span",{className:Ct.emptyActionHint,children:Se("files.description")}),a.jsx(Vl,{className:Ct.emptyActionChevron,strokeWidth:1.6,"aria-hidden":"true"})]}),E.includes("review")&&a.jsxs("button",{type:"button",className:Ct.emptyAction,disabled:!y||!w,onClick:w,children:[a.jsx("span",{className:Ct.emptyActionIcon,"aria-hidden":"true",children:a.jsx(Foe,{})}),a.jsx("span",{className:Ct.emptyActionTitle,children:Se("turnOutputs.review")}),a.jsx("span",{className:Ct.emptyActionHint,children:Se("turnOutputs.reviewLatest")}),a.jsx(Vl,{className:Ct.emptyActionChevron,strokeWidth:1.6,"aria-hidden":"true"})]}),E.includes("sideTask")&&I&&M&&(C.length===0&&N.length===0?a.jsxs("button",{type:"button",className:Ct.emptyAction,disabled:A,"aria-busy":A,onClick:M,children:[a.jsx("span",{className:Ct.emptyActionIcon,"aria-hidden":"true",children:a.jsx(sF,{strokeWidth:1.6})}),a.jsx("span",{className:Ct.emptyActionTitle,children:Se("sideTask.title")}),a.jsx("span",{className:Ct.emptyActionHint,children:Se("sideTask.description")}),a.jsx(Vl,{className:Ct.emptyActionChevron,strokeWidth:1.6,"aria-hidden":"true"})]}):a.jsxs(sf,{open:fe,onOpenChange:we,modal:!1,children:[a.jsx(Nh,{asChild:!0,children:a.jsxs("button",{type:"button",className:Ct.emptyAction,"aria-expanded":fe,onMouseEnter:Y,onMouseLeave:se,children:[a.jsx("span",{className:Ct.emptyActionIcon,"aria-hidden":"true",children:a.jsx(sF,{strokeWidth:1.6})}),a.jsx("span",{className:Ct.emptyActionTitle,children:Se("sideTask.title")}),a.jsx("span",{className:Ct.emptyActionHint,children:Se("sideTask.description")}),a.jsx(Vl,{className:Ct.emptyActionChevron,strokeWidth:1.6,"aria-hidden":"true"})]})}),a.jsxs(Mh,{align:"end",className:"w-80",onMouseEnter:Y,onMouseLeave:se,children:[C.map(me=>{const it=a.jsxs(a.Fragment,{children:[a.jsx("span",{className:Ct.sideTaskListTitle,children:me.title}),me.updatedAt&&a.jsx("span",{className:Ct.sideTaskListTime,children:u2(me.updatedAt,Se)})]});return L?a.jsxs(UC,{children:[a.jsx(WC,{children:it}),a.jsxs(HC,{onMouseEnter:Y,onMouseLeave:se,children:[a.jsxs(Mr,{onSelect:()=>P?.(me),children:[a.jsx(_q,{}),Se("common.open")]}),a.jsxs(Mr,{disabled:me.archivable!==!0,title:me.archivable===!0?void 0:Se("sideTask.archiveUnavailable"),onSelect:()=>{L([me])},children:[a.jsx(ST,{}),Se("sidebar.archive")]})]})]},me.sessionId):a.jsx(Mr,{onSelect:()=>P?.(me),children:it},me.sessionId)}),L&&C.length>0&&a.jsx(ug,{}),L&&C.length>0&&a.jsxs(Mr,{disabled:!Ge,onSelect:()=>{L(C)},children:[a.jsx(ST,{}),a.jsx("span",{className:Ct.sideTaskListTitle,children:Se("sideTask.archiveCompleted")})]}),F&&N.length>0&&a.jsxs(a.Fragment,{children:[C.length>0&&a.jsx(ug,{}),a.jsxs(UC,{children:[a.jsxs(WC,{children:[a.jsx(kle,{}),a.jsxs("span",{className:Ct.sideTaskListTitle,children:[Se("sidebar.archivedTitle")," (",N.length,")"]})]}),a.jsx(HC,{className:"max-h-(--radix-dropdown-menu-content-available-height) overflow-x-hidden overflow-y-auto",onMouseEnter:Y,onMouseLeave:se,children:N.map(me=>a.jsxs(Mr,{onSelect:()=>{F([me])},children:[a.jsx(kle,{}),a.jsx("span",{className:Ct.sideTaskListTitle,children:me.title}),a.jsx("span",{className:Ct.sideTaskListTime,children:Se("sidebar.unarchive")})]},me.sessionId))})]})]}),C.length>0&&a.jsx(ug,{}),a.jsxs(Mr,{onSelect:M,children:[a.jsx(q3t,{className:Ct.sideTaskNewIcon,strokeWidth:1.6,"aria-hidden":"true"}),a.jsx("span",{className:Ct.sideTaskListTitle,children:Se("sideTask.new")})]})]})]})),tt&&a.jsxs("button",{type:"button",className:Ct.emptyAction,"data-testid":"right-panel-open-web-preview",onClick:R,children:[a.jsx("span",{className:Ct.emptyActionIcon,"aria-hidden":"true",children:a.jsx(k4,{strokeWidth:1.6})}),a.jsx("span",{className:Ct.emptyActionTitle,children:Se("webPreview.title")}),a.jsx("span",{className:Ct.emptyActionHint,children:Se("webPreview.openHint")}),a.jsx(Vl,{className:Ct.emptyActionChevron,"aria-hidden":"true"})]}),ht&&a.jsxs("button",{type:"button",className:Ct.emptyAction,onClick:()=>x?.(),"data-testid":"right-panel-open-trajectory",children:[a.jsx("span",{className:Ct.emptyActionIcon,"aria-hidden":"true",children:a.jsx(jte,{strokeWidth:1.6})}),a.jsx("span",{className:Ct.emptyActionTitle,children:Se("trajectory.title")}),a.jsx("span",{className:Ct.emptyActionHint,children:Se("trajectory.description")}),a.jsx(Vl,{className:Ct.emptyActionChevron,"aria-hidden":"true"})]}),b&&a.jsxs("button",{type:"button",className:Ct.emptyAction,onClick:()=>b(),children:[a.jsx("span",{className:Ct.emptyActionIcon,"aria-hidden":"true",children:a.jsx(RR,{strokeWidth:1.6})}),a.jsx("span",{className:Ct.emptyActionTitle,children:Se("terminal.title")}),a.jsx("span",{className:Ct.emptyActionHint,children:Se("terminal.open")}),a.jsx(Vl,{className:Ct.emptyActionChevron,strokeWidth:1.6,"aria-hidden":"true"})]})]})]})]})}function WCs(){return a.jsxs("svg",{className:Ct.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 HCs(){return a.jsx("svg",{className:Ct.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 Foe(){return a.jsxs("svg",{className:Ct.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 qCs(){return a.jsxs("svg",{className:Ct.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 VCs({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(oTs,{artifact:l,sourceSessionId:n,workspaceActions:s,previewContent:r}):o?a.jsx("div",{className:Ct.empty,children:"Loading artifact..."}):i?a.jsx("div",{className:Ct.empty,children:i}):a.jsx("div",{className:Ct.empty,children:"Artifact not found."})}function GCs({task:e,actions:t}){const{t:n}=Xe(),[s,r]=u.useState(null),[o,i]=u.useState(!0),[l,c]=u.useState(null),[d,h]=u.useState(""),[f,p]=u.useState(e.prompt),[m,g]=u.useState(()=>bC(e.cron)),[v,y]=u.useState(!1),[w,b]=u.useState(!1),[x,k]=u.useState(!1),[_,S]=u.useState(!1),[R,j]=u.useState(null),E=u.useRef(0),I=u.useRef(0),C=u.useRef({actions:t,taskId:e.id,workspaceId:e.workspaceId});C.current={actions:t,taskId:e.id,workspaceId:e.workspaceId};const N=u.useCallback((W,G,J,X)=>{const de=C.current;return W===E.current&&de.actions===G&&de.taskId===J&&de.workspaceId===X},[]),A=u.useCallback((W,G,J,X)=>{const de=C.current;return W===I.current&&de.actions===G&&de.taskId===J&&de.workspaceId===X},[]);u.useEffect(()=>()=>{E.current+=1,I.current+=1},[]),u.useEffect(()=>{k(!1),S(!1),j(null)},[t,e.id,e.workspaceId]);const M=u.useCallback(async()=>{const W=++E.current,G=++I.current,J=e.id,X=e.workspaceId;if(!e.durable||!t){r(null),h(""),p(e.prompt),g(bC(e.cron)),c(null),i(!1);return}i(!0),c(null);try{const de=await t.listScheduledTasks(X);if(!N(W,t,J,X))return;const ae=de.find(ne=>ne.id===e.id)??null;r(ae),ae?(h(ae.name??""),p(ae.prompt),g(bC(ae.cron))):(h(""),p(e.prompt),g(bC(e.cron)))}catch(de){A(G,t,J,X)&&c(de instanceof Error?de.message:String(de))}finally{A(G,t,J,X)&&i(!1)}},[t,A,N,e.cron,e.durable,e.id,e.prompt,e.workspaceId]);u.useEffect(()=>{M()},[M]);const P=!e.durable,L=e.durable&&!o&&!l&&!s,F=!!s,$=s?.name||s?.prompt||e.title,B=s?.prompt??e.prompt,D=s?.cron??e.cron,O=s?.recurring??e.recurring,U=s?.enabled,H=u.useCallback(()=>{s&&(h(s.name??""),p(s.prompt),g(bC(s.cron)),j(null),y(!0))},[s]),Q=u.useCallback(()=>{y(!1),j(null),s&&(h(s.name??""),p(s.prompt),g(bC(s.cron)))},[s]),q=u.useCallback(async()=>{if(!s||!t)return;const W=sV(m);if(!W){j(n("scheduledTasks.error.invalidSchedule"));return}if(f.trim().length===0){j(n("scheduledTasks.error.emptyPrompt"));return}const G=++E.current,J=e.id,X=e.workspaceId;S(!0),j(null);try{const de=await t.updateScheduledTask(s.id,{cron:W,prompt:f.trim(),name:d.trim()||null},X);if(!N(G,t,J,X))return;r(de),h(de.name??""),p(de.prompt),g(bC(de.cron)),y(!1)}catch(de){N(G,t,J,X)&&j(de instanceof Error?de.message:String(de))}finally{N(G,t,J,X)&&S(!1)}},[t,m,N,s,d,f,n,e.id,e.workspaceId]),te=u.useCallback(async()=>{if(!s||!t)return;const W=++E.current,G=e.id,J=e.workspaceId;k(!0),j(null);try{const X=await t.updateScheduledTask(s.id,{enabled:!s.enabled},J);if(!N(W,t,G,J))return;r(X)}catch(X){N(W,t,G,J)&&j(X instanceof Error?X.message:String(X))}finally{N(W,t,G,J)&&k(!1)}},[t,N,s,e.id,e.workspaceId]),Z=u.useCallback(async()=>{if(!s||!t)return;const W=++E.current,G=e.id,J=e.workspaceId;k(!0),j(null);try{if(await t.deleteScheduledTask(s.id,J),!N(W,t,G,J))return;r(null),b(!1)}catch(X){N(W,t,G,J)&&j(X instanceof Error?X.message:String(X))}finally{N(W,t,G,J)&&k(!1)}},[t,N,s,e.id,e.workspaceId]),ce=sV(m),he=ce?xM(ce,n):null;return a.jsxs("div",{className:Ct.detail,children:[o&&a.jsx("div",{className:Ct.empty,children:n("scheduledTasks.loading")}),l&&a.jsx("div",{className:cn.loadError,children:l}),L&&a.jsx("div",{className:Ct.empty,children:n("scheduledTasks.deletedSnapshot")}),P&&a.jsx("div",{className:Ct.empty,children:n("scheduledTasks.sessionScopedSnapshot")}),!L&&a.jsx("div",{className:Ct.section,children:a.jsxs("div",{className:Ct.fieldGrid,children:[a.jsx("span",{className:Ct.fieldLabel,children:n("scheduledTasks.name")}),a.jsx("span",{className:Ct.fieldValue,children:$}),a.jsx("span",{className:Ct.fieldLabel,children:n("scheduledTasks.taskId")}),a.jsx("span",{className:Ct.fieldValue,children:e.id}),a.jsx("span",{className:Ct.fieldLabel,children:n("scheduledTasks.schedule")}),a.jsx("span",{className:Ct.fieldValue,children:xM(D,n)}),a.jsx("span",{className:Ct.fieldLabel,children:"Cron"}),a.jsx("span",{className:Ct.fieldValue,children:D}),a.jsx("span",{className:Ct.fieldLabel,children:n("scheduledTasks.type")}),a.jsx("span",{className:Ct.fieldValue,children:n(O?"scheduledTasks.repeats":"scheduledTasks.runsOnce")}),U!==void 0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:Ct.fieldLabel,children:n("scheduledTasks.status")}),a.jsx("span",{className:Ct.fieldValue,children:n(U?"scheduledTasks.enable":"scheduledTasks.disable")})]})]})}),!L&&a.jsxs("div",{className:Ct.section,children:[a.jsx("div",{className:Ct.sectionTitle,children:"Prompt"}),a.jsx("div",{className:Ct.description,children:B})]}),R&&a.jsx("div",{className:cn.formError,children:R}),a.jsxs("div",{className:Ct.actionsRow,children:[a.jsx("button",{type:"button",className:cn.primaryButton,disabled:!F||x,onClick:H,children:n("scheduledTasks.edit")}),a.jsx("button",{type:"button",className:cn.secondaryButton,disabled:!F||x,onClick:()=>void te(),children:s?.enabled?n("scheduledTasks.disable"):n("scheduledTasks.enable")}),a.jsx("button",{type:"button",className:cn.secondaryButton,disabled:!F||x,onClick:()=>b(!0),children:n("scheduledTasks.delete")})]}),w&&s&&a.jsx(Xa,{title:n("scheduledTasks.deleteConfirmTitle"),size:"sm",onClose:()=>b(!1),children:a.jsxs("div",{className:cn.formFields,children:[a.jsx("div",{className:Ct.description,children:n("scheduledTasks.deleteConfirm",{name:s.name||s.prompt})}),R&&a.jsx("div",{className:cn.formError,children:R}),a.jsxs("div",{className:cn.formActions,children:[a.jsx("button",{type:"button",className:cn.secondaryButton,onClick:()=>b(!1),disabled:x,children:n("scheduledTasks.cancel")}),a.jsx("button",{type:"button",className:cn.primaryButton,onClick:()=>void Z(),disabled:x,children:n("scheduledTasks.delete")})]})]})}),v&&a.jsx(Xa,{title:n("scheduledTasks.editTitle"),size:"md",onClose:Q,children:a.jsxs("div",{className:cn.formFields,children:[a.jsxs("label",{className:cn.field,children:[a.jsx("span",{className:cn.fieldLabel,children:n("scheduledTasks.name")}),a.jsx("input",{className:cn.input,type:"text",value:d,maxLength:200,placeholder:n("scheduledTasks.namePlaceholder"),onChange:W=>h(W.target.value)})]}),a.jsxs("label",{className:cn.field,children:[a.jsxs("span",{className:cn.fieldLabel,children:[n("scheduledTasks.prompt"),a.jsx("span",{className:cn.required,children:"*"})]}),a.jsx("textarea",{className:cn.textarea,value:f,rows:4,maxLength:1e5,placeholder:n("scheduledTasks.promptPlaceholder"),onChange:W=>p(W.target.value)})]}),a.jsxs("div",{className:cn.scheduleRow,children:[a.jsxs("label",{className:cn.field,children:[a.jsx("span",{className:cn.fieldLabel,children:n("scheduledTasks.frequency")}),a.jsx("select",{className:cn.select,value:m.frequency,onChange:W=>{const G=W.target.value;g(J=>({...J,frequency:G,...G==="hourly"?{time:"00:00"}:{}}))},children:DCs.map(W=>a.jsx("option",{value:W,children:n(`scheduledTasks.freq.${W}`)},W))})]}),(m.frequency==="daily"||m.frequency==="weekdays"||m.frequency==="weekly")&&a.jsxs("label",{className:cn.field,children:[a.jsx("span",{className:cn.fieldLabel,children:n("scheduledTasks.time")}),a.jsx("input",{className:cn.input,type:"time",value:m.time,onChange:W=>g(G=>({...G,time:W.target.value}))})]}),m.frequency==="weekly"&&a.jsxs("label",{className:cn.field,children:[a.jsx("span",{className:cn.fieldLabel,children:n("scheduledTasks.weekday")}),a.jsx("select",{className:cn.select,value:m.weekday,onChange:W=>g(G=>({...G,weekday:Number(W.target.value)})),children:n("scheduledTasks.weekdayNames").split(",").map((W,G)=>a.jsx("option",{value:G,children:W},G))})]}),m.frequency==="minutes"&&a.jsxs("label",{className:cn.field,children:[a.jsx("span",{className:cn.fieldLabel,children:n("scheduledTasks.interval")}),a.jsx("select",{className:cn.select,value:m.minuteInterval,onChange:W=>g(G=>({...G,minuteInterval:Number(W.target.value)})),children:LCs.map(W=>a.jsx("option",{value:W,children:W},W))})]}),m.frequency==="custom"&&a.jsxs("label",{className:`${cn.field} ${cn.fieldGrow}`,children:[a.jsx("span",{className:cn.fieldLabel,children:n("scheduledTasks.cron")}),a.jsx("input",{className:cn.input,type:"text",value:m.customCron,spellCheck:!1,placeholder:"0 9 * * 1-5",onChange:W=>g(G=>({...G,customCron:W.target.value}))})]})]}),a.jsx("div",{className:cn.preview,children:he?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:cn.previewLabel,children:he}),a.jsx("code",{className:cn.previewCron,children:ce})]}):a.jsx("span",{className:cn.previewInvalid,children:n("scheduledTasks.error.invalidSchedule")})}),R&&a.jsx("div",{className:cn.formError,children:R}),a.jsxs("div",{className:cn.formActions,children:[a.jsx("button",{type:"button",className:cn.secondaryButton,onClick:Q,disabled:_,children:n("scheduledTasks.cancel")}),a.jsx("button",{type:"button",className:cn.primaryButton,onClick:()=>void q(),disabled:_,children:n(_?"scheduledTasks.saving":"scheduledTasks.save")})]})]})})]})}function KCs({changes:e,selectedPath:t,workspaceCwd:n,onOpenFilePreview:s,onDownloadFile:r,onDownloadError:o}){const{t:i}=Xe(),[l,c]=u.useState(!1),[d,h]=u.useState(!0),[f,p]=u.useState(!1),[m,g]=u.useState(520),v=u.useRef(m),y=u.useRef(null),w=u.useRef(null),[b,x]=u.useState(null),[k,_]=u.useState(()=>new Set),S=u.useRef(!0);u.useEffect(()=>(S.current=!0,()=>{S.current=!1}),[]);const R=l,j=u.useMemo(()=>rTs(e,n),[e,n]);u.useEffect(()=>{x(t)},[t]),u.useEffect(()=>{v.current=m},[m]),u.useEffect(()=>{const A=y.current;if(!A)return;const M=()=>{p(A.clientWidth<PCs)};M();const P=new ResizeObserver(M);return P.observe(A),()=>P.disconnect()},[d]),u.useEffect(()=>()=>w.current?.(),[]);const E=u.useCallback(A=>{const M=y.current;if(!M)return;A.preventDefault();const P=A.currentTarget;P.setPointerCapture(A.pointerId);const L=A.clientX,F=v.current,$=M.getBoundingClientRect().width,B=Math.max(180,$-180),D=document.body.style.cursor,O=document.body.style.userSelect;let U=F,H=null;document.body.style.cursor="col-resize",document.body.style.userSelect="none";const Q=()=>{H=null,g(U)},q=ce=>{U=Math.min(B,Math.max(180,F+(ce.clientX-L))),H===null&&(H=window.requestAnimationFrame(Q))};let te=()=>{};const Z=ce=>{w.current=null,H!==null&&(window.cancelAnimationFrame(H),H=null),ce&&g(U),P.hasPointerCapture(A.pointerId)&&P.releasePointerCapture(A.pointerId),document.body.style.cursor=D,document.body.style.userSelect=O,window.removeEventListener("pointermove",q),window.removeEventListener("pointerup",te),window.removeEventListener("pointercancel",te)};te=()=>Z(!0),w.current=()=>Z(!1),window.addEventListener("pointermove",q),window.addEventListener("pointerup",te),window.addEventListener("pointercancel",te)},[]);if(e.length===0)return a.jsx("div",{className:Ct.empty,children:"No file changes to review."});const I=GZe(e),C=A=>{x(M=>M===A?null:A)},N=async A=>{if(!(!r||k.has(A.path))){_(M=>new Set(M).add(A.path));try{await r(A,()=>!S.current)}catch(M){S.current&&o(M)}finally{_(M=>{const P=new Set(M);return P.delete(A.path),P})}}};return a.jsxs("div",{className:Ct.review,children:[a.jsxs("div",{className:Ct.reviewToolbar,children:[a.jsxs("div",{className:Ct.reviewToolbarTitle,children:[a.jsx("span",{children:i("turnOutputs.previousTurn")}),a.jsx(SV,{additions:I?.additions,deletions:I?.deletions,className:Ct.lineStats,additionsClassName:Ct.additions,deletionsClassName:Ct.deletions})]}),a.jsxs("div",{className:Ct.reviewToolbarActions,children:[a.jsxs("button",{type:"button",className:Ct.reviewTotalsButton,onClick:()=>h(A=>!A),"aria-expanded":d,children:[a.jsx("span",{children:i("turnOutputs.fileCount",{count:e.length})}),a.jsx("span",{className:[Ct.chevron,d?Ct.chevronOpen:""].filter(Boolean).join(" "),"aria-hidden":"true",children:a.jsx(MDe,{})})]}),a.jsx("button",{type:"button",className:[Ct.iconButton,l?Ct.iconButtonActive:""].filter(Boolean).join(" "),onClick:()=>c(A=>!A),"aria-label":i(l?"turnOutputs.closeFileTree":"turnOutputs.openFileTree"),title:i(l?"turnOutputs.closeFileTree":"turnOutputs.openFileTree"),children:l?a.jsx(nTs,{}):a.jsx(tTs,{})})]})]}),d&&a.jsxs("div",{ref:y,className:[Ct.reviewContent,R?"":Ct.reviewContentListOnly,R&&f?Ct.reviewContentStacked:""].filter(Boolean).join(" "),style:{"--review-list-width":`${m}px`},children:[a.jsx("div",{className:[Ct.reviewList,b?Ct.reviewListWithExpanded:""].filter(Boolean).join(" "),children:e.map(A=>{const M=b===A.path,P=s&&XZe(A.path),L=r&&Lkn(A.path);return a.jsxs("div",{className:[Ct.reviewItem,M?Ct.reviewItemExpanded:""].filter(Boolean).join(" "),children:[a.jsxs("div",{className:Ct.reviewRow,"data-selected":A.path===t||void 0,children:[a.jsx("button",{type:"button",className:Ct.reviewRowToggle,onClick:()=>C(A.path),"aria-label":A.path,"aria-expanded":M}),a.jsx("span",{className:Ct.fileIcon,children:Bdt(A.path)}),a.jsxs("span",{className:Ct.reviewFileName,children:[a.jsx(QCs,{path:CJ(A.path,n),title:A.path}),P&&a.jsx("button",{type:"button",className:Ct.reviewOpenButton,onClick:()=>s?.(A),title:`${i("turnOutputs.preview")} ${A.path}`,children:i("turnOutputs.preview")}),L&&a.jsx("button",{type:"button",className:Ct.reviewOpenButton,onClick:()=>void N(A),title:`${i("common.download")} ${A.path}`,disabled:k.has(A.path),children:i(k.has(A.path)?"common.downloading":"common.download")})]}),a.jsx(SV,{additions:A.additions,deletions:A.deletions,className:Ct.lineStats,additionsClassName:Ct.additions,deletionsClassName:Ct.deletions}),a.jsx("span",{className:[Ct.chevron,M?Ct.chevronOpen:""].filter(Boolean).join(" "),"aria-hidden":"true",children:a.jsx(MDe,{})})]}),M&&a.jsx(YCs,{change:A})]},`${A.toolCallId}:${A.path}`)})}),R&&!f&&a.jsx("div",{className:Ct.reviewSplitHandle,role:"separator","aria-orientation":"vertical",onPointerDown:E}),R&&a.jsx("div",{className:Ct.tree,children:j.children.map(A=>a.jsx(Ddt,{node:A,depth:0,selectedPath:t},A.path))})]})]})}function YCs({change:e}){if(e.diffs.length===0)return a.jsx("div",{className:Ct.diffEmpty,children:"No diff available."});const t=JCs(e.diffs);return a.jsx("div",{className:Ct.diffPreview,children:t.map((n,s)=>n.fileDiff&&!n.fullContent?a.jsx(z9,{diff:n.fileDiff},s):a.jsx(XCs,{oldText:n.oldText,newText:n.newText},s))})}function JCs(e){for(let t=e.length-1;t>=0;t--)if(e[t]?.fullContent)return e.slice(t);return e}function XCs({oldText:e,newText:t}){const n=u.useRef(null),[s,r]=u.useState(null),[o,i]=u.useState(null);return u.useEffect(()=>{const l=n.current;if(!l)return;const c=()=>r(l.clientWidth>=720);c();const d=new ResizeObserver(c);return d.observe(l),()=>d.disconnect()},[]),u.useEffect(()=>{const l=n.current;if(!l||s===null)return;l.replaceChildren(),i(null);let c=!1,d=null;const h=[mst,lr.editable.of(!1),_l.readOnly.of(!0),lr.lineWrapping],f={scanLimit:1e3,timeout:500},p={margin:3,minSize:8};return xt(async()=>{const{MergeView:m,unifiedMergeView:g}=await import("./index-Dbm3-Fps.js");return{MergeView:m,unifiedMergeView:g}},[]).then(({MergeView:m,unifiedMergeView:g})=>{if(!c)try{if(s){d=new m({a:{doc:e,extensions:h},b:{doc:t,extensions:h},parent:l,highlightChanges:!0,gutter:!0,revertControls:void 0,collapseUnchanged:p,diffConfig:f});return}d=new lr({doc:t,extensions:[...h,g({original:e,highlightChanges:!0,gutter:!0,mergeControls:!1,allowInlineDiffs:!0,collapseUnchanged:p,diffConfig:f})],parent:l})}catch(v){c||i(v instanceof Error?v.message:String(v))}}).catch(m=>{c||i(m instanceof Error?m.message:String(m))}),()=>{c=!0,d?.destroy()}},[s,t,e]),a.jsxs("div",{className:Ct.codeMirrorDiffWrap,children:[a.jsx("div",{ref:n,className:Ct.codeMirrorDiff}),o&&a.jsxs("div",{className:Ct.diffError,children:["Diff unavailable: ",o]})]})}function Ddt({node:e,depth:t,selectedPath:n}){const s=!!e.file,[r,o]=u.useState(!0),i=[Ct.treeRow,s?Ct.treeFile:Ct.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`},d=a.jsxs(a.Fragment,{children:[a.jsx("span",{className:Ct.treeTwisty,children:!s&&a.jsx("span",{className:[Ct.treeChevron,r?"":Ct.treeChevronClosed].filter(Boolean).join(" "),children:a.jsx(sTs,{})})}),a.jsxs("span",{className:Ct.treeContent,children:[s&&a.jsx("span",{className:Ct.fileIcon,children:Bdt(e.path)}),a.jsx("span",{className:Ct.treeName,children:e.name})]}),e.file?.isArtifact&&a.jsx("span",{className:Ct.reviewBadge,children:"artifact"})]});return a.jsxs("div",{className:Ct.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:d}):a.jsx("button",{type:"button",className:i,"data-depth":t,style:l,title:e.path,"aria-expanded":r,onClick:()=>o(h=>!h),children:d}),!s&&r&&e.children.length>0&&a.jsx("div",{className:Ct.treeChildren,style:c,children:e.children.map(h=>a.jsx(Ddt,{node:h,depth:t+1,selectedPath:n},h.path))})]})}function QCs({path:e,title:t}){const n=u.useRef(null),[s,r]=u.useState(()=>Ldt(e));return u.useLayoutEffect(()=>{const o=n.current;if(!o)return;const i=()=>r(ZCs(e,o));i();const l=new ResizeObserver(i);return l.observe(o),()=>l.disconnect()},[e]),a.jsxs("span",{ref:n,className:Ct.reviewPath,title:t??e,children:[s.prefix&&a.jsx("span",{className:Ct.pathPrefix,children:s.prefix}),a.jsx("span",{className:Ct.pathFileName,children:s.leaf})]})}function Ldt(e){const t=e.lastIndexOf("/");return t<0?{prefix:"",leaf:e}:{prefix:e.slice(0,t+1),leaf:e.slice(t+1)}}let NDe=null;function ZCs(e,t){const n=Ldt(e),s=t.clientWidth;if(s<=0)return n;const r=eTs(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 d=1;d<o.length;d++){const f=`.../${o.slice(o.length-1-d,-1).join("/")}/`;if(r(f)+l>s)break;c=f}return{prefix:c,leaf:i}}function eTs(e){NDe??=document.createElement("canvas");const t=NDe.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 tTs(){return a.jsxs("svg",{className:Ct.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 nTs(){return a.jsxs("svg",{className:Ct.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 MDe(){return a.jsx("svg",{className:Ct.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 sTs(){return a.jsx("svg",{className:Ct.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 rTs(e,t){const n={name:"",path:"",children:[]};for(const s of e){const r=CJ(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 d=o.children.find(h=>h.name===l);d||(d={name:l,path:c,children:[]},o.children.push(d)),i===r.length-1&&(d.file=s),o=d}}return Odt(n),n}function Odt(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)Odt(t)}function z4(e){return QT(e).split("/").filter(Boolean).at(-1)??e}function Bdt(e){const t=z4(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 oTs({artifact:e,sourceSessionId:t,workspaceActions:n,previewContent:s}){const{t:r}=Xe(),o=Dm(),i=xQt(e),l=A2(e.url)?e.url:void 0,c=e.metadata?.artifactType==="automation_snapshot",d=e.metadata?.artifactType==="code_review",h=e.storage==="workspace"&&!!e.workspacePath,f=cve(e);return e.metadata?.artifactType==="web_preview_snapshot"?a.jsx(zbs,{artifact:e,sourceSessionId:t}):d?e.status!=="available"?a.jsx(iTs,{status:e.status}):!h||!e.workspacePath?a.jsx(aTs,{}):a.jsx(n0s,{workspacePath:e.workspacePath,artifactVersion:jAe(e),workspaceActions:n}):h&&e.workspacePath?jJe(e)||(P9(e.workspacePath,e.mimeType)||M9(e.workspacePath,e.mimeType)||JT(e))&&e.status!=="available"&&e.status!=="changed"?a.jsx($dt,{artifact:e,workspaceActions:n}):a.jsx(S7,{workspacePath:e.workspacePath,artifactVersion:jAe(e),workspaceActions:n,previewContent:s,previewSizeBytes:e.sizeBytes,previewMimeType:JT(e)?"application/pdf":e.mimeType,imageMimeType:f,previewKind:lTs(e)?"html":cTs(e)?"markdown":f?"image":"source"}):a.jsxs("div",{className:Ct.detail,children:[a.jsxs("div",{className:Ct.section,children:[a.jsx("div",{className:Ct.sectionTitle,children:c?"Automation Snapshot":"Artifact"}),a.jsxs("div",{className:Ct.fieldGrid,children:[a.jsx(Zg,{label:"Type",value:ive(e.kind,e.workspacePath)}),a.jsx(Zg,{label:"Storage",value:e.storage}),a.jsx(Zg,{label:"Status",value:e.status}),a.jsx(Zg,{label:"Source",value:e.source}),a.jsx(Zg,{label:"Size",value:uJ(e.sizeBytes)}),a.jsx(Zg,{label:"Created",value:e.createdAt}),a.jsx(Zg,{label:"Updated",value:e.updatedAt}),e.toolName&&a.jsx(Zg,{label:"Tool",value:e.toolName}),e.toolCallId&&a.jsx(Zg,{label:"Tool call",value:e.toolCallId})]})]}),e.description&&a.jsxs("div",{className:Ct.section,children:[a.jsx("div",{className:Ct.sectionTitle,children:"Description"}),a.jsx("div",{className:Ct.description,children:e.description})]}),c&&e.metadata&&a.jsxs("div",{className:Ct.section,children:[a.jsx("div",{className:Ct.sectionTitle,children:"Details"}),a.jsxs("div",{className:Ct.fieldGrid,children:[Yj(e.metadata,"automationId","Automation ID"),Yj(e.metadata,"schedule","Schedule"),Yj(e.metadata,"timezone","Timezone"),Yj(e.metadata,"status","Status"),Yj(e.metadata,"nextRunAt","Next run"),Yj(e.metadata,"prompt","Prompt")]})]}),(i||l)&&a.jsxs("div",{className:Ct.section,children:[a.jsx("div",{className:Ct.sectionTitle,children:"Location"}),l?a.jsxs("div",{className:Ct.locationRow,children:[a.jsx("a",{className:Ct.link,href:l,target:"_blank",rel:"noopener noreferrer",onClick:p=>o(p,l),children:l}),a.jsx("a",{className:Ct.openButton,href:l,target:"_blank",rel:"noopener noreferrer",onClick:p=>o(p,l),children:r("artifact.openLink")})]}):a.jsx("div",{className:Ct.meta,children:i})]})]})}function iTs({status:e}){const{t}=Xe();return a.jsx("div",{className:Ct.previewError,role:"alert",children:t("codeReview.unavailable",{status:e})})}function aTs(){const{t:e}=Xe();return a.jsx("div",{className:Ct.previewError,role:"alert",children:e("codeReview.workspaceRequired")})}function lTs(e){const t=e.workspacePath?.toLowerCase()??"",n=xy(e.mimeType);return e.kind==="html"||t.endsWith(".html")||t.endsWith(".htm")||n==="text/html"}function cTs(e){const t=e.workspacePath?.toLowerCase()??"",n=xy(e.mimeType);return t.endsWith(".md")||t.endsWith(".markdown")||n==="text/markdown"}function $dt({artifact:e,workspaceActions:t}){const{t:n}=Xe(),[s,r]=u.useState(null),[o,i]=u.useState(!1),l=u.useRef(!0),c=e.workspacePath;u.useEffect(()=>(l.current=!0,()=>{l.current=!1}),[]);const d=async()=>{if(e.workspacePath){i(!0),r(null);try{await L9(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:Ct.detail,children:a.jsxs("div",{className:Ct.section,children:[a.jsx("div",{className:Ct.sectionTitle,children:n("common.download")}),a.jsxs("div",{className:Ct.fieldGrid,children:[a.jsx(Zg,{label:"Type",value:ive(e.kind,e.workspacePath)}),a.jsx(Zg,{label:"Size",value:uJ(e.sizeBytes)}),c?a.jsx(Zg,{label:"Location",value:c}):null,e.status!=="available"&&e.status!=="changed"?a.jsx(Zg,{label:"Status",value:e.status??"missing"}):null]}),a.jsx("div",{className:Ct.downloadRow,children:a.jsx("button",{type:"button",className:Ct.downloadButton,onClick:()=>{d()},disabled:o||e.status!=="available"&&e.status!=="changed",children:n(o?"common.downloading":"common.download")})}),s&&a.jsx("div",{className:Ct.previewError,children:s})]})})}function dTs({tab:e}){const{t}=Xe(),n=Da(),s=dA(e.workspaceCwd),r=s?.actions,o=Dm(),[i,l]=u.useState(0),[c,d]=u.useState(),[h,f]=u.useState(),[p,m]=u.useState(),g=e.source,v=g.locator,y=e.owner.isCurrent()&&n.sessionId===e.sourceSessionId&&n.capabilities?.features.includes("session_sources")&&s?.workspaceId===e.workspaceId&&(!!s||e.workspaceCwd===void 0&&v.type!=="workspace_file")&&(v.type!=="workspace_file"||g.workspaceCwd===n.workspaceCwd),w=v.type==="workspace_file"?v.workspacePath:v.type==="attachment"?v.attachmentId:"",b=JT({workspacePath:w});if(u.useEffect(()=>{let k=!1;return d(void 0),f(void 0),m(void 0),!y||v.type==="url"?void 0:((async()=>{if(v.type==="attachment"){const S=await e.sessionActions.readAttachment(v.attachmentId);if(k||!e.owner.isCurrent())return;const R=Uint8Array.from(atob(S.data),j=>j.charCodeAt(0));d(new Blob([R],{type:S.mimeType}))}else if(b&&r){const S=await j2(r.readFileBytes,w,"application/pdf",{statFile:r.stat,isCancelled:()=>k||!e.owner.isCurrent()});!k&&e.owner.isCurrent()&&d(S)}})().catch(S=>{!k&&e.owner.isCurrent()&&f(Wa(S))}),()=>{k=!0})},[i,y,v,w,b,e.owner,e.sessionActions,r]),y&&v.type==="url")return a.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[a.jsx("h3",{children:g.title}),g.description&&a.jsx("p",{children:g.description}),a.jsx("p",{className:"break-all text-sm text-muted-foreground",children:v.url}),A2(v.url)&&a.jsx("a",{className:"text-primary underline",href:v.url,target:"_blank",rel:"noopener noreferrer",onClick:k=>o(k,v.url),children:t("sources.openOriginal")})]});if(!y||!s&&v.type!=="attachment")return a.jsx("div",{className:Ct.empty,role:"alert",children:t("sources.unavailable")});const x=v.type==="workspace_file"&&!b&&jJe({workspacePath:w});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:w,children:w}),a.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[p&&a.jsx(Ne,{variant:"ghost",size:"icon-sm",asChild:!0,children:a.jsx("a",{href:p,download:g.title,"aria-label":`Download ${g.title}`,title:t("common.download"),children:a.jsx(oy,{})})}),h&&a.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>l(k=>k+1),children:t("common.retry")})]})]}),h?a.jsx("div",{className:Ct.previewError,role:"alert",children:h}):x?a.jsxs("div",{className:"p-4",children:[a.jsx("p",{children:t("attachment.previewUnsupported")}),a.jsx(Ne,{onClick:()=>void L9(r,w,"application/octet-stream",()=>!e.owner.isCurrent()).catch(k=>{e.owner.isCurrent()&&f(Wa(k))}),children:t("common.download")})]}):(v.type==="attachment"||b)&&!c?a.jsx("div",{className:Ct.empty,role:"status",children:t("common.loading")}):c&&!P9(w,c.type)&&!M9(w,c.type)&&!JT({workspacePath:w,mimeType:c.type})&&!FM(c.type,w)?a.jsx(pxe,{data:c,title:g.title,onDownloadUrl:m,showDownload:!1,image:!!XT(w)&&c.type.startsWith("image/")}):a.jsx("div",{className:"relative min-h-0 flex-1 overflow-auto",children:a.jsx(S7,{workspacePath:w,workspaceActions:r,onLoadError:f,previewData:c,previewOnly:v.type==="attachment",downloadName:v.type==="attachment"?g.title:void 0,previewMimeType:c?.type,previewKind:/\.html?$/i.test(w)||xy(c?.type)==="text/html"?"source":void 0},i)})]})}function pxe({data:e,title:t,image:n,onDownloadUrl:s,showDownload:r=!0}){const[o,i]=u.useState();return u.useEffect(()=>{const l=URL.createObjectURL(e);return i(l),s?.(l),()=>URL.revokeObjectURL(l)},[e,s]),o?a.jsxs("div",{className:Ct.imagePreviewWrap,children:[n?a.jsx("img",{className:Ct.imagePreview,src:o,alt:t}):a.jsx(zdt,{name:t,mimeType:e.type,size:e.size}),r&&a.jsx("a",{href:o,download:t,"aria-label":`Download ${t}`,children:a.jsx(oy,{})})]}):null}function S7({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewSizeBytes:r,previewData:o,previewMimeType:i,imageMimeType:l,previewKind:c,previewOnly:d,onLoadError:h,sourceRenderer:f,downloadName:p}){const{t:m}=Xe();if(P9(e,i||o?.type))return a.jsx(o0s,{workspacePath:e,workspaceActions:n,data:o,artifactVersion:t,downloadName:p});if(M9(e,i||o?.type))return a.jsx(Rm,{resetKeys:[e,n,o,t],fallback:a.jsxs("div",{children:[a.jsx("div",{role:"alert",className:Ct.previewError,children:m("excel.invalid")}),o?a.jsx(pxe,{data:o,title:e.split(/[/\\]/).pop(),image:!1}):n?a.jsx($dt,{artifact:{workspacePath:e,kind:"document",mimeType:i,status:"available"},workspaceActions:n},e):null]}),children:a.jsx(u.Suspense,{fallback:a.jsx("div",{className:Ct.empty,role:"status",children:m("common.loading")}),children:a.jsx(MCs,{workspacePath:e,workspaceActions:n,data:o,artifactVersion:t})})});if(o)return a.jsx(uTs,{workspacePath:e,workspaceActions:n,data:o,mimeType:i,previewKind:c,onLoadError:h});if(JT({workspacePath:e,mimeType:i}))return a.jsx(fTs,{workspacePath:e,artifactVersion:t,workspaceActions:n,onLoadError:h});const g=e.toLowerCase(),v=l??XT(e),y=c??(g.endsWith(".html")||g.endsWith(".htm")?"html":g.endsWith(".md")||g.endsWith(".markdown")?"markdown":v?"image":"source");return y==="html"?a.jsx(mTs,{workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewSizeBytes:r,previewOnly:d,onLoadError:h}):y==="markdown"?a.jsx(vTs,{workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewSizeBytes:r,previewOnly:d,onLoadError:h}):y==="image"&&v?a.jsx(pTs,{workspacePath:e,artifactVersion:t,workspaceActions:n,mimeType:v,onLoadError:h}):a.jsx(Udt,{sourceRenderer:f,workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:d,onLoadError:h})}function uTs({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 JT({workspacePath:e,mimeType:i})?a.jsx(Fdt,{data:n,mimeType:"application/pdf",title:e}):FM(i,e)?a.jsx(hTs,{workspacePath:e,workspaceActions:t,data:n,previewKind:r,onLoadError:o}):a.jsx(zdt,{name:e,mimeType:i,size:n.size})}function hTs({workspacePath:e,workspaceActions:t,data:n,previewKind:s,onLoadError:r}){const{t:o}=Xe(),[i,l]=u.useState(),[c,d]=u.useState();return u.useEffect(()=>{const h=new FileReader;return l(void 0),d(void 0),h.onload=()=>l(String(h.result??"")),h.onerror=()=>{const f=o("attachment.readFailed");d(f),r?.(f)},h.readAsText(n),()=>{h.readyState===FileReader.LOADING&&h.abort()}},[n,r,o]),c?a.jsx("div",{className:Ct.previewError,children:c}):i===void 0?a.jsx("div",{className:Ct.empty,children:o("attachment.loadingFile")}):a.jsx(S7,{workspacePath:e,workspaceActions:t,previewContent:i,previewSizeBytes:n.size,previewOnly:!0,previewKind:s})}function fTs({workspacePath:e,artifactVersion:t,workspaceActions:n,onLoadError:s}){const{t:r}=Xe(),[o,i]=u.useState(),[l,c]=u.useState(),[d,h]=u.useState(0);return u.useEffect(()=>{let f=!1;return i(void 0),c(void 0),j2(n.readFileBytes,e,"application/pdf",{statFile:n.stat,isCancelled:()=>f}).then(p=>{f||i(p)},p=>{if(f)return;const m=Wa(p);c(m),s?.(m)}),()=>{f=!0}},[e,n,t,d,s]),l?a.jsxs("div",{className:Ct.empty,children:[a.jsx("div",{role:"alert",className:Ct.previewError,children:l}),a.jsx(Ne,{onClick:()=>h(f=>f+1),children:r("common.retry")})]}):o?a.jsx(Fdt,{data:o,mimeType:"application/pdf",title:e}):a.jsx("div",{className:Ct.empty,role:"status",children:r("attachment.loadingPreview")})}function Fdt({data:e,mimeType:t,title:n}){const{t:s}=Xe(),[r,o]=u.useState();return u.useEffect(()=>{const i=URL.createObjectURL(e.type===t?e:new Blob([e],{type:t}));return o(i),()=>URL.revokeObjectURL(i)},[e,t]),r?a.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[a.jsx("div",{className:"flex justify-end border-b border-border p-1",children:a.jsx(Ne,{variant:"ghost",size:"sm",asChild:!0,children:a.jsxs("a",{href:r,download:z4(n),"aria-label":`Download ${z4(n)}`,children:[a.jsx(oy,{"aria-hidden":"true"}),s("common.download")]})})}),navigator.pdfViewerEnabled===!1?a.jsx("div",{className:Ct.empty,children:s("attachment.previewUnsupported")}):a.jsx("iframe",{className:`${Ct.pdfAttachmentPreview} min-h-0 flex-1`,src:r,title:`Preview ${n}`})]}):a.jsx("div",{className:Ct.empty,children:s("attachment.loadingPreview")})}function zdt({name:e,mimeType:t,size:n}){const{t:s}=Xe();return a.jsxs("div",{className:Ct.unsupportedAttachmentPreview,children:[a.jsx(Tb,{name:e,mimeType:t,"aria-hidden":"true"}),a.jsx("div",{children:s("attachment.previewUnsupported")}),a.jsxs("div",{className:Ct.unsupportedAttachmentMeta,children:[t," · ",uJ(n)]})]})}function pTs({workspacePath:e,artifactVersion:t,workspaceActions:n,mimeType:s,onLoadError:r}){const[o,i]=u.useState(null),[l,c]=u.useState(null);return u.useEffect(()=>{let d=!1,h;return i(null),c(null),j2((f,p)=>n.readFileBytes(f,p),e,s,{statFile:f=>n.stat(f),isCancelled:()=>d}).then(f=>{d||(h=URL.createObjectURL(f),i(h))}).catch(f=>{if(d)return;const p=f instanceof Error?f.message:String(f);c(p),r?.(p)}),()=>{d=!0,h&&URL.revokeObjectURL(h)}},[t,s,r,n,e]),a.jsxs("div",{className:Ct.imagePreviewWrap,children:[o?a.jsxs(a.Fragment,{children:[a.jsx("img",{className:Ct.imagePreview,src:o,alt:z4(e)}),a.jsx("a",{className:Ct.imageDownloadButton,href:o,download:z4(e),"aria-label":`Download ${z4(e)}`,title:"Download",children:a.jsx(oy,{size:16,strokeWidth:1.8})})]}):l?null:a.jsx("div",{className:Ct.empty,children:"Loading image..."}),l&&a.jsx("div",{className:Ct.previewError,children:l})]})}function mxe({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:r,onLoadError:o,maxPreviewBytes:i}){const{t:l}=Xe(),[c,d]=u.useState(s??null),[h,f]=u.useState(),[p,m]=u.useState(null);return u.useEffect(()=>{let g=!1;if(d(s??null),m(null),f(void 0),!r)return n.stat(e).then(v=>{if(!g){if(v.type==="directory")throw new Error("Directories cannot be opened as artifacts.");if(i!==void 0&&v.sizeBytes>i)throw new Error(l("files.sourceTooLarge"));return n.readWorkspaceFile(e,{maxBytes:256*1024})}}).then(async v=>{if(g||!v||!v.truncated)return v;const y=await j2((w,b)=>n.readFileBytes(w,b),e,"application/octet-stream",{statFile:w=>n.stat(w),isCancelled:()=>g,maxBytes:i});return{sizeBytes:y.size,content:new TextDecoder(v.encoding||"utf-8").decode(await y.arrayBuffer())}}).then(v=>{g||!v||(f(v.sizeBytes),d(v.content))}).catch(v=>{if(g)return;const y=v instanceof Error?v.message:String(v);m(y),o?.(y)}),()=>{g=!0}},[t,s,r,o,n,e,i,l]),{content:c,error:p,sizeBytes:h}}function mTs({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewSizeBytes:r,previewOnly:o,onLoadError:i}){const{content:l,error:c,sizeBytes:d}=mxe({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:o,onLoadError:i});return a.jsxs("div",{className:Ct.htmlPreviewWrap,children:[l===null?!c&&a.jsx("div",{className:Ct.empty,children:"Loading preview..."}):a.jsx(Wdt,{content:l,sizeBytes:d??r,workspacePath:e,workspaceActions:n,children:()=>a.jsx(gTs,{content:l,workspacePath:e})}),c&&a.jsx("div",{className:Ct.previewError,children:c})]})}function gTs({content:e,workspacePath:t}){const n=`Preview ${t}`,{t:s}=Xe(),[r,o]=u.useState(null),[i,l]=u.useState(null);return u.useEffect(()=>{const c=new AbortController;return o(null),l(null),kQt(e,n,c.signal).then(d=>{c.signal.aborted||o(d)},d=>{c.signal.aborted||l(Wa(d))}),()=>c.abort()},[e,n]),i?a.jsx("div",{className:Ct.previewError,children:s("artifact.previewFailed",{message:i})}):r===null?a.jsx("div",{className:Ct.empty,children:s("attachment.loadingPreview")}):a.jsx("iframe",{className:Ct.htmlPreview,referrerPolicy:"no-referrer",sandbox:"allow-scripts",srcDoc:r,title:n})}function Udt({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:r,onLoadError:o,sourceRenderer:i}){const l=u.useRef(null),[c,d]=u.useState(null),{content:h,error:f}=mxe({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:r,onLoadError:o,maxPreviewBytes:i?4*1024*1024:void 0});return u.useEffect(()=>{const p=l.current;if(!p||h===null)return;p.replaceChildren(),d(null);let m;try{m=new lr({doc:h,extensions:[mst,lr.editable.of(!1),_l.readOnly.of(!0),lr.lineWrapping],parent:p})}catch(g){d(g instanceof Error?g.message:String(g));return}return()=>m.destroy()},[h,i]),a.jsxs("div",{className:Ct.filePreviewWrap,children:[h===null?!f&&a.jsx("div",{className:Ct.empty,children:"Loading file..."}):i?a.jsx("div",{className:Ct.codeMirrorFile,children:i(h)}):a.jsx("div",{ref:l,className:Ct.codeMirrorFile}),(f||c)&&a.jsx("div",{className:Ct.previewError,children:f||c})]})}function Wdt({content:e,sizeBytes:t,workspacePath:n,workspaceActions:s,children:r}){const{t:o}=Xe(),[i,l]=u.useState(null);if(!u.useMemo(()=>(t??new TextEncoder().encode(e).byteLength)>1024*1024,[e,t]))return r();const d=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(Ne,{className:"ml-auto shrink-0",variant:"outline",size:"sm",onClick:()=>l(d?null:e),children:o(d?"artifact.showSource":"artifact.renderFullPreview")})]}),a.jsx("div",{className:"relative min-h-0 flex-1 overflow-auto",children:d?r():a.jsx(Udt,{workspacePath:n,workspaceActions:s,previewContent:e,previewOnly:!0})})]})}function vTs({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewSizeBytes:r,previewOnly:o,onLoadError:i}){const{content:l,error:c,sizeBytes:d}=mxe({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:o,onLoadError:i});return a.jsxs("div",{className:Ct.htmlPreviewWrap,children:[l===null?!c&&a.jsx("div",{className:Ct.empty,children:"Loading preview..."}):a.jsx(Wdt,{content:l,sizeBytes:d??r,workspacePath:e,workspaceActions:n,children:()=>a.jsx("div",{className:Ct.markdownPreviewWrap,children:a.jsx(dp,{content:l})})}),c&&a.jsx("div",{className:Ct.previewError,children:c})]})}function Zg({label:e,value:t}){return t?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:Ct.fieldLabel,children:e}),a.jsx("span",{className:Ct.fieldValue,children:t})]}):null}function Yj(e,t,n){const s=e[t];return s==null||s===""?null:a.jsx(Zg,{label:n,value:String(s)},t)}/**
2983
+ `);return n===-1?t:t.slice(0,n)}function yCs(e,t){if(e.kind==="request"){const n=[na(e.timing.durationMs)];return e.timing.ttftMs!==void 0&&n.push(t("trajectory.ttft",{duration:na(e.timing.ttftMs)})),e.usage&&n.push(gCs(e.usage)),n}if(e.kind==="tool"){const n=[];if(e.timing&&n.push(na(e.timing.durationMs)),e.subagentSummary){const{requests:s,tools:r,requestMs:o}=e.subagentSummary;n.push(t("trajectory.subagentRollup",{requests:s,tools:r,duration:na(o)}))}return n}return[]}function $oe(e){const t=e.toolStatus??e.block.status;if(t==="error"||t==="failed")return Po.toneError;if(t==="cancelled"||t==="canceled")return Po.toneMuted}function Rfe(e,t){switch(e.kind){case"user":return{badge:t("trajectory.badge.user"),text:vE(e.block.text)};case"request":{const n=wCs(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:Po.toneError}:{},text:s?`${r} · ${t("trajectory.requestFailed")}`:r}}case"message":return{badge:e.thought?t("trajectory.badge.thought"):t("trajectory.badge.message"),text:vE(e.block.text),faint:e.thought};case"tool":return{badge:e.block.toolName??t("trajectory.badge.tool"),...$oe(e)?{badgeTone:$oe(e)}:{},text:`${e.block.title||(e.block.toolName??"")}${$oe(e)===Po.toneError?` · ${t("trajectory.toolFailed")}`:""}`};default:return bCs(e.block,t)}}function bCs(e,t){switch(e.kind){case"shell":return{badge:t("trajectory.badge.shell"),text:vE(e.text)};case"user_shell":return{badge:t("trajectory.badge.shell"),text:vE(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:Po.toneError}:{},text:vE(e.text),faint:e.kind!=="error"};case"prompt_cancelled":return{badge:t("trajectory.badge.cancelled"),badgeTone:Po.toneMuted,text:e.reason??t("trajectory.cancelled"),faint:!0};default:return{badge:t("trajectory.badge.other"),text:""}}}function xCs(e){return e.rows.some(t=>t.kind==="request"||t.kind==="tool"&&t.timing!==void 0)}function kCs({loadPage:e,historyGapRevision:t=0}){const{t:n,language:s}=Xe(),r=u.useRef(null),[o,i]=u.useState(!1);u.useLayoutEffect(()=>{const bt=r.current;if(!bt)return;const be=()=>i(bt.clientWidth>=mCs);if(be(),typeof ResizeObserver>"u")return;const It=new ResizeObserver(be);return It.observe(bt),()=>It.disconnect()},[]);const l=u.useRef(e);u.useLayoutEffect(()=>{l.current=e},[e]);const c=u.useCallback(()=>{if(l.current!==e)return;const bt=r.current?.querySelector('[data-testid="trajectory-executions"]');(bt?.querySelector('[role="grid"]')??bt?.querySelector("button")??se.current)?.focus({preventScroll:!0})},[e]),{trajectory:d,lifecycle:h,status:f,error:p,loadedPages:m,windowPages:g,truncated:v,olderFailure:y,refresh:w,retry:b,older:x,newer:k,mode:_,navigationVersion:S,navigationError:R,loadingKind:j,canRefresh:E,canOlder:I,canNewer:C,historyReleased:N}=cks(e),[A,M]=u.useState({loader:e,paused:!1});A.loader!==e&&M({loader:e,paused:!1});const P=u.useCallback(()=>{M(bt=>bt.loader!==e||bt.paused&&!bt.pending?bt:{loader:e,paused:!0})},[e]),L=u.useRef({loader:e,status:h.status});u.useLayoutEffect(()=>{const bt=L.current;L.current={loader:e,status:h.status},bt.loader===e&&bt.status==="live"&&h.status!=="live"&&P()},[e,h.status,P]);const F=A.loader===e&&!A.paused&&_==="latest",$=A.loader===e&&!!A.pending,[B,D]=u.useState({loader:e,revision:0}),O=u.useRef(void 0),U=u.useCallback(()=>{O.current={revision:t,trajectory:d},w()},[t,d,w]),H=u.useCallback(()=>{E&&(M({loader:e,paused:!0,pending:{of:d}}),U())},[E,e,d,U]);u.useEffect(()=>{O.current=void 0},[e]),u.useEffect(()=>{const bt=O.current;bt&&f!=="loading"&&p?O.current=void 0:bt&&f==="ready"&&d!==bt.trajectory&&(D({loader:e,revision:bt.revision}),O.current=void 0)},[f,d,p,e]);const Q=t>(B.loader===e?B.revision:0),q=u.useRef(!1),[te,Z]=u.useState({loader:e,version:S,selectionLost:!1}),[ce,he]=u.useState(!1),[W,G]=u.useState(!1),[J,X]=u.useState({loader:e,value:i6,scope:0});J.loader!==e&&X({loader:e,value:i6,scope:J.scope+1});const de=J.loader===e?J.value:i6,ae=u.useCallback(bt=>{P(),X(be=>be.loader===e&&be.value.query===bt.query&&be.value.type===bt.type&&be.value.status===bt.status?be:{loader:e,value:bt,scope:be.scope})},[e,P]),ne=u.useCallback(()=>ae(i6),[ae]),pe=EDe(de),Re=u.useMemo(()=>d?pCs(d):void 0,[d]),ke=u.useMemo(()=>Re?RDe(Re,de):[],[Re,de]),Te=u.useMemo(()=>new Set(ke),[ke]),[Fe,Se]=u.useState(void 0),[Le,ge]=u.useState(),fe=u.useMemo(()=>G_s(h,Alt(e)),[h,e]),[we,Ae]=u.useState(),Be=we?.loader===e?fe.rows.find(bt=>bt.key===we?.key):void 0,[ve,Y]=u.useState(!1);u.useEffect(()=>{we&&!Be&&Ae(void 0)},[we,Be]),u.useEffect(()=>{Y(!1),ge(void 0),Ae(void 0)},[e]),u.useEffect(()=>{Le?.of&&d&&Le.of!==d&&ge({...Le,of:void 0})},[Le,d]);const se=u.useRef(null),V=u.useRef(!1),oe=u.useRef(0),Ie=u.useId(),Me=u.useCallback(bt=>`${Ie}-row-${bt}`,[Ie]),Ce=u.useCallback((bt,be)=>{bt.scrollTop=be,oe.current=bt.scrollTop},[]),_e=u.useRef(void 0),[Ge,We]=u.useState("active"),tt=u.useMemo(()=>d?adt(d,{mode:Ge}):void 0,[d,Ge]),ht=PSs(tt),rt=u.useMemo(()=>new Map(tt?.spans.map(bt=>[bt.row.key,bt])),[tt]),[kt,Ve]=u.useState(void 0),mt=kt!==void 0&&kt.of===d&&kt.mode===Ge?kt.range:void 0,jt=u.useCallback(bt=>{P(),Ve(bt!==void 0&&d!==void 0?{range:bt,of:d,mode:Ge}:void 0)},[d,Ge,P]);u.useEffect(()=>{kt&&(kt.of!==d||kt.mode!==Ge)&&Ve(void 0)},[kt,d,Ge]);const Ot=u.useMemo(()=>mt&&tt?ldt(tt,mt):void 0,[mt,tt]),me=u.useMemo(()=>d?jSs(d):void 0,[d]),it=u.useMemo(()=>new Map((me?.rows??[]).flatMap(bt=>bt.kind==="turn"?[[bt.key,bt.turn]]:[])),[me]),[He,Ye]=u.useState(),Kt=u.useMemo(()=>!me||!He||He.loader!==e?new Set:He.of===me?He.keys:new Set([...He.keys].filter(bt=>{const be=me.groupIdentities.get(bt);return be!==void 0&&be===He.of.groupIdentities.get(bt)})),[He,me,e]);u.useEffect(()=>{He&&(He.of!==me||He.loader!==e)&&Ye(me?{of:me,loader:e,keys:Kt}:void 0)},[He,me,e,Kt]);const Ft=u.useMemo(()=>ke.filter(bt=>!Ot||Ot.has(bt)),[ke,Ot]),Lt=u.useMemo(()=>pe?new Set(Ft):Ot,[pe,Ft,Ot]),Mn=Boe(de,mt,Ge),[An,En]=u.useState(),Wn=u.useMemo(()=>An?.of===d&&An?.loader===e&&An?.signature===Mn?An.overrides:new Map,[An,d,e,Mn]);u.useEffect(()=>{An&&(!pe||An.of!==d||An.loader!==e||An.signature!==Mn)&&En(void 0)},[An,pe,d,e,Mn]);const ys=u.useMemo(()=>{if(!pe)return Kt;const bt=new Set(Kt);for(const be of Ft)for(const It of me?.ancestors.get(be)??[])bt.delete(It);for(const[be,It]of Wn)It?bt.add(be):bt.delete(be);return bt},[pe,Kt,Ft,me,Wn]),Pt=u.useMemo(()=>me?NSs(me,Lt):[],[me,Lt]),Zt=u.useMemo(()=>new Set(Pt.map(bt=>bt.key)),[Pt]),nn=u.useMemo(()=>me?MSs(me,Pt,ys):[],[me,Pt,ys]),Yt=u.useMemo(()=>new Set(nn.map(bt=>bt.key)),[nn]),Ht=me&&Fe?SDe(me,Fe,Yt):void 0,$t=u.useMemo(()=>{const bt=new Map;for(const be of Pt)if(be.kind==="row")for(const It of me?.ancestors.get(be.key)??[])bt.set(It,(bt.get(It)??0)+1);return bt},[me,Pt]),gt=_==="history",zt=rve({count:nn.length,getScrollElement:()=>se.current,getItemKey:bt=>nn[bt]?.key??bt,estimateSize:()=>Cx,paddingStart:Cx,paddingEnd:gt?Cx:0,overscan:12}),Jt=u.useCallback(bt=>{bt===0?zt.scrollToOffset(0):zt.scrollToIndex(bt,{align:"auto"})},[zt]),kn=u.useCallback(bt=>{if(!d||!me?.groups.has(bt))return;P();const be=se.current;if(be){const Oe=be.scrollTop-Cx,Rt=Math.max(0,Math.min(nn.length-1,Math.floor(Oe/Cx))),pn=nn[Rt];pn&&(_e.current={key:pn.key,offset:Oe-Rt*Cx})}const It=new Set(ys);if(It.has(bt)?It.delete(bt):It.add(bt),pe){const Oe=new Map(Wn);Oe.set(bt,It.has(bt)),En({of:d,loader:e,signature:Mn,overrides:Oe})}else Ye({of:me,loader:e,keys:It});se.current?.focus({preventScroll:!0})},[d,me,nn,ys,e,pe,Mn,Wn,P]);u.useLayoutEffect(()=>{const bt=_e.current;if(!bt||!me||!se.current)return;_e.current=void 0;const be=SDe(me,bt.key,Yt),It=nn.findIndex(Oe=>Oe.key===be);It>=0&&Ce(se.current,(It+1)*Cx+bt.offset)},[me,nn,Yt,Ce]);const ze=nn.length>0;u.useLayoutEffect(()=>{const bt=se.current;if(!bt||typeof ResizeObserver>"u")return;let be=0;const It=()=>{bt.scrollTop===0&&oe.current>0&&(bt.scrollTop=oe.current)},Oe=new ResizeObserver(()=>{It(),be=requestAnimationFrame(It)});return Oe.observe(bt),()=>{Oe.disconnect(),be!==0&&cancelAnimationFrame(be)}},[ze]),u.useEffect(()=>{if(f!=="ready"||V.current||nn.length===0)return;V.current=!0;const bt=se.current;bt&&Ce(bt,bt.scrollHeight)},[Ce,f,nn.length]);const Qe=u.useMemo(()=>Ht===void 0?-1:nn.findIndex(bt=>bt.key===Ht),[Ht,nn]),wt=u.useRef(Qe);wt.current=Qe,u.useLayoutEffect(()=>{const bt=wt.current;if(!ve||bt<0)return;const be=requestAnimationFrame(()=>{Jt(bt)});return()=>cancelAnimationFrame(be)},[ve,Jt]);const Je=u.useCallback(bt=>{if(nn.length===0)return;P();const be=Math.min(Math.max(bt,0),nn.length-1),It=nn[be].key;Ae(void 0),Se(It),ve&&d&&e&&ge({of:d,loader:e,key:It}),Jt(be)},[ve,e,d,Jt,nn,P]),Ee=u.useCallback((bt,be=!0)=>{P(),Ae(void 0),Se(bt),ve&&d&&e&&ge({of:d,loader:e,key:bt}),be&&se.current?.focus({preventScroll:!0})},[ve,d,e,P]),st=u.useCallback((bt=Fe)=>{!d||!e||!bt||!d.rowIndexByKey.has(bt)&&!it.has(bt)||(P(),Ae(void 0),ge({of:d,loader:e,key:bt}),Se(bt),Y(!0))},[d,e,Fe,P,it]),Ue=u.useCallback(bt=>{Ee(bt),st(bt)},[Ee,st]),Pe=u.useRef(null),vt=u.useRef(void 0),yt=ve||!!Be,Et=o?"side":"drill-in",Wt=yt&&Et==="drill-in";u.useLayoutEffect(()=>{Pe.current?.toggleAttribute("inert",Wt);const bt=vt.current;Wt||!bt||(vt.current=void 0,bt())},[Wt,yt]);const Gt=u.useCallback(bt=>{vt.current=bt},[]),sn=u.useCallback(()=>{se.current?.focus({preventScroll:!0})},[]),jn=u.useCallback(()=>{Y(!1),ge(void 0),Gt(sn)},[Gt,sn]),bs=u.useCallback(bt=>{if(bt.target!==bt.currentTarget&&bt.target.tabIndex>=0){if(!["ArrowDown","ArrowUp","Home","End"].includes(bt.key))return;bt.currentTarget.focus({preventScroll:!0})}if(bt.key==="Escape"){mt!==void 0&&(bt.preventDefault(),jt(void 0));return}if(nn.length===0)return;if(bt.key==="Enter"){bt.preventDefault(),Ht&&Ue(Ht);return}if((bt.key==="ArrowLeft"||bt.key==="ArrowRight")&&Ht&&me?.groups.has(Ht)&&($t.get(Ht)??0)>0){const It=bt.key==="ArrowLeft";ys.has(Ht)!==It&&(bt.preventDefault(),kn(Ht));return}const be=Qe<0?-1:Qe;bt.key==="ArrowDown"?(bt.preventDefault(),Je(be+1)):bt.key==="ArrowUp"?(bt.preventDefault(),Je(be<=0?0:be-1)):bt.key==="Home"?(bt.preventDefault(),Je(0)):bt.key==="End"?(bt.preventDefault(),Je(nn.length-1)):(bt.key==="PageUp"||bt.key==="PageDown"||bt.key===" ")&&P()},[Je,Ue,mt,Qe,jt,nn,Ht,me,$t,ys,kn,P]),Ys=u.useMemo(()=>d?uks(d):void 0,[d]),Ws=Le!==void 0&&Le.of===d&&Le.loader===e,Os=Ws?d?.rowIndexByKey.get(Le.key):void 0,mn=Ws?it.get(Le.key):void 0,vn=mn?mn.userRowKey===void 0?void 0:d?.rows[d.rowIndexByKey.get(mn.userRowKey)??-1]:Os===void 0?void 0:d?.rows[Os],xs=(f==="ready"||f==="error"&&d!==void 0)&&nn.length===0,Ke=d!==void 0&&d.rows.length>0&&!xCs(d),wn=Ys!==void 0&&Ys.plottedCount===0&&Ys.missingStartCount>0,Gn=u.useMemo(()=>{if(!(!d||!mt&&!pe&&ys.size===0))return{shown:nn.filter(bt=>bt.kind==="row").length,total:d.rows.length}},[mt,d,nn,ys,pe]),Dt=y===void 0?void 0:y.kind==="partial"?n("trajectory.olderPartial"):y.kind==="unreadable"?n("trajectory.olderFailed",{message:y.message}):n(`trajectory.window.${y.kind}`),tn=u.useRef(void 0);if(te.loader!==e||te.version!==S){const bt=te.loader!==e;q.current=!bt,Z({loader:e,version:S,selectionLost:!bt&&Fe!==void 0}),Se(void 0),ge(void 0),Y(!1),Ye(void 0),En(void 0),Ve(void 0),_e.current=void 0,tn.current=void 0,oe.current=0,V.current=!bt}u.useLayoutEffect(()=>{q.current&&se.current&&(q.current=!1,zt.scrollToOffset(0),Ce(se.current,0))},[S,ze,zt,Ce]);const In=u.useRef(!1);u.useEffect(()=>{const bt=A.loader===e&&A.pending;!bt||f==="loading"||(p||y||R?P():f==="ready"&&d!==bt.of&&_==="latest"&&(In.current=!0,M({loader:e,paused:!1}),Se(void 0),Ae(void 0),Y(!1),ge(void 0),X(be=>({...be,value:i6})),Ve(void 0)))},[A,e,f,p,y,R,d,_,P]),u.useLayoutEffect(()=>{if(!In.current)return;In.current=!1;const bt=se.current;bt&&(Ce(bt,bt.scrollHeight),bM(bt.getRootNode())&&bt.focus({preventScroll:!0}))},[F,nn,Ce]);const _s=u.useRef(void 0);u.useLayoutEffect(()=>{const bt=_s.current,be=r.current;!bt||!be||f==="loading"||(_s.current=void 0,bM(be.getRootNode())&&(be.querySelector(`[data-testid="${bt}"]`)??se.current)?.focus({preventScroll:!0}))},[S,f,ze]);const Ts=u.useCallback(()=>{const bt=se.current;G(!!bt&&bt.scrollHeight-bt.clientHeight-bt.scrollTop>Cx)},[]),Is=zt.getTotalSize(),Hs=nn.length>0;u.useLayoutEffect(()=>{Ts()},[Ts,Is,Hs]);const Ps=u.useCallback(bt=>{const be=nn.findIndex(It=>It.key===bt);if(be<0&&d&&me){tn.current=bt;const It=pe&&!Zt.has(bt)&&!Te.has(bt),Oe=mt!==void 0&&!Zt.has(bt)&&!Ot?.has(bt);It&&ne(),Oe&&jt(void 0);const Rt=me.ancestors.get(bt)??[];if(pe&&!It){const pn=new Map(Oe?[]:Wn);for(const Kn of Rt)pn.set(Kn,!1);En({of:d,loader:e,signature:Boe(de,Oe?void 0:mt,Ge),overrides:pn})}else{const pn=new Set(Kt);for(const Kn of Rt)pn.delete(Kn);Ye({of:me,loader:e,keys:pn})}Ee(bt);return}Ee(bt),be>=0&&Jt(be)},[d,me,Te,Zt,Ot,pe,ne,Wn,de,mt,Ge,Kt,e,Ee,jt,Jt,nn]),io=u.useCallback((bt,be=de)=>{if(!EDe(be)||!Re||!d||!me)return;ae(be);const It=RDe(Re,be).filter(fo=>!Ot||Ot.has(fo));if(!It.length)return;const Oe=Fe?It.indexOf(Fe):-1,Rt=Oe<0?bt===1?0:It.length-1:(Oe+bt+It.length)%It.length,pn=It[Rt],Kn=me.ancestors.get(pn)??[],vs=Boe(be,mt,Ge),fr=new Map(vs===Mn?Wn:[]);for(const fo of Kn)fr.set(fo,!1);En({of:d,loader:e,signature:vs,overrides:fr}),tn.current=pn,Ee(pn,!1)},[Re,d,me,ae,de,Ot,Fe,mt,Ge,Mn,Wn,e,Ee]);u.useLayoutEffect(()=>{const bt=tn.current;if(bt===void 0)return;tn.current=void 0;const be=nn.findIndex(It=>It.key===bt);be>=0&&Jt(be)},[Jt,nn]);const ut=u.useCallback(bt=>{const be=[Rfe(bt.row,n).text],It=bt.row.kind==="request"||bt.row.kind==="tool"?bt.row.timing?.startedAt:void 0;return It!==void 0&&be.push(`${new Date(It).toLocaleString()}–${new Date(It+bt.end-bt.start).toLocaleString()}`),be.push(na(bt.end-bt.start)),bt.ttftEnd!==void 0&&be.push(n("trajectory.ttft",{duration:na(bt.ttftEnd-bt.start)})),be.filter(Boolean).join(" · ")},[n]),Ze=ce&&fe.rows.length>0,Sn=Uks({windowMode:_,following:F,returning:$,liveStatus:h.status}),Zn=Wks({hasTrajectory:d!==void 0,error:p,navigationError:R,historyStale:Q,lifecycleIncomplete:h.incomplete&&h.status!=="unavailable"||h.truncated}),_n=Hks({truncated:v,loading:f==="loading"&&j!=="latest",olderFailure:y}),$n=mt&&tt?`${xfe(tt,mt.start,mt.end-mt.start,s)} – ${xfe(tt,mt.end,mt.end-mt.start,s)}`:void 0,Xn=a.jsx("div",{className:Po.boundary,"aria-live":"polite","data-testid":"trajectory-older-bar","data-state":_n,children:_n==="failed"?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:`${Po.boundaryText} ${Po.toneError}`,"data-testid":"trajectory-older-failed",title:Dt,children:Dt}),a.jsx("button",{type:"button",className:Po.boundaryButton,onClick:()=>{f!=="loading"&&b()},"aria-disabled":f==="loading"||y!==void 0&&!kfe(y),"data-testid":"trajectory-older-retry",children:n("common.retry")})]}):_n==="loading"||_n==="earlier"?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:Po.boundaryText,..._n==="earlier"?{"data-testid":"trajectory-truncated"}:{},children:_n==="loading"?n("trajectory.loadingPages",{pages:m}):n(_==="history"?"trajectory.window.outside":"trajectory.boundary.earlier")}),v&&a.jsx("button",{type:"button",className:Po.boundaryButton,"aria-disabled":!I,onClick:()=>{I&&(P(),_s.current="trajectory-window-older",x())},"data-testid":"trajectory-window-older",children:n("trajectory.boundary.loadEarlier")})]}):a.jsx("span",{className:Po.boundaryText,children:n("trajectory.boundary.start")})}),ao=a.jsxs("div",{className:Po.boundary,children:[a.jsx("button",{type:"button",className:Po.boundaryButton,"aria-disabled":!C,onClick:()=>{C&&(P(),_s.current="trajectory-window-newer",k())},"data-testid":"trajectory-window-newer",children:n("trajectory.boundary.newer")}),a.jsx("button",{type:"button",className:Po.boundaryButton,"aria-disabled":!E,onClick:()=>{E&&(_s.current="trajectory-window-latest",H())},"data-testid":"trajectory-window-latest",children:n("trajectory.window.return")}),N&&!C&&f!=="loading"&&!R&&!p&&!y&&a.jsx("span",{className:Po.boundaryText,children:n("trajectory.window.released")})]}),Do=vn&&!mn,Er=Be?a.jsx(tDe,{presentation:Et,execution:Be,title:Be.name,onClose:()=>{Ae(void 0),Gt(c)},onFocusedUnmount:c,onLocateExecution:Be.historyRowKey?()=>{const bt=Be.historyRowKey;Ps(bt),st(bt)}:void 0},Be.key):ve&&Le!==void 0&&Le.loader===e?a.jsx(tDe,{presentation:Et,row:vn,turn:mn,lifecycle:Ws&&vn&&!mn?h.byRowKey.get(vn.key):void 0,stale:!Ws,title:mn?n(mn.partial?"trajectory.turnPartial":"trajectory.turn",{index:mn.index}):vn?Rfe(vn,n).text:void 0,hiddenByRange:!!(mt&&Do&&!Zt.has(vn.key)&&!Ot?.has(vn.key)),hiddenByFilter:!!(pe&&Do&&!Zt.has(vn.key)&&!Te.has(vn.key)),onClearFilter:ne,hiddenByCollapse:!!(Do&&me?.ancestors.get(vn.key)?.some(bt=>ys.has(bt))),onReveal:()=>{vn&&Ps(vn.key)},onClearRange:()=>jt(void 0),onClose:jn,onStep:bt=>Je(Qe+bt),onFocusedUnmount:sn}):void 0;return a.jsxs("div",{ref:r,className:Po.panel,"data-testid":"trajectory-panel",children:[a.jsx(u1s,{summary:Ys,pill:Sn,onPill:()=>{Sn==="paused"||Sn==="history"?H():P()},warnings:Zn,onRetry:b,onRefresh:()=>{P(),U()},onReturnToLatest:H,canRefresh:E,history:_==="history",failuresOn:de.status==="error",onToggleFailures:()=>ae({...de,status:de.status==="error"?"all":"error"}),about:{pages:g,searchExcluded:Re?.truncatedCount??0,executionsOmitted:fe.omitted,executionsOutside:h.outsideWindow.length}}),a.jsx(zks,{model:tt,viewportControl:{...ht,applyViewport:bt=>{P(),ht.applyViewport(bt)}},...Ke||wn?{notice:n(wn?"trajectory.noStart":"trajectory.noTiming")}:{},selectedKey:Fe,onSelect:Ps,describe:ut,...mt!==void 0?{range:mt}:{},onRangeChange:jt,onModeChange:bt=>{P(),We(bt)}}),a.jsxs(Adt,{className:Po.split,orientation:"horizontal","data-testid":"trajectory-split",children:[a.jsxs(Ife,{id:"trajectory-records",className:Po.recordsPanel,minSize:320,children:[a.jsxs("div",{ref:Pe,className:Po.records,children:[d&&d.rows.length>0&&a.jsx(rCs,{value:de,onChange:ae,onNavigate:io,onClear:ne,count:pe?Ft.length:0,position:pe&&Fe?Ft.indexOf(Fe)+1:0,truncatedCount:Re?.truncatedCount??0,...$n!==void 0?{range:$n}:{},onClearRange:()=>jt(void 0),...Gn?{status:n("trajectory.range.status",Gn)}:{}},J.scope),a.jsx(V_s,{rows:fe.rows,selectedKey:Be?.key,following:F,liveStatus:h.status,historySnapshot:d,onPause:P,onUpdatedChange:he,onFocusLost:()=>se.current?.focus({preventScroll:!0}),onSelect:bt=>{P(),Se(void 0),Y(!1),Ae({loader:e,key:bt})}},`executions-${J.scope}`),a.jsxs("div",{className:Po.tableWrap,children:[a.jsx("span",{className:Po.srOnly,role:"status","data-testid":"trajectory-window-changed",children:te.selectionLost&&!Fe?n("trajectory.window.changed"):""}),nn.length===0?a.jsxs(a.Fragment,{children:[d&&Xn,f==="error"&&p&&!d?a.jsxs("div",{className:Po.placeholder,role:"alert",children:[a.jsx("span",{children:rxe(p,n)})," ",kfe(p)&&a.jsx("button",{type:"button",className:Po.headerButton,onClick:b,children:n("common.retry")})]}):pe?a.jsxs("div",{className:Po.placeholder,"data-testid":"trajectory-filter-empty",children:[a.jsx("span",{children:n("trajectory.filter.empty")})," ",a.jsx("button",{type:"button",className:Po.headerButton,onClick:ne,children:n("trajectory.filter.clear")})]}):mt!==void 0?a.jsxs("div",{className:Po.placeholder,"data-testid":"trajectory-range-empty",children:[a.jsx("span",{children:n("trajectory.range.empty")})," ",a.jsx("button",{type:"button",className:Po.headerButton,onClick:()=>jt(void 0),children:n("trajectory.range.clear")})]}):a.jsx("div",{className:Po.placeholder,role:"status",children:xs?n("trajectory.empty"):m>0?n("trajectory.loadingPages",{pages:m}):n("common.loading")}),d&&gt&&ao]}):a.jsx("div",{ref:se,className:Po.scroll,role:"grid",tabIndex:0,"aria-label":n("trajectory.title"),"aria-rowcount":nn.length,"aria-activedescendant":zt.getVirtualItems().some(bt=>bt.index===Qe)?Me(Qe):void 0,onKeyDown:bs,onWheel:P,onPointerDown:P,onScroll:bt=>{oe.current=bt.currentTarget.scrollTop,Ts()},"data-testid":"trajectory-rows",children:a.jsxs("div",{className:Po.virtualBody,style:{height:`${zt.getTotalSize()}px`},children:[a.jsx("div",{className:Po.virtualBoundary,children:Xn}),zt.getVirtualItems().map(bt=>{const be=nn[bt.index];return a.jsx("div",{id:Me(bt.index),className:Po.virtualRow,style:{height:`${Cx}px`,transform:`translateY(${bt.start}px)`},role:"row","aria-rowindex":bt.index+1,children:be.kind==="turn"?a.jsx(_Cs,{turn:be.turn,prompt:be.turn.userRowKey?d?.rows[d.rowIndexByKey.get(be.turn.userRowKey)??-1]:void 0,collapsed:ys.has(be.key),hiddenCount:$t.get(be.key)??0,onToggle:()=>kn(be.key),selected:be.key===Ht,onSelect:()=>Ue(be.key)}):a.jsx(SCs,{row:be.row,grouped:(me?.ancestors.get(be.key)?.length??0)>1,unresolvedParent:me?.unresolvedParents.has(be.key)??!1,fold:me?.groups.has(be.key)&&($t.get(be.key)??0)>0?{collapsed:ys.has(be.key),hiddenCount:$t.get(be.key)??0,onToggle:()=>kn(be.key)}:void 0,span:rt.get(be.key),total:tt?.total??0,viewport:ht.viewport,range:mt,context:!!Lt&&!Lt.has(be.key),selected:be.key===Ht,onSelect:()=>Ue(be.key)})},bt.key)}),gt&&a.jsx("div",{className:Po.virtualBoundary,style:{transform:`translateY(${zt.getTotalSize()-Cx}px)`},children:ao})]})}),Sn==="paused"&&(W||Ze)&&a.jsxs("button",{type:"button",className:Po.jumpLatest,"aria-disabled":!E,onClick:()=>{E&&H()},"data-testid":"trajectory-jump-latest",children:[a.jsx(Dge,{size:13,"aria-hidden":"true"}),n("trajectory.jumpLatest"),Ze&&a.jsx("span",{className:Po.updatedDot,role:"img","aria-label":n("trajectory.jumpLatest.updated")})]})]})]}),Et==="drill-in"&&Er]}),Et==="side"&&yt&&a.jsxs(a.Fragment,{children:[a.jsx(jdt,{className:Po.splitHandle,"aria-label":n("trajectory.detail.resize")}),a.jsx(Ife,{id:"trajectory-detail-panel",className:Po.detailPanel,defaultSize:"40%",minSize:320,maxSize:"60%",children:Er})]})]})]})}function _Cs({turn:e,prompt:t,collapsed:n,hiddenCount:s,onToggle:r,selected:o,onSelect:i}){const{t:l}=Xe();return a.jsxs("div",{className:`${Po.turnHeader} ${o?Po.selected:""}`,onClick:i,"aria-selected":o,"data-selected":o?"true":void 0,role:"gridcell","data-testid":"trajectory-turn",children:[a.jsx(Ndt,{collapsed:n,name:l("trajectory.turn",{index:e.index}),onToggle:r}),a.jsx("span",{className:Po.turnTitle,children:e.partial?l("trajectory.turnPartial",{index:e.index}):l("trajectory.turn",{index:e.index})}),t?.kind==="user"&&a.jsx("span",{className:Po.turnPrompt,title:vE(t.block.text),children:vE(t.block.text).slice(0,160)}),n&&s>0&&a.jsx("span",{className:Po.foldCount,children:l("trajectory.collapsed",{count:s})}),a.jsx("span",{className:Po.turnSummary,children:l("trajectory.turnSummary",{requests:e.requestCount,tools:e.toolCount,duration:e.requestCount>0?na(e.requestMs):"—"})})]})}function SCs({row:e,grouped:t,unresolvedParent:n,fold:s,span:r,total:o,viewport:i,range:l,context:c,selected:d,onSelect:h}){const{t:f}=Xe(),p=Rfe(e,f),m=yCs(e,f);return a.jsxs("div",{className:`${Po.record} ${d?Po.selected:""}`,role:"gridcell","aria-selected":d,"data-selected":d?"true":void 0,onClick:h,"data-testid":`trajectory-row-${e.kind}`,"data-depth":e.depth,"data-grouped":t||void 0,"data-context":c||void 0,"data-row-key":e.key,children:[s?a.jsx(Ndt,{collapsed:s.collapsed,name:p.text,onToggle:s.onToggle}):a.jsx("span",{className:Po.foldSpacer}),e.depth>0&&a.jsx(a5t,{size:12,strokeWidth:1.6,className:Po.nestMarker,"aria-hidden":"true"}),a.jsx("span",{className:`${Po.badge} ${p.badgeTone??""}`,children:p.badge}),a.jsx("span",{className:`${Po.text} ${p.faint?Po.faint:""}`,children:p.text}),n&&a.jsx("span",{className:Po.parentNotice,title:f("trajectory.parentUnresolved"),children:f("trajectory.parentUnresolved")}),c&&a.jsx("span",{className:Po.foldCount,children:f("trajectory.contextRow")}),s?.collapsed&&a.jsx("span",{className:Po.foldCount,children:f("trajectory.collapsed",{count:s.hiddenCount})}),a.jsx("span",{className:Po.waterfallSlot,children:a.jsx(FSs,{span:r,total:o,viewport:i,range:l,title:m.join(" · ")})}),a.jsx("span",{className:Po.rowMetrics,"data-testid":"trajectory-row-metrics",title:m.length>0?m.join(" · "):void 0,children:m.length>0?m.join(" · "):"—"})]})}function Ndt({collapsed:e,name:t,onToggle:n}){const{t:s}=Xe();return a.jsx("button",{type:"button",tabIndex:-1,className:Po.foldButton,"aria-expanded":!e,"aria-label":s(e?"trajectory.expand":"trajectory.collapse",{name:t}),onClick:r=>{r.stopPropagation(),n()},children:e?a.jsx(Vl,{size:13,"aria-hidden":"true"}):a.jsx(ud,{size:13,"aria-hidden":"true"})})}const CCs="_panel_pwtdr_1",TCs="_toolbar_pwtdr_5",ICs="_actions_pwtdr_15",RCs="_feedback_pwtdr_21",ECs="_state_pwtdr_31",R1={panel:CCs,toolbar:TCs,actions:ICs,feedback:RCs,state:ECs};function ACs({sessionActions:e,sessionId:t,controls:n,onOpenMemoryFile:s}){const{t:r}=Xe(),[o,i]=u.useState(null),[l,c]=u.useState(!0),[d,h]=u.useState(!1),f=u.useRef(0),p=u.useRef(()=>{}),m=u.useRef(null),g=n?.sessionId===t?n:void 0,v=g?.getContextUsage??e?.getContextUsage,y=u.useRef(g);y.current=g;const w=g?.result,[b,x]=u.useState(w),k=!!(w&&w!==b&&(w.kind!=="completed"||!d));u.useEffect(()=>{w?.kind==="completed"&&(f.current++,i(w.usage),h(!1))},[w]),u.useEffect(()=>{let R=!0,j=!1;const E=y.current?.result;i(C=>C?.sessionId===t?C:E?.kind==="completed"?E.usage:null),h(!1),c(!!v);const I=async()=>{if(!R||j||!v)return;j=!0,c(!0),h(!1);const C=f.current,N=m.current,A=N&&N.getContextUsage===v&&N.sessionId===t?N:{getContextUsage:v,sessionId:t,promise:v({detail:!0,silent:!0,...y.current?.result?{syncCounters:!0}:{}})};m.current=A;try{const M=await A.promise;if(!R||C!==f.current)return;i(M.sessionId===t&&M.usage.contextWindowSize>0?M:null)}catch(M){if(!R||C!==f.current)return;h(nq(M)?"transient":"hard")}finally{j=!1,m.current===A&&(m.current=null),R&&c(!1)}};return p.current=()=>void I(),I(),()=>{R=!1}},[v,t]);const _=!v||l||g?.compressing,S=()=>{x(w),p.current()};return a.jsxs("div",{className:R1.panel,"aria-busy":l,children:[a.jsxs("div",{className:R1.toolbar,children:[a.jsx("span",{children:r("contextUsage.title")}),a.jsxs("div",{className:R1.actions,children:[a.jsx(Ne,{type:"button",variant:"ghost",size:"icon-sm","aria-label":r("contextUsage.refresh"),title:r("contextUsage.refresh"),disabled:_,onClick:S,children:a.jsx(ph,{"aria-hidden":"true"})}),a.jsx("span",{title:g?.compressing?void 0:g?.canCompress?l?r("common.loading"):void 0:r("contextUsage.compressUnavailable"),children:a.jsx(Ne,{type:"button",variant:"outline",size:"sm",disabled:!g?.canCompress||l,onClick:()=>void g?.compress(),children:r(g?.compressing?"contextUsage.compressing":"contextUsage.compress")})})]})]}),(g?.compressing||k)&&a.jsx(hrt,{controls:g,className:R1.feedback}),d==="transient"&&o&&a.jsx("div",{className:R1.feedback,role:"status",children:r("contextUsage.previousReading")}),d==="hard"?a.jsxs("div",{className:R1.state,role:"alert",children:[a.jsx("span",{children:r("contextUsage.loadError")}),a.jsx(Ne,{type:"button",variant:"outline",size:"sm",disabled:_,onClick:S,children:r("contextUsage.retry")})]}):v?l&&!o?a.jsx("div",{className:R1.state,role:"status",children:r("common.loading")}):o?a.jsx(fXe,{status:o,compact:!0,onOpenMemoryFile:s?R=>s(R,o.workspaceRoot??o.workspaceCwd):void 0}):a.jsx("div",{className:R1.state,children:r("contextUsage.unavailable")}):a.jsx("div",{className:R1.state,children:r("contextUsage.unavailable")})]})}class Mdt extends Error{}function Pdt(e){throw new Mdt(e instanceof Error?e.message:String(e))}const jCs=()=>xt(()=>import("./WorkspaceFileBrowser-Du9bMpNo.js"),__vite__mapDeps([95,96])).then(e=>({default:e.WorkspaceFileBrowser})).catch(Pdt),NCs=()=>xt(()=>import("./PierreFilePreview-Dkt6iPte.js"),[]).catch(Pdt),MCs=u.lazy(()=>xt(()=>import("./SpreadsheetPreview-I4yiL7q3.js"),[])),PCs=700,DCs=["daily","weekdays","weekly","hourly","minutes","custom"],LCs=[1,2,3,4,5,6,10,12,15,20,30],OCs=(e,t)=>{},BCs=(e,t,n)=>{},$Cs=()=>Promise.reject(new Error("Side-task session creation is unavailable"));function ADe(e){return e.kind==="review"||e.kind==="file"||e.kind==="artifact"||e.kind==="scheduled_task"}function E1(e){return e.kind==="pending"?e.targetKind:e.kind}function FCs(e){return`image.${(e.match(/^data:image\/([a-z0-9+.+-]+)/i)?.[1]??"png").split("+")[0].toLowerCase()}`}const zCs=["review","sideTask"];function UCs({tab:e,workspaceCwd:t,onOpenFilePreview:n,onReferenceFile:s,onClose:r}){const{t:o,language:i}=Xe(),l=c9(),c=u.useMemo(()=>u.lazy(jCs),[]),d=u.useMemo(()=>u.lazy(NCs),[]),h=dA(e.workspaceCwd),f=h?.workspaceId===e.workspaceId?h?.actions:void 0;if(!f)return a.jsx("div",{className:Ct.empty,role:"alert",children:o("workspace.notFoundDescription")});const p=(m,g)=>{const v=m instanceof Mdt,y=()=>!!(l&&(!l.activeToken||bpe()));return v&&!y()?a.jsxs("div",{role:"alert",className:Ct.empty,children:[a.jsx("p",{children:o("files.loadFailed")}),a.jsx("p",{children:o("files.reloadUnavailable")}),a.jsx(Ne,{onClick:r,children:o("files.close")})]}):a.jsx(wX,{error:m,language:i,retryMode:v?"reload":"reset",onRetry:v?()=>{y()?window.location.reload():r()}:g})};return a.jsx(Rm,{label:"workspace file browser",fallback:p,children:a.jsx(u.Suspense,{fallback:a.jsx("div",{className:`${Ct.empty} text-center`,role:"status",children:o("common.loading")}),children:a.jsx(c,{workspaceCwd:e.workspaceCwd,actions:f,onOpenPreview:m=>n(m,e.workspaceCwd,e.workspaceId),onReferenceFile:e.workspaceCwd===t?s:void 0,renderPreview:(m,g,v)=>a.jsx(S7,{workspacePath:m,workspaceActions:f,previewKind:g?"source":void 0,sourceRenderer:y=>a.jsx(Rm,{label:"workspace file source",resetKeys:[m],fallback:p,children:a.jsx(u.Suspense,{fallback:a.jsx("div",{className:Ct.empty,children:o("common.loading")}),children:a.jsx(d,{path:m,content:y})})})},`${m}:${g}:${v}`)},`${e.workspaceCwd}:${e.workspaceId??""}`)})})}function jDe({contextUsageControls:e,artifacts:t,tabs:n,activeTabId:s,reviewChanges:r,selectedReviewPath:o,panelWidth:i,workspaceCwd:l,loading:c,restoring:d=!1,error:h,onSelectTab:f,onSelectTurnCallsPrompt:p,onCloseTab:m,onOpenFilePreview:g,onOpenMemoryFile:v,latestReviewAvailable:y=!1,onOpenLatestReview:w,onOpenTerminal:b,onOpenTrajectory:x,trajectoryTabId:k,onOpenFiles:_,onReferenceFile:S,onOpenWebPreview:R,onWebPreviewChange:j,items:E=zCs,sideTaskAvailable:I=!1,sideTasks:C=[],archivedSideTasks:N=[],sideTasksLoading:A=!1,onCreateSideTask:M,onOpenSideTask:P,onArchiveSideTasks:L,onUnarchiveSideTasks:F,onSideTaskMenuOpen:$,onCreateSideTaskSession:B,onSideTaskCreated:D,onSideTaskTitleChange:O,onSideTaskInitialPromptRefused:U,onNestedRightPanelOpen:H,onNestedArtifactsChange:Q,onOpenNestedSubagent:q,agentTasks:te=[],agentTraceLoading:Z=!1,agentTraceError:ce,onOpenWorkflowAgent:he,onError:W,sessionWorkflowEnabled:G,modelManagement:J,unavailableModels:X,mountUnavailableModelTooltip:de,workflow:ae,onImageIngestionNotice:ne,deferSubagentMount:pe=!1,onClose:Re,variant:ke="docked",fullscreen:Te=!1,onToggleFullscreen:Fe}){const{t:Se}=Xe(),Le=ko(),ge=q1(Le.capabilities,l),[fe,we]=u.useState(!1),[Ae,Be]=u.useState(),ve=u.useRef(null),Y=u.useCallback(()=>{ve.current&&(clearTimeout(ve.current),ve.current=null),we(!0)},[]),se=u.useCallback(()=>{ve.current&&clearTimeout(ve.current),ve.current=setTimeout(()=>{we(!1),ve.current=null},120)},[]);u.useEffect(()=>{fe&&$?.()},[$,fe]),u.useEffect(()=>()=>{ve.current&&clearTimeout(ve.current)},[]);const V=n.find(me=>me.id===s)??n[0],oe=V?.kind==="file"&&V.sourcePreview&&(/\.html?$/i.test(V.workspacePath)||xy(V.previewMimeType||V.previewData?.type)==="text/html"),Ie=V?.kind==="file"&&V.previewOnly===!0&&!oe&&/\.(?:html?|md|markdown)$/i.test(V.workspacePath)&&(V.previewContent!==void 0||!V.previewData||!!FM(V.previewMimeType||V.previewData.type,V.workspacePath)),Me=Ae===V?.id,Ce=E.includes("review")&&!n.some(me=>E1(me)==="review"),_e=E.includes("sideTask")&&I&&!!M,Ge=C.some(me=>me.archivable===!0),We=!!b,tt=E.includes("webPreview")&&!!R,ht=E.includes("trajectory")&&!!x&&!n.some(me=>me.id===k),rt=E.includes("files")&&!!_&&!n.some(me=>me.kind==="files"&&me.workspaceCwd===l&&me.workspaceId===ge?.id),kt=!!V&&(rt||Ce||_e||We||tt||ht),Ve=V&&ADe(V)?{workspaceCwd:V.workspaceCwd,workspaceId:V.workspaceId}:void 0,mt=dA(Ve?.workspaceCwd),jt=mt?.workspaceId===Ve?.workspaceId?mt?.actions:void 0,Ot=V?.kind==="artifact"?t.find(me=>me.id===V.artifactId):void 0;return a.jsxs("aside",{className:`${Ct.panel} ${ke==="drawer"?Ct.panelDrawer:""} ${Te?Ct.panelFullscreen:""}`,style:ke==="docked"&&i&&!Te?{flexBasis:i,width:i}:void 0,"aria-label":"Right panel",children:[a.jsxs("div",{className:Ct.header,children:[n.length>0&&a.jsx("div",{className:Ct.tabs,role:"tablist","aria-label":"Right panel",children:n.map(me=>a.jsxs("div",{className:[Ct.tabItem,me.id===V?.id?Ct.tabActive:""].filter(Boolean).join(" "),children:[a.jsxs("button",{type:"button",role:"tab","aria-selected":me.id===V?.id,className:Ct.tab,onClick:()=>f(me.id),onMouseEnter:it=>E_(it.currentTarget),onFocus:it=>E_(it.currentTarget),title:me.kind==="turn_calls"?Se("turnCalls.title"):me.title,children:[a.jsx("span",{className:`${Ct.tabIcon} ${E1(me)==="artifact"?Ct.tabArtifactIcon:""}`,"aria-hidden":"true",children:E1(me)==="review"?a.jsx(Foe,{}):me.kind==="files"?a.jsx(L8,{className:Ct.tabIconSvg}):me.kind==="workflow"?a.jsx(wVe,{className:Ct.tabIconSvg,strokeWidth:1.6}):me.kind==="file"?a.jsx(Tb,{name:me.workspacePath,className:Ct.tabIconSvg,strokeWidth:1.6}):E1(me)==="artifact"?a.jsx(LJe,{artifact:t.find(it=>"artifactId"in me&&it.id===me.artifactId),className:Ct.tabIconSvg}):E1(me)==="subagent"?a.jsx(WCs,{}):E1(me)==="monitor"?a.jsx(Vge,{className:Ct.tabIconSvg,strokeWidth:1.6}):E1(me)==="shell"?a.jsx(RR,{className:Ct.tabIconSvg,strokeWidth:1.6}):E1(me)==="side_task"?a.jsx(sF,{className:Ct.tabIconSvg,strokeWidth:1.6}):me.kind==="web_preview"?a.jsx(k4,{className:Ct.tabIconSvg}):me.kind==="terminal"?a.jsx(RR,{className:Ct.tabIconSvg,strokeWidth:1.6}):E1(me)==="image"?a.jsx(hVe,{className:Ct.tabIconSvg,strokeWidth:1.6}):me.kind==="context_usage"?a.jsx(OY,{className:Ct.tabIconSvg,strokeWidth:1.6}):me.kind==="token_usage"?a.jsx(LY,{className:Ct.tabIconSvg,strokeWidth:1.6}):me.kind==="turn_calls"?a.jsx(hL,{className:Ct.tabIconSvg,strokeWidth:1.6}):me.kind==="trajectory"?a.jsx(jte,{className:Ct.tabIconSvg,strokeWidth:1.6}):a.jsx(qCs,{})}),a.jsx("span",{className:Ct.tabTitle,"data-web-shell-session-title":!0,children:a.jsx("span",{className:Ct.tabTitleInner,children:me.kind==="turn_calls"?Se("turnCalls.title"):me.title})})]}),a.jsx("button",{type:"button",className:Ct.tabCloseButton,onClick:()=>m(me.id),"aria-label":`Close ${me.kind==="turn_calls"?Se("turnCalls.title"):me.title}`,title:"Close",children:a.jsx(HCs,{})})]},me.id))}),a.jsxs("div",{className:Ct.headerActions,children:[kt&&a.jsxs(sf,{modal:!1,children:[a.jsx(Nh,{asChild:!0,children:a.jsx("button",{type:"button",className:`${Ct.iconButton} ${Ct.addButton}`,"aria-label":Se("rightPanel.add"),title:Se("rightPanel.add"),children:a.jsx(Nf,{className:Ct.toolbarIcon})})}),a.jsxs(Mh,{align:"end",className:"w-64",children:[rt&&a.jsxs(Mr,{onSelect:_,children:[a.jsx(L8,{}),a.jsx("span",{className:Ct.sideTaskListTitle,children:Se("files.title")})]}),Ce&&a.jsxs(Mr,{disabled:!y||!w,onSelect:w,children:[a.jsx(Foe,{}),a.jsx("span",{className:Ct.sideTaskListTitle,children:Se("turnOutputs.review")})]}),Ce&&_e&&a.jsx(ug,{}),_e&&a.jsxs(Mr,{disabled:A,onSelect:M,children:[a.jsx(sF,{className:Ct.sideTaskNewIcon,strokeWidth:1.6,"aria-hidden":"true"}),a.jsx("span",{className:Ct.sideTaskListTitle,children:Se("sideTask.create")})]}),We&&(Ce||_e)&&a.jsx(ug,{}),We&&a.jsxs(Mr,{onSelect:()=>b?.(),children:[a.jsx(RR,{className:Ct.sideTaskNewIcon,strokeWidth:1.6,"aria-hidden":"true"}),a.jsx("span",{className:Ct.sideTaskListTitle,children:Se("terminal.title")})]}),tt&&a.jsxs(Mr,{onSelect:R,children:[a.jsx(k4,{className:Ct.sideTaskNewIcon}),a.jsx("span",{className:Ct.sideTaskListTitle,children:Se("webPreview.title")})]}),ht&&a.jsxs(Mr,{onSelect:()=>x?.(),children:[a.jsx(jte,{className:Ct.sideTaskNewIcon,strokeWidth:1.6,"aria-hidden":"true"}),a.jsx("span",{className:Ct.sideTaskListTitle,children:Se("trajectory.title")})]})]})]}),Fe&&a.jsx("button",{type:"button",className:`${Ct.iconButton} ${Ct.fullscreenButton} ${Te?Ct.iconButtonActive:""}`,onClick:Fe,"aria-label":Se(Te?"common.exitFullscreen":"common.fullscreen"),"aria-pressed":Te,title:Se(Te?"common.exitFullscreen":"common.fullscreen"),children:Te?a.jsx($Y,{className:Ct.toolbarIcon,"aria-hidden":!0}):a.jsx(DY,{className:Ct.toolbarIcon,"aria-hidden":!0})}),a.jsx("button",{type:"button",className:`${Ct.iconButton} ${Ct.panelToggleButton}`,onClick:Re,"aria-label":Se("chatHeader.toggleRightPanel"),"aria-pressed":"true",title:Se("chatHeader.toggleRightPanel"),children:a.jsx(yVe,{className:Ct.panelToggleIcon})})]})]}),(Te||ke==="drawer")&&a.jsx(Yit,{}),a.jsxs("div",{className:`${Ct.body} ${V?.kind==="side_task"||V?.kind==="files"?Ct.bodySideTask:""}`.trim(),children:[n.filter(me=>me.kind==="web_preview").map(me=>a.jsx("div",{className:"h-full",hidden:me.id!==V?.id,children:a.jsx(Fbs,{state:me,onChange:it=>j?.(me.id,it)})},me.id)),n.filter(me=>me.kind==="files").map(me=>a.jsx("div",{className:"h-full",hidden:me.id!==V?.id,children:a.jsx(UCs,{onClose:()=>m(me.id),tab:me,workspaceCwd:l,onOpenFilePreview:g,onReferenceFile:S})},me.id)),n.filter(me=>me.kind==="terminal").map(me=>a.jsx("div",{className:`${Ct.terminalPane} ${me.id===V?.id?"":Ct.terminalPaneHidden}`.trim(),"aria-hidden":me.id===V?.id?void 0:!0,children:a.jsx($bs,{terminalId:me.id,cwd:me.workspaceCwd??l,active:me.id===V?.id,enabled:me.initialized!==!1})},me.id)),Ie&&a.jsxs("button",{type:"button",className:Ct.attachmentPreviewButton,onClick:()=>Be(Me?void 0:V?.id),"aria-label":Se(Me?"attachment.showSource":"attachment.showPreview"),"aria-pressed":Me,children:[Me?a.jsx(t5t,{"aria-hidden":!0}):a.jsx(_q,{"aria-hidden":!0}),Se(Me?"attachment.showSource":"attachment.showPreview")]}),d&&!V?a.jsxs("div",{className:"flex flex-col gap-4 p-5","data-testid":"right-panel-loading-skeleton",role:"status","aria-label":Se("common.loading"),children:[a.jsx(rk,{className:"h-5 w-2/5"}),a.jsx(rk,{className:"h-32 w-full"}),a.jsx(rk,{className:"h-4 w-4/5"}),a.jsx(rk,{className:"h-4 w-3/5"})]}):V?.kind==="terminal"||V?.kind==="web_preview"||V?.kind==="files"?null:V?V.kind==="pending"?a.jsx("div",{className:Ct.empty,role:V.loadError?"alert":"status",children:V.loadError??Se("common.loading")}):V.kind==="workflow"?V.sessionId?a.jsx($0s,{tasks:te,loading:Z,error:ce,onOpenAgent:he}):ae?a.jsx(kvs,{...ae}):a.jsx("div",{className:Ct.empty,children:Se("workflow.empty.title")}):ADe(V)&&(V.kind!=="scheduled_task"||V.task.durable)&&(V.kind!=="file"||!V.previewOnly)&&(V.kind!=="review"||!(V.changes??r).some(me=>me.diffs.length>0))&&(V.kind!=="artifact"||Ot?.metadata?.artifactType!=="web_preview_snapshot")&&!jt?a.jsx("div",{className:Ct.empty,role:"alert",children:Se("workspace.notFoundDescription")}):V.kind==="review"?a.jsx(KCs,{changes:V.changes??r,selectedPath:V.selectedPath??o,workspaceCwd:V.workspaceCwd??l,onOpenFilePreview:jt?me=>g(me,V.workspaceCwd??l,V.workspaceId):void 0,onDownloadFile:jt?(me,it)=>L9(jt,me.path,bQt(me.path),it):void 0,onDownloadError:me=>{const it=Se("common.downloadFailed",{message:Wa(me)});W?W(new Error(it,{cause:me}),it):console.error(it,me)}}):V.kind==="file"?V.attachmentId&&!V.previewData&&V.previewContent===void 0?a.jsx("div",{className:Ct.empty,role:V.loadError?"alert":"status",children:V.loadError??Se("common.loading")}):V.sourcePreview&&V.previewData&&!P9(V.workspacePath,V.previewMimeType||V.previewData.type)&&!M9(V.workspacePath,V.previewMimeType||V.previewData.type)&&!JT({workspacePath:V.workspacePath,mimeType:V.previewMimeType||V.previewData.type})&&!FM(V.previewMimeType||V.previewData.type,V.workspacePath)?a.jsx(pxe,{data:V.previewData,title:V.title,image:!!XT(V.workspacePath)&&V.previewData.type.startsWith("image/")}):a.jsx(S7,{workspacePath:V.workspacePath,artifactVersion:String(V.previewVersion??0),workspaceActions:jt,previewContent:V.previewContent,previewData:V.previewData,previewMimeType:V.previewMimeType,previewOnly:V.previewOnly,previewKind:oe||V.previewOnly&&!Me?"source":void 0},V.id):V.kind==="source"?a.jsx(dTs,{tab:V},V.id):V.kind==="artifact"?a.jsx(VCs,{artifacts:t,artifactId:V.artifactId,sourceSessionId:V.sourceSessionId,workspaceActions:jt,previewContent:V.previewContent,loading:c,error:h},V.id):V.kind==="subagent"?pe?null:a.jsx(x0s,{sessionId:V.sessionId,rootToolCallId:V.rootToolCallId,initialRootTool:V.rootTool,workspaceCwd:V.workspaceCwd??l,onRightPanelOpen:H,onArtifactsChange:Q,onOpenSubagent:q,onError:W}):V.kind==="monitor"?a.jsx(scn,{task:V.task,actions:V.sessionActions},V.id):V.kind==="shell"?a.jsx(rcn,{task:V.task,actions:V.sessionActions},V.id):V.kind==="side_task"?a.jsx(z0s,{tabId:V.id,sessionId:V.sessionId,parentSessionId:V.parentSessionId,workspaceCwd:V.workspaceCwd??l,title:V.title,shouldNameFromFirstPrompt:V.nameFromFirstPrompt,initialPrompt:V.initialPrompt,createSession:B??$Cs,onCreated:D??OCs,onTitleChange:O??BCs,onInitialPromptRefused:U,onRightPanelOpen:H,onArtifactsChange:Q,onError:W,sessionWorkflowEnabled:G,modelManagement:J,unavailableModels:X,mountUnavailableModelTooltip:de,onImageIngestionNotice:ne},V.id):V.kind==="image"?V.src?a.jsxs("div",{className:Ct.imagePreviewWrap,children:[a.jsx("img",{src:V.src,alt:V.alt??V.title,className:Ct.imagePreview}),a.jsx("a",{className:Ct.imageDownloadButton,href:V.src,download:FCs(V.src),"aria-label":Se("common.download"),title:Se("common.download"),children:a.jsx(oy,{size:16,strokeWidth:1.8})})]}):a.jsx("div",{className:Ct.empty,role:V.loadError?"alert":"status",children:V.loadError??Se("common.loading")}):V.kind==="context_usage"?a.jsx(ACs,{controls:e?.[V.sessionId],sessionActions:V.sessionActions,sessionId:V.sessionId,onOpenMemoryFile:v},V.id):V.kind==="trajectory"?a.jsx(kCs,{loadPage:V.loadPage,historyGapRevision:V.historyGapRevision},V.id):V.kind==="token_usage"?a.jsx(Kxs,{sessionActions:V.sessionActions,sessionId:V.sessionId},V.id):V.kind==="turn_calls"?a.jsx(ofs,{turnId:V.turnId,ownerSessionId:V.sessionId,recordId:V.recordId,promptId:V.promptId,promptLabel:V.promptLabel,onSelectPrompt:p,workspaceCwd:l,onOpenFile:H,onOpenAgent:q},`${V.sessionId}:${l}`):a.jsx(GCs,{task:V.task,actions:jt},V.id):a.jsxs("div",{className:Ct.emptyActions,"data-testid":"right-panel-empty-actions",children:[E.includes("files")&&a.jsxs("button",{type:"button",className:Ct.emptyAction,disabled:!_,onClick:_,children:[a.jsx("span",{className:Ct.emptyActionIcon,"aria-hidden":"true",children:a.jsx(L8,{})}),a.jsx("span",{className:Ct.emptyActionTitle,children:Se("files.title")}),a.jsx("span",{className:Ct.emptyActionHint,children:Se("files.description")}),a.jsx(Vl,{className:Ct.emptyActionChevron,strokeWidth:1.6,"aria-hidden":"true"})]}),E.includes("review")&&a.jsxs("button",{type:"button",className:Ct.emptyAction,disabled:!y||!w,onClick:w,children:[a.jsx("span",{className:Ct.emptyActionIcon,"aria-hidden":"true",children:a.jsx(Foe,{})}),a.jsx("span",{className:Ct.emptyActionTitle,children:Se("turnOutputs.review")}),a.jsx("span",{className:Ct.emptyActionHint,children:Se("turnOutputs.reviewLatest")}),a.jsx(Vl,{className:Ct.emptyActionChevron,strokeWidth:1.6,"aria-hidden":"true"})]}),E.includes("sideTask")&&I&&M&&(C.length===0&&N.length===0?a.jsxs("button",{type:"button",className:Ct.emptyAction,disabled:A,"aria-busy":A,onClick:M,children:[a.jsx("span",{className:Ct.emptyActionIcon,"aria-hidden":"true",children:a.jsx(sF,{strokeWidth:1.6})}),a.jsx("span",{className:Ct.emptyActionTitle,children:Se("sideTask.title")}),a.jsx("span",{className:Ct.emptyActionHint,children:Se("sideTask.description")}),a.jsx(Vl,{className:Ct.emptyActionChevron,strokeWidth:1.6,"aria-hidden":"true"})]}):a.jsxs(sf,{open:fe,onOpenChange:we,modal:!1,children:[a.jsx(Nh,{asChild:!0,children:a.jsxs("button",{type:"button",className:Ct.emptyAction,"aria-expanded":fe,onMouseEnter:Y,onMouseLeave:se,children:[a.jsx("span",{className:Ct.emptyActionIcon,"aria-hidden":"true",children:a.jsx(sF,{strokeWidth:1.6})}),a.jsx("span",{className:Ct.emptyActionTitle,children:Se("sideTask.title")}),a.jsx("span",{className:Ct.emptyActionHint,children:Se("sideTask.description")}),a.jsx(Vl,{className:Ct.emptyActionChevron,strokeWidth:1.6,"aria-hidden":"true"})]})}),a.jsxs(Mh,{align:"end",className:"w-80",onMouseEnter:Y,onMouseLeave:se,children:[C.map(me=>{const it=a.jsxs(a.Fragment,{children:[a.jsx("span",{className:Ct.sideTaskListTitle,children:me.title}),me.updatedAt&&a.jsx("span",{className:Ct.sideTaskListTime,children:u2(me.updatedAt,Se)})]});return L?a.jsxs(UC,{children:[a.jsx(WC,{children:it}),a.jsxs(HC,{onMouseEnter:Y,onMouseLeave:se,children:[a.jsxs(Mr,{onSelect:()=>P?.(me),children:[a.jsx(_q,{}),Se("common.open")]}),a.jsxs(Mr,{disabled:me.archivable!==!0,title:me.archivable===!0?void 0:Se("sideTask.archiveUnavailable"),onSelect:()=>{L([me])},children:[a.jsx(ST,{}),Se("sidebar.archive")]})]})]},me.sessionId):a.jsx(Mr,{onSelect:()=>P?.(me),children:it},me.sessionId)}),L&&C.length>0&&a.jsx(ug,{}),L&&C.length>0&&a.jsxs(Mr,{disabled:!Ge,onSelect:()=>{L(C)},children:[a.jsx(ST,{}),a.jsx("span",{className:Ct.sideTaskListTitle,children:Se("sideTask.archiveCompleted")})]}),F&&N.length>0&&a.jsxs(a.Fragment,{children:[C.length>0&&a.jsx(ug,{}),a.jsxs(UC,{children:[a.jsxs(WC,{children:[a.jsx(kle,{}),a.jsxs("span",{className:Ct.sideTaskListTitle,children:[Se("sidebar.archivedTitle")," (",N.length,")"]})]}),a.jsx(HC,{className:"max-h-(--radix-dropdown-menu-content-available-height) overflow-x-hidden overflow-y-auto",onMouseEnter:Y,onMouseLeave:se,children:N.map(me=>a.jsxs(Mr,{onSelect:()=>{F([me])},children:[a.jsx(kle,{}),a.jsx("span",{className:Ct.sideTaskListTitle,children:me.title}),a.jsx("span",{className:Ct.sideTaskListTime,children:Se("sidebar.unarchive")})]},me.sessionId))})]})]}),C.length>0&&a.jsx(ug,{}),a.jsxs(Mr,{onSelect:M,children:[a.jsx(q3t,{className:Ct.sideTaskNewIcon,strokeWidth:1.6,"aria-hidden":"true"}),a.jsx("span",{className:Ct.sideTaskListTitle,children:Se("sideTask.new")})]})]})]})),tt&&a.jsxs("button",{type:"button",className:Ct.emptyAction,"data-testid":"right-panel-open-web-preview",onClick:R,children:[a.jsx("span",{className:Ct.emptyActionIcon,"aria-hidden":"true",children:a.jsx(k4,{strokeWidth:1.6})}),a.jsx("span",{className:Ct.emptyActionTitle,children:Se("webPreview.title")}),a.jsx("span",{className:Ct.emptyActionHint,children:Se("webPreview.openHint")}),a.jsx(Vl,{className:Ct.emptyActionChevron,"aria-hidden":"true"})]}),ht&&a.jsxs("button",{type:"button",className:Ct.emptyAction,onClick:()=>x?.(),"data-testid":"right-panel-open-trajectory",children:[a.jsx("span",{className:Ct.emptyActionIcon,"aria-hidden":"true",children:a.jsx(jte,{strokeWidth:1.6})}),a.jsx("span",{className:Ct.emptyActionTitle,children:Se("trajectory.title")}),a.jsx("span",{className:Ct.emptyActionHint,children:Se("trajectory.description")}),a.jsx(Vl,{className:Ct.emptyActionChevron,"aria-hidden":"true"})]}),b&&a.jsxs("button",{type:"button",className:Ct.emptyAction,onClick:()=>b(),children:[a.jsx("span",{className:Ct.emptyActionIcon,"aria-hidden":"true",children:a.jsx(RR,{strokeWidth:1.6})}),a.jsx("span",{className:Ct.emptyActionTitle,children:Se("terminal.title")}),a.jsx("span",{className:Ct.emptyActionHint,children:Se("terminal.open")}),a.jsx(Vl,{className:Ct.emptyActionChevron,strokeWidth:1.6,"aria-hidden":"true"})]})]})]})]})}function WCs(){return a.jsxs("svg",{className:Ct.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 HCs(){return a.jsx("svg",{className:Ct.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 Foe(){return a.jsxs("svg",{className:Ct.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 qCs(){return a.jsxs("svg",{className:Ct.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 VCs({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(oTs,{artifact:l,sourceSessionId:n,workspaceActions:s,previewContent:r}):o?a.jsx("div",{className:Ct.empty,children:"Loading artifact..."}):i?a.jsx("div",{className:Ct.empty,children:i}):a.jsx("div",{className:Ct.empty,children:"Artifact not found."})}function GCs({task:e,actions:t}){const{t:n}=Xe(),[s,r]=u.useState(null),[o,i]=u.useState(!0),[l,c]=u.useState(null),[d,h]=u.useState(""),[f,p]=u.useState(e.prompt),[m,g]=u.useState(()=>bC(e.cron)),[v,y]=u.useState(!1),[w,b]=u.useState(!1),[x,k]=u.useState(!1),[_,S]=u.useState(!1),[R,j]=u.useState(null),E=u.useRef(0),I=u.useRef(0),C=u.useRef({actions:t,taskId:e.id,workspaceId:e.workspaceId});C.current={actions:t,taskId:e.id,workspaceId:e.workspaceId};const N=u.useCallback((W,G,J,X)=>{const de=C.current;return W===E.current&&de.actions===G&&de.taskId===J&&de.workspaceId===X},[]),A=u.useCallback((W,G,J,X)=>{const de=C.current;return W===I.current&&de.actions===G&&de.taskId===J&&de.workspaceId===X},[]);u.useEffect(()=>()=>{E.current+=1,I.current+=1},[]),u.useEffect(()=>{k(!1),S(!1),j(null)},[t,e.id,e.workspaceId]);const M=u.useCallback(async()=>{const W=++E.current,G=++I.current,J=e.id,X=e.workspaceId;if(!e.durable||!t){r(null),h(""),p(e.prompt),g(bC(e.cron)),c(null),i(!1);return}i(!0),c(null);try{const de=await t.listScheduledTasks(X);if(!N(W,t,J,X))return;const ae=de.find(ne=>ne.id===e.id)??null;r(ae),ae?(h(ae.name??""),p(ae.prompt),g(bC(ae.cron))):(h(""),p(e.prompt),g(bC(e.cron)))}catch(de){A(G,t,J,X)&&c(de instanceof Error?de.message:String(de))}finally{A(G,t,J,X)&&i(!1)}},[t,A,N,e.cron,e.durable,e.id,e.prompt,e.workspaceId]);u.useEffect(()=>{M()},[M]);const P=!e.durable,L=e.durable&&!o&&!l&&!s,F=!!s,$=s?.name||s?.prompt||e.title,B=s?.prompt??e.prompt,D=s?.cron??e.cron,O=s?.recurring??e.recurring,U=s?.enabled,H=u.useCallback(()=>{s&&(h(s.name??""),p(s.prompt),g(bC(s.cron)),j(null),y(!0))},[s]),Q=u.useCallback(()=>{y(!1),j(null),s&&(h(s.name??""),p(s.prompt),g(bC(s.cron)))},[s]),q=u.useCallback(async()=>{if(!s||!t)return;const W=sV(m);if(!W){j(n("scheduledTasks.error.invalidSchedule"));return}if(f.trim().length===0){j(n("scheduledTasks.error.emptyPrompt"));return}const G=++E.current,J=e.id,X=e.workspaceId;S(!0),j(null);try{const de=await t.updateScheduledTask(s.id,{cron:W,prompt:f.trim(),name:d.trim()||null},X);if(!N(G,t,J,X))return;r(de),h(de.name??""),p(de.prompt),g(bC(de.cron)),y(!1)}catch(de){N(G,t,J,X)&&j(de instanceof Error?de.message:String(de))}finally{N(G,t,J,X)&&S(!1)}},[t,m,N,s,d,f,n,e.id,e.workspaceId]),te=u.useCallback(async()=>{if(!s||!t)return;const W=++E.current,G=e.id,J=e.workspaceId;k(!0),j(null);try{const X=await t.updateScheduledTask(s.id,{enabled:!s.enabled},J);if(!N(W,t,G,J))return;r(X)}catch(X){N(W,t,G,J)&&j(X instanceof Error?X.message:String(X))}finally{N(W,t,G,J)&&k(!1)}},[t,N,s,e.id,e.workspaceId]),Z=u.useCallback(async()=>{if(!s||!t)return;const W=++E.current,G=e.id,J=e.workspaceId;k(!0),j(null);try{if(await t.deleteScheduledTask(s.id,J),!N(W,t,G,J))return;r(null),b(!1)}catch(X){N(W,t,G,J)&&j(X instanceof Error?X.message:String(X))}finally{N(W,t,G,J)&&k(!1)}},[t,N,s,e.id,e.workspaceId]),ce=sV(m),he=ce?xM(ce,n):null;return a.jsxs("div",{className:Ct.detail,children:[o&&a.jsx("div",{className:Ct.empty,children:n("scheduledTasks.loading")}),l&&a.jsx("div",{className:cn.loadError,children:l}),L&&a.jsx("div",{className:Ct.empty,children:n("scheduledTasks.deletedSnapshot")}),P&&a.jsx("div",{className:Ct.empty,children:n("scheduledTasks.sessionScopedSnapshot")}),!L&&a.jsx("div",{className:Ct.section,children:a.jsxs("div",{className:Ct.fieldGrid,children:[a.jsx("span",{className:Ct.fieldLabel,children:n("scheduledTasks.name")}),a.jsx("span",{className:Ct.fieldValue,children:$}),a.jsx("span",{className:Ct.fieldLabel,children:n("scheduledTasks.taskId")}),a.jsx("span",{className:Ct.fieldValue,children:e.id}),a.jsx("span",{className:Ct.fieldLabel,children:n("scheduledTasks.schedule")}),a.jsx("span",{className:Ct.fieldValue,children:xM(D,n)}),a.jsx("span",{className:Ct.fieldLabel,children:"Cron"}),a.jsx("span",{className:Ct.fieldValue,children:D}),a.jsx("span",{className:Ct.fieldLabel,children:n("scheduledTasks.type")}),a.jsx("span",{className:Ct.fieldValue,children:n(O?"scheduledTasks.repeats":"scheduledTasks.runsOnce")}),U!==void 0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:Ct.fieldLabel,children:n("scheduledTasks.status")}),a.jsx("span",{className:Ct.fieldValue,children:n(U?"scheduledTasks.enable":"scheduledTasks.disable")})]})]})}),!L&&a.jsxs("div",{className:Ct.section,children:[a.jsx("div",{className:Ct.sectionTitle,children:"Prompt"}),a.jsx("div",{className:Ct.description,children:B})]}),R&&a.jsx("div",{className:cn.formError,children:R}),a.jsxs("div",{className:Ct.actionsRow,children:[a.jsx("button",{type:"button",className:cn.primaryButton,disabled:!F||x,onClick:H,children:n("scheduledTasks.edit")}),a.jsx("button",{type:"button",className:cn.secondaryButton,disabled:!F||x,onClick:()=>void te(),children:s?.enabled?n("scheduledTasks.disable"):n("scheduledTasks.enable")}),a.jsx("button",{type:"button",className:cn.secondaryButton,disabled:!F||x,onClick:()=>b(!0),children:n("scheduledTasks.delete")})]}),w&&s&&a.jsx(Xa,{title:n("scheduledTasks.deleteConfirmTitle"),size:"sm",onClose:()=>b(!1),children:a.jsxs("div",{className:cn.formFields,children:[a.jsx("div",{className:Ct.description,children:n("scheduledTasks.deleteConfirm",{name:s.name||s.prompt})}),R&&a.jsx("div",{className:cn.formError,children:R}),a.jsxs("div",{className:cn.formActions,children:[a.jsx("button",{type:"button",className:cn.secondaryButton,onClick:()=>b(!1),disabled:x,children:n("scheduledTasks.cancel")}),a.jsx("button",{type:"button",className:cn.primaryButton,onClick:()=>void Z(),disabled:x,children:n("scheduledTasks.delete")})]})]})}),v&&a.jsx(Xa,{title:n("scheduledTasks.editTitle"),size:"md",onClose:Q,children:a.jsxs("div",{className:cn.formFields,children:[a.jsxs("label",{className:cn.field,children:[a.jsx("span",{className:cn.fieldLabel,children:n("scheduledTasks.name")}),a.jsx("input",{className:cn.input,type:"text",value:d,maxLength:200,placeholder:n("scheduledTasks.namePlaceholder"),onChange:W=>h(W.target.value)})]}),a.jsxs("label",{className:cn.field,children:[a.jsxs("span",{className:cn.fieldLabel,children:[n("scheduledTasks.prompt"),a.jsx("span",{className:cn.required,children:"*"})]}),a.jsx("textarea",{className:cn.textarea,value:f,rows:4,maxLength:1e5,placeholder:n("scheduledTasks.promptPlaceholder"),onChange:W=>p(W.target.value)})]}),a.jsxs("div",{className:cn.scheduleRow,children:[a.jsxs("label",{className:cn.field,children:[a.jsx("span",{className:cn.fieldLabel,children:n("scheduledTasks.frequency")}),a.jsx("select",{className:cn.select,value:m.frequency,onChange:W=>{const G=W.target.value;g(J=>({...J,frequency:G,...G==="hourly"?{time:"00:00"}:{}}))},children:DCs.map(W=>a.jsx("option",{value:W,children:n(`scheduledTasks.freq.${W}`)},W))})]}),(m.frequency==="daily"||m.frequency==="weekdays"||m.frequency==="weekly")&&a.jsxs("label",{className:cn.field,children:[a.jsx("span",{className:cn.fieldLabel,children:n("scheduledTasks.time")}),a.jsx("input",{className:cn.input,type:"time",value:m.time,onChange:W=>g(G=>({...G,time:W.target.value}))})]}),m.frequency==="weekly"&&a.jsxs("label",{className:cn.field,children:[a.jsx("span",{className:cn.fieldLabel,children:n("scheduledTasks.weekday")}),a.jsx("select",{className:cn.select,value:m.weekday,onChange:W=>g(G=>({...G,weekday:Number(W.target.value)})),children:n("scheduledTasks.weekdayNames").split(",").map((W,G)=>a.jsx("option",{value:G,children:W},G))})]}),m.frequency==="minutes"&&a.jsxs("label",{className:cn.field,children:[a.jsx("span",{className:cn.fieldLabel,children:n("scheduledTasks.interval")}),a.jsx("select",{className:cn.select,value:m.minuteInterval,onChange:W=>g(G=>({...G,minuteInterval:Number(W.target.value)})),children:LCs.map(W=>a.jsx("option",{value:W,children:W},W))})]}),m.frequency==="custom"&&a.jsxs("label",{className:`${cn.field} ${cn.fieldGrow}`,children:[a.jsx("span",{className:cn.fieldLabel,children:n("scheduledTasks.cron")}),a.jsx("input",{className:cn.input,type:"text",value:m.customCron,spellCheck:!1,placeholder:"0 9 * * 1-5",onChange:W=>g(G=>({...G,customCron:W.target.value}))})]})]}),a.jsx("div",{className:cn.preview,children:he?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:cn.previewLabel,children:he}),a.jsx("code",{className:cn.previewCron,children:ce})]}):a.jsx("span",{className:cn.previewInvalid,children:n("scheduledTasks.error.invalidSchedule")})}),R&&a.jsx("div",{className:cn.formError,children:R}),a.jsxs("div",{className:cn.formActions,children:[a.jsx("button",{type:"button",className:cn.secondaryButton,onClick:Q,disabled:_,children:n("scheduledTasks.cancel")}),a.jsx("button",{type:"button",className:cn.primaryButton,onClick:()=>void q(),disabled:_,children:n(_?"scheduledTasks.saving":"scheduledTasks.save")})]})]})})]})}function KCs({changes:e,selectedPath:t,workspaceCwd:n,onOpenFilePreview:s,onDownloadFile:r,onDownloadError:o}){const{t:i}=Xe(),[l,c]=u.useState(!1),[d,h]=u.useState(!0),[f,p]=u.useState(!1),[m,g]=u.useState(520),v=u.useRef(m),y=u.useRef(null),w=u.useRef(null),[b,x]=u.useState(null),[k,_]=u.useState(()=>new Set),S=u.useRef(!0);u.useEffect(()=>(S.current=!0,()=>{S.current=!1}),[]);const R=l,j=u.useMemo(()=>rTs(e,n),[e,n]);u.useEffect(()=>{x(t)},[t]),u.useEffect(()=>{v.current=m},[m]),u.useEffect(()=>{const A=y.current;if(!A)return;const M=()=>{p(A.clientWidth<PCs)};M();const P=new ResizeObserver(M);return P.observe(A),()=>P.disconnect()},[d]),u.useEffect(()=>()=>w.current?.(),[]);const E=u.useCallback(A=>{const M=y.current;if(!M)return;A.preventDefault();const P=A.currentTarget;P.setPointerCapture(A.pointerId);const L=A.clientX,F=v.current,$=M.getBoundingClientRect().width,B=Math.max(180,$-180),D=document.body.style.cursor,O=document.body.style.userSelect;let U=F,H=null;document.body.style.cursor="col-resize",document.body.style.userSelect="none";const Q=()=>{H=null,g(U)},q=ce=>{U=Math.min(B,Math.max(180,F+(ce.clientX-L))),H===null&&(H=window.requestAnimationFrame(Q))};let te=()=>{};const Z=ce=>{w.current=null,H!==null&&(window.cancelAnimationFrame(H),H=null),ce&&g(U),P.hasPointerCapture(A.pointerId)&&P.releasePointerCapture(A.pointerId),document.body.style.cursor=D,document.body.style.userSelect=O,window.removeEventListener("pointermove",q),window.removeEventListener("pointerup",te),window.removeEventListener("pointercancel",te)};te=()=>Z(!0),w.current=()=>Z(!1),window.addEventListener("pointermove",q),window.addEventListener("pointerup",te),window.addEventListener("pointercancel",te)},[]);if(e.length===0)return a.jsx("div",{className:Ct.empty,children:"No file changes to review."});const I=GZe(e),C=A=>{x(M=>M===A?null:A)},N=async A=>{if(!(!r||k.has(A.path))){_(M=>new Set(M).add(A.path));try{await r(A,()=>!S.current)}catch(M){S.current&&o(M)}finally{_(M=>{const P=new Set(M);return P.delete(A.path),P})}}};return a.jsxs("div",{className:Ct.review,children:[a.jsxs("div",{className:Ct.reviewToolbar,children:[a.jsxs("div",{className:Ct.reviewToolbarTitle,children:[a.jsx("span",{children:i("turnOutputs.previousTurn")}),a.jsx(SV,{additions:I?.additions,deletions:I?.deletions,className:Ct.lineStats,additionsClassName:Ct.additions,deletionsClassName:Ct.deletions})]}),a.jsxs("div",{className:Ct.reviewToolbarActions,children:[a.jsxs("button",{type:"button",className:Ct.reviewTotalsButton,onClick:()=>h(A=>!A),"aria-expanded":d,children:[a.jsx("span",{children:i("turnOutputs.fileCount",{count:e.length})}),a.jsx("span",{className:[Ct.chevron,d?Ct.chevronOpen:""].filter(Boolean).join(" "),"aria-hidden":"true",children:a.jsx(MDe,{})})]}),a.jsx("button",{type:"button",className:[Ct.iconButton,l?Ct.iconButtonActive:""].filter(Boolean).join(" "),onClick:()=>c(A=>!A),"aria-label":i(l?"turnOutputs.closeFileTree":"turnOutputs.openFileTree"),title:i(l?"turnOutputs.closeFileTree":"turnOutputs.openFileTree"),children:l?a.jsx(nTs,{}):a.jsx(tTs,{})})]})]}),d&&a.jsxs("div",{ref:y,className:[Ct.reviewContent,R?"":Ct.reviewContentListOnly,R&&f?Ct.reviewContentStacked:""].filter(Boolean).join(" "),style:{"--review-list-width":`${m}px`},children:[a.jsx("div",{className:[Ct.reviewList,b?Ct.reviewListWithExpanded:""].filter(Boolean).join(" "),children:e.map(A=>{const M=b===A.path,P=s&&XZe(A.path),L=r&&Lkn(A.path);return a.jsxs("div",{className:[Ct.reviewItem,M?Ct.reviewItemExpanded:""].filter(Boolean).join(" "),children:[a.jsxs("div",{className:Ct.reviewRow,"data-selected":A.path===t||void 0,children:[a.jsx("button",{type:"button",className:Ct.reviewRowToggle,onClick:()=>C(A.path),"aria-label":A.path,"aria-expanded":M}),a.jsx("span",{className:Ct.fileIcon,children:Bdt(A.path)}),a.jsxs("span",{className:Ct.reviewFileName,children:[a.jsx(QCs,{path:CJ(A.path,n),title:A.path}),P&&a.jsx("button",{type:"button",className:Ct.reviewOpenButton,onClick:()=>s?.(A),title:`${i("turnOutputs.preview")} ${A.path}`,children:i("turnOutputs.preview")}),L&&a.jsx("button",{type:"button",className:Ct.reviewOpenButton,onClick:()=>void N(A),title:`${i("common.download")} ${A.path}`,disabled:k.has(A.path),children:i(k.has(A.path)?"common.downloading":"common.download")})]}),a.jsx(SV,{additions:A.additions,deletions:A.deletions,className:Ct.lineStats,additionsClassName:Ct.additions,deletionsClassName:Ct.deletions}),a.jsx("span",{className:[Ct.chevron,M?Ct.chevronOpen:""].filter(Boolean).join(" "),"aria-hidden":"true",children:a.jsx(MDe,{})})]}),M&&a.jsx(YCs,{change:A})]},`${A.toolCallId}:${A.path}`)})}),R&&!f&&a.jsx("div",{className:Ct.reviewSplitHandle,role:"separator","aria-orientation":"vertical",onPointerDown:E}),R&&a.jsx("div",{className:Ct.tree,children:j.children.map(A=>a.jsx(Ddt,{node:A,depth:0,selectedPath:t},A.path))})]})]})}function YCs({change:e}){if(e.diffs.length===0)return a.jsx("div",{className:Ct.diffEmpty,children:"No diff available."});const t=JCs(e.diffs);return a.jsx("div",{className:Ct.diffPreview,children:t.map((n,s)=>n.fileDiff&&!n.fullContent?a.jsx(z9,{diff:n.fileDiff},s):a.jsx(XCs,{oldText:n.oldText,newText:n.newText},s))})}function JCs(e){for(let t=e.length-1;t>=0;t--)if(e[t]?.fullContent)return e.slice(t);return e}function XCs({oldText:e,newText:t}){const n=u.useRef(null),[s,r]=u.useState(null),[o,i]=u.useState(null);return u.useEffect(()=>{const l=n.current;if(!l)return;const c=()=>r(l.clientWidth>=720);c();const d=new ResizeObserver(c);return d.observe(l),()=>d.disconnect()},[]),u.useEffect(()=>{const l=n.current;if(!l||s===null)return;l.replaceChildren(),i(null);let c=!1,d=null;const h=[mst,lr.editable.of(!1),_l.readOnly.of(!0),lr.lineWrapping],f={scanLimit:1e3,timeout:500},p={margin:3,minSize:8};return xt(async()=>{const{MergeView:m,unifiedMergeView:g}=await import("./index-DjwWlZt0.js");return{MergeView:m,unifiedMergeView:g}},[]).then(({MergeView:m,unifiedMergeView:g})=>{if(!c)try{if(s){d=new m({a:{doc:e,extensions:h},b:{doc:t,extensions:h},parent:l,highlightChanges:!0,gutter:!0,revertControls:void 0,collapseUnchanged:p,diffConfig:f});return}d=new lr({doc:t,extensions:[...h,g({original:e,highlightChanges:!0,gutter:!0,mergeControls:!1,allowInlineDiffs:!0,collapseUnchanged:p,diffConfig:f})],parent:l})}catch(v){c||i(v instanceof Error?v.message:String(v))}}).catch(m=>{c||i(m instanceof Error?m.message:String(m))}),()=>{c=!0,d?.destroy()}},[s,t,e]),a.jsxs("div",{className:Ct.codeMirrorDiffWrap,children:[a.jsx("div",{ref:n,className:Ct.codeMirrorDiff}),o&&a.jsxs("div",{className:Ct.diffError,children:["Diff unavailable: ",o]})]})}function Ddt({node:e,depth:t,selectedPath:n}){const s=!!e.file,[r,o]=u.useState(!0),i=[Ct.treeRow,s?Ct.treeFile:Ct.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`},d=a.jsxs(a.Fragment,{children:[a.jsx("span",{className:Ct.treeTwisty,children:!s&&a.jsx("span",{className:[Ct.treeChevron,r?"":Ct.treeChevronClosed].filter(Boolean).join(" "),children:a.jsx(sTs,{})})}),a.jsxs("span",{className:Ct.treeContent,children:[s&&a.jsx("span",{className:Ct.fileIcon,children:Bdt(e.path)}),a.jsx("span",{className:Ct.treeName,children:e.name})]}),e.file?.isArtifact&&a.jsx("span",{className:Ct.reviewBadge,children:"artifact"})]});return a.jsxs("div",{className:Ct.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:d}):a.jsx("button",{type:"button",className:i,"data-depth":t,style:l,title:e.path,"aria-expanded":r,onClick:()=>o(h=>!h),children:d}),!s&&r&&e.children.length>0&&a.jsx("div",{className:Ct.treeChildren,style:c,children:e.children.map(h=>a.jsx(Ddt,{node:h,depth:t+1,selectedPath:n},h.path))})]})}function QCs({path:e,title:t}){const n=u.useRef(null),[s,r]=u.useState(()=>Ldt(e));return u.useLayoutEffect(()=>{const o=n.current;if(!o)return;const i=()=>r(ZCs(e,o));i();const l=new ResizeObserver(i);return l.observe(o),()=>l.disconnect()},[e]),a.jsxs("span",{ref:n,className:Ct.reviewPath,title:t??e,children:[s.prefix&&a.jsx("span",{className:Ct.pathPrefix,children:s.prefix}),a.jsx("span",{className:Ct.pathFileName,children:s.leaf})]})}function Ldt(e){const t=e.lastIndexOf("/");return t<0?{prefix:"",leaf:e}:{prefix:e.slice(0,t+1),leaf:e.slice(t+1)}}let NDe=null;function ZCs(e,t){const n=Ldt(e),s=t.clientWidth;if(s<=0)return n;const r=eTs(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 d=1;d<o.length;d++){const f=`.../${o.slice(o.length-1-d,-1).join("/")}/`;if(r(f)+l>s)break;c=f}return{prefix:c,leaf:i}}function eTs(e){NDe??=document.createElement("canvas");const t=NDe.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 tTs(){return a.jsxs("svg",{className:Ct.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 nTs(){return a.jsxs("svg",{className:Ct.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 MDe(){return a.jsx("svg",{className:Ct.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 sTs(){return a.jsx("svg",{className:Ct.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 rTs(e,t){const n={name:"",path:"",children:[]};for(const s of e){const r=CJ(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 d=o.children.find(h=>h.name===l);d||(d={name:l,path:c,children:[]},o.children.push(d)),i===r.length-1&&(d.file=s),o=d}}return Odt(n),n}function Odt(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)Odt(t)}function z4(e){return QT(e).split("/").filter(Boolean).at(-1)??e}function Bdt(e){const t=z4(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 oTs({artifact:e,sourceSessionId:t,workspaceActions:n,previewContent:s}){const{t:r}=Xe(),o=Dm(),i=xQt(e),l=A2(e.url)?e.url:void 0,c=e.metadata?.artifactType==="automation_snapshot",d=e.metadata?.artifactType==="code_review",h=e.storage==="workspace"&&!!e.workspacePath,f=cve(e);return e.metadata?.artifactType==="web_preview_snapshot"?a.jsx(zbs,{artifact:e,sourceSessionId:t}):d?e.status!=="available"?a.jsx(iTs,{status:e.status}):!h||!e.workspacePath?a.jsx(aTs,{}):a.jsx(n0s,{workspacePath:e.workspacePath,artifactVersion:jAe(e),workspaceActions:n}):h&&e.workspacePath?jJe(e)||(P9(e.workspacePath,e.mimeType)||M9(e.workspacePath,e.mimeType)||JT(e))&&e.status!=="available"&&e.status!=="changed"?a.jsx($dt,{artifact:e,workspaceActions:n}):a.jsx(S7,{workspacePath:e.workspacePath,artifactVersion:jAe(e),workspaceActions:n,previewContent:s,previewSizeBytes:e.sizeBytes,previewMimeType:JT(e)?"application/pdf":e.mimeType,imageMimeType:f,previewKind:lTs(e)?"html":cTs(e)?"markdown":f?"image":"source"}):a.jsxs("div",{className:Ct.detail,children:[a.jsxs("div",{className:Ct.section,children:[a.jsx("div",{className:Ct.sectionTitle,children:c?"Automation Snapshot":"Artifact"}),a.jsxs("div",{className:Ct.fieldGrid,children:[a.jsx(Zg,{label:"Type",value:ive(e.kind,e.workspacePath)}),a.jsx(Zg,{label:"Storage",value:e.storage}),a.jsx(Zg,{label:"Status",value:e.status}),a.jsx(Zg,{label:"Source",value:e.source}),a.jsx(Zg,{label:"Size",value:uJ(e.sizeBytes)}),a.jsx(Zg,{label:"Created",value:e.createdAt}),a.jsx(Zg,{label:"Updated",value:e.updatedAt}),e.toolName&&a.jsx(Zg,{label:"Tool",value:e.toolName}),e.toolCallId&&a.jsx(Zg,{label:"Tool call",value:e.toolCallId})]})]}),e.description&&a.jsxs("div",{className:Ct.section,children:[a.jsx("div",{className:Ct.sectionTitle,children:"Description"}),a.jsx("div",{className:Ct.description,children:e.description})]}),c&&e.metadata&&a.jsxs("div",{className:Ct.section,children:[a.jsx("div",{className:Ct.sectionTitle,children:"Details"}),a.jsxs("div",{className:Ct.fieldGrid,children:[Yj(e.metadata,"automationId","Automation ID"),Yj(e.metadata,"schedule","Schedule"),Yj(e.metadata,"timezone","Timezone"),Yj(e.metadata,"status","Status"),Yj(e.metadata,"nextRunAt","Next run"),Yj(e.metadata,"prompt","Prompt")]})]}),(i||l)&&a.jsxs("div",{className:Ct.section,children:[a.jsx("div",{className:Ct.sectionTitle,children:"Location"}),l?a.jsxs("div",{className:Ct.locationRow,children:[a.jsx("a",{className:Ct.link,href:l,target:"_blank",rel:"noopener noreferrer",onClick:p=>o(p,l),children:l}),a.jsx("a",{className:Ct.openButton,href:l,target:"_blank",rel:"noopener noreferrer",onClick:p=>o(p,l),children:r("artifact.openLink")})]}):a.jsx("div",{className:Ct.meta,children:i})]})]})}function iTs({status:e}){const{t}=Xe();return a.jsx("div",{className:Ct.previewError,role:"alert",children:t("codeReview.unavailable",{status:e})})}function aTs(){const{t:e}=Xe();return a.jsx("div",{className:Ct.previewError,role:"alert",children:e("codeReview.workspaceRequired")})}function lTs(e){const t=e.workspacePath?.toLowerCase()??"",n=xy(e.mimeType);return e.kind==="html"||t.endsWith(".html")||t.endsWith(".htm")||n==="text/html"}function cTs(e){const t=e.workspacePath?.toLowerCase()??"",n=xy(e.mimeType);return t.endsWith(".md")||t.endsWith(".markdown")||n==="text/markdown"}function $dt({artifact:e,workspaceActions:t}){const{t:n}=Xe(),[s,r]=u.useState(null),[o,i]=u.useState(!1),l=u.useRef(!0),c=e.workspacePath;u.useEffect(()=>(l.current=!0,()=>{l.current=!1}),[]);const d=async()=>{if(e.workspacePath){i(!0),r(null);try{await L9(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:Ct.detail,children:a.jsxs("div",{className:Ct.section,children:[a.jsx("div",{className:Ct.sectionTitle,children:n("common.download")}),a.jsxs("div",{className:Ct.fieldGrid,children:[a.jsx(Zg,{label:"Type",value:ive(e.kind,e.workspacePath)}),a.jsx(Zg,{label:"Size",value:uJ(e.sizeBytes)}),c?a.jsx(Zg,{label:"Location",value:c}):null,e.status!=="available"&&e.status!=="changed"?a.jsx(Zg,{label:"Status",value:e.status??"missing"}):null]}),a.jsx("div",{className:Ct.downloadRow,children:a.jsx("button",{type:"button",className:Ct.downloadButton,onClick:()=>{d()},disabled:o||e.status!=="available"&&e.status!=="changed",children:n(o?"common.downloading":"common.download")})}),s&&a.jsx("div",{className:Ct.previewError,children:s})]})})}function dTs({tab:e}){const{t}=Xe(),n=Da(),s=dA(e.workspaceCwd),r=s?.actions,o=Dm(),[i,l]=u.useState(0),[c,d]=u.useState(),[h,f]=u.useState(),[p,m]=u.useState(),g=e.source,v=g.locator,y=e.owner.isCurrent()&&n.sessionId===e.sourceSessionId&&n.capabilities?.features.includes("session_sources")&&s?.workspaceId===e.workspaceId&&(!!s||e.workspaceCwd===void 0&&v.type!=="workspace_file")&&(v.type!=="workspace_file"||g.workspaceCwd===n.workspaceCwd),w=v.type==="workspace_file"?v.workspacePath:v.type==="attachment"?v.attachmentId:"",b=JT({workspacePath:w});if(u.useEffect(()=>{let k=!1;return d(void 0),f(void 0),m(void 0),!y||v.type==="url"?void 0:((async()=>{if(v.type==="attachment"){const S=await e.sessionActions.readAttachment(v.attachmentId);if(k||!e.owner.isCurrent())return;const R=Uint8Array.from(atob(S.data),j=>j.charCodeAt(0));d(new Blob([R],{type:S.mimeType}))}else if(b&&r){const S=await j2(r.readFileBytes,w,"application/pdf",{statFile:r.stat,isCancelled:()=>k||!e.owner.isCurrent()});!k&&e.owner.isCurrent()&&d(S)}})().catch(S=>{!k&&e.owner.isCurrent()&&f(Wa(S))}),()=>{k=!0})},[i,y,v,w,b,e.owner,e.sessionActions,r]),y&&v.type==="url")return a.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[a.jsx("h3",{children:g.title}),g.description&&a.jsx("p",{children:g.description}),a.jsx("p",{className:"break-all text-sm text-muted-foreground",children:v.url}),A2(v.url)&&a.jsx("a",{className:"text-primary underline",href:v.url,target:"_blank",rel:"noopener noreferrer",onClick:k=>o(k,v.url),children:t("sources.openOriginal")})]});if(!y||!s&&v.type!=="attachment")return a.jsx("div",{className:Ct.empty,role:"alert",children:t("sources.unavailable")});const x=v.type==="workspace_file"&&!b&&jJe({workspacePath:w});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:w,children:w}),a.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[p&&a.jsx(Ne,{variant:"ghost",size:"icon-sm",asChild:!0,children:a.jsx("a",{href:p,download:g.title,"aria-label":`Download ${g.title}`,title:t("common.download"),children:a.jsx(oy,{})})}),h&&a.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>l(k=>k+1),children:t("common.retry")})]})]}),h?a.jsx("div",{className:Ct.previewError,role:"alert",children:h}):x?a.jsxs("div",{className:"p-4",children:[a.jsx("p",{children:t("attachment.previewUnsupported")}),a.jsx(Ne,{onClick:()=>void L9(r,w,"application/octet-stream",()=>!e.owner.isCurrent()).catch(k=>{e.owner.isCurrent()&&f(Wa(k))}),children:t("common.download")})]}):(v.type==="attachment"||b)&&!c?a.jsx("div",{className:Ct.empty,role:"status",children:t("common.loading")}):c&&!P9(w,c.type)&&!M9(w,c.type)&&!JT({workspacePath:w,mimeType:c.type})&&!FM(c.type,w)?a.jsx(pxe,{data:c,title:g.title,onDownloadUrl:m,showDownload:!1,image:!!XT(w)&&c.type.startsWith("image/")}):a.jsx("div",{className:"relative min-h-0 flex-1 overflow-auto",children:a.jsx(S7,{workspacePath:w,workspaceActions:r,onLoadError:f,previewData:c,previewOnly:v.type==="attachment",downloadName:v.type==="attachment"?g.title:void 0,previewMimeType:c?.type,previewKind:/\.html?$/i.test(w)||xy(c?.type)==="text/html"?"source":void 0},i)})]})}function pxe({data:e,title:t,image:n,onDownloadUrl:s,showDownload:r=!0}){const[o,i]=u.useState();return u.useEffect(()=>{const l=URL.createObjectURL(e);return i(l),s?.(l),()=>URL.revokeObjectURL(l)},[e,s]),o?a.jsxs("div",{className:Ct.imagePreviewWrap,children:[n?a.jsx("img",{className:Ct.imagePreview,src:o,alt:t}):a.jsx(zdt,{name:t,mimeType:e.type,size:e.size}),r&&a.jsx("a",{href:o,download:t,"aria-label":`Download ${t}`,children:a.jsx(oy,{})})]}):null}function S7({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewSizeBytes:r,previewData:o,previewMimeType:i,imageMimeType:l,previewKind:c,previewOnly:d,onLoadError:h,sourceRenderer:f,downloadName:p}){const{t:m}=Xe();if(P9(e,i||o?.type))return a.jsx(o0s,{workspacePath:e,workspaceActions:n,data:o,artifactVersion:t,downloadName:p});if(M9(e,i||o?.type))return a.jsx(Rm,{resetKeys:[e,n,o,t],fallback:a.jsxs("div",{children:[a.jsx("div",{role:"alert",className:Ct.previewError,children:m("excel.invalid")}),o?a.jsx(pxe,{data:o,title:e.split(/[/\\]/).pop(),image:!1}):n?a.jsx($dt,{artifact:{workspacePath:e,kind:"document",mimeType:i,status:"available"},workspaceActions:n},e):null]}),children:a.jsx(u.Suspense,{fallback:a.jsx("div",{className:Ct.empty,role:"status",children:m("common.loading")}),children:a.jsx(MCs,{workspacePath:e,workspaceActions:n,data:o,artifactVersion:t})})});if(o)return a.jsx(uTs,{workspacePath:e,workspaceActions:n,data:o,mimeType:i,previewKind:c,onLoadError:h});if(JT({workspacePath:e,mimeType:i}))return a.jsx(fTs,{workspacePath:e,artifactVersion:t,workspaceActions:n,onLoadError:h});const g=e.toLowerCase(),v=l??XT(e),y=c??(g.endsWith(".html")||g.endsWith(".htm")?"html":g.endsWith(".md")||g.endsWith(".markdown")?"markdown":v?"image":"source");return y==="html"?a.jsx(mTs,{workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewSizeBytes:r,previewOnly:d,onLoadError:h}):y==="markdown"?a.jsx(vTs,{workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewSizeBytes:r,previewOnly:d,onLoadError:h}):y==="image"&&v?a.jsx(pTs,{workspacePath:e,artifactVersion:t,workspaceActions:n,mimeType:v,onLoadError:h}):a.jsx(Udt,{sourceRenderer:f,workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:d,onLoadError:h})}function uTs({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 JT({workspacePath:e,mimeType:i})?a.jsx(Fdt,{data:n,mimeType:"application/pdf",title:e}):FM(i,e)?a.jsx(hTs,{workspacePath:e,workspaceActions:t,data:n,previewKind:r,onLoadError:o}):a.jsx(zdt,{name:e,mimeType:i,size:n.size})}function hTs({workspacePath:e,workspaceActions:t,data:n,previewKind:s,onLoadError:r}){const{t:o}=Xe(),[i,l]=u.useState(),[c,d]=u.useState();return u.useEffect(()=>{const h=new FileReader;return l(void 0),d(void 0),h.onload=()=>l(String(h.result??"")),h.onerror=()=>{const f=o("attachment.readFailed");d(f),r?.(f)},h.readAsText(n),()=>{h.readyState===FileReader.LOADING&&h.abort()}},[n,r,o]),c?a.jsx("div",{className:Ct.previewError,children:c}):i===void 0?a.jsx("div",{className:Ct.empty,children:o("attachment.loadingFile")}):a.jsx(S7,{workspacePath:e,workspaceActions:t,previewContent:i,previewSizeBytes:n.size,previewOnly:!0,previewKind:s})}function fTs({workspacePath:e,artifactVersion:t,workspaceActions:n,onLoadError:s}){const{t:r}=Xe(),[o,i]=u.useState(),[l,c]=u.useState(),[d,h]=u.useState(0);return u.useEffect(()=>{let f=!1;return i(void 0),c(void 0),j2(n.readFileBytes,e,"application/pdf",{statFile:n.stat,isCancelled:()=>f}).then(p=>{f||i(p)},p=>{if(f)return;const m=Wa(p);c(m),s?.(m)}),()=>{f=!0}},[e,n,t,d,s]),l?a.jsxs("div",{className:Ct.empty,children:[a.jsx("div",{role:"alert",className:Ct.previewError,children:l}),a.jsx(Ne,{onClick:()=>h(f=>f+1),children:r("common.retry")})]}):o?a.jsx(Fdt,{data:o,mimeType:"application/pdf",title:e}):a.jsx("div",{className:Ct.empty,role:"status",children:r("attachment.loadingPreview")})}function Fdt({data:e,mimeType:t,title:n}){const{t:s}=Xe(),[r,o]=u.useState();return u.useEffect(()=>{const i=URL.createObjectURL(e.type===t?e:new Blob([e],{type:t}));return o(i),()=>URL.revokeObjectURL(i)},[e,t]),r?a.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[a.jsx("div",{className:"flex justify-end border-b border-border p-1",children:a.jsx(Ne,{variant:"ghost",size:"sm",asChild:!0,children:a.jsxs("a",{href:r,download:z4(n),"aria-label":`Download ${z4(n)}`,children:[a.jsx(oy,{"aria-hidden":"true"}),s("common.download")]})})}),navigator.pdfViewerEnabled===!1?a.jsx("div",{className:Ct.empty,children:s("attachment.previewUnsupported")}):a.jsx("iframe",{className:`${Ct.pdfAttachmentPreview} min-h-0 flex-1`,src:r,title:`Preview ${n}`})]}):a.jsx("div",{className:Ct.empty,children:s("attachment.loadingPreview")})}function zdt({name:e,mimeType:t,size:n}){const{t:s}=Xe();return a.jsxs("div",{className:Ct.unsupportedAttachmentPreview,children:[a.jsx(Tb,{name:e,mimeType:t,"aria-hidden":"true"}),a.jsx("div",{children:s("attachment.previewUnsupported")}),a.jsxs("div",{className:Ct.unsupportedAttachmentMeta,children:[t," · ",uJ(n)]})]})}function pTs({workspacePath:e,artifactVersion:t,workspaceActions:n,mimeType:s,onLoadError:r}){const[o,i]=u.useState(null),[l,c]=u.useState(null);return u.useEffect(()=>{let d=!1,h;return i(null),c(null),j2((f,p)=>n.readFileBytes(f,p),e,s,{statFile:f=>n.stat(f),isCancelled:()=>d}).then(f=>{d||(h=URL.createObjectURL(f),i(h))}).catch(f=>{if(d)return;const p=f instanceof Error?f.message:String(f);c(p),r?.(p)}),()=>{d=!0,h&&URL.revokeObjectURL(h)}},[t,s,r,n,e]),a.jsxs("div",{className:Ct.imagePreviewWrap,children:[o?a.jsxs(a.Fragment,{children:[a.jsx("img",{className:Ct.imagePreview,src:o,alt:z4(e)}),a.jsx("a",{className:Ct.imageDownloadButton,href:o,download:z4(e),"aria-label":`Download ${z4(e)}`,title:"Download",children:a.jsx(oy,{size:16,strokeWidth:1.8})})]}):l?null:a.jsx("div",{className:Ct.empty,children:"Loading image..."}),l&&a.jsx("div",{className:Ct.previewError,children:l})]})}function mxe({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:r,onLoadError:o,maxPreviewBytes:i}){const{t:l}=Xe(),[c,d]=u.useState(s??null),[h,f]=u.useState(),[p,m]=u.useState(null);return u.useEffect(()=>{let g=!1;if(d(s??null),m(null),f(void 0),!r)return n.stat(e).then(v=>{if(!g){if(v.type==="directory")throw new Error("Directories cannot be opened as artifacts.");if(i!==void 0&&v.sizeBytes>i)throw new Error(l("files.sourceTooLarge"));return n.readWorkspaceFile(e,{maxBytes:256*1024})}}).then(async v=>{if(g||!v||!v.truncated)return v;const y=await j2((w,b)=>n.readFileBytes(w,b),e,"application/octet-stream",{statFile:w=>n.stat(w),isCancelled:()=>g,maxBytes:i});return{sizeBytes:y.size,content:new TextDecoder(v.encoding||"utf-8").decode(await y.arrayBuffer())}}).then(v=>{g||!v||(f(v.sizeBytes),d(v.content))}).catch(v=>{if(g)return;const y=v instanceof Error?v.message:String(v);m(y),o?.(y)}),()=>{g=!0}},[t,s,r,o,n,e,i,l]),{content:c,error:p,sizeBytes:h}}function mTs({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewSizeBytes:r,previewOnly:o,onLoadError:i}){const{content:l,error:c,sizeBytes:d}=mxe({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:o,onLoadError:i});return a.jsxs("div",{className:Ct.htmlPreviewWrap,children:[l===null?!c&&a.jsx("div",{className:Ct.empty,children:"Loading preview..."}):a.jsx(Wdt,{content:l,sizeBytes:d??r,workspacePath:e,workspaceActions:n,children:()=>a.jsx(gTs,{content:l,workspacePath:e})}),c&&a.jsx("div",{className:Ct.previewError,children:c})]})}function gTs({content:e,workspacePath:t}){const n=`Preview ${t}`,{t:s}=Xe(),[r,o]=u.useState(null),[i,l]=u.useState(null);return u.useEffect(()=>{const c=new AbortController;return o(null),l(null),kQt(e,n,c.signal).then(d=>{c.signal.aborted||o(d)},d=>{c.signal.aborted||l(Wa(d))}),()=>c.abort()},[e,n]),i?a.jsx("div",{className:Ct.previewError,children:s("artifact.previewFailed",{message:i})}):r===null?a.jsx("div",{className:Ct.empty,children:s("attachment.loadingPreview")}):a.jsx("iframe",{className:Ct.htmlPreview,referrerPolicy:"no-referrer",sandbox:"allow-scripts",srcDoc:r,title:n})}function Udt({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:r,onLoadError:o,sourceRenderer:i}){const l=u.useRef(null),[c,d]=u.useState(null),{content:h,error:f}=mxe({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:r,onLoadError:o,maxPreviewBytes:i?4*1024*1024:void 0});return u.useEffect(()=>{const p=l.current;if(!p||h===null)return;p.replaceChildren(),d(null);let m;try{m=new lr({doc:h,extensions:[mst,lr.editable.of(!1),_l.readOnly.of(!0),lr.lineWrapping],parent:p})}catch(g){d(g instanceof Error?g.message:String(g));return}return()=>m.destroy()},[h,i]),a.jsxs("div",{className:Ct.filePreviewWrap,children:[h===null?!f&&a.jsx("div",{className:Ct.empty,children:"Loading file..."}):i?a.jsx("div",{className:Ct.codeMirrorFile,children:i(h)}):a.jsx("div",{ref:l,className:Ct.codeMirrorFile}),(f||c)&&a.jsx("div",{className:Ct.previewError,children:f||c})]})}function Wdt({content:e,sizeBytes:t,workspacePath:n,workspaceActions:s,children:r}){const{t:o}=Xe(),[i,l]=u.useState(null);if(!u.useMemo(()=>(t??new TextEncoder().encode(e).byteLength)>1024*1024,[e,t]))return r();const d=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(Ne,{className:"ml-auto shrink-0",variant:"outline",size:"sm",onClick:()=>l(d?null:e),children:o(d?"artifact.showSource":"artifact.renderFullPreview")})]}),a.jsx("div",{className:"relative min-h-0 flex-1 overflow-auto",children:d?r():a.jsx(Udt,{workspacePath:n,workspaceActions:s,previewContent:e,previewOnly:!0})})]})}function vTs({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewSizeBytes:r,previewOnly:o,onLoadError:i}){const{content:l,error:c,sizeBytes:d}=mxe({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:o,onLoadError:i});return a.jsxs("div",{className:Ct.htmlPreviewWrap,children:[l===null?!c&&a.jsx("div",{className:Ct.empty,children:"Loading preview..."}):a.jsx(Wdt,{content:l,sizeBytes:d??r,workspacePath:e,workspaceActions:n,children:()=>a.jsx("div",{className:Ct.markdownPreviewWrap,children:a.jsx(dp,{content:l})})}),c&&a.jsx("div",{className:Ct.previewError,children:c})]})}function Zg({label:e,value:t}){return t?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:Ct.fieldLabel,children:e}),a.jsx("span",{className:Ct.fieldValue,children:t})]}):null}function Yj(e,t,n){const s=e[t];return s==null||s===""?null:a.jsx(Zg,{label:n,value:String(s)},t)}/**
2984
2984
  * @license
2985
2985
  * Copyright 2025 Qwen Team
2986
2986
  * SPDX-License-Identifier: Apache-2.0