@agimon-ai/po-cloudflare 0.0.2-alpha.76 → 0.0.2-alpha.78

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 (168) hide show
  1. package/dist/{approval-BlHIxC2J.js → approval-DRipNxVh.js} +4 -0
  2. package/dist/{approvalSession-UtzXVEB4.js → approvalSession-DPQQRkG4.js} +2 -2
  3. package/dist/assets/assets/{CodeEditorView-CaFk98Ji.js → CodeEditorView-CwDhkcuX.js} +2 -2
  4. package/dist/assets/assets/{abnfDiagram-WEYOIA3C-gzdpxFaJ.js → abnfDiagram-WEYOIA3C-x7ICShZ-.js} +2 -2
  5. package/dist/assets/assets/{architecture-WOLXFQ4H-TugrtWoO.js → architecture-WOLXFQ4H-BbNcuwIa.js} +1 -1
  6. package/dist/assets/assets/{architectureDiagram-ZHVYKT53-Xy_pnmaH.js → architectureDiagram-ZHVYKT53-BaKFNXDN.js} +2 -2
  7. package/dist/assets/assets/{blockDiagram-RJAE7QA3-pH1-jWYL.js → blockDiagram-RJAE7QA3-BpBDuUhc.js} +2 -2
  8. package/dist/assets/assets/{c4Diagram-XDPPPE54-CWmWk7y2.js → c4Diagram-XDPPPE54-CH1AYBxk.js} +2 -2
  9. package/dist/assets/assets/channel-DUu4-rZu.js +2 -0
  10. package/dist/assets/assets/{chunk-2E7WHVMD-C2O60zos.js → chunk-2E7WHVMD-zuvalEA0.js} +2 -2
  11. package/dist/assets/assets/{chunk-4EMNKR2T-CEHzGYY0.js → chunk-4EMNKR2T-Y1aujIa_.js} +2 -2
  12. package/dist/assets/assets/{chunk-55XCU76K-CjyzuqJm.js → chunk-55XCU76K-Cj_usw4a.js} +2 -2
  13. package/dist/assets/assets/{chunk-7S6XSTFO-Db8_vjDs.js → chunk-7S6XSTFO-CNv4j2oa.js} +2 -2
  14. package/dist/assets/assets/{chunk-AQDTSKZB-92c_fipW.js → chunk-AQDTSKZB-BgiafkbC.js} +2 -2
  15. package/dist/assets/assets/{chunk-DSNLSHJZ-DFGW_rzV.js → chunk-DSNLSHJZ-CEqk3yOv.js} +2 -2
  16. package/dist/assets/assets/{chunk-HAGFOTED-Cpx79XgA.js → chunk-HAGFOTED-w6XwPptZ.js} +2 -2
  17. package/dist/assets/assets/{chunk-HNE4Q36P-cz6K5cWs.js → chunk-HNE4Q36P-Du2F5NKF.js} +2 -2
  18. package/dist/assets/assets/{chunk-NQOKRVIF-Bhj8Cnrq.js → chunk-NQOKRVIF-e7LK2NBD.js} +2 -2
  19. package/dist/assets/assets/{chunk-UHW7PFBP-DugRZU3d.js → chunk-UHW7PFBP-CV1yEqMO.js} +2 -2
  20. package/dist/assets/assets/{chunk-VQ5W62QI-CFXU98Td.js → chunk-VQ5W62QI-Dz5nQ93K.js} +2 -2
  21. package/dist/assets/assets/{chunk-WQQL4CDK-BDYjxxgH.js → chunk-WQQL4CDK-CR_tliyN.js} +2 -2
  22. package/dist/assets/assets/chunk-XXDRQBXY-KxRgluI2.js +2 -0
  23. package/dist/assets/assets/{chunk-YZO67HFG-Bw3Zv3ms.js → chunk-YZO67HFG-DFykz1uM.js} +2 -2
  24. package/dist/assets/assets/{chunk-ZAUX2LTX-reWd5PI6.js → chunk-ZAUX2LTX-C-HZEj8t.js} +2 -2
  25. package/dist/assets/assets/{chunk-ZCHMQSOR-RCmNKJ0K.js → chunk-ZCHMQSOR-DhOusRJf.js} +2 -2
  26. package/dist/assets/assets/{classDiagram-v2-4MYWR3UA-DOBOI7kO.js → classDiagram-v2-4MYWR3UA-CODBKWcv.js} +2 -2
  27. package/dist/assets/assets/{cose-bilkent-JH36ORCC-Dnga9ThU.js → cose-bilkent-JH36ORCC-CQBDxRkG.js} +2 -2
  28. package/dist/assets/assets/{cynefin-EF2NZ3EQ-mbxppeTd.js → cynefin-EF2NZ3EQ-BqEZr_DI.js} +1 -1
  29. package/dist/assets/assets/{cynefinDiagram-WF24UDRP-D5uSCW7P.js → cynefinDiagram-WF24UDRP-CAFtVFnZ.js} +2 -2
  30. package/dist/assets/assets/{dagre-NK4GIZVX-D3Utujwv.js → dagre-NK4GIZVX-6EbIcHjw.js} +2 -2
  31. package/dist/assets/assets/{diagram-CBK3MWTC-Bg8QfzPb.js → diagram-CBK3MWTC-DxOPl4wX.js} +2 -2
  32. package/dist/assets/assets/{diagram-I5XIIV2D-NjETU96V.js → diagram-I5XIIV2D-Dn-nrQn0.js} +2 -2
  33. package/dist/assets/assets/{diagram-ODIL2UCW-BRY10xxY.js → diagram-ODIL2UCW-Df9GeJiZ.js} +2 -2
  34. package/dist/assets/assets/{diagram-PFBEJUXE-CO5Nfc2a.js → diagram-PFBEJUXE-CzsqYRcB.js} +2 -2
  35. package/dist/assets/assets/{diagram-RJA3I4VV-jxuLnXXk.js → diagram-RJA3I4VV-Chxf9kLz.js} +2 -2
  36. package/dist/assets/assets/{diagram-TYUNFSNR-B-dUsynt.js → diagram-TYUNFSNR-DsSL0naA.js} +2 -2
  37. package/dist/assets/assets/{dist-Bsp48Zck.js → dist-1eIdTf5S.js} +2 -2
  38. package/dist/assets/assets/{dist-JCg255PN.js → dist-B7Fq62ue.js} +2 -2
  39. package/dist/assets/assets/{dist-DtWJqHVb.js → dist-C-zBeZYG.js} +2 -2
  40. package/dist/assets/assets/{dist-BMmgMuDM.js → dist-CNPkFbM6.js} +2 -2
  41. package/dist/assets/assets/{dist-lOIB9DJk.js → dist-DHBIyPPx.js} +2 -2
  42. package/dist/assets/assets/{dist-9C1WeAys.js → dist-DR6uuD7b.js} +2 -2
  43. package/dist/assets/assets/{dist-C8son2cz.js → dist-Dul31jTx.js} +2 -2
  44. package/dist/assets/assets/{dist-CXebcDwS.js → dist-dedZfm22.js} +2 -2
  45. package/dist/assets/assets/{dist-CUuM0eUM.js → dist-zUhlfRuY.js} +2 -2
  46. package/dist/assets/assets/{ebnfDiagram-V4P3TTPT-KNVNlIfc.js → ebnfDiagram-V4P3TTPT-fUIcNhqL.js} +2 -2
  47. package/dist/assets/assets/{elk-QONTBCTQ-DsX7hxD1.js → elk-QONTBCTQ-BtFtt9dx.js} +2 -2
  48. package/dist/assets/assets/{erDiagram-KYQIGQAA-pjQN44eX.js → erDiagram-KYQIGQAA-8nTQgw_u.js} +2 -2
  49. package/dist/assets/assets/{eventmodeling-K75KTNOO-BCKz9w4V.js → eventmodeling-K75KTNOO-u--ksfW0.js} +1 -1
  50. package/dist/assets/assets/flowDiagram-IUGLLWBU-U-4ltU4o.js +1 -0
  51. package/dist/assets/assets/{ganttDiagram-R7GPNTJY-CeuiGYpW.js → ganttDiagram-R7GPNTJY-CWqNS4bm.js} +2 -2
  52. package/dist/assets/assets/{gitGraph-VSP46ZUC-BsN0Vwsr.js → gitGraph-VSP46ZUC-Dy9xUPnQ.js} +1 -1
  53. package/dist/assets/assets/{gitGraphDiagram-PDYL7XHY-ZIMBu3bo.js → gitGraphDiagram-PDYL7XHY-D9OwLXxL.js} +2 -2
  54. package/dist/assets/assets/{index-fYkh5qQp.js → index-Blt5rLZT.js} +90 -90
  55. package/dist/assets/assets/{info-OHQRW6UA-CJmrVYr6.js → info-OHQRW6UA-ByFo5VxO.js} +1 -1
  56. package/dist/assets/assets/{infoDiagram-MVDRKAX5-BsAIEQmU.js → infoDiagram-MVDRKAX5-DkV7tUak.js} +2 -2
  57. package/dist/assets/assets/{ishikawaDiagram-HPEHV2GE-BX_86A9r.js → ishikawaDiagram-HPEHV2GE-D62xVlJr.js} +2 -2
  58. package/dist/assets/assets/{journeyDiagram-BOSHW7O7-DVGI0WoP.js → journeyDiagram-BOSHW7O7-CmGrCQyD.js} +2 -2
  59. package/dist/assets/assets/{kanban-definition-FNSA4HC5-4RLBwWbL.js → kanban-definition-FNSA4HC5-CQ-96zcl.js} +2 -2
  60. package/dist/assets/assets/{line-BL8hbik-.js → line-LyW2S8xe.js} +2 -2
  61. package/dist/assets/assets/{linear-BWVrkBYc.js → linear-Df5iFoGG.js} +2 -2
  62. package/dist/assets/assets/{mermaid-parser.core-CMk5l3Wp.js → mermaid-parser.core-DwGEOVKN.js} +4 -4
  63. package/dist/assets/assets/{mermaid.core-DZuf73R_.js → mermaid.core-UZa2JDq1.js} +5 -5
  64. package/dist/assets/assets/{mindmap-definition-6OY57UG3-CPuk1tgo.js → mindmap-definition-6OY57UG3-DXZpBkD7.js} +2 -2
  65. package/dist/assets/assets/{packet-JDAUHWVQ-pVue6YBL.js → packet-JDAUHWVQ-DVu5opyp.js} +1 -1
  66. package/dist/assets/assets/{pegDiagram-ECIUJNBX-B8Ly6ehm.js → pegDiagram-ECIUJNBX-D2PGrJQR.js} +2 -2
  67. package/dist/assets/assets/{pie-XZMESJXO-DXAHc3bX.js → pie-XZMESJXO-CoJXcSM1.js} +1 -1
  68. package/dist/assets/assets/{pieDiagram-GNMPY74T-9nVo6xZM.js → pieDiagram-GNMPY74T-DlPni3lE.js} +2 -2
  69. package/dist/assets/assets/{quadrantDiagram-D57K4MC3-DbBqshQw.js → quadrantDiagram-D57K4MC3-tDWbeX9Y.js} +2 -2
  70. package/dist/assets/assets/{radar-ABXABTNO-CKPxbvS6.js → radar-ABXABTNO-CiE-yXqS.js} +1 -1
  71. package/dist/assets/assets/{railroad-I3PHUGI6-CULlMjWr.js → railroad-I3PHUGI6-Bt5352hi.js} +1 -1
  72. package/dist/assets/assets/{railroad-abnf-LNEFI6M7-BRjXoZsa.js → railroad-abnf-LNEFI6M7-BJH5rnqj.js} +1 -1
  73. package/dist/assets/assets/{railroad-ebnf-DWYD2UWJ-CD_uPeUF.js → railroad-ebnf-DWYD2UWJ-C0KftBWL.js} +1 -1
  74. package/dist/assets/assets/{railroad-peg-JR7BVNR7-Cv-b3SRa.js → railroad-peg-JR7BVNR7-CRa7U91X.js} +1 -1
  75. package/dist/assets/assets/{railroadDiagram-Y72NRBL7-DJ77wAhA.js → railroadDiagram-Y72NRBL7-fOs3RTR8.js} +2 -2
  76. package/dist/assets/assets/{requirementDiagram-EQYSW5RA-R7PFvkp-.js → requirementDiagram-EQYSW5RA-SvE7rYXk.js} +2 -2
  77. package/dist/assets/assets/{sankeyDiagram-SY24JHO5-DR2gLc8z.js → sankeyDiagram-SY24JHO5-nqR9ZUs4.js} +2 -2
  78. package/dist/assets/assets/{sequenceDiagram-BLEHNHQU-TwEQL0yK.js → sequenceDiagram-BLEHNHQU-CgEFMQSq.js} +2 -2
  79. package/dist/assets/assets/{src-Cv8dmcJt.js → src-B4g3Iold.js} +2 -2
  80. package/dist/assets/assets/{stateDiagram-v2-A6IESKWZ-ShloXczl.js → stateDiagram-v2-A6IESKWZ-C2jH_xDT.js} +2 -2
  81. package/dist/assets/assets/{swimlanes-B3ENRKFQ-D17E07lx.js → swimlanes-B3ENRKFQ-Dbf1mXvK.js} +2 -2
  82. package/dist/assets/assets/swimlanesDiagram-AYQRV4AK-Bc5KGsMc.js +9 -0
  83. package/dist/assets/assets/{timeline-definition-JXYKGLGB-BEvN2l_s.js → timeline-definition-JXYKGLGB-4u-pC3xz.js} +2 -2
  84. package/dist/assets/assets/{treeView-D4JQ5SDB-B0QcYOKz.js → treeView-D4JQ5SDB-CZmVi5-J.js} +1 -1
  85. package/dist/assets/assets/{treemap-SAJKECNS-CIGIJniE.js → treemap-SAJKECNS-BajhrENS.js} +1 -1
  86. package/dist/assets/assets/{usecaseDiagram-WPOLBNNX-DbS-GLv8.js → usecaseDiagram-WPOLBNNX-J1gh4d5h.js} +2 -2
  87. package/dist/assets/assets/{vennDiagram-Q3Y3IDCW-CEkmUNoT.js → vennDiagram-Q3Y3IDCW-CIRtS6C5.js} +2 -2
  88. package/dist/assets/assets/{wardley-7MLQ67FV-D9b-h7oE.js → wardley-7MLQ67FV-DjBwbtAb.js} +1 -1
  89. package/dist/assets/assets/{wardleyDiagram-IVAIDKWA-BoWIYn_M.js → wardleyDiagram-IVAIDKWA-Cui7ZUN1.js} +2 -2
  90. package/dist/assets/assets/{webpack-rEg3nylj.js → webpack-FJjN4adW.js} +2 -2
  91. package/dist/assets/assets/{xychartDiagram-4URNHDU4-xJdWE_nx.js → xychartDiagram-4URNHDU4-I-UzMoDZ.js} +2 -2
  92. package/dist/assets/bundle-asset-policy.json +1 -1
  93. package/dist/assets/index.html +1 -1
  94. package/dist/assets/plugins/chunks/po-web-runtime-C0B3uAoC.js +1 -0
  95. package/dist/assets/plugins/compositions.json +1 -1
  96. package/dist/assets/plugins/slots/{approval.09e72f36-B4Y8Wjzl.js → approval.dd60ec90-gfcirIrD.js} +1 -1
  97. package/dist/assets/plugins/slots/{artifacts.50b639bb-5Kf50LM1.js → artifacts.a078f1a5-B5YmdqFC.js} +1 -1
  98. package/dist/assets/plugins/slots/{author.ea449ace-BUAjd0RY.js → author.b2063a1b-QDThbn6B.js} +3 -3
  99. package/dist/assets/plugins/slots/{autocompact.6f428144-DUwf4L4s.js → autocompact.86aeccf4-DxTuE9o-.js} +1 -1
  100. package/dist/assets/plugins/slots/{backdrop-bamboo.6e4c928d-CT9PXrny.js → backdrop-bamboo.1a7d88ef-BfruoASs.js} +1 -1
  101. package/dist/assets/plugins/slots/{browse.fa1f1a50-ClrBioNv.js → browse.4b750f64-LwBuFuNb.js} +1 -1
  102. package/dist/assets/plugins/slots/{builtin-tools.75108f21-DmtavYBT.js → builtin-tools.0a7f0b8e-Cy2eN76-.js} +1 -1
  103. package/dist/assets/plugins/slots/{calendar.d8b70190-DmudDrcG.js → calendar.76ad65fa-CihobxD6.js} +1 -1
  104. package/dist/assets/plugins/slots/{codemode.c58fb583-BkVR1X2Y.js → codemode.ff16ac06-Dbjm7Efq.js} +1 -1
  105. package/dist/assets/plugins/slots/{domain.753f9f92-Bv-dlY79.js → domain.3ddea842-CJa-EzBA.js} +1 -1
  106. package/dist/assets/plugins/slots/{edit.804fec90-mJXCIk4G.js → edit.c5b0b072-Bp0bQ3N2.js} +1 -1
  107. package/dist/assets/plugins/slots/{files.66ffc636-CCRW8t1-.js → files.8ffcdcc0-re8nr2oz.js} +1 -1
  108. package/dist/assets/plugins/slots/{goal.45dffa01-q_Zh5QxW.js → goal.4524e2bf-C5mGe79a.js} +1 -1
  109. package/dist/assets/plugins/slots/{grep.98262cff-CTDwtVaK.js → grep.95f470b3-ClgsMgtm.js} +1 -1
  110. package/dist/assets/plugins/slots/{help.5fbd20f7-BBw7NYJI.js → help.dfbc8216-BGywkUKZ.js} +1 -1
  111. package/dist/assets/plugins/slots/{log.cb964209-BLY7IzD1.js → log.19bda339-6jMYUtlN.js} +1 -1
  112. package/dist/assets/plugins/slots/{mcp.82cc1ff5-5yoTabz8.js → mcp.ffbe405a-BnDP_LDU.js} +1 -1
  113. package/dist/assets/plugins/slots/{plan.3852ba52-DmdaEVVw.js → plan.2879a6ae-BXxVUfMI.js} +1 -1
  114. package/dist/assets/plugins/slots/{profile.ab16dcec-DOw3MhWl.js → profile.176710dd-Bc4Rwfhz.js} +1 -1
  115. package/dist/assets/plugins/slots/{prompts.ae48c07a-DQVmTxFZ.js → prompts.2c187969-CIBsOkp9.js} +1 -1
  116. package/dist/assets/plugins/slots/{read.4560591a-Bun0fKn1.js → read.1629d556-D-NY0ZCv.js} +1 -1
  117. package/dist/assets/plugins/slots/{runner.6e494d59-BDtBIqmQ.js → runner.962030e5-CCUVliK7.js} +1 -1
  118. package/dist/assets/plugins/slots/{scaffold.d87a6ee0-DZOiNwOS.js → scaffold.14b5f76b-DW44NU9X.js} +1 -1
  119. package/dist/assets/plugins/slots/{session-mcp.2be84084-DQpF2DkA.js → session-mcp.51089b63-Im-iuHcn.js} +1 -1
  120. package/dist/assets/plugins/slots/{sessions.6f47cb4c-y61JDvak.js → sessions.fc763f42-CL0PHuD4.js} +1 -1
  121. package/dist/assets/plugins/slots/{skill.62a0a1b3-C-mkriRv.js → skill.f5396fde-DHDfhNXW.js} +1 -1
  122. package/dist/assets/plugins/slots/{space.65a27e5a-Cr1HSI_z.js → space.d7bddb51-DFHblvL5.js} +1 -1
  123. package/dist/assets/plugins/slots/{subagents.8bb9992c-CrpR1Jhi.js → subagents.24539507-Db6YnHJd.js} +1 -1
  124. package/dist/assets/plugins/slots/{template-advanced.59f3f98a-CSuMHJ9x.js → template-advanced.292533fb-DyvcGxNV.js} +1 -1
  125. package/dist/assets/plugins/slots/{template-desktop.0f0b8491-C2ZheI0_.js → template-desktop.a1ef756c-5EQH-r7P.js} +1 -1
  126. package/dist/assets/plugins/slots/{template-elegant.0e3b0acf-Cq5Y_6VL.js → template-elegant.ceb23ac7-CrmEUE6V.js} +1 -1
  127. package/dist/assets/plugins/slots/{vault.3cbfcdc3-ZKO66wy8.js → vault.57fd9047-9cm8PfeP.js} +1 -1
  128. package/dist/assets/plugins/slots/{voice.a952113d-CsdoPA4G.js → voice.76006b18-BSC2gHHY.js} +1 -1
  129. package/dist/assets/plugins/slots/{web-search.65013836-C7W5RyLj.js → web-search.b025dda1-BMe5RM8K.js} +1 -1
  130. package/dist/assets/plugins/slots/{workflows.cbc5c5c0-BLNlHcfa.js → workflows.1fd6a554-CzFPuLnU.js} +1 -1
  131. package/dist/browser-BYWSPAEE.js +897 -0
  132. package/dist/{exports-Ct56PRB9.js → exports-BnHiOfC6.js} +1 -1
  133. package/dist/{index.edge-BRaAhap2.js → index.edge-By7eSfpp.js} +2 -2
  134. package/dist/sealedChannel-BeWNTWys.js +27 -0
  135. package/dist/{server-B3U0W7zD.js → server-1yS_uE-G.js} +1 -1
  136. package/dist/{server-CcKKktvn.js → server-B1kdSQrK.js} +1 -1
  137. package/dist/{server-fYfb0gN8.js → server-B3tod9fX.js} +3 -3
  138. package/dist/{server-BlbuM_IJ.js → server-BCuQ5v6n.js} +2 -2
  139. package/dist/{server-DAFM6HnJ.js → server-BGHoSIRR.js} +3 -3
  140. package/dist/{server-BUBijhBb.js → server-BN4AdrfM.js} +3 -3
  141. package/dist/{server-BSpJMYLb.js → server-Bl6gkrM7.js} +1 -1
  142. package/dist/{server-BPS6xFya.js → server-Bp5B4707.js} +1 -1
  143. package/dist/{server-D6-_DT9g.js → server-C-LM-7Mp.js} +1 -1
  144. package/dist/{server-CaFzaibK.js → server-Ca3X3h6Q.js} +1 -1
  145. package/dist/{server-CLRgSPVY.js → server-Cdrr9D-D.js} +1 -1
  146. package/dist/{server-BJssIIpm.js → server-Cj-2V-Z6.js} +1 -1
  147. package/dist/{server-Dnvp2U6V.js → server-CkEwZP4t.js} +1 -1
  148. package/dist/{server-DPG7BH6w.js → server-CodZPkK3.js} +1 -1
  149. package/dist/{server-7-DnO2Ww.js → server-CuKy4B95.js} +230 -117
  150. package/dist/{server-Dl3sng3O.js → server-D467psm_.js} +1 -1
  151. package/dist/{server-BUgDdcRW.js → server-DHAcLeIr.js} +1 -1
  152. package/dist/{server-HIbQWBba.js → server-DLZgrjI9.js} +9 -7
  153. package/dist/{server-BeAYfrzJ.js → server-DqEJjOJZ.js} +1 -1
  154. package/dist/{server-CKQwNrO8.js → server-DvXlixQN.js} +1 -1
  155. package/dist/{server-CMov-S5-.js → server-EyLWvUXw.js} +1 -1
  156. package/dist/{server-DMbdJzSQ.js → server-RF5gqssS.js} +1 -1
  157. package/dist/{server-BLcw1z6S.js → server-pp-NQWAR.js} +1 -1
  158. package/dist/{server-BqvkcVLn.js → server-rKR_yimq.js} +1 -1
  159. package/dist/{server-OzzJbeaS.js → server-sbfI6TAL.js} +2 -2
  160. package/dist/{type-DppaYz6F.js → type-1FxIJmfz.js} +2 -26
  161. package/dist/worker.js +80525 -80817
  162. package/package.json +49 -49
  163. package/dist/assets/assets/channel-CJxh7kPr.js +0 -2
  164. package/dist/assets/assets/chunk-XXDRQBXY-B7vCmBOn.js +0 -2
  165. package/dist/assets/assets/flowDiagram-IUGLLWBU-BU7xmb8h.js +0 -1
  166. package/dist/assets/assets/swimlanesDiagram-AYQRV4AK-i6-zDqZm.js +0 -9
  167. package/dist/assets/plugins/chunks/po-web-runtime-CQ9hLtG-.js +0 -1
  168. package/dist/browser-ks_k-6KA.js +0 -36
@@ -1,4 +1,4 @@
1
- import{$n as e,$r as t,At as n,Ba as r,Bt as i,Da as a,En as o,Er as s,Fa as c,Ft as l,Ha as u,Ht as d,It as f,Ji as p,Jr as m,Ki as h,Kt as g,Lt as _,Mi as v,Na as y,Nr as b,Oa as x,Pt as S,Qa as C,Qn as w,Ra as T,Sr as ee,Ta as te,Ti as ne,Tr as re,Ut as ie,Va as E,Wa as ae,Wi as D,Xi as oe,Xn as se,Yi as ce,Zi as le,Zn as O,_n as k,aa as A,ar as j,br as M,cr as N,dn as P,ea as F,eo as ue,er as de,fr as fe,gn as pe,hn as me,hr as he,ia as I,ja as ge,li as _e,mn as ve,mr as ye,ni as be,nr as xe,or as Se,pr as Ce,qa as we,qi as Te,qn as Ee,qt as L,ra as De,rn as Oe,rr as ke,sa as Ae,ta as je,tn as Me,tr as Ne,ur as Pe,xr as Fe,za as Ie}from"../chunks/po-web-runtime-CQ9hLtG-.js";var Le=`team`,Re=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],ze=`team-settings`,Be=`/agents`,Ve=[{id:`model`,label:`default model`,keyPath:[`subagents`,`model`],placeholder:`inherit existing defaults`,detail:`model used when the agent frontmatter does not set one.`,models:!0},{id:`thinking`,label:`default thinking`,keyPath:[`subagents`,`thinking`],placeholder:`inherit`,detail:`thinking level used when the agent frontmatter does not set one. off disables thinking by default.`,options:Re},{id:`fallbackModels`,label:`fallback models`,keyPath:[`subagents`,`fallbackModels`],placeholder:`provider/model:thinking, provider/model`,detail:`comma-separated model specs, tried in order. each may include a :thinking suffix.`},{id:`excludeTools`,label:`excluded tools`,keyPath:[`subagents`,`excludeTools`],placeholder:`tool-one, tool-two`,detail:`comma-separated tool names added to the layer exclusions. existing restrictions still apply.`}],He=`subagents.model`,Ue=`subagents.fallbackModels`,We=`Loaded by a plugin or domain when a session starts.`;function R(e,t){return`subagents.agents.${e}.${t}`}function Ge(e){let t=e===void 0?`/api`:`/api/workspaces/${encodeURIComponent(e)}`;return{agents:`${t}/plugins/${ze}${Be}`,read:`${t}/settings`,write:`${t}/settings/value`,models:`/api/plugins/po/models`}}function Ke(e){let t=e.lastIndexOf(`:`);return t!==-1&&Re.includes(e.slice(t+1))?e.slice(0,t):e}function qe(e){let t=new Set(e.available),n=e=>e!==void 0&&e.trim()!==``&&(t.size===0||t.has(Ke(e)));if(n(e.setting))return{model:e.setting,from:`agent setting`};if(n(e.file))return{model:e.file,from:`agent file`};let r=e.defaults.find(n);return r===void 0?void 0:{model:r,from:`team default`}}function Je(e){return(e??``).split(`,`).map(e=>e.trim()).filter(Boolean)}function Ye(e,t,n,r){let i=e=>t.values[e],a=[i(He)?.value,...Je(i(Ue)?.value)].filter(e=>!!e),o=r.map(e=>e.value);return e.map(e=>{let t=i(R(e.name,`model`)),r=i(R(e.name,`thinking`)),s={...t?.origin===n&&t.value?{model:t.value}:{},...r?.origin===n&&r.value?{thinking:r.value}:{}},c=qe({setting:t?.value,file:e.model,defaults:a,available:o});return{name:e.name,description:e.description||We,...c?{runsOn:c}:{},...Object.keys(s).length>0?{here:s}:{},...n===`host`&&(t?.origin===`repository`||r?.origin===`repository`)?{overridden:!0}:{}}})}function Xe(e){return Object.entries(e).flatMap(([e,t])=>[`model`,`thinking`].filter(e=>t[e]!==void 0).map(n=>({keyPath:[`subagents`,`agents`,e,n],value:t[n]??null})))}function z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function Ze(e){let t=await e.text();try{return t===``?void 0:JSON.parse(t)}catch{return}}function Qe(e,t){return z(e)&&typeof e.error==`string`&&e.error!==``?e.error:`Po answered ${t}.`}async function $e(e,t){let n=Ge(t),r=await e(n.agents),i=await Ze(r);if(!r.ok||!z(i)||!Array.isArray(i.agents))throw Error(Qe(i,r.status));let a=i.agents,o=new URLSearchParams;for(let e of[He,Ue,...a.flatMap(e=>[R(e.name,`model`),R(e.name,`thinking`)])])o.append(`key`,e);let[s,c]=await Promise.all([e(`${n.read}?${o.toString()}`),e(n.models)]),l=await Ze(s);if(!s.ok||!z(l)||typeof l.repoRoot!=`string`||!z(l.values))throw Error(Qe(l,s.status));let u=await Ze(c);return{agents:a,config:l,models:c.ok&&z(u)&&Array.isArray(u.models)?u.models:[]}}async function et(e,t,n){let r=await e(Ge(t).write,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({repoRoot:n.config.repoRoot,scope:n.scope,edits:Xe(n.drafts),expectedHash:n.config.hashes[n.scope]})});return r.ok?{ok:!0}:{ok:!1,stale:r.status===409,error:Qe(await Ze(r),r.status)}}var tt=`__inherit__`,nt={"agent file":`from its agent file`,"agent setting":`from agent settings`,"team default":`from the Team defaults`,"pi settings":`from Pi settings`};function rt(e,t,n){let r=t?.[n];return r===void 0?e.here?.[n]??``:r??``}function it(e){return e!==void 0&&Object.keys(e).length>0}function at({agent:t,label:n,value:r,options:i,disabled:a,onChange:o}){let s=[...new Set(i.map(e=>e.group??``))],c=r!==``&&!i.some(e=>e.value===r)?r:void 0;return _(se,{value:r===``?tt:r,disabled:a,onValueChange:e=>o(e===tt?null:e),children:[f(Ne,{"data-testid":`agent-models-${n.toLowerCase()}-${t}`,"aria-label":`${n} for ${t}`,className:`w-full text-sm`,children:f(xe,{placeholder:`Inherit`})}),_(O,{children:[f(e,{value:tt,children:`Inherit`}),c===void 0?null:_(e,{value:c,children:[c,` · not in catalog`]}),s.map(t=>_(w,{children:[t===``?null:f(de,{children:t}),i.filter(e=>(e.group??``)===t).map(t=>f(e,{value:t.value,children:t.label},t.value))]},t))]})]})}function ot({row:e,draft:n,models:r,thinkingLevels:i,busy:a=!1,onDraft:o}){let s=it(n),c=e.here?.model!==void 0||e.here?.thinking!==void 0,l=i.map(e=>({value:e,label:e}));return _(fe,{"data-testid":`agent-models-row-${e.name}`,"data-dirty":s,changed:c,className:`items-start`,children:[_(ye,{className:`gap-1`,children:[_(he,{className:`flex min-h-6 flex-wrap items-center gap-x-2 gap-y-1`,children:[f(`span`,{className:`min-w-0 break-all`,children:e.name}),c?f(`span`,{className:`sr-only`,children:`, set here`}):null,e.overridden?f(N,{tone:`yellow`,className:`shrink-0`,children:`Overridden by repository`}):null,s?f(N,{tone:`cyan`,className:`shrink-0`,children:`Unsaved`}):null,s?f(t,{variant:`ghost`,size:`xs`,"data-testid":`agent-models-revert-${e.name}`,disabled:a,onClick:()=>{o(e.name,`model`,void 0),o(e.name,`thinking`,void 0)},className:`text-po-dim`,children:`Revert`}):c?f(t,{variant:`ghost`,size:`xs`,"data-testid":`agent-models-reset-${e.name}`,disabled:a,onClick:()=>{e.here?.model!==void 0&&o(e.name,`model`,null),e.here?.thinking!==void 0&&o(e.name,`thinking`,null)},className:`text-po-dim`,children:`Reset`}):null]}),f(Ce,{children:e.description}),e.runsOn===void 0?f(`span`,{className:`text-sm text-po-dim`,children:`Runs on the session's own model`}):_(`span`,{className:`text-sm text-po-dim`,children:[`Runs on `,f(`code`,{className:`break-all font-mono text-sm text-po-text`,children:e.runsOn.model}),`,`,` `,c?`set here`:nt[e.runsOn.from]]}),_(`code`,{className:`min-w-0 max-w-full break-all font-mono text-sm text-po-dim`,children:[`subagents.agents.`,e.name]})]}),_(`div`,{className:`flex w-full flex-col gap-2 sm:w-64`,children:[f(at,{agent:e.name,label:`Model`,value:rt(e,n,`model`),options:r,disabled:a,onChange:t=>o(e.name,`model`,t)}),f(at,{agent:e.name,label:`Thinking`,value:rt(e,n,`thinking`),options:l,disabled:a,onChange:t=>o(e.name,`thinking`,t)})]})]})}function st(e){let{scope:n,agents:r,drafts:i,busy:a=!1,error:o,onSave:s,onDiscard:c,onReload:l,notice:u}=e,d=Object.values(i).filter(it).length,p=n===`host`?`this host`:`this repository`;return u===void 0?_(`div`,{className:`flex min-w-0 flex-col gap-4`,"data-testid":`agent-models`,children:[o===void 0||o===``?null:f(Se,{children:_(fe,{children:[_(ye,{role:`alert`,children:[f(he,{children:`Po couldn't load or save agent models`}),f(Ce,{"data-testid":`agent-models-error`,className:`text-po-red`,children:o})]}),f(t,{size:`sm`,variant:`outline`,disabled:a,onClick:l,children:`Reload agents`})]})}),r===void 0?o?null:f(Pe,{"aria-busy":`true`,"data-testid":`agent-models-loading`,children:`Loading agents…`}):r.length===0?f(Se,{children:f(fe,{children:_(ye,{children:[f(he,{children:`No agents yet`}),f(Ce,{children:`When you add a subagent, it shows up here. In Help mode, ask Po to add one.`})]})})}):f(Se,{children:r.map(t=>f(ot,{...e,row:t,draft:i[t.name]},t.name))}),r===void 0||r.length===0?null:_(j,{children:[f(t,{variant:d>0?`primary`:`outline`,size:`sm`,"data-testid":`agent-models-save`,loading:a,disabled:a||d===0,onClick:s,children:`Save`}),d===0?null:f(t,{variant:`ghost`,size:`sm`,"data-testid":`agent-models-discard`,disabled:a,onClick:c,children:`Discard`}),f(Pe,{"data-testid":`agent-models-note`,children:d>0?`${d} ${d===1?`agent`:`agents`} changed. Saving writes ${p}'s config.yaml for new sessions.`:`Changes apply to new sessions on ${p}.`})]})]}):f(Pe,{"data-testid":`agent-models-notice`,children:u})}var ct=`Pick a repository above to choose its agent models.`,lt=e=>e instanceof Error?e.message:String(e);function ut({scope:e,workspaceId:t,request:n,requestWithStepUp:r}){let[a,o]=L(),[s,c]=L([]),[l,u]=L(),[p,m]=L({}),[h,g]=L(!1),[_,v]=L(),y=e===`repository`&&t===void 0,b=i(t=>{v(void 0),c(t.models),u(t.config),o(Ye(t.agents,t.config,e,t.models))},[e]),x=async()=>{try{b(await $e(n,t))}catch(e){v(lt(e))}};d(()=>{if(y)return;let e=!0;return $e(n,t).then(t=>e&&b(t),t=>e&&v(lt(t))),()=>{e=!1}},[n,b,y,t]);let S=(e,t,n)=>m(r=>{let i={...r[e]};n===void 0?delete i[t]:i[t]=n;let a=Object.fromEntries(Object.entries(r).filter(([t])=>t!==e));return Object.keys(i).length===0?a:{...a,[e]:i}}),C=async()=>{if(l&&Xe(p).length!==0){g(!0);try{let n=await et(r,t,{config:l,scope:e,drafts:p});if(n.ok){m({}),await x();return}n.stale&&await x(),v(n.error)}catch(e){v(lt(e))}finally{g(!1)}}};return f(st,{scope:e,agents:a,models:s,thinkingLevels:Re,drafts:p,busy:h,..._===void 0?{}:{error:_},...y?{notice:ct}:{},onDraft:S,onSave:()=>void C(),onDiscard:()=>m({}),onReload:()=>void x()})}function dt({request:e,requestWithStepUp:t}){return f(ut,{scope:`host`,request:e,requestWithStepUp:t})}var ft=Ie({label:`Agent models`,detail:`Choose a model or thinking level for one agent. It wins over its agent file and the Team defaults.`,order:100,component:dt}),pt={id:Le,label:`Team`,detail:`subagent defaults for new sessions, used only where agent frontmatter is unset. existing overrides still apply.`,order:50,fields:Ve.map(e=>({id:e.id,label:e.label,kind:e.models===!0||e.options!==void 0?`select`:`text`,keyPath:e.keyPath,detail:e.detail,placeholder:e.placeholder,...e.models===!0?{optionsFrom:`models`}:{},...e.options===void 0?{}:{options:e.options.map(e=>({value:e,label:e}))}}))},mt=r({...pt,icon:be}),ht=ge({data:{version:1,label:`Team`,source:`subagent_runs`,destination:`agents`,icon:be}});function gt({repository:e,request:t,requestWithStepUp:n}){return f(ut,{scope:`repository`,...e?{workspaceId:e.id}:{},request:t,requestWithStepUp:n},e?.id??`none`)}var _t=c({label:`Agent models`,detail:`Choose a model or thinking level for one agent. It wins over its agent file and the Team defaults.`,order:100,component:gt}),vt=r({...pt,icon:be}),yt=`subagent_runs`,bt=`subagent_catalog`;function xt(e,t){return C(ue(e),`team`,t)}function B(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function V(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function St(e){return B(e)&&typeof e.name==`string`&&typeof e.description==`string`&&typeof e.filePath==`string`&&[`project`,`user`,`plugin`].includes(String(e.source))&&(e.packageName===void 0||typeof e.packageName==`string`)&&(e.model===void 0||typeof e.model==`string`)&&V(e.fallbackModels)&&V(e.tools)&&V(e.skills)&&V(e.extensions)&&(e.defaultContext===`fresh`||e.defaultContext===`fork`)}async function Ct(e,t){let r=await n.fetch(xt(e,`/catalog`),{signal:t,cache:`no-store`}),i=await r.json();if(!r.ok)throw Error(B(i)&&typeof i.error==`string`?i.error:`Agent catalog could not be loaded (${r.status}).`);if(!B(i)||typeof i.cwd!=`string`||!Array.isArray(i.agents)||!i.agents.every(St)||!V(i.models))throw Error(`The server returned an invalid agent catalog.`);return{cwd:i.cwd,agents:i.agents,models:i.models}}async function wt(e,t){let r=await n.fetch(xt(e,`/run`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),i=await r.json();if(!r.ok)throw Error(B(i)&&typeof i.error==`string`?i.error:`Agent could not be launched (${r.status}).`);if(!B(i)||typeof i.runId!=`string`||i.runId===``)throw Error(`The server returned an invalid run ID.`);return i.runId}function Tt(e){return e===`delivered`||e===`failed`||e===`pending`}async function Et(e,t,r){let i=await n.fetch(xt(e,`/steer`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({runId:t,message:r})}),a=await i.json();if(!i.ok)throw Error(B(a)&&typeof a.error==`string`?a.error:`Guidance could not be sent (${i.status}).`);if(!B(a)||!Tt(a.state)||typeof a.message!=`string`)throw Error(`The server returned an invalid steer result.`);return{state:a.state,message:a.message}}async function Dt(e,t){let r=await n.fetch(xt(e,`/stop`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({runId:t})}),i=await r.json();if(!r.ok)throw Error(B(i)&&typeof i.error==`string`?i.error:`The run could not be stopped (${r.status}).`)}var H=T({cwd:``,agents:[],models:[],warning:void 0,loading:!1,requestId:0,open:!1,filter:``,task:``,selected:void 0,inspected:void 0,launch:void 0});function Ot(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kt(e,t=``){H.update(e,e=>({...e,open:!0,task:t}))}function At(e,t){e.sessionId!==null&&(kt(e.sessionId,e.item.content),e.openTransientTab(t()))}function jt(e){H.update(e,e=>({...e,open:!1,task:``,launch:void 0}))}function Mt(e){let t=new AbortController,n=H.select(H.store.state,e).requestId+1;H.update(e,e=>({...e,requestId:n,loading:!0,warning:void 0}));let r=()=>!t.signal.aborted&&H.store.state[e]?.requestId===n;return Ct(e,t.signal).then(t=>{r()&&Nt.apply(e,t)}).catch(t=>{r()&&H.update(e,e=>({...e,warning:t instanceof Error?t.message:String(t)}))}).finally(()=>{r()&&H.update(e,e=>({...e,loading:!1}))}),()=>{r()&&H.update(e,e=>({...e,loading:!1})),t.abort()}}var Nt=H.channel({channel:bt,parse(e){if(!Ot(e)||typeof e.cwd!=`string`||!Array.isArray(e.agents))return null;let t=Array.isArray(e.models)?e.models.filter(e=>typeof e==`string`):[];return{cwd:e.cwd,agents:e.agents.filter(Ot),models:t,...typeof e.warning==`string`?{warning:e.warning}:{}}},reduce(e,t){let n=new Set(t.agents.map(e=>e.name));return{...e,cwd:t.cwd,agents:t.agents,models:t.models,warning:t.warning,selected:e.selected!==void 0&&n.has(e.selected)?e.selected:void 0,inspected:e.inspected!==void 0&&n.has(e.inspected)?e.inspected:void 0,launch:e.launch!==void 0&&n.has(e.launch.agent)?e.launch:void 0}}}),Pt=6e4,Ft=60*Pt;function It(e){if(e<Pt)return`<1m`;if(e<Ft)return`${Math.floor(e/Pt)}m`;let t=Math.floor(e/Ft),n=Math.floor(e%Ft/Pt);return`${t}h ${String(n).padStart(2,`0`)}m`}function Lt(e){let t=/^\/(?:Users|home)\/[^/]+/u.exec(e);return t?`~${e.slice(t[0].length)}`:e}function Rt(e){return U(e).name}function zt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function U(e){let t=e.identity?.split(`-`)[0];return!e.identity||!t?{name:e.agent,role:``,seed:e.agent}:{name:zt(t),role:e.agent,seed:e.identity}}var Bt=E({slot:`subagents.run-actions`}),Vt=new Set([`done`,`failed`,`stopped`]);function W(e){return Vt.has(e.state)}var G=T({runs:[],dismissed:[],stopRequested:[],openRunId:void 0,pendingLaunch:void 0,autoOpenRunId:void 0});function Ht(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ut(e,t){return e.filter(e=>e!==t)}function Wt(e){return e.runs.filter(t=>!e.dismissed.includes(t.runId)).sort((e,t)=>Number(W(e))-Number(W(t)))}function Gt(e){return Wt(e).filter(e=>e.state===`queued`||e.state===`running`)}async function Kt(e,t){G.update(e,e=>({...e,stopRequested:[...Ut(e.stopRequested,t),t]}));try{await Dt(e,t)}catch(n){throw G.update(e,e=>({...e,stopRequested:Ut(e.stopRequested,t)})),n}}function qt(e,t){G.update(e,e=>({...e,dismissed:[...Ut(e.dismissed,t),t],openRunId:e.openRunId===t?void 0:e.openRunId}))}function Jt(e,t){G.update(e,e=>({...e,pendingLaunch:{agent:t,knownRunIds:e.runs.map(e=>e.runId)}}))}function Yt(e){G.update(e,e=>({...e,pendingLaunch:void 0}))}function Xt(e){G.update(e,e=>({...e,autoOpenRunId:void 0}))}function Zt(e,t){G.update(e,e=>({...e,openRunId:t}))}var Qt=G.channel({channel:yt,parse(e){return!Ht(e)||!Array.isArray(e.runs)?null:{runs:e.runs.filter(Ht)}},reduce(e,{runs:t}){let n=new Map(t.map(e=>[e.runId,e])),r=e.stopRequested.filter(e=>{let t=n.get(e);return t!==void 0&&!W(t)}),i=e.dismissed.filter(e=>n.has(e)),a=e.pendingLaunch===void 0?void 0:t.find(t=>t.agent===e.pendingLaunch?.agent&&!e.pendingLaunch.knownRunIds.includes(t.runId));return{...e,runs:t,stopRequested:r,dismissed:i,pendingLaunch:a===void 0?e.pendingLaunch:void 0,autoOpenRunId:a===void 0?e.autoOpenRunId:a.runId}}});function $t(e,t){let n=t.trim().toLowerCase();return n===``?[...e]:e.filter(e=>[e.name,e.source,e.packageName??``,e.description,...e.tools].some(e=>e.toLowerCase().includes(n)))}function en(e,t){let n=new Set,r=[];for(let i of[e.model??``,...e.fallbackModels,...t])i===``||n.has(i)||(n.add(i),r.push(i));return r}var tn={project:`Project`,user:`User`,plugin:`Package`};function nn({label:t,value:n,onChange:r,options:i,disabled:a}){return _(se,{disabled:a,value:n,onValueChange:r,children:[f(Ne,{"aria-label":t,className:`h-9 w-full`,children:f(xe,{})}),f(O,{children:i.map(([t,n])=>f(e,{value:t,children:n},t))})]})}function rn({agents:e,models:n,initialSearch:r=``,initialSelected:i,initialTask:a=``,initialFork:o,loading:s=!1,warning:c,cwd:u=``,catalogNote:d,runNote:p,onClose:v,onLaunch:y,onSource:b}){let[x,S]=L(r),[C,w]=L(`all`),[T,ee]=L(i),[te,ne]=L(a),[re,ie]=L(o===void 0?void 0:o?`fork`:`fresh`),[E,ae]=L(`default`),[D,se]=L(!1),O=g(!1),[k,A]=L(),j=$t(e,x).filter(e=>C===`all`||e.source===C),M=T===void 0?j[0]:j.find(e=>e.name===T),P=re??M?.defaultContext??`fresh`,F=e=>{ee(e.name),ie(e.defaultContext),ae(`default`),A(void 0)},ue=async()=>{if(!(!M||s||O.current)){O.current=!0,se(!0),A(void 0);try{await y({agent:M.name,task:te,fork:P===`fork`,...E==="default"?{}:{model:E}})}catch(e){A(e instanceof Error?e.message:String(e))}finally{O.current=!1,se(!1)}}},de=E==="default"?M?.model??`Runtime default`:E,fe=P===`fresh`?`Fresh context`:`This conversation`;return _(h,{"data-testid":`launch-dialog`,className:`w-6xl`,"aria-describedby":`launcher-description`,children:[f(oe,{dismissible:!0,closeLabel:`Close new agent run`,className:`p-6 sm:px-6`,children:_(`div`,{className:`space-y-1`,children:[f(le,{children:`New agent run`}),f(Te,{id:`launcher-description`,children:`Choose an agent, review its setup, then give it a task.`})]})}),_(`div`,{className:`grid min-h-0 overflow-y-auto md:grid-cols-3`,children:[_(`aside`,{"aria-label":`Agent catalog`,onKeyDown:e=>{if(!(D||e.target.getAttribute(`role`)===`combobox`)){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=j.findIndex(e=>e.name===M?.name),n=j[(t+(e.key===`ArrowDown`?1:-1)+j.length)%j.length];n&&F(n)}if(e.target.tagName!==`INPUT`&&(e.key===`f`&&ie(`fork`),e.key===`i`)){let t=e.currentTarget.parentElement?.querySelector(`details`);t&&(t.open=!t.open)}}},className:`flex flex-col gap-3 border-b border-po-border p-5 md:border-r md:border-b-0`,children:[f(Me,{autoFocus:!0,"data-testid":`catalog-filter`,disabled:D,"aria-label":`Find an agent`,placeholder:`Find an agent…`,value:x,onChange:e=>S(e.target.value)}),f(nn,{disabled:D,label:`Source filter`,value:C,onChange:w,options:[[`all`,`All sources`],[`project`,`Project`],[`user`,`User`],[`plugin`,`Package`]]}),_(`div`,{className:`flex flex-col gap-1 py-2`,children:[s?f(`p`,{role:`status`,className:`text-sm text-po-dim`,children:`Loading agents…`}):null,c?f(`p`,{role:`alert`,className:`text-sm text-po-red`,children:c}):null,j.map(e=>_(t,{variant:`ghost`,size:`card`,"aria-pressed":M?.name===e.name,className:M?.name===e.name?`border-l-4 border-po-green bg-po-selected/15`:`border-l-4 border-transparent`,disabled:D,onClick:()=>{F(e)},children:[f(`span`,{className:`font-semibold text-po-hi`,children:e.name}),f(`span`,{className:`text-sm text-po-dim`,children:e.description.split(`.`)[0]}),_(`span`,{className:`text-sm text-po-dim`,children:[tn[e.source],` · `,e.model??`Default model`]})]},e.name)),j.length===0&&!s?_(`div`,{className:`space-y-3 py-6`,children:[f(`p`,{className:`text-base text-po-hi`,children:`No matching agents`}),f(`p`,{className:`text-sm text-po-dim`,children:`Try another name or source.`}),f(t,{onClick:()=>{S(``),w(`all`)},children:`Clear filters`})]}):null]}),_(`p`,{className:`mt-auto text-sm text-po-dim`,children:[j.length,` agents`,d?` · ${d}`:``]})]}),f(`section`,{className:`space-y-5 p-6 md:col-span-2`,"aria-label":`Agent definition and run`,children:M?_(l,{children:[_(`div`,{className:`space-y-2`,children:[f(`p`,{className:`text-sm text-po-dim`,children:`Agent definition`}),_(`div`,{className:`flex items-center gap-3`,children:[f(`h2`,{className:`text-2xl font-semibold text-po-hi`,children:M.name}),f(N,{children:tn[M.source]})]}),f(`p`,{className:`text-base text-po-text`,children:M.description}),f(`p`,{className:`break-all font-mono text-sm text-po-dim`,children:b?.(M)?f(`button`,{type:`button`,className:`text-left text-po-green underline`,onClick:b(M),children:M.filePath}):M.filePath}),M.packageName?f(`p`,{className:`text-sm text-po-dim`,children:M.packageName}):null,_(`details`,{className:`text-base text-po-text`,children:[f(`summary`,{className:`cursor-pointer text-po-green`,children:`View instructions`}),f(`p`,{className:`mt-2 whitespace-pre-wrap rounded-md bg-po-deep p-3 text-sm`,children:b?.(M)?f(t,{variant:`link`,onClick:b(M),children:`Open source instructions`}):`Instructions stay in the source definition. File viewing is not available in this host.`})]})]}),f(`dl`,{className:`grid gap-x-6 gap-y-3 text-base sm:grid-cols-2`,children:[[`Model`,M.model??`Runtime default`],[`Tools`,M.tools.length?M.tools.join(` · `):`All session tools (not narrowed)`],[`Fallback models`,M.fallbackModels.join(` · `)||`None specified`],[`Skills`,M.skills.join(` · `)||`None specified`],[`Default context`,M.defaultContext===`fresh`?`Fresh`:`This conversation`],[`Extensions`,M.extensions.join(` · `)||`None specified`]].map(([e,t])=>_(`div`,{className:`space-y-1`,children:[f(`dt`,{className:`text-sm text-po-dim`,children:e}),f(`dd`,{className:`break-words text-po-text`,children:t})]},e))}),_(`div`,{className:`space-y-3 border-t border-po-border pt-4`,children:[f(`h3`,{className:`text-lg font-semibold text-po-hi`,children:`This run`}),_(`label`,{className:`flex flex-col gap-1 text-base text-po-text`,children:[`Task`,f(m,{"data-testid":`launch-task`,disabled:D,placeholder:`What should the agent do? Leave empty to use its own prompt.`,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),ue())},rows:3,value:te,onChange:e=>{ne(e.target.value),A(void 0)}})]}),_(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[_(`div`,{className:`space-y-1`,children:[f(`p`,{className:`text-base text-po-text`,children:`Context`}),f(nn,{disabled:D,label:`Context`,value:P,onChange:ie,options:[[`fresh`,`Fresh context`],[`fork`,`This conversation`]]}),f(`p`,{className:`text-sm text-po-dim`,children:`Start clean, or include this conversation.`})]}),_(`div`,{className:`space-y-1`,children:[f(`p`,{className:`text-base text-po-text`,children:`Model override`}),f(nn,{disabled:D,label:`Model override`,value:E,onChange:ae,options:[[`default`,`Use agent default`],...en(M,n).map(e=>[e,e])]}),f(`p`,{className:`text-sm text-po-dim`,children:`Changes apply only to this run.`})]})]})]})]}):f(`p`,{className:`py-12 text-base text-po-dim`,children:`Choose an agent to review its definition. Clear the filters if no agents match.`})})]}),_(ce,{variant:`bar`,className:`gap-3 p-4 sm:px-6 sm:py-4`,children:[_(`div`,{className:`min-w-0 flex-1 space-y-1 text-sm text-po-dim`,children:[f(`p`,{className:`break-words`,children:M?`${M.name} · ${fe} · ${de}`:`No agent selected`}),f(`p`,{role:`status`,children:p??`Enter starts the run · Shift+Enter for a new line${u?` · ${u}`:``}`}),k?f(`p`,{role:`alert`,className:`text-po-red`,children:k}):null]}),f(t,{"data-testid":`launch-cancel`,onClick:v,children:`Cancel`}),f(t,{"data-testid":`launch-submit`,variant:`primary`,disabled:!M||D||s,onClick:()=>void ue(),children:D?`Starting…`:`Start run`})]})]})}function an({sessionId:e,agent:t,agents:n,loading:r,warning:i,onSource:a,cwd:o,models:s,fork:c,initialTask:l,onClose:u,onLaunched:d}){return f(D,{open:!0,onOpenChange:e=>{e||u()},children:f(rn,{agents:n??(t?[t]:[]),models:s,initialSelected:t?.name,initialTask:l,initialFork:c,loading:r,warning:i,cwd:o,onSource:a,onClose:u,onLaunch:async t=>{Jt(e,t.agent);try{await wt(e,t),d()}catch(t){throw Yt(e),t}}})})}function on({sessionId:e,onClose:t,onSource:n}){let r=S(H.store,t=>H.select(t,e));return f(an,{sessionId:e,agents:r.agents,agent:r.agents.find(e=>e.name===(r.launch?.agent??r.selected)),cwd:r.cwd,models:r.models,fork:r.launch?.fork,initialTask:r.task,loading:r.loading,warning:r.warning,onSource:n,onClose:t,onLaunched:t})}var sn={queued:{label:`QUEUED`,tone:`neutral`},running:{label:`RUNNING`,tone:`running`},done:{label:`DONE`,tone:`ok`},failed:{label:`FAILED`,tone:`error`},stopped:{label:`STOPPED`,tone:`neutral`}};function cn(e,t){let n=e.endedAt??(e.state===`running`||e.state===`queued`?t:e.lastUpdate);return It(Math.max(0,n-e.startedAt))}function ln({run:e}){let t=g(null),[n]=L(Date.now);return d(()=>{let n,r=()=>{let i=t.current?.firstChild,a=Date.now();i&&(i.nodeValue=cn(e,a)),!W(e)&&e.endedAt===void 0&&(n=setTimeout(r,6e4-Math.max(0,a-e.startedAt)%6e4))};return r(),()=>clearTimeout(n)},[e]),f(`span`,{ref:t,children:cn(e,n)})}function un({sessionId:e,run:n,stopping:r}){let[i,a]=L(),o=(e,t)=>{e.stopPropagation(),t()},s=()=>{a(void 0),Kt(e,n.runId).catch(e=>a(e instanceof Error?e.message:String(e)))};return W(n)?f(t,{variant:`outline`,size:`xs`,"data-testid":`run-clear-${n.runId}`,title:`clear this run from the grid`,onClick:t=>o(t,()=>qt(e,n.runId)),children:`clear`}):_(l,{children:[i?f(`span`,{role:`alert`,"data-testid":`run-stop-error-${n.runId}`,title:i,className:`min-w-0 truncate text-sm text-po-red`,children:i}):null,f(t,{variant:r?`outline`:`danger-outline`,size:`xs`,"data-testid":`run-stop-${n.runId}`,"data-stopping":r,disabled:r,title:r?`stop requested; the run reports its own final state`:`ask the runtime to stop this run`,onClick:e=>o(e,s),children:r?`stopping…`:`stop`})]})}var K=`Not reported`,dn={done:`This run has finished. Start a new run from Agents.`,failed:`This run failed. Start a new run from Agents.`,stopped:`This run was stopped. Start a new run from Agents.`};function q({label:e,children:t}){return _(`div`,{className:`flex gap-3`,children:[f(`span`,{className:`w-24 shrink-0 text-sm text-po-dim`,children:e}),f(`div`,{className:`min-w-0 flex-1 break-words text-base text-po-text`,children:t})]})}function fn({run:e}){let t=[e?.toolCount===void 0?void 0:`${e.toolCount} tools`,e?.tokens===void 0?void 0:`${e.tokens.toLocaleString()} tokens`].filter(Boolean).join(` · `);return _(l,{children:[_(q,{label:`Agent`,children:[f(`span`,{className:`font-semibold text-po-hi`,children:e?.agent??K}),e?.agentDescription?f(`p`,{className:`text-po-dim`,children:e.agentDescription}):null,e?.agentFilePath?f(`p`,{className:`font-mono text-sm text-po-dim`,children:e.agentFilePath}):null]}),_(q,{label:`Model`,children:[e?.model??K,e?.model&&e.modelSource===`configured`?f(`span`,{className:`text-po-dim`,children:` · configured, not confirmed by the runtime`}):null]}),f(q,{label:`Thinking`,children:f(`span`,{className:`capitalize`,children:e?.thinking??K})}),f(q,{label:`Prompt`,children:e?.promptWithheld?f(`span`,{className:`text-po-dim`,children:`Withheld: this task was marked sensitive.`}):f(`pre`,{className:`max-h-40 overflow-y-auto rounded-md bg-po-deep px-3 py-2 font-sans whitespace-pre-wrap break-words`,children:e?.task||K})}),e?.taskRef?f(q,{label:`Task`,children:f(N,{tone:`violet`,size:`xs`,className:`rounded-sm bg-po-violet/10`,children:e.taskRef})}):null,f(q,{label:`Folder`,children:f(`span`,{className:`font-mono text-sm`,children:e?.cwd?Lt(e.cwd):K})}),f(q,{label:`Usage`,children:f(`span`,{className:`text-po-dim`,children:t||K})})]})}function pn({run:e,gone:n,elapsed:r,stopControl:i,thread:a,canSteer:o,stopping:s,guidance:c,sending:l,error:u,notice:d,onGuidanceChange:h,onSubmit:g,initialInfoOpen:v=!1}){let[y,x]=L(v),S=ie(),C=e?sn[e.state]:void 0,w={variant:`outline`,size:`md`,className:`min-w-0 max-w-full gap-2`,"aria-expanded":y,"aria-controls":S,onClick:()=>x(e=>!e)},T=e&&W(e)?dn[e.state]:e?.canSteer===!1&&!n?`This runtime does not take guidance while it runs.`:`Guidance is unavailable for this run.`;return _(`div`,{"data-testid":`agent-thread-panel`,className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-po-bg`,children:[_(`div`,{"data-testid":`agent-thread-header`,className:`flex h-11 shrink-0 items-center gap-2.5 border-b border-po-border-soft bg-po-rail px-[26px]`,children:[e?f(p,{name:U(e).name,seed:U(e).seed,size:`sm`}):null,f(`span`,{"data-testid":`agent-thread-agent`,className:`min-w-0 shrink truncate text-base font-semibold text-po-hi`,children:e?Rt(e):`Agent run`}),e&&U(e).role?f(`span`,{className:`min-w-0 shrink truncate text-sm text-po-dim`,children:U(e).role}):null,C?f(b,{tone:C.tone,"data-testid":`agent-thread-state`,className:`shrink-0`,children:s&&e&&!W(e)?`STOPPING…`:C.label}):null,f(`span`,{className:`min-w-0 flex-1 truncate text-sm text-po-dim`,children:r}),i]}),n?f(`div`,{"data-testid":`agent-thread-gone`,className:`shrink-0 border-b border-po-border-soft px-[26px] py-2 text-sm text-po-dim`,children:`This run is no longer listed. Its thread stays readable.`}):null,f(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:a}),f(`section`,{id:S,"aria-label":`Run info`,"data-testid":`run-info`,hidden:!y,className:`mx-[26px] mb-2 flex max-h-[40vh] shrink-0 flex-col gap-3 overflow-y-auto rounded-lg border border-po-border bg-po-panel px-4 py-3`,children:f(fn,{run:e})}),o?f(`form`,{"data-testid":`agent-steer-composer`,className:`shrink-0 px-[26px] pt-2 pb-2`,onSubmit:e=>{e.preventDefault(),g()},children:_(`div`,{className:`rounded-lg border border-po-border bg-po-panel transition-colors focus-within:border-po-blue/60`,children:[f(m,{variant:`bare`,"data-testid":`agent-steer-input`,"aria-label":`Steering guidance`,rows:2,value:c,readOnly:l,disabled:s,placeholder:s?`Stopping, guidance paused`:`Guide this agent · it reads this at its next step`,className:`w-full px-4 pt-3 text-lg leading-relaxed`,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}),u?f(`p`,{role:`alert`,"data-testid":`agent-steer-error`,className:`px-4 pt-1 text-sm text-po-red`,children:u}):null,_(`div`,{className:`flex items-center gap-3 px-4 pt-1 pb-3`,children:[f(`span`,{className:`min-w-0 flex-1`}),f(`span`,{role:`status`,"data-testid":`agent-steer-hint`,title:d,className:`min-w-0 truncate text-sm text-po-dim`,children:d??`Shift + Enter for a new line`}),_(t,{"data-testid":`agent-steer-submit`,type:`submit`,variant:`primary`,size:`lg`,className:`shrink-0 gap-2`,disabled:s||l||c.trim()===``,children:[f(ke,{className:`size-4`}),l?`Sending…`:`Send`]})]})]})}):f(`div`,{"data-testid":`agent-thread-end`,className:`shrink-0 px-[26px] pt-3 pb-2 text-sm text-po-dim`,children:T}),_(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 px-[26px] pb-4`,children:[_(t,{...w,"data-testid":`run-chip-agent`,children:[f(`span`,{"aria-hidden":!0,className:`size-1.5 shrink-0 rounded-full bg-po-magenta`}),f(`span`,{className:`truncate`,children:e?.agent??`Agent`}),f(ne,{"aria-hidden":!0,className:`size-3.5 shrink-0`})]}),_(t,{...w,"data-testid":`run-chip-model`,children:[f(`span`,{"aria-hidden":!0,className:`size-1.5 shrink-0 rounded-full bg-po-green`}),f(`span`,{className:`truncate`,children:e?.model?e.model.split(`/`).pop()??e.model:`Model not reported`}),e?.thinking?f(`span`,{className:`shrink-0 text-po-dim`,children:e.thinking}):null,f(ne,{"aria-hidden":!0,className:`size-3.5 shrink-0`})]}),_(t,{...w,"data-testid":`run-chip-prompt`,children:[f(`span`,{"aria-hidden":!0,className:`size-1.5 shrink-0 rounded-full bg-po-blue`}),`Prompt`,f(ne,{"aria-hidden":!0,className:`size-3.5 shrink-0`})]})]})]})}var mn=`subagents-run-`;function hn(e){let t=e.runId;return{id:`${mn}${t}`,label:Rt(e),panel:e=>f(gn,{...e,runId:t},`${e.sessionId}:${t}`)}}function gn({sessionId:e,runId:t,renderThread:n}){let{runs:r,stopRequested:i}=S(G.store,t=>G.select(t,e)),a=r.find(e=>e.runId===t),[o,s]=L(a);a!==void 0&&a!==o&&s(a);let c=a??o,l=a===void 0,[u,d]=L(``),[p,m]=L(!1),[h,g]=L(),[_,v]=L(),y=e!==null&&a!==void 0&&!W(a),b=i.includes(t),x=y&&a.canSteer!==!1,C=async()=>{let n=u.trim();if(x&&!b&&n&&!p){m(!0),g(void 0),v(void 0);try{let r=await Et(e,t,n);if(r.state===`failed`){g(r.message);return}d(``),r.state===`pending`&&v(r.message)}catch(e){g(e instanceof Error?e.message:String(e))}finally{m(!1)}}};return f(pn,{run:c,gone:l,elapsed:c?f(ln,{run:l?{...c,endedAt:c.endedAt??c.lastUpdate}:c}):void 0,stopControl:y?f(un,{sessionId:e,run:a,stopping:b}):void 0,thread:n(t),canSteer:x,stopping:b,guidance:u,sending:p,error:h,notice:_,onGuidanceChange:d,onSubmit:()=>void C()})}var _n=`subagents-fleet`,vn=8;function yn({run:e}){let t=e.task.split(`
1
+ import{$n as e,$r as t,At as n,Ba as r,Bt as i,Da as a,En as o,Er as s,Fa as c,Ft as l,Ha as u,Ht as d,It as f,Ji as p,Jr as m,Ki as h,Kt as g,Lt as _,Mi as v,Na as y,Nr as b,Oa as x,Pt as S,Qa as C,Qn as w,Ra as T,Sr as ee,Ta as te,Ti as ne,Tr as re,Ut as ie,Va as E,Wa as ae,Wi as D,Xi as oe,Xn as se,Yi as ce,Zi as le,Zn as O,_n as k,aa as A,ar as j,br as M,cr as N,dn as P,ea as F,eo as ue,er as de,fr as fe,gn as pe,hn as me,hr as he,ia as I,ja as ge,li as _e,mn as ve,mr as ye,ni as be,nr as xe,or as Se,pr as Ce,qa as we,qi as Te,qn as Ee,qt as L,ra as De,rn as Oe,rr as ke,sa as Ae,ta as je,tn as Me,tr as Ne,ur as Pe,xr as Fe,za as Ie}from"../chunks/po-web-runtime-C0B3uAoC.js";var Le=`team`,Re=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],ze=`team-settings`,Be=`/agents`,Ve=[{id:`model`,label:`default model`,keyPath:[`subagents`,`model`],placeholder:`inherit existing defaults`,detail:`model used when the agent frontmatter does not set one.`,models:!0},{id:`thinking`,label:`default thinking`,keyPath:[`subagents`,`thinking`],placeholder:`inherit`,detail:`thinking level used when the agent frontmatter does not set one. off disables thinking by default.`,options:Re},{id:`fallbackModels`,label:`fallback models`,keyPath:[`subagents`,`fallbackModels`],placeholder:`provider/model:thinking, provider/model`,detail:`comma-separated model specs, tried in order. each may include a :thinking suffix.`},{id:`excludeTools`,label:`excluded tools`,keyPath:[`subagents`,`excludeTools`],placeholder:`tool-one, tool-two`,detail:`comma-separated tool names added to the layer exclusions. existing restrictions still apply.`}],He=`subagents.model`,Ue=`subagents.fallbackModels`,We=`Loaded by a plugin or domain when a session starts.`;function R(e,t){return`subagents.agents.${e}.${t}`}function Ge(e){let t=e===void 0?`/api`:`/api/workspaces/${encodeURIComponent(e)}`;return{agents:`${t}/plugins/${ze}${Be}`,read:`${t}/settings`,write:`${t}/settings/value`,models:`/api/plugins/po/models`}}function Ke(e){let t=e.lastIndexOf(`:`);return t!==-1&&Re.includes(e.slice(t+1))?e.slice(0,t):e}function qe(e){let t=new Set(e.available),n=e=>e!==void 0&&e.trim()!==``&&(t.size===0||t.has(Ke(e)));if(n(e.setting))return{model:e.setting,from:`agent setting`};if(n(e.file))return{model:e.file,from:`agent file`};let r=e.defaults.find(n);return r===void 0?void 0:{model:r,from:`team default`}}function Je(e){return(e??``).split(`,`).map(e=>e.trim()).filter(Boolean)}function Ye(e,t,n,r){let i=e=>t.values[e],a=[i(He)?.value,...Je(i(Ue)?.value)].filter(e=>!!e),o=r.map(e=>e.value);return e.map(e=>{let t=i(R(e.name,`model`)),r=i(R(e.name,`thinking`)),s={...t?.origin===n&&t.value?{model:t.value}:{},...r?.origin===n&&r.value?{thinking:r.value}:{}},c=qe({setting:t?.value,file:e.model,defaults:a,available:o});return{name:e.name,description:e.description||We,...c?{runsOn:c}:{},...Object.keys(s).length>0?{here:s}:{},...n===`host`&&(t?.origin===`repository`||r?.origin===`repository`)?{overridden:!0}:{}}})}function Xe(e){return Object.entries(e).flatMap(([e,t])=>[`model`,`thinking`].filter(e=>t[e]!==void 0).map(n=>({keyPath:[`subagents`,`agents`,e,n],value:t[n]??null})))}function z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function Ze(e){let t=await e.text();try{return t===``?void 0:JSON.parse(t)}catch{return}}function Qe(e,t){return z(e)&&typeof e.error==`string`&&e.error!==``?e.error:`Po answered ${t}.`}async function $e(e,t){let n=Ge(t),r=await e(n.agents),i=await Ze(r);if(!r.ok||!z(i)||!Array.isArray(i.agents))throw Error(Qe(i,r.status));let a=i.agents,o=new URLSearchParams;for(let e of[He,Ue,...a.flatMap(e=>[R(e.name,`model`),R(e.name,`thinking`)])])o.append(`key`,e);let[s,c]=await Promise.all([e(`${n.read}?${o.toString()}`),e(n.models)]),l=await Ze(s);if(!s.ok||!z(l)||typeof l.repoRoot!=`string`||!z(l.values))throw Error(Qe(l,s.status));let u=await Ze(c);return{agents:a,config:l,models:c.ok&&z(u)&&Array.isArray(u.models)?u.models:[]}}async function et(e,t,n){let r=await e(Ge(t).write,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({repoRoot:n.config.repoRoot,scope:n.scope,edits:Xe(n.drafts),expectedHash:n.config.hashes[n.scope]})});return r.ok?{ok:!0}:{ok:!1,stale:r.status===409,error:Qe(await Ze(r),r.status)}}var tt=`__inherit__`,nt={"agent file":`from its agent file`,"agent setting":`from agent settings`,"team default":`from the Team defaults`,"pi settings":`from Pi settings`};function rt(e,t,n){let r=t?.[n];return r===void 0?e.here?.[n]??``:r??``}function it(e){return e!==void 0&&Object.keys(e).length>0}function at({agent:t,label:n,value:r,options:i,disabled:a,onChange:o}){let s=[...new Set(i.map(e=>e.group??``))],c=r!==``&&!i.some(e=>e.value===r)?r:void 0;return _(se,{value:r===``?tt:r,disabled:a,onValueChange:e=>o(e===tt?null:e),children:[f(Ne,{"data-testid":`agent-models-${n.toLowerCase()}-${t}`,"aria-label":`${n} for ${t}`,className:`w-full text-sm`,children:f(xe,{placeholder:`Inherit`})}),_(O,{children:[f(e,{value:tt,children:`Inherit`}),c===void 0?null:_(e,{value:c,children:[c,` · not in catalog`]}),s.map(t=>_(w,{children:[t===``?null:f(de,{children:t}),i.filter(e=>(e.group??``)===t).map(t=>f(e,{value:t.value,children:t.label},t.value))]},t))]})]})}function ot({row:e,draft:n,models:r,thinkingLevels:i,busy:a=!1,onDraft:o}){let s=it(n),c=e.here?.model!==void 0||e.here?.thinking!==void 0,l=i.map(e=>({value:e,label:e}));return _(fe,{"data-testid":`agent-models-row-${e.name}`,"data-dirty":s,changed:c,className:`items-start`,children:[_(ye,{className:`gap-1`,children:[_(he,{className:`flex min-h-6 flex-wrap items-center gap-x-2 gap-y-1`,children:[f(`span`,{className:`min-w-0 break-all`,children:e.name}),c?f(`span`,{className:`sr-only`,children:`, set here`}):null,e.overridden?f(N,{tone:`yellow`,className:`shrink-0`,children:`Overridden by repository`}):null,s?f(N,{tone:`cyan`,className:`shrink-0`,children:`Unsaved`}):null,s?f(t,{variant:`ghost`,size:`xs`,"data-testid":`agent-models-revert-${e.name}`,disabled:a,onClick:()=>{o(e.name,`model`,void 0),o(e.name,`thinking`,void 0)},className:`text-po-dim`,children:`Revert`}):c?f(t,{variant:`ghost`,size:`xs`,"data-testid":`agent-models-reset-${e.name}`,disabled:a,onClick:()=>{e.here?.model!==void 0&&o(e.name,`model`,null),e.here?.thinking!==void 0&&o(e.name,`thinking`,null)},className:`text-po-dim`,children:`Reset`}):null]}),f(Ce,{children:e.description}),e.runsOn===void 0?f(`span`,{className:`text-sm text-po-dim`,children:`Runs on the session's own model`}):_(`span`,{className:`text-sm text-po-dim`,children:[`Runs on `,f(`code`,{className:`break-all font-mono text-sm text-po-text`,children:e.runsOn.model}),`,`,` `,c?`set here`:nt[e.runsOn.from]]}),_(`code`,{className:`min-w-0 max-w-full break-all font-mono text-sm text-po-dim`,children:[`subagents.agents.`,e.name]})]}),_(`div`,{className:`flex w-full flex-col gap-2 sm:w-64`,children:[f(at,{agent:e.name,label:`Model`,value:rt(e,n,`model`),options:r,disabled:a,onChange:t=>o(e.name,`model`,t)}),f(at,{agent:e.name,label:`Thinking`,value:rt(e,n,`thinking`),options:l,disabled:a,onChange:t=>o(e.name,`thinking`,t)})]})]})}function st(e){let{scope:n,agents:r,drafts:i,busy:a=!1,error:o,onSave:s,onDiscard:c,onReload:l,notice:u}=e,d=Object.values(i).filter(it).length,p=n===`host`?`this host`:`this repository`;return u===void 0?_(`div`,{className:`flex min-w-0 flex-col gap-4`,"data-testid":`agent-models`,children:[o===void 0||o===``?null:f(Se,{children:_(fe,{children:[_(ye,{role:`alert`,children:[f(he,{children:`Po couldn't load or save agent models`}),f(Ce,{"data-testid":`agent-models-error`,className:`text-po-red`,children:o})]}),f(t,{size:`sm`,variant:`outline`,disabled:a,onClick:l,children:`Reload agents`})]})}),r===void 0?o?null:f(Pe,{"aria-busy":`true`,"data-testid":`agent-models-loading`,children:`Loading agents…`}):r.length===0?f(Se,{children:f(fe,{children:_(ye,{children:[f(he,{children:`No agents yet`}),f(Ce,{children:`When you add a subagent, it shows up here. In Help mode, ask Po to add one.`})]})})}):f(Se,{children:r.map(t=>f(ot,{...e,row:t,draft:i[t.name]},t.name))}),r===void 0||r.length===0?null:_(j,{children:[f(t,{variant:d>0?`primary`:`outline`,size:`sm`,"data-testid":`agent-models-save`,loading:a,disabled:a||d===0,onClick:s,children:`Save`}),d===0?null:f(t,{variant:`ghost`,size:`sm`,"data-testid":`agent-models-discard`,disabled:a,onClick:c,children:`Discard`}),f(Pe,{"data-testid":`agent-models-note`,children:d>0?`${d} ${d===1?`agent`:`agents`} changed. Saving writes ${p}'s config.yaml for new sessions.`:`Changes apply to new sessions on ${p}.`})]})]}):f(Pe,{"data-testid":`agent-models-notice`,children:u})}var ct=`Pick a repository above to choose its agent models.`,lt=e=>e instanceof Error?e.message:String(e);function ut({scope:e,workspaceId:t,request:n,requestWithStepUp:r}){let[a,o]=L(),[s,c]=L([]),[l,u]=L(),[p,m]=L({}),[h,g]=L(!1),[_,v]=L(),y=e===`repository`&&t===void 0,b=i(t=>{v(void 0),c(t.models),u(t.config),o(Ye(t.agents,t.config,e,t.models))},[e]),x=async()=>{try{b(await $e(n,t))}catch(e){v(lt(e))}};d(()=>{if(y)return;let e=!0;return $e(n,t).then(t=>e&&b(t),t=>e&&v(lt(t))),()=>{e=!1}},[n,b,y,t]);let S=(e,t,n)=>m(r=>{let i={...r[e]};n===void 0?delete i[t]:i[t]=n;let a=Object.fromEntries(Object.entries(r).filter(([t])=>t!==e));return Object.keys(i).length===0?a:{...a,[e]:i}}),C=async()=>{if(l&&Xe(p).length!==0){g(!0);try{let n=await et(r,t,{config:l,scope:e,drafts:p});if(n.ok){m({}),await x();return}n.stale&&await x(),v(n.error)}catch(e){v(lt(e))}finally{g(!1)}}};return f(st,{scope:e,agents:a,models:s,thinkingLevels:Re,drafts:p,busy:h,..._===void 0?{}:{error:_},...y?{notice:ct}:{},onDraft:S,onSave:()=>void C(),onDiscard:()=>m({}),onReload:()=>void x()})}function dt({request:e,requestWithStepUp:t}){return f(ut,{scope:`host`,request:e,requestWithStepUp:t})}var ft=Ie({label:`Agent models`,detail:`Choose a model or thinking level for one agent. It wins over its agent file and the Team defaults.`,order:100,component:dt}),pt={id:Le,label:`Team`,detail:`subagent defaults for new sessions, used only where agent frontmatter is unset. existing overrides still apply.`,order:50,fields:Ve.map(e=>({id:e.id,label:e.label,kind:e.models===!0||e.options!==void 0?`select`:`text`,keyPath:e.keyPath,detail:e.detail,placeholder:e.placeholder,...e.models===!0?{optionsFrom:`models`}:{},...e.options===void 0?{}:{options:e.options.map(e=>({value:e,label:e}))}}))},mt=r({...pt,icon:be}),ht=ge({data:{version:1,label:`Team`,source:`subagent_runs`,destination:`agents`,icon:be}});function gt({repository:e,request:t,requestWithStepUp:n}){return f(ut,{scope:`repository`,...e?{workspaceId:e.id}:{},request:t,requestWithStepUp:n},e?.id??`none`)}var _t=c({label:`Agent models`,detail:`Choose a model or thinking level for one agent. It wins over its agent file and the Team defaults.`,order:100,component:gt}),vt=r({...pt,icon:be}),yt=`subagent_runs`,bt=`subagent_catalog`;function xt(e,t){return C(ue(e),`team`,t)}function B(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function V(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function St(e){return B(e)&&typeof e.name==`string`&&typeof e.description==`string`&&typeof e.filePath==`string`&&[`project`,`user`,`plugin`].includes(String(e.source))&&(e.packageName===void 0||typeof e.packageName==`string`)&&(e.model===void 0||typeof e.model==`string`)&&V(e.fallbackModels)&&V(e.tools)&&V(e.skills)&&V(e.extensions)&&(e.defaultContext===`fresh`||e.defaultContext===`fork`)}async function Ct(e,t){let r=await n.fetch(xt(e,`/catalog`),{signal:t,cache:`no-store`}),i=await r.json();if(!r.ok)throw Error(B(i)&&typeof i.error==`string`?i.error:`Agent catalog could not be loaded (${r.status}).`);if(!B(i)||typeof i.cwd!=`string`||!Array.isArray(i.agents)||!i.agents.every(St)||!V(i.models))throw Error(`The server returned an invalid agent catalog.`);return{cwd:i.cwd,agents:i.agents,models:i.models}}async function wt(e,t){let r=await n.fetch(xt(e,`/run`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),i=await r.json();if(!r.ok)throw Error(B(i)&&typeof i.error==`string`?i.error:`Agent could not be launched (${r.status}).`);if(!B(i)||typeof i.runId!=`string`||i.runId===``)throw Error(`The server returned an invalid run ID.`);return i.runId}function Tt(e){return e===`delivered`||e===`failed`||e===`pending`}async function Et(e,t,r){let i=await n.fetch(xt(e,`/steer`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({runId:t,message:r})}),a=await i.json();if(!i.ok)throw Error(B(a)&&typeof a.error==`string`?a.error:`Guidance could not be sent (${i.status}).`);if(!B(a)||!Tt(a.state)||typeof a.message!=`string`)throw Error(`The server returned an invalid steer result.`);return{state:a.state,message:a.message}}async function Dt(e,t){let r=await n.fetch(xt(e,`/stop`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({runId:t})}),i=await r.json();if(!r.ok)throw Error(B(i)&&typeof i.error==`string`?i.error:`The run could not be stopped (${r.status}).`)}var H=T({cwd:``,agents:[],models:[],warning:void 0,loading:!1,requestId:0,open:!1,filter:``,task:``,selected:void 0,inspected:void 0,launch:void 0});function Ot(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kt(e,t=``){H.update(e,e=>({...e,open:!0,task:t}))}function At(e,t){e.sessionId!==null&&(kt(e.sessionId,e.item.content),e.openTransientTab(t()))}function jt(e){H.update(e,e=>({...e,open:!1,task:``,launch:void 0}))}function Mt(e){let t=new AbortController,n=H.select(H.store.state,e).requestId+1;H.update(e,e=>({...e,requestId:n,loading:!0,warning:void 0}));let r=()=>!t.signal.aborted&&H.store.state[e]?.requestId===n;return Ct(e,t.signal).then(t=>{r()&&Nt.apply(e,t)}).catch(t=>{r()&&H.update(e,e=>({...e,warning:t instanceof Error?t.message:String(t)}))}).finally(()=>{r()&&H.update(e,e=>({...e,loading:!1}))}),()=>{r()&&H.update(e,e=>({...e,loading:!1})),t.abort()}}var Nt=H.channel({channel:bt,parse(e){if(!Ot(e)||typeof e.cwd!=`string`||!Array.isArray(e.agents))return null;let t=Array.isArray(e.models)?e.models.filter(e=>typeof e==`string`):[];return{cwd:e.cwd,agents:e.agents.filter(Ot),models:t,...typeof e.warning==`string`?{warning:e.warning}:{}}},reduce(e,t){let n=new Set(t.agents.map(e=>e.name));return{...e,cwd:t.cwd,agents:t.agents,models:t.models,warning:t.warning,selected:e.selected!==void 0&&n.has(e.selected)?e.selected:void 0,inspected:e.inspected!==void 0&&n.has(e.inspected)?e.inspected:void 0,launch:e.launch!==void 0&&n.has(e.launch.agent)?e.launch:void 0}}}),Pt=6e4,Ft=60*Pt;function It(e){if(e<Pt)return`<1m`;if(e<Ft)return`${Math.floor(e/Pt)}m`;let t=Math.floor(e/Ft),n=Math.floor(e%Ft/Pt);return`${t}h ${String(n).padStart(2,`0`)}m`}function Lt(e){let t=/^\/(?:Users|home)\/[^/]+/u.exec(e);return t?`~${e.slice(t[0].length)}`:e}function Rt(e){return U(e).name}function zt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function U(e){let t=e.identity?.split(`-`)[0];return!e.identity||!t?{name:e.agent,role:``,seed:e.agent}:{name:zt(t),role:e.agent,seed:e.identity}}var Bt=E({slot:`subagents.run-actions`}),Vt=new Set([`done`,`failed`,`stopped`]);function W(e){return Vt.has(e.state)}var G=T({runs:[],dismissed:[],stopRequested:[],openRunId:void 0,pendingLaunch:void 0,autoOpenRunId:void 0});function Ht(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ut(e,t){return e.filter(e=>e!==t)}function Wt(e){return e.runs.filter(t=>!e.dismissed.includes(t.runId)).sort((e,t)=>Number(W(e))-Number(W(t)))}function Gt(e){return Wt(e).filter(e=>e.state===`queued`||e.state===`running`)}async function Kt(e,t){G.update(e,e=>({...e,stopRequested:[...Ut(e.stopRequested,t),t]}));try{await Dt(e,t)}catch(n){throw G.update(e,e=>({...e,stopRequested:Ut(e.stopRequested,t)})),n}}function qt(e,t){G.update(e,e=>({...e,dismissed:[...Ut(e.dismissed,t),t],openRunId:e.openRunId===t?void 0:e.openRunId}))}function Jt(e,t){G.update(e,e=>({...e,pendingLaunch:{agent:t,knownRunIds:e.runs.map(e=>e.runId)}}))}function Yt(e){G.update(e,e=>({...e,pendingLaunch:void 0}))}function Xt(e){G.update(e,e=>({...e,autoOpenRunId:void 0}))}function Zt(e,t){G.update(e,e=>({...e,openRunId:t}))}var Qt=G.channel({channel:yt,parse(e){return!Ht(e)||!Array.isArray(e.runs)?null:{runs:e.runs.filter(Ht)}},reduce(e,{runs:t}){let n=new Map(t.map(e=>[e.runId,e])),r=e.stopRequested.filter(e=>{let t=n.get(e);return t!==void 0&&!W(t)}),i=e.dismissed.filter(e=>n.has(e)),a=e.pendingLaunch===void 0?void 0:t.find(t=>t.agent===e.pendingLaunch?.agent&&!e.pendingLaunch.knownRunIds.includes(t.runId));return{...e,runs:t,stopRequested:r,dismissed:i,pendingLaunch:a===void 0?e.pendingLaunch:void 0,autoOpenRunId:a===void 0?e.autoOpenRunId:a.runId}}});function $t(e,t){let n=t.trim().toLowerCase();return n===``?[...e]:e.filter(e=>[e.name,e.source,e.packageName??``,e.description,...e.tools].some(e=>e.toLowerCase().includes(n)))}function en(e,t){let n=new Set,r=[];for(let i of[e.model??``,...e.fallbackModels,...t])i===``||n.has(i)||(n.add(i),r.push(i));return r}var tn={project:`Project`,user:`User`,plugin:`Package`};function nn({label:t,value:n,onChange:r,options:i,disabled:a}){return _(se,{disabled:a,value:n,onValueChange:r,children:[f(Ne,{"aria-label":t,className:`h-9 w-full`,children:f(xe,{})}),f(O,{children:i.map(([t,n])=>f(e,{value:t,children:n},t))})]})}function rn({agents:e,models:n,initialSearch:r=``,initialSelected:i,initialTask:a=``,initialFork:o,loading:s=!1,warning:c,cwd:u=``,catalogNote:d,runNote:p,onClose:v,onLaunch:y,onSource:b}){let[x,S]=L(r),[C,w]=L(`all`),[T,ee]=L(i),[te,ne]=L(a),[re,ie]=L(o===void 0?void 0:o?`fork`:`fresh`),[E,ae]=L(`default`),[D,se]=L(!1),O=g(!1),[k,A]=L(),j=$t(e,x).filter(e=>C===`all`||e.source===C),M=T===void 0?j[0]:j.find(e=>e.name===T),P=re??M?.defaultContext??`fresh`,F=e=>{ee(e.name),ie(e.defaultContext),ae(`default`),A(void 0)},ue=async()=>{if(!(!M||s||O.current)){O.current=!0,se(!0),A(void 0);try{await y({agent:M.name,task:te,fork:P===`fork`,...E==="default"?{}:{model:E}})}catch(e){A(e instanceof Error?e.message:String(e))}finally{O.current=!1,se(!1)}}},de=E==="default"?M?.model??`Runtime default`:E,fe=P===`fresh`?`Fresh context`:`This conversation`;return _(h,{"data-testid":`launch-dialog`,className:`w-6xl`,"aria-describedby":`launcher-description`,children:[f(oe,{dismissible:!0,closeLabel:`Close new agent run`,className:`p-6 sm:px-6`,children:_(`div`,{className:`space-y-1`,children:[f(le,{children:`New agent run`}),f(Te,{id:`launcher-description`,children:`Choose an agent, review its setup, then give it a task.`})]})}),_(`div`,{className:`grid min-h-0 overflow-y-auto md:grid-cols-3`,children:[_(`aside`,{"aria-label":`Agent catalog`,onKeyDown:e=>{if(!(D||e.target.getAttribute(`role`)===`combobox`)){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=j.findIndex(e=>e.name===M?.name),n=j[(t+(e.key===`ArrowDown`?1:-1)+j.length)%j.length];n&&F(n)}if(e.target.tagName!==`INPUT`&&(e.key===`f`&&ie(`fork`),e.key===`i`)){let t=e.currentTarget.parentElement?.querySelector(`details`);t&&(t.open=!t.open)}}},className:`flex flex-col gap-3 border-b border-po-border p-5 md:border-r md:border-b-0`,children:[f(Me,{autoFocus:!0,"data-testid":`catalog-filter`,disabled:D,"aria-label":`Find an agent`,placeholder:`Find an agent…`,value:x,onChange:e=>S(e.target.value)}),f(nn,{disabled:D,label:`Source filter`,value:C,onChange:w,options:[[`all`,`All sources`],[`project`,`Project`],[`user`,`User`],[`plugin`,`Package`]]}),_(`div`,{className:`flex flex-col gap-1 py-2`,children:[s?f(`p`,{role:`status`,className:`text-sm text-po-dim`,children:`Loading agents…`}):null,c?f(`p`,{role:`alert`,className:`text-sm text-po-red`,children:c}):null,j.map(e=>_(t,{variant:`ghost`,size:`card`,"aria-pressed":M?.name===e.name,className:M?.name===e.name?`border-l-4 border-po-green bg-po-selected/15`:`border-l-4 border-transparent`,disabled:D,onClick:()=>{F(e)},children:[f(`span`,{className:`font-semibold text-po-hi`,children:e.name}),f(`span`,{className:`text-sm text-po-dim`,children:e.description.split(`.`)[0]}),_(`span`,{className:`text-sm text-po-dim`,children:[tn[e.source],` · `,e.model??`Default model`]})]},e.name)),j.length===0&&!s?_(`div`,{className:`space-y-3 py-6`,children:[f(`p`,{className:`text-base text-po-hi`,children:`No matching agents`}),f(`p`,{className:`text-sm text-po-dim`,children:`Try another name or source.`}),f(t,{onClick:()=>{S(``),w(`all`)},children:`Clear filters`})]}):null]}),_(`p`,{className:`mt-auto text-sm text-po-dim`,children:[j.length,` agents`,d?` · ${d}`:``]})]}),f(`section`,{className:`space-y-5 p-6 md:col-span-2`,"aria-label":`Agent definition and run`,children:M?_(l,{children:[_(`div`,{className:`space-y-2`,children:[f(`p`,{className:`text-sm text-po-dim`,children:`Agent definition`}),_(`div`,{className:`flex items-center gap-3`,children:[f(`h2`,{className:`text-2xl font-semibold text-po-hi`,children:M.name}),f(N,{children:tn[M.source]})]}),f(`p`,{className:`text-base text-po-text`,children:M.description}),f(`p`,{className:`break-all font-mono text-sm text-po-dim`,children:b?.(M)?f(`button`,{type:`button`,className:`text-left text-po-green underline`,onClick:b(M),children:M.filePath}):M.filePath}),M.packageName?f(`p`,{className:`text-sm text-po-dim`,children:M.packageName}):null,_(`details`,{className:`text-base text-po-text`,children:[f(`summary`,{className:`cursor-pointer text-po-green`,children:`View instructions`}),f(`p`,{className:`mt-2 whitespace-pre-wrap rounded-md bg-po-deep p-3 text-sm`,children:b?.(M)?f(t,{variant:`link`,onClick:b(M),children:`Open source instructions`}):`Instructions stay in the source definition. File viewing is not available in this host.`})]})]}),f(`dl`,{className:`grid gap-x-6 gap-y-3 text-base sm:grid-cols-2`,children:[[`Model`,M.model??`Runtime default`],[`Tools`,M.tools.length?M.tools.join(` · `):`All session tools (not narrowed)`],[`Fallback models`,M.fallbackModels.join(` · `)||`None specified`],[`Skills`,M.skills.join(` · `)||`None specified`],[`Default context`,M.defaultContext===`fresh`?`Fresh`:`This conversation`],[`Extensions`,M.extensions.join(` · `)||`None specified`]].map(([e,t])=>_(`div`,{className:`space-y-1`,children:[f(`dt`,{className:`text-sm text-po-dim`,children:e}),f(`dd`,{className:`break-words text-po-text`,children:t})]},e))}),_(`div`,{className:`space-y-3 border-t border-po-border pt-4`,children:[f(`h3`,{className:`text-lg font-semibold text-po-hi`,children:`This run`}),_(`label`,{className:`flex flex-col gap-1 text-base text-po-text`,children:[`Task`,f(m,{"data-testid":`launch-task`,disabled:D,placeholder:`What should the agent do? Leave empty to use its own prompt.`,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),ue())},rows:3,value:te,onChange:e=>{ne(e.target.value),A(void 0)}})]}),_(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[_(`div`,{className:`space-y-1`,children:[f(`p`,{className:`text-base text-po-text`,children:`Context`}),f(nn,{disabled:D,label:`Context`,value:P,onChange:ie,options:[[`fresh`,`Fresh context`],[`fork`,`This conversation`]]}),f(`p`,{className:`text-sm text-po-dim`,children:`Start clean, or include this conversation.`})]}),_(`div`,{className:`space-y-1`,children:[f(`p`,{className:`text-base text-po-text`,children:`Model override`}),f(nn,{disabled:D,label:`Model override`,value:E,onChange:ae,options:[[`default`,`Use agent default`],...en(M,n).map(e=>[e,e])]}),f(`p`,{className:`text-sm text-po-dim`,children:`Changes apply only to this run.`})]})]})]})]}):f(`p`,{className:`py-12 text-base text-po-dim`,children:`Choose an agent to review its definition. Clear the filters if no agents match.`})})]}),_(ce,{variant:`bar`,className:`gap-3 p-4 sm:px-6 sm:py-4`,children:[_(`div`,{className:`min-w-0 flex-1 space-y-1 text-sm text-po-dim`,children:[f(`p`,{className:`break-words`,children:M?`${M.name} · ${fe} · ${de}`:`No agent selected`}),f(`p`,{role:`status`,children:p??`Enter starts the run · Shift+Enter for a new line${u?` · ${u}`:``}`}),k?f(`p`,{role:`alert`,className:`text-po-red`,children:k}):null]}),f(t,{"data-testid":`launch-cancel`,onClick:v,children:`Cancel`}),f(t,{"data-testid":`launch-submit`,variant:`primary`,disabled:!M||D||s,onClick:()=>void ue(),children:D?`Starting…`:`Start run`})]})]})}function an({sessionId:e,agent:t,agents:n,loading:r,warning:i,onSource:a,cwd:o,models:s,fork:c,initialTask:l,onClose:u,onLaunched:d}){return f(D,{open:!0,onOpenChange:e=>{e||u()},children:f(rn,{agents:n??(t?[t]:[]),models:s,initialSelected:t?.name,initialTask:l,initialFork:c,loading:r,warning:i,cwd:o,onSource:a,onClose:u,onLaunch:async t=>{Jt(e,t.agent);try{await wt(e,t),d()}catch(t){throw Yt(e),t}}})})}function on({sessionId:e,onClose:t,onSource:n}){let r=S(H.store,t=>H.select(t,e));return f(an,{sessionId:e,agents:r.agents,agent:r.agents.find(e=>e.name===(r.launch?.agent??r.selected)),cwd:r.cwd,models:r.models,fork:r.launch?.fork,initialTask:r.task,loading:r.loading,warning:r.warning,onSource:n,onClose:t,onLaunched:t})}var sn={queued:{label:`QUEUED`,tone:`neutral`},running:{label:`RUNNING`,tone:`running`},done:{label:`DONE`,tone:`ok`},failed:{label:`FAILED`,tone:`error`},stopped:{label:`STOPPED`,tone:`neutral`}};function cn(e,t){let n=e.endedAt??(e.state===`running`||e.state===`queued`?t:e.lastUpdate);return It(Math.max(0,n-e.startedAt))}function ln({run:e}){let t=g(null),[n]=L(Date.now);return d(()=>{let n,r=()=>{let i=t.current?.firstChild,a=Date.now();i&&(i.nodeValue=cn(e,a)),!W(e)&&e.endedAt===void 0&&(n=setTimeout(r,6e4-Math.max(0,a-e.startedAt)%6e4))};return r(),()=>clearTimeout(n)},[e]),f(`span`,{ref:t,children:cn(e,n)})}function un({sessionId:e,run:n,stopping:r}){let[i,a]=L(),o=(e,t)=>{e.stopPropagation(),t()},s=()=>{a(void 0),Kt(e,n.runId).catch(e=>a(e instanceof Error?e.message:String(e)))};return W(n)?f(t,{variant:`outline`,size:`xs`,"data-testid":`run-clear-${n.runId}`,title:`clear this run from the grid`,onClick:t=>o(t,()=>qt(e,n.runId)),children:`clear`}):_(l,{children:[i?f(`span`,{role:`alert`,"data-testid":`run-stop-error-${n.runId}`,title:i,className:`min-w-0 truncate text-sm text-po-red`,children:i}):null,f(t,{variant:r?`outline`:`danger-outline`,size:`xs`,"data-testid":`run-stop-${n.runId}`,"data-stopping":r,disabled:r,title:r?`stop requested; the run reports its own final state`:`ask the runtime to stop this run`,onClick:e=>o(e,s),children:r?`stopping…`:`stop`})]})}var K=`Not reported`,dn={done:`This run has finished. Start a new run from Agents.`,failed:`This run failed. Start a new run from Agents.`,stopped:`This run was stopped. Start a new run from Agents.`};function q({label:e,children:t}){return _(`div`,{className:`flex gap-3`,children:[f(`span`,{className:`w-24 shrink-0 text-sm text-po-dim`,children:e}),f(`div`,{className:`min-w-0 flex-1 break-words text-base text-po-text`,children:t})]})}function fn({run:e}){let t=[e?.toolCount===void 0?void 0:`${e.toolCount} tools`,e?.tokens===void 0?void 0:`${e.tokens.toLocaleString()} tokens`].filter(Boolean).join(` · `);return _(l,{children:[_(q,{label:`Agent`,children:[f(`span`,{className:`font-semibold text-po-hi`,children:e?.agent??K}),e?.agentDescription?f(`p`,{className:`text-po-dim`,children:e.agentDescription}):null,e?.agentFilePath?f(`p`,{className:`font-mono text-sm text-po-dim`,children:e.agentFilePath}):null]}),_(q,{label:`Model`,children:[e?.model??K,e?.model&&e.modelSource===`configured`?f(`span`,{className:`text-po-dim`,children:` · configured, not confirmed by the runtime`}):null]}),f(q,{label:`Thinking`,children:f(`span`,{className:`capitalize`,children:e?.thinking??K})}),f(q,{label:`Prompt`,children:e?.promptWithheld?f(`span`,{className:`text-po-dim`,children:`Withheld: this task was marked sensitive.`}):f(`pre`,{className:`max-h-40 overflow-y-auto rounded-md bg-po-deep px-3 py-2 font-sans whitespace-pre-wrap break-words`,children:e?.task||K})}),e?.taskRef?f(q,{label:`Task`,children:f(N,{tone:`violet`,size:`xs`,className:`rounded-sm bg-po-violet/10`,children:e.taskRef})}):null,f(q,{label:`Folder`,children:f(`span`,{className:`font-mono text-sm`,children:e?.cwd?Lt(e.cwd):K})}),f(q,{label:`Usage`,children:f(`span`,{className:`text-po-dim`,children:t||K})})]})}function pn({run:e,gone:n,elapsed:r,stopControl:i,thread:a,canSteer:o,stopping:s,guidance:c,sending:l,error:u,notice:d,onGuidanceChange:h,onSubmit:g,initialInfoOpen:v=!1}){let[y,x]=L(v),S=ie(),C=e?sn[e.state]:void 0,w={variant:`outline`,size:`md`,className:`min-w-0 max-w-full gap-2`,"aria-expanded":y,"aria-controls":S,onClick:()=>x(e=>!e)},T=e&&W(e)?dn[e.state]:e?.canSteer===!1&&!n?`This runtime does not take guidance while it runs.`:`Guidance is unavailable for this run.`;return _(`div`,{"data-testid":`agent-thread-panel`,className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-po-bg`,children:[_(`div`,{"data-testid":`agent-thread-header`,className:`flex h-11 shrink-0 items-center gap-2.5 border-b border-po-border-soft bg-po-rail px-[26px]`,children:[e?f(p,{name:U(e).name,seed:U(e).seed,size:`sm`}):null,f(`span`,{"data-testid":`agent-thread-agent`,className:`min-w-0 shrink truncate text-base font-semibold text-po-hi`,children:e?Rt(e):`Agent run`}),e&&U(e).role?f(`span`,{className:`min-w-0 shrink truncate text-sm text-po-dim`,children:U(e).role}):null,C?f(b,{tone:C.tone,"data-testid":`agent-thread-state`,className:`shrink-0`,children:s&&e&&!W(e)?`STOPPING…`:C.label}):null,f(`span`,{className:`min-w-0 flex-1 truncate text-sm text-po-dim`,children:r}),i]}),n?f(`div`,{"data-testid":`agent-thread-gone`,className:`shrink-0 border-b border-po-border-soft px-[26px] py-2 text-sm text-po-dim`,children:`This run is no longer listed. Its thread stays readable.`}):null,f(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:a}),f(`section`,{id:S,"aria-label":`Run info`,"data-testid":`run-info`,hidden:!y,className:`mx-[26px] mb-2 flex max-h-[40vh] shrink-0 flex-col gap-3 overflow-y-auto rounded-lg border border-po-border bg-po-panel px-4 py-3`,children:f(fn,{run:e})}),o?f(`form`,{"data-testid":`agent-steer-composer`,className:`shrink-0 px-[26px] pt-2 pb-2`,onSubmit:e=>{e.preventDefault(),g()},children:_(`div`,{className:`rounded-lg border border-po-border bg-po-panel transition-colors focus-within:border-po-blue/60`,children:[f(m,{variant:`bare`,"data-testid":`agent-steer-input`,"aria-label":`Steering guidance`,rows:2,value:c,readOnly:l,disabled:s,placeholder:s?`Stopping, guidance paused`:`Guide this agent · it reads this at its next step`,className:`w-full px-4 pt-3 text-lg leading-relaxed`,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}),u?f(`p`,{role:`alert`,"data-testid":`agent-steer-error`,className:`px-4 pt-1 text-sm text-po-red`,children:u}):null,_(`div`,{className:`flex items-center gap-3 px-4 pt-1 pb-3`,children:[f(`span`,{className:`min-w-0 flex-1`}),f(`span`,{role:`status`,"data-testid":`agent-steer-hint`,title:d,className:`min-w-0 truncate text-sm text-po-dim`,children:d??`Shift + Enter for a new line`}),_(t,{"data-testid":`agent-steer-submit`,type:`submit`,variant:`primary`,size:`lg`,className:`shrink-0 gap-2`,disabled:s||l||c.trim()===``,children:[f(ke,{className:`size-4`}),l?`Sending…`:`Send`]})]})]})}):f(`div`,{"data-testid":`agent-thread-end`,className:`shrink-0 px-[26px] pt-3 pb-2 text-sm text-po-dim`,children:T}),_(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 px-[26px] pb-4`,children:[_(t,{...w,"data-testid":`run-chip-agent`,children:[f(`span`,{"aria-hidden":!0,className:`size-1.5 shrink-0 rounded-full bg-po-magenta`}),f(`span`,{className:`truncate`,children:e?.agent??`Agent`}),f(ne,{"aria-hidden":!0,className:`size-3.5 shrink-0`})]}),_(t,{...w,"data-testid":`run-chip-model`,children:[f(`span`,{"aria-hidden":!0,className:`size-1.5 shrink-0 rounded-full bg-po-green`}),f(`span`,{className:`truncate`,children:e?.model?e.model.split(`/`).pop()??e.model:`Model not reported`}),e?.thinking?f(`span`,{className:`shrink-0 text-po-dim`,children:e.thinking}):null,f(ne,{"aria-hidden":!0,className:`size-3.5 shrink-0`})]}),_(t,{...w,"data-testid":`run-chip-prompt`,children:[f(`span`,{"aria-hidden":!0,className:`size-1.5 shrink-0 rounded-full bg-po-blue`}),`Prompt`,f(ne,{"aria-hidden":!0,className:`size-3.5 shrink-0`})]})]})]})}var mn=`subagents-run-`;function hn(e){let t=e.runId;return{id:`${mn}${t}`,label:Rt(e),panel:e=>f(gn,{...e,runId:t},`${e.sessionId}:${t}`)}}function gn({sessionId:e,runId:t,renderThread:n}){let{runs:r,stopRequested:i}=S(G.store,t=>G.select(t,e)),a=r.find(e=>e.runId===t),[o,s]=L(a);a!==void 0&&a!==o&&s(a);let c=a??o,l=a===void 0,[u,d]=L(``),[p,m]=L(!1),[h,g]=L(),[_,v]=L(),y=e!==null&&a!==void 0&&!W(a),b=i.includes(t),x=y&&a.canSteer!==!1,C=async()=>{let n=u.trim();if(x&&!b&&n&&!p){m(!0),g(void 0),v(void 0);try{let r=await Et(e,t,n);if(r.state===`failed`){g(r.message);return}d(``),r.state===`pending`&&v(r.message)}catch(e){g(e instanceof Error?e.message:String(e))}finally{m(!1)}}};return f(pn,{run:c,gone:l,elapsed:c?f(ln,{run:l?{...c,endedAt:c.endedAt??c.lastUpdate}:c}):void 0,stopControl:y?f(un,{sessionId:e,run:a,stopping:b}):void 0,thread:n(t),canSteer:x,stopping:b,guidance:u,sending:p,error:h,notice:_,onGuidanceChange:d,onSubmit:()=>void C()})}var _n=`subagents-fleet`,vn=8;function yn({run:e}){let t=e.task.split(`
2
2
  `).find(e=>e.trim()!==``)??``;return e.taskRef?_(`div`,{className:`flex items-center gap-2 px-3 pb-2.5`,children:[_(N,{tone:`violet`,size:`xs`,className:`shrink-0 rounded-sm bg-po-violet/10`,children:[`TASK `,e.taskRef]}),f(`span`,{"data-testid":`run-work`,className:`min-w-0 truncate text-base text-po-hi`,children:t})]}):_(`div`,{className:`flex items-center gap-2 px-3 pb-2.5`,children:[f(`span`,{className:`shrink-0 text-base font-medium text-po-dim`,children:`Prompt`}),f(`span`,{"data-testid":`run-work`,className:`min-w-0 truncate text-base text-po-dim`,children:t})]})}function bn({sessionId:e,run:n,stopping:r,onOpenThread:i,onOpenDetail:a}){let[o,s]=L();return _(l,{children:[o?f(`span`,{role:`alert`,"data-testid":`run-menu-stop-error-${n.runId}`,title:o,className:`min-w-0 truncate text-sm text-po-red`,children:o}):null,_(je,{children:[f(Ae,{asChild:!0,children:f(t,{variant:`ghost`,size:`icon`,"data-testid":`run-menu-${n.runId}`,title:`what this run can do`,"aria-label":`run actions`,onClick:e=>e.stopPropagation(),children:f(Oe,{className:`h-3 w-3`})})}),_(De,{"data-testid":`run-menu-content-${n.runId}`,children:[f(I,{"data-testid":`run-open-${n.runId}`,onSelect:i,children:`open thread`}),f(I,{"data-testid":`run-detail-${n.runId}`,onSelect:a,children:`details`}),f(A,{}),W(n)?f(I,{"data-testid":`run-clear-${n.runId}`,onSelect:()=>qt(e,n.runId),children:`clear from the grid`}):f(I,{variant:`destructive`,"data-testid":`run-stop-${n.runId}`,"data-stopping":r,disabled:r,onSelect:()=>{s(void 0),Kt(e,n.runId).catch(e=>s(e instanceof Error?e.message:String(e)))},children:r?`stopping…`:`stop`})]})]})]})}function xn({sessionId:e,run:t,stopping:n,renderThread:r,onOpenThread:i,onOpenDetail:a}){let s=sn[t.state],c=U(t);return f(o,{asChild:!0,className:_e(`flex h-[280px] min-w-0 flex-col text-left transition-colors outline-none hover:border-po-blue/50 focus-within:border-po-blue`,Ee[s.tone]),children:_(`div`,{"data-testid":`run-card-${t.runId}`,"data-run-state":t.state,children:[_(`div`,{role:`button`,tabIndex:0,"data-testid":`run-open-card-${t.runId}`,className:`flex min-h-0 flex-1 cursor-pointer flex-col outline-none`,title:`open this run's own thread in a tab`,onClick:i,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),i())},children:[_(`div`,{className:`flex items-center gap-2 px-3 pt-2.5 pb-1.5`,children:[f(p,{name:c.name,seed:c.seed,size:`sm`}),f(`span`,{"data-testid":`run-agent`,className:`truncate text-base font-semibold text-po-hi`,children:c.name}),c.role?f(`span`,{className:`truncate text-sm text-po-dim`,children:c.role}):null,f(`span`,{className:`min-w-0 flex-1`}),f(`span`,{className:`shrink-0 text-sm text-po-dim`,children:f(ln,{run:t})}),f(b,{tone:s.tone,"data-testid":`run-state`,children:s.label})]}),f(yn,{run:t}),f(`div`,{"data-testid":`run-stream`,className:`pointer-events-none flex min-h-0 flex-1 flex-col overflow-hidden border-t border-po-border-soft bg-po-deep`,children:r(t.runId,{limit:vn,compact:!0})}),t.state===`failed`&&t.error?f(`span`,{"data-testid":`run-error`,className:`truncate border-t border-po-border-soft px-3 py-1.5 text-sm text-po-red`,children:t.error}):null]}),_(`div`,{className:`flex shrink-0 items-center gap-3 border-t border-po-border-soft px-3 py-1.5`,children:[_(`span`,{className:`truncate text-sm text-po-dim`,children:[t.toolCount===void 0?`—`:`${t.toolCount} tools`,t.tokens===void 0?``:` · ${t.tokens.toLocaleString()} tk`,t.model?` · ${t.model.split(`/`).pop()??t.model}`:``]}),f(`span`,{className:`min-w-0 flex-1`}),f(bn,{sessionId:e,run:t,stopping:n,onOpenThread:i,onOpenDetail:a})]})]})})}function J({label:e,value:t,tone:n=`text-po-dim`}){return _(`div`,{className:`flex gap-2.5`,children:[f(`span`,{className:`w-11 shrink-0 text-sm text-po-dim`,children:e}),f(`span`,{className:`min-w-0 break-words text-base ${n}`,children:t})]})}function Sn({label:e,text:t,testId:n,tone:r}){return _(`div`,{className:`flex flex-col gap-1 rounded-md border border-po-border bg-po-deep px-3 py-2.5`,children:[f(`span`,{className:`text-base font-medium text-po-dim`,children:e}),f(`pre`,{"data-testid":n,className:`overflow-x-auto whitespace-pre-wrap break-words text-base leading-relaxed ${r??`text-po-text`}`,children:t})]})}function Cn({sessionId:e,run:t,stopping:n,renderSlot:r,onClose:i}){let a=sn[t.state];return f(M,{open:!0,onOpenChange:e=>{e||i()},children:_(ee,{"data-testid":`run-sheet`,"aria-describedby":void 0,children:[_(re,{closeLabel:`close the run detail`,children:[f(s,{"data-testid":`sheet-agent`,children:Rt(t)}),f(b,{tone:a.tone,children:a.label}),f(`span`,{className:`min-w-0 flex-1`}),f(`span`,{className:`text-sm text-po-dim`,children:f(ln,{run:t})}),r(Bt.slot),f(un,{sessionId:e,run:t,stopping:n})]}),_(Fe,{children:[_(`div`,{className:`flex flex-col gap-1.5`,children:[f(J,{label:`run`,value:t.runId}),t.taskRef?f(J,{label:`task`,value:t.taskRef,tone:`text-po-violet`}):null,f(J,{label:`model`,value:t.model??`the runtime default`}),f(J,{label:`cwd`,value:Lt(t.cwd)}),f(J,{label:`work`,value:`${t.toolCount===void 0?`no`:String(t.toolCount)} tools${t.tokens===void 0?``:` · ${t.tokens.toLocaleString()} tk`}`})]}),f(Sn,{label:`PROMPT FROM THE MAIN AGENT`,testId:`sheet-task`,text:t.task||`(no prompt recorded)`}),t.summary?f(Sn,{label:`REPORT`,testId:`sheet-summary`,text:t.summary}):null,t.error?f(Sn,{label:`FAILURE`,testId:`sheet-error`,text:t.error,tone:`text-po-red`}):null]})]})})}function wn({sessionId:e,renderSlot:n,renderThread:r,openTransientTab:i,fileTabFor:a}){let o=S(G.store,t=>Wt(G.select(t,e))),{openRunId:s,stopRequested:c,autoOpenRunId:u}=S(G.store,t=>G.select(t,e)),p=S(H.store,t=>H.select(t,e));d(()=>{if(e!==null&&p.open)return Mt(e)},[e,p.open]),d(()=>{if(u===void 0||e===null)return;let t=o.find(e=>e.runId===u);t&&i(hn(t)),Xt(e)},[u,o,e,i]);let m=s===void 0?void 0:o.find(e=>e.runId===s),h=e=>c.includes(e.runId),g=o.filter(e=>e.state===`running`||e.state===`queued`).length,v=o.filter(e=>e.state===`done`).length,y=o.filter(e=>e.state===`failed`||e.state===`stopped`).length;return _(`div`,{"data-testid":`subagents-panel`,className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[_(`div`,{className:`@container flex min-w-0 flex-1 flex-col overflow-y-auto px-3 py-3 sm:px-[26px] sm:py-[18px]`,children:[_(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 pb-3`,children:[f(`span`,{className:`text-lg font-semibold text-po-hi`,children:`Agents · this session`}),f(`span`,{className:`hidden min-w-0 flex-1 sm:block`}),f(`span`,{"data-testid":`subagents-tally`,className:`order-3 w-full text-sm text-po-dim sm:order-none sm:w-auto`,children:o.length===0?`no runs yet`:`${g} running · ${v} done · ${y} failed`}),f(t,{variant:`primary`,className:`ml-auto sm:ml-0`,"data-testid":`subagents-launch`,title:`pick an agent from the catalog and launch it`,onClick:()=>{e!==null&&(Zt(e,void 0),kt(e))},children:`New agent run`})]}),o.length===0?_(`div`,{"data-testid":`subagents-empty`,className:`text-base text-po-dim`,children:[f(`p`,{children:`No runs yet`}),f(`p`,{children:`Start an agent run to get help with your work.`}),f(`p`,{className:`py-32 text-center text-sm`,children:`Agent runs will appear here once you start one.`})]}):_(l,{children:[f(`div`,{"data-testid":`subagents-grid`,className:`grid grid-cols-1 gap-4 @2xl:grid-cols-2`,children:e===null?null:o.map(t=>f(xn,{sessionId:e,run:t,stopping:h(t),renderThread:r,onOpenThread:()=>{jt(e),i(hn(t))},onOpenDetail:()=>{jt(e),Zt(e,t.runId)}},t.runId))}),f(`span`,{className:`pt-3 text-sm text-po-dim`,children:`click a card to open the run's thread · the card menu holds details, stop and clear · finished runs leave the grid after 10m`})]})]}),e!==null&&p.open?f(on,{sessionId:e,onClose:()=>jt(e),onSource:t=>{let n=a(t.filePath);return n?()=>{jt(e),i(n)}:void 0}}):null,m&&e!==null?f(Cn,{sessionId:e,run:m,stopping:h(m),renderSlot:n,onClose:()=>Zt(e,void 0)}):null]})}function Y(){return{id:_n,label:`Agents`,panel:wn}}var Tn=x({label:`Launch Agent`,detail:`Choose an agent, review the task, then launch it.`,kinds:[`work-item`],order:10,run:e=>At(e,Y)}),En=te({keys:`a r`,icon:be,statusKey:`po-team-agents`,activeSource:{subscribe(e){let t=G.store.subscribe(e);return()=>t.unsubscribe()},isActive(e){return Gt(G.select(G.store.state,e)).some(e=>!W(e))}},transientTab:Y,order:10}),Dn=a(Nt),On=a(Qt),kn={queued:`waiting`,running:`running`,done:`done`,failed:`failed`,stopped:`done`};function An(e){return e.state===`failed`&&e.error?e.error:e.summary?e.summary.split(`
3
3
  `).find(e=>e.trim()!==``)??``:e.currentTool??e.tail.at(-1)??(e.state===`running`?``:e.state)}function jn({sessionId:e,openTransientTab:n}){let r=S(G.store,t=>Gt(G.select(t,e)));return r.length===0?_(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1`,children:[f(`p`,{"data-testid":`activity-summary-agents`,className:`text-sm text-po-dim`,children:`Idle`}),_(t,{variant:`link`,size:`sm`,"data-testid":`activity-agents-launch`,className:`h-auto gap-1 px-0 text-sm text-po-green`,onClick:()=>{e!==null&&(kt(e),n(Y()))},children:[`Launch an agent`,f(P,{"aria-hidden":!0,className:`size-3.5`})]})]}):f(`div`,{"data-testid":`activity-agent-runs`,className:`flex flex-col gap-0.5`,children:r.map(r=>{let i=U(r),a=An(r);return f(t,{variant:`ghost`,size:`card`,"data-testid":`activity-run-${r.runId}`,"data-run-state":r.state,title:`open this run's conversation`,onClick:()=>{e!==null&&n(hn(r))},className:`min-w-0 gap-0.5 rounded-md px-1 py-1 hover:bg-po-panel`,children:_(`span`,{className:`flex min-w-0 items-center gap-2`,children:[f(p,{name:i.name,seed:i.seed,state:kn[r.state],size:`sm`}),_(`span`,{className:`flex min-w-0 flex-1 flex-col text-left`,children:[_(`span`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[f(`span`,{className:`truncate text-base font-semibold text-po-hi`,children:i.name}),i.role?f(`span`,{className:`truncate text-sm text-po-dim`,children:i.role}):null]}),a?f(`span`,{className:`truncate text-sm ${r.state===`failed`?`text-po-red`:`text-po-dim`}`,children:a}):null]}),_(`span`,{className:`shrink-0 text-sm text-po-dim`,children:[f(ln,{run:r}),r.toolCount===void 0?``:` · ${r.toolCount} tools`]})]})},r.runId)})})}var Mn=ge({component:jn}),Nn={key:`a`,label:`agents`,detail:`subagent resources and runs`},Pn=y({path:[Nn,{key:`l`,label:`launch`,detail:`pick an agent and launch it`}],run:e=>{e.sessionId!==null&&kt(e.sessionId),e.openTransientTab(Y())}}),Fn=y({path:[Nn,{key:`r`,label:`runs`,detail:`runs in this session`}],run:e=>e.openTransientTab(Y())}),In=u({description:`Render an action beside the stop control in a subagent run detail sheet, using that run's props.`}),Ln=72,Rn=`…`;function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e){return typeof e==`string`?e:``}function zn(e){switch(e.action){case`agents`:return Z(e.name);case`run`:{let t=Array.isArray(e.requests)?e.requests:[],n=t.map(e=>X(e)?Z(e.agent):``).filter(Boolean),r=`${t.length} agent${t.length===1?``:`s`}`;return n.length>0?`${r} · ${n.join(`, `)}`:r}case`status`:return e.id?`run`:`fleet`;default:return``}}function Bn(e){let t=e.split(`
4
4
  `);for(;t.length>0&&t.at(-1)?.trim()===``;)t.pop();return t.length===1&&t[0]===``?[]:t}function Vn(e,t){let n=Bn(e);if(t.isPartial)return{lines:n.slice(-12),glyph:`running`,hidden:0};let r=t.expanded?n:n.slice(0,12),i=n.length-r.length;return t.isError?{lines:r,glyph:`failed`,hidden:i}:i>0?{lines:r,glyph:`more`,hidden:i}:r.length===0?{lines:r,glyph:`done`,hidden:0}:{lines:r,glyph:`none`,hidden:0}}function Q(e){let t=e.replace(/\s+/g,` `).trim();return t.length>Ln?`${t.slice(0,71)}${Rn}`:t}function Hn(e){return Array.isArray(e)?e.filter(X):[]}function Un(e){return e.filter(e=>typeof e==`string`&&e.trim()!==``).join(` · `)}function Wn(e){if(e===`failed`||e===`error`)return`failed`;if(e===`running`||e===`starting`)return`running`;if(e===`queued`)return`waiting`;if(e===`complete`||e===`completed`||e===`stopped`)return`done`}function Gn(e){return e===`failed`||e===`error`?`error`:e===`complete`||e===`completed`?`ok`:e===`running`||e===`starting`?`running`:`idle`}function Kn(e,t){return e===0?`no ${t}s`:`${e} ${t}${e===1?``:`s`}`}function qn(e){let t=Hn(e).map((e,t)=>({key:`${Z(e.name)}-${t}`,label:Z(e.name),seed:Z(e.name),detail:Q(Z(e.description)),state:Z(e.source),tone:`idle`}));return{kind:`agents`,rows:t,summary:Kn(t.length,`agent`),tone:`idle`}}function Jn(e){let t=Hn(e).map((e,t)=>{let n=Z(e.runId);return{key:n||`${Z(e.agent)}-${t}`,label:Z(e.agent),seed:Z(e.agent),avatar:n?`running`:`failed`,detail:Q(Z(n?e.task:e.error))||(n?``:`unknown error`),state:n?`started`:`failed`,tone:n?`ok`:`error`}}),n=t.filter(e=>e.state===`started`).length,r=t.length-n;return{kind:`run`,rows:t,summary:r===0?`${n} started`:`${n} started · ${r} failed`,tone:r===0?`ok`:`error`}}function Yn(e){let t=Hn(e).map((e,t)=>{let n=Z(e.status)||`starting`,r=U({agent:Z(e.agent),identity:Z(e.identity)||void 0});return{key:Z(e.runId)||`run-${t}`,label:r.name,seed:r.seed,avatar:Wn(n),detail:Q(Un([r.role,e.currentTool,e.activityState,e.attentionReason,e.error])),state:n,tone:Gn(n)}});return{kind:`fleet`,rows:t,summary:Kn(t.length,`run`),tone:`idle`}}function Xn(e){let t=Z(e.runId),n=X(e.status)?e.status:void 0,r=n?Z(n.state):``;if(!r)return{kind:`status`,rows:[],summary:`no status yet`,tone:`idle`};let i=U({agent:Z(n?.agent),identity:Z(n?.identity)||void 0});return{kind:`status`,rows:[{key:t,label:i.name,seed:i.seed,avatar:Wn(r),detail:Q(Un([i.role,n?.activityState,n?.summary,n?.error])),state:r,tone:Gn(r)}],summary:``,tone:Gn(r)}}function Zn(e,t){return{kind:`control`,rows:[],summary:e,tone:t}}function Qn(e){if(!X(e)||e.partial===!0)return null;if(Array.isArray(e.agents))return qn(e.agents);if(Array.isArray(e.outcomes))return Jn(e.outcomes);if(X(e.spawn)&&Array.isArray(e.spawn.outcomes))return Jn(e.spawn.outcomes);if(Array.isArray(e.runs))return Yn(e.runs);if(Array.isArray(e.fleet))return Yn(e.fleet);if(X(e.control))return Zn(`stop requested`,`ok`);if(X(e.steer)){let t=Z(e.steer.state);return Zn(`steer ${t}${e.steer.message?`: ${Q(Z(e.steer.message))}`:``}`,t===`failed`?`error`:`ok`)}return typeof e.runId==`string`?Xn(e):null}function $n(e,t){let n=Z(e.action),r=X(t)?Z(t.toName).trim():``;switch(n){case`send`:case`ask`:return{action:n,target:r||Z(e.to),message:Q(Z(e.message))};case`reply`:return{action:n,target:Z(e.requestId),message:Q(Z(e.message))};default:return{action:n,target:``,message:``}}}function er(e){return X(e)?e.delivered===!0?{outcome:`delivered`,who:Z(e.to),reply:``}:e.state===`queued`?{outcome:`queued`,who:Z(e.to),reply:``}:typeof e.reply==`string`?{outcome:`answered`,who:Z(e.from),reply:e.reply}:typeof e.requestId==`string`&&typeof e.to==`string`?{outcome:`replied`,who:e.to,reply:``}:{outcome:`none`,who:``,reply:``}:{outcome:`none`,who:``,reply:``}}function tr(e){return X(e)?Z(e.sender):``}var nr={delivered:{tone:`neutral`,glyph:`✓`,text:`Delivered`},queued:{tone:`running`,glyph:void 0,text:`Queued, not yet confirmed`},replied:{tone:`neutral`,glyph:`✓`,text:`Replied`}},rr={ask:`Asked`,send:`Message`,reply:`Reply`};function ir({name:e,chip:t,state:n,testId:r,children:i}){return _(`div`,{"data-testid":r,className:`flex items-start gap-2`,children:[f(p,{name:e,size:`sm`,...n?{state:n}:{}}),_(`div`,{className:`flex min-w-0 flex-col items-start gap-1`,children:[_(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-sm`,children:[f(`span`,{className:`truncate font-semibold text-po-hi`,children:e}),t]}),i]})]})}function ar({args:e,result:t,output:n,running:r,isError:i}){let a=$n(e,t?.details),o=Vn(n,{expanded:!1,isPartial:r,isError:i}),s=r||i?{outcome:`none`,who:``,reply:``}:er(t?.details),c=s.outcome===`none`||s.outcome===`answered`?null:nr[s.outcome],u=typeof e.message==`string`?e.message.trim():``,d=a.action===`reply`?s.who:a.target,m=tr(t?.details),h=rr[a.action];return f(ve,{tone:v({running:r,isError:i}),expandable:o.glyph===`more`,children:({expanded:e})=>{let t=e?Vn(n,{expanded:!0,isPartial:r,isError:i}):o;return _(l,{children:[f(pe,{title:`intercom`,children:_(`span`,{"data-testid":`tool-call-intercom`,className:`flex min-w-0 flex-1 items-center gap-2`,children:[f(`span`,{className:`text-po-hi`,children:a.action}),d?_(`span`,{className:`shrink-0 text-po-cyan`,children:[`→ `,d]}):null]})}),_(me,{"data-testid":`tool-result-intercom`,className:`flex flex-col gap-3`,children:[u&&!i?_(`div`,{"data-testid":`intercom-outgoing`,className:`flex flex-col items-end gap-1`,children:[_(`div`,{className:`flex min-w-0 items-center gap-2 text-sm`,children:[h?f(N,{tone:`neutral`,size:`xs`,children:h}):null,m?_(l,{children:[f(p,{name:m,size:`sm`}),f(`span`,{className:`truncate font-semibold text-po-hi`,children:m})]}):null]}),f(`p`,{className:`max-w-xl rounded-lg bg-po-tint-green px-3 py-2 text-base break-words whitespace-pre-wrap text-po-hi`,children:u}),c?f(k,{tone:c.tone,glyph:c.glyph,children:c.text}):null,r&&a.action!==`ask`?f(k,{tone:`running`,children:`Sending`}):null]}):null,r&&u&&a.action===`ask`?f(ir,{testId:`intercom-replying`,name:d||`reply`,state:`running`,chip:f(`span`,{className:`text-po-dim`,children:`is replying`}),children:_(`div`,{role:`status`,"aria-label":`${d||`The recipient`} is replying`,className:`flex items-center gap-1.5 rounded-lg bg-po-rail px-3 py-3`,children:[f(F,{tone:`muted`,size:`md`,pulse:!0}),f(F,{tone:`muted`,size:`md`,pulse:!0}),f(F,{tone:`muted`,size:`md`,pulse:!0})]})}):null,s.outcome===`answered`?f(ir,{testId:`intercom-incoming`,name:s.who,chip:f(N,{tone:`green`,size:`xs`,children:`Replied`}),children:f(`p`,{className:`max-w-xl rounded-lg bg-po-rail px-3 py-2 text-base break-words whitespace-pre-wrap text-po-hi`,children:s.reply})}):null,i?f(`p`,{role:`alert`,className:`text-base break-words text-po-red`,children:t.lines.join(`
@@ -1 +1 @@
1
- import{$a as e,$r as t,$t as n,A as r,Ar as i,B as a,Bt as o,C as s,D as c,Di as l,Dn as u,Dt as d,E as f,Et as p,F as m,Fn as h,Ft as g,G as _,Gi as v,H as y,Hn as b,Ht as x,It as S,J as C,Ja as w,Jr as T,K as E,Ki as D,Kt as O,L as k,Lt as A,M as j,N as M,O as N,Ot as P,P as F,Pi as I,Pt as L,Q as ee,R as te,Rr as R,S as ne,Si as z,St as re,T as ie,Ti as ae,Tt as oe,Ut as se,Vi as ce,Wi as B,X as V,Xi as H,Y as le,Yi as U,Z as ue,Zi as W,_ as de,_a as fe,_i as pe,_t as G,a as me,ai as he,at as ge,b as _e,bn as ve,bt as ye,c as be,ca as xe,cn as Se,cr as Ce,d as we,dt as Te,et as Ee,f as De,ft as Oe,g as ke,ga as Ae,gt as je,h as Me,ia as K,in as Ne,it as q,j as Pe,ji as Fe,jn as Ie,li as Le,lt as Re,mt as ze,n as Be,na as Ve,ni as He,nn as Ue,nt as We,o as Ge,ot as Ke,p as qe,pn as Je,pt as Ye,q as Xe,qa as Ze,qi as Qe,qt as J,r as $e,ra as Y,rn as et,s as tt,sa as X,sn as nt,st as rt,t as it,ta as Z,ti as at,tn as Q,u as ot,ut as st,v as $,va as ct,w as lt,wn as ut,wt as dt,x as ft,xn as pt,xt as mt,y as ht,ya as gt,z as _t,zt as vt}from"../chunks/po-web-runtime-CQ9hLtG-.js";function yt(e){return e.slice(e.lastIndexOf(`/`)+1)||e}function bt({start:e,listDirectory:n,onSelect:r}){let[i,a]=J(e),[o,s]=J(null),[c,l]=J(``);return x(()=>{let e=!1;return n(i).then(t=>{e||(`error`in t?l(t.error):(l(``),s(t)))}),()=>{e=!0}},[i,n]),A(`div`,{"data-testid":`folder-browser`,className:`flex flex-col gap-1 rounded border border-po-border bg-po-deep p-1`,children:[A(`div`,{className:`flex items-center gap-1 px-1`,children:[S(t,{variant:`ghost`,size:`icon`,"data-testid":`folder-browser-up`,title:`parent folder`,"aria-label":`parent folder`,disabled:o?.parent===void 0,onClick:()=>o?.parent!==void 0&&a(o.parent),children:S(Fe,{className:`h-3 w-3`})}),S(`span`,{className:`min-w-0 flex-1 truncate text-sm text-po-dim`,title:o?.path,children:o?.path??`loading…`}),S(t,{variant:`outline`,size:`xs`,"data-testid":`folder-browser-select`,disabled:o===null,onClick:()=>o!==null&&r(o.path),children:`use this folder`})]}),c?S(`p`,{className:`px-2 py-1 text-sm text-po-red`,children:c}):null,A(`div`,{role:`listbox`,"aria-label":`folders`,className:`max-h-40 overflow-y-auto`,children:[o!==null&&o.directories.length===0?S(`p`,{className:`px-2 py-1 text-sm text-po-dim`,children:`no folders here`}):null,o?.directories.map(e=>S(ut,{density:`compact`,"data-testid":`folder-browser-entry`,onClick:()=>a(e),className:`w-full px-2.5 py-1 `,children:yt(e)},e))]})]})}var xt=120,St=-1,Ct=/\/+$/u;function wt(e){let t=e.trim().replace(Ct,``);return t.slice(t.lastIndexOf(`/`)+1)}function Tt({suggestedPaths:e,actions:t}){let n=L(d,e=>e),r=n.path??e[0]??``,[i,a]=J({path:``,directories:[]});return x(()=>{let e=r.trim();if(e===``)return;let n=!1,i=setTimeout(async()=>{let i=await t.searchDirectories(e);n||a({path:r,directories:i.filter(t=>t!==e)})},xt);return()=>{n=!0,clearTimeout(i)}},[r,t]),x(()=>_(r,t.discoverWorkspaces),[r,t.discoverWorkspaces]),S(Et,{suggestions:r.trim()!==``&&i.path===r?i.directories:[],suggestedPaths:e,actions:t,draft:n,updateDraft:Oe})}function Et({suggestedPaths:e,actions:n,draft:r,updateDraft:i,style:a,suggestions:o=[]}){let{name:s,nameEdited:c,instructions:l,pending:u,error:d,discovery:f}=r,p=r.path??e[0]??``,m=e=>i({name:e}),h=e=>i({nameEdited:e}),_=e=>i({path:e}),[y,b]=J(!1),[x,C]=J(St),w=O(null),E=c?s:wt(p),k=e=>{u||(_(e),C(St))},j=e=>{k(`${e}/`),w.current?.focus()},M=p.trim().replace(Ct,``)||(p.trim()===``?``:`/`),N=r.discovering||!!p.trim()&&n.discoverWorkspaces!==void 0&&r.discoveryPath!==p,P=f&&`error`in f?f.error:``,F=f&&`declarations`in f&&f.declarations.length>0?f.declarations:void 0,I=e=>F?.find(t=>t.name===e)?.workspaceId??r.results.find(t=>t.name===e)?.workspaceId,L=F?.filter(e=>r.checked.includes(e.name)&&!I(e.name)).map(e=>e.name)??[],ee=!F&&!N&&!P,te=!u&&!N&&!P&&(F?L.length>0&&n.addDeclaredWorkspaces!==void 0:M!==``||E.trim()!==``),R=async()=>{te&&(F?await n.addDeclaredWorkspaces?.({path:f&&`root`in f?f.root:M,names:L}):await n.addWorkspace({...l===``?{}:{instructions:l},name:E.trim(),...M===``?{}:{path:M}}))};return S(B,{open:!0,onOpenChange:e=>!e&&!u&&n.closeAddWorkspace(),children:A(D,{style:a,width:`md`,"data-testid":`add-workspace-dialog`,"aria-describedby":void 0,children:[S(H,{children:S(W,{children:`Add workspace`})}),A(v,{children:[A(`label`,{htmlFor:`add-workspace-root`,className:`flex flex-col gap-1`,children:[S(`span`,{className:`text-base font-medium text-po-dim`,children:`Folder`}),A(`span`,{className:`flex items-center gap-1.5`,children:[S(Q,{id:`add-workspace-root`,ref:w,"data-testid":`add-workspace-root`,value:p,autoFocus:!0,disabled:u,onChange:e=>k(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`&&o.length>0)e.preventDefault(),C(e=>(e+1)%o.length);else if(e.key===`ArrowUp`&&o.length>0)e.preventDefault(),C(e=>e<=0?o.length-1:e-1);else if(e.key===`Enter`){let e=x===St?void 0:o[x];e===void 0?R():j(e)}},placeholder:`~/workspace/my-project`,className:`min-w-0 flex-1 font-mono`}),S(t,{variant:y?`subtle`:`outline`,size:`md`,"data-testid":`add-workspace-browse`,"aria-pressed":y,disabled:u,onClick:()=>b(e=>!e),children:`Browse`})]})]}),y?S(bt,{...M.startsWith(`/`)?{start:M}:{},listDirectory:n.listDirectory,onSelect:e=>{k(e),b(!1)}}):o.length>0?S(`div`,{role:`listbox`,"aria-label":`matching directories`,"data-testid":`add-workspace-suggestions`,className:`max-h-40 overflow-y-auto rounded border border-po-border bg-po-deep p-1`,children:o.map((e,t)=>S(ut,{density:`compact`,active:t===x,"data-testid":`add-workspace-suggestion`,onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>C(t),onClick:()=>j(e),className:`w-full px-2.5 py-1 `,children:e},e))}):null,e.length>0?S(`div`,{className:`flex flex-wrap gap-1`,children:e.slice(0,4).map(e=>S(t,{variant:`outline`,size:`xs`,disabled:u,onClick:()=>k(e),children:e},e))}):null,N?S(`p`,{role:`status`,className:`text-sm text-po-dim`,children:`Reading workspace declarations…`}):null,P?S(`p`,{role:`alert`,className:`text-sm text-po-red`,children:P}):null,F?A(`fieldset`,{className:`flex min-w-0 flex-col gap-1`,children:[S(`legend`,{className:`mb-1 text-base font-medium text-po-hi`,children:`Workspaces`}),S(`p`,{className:`mb-1 text-sm text-po-dim`,children:`Declared in .po/config.yaml. Choose which to add.`}),F.map((e,t)=>{let n=I(e.name)!==void 0,a=n||r.checked.includes(e.name),o=r.results.find(t=>t.name===e.name)?.error;return S(`div`,{"data-checked":a,className:`rounded-sm px-2 py-1.5 data-[checked=true]:bg-po-tint-green`,children:A(`label`,{htmlFor:`add-workspace-declaration-${t}`,className:`flex min-w-0 cursor-pointer items-start gap-2.5`,children:[S(z,{id:`add-workspace-declaration-${t}`,checked:a,disabled:n||u,onCheckedChange:()=>i({checked:a?r.checked.filter(t=>t!==e.name):[...r.checked,e.name]}),className:`mt-1`}),A(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[S(`span`,{className:`text-base font-semibold text-po-hi`,children:e.name}),S(`span`,{className:`truncate text-sm text-po-dim`,title:e.instructions,children:e.instructions}),o?S(`span`,{role:`alert`,className:`text-sm text-po-red`,children:o}):null]}),n?S(`span`,{className:`text-sm text-po-dim`,children:`Added`}):null]})},e.name)})]}):ee?A(g,{children:[A(`label`,{htmlFor:`add-workspace-name`,className:`flex flex-col gap-1`,children:[S(`span`,{className:`text-base font-medium text-po-dim`,children:`Name`}),S(Q,{id:`add-workspace-name`,"data-testid":`add-workspace-name`,value:E,disabled:u,onChange:e=>{h(!0),m(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&R()},placeholder:`my-project`})]}),A(`label`,{htmlFor:`add-workspace-instructions`,className:`flex flex-col gap-1`,children:[A(`span`,{className:`text-base font-medium text-po-dim`,children:[`Instructions `,S(`span`,{className:`font-normal`,children:`(optional)`})]}),S(T,{id:`add-workspace-instructions`,rows:3,value:l,disabled:u,onChange:e=>i({instructions:e.target.value})}),S(`span`,{className:`text-sm text-po-dim`,children:`For main sessions in this workspace.`})]})]}):null,ee&&M===``&&E.trim()!==``?A(`p`,{"data-testid":`add-workspace-default-hint`,className:`text-sm text-po-dim`,children:[`creates ~/.po/workspace/`,E.trim()]}):null,d?S(`pre`,{className:`max-h-28 overflow-y-auto rounded border border-po-edge-red bg-po-tint-red/40 px-2.5 py-2 text-sm whitespace-pre-wrap text-po-red`,children:d}):null,A(U,{children:[S(t,{variant:`outline`,onClick:()=>n.closeAddWorkspace(),disabled:u,children:`Cancel`}),S(t,{variant:`primary`,"data-testid":`add-workspace-confirm`,onClick:()=>void R(),disabled:!te,children:u?`Adding…`:F?`Add ${L.length} ${L.length===1?`workspace`:`workspaces`}`:`Add workspace`})]})]})]})})}var Dt=`rail/workflow-steps-expanded`,Ot=e=>e.awaitingInput||(e.waitingCount??0)>0;function kt(e){let t=new Set(e.map(({session:e})=>e.id)),n=new Map,r=[];for(let i of e){let e=i.session.parentId;i.session.provenance===`workflow`&&e!==void 0&&t.has(e)?n.set(e,[...n.get(e)??[],i]):r.push(i)}let i=r.sort((e,t)=>(t.session.lastActivityAt??0)-(e.session.lastActivityAt??0)).map(e=>[e,...n.get(e.session.id)??[]]),a=e=>e.some(({session:e})=>Ot(e));return[{key:`needs`,title:`Needs you`,data:i.filter(a).flat()},{key:`recent`,title:`Recent`,data:i.filter(e=>!a(e)).flat()}].filter(e=>e.data.length>0)}function At({sessionId:e,setup:n,actions:r}){let i=JSON.stringify([`rail/setup`,e,n.id]),[a,o,s]=G(`${i}/busy`,!1),[c,l]=G(`${i}/error`,``),u=async()=>{if(s.state)return;o(!0),l(``);let t=await r.removePendingSetup(e,n.id);o(!1),t!==void 0&&l(t.error)};return A(`div`,{"data-testid":`pending-session-${n.id}`,className:`ml-4 rounded-md border border-po-border-soft bg-po-panel p-3`,children:[A(`div`,{className:`flex items-center justify-between gap-2`,children:[S(`span`,{className:`truncate text-base font-semibold text-po-hi`,children:n.name}),A(Z,{children:[S(X,{asChild:!0,children:S(t,{variant:`ghost`,size:`icon`,title:`session setup actions`,disabled:a,"data-testid":`pending-session-menu-${n.id}`,children:S(et,{className:`h-3 w-3`})})}),S(Y,{children:S(K,{variant:`destructive`,onSelect:()=>void u(),children:`remove setup`})})]})]}),S(`p`,{className:n.failed?`text-sm text-po-red`:`text-sm text-po-dim`,children:n.status}),n.recovery?S(`p`,{role:n.failed?`alert`:void 0,className:`text-sm text-po-dim`,children:n.recovery}):null,c?S(`p`,{role:`alert`,className:`text-sm text-po-red`,children:c}):null]})}function jt(e,t,n=[]){return[...new Set([...e.flatMap(e=>e.groups??[]),...n])].map(n=>({name:n,members:e.filter(e=>e.id!==t&&e.groups?.includes(n)===!0).map(e=>e.name||`Untitled`)}))}function Mt(e,t){if(e.length>32)return`group names are at most 32 characters.`;if(t>=8)return`a session can belong to at most 8 groups.`}function Nt({groups:e}){return A(`span`,{"data-testid":`session-groups`,"aria-label":`groups`,className:`flex min-w-0 items-start gap-1.5 text-sm text-po-dim`,children:[S(He,{"aria-hidden":!0,className:`mt-0.5 size-3.5 shrink-0`}),S(`span`,{className:`flex min-w-0 flex-wrap gap-1`,children:e.map(e=>S(Ce,{tone:`magenta`,size:`xs`,className:`font-normal`,children:e},e))})]})}function Pt({options:e,value:n,query:r,active:i,renaming:a,deleting:o,error:s,busy:c=!1,onQueryChange:l,onToggle:u,onCreate:d,onActive:f,onRenameStart:p,onRenameDraft:m,onRenameConfirm:h,onDeleteStart:g,onDeleteConfirm:_,onRowCancel:v,onCancel:y,onSave:b}){let x=se(),C=r.trim(),w=e.filter(e=>e.name.includes(C)),T=C!==``&&!e.some(e=>e.name===C),E=T?Mt(C,n.length):void 0;return A(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),b()},children:[S(Qe,{children:`sessions that share a group can message each other.`}),A(`div`,{className:`flex flex-col overflow-hidden rounded-md border border-po-border focus-within:border-po-edge-green`,children:[A(`div`,{className:`flex flex-wrap items-center gap-1 bg-po-deep px-2 py-1.5`,children:[n.map(e=>A(Ce,{tone:`magenta`,size:`xs`,className:`font-normal`,children:[e,S(`button`,{type:`button`,"aria-label":`remove ${e}`,className:`text-po-magenta`,onClick:()=>u(e),children:S(I,{"aria-hidden":!0,className:`size-2.5`})})]},e)),S(Q,{variant:`bare`,"data-testid":`session-groups-query`,"aria-label":`find or create a group`,autoFocus:!0,placeholder:n.length===0?`find or create a group`:`add another`,value:r,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&C!==``&&(e.preventDefault(),T?E===void 0&&d():w[0]!==void 0&&(u(w[0].name),l(``)))},className:`h-6 min-w-24 flex-1`})]}),A(`div`,{className:`flex flex-col border-t border-po-border-soft p-1`,onMouseLeave:()=>f(void 0),children:[w.map((e,r)=>{let s=n.includes(e.name),l=`${x}-${String(r)}`,d=e.members.length+ +!!s,y=d===1?`its one session`:`all ${String(d)} sessions`;return a?.group===e.name?A(`div`,{className:`flex flex-col gap-1 rounded-sm bg-po-deep px-2 py-1.5`,children:[A(`span`,{className:`flex items-center gap-2`,children:[S(Q,{"aria-label":`rename ${e.name}`,value:a.draft,autoFocus:!0,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),h())},className:`h-7 flex-1`}),S(t,{type:`button`,variant:`ghost`,size:`sm`,onClick:v,children:`cancel`}),S(t,{type:`button`,variant:`outline`,size:`sm`,disabled:c||a.draft.trim()===``,onClick:h,children:`rename`})]}),A(`span`,{className:`text-sm text-po-dim`,children:[`renames it on `,y,`.`]})]},e.name):o===e.name?A(`div`,{className:`flex items-center gap-2 rounded-sm border border-po-red/40 px-2 py-1.5`,children:[A(`span`,{className:`flex-1 text-sm text-po-text`,children:[`remove `,S(`span`,{className:`font-semibold text-po-hi`,children:e.name}),` from `,y,`? they can no longer message through it.`]}),S(t,{type:`button`,variant:`ghost`,size:`sm`,onClick:v,children:`cancel`}),S(t,{type:`button`,variant:`danger`,size:`sm`,disabled:c,onClick:_,children:`delete`})]},e.name):A(`div`,{"data-testid":`session-group-${e.name}`,onMouseEnter:()=>f(e.name),className:`group flex items-start gap-2.5 rounded-sm px-2 py-1.5 ${s?`bg-po-tint-green`:i===e.name?`bg-po-deep`:``}`,children:[A(`label`,{htmlFor:l,className:`flex min-w-0 flex-1 cursor-pointer items-start gap-2.5`,children:[S(z,{id:l,checked:s,onCheckedChange:()=>u(e.name),className:`mt-1`}),A(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[S(`span`,{className:`text-base ${s?`font-semibold text-po-hi`:`text-po-text`}`,children:e.name}),S(`span`,{className:`truncate text-sm text-po-dim`,title:e.members.join(`, `),children:e.members.length===0?`no other sessions yet`:e.members.join(`, `)})]})]}),A(`span`,{className:`flex shrink-0 items-center gap-0.5 ${i===e.name?`opacity-100`:`opacity-0 group-focus-within:opacity-100`}`,children:[S(t,{type:`button`,variant:`ghost`,size:`icon`,title:`rename ${e.name}`,onClick:()=>p(e.name),children:S(xe,{"aria-hidden":!0,className:`size-3.5`})}),S(t,{type:`button`,variant:`ghost`,size:`icon`,title:`delete ${e.name}`,onClick:()=>g(e.name),children:S(at,{"aria-hidden":!0,className:`size-3.5`})})]})]},e.name)}),T?A(`button`,{type:`button`,"data-testid":`session-groups-create`,disabled:E!==void 0,onClick:d,className:`flex flex-col gap-0.5 rounded-sm px-2 py-1.5 text-left ${E===void 0?`bg-po-deep`:``}`,children:[A(`span`,{className:`flex items-center gap-2.5 text-base ${E===void 0?`text-po-magenta`:`text-po-faint`}`,children:[S(Ie,{"aria-hidden":!0,className:`size-3.5`}),A(`span`,{className:`truncate`,children:[`create group “`,C,`”`]})]}),E===void 0?null:S(`span`,{className:`pl-6 text-sm text-po-red`,children:E})]}):null]})]}),A(`span`,{className:`text-sm text-po-dim`,children:[n.length,` of `,8,` groups`]}),s===void 0?null:S(`span`,{"data-testid":`session-groups-error`,className:`text-sm text-po-red`,children:s}),A(U,{children:[S(t,{type:`button`,variant:`outline`,size:`md`,onClick:y,children:`cancel`}),S(t,{type:`submit`,variant:`primary`,size:`md`,disabled:c,children:`save`})]})]})}function Ft({session:e,sessions:t,actions:n,onClose:r}){let[i,a]=J(()=>[...e.groups??[]]),[o,s]=J(``),[c,l]=J(),[u,d]=J(),[f,p]=J(),[m,h]=J(),[g,_]=J(!1),y=async(e,t)=>{_(!0),h(void 0);let n=await e();_(!1),n===void 0?t():h(n.error)},b=()=>{d(void 0),p(void 0)};return S(B,{open:!0,onOpenChange:e=>!e&&!g&&r(),children:A(D,{width:`sm`,"data-testid":`session-groups-dialog-${e.id}`,"aria-describedby":void 0,children:[S(H,{children:S(W,{children:`session groups`})}),S(v,{children:S(Pt,{options:jt(t,e.id,i),value:i,query:o,active:c,renaming:u,deleting:f,error:m,busy:g,onQueryChange:s,onToggle:e=>{h(void 0),i.includes(e)?a(i.filter(t=>t!==e)):i.length>=8?h(Mt(``,i.length)):a([...i,e])},onCreate:()=>{let e=o.trim();e!==``&&Mt(e,i.length)===void 0&&(a([...i,e]),s(``))},onActive:l,onRenameStart:e=>{p(void 0),d({group:e,draft:e})},onRenameDraft:e=>d(t=>t===void 0?t:{...t,draft:e}),onRenameConfirm:()=>{if(u===void 0)return;let e=u.draft.trim();e===``||e===u.group?b():y(()=>n.renameGroup(u.group,e),()=>{a(t=>[...new Set(t.map(t=>t===u.group?e:t))]),b()})},onDeleteStart:e=>{d(void 0),p(e)},onDeleteConfirm:()=>{f!==void 0&&y(()=>n.deleteGroup(f),()=>{a(e=>e.filter(e=>e!==f)),b()})},onRowCancel:b,onCancel:r,onSave:()=>void y(()=>n.setSessionGroups(e.id,i),r)})})]})})}function It(e=[],t=[]){return e.length===t.length&&e.every((e,n)=>e===t[n])}function Lt(e){return e.filter(e=>e.groups!==void 0&&e.groups.length>0)}function Rt(e,t){if(e.session!==t.session||e.actions!==t.actions||e.workspaceName!==t.workspaceName||e.coordinates!==t.coordinates||e.coordinatorEligible!==t.coordinatorEligible||e.coordinator!==t.coordinator||e.readOnly!==t.readOnly||e.stepsExpanded!==t.stepsExpanded||e.onToggleSteps!==t.onToggleSteps)return!1;let n=Lt(e.sessions),r=Lt(t.sessions);return n.length===r.length&&n.every((e,t)=>{let n=r[t];return e.id===n.id&&e.name===n.name&&It(e.groups,n.groups)})}function zt({session:e,className:t}){let n=e.waitingCount??+!!e.awaitingInput;return n<=0?null:A(g,{children:[S(pt,{ask:!0,"aria-hidden":!0,"data-testid":`session-awaiting-input`,className:t,children:n}),A(`span`,{className:`sr-only`,children:[`, `,n,` waiting for you`]})]})}var Bt=vt(function({session:e,sessions:n,actions:r,workspaceName:i,coordinates:a,coordinatorEligible:o=!1,coordinator:s,readOnly:c=!1,stepsExpanded:d,onToggleSteps:f}){let p=`rail/session/${e.id}`,[m,_]=G(`${p}/mode`,`view`),[y,x]=G(`${p}/draft`,``),[C,w]=G(`${p}/error`,``),[T,E]=G(`${p}/role-error`,``),[,k,j]=G(`${p}/removing`,!1),M=O(m),N=e=>{M.current=e,_(e)},{active:P}=e,F=C||T||e.error,I=async t=>{N(`view`),E(``);let n=await r.setSessionRole?.(e.id,t);n!==void 0&&E(n.error)},L=r.setSessionRole===void 0||!o||e.coordinatorEligible!==!0||a===void 0?null:e.coordinator?S(K,{"data-testid":`session-make-regular-${e.id}`,disabled:e.restartBlocked===!0,onSelect:()=>void I(!1),children:`Make regular session`}):S(K,{"data-testid":`session-make-coordinator-${e.id}`,disabled:e.restartBlocked===!0,onSelect:()=>s===void 0?void I(!0):N(`promote`),children:`Make coordinator`}),ee=P?`rounded-lg border border-po-edge-green bg-po-tint-green px-3 py-3 hover:bg-po-tint-green`:`rounded-lg border border-transparent px-3 py-3 hover:bg-po-panel`,te=()=>{r.renameSession(e.id,y),N(`view`)},ne=async()=>{if(j.state)return;k(!0),N(`view`),w(``);let t=await r.removeSession(e.id);k(!1),t!==void 0&&w(t.error)},z=e.status.startsWith(`failed`)||e.status.includes(` failed`),re=e.status.startsWith(`running`),ie=A(`span`,{className:`flex min-w-0 items-start gap-1.5 text-sm leading-snug ${z?`text-po-red`:re?`text-po-yellow`:P?`text-po-text`:`text-po-dim`}`,children:[re?S(Se,{"aria-hidden":!0,className:`mt-0.5 size-3 shrink-0 animate-spin`}):z?S(Ve,{"aria-hidden":!0,className:`mt-0.5 size-3 shrink-0`}):null,e.clock?S(nt,{"data-testid":`session-status`,className:P?`line-clamp-2`:`truncate`,label:e.clock.label,since:e.clock.since}):S(`span`,{"data-testid":`session-status`,className:P?`line-clamp-2`:`truncate`,children:e.status})]}),oe=A(`span`,{className:`flex min-w-0 items-start gap-2`,children:[e.nested&&e.provenance===`workflow-session`?S(ce,{"aria-label":`workflow session`,className:`mt-1 size-3 shrink-0 ${P?`text-po-green`:`text-po-faint`}`}):e.provenance===`workflow`?S(he,{"aria-label":`workflow step`,className:`mt-1 size-3 shrink-0 ${P?`text-po-green`:`text-po-faint`}`}):e.nested&&e.provenance?S(fe,{"aria-label":e.provenance===`worktree`?`automatic per-conversation worktree`:e.provenance,className:`mt-1 size-3 shrink-0 ${P?`text-po-green`:`text-po-faint`}`}):null,S(`span`,{className:`min-w-0 flex-1 text-base font-semibold break-words text-po-hi`,children:e.name||`Untitled`}),(e.waitingCount??+!!e.awaitingInput)>0?S(zt,{session:e,className:`mt-0.5 shrink-0 transition-opacity group-focus-within:opacity-0 group-hover:opacity-0`}):e.ordinal>=1&&e.ordinal<=9?S(`span`,{title:`press ${String(e.ordinal)} to focus`,className:`grid size-5 shrink-0 place-items-center rounded-full bg-po-panel text-2xs text-po-dim transition-opacity group-focus-within:opacity-0 group-hover:opacity-0`,children:e.ordinal}):null]}),se=A(g,{children:[oe,A(`span`,{className:`flex w-full min-w-0 items-end gap-2`,children:[A(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[ie,e.coordinator?A(`span`,{"data-testid":`session-coordinator`,className:`text-sm text-po-dim`,children:[`Coordinates `,a??`workspace`]}):null,i?A(`span`,{"data-testid":`session-workspace`,className:`flex min-w-0 items-center gap-1.5 text-sm text-po-dim`,children:[S(Ae,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),S(`span`,{className:`truncate`,children:i})]}):null,e.git?A(`span`,{"data-testid":`session-branch`,className:`flex min-w-0 items-center gap-1.5 text-sm text-po-dim`,children:[S(R,{className:`size-3.5 shrink-0 ${P?`text-po-green`:``}`}),S(`span`,{className:`truncate font-mono`,children:e.git.branch}),e.git.dirty?S(`span`,{className:`shrink-0 text-po-yellow`,children:`modified`}):null]}):null]}),e.profile?A(u,{"data-testid":`session-avatar`,"aria-label":e.profile.label,title:e.profile.label,className:`size-8 shrink-0 rounded-full`,children:[e.profile.avatarUrl?S(b,{src:e.profile.avatarUrl,alt:``}):null,S(h,{className:`bg-po-tint-green text-xs font-semibold text-po-green`,children:e.profile.initials})]}):null]}),e.groups!==void 0&&e.groups.length>0?S(Nt,{groups:e.groups}):null,F?S(`span`,{"data-testid":`session-error`,className:`line-clamp-3 text-sm break-words text-po-red`,children:F}):null]}),V=m===`menu`;return A(g,{children:[A(`div`,{className:Le(`group relative`,e.provenance===`workflow`?`pl-10`:(e.nested||d!==void 0)&&`pl-5`),"data-testid":`session-card-${e.id}`,"data-active":P,"data-nested":e.nested,children:[d===void 0?null:S(`button`,{type:`button`,"data-testid":`session-steps-${e.id}`,"aria-expanded":d,"aria-label":`${d?`Hide`:`Show`} steps of ${e.name||`this workflow`}`,onClick:()=>f?.(e.id),className:`absolute top-3.5 left-0 grid size-5 place-items-center rounded-sm text-po-faint outline-none hover:text-po-hi focus-visible:ring-2 focus-visible:ring-po-green/50`,children:S(d?ae:l,{"aria-hidden":!0,className:`size-3.5`})}),S(t,{variant:`ghost`,size:`card`,"data-testid":`session-open-${e.id}`,onClick:()=>r.openSession(e.id),className:ee,children:se}),!c&&(m===`view`||V)?S(`div`,{className:`absolute top-2 right-2 transition-opacity ${V?`opacity-100`:`opacity-0 group-focus-within:opacity-100 group-hover:opacity-100`}`,children:A(Z,{open:V,onOpenChange:e=>{let t=M.current;N(e?`menu`:t===`menu`?`view`:t)},children:[S(X,{asChild:!0,children:S(t,{variant:`ghost`,size:`icon`,"data-testid":`session-menu-${e.id}`,title:`session actions`,className:P?`text-po-dim hover:bg-po-tint-green hover:text-po-hi data-[state=open]:bg-po-tint-green data-[state=open]:text-po-hi`:`text-po-faint hover:bg-po-deep hover:text-po-hi data-[state=open]:bg-po-deep data-[state=open]:text-po-hi`,children:S(et,{className:`h-3 w-3`})})}),A(Y,{"data-testid":`session-menu-list-${e.id}`,onCloseAutoFocus:e=>{M.current!==`view`&&e.preventDefault()},children:[r.renderSessionMenuItems(e.id),e.canInteract===!1?null:A(g,{children:[L,S(K,{"data-testid":`session-rename-${e.id}`,onSelect:()=>{x(e.name),N(`rename`)},children:`Rename`}),S(K,{"data-testid":`session-groups-${e.id}`,onSelect:()=>N(`groups`),children:`Groups`}),S(K,{"data-testid":`session-resume-${e.id}`,onSelect:()=>r.resumeSession(e.id),children:`Resume`}),r.openMoveSession&&e.move?S(K,{"data-testid":`session-move-${e.id}`,disabled:e.restarting||e.move.blocked,onSelect:()=>r.openMoveSession(e.id),children:`Move to workspace…`}):null,S(K,{"data-testid":`session-restart-${e.id}`,disabled:e.restarting||e.restartBlocked===!0,onSelect:()=>r.restartSession(e.id),children:`Restart`}),S(K,{variant:`destructive`,"data-testid":`session-stop-${e.id}`,onSelect:()=>N(`confirm`),children:`Remove`})]})]})]})}):null,S(B,{open:e.canInteract!==!1&&m===`rename`,onOpenChange:e=>!e&&N(`view`),children:A(D,{width:`sm`,"data-testid":`session-rename-dialog-${e.id}`,"aria-describedby":void 0,children:[S(H,{children:S(W,{children:`rename session`})}),S(v,{children:A(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),te()},children:[S(Q,{"data-testid":`session-name-input-${e.id}`,"aria-label":`session name`,value:y,autoFocus:!0,onChange:e=>x(e.target.value)}),A(U,{children:[S(t,{type:`button`,variant:`outline`,size:`md`,"data-testid":`session-rename-cancel-${e.id}`,onClick:()=>N(`view`),children:`cancel`}),S(t,{type:`submit`,variant:`primary`,size:`md`,"data-testid":`session-rename-confirm-${e.id}`,disabled:y.trim()===``,children:`rename`})]})]})})]})}),e.canInteract!==!1&&m===`groups`?S(Ft,{session:e,sessions:n,actions:r,onClose:()=>N(`view`)}):null,S(B,{open:e.canInteract!==!1&&m===`confirm`,onOpenChange:e=>!e&&N(`view`),children:A(D,{width:`sm`,"data-testid":`session-stop-dialog-${e.id}`,"aria-describedby":void 0,children:[S(H,{children:S(W,{children:`remove session`})}),A(v,{children:[A(Qe,{children:[`this stops `,S(`span`,{className:`font-semibold text-po-hi`,children:e.name||`untitled`}),` and removes it from the rail. anything it is running ends now. you can restore it for 7 days.`]}),A(U,{children:[S(t,{variant:`outline`,size:`md`,"data-testid":`session-stop-cancel-${e.id}`,autoFocus:!0,onClick:()=>N(`view`),children:`cancel`}),S(t,{variant:`danger`,size:`md`,"data-testid":`session-stop-confirm-${e.id}`,onClick:()=>void ne(),children:`remove`})]})]})]})}),S(B,{open:e.canInteract!==!1&&m===`promote`,onOpenChange:e=>!e&&N(`view`),children:A(D,{width:`sm`,"data-testid":`session-promote-dialog-${e.id}`,"aria-describedby":void 0,children:[S(H,{children:A(W,{children:[`Make `,e.name||`Untitled`,` the coordinator of `,a,`?`]})}),A(v,{children:[A(Qe,{children:[S(`span`,{className:`font-semibold text-po-hi`,children:e.name||`Untitled`}),` will see every session in`,` `,a,`, message them, and start new ones.`,` `,S(`span`,{className:`font-semibold text-po-hi`,children:s}),` becomes a regular session. Both restart to take on their new roles, so anything they are running stops now.`]}),A(U,{children:[S(t,{variant:`outline`,size:`md`,"data-testid":`session-promote-cancel-${e.id}`,autoFocus:!0,onClick:()=>N(`view`),children:`Cancel`}),S(t,{variant:`primary`,size:`md`,"data-testid":`session-promote-confirm-${e.id}`,onClick:()=>void I(!0),children:`Make coordinator`})]})]})]})})]}),e.pendingSetups.map(t=>S(At,{sessionId:e.id,setup:t,actions:r},`setup:${t.id}`))]})},Rt);function Vt({workspace:n,sessions:r,actions:i,quiet:a=!1,readOnly:s=!1}){let c=`rail/workspace/${n.id}`,[l,u]=G(`${c}/open`,!1),[d,f]=G(`${c}/error`,``),[p,m,h]=G(`${c}/removing`,!1),[_,y]=G(`${c}/coordinator-error`,``),[b,x]=G(Dt,[]),C=o(e=>x(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),[x]),{id:w,name:T,root:E,available:O,legacy:k}=n,j=n.sessions.find(e=>e.coordinator),M=e(n.sessions,new Set(b)),N=e=>M.withSteps.has(e)?{stepsExpanded:b.includes(e),onToggleSteps:C}:{},P=async()=>{y(``);let e=await i.addCoordinator?.(w);e!==void 0&&y(e.error)};if(n.kind===`session`)return n.sessions.length===0?null:S(`div`,{"data-testid":`session-group-${w}`,className:`flex flex-col gap-1`,children:M.sessions.map(e=>S(Bt,{session:e,sessions:r,actions:i,readOnly:s,coordinates:`Home`,coordinatorEligible:e.coordinatorEligible===!0,coordinator:j?.id===e.id?void 0:j?.name,...N(e.id)},e.id))});let F=async()=>{if(h.state)return;m(!0),f(``);let e=await i.deleteWorkspace(w);m(!1),e===void 0?u(!1):f(e.error)};return A(`section`,{"data-testid":`workspace-group-${w}`,"data-available":O,className:`flex flex-col gap-1.5`,children:[A(`div`,{className:`flex min-w-0 items-start gap-2.5 rounded-md px-2 py-1 transition-colors hover:bg-po-panel/60`,children:[a?null:S(Ae,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-po-dim`}),A(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[!k&&i.openWorkspace?S(`button`,{type:`button`,"data-testid":`workspace-open-${w}`,onClick:()=>i.openWorkspace?.(w),className:`truncate rounded-sm text-left text-base text-po-hi outline-none focus-visible:ring-2 focus-visible:ring-po-green/50 ${a?`font-medium`:`font-semibold`}`,title:a?E:`Open ${T} workspace`,children:T}):S(`p`,{className:`truncate text-base text-po-hi ${a?`font-medium`:`font-semibold`}`,title:a?E:void 0,children:T}),a?null:S(`p`,{className:`truncate font-mono text-sm text-po-dim`,title:E,children:E})]}),k||s?null:A(g,{children:[S(t,{variant:`ghost`,size:`icon`,"data-testid":`workspace-new-session-${w}`,title:`New session`,"aria-label":`New session in ${T}`,disabled:!O,onClick:()=>i.createSession(w),className:`text-po-faint hover:text-po-hi`,children:S(Ie,{className:`size-3.5`})}),A(Z,{children:[S(X,{asChild:!0,children:S(t,{variant:`ghost`,size:`icon`,"data-testid":`workspace-menu-${w}`,title:`Workspace actions`,"aria-label":`${T} actions`,className:`text-po-faint hover:text-po-hi`,children:S(et,{className:`size-3.5`})})}),A(Y,{children:[S(K,{disabled:!O,onSelect:()=>i.resumeInWorkspace(w),children:`Resume Session`}),i.addCoordinator?S(K,{"data-testid":`workspace-add-coordinator-${w}`,disabled:!O,onSelect:()=>void P(),children:`Add bot`}):null,S(K,{disabled:!O,onSelect:()=>i.openWorkspaceSettings(w),children:`Workspace Settings`}),S(K,{variant:`destructive`,"data-testid":`workspace-delete-${w}`,onSelect:()=>{f(``),u(!0)},children:`Delete Workspace`})]})]})]})]}),O?null:S(`p`,{className:`px-9 text-sm text-po-red`,children:`Workspace unavailable`}),_?S(`p`,{"data-testid":`workspace-coordinator-error-${w}`,className:`px-9 text-sm text-po-red`,children:_}):null,n.sessions.length>0?S(`div`,{className:`flex flex-col gap-1`,children:M.sessions.map(e=>S(Bt,{session:e,sessions:r,actions:i,readOnly:s,coordinates:T,coordinatorEligible:e.coordinatorEligible===!0,coordinator:j?.id===e.id?void 0:j?.name,...N(e.id)},e.id))}):null,S(B,{open:l,onOpenChange:e=>!e&&!p&&u(!1),children:A(D,{width:`sm`,"data-testid":`workspace-delete-dialog-${w}`,"aria-describedby":void 0,children:[S(H,{children:S(W,{children:`delete workspace`})}),A(v,{children:[A(Qe,{children:[`this removes `,S(`span`,{className:`font-semibold text-po-hi`,children:T}),` and all its sessions from Po. running work will stop. files at `,S(`code`,{children:E}),` stay on disk.`]}),d?S(`p`,{"data-testid":`workspace-delete-error-${w}`,className:`text-sm text-po-red`,children:d}):null,A(U,{children:[S(t,{variant:`outline`,size:`md`,"data-testid":`workspace-delete-cancel-${w}`,disabled:p,autoFocus:!0,onClick:()=>u(!1),children:`cancel`}),S(t,{variant:`danger`,size:`md`,"data-testid":`workspace-delete-confirm-${w}`,disabled:p,onClick:()=>void F(),children:p?`deleting…`:`delete`})]})]})]})})]})}var Ht=`po.session-view`,Ut=`self-host`,Wt=`po.other-workspaces-open`,Gt=[{value:`workspaces`,title:`Workspaces`,description:`Sessions grouped by workspace`,Icon:Ae},{value:`sessions`,title:`Sessions`,description:`Needs you first, then latest change`,Icon:Je}];function Kt(e){try{return window.localStorage.getItem(e)}catch{return null}}function qt(e,t){try{window.localStorage.setItem(e,t)}catch{}}function Jt(){return typeof window<`u`&&window.poDesktop?.cloud!==void 0}function Yt(){return typeof window<`u`&&window.poDesktop?.platform===Ut}function Xt(){window.history.pushState(null,``,`/cloud`),window.dispatchEvent(new PopStateEvent(`popstate`))}var Zt=e=>e.kind!==`session`&&e.sessions.length===0;function Qt({rail:e,onClose:r,selfHost:i=Yt(),cloud:a=Jt()&&!i}){let{actions:o}=e;return A(`div`,{className:`flex min-h-full flex-col`,children:[A(`div`,{"data-po-session-rail-header":!0,className:`flex min-h-16 items-center justify-between gap-2 px-5 py-3`,children:[A(`span`,{className:`flex items-center gap-2.5`,"aria-label":`Po`,children:[S(`img`,{src:`/favicon.svg`,alt:``,"aria-hidden":`true`,className:`size-9 rounded-lg`}),S(`span`,{"aria-hidden":`true`,className:`text-2xl font-semibold text-po-hi`,children:`Po`})]}),A(`span`,{className:`flex items-center gap-1`,children:[S(`div`,{"data-rail-status":`advanced-action`,className:`contents`,children:S($,{slot:P.railStatus,sessionId:null})}),S(t,{variant:`ghost`,size:`icon`,"data-testid":`mobile-sessions-close`,title:`Hide sessions`,"aria-label":`Hide sessions`,onClick:r,className:`text-po-dim md:hidden`,children:S(I,{className:`size-3.5`})})]})]}),S(`div`,{className:`px-3 pt-4`,children:A(t,{variant:`ghost`,size:`lg`,"data-testid":`home-open`,"aria-current":e.homeActive?`page`:void 0,onClick:o.openHome,className:e.homeActive?`w-full justify-start gap-2.5 border border-po-edge-green bg-po-tint-green px-2 text-po-hi`:`w-full justify-start gap-2.5 border border-transparent px-2 text-po-text`,children:[S(n,{"aria-hidden":`true`,className:e.homeActive?`size-5 text-po-green`:`size-5 text-po-dim`}),`Home`]})}),e.pluginContent,S($t,{rail:e}),S(`div`,{className:`flex-1`}),A(`div`,{className:`sticky bottom-0 mt-auto shrink-0 bg-po-rail`,children:[S(`div`,{"data-rail-status":`advanced-banner`,className:`contents`,children:S($,{slot:P.railStatus,sessionId:null})}),A(`div`,{className:`flex flex-col gap-1 border-t border-po-border-soft px-3 py-3`,children:[A(t,{variant:`ghost`,size:`lg`,"data-testid":`settings-open`,onClick:o.openSettings,className:`justify-start gap-2.5 px-2 text-po-text`,children:[S(ct,{className:`size-5 text-po-dim`}),`Settings`]}),a?A(t,{variant:`ghost`,size:`lg`,"data-testid":`cloud-open`,onClick:Xt,className:`justify-start gap-2.5 px-2 text-po-text`,children:[S(gt,{className:`size-5 text-po-dim`}),`Po Cloud`]}):null,A(`span`,{className:`px-2 text-sm text-po-dim max-sm:hidden`,children:[S(Ue,{className:`bg-po-panel`,children:`ctrl+k`}),` commands · `,S(Ue,{className:`bg-po-panel`,children:`ctrl+t`}),` new session`]})]})]})]})}function $t({rail:n,createMenuDefaultOpen:r=!1}){let{actions:a}=n,s=n.coordinatorHosts??[],[c,u]=G(`rail/coordinator-error`,``),d=async e=>{u(``);let t=await a.addCoordinator?.(void 0,e);t!==void 0&&u(t.error)},f=n.workspaces.flatMap(e=>e.sessions),[p,m]=G(Dt,[]),h=o(e=>m(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),[m]),_=e(f,new Set(p)),v=new Set(_.sessions.map(e=>e.id)),y=n.workspaces.every(e=>e.kind===`session`&&e.sessions.length===0),b=n.workspaces.filter(Zt),C=O(null),[w,T]=G(`rail/initial-selection-revealed`,!1),[E,D]=G(`rail/session-view`,()=>Kt(Ht)===`sessions`?`sessions`:`workspaces`),[k,j]=G(`rail/other-workspaces-open`,()=>Kt(Wt)===`true`),M=Gt.find(e=>e.value===E)??Gt[0];return x(()=>{if(w)return;let e=C.current?.querySelector(`[data-active="true"]`);e&&(e.scrollIntoView({block:`center`,inline:`nearest`,behavior:`instant`}),T(!0))},[n.workspaces,w,T]),A(g,{children:[A(`div`,{className:`flex items-center justify-between px-5 pt-4 pb-2`,children:[S(`h2`,{className:`text-lg font-semibold text-po-hi`,children:`Sessions`}),A(`span`,{className:`flex items-center gap-1`,children:[A(Z,{children:[S(X,{asChild:!0,children:S(t,{variant:`ghost`,size:`icon`,"data-testid":`session-view-menu`,title:`View: ${M.title}`,"aria-label":`View: ${M.title}`,className:`text-po-dim hover:text-po-hi`,children:S(i,{className:`size-3.5`})})}),S(Y,{align:`end`,"aria-label":`View`,children:Gt.map(({value:e,title:t,description:n,Icon:r})=>A(K,{"data-testid":`session-view-${e}`,"aria-checked":E===e,role:`menuitemradio`,onSelect:()=>{D(e),qt(Ht,e)},className:`items-start gap-2.5 ${E===e?`bg-po-tint-green`:``}`,children:[S(r,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 ${E===e?`text-po-green`:`text-po-dim`}`}),A(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[S(`span`,{className:`text-po-hi`,children:t}),S(`span`,{className:`text-sm text-po-dim`,children:n})]}),E===e?S(pe,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-po-green`}):null]},e))})]}),A(Z,{defaultOpen:r,children:[S(X,{asChild:!0,children:S(t,{variant:`ghost`,size:`icon`,"data-testid":`session-create-menu`,title:`Create workspace, session or bot`,"aria-label":`Create workspace, session or bot`,className:`text-po-dim hover:text-po-hi`,children:S(Ie,{className:`size-3.5`})})}),A(Y,{children:[S(K,{"data-testid":`add-workspace-open`,onSelect:a.openAddWorkspace,children:`Create workspace`}),a.createGeneralSession?S(K,{"data-testid":`new-session-open`,onSelect:a.createGeneralSession,children:`Create session`}):null,a.addCoordinator?s.map(e=>S(K,{"data-testid":e.hostId?`coordinator-create-${e.hostId}`:`coordinator-create`,onSelect:()=>void d(e.hostId),children:s.length>1?`Create bot on ${e.label}`:`Create bot`},e.hostId??`local`)):null]})]})]})]}),c?S(`p`,{"data-testid":`coordinator-create-error`,className:`px-5 text-sm text-po-red`,children:c}):null,A(`div`,{ref:C,className:`flex flex-col gap-4 px-3 pb-3`,children:[E===`sessions`?kt(n.workspaces.flatMap(e=>e.sessions.filter(e=>v.has(e.id)).map(t=>({session:t,workspaceName:e.kind===`session`?void 0:e.name,coordinates:e.kind===`session`?`Home`:e.name,coordinatorEligible:t.coordinatorEligible===!0,coordinator:e.sessions.find(e=>e.coordinator&&e.id!==t.id)?.name})))).map(e=>A(`section`,{"data-testid":`session-timeline-${e.key}`,className:`flex flex-col gap-1`,children:[S(`h3`,{className:`px-2 text-xs font-semibold tracking-wide text-po-dim uppercase`,children:e.title}),e.data.map(({session:e,workspaceName:t,coordinates:n,coordinatorEligible:r,coordinator:i})=>S(Bt,{session:e,sessions:f,actions:a,workspaceName:t,coordinates:n,coordinatorEligible:r,coordinator:i,..._.withSteps.has(e.id)?{stepsExpanded:p.includes(e.id),onToggleSteps:h}:{}},e.id))]},e.key)):n.workspaces.filter(e=>!Zt(e)).map(e=>S(Vt,{workspace:e,sessions:f,actions:a},e.id)),E===`workspaces`&&b.length>0?A(`section`,{"data-testid":`other-workspaces`,className:`flex flex-col gap-1`,children:[A(`button`,{type:`button`,"data-testid":`other-workspaces-toggle`,"aria-expanded":k,"aria-label":`Other workspaces, ${String(b.length)} without sessions`,onClick:()=>{j(!k),qt(Wt,String(!k))},className:`flex items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors outline-none hover:bg-po-panel/60 focus-visible:ring-2 focus-visible:ring-po-green/50`,children:[S(k?ae:l,{"aria-hidden":!0,className:`size-4 shrink-0 text-po-dim`}),S(`span`,{className:`flex-1 text-base font-semibold text-po-hi`,children:`Other workspaces`}),S(`span`,{className:`min-w-5.5 rounded-full bg-po-panel px-1.5 text-center text-xs text-po-dim`,children:b.length})]}),k?S(`div`,{className:`flex flex-col gap-0.5 pl-4`,children:b.map(e=>S(Vt,{workspace:e,sessions:f,actions:a,quiet:!0},e.id))}):null]}):null,y||E===`sessions`&&f.length===0?S(`p`,{className:`px-2 text-sm text-po-dim`,children:`Start a session to work with Po. No workspace needed.`}):null]})]})}function en({view:e,slots:n,rail:r,navigationOpen:i,desktopActivityOpen:a,mobileActivityOpen:o,onNavigationOpenChange:s,onDesktopActivityOpenChange:c,onMobileActivityOpenChange:l}){let{scrollRef:u}=r,d=e===`conversation`||e===`welcome`,f=o?a?`fixed inset-y-0 right-0 z-40 flex lg:static lg:z-auto`:`fixed inset-y-0 right-0 z-40 flex lg:hidden`:a?`hidden lg:flex`:`hidden`;return A(`div`,{className:`relative flex h-full min-w-0 overflow-hidden [--po-backdrop-blur:0px]`,children:[S(`aside`,{ref:u,"data-testid":`session-rail-panel`,"data-po-region":`rail`,className:`fixed inset-y-0 left-0 z-40 flex w-[min(320px,calc(100vw-48px))] shrink-0 flex-col overflow-y-auto border-r border-po-border-soft bg-po-rail transition-transform md:visible md:static md:z-auto md:w-[320px] md:translate-x-0 ${i?`visible translate-x-0`:`invisible -translate-x-full`}`,children:S(Qt,{rail:r,onClose:()=>s(!1)})}),i?S(t,{variant:`ghost`,"data-testid":`mobile-drawer-backdrop`,"aria-label":`Hide sessions`,className:`fixed inset-0 z-30 h-auto w-auto rounded-none bg-black/55 p-0 hover:bg-black/55 md:hidden`,onClick:()=>s(!1)}):null,A(`main`,{"data-po-region":`content`,className:`flex min-w-0 flex-1 flex-col overflow-hidden`,children:[n.notices,n.header({navigationToggle:`mobile`,activityToggle:`mobile`}),A(`div`,{"data-testid":`template-content`,className:d?`mx-auto flex min-h-0 w-full max-w-[960px] flex-1 flex-col overflow-hidden px-2 sm:px-4`:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[n.content,n.composer,n.controls]})]}),n.activity==null?null:a||o?S(`div`,{"data-po-region":`activity`,className:f,children:n.activity}):S(t,{variant:`ghost`,"data-testid":`activity-show`,title:`Show activity`,onClick:()=>c(!0),className:`hidden h-auto shrink-0 rounded-none border-l border-po-border-soft bg-po-rail px-2 py-3 font-semibold text-po-dim hover:bg-po-panel hover:text-po-hi lg:flex`,style:{writingMode:`vertical-rl`},children:`Activity`}),o?S(t,{variant:`ghost`,"data-testid":`mobile-activity-backdrop`,"aria-label":`Hide activity`,className:`fixed inset-0 z-30 h-auto w-auto rounded-none bg-black/55 p-0 hover:bg-black/55 lg:hidden`,onClick:()=>l(!1)}):null,r.addWorkspace?S(Tt,{suggestedPaths:r.addWorkspace.suggestedPaths,actions:r.actions}):null]})}function tn({onDismiss:e,...t}){return S(en,{...t,rail:y({onDismiss:e})})}function nn({homeHosts:e}){dt();let t=L(Te,e=>e.dockOpen),[n,r]=J(!1),[i,o]=J(!1),{kind:s,sessionId:c,tabId:l,pageId:u,pluginId:d,workspaceId:f}=je(),h=re(c??null),_=L(q,e=>e.activeId),v=L(q,e=>e.transferringToId===null?null:e.byId[e.transferringToId]?.summary.name??`destination session`),y=mt(),b=ze(),x=b?.summary.dormant===!0?b:null,w=Ye(e=>e.dialog?.id??null),T=L(st,e=>Xe(e,c,l)),D=T===void 0?void 0:ee(c??null).map(e=>e.transientTab?.()).find(e=>e?.id===T.id)??T,O=(l===void 0?void 0:p(c??null).find(e=>e.id===l))??D,j=O===D?D?.composerContext:void 0,F=O!==void 0&&O===D&&D.retainComposer===!0&&D.composerAside===!0,I=ye(`(min-width: 1024px)`),R=L(Te,e=>E(e,_)),ne=F&&O!==void 0?S(be,{label:O.label,composer:S(k,{quiet:!0,composerContext:j})}):null,z=`${s}\u0000${c??``}\u0000${l??``}\u0000${u??``}\u0000${f??``}`,[ae,oe]=J(z);ae!==z&&(oe(z),r(!1),o(!1));let[se,ce]=J(w);se!==w&&(ce(w),w!==null&&(o(!1),r(!1)));let B=()=>{i?o(!1):ge(!1)},V=u===void 0?s===`workspace`&&f!==void 0?S(a,{workspaceId:f,onShowSessions:()=>r(!0)}):s===`home`&&!y?S(we,{hosts:e,onShowSessions:()=>r(!0)}):null:A(de,{pageId:u,sessionId:null,workspaceId:f,onShowSessions:()=>r(!0),children:[u===C?S(ht,{workspaceId:f,pluginId:d}):null,u===le?S(M,{}):null]});return A(`div`,{"data-testid":`cockpit`,className:`h-full min-w-0 overflow-hidden`,children:[S(tn,{view:V||O?`panel`:y?`welcome`:`conversation`,navigationOpen:n,desktopActivityOpen:t,mobileActivityOpen:i,onNavigationOpenChange:r,onDesktopActivityOpenChange:ge,onMobileActivityOpenChange:o,onDismiss:()=>r(!1),slots:{header:e=>V?null:A(g,{children:[S(te,{...e,view:O?.id??`conversation`,onShowSessions:()=>{o(!1),r(!0)},onShowActivity:()=>{r(!1),o(!0)}}),S(`div`,{className:`shrink-0 px-3 pt-2 empty:hidden sm:px-6`,children:S($,{slot:P.conversationStrip,sessionId:c??null})})]}),notices:v===null?null:A(`output`,{"data-testid":`voice-transfer-transition`,className:`border-b border-po-cyan/30 bg-po-cyan/10 px-4 py-2 text-center text-base font-medium text-po-cyan`,children:[`Transferring voice to `,v,`...`]}),content:V||(O?F?S(Ge,{narrow:!I,conversationShown:I&&t&&R===`conversation`,onOpenRail:()=>{ge(!0),Ke(_,`conversation`)},conversation:ne,children:S(O.panel,{...h})},O.id):S(O.panel,{...h}):S(y?_t:m,{})),composer:V?null:O?O.retainComposer===!0&&!F?S(k,{composerContext:j}):null:y?null:S(k,{}),controls:!V&&(!O||O.targetSessionId!==void 0)&&!y&&x===null?S(ie,{}):null,activity:V?null:S(ot,{conversation:F&&I&&t?ne:void 0,conversationBeside:F?D?.asideFace:void 0,conversationLabel:F?O?.label:void 0,scope:O===D&&D?.targetSessionId!==void 0?D.activityScope:void 0,onClose:B,onOpenContent:()=>o(!1)})}}),S(N,{})]})}function rn({isSignedInWorkerOrigin:e=!1,accountSettings:n,homeHosts:r,hostManagement:i=`unavailable`}={}){dt();let{section:a,workspaceId:o}=je(),s=Be(),c=L(q,e=>e.activeId),[l,u]=J(),[d,f]=J(!1),[p,m]=G(`settings/template-target`,`global`),h=i===`available`,g=rt(a,e,{canManageHosts:h}),_=g?.workspace??(a?.startsWith(`repository-`)?`repository`:`general`);return x(()=>{if(g||a===`hosts`&&i===`loading`||_===`repository`&&!d)return;let t=!1;return Ee().then(()=>{if(t||rt(a,e,{canManageHosts:h}))return;let n=V(a);s(n===void 0?{to:`/settings/$section`,params:{section:We},search:{workspace:o},replace:!0}:{to:`/plugins/$pluginId`,params:{pluginId:n},search:{workspace:o},hash:`settings`,replace:!0})}).catch(e=>{t||u(e instanceof Error?e.message:String(e))}),()=>{t=!0}},[g,a,s,_,o,d,i,h,e]),A(`div`,{"data-testid":`settings`,"data-po-region":`content`,className:`flex h-full min-h-0 min-w-0 flex-col overflow-hidden bg-po-bg [--po-backdrop-blur:0px]`,children:[A(`header`,{className:`grid shrink-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-2 gap-y-2 border-b border-po-border px-3 py-2 sm:h-14 sm:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] sm:px-6 sm:py-0`,children:[S(`h1`,{className:`order-1 min-w-0 truncate text-xl font-semibold text-po-hi sm:order-none`,children:`Settings`}),A(`nav`,{className:`order-3 col-span-2 flex w-full items-center gap-1 rounded-lg bg-po-panel p-1 sm:order-none sm:col-span-1 sm:w-auto`,"aria-label":`settings workspace`,children:[S(ve,{asChild:!0,active:_===`general`,className:`min-h-8 flex-1 justify-center rounded-md px-4 focus-visible:ring-2 focus-visible:ring-po-green sm:flex-none`,"aria-current":_===`general`?`true`:void 0,children:S(it,{to:`/settings/$section`,params:{section:We},search:{workspace:o},"data-testid":`settings-workspace-general`,children:`General`})}),S(ve,{asChild:!0,active:_===`repository`,className:`min-h-8 flex-1 justify-center rounded-md px-4 focus-visible:ring-2 focus-visible:ring-po-green sm:flex-none`,"aria-current":_===`repository`?`true`:void 0,children:S(it,{to:`/settings/$section`,params:{section:ue},search:{workspace:o},"data-testid":`settings-workspace-repository`,children:`Workspaces`})})]}),S(t,{asChild:!0,variant:`outline`,size:`sm`,className:`order-2 gap-1.5 sm:order-none sm:justify-self-end`,children:c===null?A(it,{to:`/`,"data-testid":`settings-close`,children:[S(Ne,{"aria-hidden":!0,className:`size-3.5`}),`Back`]}):A(it,{to:`/session/$sessionId`,params:{sessionId:c},"data-testid":`settings-close`,children:[S(Ne,{"aria-hidden":!0,className:`size-3.5`}),S(`span`,{className:`sm:hidden`,children:`Back`}),S(`span`,{className:`hidden sm:inline`,children:`Back to session`})]})})]}),S(`main`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:_===`repository`?S(lt,{current:g??{id:a??``,label:``,detail:``,workspace:`repository`},initialRepositoryId:o,onRepositoryChange:e=>{s({to:`/settings/$section`,params:{section:g?.id??a??ue},search:{workspace:e},replace:!0})},onReady:f},o??`remembered-workspace`):A(`div`,{className:`flex min-h-0 flex-1 flex-col lg:flex-row`,children:[S(Pe,{hosts:r,isSignedInWorkerOrigin:e,canManageHosts:h,active:g?.id,workspace:`general`,repositoryId:o}),S(`section`,{"data-testid":`settings-content`,className:`min-w-0 flex-1 overflow-y-auto px-4 py-6 sm:px-6 sm:py-8 lg:px-8 lg:py-10`,children:A(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-8`,children:[!g&&l?S(`p`,{role:`alert`,children:l}):null,a===`hosts`&&i===`loading`?S(`p`,{role:`status`,children:`Checking host access…`}):null,g?.id===`hosts`?S(De,{}):null,g?.id===`account-preferences`?n??S(`p`,{children:`Account settings are read-only on this host.`}):null,g?.id===`providers`?S(ne,{}):null,g?.id===`devices`?S(ft,{}):null,g?.id===`appearance`?S(Me,{templateTarget:p,onTemplateTargetChange:m}):null,g?.id===`notifications`?S(ke,{}):null,g?.id===`images`?S(qe,{}):null,g?.id===`presets`?S(_e,{}):null,g?.id===`account`?S($e,{}):null,g?.contribution===void 0?null:S(me,{section:g.contribution,scope:`host`}),g?.panel===void 0?null:S(j,{panel:g.panel})]})})]})})]})}var an={thread:(e,t,n)=>S(F,{sessionId:e,threadId:t,options:n}),activity:(e,t)=>S(f,{sessionId:e,onOpenConversation:t}),transcript:(e,t)=>S(r,{sessionId:e,options:t,watch:oe})};function on({isSignedInWorkerOrigin:e=!1,accountSettings:t,homeHosts:n,hostManagement:r}={}){let i=je(),a=L(q,e=>e.activeId);return A(Re,{value:an,children:[i.kind===`settings`?S(rn,{homeHosts:n,isSignedInWorkerOrigin:e,hostManagement:r,accountSettings:t}):S(nn,{homeHosts:n}),S(tt,{}),S(s,{}),S(c,{}),S($,{slot:P.overlay,sessionId:a})]})}function sn(){return A(`div`,{className:`flex size-full`,children:[A(`div`,{className:`flex w-1/4 flex-col gap-1 border-r border-po-border bg-po-rail p-1.5`,children:[S(`span`,{className:`h-1 w-1/2 rounded-full bg-po-dim`}),S(`span`,{className:`mt-1 h-3 w-full rounded-sm bg-po-tint-green`}),S(`span`,{className:`h-1 w-3/4 rounded-full bg-po-faint`}),S(`span`,{className:`h-1 w-2/3 rounded-full bg-po-faint`})]}),A(`div`,{className:`flex flex-1 flex-col justify-between p-2`,children:[A(`div`,{className:`flex flex-col gap-1`,children:[S(`span`,{className:`h-1 w-2/3 rounded-full bg-po-dim`}),S(`span`,{className:`h-1 w-1/2 rounded-full bg-po-faint`}),S(`span`,{className:`h-3 w-3/4 rounded-sm border border-po-border bg-po-panel`})]}),S(`span`,{className:`h-3 w-full rounded-sm border border-po-border bg-po-panel`})]}),A(`div`,{className:`flex w-1/4 flex-col gap-1 border-l border-po-border bg-po-rail p-1.5`,children:[S(`span`,{className:`h-3 w-full rounded-sm border border-po-border bg-po-panel`}),S(`span`,{className:`h-3 w-full rounded-sm border border-po-border bg-po-panel`})]})]})}var cn={label:`Advanced`,description:`The full cockpit with persistent session navigation and an activity dock.`,contractVersion:3,app:on,preview:sn},ln=w(cn),un=w(cn),dn=w(cn),fn=(e,t)=>t===void 0?void 0:{...e,...t},pn=Ze({id:`template-advanced`,packageName:`@agimon-ai/po-template-advanced`,host:{get templates(){return[fn({id:`po-template-advanced`},ln)]}},workspace:{get templates(){return[fn({id:`po-template-advanced`},un)]}},session:{get templates(){return[fn({id:`po-template-advanced`},dn)]}}});export{pn as webPlugin};
1
+ import{$a as e,$r as t,$t as n,A as r,Ar as i,B as a,Bt as o,C as s,D as c,Di as l,Dn as u,Dt as d,E as f,Et as p,F as m,Fn as h,Ft as g,G as _,Gi as v,H as y,Hn as b,Ht as x,It as S,J as C,Ja as w,Jr as T,K as E,Ki as D,Kt as O,L as k,Lt as A,M as j,N as M,O as N,Ot as P,P as F,Pi as I,Pt as L,Q as ee,R as te,Rr as R,S as ne,Si as z,St as re,T as ie,Ti as ae,Tt as oe,Ut as se,Vi as ce,Wi as B,X as V,Xi as H,Y as le,Yi as U,Z as ue,Zi as W,_ as de,_a as fe,_i as pe,_t as G,a as me,ai as he,at as ge,b as _e,bn as ve,bt as ye,c as be,ca as xe,cn as Se,cr as Ce,d as we,dt as Te,et as Ee,f as De,ft as Oe,g as ke,ga as Ae,gt as je,h as Me,ia as K,in as Ne,it as q,j as Pe,ji as Fe,jn as Ie,li as Le,lt as Re,mt as ze,n as Be,na as Ve,ni as He,nn as Ue,nt as We,o as Ge,ot as Ke,p as qe,pn as Je,pt as Ye,q as Xe,qa as Ze,qi as Qe,qt as J,r as $e,ra as Y,rn as et,s as tt,sa as X,sn as nt,st as rt,t as it,ta as Z,ti as at,tn as Q,u as ot,ut as st,v as $,va as ct,w as lt,wn as ut,wt as dt,x as ft,xn as pt,xt as mt,y as ht,ya as gt,z as _t,zt as vt}from"../chunks/po-web-runtime-C0B3uAoC.js";function yt(e){return e.slice(e.lastIndexOf(`/`)+1)||e}function bt({start:e,listDirectory:n,onSelect:r}){let[i,a]=J(e),[o,s]=J(null),[c,l]=J(``);return x(()=>{let e=!1;return n(i).then(t=>{e||(`error`in t?l(t.error):(l(``),s(t)))}),()=>{e=!0}},[i,n]),A(`div`,{"data-testid":`folder-browser`,className:`flex flex-col gap-1 rounded border border-po-border bg-po-deep p-1`,children:[A(`div`,{className:`flex items-center gap-1 px-1`,children:[S(t,{variant:`ghost`,size:`icon`,"data-testid":`folder-browser-up`,title:`parent folder`,"aria-label":`parent folder`,disabled:o?.parent===void 0,onClick:()=>o?.parent!==void 0&&a(o.parent),children:S(Fe,{className:`h-3 w-3`})}),S(`span`,{className:`min-w-0 flex-1 truncate text-sm text-po-dim`,title:o?.path,children:o?.path??`loading…`}),S(t,{variant:`outline`,size:`xs`,"data-testid":`folder-browser-select`,disabled:o===null,onClick:()=>o!==null&&r(o.path),children:`use this folder`})]}),c?S(`p`,{className:`px-2 py-1 text-sm text-po-red`,children:c}):null,A(`div`,{role:`listbox`,"aria-label":`folders`,className:`max-h-40 overflow-y-auto`,children:[o!==null&&o.directories.length===0?S(`p`,{className:`px-2 py-1 text-sm text-po-dim`,children:`no folders here`}):null,o?.directories.map(e=>S(ut,{density:`compact`,"data-testid":`folder-browser-entry`,onClick:()=>a(e),className:`w-full px-2.5 py-1 `,children:yt(e)},e))]})]})}var xt=120,St=-1,Ct=/\/+$/u;function wt(e){let t=e.trim().replace(Ct,``);return t.slice(t.lastIndexOf(`/`)+1)}function Tt({suggestedPaths:e,actions:t}){let n=L(d,e=>e),r=n.path??e[0]??``,[i,a]=J({path:``,directories:[]});return x(()=>{let e=r.trim();if(e===``)return;let n=!1,i=setTimeout(async()=>{let i=await t.searchDirectories(e);n||a({path:r,directories:i.filter(t=>t!==e)})},xt);return()=>{n=!0,clearTimeout(i)}},[r,t]),x(()=>_(r,t.discoverWorkspaces),[r,t.discoverWorkspaces]),S(Et,{suggestions:r.trim()!==``&&i.path===r?i.directories:[],suggestedPaths:e,actions:t,draft:n,updateDraft:Oe})}function Et({suggestedPaths:e,actions:n,draft:r,updateDraft:i,style:a,suggestions:o=[]}){let{name:s,nameEdited:c,instructions:l,pending:u,error:d,discovery:f}=r,p=r.path??e[0]??``,m=e=>i({name:e}),h=e=>i({nameEdited:e}),_=e=>i({path:e}),[y,b]=J(!1),[x,C]=J(St),w=O(null),E=c?s:wt(p),k=e=>{u||(_(e),C(St))},j=e=>{k(`${e}/`),w.current?.focus()},M=p.trim().replace(Ct,``)||(p.trim()===``?``:`/`),N=r.discovering||!!p.trim()&&n.discoverWorkspaces!==void 0&&r.discoveryPath!==p,P=f&&`error`in f?f.error:``,F=f&&`declarations`in f&&f.declarations.length>0?f.declarations:void 0,I=e=>F?.find(t=>t.name===e)?.workspaceId??r.results.find(t=>t.name===e)?.workspaceId,L=F?.filter(e=>r.checked.includes(e.name)&&!I(e.name)).map(e=>e.name)??[],ee=!F&&!N&&!P,te=!u&&!N&&!P&&(F?L.length>0&&n.addDeclaredWorkspaces!==void 0:M!==``||E.trim()!==``),R=async()=>{te&&(F?await n.addDeclaredWorkspaces?.({path:f&&`root`in f?f.root:M,names:L}):await n.addWorkspace({...l===``?{}:{instructions:l},name:E.trim(),...M===``?{}:{path:M}}))};return S(B,{open:!0,onOpenChange:e=>!e&&!u&&n.closeAddWorkspace(),children:A(D,{style:a,width:`md`,"data-testid":`add-workspace-dialog`,"aria-describedby":void 0,children:[S(H,{children:S(W,{children:`Add workspace`})}),A(v,{children:[A(`label`,{htmlFor:`add-workspace-root`,className:`flex flex-col gap-1`,children:[S(`span`,{className:`text-base font-medium text-po-dim`,children:`Folder`}),A(`span`,{className:`flex items-center gap-1.5`,children:[S(Q,{id:`add-workspace-root`,ref:w,"data-testid":`add-workspace-root`,value:p,autoFocus:!0,disabled:u,onChange:e=>k(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`&&o.length>0)e.preventDefault(),C(e=>(e+1)%o.length);else if(e.key===`ArrowUp`&&o.length>0)e.preventDefault(),C(e=>e<=0?o.length-1:e-1);else if(e.key===`Enter`){let e=x===St?void 0:o[x];e===void 0?R():j(e)}},placeholder:`~/workspace/my-project`,className:`min-w-0 flex-1 font-mono`}),S(t,{variant:y?`subtle`:`outline`,size:`md`,"data-testid":`add-workspace-browse`,"aria-pressed":y,disabled:u,onClick:()=>b(e=>!e),children:`Browse`})]})]}),y?S(bt,{...M.startsWith(`/`)?{start:M}:{},listDirectory:n.listDirectory,onSelect:e=>{k(e),b(!1)}}):o.length>0?S(`div`,{role:`listbox`,"aria-label":`matching directories`,"data-testid":`add-workspace-suggestions`,className:`max-h-40 overflow-y-auto rounded border border-po-border bg-po-deep p-1`,children:o.map((e,t)=>S(ut,{density:`compact`,active:t===x,"data-testid":`add-workspace-suggestion`,onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>C(t),onClick:()=>j(e),className:`w-full px-2.5 py-1 `,children:e},e))}):null,e.length>0?S(`div`,{className:`flex flex-wrap gap-1`,children:e.slice(0,4).map(e=>S(t,{variant:`outline`,size:`xs`,disabled:u,onClick:()=>k(e),children:e},e))}):null,N?S(`p`,{role:`status`,className:`text-sm text-po-dim`,children:`Reading workspace declarations…`}):null,P?S(`p`,{role:`alert`,className:`text-sm text-po-red`,children:P}):null,F?A(`fieldset`,{className:`flex min-w-0 flex-col gap-1`,children:[S(`legend`,{className:`mb-1 text-base font-medium text-po-hi`,children:`Workspaces`}),S(`p`,{className:`mb-1 text-sm text-po-dim`,children:`Declared in .po/config.yaml. Choose which to add.`}),F.map((e,t)=>{let n=I(e.name)!==void 0,a=n||r.checked.includes(e.name),o=r.results.find(t=>t.name===e.name)?.error;return S(`div`,{"data-checked":a,className:`rounded-sm px-2 py-1.5 data-[checked=true]:bg-po-tint-green`,children:A(`label`,{htmlFor:`add-workspace-declaration-${t}`,className:`flex min-w-0 cursor-pointer items-start gap-2.5`,children:[S(z,{id:`add-workspace-declaration-${t}`,checked:a,disabled:n||u,onCheckedChange:()=>i({checked:a?r.checked.filter(t=>t!==e.name):[...r.checked,e.name]}),className:`mt-1`}),A(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[S(`span`,{className:`text-base font-semibold text-po-hi`,children:e.name}),S(`span`,{className:`truncate text-sm text-po-dim`,title:e.instructions,children:e.instructions}),o?S(`span`,{role:`alert`,className:`text-sm text-po-red`,children:o}):null]}),n?S(`span`,{className:`text-sm text-po-dim`,children:`Added`}):null]})},e.name)})]}):ee?A(g,{children:[A(`label`,{htmlFor:`add-workspace-name`,className:`flex flex-col gap-1`,children:[S(`span`,{className:`text-base font-medium text-po-dim`,children:`Name`}),S(Q,{id:`add-workspace-name`,"data-testid":`add-workspace-name`,value:E,disabled:u,onChange:e=>{h(!0),m(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&R()},placeholder:`my-project`})]}),A(`label`,{htmlFor:`add-workspace-instructions`,className:`flex flex-col gap-1`,children:[A(`span`,{className:`text-base font-medium text-po-dim`,children:[`Instructions `,S(`span`,{className:`font-normal`,children:`(optional)`})]}),S(T,{id:`add-workspace-instructions`,rows:3,value:l,disabled:u,onChange:e=>i({instructions:e.target.value})}),S(`span`,{className:`text-sm text-po-dim`,children:`For main sessions in this workspace.`})]})]}):null,ee&&M===``&&E.trim()!==``?A(`p`,{"data-testid":`add-workspace-default-hint`,className:`text-sm text-po-dim`,children:[`creates ~/.po/workspace/`,E.trim()]}):null,d?S(`pre`,{className:`max-h-28 overflow-y-auto rounded border border-po-edge-red bg-po-tint-red/40 px-2.5 py-2 text-sm whitespace-pre-wrap text-po-red`,children:d}):null,A(U,{children:[S(t,{variant:`outline`,onClick:()=>n.closeAddWorkspace(),disabled:u,children:`Cancel`}),S(t,{variant:`primary`,"data-testid":`add-workspace-confirm`,onClick:()=>void R(),disabled:!te,children:u?`Adding…`:F?`Add ${L.length} ${L.length===1?`workspace`:`workspaces`}`:`Add workspace`})]})]})]})})}var Dt=`rail/workflow-steps-expanded`,Ot=e=>e.awaitingInput||(e.waitingCount??0)>0;function kt(e){let t=new Set(e.map(({session:e})=>e.id)),n=new Map,r=[];for(let i of e){let e=i.session.parentId;i.session.provenance===`workflow`&&e!==void 0&&t.has(e)?n.set(e,[...n.get(e)??[],i]):r.push(i)}let i=r.sort((e,t)=>(t.session.lastActivityAt??0)-(e.session.lastActivityAt??0)).map(e=>[e,...n.get(e.session.id)??[]]),a=e=>e.some(({session:e})=>Ot(e));return[{key:`needs`,title:`Needs you`,data:i.filter(a).flat()},{key:`recent`,title:`Recent`,data:i.filter(e=>!a(e)).flat()}].filter(e=>e.data.length>0)}function At({sessionId:e,setup:n,actions:r}){let i=JSON.stringify([`rail/setup`,e,n.id]),[a,o,s]=G(`${i}/busy`,!1),[c,l]=G(`${i}/error`,``),u=async()=>{if(s.state)return;o(!0),l(``);let t=await r.removePendingSetup(e,n.id);o(!1),t!==void 0&&l(t.error)};return A(`div`,{"data-testid":`pending-session-${n.id}`,className:`ml-4 rounded-md border border-po-border-soft bg-po-panel p-3`,children:[A(`div`,{className:`flex items-center justify-between gap-2`,children:[S(`span`,{className:`truncate text-base font-semibold text-po-hi`,children:n.name}),A(Z,{children:[S(X,{asChild:!0,children:S(t,{variant:`ghost`,size:`icon`,title:`session setup actions`,disabled:a,"data-testid":`pending-session-menu-${n.id}`,children:S(et,{className:`h-3 w-3`})})}),S(Y,{children:S(K,{variant:`destructive`,onSelect:()=>void u(),children:`remove setup`})})]})]}),S(`p`,{className:n.failed?`text-sm text-po-red`:`text-sm text-po-dim`,children:n.status}),n.recovery?S(`p`,{role:n.failed?`alert`:void 0,className:`text-sm text-po-dim`,children:n.recovery}):null,c?S(`p`,{role:`alert`,className:`text-sm text-po-red`,children:c}):null]})}function jt(e,t,n=[]){return[...new Set([...e.flatMap(e=>e.groups??[]),...n])].map(n=>({name:n,members:e.filter(e=>e.id!==t&&e.groups?.includes(n)===!0).map(e=>e.name||`Untitled`)}))}function Mt(e,t){if(e.length>32)return`group names are at most 32 characters.`;if(t>=8)return`a session can belong to at most 8 groups.`}function Nt({groups:e}){return A(`span`,{"data-testid":`session-groups`,"aria-label":`groups`,className:`flex min-w-0 items-start gap-1.5 text-sm text-po-dim`,children:[S(He,{"aria-hidden":!0,className:`mt-0.5 size-3.5 shrink-0`}),S(`span`,{className:`flex min-w-0 flex-wrap gap-1`,children:e.map(e=>S(Ce,{tone:`magenta`,size:`xs`,className:`font-normal`,children:e},e))})]})}function Pt({options:e,value:n,query:r,active:i,renaming:a,deleting:o,error:s,busy:c=!1,onQueryChange:l,onToggle:u,onCreate:d,onActive:f,onRenameStart:p,onRenameDraft:m,onRenameConfirm:h,onDeleteStart:g,onDeleteConfirm:_,onRowCancel:v,onCancel:y,onSave:b}){let x=se(),C=r.trim(),w=e.filter(e=>e.name.includes(C)),T=C!==``&&!e.some(e=>e.name===C),E=T?Mt(C,n.length):void 0;return A(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),b()},children:[S(Qe,{children:`sessions that share a group can message each other.`}),A(`div`,{className:`flex flex-col overflow-hidden rounded-md border border-po-border focus-within:border-po-edge-green`,children:[A(`div`,{className:`flex flex-wrap items-center gap-1 bg-po-deep px-2 py-1.5`,children:[n.map(e=>A(Ce,{tone:`magenta`,size:`xs`,className:`font-normal`,children:[e,S(`button`,{type:`button`,"aria-label":`remove ${e}`,className:`text-po-magenta`,onClick:()=>u(e),children:S(I,{"aria-hidden":!0,className:`size-2.5`})})]},e)),S(Q,{variant:`bare`,"data-testid":`session-groups-query`,"aria-label":`find or create a group`,autoFocus:!0,placeholder:n.length===0?`find or create a group`:`add another`,value:r,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&C!==``&&(e.preventDefault(),T?E===void 0&&d():w[0]!==void 0&&(u(w[0].name),l(``)))},className:`h-6 min-w-24 flex-1`})]}),A(`div`,{className:`flex flex-col border-t border-po-border-soft p-1`,onMouseLeave:()=>f(void 0),children:[w.map((e,r)=>{let s=n.includes(e.name),l=`${x}-${String(r)}`,d=e.members.length+ +!!s,y=d===1?`its one session`:`all ${String(d)} sessions`;return a?.group===e.name?A(`div`,{className:`flex flex-col gap-1 rounded-sm bg-po-deep px-2 py-1.5`,children:[A(`span`,{className:`flex items-center gap-2`,children:[S(Q,{"aria-label":`rename ${e.name}`,value:a.draft,autoFocus:!0,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),h())},className:`h-7 flex-1`}),S(t,{type:`button`,variant:`ghost`,size:`sm`,onClick:v,children:`cancel`}),S(t,{type:`button`,variant:`outline`,size:`sm`,disabled:c||a.draft.trim()===``,onClick:h,children:`rename`})]}),A(`span`,{className:`text-sm text-po-dim`,children:[`renames it on `,y,`.`]})]},e.name):o===e.name?A(`div`,{className:`flex items-center gap-2 rounded-sm border border-po-red/40 px-2 py-1.5`,children:[A(`span`,{className:`flex-1 text-sm text-po-text`,children:[`remove `,S(`span`,{className:`font-semibold text-po-hi`,children:e.name}),` from `,y,`? they can no longer message through it.`]}),S(t,{type:`button`,variant:`ghost`,size:`sm`,onClick:v,children:`cancel`}),S(t,{type:`button`,variant:`danger`,size:`sm`,disabled:c,onClick:_,children:`delete`})]},e.name):A(`div`,{"data-testid":`session-group-${e.name}`,onMouseEnter:()=>f(e.name),className:`group flex items-start gap-2.5 rounded-sm px-2 py-1.5 ${s?`bg-po-tint-green`:i===e.name?`bg-po-deep`:``}`,children:[A(`label`,{htmlFor:l,className:`flex min-w-0 flex-1 cursor-pointer items-start gap-2.5`,children:[S(z,{id:l,checked:s,onCheckedChange:()=>u(e.name),className:`mt-1`}),A(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[S(`span`,{className:`text-base ${s?`font-semibold text-po-hi`:`text-po-text`}`,children:e.name}),S(`span`,{className:`truncate text-sm text-po-dim`,title:e.members.join(`, `),children:e.members.length===0?`no other sessions yet`:e.members.join(`, `)})]})]}),A(`span`,{className:`flex shrink-0 items-center gap-0.5 ${i===e.name?`opacity-100`:`opacity-0 group-focus-within:opacity-100`}`,children:[S(t,{type:`button`,variant:`ghost`,size:`icon`,title:`rename ${e.name}`,onClick:()=>p(e.name),children:S(xe,{"aria-hidden":!0,className:`size-3.5`})}),S(t,{type:`button`,variant:`ghost`,size:`icon`,title:`delete ${e.name}`,onClick:()=>g(e.name),children:S(at,{"aria-hidden":!0,className:`size-3.5`})})]})]},e.name)}),T?A(`button`,{type:`button`,"data-testid":`session-groups-create`,disabled:E!==void 0,onClick:d,className:`flex flex-col gap-0.5 rounded-sm px-2 py-1.5 text-left ${E===void 0?`bg-po-deep`:``}`,children:[A(`span`,{className:`flex items-center gap-2.5 text-base ${E===void 0?`text-po-magenta`:`text-po-faint`}`,children:[S(Ie,{"aria-hidden":!0,className:`size-3.5`}),A(`span`,{className:`truncate`,children:[`create group “`,C,`”`]})]}),E===void 0?null:S(`span`,{className:`pl-6 text-sm text-po-red`,children:E})]}):null]})]}),A(`span`,{className:`text-sm text-po-dim`,children:[n.length,` of `,8,` groups`]}),s===void 0?null:S(`span`,{"data-testid":`session-groups-error`,className:`text-sm text-po-red`,children:s}),A(U,{children:[S(t,{type:`button`,variant:`outline`,size:`md`,onClick:y,children:`cancel`}),S(t,{type:`submit`,variant:`primary`,size:`md`,disabled:c,children:`save`})]})]})}function Ft({session:e,sessions:t,actions:n,onClose:r}){let[i,a]=J(()=>[...e.groups??[]]),[o,s]=J(``),[c,l]=J(),[u,d]=J(),[f,p]=J(),[m,h]=J(),[g,_]=J(!1),y=async(e,t)=>{_(!0),h(void 0);let n=await e();_(!1),n===void 0?t():h(n.error)},b=()=>{d(void 0),p(void 0)};return S(B,{open:!0,onOpenChange:e=>!e&&!g&&r(),children:A(D,{width:`sm`,"data-testid":`session-groups-dialog-${e.id}`,"aria-describedby":void 0,children:[S(H,{children:S(W,{children:`session groups`})}),S(v,{children:S(Pt,{options:jt(t,e.id,i),value:i,query:o,active:c,renaming:u,deleting:f,error:m,busy:g,onQueryChange:s,onToggle:e=>{h(void 0),i.includes(e)?a(i.filter(t=>t!==e)):i.length>=8?h(Mt(``,i.length)):a([...i,e])},onCreate:()=>{let e=o.trim();e!==``&&Mt(e,i.length)===void 0&&(a([...i,e]),s(``))},onActive:l,onRenameStart:e=>{p(void 0),d({group:e,draft:e})},onRenameDraft:e=>d(t=>t===void 0?t:{...t,draft:e}),onRenameConfirm:()=>{if(u===void 0)return;let e=u.draft.trim();e===``||e===u.group?b():y(()=>n.renameGroup(u.group,e),()=>{a(t=>[...new Set(t.map(t=>t===u.group?e:t))]),b()})},onDeleteStart:e=>{d(void 0),p(e)},onDeleteConfirm:()=>{f!==void 0&&y(()=>n.deleteGroup(f),()=>{a(e=>e.filter(e=>e!==f)),b()})},onRowCancel:b,onCancel:r,onSave:()=>void y(()=>n.setSessionGroups(e.id,i),r)})})]})})}function It(e=[],t=[]){return e.length===t.length&&e.every((e,n)=>e===t[n])}function Lt(e){return e.filter(e=>e.groups!==void 0&&e.groups.length>0)}function Rt(e,t){if(e.session!==t.session||e.actions!==t.actions||e.workspaceName!==t.workspaceName||e.coordinates!==t.coordinates||e.coordinatorEligible!==t.coordinatorEligible||e.coordinator!==t.coordinator||e.readOnly!==t.readOnly||e.stepsExpanded!==t.stepsExpanded||e.onToggleSteps!==t.onToggleSteps)return!1;let n=Lt(e.sessions),r=Lt(t.sessions);return n.length===r.length&&n.every((e,t)=>{let n=r[t];return e.id===n.id&&e.name===n.name&&It(e.groups,n.groups)})}function zt({session:e,className:t}){let n=e.waitingCount??+!!e.awaitingInput;return n<=0?null:A(g,{children:[S(pt,{ask:!0,"aria-hidden":!0,"data-testid":`session-awaiting-input`,className:t,children:n}),A(`span`,{className:`sr-only`,children:[`, `,n,` waiting for you`]})]})}var Bt=vt(function({session:e,sessions:n,actions:r,workspaceName:i,coordinates:a,coordinatorEligible:o=!1,coordinator:s,readOnly:c=!1,stepsExpanded:d,onToggleSteps:f}){let p=`rail/session/${e.id}`,[m,_]=G(`${p}/mode`,`view`),[y,x]=G(`${p}/draft`,``),[C,w]=G(`${p}/error`,``),[T,E]=G(`${p}/role-error`,``),[,k,j]=G(`${p}/removing`,!1),M=O(m),N=e=>{M.current=e,_(e)},{active:P}=e,F=C||T||e.error,I=async t=>{N(`view`),E(``);let n=await r.setSessionRole?.(e.id,t);n!==void 0&&E(n.error)},L=r.setSessionRole===void 0||!o||e.coordinatorEligible!==!0||a===void 0?null:e.coordinator?S(K,{"data-testid":`session-make-regular-${e.id}`,disabled:e.restartBlocked===!0,onSelect:()=>void I(!1),children:`Make regular session`}):S(K,{"data-testid":`session-make-coordinator-${e.id}`,disabled:e.restartBlocked===!0,onSelect:()=>s===void 0?void I(!0):N(`promote`),children:`Make coordinator`}),ee=P?`rounded-lg border border-po-edge-green bg-po-tint-green px-3 py-3 hover:bg-po-tint-green`:`rounded-lg border border-transparent px-3 py-3 hover:bg-po-panel`,te=()=>{r.renameSession(e.id,y),N(`view`)},ne=async()=>{if(j.state)return;k(!0),N(`view`),w(``);let t=await r.removeSession(e.id);k(!1),t!==void 0&&w(t.error)},z=e.status.startsWith(`failed`)||e.status.includes(` failed`),re=e.status.startsWith(`running`),ie=A(`span`,{className:`flex min-w-0 items-start gap-1.5 text-sm leading-snug ${z?`text-po-red`:re?`text-po-yellow`:P?`text-po-text`:`text-po-dim`}`,children:[re?S(Se,{"aria-hidden":!0,className:`mt-0.5 size-3 shrink-0 animate-spin`}):z?S(Ve,{"aria-hidden":!0,className:`mt-0.5 size-3 shrink-0`}):null,e.clock?S(nt,{"data-testid":`session-status`,className:P?`line-clamp-2`:`truncate`,label:e.clock.label,since:e.clock.since}):S(`span`,{"data-testid":`session-status`,className:P?`line-clamp-2`:`truncate`,children:e.status})]}),oe=A(`span`,{className:`flex min-w-0 items-start gap-2`,children:[e.nested&&e.provenance===`workflow-session`?S(ce,{"aria-label":`workflow session`,className:`mt-1 size-3 shrink-0 ${P?`text-po-green`:`text-po-faint`}`}):e.provenance===`workflow`?S(he,{"aria-label":`workflow step`,className:`mt-1 size-3 shrink-0 ${P?`text-po-green`:`text-po-faint`}`}):e.nested&&e.provenance?S(fe,{"aria-label":e.provenance===`worktree`?`automatic per-conversation worktree`:e.provenance,className:`mt-1 size-3 shrink-0 ${P?`text-po-green`:`text-po-faint`}`}):null,S(`span`,{className:`min-w-0 flex-1 text-base font-semibold break-words text-po-hi`,children:e.name||`Untitled`}),(e.waitingCount??+!!e.awaitingInput)>0?S(zt,{session:e,className:`mt-0.5 shrink-0 transition-opacity group-focus-within:opacity-0 group-hover:opacity-0`}):e.ordinal>=1&&e.ordinal<=9?S(`span`,{title:`press ${String(e.ordinal)} to focus`,className:`grid size-5 shrink-0 place-items-center rounded-full bg-po-panel text-2xs text-po-dim transition-opacity group-focus-within:opacity-0 group-hover:opacity-0`,children:e.ordinal}):null]}),se=A(g,{children:[oe,A(`span`,{className:`flex w-full min-w-0 items-end gap-2`,children:[A(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[ie,e.coordinator?A(`span`,{"data-testid":`session-coordinator`,className:`text-sm text-po-dim`,children:[`Coordinates `,a??`workspace`]}):null,i?A(`span`,{"data-testid":`session-workspace`,className:`flex min-w-0 items-center gap-1.5 text-sm text-po-dim`,children:[S(Ae,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),S(`span`,{className:`truncate`,children:i})]}):null,e.git?A(`span`,{"data-testid":`session-branch`,className:`flex min-w-0 items-center gap-1.5 text-sm text-po-dim`,children:[S(R,{className:`size-3.5 shrink-0 ${P?`text-po-green`:``}`}),S(`span`,{className:`truncate font-mono`,children:e.git.branch}),e.git.dirty?S(`span`,{className:`shrink-0 text-po-yellow`,children:`modified`}):null]}):null]}),e.profile?A(u,{"data-testid":`session-avatar`,"aria-label":e.profile.label,title:e.profile.label,className:`size-8 shrink-0 rounded-full`,children:[e.profile.avatarUrl?S(b,{src:e.profile.avatarUrl,alt:``}):null,S(h,{className:`bg-po-tint-green text-xs font-semibold text-po-green`,children:e.profile.initials})]}):null]}),e.groups!==void 0&&e.groups.length>0?S(Nt,{groups:e.groups}):null,F?S(`span`,{"data-testid":`session-error`,className:`line-clamp-3 text-sm break-words text-po-red`,children:F}):null]}),V=m===`menu`;return A(g,{children:[A(`div`,{className:Le(`group relative`,e.provenance===`workflow`?`pl-10`:(e.nested||d!==void 0)&&`pl-5`),"data-testid":`session-card-${e.id}`,"data-active":P,"data-nested":e.nested,children:[d===void 0?null:S(`button`,{type:`button`,"data-testid":`session-steps-${e.id}`,"aria-expanded":d,"aria-label":`${d?`Hide`:`Show`} steps of ${e.name||`this workflow`}`,onClick:()=>f?.(e.id),className:`absolute top-3.5 left-0 grid size-5 place-items-center rounded-sm text-po-faint outline-none hover:text-po-hi focus-visible:ring-2 focus-visible:ring-po-green/50`,children:S(d?ae:l,{"aria-hidden":!0,className:`size-3.5`})}),S(t,{variant:`ghost`,size:`card`,"data-testid":`session-open-${e.id}`,onClick:()=>r.openSession(e.id),className:ee,children:se}),!c&&(m===`view`||V)?S(`div`,{className:`absolute top-2 right-2 transition-opacity ${V?`opacity-100`:`opacity-0 group-focus-within:opacity-100 group-hover:opacity-100`}`,children:A(Z,{open:V,onOpenChange:e=>{let t=M.current;N(e?`menu`:t===`menu`?`view`:t)},children:[S(X,{asChild:!0,children:S(t,{variant:`ghost`,size:`icon`,"data-testid":`session-menu-${e.id}`,title:`session actions`,className:P?`text-po-dim hover:bg-po-tint-green hover:text-po-hi data-[state=open]:bg-po-tint-green data-[state=open]:text-po-hi`:`text-po-faint hover:bg-po-deep hover:text-po-hi data-[state=open]:bg-po-deep data-[state=open]:text-po-hi`,children:S(et,{className:`h-3 w-3`})})}),A(Y,{"data-testid":`session-menu-list-${e.id}`,onCloseAutoFocus:e=>{M.current!==`view`&&e.preventDefault()},children:[r.renderSessionMenuItems(e.id),e.canInteract===!1?null:A(g,{children:[L,S(K,{"data-testid":`session-rename-${e.id}`,onSelect:()=>{x(e.name),N(`rename`)},children:`Rename`}),S(K,{"data-testid":`session-groups-${e.id}`,onSelect:()=>N(`groups`),children:`Groups`}),S(K,{"data-testid":`session-resume-${e.id}`,onSelect:()=>r.resumeSession(e.id),children:`Resume`}),r.openMoveSession&&e.move?S(K,{"data-testid":`session-move-${e.id}`,disabled:e.restarting||e.move.blocked,onSelect:()=>r.openMoveSession(e.id),children:`Move to workspace…`}):null,S(K,{"data-testid":`session-restart-${e.id}`,disabled:e.restarting||e.restartBlocked===!0,onSelect:()=>r.restartSession(e.id),children:`Restart`}),S(K,{variant:`destructive`,"data-testid":`session-stop-${e.id}`,onSelect:()=>N(`confirm`),children:`Remove`})]})]})]})}):null,S(B,{open:e.canInteract!==!1&&m===`rename`,onOpenChange:e=>!e&&N(`view`),children:A(D,{width:`sm`,"data-testid":`session-rename-dialog-${e.id}`,"aria-describedby":void 0,children:[S(H,{children:S(W,{children:`rename session`})}),S(v,{children:A(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),te()},children:[S(Q,{"data-testid":`session-name-input-${e.id}`,"aria-label":`session name`,value:y,autoFocus:!0,onChange:e=>x(e.target.value)}),A(U,{children:[S(t,{type:`button`,variant:`outline`,size:`md`,"data-testid":`session-rename-cancel-${e.id}`,onClick:()=>N(`view`),children:`cancel`}),S(t,{type:`submit`,variant:`primary`,size:`md`,"data-testid":`session-rename-confirm-${e.id}`,disabled:y.trim()===``,children:`rename`})]})]})})]})}),e.canInteract!==!1&&m===`groups`?S(Ft,{session:e,sessions:n,actions:r,onClose:()=>N(`view`)}):null,S(B,{open:e.canInteract!==!1&&m===`confirm`,onOpenChange:e=>!e&&N(`view`),children:A(D,{width:`sm`,"data-testid":`session-stop-dialog-${e.id}`,"aria-describedby":void 0,children:[S(H,{children:S(W,{children:`remove session`})}),A(v,{children:[A(Qe,{children:[`this stops `,S(`span`,{className:`font-semibold text-po-hi`,children:e.name||`untitled`}),` and removes it from the rail. anything it is running ends now. you can restore it for 7 days.`]}),A(U,{children:[S(t,{variant:`outline`,size:`md`,"data-testid":`session-stop-cancel-${e.id}`,autoFocus:!0,onClick:()=>N(`view`),children:`cancel`}),S(t,{variant:`danger`,size:`md`,"data-testid":`session-stop-confirm-${e.id}`,onClick:()=>void ne(),children:`remove`})]})]})]})}),S(B,{open:e.canInteract!==!1&&m===`promote`,onOpenChange:e=>!e&&N(`view`),children:A(D,{width:`sm`,"data-testid":`session-promote-dialog-${e.id}`,"aria-describedby":void 0,children:[S(H,{children:A(W,{children:[`Make `,e.name||`Untitled`,` the coordinator of `,a,`?`]})}),A(v,{children:[A(Qe,{children:[S(`span`,{className:`font-semibold text-po-hi`,children:e.name||`Untitled`}),` will see every session in`,` `,a,`, message them, and start new ones.`,` `,S(`span`,{className:`font-semibold text-po-hi`,children:s}),` becomes a regular session. Both restart to take on their new roles, so anything they are running stops now.`]}),A(U,{children:[S(t,{variant:`outline`,size:`md`,"data-testid":`session-promote-cancel-${e.id}`,autoFocus:!0,onClick:()=>N(`view`),children:`Cancel`}),S(t,{variant:`primary`,size:`md`,"data-testid":`session-promote-confirm-${e.id}`,onClick:()=>void I(!0),children:`Make coordinator`})]})]})]})})]}),e.pendingSetups.map(t=>S(At,{sessionId:e.id,setup:t,actions:r},`setup:${t.id}`))]})},Rt);function Vt({workspace:n,sessions:r,actions:i,quiet:a=!1,readOnly:s=!1}){let c=`rail/workspace/${n.id}`,[l,u]=G(`${c}/open`,!1),[d,f]=G(`${c}/error`,``),[p,m,h]=G(`${c}/removing`,!1),[_,y]=G(`${c}/coordinator-error`,``),[b,x]=G(Dt,[]),C=o(e=>x(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),[x]),{id:w,name:T,root:E,available:O,legacy:k}=n,j=n.sessions.find(e=>e.coordinator),M=e(n.sessions,new Set(b)),N=e=>M.withSteps.has(e)?{stepsExpanded:b.includes(e),onToggleSteps:C}:{},P=async()=>{y(``);let e=await i.addCoordinator?.(w);e!==void 0&&y(e.error)};if(n.kind===`session`)return n.sessions.length===0?null:S(`div`,{"data-testid":`session-group-${w}`,className:`flex flex-col gap-1`,children:M.sessions.map(e=>S(Bt,{session:e,sessions:r,actions:i,readOnly:s,coordinates:`Home`,coordinatorEligible:e.coordinatorEligible===!0,coordinator:j?.id===e.id?void 0:j?.name,...N(e.id)},e.id))});let F=async()=>{if(h.state)return;m(!0),f(``);let e=await i.deleteWorkspace(w);m(!1),e===void 0?u(!1):f(e.error)};return A(`section`,{"data-testid":`workspace-group-${w}`,"data-available":O,className:`flex flex-col gap-1.5`,children:[A(`div`,{className:`flex min-w-0 items-start gap-2.5 rounded-md px-2 py-1 transition-colors hover:bg-po-panel/60`,children:[a?null:S(Ae,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-po-dim`}),A(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[!k&&i.openWorkspace?S(`button`,{type:`button`,"data-testid":`workspace-open-${w}`,onClick:()=>i.openWorkspace?.(w),className:`truncate rounded-sm text-left text-base text-po-hi outline-none focus-visible:ring-2 focus-visible:ring-po-green/50 ${a?`font-medium`:`font-semibold`}`,title:a?E:`Open ${T} workspace`,children:T}):S(`p`,{className:`truncate text-base text-po-hi ${a?`font-medium`:`font-semibold`}`,title:a?E:void 0,children:T}),a?null:S(`p`,{className:`truncate font-mono text-sm text-po-dim`,title:E,children:E})]}),k||s?null:A(g,{children:[S(t,{variant:`ghost`,size:`icon`,"data-testid":`workspace-new-session-${w}`,title:`New session`,"aria-label":`New session in ${T}`,disabled:!O,onClick:()=>i.createSession(w),className:`text-po-faint hover:text-po-hi`,children:S(Ie,{className:`size-3.5`})}),A(Z,{children:[S(X,{asChild:!0,children:S(t,{variant:`ghost`,size:`icon`,"data-testid":`workspace-menu-${w}`,title:`Workspace actions`,"aria-label":`${T} actions`,className:`text-po-faint hover:text-po-hi`,children:S(et,{className:`size-3.5`})})}),A(Y,{children:[S(K,{disabled:!O,onSelect:()=>i.resumeInWorkspace(w),children:`Resume Session`}),i.addCoordinator?S(K,{"data-testid":`workspace-add-coordinator-${w}`,disabled:!O,onSelect:()=>void P(),children:`Add bot`}):null,S(K,{disabled:!O,onSelect:()=>i.openWorkspaceSettings(w),children:`Workspace Settings`}),S(K,{variant:`destructive`,"data-testid":`workspace-delete-${w}`,onSelect:()=>{f(``),u(!0)},children:`Delete Workspace`})]})]})]})]}),O?null:S(`p`,{className:`px-9 text-sm text-po-red`,children:`Workspace unavailable`}),_?S(`p`,{"data-testid":`workspace-coordinator-error-${w}`,className:`px-9 text-sm text-po-red`,children:_}):null,n.sessions.length>0?S(`div`,{className:`flex flex-col gap-1`,children:M.sessions.map(e=>S(Bt,{session:e,sessions:r,actions:i,readOnly:s,coordinates:T,coordinatorEligible:e.coordinatorEligible===!0,coordinator:j?.id===e.id?void 0:j?.name,...N(e.id)},e.id))}):null,S(B,{open:l,onOpenChange:e=>!e&&!p&&u(!1),children:A(D,{width:`sm`,"data-testid":`workspace-delete-dialog-${w}`,"aria-describedby":void 0,children:[S(H,{children:S(W,{children:`delete workspace`})}),A(v,{children:[A(Qe,{children:[`this removes `,S(`span`,{className:`font-semibold text-po-hi`,children:T}),` and all its sessions from Po. running work will stop. files at `,S(`code`,{children:E}),` stay on disk.`]}),d?S(`p`,{"data-testid":`workspace-delete-error-${w}`,className:`text-sm text-po-red`,children:d}):null,A(U,{children:[S(t,{variant:`outline`,size:`md`,"data-testid":`workspace-delete-cancel-${w}`,disabled:p,autoFocus:!0,onClick:()=>u(!1),children:`cancel`}),S(t,{variant:`danger`,size:`md`,"data-testid":`workspace-delete-confirm-${w}`,disabled:p,onClick:()=>void F(),children:p?`deleting…`:`delete`})]})]})]})})]})}var Ht=`po.session-view`,Ut=`self-host`,Wt=`po.other-workspaces-open`,Gt=[{value:`workspaces`,title:`Workspaces`,description:`Sessions grouped by workspace`,Icon:Ae},{value:`sessions`,title:`Sessions`,description:`Needs you first, then latest change`,Icon:Je}];function Kt(e){try{return window.localStorage.getItem(e)}catch{return null}}function qt(e,t){try{window.localStorage.setItem(e,t)}catch{}}function Jt(){return typeof window<`u`&&window.poDesktop?.cloud!==void 0}function Yt(){return typeof window<`u`&&window.poDesktop?.platform===Ut}function Xt(){window.history.pushState(null,``,`/cloud`),window.dispatchEvent(new PopStateEvent(`popstate`))}var Zt=e=>e.kind!==`session`&&e.sessions.length===0;function Qt({rail:e,onClose:r,selfHost:i=Yt(),cloud:a=Jt()&&!i}){let{actions:o}=e;return A(`div`,{className:`flex min-h-full flex-col`,children:[A(`div`,{"data-po-session-rail-header":!0,className:`flex min-h-16 items-center justify-between gap-2 px-5 py-3`,children:[A(`span`,{className:`flex items-center gap-2.5`,"aria-label":`Po`,children:[S(`img`,{src:`/favicon.svg`,alt:``,"aria-hidden":`true`,className:`size-9 rounded-lg`}),S(`span`,{"aria-hidden":`true`,className:`text-2xl font-semibold text-po-hi`,children:`Po`})]}),A(`span`,{className:`flex items-center gap-1`,children:[S(`div`,{"data-rail-status":`advanced-action`,className:`contents`,children:S($,{slot:P.railStatus,sessionId:null})}),S(t,{variant:`ghost`,size:`icon`,"data-testid":`mobile-sessions-close`,title:`Hide sessions`,"aria-label":`Hide sessions`,onClick:r,className:`text-po-dim md:hidden`,children:S(I,{className:`size-3.5`})})]})]}),S(`div`,{className:`px-3 pt-4`,children:A(t,{variant:`ghost`,size:`lg`,"data-testid":`home-open`,"aria-current":e.homeActive?`page`:void 0,onClick:o.openHome,className:e.homeActive?`w-full justify-start gap-2.5 border border-po-edge-green bg-po-tint-green px-2 text-po-hi`:`w-full justify-start gap-2.5 border border-transparent px-2 text-po-text`,children:[S(n,{"aria-hidden":`true`,className:e.homeActive?`size-5 text-po-green`:`size-5 text-po-dim`}),`Home`]})}),e.pluginContent,S($t,{rail:e}),S(`div`,{className:`flex-1`}),A(`div`,{className:`sticky bottom-0 mt-auto shrink-0 bg-po-rail`,children:[S(`div`,{"data-rail-status":`advanced-banner`,className:`contents`,children:S($,{slot:P.railStatus,sessionId:null})}),A(`div`,{className:`flex flex-col gap-1 border-t border-po-border-soft px-3 py-3`,children:[A(t,{variant:`ghost`,size:`lg`,"data-testid":`settings-open`,onClick:o.openSettings,className:`justify-start gap-2.5 px-2 text-po-text`,children:[S(ct,{className:`size-5 text-po-dim`}),`Settings`]}),a?A(t,{variant:`ghost`,size:`lg`,"data-testid":`cloud-open`,onClick:Xt,className:`justify-start gap-2.5 px-2 text-po-text`,children:[S(gt,{className:`size-5 text-po-dim`}),`Po Cloud`]}):null,A(`span`,{className:`px-2 text-sm text-po-dim max-sm:hidden`,children:[S(Ue,{className:`bg-po-panel`,children:`ctrl+k`}),` commands · `,S(Ue,{className:`bg-po-panel`,children:`ctrl+t`}),` new session`]})]})]})]})}function $t({rail:n,createMenuDefaultOpen:r=!1}){let{actions:a}=n,s=n.coordinatorHosts??[],[c,u]=G(`rail/coordinator-error`,``),d=async e=>{u(``);let t=await a.addCoordinator?.(void 0,e);t!==void 0&&u(t.error)},f=n.workspaces.flatMap(e=>e.sessions),[p,m]=G(Dt,[]),h=o(e=>m(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),[m]),_=e(f,new Set(p)),v=new Set(_.sessions.map(e=>e.id)),y=n.workspaces.every(e=>e.kind===`session`&&e.sessions.length===0),b=n.workspaces.filter(Zt),C=O(null),[w,T]=G(`rail/initial-selection-revealed`,!1),[E,D]=G(`rail/session-view`,()=>Kt(Ht)===`sessions`?`sessions`:`workspaces`),[k,j]=G(`rail/other-workspaces-open`,()=>Kt(Wt)===`true`),M=Gt.find(e=>e.value===E)??Gt[0];return x(()=>{if(w)return;let e=C.current?.querySelector(`[data-active="true"]`);e&&(e.scrollIntoView({block:`center`,inline:`nearest`,behavior:`instant`}),T(!0))},[n.workspaces,w,T]),A(g,{children:[A(`div`,{className:`flex items-center justify-between px-5 pt-4 pb-2`,children:[S(`h2`,{className:`text-lg font-semibold text-po-hi`,children:`Sessions`}),A(`span`,{className:`flex items-center gap-1`,children:[A(Z,{children:[S(X,{asChild:!0,children:S(t,{variant:`ghost`,size:`icon`,"data-testid":`session-view-menu`,title:`View: ${M.title}`,"aria-label":`View: ${M.title}`,className:`text-po-dim hover:text-po-hi`,children:S(i,{className:`size-3.5`})})}),S(Y,{align:`end`,"aria-label":`View`,children:Gt.map(({value:e,title:t,description:n,Icon:r})=>A(K,{"data-testid":`session-view-${e}`,"aria-checked":E===e,role:`menuitemradio`,onSelect:()=>{D(e),qt(Ht,e)},className:`items-start gap-2.5 ${E===e?`bg-po-tint-green`:``}`,children:[S(r,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 ${E===e?`text-po-green`:`text-po-dim`}`}),A(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[S(`span`,{className:`text-po-hi`,children:t}),S(`span`,{className:`text-sm text-po-dim`,children:n})]}),E===e?S(pe,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-po-green`}):null]},e))})]}),A(Z,{defaultOpen:r,children:[S(X,{asChild:!0,children:S(t,{variant:`ghost`,size:`icon`,"data-testid":`session-create-menu`,title:`Create workspace, session or bot`,"aria-label":`Create workspace, session or bot`,className:`text-po-dim hover:text-po-hi`,children:S(Ie,{className:`size-3.5`})})}),A(Y,{children:[S(K,{"data-testid":`add-workspace-open`,onSelect:a.openAddWorkspace,children:`Create workspace`}),a.createGeneralSession?S(K,{"data-testid":`new-session-open`,onSelect:a.createGeneralSession,children:`Create session`}):null,a.addCoordinator?s.map(e=>S(K,{"data-testid":e.hostId?`coordinator-create-${e.hostId}`:`coordinator-create`,onSelect:()=>void d(e.hostId),children:s.length>1?`Create bot on ${e.label}`:`Create bot`},e.hostId??`local`)):null]})]})]})]}),c?S(`p`,{"data-testid":`coordinator-create-error`,className:`px-5 text-sm text-po-red`,children:c}):null,A(`div`,{ref:C,className:`flex flex-col gap-4 px-3 pb-3`,children:[E===`sessions`?kt(n.workspaces.flatMap(e=>e.sessions.filter(e=>v.has(e.id)).map(t=>({session:t,workspaceName:e.kind===`session`?void 0:e.name,coordinates:e.kind===`session`?`Home`:e.name,coordinatorEligible:t.coordinatorEligible===!0,coordinator:e.sessions.find(e=>e.coordinator&&e.id!==t.id)?.name})))).map(e=>A(`section`,{"data-testid":`session-timeline-${e.key}`,className:`flex flex-col gap-1`,children:[S(`h3`,{className:`px-2 text-xs font-semibold tracking-wide text-po-dim uppercase`,children:e.title}),e.data.map(({session:e,workspaceName:t,coordinates:n,coordinatorEligible:r,coordinator:i})=>S(Bt,{session:e,sessions:f,actions:a,workspaceName:t,coordinates:n,coordinatorEligible:r,coordinator:i,..._.withSteps.has(e.id)?{stepsExpanded:p.includes(e.id),onToggleSteps:h}:{}},e.id))]},e.key)):n.workspaces.filter(e=>!Zt(e)).map(e=>S(Vt,{workspace:e,sessions:f,actions:a},e.id)),E===`workspaces`&&b.length>0?A(`section`,{"data-testid":`other-workspaces`,className:`flex flex-col gap-1`,children:[A(`button`,{type:`button`,"data-testid":`other-workspaces-toggle`,"aria-expanded":k,"aria-label":`Other workspaces, ${String(b.length)} without sessions`,onClick:()=>{j(!k),qt(Wt,String(!k))},className:`flex items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors outline-none hover:bg-po-panel/60 focus-visible:ring-2 focus-visible:ring-po-green/50`,children:[S(k?ae:l,{"aria-hidden":!0,className:`size-4 shrink-0 text-po-dim`}),S(`span`,{className:`flex-1 text-base font-semibold text-po-hi`,children:`Other workspaces`}),S(`span`,{className:`min-w-5.5 rounded-full bg-po-panel px-1.5 text-center text-xs text-po-dim`,children:b.length})]}),k?S(`div`,{className:`flex flex-col gap-0.5 pl-4`,children:b.map(e=>S(Vt,{workspace:e,sessions:f,actions:a,quiet:!0},e.id))}):null]}):null,y||E===`sessions`&&f.length===0?S(`p`,{className:`px-2 text-sm text-po-dim`,children:`Start a session to work with Po. No workspace needed.`}):null]})]})}function en({view:e,slots:n,rail:r,navigationOpen:i,desktopActivityOpen:a,mobileActivityOpen:o,onNavigationOpenChange:s,onDesktopActivityOpenChange:c,onMobileActivityOpenChange:l}){let{scrollRef:u}=r,d=e===`conversation`||e===`welcome`,f=o?a?`fixed inset-y-0 right-0 z-40 flex lg:static lg:z-auto`:`fixed inset-y-0 right-0 z-40 flex lg:hidden`:a?`hidden lg:flex`:`hidden`;return A(`div`,{className:`relative flex h-full min-w-0 overflow-hidden [--po-backdrop-blur:0px]`,children:[S(`aside`,{ref:u,"data-testid":`session-rail-panel`,"data-po-region":`rail`,className:`fixed inset-y-0 left-0 z-40 flex w-[min(320px,calc(100vw-48px))] shrink-0 flex-col overflow-y-auto border-r border-po-border-soft bg-po-rail transition-transform md:visible md:static md:z-auto md:w-[320px] md:translate-x-0 ${i?`visible translate-x-0`:`invisible -translate-x-full`}`,children:S(Qt,{rail:r,onClose:()=>s(!1)})}),i?S(t,{variant:`ghost`,"data-testid":`mobile-drawer-backdrop`,"aria-label":`Hide sessions`,className:`fixed inset-0 z-30 h-auto w-auto rounded-none bg-black/55 p-0 hover:bg-black/55 md:hidden`,onClick:()=>s(!1)}):null,A(`main`,{"data-po-region":`content`,className:`flex min-w-0 flex-1 flex-col overflow-hidden`,children:[n.notices,n.header({navigationToggle:`mobile`,activityToggle:`mobile`}),A(`div`,{"data-testid":`template-content`,className:d?`mx-auto flex min-h-0 w-full max-w-[960px] flex-1 flex-col overflow-hidden px-2 sm:px-4`:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[n.content,n.composer,n.controls]})]}),n.activity==null?null:a||o?S(`div`,{"data-po-region":`activity`,className:f,children:n.activity}):S(t,{variant:`ghost`,"data-testid":`activity-show`,title:`Show activity`,onClick:()=>c(!0),className:`hidden h-auto shrink-0 rounded-none border-l border-po-border-soft bg-po-rail px-2 py-3 font-semibold text-po-dim hover:bg-po-panel hover:text-po-hi lg:flex`,style:{writingMode:`vertical-rl`},children:`Activity`}),o?S(t,{variant:`ghost`,"data-testid":`mobile-activity-backdrop`,"aria-label":`Hide activity`,className:`fixed inset-0 z-30 h-auto w-auto rounded-none bg-black/55 p-0 hover:bg-black/55 lg:hidden`,onClick:()=>l(!1)}):null,r.addWorkspace?S(Tt,{suggestedPaths:r.addWorkspace.suggestedPaths,actions:r.actions}):null]})}function tn({onDismiss:e,...t}){return S(en,{...t,rail:y({onDismiss:e})})}function nn({homeHosts:e}){dt();let t=L(Te,e=>e.dockOpen),[n,r]=J(!1),[i,o]=J(!1),{kind:s,sessionId:c,tabId:l,pageId:u,pluginId:d,workspaceId:f}=je(),h=re(c??null),_=L(q,e=>e.activeId),v=L(q,e=>e.transferringToId===null?null:e.byId[e.transferringToId]?.summary.name??`destination session`),y=mt(),b=ze(),x=b?.summary.dormant===!0?b:null,w=Ye(e=>e.dialog?.id??null),T=L(st,e=>Xe(e,c,l)),D=T===void 0?void 0:ee(c??null).map(e=>e.transientTab?.()).find(e=>e?.id===T.id)??T,O=(l===void 0?void 0:p(c??null).find(e=>e.id===l))??D,j=O===D?D?.composerContext:void 0,F=O!==void 0&&O===D&&D.retainComposer===!0&&D.composerAside===!0,I=ye(`(min-width: 1024px)`),R=L(Te,e=>E(e,_)),ne=F&&O!==void 0?S(be,{label:O.label,composer:S(k,{quiet:!0,composerContext:j})}):null,z=`${s}\u0000${c??``}\u0000${l??``}\u0000${u??``}\u0000${f??``}`,[ae,oe]=J(z);ae!==z&&(oe(z),r(!1),o(!1));let[se,ce]=J(w);se!==w&&(ce(w),w!==null&&(o(!1),r(!1)));let B=()=>{i?o(!1):ge(!1)},V=u===void 0?s===`workspace`&&f!==void 0?S(a,{workspaceId:f,onShowSessions:()=>r(!0)}):s===`home`&&!y?S(we,{hosts:e,onShowSessions:()=>r(!0)}):null:A(de,{pageId:u,sessionId:null,workspaceId:f,onShowSessions:()=>r(!0),children:[u===C?S(ht,{workspaceId:f,pluginId:d}):null,u===le?S(M,{}):null]});return A(`div`,{"data-testid":`cockpit`,className:`h-full min-w-0 overflow-hidden`,children:[S(tn,{view:V||O?`panel`:y?`welcome`:`conversation`,navigationOpen:n,desktopActivityOpen:t,mobileActivityOpen:i,onNavigationOpenChange:r,onDesktopActivityOpenChange:ge,onMobileActivityOpenChange:o,onDismiss:()=>r(!1),slots:{header:e=>V?null:A(g,{children:[S(te,{...e,view:O?.id??`conversation`,onShowSessions:()=>{o(!1),r(!0)},onShowActivity:()=>{r(!1),o(!0)}}),S(`div`,{className:`shrink-0 px-3 pt-2 empty:hidden sm:px-6`,children:S($,{slot:P.conversationStrip,sessionId:c??null})})]}),notices:v===null?null:A(`output`,{"data-testid":`voice-transfer-transition`,className:`border-b border-po-cyan/30 bg-po-cyan/10 px-4 py-2 text-center text-base font-medium text-po-cyan`,children:[`Transferring voice to `,v,`...`]}),content:V||(O?F?S(Ge,{narrow:!I,conversationShown:I&&t&&R===`conversation`,onOpenRail:()=>{ge(!0),Ke(_,`conversation`)},conversation:ne,children:S(O.panel,{...h})},O.id):S(O.panel,{...h}):S(y?_t:m,{})),composer:V?null:O?O.retainComposer===!0&&!F?S(k,{composerContext:j}):null:y?null:S(k,{}),controls:!V&&(!O||O.targetSessionId!==void 0)&&!y&&x===null?S(ie,{}):null,activity:V?null:S(ot,{conversation:F&&I&&t?ne:void 0,conversationBeside:F?D?.asideFace:void 0,conversationLabel:F?O?.label:void 0,scope:O===D&&D?.targetSessionId!==void 0?D.activityScope:void 0,onClose:B,onOpenContent:()=>o(!1)})}}),S(N,{})]})}function rn({isSignedInWorkerOrigin:e=!1,accountSettings:n,homeHosts:r,hostManagement:i=`unavailable`}={}){dt();let{section:a,workspaceId:o}=je(),s=Be(),c=L(q,e=>e.activeId),[l,u]=J(),[d,f]=J(!1),[p,m]=G(`settings/template-target`,`global`),h=i===`available`,g=rt(a,e,{canManageHosts:h}),_=g?.workspace??(a?.startsWith(`repository-`)?`repository`:`general`);return x(()=>{if(g||a===`hosts`&&i===`loading`||_===`repository`&&!d)return;let t=!1;return Ee().then(()=>{if(t||rt(a,e,{canManageHosts:h}))return;let n=V(a);s(n===void 0?{to:`/settings/$section`,params:{section:We},search:{workspace:o},replace:!0}:{to:`/plugins/$pluginId`,params:{pluginId:n},search:{workspace:o},hash:`settings`,replace:!0})}).catch(e=>{t||u(e instanceof Error?e.message:String(e))}),()=>{t=!0}},[g,a,s,_,o,d,i,h,e]),A(`div`,{"data-testid":`settings`,"data-po-region":`content`,className:`flex h-full min-h-0 min-w-0 flex-col overflow-hidden bg-po-bg [--po-backdrop-blur:0px]`,children:[A(`header`,{className:`grid shrink-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-2 gap-y-2 border-b border-po-border px-3 py-2 sm:h-14 sm:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] sm:px-6 sm:py-0`,children:[S(`h1`,{className:`order-1 min-w-0 truncate text-xl font-semibold text-po-hi sm:order-none`,children:`Settings`}),A(`nav`,{className:`order-3 col-span-2 flex w-full items-center gap-1 rounded-lg bg-po-panel p-1 sm:order-none sm:col-span-1 sm:w-auto`,"aria-label":`settings workspace`,children:[S(ve,{asChild:!0,active:_===`general`,className:`min-h-8 flex-1 justify-center rounded-md px-4 focus-visible:ring-2 focus-visible:ring-po-green sm:flex-none`,"aria-current":_===`general`?`true`:void 0,children:S(it,{to:`/settings/$section`,params:{section:We},search:{workspace:o},"data-testid":`settings-workspace-general`,children:`General`})}),S(ve,{asChild:!0,active:_===`repository`,className:`min-h-8 flex-1 justify-center rounded-md px-4 focus-visible:ring-2 focus-visible:ring-po-green sm:flex-none`,"aria-current":_===`repository`?`true`:void 0,children:S(it,{to:`/settings/$section`,params:{section:ue},search:{workspace:o},"data-testid":`settings-workspace-repository`,children:`Workspaces`})})]}),S(t,{asChild:!0,variant:`outline`,size:`sm`,className:`order-2 gap-1.5 sm:order-none sm:justify-self-end`,children:c===null?A(it,{to:`/`,"data-testid":`settings-close`,children:[S(Ne,{"aria-hidden":!0,className:`size-3.5`}),`Back`]}):A(it,{to:`/session/$sessionId`,params:{sessionId:c},"data-testid":`settings-close`,children:[S(Ne,{"aria-hidden":!0,className:`size-3.5`}),S(`span`,{className:`sm:hidden`,children:`Back`}),S(`span`,{className:`hidden sm:inline`,children:`Back to session`})]})})]}),S(`main`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:_===`repository`?S(lt,{current:g??{id:a??``,label:``,detail:``,workspace:`repository`},initialRepositoryId:o,onRepositoryChange:e=>{s({to:`/settings/$section`,params:{section:g?.id??a??ue},search:{workspace:e},replace:!0})},onReady:f},o??`remembered-workspace`):A(`div`,{className:`flex min-h-0 flex-1 flex-col lg:flex-row`,children:[S(Pe,{hosts:r,isSignedInWorkerOrigin:e,canManageHosts:h,active:g?.id,workspace:`general`,repositoryId:o}),S(`section`,{"data-testid":`settings-content`,className:`min-w-0 flex-1 overflow-y-auto px-4 py-6 sm:px-6 sm:py-8 lg:px-8 lg:py-10`,children:A(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-8`,children:[!g&&l?S(`p`,{role:`alert`,children:l}):null,a===`hosts`&&i===`loading`?S(`p`,{role:`status`,children:`Checking host access…`}):null,g?.id===`hosts`?S(De,{}):null,g?.id===`account-preferences`?n??S(`p`,{children:`Account settings are read-only on this host.`}):null,g?.id===`providers`?S(ne,{}):null,g?.id===`devices`?S(ft,{}):null,g?.id===`appearance`?S(Me,{templateTarget:p,onTemplateTargetChange:m}):null,g?.id===`notifications`?S(ke,{}):null,g?.id===`images`?S(qe,{}):null,g?.id===`presets`?S(_e,{}):null,g?.id===`account`?S($e,{}):null,g?.contribution===void 0?null:S(me,{section:g.contribution,scope:`host`}),g?.panel===void 0?null:S(j,{panel:g.panel})]})})]})})]})}var an={thread:(e,t,n)=>S(F,{sessionId:e,threadId:t,options:n}),activity:(e,t)=>S(f,{sessionId:e,onOpenConversation:t}),transcript:(e,t)=>S(r,{sessionId:e,options:t,watch:oe})};function on({isSignedInWorkerOrigin:e=!1,accountSettings:t,homeHosts:n,hostManagement:r}={}){let i=je(),a=L(q,e=>e.activeId);return A(Re,{value:an,children:[i.kind===`settings`?S(rn,{homeHosts:n,isSignedInWorkerOrigin:e,hostManagement:r,accountSettings:t}):S(nn,{homeHosts:n}),S(tt,{}),S(s,{}),S(c,{}),S($,{slot:P.overlay,sessionId:a})]})}function sn(){return A(`div`,{className:`flex size-full`,children:[A(`div`,{className:`flex w-1/4 flex-col gap-1 border-r border-po-border bg-po-rail p-1.5`,children:[S(`span`,{className:`h-1 w-1/2 rounded-full bg-po-dim`}),S(`span`,{className:`mt-1 h-3 w-full rounded-sm bg-po-tint-green`}),S(`span`,{className:`h-1 w-3/4 rounded-full bg-po-faint`}),S(`span`,{className:`h-1 w-2/3 rounded-full bg-po-faint`})]}),A(`div`,{className:`flex flex-1 flex-col justify-between p-2`,children:[A(`div`,{className:`flex flex-col gap-1`,children:[S(`span`,{className:`h-1 w-2/3 rounded-full bg-po-dim`}),S(`span`,{className:`h-1 w-1/2 rounded-full bg-po-faint`}),S(`span`,{className:`h-3 w-3/4 rounded-sm border border-po-border bg-po-panel`})]}),S(`span`,{className:`h-3 w-full rounded-sm border border-po-border bg-po-panel`})]}),A(`div`,{className:`flex w-1/4 flex-col gap-1 border-l border-po-border bg-po-rail p-1.5`,children:[S(`span`,{className:`h-3 w-full rounded-sm border border-po-border bg-po-panel`}),S(`span`,{className:`h-3 w-full rounded-sm border border-po-border bg-po-panel`})]})]})}var cn={label:`Advanced`,description:`The full cockpit with persistent session navigation and an activity dock.`,contractVersion:3,app:on,preview:sn},ln=w(cn),un=w(cn),dn=w(cn),fn=(e,t)=>t===void 0?void 0:{...e,...t},pn=Ze({id:`template-advanced`,packageName:`@agimon-ai/po-template-advanced`,host:{get templates(){return[fn({id:`po-template-advanced`},ln)]}},workspace:{get templates(){return[fn({id:`po-template-advanced`},un)]}},session:{get templates(){return[fn({id:`po-template-advanced`},dn)]}}});export{pn as webPlugin};