@ensocode/server 0.3.15-beta.244 → 0.3.15-beta.245

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 (166) hide show
  1. package/out/phone/assets/{EditDiff-Dl1v7xzD.js → EditDiff-LjLnu8xm.js} +1 -1
  2. package/out/phone/assets/{ReadFileView-DnbZC0ty.js → ReadFileView-D_aDFZ3i.js} +1 -1
  3. package/out/phone/assets/{abnfDiagram-VCTEODGH-Co7grfeK.js → abnfDiagram-VCTEODGH-BH4d-cbL.js} +1 -1
  4. package/out/phone/assets/architecture-7GRP2DOG-CzvFNlBu.js +1 -0
  5. package/out/phone/assets/{architectureDiagram-5GKGNRK7-63szDTwV.js → architectureDiagram-5GKGNRK7-CZUm8whq.js} +1 -1
  6. package/out/phone/assets/{blockDiagram-I7D4REHJ-DiqufW2M.js → blockDiagram-I7D4REHJ-CibsN4eX.js} +1 -1
  7. package/out/phone/assets/{c4Diagram-7LVT6UL2-DEkuGuT5.js → c4Diagram-7LVT6UL2-4Q1GvDNL.js} +1 -1
  8. package/out/phone/assets/channel-B1OjjanR.js +1 -0
  9. package/out/phone/assets/{chunk-4HAMMTFA-BBPCzb9_.js → chunk-4HAMMTFA-qmi-wrXZ.js} +1 -1
  10. package/out/phone/assets/{chunk-75Z2AOVW-CvsXKk5y.js → chunk-75Z2AOVW-BuwyNEKi.js} +1 -1
  11. package/out/phone/assets/{chunk-DU6HZSFF-DFN-6z2K.js → chunk-DU6HZSFF-BU48Ba4y.js} +1 -1
  12. package/out/phone/assets/{chunk-F27PBJKO-CxbPevJY.js → chunk-F27PBJKO-BmRqQ1LD.js} +1 -1
  13. package/out/phone/assets/{chunk-GMAD6QVW-BKkB3y89.js → chunk-GMAD6QVW-2xpTjCMU.js} +1 -1
  14. package/out/phone/assets/{chunk-GVQU2GXP-BmuuVTk9.js → chunk-GVQU2GXP-DcgAJ1hb.js} +1 -1
  15. package/out/phone/assets/{chunk-IMKFNOWR-DtyReyu7.js → chunk-IMKFNOWR-CDKQTDLE.js} +1 -1
  16. package/out/phone/assets/{chunk-L3NEJ4N5-CYQouxRc.js → chunk-L3NEJ4N5-C9I8xbyo.js} +1 -1
  17. package/out/phone/assets/{chunk-OSK3NFVY-C8s892Xu.js → chunk-OSK3NFVY-B68u1et1.js} +1 -1
  18. package/out/phone/assets/{chunk-P2QGCYS3-Wo7i2bF8.js → chunk-P2QGCYS3-3LE80g6a.js} +1 -1
  19. package/out/phone/assets/{chunk-POPQ4Y6H-Cs3x8DIB.js → chunk-POPQ4Y6H-DYC-7n06.js} +1 -1
  20. package/out/phone/assets/{chunk-PWAF6VOD-JEGLXjtH.js → chunk-PWAF6VOD--cFXgKVZ.js} +1 -1
  21. package/out/phone/assets/{chunk-SHT3W25Y-DtlDK80W.js → chunk-SHT3W25Y-BBi9f7KR.js} +1 -1
  22. package/out/phone/assets/{chunk-SVP7TREG-DCDTtBi2.js → chunk-SVP7TREG-B1DVeaeC.js} +1 -1
  23. package/out/phone/assets/{chunk-TICWLB2K-DH_cShpv.js → chunk-TICWLB2K-DGL1KENT.js} +1 -1
  24. package/out/phone/assets/classDiagram-ZZMXUADV-DIqrjRkT.js +1 -0
  25. package/out/phone/assets/classDiagram-v2-VYDZK3BY-DIqrjRkT.js +1 -0
  26. package/out/phone/assets/{codeHighlighter-oIs6aBXZ.js → codeHighlighter-Dv9S_gnx.js} +1 -1
  27. package/out/phone/assets/{cynefin-OW5HDTMX-DWY8sMmw.js → cynefin-OW5HDTMX-DvPig7gg.js} +1 -1
  28. package/out/phone/assets/{cynefinDiagram-5FMLGOSQ-DystTHhc.js → cynefinDiagram-5FMLGOSQ-CZScsP4a.js} +1 -1
  29. package/out/phone/assets/{dagre-GXQ25YYZ-CjIk5Pm7.js → dagre-GXQ25YYZ-Rm1WuHFV.js} +1 -1
  30. package/out/phone/assets/{diagram-S7CK7UJ4-CY0PD39z.js → diagram-S7CK7UJ4-DNecQbFS.js} +1 -1
  31. package/out/phone/assets/{diagram-UQ7AKVKN-CwX9S12n.js → diagram-UQ7AKVKN-DNJ5891_.js} +1 -1
  32. package/out/phone/assets/{diagram-VSXAHHWV-Bk_rb32-.js → diagram-VSXAHHWV-hgX1MmPB.js} +1 -1
  33. package/out/phone/assets/{diagram-VX7I27RA-C3JVMUBL.js → diagram-VX7I27RA-BINDbSM_.js} +1 -1
  34. package/out/phone/assets/{diagram-Z3DM3KII-Drf5stHv.js → diagram-Z3DM3KII-BznaX7I6.js} +1 -1
  35. package/out/phone/assets/{ebnfDiagram-PWID7BFC-Cz19FBqO.js → ebnfDiagram-PWID7BFC-35AZ2YXG.js} +1 -1
  36. package/out/phone/assets/{erDiagram-RLTQ6QDP-BXmpqk2p.js → erDiagram-RLTQ6QDP-Cchr8eGN.js} +1 -1
  37. package/out/phone/assets/eventmodeling-NTZA5JFV-Rdm0dM4t.js +1 -0
  38. package/out/phone/assets/flowDiagram-HODETNUW-qD44MaaR.js +1 -0
  39. package/out/phone/assets/{ganttDiagram-EL5Y4UJY-Bum0_E5J.js → ganttDiagram-EL5Y4UJY-D5_HL1Hs.js} +1 -1
  40. package/out/phone/assets/{gitGraph-4MIJSDKK-BCw9r0Vf.js → gitGraph-4MIJSDKK-CWlj41of.js} +1 -1
  41. package/out/phone/assets/{gitGraphDiagram-WWUBYQGX-BrS3oYOR.js → gitGraphDiagram-WWUBYQGX-B1Z4kUI3.js} +1 -1
  42. package/out/phone/assets/{info-A6RAGUB7-CdAqHFpo.js → info-A6RAGUB7-BsUYEjC5.js} +1 -1
  43. package/out/phone/assets/{infoDiagram-27XIBGKW-eIHi-wVl.js → infoDiagram-27XIBGKW-lrQnoW76.js} +1 -1
  44. package/out/phone/assets/{ishikawaDiagram-5VMMS53U--ZByOgbd.js → ishikawaDiagram-5VMMS53U-BBmwYGjK.js} +1 -1
  45. package/out/phone/assets/{journeyDiagram-3NMN7TZE-Cez_oRvQ.js → journeyDiagram-3NMN7TZE-DNkmhKoE.js} +1 -1
  46. package/out/phone/assets/{kanban-definition-UXKFOSKX-CzRnvsUw.js → kanban-definition-UXKFOSKX-CN7mnAup.js} +1 -1
  47. package/out/phone/assets/{line-BI6dRkfB.js → line-B8a5usVN.js} +1 -1
  48. package/out/phone/assets/{main-Bb-GRoqY.js → main-Drpa9hsc.js} +4 -4
  49. package/out/phone/assets/{mermaid-parser.core-hbmkLOwJ.js → mermaid-parser.core-PgYmkOU6.js} +3 -3
  50. package/out/phone/assets/{mermaid.core-DyabQfxY.js → mermaid.core-DbT50CUC.js} +4 -4
  51. package/out/phone/assets/{mindmap-definition-YA3MSWOX-BsrANfeL.js → mindmap-definition-YA3MSWOX-CMdUpbu5.js} +1 -1
  52. package/out/phone/assets/{packet-AYTQ26CC-C10GNvQY.js → packet-AYTQ26CC-DE5zcURD.js} +1 -1
  53. package/out/phone/assets/{pegDiagram-XKGWAZYB-BJZdvuYe.js → pegDiagram-XKGWAZYB-CAHbWi6O.js} +1 -1
  54. package/out/phone/assets/{pie-WAS4IAKB-BO4lKzBO.js → pie-WAS4IAKB-CeuBFJWN.js} +1 -1
  55. package/out/phone/assets/{pieDiagram-E7YTZNPT-CebvsUnG.js → pieDiagram-E7YTZNPT-EsoDg3k_.js} +1 -1
  56. package/out/phone/assets/{quadrantDiagram-AXDQQJYC-DAIoWitA.js → quadrantDiagram-AXDQQJYC-BjX3KPnW.js} +1 -1
  57. package/out/phone/assets/{radar-RG4KPBEZ-BSvMj116.js → radar-RG4KPBEZ-jlg2WilL.js} +1 -1
  58. package/out/phone/assets/{railroad-74A4TZTK-CC8n5mQv.js → railroad-74A4TZTK-BhL0maDf.js} +1 -1
  59. package/out/phone/assets/railroad-abnf-HS5TGJTU-CG8Dvjf0.js +1 -0
  60. package/out/phone/assets/railroad-ebnf-LZEXJU2U-BmdoUAXy.js +1 -0
  61. package/out/phone/assets/railroad-peg-WCYAUIDC-BPjXhfuj.js +1 -0
  62. package/out/phone/assets/{railroadDiagram-O6MQD6OU-BzydbcBb.js → railroadDiagram-O6MQD6OU-CJUntIWK.js} +1 -1
  63. package/out/phone/assets/{requirementDiagram-BXWQKSXE-CKe0Zr83.js → requirementDiagram-BXWQKSXE-CUYcJ7Ct.js} +1 -1
  64. package/out/phone/assets/{sankeyDiagram-P5KCCOFB-CJworGIH.js → sankeyDiagram-P5KCCOFB-B7yjnRpp.js} +1 -1
  65. package/out/phone/assets/{sequenceDiagram-WJ2MYXX4-DdpCJT7e.js → sequenceDiagram-WJ2MYXX4-CI73HGux.js} +1 -1
  66. package/out/phone/assets/{stateDiagram-D77RDMKH-D-IrCDnR.js → stateDiagram-D77RDMKH-BF_1QkEi.js} +1 -1
  67. package/out/phone/assets/stateDiagram-v2-MP3YSRHH-CgcJvB8p.js +1 -0
  68. package/out/phone/assets/{swimlanes-42K2YHIH-Cy0iyaFc.js → swimlanes-42K2YHIH-Bwq7r81u.js} +1 -1
  69. package/out/phone/assets/swimlanesDiagram-VR7AAH4N-3afyqKQ7.js +8 -0
  70. package/out/phone/assets/{timeline-definition-24CTP7MA-DmctHGEI.js → timeline-definition-24CTP7MA-Drxbs-AR.js} +1 -1
  71. package/out/phone/assets/{treeView-Q6P3EWNA-DJ3NLlKQ.js → treeView-Q6P3EWNA-DuBbC28F.js} +1 -1
  72. package/out/phone/assets/{treemap-WGGIJYW6-Wu9CYVkP.js → treemap-WGGIJYW6-BfQDwuyr.js} +1 -1
  73. package/out/phone/assets/{vennDiagram-4TSXK5OY-C9U0vhBw.js → vennDiagram-4TSXK5OY-D2oNPJPu.js} +1 -1
  74. package/out/phone/assets/{wardley-WFR3VGLG-Bux_FNX8.js → wardley-WFR3VGLG-BCgggqb2.js} +1 -1
  75. package/out/phone/assets/{wardleyDiagram-VM6X3IG4-YeXD-Py0.js → wardleyDiagram-VM6X3IG4-C1BpdV7C.js} +1 -1
  76. package/out/phone/assets/{xychartDiagram-S5SC5T6Z-6G4BJgCo.js → xychartDiagram-S5SC5T6Z-DHZBXtsf.js} +1 -1
  77. package/out/phone/desk.html +1 -1
  78. package/out/phone/index.html +2 -2
  79. package/out/phone/sw.js +1 -1
  80. package/out/renderer/assets/{EditDiff-Dq1ru-27.js → EditDiff-1q8ZinKY.js} +1 -1
  81. package/out/renderer/assets/{ReadFileView-DRDsV4Qh.js → ReadFileView-B24dkbc8.js} +1 -1
  82. package/out/renderer/assets/{SidePanel-BzHQWaD_.js → SidePanel-HvFay_uK.js} +1 -1
  83. package/out/renderer/assets/{abnfDiagram-VCTEODGH-BvoAbCWQ.js → abnfDiagram-VCTEODGH-C28b6KaR.js} +1 -1
  84. package/out/renderer/assets/{arc-CJC8vTfi.js → arc-D654WPOQ.js} +1 -1
  85. package/out/renderer/assets/{architectureDiagram-5GKGNRK7-DUaKoTV1.js → architectureDiagram-5GKGNRK7-in73oE1l.js} +1 -1
  86. package/out/renderer/assets/{blockDiagram-I7D4REHJ-Ctrde6gr.js → blockDiagram-I7D4REHJ-D3Uz_3X8.js} +1 -1
  87. package/out/renderer/assets/{c4Diagram-7LVT6UL2-m237al85.js → c4Diagram-7LVT6UL2-BFnUhWBv.js} +1 -1
  88. package/out/renderer/assets/channel-Dtd4BQ0v.js +1 -0
  89. package/out/renderer/assets/{chunk-2Q5K7J3B-DxInKfng.js → chunk-2Q5K7J3B-BRnCXB5O.js} +1 -1
  90. package/out/renderer/assets/{chunk-5VM5RSS4-DYWVp5wB.js → chunk-5VM5RSS4-Bzdf1vbV.js} +1 -1
  91. package/out/renderer/assets/{chunk-F27PBJKO-B4co86fQ.js → chunk-F27PBJKO-TNiuEksf.js} +1 -1
  92. package/out/renderer/assets/{chunk-IMKFNOWR-BhBcruMO.js → chunk-IMKFNOWR-CibX_GX4.js} +1 -1
  93. package/out/renderer/assets/{chunk-JWPE2WC7-C_OTocS8.js → chunk-JWPE2WC7-Cvj3V5D8.js} +1 -1
  94. package/out/renderer/assets/{chunk-POPQ4Y6H-DuPM2iNq.js → chunk-POPQ4Y6H-DD8kMK_f.js} +1 -1
  95. package/out/renderer/assets/{chunk-SVP7TREG-BBAC9v6R.js → chunk-SVP7TREG-Cr44V1VF.js} +1 -1
  96. package/out/renderer/assets/{chunk-TICWLB2K-N6m7s6mw.js → chunk-TICWLB2K-BJZ6A5Jw.js} +1 -1
  97. package/out/renderer/assets/{chunk-XXDRQBXY-B1Gr5MJz.js → chunk-XXDRQBXY-wAi8ZQ9I.js} +1 -1
  98. package/out/renderer/assets/classDiagram-ZZMXUADV-B2CoHNXJ.js +1 -0
  99. package/out/renderer/assets/classDiagram-v2-VYDZK3BY-B2CoHNXJ.js +1 -0
  100. package/out/renderer/assets/{cose-bilkent-JH36ORCC-BGacAdLc.js → cose-bilkent-JH36ORCC-vqLyUO2H.js} +1 -1
  101. package/out/renderer/assets/{cynefin-OW5HDTMX-CstxFU_f.js → cynefin-OW5HDTMX-utxTipjM.js} +1 -1
  102. package/out/renderer/assets/{cynefinDiagram-5FMLGOSQ-B2A_z92b.js → cynefinDiagram-5FMLGOSQ-tmHpgrII.js} +1 -1
  103. package/out/renderer/assets/{dagre-GXQ25YYZ-B2Cuq6s4.js → dagre-GXQ25YYZ-DHvmbJzP.js} +1 -1
  104. package/out/renderer/assets/{diagram-S7CK7UJ4-sPp6xmTo.js → diagram-S7CK7UJ4-CxkJYeKg.js} +1 -1
  105. package/out/renderer/assets/{diagram-UQ7AKVKN-C1nSgHxc.js → diagram-UQ7AKVKN-DXiV9Phb.js} +1 -1
  106. package/out/renderer/assets/{diagram-VSXAHHWV-DyrFmlyo.js → diagram-VSXAHHWV-Bqowd_xF.js} +1 -1
  107. package/out/renderer/assets/{diagram-VX7I27RA-C1YDNDgn.js → diagram-VX7I27RA-BFJEhjwB.js} +1 -1
  108. package/out/renderer/assets/{diagram-Z3DM3KII-vDjTMVCb.js → diagram-Z3DM3KII-B8M6zQkH.js} +1 -1
  109. package/out/renderer/assets/{ebnfDiagram-PWID7BFC-go5p9rJU.js → ebnfDiagram-PWID7BFC-AWO_Tu8S.js} +1 -1
  110. package/out/renderer/assets/{erDiagram-RLTQ6QDP--7HBypuL.js → erDiagram-RLTQ6QDP-CFT_O4xb.js} +1 -1
  111. package/out/renderer/assets/{flowDiagram-HODETNUW-BhISSZBS.js → flowDiagram-HODETNUW-aVBgaS_Y.js} +1 -1
  112. package/out/renderer/assets/{ganttDiagram-EL5Y4UJY-BcBSKfXJ.js → ganttDiagram-EL5Y4UJY-Cm5xhQPI.js} +1 -1
  113. package/out/renderer/assets/{gitGraphDiagram-WWUBYQGX-CKps0oQ_.js → gitGraphDiagram-WWUBYQGX-Ypn2Cmdp.js} +1 -1
  114. package/out/renderer/assets/{index-DOMKWUhA.js → index-C_-_8kzt.js} +6 -6
  115. package/out/renderer/assets/{infoDiagram-27XIBGKW-Cuwh5obU.js → infoDiagram-27XIBGKW-C7fB8bNU.js} +1 -1
  116. package/out/renderer/assets/{ishikawaDiagram-5VMMS53U-BLMUHtbz.js → ishikawaDiagram-5VMMS53U-CcWTHcnO.js} +1 -1
  117. package/out/renderer/assets/{journeyDiagram-3NMN7TZE-CdyKTe8S.js → journeyDiagram-3NMN7TZE-xqTIZ2Hh.js} +1 -1
  118. package/out/renderer/assets/{kanban-definition-UXKFOSKX-CLmlyeai.js → kanban-definition-UXKFOSKX-BOT23Tck.js} +1 -1
  119. package/out/renderer/assets/{layout-Blff8S_S.js → layout-CjcdzPZ2.js} +1 -1
  120. package/out/renderer/assets/{linear-E24BfEe_.js → linear-h8_X4_Uj.js} +1 -1
  121. package/out/renderer/assets/{mermaid.core-tBzIgBPK.js → mermaid.core-CSXvmdq9.js} +5 -5
  122. package/out/renderer/assets/{mindmap-definition-YA3MSWOX-Ctunlg4e.js → mindmap-definition-YA3MSWOX-C_1TjiTd.js} +1 -1
  123. package/out/renderer/assets/{pegDiagram-XKGWAZYB-BGUDmJ0t.js → pegDiagram-XKGWAZYB-BzuEKB_Y.js} +1 -1
  124. package/out/renderer/assets/{pieDiagram-E7YTZNPT-BV3SKGcw.js → pieDiagram-E7YTZNPT-DjKNMc5Y.js} +1 -1
  125. package/out/renderer/assets/{quadrantDiagram-AXDQQJYC-Cto7yY8W.js → quadrantDiagram-AXDQQJYC-C20n16ud.js} +1 -1
  126. package/out/renderer/assets/{railroadDiagram-O6MQD6OU--eLvppDh.js → railroadDiagram-O6MQD6OU-nL2WEzvu.js} +1 -1
  127. package/out/renderer/assets/{requirementDiagram-BXWQKSXE-Dom34Gkz.js → requirementDiagram-BXWQKSXE-CjSoTsFt.js} +1 -1
  128. package/out/renderer/assets/{sankeyDiagram-P5KCCOFB-CN11JSQo.js → sankeyDiagram-P5KCCOFB-Cf75s3NX.js} +1 -1
  129. package/out/renderer/assets/{sequenceDiagram-WJ2MYXX4-9uQUwoRg.js → sequenceDiagram-WJ2MYXX4-F5oCjnNZ.js} +1 -1
  130. package/out/renderer/assets/{sessionChanges-DLMjbWOi.js → sessionChanges-9mvBQ4nC.js} +1 -1
  131. package/out/renderer/assets/{sizeCapture-INFHLROL-C1rIYWoA.js → sizeCapture-INFHLROL-xvtssqwL.js} +1 -1
  132. package/out/renderer/assets/{stateDiagram-D77RDMKH-M3C0QecZ.js → stateDiagram-D77RDMKH-WIM9GNDw.js} +1 -1
  133. package/out/renderer/assets/stateDiagram-v2-MP3YSRHH-C4trPT9p.js +1 -0
  134. package/out/renderer/assets/{swimlanes-42K2YHIH-DnLqJear.js → swimlanes-42K2YHIH-Cx1Lq7uL.js} +1 -1
  135. package/out/renderer/assets/swimlanesDiagram-VR7AAH4N-CdzbCDJL.js +8 -0
  136. package/out/renderer/assets/{timeline-definition-24CTP7MA-DJcjXRdy.js → timeline-definition-24CTP7MA-DAenmhFb.js} +1 -1
  137. package/out/renderer/assets/{vennDiagram-4TSXK5OY-B7cvho9j.js → vennDiagram-4TSXK5OY-C20f02ii.js} +1 -1
  138. package/out/renderer/assets/{wardleyDiagram-VM6X3IG4-BE0YuPQP.js → wardleyDiagram-VM6X3IG4-BKts4ozC.js} +1 -1
  139. package/out/renderer/assets/{xychartDiagram-S5SC5T6Z-D6oIwCDT.js → xychartDiagram-S5SC5T6Z-Bega92Q5.js} +1 -1
  140. package/out/renderer/index.html +1 -1
  141. package/out/server/agent.js +4 -4
  142. package/out/server/chunks/{builtinOccupancy-DvzfBkum.js → builtinOccupancy-8qzMLEUu.js} +3 -3
  143. package/out/server/chunks/{dispatchModel-0Gu9nhKa.js → dispatchModel-ztJp_gru.js} +2 -2
  144. package/out/server/chunks/{loadProvider-CDXRBHj8.js → loadProvider-6Q-YAwjb.js} +2 -2
  145. package/out/server/chunks/{menuSkills-C0v0R3gX.js → menuSkills-BPjdWW4F.js} +3 -3
  146. package/out/server/chunks/{projectCode-CxP4jjhK.js → projectCode-D1meiWQp.js} +2 -2
  147. package/out/server/chunks/{web-Dw5EcbGj.js → web-2773VU9n.js} +2 -2
  148. package/out/server/chunks/{workflowPresets-CI-duJC2.js → workflowPresets-CPtxxd8V.js} +2 -2
  149. package/out/server/index.js +6 -6
  150. package/package.json +1 -1
  151. package/out/phone/assets/architecture-7GRP2DOG-CPQkhXxx.js +0 -1
  152. package/out/phone/assets/channel-CTU5U1Gc.js +0 -1
  153. package/out/phone/assets/classDiagram-ZZMXUADV-CAp7xfKw.js +0 -1
  154. package/out/phone/assets/classDiagram-v2-VYDZK3BY-CAp7xfKw.js +0 -1
  155. package/out/phone/assets/eventmodeling-NTZA5JFV-3NMIapix.js +0 -1
  156. package/out/phone/assets/flowDiagram-HODETNUW-DEM4t2yp.js +0 -1
  157. package/out/phone/assets/railroad-abnf-HS5TGJTU-CFJfM9dh.js +0 -1
  158. package/out/phone/assets/railroad-ebnf-LZEXJU2U-B_0R-wZF.js +0 -1
  159. package/out/phone/assets/railroad-peg-WCYAUIDC-ObEBCIxG.js +0 -1
  160. package/out/phone/assets/stateDiagram-v2-MP3YSRHH-D6EyGCQb.js +0 -1
  161. package/out/phone/assets/swimlanesDiagram-VR7AAH4N-BgU-mVRE.js +0 -8
  162. package/out/renderer/assets/channel-4OCJMTsH.js +0 -1
  163. package/out/renderer/assets/classDiagram-ZZMXUADV-lVKI638e.js +0 -1
  164. package/out/renderer/assets/classDiagram-v2-VYDZK3BY-lVKI638e.js +0 -1
  165. package/out/renderer/assets/stateDiagram-v2-MP3YSRHH-B8HJtGSb.js +0 -1
  166. package/out/renderer/assets/swimlanesDiagram-VR7AAH4N-CNAGwVvM.js +0 -8
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./angular-html-DA-rfuFy.js","./html-pp8916En.js","./javascript-wDzz0qaB.js","./css-CLj8gQPS.js","./angular-ts-BrjP3tb8.js","./scss-D5BDwBP9.js","./apl-CORt7UWP.js","./xml-sdJ4AIDG.js","./java-CylS5w8V.js","./json-Cp-IABpG.js","./astro-HNnZUWAn.js","./typescript-BPQ3VLAy.js","./postcss-CXtECtnM.js","./tsx-COt5Ahok.js","./blade-2xfisSek.js","./html-derivative-DlHx6ybY.js","./sql-CRqJ_cUM.js","./bsl-DlhNcFeZ.js","./sdbl-DVxCFoDh.js","./cairo-KRGpt6FW.js","./python-B6aJPvgy.js","./chapel-DTp_pixX.js","./c-BIGW1oBm.js","./cobol-nBiQ_Alo.js","./coffee-Ch7k5sss.js","./cpp-BMRokrvK.js","./regexp-CDVJQ6XC.js","./glsl-DplSGwfg.js","./crystal-DGywbUpC.js","./shellscript-Yzrsuije.js","./edge-FbVlp4U3.js","./elixir-CkH2-t6x.js","./elm-DbKCFpqz.js","./erb-DXfck5VN.js","./ruby-C0TQ7zu5.js","./haml-D5jkg6IW.js","./graphql-ChdNCCLP.js","./jsx-g9-lgVsj.js","./lua-BaeVxFsk.js","./yaml-Buea-lGh.js","./erlang-DsQrWhSR.js","./markdown-Cvjx9yec.js","./fortran-fixed-form-CkoXwp7k.js","./fortran-free-form-BxgE0vQu.js","./fsharp-CXgrBDvD.js","./gdresource-TyuKm33G.js","./gdshader-DkwncUOv.js","./gdscript-DqcFQ5yU.js","./git-commit-F4YmCXRG.js","./diff-D97Zzqfu.js","./git-rebase-r7XF79zn.js","./glimmer-js-ByusRIyA.js","./glimmer-ts-BfAWNZQY.js","./hack-BWmVpMyf.js","./handlebars-BpdQsYii.js","./http-jrhK8wxY.js","./hurl-irOxFIW8.js","./csv-fuZLfV_i.js","./hxml-2-FPmUDs.js","./haxe-CfZj7gIn.js","./jinja-f2NsQr07.js","./jison-wvAkD_A8.js","./julia-5Bft2YPA.js","./r-Cf5RLm7j.js","./just-Cwhn7H3k.js","./perl-B9cMNwum.js","./latex-D5pSuvFb.js","./tex-D96PA37w.js","./liquid-C0sCDyMI.js","./marko-DjSrsDqO.js","./less-B1dDrJ26.js","./mdc-D1_yUvq7.js","./nextflow-C-mBbutL.js","./nextflow-groovy-vE_lwT2v.js","./nginx-BpAMiNFr.js","./nim-BIad80T-.js","./org-DM6o9KBp.js","./ini-BEwlwnbL.js","./make-CHLpvVh8.js","./php-Csjmro_R.js","./vb-Cu-pLBUe.js","./clojure-P80f7IUj.js","./objective-c-DXmwc3jG.js","./docker-BcOcwvcX.js","./go-C27-OAKa.js","./groovy-gcz8RCvz.js","./raku-DXvB9xmW.js","./rust-B1yitclQ.js","./scala-CqE71os6.js","./csharp-DSvCPggb.js","./dart-bE4Kk8sk.js","./ocaml-C0hk2d4L.js","./zig-VOosw3JB.js","./xsl-CtQFsRM5.js","./pug-DKIMFp6K.js","./qml-3beO22l8.js","./razor-BjBPvh-w.js","./rst-bs7f0vWN.js","./cmake-D1j8_8rp.js","./sas-DEy46yEz.js","./shaderlab-Dg9Lc6iA.js","./hlsl-D3lLCCz7.js","./shellsession-BADoaaVG.js","./soy-8wufbnw4.js","./sparql-rVzFXLq3.js","./turtle-BsS91CYL.js","./stata-DI20mbqo.js","./surrealql-Cjom0U5J.js","./svelte-Cy7k_4gC.js","./templ-DhtptRzy.js","./ts-tags-D351s5mN.js","./twig-27uCiNez.js","./typst-BUadGCkm.js","./bat-CickPsom.js","./bibtex-CHM0blh-.js","./jsonc-Des-eS-w.js","./log-2UxHyX5q.js","./powershell-BmBUJMz7.js","./swift-C2oV4EkX.js","./verilog-nZwndyjY.js","./system-verilog-0hqHdDBg.js","./vue-BqiEGhQt.js","./vue-html-AaS7Mt5G.js","./vue-vine-BoDAl6tE.js","./stylus-BEDo0Tqx.js","./EditDiff-Dq1ru-27.js","./sessionChanges-DLMjbWOi.js","./SidePanel-BzHQWaD_.js","./SidePanel-DN2RL6QD.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./angular-html-DA-rfuFy.js","./html-pp8916En.js","./javascript-wDzz0qaB.js","./css-CLj8gQPS.js","./angular-ts-BrjP3tb8.js","./scss-D5BDwBP9.js","./apl-CORt7UWP.js","./xml-sdJ4AIDG.js","./java-CylS5w8V.js","./json-Cp-IABpG.js","./astro-HNnZUWAn.js","./typescript-BPQ3VLAy.js","./postcss-CXtECtnM.js","./tsx-COt5Ahok.js","./blade-2xfisSek.js","./html-derivative-DlHx6ybY.js","./sql-CRqJ_cUM.js","./bsl-DlhNcFeZ.js","./sdbl-DVxCFoDh.js","./cairo-KRGpt6FW.js","./python-B6aJPvgy.js","./chapel-DTp_pixX.js","./c-BIGW1oBm.js","./cobol-nBiQ_Alo.js","./coffee-Ch7k5sss.js","./cpp-BMRokrvK.js","./regexp-CDVJQ6XC.js","./glsl-DplSGwfg.js","./crystal-DGywbUpC.js","./shellscript-Yzrsuije.js","./edge-FbVlp4U3.js","./elixir-CkH2-t6x.js","./elm-DbKCFpqz.js","./erb-DXfck5VN.js","./ruby-C0TQ7zu5.js","./haml-D5jkg6IW.js","./graphql-ChdNCCLP.js","./jsx-g9-lgVsj.js","./lua-BaeVxFsk.js","./yaml-Buea-lGh.js","./erlang-DsQrWhSR.js","./markdown-Cvjx9yec.js","./fortran-fixed-form-CkoXwp7k.js","./fortran-free-form-BxgE0vQu.js","./fsharp-CXgrBDvD.js","./gdresource-TyuKm33G.js","./gdshader-DkwncUOv.js","./gdscript-DqcFQ5yU.js","./git-commit-F4YmCXRG.js","./diff-D97Zzqfu.js","./git-rebase-r7XF79zn.js","./glimmer-js-ByusRIyA.js","./glimmer-ts-BfAWNZQY.js","./hack-BWmVpMyf.js","./handlebars-BpdQsYii.js","./http-jrhK8wxY.js","./hurl-irOxFIW8.js","./csv-fuZLfV_i.js","./hxml-2-FPmUDs.js","./haxe-CfZj7gIn.js","./jinja-f2NsQr07.js","./jison-wvAkD_A8.js","./julia-5Bft2YPA.js","./r-Cf5RLm7j.js","./just-Cwhn7H3k.js","./perl-B9cMNwum.js","./latex-D5pSuvFb.js","./tex-D96PA37w.js","./liquid-C0sCDyMI.js","./marko-DjSrsDqO.js","./less-B1dDrJ26.js","./mdc-D1_yUvq7.js","./nextflow-C-mBbutL.js","./nextflow-groovy-vE_lwT2v.js","./nginx-BpAMiNFr.js","./nim-BIad80T-.js","./org-DM6o9KBp.js","./ini-BEwlwnbL.js","./make-CHLpvVh8.js","./php-Csjmro_R.js","./vb-Cu-pLBUe.js","./clojure-P80f7IUj.js","./objective-c-DXmwc3jG.js","./docker-BcOcwvcX.js","./go-C27-OAKa.js","./groovy-gcz8RCvz.js","./raku-DXvB9xmW.js","./rust-B1yitclQ.js","./scala-CqE71os6.js","./csharp-DSvCPggb.js","./dart-bE4Kk8sk.js","./ocaml-C0hk2d4L.js","./zig-VOosw3JB.js","./xsl-CtQFsRM5.js","./pug-DKIMFp6K.js","./qml-3beO22l8.js","./razor-BjBPvh-w.js","./rst-bs7f0vWN.js","./cmake-D1j8_8rp.js","./sas-DEy46yEz.js","./shaderlab-Dg9Lc6iA.js","./hlsl-D3lLCCz7.js","./shellsession-BADoaaVG.js","./soy-8wufbnw4.js","./sparql-rVzFXLq3.js","./turtle-BsS91CYL.js","./stata-DI20mbqo.js","./surrealql-Cjom0U5J.js","./svelte-Cy7k_4gC.js","./templ-DhtptRzy.js","./ts-tags-D351s5mN.js","./twig-27uCiNez.js","./typst-BUadGCkm.js","./bat-CickPsom.js","./bibtex-CHM0blh-.js","./jsonc-Des-eS-w.js","./log-2UxHyX5q.js","./powershell-BmBUJMz7.js","./swift-C2oV4EkX.js","./verilog-nZwndyjY.js","./system-verilog-0hqHdDBg.js","./vue-BqiEGhQt.js","./vue-html-AaS7Mt5G.js","./vue-vine-BoDAl6tE.js","./stylus-BEDo0Tqx.js","./EditDiff-1q8ZinKY.js","./sessionChanges-9mvBQ4nC.js","./SidePanel-HvFay_uK.js","./SidePanel-DN2RL6QD.css"])))=>i.map(i=>d[i]);
2
2
  function HPe(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in e)){const o=Object.getOwnPropertyDescriptor(r,s);o&&Object.defineProperty(e,s,o.get?o:{enumerable:!0,get:()=>r[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}function Oy(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function UPe(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function r(){var s=!1;try{s=this instanceof r}catch{}return s?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,s.get?s:{enumerable:!0,get:function(){return e[r]}})}),n}var j8={exports:{}},LS={};var dJ;function VPe(){if(dJ)return LS;dJ=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,s,o){var i=null;if(o!==void 0&&(i=""+o),s.key!==void 0&&(i=""+s.key),"key"in s){o={};for(var l in s)l!=="key"&&(o[l]=s[l])}else o=s;return s=o.ref,{$$typeof:e,type:r,key:i,ref:s!==void 0?s:null,props:o}}return LS.Fragment=t,LS.jsx=n,LS.jsxs=n,LS}var fJ;function GPe(){return fJ||(fJ=1,j8.exports=VPe()),j8.exports}var a=GPe(),R8={exports:{}},us={};var hJ;function WPe(){if(hJ)return us;hJ=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),i=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),h=Symbol.iterator;function p(T){return T===null||typeof T!="object"?null:(T=h&&T[h]||T["@@iterator"],typeof T=="function"?T:null)}var m={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,b={};function x(T,U,P){this.props=T,this.context=U,this.refs=b,this.updater=P||m}x.prototype.isReactComponent={},x.prototype.setState=function(T,U){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,U,"setState")},x.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function S(){}S.prototype=x.prototype;function k(T,U,P){this.props=T,this.context=U,this.refs=b,this.updater=P||m}var C=k.prototype=new S;C.constructor=k,v(C,x.prototype),C.isPureReactComponent=!0;var A=Array.isArray;function N(){}var j={H:null,A:null,T:null,S:null},I=Object.prototype.hasOwnProperty;function _(T,U,P){var K=P.ref;return{$$typeof:e,type:T,key:U,ref:K!==void 0?K:null,props:P}}function L(T,U){return _(T.type,U,T.props)}function M(T){return typeof T=="object"&&T!==null&&T.$$typeof===e}function F(T){var U={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(P){return U[P]})}var D=/\/+/g;function R(T,U){return typeof T=="object"&&T!==null&&T.key!=null?F(""+T.key):U.toString(36)}function z(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(N,N):(T.status="pending",T.then(function(U){T.status==="pending"&&(T.status="fulfilled",T.value=U)},function(U){T.status==="pending"&&(T.status="rejected",T.reason=U)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function B(T,U,P,K,J){var ee=typeof T;(ee==="undefined"||ee==="boolean")&&(T=null);var X=!1;if(T===null)X=!0;else switch(ee){case"bigint":case"string":case"number":X=!0;break;case"object":switch(T.$$typeof){case e:case t:X=!0;break;case d:return X=T._init,B(X(T._payload),U,P,K,J)}}if(X)return J=J(T),X=K===""?"."+R(T,0):K,A(J)?(P="",X!=null&&(P=X.replace(D,"$&/")+"/"),B(J,U,P,"",function(oe){return oe})):J!=null&&(M(J)&&(J=L(J,P+(J.key==null||T&&T.key===J.key?"":(""+J.key).replace(D,"$&/")+"/")+X)),U.push(J)),1;X=0;var te=K===""?".":K+":";if(A(T))for(var Q=0;Q<T.length;Q++)K=T[Q],ee=te+R(K,Q),X+=B(K,U,P,ee,J);else if(Q=p(T),typeof Q=="function")for(T=Q.call(T),Q=0;!(K=T.next()).done;)K=K.value,ee=te+R(K,Q++),X+=B(K,U,P,ee,J);else if(ee==="object"){if(typeof T.then=="function")return B(z(T),U,P,K,J);throw U=String(T),Error("Objects are not valid as a React child (found: "+(U==="[object Object]"?"object with keys {"+Object.keys(T).join(", ")+"}":U)+"). If you meant to render a collection of children, use an array instead.")}return X}function H(T,U,P){if(T==null)return T;var K=[],J=0;return B(T,K,"","",function(ee){return U.call(P,ee,J++)}),K}function G(T){if(T._status===-1){var U=T._result;U=U(),U.then(function(P){(T._status===0||T._status===-1)&&(T._status=1,T._result=P)},function(P){(T._status===0||T._status===-1)&&(T._status=2,T._result=P)}),T._status===-1&&(T._status=0,T._result=U)}if(T._status===1)return T._result.default;throw T._result}var ne=typeof reportError=="function"?reportError:function(T){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var U=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof T=="object"&&T!==null&&typeof T.message=="string"?String(T.message):String(T),error:T});if(!window.dispatchEvent(U))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",T);return}console.error(T)},W={map:H,forEach:function(T,U,P){H(T,function(){U.apply(this,arguments)},P)},count:function(T){var U=0;return H(T,function(){U++}),U},toArray:function(T){return H(T,function(U){return U})||[]},only:function(T){if(!M(T))throw Error("React.Children.only expected to receive a single React element child.");return T}};return us.Activity=f,us.Children=W,us.Component=x,us.Fragment=n,us.Profiler=s,us.PureComponent=k,us.StrictMode=r,us.Suspense=c,us.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=j,us.__COMPILER_RUNTIME={__proto__:null,c:function(T){return j.H.useMemoCache(T)}},us.cache=function(T){return function(){return T.apply(null,arguments)}},us.cacheSignal=function(){return null},us.cloneElement=function(T,U,P){if(T==null)throw Error("The argument must be a React element, but you passed "+T+".");var K=v({},T.props),J=T.key;if(U!=null)for(ee in U.key!==void 0&&(J=""+U.key),U)!I.call(U,ee)||ee==="key"||ee==="__self"||ee==="__source"||ee==="ref"&&U.ref===void 0||(K[ee]=U[ee]);var ee=arguments.length-2;if(ee===1)K.children=P;else if(1<ee){for(var X=Array(ee),te=0;te<ee;te++)X[te]=arguments[te+2];K.children=X}return _(T.type,J,K)},us.createContext=function(T){return T={$$typeof:i,_currentValue:T,_currentValue2:T,_threadCount:0,Provider:null,Consumer:null},T.Provider=T,T.Consumer={$$typeof:o,_context:T},T},us.createElement=function(T,U,P){var K,J={},ee=null;if(U!=null)for(K in U.key!==void 0&&(ee=""+U.key),U)I.call(U,K)&&K!=="key"&&K!=="__self"&&K!=="__source"&&(J[K]=U[K]);var X=arguments.length-2;if(X===1)J.children=P;else if(1<X){for(var te=Array(X),Q=0;Q<X;Q++)te[Q]=arguments[Q+2];J.children=te}if(T&&T.defaultProps)for(K in X=T.defaultProps,X)J[K]===void 0&&(J[K]=X[K]);return _(T,ee,J)},us.createRef=function(){return{current:null}},us.forwardRef=function(T){return{$$typeof:l,render:T}},us.isValidElement=M,us.lazy=function(T){return{$$typeof:d,_payload:{_status:-1,_result:T},_init:G}},us.memo=function(T,U){return{$$typeof:u,type:T,compare:U===void 0?null:U}},us.startTransition=function(T){var U=j.T,P={};j.T=P;try{var K=T(),J=j.S;J!==null&&J(P,K),typeof K=="object"&&K!==null&&typeof K.then=="function"&&K.then(N,ne)}catch(ee){ne(ee)}finally{U!==null&&P.types!==null&&(U.types=P.types),j.T=U}},us.unstable_useCacheRefresh=function(){return j.H.useCacheRefresh()},us.use=function(T){return j.H.use(T)},us.useActionState=function(T,U,P){return j.H.useActionState(T,U,P)},us.useCallback=function(T,U){return j.H.useCallback(T,U)},us.useContext=function(T){return j.H.useContext(T)},us.useDebugValue=function(){},us.useDeferredValue=function(T,U){return j.H.useDeferredValue(T,U)},us.useEffect=function(T,U){return j.H.useEffect(T,U)},us.useEffectEvent=function(T){return j.H.useEffectEvent(T)},us.useId=function(){return j.H.useId()},us.useImperativeHandle=function(T,U,P){return j.H.useImperativeHandle(T,U,P)},us.useInsertionEffect=function(T,U){return j.H.useInsertionEffect(T,U)},us.useLayoutEffect=function(T,U){return j.H.useLayoutEffect(T,U)},us.useMemo=function(T,U){return j.H.useMemo(T,U)},us.useOptimistic=function(T,U){return j.H.useOptimistic(T,U)},us.useReducer=function(T,U,P){return j.H.useReducer(T,U,P)},us.useRef=function(T){return j.H.useRef(T)},us.useState=function(T){return j.H.useState(T)},us.useSyncExternalStore=function(T,U,P){return j.H.useSyncExternalStore(T,U,P)},us.useTransition=function(){return j.H.useTransition()},us.version="19.2.8",us}var pJ;function Dy(){return pJ||(pJ=1,R8.exports=WPe()),R8.exports}var y=Dy();const Hn=Oy(y),e0e=HPe({__proto__:null,default:Hn},[y]);var M8={exports:{}},OS={},_8={exports:{}},P8={};var mJ;function qPe(){return mJ||(mJ=1,(function(e){function t(B,H){var G=B.length;B.push(H);e:for(;0<G;){var ne=G-1>>>1,W=B[ne];if(0<s(W,H))B[ne]=H,B[G]=W,G=ne;else break e}}function n(B){return B.length===0?null:B[0]}function r(B){if(B.length===0)return null;var H=B[0],G=B.pop();if(G!==H){B[0]=G;e:for(var ne=0,W=B.length,T=W>>>1;ne<T;){var U=2*(ne+1)-1,P=B[U],K=U+1,J=B[K];if(0>s(P,G))K<W&&0>s(J,P)?(B[ne]=J,B[K]=G,ne=K):(B[ne]=P,B[U]=G,ne=U);else if(K<W&&0>s(J,G))B[ne]=J,B[K]=G,ne=K;else break e}}return H}function s(B,H){var G=B.sortIndex-H.sortIndex;return G!==0?G:B.id-H.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var i=Date,l=i.now();e.unstable_now=function(){return i.now()-l}}var c=[],u=[],d=1,f=null,h=3,p=!1,m=!1,v=!1,b=!1,x=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;function C(B){for(var H=n(u);H!==null;){if(H.callback===null)r(u);else if(H.startTime<=B)r(u),H.sortIndex=H.expirationTime,t(c,H);else break;H=n(u)}}function A(B){if(v=!1,C(B),!m)if(n(c)!==null)m=!0,N||(N=!0,F());else{var H=n(u);H!==null&&z(A,H.startTime-B)}}var N=!1,j=-1,I=5,_=-1;function L(){return b?!0:!(e.unstable_now()-_<I)}function M(){if(b=!1,N){var B=e.unstable_now();_=B;var H=!0;try{e:{m=!1,v&&(v=!1,S(j),j=-1),p=!0;var G=h;try{t:{for(C(B),f=n(c);f!==null&&!(f.expirationTime>B&&L());){var ne=f.callback;if(typeof ne=="function"){f.callback=null,h=f.priorityLevel;var W=ne(f.expirationTime<=B);if(B=e.unstable_now(),typeof W=="function"){f.callback=W,C(B),H=!0;break t}f===n(c)&&r(c),C(B)}else r(c);f=n(c)}if(f!==null)H=!0;else{var T=n(u);T!==null&&z(A,T.startTime-B),H=!1}}break e}finally{f=null,h=G,p=!1}H=void 0}}finally{H?F():N=!1}}}var F;if(typeof k=="function")F=function(){k(M)};else if(typeof MessageChannel<"u"){var D=new MessageChannel,R=D.port2;D.port1.onmessage=M,F=function(){R.postMessage(null)}}else F=function(){x(M,0)};function z(B,H){j=x(function(){B(e.unstable_now())},H)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(B){B.callback=null},e.unstable_forceFrameRate=function(B){0>B||125<B?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):I=0<B?Math.floor(1e3/B):5},e.unstable_getCurrentPriorityLevel=function(){return h},e.unstable_next=function(B){switch(h){case 1:case 2:case 3:var H=3;break;default:H=h}var G=h;h=H;try{return B()}finally{h=G}},e.unstable_requestPaint=function(){b=!0},e.unstable_runWithPriority=function(B,H){switch(B){case 1:case 2:case 3:case 4:case 5:break;default:B=3}var G=h;h=B;try{return H()}finally{h=G}},e.unstable_scheduleCallback=function(B,H,G){var ne=e.unstable_now();switch(typeof G=="object"&&G!==null?(G=G.delay,G=typeof G=="number"&&0<G?ne+G:ne):G=ne,B){case 1:var W=-1;break;case 2:W=250;break;case 5:W=1073741823;break;case 4:W=1e4;break;default:W=5e3}return W=G+W,B={id:d++,callback:H,priorityLevel:B,startTime:G,expirationTime:W,sortIndex:-1},G>ne?(B.sortIndex=G,t(u,B),n(c)===null&&B===n(u)&&(v?(S(j),j=-1):v=!0,z(A,G-ne))):(B.sortIndex=W,t(c,B),m||p||(m=!0,N||(N=!0,F()))),B},e.unstable_shouldYield=L,e.unstable_wrapCallback=function(B){var H=h;return function(){var G=h;h=H;try{return B.apply(this,arguments)}finally{h=G}}}})(P8)),P8}var gJ;function YPe(){return gJ||(gJ=1,_8.exports=qPe()),_8.exports}var L8={exports:{}},mc={};var vJ;function $Pe(){if(vJ)return mc;vJ=1;var e=Dy();function t(c){var u="https://react.dev/errors/"+c;if(1<arguments.length){u+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)u+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+c+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},s=Symbol.for("react.portal");function o(c,u,d){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:s,key:f==null?null:""+f,children:c,containerInfo:u,implementation:d}}var i=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(c,u){if(c==="font")return"";if(typeof u=="string")return u==="use-credentials"?u:""}return mc.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,mc.createPortal=function(c,u){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)throw Error(t(299));return o(c,u,null,d)},mc.flushSync=function(c){var u=i.T,d=r.p;try{if(i.T=null,r.p=2,c)return c()}finally{i.T=u,r.p=d,r.d.f()}},mc.preconnect=function(c,u){typeof c=="string"&&(u?(u=u.crossOrigin,u=typeof u=="string"?u==="use-credentials"?u:"":void 0):u=null,r.d.C(c,u))},mc.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},mc.preinit=function(c,u){if(typeof c=="string"&&u&&typeof u.as=="string"){var d=u.as,f=l(d,u.crossOrigin),h=typeof u.integrity=="string"?u.integrity:void 0,p=typeof u.fetchPriority=="string"?u.fetchPriority:void 0;d==="style"?r.d.S(c,typeof u.precedence=="string"?u.precedence:void 0,{crossOrigin:f,integrity:h,fetchPriority:p}):d==="script"&&r.d.X(c,{crossOrigin:f,integrity:h,fetchPriority:p,nonce:typeof u.nonce=="string"?u.nonce:void 0})}},mc.preinitModule=function(c,u){if(typeof c=="string")if(typeof u=="object"&&u!==null){if(u.as==null||u.as==="script"){var d=l(u.as,u.crossOrigin);r.d.M(c,{crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0})}}else u==null&&r.d.M(c)},mc.preload=function(c,u){if(typeof c=="string"&&typeof u=="object"&&u!==null&&typeof u.as=="string"){var d=u.as,f=l(d,u.crossOrigin);r.d.L(c,d,{crossOrigin:f,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0,type:typeof u.type=="string"?u.type:void 0,fetchPriority:typeof u.fetchPriority=="string"?u.fetchPriority:void 0,referrerPolicy:typeof u.referrerPolicy=="string"?u.referrerPolicy:void 0,imageSrcSet:typeof u.imageSrcSet=="string"?u.imageSrcSet:void 0,imageSizes:typeof u.imageSizes=="string"?u.imageSizes:void 0,media:typeof u.media=="string"?u.media:void 0})}},mc.preloadModule=function(c,u){if(typeof c=="string")if(u){var d=l(u.as,u.crossOrigin);r.d.m(c,{as:typeof u.as=="string"&&u.as!=="script"?u.as:void 0,crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0})}else r.d.m(c)},mc.requestFormReset=function(c){r.d.r(c)},mc.unstable_batchedUpdates=function(c,u){return c(u)},mc.useFormState=function(c,u,d){return i.H.useFormState(c,u,d)},mc.useFormStatus=function(){return i.H.useHostTransitionStatus()},mc.version="19.2.8",mc}var xJ;function L4(){if(xJ)return L8.exports;xJ=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),L8.exports=$Pe(),L8.exports}var bJ;function KPe(){if(bJ)return OS;bJ=1;var e=YPe(),t=Dy(),n=L4();function r(g){var w="https://react.dev/errors/"+g;if(1<arguments.length){w+="?args[]="+encodeURIComponent(arguments[1]);for(var E=2;E<arguments.length;E++)w+="&args[]="+encodeURIComponent(arguments[E])}return"Minified React error #"+g+"; visit "+w+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(g){return!(!g||g.nodeType!==1&&g.nodeType!==9&&g.nodeType!==11)}function o(g){var w=g,E=g;if(g.alternate)for(;w.return;)w=w.return;else{g=w;do w=g,(w.flags&4098)!==0&&(E=w.return),g=w.return;while(g)}return w.tag===3?E:null}function i(g){if(g.tag===13){var w=g.memoizedState;if(w===null&&(g=g.alternate,g!==null&&(w=g.memoizedState)),w!==null)return w.dehydrated}return null}function l(g){if(g.tag===31){var w=g.memoizedState;if(w===null&&(g=g.alternate,g!==null&&(w=g.memoizedState)),w!==null)return w.dehydrated}return null}function c(g){if(o(g)!==g)throw Error(r(188))}function u(g){var w=g.alternate;if(!w){if(w=o(g),w===null)throw Error(r(188));return w!==g?null:g}for(var E=g,O=w;;){var Z=E.return;if(Z===null)break;var re=Z.alternate;if(re===null){if(O=Z.return,O!==null){E=O;continue}break}if(Z.child===re.child){for(re=Z.child;re;){if(re===E)return c(Z),g;if(re===O)return c(Z),w;re=re.sibling}throw Error(r(188))}if(E.return!==O.return)E=Z,O=re;else{for(var Ce=!1,Qe=Z.child;Qe;){if(Qe===E){Ce=!0,E=Z,O=re;break}if(Qe===O){Ce=!0,O=Z,E=re;break}Qe=Qe.sibling}if(!Ce){for(Qe=re.child;Qe;){if(Qe===E){Ce=!0,E=re,O=Z;break}if(Qe===O){Ce=!0,O=re,E=Z;break}Qe=Qe.sibling}if(!Ce)throw Error(r(189))}}if(E.alternate!==O)throw Error(r(190))}if(E.tag!==3)throw Error(r(188));return E.stateNode.current===E?g:w}function d(g){var w=g.tag;if(w===5||w===26||w===27||w===6)return g;for(g=g.child;g!==null;){if(w=d(g),w!==null)return w;g=g.sibling}return null}var f=Object.assign,h=Symbol.for("react.element"),p=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),b=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),k=Symbol.for("react.context"),C=Symbol.for("react.forward_ref"),A=Symbol.for("react.suspense"),N=Symbol.for("react.suspense_list"),j=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),_=Symbol.for("react.activity"),L=Symbol.for("react.memo_cache_sentinel"),M=Symbol.iterator;function F(g){return g===null||typeof g!="object"?null:(g=M&&g[M]||g["@@iterator"],typeof g=="function"?g:null)}var D=Symbol.for("react.client.reference");function R(g){if(g==null)return null;if(typeof g=="function")return g.$$typeof===D?null:g.displayName||g.name||null;if(typeof g=="string")return g;switch(g){case v:return"Fragment";case x:return"Profiler";case b:return"StrictMode";case A:return"Suspense";case N:return"SuspenseList";case _:return"Activity"}if(typeof g=="object")switch(g.$$typeof){case m:return"Portal";case k:return g.displayName||"Context";case S:return(g._context.displayName||"Context")+".Consumer";case C:var w=g.render;return g=g.displayName,g||(g=w.displayName||w.name||"",g=g!==""?"ForwardRef("+g+")":"ForwardRef"),g;case j:return w=g.displayName||null,w!==null?w:R(g.type)||"Memo";case I:w=g._payload,g=g._init;try{return R(g(w))}catch{}}return null}var z=Array.isArray,B=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,H=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G={pending:!1,data:null,method:null,action:null},ne=[],W=-1;function T(g){return{current:g}}function U(g){0>W||(g.current=ne[W],ne[W]=null,W--)}function P(g,w){W++,ne[W]=g.current,g.current=w}var K=T(null),J=T(null),ee=T(null),X=T(null);function te(g,w){switch(P(ee,w),P(J,g),P(K,null),w.nodeType){case 9:case 11:g=(g=w.documentElement)&&(g=g.namespaceURI)?PZ(g):0;break;default:if(g=w.tagName,w=w.namespaceURI)w=PZ(w),g=LZ(w,g);else switch(g){case"svg":g=1;break;case"math":g=2;break;default:g=0}}U(K),P(K,g)}function Q(){U(K),U(J),U(ee)}function oe(g){g.memoizedState!==null&&P(X,g);var w=K.current,E=LZ(w,g.type);w!==E&&(P(J,g),P(K,E))}function de(g){J.current===g&&(U(K),U(J)),X.current===g&&(U(X),RS._currentValue=G)}var ie,ue;function xe(g){if(ie===void 0)try{throw Error()}catch(E){var w=E.stack.trim().match(/\n( *(at )?)/);ie=w&&w[1]||"",ue=-1<E.stack.indexOf(`
3
3
  at`)?" (<anonymous>)":-1<E.stack.indexOf("@")?"@unknown:0:0":""}return`
4
4
  `+ie+g+ue}var ge=!1;function Te(g,w){if(!g||ge)return"";ge=!0;var E=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var O={DetermineComponentFrameRoot:function(){try{if(w){var Sn=function(){throw Error()};if(Object.defineProperty(Sn.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Sn,[])}catch(tn){var Yt=tn}Reflect.construct(g,[],Sn)}else{try{Sn.call()}catch(tn){Yt=tn}g.call(Sn.prototype)}}else{try{throw Error()}catch(tn){Yt=tn}(Sn=g())&&typeof Sn.catch=="function"&&Sn.catch(function(){})}}catch(tn){if(tn&&Yt&&typeof tn.stack=="string")return[tn.stack,Yt.stack]}return[null,null]}};O.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var Z=Object.getOwnPropertyDescriptor(O.DetermineComponentFrameRoot,"name");Z&&Z.configurable&&Object.defineProperty(O.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var re=O.DetermineComponentFrameRoot(),Ce=re[0],Qe=re[1];if(Ce&&Qe){var bt=Ce.split(`
@@ -323,7 +323,7 @@ XID_Continue XIDC
323
323
  XID_Start XIDS`.split(/\s/).map(e=>[LP(e),e])),KCt=new Map([["s",cl(383)],[cl(383),"s"]]),XCt=new Map([[cl(223),cl(7838)],[cl(107),cl(8490)],[cl(229),cl(8491)],[cl(969),cl(8486)]]),QCt=new Map([nv(453),nv(456),nv(459),nv(498),...HD(8072,8079),...HD(8088,8095),...HD(8104,8111),nv(8124),nv(8140),nv(8188)]),ZCt=new Map([["alnum",ps`[\p{Alpha}\p{Nd}]`],["alpha",ps`\p{Alpha}`],["ascii",ps`\p{ASCII}`],["blank",ps`[\p{Zs}\t]`],["cntrl",ps`\p{Cc}`],["digit",ps`\p{Nd}`],["graph",ps`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",ps`\p{Lower}`],["print",ps`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",ps`[\p{P}\p{S}]`],["space",ps`\p{space}`],["upper",ps`\p{Upper}`],["word",ps`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",ps`\p{AHex}`]]);function JCt(e,t){const n=[];for(let r=e;r<=t;r++)n.push(r);return n}function nv(e){const t=cl(e);return[t.toLowerCase(),t]}function HD(e,t){return JCt(e,t).map(n=>nv(n))}var DTe=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function eEt(e,t){const n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t};BTe(e);const r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:CU(n.bestEffortTarget,"ES2024"),passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:e.flags.digitIsAscii,spaceIsAscii:e.flags.spaceIsAscii,wordIsAscii:e.flags.wordIsAscii};GE(e,tEt,r);const s={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},o={currentFlags:s,prevFlags:null,globalFlags:s,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:r.subroutineRefMap};GE(e,nEt,o);const i={groupsByName:o.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:o.reffedNodesByReferencer};return GE(e,rEt,i),e._originMap=o.groupOriginByCopy,e._strategy=r.strategy,e}var tEt={AbsenceFunction({node:e,parent:t,replaceWith:n}){const{body:r,kind:s}=e;if(s==="repeater"){const o=mh();o.body[0].body.push(Mb({negate:!0,body:r}),vw("Any"));const i=mh();i.body[0].body.push(ITe("greedy",0,1/0,o)),n(wa(i,t),{traverse:!0})}else throw new Error('Unsupported absence function "(?~|"')},Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:r}){const s=e.body.filter(o=>o.kind==="flags");for(let o=n+1;o<t.body.length;o++){const i=t.body[o];ZT(r,i,[]).push(...s)}},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){const n=zTe(t.get(e));if(n){const r=mh({flags:n});r.body[0].body=e.body,e.body=[wa(r,e)]}}}},Assertion({node:e,parent:t,key:n,container:r,root:s,remove:o,replaceWith:i},l){const{kind:c,negate:u}=e,{asciiWordBoundaries:d,avoidSubclass:f,supportedGNodes:h,wordIsAscii:p}=l;if(c==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${u?"Y":"y"}"`);if(c==="line_end")i(wa(Mb({body:[Cy({body:[yU("string_end")]}),Cy({body:[PP(10)]})]}),t));else if(c==="line_start")i(wa(Gm(ps`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(c==="search_start")if(h.has(e))s.flags.sticky=!0,o();else{const m=r[n-1];if(m&&cEt(m))i(wa(Mb({negate:!0}),t));else{if(f)throw new Error(ps`Uses "\G" in a way that requires a subclass`);i(rv(yU("string_start"),t)),l.strategy="clip_search"}}else if(!(c==="string_end"||c==="string_start"))if(c==="string_end_newline")i(wa(Gm(ps`(?=\n?\z)`),t));else if(c==="word_boundary"){if(!p&&!d){const m=`(?:(?<=${Vm})(?!${Vm})|(?<!${Vm})(?=${Vm}))`,v=`(?:(?<=${Vm})(?=${Vm})|(?<!${Vm})(?!${Vm}))`;i(wa(Gm(u?v:m),t))}}else throw new Error(`Unexpected assertion kind "${c}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!VD(n)&&(n=UD(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!VD(r)&&(r=UD(r,t),e.name=r),n.set(e.number,e),r&&n.set(r,e)},CharacterClassRange({node:e,parent:t,replaceWith:n}){if(t.kind==="intersection"){const r=nR({body:[e]});n(wa(r,t),{traverse:!0})}},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:r,minTargetEs2024:s,digitIsAscii:o,spaceIsAscii:i,wordIsAscii:l}){const{kind:c,negate:u,value:d}=e;if(o&&(c==="digit"||d==="digit")){n(rv(kU("digit",{negate:u}),t));return}if(i&&(c==="space"||d==="space")){n(wa(GD(Gm(YCt),u),t));return}if(l&&(c==="word"||d==="word")){n(rv(kU("word",{negate:u}),t));return}if(c==="any")n(rv(vw("Any"),t));else if(c==="digit")n(rv(vw("Nd",{negate:u}),t));else if(c!=="dot")if(c==="text_segment"){if(r==="strict")throw new Error(ps`Use of "\X" requires non-strict accuracy`);const f="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",h=ps`\p{RI}{2}|${f}(?:\u200D${f})*`;n(wa(Gm(ps`(?>\r\n|${s?ps`\p{RGI_Emoji}`:h}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(c==="hex")n(rv(vw("AHex",{negate:u}),t));else if(c==="newline")n(wa(Gm(u?`[^
324
324
  ]`:`(?>\r
325
325
  ?|[
326
- \v\f…\u2028\u2029])`),t));else if(c==="posix")if(!s&&(d==="graph"||d==="print")){if(r==="strict")throw new Error(`POSIX class "${d}" requires min target ES2024 or non-strict accuracy`);let f={graph:"!-~",print:" -~"}[d];u&&(f=`\0-${cl(f.codePointAt(0)-1)}${cl(f.codePointAt(2)+1)}-􏿿`),n(wa(Gm(`[${f}]`),t))}else n(wa(GD(Gm(ZCt.get(d)),u),t));else if(c==="property")F$.has(LP(d))||(e.key="sc");else if(c==="space")n(rv(vw("space",{negate:u}),t));else if(c==="word")n(wa(GD(Gm(Vm),u),t));else throw new Error(`Unexpected character set kind "${c}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:s,removeAllPrevSiblings:o,removeAllNextSiblings:i}){const{kind:l,flags:c}=e;if(l==="flags")if(!c.enable&&!c.disable)r();else{const u=mh({flags:c});u.body[0].body=i(),s(wa(u,t),{traverse:!0})}else if(l==="keep"){const u=n.body[0],f=n.body.length===1&&TTe(u,{type:"Group"})&&u.body[0].body.length===1?u.body[0]:n;if(t.parent!==f||f.body.length>1)throw new Error(ps`Uses "\K" in a way that's unsupported`);const h=Mb({behind:!0});h.body[0].body=o(),s(wa(h,t))}else throw new Error(`Unexpected directive kind "${l}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw new Error('Unsupported flag "P"');if(e.textSegmentMode==="word")throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(n=>delete e[n]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;const{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){const{kind:n}=e;n==="lookbehind"&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){const{kind:r}=e;if(r==="fail")n(wa(Mb({negate:!0}),t));else throw new Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){const t=mh();t.body[0].body.push(e.body),e.body=wa(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){const n=[];let r=!1,s=!1;for(const o of e.body)if(o.body.length===1&&o.body[0].kind==="search_start")o.body.pop();else{const i=UTe(o.body);i?(r=!0,Array.isArray(i)?n.push(...i):n.push(i)):s=!0}r&&!s&&n.forEach(o=>t.add(o))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t==="strict"&&n&&r)throw new Error(ps`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!VD(n)&&(n=UD(n,t),e.ref=n)}},nEt={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){const{orphan:r,ref:s}=e;r||n.set(e,[...t.get(s).map(({node:o})=>o)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:s,groupsByName:o,multiplexCapturesToLeftByRef:i,openRefs:l,reffedNodesByReferencer:c}){const u=s.get(e);if(u&&l.has(e.number)){const f=rv(fae(e.number),t);c.set(f,l.get(e.number)),n(f);return}l.set(e.number,e),i.set(e.number,[]),e.name&&ZT(i,e.name,[]);const d=i.get(e.name??e.number);for(let f=0;f<d.length;f++){const h=d[f];if(u===h.node||u&&u===h.origin||e===h.origin){d.splice(f,1);break}}if(i.get(e.number).push({node:e,origin:u}),e.name&&i.get(e.name).push({node:e,origin:u}),e.name){const f=ZT(o,e.name,new Map);let h=!1;if(u)h=!0;else for(const p of f.values())if(!p.hasDuplicateNameToRemove){h=!0;break}o.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:h})}},exit({node:e},{openRefs:t}){t.get(e.number)===e&&t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=j6(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){const{isRecursive:s,ref:o}=e;if(s){let d=t;for(;(d=d.parent)&&!(d.type==="CapturingGroup"&&(d.name===o||d.number===o)););r.reffedNodesByReferencer.set(e,d);return}const i=r.subroutineRefMap.get(o),l=o===0,c=l?fae(0):FTe(i,r.groupOriginByCopy,null);let u=c;if(!l){const d=zTe(iEt(i,h=>h.type==="Group"&&!!h.flags)),f=d?j6(r.globalFlags,d):r.globalFlags;sEt(f,r.currentFlags)||(u=mh({flags:aEt(f)}),u.body[0].body.push(c))}n(wa(u,t),{traverse:!l})}},rEt={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}const o=r.reffedNodesByReferencer.get(e).filter(i=>oEt(i,e));if(!o.length)n(wa(Mb({negate:!0}),t));else if(o.length>1){const i=mh({atomic:!0,body:o.reverse().map(l=>Cy({body:[wU(l.number)]}))});n(wa(i,t))}else e.ref=o[0].number},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){const n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let r=0;r<n;r++){const s=NTe();e.body.at(-1).body.push(s)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function BTe(e){GE(e,{"*"({node:t,parent:n}){t.parent=n}})}function sEt(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function oEt(e,t){let n=t;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===e)return!1;const r=HTe(n.parent);for(const s of r){if(s===n)break;if(s===e||VTe(s,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function FTe(e,t,n,r){const s=Array.isArray(e)?[]:{};for(const[o,i]of Object.entries(e))o==="parent"?s.parent=Array.isArray(n)?r:n:i&&typeof i=="object"?s[o]=FTe(i,t,s,n):(o==="type"&&i==="CapturingGroup"&&t.set(s,t.get(e)??e),s[o]=i);return s}function fae(e){const t=jTe(e);return t.isRecursive=!0,t}function iEt(e,t){const n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function UD(e,t){if(t.has(e))return t.get(e);const n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug,"_")}`;return t.set(e,n),n}function zTe(e){const t=["dotAll","ignoreCase"],n={enable:{},disable:{}};return e.forEach(({flags:r})=>{t.forEach(s=>{r.enable?.[s]&&(delete n.disable[s],n.enable[s]=!0),r.disable?.[s]&&(n.disable[s]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function aEt({dotAll:e,ignoreCase:t}){const n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function HTe(e){if(!e)throw new Error("Node expected");const{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function UTe(e){const t=e.find(n=>n.kind==="search_start"||uEt(n,{negate:!1})||!lEt(n));if(!t)return null;if(t.kind==="search_start")return t;if(t.type==="LookaroundAssertion")return t.body[0].body[0];if(t.type==="CapturingGroup"||t.type==="Group"){const n=[];for(const r of t.body){const s=UTe(r.body);if(!s)return null;Array.isArray(s)?n.push(...s):n.push(s)}return n}return null}function VTe(e,t){const n=HTe(e)??[];for(const r of n)if(r===t||VTe(r,t))return!0;return!1}function lEt({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function cEt(e){const t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function uEt(e,t){const n={negate:null,...t};return e.type==="LookaroundAssertion"&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&TTe(e.body[0],{type:"Assertion",kind:"search_start"})}function VD(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function Gm(e,t){const r=ATe(e,{...t,unicodePropertyMap:F$}).body;return r.length>1||r[0].body.length>1?mh({body:r}):r[0].body[0]}function GD(e,t){return e.negate=t,e}function rv(e,t){return e.parent=t,e}function wa(e,t){return BTe(e),e.parent=t,e}function dEt(e,t){const n=LTe(t),r=CU(n.target,"ES2024"),s=CU(n.target,"ES2025"),o=n.rules.recursionLimit;if(!Number.isInteger(o)||o<2||o>20)throw new Error("Invalid recursionLimit; use 2-20");let i=null,l=null;if(!s){const p=[e.flags.ignoreCase];GE(e,fEt,{getCurrentModI:()=>p.at(-1),popModI(){p.pop()},pushModI(m){p.push(m)},setHasCasedChar(){p.at(-1)?i=!0:l=!0}})}const c={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||i)&&!l)};let u=e;const d={accuracy:n.accuracy,appliedGlobalFlags:c,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:u,originMap:e._originMap,recursionLimit:o,useAppliedIgnoreCase:!!(!s&&i&&l),useFlagMods:s,useFlagV:r,verbose:n.verbose};function f(p){return d.lastNode=u,u=p,WCt(hEt[p.type],`Unexpected node type "${p.type}"`)(p,d,f)}const h={pattern:e.body.map(f).join("|"),flags:f(e.flags),options:{...e.options}};return r||(delete h.options.force.v,h.options.disable.v=!0,h.options.unicodeSetsPlugin=null),h._captureTransfers=new Map,h._hiddenCaptures=[],d.captureMap.forEach((p,m)=>{p.hidden&&h._hiddenCaptures.push(m),p.transferTo&&ZT(h._captureTransfers,p.transferTo,[]).push(m)}),h}var fEt={"*":{enter({node:e},t){if(pae(e)){const n=t.getCurrentModI();t.pushModI(e.flags?j6({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){pae(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){z$(cl(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),GTe(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind==="property"&&DTe.has(e.value)&&t.setHasCasedChar()}},hEt={Alternative({body:e},t,n){return e.map(n).join("")},Assertion({kind:e,negate:t}){if(e==="string_end")return"$";if(e==="string_start")return"^";if(e==="word_boundary")return t?ps`\B`:ps`\b`;throw new Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!="number")throw new Error("Unexpected named backref in transformed AST");if(!t.useFlagMods&&t.accuracy==="strict"&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e},CapturingGroup(e,t,n){const{body:r,name:s,number:o}=e,i={ignoreCase:t.currentFlags.ignoreCase},l=t.originMap.get(e);return l&&(i.hidden=!0,o>l.number&&(i.transferTo=l.number)),t.captureMap.set(o,i),`(${s?`?<${s}>`:""}${r.map(n).join("|")})`},Character({value:e},t){const n=cl(e),r=G1(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&z$(n)){const s=OTe(n);return t.inCharClass?s.join(""):s.length>1?`[${s.join("")}]`:s[0]}return n},CharacterClass(e,t,n){const{kind:r,negate:s,parent:o}=e;let{body:i}=e;if(r==="intersection"&&!t.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");Sh.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&i.some(mae)&&(i=[PP(45),...i.filter(u=>!mae(u))]);const l=()=>`[${s?"^":""}${i.map(n).join(r==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||Sh.bugNestedClassIgnoresNegation)&&!s){const d=i.filter(f=>f.type==="CharacterClass"&&f.kind==="union"&&f.negate);if(d.length){const f=mh(),h=f.body[0];return f.parent=o,h.parent=f,i=i.filter(p=>!d.includes(p)),e.body=i,i.length?(e.parent=h,h.body.push(e)):f.body.pop(),d.forEach(p=>{const m=Cy({body:[p]});p.parent=m,m.parent=f,f.body.push(m)}),n(f)}}t.inCharClass=!0;const u=l();return t.inCharClass=!1,u}const c=i[0];if(r==="union"&&!s&&c&&((!t.useFlagV||!t.verbose)&&o.kind==="union"&&!(Sh.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&o.kind==="intersection"&&i.length===1&&c.type!=="CharacterClassRange"))return i.map(n).join("");if(!t.useFlagV&&o.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return l()},CharacterClassRange(e,t){const n=e.min.value,r=e.max.value,s={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},o=G1(n,s),i=G1(r,s),l=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){const c=GTe(e);xEt(c).forEach(d=>{l.add(Array.isArray(d)?`${G1(d[0],s)}-${G1(d[1],s)}`:G1(d,s))})}return`${o}-${i}${[...l].join("")}`},CharacterSet({kind:e,negate:t,value:n,key:r},s){if(e==="dot")return s.currentFlags.dotAll?s.appliedGlobalFlags.dotAll||s.useFlagMods?".":"[^]":ps`[^\n]`;if(e==="digit")return t?ps`\D`:ps`\d`;if(e==="property"){if(s.useAppliedIgnoreCase&&s.currentFlags.ignoreCase&&DTe.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?ps`\P`:ps`\p`}{${r?`${r}=`:""}${n}}`}if(e==="word")return t?ps`\W`:ps`\w`;throw new Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":"")},Group({atomic:e,body:t,flags:n,parent:r},s,o){const i=s.currentFlags;n&&(s.currentFlags=j6(i,n));const l=t.map(o).join("|"),c=!s.verbose&&t.length===1&&r.type!=="Quantifier"&&!e&&(!s.useFlagMods||!n)?l:`(?${bEt(e,n,s.useFlagMods)}${l})`;return s.currentFlags=i,c},LookaroundAssertion({body:e,kind:t,negate:n},r,s){return`(?${`${t==="lookahead"?"":"<"}${n?"!":"="}`}${e.map(s).join("|")})`},Quantifier(e,t,n){return n(e.body)+yEt(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw new Error("Unexpected non-recursive subroutine in transformed AST");const r=n.recursionLimit;return t===0?`(?R=${r})`:ps`\g<${t}&R=${r}>`}},pEt=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),mEt=new Set(["-","\\","]","^","["]),gEt=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),hae=new Map([[9,ps`\t`],[10,ps`\n`],[11,ps`\v`],[12,ps`\f`],[13,ps`\r`],[8232,ps`\u2028`],[8233,ps`\u2029`],[65279,ps`\uFEFF`]]),vEt=new RegExp("^\\p{Cased}$","u");function z$(e){return vEt.test(e)}function GTe(e,t){const n=!!t?.firstOnly,r=e.min.value,s=e.max.value,o=[];if(r<65&&(s===65535||s>=131071)||r===65536&&s>=131071)return o;for(let i=r;i<=s;i++){const l=cl(i);if(!z$(l))continue;const c=OTe(l).filter(u=>{const d=u.codePointAt(0);return d<r||d>s});if(c.length&&(o.push(...c),n))break}return o}function G1(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(hae.has(e))return hae.get(e);if(e<32||e>126&&e<160||e>262143||t&&wEt(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;const s=n?r?gEt:mEt:pEt,o=cl(e);return(s.has(o)?"\\":"")+o}function xEt(e){const t=e.map(s=>s.codePointAt(0)).sort((s,o)=>s-o),n=[];let r=null;for(let s=0;s<t.length;s++)t[s+1]===t[s]+1?r??=t[s]:r===null?n.push(t[s]):(n.push([r,t[s]]),r=null);return n}function bEt(e,t,n){if(e)return">";let r="";if(t&&n){const{enable:s,disable:o}=t;r=(s?.ignoreCase?"i":"")+(s?.dotAll?"s":"")+(o?"-":"")+(o?.ignoreCase?"i":"")+(o?.dotAll?"s":"")}return`${r}:`}function yEt({kind:e,max:t,min:n}){let r;return!n&&t===1?r="?":!n&&t===1/0?r="*":n===1&&t===1/0?r="+":n===t?r=`{${n}}`:r=`{${n},${t===1/0?"":t}}`,r+{greedy:"",lazy:"?",possessive:"+"}[e]}function pae({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function wEt(e){return e>47&&e<58}function mae({type:e,value:t}){return e==="Character"&&t===45}var kEt=class EU extends RegExp{#t=new Map;#e=null;#s;#n=null;#i=null;rawOptions={};get source(){return this.#s||"(?:)"}constructor(t,n,r){const s=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw new Error("Cannot provide options when copying a regexp");const o=t;super(o,n),this.#s=o.source,o instanceof EU&&(this.#t=o.#t,this.#n=o.#n,this.#i=o.#i,this.rawOptions=o.rawOptions)}else{const o={hiddenCaptures:[],strategy:null,transfers:[],...r};super(s?"":t,n),this.#s=t,this.#t=CEt(o.hiddenCaptures,o.transfers),this.#i=o.strategy,this.rawOptions=r??{}}s||(this.#e=this)}exec(t){if(!this.#e){const{lazyCompile:s,...o}=this.rawOptions;this.#e=new EU(this.#s,this.flags,o)}const n=this.global||this.sticky,r=this.lastIndex;if(this.#i==="clip_search"&&n&&r){this.lastIndex=0;const s=this.#l(t.slice(r));return s&&(SEt(s,r,t,this.hasIndices),this.lastIndex+=r),s}return this.#l(t)}#l(t){this.#e.lastIndex=this.lastIndex;const n=super.exec.call(this.#e,t);if(this.lastIndex=this.#e.lastIndex,!n||!this.#t.size)return n;const r=[...n];n.length=1;let s;this.hasIndices&&(s=[...n.indices],n.indices.length=1);const o=[0];for(let i=1;i<r.length;i++){const{hidden:l,transferTo:c}=this.#t.get(i)??{};if(l?o.push(null):(o.push(n.length),n.push(r[i]),this.hasIndices&&n.indices.push(s[i])),c&&r[i]!==void 0){const u=o[c];if(!u)throw new Error(`Invalid capture transfer to "${u}"`);if(n[u]=r[i],this.hasIndices&&(n.indices[u]=s[i]),n.groups){this.#n||(this.#n=EEt(this.source));const d=this.#n.get(c);d&&(n.groups[d]=r[i],this.hasIndices&&(n.indices.groups[d]=s[i]))}}}return n}};function SEt(e,t,n,r){if(e.index+=t,e.input=n,r){const s=e.indices;for(let i=0;i<s.length;i++){const l=s[i];l&&(s[i]=[l[0]+t,l[1]+t])}const o=s.groups;o&&Object.keys(o).forEach(i=>{const l=o[i];l&&(o[i]=[l[0]+t,l[1]+t])})}}function CEt(e,t){const n=new Map;for(const r of e)n.set(r,{hidden:!0});for(const[r,s]of t)for(const o of s)ZT(n,o,{}).transferTo=r;return n}function EEt(e){const t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map;let r=0,s=0,o;for(;o=t.exec(e);){const{0:i,groups:{capture:l,name:c}}=o;i==="["?r++:r?i==="]"&&r--:l&&(s++,c&&n.set(s,c))}return n}function TEt(e,t){const n=AEt(e,t);return n.options?new kEt(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function AEt(e,t){const n=LTe(t),r=ATe(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:F$}),s=eEt(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),o=dEt(s,n),i=VCt(o.pattern,{captureTransfers:o._captureTransfers,hiddenCaptures:o._hiddenCaptures,mode:"external"}),l=HCt(i.pattern),c=zCt(l.pattern,{captureTransfers:i.captureTransfers,hiddenCaptures:i.hiddenCaptures}),u={pattern:c.pattern,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${o.flags}${o.options.disable.v?"u":"v"}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{const d=c.hiddenCaptures.sort((m,v)=>m-v),f=Array.from(c.captureTransfers),h=s._strategy,p=u.pattern.length>=n.lazyCompileLength;(d.length||f.length||h||p)&&(u.options={...d.length&&{hiddenCaptures:d},...f.length&&{transfers:f},...h&&{strategy:h},...p&&{lazyCompile:p}})}return u}function NEt(e,t){return TEt(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function WTe(e={}){const t={target:"auto",cache:new Map,...e};return t.regexConstructor||=n=>NEt(n,{target:t.target}),{createScanner(n){return new GSt(n,t)},createString(n){return{content:n}}}}const IEt=["markdown","typescript","tsx","javascript","jsx","json","css","html","html-derivative","python","rust","go","shellscript","yaml"];let gae=null;function jEt(){return gae??=yTe({themes:["github-dark","github-light"],langs:[...IEt],engine:WTe()}),gae}const REt=200,MEt=20*1024*1024,Cp=new Map;let WD=0;function _Et(e){const t=Cp.get(e);return t!==void 0&&(Cp.delete(e),Cp.set(e,t)),t}function PEt(e,t){if(!Cp.has(e))for(Cp.set(e,t),WD+=t.length*2;(Cp.size>REt||WD>MEt)&&Cp.size>0;){const n=Cp.keys().next().value;WD-=(Cp.get(n)?.length??0)*2,Cp.delete(n)}}async function qTe(e,t,n=!0){const r=`${t}\0${e}`;if(n){const s=_Et(r);if(s!==void 0)return s}try{const s=await jEt(),o=s.getLoadedLanguages().includes(t)?t:"text",i=s.codeToHtml(e,{lang:o,themes:{light:"github-light",dark:"github-dark"},defaultColor:"light"});return n&&PEt(r,i),i}catch(s){return console.error("snippet highlight failed:",s),null}}const vae="my-2 overflow-x-auto rounded-lg border bg-[var(--sunken,var(--muted))] text-(length:--chat-code-block-size) [font-weight:var(--chat-code-block-weight)] leading-relaxed";function LEt(e){const t=e.trimStart();return/^<[a-zA-Z!/]/.test(t)?"html":/^[{[]/.test(t)?"json":/^[$#] /.test(t)?"shellscript":"text"}function R6({code:e,language:t,streaming:n=!1}){const[r,s]=y.useState(null);y.useEffect(()=>{if(n){s(null);return}let i=!0;return qTe(e,t??LEt(e),!0).then(l=>{i&&s(l)}),()=>{i=!1}},[e,t,n]);const o=!n&&a.jsx(px,{text:e,className:"absolute top-1.5 right-1.5 rounded-md border bg-background/80 p-1.5 text-muted-foreground opacity-0 backdrop-blur transition-opacity group-hover/code:opacity-100"});return r==null?a.jsxs("div",{"data-enso":"code-block","data-language":t,className:"group/code relative",children:[a.jsx("pre",{className:`${vae} p-3 font-mono`,children:a.jsx("code",{children:e})}),o]}):a.jsxs("div",{"data-enso":"code-block","data-language":t,className:"group/code relative",children:[a.jsx("div",{className:`${vae} [&_pre]:m-0 [&_pre]:overflow-x-auto [&_pre]:bg-transparent! [&_pre]:p-3 [&_pre]:font-mono [&_pre]:[--shiki-dark-bg:transparent]!`,dangerouslySetInnerHTML:{__html:r}}),o]})}const OEt=50,xae=200,DEt=3e4,YTe={status:"missing"},M6=new Map,rR=new Map,TU=new Set,_6=new Map;let $Te=null,H$=0;const qD={batches:0,paths:0,ms:0},BEt=e=>e.cwd??`conversation:${e.conversationId}`,BP=(e,t)=>`${BEt(e)}\0${t}`;function FEt(e){return e?e.state.status==="ok"?e.epoch===H$:Date.now()-e.at<DEt:!1}function KTe(e,t){const n=M6.get(e)?.state,r=n?.status===t.status&&(t.status==="missing"||n.status==="ok"&&n.rel===t.rel&&n.kind===t.kind);if(M6.set(e,{state:r&&n?n:t,epoch:H$,at:Date.now()}),!r)for(const s of rR.get(e)??[])s()}function zEt(e){return e?{status:"ok",rel:e.rel,kind:e.kind}:YTe}async function XTe(e,t){const n=performance.now();try{const r=await window.electronAPI.workspaceFiles.resolveLinks({conversationId:e.conversationId,projectId:e.projectId,rels:t});return t.map((s,o)=>zEt(r.ok?r.items[o]:null))}catch{return t.map(()=>YTe)}finally{qD.batches+=1,qD.paths+=t.length,qD.ms+=performance.now()-n}}function HEt(){$Te=null;const e=[..._6.values()];_6.clear();for(const{scope:t,rels:n}of e){const r=[...n];for(let s=0;s<r.length;s+=xae){const o=r.slice(s,s+xae);XTe(t,o).then(i=>{o.forEach((l,c)=>{const u=BP(t,l);TU.delete(u),KTe(u,i[c])})})}}}function UEt(e,t){const n=BP(e,t);if(TU.has(n)||FEt(M6.get(n)))return;TU.add(n);const r=`${e.conversationId}\0${e.projectId}`,s=_6.get(r)??{scope:e,rels:new Set};s.rels.add(t),_6.set(r,s),$Te??=setTimeout(HEt,OEt)}function VEt(){H$+=1}async function QTe(e,t){const[n]=await XTe(e,[t]);return KTe(BP(e,t),n),n}function ZTe(e,t,n){const r=e&&t?BP(e,t):null,s=y.useCallback(i=>{if(!r)return()=>{};const l=rR.get(r)??new Set;return rR.set(r,l),l.add(i),()=>{l.delete(i),l.size===0&&rR.delete(r)}},[r]),o=y.useSyncExternalStore(s,()=>r?M6.get(r)?.state:void 0);return y.useEffect(()=>{n&&e&&t&&UEt(e,t)},[n,r]),o}const JTe=y.createContext({query:"",activeKey:"",activeNth:-1});function GEt(){return y.useContext(JTe)}const eAe="rounded-[2px] px-0.5 py-px",WEt=`${eAe} bg-yellow-300 text-foreground dark:bg-yellow-500/80`,qEt=`${eAe} bg-orange-600 text-white dark:bg-orange-500`;function tAe(e,t,n,r){const s=t.trim();if(!s)return e;const o=e.toLowerCase(),i=s.toLowerCase();let l=0,c=o.indexOf(i,l);if(c<0)return e;const u=[];for(;c>=0;){c>l&&u.push(e.slice(l,c));const d=r.n++;u.push(a.jsx("mark",{className:d===n?qEt:WEt,children:e.slice(c,c+s.length)},d)),l=c+s.length,c=o.indexOf(i,l)}return l<e.length&&u.push(e.slice(l)),u}function nAe(e,t,n,r){return e==null||typeof e=="boolean"?e:typeof e=="string"||typeof e=="number"?tAe(String(e),t,n,r):Array.isArray(e)?e.map((s,o)=>a.jsx(y.Fragment,{children:nAe(s,t,n,r)},o)):e}const YEt=2;function $Et({value:e}){return typeof e=="string"?a.jsx("span",{className:"text-emerald-700 dark:text-emerald-400",children:JSON.stringify(e)}):typeof e=="number"?a.jsx("span",{className:"text-sky-700 dark:text-sky-400",children:String(e)}):a.jsx("span",{className:"text-violet-700 dark:text-violet-400",children:String(e)})}function rAe({name:e,value:t,depth:n}){const[r,s]=y.useState(n<YEt),o=e!==void 0&&a.jsxs("span",{className:"text-foreground/80",children:[e,a.jsx("span",{className:"text-muted-foreground",children:": "})]});if(t===null||typeof t!="object")return a.jsxs("div",{className:"pl-4",children:[o,a.jsx($Et,{value:t})]});const i=Array.isArray(t),l=i?t.map((d,f)=>[String(f),d]):Object.entries(t),[c,u]=i?["[","]"]:["{","}"];return a.jsxs("div",{className:n>0?"pl-4":void 0,children:[a.jsxs("button",{type:"button","aria-expanded":r,onClick:()=>s(!r),className:"-ml-4 inline-flex items-center text-left hover:text-foreground",children:[a.jsx(Bs,{className:ve("h-3 w-3 shrink-0 transition-transform",r&&"rotate-90")}),a.jsxs("span",{className:"ml-1",children:[o,a.jsxs("span",{className:"text-muted-foreground",children:[c,!r&&` ${l.length} ${u}`]})]})]}),r&&a.jsxs(a.Fragment,{children:[l.map(([d,f])=>a.jsx(rAe,{name:i?void 0:d,value:f,depth:n+1},d)),a.jsx("div",{className:"text-muted-foreground",children:u})]})]})}function KEt({source:e,value:t}){const{t:n}=Se(),[r,s]=y.useState(!1),o=i=>ve("rounded px-1.5 py-0.5",i?"bg-muted text-foreground":"hover:text-foreground");return a.jsxs("div",{"data-enso":"json-tree",className:"group/code relative my-2 rounded-lg border",children:[a.jsxs("div",{className:"flex items-center gap-1 border-b px-2 py-1 text-[11px] text-muted-foreground",children:[a.jsx("span",{className:"mr-auto font-mono",children:"JSON"}),a.jsx("button",{type:"button",className:o(!r),onClick:()=>s(!1),children:n("Tree view")}),a.jsx("button",{type:"button",className:o(r),onClick:()=>s(!0),children:n("Raw text")}),a.jsx(px,{text:e,className:"rounded p-1"})]}),r?a.jsx("div",{className:"px-2",children:a.jsx(R6,{code:e,language:"json"})}):a.jsx("div",{className:"max-h-[480px] overflow-auto py-2 pr-3 pl-6 font-mono text-(length:--chat-code-block-size) leading-relaxed",children:a.jsx(rAe,{value:t,depth:0})})]})}function XEt(){return window.matchMedia("(prefers-color-scheme: dark)").matches}function U$(){const e=be(s=>s.theme),t=be(s=>s.terminalTheme),[n,r]=y.useState(XEt);return y.useEffect(()=>{const s=window.matchMedia("(prefers-color-scheme: dark)"),o=()=>r(s.matches);return o(),s.addEventListener("change",o),()=>s.removeEventListener("change",o)},[]),Xbe(e,{prefersDark:n,terminalIsDark:eye(t)})}function QEt(e){const t=U$();return y.useMemo(()=>({...e,themeType:t}),[e,t])}const ZEt="http://www.w3.org/2000/svg",JEt="http://www.w3.org/1999/xlink",sAe=/<svg\b(?:[^>"']|"[^"]*"|'[^']*')*>/i,P6=16384,eTt=P6*P6,tTt=2;function V$(e){return new RegExp(`\\s${e}\\s*=\\s*(?:"[^"]*"|'[^']*'|[^\\s"'>]+)`,"i")}function sR(e,t){const n=e.match(V$(t));return n?n[0].replace(/^[^=]*=\s*/,"").replace(/^["']|["']$/g,""):null}function aC(e,t,n){const r=` ${t}="${n}"`,s=V$(t);return s.test(e)?e.replace(s,r):e.replace(/\s*\/?>$/,o=>`${r}${o}`)}function oAe(e){const t=e.match(sAe)?.[0],n=t?sR(t,"viewBox"):null;if(!n)return null;const r=n.trim().split(/[\s,]+/).map(Number);if(r.length!==4)return null;const[,,s,o]=r;return Number.isFinite(s)&&Number.isFinite(o)&&s>0&&o>0?{width:s,height:o}:null}function G$(e){const t=e.match(sAe);if(!t)return e;let n=t[0];sR(n,"xmlns")||(n=aC(n,"xmlns",ZEt)),e.includes("xlink:")&&!sR(n,"xmlns:xlink")&&(n=aC(n,"xmlns:xlink",JEt));const r=oAe(e);if(r){n=aC(n,"width",String(r.width)),n=aC(n,"height",String(r.height));const s=sR(n,"style");if(s!==null){const o=s.split(";").filter(i=>i.trim()&&!/^\s*max-width\s*:/i.test(i)).join(";").trim();n=o?aC(n,"style",o):n.replace(V$("style"),"")}}return e.replace(t[0],()=>n)}function AU(e,t=new Date){const n=o=>String(o).padStart(2,"0"),r=`${t.getFullYear()}${n(t.getMonth()+1)}${n(t.getDate())}`,s=`${n(t.getHours())}${n(t.getMinutes())}${n(t.getSeconds())}`;return`mermaid-${r}-${s}.${e}`}function nTt(e,t){const n=Math.min(tTt,P6/e,P6/t,Math.sqrt(eTt/(e*t)));return n>=1?n:null}function iAe(e){return new Blob([G$(e)],{type:"image/svg+xml"})}function NU(e){return G$(new XMLSerializer().serializeToString(e))}function rTt(e){const t=new DOMParser().parseFromString(e,"text/html").querySelector("svg");if(!t)throw new Error("No svg in markup");return NU(t)}function bae(e,t){const n=typeof e=="string"?e:URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,r.click(),typeof e!="string"&&setTimeout(()=>URL.revokeObjectURL(n),0)}async function sTt(e,t,n,r,s){const o=new Image;o.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`,await o.decode();const i=document.createElement("canvas");i.width=Math.floor(t*r),i.height=Math.floor(n*r);const l=i.getContext("2d");if(!l)throw new Error("Canvas unavailable");l.fillStyle=s,l.fillRect(0,0,i.width,i.height),l.drawImage(o,0,0,i.width,i.height);const c=i.toDataURL("image/png");if(!c.startsWith("data:image/png"))throw new Error("Canvas export failed");return c}async function oTt(e){const t=o=>{try{const i=e.currentSvg();return i?(e.download(iAe(i),AU("svg")),{kind:"svg",reason:o}):{kind:"failed"}}catch{return{kind:"failed"}}};let n;try{n=G$(await e.rerender())}catch{return t("rerender-failed")}if(/<foreignObject\b/i.test(n))return t("rerender-failed");const r=oAe(n);if(!r)return t("draw-failed");const s=nTt(r.width,r.height);if(s===null)return t("too-large");try{const o=await e.rasterize(n,r.width,r.height,s);return e.download(o,AU("png")),{kind:"png"}}catch{return t("draw-failed")}}const iTt="position:fixed;left:0;top:0;width:800px;height:600px;overflow:hidden;opacity:0;pointer-events:none;visibility:hidden;contain:strict;";function aTt(e){return!e.includes("<svg")||/\bfocusable=/.test(e)?e:e.replace("<svg",'<svg focusable="false" tabindex="-1"')}function lTt(e){return{startOnLoad:!1,theme:e,securityLevel:"strict",fontFamily:"inherit",suppressErrorRendering:!0,flowchart:{htmlLabels:!1,useMaxWidth:!0}}}const cTt=/<(?:a|area)\b(?:[^>"']|"[^"]*"|'[^']*')*>/gi,uTt=/\s(?:xlink:)?(?:href|target)\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'>]+)/gi;function dTt(e){return e.replace(cTt,t=>t.replace(uTt,""))}let o3=null,i3=null,yae=Promise.resolve(),fTt=0;async function hTt(){return i3||(o3||(o3=Be(()=>import("./mermaid.core-tBzIgBPK.js").then(e=>e.cb),[],import.meta.url).then(e=>(i3=e.default,i3)).catch(e=>{throw o3=null,e})),o3)}function pTt(e){const t=yae.then(e,e);return yae=t.then(()=>{},()=>{}),t}async function wae(e,t,n={}){return pTt(async()=>{const r=await hTt();r.initialize({...lTt(t),...n});const s=`ensoMermaid${++fTt}`,o=document.createElement("div");o.setAttribute("aria-hidden","true"),o.style.cssText=iTt,document.body.appendChild(o);try{const{svg:i}=await r.render(s,e,o);return aTt(dTt(i))}finally{o.remove(),document.getElementById(s)?.remove(),document.getElementById(`d${s}`)?.remove()}})}const a3=.1,mTt={dark:"#1f2020",default:"#ffffff"},l3=.1;function gTt({code:e,streaming:t=!1,className:n}){const{t:r}=Se(),s=y.useRef(null),[o,i]=y.useState(null),[l,c]=y.useState(null),[u,d]=y.useState(1),[f,h]=y.useState({x:0,y:0}),[p,m]=y.useState(!1),[v,b]=y.useState(!1);_N(v);const x=y.useRef({x:0,y:0}),S=y.useRef({x:0,y:0}),k=y.useRef(null),C=y.useRef(!1),N=U$()==="dark"?"dark":"default";y.useEffect(()=>{if(t){i(null),c(null);return}let T=!1;return(async()=>{if(!e.trim()){i(null),c(null);return}try{const P=await wae(e,N);T||(i(P),c(null),d(1),h({x:0,y:0}))}catch(P){T||(c(P instanceof Error?P.message:"Mermaid render failed"),i(null))}})(),()=>{T=!0}},[e,N,t]);const j=y.useCallback(()=>d(T=>T+a3),[]),I=y.useCallback(()=>d(T=>Math.max(T-a3,l3)),[]),_=y.useCallback(()=>{d(1),h({x:0,y:0})},[]),L=y.useCallback(()=>{b(!1),d(1),h({x:0,y:0})},[]),M=y.useCallback(()=>{b(!0),requestAnimationFrame(()=>{const T=k.current,U=T?.firstElementChild;if(!T||!U?.offsetWidth||!U.offsetHeight)return;const P=24,K=Math.min((T.clientWidth-P*2)/U.offsetWidth,(T.clientHeight-P*2)/U.offsetHeight);d(Math.round(K*100)/100),h({x:0,y:0})})},[]),F=y.useCallback(T=>{if(!v)return;T.preventDefault();const U=T.deltaY>0?-a3:a3;d(P=>Math.round(Math.max(P+U,l3)*100)/100)},[v]),D=y.useCallback(T=>{!v||T.button!==0||(m(!0),C.current=!1,x.current={x:T.clientX,y:T.clientY},S.current={...f})},[v,f]),R=y.useCallback(T=>{if(!p)return;const U=T.clientX-x.current.x,P=T.clientY-x.current.y;(Math.abs(U)>2||Math.abs(P)>2)&&(C.current=!0),h({x:S.current.x+U,y:S.current.y+P})},[p]),z=y.useCallback(()=>m(!1),[]),B=y.useCallback(T=>{T.stopPropagation()},[]),H=y.useCallback(()=>{C.current||L()},[L]),G=y.useCallback(()=>{try{const T=s.current?.querySelector("svg");if(!T)throw new Error("No svg");bae(iAe(NU(T)),AU("svg"))}catch{Ht({type:"error",title:r("Export failed")})}},[r]),ne=y.useCallback(async()=>{const T=await oTt({currentSvg:()=>{const U=s.current?.querySelector("svg");return U?NU(U):null},rerender:async()=>rTt(await wae(e,N,{htmlLabels:!1})),rasterize:(U,P,K,J)=>sTt(U,P,K,J,mTt[N]),download:bae});T.kind==="failed"?Ht({type:"error",title:r("Export failed")}):T.kind==="svg"&&Ht({type:"warning",title:T.reason==="too-large"?r("Diagram is too large for PNG, exported SVG instead"):r("PNG export failed, exported SVG instead")})},[e,N,r]),W=T=>{const U=T==="sm"?"h-6 w-6":"h-7 w-7",P=T==="sm"?"h-3.5 w-3.5":"h-4 w-4",K=T==="sm"?"h-6 min-w-[2.5rem]":"h-7 min-w-[3rem]";return a.jsxs("div",{className:"flex items-center gap-1 rounded-md border border-border bg-background/95 p-1 shadow-sm",children:[a.jsx("button",{type:"button",onClick:j,className:ve("flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground",U),title:r("Zoom in"),children:a.jsx(xs,{className:P})}),a.jsxs("button",{type:"button",onClick:_,className:ve("flex items-center justify-center rounded text-xs transition-colors hover:bg-accent hover:text-accent-foreground",K),title:r("Reset zoom"),children:[Math.round(u*100),"%"]}),a.jsx("button",{type:"button",onClick:I,disabled:u<=l3,className:ve("flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground",U,u<=l3&&"cursor-not-allowed opacity-50"),title:r("Zoom out"),children:a.jsx(Txe,{className:P})}),u!==1&&a.jsx("button",{type:"button",onClick:_,className:ve("flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground",U),title:r("Fit to original size"),children:a.jsx($u,{className:P})}),a.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),a.jsx("button",{type:"button",onClick:G,className:ve("flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground",U),title:r("Export SVG"),children:a.jsx(Lf,{className:P})}),a.jsx("button",{type:"button",onClick:()=>{ne()},className:ve("flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground",U),title:r("Export PNG"),children:a.jsx(EHe,{className:P})}),v?a.jsx("button",{type:"button",onClick:L,className:ve("flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground",U),title:r("Exit fullscreen"),children:a.jsx(fUe,{className:P})}):a.jsx("button",{type:"button",onClick:M,className:ve("flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground",U),title:r("View fullscreen"),children:a.jsx(Exe,{className:P})})]})};return l?a.jsxs("div",{className:ve("overflow-x-auto rounded-lg border border-destructive/50",n),children:[a.jsx("div",{className:"flex items-center gap-2 border-b border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:a.jsx("span",{children:r("Mermaid render error")})}),a.jsx("pre",{className:"p-4 text-sm",children:a.jsx("code",{className:"block font-mono leading-relaxed text-muted-foreground",children:e})}),a.jsx("div",{className:"border-t border-border bg-muted/30 px-3 py-2 text-xs text-muted-foreground",children:l})]}):o?a.jsxs("div",{className:ve("relative rounded-lg border border-border bg-muted/30",n),style:{userSelect:"none",WebkitUserSelect:"none"},children:[a.jsx("div",{ref:s,className:ve("max-h-[min(50vh,20rem)] overflow-hidden [overflow-anchor:none]",v&&(p?"cursor-grabbing":"cursor-grab")),onWheel:F,onMouseDown:D,onMouseMove:R,onMouseUp:z,onMouseLeave:z,onDoubleClick:v?void 0:M,children:a.jsx("div",{className:"origin-center transition-transform duration-100 ease-out",style:{transform:`translate(${f.x}px, ${f.y}px) scale(${u})`},children:a.jsx("div",{className:"p-4",dangerouslySetInnerHTML:{__html:o}})})}),a.jsx("div",{className:"absolute right-2 bottom-2",children:W("sm")}),v&&a.jsxs("div",{className:"fixed inset-0 flex select-none flex-col bg-background",style:{zIndex:_r.TOAST},"data-enso-float":"",onClick:H,onKeyDown:T=>{T.key==="Escape"&&L()},children:[a.jsxs("div",{className:"relative z-10 flex shrink-0 items-center justify-between border-b border-border bg-muted/30 px-4 py-2",onClick:T=>T.stopPropagation(),onKeyDown:T=>T.stopPropagation(),children:[a.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:r("Mermaid preview")}),a.jsx("button",{type:"button",onClick:L,className:"flex h-7 w-7 items-center justify-center rounded-md border border-border bg-background/95 text-sm transition-colors hover:bg-accent hover:text-accent-foreground",title:r("Exit fullscreen"),children:a.jsx(Jr,{className:"h-4 w-4"})})]}),a.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[a.jsx("div",{ref:k,className:ve("flex min-h-0 flex-1 select-none overflow-hidden",p?"cursor-grabbing":"cursor-grab"),onWheel:F,onMouseDown:D,onMouseMove:R,onMouseUp:z,onMouseLeave:z,onClick:B,onKeyDown:B,children:a.jsx("div",{className:"m-auto origin-center transition-transform duration-100 ease-out",style:{transform:`translate(${f.x}px, ${f.y}px) scale(${u})`},children:a.jsx("div",{className:"p-4",dangerouslySetInnerHTML:{__html:o}})})}),a.jsx("div",{className:"absolute right-4 bottom-4",children:W("md")})]})]})]}):a.jsx("div",{className:ve("flex items-center justify-center rounded-lg border border-border bg-muted/30 p-8",n),children:a.jsx("div",{className:"text-sm text-muted-foreground",children:r("Loading Mermaid diagram...")})})}const vTt=/^[a-z][a-z\d+.-]*:/i,xTt=/^(?:https?|ircs?|mailto|xmpp):/i,bTt=/^(?:[a-z]:[\\/]|\\\\)/i;function yTt(e){const t=e?.trim();if(!t||!/^https?:\/\//i.test(t))return null;try{return new URL(t)}catch{return null}}function aAe(e){const t=/^(.*?):(\d+)(?:-\d+)?$/.exec(e);if(!t)return{path:e};const n=Number(t[2]);return n>0?{path:t[1],line:n}:{path:t[1]}}function wTt(e){try{return decodeURIComponent(e)}catch{return null}}function kTt(e){const t=e.search(/[?#]/);return t<0?e:e.slice(0,t)}function STt(e){try{const t=new URL(e);if(t.protocol!=="file:")return null;let n=decodeURIComponent(t.pathname);return n?(t.hostname&&t.hostname.toLowerCase()!=="localhost"?n=`//${t.hostname}${n}`:/^\/[a-z]:[\\/]/i.test(n)&&(n=n.slice(1)),n):null}catch{return null}}function kae(e){const t=e.trim();if(!t||t.startsWith("#")||t.startsWith("?"))return{kind:"external"};if(/^file:/i.test(t)){const r=STt(t);return r?{kind:"local",path:r}:{kind:"blocked"}}if(xTt.test(t)||t.startsWith("//"))return{kind:"external"};const n=wTt(kTt(t));return n==null||n.includes("\0")?{kind:"blocked"}:vTt.test(n)&&!bTt.test(n)?{kind:"blocked"}:{kind:"local",path:n}}function Kw(e){const t=e.replace(/\\/g,"/"),n=/^[a-z]:\//i.test(t)||t.startsWith("//");if(!n&&!t.startsWith("/"))return null;const r=/^[a-z]:\//i.test(t)?t.slice(0,2).toLowerCase():null,o=(r||n?t.slice(2):t.slice(1)).split("/"),i=[];for(const l of o)if(!(!l||l==="."))if(l===".."){if(i.length===0)return null;i.pop()}else i.push(l);return r?{value:`${r}/${i.join("/")}`.replace(/\/$/,""),windows:!0}:n?{value:`//${i.join("/")}`,windows:!0}:{value:`/${i.join("/")}`.replace(/\/$/,"")||"/",windows:!1}}function YD(e){const t=e.replace(/\\/g,"/"),n=[];for(const r of t.split("/"))if(!(!r||r==="."))if(r===".."){if(n.length===0)return null;n.pop()}else{if(r.includes("\0"))return null;n.push(r)}return n.join("/")}function ccn(e){return Kw(e)!==null}function r1(e,t){if(!t)return Kw(e)?null:YD(e);const n=Kw(t);if(!n)return null;const r=n.windows&&/^\/[a-z]:[\\/]/i.test(e)?e.slice(1):e,s=Kw(r);if(!s)return r===e?YD(e):null;if(s.windows!==n.windows)return null;const o=n.value.toLowerCase(),i=s.value.toLowerCase();if(i===o)return"";const l=n.value.endsWith("/")?n.value:`${n.value}/`;return i.startsWith(l.toLowerCase())?YD(s.value.slice(l.length)):null}function CTt(e,t){const n=t?Kw(t):null;if(!n||r1(e,t)!==null)return null;const r=n.windows&&/^\/[a-z]:[\\/]/i.test(e)?e.slice(1):e;return Kw(r)?r:null}const ETt=/^(?:%|ms|s|sec|min|h|ms\/op|ns|µs|us|b|kb|mb|gb|tb|kib|mib|gib|x|×|k|m|bn)$/i;function IU(e){let t=e.trim().replace(/^[$€£¥₹]\s*/,""),n=!1;/^\(.*\)$/.test(t)&&(n=!0,t=t.slice(1,-1));const r=/^([+-]?(?:\d{1,3}(?:,\d{3})+|\d+)(?:\.\d+)?)\s*(\S*)$/.exec(t);if(!r||r[2]&&!ETt.test(r[2]))return null;const s=Number(r[1].replace(/,/g,""));return n?-s:s}function TTt(e){const t=Math.max(0,...e.map(n=>n.length));return Array.from({length:t},(n,r)=>{const s=e.map(o=>o[r]?.trim()??"").filter(Boolean);return s.length>0&&s.every(o=>IU(o)!==null)})}function ATt(e,t,n){return n?(IU(e)??0)-(IU(t)??0):e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function NTt(e,t,n){const r=e.map((i,l)=>l);if(!t)return r;const s=t.dir==="asc"?1:-1,o=i=>e[i][t.column]?.trim()??"";return r.sort((i,l)=>{const c=o(i),u=o(l);return!c||!u?c?-1:u?1:0:s*ATt(c,u,n[t.column]??!1)||i-l})}function ITt(e,t){return e?.column!==t?{column:t,dir:"asc"}:e.dir==="asc"?{column:t,dir:"desc"}:null}const jTt=new Set(["json","jsonc","json5"]),RTt=new Set(["console","shell-session","terminal","output","ansi"]),MTt=new Set(["sh","bash","shell","zsh","shellscript"]),L6="$ ";function _Tt(e,t){const n=e?.toLowerCase();if(n&&jTt.has(n))return Sae(t)?"json":null;if(!n&&/^\s*[{[]/.test(t)&&Sae(t))return"json";if(n&&RTt.has(n)||t.includes("\x1B["))return"terminal";if(!n||MTt.has(n)){const r=t.split(`
326
+ \v\f…\u2028\u2029])`),t));else if(c==="posix")if(!s&&(d==="graph"||d==="print")){if(r==="strict")throw new Error(`POSIX class "${d}" requires min target ES2024 or non-strict accuracy`);let f={graph:"!-~",print:" -~"}[d];u&&(f=`\0-${cl(f.codePointAt(0)-1)}${cl(f.codePointAt(2)+1)}-􏿿`),n(wa(Gm(`[${f}]`),t))}else n(wa(GD(Gm(ZCt.get(d)),u),t));else if(c==="property")F$.has(LP(d))||(e.key="sc");else if(c==="space")n(rv(vw("space",{negate:u}),t));else if(c==="word")n(wa(GD(Gm(Vm),u),t));else throw new Error(`Unexpected character set kind "${c}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:s,removeAllPrevSiblings:o,removeAllNextSiblings:i}){const{kind:l,flags:c}=e;if(l==="flags")if(!c.enable&&!c.disable)r();else{const u=mh({flags:c});u.body[0].body=i(),s(wa(u,t),{traverse:!0})}else if(l==="keep"){const u=n.body[0],f=n.body.length===1&&TTe(u,{type:"Group"})&&u.body[0].body.length===1?u.body[0]:n;if(t.parent!==f||f.body.length>1)throw new Error(ps`Uses "\K" in a way that's unsupported`);const h=Mb({behind:!0});h.body[0].body=o(),s(wa(h,t))}else throw new Error(`Unexpected directive kind "${l}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw new Error('Unsupported flag "P"');if(e.textSegmentMode==="word")throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(n=>delete e[n]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;const{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){const{kind:n}=e;n==="lookbehind"&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){const{kind:r}=e;if(r==="fail")n(wa(Mb({negate:!0}),t));else throw new Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){const t=mh();t.body[0].body.push(e.body),e.body=wa(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){const n=[];let r=!1,s=!1;for(const o of e.body)if(o.body.length===1&&o.body[0].kind==="search_start")o.body.pop();else{const i=UTe(o.body);i?(r=!0,Array.isArray(i)?n.push(...i):n.push(i)):s=!0}r&&!s&&n.forEach(o=>t.add(o))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t==="strict"&&n&&r)throw new Error(ps`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!VD(n)&&(n=UD(n,t),e.ref=n)}},nEt={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){const{orphan:r,ref:s}=e;r||n.set(e,[...t.get(s).map(({node:o})=>o)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:s,groupsByName:o,multiplexCapturesToLeftByRef:i,openRefs:l,reffedNodesByReferencer:c}){const u=s.get(e);if(u&&l.has(e.number)){const f=rv(fae(e.number),t);c.set(f,l.get(e.number)),n(f);return}l.set(e.number,e),i.set(e.number,[]),e.name&&ZT(i,e.name,[]);const d=i.get(e.name??e.number);for(let f=0;f<d.length;f++){const h=d[f];if(u===h.node||u&&u===h.origin||e===h.origin){d.splice(f,1);break}}if(i.get(e.number).push({node:e,origin:u}),e.name&&i.get(e.name).push({node:e,origin:u}),e.name){const f=ZT(o,e.name,new Map);let h=!1;if(u)h=!0;else for(const p of f.values())if(!p.hasDuplicateNameToRemove){h=!0;break}o.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:h})}},exit({node:e},{openRefs:t}){t.get(e.number)===e&&t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=j6(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){const{isRecursive:s,ref:o}=e;if(s){let d=t;for(;(d=d.parent)&&!(d.type==="CapturingGroup"&&(d.name===o||d.number===o)););r.reffedNodesByReferencer.set(e,d);return}const i=r.subroutineRefMap.get(o),l=o===0,c=l?fae(0):FTe(i,r.groupOriginByCopy,null);let u=c;if(!l){const d=zTe(iEt(i,h=>h.type==="Group"&&!!h.flags)),f=d?j6(r.globalFlags,d):r.globalFlags;sEt(f,r.currentFlags)||(u=mh({flags:aEt(f)}),u.body[0].body.push(c))}n(wa(u,t),{traverse:!l})}},rEt={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}const o=r.reffedNodesByReferencer.get(e).filter(i=>oEt(i,e));if(!o.length)n(wa(Mb({negate:!0}),t));else if(o.length>1){const i=mh({atomic:!0,body:o.reverse().map(l=>Cy({body:[wU(l.number)]}))});n(wa(i,t))}else e.ref=o[0].number},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){const n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let r=0;r<n;r++){const s=NTe();e.body.at(-1).body.push(s)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function BTe(e){GE(e,{"*"({node:t,parent:n}){t.parent=n}})}function sEt(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function oEt(e,t){let n=t;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===e)return!1;const r=HTe(n.parent);for(const s of r){if(s===n)break;if(s===e||VTe(s,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function FTe(e,t,n,r){const s=Array.isArray(e)?[]:{};for(const[o,i]of Object.entries(e))o==="parent"?s.parent=Array.isArray(n)?r:n:i&&typeof i=="object"?s[o]=FTe(i,t,s,n):(o==="type"&&i==="CapturingGroup"&&t.set(s,t.get(e)??e),s[o]=i);return s}function fae(e){const t=jTe(e);return t.isRecursive=!0,t}function iEt(e,t){const n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function UD(e,t){if(t.has(e))return t.get(e);const n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug,"_")}`;return t.set(e,n),n}function zTe(e){const t=["dotAll","ignoreCase"],n={enable:{},disable:{}};return e.forEach(({flags:r})=>{t.forEach(s=>{r.enable?.[s]&&(delete n.disable[s],n.enable[s]=!0),r.disable?.[s]&&(n.disable[s]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function aEt({dotAll:e,ignoreCase:t}){const n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function HTe(e){if(!e)throw new Error("Node expected");const{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function UTe(e){const t=e.find(n=>n.kind==="search_start"||uEt(n,{negate:!1})||!lEt(n));if(!t)return null;if(t.kind==="search_start")return t;if(t.type==="LookaroundAssertion")return t.body[0].body[0];if(t.type==="CapturingGroup"||t.type==="Group"){const n=[];for(const r of t.body){const s=UTe(r.body);if(!s)return null;Array.isArray(s)?n.push(...s):n.push(s)}return n}return null}function VTe(e,t){const n=HTe(e)??[];for(const r of n)if(r===t||VTe(r,t))return!0;return!1}function lEt({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function cEt(e){const t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function uEt(e,t){const n={negate:null,...t};return e.type==="LookaroundAssertion"&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&TTe(e.body[0],{type:"Assertion",kind:"search_start"})}function VD(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function Gm(e,t){const r=ATe(e,{...t,unicodePropertyMap:F$}).body;return r.length>1||r[0].body.length>1?mh({body:r}):r[0].body[0]}function GD(e,t){return e.negate=t,e}function rv(e,t){return e.parent=t,e}function wa(e,t){return BTe(e),e.parent=t,e}function dEt(e,t){const n=LTe(t),r=CU(n.target,"ES2024"),s=CU(n.target,"ES2025"),o=n.rules.recursionLimit;if(!Number.isInteger(o)||o<2||o>20)throw new Error("Invalid recursionLimit; use 2-20");let i=null,l=null;if(!s){const p=[e.flags.ignoreCase];GE(e,fEt,{getCurrentModI:()=>p.at(-1),popModI(){p.pop()},pushModI(m){p.push(m)},setHasCasedChar(){p.at(-1)?i=!0:l=!0}})}const c={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||i)&&!l)};let u=e;const d={accuracy:n.accuracy,appliedGlobalFlags:c,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:u,originMap:e._originMap,recursionLimit:o,useAppliedIgnoreCase:!!(!s&&i&&l),useFlagMods:s,useFlagV:r,verbose:n.verbose};function f(p){return d.lastNode=u,u=p,WCt(hEt[p.type],`Unexpected node type "${p.type}"`)(p,d,f)}const h={pattern:e.body.map(f).join("|"),flags:f(e.flags),options:{...e.options}};return r||(delete h.options.force.v,h.options.disable.v=!0,h.options.unicodeSetsPlugin=null),h._captureTransfers=new Map,h._hiddenCaptures=[],d.captureMap.forEach((p,m)=>{p.hidden&&h._hiddenCaptures.push(m),p.transferTo&&ZT(h._captureTransfers,p.transferTo,[]).push(m)}),h}var fEt={"*":{enter({node:e},t){if(pae(e)){const n=t.getCurrentModI();t.pushModI(e.flags?j6({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){pae(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){z$(cl(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),GTe(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind==="property"&&DTe.has(e.value)&&t.setHasCasedChar()}},hEt={Alternative({body:e},t,n){return e.map(n).join("")},Assertion({kind:e,negate:t}){if(e==="string_end")return"$";if(e==="string_start")return"^";if(e==="word_boundary")return t?ps`\B`:ps`\b`;throw new Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!="number")throw new Error("Unexpected named backref in transformed AST");if(!t.useFlagMods&&t.accuracy==="strict"&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e},CapturingGroup(e,t,n){const{body:r,name:s,number:o}=e,i={ignoreCase:t.currentFlags.ignoreCase},l=t.originMap.get(e);return l&&(i.hidden=!0,o>l.number&&(i.transferTo=l.number)),t.captureMap.set(o,i),`(${s?`?<${s}>`:""}${r.map(n).join("|")})`},Character({value:e},t){const n=cl(e),r=G1(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&z$(n)){const s=OTe(n);return t.inCharClass?s.join(""):s.length>1?`[${s.join("")}]`:s[0]}return n},CharacterClass(e,t,n){const{kind:r,negate:s,parent:o}=e;let{body:i}=e;if(r==="intersection"&&!t.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");Sh.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&i.some(mae)&&(i=[PP(45),...i.filter(u=>!mae(u))]);const l=()=>`[${s?"^":""}${i.map(n).join(r==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||Sh.bugNestedClassIgnoresNegation)&&!s){const d=i.filter(f=>f.type==="CharacterClass"&&f.kind==="union"&&f.negate);if(d.length){const f=mh(),h=f.body[0];return f.parent=o,h.parent=f,i=i.filter(p=>!d.includes(p)),e.body=i,i.length?(e.parent=h,h.body.push(e)):f.body.pop(),d.forEach(p=>{const m=Cy({body:[p]});p.parent=m,m.parent=f,f.body.push(m)}),n(f)}}t.inCharClass=!0;const u=l();return t.inCharClass=!1,u}const c=i[0];if(r==="union"&&!s&&c&&((!t.useFlagV||!t.verbose)&&o.kind==="union"&&!(Sh.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&o.kind==="intersection"&&i.length===1&&c.type!=="CharacterClassRange"))return i.map(n).join("");if(!t.useFlagV&&o.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return l()},CharacterClassRange(e,t){const n=e.min.value,r=e.max.value,s={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},o=G1(n,s),i=G1(r,s),l=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){const c=GTe(e);xEt(c).forEach(d=>{l.add(Array.isArray(d)?`${G1(d[0],s)}-${G1(d[1],s)}`:G1(d,s))})}return`${o}-${i}${[...l].join("")}`},CharacterSet({kind:e,negate:t,value:n,key:r},s){if(e==="dot")return s.currentFlags.dotAll?s.appliedGlobalFlags.dotAll||s.useFlagMods?".":"[^]":ps`[^\n]`;if(e==="digit")return t?ps`\D`:ps`\d`;if(e==="property"){if(s.useAppliedIgnoreCase&&s.currentFlags.ignoreCase&&DTe.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?ps`\P`:ps`\p`}{${r?`${r}=`:""}${n}}`}if(e==="word")return t?ps`\W`:ps`\w`;throw new Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":"")},Group({atomic:e,body:t,flags:n,parent:r},s,o){const i=s.currentFlags;n&&(s.currentFlags=j6(i,n));const l=t.map(o).join("|"),c=!s.verbose&&t.length===1&&r.type!=="Quantifier"&&!e&&(!s.useFlagMods||!n)?l:`(?${bEt(e,n,s.useFlagMods)}${l})`;return s.currentFlags=i,c},LookaroundAssertion({body:e,kind:t,negate:n},r,s){return`(?${`${t==="lookahead"?"":"<"}${n?"!":"="}`}${e.map(s).join("|")})`},Quantifier(e,t,n){return n(e.body)+yEt(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw new Error("Unexpected non-recursive subroutine in transformed AST");const r=n.recursionLimit;return t===0?`(?R=${r})`:ps`\g<${t}&R=${r}>`}},pEt=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),mEt=new Set(["-","\\","]","^","["]),gEt=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),hae=new Map([[9,ps`\t`],[10,ps`\n`],[11,ps`\v`],[12,ps`\f`],[13,ps`\r`],[8232,ps`\u2028`],[8233,ps`\u2029`],[65279,ps`\uFEFF`]]),vEt=new RegExp("^\\p{Cased}$","u");function z$(e){return vEt.test(e)}function GTe(e,t){const n=!!t?.firstOnly,r=e.min.value,s=e.max.value,o=[];if(r<65&&(s===65535||s>=131071)||r===65536&&s>=131071)return o;for(let i=r;i<=s;i++){const l=cl(i);if(!z$(l))continue;const c=OTe(l).filter(u=>{const d=u.codePointAt(0);return d<r||d>s});if(c.length&&(o.push(...c),n))break}return o}function G1(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(hae.has(e))return hae.get(e);if(e<32||e>126&&e<160||e>262143||t&&wEt(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;const s=n?r?gEt:mEt:pEt,o=cl(e);return(s.has(o)?"\\":"")+o}function xEt(e){const t=e.map(s=>s.codePointAt(0)).sort((s,o)=>s-o),n=[];let r=null;for(let s=0;s<t.length;s++)t[s+1]===t[s]+1?r??=t[s]:r===null?n.push(t[s]):(n.push([r,t[s]]),r=null);return n}function bEt(e,t,n){if(e)return">";let r="";if(t&&n){const{enable:s,disable:o}=t;r=(s?.ignoreCase?"i":"")+(s?.dotAll?"s":"")+(o?"-":"")+(o?.ignoreCase?"i":"")+(o?.dotAll?"s":"")}return`${r}:`}function yEt({kind:e,max:t,min:n}){let r;return!n&&t===1?r="?":!n&&t===1/0?r="*":n===1&&t===1/0?r="+":n===t?r=`{${n}}`:r=`{${n},${t===1/0?"":t}}`,r+{greedy:"",lazy:"?",possessive:"+"}[e]}function pae({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function wEt(e){return e>47&&e<58}function mae({type:e,value:t}){return e==="Character"&&t===45}var kEt=class EU extends RegExp{#t=new Map;#e=null;#s;#n=null;#i=null;rawOptions={};get source(){return this.#s||"(?:)"}constructor(t,n,r){const s=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw new Error("Cannot provide options when copying a regexp");const o=t;super(o,n),this.#s=o.source,o instanceof EU&&(this.#t=o.#t,this.#n=o.#n,this.#i=o.#i,this.rawOptions=o.rawOptions)}else{const o={hiddenCaptures:[],strategy:null,transfers:[],...r};super(s?"":t,n),this.#s=t,this.#t=CEt(o.hiddenCaptures,o.transfers),this.#i=o.strategy,this.rawOptions=r??{}}s||(this.#e=this)}exec(t){if(!this.#e){const{lazyCompile:s,...o}=this.rawOptions;this.#e=new EU(this.#s,this.flags,o)}const n=this.global||this.sticky,r=this.lastIndex;if(this.#i==="clip_search"&&n&&r){this.lastIndex=0;const s=this.#l(t.slice(r));return s&&(SEt(s,r,t,this.hasIndices),this.lastIndex+=r),s}return this.#l(t)}#l(t){this.#e.lastIndex=this.lastIndex;const n=super.exec.call(this.#e,t);if(this.lastIndex=this.#e.lastIndex,!n||!this.#t.size)return n;const r=[...n];n.length=1;let s;this.hasIndices&&(s=[...n.indices],n.indices.length=1);const o=[0];for(let i=1;i<r.length;i++){const{hidden:l,transferTo:c}=this.#t.get(i)??{};if(l?o.push(null):(o.push(n.length),n.push(r[i]),this.hasIndices&&n.indices.push(s[i])),c&&r[i]!==void 0){const u=o[c];if(!u)throw new Error(`Invalid capture transfer to "${u}"`);if(n[u]=r[i],this.hasIndices&&(n.indices[u]=s[i]),n.groups){this.#n||(this.#n=EEt(this.source));const d=this.#n.get(c);d&&(n.groups[d]=r[i],this.hasIndices&&(n.indices.groups[d]=s[i]))}}}return n}};function SEt(e,t,n,r){if(e.index+=t,e.input=n,r){const s=e.indices;for(let i=0;i<s.length;i++){const l=s[i];l&&(s[i]=[l[0]+t,l[1]+t])}const o=s.groups;o&&Object.keys(o).forEach(i=>{const l=o[i];l&&(o[i]=[l[0]+t,l[1]+t])})}}function CEt(e,t){const n=new Map;for(const r of e)n.set(r,{hidden:!0});for(const[r,s]of t)for(const o of s)ZT(n,o,{}).transferTo=r;return n}function EEt(e){const t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map;let r=0,s=0,o;for(;o=t.exec(e);){const{0:i,groups:{capture:l,name:c}}=o;i==="["?r++:r?i==="]"&&r--:l&&(s++,c&&n.set(s,c))}return n}function TEt(e,t){const n=AEt(e,t);return n.options?new kEt(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function AEt(e,t){const n=LTe(t),r=ATe(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:F$}),s=eEt(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),o=dEt(s,n),i=VCt(o.pattern,{captureTransfers:o._captureTransfers,hiddenCaptures:o._hiddenCaptures,mode:"external"}),l=HCt(i.pattern),c=zCt(l.pattern,{captureTransfers:i.captureTransfers,hiddenCaptures:i.hiddenCaptures}),u={pattern:c.pattern,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${o.flags}${o.options.disable.v?"u":"v"}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{const d=c.hiddenCaptures.sort((m,v)=>m-v),f=Array.from(c.captureTransfers),h=s._strategy,p=u.pattern.length>=n.lazyCompileLength;(d.length||f.length||h||p)&&(u.options={...d.length&&{hiddenCaptures:d},...f.length&&{transfers:f},...h&&{strategy:h},...p&&{lazyCompile:p}})}return u}function NEt(e,t){return TEt(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function WTe(e={}){const t={target:"auto",cache:new Map,...e};return t.regexConstructor||=n=>NEt(n,{target:t.target}),{createScanner(n){return new GSt(n,t)},createString(n){return{content:n}}}}const IEt=["markdown","typescript","tsx","javascript","jsx","json","css","html","html-derivative","python","rust","go","shellscript","yaml"];let gae=null;function jEt(){return gae??=yTe({themes:["github-dark","github-light"],langs:[...IEt],engine:WTe()}),gae}const REt=200,MEt=20*1024*1024,Cp=new Map;let WD=0;function _Et(e){const t=Cp.get(e);return t!==void 0&&(Cp.delete(e),Cp.set(e,t)),t}function PEt(e,t){if(!Cp.has(e))for(Cp.set(e,t),WD+=t.length*2;(Cp.size>REt||WD>MEt)&&Cp.size>0;){const n=Cp.keys().next().value;WD-=(Cp.get(n)?.length??0)*2,Cp.delete(n)}}async function qTe(e,t,n=!0){const r=`${t}\0${e}`;if(n){const s=_Et(r);if(s!==void 0)return s}try{const s=await jEt(),o=s.getLoadedLanguages().includes(t)?t:"text",i=s.codeToHtml(e,{lang:o,themes:{light:"github-light",dark:"github-dark"},defaultColor:"light"});return n&&PEt(r,i),i}catch(s){return console.error("snippet highlight failed:",s),null}}const vae="my-2 overflow-x-auto rounded-lg border bg-[var(--sunken,var(--muted))] text-(length:--chat-code-block-size) [font-weight:var(--chat-code-block-weight)] leading-relaxed";function LEt(e){const t=e.trimStart();return/^<[a-zA-Z!/]/.test(t)?"html":/^[{[]/.test(t)?"json":/^[$#] /.test(t)?"shellscript":"text"}function R6({code:e,language:t,streaming:n=!1}){const[r,s]=y.useState(null);y.useEffect(()=>{if(n){s(null);return}let i=!0;return qTe(e,t??LEt(e),!0).then(l=>{i&&s(l)}),()=>{i=!1}},[e,t,n]);const o=!n&&a.jsx(px,{text:e,className:"absolute top-1.5 right-1.5 rounded-md border bg-background/80 p-1.5 text-muted-foreground opacity-0 backdrop-blur transition-opacity group-hover/code:opacity-100"});return r==null?a.jsxs("div",{"data-enso":"code-block","data-language":t,className:"group/code relative",children:[a.jsx("pre",{className:`${vae} p-3 font-mono`,children:a.jsx("code",{children:e})}),o]}):a.jsxs("div",{"data-enso":"code-block","data-language":t,className:"group/code relative",children:[a.jsx("div",{className:`${vae} [&_pre]:m-0 [&_pre]:overflow-x-auto [&_pre]:bg-transparent! [&_pre]:p-3 [&_pre]:font-mono [&_pre]:[--shiki-dark-bg:transparent]!`,dangerouslySetInnerHTML:{__html:r}}),o]})}const OEt=50,xae=200,DEt=3e4,YTe={status:"missing"},M6=new Map,rR=new Map,TU=new Set,_6=new Map;let $Te=null,H$=0;const qD={batches:0,paths:0,ms:0},BEt=e=>e.cwd??`conversation:${e.conversationId}`,BP=(e,t)=>`${BEt(e)}\0${t}`;function FEt(e){return e?e.state.status==="ok"?e.epoch===H$:Date.now()-e.at<DEt:!1}function KTe(e,t){const n=M6.get(e)?.state,r=n?.status===t.status&&(t.status==="missing"||n.status==="ok"&&n.rel===t.rel&&n.kind===t.kind);if(M6.set(e,{state:r&&n?n:t,epoch:H$,at:Date.now()}),!r)for(const s of rR.get(e)??[])s()}function zEt(e){return e?{status:"ok",rel:e.rel,kind:e.kind}:YTe}async function XTe(e,t){const n=performance.now();try{const r=await window.electronAPI.workspaceFiles.resolveLinks({conversationId:e.conversationId,projectId:e.projectId,rels:t});return t.map((s,o)=>zEt(r.ok?r.items[o]:null))}catch{return t.map(()=>YTe)}finally{qD.batches+=1,qD.paths+=t.length,qD.ms+=performance.now()-n}}function HEt(){$Te=null;const e=[..._6.values()];_6.clear();for(const{scope:t,rels:n}of e){const r=[...n];for(let s=0;s<r.length;s+=xae){const o=r.slice(s,s+xae);XTe(t,o).then(i=>{o.forEach((l,c)=>{const u=BP(t,l);TU.delete(u),KTe(u,i[c])})})}}}function UEt(e,t){const n=BP(e,t);if(TU.has(n)||FEt(M6.get(n)))return;TU.add(n);const r=`${e.conversationId}\0${e.projectId}`,s=_6.get(r)??{scope:e,rels:new Set};s.rels.add(t),_6.set(r,s),$Te??=setTimeout(HEt,OEt)}function VEt(){H$+=1}async function QTe(e,t){const[n]=await XTe(e,[t]);return KTe(BP(e,t),n),n}function ZTe(e,t,n){const r=e&&t?BP(e,t):null,s=y.useCallback(i=>{if(!r)return()=>{};const l=rR.get(r)??new Set;return rR.set(r,l),l.add(i),()=>{l.delete(i),l.size===0&&rR.delete(r)}},[r]),o=y.useSyncExternalStore(s,()=>r?M6.get(r)?.state:void 0);return y.useEffect(()=>{n&&e&&t&&UEt(e,t)},[n,r]),o}const JTe=y.createContext({query:"",activeKey:"",activeNth:-1});function GEt(){return y.useContext(JTe)}const eAe="rounded-[2px] px-0.5 py-px",WEt=`${eAe} bg-yellow-300 text-foreground dark:bg-yellow-500/80`,qEt=`${eAe} bg-orange-600 text-white dark:bg-orange-500`;function tAe(e,t,n,r){const s=t.trim();if(!s)return e;const o=e.toLowerCase(),i=s.toLowerCase();let l=0,c=o.indexOf(i,l);if(c<0)return e;const u=[];for(;c>=0;){c>l&&u.push(e.slice(l,c));const d=r.n++;u.push(a.jsx("mark",{className:d===n?qEt:WEt,children:e.slice(c,c+s.length)},d)),l=c+s.length,c=o.indexOf(i,l)}return l<e.length&&u.push(e.slice(l)),u}function nAe(e,t,n,r){return e==null||typeof e=="boolean"?e:typeof e=="string"||typeof e=="number"?tAe(String(e),t,n,r):Array.isArray(e)?e.map((s,o)=>a.jsx(y.Fragment,{children:nAe(s,t,n,r)},o)):e}const YEt=2;function $Et({value:e}){return typeof e=="string"?a.jsx("span",{className:"text-emerald-700 dark:text-emerald-400",children:JSON.stringify(e)}):typeof e=="number"?a.jsx("span",{className:"text-sky-700 dark:text-sky-400",children:String(e)}):a.jsx("span",{className:"text-violet-700 dark:text-violet-400",children:String(e)})}function rAe({name:e,value:t,depth:n}){const[r,s]=y.useState(n<YEt),o=e!==void 0&&a.jsxs("span",{className:"text-foreground/80",children:[e,a.jsx("span",{className:"text-muted-foreground",children:": "})]});if(t===null||typeof t!="object")return a.jsxs("div",{className:"pl-4",children:[o,a.jsx($Et,{value:t})]});const i=Array.isArray(t),l=i?t.map((d,f)=>[String(f),d]):Object.entries(t),[c,u]=i?["[","]"]:["{","}"];return a.jsxs("div",{className:n>0?"pl-4":void 0,children:[a.jsxs("button",{type:"button","aria-expanded":r,onClick:()=>s(!r),className:"-ml-4 inline-flex items-center text-left hover:text-foreground",children:[a.jsx(Bs,{className:ve("h-3 w-3 shrink-0 transition-transform",r&&"rotate-90")}),a.jsxs("span",{className:"ml-1",children:[o,a.jsxs("span",{className:"text-muted-foreground",children:[c,!r&&` ${l.length} ${u}`]})]})]}),r&&a.jsxs(a.Fragment,{children:[l.map(([d,f])=>a.jsx(rAe,{name:i?void 0:d,value:f,depth:n+1},d)),a.jsx("div",{className:"text-muted-foreground",children:u})]})]})}function KEt({source:e,value:t}){const{t:n}=Se(),[r,s]=y.useState(!1),o=i=>ve("rounded px-1.5 py-0.5",i?"bg-muted text-foreground":"hover:text-foreground");return a.jsxs("div",{"data-enso":"json-tree",className:"group/code relative my-2 rounded-lg border",children:[a.jsxs("div",{className:"flex items-center gap-1 border-b px-2 py-1 text-[11px] text-muted-foreground",children:[a.jsx("span",{className:"mr-auto font-mono",children:"JSON"}),a.jsx("button",{type:"button",className:o(!r),onClick:()=>s(!1),children:n("Tree view")}),a.jsx("button",{type:"button",className:o(r),onClick:()=>s(!0),children:n("Raw text")}),a.jsx(px,{text:e,className:"rounded p-1"})]}),r?a.jsx("div",{className:"px-2",children:a.jsx(R6,{code:e,language:"json"})}):a.jsx("div",{className:"max-h-[480px] overflow-auto py-2 pr-3 pl-6 font-mono text-(length:--chat-code-block-size) leading-relaxed",children:a.jsx(rAe,{value:t,depth:0})})]})}function XEt(){return window.matchMedia("(prefers-color-scheme: dark)").matches}function U$(){const e=be(s=>s.theme),t=be(s=>s.terminalTheme),[n,r]=y.useState(XEt);return y.useEffect(()=>{const s=window.matchMedia("(prefers-color-scheme: dark)"),o=()=>r(s.matches);return o(),s.addEventListener("change",o),()=>s.removeEventListener("change",o)},[]),Xbe(e,{prefersDark:n,terminalIsDark:eye(t)})}function QEt(e){const t=U$();return y.useMemo(()=>({...e,themeType:t}),[e,t])}const ZEt="http://www.w3.org/2000/svg",JEt="http://www.w3.org/1999/xlink",sAe=/<svg\b(?:[^>"']|"[^"]*"|'[^']*')*>/i,P6=16384,eTt=P6*P6,tTt=2;function V$(e){return new RegExp(`\\s${e}\\s*=\\s*(?:"[^"]*"|'[^']*'|[^\\s"'>]+)`,"i")}function sR(e,t){const n=e.match(V$(t));return n?n[0].replace(/^[^=]*=\s*/,"").replace(/^["']|["']$/g,""):null}function aC(e,t,n){const r=` ${t}="${n}"`,s=V$(t);return s.test(e)?e.replace(s,r):e.replace(/\s*\/?>$/,o=>`${r}${o}`)}function oAe(e){const t=e.match(sAe)?.[0],n=t?sR(t,"viewBox"):null;if(!n)return null;const r=n.trim().split(/[\s,]+/).map(Number);if(r.length!==4)return null;const[,,s,o]=r;return Number.isFinite(s)&&Number.isFinite(o)&&s>0&&o>0?{width:s,height:o}:null}function G$(e){const t=e.match(sAe);if(!t)return e;let n=t[0];sR(n,"xmlns")||(n=aC(n,"xmlns",ZEt)),e.includes("xlink:")&&!sR(n,"xmlns:xlink")&&(n=aC(n,"xmlns:xlink",JEt));const r=oAe(e);if(r){n=aC(n,"width",String(r.width)),n=aC(n,"height",String(r.height));const s=sR(n,"style");if(s!==null){const o=s.split(";").filter(i=>i.trim()&&!/^\s*max-width\s*:/i.test(i)).join(";").trim();n=o?aC(n,"style",o):n.replace(V$("style"),"")}}return e.replace(t[0],()=>n)}function AU(e,t=new Date){const n=o=>String(o).padStart(2,"0"),r=`${t.getFullYear()}${n(t.getMonth()+1)}${n(t.getDate())}`,s=`${n(t.getHours())}${n(t.getMinutes())}${n(t.getSeconds())}`;return`mermaid-${r}-${s}.${e}`}function nTt(e,t){const n=Math.min(tTt,P6/e,P6/t,Math.sqrt(eTt/(e*t)));return n>=1?n:null}function iAe(e){return new Blob([G$(e)],{type:"image/svg+xml"})}function NU(e){return G$(new XMLSerializer().serializeToString(e))}function rTt(e){const t=new DOMParser().parseFromString(e,"text/html").querySelector("svg");if(!t)throw new Error("No svg in markup");return NU(t)}function bae(e,t){const n=typeof e=="string"?e:URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,r.click(),typeof e!="string"&&setTimeout(()=>URL.revokeObjectURL(n),0)}async function sTt(e,t,n,r,s){const o=new Image;o.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`,await o.decode();const i=document.createElement("canvas");i.width=Math.floor(t*r),i.height=Math.floor(n*r);const l=i.getContext("2d");if(!l)throw new Error("Canvas unavailable");l.fillStyle=s,l.fillRect(0,0,i.width,i.height),l.drawImage(o,0,0,i.width,i.height);const c=i.toDataURL("image/png");if(!c.startsWith("data:image/png"))throw new Error("Canvas export failed");return c}async function oTt(e){const t=o=>{try{const i=e.currentSvg();return i?(e.download(iAe(i),AU("svg")),{kind:"svg",reason:o}):{kind:"failed"}}catch{return{kind:"failed"}}};let n;try{n=G$(await e.rerender())}catch{return t("rerender-failed")}if(/<foreignObject\b/i.test(n))return t("rerender-failed");const r=oAe(n);if(!r)return t("draw-failed");const s=nTt(r.width,r.height);if(s===null)return t("too-large");try{const o=await e.rasterize(n,r.width,r.height,s);return e.download(o,AU("png")),{kind:"png"}}catch{return t("draw-failed")}}const iTt="position:fixed;left:0;top:0;width:800px;height:600px;overflow:hidden;opacity:0;pointer-events:none;visibility:hidden;contain:strict;";function aTt(e){return!e.includes("<svg")||/\bfocusable=/.test(e)?e:e.replace("<svg",'<svg focusable="false" tabindex="-1"')}function lTt(e){return{startOnLoad:!1,theme:e,securityLevel:"strict",fontFamily:"inherit",suppressErrorRendering:!0,flowchart:{htmlLabels:!1,useMaxWidth:!0}}}const cTt=/<(?:a|area)\b(?:[^>"']|"[^"]*"|'[^']*')*>/gi,uTt=/\s(?:xlink:)?(?:href|target)\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'>]+)/gi;function dTt(e){return e.replace(cTt,t=>t.replace(uTt,""))}let o3=null,i3=null,yae=Promise.resolve(),fTt=0;async function hTt(){return i3||(o3||(o3=Be(()=>import("./mermaid.core-CSXvmdq9.js").then(e=>e.cb),[],import.meta.url).then(e=>(i3=e.default,i3)).catch(e=>{throw o3=null,e})),o3)}function pTt(e){const t=yae.then(e,e);return yae=t.then(()=>{},()=>{}),t}async function wae(e,t,n={}){return pTt(async()=>{const r=await hTt();r.initialize({...lTt(t),...n});const s=`ensoMermaid${++fTt}`,o=document.createElement("div");o.setAttribute("aria-hidden","true"),o.style.cssText=iTt,document.body.appendChild(o);try{const{svg:i}=await r.render(s,e,o);return aTt(dTt(i))}finally{o.remove(),document.getElementById(s)?.remove(),document.getElementById(`d${s}`)?.remove()}})}const a3=.1,mTt={dark:"#1f2020",default:"#ffffff"},l3=.1;function gTt({code:e,streaming:t=!1,className:n}){const{t:r}=Se(),s=y.useRef(null),[o,i]=y.useState(null),[l,c]=y.useState(null),[u,d]=y.useState(1),[f,h]=y.useState({x:0,y:0}),[p,m]=y.useState(!1),[v,b]=y.useState(!1);_N(v);const x=y.useRef({x:0,y:0}),S=y.useRef({x:0,y:0}),k=y.useRef(null),C=y.useRef(!1),N=U$()==="dark"?"dark":"default";y.useEffect(()=>{if(t){i(null),c(null);return}let T=!1;return(async()=>{if(!e.trim()){i(null),c(null);return}try{const P=await wae(e,N);T||(i(P),c(null),d(1),h({x:0,y:0}))}catch(P){T||(c(P instanceof Error?P.message:"Mermaid render failed"),i(null))}})(),()=>{T=!0}},[e,N,t]);const j=y.useCallback(()=>d(T=>T+a3),[]),I=y.useCallback(()=>d(T=>Math.max(T-a3,l3)),[]),_=y.useCallback(()=>{d(1),h({x:0,y:0})},[]),L=y.useCallback(()=>{b(!1),d(1),h({x:0,y:0})},[]),M=y.useCallback(()=>{b(!0),requestAnimationFrame(()=>{const T=k.current,U=T?.firstElementChild;if(!T||!U?.offsetWidth||!U.offsetHeight)return;const P=24,K=Math.min((T.clientWidth-P*2)/U.offsetWidth,(T.clientHeight-P*2)/U.offsetHeight);d(Math.round(K*100)/100),h({x:0,y:0})})},[]),F=y.useCallback(T=>{if(!v)return;T.preventDefault();const U=T.deltaY>0?-a3:a3;d(P=>Math.round(Math.max(P+U,l3)*100)/100)},[v]),D=y.useCallback(T=>{!v||T.button!==0||(m(!0),C.current=!1,x.current={x:T.clientX,y:T.clientY},S.current={...f})},[v,f]),R=y.useCallback(T=>{if(!p)return;const U=T.clientX-x.current.x,P=T.clientY-x.current.y;(Math.abs(U)>2||Math.abs(P)>2)&&(C.current=!0),h({x:S.current.x+U,y:S.current.y+P})},[p]),z=y.useCallback(()=>m(!1),[]),B=y.useCallback(T=>{T.stopPropagation()},[]),H=y.useCallback(()=>{C.current||L()},[L]),G=y.useCallback(()=>{try{const T=s.current?.querySelector("svg");if(!T)throw new Error("No svg");bae(iAe(NU(T)),AU("svg"))}catch{Ht({type:"error",title:r("Export failed")})}},[r]),ne=y.useCallback(async()=>{const T=await oTt({currentSvg:()=>{const U=s.current?.querySelector("svg");return U?NU(U):null},rerender:async()=>rTt(await wae(e,N,{htmlLabels:!1})),rasterize:(U,P,K,J)=>sTt(U,P,K,J,mTt[N]),download:bae});T.kind==="failed"?Ht({type:"error",title:r("Export failed")}):T.kind==="svg"&&Ht({type:"warning",title:T.reason==="too-large"?r("Diagram is too large for PNG, exported SVG instead"):r("PNG export failed, exported SVG instead")})},[e,N,r]),W=T=>{const U=T==="sm"?"h-6 w-6":"h-7 w-7",P=T==="sm"?"h-3.5 w-3.5":"h-4 w-4",K=T==="sm"?"h-6 min-w-[2.5rem]":"h-7 min-w-[3rem]";return a.jsxs("div",{className:"flex items-center gap-1 rounded-md border border-border bg-background/95 p-1 shadow-sm",children:[a.jsx("button",{type:"button",onClick:j,className:ve("flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground",U),title:r("Zoom in"),children:a.jsx(xs,{className:P})}),a.jsxs("button",{type:"button",onClick:_,className:ve("flex items-center justify-center rounded text-xs transition-colors hover:bg-accent hover:text-accent-foreground",K),title:r("Reset zoom"),children:[Math.round(u*100),"%"]}),a.jsx("button",{type:"button",onClick:I,disabled:u<=l3,className:ve("flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground",U,u<=l3&&"cursor-not-allowed opacity-50"),title:r("Zoom out"),children:a.jsx(Txe,{className:P})}),u!==1&&a.jsx("button",{type:"button",onClick:_,className:ve("flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground",U),title:r("Fit to original size"),children:a.jsx($u,{className:P})}),a.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),a.jsx("button",{type:"button",onClick:G,className:ve("flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground",U),title:r("Export SVG"),children:a.jsx(Lf,{className:P})}),a.jsx("button",{type:"button",onClick:()=>{ne()},className:ve("flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground",U),title:r("Export PNG"),children:a.jsx(EHe,{className:P})}),v?a.jsx("button",{type:"button",onClick:L,className:ve("flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground",U),title:r("Exit fullscreen"),children:a.jsx(fUe,{className:P})}):a.jsx("button",{type:"button",onClick:M,className:ve("flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground",U),title:r("View fullscreen"),children:a.jsx(Exe,{className:P})})]})};return l?a.jsxs("div",{className:ve("overflow-x-auto rounded-lg border border-destructive/50",n),children:[a.jsx("div",{className:"flex items-center gap-2 border-b border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:a.jsx("span",{children:r("Mermaid render error")})}),a.jsx("pre",{className:"p-4 text-sm",children:a.jsx("code",{className:"block font-mono leading-relaxed text-muted-foreground",children:e})}),a.jsx("div",{className:"border-t border-border bg-muted/30 px-3 py-2 text-xs text-muted-foreground",children:l})]}):o?a.jsxs("div",{className:ve("relative rounded-lg border border-border bg-muted/30",n),style:{userSelect:"none",WebkitUserSelect:"none"},children:[a.jsx("div",{ref:s,className:ve("max-h-[min(50vh,20rem)] overflow-hidden [overflow-anchor:none]",v&&(p?"cursor-grabbing":"cursor-grab")),onWheel:F,onMouseDown:D,onMouseMove:R,onMouseUp:z,onMouseLeave:z,onDoubleClick:v?void 0:M,children:a.jsx("div",{className:"origin-center transition-transform duration-100 ease-out",style:{transform:`translate(${f.x}px, ${f.y}px) scale(${u})`},children:a.jsx("div",{className:"p-4",dangerouslySetInnerHTML:{__html:o}})})}),a.jsx("div",{className:"absolute right-2 bottom-2",children:W("sm")}),v&&a.jsxs("div",{className:"fixed inset-0 flex select-none flex-col bg-background",style:{zIndex:_r.TOAST},"data-enso-float":"",onClick:H,onKeyDown:T=>{T.key==="Escape"&&L()},children:[a.jsxs("div",{className:"relative z-10 flex shrink-0 items-center justify-between border-b border-border bg-muted/30 px-4 py-2",onClick:T=>T.stopPropagation(),onKeyDown:T=>T.stopPropagation(),children:[a.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:r("Mermaid preview")}),a.jsx("button",{type:"button",onClick:L,className:"flex h-7 w-7 items-center justify-center rounded-md border border-border bg-background/95 text-sm transition-colors hover:bg-accent hover:text-accent-foreground",title:r("Exit fullscreen"),children:a.jsx(Jr,{className:"h-4 w-4"})})]}),a.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[a.jsx("div",{ref:k,className:ve("flex min-h-0 flex-1 select-none overflow-hidden",p?"cursor-grabbing":"cursor-grab"),onWheel:F,onMouseDown:D,onMouseMove:R,onMouseUp:z,onMouseLeave:z,onClick:B,onKeyDown:B,children:a.jsx("div",{className:"m-auto origin-center transition-transform duration-100 ease-out",style:{transform:`translate(${f.x}px, ${f.y}px) scale(${u})`},children:a.jsx("div",{className:"p-4",dangerouslySetInnerHTML:{__html:o}})})}),a.jsx("div",{className:"absolute right-4 bottom-4",children:W("md")})]})]})]}):a.jsx("div",{className:ve("flex items-center justify-center rounded-lg border border-border bg-muted/30 p-8",n),children:a.jsx("div",{className:"text-sm text-muted-foreground",children:r("Loading Mermaid diagram...")})})}const vTt=/^[a-z][a-z\d+.-]*:/i,xTt=/^(?:https?|ircs?|mailto|xmpp):/i,bTt=/^(?:[a-z]:[\\/]|\\\\)/i;function yTt(e){const t=e?.trim();if(!t||!/^https?:\/\//i.test(t))return null;try{return new URL(t)}catch{return null}}function aAe(e){const t=/^(.*?):(\d+)(?:-\d+)?$/.exec(e);if(!t)return{path:e};const n=Number(t[2]);return n>0?{path:t[1],line:n}:{path:t[1]}}function wTt(e){try{return decodeURIComponent(e)}catch{return null}}function kTt(e){const t=e.search(/[?#]/);return t<0?e:e.slice(0,t)}function STt(e){try{const t=new URL(e);if(t.protocol!=="file:")return null;let n=decodeURIComponent(t.pathname);return n?(t.hostname&&t.hostname.toLowerCase()!=="localhost"?n=`//${t.hostname}${n}`:/^\/[a-z]:[\\/]/i.test(n)&&(n=n.slice(1)),n):null}catch{return null}}function kae(e){const t=e.trim();if(!t||t.startsWith("#")||t.startsWith("?"))return{kind:"external"};if(/^file:/i.test(t)){const r=STt(t);return r?{kind:"local",path:r}:{kind:"blocked"}}if(xTt.test(t)||t.startsWith("//"))return{kind:"external"};const n=wTt(kTt(t));return n==null||n.includes("\0")?{kind:"blocked"}:vTt.test(n)&&!bTt.test(n)?{kind:"blocked"}:{kind:"local",path:n}}function Kw(e){const t=e.replace(/\\/g,"/"),n=/^[a-z]:\//i.test(t)||t.startsWith("//");if(!n&&!t.startsWith("/"))return null;const r=/^[a-z]:\//i.test(t)?t.slice(0,2).toLowerCase():null,o=(r||n?t.slice(2):t.slice(1)).split("/"),i=[];for(const l of o)if(!(!l||l==="."))if(l===".."){if(i.length===0)return null;i.pop()}else i.push(l);return r?{value:`${r}/${i.join("/")}`.replace(/\/$/,""),windows:!0}:n?{value:`//${i.join("/")}`,windows:!0}:{value:`/${i.join("/")}`.replace(/\/$/,"")||"/",windows:!1}}function YD(e){const t=e.replace(/\\/g,"/"),n=[];for(const r of t.split("/"))if(!(!r||r==="."))if(r===".."){if(n.length===0)return null;n.pop()}else{if(r.includes("\0"))return null;n.push(r)}return n.join("/")}function ccn(e){return Kw(e)!==null}function r1(e,t){if(!t)return Kw(e)?null:YD(e);const n=Kw(t);if(!n)return null;const r=n.windows&&/^\/[a-z]:[\\/]/i.test(e)?e.slice(1):e,s=Kw(r);if(!s)return r===e?YD(e):null;if(s.windows!==n.windows)return null;const o=n.value.toLowerCase(),i=s.value.toLowerCase();if(i===o)return"";const l=n.value.endsWith("/")?n.value:`${n.value}/`;return i.startsWith(l.toLowerCase())?YD(s.value.slice(l.length)):null}function CTt(e,t){const n=t?Kw(t):null;if(!n||r1(e,t)!==null)return null;const r=n.windows&&/^\/[a-z]:[\\/]/i.test(e)?e.slice(1):e;return Kw(r)?r:null}const ETt=/^(?:%|ms|s|sec|min|h|ms\/op|ns|µs|us|b|kb|mb|gb|tb|kib|mib|gib|x|×|k|m|bn)$/i;function IU(e){let t=e.trim().replace(/^[$€£¥₹]\s*/,""),n=!1;/^\(.*\)$/.test(t)&&(n=!0,t=t.slice(1,-1));const r=/^([+-]?(?:\d{1,3}(?:,\d{3})+|\d+)(?:\.\d+)?)\s*(\S*)$/.exec(t);if(!r||r[2]&&!ETt.test(r[2]))return null;const s=Number(r[1].replace(/,/g,""));return n?-s:s}function TTt(e){const t=Math.max(0,...e.map(n=>n.length));return Array.from({length:t},(n,r)=>{const s=e.map(o=>o[r]?.trim()??"").filter(Boolean);return s.length>0&&s.every(o=>IU(o)!==null)})}function ATt(e,t,n){return n?(IU(e)??0)-(IU(t)??0):e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function NTt(e,t,n){const r=e.map((i,l)=>l);if(!t)return r;const s=t.dir==="asc"?1:-1,o=i=>e[i][t.column]?.trim()??"";return r.sort((i,l)=>{const c=o(i),u=o(l);return!c||!u?c?-1:u?1:0:s*ATt(c,u,n[t.column]??!1)||i-l})}function ITt(e,t){return e?.column!==t?{column:t,dir:"asc"}:e.dir==="asc"?{column:t,dir:"desc"}:null}const jTt=new Set(["json","jsonc","json5"]),RTt=new Set(["console","shell-session","terminal","output","ansi"]),MTt=new Set(["sh","bash","shell","zsh","shellscript"]),L6="$ ";function _Tt(e,t){const n=e?.toLowerCase();if(n&&jTt.has(n))return Sae(t)?"json":null;if(!n&&/^\s*[{[]/.test(t)&&Sae(t))return"json";if(n&&RTt.has(n)||t.includes("\x1B["))return"terminal";if(!n||MTt.has(n)){const r=t.split(`
327
327
  `).filter(s=>s.trim());if(r[0]?.startsWith(L6)&&r.some(s=>!s.startsWith(L6)))return"terminal"}return null}function Sae(e){const t=lAe(e);return t.ok&&typeof t.value=="object"&&t.value!==null}function lAe(e){let t="",n=0;for(;n<e.length;){const r=e[n];if(r==='"'){let s=n+1;for(;s<e.length&&e[s]!=='"';)s+=e[s]==="\\"?2:1;t+=e.slice(n,s+1),n=s+1}else if(r==="/"&&e[n+1]==="/")for(;n<e.length&&e[n]!==`
328
328
  `;)n++;else if(r==="/"&&e[n+1]==="*"){const s=e.indexOf("*/",n+2);n=s<0?e.length:s+2}else r===","&&/^\s*[}\]]/.test(e.slice(n+1))||(t+=r),n++}try{return{ok:!0,value:JSON.parse(t)}}catch{return{ok:!1}}}const Nw=["black","red","green","yellow","blue","magenta","cyan","white"],$D=[0,95,135,175,215,255],lC="\x1B",Cae="\x07",cAe=new RegExp(`${lC}\\[([0-9;?]*)([A-Za-z])|${lC}\\][^${Cae}${lC}]*(?:${Cae}|${lC}\\\\)?|${lC}[@-Z\\\\-_]`,"g");function Eae(...e){return`#${e.map(t=>t.toString(16).padStart(2,"0")).join("")}`}function PTt(e){if(e<0||e>255)return;if(e<8)return Nw[e];if(e<16)return`bright-${Nw[e-8]}`;if(e<232){const n=e-16;return Eae($D[Math.floor(n/36)],$D[Math.floor(n/6)%6],$D[n%6])}const t=8+(e-232)*10;return Eae(t,t,t)}function LTt(e,t){if(e[t+1]===5)return[PTt(e[t+2]??-1),3];if(e[t+1]===2){const[n,r,s]=e.slice(t+2,t+5);return[n===void 0||r===void 0||s===void 0?void 0:`rgb(${n},${r},${s})`,5]}return[void 0,1]}function OTt(e,t){const n=t?t.split(";").map(s=>Number(s||0)):[0];let r={...e};for(let s=0;s<n.length;s++){const o=n[s];if(o===0)r={};else if(o===1)r.bold=!0;else if(o===2)r.dim=!0;else if(o===3)r.italic=!0;else if(o===4)r.underline=!0;else if(o===22)delete r.bold,delete r.dim;else if(o===23)delete r.italic;else if(o===24)delete r.underline;else if(o>=30&&o<=37)r.fg=Nw[o-30];else if(o>=90&&o<=97)r.fg=`bright-${Nw[o-90]}`;else if(o>=40&&o<=47)r.bg=Nw[o-40];else if(o>=100&&o<=107)r.bg=`bright-${Nw[o-100]}`;else if(o===39)delete r.fg;else if(o===49)delete r.bg;else if(o===38||o===48){const[i,l]=LTt(n,s);i&&(r[o===38?"fg":"bg"]=i),s+=l-1}}return r}const DTt=(e,t)=>e.fg===t.fg&&e.bg===t.bg&&e.bold===t.bold&&e.dim===t.dim&&e.italic===t.italic&&e.underline===t.underline;function BTt(e){const t=[];let n={};const r=o=>{if(!o)return;const i=t.at(-1);i&&DTt(i,n)?i.text+=o:t.push({text:o,...n})};let s=0;for(const o of e.matchAll(cAe))r(e.slice(s,o.index)),s=o.index+o[0].length,o[2]==="m"&&!o[1]?.includes("?")&&(n=OTt(n,o[1]??""));return r(e.slice(s)),t}function Tae(e){return e.replace(cAe,"")}function FTt(e){const t=[];for(const n of e.split(`
329
329
  `)){if(n.startsWith(L6)){t.push({kind:"command",text:n.slice(L6.length)});continue}const r=t.at(-1);r?.kind==="output"?r.text+=`
@@ -377,12 +377,12 @@ ${e.value}
377
377
  `).filter(n=>n.trim()&&!/^\s*(```|~~~)/.test(n)).map(n=>n.replace(/^\s*#{1,6}\s+/,"").trimEnd());return{preview:t.slice(0,Mle).join(`
378
378
  `),folded:t.length>Mle||e.length>320}}function s5e({label:e,text:t}){const{t:n}=Se(),{preview:r,folded:s}=zRt(t),[o,i]=y.useState(!1),l=o||!s;return a.jsxs("section",{"data-enso":"tool-card-prompt","data-open":l?"true":"false",className:"min-w-0",children:[a.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-3 pt-1.5 text-[11px] text-muted-foreground",children:[a.jsx("span",{className:"min-w-0 truncate",children:e}),a.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2.5",children:[s&&a.jsx("button",{type:"button","data-enso":"tool-card-prompt-toggle","aria-expanded":o,onClick:()=>i(c=>!c),className:"hover:text-foreground",children:n(o?"Show less":"Show full text")}),a.jsx(px,{text:t,label:n("Copy")})]})]}),l?a.jsx("div",{"data-enso":"tool-card-prompt-body",style:FRt,className:"max-h-80 min-w-0 overflow-y-auto overscroll-contain px-3 pt-1 pb-2 text-xs leading-relaxed [&_:is(h1,h2,h3,h4)]:mt-2.5 [&_:is(h1,h2,h3,h4)]:mb-1 [&_[data-enso=code-block]>:first-child]:border-0",children:a.jsx(ua,{text:t})}):a.jsx("button",{type:"button","data-enso":"tool-card-prompt-preview",onClick:()=>i(!0),className:"line-clamp-4 block w-full min-w-0 px-3 pt-1 pb-2 text-left text-xs leading-relaxed text-muted-foreground break-words whitespace-pre-wrap",children:r})]})}function HRt({row:e}){const{t}=Se(),[n,r]=y.useState(!1),s=e.display==="long"&&(e.value.length>120||e.value.includes(`
379
379
  `));return a.jsxs("div",{className:"contents",children:[a.jsx("dt",{className:"whitespace-nowrap text-muted-foreground",children:e.label}),a.jsxs("dd",{"data-enso":"tool-card-kv-value","data-display":e.display,title:e.display==="path"?e.value:void 0,className:ve("min-w-0",e.display==="path"?"truncate":"whitespace-pre-wrap break-words"),children:[s&&!n?a.jsx("span",{className:"line-clamp-2",children:e.value}):e.value,s&&a.jsx("button",{type:"button","data-enso":"tool-card-kv-toggle","aria-expanded":n,onClick:()=>r(o=>!o),className:"block text-[11px] text-muted-foreground hover:text-foreground",children:t(n?"Show less":"Show more")})]})]})}function URt({block:e,known:t,onOpen:n}){const{t:r}=Se(),[s,o]=y.useState(!1);if(e.kind==="error")return a.jsx("p",{className:"rounded-md bg-destructive/10 px-2 py-1 text-destructive text-xs whitespace-pre-wrap",children:e.text});if(e.kind==="note")return a.jsx("p",{className:"whitespace-pre-wrap text-xs",children:e.text});if(e.kind==="prompt")return a.jsx(s5e,{label:e.label,text:e.text});if(e.kind==="markdown"){const i=e.collapsed&&!s;return a.jsxs("div",{className:"text-sm",children:[i?a.jsx("p",{className:"truncate text-xs text-muted-foreground",children:e.text.split(`
380
- `).find(l=>l.trim())}):a.jsx(ua,{text:e.text}),e.collapsed&&a.jsx("button",{type:"button","data-enso":"tool-card-fold",onClick:()=>o(l=>!l),className:"text-[11px] text-muted-foreground hover:text-foreground",children:r(s?"Show less":"Show more")})]})}return e.kind==="image"?a.jsx("div",{"data-enso":"tool-card-image",children:a.jsx(t5e,{image:e.image,path:e.path,alt:e.alt})}):e.kind==="session"?t[e.id]?a.jsx("button",{type:"button","data-enso":"tool-card-session","data-conversation-id":e.id,onClick:()=>n(e.id),className:"truncate text-left text-xs text-foreground underline-offset-2 hover:underline",children:e.label}):a.jsx("p",{className:"text-xs",children:e.label}):e.kind==="kv"?a.jsx("dl",{className:"grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-2 gap-y-0.5 text-xs",children:e.rows.map(i=>a.jsx(HRt,{row:i},i.label))}):e.kind==="diff"?a.jsx("div",{className:"space-y-0.5 text-xs",children:e.rows.map(i=>a.jsxs("p",{className:"min-w-0 break-words",children:[a.jsxs("span",{className:"text-muted-foreground",children:[i.label," "]}),a.jsx("span",{className:"text-muted-foreground line-through",children:i.before}),a.jsxs("span",{children:[" → ",i.after]})]},i.label))}):e.kind!=="list"?null:a.jsx("ul",{className:"space-y-0.5",children:e.items.map((i,l)=>a.jsxs("li",{className:"flex min-w-0 items-baseline gap-1.5 text-xs",children:[i.sessionId&&t[i.sessionId]?a.jsx("button",{type:"button","data-enso":"tool-card-session","data-conversation-id":i.sessionId,onClick:()=>n(i.sessionId),className:"min-w-0 truncate text-left hover:underline",children:i.title}):a.jsx("span",{className:"min-w-0 truncate",children:i.title}),i.badge&&a.jsx("span",{"data-enso":"tool-card-badge","data-tone":i.badgeTone,className:ve("shrink-0 rounded px-1 py-px text-[10px]",i.badgeTone==="error"&&"bg-destructive/15 text-destructive",i.badgeTone==="ok"&&"bg-success/15 text-success",i.badgeTone==="pending"&&"bg-warning/15 text-warning",(!i.badgeTone||i.badgeTone==="neutral"||i.badgeTone==="queued")&&"bg-muted text-muted-foreground"),children:i.badge}),i.detail&&a.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:i.detail})]},`${i.title}-${l}`))})}const VRt={report:()=>{},scroller:{current:null}},o5e=y.createContext(VRt),GRt=o5e.Provider;function WRt(){return y.useContext(o5e)}const _le=y.lazy(()=>Be(()=>import("./EditDiff-Dq1ru-27.js"),__vite__mapDeps([125,126]),import.meta.url).then(e=>({default:e.EditDiff}))),f9=y.lazy(()=>Be(()=>import("./ReadFileView-DRDsV4Qh.js"),[],import.meta.url).then(e=>({default:e.ReadFileView}))),qRt=(e,t)=>e===t||!!e&&!!t&&e.runMs===t.runMs&&e.turnMs===t.turnMs&&e.ttftMs===t.ttftMs&&e.tps===t.tps;function YRt(e,t){const n=e??[],r=t??[];return n.length===r.length&&n.every((s,o)=>{const i=r[o];return i!==void 0&&s.key===i.key&&s.state===i.state&&s.output===i.output&&s.image?.data===i.image?.data&&JSON.stringify(s.args??null)===JSON.stringify(i.args??null)})}function $Rt(e,t){if(e.secretarySession!==t.secretarySession)return!1;const n=e.item,r=t.item;if(n===r)return!0;if(n.kind!==r.kind||n.key!==r.key)return!1;switch(n.kind){case"user":return r.kind!=="user"||n.text!==r.text||n.images.length!==r.images.length||n.timestamp!==r.timestamp||n.deliveryState!==r.deliveryState||n.turnDurationMs!==r.turnDurationMs||n.collapsed!==r.collapsed||n.canCollapse!==r.canCollapse||n.hostTaskWrapUp!==r.hostTaskWrapUp?!1:n.images.every((s,o)=>s===r.images[o]);case"text":case"thinking":return r.kind===n.kind&&n.text===r.text&&n.streaming===r.streaming&&(n.kind!=="text"||r.kind==="text"&&qRt(n.perf,r.perf)&&n.timestamp===r.timestamp&&n.turnDurationMs===r.turnDurationMs)&&(n.kind!=="thinking"||r.kind==="thinking"&&n.durationMs===r.durationMs);case"tool":return r.kind==="tool"&&n.state===r.state&&n.name===r.name&&n.summary===r.summary&&n.output===r.output&&n.edits===r.edits&&n.writeContent===r.writeContent&&n.fileChanges===r.fileChanges&&n.imagePath===r.imagePath&&n.image?.data===r.image?.data&&n.image?.mimeType===r.image?.mimeType&&n.generatedImages===r.generatedImages&&n.todos===r.todos&&n.durationMs===r.durationMs&&n.startedAt===r.startedAt&&n.agentMeta===r.agentMeta&&n.source===r.source&&n.nestedPending===r.nestedPending&&JSON.stringify(n.sandbox)===JSON.stringify(r.sandbox)&&n.rtk===r.rtk&&n.approvalReview===r.approvalReview&&n.plan?.title===r.plan?.title&&n.plan?.text===r.plan?.text&&n.sentMessage===r.sentMessage&&n.memoryContent===r.memoryContent&&n.ask?.question===r.ask?.question&&n.ask?.options.join(`
380
+ `).find(l=>l.trim())}):a.jsx(ua,{text:e.text}),e.collapsed&&a.jsx("button",{type:"button","data-enso":"tool-card-fold",onClick:()=>o(l=>!l),className:"text-[11px] text-muted-foreground hover:text-foreground",children:r(s?"Show less":"Show more")})]})}return e.kind==="image"?a.jsx("div",{"data-enso":"tool-card-image",children:a.jsx(t5e,{image:e.image,path:e.path,alt:e.alt})}):e.kind==="session"?t[e.id]?a.jsx("button",{type:"button","data-enso":"tool-card-session","data-conversation-id":e.id,onClick:()=>n(e.id),className:"truncate text-left text-xs text-foreground underline-offset-2 hover:underline",children:e.label}):a.jsx("p",{className:"text-xs",children:e.label}):e.kind==="kv"?a.jsx("dl",{className:"grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-2 gap-y-0.5 text-xs",children:e.rows.map(i=>a.jsx(HRt,{row:i},i.label))}):e.kind==="diff"?a.jsx("div",{className:"space-y-0.5 text-xs",children:e.rows.map(i=>a.jsxs("p",{className:"min-w-0 break-words",children:[a.jsxs("span",{className:"text-muted-foreground",children:[i.label," "]}),a.jsx("span",{className:"text-muted-foreground line-through",children:i.before}),a.jsxs("span",{children:[" → ",i.after]})]},i.label))}):e.kind!=="list"?null:a.jsx("ul",{className:"space-y-0.5",children:e.items.map((i,l)=>a.jsxs("li",{className:"flex min-w-0 items-baseline gap-1.5 text-xs",children:[i.sessionId&&t[i.sessionId]?a.jsx("button",{type:"button","data-enso":"tool-card-session","data-conversation-id":i.sessionId,onClick:()=>n(i.sessionId),className:"min-w-0 truncate text-left hover:underline",children:i.title}):a.jsx("span",{className:"min-w-0 truncate",children:i.title}),i.badge&&a.jsx("span",{"data-enso":"tool-card-badge","data-tone":i.badgeTone,className:ve("shrink-0 rounded px-1 py-px text-[10px]",i.badgeTone==="error"&&"bg-destructive/15 text-destructive",i.badgeTone==="ok"&&"bg-success/15 text-success",i.badgeTone==="pending"&&"bg-warning/15 text-warning",(!i.badgeTone||i.badgeTone==="neutral"||i.badgeTone==="queued")&&"bg-muted text-muted-foreground"),children:i.badge}),i.detail&&a.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:i.detail})]},`${i.title}-${l}`))})}const VRt={report:()=>{},scroller:{current:null}},o5e=y.createContext(VRt),GRt=o5e.Provider;function WRt(){return y.useContext(o5e)}const _le=y.lazy(()=>Be(()=>import("./EditDiff-1q8ZinKY.js"),__vite__mapDeps([125,126]),import.meta.url).then(e=>({default:e.EditDiff}))),f9=y.lazy(()=>Be(()=>import("./ReadFileView-B24dkbc8.js"),[],import.meta.url).then(e=>({default:e.ReadFileView}))),qRt=(e,t)=>e===t||!!e&&!!t&&e.runMs===t.runMs&&e.turnMs===t.turnMs&&e.ttftMs===t.ttftMs&&e.tps===t.tps;function YRt(e,t){const n=e??[],r=t??[];return n.length===r.length&&n.every((s,o)=>{const i=r[o];return i!==void 0&&s.key===i.key&&s.state===i.state&&s.output===i.output&&s.image?.data===i.image?.data&&JSON.stringify(s.args??null)===JSON.stringify(i.args??null)})}function $Rt(e,t){if(e.secretarySession!==t.secretarySession)return!1;const n=e.item,r=t.item;if(n===r)return!0;if(n.kind!==r.kind||n.key!==r.key)return!1;switch(n.kind){case"user":return r.kind!=="user"||n.text!==r.text||n.images.length!==r.images.length||n.timestamp!==r.timestamp||n.deliveryState!==r.deliveryState||n.turnDurationMs!==r.turnDurationMs||n.collapsed!==r.collapsed||n.canCollapse!==r.canCollapse||n.hostTaskWrapUp!==r.hostTaskWrapUp?!1:n.images.every((s,o)=>s===r.images[o]);case"text":case"thinking":return r.kind===n.kind&&n.text===r.text&&n.streaming===r.streaming&&(n.kind!=="text"||r.kind==="text"&&qRt(n.perf,r.perf)&&n.timestamp===r.timestamp&&n.turnDurationMs===r.turnDurationMs)&&(n.kind!=="thinking"||r.kind==="thinking"&&n.durationMs===r.durationMs);case"tool":return r.kind==="tool"&&n.state===r.state&&n.name===r.name&&n.summary===r.summary&&n.output===r.output&&n.edits===r.edits&&n.writeContent===r.writeContent&&n.fileChanges===r.fileChanges&&n.imagePath===r.imagePath&&n.image?.data===r.image?.data&&n.image?.mimeType===r.image?.mimeType&&n.generatedImages===r.generatedImages&&n.todos===r.todos&&n.durationMs===r.durationMs&&n.startedAt===r.startedAt&&n.agentMeta===r.agentMeta&&n.source===r.source&&n.nestedPending===r.nestedPending&&JSON.stringify(n.sandbox)===JSON.stringify(r.sandbox)&&n.rtk===r.rtk&&n.approvalReview===r.approvalReview&&n.plan?.title===r.plan?.title&&n.plan?.text===r.plan?.text&&n.sentMessage===r.sentMessage&&n.memoryContent===r.memoryContent&&n.ask?.question===r.ask?.question&&n.ask?.options.join(`
381
381
  `)===r.ask?.options.join(`
382
382
  `)&&n.ask?.answer===r.ask?.answer&&n.ask?.autoSelected===r.ask?.autoSelected&&n.subagentOp===r.subagentOp&&JSON.stringify(n.subagentTitles)===JSON.stringify(r.subagentTitles)&&n.waiting===r.waiting&&n.pluginArtifacts===r.pluginArtifacts&&n.shellFailure===r.shellFailure&&n.dcgWarning===r.dcgWarning&&JSON.stringify(n.args??null)===JSON.stringify(r.args??null)&&YRt(n.cardPeers,r.cardPeers);case"tool-group":return r.kind==="tool-group"&&n.expanded===r.expanded&&n.count===r.count&&n.stats.commands===r.stats.commands&&n.stats.reads===r.stats.reads&&n.stats.searches===r.stats.searches&&n.stats.others===r.stats.others&&n.exploring===r.exploring&&n.live===r.live&&n.activity?.thinking===r.activity?.thinking&&n.activity?.workedMs===r.activity?.workedMs&&n.explore?.goal===r.explore?.goal&&n.explore?.report===r.explore?.report&&n.explore?.steps===r.explore?.steps&&n.notice===r.notice;case"error":return r.kind==="error"&&n.text===r.text;case"interrupted":return r.kind==="interrupted"&&n.at===r.at&&n.exitKind===r.exitKind&&n.unfinishedTools.length===r.unfinishedTools.length;case"task-note":return r.kind==="task-note"&&n.detail===r.detail;case"compaction":case"compaction-notice":return(r.kind==="compaction"||r.kind==="compaction-notice")&&n.kind===r.kind&&n.summary===r.summary&&n.tokensBefore===r.tokensBefore&&n.tokensAfter===r.tokensAfter&&n.verified===r.verified;case"compaction-progress":return r.kind==="compaction-progress"&&n.state===r.state;case"session-custom":return r.kind==="session-custom"&&n.entry===r.entry;case"divider":return r.kind==="divider"&&n.text===r.text;case"plugin-message":return r.kind==="plugin-message"&&n.text===r.text&&n.pluginId===r.pluginId;case"resumed-reply":return r.kind==="resumed-reply"&&n.expanded===r.expanded&&n.text===r.text&&n.thinking===r.thinking&&n.tools.length===r.tools.length;case"discarded-turn":return r.kind==="discarded-turn"&&n.expanded===r.expanded&&n.reason===r.reason&&n.messages.length===r.messages.length&&n.messages.every((s,o)=>s===r.messages[o])&&n.tools.length===r.tools.length}}const i5e=/^<role>\n?([\s\S]*?)\n?<\/role>\s*/,KRt=/^<workspace-migrated>\n?([\s\S]*?)\n?<\/workspace-migrated>\s*/,XRt=/^<workspace-branch-changed>\n?([\s\S]*?)\n?<\/workspace-branch-changed>\s*/;function QRt({note:e}){const{t}=Se(),n=/on Git branch ("(?:[^"\\]|\\.)*")/.exec(e)?.[1];let r="";try{r=n?String(JSON.parse(n)):""}catch{}return a.jsxs("aside",{title:e,className:"flex w-full items-start gap-2 rounded-lg border border-dashed border-border/60 px-3 py-2 text-xs text-muted-foreground",children:[a.jsx(wf,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),a.jsx("span",{className:"min-w-0 break-all",children:r?t("Workspace switched to branch {{branch}}",{branch:r}):t("Workspace switched branch")})]})}function a5e({items:e}){const t=Ud(),n=it(s=>t?void 0:Wa(s)?.id),r=it(s=>t?void 0:Wa(s)?.backgroundTasks);return a.jsx(IRt,{items:e,live:r,onOpen:n?s=>it.setState({pendingAgentOpen:{sessionId:n,agentId:s}}):void 0})}function ZRt({note:e}){const{t}=Se(),n=/(?:moved to|main working tree): (.+)$/m.exec(e)?.[1]?.trim(),r=e.includes("main working tree");return a.jsxs("aside",{title:e,className:"flex w-full items-start gap-2 rounded-lg border border-dashed border-border/60 px-3 py-2 text-xs text-muted-foreground",children:[a.jsx(wf,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),a.jsxs("span",{className:"min-w-0",children:[t(r?"Workspace fell back to the main working tree":"Workspace moved to an isolated worktree"),n&&a.jsx("span",{className:"ml-1.5 break-all font-mono text-[11px] opacity-80",children:n})]})]})}function l5e({note:e}){const{t}=Se();return a.jsxs("aside",{className:"flex w-full items-start gap-2 rounded-lg border border-dashed border-border/60 px-3 py-2 text-xs text-muted-foreground",children:[a.jsx(rx,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),a.jsx("span",{className:"min-w-0",children:t(e==="on"?"Plan mode on: read-only research, then a plan for your approval":e==="off"?"Plan mode off":"Context compacted: the approved plan was attached again")})]})}function c5e({note:e}){const{t}=Se(),n=e==="on";return a.jsxs("aside",{className:"flex w-full items-start gap-2 rounded-lg border border-dashed border-border/60 px-3 py-2 text-xs text-muted-foreground",children:[n?a.jsx(sM,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}):a.jsx(zW,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),a.jsx("span",{className:"min-w-0",children:t(n?"Unattended mode on: no one is watching, so it decides and keeps going":"Unattended mode off: a person is available again")})]})}function JRt({tag:e,body:t}){const n=e==="agent-notification"?Njt(t):null;return n?a.jsx(nMt,{notices:n}):a.jsx(rMt,{tag:e,body:t})}function eMt({goal:e,instructions:t}){const{t:n}=Se(),[r,s]=y.useState(!1),o=SIt(e);return a.jsxs("div",{"data-enso":"goal-continuation","data-open":r?"true":"false",className:ve("my-1 w-full min-w-0",GNe),children:[a.jsxs("button",{type:"button","aria-expanded":r,onClick:()=>s(i=>!i),className:"flex w-full min-w-0 items-center gap-2 text-left text-muted-foreground hover:text-foreground",children:[a.jsx(WNe,{}),a.jsx("span",{className:"min-w-0 flex-1 truncate",children:n("Continue goal: {{summary}}",{summary:o||e})})]}),r&&a.jsxs("div",{className:"mt-1.5 space-y-1.5 border-t border-border/60 pt-1.5",children:[a.jsx("p",{className:"whitespace-pre-wrap text-foreground",children:e}),t&&a.jsx("pre",{className:"whitespace-pre-wrap font-mono text-[11px] leading-relaxed text-muted-foreground",children:t})]})]})}function Ple({enso:e,icon:t,title:n,body:r}){const[s,o]=y.useState(!1);return a.jsxs("div",{"data-enso":e,"data-open":s?"true":"false",className:_K,children:[a.jsxs("button",{type:"button","aria-expanded":s,onClick:()=>o(i=>!i),className:"flex w-full items-start gap-2 text-left enabled:hover:text-foreground",children:[a.jsx(t,{className:$P}),a.jsx("span",{className:"min-w-0 flex-1 truncate",children:n})]}),s&&r&&a.jsx("p",{className:"mt-1.5 whitespace-pre-wrap text-foreground",children:r})]})}function tMt({segments:e,searchQuery:t,activeNth:n}){const{t:r}=Se();return a.jsx(a.Fragment,{children:e.map((s,o)=>{const i=`${s.kind}-${o}`;if(s.kind==="text"){const l=s.text.trim();return l?a.jsx(wp,{text:l,searchQuery:t,activeNth:n},i):null}if(s.kind==="goal")return a.jsx(eMt,{goal:s.goal,instructions:s.instructions},i);if(s.kind==="schedule"){const l=NIt(s.raw),c=l.length>0?l:[{summary:"",body:""}];return a.jsx(y.Fragment,{children:c.map((u,d)=>a.jsx(Ple,{enso:"secretary-schedule-card",icon:mT,title:u.summary?r("Scheduled: {{summary}}",{summary:u.summary}):r("Scheduled"),body:u.body},d))},i)}if(s.kind==="updates"){const l=RNe(s.raw);if(l)return a.jsx(u5e,{lines:l},i);const c=IIt(s.raw);return a.jsx(Ple,{enso:"session-updates-card",icon:xg,title:c.summary?r("Session updates: {{summary}}",{summary:c.summary}):r("Session updates"),body:c.body},i)}return a.jsx(JRt,{tag:s.tag,body:s.body},i)})})}function nMt({notices:e}){const{t}=Se(),[n,r]=y.useState(!1);return a.jsxs("div",{className:MK,children:[a.jsxs("button",{type:"button",onClick:()=>r(s=>!s),className:"flex w-full items-start gap-2 px-3 py-2 text-left hover:text-foreground",children:[a.jsx(Jl,{className:$P}),a.jsx("span",{className:"min-w-0 flex-1 truncate",children:e.map(s=>s.header).join(" · ")})]}),n&&e.map((s,o)=>a.jsxs("div",{className:"border-border/60 border-t",children:[e.length>1&&a.jsx("p",{className:"truncate px-3 pt-2",children:s.header}),s.report&&a.jsx("div",{className:"max-h-80 overflow-auto px-3 py-2 text-sm text-foreground",children:a.jsx(ua,{text:s.report})}),s.usage&&a.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5 border-border/60 border-t px-3 py-1 text-[10px]",children:[a.jsx("span",{className:"font-semibold tracking-wide text-foreground/75",children:"Subagent"}),a.jsx("span",{"aria-hidden":"true",children:"·"}),a.jsx("span",{children:t("{{count}} tokens",{count:Va(s.usage.tokens)})}),a.jsx("span",{"aria-hidden":"true",children:"·"}),a.jsx("span",{children:t("{{count}} tool calls",{count:s.usage.toolUses})}),a.jsx("span",{"aria-hidden":"true",children:"·"}),a.jsx("span",{children:pl(s.usage.durationMs)})]}),s.tasks&&a.jsxs("div",{className:"border-border/60 border-t px-3 py-1 text-[11px]",children:[a.jsx("p",{className:"text-foreground/75",children:t("Background tasks started by this subagent")}),s.tasks.map(i=>a.jsx("p",{className:"truncate font-mono text-muted-foreground",children:i},i))]})]},o))]})}function rMt({tag:e,body:t}){const[n,r]=y.useState(!1),s=NK(t);if(!s)return null;const o=s.indexOf(`
383
383
  `),i=o>0,l=e.startsWith("coworker-")||e==="agent-notification"?Jl:_g;return a.jsxs("div",{className:_K,children:[a.jsxs("button",{type:"button",disabled:!i,onClick:()=>r(c=>!c),className:"flex w-full items-start gap-2 text-left enabled:hover:text-foreground",children:[a.jsx(l,{className:$P}),a.jsx("span",{className:ve("min-w-0 flex-1",i?"truncate":"whitespace-pre-wrap"),children:i?s.slice(0,o):s})]}),i&&n&&a.jsx("pre",{className:"mt-1.5 max-h-80 overflow-auto font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-words",children:s.slice(o+1)})]})}const sMt={"goal-complete":Is,"goal-blocked":qa,"needs-user":zW,"turn-ended":xg,failed:SW,stalled:mE,interrupted:Xp,proposal:EW,schedule:mT,pending:mE,"ask-relay":bT,leftover:mE,queued:mT};function u5e({lines:e}){return a.jsx("div",{"data-enso":"secretary-updates",className:ve(MK,"divide-y divide-border/60"),children:e.map((t,n)=>a.jsx(oMt,{line:t,onOpen:cA},n))})}function oMt({line:e,onOpen:t}){const{t:n}=Se(),[r,s]=y.useState(!1),o=sMt[e.kind],i="conversationId"in e?e.conversationId:void 0,l=a.jsxs(a.Fragment,{children:[a.jsx(o,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),a.jsx("span",{className:"min-w-0 flex-1",children:e.text})]});return a.jsxs("div",{"data-enso":"secretary-update","data-open":r?"true":"false",className:"px-3 py-2",children:[a.jsxs("div",{className:"flex items-start gap-2",children:[e.detail?a.jsx("button",{type:"button","data-enso":"secretary-update-expand","aria-expanded":r,onClick:()=>s(c=>!c),className:"flex min-w-0 flex-1 items-start gap-2 text-left hover:text-foreground",children:l}):a.jsx("div",{className:"flex min-w-0 flex-1 items-start gap-2",children:l}),i&&t?a.jsx("button",{type:"button","data-enso":"secretary-update-open",title:n("Open session"),"aria-label":n("Open session"),onClick:c=>{c.stopPropagation(),t(i)},className:"-mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-[5px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:a.jsx(r2,{className:"h-3.5 w-3.5"})}):null]}),e.detail&&r&&a.jsx("pre",{className:"mt-1.5 ml-5.5 max-h-60 overflow-auto font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-words",children:e.detail})]})}const d5e=/^<message-from-main-agent>\n?([\s\S]*?)\n?<\/message-from-main-agent>\s*$/;function iMt(e){const t=i5e.exec(e);return d5e.test(t?e.slice(t[0].length):e)}function aMt({name:e,content:t}){const{t:n}=Se();return a.jsxs(gr,{children:[a.jsxs(Eut,{className:ZNe("skill",!0),children:[a.jsx(du,{className:"h-3 w-3"}),e]}),a.jsxs(vr,{className:"max-w-lg",children:[a.jsx(xr,{children:a.jsxs(dr,{className:"text-base",children:[n("Skill")," · ",e]})}),a.jsx(rr,{className:"max-h-[50vh] text-sm",children:a.jsx(ua,{text:t})})]})]})}function eV({chip:e,extra:t}){return a.jsxs("div",{className:"max-w-[80%] rounded-2xl rounded-br-md bg-muted px-4 py-2.5 text-sm",children:[a.jsx("div",{className:"flex flex-wrap items-center gap-1",children:e}),t?a.jsx("div",{className:"mt-1.5 whitespace-pre-wrap break-words leading-relaxed",children:a.jsx(YC,{text:t})}):null]})}function lMt({blocks:e,hostTaskWrapUp:t}){const n=h_(e.rest),r=t?Uz(e.rest):void 0,s=a.jsx(eV,{chip:a.jsx("span",{className:"inline-flex flex-wrap gap-1 align-middle",children:e.skills.map(o=>a.jsx(aMt,{name:o.name,content:o.body},o.location))}),extra:n.rest.trim()});return!n.plan&&!n.unattended&&!r?s:a.jsxs(a.Fragment,{children:[n.plan&&a.jsx(l5e,{note:n.plan}),n.unattended&&a.jsx(c5e,{note:n.unattended}),r&&a.jsx(a5e,{items:r.items}),s]})}function cMt({text:e}){const t=p_(e);if(t.names.length>1)return a.jsx(eV,{chip:a.jsx("span",{className:"inline-flex flex-wrap gap-1 align-middle",children:t.names.map(r=>a.jsx(U6,{name:`/skill:${r}`},r))}),extra:t.rest});const n=H6(e);return n.slash?a.jsx(eV,{chip:a.jsx(U6,{name:n.slash}),extra:n.rest.trim()}):null}function uMt({preset:e}){const{t}=Se();return a.jsxs("div",{className:"min-w-64 max-w-[80%] overflow-hidden rounded-2xl rounded-br-md bg-muted text-sm",children:[a.jsxs("div",{className:"flex items-center gap-2.5 px-3.5 py-2.5",children:[a.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-info/15 text-info",children:a.jsx(r_,{className:"h-4 w-4"})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-[11px] text-muted-foreground",children:t("Workflow preset")}),a.jsx("p",{className:"truncate font-medium",title:e.id,children:e.name||e.id})]})]}),e.args.length>0&&a.jsx("dl",{className:"space-y-1 border-t border-border/60 px-3.5 py-2 text-xs",children:e.args.map(([n,r])=>a.jsxs("div",{className:"flex gap-2",children:[a.jsx("dt",{className:"shrink-0 font-mono text-muted-foreground",children:n}),a.jsx("dd",{className:"min-w-0 whitespace-pre-wrap break-words",children:r})]},n))})]})}function uA({kind:e,label:t,title:n}){const r=e==="file"?Kp:e==="chat"?Xp:dVe;return a.jsxs("span",{className:ve(KP(e),"mx-0.5 max-w-52 rounded-md px-1.5 align-middle leading-4"),title:n,children:[a.jsx(r,{className:"h-3 w-3 shrink-0"}),a.jsx("span",{className:"truncate",children:t})]})}function dMt({label:e,sessionFile:t}){const n=it(s=>s.conversations),r=o3t(n,t);return r?a.jsxs("button",{type:"button","data-enso":"chat-ref",onClick:()=>cA(r),title:t,className:ve(KP("chat"),"mx-0.5 inline-flex max-w-52 items-center gap-1 rounded-md px-1.5 align-middle leading-4 hover:bg-muted"),children:[a.jsx(Xp,{className:"h-3 w-3 shrink-0"}),a.jsx("span",{className:"truncate",children:e})]}):a.jsx(uA,{kind:"chat",label:e,title:t})}const Lle=240;function fMt({text:e,originalLines:t}){const{t:n}=Se(),r=y.useRef(null),[s,o]=y.useState(!1),[i,l]=y.useState(!1);y.useLayoutEffect(()=>{const u=r.current;if(!u)return;const d=()=>o(u.scrollHeight>Lle+1);if(d(),typeof ResizeObserver>"u")return;const f=new ResizeObserver(d);return f.observe(u),()=>f.disconnect()},[]);const c=s&&!i;return a.jsxs("span",{"data-enso":"quote-block",className:"mt-1 mb-2.5 block border-l-2 border-brand/40 pl-2.5 text-muted-foreground",children:[t?a.jsx("span",{"data-quote-truncated":"",className:"mb-0.5 block text-[11px] text-warning",children:n("Truncated · original {{count}} lines",{count:t})}):null,a.jsx("span",{ref:r,"data-quote-body":"","data-clipped":c?"":void 0,style:c?{maxHeight:Lle}:void 0,className:ve("block",c&&"overflow-hidden mask-b-from-60%"),children:lIt(e).map((u,d)=>u.type==="code"?a.jsx("span",{"data-quote-code":"",className:"my-1 block overflow-x-auto whitespace-pre rounded-md bg-background/60 px-2 py-1 font-mono text-xs",children:u.code},d):a.jsx("span",{children:u.text},d))}),s?a.jsx("button",{type:"button","data-quote-toggle":"","data-quote-skip":"",onClick:()=>l(u=>!u),className:"mt-0.5 text-[11px] text-muted-foreground/80 select-none hover:text-foreground",children:n(i?"Show less":"Show more")}):null]})}function YC({text:e,searchQuery:t="",activeNth:n=-1}){const r=UJe(vq(e)),s={n:0};return a.jsx("span",{className:"whitespace-pre-wrap",children:r.map((o,i)=>o.type==="file"?a.jsx(Y$,{path:o.path,children:a.jsx(uA,{kind:"file",label:g_(o.path),title:o.path})},i):o.type==="chat"?a.jsx(dMt,{label:o.label,sessionFile:o.sessionFile},i):o.type==="ui-element"?a.jsx(uA,{kind:"ui-element",label:o.label,title:`${o.path}${o.text?` · ${o.text}`:""}`},i):o.type==="quote"?a.jsx(fMt,{text:o.text,originalLines:o.originalLines},i):a.jsx("span",{children:t.trim()?tAe(o.text,t,n,s):o.text},i))})}function hMt({files:e,chats:t}){return a.jsxs("span",{className:"mt-1.5 flex flex-wrap gap-1.5",children:[e.map(n=>a.jsx(Y$,{path:n,children:a.jsx(uA,{kind:"file",label:g_(n),title:n})},`f:${n}`)),t.map(n=>a.jsx(uA,{kind:"chat",label:n.label,title:n.sessionFile},`c:${n.sessionFile}`))]})}const lR="max-w-[82%] rounded-[10px] bg-muted px-3.5 py-[9px] text-(length:--chat-body-size) leading-[1.6]";function wp({text:e,searchQuery:t="",activeNth:n=-1,thumbnails:r=0,align:s="end",hostTaskWrapUp:o=!1}){const{t:i}=Se(),l=Ud(),c=!!(l?.speaker||l?.botSession),u=Qet(e,r);if(u)return a.jsxs(a.Fragment,{children:[u.text&&a.jsx(wp,{text:u.text,searchQuery:t,activeNth:n,hostTaskWrapUp:o}),a.jsx(FNe,{entries:u.entries,thumbnails:r,align:s})]});const d=bIt(e);if(d)return a.jsx(J3t,{message:d});const f=c?Q2e(e):null;if(f)return a.jsx(s3t,{message:f});const h=c?rP(e):e;if(h!==e)return a.jsx(wp,{text:h,searchQuery:t,activeNth:n,hostTaskWrapUp:o});const p=c?DY(e):null;if(p?.refs.length)return a.jsxs("div",{className:"flex w-full flex-col items-end gap-1.5",children:[p.body&&a.jsx(wp,{text:p.body,searchQuery:t,activeNth:n}),a.jsx("div",{className:"flex flex-wrap justify-end gap-1.5",children:p.refs.map(R=>a.jsxs("span",{title:i("Referenced chat"),className:"inline-flex h-6 max-w-56 items-center gap-1 rounded-md bg-muted px-1.5 text-xs",children:[a.jsx(xg,{className:"h-3 w-3 shrink-0"}),a.jsx("span",{className:"min-w-0 truncate",children:R.title})]},R.id))})]});const m=c_(e);if(m.note){const R=m.rest.trim();return a.jsxs(a.Fragment,{children:[a.jsx(l5e,{note:m.note}),R&&a.jsx(wp,{text:R,searchQuery:t,activeNth:n,hostTaskWrapUp:o})]})}const v=u2(e);if(v.note){const R=v.rest.trim();return a.jsxs(a.Fragment,{children:[a.jsx(c5e,{note:v.note}),R&&a.jsx(wp,{text:R,searchQuery:t,activeNth:n,hostTaskWrapUp:o})]})}const b=o?Zye(e):null;if(b){const R=b.rest.trim();return a.jsxs(a.Fragment,{children:[a.jsx(a5e,{items:b.items}),R&&a.jsx(wp,{text:R,searchQuery:t,activeNth:n})]})}const x=XRt.exec(e);if(x){const R=e.slice(x[0].length).trim();return a.jsxs(a.Fragment,{children:[a.jsx(QRt,{note:x[1]??""}),R&&a.jsx(wp,{text:R,searchQuery:t,activeNth:n})]})}const S=fQe(e);if(S?.kind==="approved")return a.jsxs("div",{className:"flex w-full items-start gap-2 rounded-lg border border-dashed border-border/60 px-3 py-2 text-xs text-muted-foreground",children:[a.jsx(EW,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),a.jsxs("span",{className:"min-w-0",children:[i("Plan approved, executing"),a.jsx("span",{className:"ml-1.5 text-foreground",children:S.title})]})]});if(S?.kind==="feedback")return a.jsxs("div",{className:ve(lR,"whitespace-pre-wrap"),children:[a.jsxs("p",{className:"mb-1 flex items-center gap-1 text-[10px] font-medium tracking-wide text-muted-foreground uppercase",children:[a.jsx(rx,{className:"h-3 w-3"}),i("Plan feedback")]}),a.jsx(YC,{text:S.feedback,searchQuery:t,activeNth:n})]});const k=e1e(e);if(k)return a.jsx(uMt,{preset:k});const C=$Je(e);if(C.files.length>0||C.chats.length>0){const R=H6(C.body);return a.jsxs("div",{className:lR,children:[R.slash?a.jsxs(a.Fragment,{children:[a.jsx(U6,{name:R.slash}),R.rest.trim()?a.jsx("span",{className:"ml-1.5 align-middle",children:a.jsx(YC,{text:R.rest.trim(),searchQuery:t,activeNth:n})}):null]}):a.jsx(YC,{text:C.body,searchQuery:t,activeNth:n}),a.jsx(hMt,{files:C.files,chats:C.chats})]})}const N=m_(e);if(N)return a.jsx(lMt,{blocks:N,hostTaskWrapUp:o});if(H6(e).slash)return a.jsx(cMt,{text:e});const j=KRt.exec(e);if(j){const R=e.slice(j[0].length).trim();return a.jsxs(a.Fragment,{children:[a.jsx(ZRt,{note:j[1]}),R&&a.jsx(wp,{text:R,searchQuery:t,activeNth:n})]})}const I=EIt(e);if(I)return a.jsx(tMt,{segments:I,searchQuery:t,activeNth:n});const _=RNe(e);if(_)return a.jsx(u5e,{lines:_});const L=i5e.exec(e),M=L?e.slice(L[0].length):e,F=d5e.exec(M),D=F?F[1]:M;return a.jsxs("div",{className:ve(F?"max-w-[80%] rounded-2xl rounded-bl-md border border-blue-500/20 bg-blue-500/8 px-4 py-2.5 text-sm":ve(lR,"whitespace-pre-wrap")),children:[F&&a.jsxs("p",{className:"mb-1 flex items-center gap-1 text-[10px] font-medium tracking-wide text-blue-600 uppercase dark:text-blue-400",children:[a.jsx(Jl,{className:"h-3 w-3"}),i("From main agent")]}),L?.[1]&&!pIt(L[1])&&a.jsxs("div",{className:"mb-2 rounded-md bg-background/60 px-2.5 py-1.5 text-xs text-muted-foreground",children:[a.jsx("span",{className:"font-semibold",children:i("Role")})," · ",L[1]]}),F?a.jsx(ua,{text:D,searchQuery:t,activeNth:n}):a.jsx(YC,{text:D,searchQuery:t,activeNth:n})]})}function Ole(e){return e.kind==="tool-group"||e.kind==="thinking"||e.kind==="tool"&&OM(e)}const Eh="text-[color:var(--subtle-foreground,var(--muted-foreground))]",ek="animate-pulse motion-reduce:animate-none";function pMt({model:e,at:t,privacyMask:n,secretarySession:r=!1,face:s,conversationId:o}){const i=Ud(),l=kNe(o),c=r?s??l:null,u=i?.speaker??(i?null:c),d=!i&&c?!0:void 0,f=[e,typeof t=="number"?QP(t):null].filter(Boolean).join(" · ");return!u&&!f&&!n?null:a.jsxs("div",{"data-quote-skip":"",className:"mb-2 flex h-6 min-w-0 items-center gap-2 text-xs select-none",children:[u&&(u.image?a.jsx("img",{"data-enso":d?"secretary-chat-avatar":void 0,"data-image":d?"true":void 0,src:u.image,alt:"",draggable:!1,className:"size-[22px] shrink-0 rounded-full object-cover",style:{backgroundColor:u.color}}):d?a.jsx(IN,{name:u.name,color:u.color,enso:"secretary-chat-avatar",className:"size-[22px] rounded-full"}):a.jsx("span",{className:"flex size-[22px] shrink-0 items-center justify-center rounded-full font-semibold text-[11px] text-white",style:{backgroundColor:u.color},children:[...u.name.trim()][0]?.toUpperCase()??"?"})),u&&a.jsx("span",{className:"shrink-0 truncate text-[13px] font-semibold text-foreground",children:u.name}),f&&a.jsx("span",{className:ve("min-w-0 truncate text-[11.5px]",Eh),children:f}),n&&a.jsx(tRt,{report:n})]})}const mMt=y.memo(function({item:t,secretarySession:n=!1,onToggleGroup:r,onToggleTurn:s}){const o=GEt(),i=o.query,l=o.activeKey===t.key?o.activeNth:-1,c=n;switch(t.kind){case"user":{const u=t.text?iMt(t.text):!1,d=t.collapsed===!0,f=t.hostTaskWrapUp?AJe(t.text):t.text;return a.jsxs("div",{"data-enso":"message-user",className:ve("group/user flex flex-col gap-1.5",u?"items-start":"items-end"),children:[t.images.map((h,p)=>a.jsx(QN,{src:`data:${h.mimeType};base64,${h.data}`,className:"max-h-48 max-w-full rounded-lg border object-contain"},p)),t.text&&a.jsx(wp,{text:t.text,searchQuery:i,activeNth:l,thumbnails:t.images.length,align:u?"start":"end",hostTaskWrapUp:t.hostTaskWrapUp===!0}),d?a.jsx(IMt,{turnKey:t.key,text:f,timestamp:t.timestamp,turnDurationMs:t.turnDurationMs,onToggle:s}):a.jsx(jMt,{turnKey:t.key,messageIndex:Number(t.key),text:f,timestamp:t.timestamp,deliveryState:t.deliveryState,canCollapse:t.canCollapse,onToggleTurn:s})]})}case"text":return a.jsx(MMt,{item:t,searchQuery:i,activeNth:l});case"thinking":return a.jsx(OMt,{itemKey:t.key,text:t.text,streaming:t.streaming,durationMs:t.durationMs,startedAt:t.startedAt});case"tool":{const u=M3t(t),d=iN(t.name,c),f=a.jsxs(a.Fragment,{children:[a.jsx(_wt,{name:t.name,output:t.output,state:t.state}),d?a.jsx(DRt,{item:t,framed:c}):a.jsx(VMt,{item:t}),u?a.jsx(L3t,{proposalId:u}):null,t.pluginArtifacts?a.jsx(gjt,{artifacts:t.pluginArtifacts,align:d?"card":"tool-row"}):null]});return d?a.jsx("div",{"data-enso":"tool-card-pair",className:"w-full min-w-0",children:f}):f}case"tool-group":return a.jsx(zMt,{item:t,onToggle:r});case"error":return a.jsxs("div",{className:"flex items-start gap-2 text-sm text-destructive",children:[a.jsx(qa,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),a.jsx("p",{className:"min-w-0 flex-1 whitespace-pre-wrap",children:t.text}),a.jsx(p5e,{})]});case"interrupted":return a.jsx(wMt,{item:t});case"task-note":return a.jsx(DMt,{item:t});case"compaction":case"compaction-notice":return a.jsx(FMt,{item:t});case"compaction-progress":return a.jsx(BMt,{state:t.state});case"session-custom":return a.jsx(yMt,{entry:t.entry});case"plugin-message":return a.jsx(vMt,{item:t});case"discarded-turn":return a.jsx(xMt,{item:t,onToggle:r});case"resumed-reply":return a.jsx(bMt,{item:t,onToggle:r});case"divider":return a.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-muted-foreground",children:[a.jsx("span",{className:"h-px flex-1 bg-border"}),t.text,a.jsx("span",{className:"h-px flex-1 bg-border"})]})}},$Rt),Dle=e=>{if(typeof e=="string")return e;if(e===void 0)return"—";try{return JSON.stringify(e)}catch{return String(e)}};function gMt({entry:e}){const{t}=Se(),n=tjt(),r=n.get(e.accountKey),s=e.previousAccountKey?n.get(e.previousAccountKey):void 0,o=e.previousAccountKey?s&&r?t("ChatGPT account switched: {{previous}} → {{current}}",{previous:s,current:r}):t("ChatGPT account switched"):r?t("ChatGPT account selected: {{account}}",{account:r}):t("ChatGPT account selected");return a.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-border/60 bg-muted/20 px-2.5 py-2 text-xs",children:[a.jsx(bo,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-primary"}),a.jsx("p",{className:"min-w-0 break-words text-muted-foreground",children:o})]})}function vMt({item:e}){const{t}=Se();return a.jsxs("div",{"data-plugin-message":e.pluginId,className:"rounded-md border border-dashed border-border bg-muted/20 px-3 py-2 text-xs",children:[a.jsxs("p",{className:"mb-1 flex items-center gap-1.5 text-muted-foreground",children:[a.jsx(YP,{pluginId:e.pluginId,className:"h-3.5 w-3.5 shrink-0"}),a.jsx("span",{children:t("From plugin {{name}}",{name:e.pluginName})}),a.jsx("span",{className:"font-mono opacity-70",children:e.pluginId})]}),a.jsx("div",{className:f5e,children:a.jsx(ua,{text:e.text})})]})}const f5e="break-words text-foreground [&_p]:whitespace-pre-line";function xMt({item:e,onToggle:t}){const{t:n}=Se();return a.jsxs("div",{"data-discarded-turn":e.pluginId,children:[a.jsxs("button",{type:"button",onClick:()=>t?.(e.key),"data-enso":"tool-row",className:ve("group/step flex min-h-6 w-full items-center gap-2 text-left text-[13px] transition-colors hover:text-foreground",Eh),children:[a.jsx(FW,{className:"h-3.5 w-3.5 shrink-0"}),a.jsx("span",{className:"shrink-0 text-muted-foreground group-hover/step:text-foreground",children:wg("turn_discard",n)}),a.jsx("span",{className:"min-w-0 flex-1 truncate",children:[e.pluginName,e.reason].filter(Boolean).join(" · ")}),a.jsx(Bs,{className:ve("h-3 w-3 shrink-0 transition-transform",e.expanded&&"rotate-90")})]}),e.expanded&&a.jsxs("div",{className:"t-acc-reveal mt-1 mb-1.5 ml-5 space-y-2 rounded-md border border-dashed border-border bg-muted/20 px-3 py-2 text-xs",children:[a.jsxs("p",{className:"flex items-center gap-1.5 text-muted-foreground",children:[a.jsx(YP,{pluginId:e.pluginId,className:"h-3.5 w-3.5 shrink-0"}),a.jsx("span",{children:n("From plugin {{name}}",{name:e.pluginName})})]}),e.messages.map((r,s)=>a.jsx("div",{className:f5e,children:a.jsx(ua,{text:r})},s)),e.tools.map((r,s)=>a.jsxs("p",{className:ve("truncate",Eh),children:[wg(r.name,n)," ",r.summary]},s))]})]})}function bMt({item:e,onToggle:t}){const{t:n}=Se();return a.jsxs("div",{"data-resumed-reply":"",children:[a.jsxs("button",{type:"button",onClick:()=>t?.(e.key),"aria-expanded":e.expanded,"data-enso":"tool-row",className:ve("group/step flex min-h-6 w-full items-center gap-2 text-left text-[13px] transition-colors hover:text-foreground",Eh),children:[a.jsx(Ixe,{className:"h-3.5 w-3.5 shrink-0"}),a.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[n("Interrupted by a restart, continued below"),a.jsx("span",{className:"ml-1.5 opacity-70",children:e.expanded?n("Hide the interrupted part"):n("Show the interrupted part")})]}),a.jsx(Bs,{className:ve("h-3 w-3 shrink-0 transition-transform",e.expanded&&"rotate-90")})]}),e.expanded&&a.jsxs("div",{className:"t-acc-reveal mt-1 mb-1.5 ml-5 space-y-2 rounded-md border border-dashed border-border bg-muted/20 px-3 py-2 text-xs",children:[e.thinking&&a.jsx("p",{className:ve("whitespace-pre-wrap break-words",Eh),children:e.thinking}),e.text&&a.jsx("p",{className:"whitespace-pre-wrap break-words text-foreground",children:e.text}),e.tools.map((r,s)=>a.jsxs("p",{className:ve("truncate",Eh),children:[wg(r.name,n)," ",r.summary]},s))]})]})}function yMt({entry:e}){const{t}=Se();if(e.kind==="oauth-account-selected")return a.jsx(gMt,{entry:e});if(e.kind==="agent-dispatch")return a.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border/60 bg-muted/20 px-2.5 py-2 text-xs",children:[a.jsx(Jl,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),a.jsx("span",{className:"text-muted-foreground",children:t("Dispatched to")}),a.jsx("span",{className:"font-medium",children:e.child.instanceName})]});if(e.kind==="agent-completed")return a.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-emerald-500/20 bg-emerald-500/5 px-2.5 py-2 text-xs",children:[a.jsx(Is,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-emerald-500"}),a.jsxs("div",{className:"min-w-0",children:[a.jsxs("p",{className:"font-medium",children:[e.child.instanceName," · ",t("Completed")]}),e.receiptSummary&&a.jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-muted-foreground",children:e.receiptSummary})]})]});if(e.kind==="agent-failed")return a.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-destructive/20 bg-destructive/5 px-2.5 py-2 text-xs",children:[a.jsx(qa,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-destructive"}),a.jsxs("div",{className:"min-w-0",children:[a.jsxs("p",{className:"font-medium",children:[e.child.instanceName," · ",t("Failed")]}),a.jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-muted-foreground",children:e.message})]})]});if(e.kind==="tool-batch-label")return null;if(e.kind==="task-wrap-up-nudge")return a.jsxs("div",{"data-enso":"task-wrap-up-nudge",className:"my-1 flex items-center gap-1.5 text-[12px] text-subtle-foreground",children:[a.jsx(vg,{className:"size-3.5 shrink-0"}),t("{{count}} background tasks are still undeclared; the next message asks the agent to stop each one or state why it keeps running",{count:e.count})]});const n=e.receipt,r=n.outcome==="succeeded";return a.jsx("div",{className:ve("rounded-md border px-2.5 py-2 text-xs",r?"border-emerald-500/20 bg-emerald-500/5":n.outcome==="failed"?"border-destructive/20 bg-destructive/5":"border-amber-500/20 bg-amber-500/5"),children:a.jsxs("div",{className:"flex items-start gap-2",children:[r?a.jsx(Is,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-emerald-500"}):a.jsx(qa,{className:ve("mt-0.5 h-3.5 w-3.5 shrink-0",n.outcome==="failed"?"text-destructive":"text-amber-500")}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("p",{className:"font-medium",children:[n.subject.label," · ",t(n.outcome)]}),a.jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-muted-foreground",children:n.summary}),n.changes&&n.changes.length>0&&a.jsx("dl",{className:"mt-2 space-y-1 border-t border-border/50 pt-2",children:n.changes.map(s=>a.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] gap-2",children:[a.jsx("dt",{className:"truncate text-muted-foreground",children:s.field}),a.jsxs("dd",{className:"text-right font-mono",children:[Dle(s.previous)," → ",Dle(s.value)]})]},s.field))})]})]})})}function Wa(e){const t=e.activeId?e.conversations[e.activeId]:null;return t?t.activeTabId?e.conversations[t.activeTabId]??t:t:null}const h5e=()=>()=>{};function wMt({item:e}){const{locale:t}=Se(),n=vIt({at:e.at,kind:e.exitKind,unfinishedTools:e.unfinishedTools,lang:t});return a.jsxs("div",{"data-enso":"timeline-interrupted",className:"flex items-start gap-2 text-sm text-warning",children:[a.jsx(qa,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),a.jsx("p",{className:"min-w-0 flex-1 whitespace-pre-wrap",children:n}),a.jsx(kMt,{})]})}function kMt(){const{t:e}=Se();return it(n=>{const r=Wa(n);return!!(r&&!r.spawning&&r.status!=="running")})?a.jsxs("button",{type:"button","data-enso":"timeline-interrupted-retry",title:e("Retry"),onClick:()=>{const n=Wa(it.getState());n&&it.getState().retryInterrupted(n.id)},className:"mt-0.5 inline-flex shrink-0 items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground",children:[a.jsx(bo,{className:"h-3 w-3"}),e("Retry")]}):null}function p5e(){const{t:e}=Se(),t=Ud(),n=t?.botControls,r=it(l=>{if(t&&(!t.canRetry||t.botControls))return!1;const c=Wa(l);return!!(c?.started&&!c.spawning&&c.status!=="running")}),s=()=>{if(!n||!t?.canRetry)return!1;const l=n.projection();return!!(l&&l.status!=="running")},o=y.useSyncExternalStore(n?.subscribe??h5e,s,s);return(n?o:r)?a.jsxs("button",{type:"button",title:e("Retry"),onClick:()=>{if(n)return n.retry();const l=Wa(it.getState());l&&it.getState().retry(l.id)},className:"mt-0.5 inline-flex shrink-0 items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground",children:[a.jsx(bo,{className:"h-3 w-3"}),e("Retry")]}):null}function SMt(e,t){return oet(Wa(e),t)}const LK="flex items-center gap-1 text-[11px] text-muted-foreground transition-opacity hover:text-foreground";function CMt({messageIndex:e}){const{t}=Se(),n=Ud();return it(s=>{const o=Wa(s);return iet(o,n,o?y_(s.conversations,o.id):1)})?a.jsxs("button",{type:"button",className:LK,title:t("Keep this session and start a parallel one from here"),onClick:()=>{const s=it.getState(),o=Wa(s);o&&s.forkFromTurn(o.id,e)},children:[a.jsx(wf,{className:"h-3 w-3"}),t("Conversation branch")]}):null}function EMt({messageIndex:e}){const{t}=Se(),n=Ud(),r=it(o=>Wa(o)?.id),s=it(o=>{const i=r?o.conversations[r]:void 0;if(n||!i||i.historyOnly||i.rewinding||i.restoringFiles||i.workspaceMigrating)return;const l=i.messages[e-(i.historyBaseIndex??0)];return DM(l)||i.status==="running"&&Z1e(l)?l?.deliveryId:void 0});return!r||!s?null:a.jsxs("button",{type:"button",title:t("Withdraw message"),onClick:()=>it.getState().withdrawMessage(r,{kind:"delivery",id:s}),className:"inline-flex items-center gap-1 hover:text-foreground",children:[a.jsx(kT,{className:"h-3 w-3"}),t("Withdraw message")]})}function TMt(){const{t:e}=Se(),t=it(n=>Wa(n)?.id);return t?a.jsxs("button",{type:"button",onClick:()=>{_Ne(t,e)},className:"inline-flex items-center gap-1 hover:text-foreground",children:[a.jsx($u,{className:"h-3 w-3"}),e("Restart conversation")]}):null}function AMt({messageIndex:e}){const{t}=Se(),n=Ud(),r=it(o=>Wa(o)?.id),s=it(o=>{const i=r?o.conversations[r]:void 0;if(n||!i||i.historyOnly)return;const l=i.messages[e-(i.historyBaseIndex??0)];return DM(l)?l?.deliveryId:void 0});return!r||!s?null:a.jsxs("button",{type:"button",title:t("Resend"),onClick:()=>it.getState().resendMessage(r,s),className:"inline-flex items-center gap-1 hover:text-foreground",children:[a.jsx(bo,{className:"h-3 w-3"}),t("Resend")]})}function NMt({messageIndex:e}){const{t}=Se(),[n,r]=y.useState(!1),[s,o]=y.useState(null),i=Ud(),l=i?.botControls,c=it(v=>{if(i?.botControls)return!1;const b=Wa(v);return SMt(v,i)&&!!(b&&SI(b.id,b.id,b,e))}),u=()=>{if(!l||!i?.canRewind||!i.sessionId)return null;const v=l.projection();return!v||v.status==="running"?null:SI(i.sessionId,i.sessionId,v,e)?.entryId??null},d=y.useSyncExternalStore(l?.subscribe??h5e,u,u);if(!(l?d!==null:c))return null;const h=v=>{if(l&&i?.sessionId&&d){o({restoreFiles:v,conversationId:i.sessionId,entryId:d});return}const b=Wa(it.getState());if(!b)return;const x=SI(b.id,b.id,b,e);x&&o({restoreFiles:v,conversationId:b.id,entryId:x.entryId})},p=(v,b,x)=>{if(l)return l.rewind(x,v);const S=it.getState(),k=Wa(S),C=SI(b,k?.id,S.conversations[b],e,x);C&&S.rewind(C.conversationId,C.entryId,v)},m=[{icon:kT,label:t("Conversation only"),desc:t("Rewind to this message"),restoreFiles:!1,action:()=>h(!1)},{icon:Xp,label:t("Conversation + files"),desc:t("Rewind and restore files to before this turn"),restoreFiles:!0,action:()=>h(!0)}];return a.jsxs(Gu,{open:n,onOpenChange:r,children:[a.jsxs(Wu,{className:LK,title:t("Rewind to this message"),children:[a.jsx(kT,{className:"h-3 w-3"}),t("Rewind")]}),a.jsx(qu,{side:"bottom",align:"end",className:"w-72 [&_[data-slot=popover-viewport]]:p-1",children:m.map(v=>a.jsxs("button",{type:"button",onClick:()=>{r(!1),v.action()},className:"flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-muted/60",children:[a.jsx(v.icon,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:"block",children:v.label}),a.jsx("span",{className:"block text-xs text-muted-foreground",children:v.desc})]})]},v.label))}),a.jsx(ec,{open:s!==null,onOpenChange:v=>{v||o(null)},title:t("Rewind to this message?"),description:s?.restoreFiles?t("Later messages leave the current branch and working-tree files are restored to before this turn."):t("Later messages leave the current branch; the text returns to the input box."),confirmLabel:t("Rewind"),onConfirm:()=>{s&&p(s.restoreFiles,s.conversationId,s.entryId)}})]})}function IMt({turnKey:e,text:t,timestamp:n,turnDurationMs:r,onToggle:s}){const{t:o}=Se();return a.jsxs("div",{"data-quote-skip":"",className:"flex items-center gap-1.5 text-[11px] text-muted-foreground/80 select-none",children:[a.jsxs("button",{type:"button",onClick:()=>s?.(e,!1),className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-muted-foreground transition-colors hover:bg-muted/70 hover:text-foreground cursor-pointer border border-border/40",title:o("Expand"),children:[a.jsx(Bs,{className:"h-3 w-3 shrink-0"}),a.jsx("span",{children:o("Expand")})]}),a.jsx(m5e,{text:t}),typeof n=="number"&&a.jsx("span",{children:QP(n)}),r!==void 0&&a.jsxs("span",{children:["· ",o("took {{duration}}",{duration:pl(r)})]})]})}function m5e({text:e}){return e.trim()?a.jsx("span",{"data-enso":"copy-user-prompt",className:"inline-flex",children:a.jsx(g5e,{text:d_(e),className:"opacity-0 transition-opacity group-hover/user:opacity-100 focus-visible:opacity-100"})}):null}function jMt({turnKey:e,messageIndex:t,text:n,timestamp:r,canCollapse:s,deliveryState:o,onToggleTurn:i}){const{t:l}=Se(),c=be(u=>u.autoCollapseTurns);return a.jsxs("div",{"data-quote-skip":"",className:"flex items-center gap-2 text-[11px] text-muted-foreground/75 select-none",children:[a.jsx(NMt,{messageIndex:t}),a.jsx(AMt,{messageIndex:t}),a.jsx(EMt,{messageIndex:t}),a.jsx(m5e,{text:n}),o&&a.jsx("span",{children:l(o==="stuck"?"Not sent: the previous turn is stuck and could not be interrupted. Restart the conversation, then resend.":o==="rejected"?"Not sent":"Delivery unconfirmed")}),o==="stuck"&&a.jsx(TMt,{}),c&&s&&i&&a.jsxs("button",{type:"button",onClick:()=>i(e,!0),className:ve(LK,"cursor-pointer opacity-0 group-hover/user:opacity-100"),title:l("Collapse"),children:[a.jsx(Ho,{className:"h-3 w-3 shrink-0"}),a.jsx("span",{children:l("Collapse")})]}),typeof r=="number"&&a.jsx("span",{children:QP(r)})]})}function RMt({turnKey:e,canCollapse:t,collapsed:n,onToggleTurn:r}){const{t:s}=Se();return!be(i=>i.autoCollapseTurns)||!t||!r||n?null:a.jsxs("button",{type:"button","data-enso":"turn-collapse","data-quote-skip":"",onClick:()=>r(e,!0),className:ve("mt-1 flex min-h-6 select-none items-center gap-1 text-[12px] transition-colors hover:text-foreground [@media(hover:none)]:min-h-10 [@media(hover:none)]:pr-3",Eh),children:[a.jsx($4,{className:"h-3 w-3"}),a.jsx("span",{children:s("Collapse")})]})}function MMt({item:e,searchQuery:t="",activeNth:n=-1}){const{t:r}=Se(),s=Ud(),o=e.perf?_Mt(e.perf,r,e.turnDurationMs!==void 0):"",i=it(u=>Wa(u)?.id??null),l=Number(e.key.split("-")[0]),c={text:e.text,messageIndex:l,sessionId:s?s.sessionId:i};return a.jsxs("div",{"data-enso":"message-assistant",className:"group text-(length:--chat-body-size)",children:[a.jsx(ua,{text:e.text,streaming:e.streaming,searchQuery:t,activeNth:n,leaf:{messageIndex:c.messageIndex,sessionId:c.sessionId}}),e.turnEnd&&!e.streaming&&s?.turnFooter?.(Number(e.key.split("-")[0])),!e.streaming&&a.jsxs("div",{"data-quote-skip":"",className:"mt-1 flex items-center gap-2 text-[11px] text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100",children:[a.jsx(Iie,{position:"left",...c}),a.jsx(g5e,{text:e.text}),a.jsx(Iie,{position:"right",...c}),e.turnEnd&&a.jsx(CMt,{messageIndex:Number(e.key.split("-")[0])}),e.timestamp&&!e.turnEnd&&a.jsx("span",{children:QP(e.timestamp)}),e.turnDurationMs!==void 0&&a.jsxs("span",{children:[e.timestamp&&!e.turnEnd&&"· ",r("took {{duration}}",{duration:pl(e.turnDurationMs)})]}),o&&a.jsxs("span",{children:["· ",o]})]})]})}function g5e({text:e,className:t}){const{t:n}=Se(),[r,s]=y.useState(!1);return a.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(e).then(()=>{s(!0),setTimeout(()=>s(!1),1e3)})},className:ve("flex items-center gap-1 transition-colors hover:text-foreground",t),title:n("Copy"),children:r?a.jsx(Is,{className:"h-3 w-3"}):a.jsx(zd,{className:"h-3 w-3"})})}const Ble=e=>String(e).padStart(2,"0"),QP=e=>{const t=new Date(e);return`${Ble(t.getHours())}:${Ble(t.getMinutes())}`},Fle=e=>{const t=e/1e3;return t<10?String(Math.round(t*10)/10):String(Math.round(t))};function _Mt(e,t,n=!1){const r=[];return(!n||e.turnMs!==void 0)&&r.push(`${Fle(e.runMs)}s`),e.ttftMs!==void 0&&r.push(`TTFT ${Fle(e.ttftMs)}s`),e.tps!==void 0&&r.push(`${Math.round(e.tps)} tok/s`),!n&&e.turnMs!==void 0&&r.push(t("total {{duration}}",{duration:pl(e.turnMs)})),r.join(" · ")}function PMt(e,t,n=16){return e.top<t.top?e.top-t.top-n:e.bottom>t.bottom?e.bottom-t.bottom+n:0}function LMt(e){let t=e.parentElement;for(;t;){if(t.hasAttribute("data-virtuoso-scroller"))return t;const n=typeof window.getComputedStyle=="function"?window.getComputedStyle(t).overflowY:t.style.overflowY;if(n==="auto"||n==="scroll"||n==="overlay")return t;t=t.parentElement}return null}function v5e(e,t=LMt(e)){if(!t){e.getBoundingClientRect().top<0&&e.scrollIntoView?.({block:"nearest"});return}const n=PMt(e.getBoundingClientRect(),t.getBoundingClientRect());n!==0&&(t.scrollTop=Math.max(0,t.scrollTop+n))}function OMt({itemKey:e,text:t,streaming:n,durationMs:r,startedAt:s}){const{t:o}=Se(),i=be(h=>h.expandLiveReasoning),[l,c]=y.useState(null),u=tnt(l,n,i),d=y.useRef(null),f=y.useRef(!1);return y.useLayoutEffect(()=>{u||!f.current||(f.current=!1,d.current&&v5e(d.current))},[u]),a.jsxs("div",{ref:d,"data-enso":"thinking","data-live":n||void 0,children:[a.jsxs("button",{type:"button","data-quote-skip":"",onClick:()=>c(!u),className:ve("flex min-h-6 select-none items-center gap-2 text-[13px] transition-colors hover:text-foreground",Eh),children:[a.jsx("span",{className:"flex size-3 shrink-0 items-center justify-center",children:a.jsx(vT,{className:ve("size-3",n&&"animate-pulse text-brand")})}),n?a.jsx("span",{className:ve("text-foreground",ek),children:o("Thinking…")}):r!==null?a.jsx("span",{children:o("Thought for {{duration}}",{duration:pl(r)})}):a.jsx("span",{children:o("Thought process")}),n&&a.jsx(x5e,{itemKey:e,since:s}),a.jsx(Bs,{className:ve("h-3 w-3 transition-transform",u&&"rotate-90")})]}),u&&a.jsx(Pwt,{text:t,streaming:n,itemKey:e}),u&&!n&&a.jsxs("button",{type:"button","data-enso":"thinking-collapse","data-quote-skip":"",onClick:()=>{f.current=!0,c(!1)},className:ve("mt-1 ml-[31px] flex min-h-6 select-none items-center gap-1 text-[12px] transition-colors hover:text-foreground",Eh),children:[a.jsx($4,{className:"h-3 w-3"}),a.jsx("span",{children:o("Collapse thinking")})]})]})}function DMt({item:e}){const{t}=Se(),[n,r]=y.useState(!1),[s,o]=y.useState(void 0),i=/^Background task (\S+) finished \((.+?), ran (.+?)\)/.exec(e.summary),l=i?`${i[1]} · ${i[2]} · ${i[3]}`:e.summary,c=/(?:read ((?:\/|[A-Za-z]:[\\/]).+?\.log) for the complete log|Full log: ((?:\/|[A-Za-z]:[\\/])\S+?\.log))/.exec(e.detail)?.slice(1).find(Boolean)??null;return y.useEffect(()=>{!n||!c||s!==void 0||window.electronAPI.files.read(c).then(u=>{o(typeof u=="string"?u:null)}).catch(()=>o(null))},[n,c,s]),a.jsxs("div",{children:[a.jsxs("button",{type:"button",onClick:()=>r(u=>!u),className:"flex w-full items-center gap-3",title:e.detail,children:[a.jsx("span",{className:"h-px flex-1 bg-border"}),a.jsxs("span",{className:"flex shrink-0 items-center gap-1.5 text-[11px] text-muted-foreground transition-colors hover:text-foreground",children:[a.jsx(Is,{className:"h-3 w-3 text-green-600 dark:text-green-500"}),l,a.jsx(Bs,{className:ve("h-3 w-3 transition-transform",n&&"rotate-90")})]}),a.jsx("span",{className:"h-px flex-1 bg-border"})]}),n&&a.jsxs("div",{className:"mt-1.5 rounded-lg border border-border/60 bg-muted/20",children:[a.jsx("pre",{className:"border-b border-border/60 px-3 py-2 font-mono text-[11px] leading-relaxed whitespace-pre-wrap text-muted-foreground",children:e.detail}),a.jsx("pre",{className:"max-h-64 overflow-auto px-3 py-2 font-mono text-xs leading-relaxed whitespace-pre-wrap text-muted-foreground",children:c?s===void 0?t("Loading…"):If(s??t("(log unavailable)")):t("(no log available)")})]})]})}function BMt({state:e}){const{t}=Se();return a.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[a.jsx(Jn,{className:"h-3 w-3 animate-spin"}),a.jsx("span",{children:t(e==="queued"?"Compacts after this turn":"Compacting…")})]})}function FMt({item:e}){const{t}=Se(),[n,r]=y.useState(!1),s=e.kind==="compaction",o=e.tokensBefore===null?null:Va(e.tokensBefore),i=Rjt(e.tokensBefore,e.tokensAfter),l=i!==null&&e.tokensBefore!==null&&e.tokensAfter!==void 0?t("{{kind}} · {{before}} → {{after}} · freed {{percent}}%",{kind:t(e.memory?"Memory context compacted":e.verified?"Verified context compacted":"Context compacted"),before:Va(e.tokensBefore),after:Va(e.tokensAfter),percent:i}):e.memory?o===null?t("Memory context compacted"):t("Memory context compacted ({{tokens}} tokens before)",{tokens:o}):e.verified?o===null?t("Verified context compacted"):t("Verified context compacted ({{tokens}} tokens before)",{tokens:o}):o===null?t("Context compacted"):t("Context compacted ({{tokens}} tokens before)",{tokens:o});return a.jsxs("div",{children:[a.jsxs("button",{type:"button",onClick:()=>r(c=>!c),className:ve("flex items-center gap-3",s&&"w-full"),title:e.memory?t("Summary rendered from continuous memory. Messages above are no longer in the model context; use recall for sources."):e.verified?t("Verified summary from smart compaction. Messages above are no longer in the model context."):t(s?"Messages above are no longer in the model context; only this summary is.":"Latest compaction summary — expand to read what the model kept."),children:[s&&a.jsx("span",{className:"h-px flex-1 bg-border"}),a.jsxs("span",{className:"flex shrink-0 items-center gap-1.5 text-[11px] text-muted-foreground transition-colors hover:text-foreground",children:[a.jsx(vUe,{className:"h-3 w-3"}),l,a.jsx(Bs,{className:ve("h-3 w-3 transition-transform",n&&"rotate-90")})]}),s&&a.jsx("span",{className:"h-px flex-1 bg-border"})]}),n&&a.jsx("pre",{className:"mt-1.5 max-h-80 overflow-auto rounded-lg border border-border/60 bg-muted/20 px-3 py-2 font-mono text-[11px] leading-relaxed whitespace-pre-wrap text-muted-foreground",children:e.summary||t("(summary unavailable)")})]})}function zMt({item:e,onToggle:t}){const{t:n}=Se(),r=be(m=>m.compactReadOnlyTools),s=[];e.stats.commands>0&&s.push(n("ran {{count}} commands",{count:e.stats.commands})),e.stats.reads>0&&s.push(n("read {{count}} files",{count:e.stats.reads})),e.stats.searches>0&&s.push(n("searched {{count}} times",{count:e.stats.searches})),e.stats.others>0&&s.push(n("{{count}} other calls",{count:e.stats.others}));const o=[];r&&(e.stats.reads>0&&o.push(n("{{count}} files",{count:e.stats.reads})),e.stats.searches>0&&o.push(n("{{count}} searches",{count:e.stats.searches})));const i=e.activity,l=[];i&&(i.thinking>0&&l.push(n("{{count}} thinking steps",{count:i.thinking})),e.count>0&&l.push(n("{{count}} tool calls",{count:e.count})));const c=e.explore,u=e.exploring||!!(i&&e.live),d=e.notice==="patrol"?n("Patrol clear"):e.notice==="seen"?n("Update seen"):null,f=c?wg("explore_fold",n):d||(i?n("Worked for {{duration}}",{duration:pl(i.workedMs)}):r?e.exploring?n("Exploring"):n("Explored"):n("{{count}} tool calls",{count:e.count})),h=c?[c.goal,n("{{count}} tool calls",{count:e.count})].filter(Boolean):d?l:e.summary&&!e.exploring?[e.summary]:i?l:r?o:s,p=a.jsxs("button",{type:"button",onClick:()=>{c?.steps&&t?.(tH(e.key)),t?.(e.key)},title:c?.goal,"data-explore-head":c?"":void 0,"data-enso":"tool-row","data-notice":e.notice,className:ve("group/step flex min-h-6 w-full items-center gap-2 text-left text-[13px] transition-colors hover:text-foreground",Eh),children:[a.jsx(J$,{state:e.exploring?"running":"ok"}),a.jsx("span",{className:ve("shrink-0 text-muted-foreground group-hover/step:text-foreground",u&&ve(ek,"text-foreground"),e.exploring&&"font-medium"),children:f}),a.jsx("span",{className:ve("min-w-0 flex-1 truncate",u&&ek),children:h.join(" · ")}),a.jsx(Bs,{className:ve("h-3 w-3 shrink-0 transition-transform",e.expanded&&"rotate-90")})]});return!c||!e.expanded?p:a.jsxs(a.Fragment,{children:[p,a.jsxs("div",{"data-slot":"tool-details",className:"t-acc-reveal mt-1 mb-1.5 ml-5 overflow-hidden rounded-lg border border-border/70 bg-card text-sm shadow-xs",children:[c.goal&&a.jsxs("div",{className:"border-b border-border/60 px-3 py-2",children:[a.jsx("div",{className:"mb-0.5 text-[11px] text-muted-foreground",children:n("Goal")}),a.jsx("p",{className:"whitespace-pre-wrap",children:c.goal})]}),c.report&&a.jsxs("div",{className:"border-b border-border/60 px-3 py-2",children:[a.jsx("div",{className:"mb-0.5 text-[11px] text-muted-foreground",children:n("Result")}),a.jsx(ua,{text:c.report})]}),a.jsxs("button",{type:"button",onClick:()=>t?.(tH(e.key)),className:"flex w-full items-center gap-1.5 px-3 py-1.5 text-left text-xs text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground",children:[a.jsx(Bs,{className:ve("h-3 w-3 shrink-0 transition-transform",c.steps&&"rotate-90")}),a.jsx("span",{children:c.steps?n("Hide process"):n("Show process")}),a.jsxs("span",{children:["· ",n("{{count}} tool calls",{count:e.count})]})]})]})]})}function cC({children:e,className:t,follow:n}){const r=y.useRef(null),s=y.useRef(null),o=y.useRef(n),i=y.useRef(n),l=y.useRef(null),c=y.useRef(null),u=y.useRef(0);i.current=n;const d=y.useCallback(()=>{o.current=!1,l.current=null,cancelAnimationFrame(u.current)},[]),f=y.useCallback(()=>{!i.current||!o.current||(cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{const h=r.current;if(!h||!i.current||!o.current)return;const p=Math.max(0,h.scrollHeight-h.clientHeight);l.current=p,h.scrollTop=p}))},[]);return y.useEffect(()=>{n?(o.current=!0,f()):(l.current=null,cancelAnimationFrame(u.current))},[n,f]),y.useEffect(f),y.useEffect(()=>{const h=s.current;if(!h)return;const p=new ResizeObserver(f);return p.observe(h),()=>p.disconnect()},[f]),y.useEffect(()=>()=>cancelAnimationFrame(u.current),[]),a.jsx("div",{ref:r,onWheel:h=>{h.deltaY<0&&d()},onPointerDown:h=>{h.target===h.currentTarget&&d()},onTouchStart:h=>{c.current=h.touches[0]?.clientY??null},onTouchMove:h=>{const p=h.touches[0]?.clientY;p!==void 0&&c.current!==null&&p>c.current&&d(),c.current=p??null},onTouchEnd:()=>{c.current=null},onScroll:h=>{if(!i.current)return;const p=h.currentTarget;if(p.scrollHeight-p.scrollTop-p.clientHeight<=2){o.current=!0,l.current=null;return}const v=l.current;if(v!==null&&p.scrollTop>=v-2){l.current=null,f();return}d()},className:ve("max-h-96 overflow-auto [overflow-anchor:none]",t),children:a.jsx("div",{ref:s,children:e})})}function HMt(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)??""}catch{return String(e)}}function UMt({source:e,output:t,view:n}){const r=n?.status==="completed"?HMt(n.value):n?.error??t;return a.jsxs("div",{className:"space-y-1 px-3 py-1",children:[e?a.jsx(R6,{code:e,language:"javascript"}):null,n&&n.calls.length>0?a.jsx("div",{className:"flex flex-wrap gap-1",children:[...new Map(n.calls.map(s=>[s.name,s])).keys()].map(s=>{const o=n.calls.filter(c=>c.name===s),i=o.find(c=>!c.ok),l=`${s} ×${o.length}`;return a.jsx("span",{className:ve("rounded-md border px-1.5 py-0.5 font-mono text-[10px]",i?"border-destructive/40 text-destructive":"text-muted-foreground"),title:o.map(c=>c.summary).filter(Boolean).join(`
384
384
  `),children:i?`${l} · ${i.error??"error"}`:l},s)})}):null,r?n?.status==="completed"&&typeof n.value!="string"?a.jsx(R6,{code:r,language:"json"}):a.jsx("pre",{className:"font-mono text-xs leading-relaxed text-muted-foreground whitespace-pre-wrap",children:If(r)}):null,n?.console?a.jsx("pre",{className:"border-l-2 pl-2 font-mono text-xs leading-relaxed text-muted-foreground whitespace-pre-wrap",children:If(n.console)}):null]})}function zle({path:e,fallback:t}){const[n,r]=y.useState(!1);return n?t:a.jsx("div",{"data-slot":"read-image",className:"w-full min-w-0 px-3 py-3",children:a.jsx(QN,{src:CT(e),onError:()=>r(!0),frameClassName:"block w-full",className:"mx-auto block max-h-80 max-w-full rounded-md bg-muted/40 object-contain"})})}function VMt({item:e}){const{t}=Se(),n=Ud(),r=be(B=>B.compactReadOnlyTools),s=be(B=>B.expandLiveEdits),o=r&&e.name!=="bash"&&OM(e),i=!!(e.edits&&e.edits.length>0),l=!!e.writeContent,c=!!(e.fileChanges&&e.fileChanges.length>0),u=e.sandbox??null,d=e.state==="error"?null:e.sentMessage,f=!!e.imagePath&&e.state!=="error",h=Rq[e.name],p=sN(e.name),m=e.state!=="error"&&e.todos?.length===0,v=m?t("Todo list cleared"):e.subagentOp?[t(Rtt[e.subagentOp]),e.summary].filter(Boolean).join(" · "):e.summary,b=e.nestedPending&&e.state==="running"?`${v} · ${e.nestedPending} pending`:u?.calls.length&&e.state!=="error"?gnt(u.calls):v,x=!m&&!!(e.output||e.source||d||e.ask),S=e.state==="running"&&e.waiting==="subagent"&&!n,k=i||l||c||x||S||f,C=s&&(i||l||f)&&e.state==="running",[A,N]=y.useState(C),[j,I]=y.useState(!1),_=y.useRef(null),L=WRt();y.useEffect(()=>{if(!j)return;const B=_.current;if(!B)return;const H=e.key,G=L.report,ne=new IntersectionObserver(([W])=>G(H,W?.isIntersecting===!0),{root:L.scroller.current});return ne.observe(B),()=>{ne.disconnect(),G(H,!1)}},[j,e.key,L]);const M=A&&e.name==="memory_search"?I1e(e.output):null,F=A&&e.name==="memory_capture"?j1e(e.output,e.memoryContent):null,D=A&&e.name==="subagent"&&e.state!=="error"?TRt(e.subagentOp,e.output):null,R=e.name==="subagent"&&e.state==="error"?NRt(e.output):null,z=y.useRef(c);return y.useEffect(()=>{const B=ent(e,z.current);z.current=c,(C||s&&B)&&N(!0)},[C,s,c,e]),e.todos&&e.todos.length>0?a.jsx(qMt,{todos:e.todos}):e.name.startsWith("goal_")?a.jsx(GMt,{item:e}):e.plan&&e.state!=="error"?a.jsx(WMt,{plan:e.plan}):a.jsxs("div",{ref:_,"data-enso":"tool-row","data-tool-style":o?"compact":"full","data-user-open":j?"true":void 0,children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs("button",{type:"button",disabled:!k,onClick:()=>{const B=!A;N(B),I(B),L.report(e.key,B)},className:ve("group/step flex min-h-6 min-w-0 flex-1 items-center gap-2 text-left text-[13px]",Eh,k&&"cursor-pointer"),children:[a.jsx(J$,{state:e.state}),a.jsx("span",{className:ve("shrink-0 text-muted-foreground transition-colors group-hover/step:text-foreground",e.state==="running"&&ve(ek,"text-foreground")),children:h?t(h):p?.tool??e.name}),a.jsx("span",{className:ve("min-w-0 flex-1 truncate font-mono text-[12px]",e.state==="error"?"text-destructive":"text-muted-foreground",e.state==="running"&&ek),children:e.state==="error"&&e.output?v&&e.name==="apply_patch"&&c?`${b} · ${JMt(e.output)}`:R?t(R):r3t(If(e.output)):v?b:null}),e.backgroundTaskId&&a.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",title:e.backgroundTaskId,children:t("Moved to background")}),e.shellFailure&&e.state!=="running"&&a.jsx(pRt,{failure:e.shellFailure}),e.dcgWarning&&a.jsx(mRt,{warning:e.dcgWarning}),e.state==="reviewing"?a.jsx("span",{className:ve("shrink-0 text-[11px] text-foreground",ek),children:t("Assistant reviewing…")}):e.state==="running"&&e.startedAt!==null?a.jsxs(a.Fragment,{children:[e.callId&&(e.name==="bash"||e.name==="powershell")&&a.jsx(ZMt,{callId:e.callId,startedAt:e.startedAt,output:e.output??""}),a.jsx(x5e,{itemKey:e.key,since:e.startedAt??void 0})]}):(e.agentMeta||e.durationMs!==null)&&a.jsx("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground/70 tabular-nums",children:[e.agentMeta?.modelId,e.agentMeta?.outputTokens?`${e.agentMeta.outputTokens} tok`:null,e.durationMs!==null?pl(e.durationMs):null].filter(Boolean).join(" · ")}),k&&a.jsx(Bs,{className:ve("h-3 w-3 shrink-0 text-muted-foreground opacity-0 transition-[opacity,transform] group-hover/step:opacity-100",A&&"rotate-90 opacity-100")})]}),e.state==="running"&&e.callId&&!n&&a.jsx(YMt,{callId:e.callId,waiting:!!e.waiting}),(i||l||c)&&(e.state==="ok"||c)&&a.jsx("button",{type:"button",title:t("Open in side panel"),className:"flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:()=>jEe(),children:a.jsx(dHe,{className:"h-3 w-3"})})]}),e.generatedImages?.length?a.jsx("div",{"data-slot":"generated-images",className:"mt-2 mb-3 ml-5 grid gap-3",children:e.generatedImages.map(B=>a.jsx(zle,{path:B,fallback:a.jsx("p",{className:"break-all px-3 py-2 text-xs text-muted-foreground",children:B})},B))}):null,A&&k&&a.jsxs("div",{"data-slot":"tool-details",className:"t-acc-reveal mt-1 mb-1.5 ml-5 overflow-hidden rounded-lg border border-border/70 bg-card shadow-xs",children:[p&&a.jsxs("div",{className:"truncate border-b border-border/60 px-3 py-1 font-mono text-[10px] text-muted-foreground",children:[p.server,".",p.tool]}),S&&a.jsx(QMt,{agentIds:e.subagentTitles?Object.keys(e.subagentTitles):void 0}),i&&e.edits&&a.jsx(cC,{follow:e.state==="running",children:a.jsx(y.Suspense,{fallback:null,children:a.jsx(_le,{path:e.summary,blocks:e.edits})})}),c&&e.fileChanges&&a.jsx(cC,{follow:e.state==="running",children:e.fileChanges.map((B,H)=>a.jsxs("div",{children:[a.jsxs("div",{className:ve("flex items-center gap-2 border-border/60 px-3 py-1 font-mono text-[10px] text-muted-foreground",(H>0||i)&&"border-t"),children:[a.jsx("span",{className:"uppercase",children:B.type}),a.jsx("span",{className:"min-w-0 flex-1 truncate",title:B.path,children:B.path}),B.truncated&&a.jsx("span",{children:t("Truncated preview")})]}),a.jsx(y.Suspense,{fallback:null,children:a.jsx(_le,{path:B.path,blocks:[B],snapshot:B})})]},`${B.type}:${njt(B.path,B.oldText,B.newText)}`))}),nnt(e)&&a.jsx(cC,{follow:!1,className:"border-t border-border/60",children:a.jsx("pre",{className:"px-3 py-2 font-mono text-xs leading-relaxed text-muted-foreground whitespace-pre-wrap",children:If(e.output??"")})}),l&&e.writeContent&&a.jsx(cC,{follow:e.state==="running",className:ve((i||c)&&"border-t border-border/60"),children:a.jsx(y.Suspense,{fallback:null,children:a.jsx(f9,{path:e.summary,contents:e.writeContent})})}),!i&&!l&&!c&&(x||f)&&a.jsxs(cC,{follow:e.state==="running",children:[V1e(e.name)?a.jsx(UMt,{source:e.source,output:e.output,view:u}):e.name==="bash"||e.name==="powershell"?a.jsx(RRt,{command:e.summary,output:e.output??"",failure:e.shellFailure}):e.name==="read"&&f&&e.imagePath?a.jsx(zle,{path:e.imagePath,fallback:a.jsx(y.Suspense,{fallback:null,children:a.jsx(f9,{path:e.summary,contents:e.output??""})})},e.imagePath):e.name==="image_view"&&e.state==="ok"?a.jsx(PRt,{image:e.image,output:e.output}):e.name==="read"?a.jsx(y.Suspense,{fallback:null,children:a.jsx(f9,{path:e.summary,contents:e.output??""})}):e.name==="subagent"&&e.state!=="error"&&!d&&!D?a.jsx("div",{className:"px-3 py-2 text-sm",children:a.jsx(ua,{text:e.output??""})}):M?a.jsx(QU,{hits:M}):F?a.jsx(Pjt,{view:F}):a.jsxs(a.Fragment,{children:[e.ask&&a.jsx(kjt,{ask:e.ask,waiting:e.state==="running"}),d&&a.jsx("div",{className:"px-3 py-2 text-sm",children:a.jsx(ua,{text:d})}),D?a.jsx(kRt,{view:D,titles:e.subagentTitles}):e.output&&a.jsx("pre",{className:"px-3 py-2 font-mono text-xs leading-relaxed text-muted-foreground whitespace-pre-wrap",children:If(e.output)})]}),a.jsx(sRt,{value:e.rtk}),a.jsx(wjt,{value:e.approvalReview})]})]})]})}function GMt({item:e}){const{t}=Se(),n=e.name.replace("goal_",""),r=t(n==="complete"?"Goal completed":n==="blocked"?"Goal blocked":"Goal waiting");return a.jsxs("div",{className:ve("flex items-start gap-2 rounded-lg border px-3 py-2 text-sm",n==="complete"&&"border-green-500/50 bg-green-500/5",n==="blocked"&&"border-destructive/50 bg-destructive/5",n==="wait"&&"border-amber-500/50 bg-amber-500/5"),children:[a.jsx(i2,{className:ve("mt-0.5 h-4 w-4 shrink-0",n==="complete"&&"text-green-600 dark:text-green-500",n==="blocked"&&"text-destructive",n==="wait"&&"text-amber-500")}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"font-medium",children:r}),e.summary&&a.jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-muted-foreground text-xs",children:e.summary})]})]})}function WMt({plan:e}){const{t}=Se(),[n,r]=y.useState(!1);return a.jsxs("div",{className:"rounded-lg border border-border/60 bg-muted/30 px-3 py-2",children:[a.jsxs("button",{type:"button",onClick:()=>r(s=>!s),className:"flex w-full min-w-0 items-center gap-2 text-left text-xs",children:[a.jsx(rx,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),a.jsx("span",{className:"shrink-0 font-medium text-muted-foreground",children:t("Plan")}),a.jsx("span",{className:"min-w-0 flex-1 truncate",children:e.title}),a.jsx(Bs,{className:ve("h-3 w-3 shrink-0 text-muted-foreground transition-transform",n&&"rotate-90")})]}),n&&a.jsx("div",{className:"mt-2 border-border/60 border-t pt-2 text-sm",children:a.jsx(ua,{text:e.text})})]})}function qMt({todos:e}){const{t}=Se(),n=e.filter(r=>r.status==="completed").length;return a.jsxs("div",{"data-enso":"todo",className:"rounded-lg border bg-card px-3 py-2",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[a.jsx(RW,{className:"h-3.5 w-3.5 shrink-0"}),a.jsx("span",{className:"font-medium text-foreground",children:t("Todos")}),a.jsxs("span",{className:"ml-auto tabular-nums",children:[n,"/",e.length]})]}),a.jsx(e5e,{done:n,total:e.length,className:"mt-1.5 mb-2"}),a.jsx(JNe,{todos:e})]})}const Hle=new Map;function YMt({callId:e,waiting:t}){const{t:n}=Se(),r=it(c=>Wa(c)?.id??""),[s,o]=y.useState(!1);if(y.useEffect(()=>{if(!s)return;const c=setTimeout(()=>o(!1),5e3);return()=>clearTimeout(c)},[s]),!r)return null;const i=n(t?s?"Stopping wait…":"Stop waiting":s?"Moving to background…":"Move to background"),l=t?FW:uFe;return a.jsxs("button",{type:"button",disabled:s,title:i,className:"flex h-6 shrink-0 items-center gap-1 rounded-md px-1.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-60",onClick:()=>{o(!0),window.electronAPI.agent.backgroundTool(r,e).then(c=>{c.ok||o(!1)},()=>o(!1))},children:[a.jsx(l,{className:"h-3 w-3"}),i]})}const $Mt=5e3,KMt=[];function XMt(e,t){if(e.status==="queued")return t("Queued");const n=e.activity;return n?.phase==="tool"?[n.tool,n.detail].filter(Boolean).join(" "):n?.phase==="writing"?t("Writing reply…"):t("Thinking…")}function QMt({agentIds:e}){const{t}=Se(),n=it(l=>Wa(l)?.id??""),r=RM(l=>l.byConversation[n]??KMt),[s,o]=y.useState(!1);if(y.useEffect(()=>{if(!n)return;let l=!0;const c=h=>{l&&(RM.getState().replace(n,h),o(!0))},u=()=>window.electronAPI.agent.subagentProgress(n).then(c,()=>{}),d=window.electronAPI.agent.onSubagentProgress(h=>{h.sessionId===n&&c(h.runs)});u();const f=setInterval(u,$Mt);return()=>{l=!1,clearInterval(f),d()}},[n]),!s)return null;const i=e?.length?r.filter(l=>e.includes(l.agentId)):r;return a.jsxs("div",{className:"border-b border-border/60 px-3 py-2 text-xs",children:[i.length===0?a.jsx("div",{className:"text-muted-foreground",children:t("No running subagents")}):i.map(l=>a.jsxs("div",{className:"py-0.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"max-w-[40%] shrink-0 truncate font-medium",children:l.title??l.agentId.slice(0,8)}),a.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-muted-foreground",children:XMt(l,t)}),a.jsx("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground/70 tabular-nums",children:pl(l.elapsedMs)})]}),l.text&&a.jsx("div",{className:"line-clamp-2 break-words pl-2 text-[11px] text-muted-foreground/80",children:l.text.replace(/\s+/g," ")})]},l.runId)),a.jsx("div",{className:"mt-1 text-[11px] text-muted-foreground/80",children:t("Stopping the wait does not stop subagents; the assistant is notified when they finish.")})]})}function x5e({itemKey:e,since:t}){const n=Ud(),r=it(c=>Wa(c)?.id??""),s=n?n.sessionId??"":r,o=y.useRef(null);if(o.current===null){const c=`${s}:${e}`;o.current=t??Hle.get(c)??Date.now(),t===void 0&&Hle.set(c,o.current)}const i=t??o.current,[,l]=y.useState(0);return y.useEffect(()=>{const c=setInterval(()=>l(u=>u+1),1e3);return()=>clearInterval(c)},[]),a.jsx("span",{className:"shrink-0 font-mono text-[10px] text-muted-foreground/70 tabular-nums",children:pl(Date.now()-i)})}function ZMt({callId:e,startedAt:t,output:n}){const r=Ud(),s=it(o=>r?void 0:Wa(o)?.toolDeadlineAt?.[e]);return a.jsx(hRt,{startedAt:t,deadlineAt:s,output:n})}function Ule(e){return e.kind==="tool-group"?!0:e.kind==="tool"&&!e.todos?.length&&!e.name.startsWith("goal_")}const JMt=e=>If(e.split(`
385
- `,1)[0]??""),e6t=100;function t6t(e,t,n,r,s=e6t){if(r||!n)return{hiddenSince:t,delayMs:null};const o=t??e;return{hiddenSince:o,delayMs:Math.max(0,s-(e-o))}}const n6t=1e6;function r6t(e,t,n=n6t){if(t.length===0)return{anchor:null,firstItemIndex:n,remount:!1};if(!e)return{anchor:{keys:t,index:n},firstItemIndex:n,remount:!1};const r=new Map(t.map((s,o)=>[s,o]));for(let s=0;s<e.keys.length;s++){const o=r.get(e.keys[s]);if(o===void 0)continue;const i=e.index+s-o;return{anchor:{keys:t,index:i},firstItemIndex:i,remount:!1}}return{anchor:{keys:t,index:n},firstItemIndex:n,remount:!0}}function Vle(e,t){return t}const s6t=new Set(["text","thinking","tool","tool-group"]);function o6t(e,t,n,r){const s=y.useRef(rH),[o,i]=y.useState(()=>Date.now()),l=r.compact,c=r.autoCollapseCompletedTurns,u=r.collapseCompletedActivity===!0,d=r.collapseLiveActivity===!0,f=r.turnOverrides,h={compact:l,autoCollapseCompletedTurns:c,turnOverrides:f},p=d?drt(e,t,r,s.current,o):null;s.current=p?.witness??rH;const m=p?.wakeAt??null,v=xrt(e,t,n,{...h,collapseCompletedActivity:u,collapseLiveActivity:d,releasedLiveActivity:p?.released,heldOpenTools:r.heldOpenTools,foldToolOnlyTurns:r.foldToolOnlyTurns===!0,readableToolCards:r.readableToolCards===!0});return y.useEffect(()=>{if(m===null||m<=o)return;const b=window.setTimeout(()=>i(m),m-o);return()=>window.clearTimeout(b)},[m,o]),v}const i6t=[{icon:hze,title:"Map the project",hint:"Entry points, modules and key dependencies",prompt:"Walk me through this project's structure: entry points, module layout and key dependencies."},{icon:vxe,title:"Find potential issues",hint:"Suspicious logic and unhandled edge cases",prompt:"Review this project for potential bugs, suspicious logic and unhandled edge cases, and list them by severity."},{icon:NW,title:"Add unit tests",hint:"Cover the core modules with tests",prompt:"Find the core modules that lack tests and add unit tests for them."},{icon:Xp,title:"Summarize recent changes",hint:"A digest based on git log",prompt:"Summarize the recent changes in this repository based on git log."}],a6t=[{icon:_xe,title:"Check today's progress",hint:"Progress report and items waiting on you",prompt:"Summarize today's progress and list anything waiting on me."},{icon:zy,title:"Assign a task",hint:"A one-off job for the secretary to run",prompt:"Take care of a one-off task: "},{icon:rx,title:"Organize the to-do list",hint:"Sort the board into clear next steps",prompt:"Go through the board and organize it into clear next steps."},{icon:wf,title:"Clean up merged branches",hint:"Remove branches that are already merged",prompt:"Clean up merged branches and worktrees you no longer need."}];function l6t({onPick:e,variant:t="project"}){const{t:n}=Se(),r=t==="secretary"?a6t:i6t;return a.jsx("div",{className:"mx-auto grid w-full max-w-[560px] grid-cols-1 gap-2.5 text-left @min-[36rem]:grid-cols-2",children:r.map(({icon:s,title:o,hint:i,prompt:l})=>a.jsxs("button",{type:"button",onClick:()=>e(n(l)),"data-slot":"welcome-suggestion",className:"group flex items-start gap-3 rounded-xl border bg-card px-3.5 py-3 text-left shadow-xs transition-[border-color,box-shadow,transform] duration-200 hover:-translate-y-px hover:border-brand/25 hover:shadow-float",children:[a.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-lg bg-brand/8 text-brand dark:bg-brand/14",children:a.jsx(s,{className:"size-3.5"})}),a.jsxs("span",{className:"min-w-0",children:[a.jsx("span",{className:"block text-[13px] font-medium",children:n(o)}),a.jsx("span",{className:"block text-xs text-muted-foreground",children:n(i)})]})]},o))})}const Dg="enso-chat-col mx-auto w-full max-w-2xl px-4 @min-[56rem]:max-w-3xl @min-[72rem]:max-w-4xl @min-[84rem]:max-w-5xl @min-[96rem]:max-w-6xl @min-[112rem]:max-w-7xl",Gle=1e3;function Wle({className:e,children:t}){const[n,r]=y.useState(!1);return y.useEffect(()=>{const s=requestAnimationFrame(()=>r(!0));return()=>cancelAnimationFrame(s)},[]),a.jsx("div",{className:ve("t-stagger",n&&"is-shown",e),children:t})}const qle=40,c6t={index:"LAST",align:"end"},u6t={top:600,bottom:600},d6t=e=>e&&!AK()?"auto":!1,f6t={owners:new Map,ends:new Map};function h6t(e){const t=new Map,n=new Map;let r=null,s=null;const o=()=>{r&&s&&n.set(s,r)};for(const i of e)i.kind==="user"?(o(),r=!i.collapsed&&i.canCollapse===!0?i.key:null,s=null,r&&t.set(i.key,r)):r&&(t.set(i.key,r),s=i.key);return o(),{owners:t,ends:n}}const p6t='input, textarea, select, [contenteditable=""], [contenteditable="true"]';function m6t({style:e,...t}){const n=e?.visibility==="hidden",[r,s]=y.useState(!1),o=y.useRef(null);return y.useEffect(()=>{const i=t6t(Date.now(),o.current,n,r);if(o.current=i.hiddenSince,i.delayMs===null)return;const l=window.setTimeout(()=>s(!0),i.delayMs);return()=>window.clearTimeout(l)},[n,r]),a.jsx("div",{...t,style:n&&r?{...e,visibility:"visible"}:e})}function OK({ref:e,items:t,busy:n,loading:r=!1,running:s,runStartedAt:o,lastOutputAt:i,error:l,emptyTitle:c,emptyDescription:u,onSuggestion:d,emptyVariant:f,onRetryResume:h,onRetrySync:p,virtualize:m=!0,onStartReached:v,historyLoading:b=!1,hasOlder:x,olderCursor:S,searchQuery:k="",activeHit:C=null,secretarySession:A=!1,secretaryFace:N,conversationId:j,quotable:I=!1}){const{t:_}=Se(),L=Ud(),M=kNe(j),F=A?N??M:null,D=!L&&F?F:null,R=A,z=y.useRef(null),[B,H]=y.useState(!0),[G,ne]=y.useState(!1),W=y.useRef(!0),T=y.useRef(null),U=y.useRef(null),P=y.useRef(0),K=y.useRef(0),J=y.useRef(null),ee=y.useRef(!1),X=y.useRef(!1),te=y.useRef(0),Q=y.useRef(!1),[oe,de]=y.useState(null),ie=y.useRef(0),ue=y.useCallback(Fe=>{cancelAnimationFrame(ie.current),ie.current=requestAnimationFrame(()=>de(Fe()))},[]);y.useEffect(()=>()=>cancelAnimationFrame(ie.current),[]);const[xe,ge]=y.useState(new Set),Te=y.useRef(new Set),[De,Me]=y.useState(()=>new Set),ze=y.useCallback((Fe,We)=>{const lt=Te.current;We!==lt.has(Fe)&&(We?lt.add(Fe):lt.delete(Fe),Me(new Set(lt)))},[]),He=y.useRef({report:ze,scroller:T});He.current.report=ze;const tt=y.useCallback(Fe=>{ge(We=>{const lt=new Set(We);return lt.has(Fe)?lt.delete(Fe):lt.add(Fe),lt})},[]),[$e,Ue]=y.useState(new Map),Pe=be(Fe=>Fe.autoCollapseTurns),we=be(Fe=>Fe.collapseCompletedActivity),ye=be(Fe=>Fe.collapseLiveActivity),Re=be(Fe=>Fe.liveActivityFoldDelaySec),_e=be(Fe=>Fe.compactReadOnlyTools),Ve=o6t(t,s,xe,{compact:_e,autoCollapseCompletedTurns:Pe,collapseCompletedActivity:we,collapseLiveActivity:ye,liveActivityFoldDelaySec:Re,heldOpenTools:De,turnOverrides:$e,foldToolOnlyTurns:!L&&R,readableToolCards:R}),he=y.useRef({state:J5t,collapse:new Map,reveal:new Map}),Ye=y.useMemo(()=>{const Fe=he.current,We=Bt=>T.current?.querySelector(`[data-nav-key="${CSS.escape(Bt)}"]`),lt=eIt(Fe.state,Ve,(Bt,Qt)=>{const dn=We(Bt)?.getBoundingClientRect().top,pn=We(Qt)?.getBoundingClientRect().bottom;return dn===void 0||pn===void 0?0:pn-dn}),yt=Date.now();Fe.state=lt.next;for(const{key:Bt,...Qt}of lt.collapses)Fe.collapse.set(Bt,{at:yt,...Qt});for(const Bt of lt.expands)Fe.reveal.set(Bt,yt);return lt.children},[Ve]),Le=y.useRef(null),Ne=y.useRef(0),Ge=y.useRef(null),ft=r6t(Le.current,Ve.map(Fe=>Fe.key));Le.current=ft.anchor,ft.remount&&(Ne.current+=1,Ge.current=null);const Ze=ft.firstItemIndex,je=y.useCallback((Fe,We)=>{Ue(lt=>lt.get(Fe)===We?lt:new Map(lt).set(Fe,We))},[]),Je=y.useMemo(()=>Pe?h6t(Ve):f6t,[Pe,Ve]),st=y.useRef(null),gt=y.useMemo(()=>{const Fe=[];for(let We=0;We<t.length;We++){const lt=t[We];if(lt.kind!=="user")continue;let yt="";for(let Bt=We+1;Bt<t.length;Bt++){const Qt=t[Bt];if(Qt.kind==="user")break;if(Qt.kind==="text"){yt=Qt.text;break}}Fe.push({key:lt.key,question:fq(lt.text)||"[image]",answer:yt})}return Fe},[t]),ut=y.useCallback(()=>{const Fe=T.current;Fe&&Fe.scrollHeight-Fe.scrollTop-Fe.clientHeight>2&&(ee.current=!0,Fe.scrollTop=Fe.scrollHeight)},[]),pt=y.useCallback(()=>{cancelAnimationFrame(P.current);const Fe=Date.now()+1200;let We=null;const lt=()=>{cancelAnimationFrame(P.current),ee.current=!1,We?.removeEventListener("touchstart",lt),We?.removeEventListener("wheel",lt)},yt=()=>{if(X.current){lt();return}!We&&T.current&&(We=T.current,We.addEventListener("touchstart",lt,{passive:!0,once:!0}),We.addEventListener("wheel",lt,{passive:!0,once:!0})),ut(),W.current=!0,H(!0),Date.now()<Fe?P.current=requestAnimationFrame(yt):lt()};yt(),H(!0),W.current=!0},[ut]);y.useEffect(()=>()=>{cancelAnimationFrame(P.current),cancelAnimationFrame(K.current),window.clearTimeout(te.current)},[]),y.useEffect(()=>TK.subscribe(({active:Fe},We)=>{if(Fe===We.active)return;if(Fe){cancelAnimationFrame(P.current),cancelAnimationFrame(K.current),ee.current=!1;return}const lt=Q.current;Q.current=!1,lt&&W.current&&!X.current&&ut()}),[ut]);const It=()=>{X.current=!0,window.clearTimeout(te.current)},kt=()=>{window.clearTimeout(te.current),te.current=window.setTimeout(()=>{X.current=!1},400)},ln=()=>{It(),kt()},qt=()=>[...T.current?.querySelectorAll("[data-nav-key]")??[]],Jt=Fe=>{ln(),st.current=Fe,je(Fe,!0)},cn=Fe=>{if(Fe.key!=="Escape"||Fe.defaultPrevented||Je.owners.size===0)return;const We=T.current,lt=Fe.target;if(!We?.contains(lt)||lt.closest?.(p6t)||_2e()||document.querySelector('[role="dialog"], [role="alertdialog"]'))return;const yt=We.getBoundingClientRect();for(const Bt of qt()){const Qt=Je.owners.get(Bt.getAttribute("data-nav-key")??"");if(!Qt)continue;const dn=Bt.getBoundingClientRect();if(dn.bottom<=yt.top||dn.top>=yt.bottom)continue;const pn=Fe.nativeEvent;window.addEventListener("keydown",Zt=>{Zt!==pn||Zt.defaultPrevented||(Zt.preventDefault(),Jt(Qt))},{once:!0});return}},hn=()=>{cancelAnimationFrame(P.current),cancelAnimationFrame(K.current),ee.current=!1,W.current=!1,H(!1)},St=y.useCallback(Fe=>{if(J.current?.disconnect(),J.current=null,!Fe)return;const We=new ResizeObserver(()=>{if(!W.current&&!ee.current)return;cancelAnimationFrame(K.current);let lt=8;const yt=()=>{ut();const Bt=T.current;(Bt?Bt.scrollHeight-Bt.scrollTop-Bt.clientHeight:0)<=2||(--lt>0?K.current=requestAnimationFrame(yt):pt())};yt()});We.observe(Fe),J.current=We,pt()},[ut,pt]);y.useEffect(()=>()=>J.current?.disconnect(),[]);const wt=Fe=>Ve.findIndex(We=>We.key===Fe||We.kind==="tool-group"&&b5e(We,Fe)),Dt=Fe=>{if(!m){T.current?.querySelector(`[data-nav-key="${CSS.escape(Fe)}"]`)?.scrollIntoView({block:"center"});return}const We=wt(Fe);We>=0&&z.current?.scrollToIndex({index:Vle(Ze,We),align:"center"})},fe=y.useRef(null),Ie=Fe=>{if(hn(),wt(Fe)>=0){fe.current=null,Dt(Fe);return}let We=null,lt=!1;for(const yt of t)if(yt.kind==="user"&&(We=yt.key),yt.key===Fe){lt=!0;break}!lt||!We||(fe.current=Fe,je(We,!1))};y.useLayoutEffect(()=>{const Fe=fe.current;!Fe||wt(Fe)<0||(fe.current=null,Dt(Fe))},[Ve]),y.useLayoutEffect(()=>{const Fe=st.current;if(!Fe)return;st.current=null;const We=qt().find(yt=>yt.getAttribute("data-nav-key")===Fe);if(We){v5e(We,T.current);return}const lt=Ve.findIndex(yt=>yt.key===Fe);m&&lt>=0&&z.current?.scrollToIndex({index:Vle(Ze,lt),align:"start"})},[Ve]),y.useImperativeHandle(e,()=>({scrollToBottom:pt,pinToBottom:ut,isAtBottom:()=>W.current,getScroller:()=>m?null:T.current,scrollToKey:Ie}));const Ae=y.useRef(!1),ce=`${S}:${Ze}`,Oe=y.useRef(ce);Oe.current!==ce&&(Oe.current=ce,Ae.current=!1);const dt=()=>{!v||Ae.current||(Ae.current=!0,v())};y.useEffect(()=>{m&&!b&&Ge.current===Ze&&dt()},[S,b]);const vt=y.useMemo(()=>({query:k,activeKey:C?.key??"",activeNth:C?.nth??-1}),[k,C?.key,C?.nth]),Et=(Fe,We)=>{const lt=Ve[We+1];if(lt!==void 0&&Ule(Fe)&&Ule(lt))return"pb-0";if(!_e)return"pb-4";const yt=lt!==void 0&&Ole(lt);return Ole(Fe)?yt?"pb-1":"pb-2":Fe.kind==="text"&&yt?"pb-1":"pb-4"},Ct=(Fe,We)=>{const lt=Ve[We-1],yt=lt?.kind==="user"&&!lt.collapsed&&s6t.has(Fe.kind)?lt:void 0,Bt=Date.now(),Qt=he.current.collapse.get(Fe.key),dn=Qt&&Bt-Qt.at<Gle?Qt:void 0,pn=Ye.get(Fe.key),Zt=pn&&he.current.reveal.get(pn.group),An=pn&&Zt!==void 0&&Bt-Zt<Gle,bn=Je.ends.get(Fe.key);return a.jsxs("div",{"data-nav-key":Fe.key,"data-fold-collapse":dn?dn.pair?"pair":"toggle":void 0,style:dn?{"--fold-from":`${dn.height}px`}:An?{"--fold-i":pn.index}:void 0,className:ve(Dg,Et(Fe,We),An&&"t-fold-reveal","[overflow-wrap:anywhere]"),children:[yt&&a.jsx(pMt,{model:yt.replyModel,at:yt.replyAt,privacyMask:yt.replyPrivacyMask,secretarySession:R,face:F,conversationId:j}),a.jsx(w6t,{itemKey:Fe.key,children:a.jsx(mMt,{item:Fe,secretarySession:R,onToggleGroup:tt,onToggleTurn:je})}),bn&&a.jsx(RMt,{turnKey:bn,canCollapse:!0,collapsed:!1,onToggleTurn:Jt})]},Fe.key)},xn=y.useRef(!1);x===!0&&(xn.current=!0);const yn=fnt(t.length>0,b,x,xn.current,!m&&G);y.useLayoutEffect(()=>{if(m){ne(!1);return}const Fe=T.current;ne(!!Fe&&hnt(x===!0,b,Fe.scrollHeight,Fe.clientHeight))},[m,x,b,Ze,Ve.length,t.length]);const er={pageChrome:yn,onLoadMore:yn==="more"?dt:void 0,busy:n,loading:!!r,since:tIt({loading:!!r,runStartedAt:o}),error:l,onRetryResume:h};return a.jsx(JTe.Provider,{value:vt,children:a.jsx(GRt,{value:He.current,children:a.jsxs("div",{ref:U,"data-enso":"timeline",className:"@container relative min-h-24 flex-1",onWheel:ln,onKeyDown:Fe=>{ln(),cn(Fe)},onTouchStart:Fe=>{T.current?.contains(Fe.target)&&It()},onTouchEnd:kt,onPointerDown:Fe=>{Fe.target===T.current&&(It(),window.addEventListener("pointerup",kt,{once:!0}))},children:[a.jsx(sIt,{items:gt,activeKey:oe,onJump:Ie}),I&&a.jsx(hIt,{containerRef:U}),t.length===0&&!n?a.jsxs(Wle,{className:"flex h-full flex-col items-center justify-center gap-2 overflow-y-auto px-4 text-center",children:[a.jsx("span",{className:"t-stagger-line t-stagger-line--1 mb-3",children:D?a.jsx(XN,{name:D.name,color:D.color,image:D.image,needsYou:0,running:0,size:"lg",enso:"secretary-chat-avatar"}):a.jsx("span",{className:"flex size-11 items-center justify-center rounded-[13px] border border-brand/20 bg-brand/8 text-brand dark:bg-brand/14",children:a.jsx(Z5t,{className:"size-6"})})}),a.jsx("p",{className:"t-stagger-line t-stagger-line--1 text-[22px] font-semibold tracking-tight",children:c}),l?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"t-stagger-line t-stagger-line--2 max-w-md text-sm text-destructive whitespace-pre-wrap",children:_(l)}),h&&a.jsx(Ke,{size:"sm",variant:"outline",onClick:h,children:_("Retry resume")})]}):a.jsxs(a.Fragment,{children:[p?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"t-stagger-line t-stagger-line--2 max-w-md text-sm text-muted-foreground",children:_("Session is not ready yet — no history to show.")}),a.jsx(Ke,{size:"sm",variant:"outline",onClick:p,children:_("Retry sync")})]}):u!==""?a.jsx("p",{className:"t-stagger-line t-stagger-line--2 text-sm text-muted-foreground",children:u??_(f==="secretary"?"Tell the secretary what to take care of…":"Ask the agent…")}):null,d&&a.jsx("div",{className:"t-stagger-line t-stagger-line--3 mt-5 w-full",children:a.jsx(l6t,{onPick:d,variant:f})})]})]}):t.length===0&&l?a.jsxs(Wle,{className:"flex h-full flex-col items-center justify-center gap-2 text-center",children:[a.jsx("p",{className:"t-stagger-line t-stagger-line--1 max-w-md text-sm text-destructive whitespace-pre-wrap",children:_(l)}),h&&a.jsx(Ke,{size:"sm",variant:"outline",onClick:h,children:_("Retry resume")})]}):t.length===0?a.jsxs("div",{"data-timeline-loading":"",className:"flex h-full flex-col items-center justify-center gap-2.5 text-center",children:[a.jsx(Jn,{className:"h-5 w-5 animate-spin text-muted-foreground"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:_("Preparing session…")})]}):m?a.jsx(_5t,{ref:z,data:Ve,defaultItemHeight:80,computeItemKey:(Fe,We)=>We.key,firstItemIndex:Ze,startReached:dt,followOutput:d6t,atBottomThreshold:qle,atBottomStateChange:Fe=>{if(!Fe&&W.current&&!X.current){if(AK()){Q.current=!0;return}pt();return}H(Fe),W.current=Fe},increaseViewportBy:u6t,initialTopMostItemIndex:c6t,rangeChanged:({startIndex:Fe})=>{Ge.current=Fe,Fe>Ze+4&&(Ae.current=!1),ue(()=>{const We=Math.max(0,Fe-Ze);let lt=null;for(let yt=0;yt<=Math.min(We+1,Ve.length-1);yt++)Ve[yt]?.kind==="user"&&(lt=Ve[yt].key);return lt})},scrollerRef:Fe=>{T.current=Fe instanceof HTMLElement?Fe:null},className:"h-full select-text",context:er,components:v6t,itemContent:(Fe,We)=>Ct(We,Fe-Ze)},Ne.current):a.jsx("div",{ref:Fe=>{T.current=Fe},onScroll:Fe=>{const We=Fe.currentTarget;if(ee.current){ee.current=!1,W.current=!0,H(!0);return}if(!X.current){W.current&&ut();return}const lt=We.scrollHeight-We.scrollTop-We.clientHeight<=qle;lt!==W.current&&(W.current=lt,H(lt)),v&&(We.scrollTop<80&&!Ae.current?(Ae.current=!0,v()):We.scrollTop>240&&(Ae.current=!1))},className:"h-full select-text overflow-y-auto [overflow-anchor:none]",children:a.jsxs("div",{ref:St,children:[a.jsx(y5e,{context:er}),Ve.map((Fe,We)=>Ct(Fe,We)),a.jsx(w5e,{context:er})]})}),!B&&t.length>0&&a.jsxs("button",{type:"button",onClick:pt,className:"absolute bottom-4 left-1/2 z-10 inline-flex h-7 -translate-x-1/2 items-center gap-1.5 rounded-full border bg-card px-3 text-xs text-muted-foreground shadow-float transition-colors hover:text-foreground",children:[a.jsx(Y4,{className:"h-3 w-3"}),_("Scroll to bottom")]})]})})})}function b5e(e,t){return e.children.some(n=>n.key===t||n.kind==="tool-group"&&b5e(n,t))}function g6t({chrome:e,onLoadMore:t}){const{t:n}=Se();return e==="none"?a.jsx("div",{className:"h-6"}):a.jsx("div",{className:ve(Dg,"flex items-center justify-center gap-2 py-3"),children:e==="loading"?a.jsxs(a.Fragment,{children:[a.jsx(Jn,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"}),a.jsx("p",{className:"text-xs text-muted-foreground",children:n("Loading earlier messages…")})]}):e==="more"?a.jsx("button",{type:"button",className:"text-xs text-muted-foreground underline-offset-2 hover:underline",onClick:t,children:n("Load earlier messages")}):a.jsx("p",{className:"text-xs text-muted-foreground",children:n("Beginning of conversation")})})}function y5e({context:e}){return a.jsx(g6t,{chrome:e.pageChrome,onLoadMore:e.onLoadMore})}function w5e({context:e}){const{t}=Se(),{busy:n,loading:r,since:s,error:o,onRetryResume:i}=e;return a.jsxs("div",{className:ve(Dg,"pb-6 [overflow-wrap:anywhere]"),children:[n&&a.jsxs("div",{className:"flex min-h-[26px] items-center gap-2 text-[13px]",children:[a.jsx(x6t,{}),a.jsx("span",{className:"animate-pulse text-foreground motion-reduce:animate-none",children:t(r?"Loading…":"Working…")}),s!==void 0&&a.jsx(y6t,{since:s})]}),o&&a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx("p",{className:"min-w-0 flex-1 text-sm text-destructive whitespace-pre-wrap",children:t(o)}),a.jsx(p5e,{}),i&&a.jsx(Ke,{size:"sm",variant:"outline",onClick:i,children:t("Retry resume")})]})]})}const v6t={List:m6t,Header:y5e,Footer:w5e};function x6t(){return a.jsxs("span",{className:"relative flex size-[22px] shrink-0 items-center justify-center",children:[a.jsx("span",{className:"absolute size-2 animate-ping rounded-full bg-brand/50"}),a.jsx("span",{className:"relative size-2 rounded-full bg-brand"})]})}const b6t=e=>{const t=Math.max(0,Math.round(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m${t%60}s`},y6t=y.memo(function({since:t}){const[,n]=y.useState(0);return y.useEffect(()=>{const r=setInterval(()=>n(s=>s+1),1e3);return()=>clearInterval(r)},[]),a.jsx("span",{className:"font-mono text-[11px] text-muted-foreground tabular-nums",children:b6t(Date.now()-t)})});class w6t extends y.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidUpdate(t){t.itemKey!==this.props.itemKey&&this.state.failed&&this.setState({failed:!1})}render(){return this.state.failed?a.jsxs("p",{className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-1.5 text-xs text-destructive",children:["message render failed · ",this.props.itemKey]}):this.props.children}}const tk={type:"spring",stiffness:400,damping:30},V6={type:"tween",duration:.22,ease:[.2,0,0,1]},h9={initial:{height:0,opacity:0},animate:{height:"auto",opacity:1,transition:V6},exit:{height:0,opacity:0,transition:V6}};function gcn(e){return e.resizing?!0:e.previousConversationId!==void 0&&e.conversationId!==void 0&&e.previousConversationId!==e.conversationId}function k6t(e){return e.skip?{duration:0}:e.cover||e.targetW===0?V6:tk}const S6t={ts:hw,tsx:hw,js:hw,jsx:hw,mjs:hw,json:X4,html:cze,css:pz,scss:pz,md:Kp,sh:wT,bash:wT,yml:Md,yaml:Md,toml:Md},C6t={ts:"text-blue-500",tsx:"text-blue-500",js:"text-yellow-500",jsx:"text-yellow-500",mjs:"text-yellow-500",json:"text-yellow-600",html:"text-orange-500",css:"text-pink-500",scss:"text-pink-500",md:"text-sky-500",sh:"text-muted-foreground"};function E6t(e,t,n=!1){if(t)return n?Yu:Q4;const r=e.split(".").pop()?.toLowerCase()??"";return S6t[r]??Hze}function T6t(e,t){if(t)return"text-amber-500";const n=e.split(".").pop()?.toLowerCase()??"";return C6t[n]??"text-muted-foreground"}const A6t=y.lazy(()=>Be(()=>import("./ReadFileView-DRDsV4Qh.js"),[],import.meta.url).then(e=>({default:e.ReadFileView}))),N6t={artifacts:[],media:[]},p9=new Map,m9=new Map,I6t=new Set(["image","markdown","html","text"]),j6t=e=>e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`;function R6t(e){const t=JSON.stringify(e),[n,r]=y.useState(()=>p9.get(t)??N6t);return y.useEffect(()=>{if(p9.has(t))return;let s=!0;return window.electronAPI.bots.artifacts.list(JSON.parse(t)).then(o=>{if(!s||!o.ok)return;const i={artifacts:o.artifacts,media:o.media??[]};(i.artifacts.length>0||i.media.length>0)&&p9.set(t,i),r(i)}).catch(()=>{}),()=>{s=!1}},[t]),n}function M6t(e){const{t}=Se();return(n,r)=>{window.electronAPI.bots.artifacts.open({...e,rel:n.rel,action:r}).then(s=>{s.ok||Ht({type:"error",title:s.error==="not-openable"?t("This file type is only shown in Finder"):t("Could not open the file")})})}}function G6({target:e}){const{artifacts:t,media:n}=R6t(e);return a.jsxs(a.Fragment,{children:[n.length>0&&a.jsx(P6t,{target:e,media:n}),t.length>0&&a.jsx(D6t,{target:e,artifacts:t})]})}function _6t(){const{t:e}=Se();return({source:t,name:n})=>t==="upload"?"":t==="web"?e("Web screenshot"):t==="desktop"?e("Desktop screenshot"):n&&/^(?:\/|[A-Za-z]:[\\/])/.test(n)?e("This computer"):e("Workspace image")}function k5e(e,t,n){const r=JSON.stringify(e),s=t&&n==="thumb"?m9.get(t):void 0,[o,i]=y.useState(s?{ok:!0,kind:"image",dataUrl:s}:null);return y.useEffect(()=>{const l=t&&n==="thumb"?m9.get(t):void 0;if(i(l?{ok:!0,kind:"image",dataUrl:l}:null),!t||l)return;let c=!0;return window.electronAPI.bots.artifacts.read({...JSON.parse(r),mediaId:t,variant:n}).then(u=>{n==="thumb"&&u.ok&&u.kind==="image"&&m9.set(t,u.dataUrl),c&&i(u)}).catch(()=>c&&i({ok:!1,error:"unavailable"})),()=>{c=!1}},[r,t,n]),o}function P6t({target:e,media:t}){const{t:n}=Se(),r=_6t(),[s,o]=y.useState(null),i=t.some(l=>l.ok&&l.source==="desktop");return a.jsxs("div",{className:"mt-2","data-bot-media":"",children:[a.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.map((l,c)=>l.ok?a.jsx(L6t,{target:e,item:l,label:r(l),onOpen:()=>o(l)},l.mediaId):a.jsxs("div",{className:"flex w-40 flex-col gap-1 rounded-lg border border-destructive/60 border-dashed p-2 text-destructive text-xs",children:[a.jsxs("span",{className:"flex items-center gap-1 font-medium",children:[a.jsx(oM,{className:"h-3.5 w-3.5 shrink-0"}),a.jsx("span",{className:"truncate",children:l.name??r(l)})]}),a.jsx("span",{children:l.error==="quota"?n("Chat image storage is full (200 MiB); not saved"):n("Not sent: still over 10 MiB after compression")})]},`failed-${c}`))}),i&&a.jsx("p",{className:"mt-1 text-warning text-xs",children:n("Desktop screenshots may capture sensitive content from other windows.")}),a.jsx(O6t,{target:e,item:s,label:s?r(s):"",onClose:()=>o(null)})]})}function L6t({target:e,item:t,label:n,onOpen:r}){const s=k5e(e,t.mediaId,"thumb"),o=t.caption??t.name??n;return a.jsxs("button",{type:"button",title:o,onClick:r,className:"relative h-24 w-36 overflow-hidden rounded-lg border bg-muted",children:[s?.ok&&s.kind==="image"?a.jsx("img",{src:s.dataUrl,alt:o,className:"h-full w-full object-cover"}):s?a.jsx(oM,{className:"m-auto h-4 w-4 text-muted-foreground"}):a.jsx(Jn,{className:"m-auto h-4 w-4 animate-spin text-muted-foreground"}),n&&a.jsx("span",{className:ve("absolute top-1 left-1 rounded px-1 text-[10px] leading-4",t.source==="desktop"?"bg-warning text-warning-foreground":"bg-black/60 text-white"),children:n}),(t.caption||t.name)&&a.jsx("span",{className:"absolute inset-x-0 bottom-0 truncate bg-gradient-to-t from-black/70 to-transparent px-1.5 pt-3 pb-0.5 text-left text-[10px] text-white",children:t.caption??t.name})]})}function O6t({target:e,item:t,label:n,onClose:r}){const{t:s}=Se(),o=k5e(e,t?.mediaId??null,"full"),i=t?.caption??t?.name??n;return a.jsx(gr,{open:t!==null,onOpenChange:l=>!l&&r(),children:a.jsxs(vr,{className:"flex h-[80vh] max-w-4xl flex-col",children:[a.jsx(xr,{children:a.jsxs(dr,{className:"flex min-w-0 items-center gap-2 pr-8",children:[a.jsx("span",{className:"truncate",children:i}),a.jsx("span",{className:"shrink-0 font-normal text-muted-foreground text-xs",children:n})]})}),t?.source==="desktop"&&a.jsx("p",{className:"text-warning text-xs",children:s("Desktop screenshots may capture sensitive content from other windows.")}),t?.source==="file"&&a.jsx("p",{className:"text-muted-foreground text-xs",children:s("Copied into this chat: later edits or deletion of the original do not change it. Deleted together with the chat.")}),a.jsx(S5e,{name:i,content:o})]})})}function D6t({target:e,artifacts:t}){const{t:n}=Se(),r=M6t(e),[s,o]=y.useState(null);return a.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-1.5","data-bot-artifacts":"",children:[t.map(i=>{const l=E6t(i.name,!1),c=I6t.has(i.kind)||i.kind==="pdf";return a.jsxs("div",{"data-slot":"bot-card",className:"group/artifact flex max-w-64 items-center gap-1 rounded-lg border bg-card py-1 pr-1 pl-2 text-xs",children:[a.jsxs("button",{type:"button",title:i.rel,disabled:!c,onClick:()=>i.kind==="pdf"?r(i,"preview"):o(i),className:"flex min-w-0 items-center gap-1.5 text-left enabled:hover:underline disabled:cursor-default",children:[a.jsx(l,{className:ve("h-3.5 w-3.5 shrink-0",T6t(i.name,!1))}),a.jsx("span",{className:"truncate",children:i.name}),a.jsx("span",{className:"shrink-0 text-muted-foreground",children:j6t(i.size)})]}),a.jsx("button",{type:"button",title:n("Show in Finder"),onClick:()=>r(i,"reveal"),className:"rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground",children:a.jsx(Yu,{className:"h-3.5 w-3.5"})}),a.jsx("button",{type:"button",title:n("Open with default app"),onClick:()=>r(i,"open"),className:"rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground",children:a.jsx(dy,{className:"h-3.5 w-3.5"})})]},i.rel)}),a.jsx(B6t,{target:e,artifact:s,onOpen:r,onClose:()=>o(null)})]})}function B6t({target:e,artifact:t,onOpen:n,onClose:r}){const{t:s}=Se(),[o,i]=y.useState(null),l=t?.rel,c=JSON.stringify(e);return y.useEffect(()=>{if(i(null),!l)return;let u=!0;return window.electronAPI.bots.artifacts.read({...JSON.parse(c),rel:l}).then(d=>u&&i(d)).catch(()=>u&&i({ok:!1,error:"unavailable"})),()=>{u=!1}},[c,l]),a.jsx(gr,{open:t!==null,onOpenChange:u=>!u&&r(),children:a.jsxs(vr,{className:"flex h-[80vh] max-w-4xl flex-col",children:[a.jsx(xr,{children:a.jsxs(dr,{className:"flex min-w-0 items-center gap-2 pr-8",children:[a.jsx("span",{className:"truncate",children:t?.name}),a.jsx("span",{className:"truncate font-normal text-muted-foreground text-xs",children:t?.rel}),a.jsx("span",{className:"flex-1"}),t&&a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",title:s("Show in Finder"),onClick:()=>n(t,"reveal"),className:"rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground",children:a.jsx(Yu,{className:"h-4 w-4"})}),a.jsx("button",{type:"button",title:s("Open with default app"),onClick:()=>n(t,"open"),className:"rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground",children:a.jsx(dy,{className:"h-4 w-4"})})]})]})}),a.jsx(S5e,{name:t?.name??"",content:o})]})})}function S5e({name:e,content:t}){const{t:n}=Se();return a.jsxs("div",{className:"min-h-0 flex-1 select-text overflow-auto border-t","data-bot-artifact-preview":"",children:[!t&&a.jsx("div",{className:"flex justify-center p-6 text-muted-foreground",children:a.jsx(Jn,{className:"h-4 w-4 animate-spin"})}),t&&!t.ok&&a.jsx("p",{className:"p-6 text-muted-foreground text-sm",children:t.error==="too-large"?n("The file is too large to preview"):n("Could not open the file")}),t?.ok&&t.kind==="image"&&a.jsx("img",{src:t.dataUrl,alt:e,className:"mx-auto max-h-full max-w-full object-contain p-4"}),t?.ok&&t.kind==="markdown"&&a.jsx("div",{className:"px-6 py-4 text-sm",children:a.jsx(ua,{text:t.text})}),t?.ok&&t.kind==="html"&&a.jsx("iframe",{title:e,sandbox:"",srcDoc:t.text,className:"h-full w-full bg-white"}),t?.ok&&t.kind==="text"&&a.jsx("div",{className:"p-2 text-xs",children:a.jsx(y.Suspense,{fallback:null,children:a.jsx(A6t,{path:e,contents:t.text})})})]})}var fb={},uC={};var Yle;function F6t(){if(Yle)return uC;Yle=1;var e=Dy(),t=L4();function n(q){var $="https://react.dev/errors/"+q;if(1<arguments.length){$+="?args[]="+encodeURIComponent(arguments[1]);for(var ae=2;ae<arguments.length;ae++)$+="&args[]="+encodeURIComponent(arguments[ae])}return"Minified React error #"+q+"; visit "+$+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=Symbol.for("react.transitional.element"),s=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),u=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),v=Symbol.for("react.scope"),b=Symbol.for("react.activity"),x=Symbol.for("react.legacy_hidden"),S=Symbol.for("react.memo_cache_sentinel"),k=Symbol.for("react.view_transition"),C=Symbol.iterator;function A(q){return q===null||typeof q!="object"?null:(q=C&&q[C]||q["@@iterator"],typeof q=="function"?q:null)}var N=Array.isArray;function j(q,$){var ae=q.length&3,me=q.length-ae,Ee=$;for($=0;$<me;){var et=q.charCodeAt($)&255|(q.charCodeAt(++$)&255)<<8|(q.charCodeAt(++$)&255)<<16|(q.charCodeAt(++$)&255)<<24;++$,et=3432918353*(et&65535)+((3432918353*(et>>>16)&65535)<<16)&4294967295,et=et<<15|et>>>17,et=461845907*(et&65535)+((461845907*(et>>>16)&65535)<<16)&4294967295,Ee^=et,Ee=Ee<<13|Ee>>>19,Ee=5*(Ee&65535)+((5*(Ee>>>16)&65535)<<16)&4294967295,Ee=(Ee&65535)+27492+(((Ee>>>16)+58964&65535)<<16)}switch(et=0,ae){case 3:et^=(q.charCodeAt($+2)&255)<<16;case 2:et^=(q.charCodeAt($+1)&255)<<8;case 1:et^=q.charCodeAt($)&255,et=3432918353*(et&65535)+((3432918353*(et>>>16)&65535)<<16)&4294967295,et=et<<15|et>>>17,Ee^=461845907*(et&65535)+((461845907*(et>>>16)&65535)<<16)&4294967295}return Ee^=q.length,Ee^=Ee>>>16,Ee=2246822507*(Ee&65535)+((2246822507*(Ee>>>16)&65535)<<16)&4294967295,Ee^=Ee>>>13,Ee=3266489909*(Ee&65535)+((3266489909*(Ee>>>16)&65535)<<16)&4294967295,(Ee^Ee>>>16)>>>0}var I=Object.assign,_=Object.prototype.hasOwnProperty,L=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),M={},F={};function D(q){return _.call(F,q)?!0:_.call(M,q)?!1:L.test(q)?F[q]=!0:(M[q]=!0,!1)}var R=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" ")),z=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),B=/["'&<>]/;function H(q){if(typeof q=="boolean"||typeof q=="number"||typeof q=="bigint")return""+q;q=""+q;var $=B.exec(q);if($){var ae="",me,Ee=0;for(me=$.index;me<q.length;me++){switch(q.charCodeAt(me)){case 34:$="&quot;";break;case 38:$="&amp;";break;case 39:$="&#x27;";break;case 60:$="&lt;";break;case 62:$="&gt;";break;default:continue}Ee!==me&&(ae+=q.slice(Ee,me)),Ee=me+1,ae+=$}q=Ee!==me?ae+q.slice(Ee,me):ae}return q}var G=/([A-Z])/g,ne=/^ms-/,W=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function T(q){return W.test(""+q)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":q}var U=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P=t.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,K={pending:!1,data:null,method:null,action:null},J=P.d;P.d={f:J.f,r:J.r,D:lt,C:yt,L:Bt,m:Qt,X:pn,S:dn,M:Zt};var ee=[],X=null,te=/(<\/|<)(s)(cript)/gi;function Q(q,$,ae,me){return""+$+(ae==="s"?"\\u0073":"\\u0053")+me}function oe(q,$,ae,me,Ee){return{idPrefix:q===void 0?"":q,nextFormID:0,streamingFormat:0,bootstrapScriptContent:ae,bootstrapScripts:me,bootstrapModules:Ee,instructions:0,hasBody:!1,hasHtml:!1,unknownResources:{},dnsResources:{},connectResources:{default:{},anonymous:{},credentials:{}},imageResources:{},styleResources:{},scriptResources:{},moduleUnknownResources:{},moduleScriptResources:{}}}function de(q,$,ae,me){return{insertionMode:q,selectedValue:$,tagScope:ae,viewTransition:me}}function ie(q,$,ae){var me=q.tagScope&-25;switch($){case"noscript":return de(2,null,me|1,null);case"select":return de(2,ae.value!=null?ae.value:ae.defaultValue,me,null);case"svg":return de(4,null,me,null);case"picture":return de(2,null,me|2,null);case"math":return de(5,null,me,null);case"foreignObject":return de(2,null,me,null);case"table":return de(6,null,me,null);case"thead":case"tbody":case"tfoot":return de(7,null,me,null);case"colgroup":return de(9,null,me,null);case"tr":return de(8,null,me,null);case"head":if(2>q.insertionMode)return de(3,null,me,null);break;case"html":if(q.insertionMode===0)return de(1,null,me,null)}return 6<=q.insertionMode||2>q.insertionMode?de(2,null,me,null):q.tagScope!==me?de(q.insertionMode,q.selectedValue,me,null):q}function ue(q){return q===null?null:{update:q.update,enter:"none",exit:"none",share:q.update,name:q.autoName,autoName:q.autoName,nameIdx:0}}function xe(q,$){return $.tagScope&32&&(q.instructions|=128),de($.insertionMode,$.selectedValue,$.tagScope|12,ue($.viewTransition))}function ge(q,$){q=ue($.viewTransition);var ae=$.tagScope|16;return q!==null&&q.share!=="none"&&(ae|=64),de($.insertionMode,$.selectedValue,ae,q)}var Te=new Map;function De(q,$){if(typeof $!="object")throw Error(n(62));var ae=!0,me;for(me in $)if(_.call($,me)){var Ee=$[me];if(Ee!=null&&typeof Ee!="boolean"&&Ee!==""){if(me.indexOf("--")===0){var et=H(me);Ee=H((""+Ee).trim())}else et=Te.get(me),et===void 0&&(et=H(me.replace(G,"-$1").toLowerCase().replace(ne,"-ms-")),Te.set(me,et)),Ee=typeof Ee=="number"?Ee===0||R.has(me)?""+Ee:Ee+"px":H((""+Ee).trim());ae?(ae=!1,q.push(' style="',et,":",Ee)):q.push(";",et,":",Ee)}}ae||q.push('"')}function Me(q,$,ae){ae&&typeof ae!="function"&&typeof ae!="symbol"&&q.push(" ",$,'=""')}function ze(q,$,ae){typeof ae!="function"&&typeof ae!="symbol"&&typeof ae!="boolean"&&q.push(" ",$,'="',H(ae),'"')}var He=H("javascript:throw new Error('React form unexpectedly submitted.')");function tt(q,$){this.push('<input type="hidden"'),$e(q),ze(this,"name",$),ze(this,"value",q),this.push("/>")}function $e(q){if(typeof q!="string")throw Error(n(480))}function Ue(q,$){if(typeof $.$$FORM_ACTION=="function"){var ae=q.nextFormID++;q=q.idPrefix+ae;try{var me=$.$$FORM_ACTION(q);if(me){var Ee=me.data;Ee?.forEach($e)}return me}catch(et){if(typeof et=="object"&&et!==null&&typeof et.then=="function")throw et}}return null}function Pe(q,$,ae,me,Ee,et,ct,$t){var At=null;if(typeof me=="function"){var Kt=Ue($,me);Kt!==null?($t=Kt.name,me=Kt.action||"",Ee=Kt.encType,et=Kt.method,ct=Kt.target,At=Kt.data):(q.push(" ","formAction",'="',He,'"'),ct=et=Ee=me=$t=null,_e($,ae))}return $t!=null&&we(q,"name",$t),me!=null&&we(q,"formAction",me),Ee!=null&&we(q,"formEncType",Ee),et!=null&&we(q,"formMethod",et),ct!=null&&we(q,"formTarget",ct),At}function we(q,$,ae){switch($){case"className":ze(q,"class",ae);break;case"tabIndex":ze(q,"tabindex",ae);break;case"dir":case"role":case"viewBox":case"width":case"height":ze(q,$,ae);break;case"style":De(q,ae);break;case"src":case"href":if(ae==="")break;case"action":case"formAction":if(ae==null||typeof ae=="function"||typeof ae=="symbol"||typeof ae=="boolean")break;ae=T(""+ae),q.push(" ",$,'="',H(ae),'"');break;case"defaultValue":case"defaultChecked":case"innerHTML":case"suppressContentEditableWarning":case"suppressHydrationWarning":case"ref":break;case"autoFocus":case"multiple":case"muted":Me(q,$.toLowerCase(),ae);break;case"xlinkHref":if(typeof ae=="function"||typeof ae=="symbol"||typeof ae=="boolean")break;ae=T(""+ae),q.push(" ","xlink:href",'="',H(ae),'"');break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":typeof ae!="function"&&typeof ae!="symbol"&&q.push(" ",$,'="',H(ae),'"');break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":ae&&typeof ae!="function"&&typeof ae!="symbol"&&q.push(" ",$,'=""');break;case"capture":case"download":ae===!0?q.push(" ",$,'=""'):ae!==!1&&typeof ae!="function"&&typeof ae!="symbol"&&q.push(" ",$,'="',H(ae),'"');break;case"cols":case"rows":case"size":case"span":typeof ae!="function"&&typeof ae!="symbol"&&!isNaN(ae)&&1<=ae&&q.push(" ",$,'="',H(ae),'"');break;case"rowSpan":case"start":typeof ae=="function"||typeof ae=="symbol"||isNaN(ae)||q.push(" ",$,'="',H(ae),'"');break;case"xlinkActuate":ze(q,"xlink:actuate",ae);break;case"xlinkArcrole":ze(q,"xlink:arcrole",ae);break;case"xlinkRole":ze(q,"xlink:role",ae);break;case"xlinkShow":ze(q,"xlink:show",ae);break;case"xlinkTitle":ze(q,"xlink:title",ae);break;case"xlinkType":ze(q,"xlink:type",ae);break;case"xmlBase":ze(q,"xml:base",ae);break;case"xmlLang":ze(q,"xml:lang",ae);break;case"xmlSpace":ze(q,"xml:space",ae);break;default:if((!(2<$.length)||$[0]!=="o"&&$[0]!=="O"||$[1]!=="n"&&$[1]!=="N")&&($=z.get($)||$,D($))){switch(typeof ae){case"function":case"symbol":return;case"boolean":var me=$.toLowerCase().slice(0,5);if(me!=="data-"&&me!=="aria-")return}q.push(" ",$,'="',H(ae),'"')}}}function ye(q,$,ae){if($!=null){if(ae!=null)throw Error(n(60));if(typeof $!="object"||!("__html"in $))throw Error(n(61));$=$.__html,$!=null&&q.push(""+$)}}function Re(q){var $="";return e.Children.forEach(q,function(ae){ae!=null&&($+=ae)}),$}function _e(q,$){if((q.instructions&16)===0){q.instructions|=16;var ae=$.preamble,me=$.bootstrapChunks;(ae.htmlChunks||ae.headChunks)&&me.length===0?(me.push($.startInlineScript),yn(me,q),me.push(">",`addEventListener("submit",function(a){if(!a.defaultPrevented){var c=a.target,d=a.submitter,e=c.action,b=d;if(d){var f=d.getAttribute("formAction");null!=f&&(e=f,b=null)}"javascript:throw new Error('React form unexpectedly submitted.')"===e&&(a.preventDefault(),b?(a=document.createElement("input"),a.name=b.name,a.value=b.value,b.parentNode.insertBefore(a,b),b=new FormData(c),a.parentNode.removeChild(a)):b=new FormData(c),a=c.ownerDocument||c,(a.$$reactFormReplay=a.$$reactFormReplay||[]).push(c,d,b))}});`,"<\/script>")):me.unshift($.startInlineScript,">",`addEventListener("submit",function(a){if(!a.defaultPrevented){var c=a.target,d=a.submitter,e=c.action,b=d;if(d){var f=d.getAttribute("formAction");null!=f&&(e=f,b=null)}"javascript:throw new Error('React form unexpectedly submitted.')"===e&&(a.preventDefault(),b?(a=document.createElement("input"),a.name=b.name,a.value=b.value,b.parentNode.insertBefore(a,b),b=new FormData(c),a.parentNode.removeChild(a)):b=new FormData(c),a=c.ownerDocument||c,(a.$$reactFormReplay=a.$$reactFormReplay||[]).push(c,d,b))}});`,"<\/script>")}}function Ve(q,$){q.push(st("link"));for(var ae in $)if(_.call($,ae)){var me=$[ae];if(me!=null)switch(ae){case"children":case"dangerouslySetInnerHTML":throw Error(n(399,"link"));default:we(q,ae,me)}}return q.push("/>"),null}var he=/(<\/|<)(s)(tyle)/gi;function Ye(q,$,ae,me){return""+$+(ae==="s"?"\\73 ":"\\53 ")+me}function Le(q,$,ae){q.push(st(ae));for(var me in $)if(_.call($,me)){var Ee=$[me];if(Ee!=null)switch(me){case"children":case"dangerouslySetInnerHTML":throw Error(n(399,ae));default:we(q,me,Ee)}}return q.push("/>"),null}function Ne(q,$){q.push(st("title"));var ae=null,me=null,Ee;for(Ee in $)if(_.call($,Ee)){var et=$[Ee];if(et!=null)switch(Ee){case"children":ae=et;break;case"dangerouslySetInnerHTML":me=et;break;default:we(q,Ee,et)}}return q.push(">"),$=Array.isArray(ae)?2>ae.length?ae[0]:null:ae,typeof $!="function"&&typeof $!="symbol"&&$!==null&&$!==void 0&&q.push(H(""+$)),ye(q,me,ae),q.push(pt("title")),null}function Ge(q,$){q.push(st("script"));var ae=null,me=null,Ee;for(Ee in $)if(_.call($,Ee)){var et=$[Ee];if(et!=null)switch(Ee){case"children":ae=et;break;case"dangerouslySetInnerHTML":me=et;break;default:we(q,Ee,et)}}return q.push(">"),ye(q,me,ae),typeof ae=="string"&&q.push((""+ae).replace(te,Q)),q.push(pt("script")),null}function ft(q,$,ae){q.push(st(ae));var me=ae=null,Ee;for(Ee in $)if(_.call($,Ee)){var et=$[Ee];if(et!=null)switch(Ee){case"children":ae=et;break;case"dangerouslySetInnerHTML":me=et;break;default:we(q,Ee,et)}}return q.push(">"),ye(q,me,ae),ae}function Ze(q,$,ae){q.push(st(ae));var me=ae=null,Ee;for(Ee in $)if(_.call($,Ee)){var et=$[Ee];if(et!=null)switch(Ee){case"children":ae=et;break;case"dangerouslySetInnerHTML":me=et;break;default:we(q,Ee,et)}}return q.push(">"),ye(q,me,ae),typeof ae=="string"?(q.push(H(ae)),null):ae}var je=/^[a-zA-Z][a-zA-Z:_\.\-\d]*$/,Je=new Map;function st(q){var $=Je.get(q);if($===void 0){if(!je.test(q))throw Error(n(65,q));$="<"+q,Je.set(q,$)}return $}function gt(q,$,ae,me,Ee,et,ct,$t,At){switch($){case"div":case"span":case"svg":case"path":break;case"a":q.push(st("a"));var Kt=null,kn=null,rn;for(rn in ae)if(_.call(ae,rn)){var zn=ae[rn];if(zn!=null)switch(rn){case"children":Kt=zn;break;case"dangerouslySetInnerHTML":kn=zn;break;case"href":zn===""?ze(q,"href",""):we(q,rn,zn);break;default:we(q,rn,zn)}}if(q.push(">"),ye(q,kn,Kt),typeof Kt=="string"){q.push(H(Kt));var ir=null}else ir=Kt;return ir;case"g":case"p":case"li":break;case"select":q.push(st("select"));var cs=null,Qr=null,qr;for(qr in ae)if(_.call(ae,qr)){var Hr=ae[qr];if(Hr!=null)switch(qr){case"children":cs=Hr;break;case"dangerouslySetInnerHTML":Qr=Hr;break;case"defaultValue":case"value":break;default:we(q,qr,Hr)}}return q.push(">"),ye(q,Qr,cs),cs;case"option":var ts=$t.selectedValue;q.push(st("option"));var Ks=null,Go=null,ys=null,ws=null,Rs;for(Rs in ae)if(_.call(ae,Rs)){var Io=ae[Rs];if(Io!=null)switch(Rs){case"children":Ks=Io;break;case"selected":ys=Io;break;case"dangerouslySetInnerHTML":ws=Io;break;case"value":Go=Io;default:we(q,Rs,Io)}}if(ts!=null){var Ts=Go!==null?""+Go:Re(Ks);if(N(ts)){for(var Si=0;Si<ts.length;Si++)if(""+ts[Si]===Ts){q.push(' selected=""');break}}else""+ts===Ts&&q.push(' selected=""')}else ys&&q.push(' selected=""');return q.push(">"),ye(q,ws,Ks),Ks;case"textarea":q.push(st("textarea"));var Xs=null,ri=null,Do=null,jo;for(jo in ae)if(_.call(ae,jo)){var Ra=ae[jo];if(Ra!=null)switch(jo){case"children":Do=Ra;break;case"value":Xs=Ra;break;case"defaultValue":ri=Ra;break;case"dangerouslySetInnerHTML":throw Error(n(91));default:we(q,jo,Ra)}}if(Xs===null&&ri!==null&&(Xs=ri),q.push(">"),Do!=null){if(Xs!=null)throw Error(n(92));if(N(Do)){if(1<Do.length)throw Error(n(93));Xs=""+Do[0]}Xs=""+Do}return typeof Xs=="string"&&Xs[0]===`
385
+ `,1)[0]??""),e6t=100;function t6t(e,t,n,r,s=e6t){if(r||!n)return{hiddenSince:t,delayMs:null};const o=t??e;return{hiddenSince:o,delayMs:Math.max(0,s-(e-o))}}const n6t=1e6;function r6t(e,t,n=n6t){if(t.length===0)return{anchor:null,firstItemIndex:n,remount:!1};if(!e)return{anchor:{keys:t,index:n},firstItemIndex:n,remount:!1};const r=new Map(t.map((s,o)=>[s,o]));for(let s=0;s<e.keys.length;s++){const o=r.get(e.keys[s]);if(o===void 0)continue;const i=e.index+s-o;return{anchor:{keys:t,index:i},firstItemIndex:i,remount:!1}}return{anchor:{keys:t,index:n},firstItemIndex:n,remount:!0}}function Vle(e,t){return t}const s6t=new Set(["text","thinking","tool","tool-group"]);function o6t(e,t,n,r){const s=y.useRef(rH),[o,i]=y.useState(()=>Date.now()),l=r.compact,c=r.autoCollapseCompletedTurns,u=r.collapseCompletedActivity===!0,d=r.collapseLiveActivity===!0,f=r.turnOverrides,h={compact:l,autoCollapseCompletedTurns:c,turnOverrides:f},p=d?drt(e,t,r,s.current,o):null;s.current=p?.witness??rH;const m=p?.wakeAt??null,v=xrt(e,t,n,{...h,collapseCompletedActivity:u,collapseLiveActivity:d,releasedLiveActivity:p?.released,heldOpenTools:r.heldOpenTools,foldToolOnlyTurns:r.foldToolOnlyTurns===!0,readableToolCards:r.readableToolCards===!0});return y.useEffect(()=>{if(m===null||m<=o)return;const b=window.setTimeout(()=>i(m),m-o);return()=>window.clearTimeout(b)},[m,o]),v}const i6t=[{icon:hze,title:"Map the project",hint:"Entry points, modules and key dependencies",prompt:"Walk me through this project's structure: entry points, module layout and key dependencies."},{icon:vxe,title:"Find potential issues",hint:"Suspicious logic and unhandled edge cases",prompt:"Review this project for potential bugs, suspicious logic and unhandled edge cases, and list them by severity."},{icon:NW,title:"Add unit tests",hint:"Cover the core modules with tests",prompt:"Find the core modules that lack tests and add unit tests for them."},{icon:Xp,title:"Summarize recent changes",hint:"A digest based on git log",prompt:"Summarize the recent changes in this repository based on git log."}],a6t=[{icon:_xe,title:"Check today's progress",hint:"Progress report and items waiting on you",prompt:"Summarize today's progress and list anything waiting on me."},{icon:zy,title:"Assign a task",hint:"A one-off job for the secretary to run",prompt:"Take care of a one-off task: "},{icon:rx,title:"Organize the to-do list",hint:"Sort the board into clear next steps",prompt:"Go through the board and organize it into clear next steps."},{icon:wf,title:"Clean up merged branches",hint:"Remove branches that are already merged",prompt:"Clean up merged branches and worktrees you no longer need."}];function l6t({onPick:e,variant:t="project"}){const{t:n}=Se(),r=t==="secretary"?a6t:i6t;return a.jsx("div",{className:"mx-auto grid w-full max-w-[560px] grid-cols-1 gap-2.5 text-left @min-[36rem]:grid-cols-2",children:r.map(({icon:s,title:o,hint:i,prompt:l})=>a.jsxs("button",{type:"button",onClick:()=>e(n(l)),"data-slot":"welcome-suggestion",className:"group flex items-start gap-3 rounded-xl border bg-card px-3.5 py-3 text-left shadow-xs transition-[border-color,box-shadow,transform] duration-200 hover:-translate-y-px hover:border-brand/25 hover:shadow-float",children:[a.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-lg bg-brand/8 text-brand dark:bg-brand/14",children:a.jsx(s,{className:"size-3.5"})}),a.jsxs("span",{className:"min-w-0",children:[a.jsx("span",{className:"block text-[13px] font-medium",children:n(o)}),a.jsx("span",{className:"block text-xs text-muted-foreground",children:n(i)})]})]},o))})}const Dg="enso-chat-col mx-auto w-full max-w-2xl px-4 @min-[56rem]:max-w-3xl @min-[72rem]:max-w-4xl @min-[84rem]:max-w-5xl @min-[96rem]:max-w-6xl @min-[112rem]:max-w-7xl",Gle=1e3;function Wle({className:e,children:t}){const[n,r]=y.useState(!1);return y.useEffect(()=>{const s=requestAnimationFrame(()=>r(!0));return()=>cancelAnimationFrame(s)},[]),a.jsx("div",{className:ve("t-stagger",n&&"is-shown",e),children:t})}const qle=40,c6t={index:"LAST",align:"end"},u6t={top:600,bottom:600},d6t=e=>e&&!AK()?"auto":!1,f6t={owners:new Map,ends:new Map};function h6t(e){const t=new Map,n=new Map;let r=null,s=null;const o=()=>{r&&s&&n.set(s,r)};for(const i of e)i.kind==="user"?(o(),r=!i.collapsed&&i.canCollapse===!0?i.key:null,s=null,r&&t.set(i.key,r)):r&&(t.set(i.key,r),s=i.key);return o(),{owners:t,ends:n}}const p6t='input, textarea, select, [contenteditable=""], [contenteditable="true"]';function m6t({style:e,...t}){const n=e?.visibility==="hidden",[r,s]=y.useState(!1),o=y.useRef(null);return y.useEffect(()=>{const i=t6t(Date.now(),o.current,n,r);if(o.current=i.hiddenSince,i.delayMs===null)return;const l=window.setTimeout(()=>s(!0),i.delayMs);return()=>window.clearTimeout(l)},[n,r]),a.jsx("div",{...t,style:n&&r?{...e,visibility:"visible"}:e})}function OK({ref:e,items:t,busy:n,loading:r=!1,running:s,runStartedAt:o,lastOutputAt:i,error:l,emptyTitle:c,emptyDescription:u,onSuggestion:d,emptyVariant:f,onRetryResume:h,onRetrySync:p,virtualize:m=!0,onStartReached:v,historyLoading:b=!1,hasOlder:x,olderCursor:S,searchQuery:k="",activeHit:C=null,secretarySession:A=!1,secretaryFace:N,conversationId:j,quotable:I=!1}){const{t:_}=Se(),L=Ud(),M=kNe(j),F=A?N??M:null,D=!L&&F?F:null,R=A,z=y.useRef(null),[B,H]=y.useState(!0),[G,ne]=y.useState(!1),W=y.useRef(!0),T=y.useRef(null),U=y.useRef(null),P=y.useRef(0),K=y.useRef(0),J=y.useRef(null),ee=y.useRef(!1),X=y.useRef(!1),te=y.useRef(0),Q=y.useRef(!1),[oe,de]=y.useState(null),ie=y.useRef(0),ue=y.useCallback(Fe=>{cancelAnimationFrame(ie.current),ie.current=requestAnimationFrame(()=>de(Fe()))},[]);y.useEffect(()=>()=>cancelAnimationFrame(ie.current),[]);const[xe,ge]=y.useState(new Set),Te=y.useRef(new Set),[De,Me]=y.useState(()=>new Set),ze=y.useCallback((Fe,We)=>{const lt=Te.current;We!==lt.has(Fe)&&(We?lt.add(Fe):lt.delete(Fe),Me(new Set(lt)))},[]),He=y.useRef({report:ze,scroller:T});He.current.report=ze;const tt=y.useCallback(Fe=>{ge(We=>{const lt=new Set(We);return lt.has(Fe)?lt.delete(Fe):lt.add(Fe),lt})},[]),[$e,Ue]=y.useState(new Map),Pe=be(Fe=>Fe.autoCollapseTurns),we=be(Fe=>Fe.collapseCompletedActivity),ye=be(Fe=>Fe.collapseLiveActivity),Re=be(Fe=>Fe.liveActivityFoldDelaySec),_e=be(Fe=>Fe.compactReadOnlyTools),Ve=o6t(t,s,xe,{compact:_e,autoCollapseCompletedTurns:Pe,collapseCompletedActivity:we,collapseLiveActivity:ye,liveActivityFoldDelaySec:Re,heldOpenTools:De,turnOverrides:$e,foldToolOnlyTurns:!L&&R,readableToolCards:R}),he=y.useRef({state:J5t,collapse:new Map,reveal:new Map}),Ye=y.useMemo(()=>{const Fe=he.current,We=Bt=>T.current?.querySelector(`[data-nav-key="${CSS.escape(Bt)}"]`),lt=eIt(Fe.state,Ve,(Bt,Qt)=>{const dn=We(Bt)?.getBoundingClientRect().top,pn=We(Qt)?.getBoundingClientRect().bottom;return dn===void 0||pn===void 0?0:pn-dn}),yt=Date.now();Fe.state=lt.next;for(const{key:Bt,...Qt}of lt.collapses)Fe.collapse.set(Bt,{at:yt,...Qt});for(const Bt of lt.expands)Fe.reveal.set(Bt,yt);return lt.children},[Ve]),Le=y.useRef(null),Ne=y.useRef(0),Ge=y.useRef(null),ft=r6t(Le.current,Ve.map(Fe=>Fe.key));Le.current=ft.anchor,ft.remount&&(Ne.current+=1,Ge.current=null);const Ze=ft.firstItemIndex,je=y.useCallback((Fe,We)=>{Ue(lt=>lt.get(Fe)===We?lt:new Map(lt).set(Fe,We))},[]),Je=y.useMemo(()=>Pe?h6t(Ve):f6t,[Pe,Ve]),st=y.useRef(null),gt=y.useMemo(()=>{const Fe=[];for(let We=0;We<t.length;We++){const lt=t[We];if(lt.kind!=="user")continue;let yt="";for(let Bt=We+1;Bt<t.length;Bt++){const Qt=t[Bt];if(Qt.kind==="user")break;if(Qt.kind==="text"){yt=Qt.text;break}}Fe.push({key:lt.key,question:fq(lt.text)||"[image]",answer:yt})}return Fe},[t]),ut=y.useCallback(()=>{const Fe=T.current;Fe&&Fe.scrollHeight-Fe.scrollTop-Fe.clientHeight>2&&(ee.current=!0,Fe.scrollTop=Fe.scrollHeight)},[]),pt=y.useCallback(()=>{cancelAnimationFrame(P.current);const Fe=Date.now()+1200;let We=null;const lt=()=>{cancelAnimationFrame(P.current),ee.current=!1,We?.removeEventListener("touchstart",lt),We?.removeEventListener("wheel",lt)},yt=()=>{if(X.current){lt();return}!We&&T.current&&(We=T.current,We.addEventListener("touchstart",lt,{passive:!0,once:!0}),We.addEventListener("wheel",lt,{passive:!0,once:!0})),ut(),W.current=!0,H(!0),Date.now()<Fe?P.current=requestAnimationFrame(yt):lt()};yt(),H(!0),W.current=!0},[ut]);y.useEffect(()=>()=>{cancelAnimationFrame(P.current),cancelAnimationFrame(K.current),window.clearTimeout(te.current)},[]),y.useEffect(()=>TK.subscribe(({active:Fe},We)=>{if(Fe===We.active)return;if(Fe){cancelAnimationFrame(P.current),cancelAnimationFrame(K.current),ee.current=!1;return}const lt=Q.current;Q.current=!1,lt&&W.current&&!X.current&&ut()}),[ut]);const It=()=>{X.current=!0,window.clearTimeout(te.current)},kt=()=>{window.clearTimeout(te.current),te.current=window.setTimeout(()=>{X.current=!1},400)},ln=()=>{It(),kt()},qt=()=>[...T.current?.querySelectorAll("[data-nav-key]")??[]],Jt=Fe=>{ln(),st.current=Fe,je(Fe,!0)},cn=Fe=>{if(Fe.key!=="Escape"||Fe.defaultPrevented||Je.owners.size===0)return;const We=T.current,lt=Fe.target;if(!We?.contains(lt)||lt.closest?.(p6t)||_2e()||document.querySelector('[role="dialog"], [role="alertdialog"]'))return;const yt=We.getBoundingClientRect();for(const Bt of qt()){const Qt=Je.owners.get(Bt.getAttribute("data-nav-key")??"");if(!Qt)continue;const dn=Bt.getBoundingClientRect();if(dn.bottom<=yt.top||dn.top>=yt.bottom)continue;const pn=Fe.nativeEvent;window.addEventListener("keydown",Zt=>{Zt!==pn||Zt.defaultPrevented||(Zt.preventDefault(),Jt(Qt))},{once:!0});return}},hn=()=>{cancelAnimationFrame(P.current),cancelAnimationFrame(K.current),ee.current=!1,W.current=!1,H(!1)},St=y.useCallback(Fe=>{if(J.current?.disconnect(),J.current=null,!Fe)return;const We=new ResizeObserver(()=>{if(!W.current&&!ee.current)return;cancelAnimationFrame(K.current);let lt=8;const yt=()=>{ut();const Bt=T.current;(Bt?Bt.scrollHeight-Bt.scrollTop-Bt.clientHeight:0)<=2||(--lt>0?K.current=requestAnimationFrame(yt):pt())};yt()});We.observe(Fe),J.current=We,pt()},[ut,pt]);y.useEffect(()=>()=>J.current?.disconnect(),[]);const wt=Fe=>Ve.findIndex(We=>We.key===Fe||We.kind==="tool-group"&&b5e(We,Fe)),Dt=Fe=>{if(!m){T.current?.querySelector(`[data-nav-key="${CSS.escape(Fe)}"]`)?.scrollIntoView({block:"center"});return}const We=wt(Fe);We>=0&&z.current?.scrollToIndex({index:Vle(Ze,We),align:"center"})},fe=y.useRef(null),Ie=Fe=>{if(hn(),wt(Fe)>=0){fe.current=null,Dt(Fe);return}let We=null,lt=!1;for(const yt of t)if(yt.kind==="user"&&(We=yt.key),yt.key===Fe){lt=!0;break}!lt||!We||(fe.current=Fe,je(We,!1))};y.useLayoutEffect(()=>{const Fe=fe.current;!Fe||wt(Fe)<0||(fe.current=null,Dt(Fe))},[Ve]),y.useLayoutEffect(()=>{const Fe=st.current;if(!Fe)return;st.current=null;const We=qt().find(yt=>yt.getAttribute("data-nav-key")===Fe);if(We){v5e(We,T.current);return}const lt=Ve.findIndex(yt=>yt.key===Fe);m&&lt>=0&&z.current?.scrollToIndex({index:Vle(Ze,lt),align:"start"})},[Ve]),y.useImperativeHandle(e,()=>({scrollToBottom:pt,pinToBottom:ut,isAtBottom:()=>W.current,getScroller:()=>m?null:T.current,scrollToKey:Ie}));const Ae=y.useRef(!1),ce=`${S}:${Ze}`,Oe=y.useRef(ce);Oe.current!==ce&&(Oe.current=ce,Ae.current=!1);const dt=()=>{!v||Ae.current||(Ae.current=!0,v())};y.useEffect(()=>{m&&!b&&Ge.current===Ze&&dt()},[S,b]);const vt=y.useMemo(()=>({query:k,activeKey:C?.key??"",activeNth:C?.nth??-1}),[k,C?.key,C?.nth]),Et=(Fe,We)=>{const lt=Ve[We+1];if(lt!==void 0&&Ule(Fe)&&Ule(lt))return"pb-0";if(!_e)return"pb-4";const yt=lt!==void 0&&Ole(lt);return Ole(Fe)?yt?"pb-1":"pb-2":Fe.kind==="text"&&yt?"pb-1":"pb-4"},Ct=(Fe,We)=>{const lt=Ve[We-1],yt=lt?.kind==="user"&&!lt.collapsed&&s6t.has(Fe.kind)?lt:void 0,Bt=Date.now(),Qt=he.current.collapse.get(Fe.key),dn=Qt&&Bt-Qt.at<Gle?Qt:void 0,pn=Ye.get(Fe.key),Zt=pn&&he.current.reveal.get(pn.group),An=pn&&Zt!==void 0&&Bt-Zt<Gle,bn=Je.ends.get(Fe.key);return a.jsxs("div",{"data-nav-key":Fe.key,"data-fold-collapse":dn?dn.pair?"pair":"toggle":void 0,style:dn?{"--fold-from":`${dn.height}px`}:An?{"--fold-i":pn.index}:void 0,className:ve(Dg,Et(Fe,We),An&&"t-fold-reveal","[overflow-wrap:anywhere]"),children:[yt&&a.jsx(pMt,{model:yt.replyModel,at:yt.replyAt,privacyMask:yt.replyPrivacyMask,secretarySession:R,face:F,conversationId:j}),a.jsx(w6t,{itemKey:Fe.key,children:a.jsx(mMt,{item:Fe,secretarySession:R,onToggleGroup:tt,onToggleTurn:je})}),bn&&a.jsx(RMt,{turnKey:bn,canCollapse:!0,collapsed:!1,onToggleTurn:Jt})]},Fe.key)},xn=y.useRef(!1);x===!0&&(xn.current=!0);const yn=fnt(t.length>0,b,x,xn.current,!m&&G);y.useLayoutEffect(()=>{if(m){ne(!1);return}const Fe=T.current;ne(!!Fe&&hnt(x===!0,b,Fe.scrollHeight,Fe.clientHeight))},[m,x,b,Ze,Ve.length,t.length]);const er={pageChrome:yn,onLoadMore:yn==="more"?dt:void 0,busy:n,loading:!!r,since:tIt({loading:!!r,runStartedAt:o}),error:l,onRetryResume:h};return a.jsx(JTe.Provider,{value:vt,children:a.jsx(GRt,{value:He.current,children:a.jsxs("div",{ref:U,"data-enso":"timeline",className:"@container relative min-h-24 flex-1",onWheel:ln,onKeyDown:Fe=>{ln(),cn(Fe)},onTouchStart:Fe=>{T.current?.contains(Fe.target)&&It()},onTouchEnd:kt,onPointerDown:Fe=>{Fe.target===T.current&&(It(),window.addEventListener("pointerup",kt,{once:!0}))},children:[a.jsx(sIt,{items:gt,activeKey:oe,onJump:Ie}),I&&a.jsx(hIt,{containerRef:U}),t.length===0&&!n?a.jsxs(Wle,{className:"flex h-full flex-col items-center justify-center gap-2 overflow-y-auto px-4 text-center",children:[a.jsx("span",{className:"t-stagger-line t-stagger-line--1 mb-3",children:D?a.jsx(XN,{name:D.name,color:D.color,image:D.image,needsYou:0,running:0,size:"lg",enso:"secretary-chat-avatar"}):a.jsx("span",{className:"flex size-11 items-center justify-center rounded-[13px] border border-brand/20 bg-brand/8 text-brand dark:bg-brand/14",children:a.jsx(Z5t,{className:"size-6"})})}),a.jsx("p",{className:"t-stagger-line t-stagger-line--1 text-[22px] font-semibold tracking-tight",children:c}),l?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"t-stagger-line t-stagger-line--2 max-w-md text-sm text-destructive whitespace-pre-wrap",children:_(l)}),h&&a.jsx(Ke,{size:"sm",variant:"outline",onClick:h,children:_("Retry resume")})]}):a.jsxs(a.Fragment,{children:[p?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"t-stagger-line t-stagger-line--2 max-w-md text-sm text-muted-foreground",children:_("Session is not ready yet — no history to show.")}),a.jsx(Ke,{size:"sm",variant:"outline",onClick:p,children:_("Retry sync")})]}):u!==""?a.jsx("p",{className:"t-stagger-line t-stagger-line--2 text-sm text-muted-foreground",children:u??_(f==="secretary"?"Tell the secretary what to take care of…":"Ask the agent…")}):null,d&&a.jsx("div",{className:"t-stagger-line t-stagger-line--3 mt-5 w-full",children:a.jsx(l6t,{onPick:d,variant:f})})]})]}):t.length===0&&l?a.jsxs(Wle,{className:"flex h-full flex-col items-center justify-center gap-2 text-center",children:[a.jsx("p",{className:"t-stagger-line t-stagger-line--1 max-w-md text-sm text-destructive whitespace-pre-wrap",children:_(l)}),h&&a.jsx(Ke,{size:"sm",variant:"outline",onClick:h,children:_("Retry resume")})]}):t.length===0?a.jsxs("div",{"data-timeline-loading":"",className:"flex h-full flex-col items-center justify-center gap-2.5 text-center",children:[a.jsx(Jn,{className:"h-5 w-5 animate-spin text-muted-foreground"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:_("Preparing session…")})]}):m?a.jsx(_5t,{ref:z,data:Ve,defaultItemHeight:80,computeItemKey:(Fe,We)=>We.key,firstItemIndex:Ze,startReached:dt,followOutput:d6t,atBottomThreshold:qle,atBottomStateChange:Fe=>{if(!Fe&&W.current&&!X.current){if(AK()){Q.current=!0;return}pt();return}H(Fe),W.current=Fe},increaseViewportBy:u6t,initialTopMostItemIndex:c6t,rangeChanged:({startIndex:Fe})=>{Ge.current=Fe,Fe>Ze+4&&(Ae.current=!1),ue(()=>{const We=Math.max(0,Fe-Ze);let lt=null;for(let yt=0;yt<=Math.min(We+1,Ve.length-1);yt++)Ve[yt]?.kind==="user"&&(lt=Ve[yt].key);return lt})},scrollerRef:Fe=>{T.current=Fe instanceof HTMLElement?Fe:null},className:"h-full select-text",context:er,components:v6t,itemContent:(Fe,We)=>Ct(We,Fe-Ze)},Ne.current):a.jsx("div",{ref:Fe=>{T.current=Fe},onScroll:Fe=>{const We=Fe.currentTarget;if(ee.current){ee.current=!1,W.current=!0,H(!0);return}if(!X.current){W.current&&ut();return}const lt=We.scrollHeight-We.scrollTop-We.clientHeight<=qle;lt!==W.current&&(W.current=lt,H(lt)),v&&(We.scrollTop<80&&!Ae.current?(Ae.current=!0,v()):We.scrollTop>240&&(Ae.current=!1))},className:"h-full select-text overflow-y-auto [overflow-anchor:none]",children:a.jsxs("div",{ref:St,children:[a.jsx(y5e,{context:er}),Ve.map((Fe,We)=>Ct(Fe,We)),a.jsx(w5e,{context:er})]})}),!B&&t.length>0&&a.jsxs("button",{type:"button",onClick:pt,className:"absolute bottom-4 left-1/2 z-10 inline-flex h-7 -translate-x-1/2 items-center gap-1.5 rounded-full border bg-card px-3 text-xs text-muted-foreground shadow-float transition-colors hover:text-foreground",children:[a.jsx(Y4,{className:"h-3 w-3"}),_("Scroll to bottom")]})]})})})}function b5e(e,t){return e.children.some(n=>n.key===t||n.kind==="tool-group"&&b5e(n,t))}function g6t({chrome:e,onLoadMore:t}){const{t:n}=Se();return e==="none"?a.jsx("div",{className:"h-6"}):a.jsx("div",{className:ve(Dg,"flex items-center justify-center gap-2 py-3"),children:e==="loading"?a.jsxs(a.Fragment,{children:[a.jsx(Jn,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"}),a.jsx("p",{className:"text-xs text-muted-foreground",children:n("Loading earlier messages…")})]}):e==="more"?a.jsx("button",{type:"button",className:"text-xs text-muted-foreground underline-offset-2 hover:underline",onClick:t,children:n("Load earlier messages")}):a.jsx("p",{className:"text-xs text-muted-foreground",children:n("Beginning of conversation")})})}function y5e({context:e}){return a.jsx(g6t,{chrome:e.pageChrome,onLoadMore:e.onLoadMore})}function w5e({context:e}){const{t}=Se(),{busy:n,loading:r,since:s,error:o,onRetryResume:i}=e;return a.jsxs("div",{className:ve(Dg,"pb-6 [overflow-wrap:anywhere]"),children:[n&&a.jsxs("div",{className:"flex min-h-[26px] items-center gap-2 text-[13px]",children:[a.jsx(x6t,{}),a.jsx("span",{className:"animate-pulse text-foreground motion-reduce:animate-none",children:t(r?"Loading…":"Working…")}),s!==void 0&&a.jsx(y6t,{since:s})]}),o&&a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx("p",{className:"min-w-0 flex-1 text-sm text-destructive whitespace-pre-wrap",children:t(o)}),a.jsx(p5e,{}),i&&a.jsx(Ke,{size:"sm",variant:"outline",onClick:i,children:t("Retry resume")})]})]})}const v6t={List:m6t,Header:y5e,Footer:w5e};function x6t(){return a.jsxs("span",{className:"relative flex size-[22px] shrink-0 items-center justify-center",children:[a.jsx("span",{className:"absolute size-2 animate-ping rounded-full bg-brand/50"}),a.jsx("span",{className:"relative size-2 rounded-full bg-brand"})]})}const b6t=e=>{const t=Math.max(0,Math.round(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m${t%60}s`},y6t=y.memo(function({since:t}){const[,n]=y.useState(0);return y.useEffect(()=>{const r=setInterval(()=>n(s=>s+1),1e3);return()=>clearInterval(r)},[]),a.jsx("span",{className:"font-mono text-[11px] text-muted-foreground tabular-nums",children:b6t(Date.now()-t)})});class w6t extends y.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidUpdate(t){t.itemKey!==this.props.itemKey&&this.state.failed&&this.setState({failed:!1})}render(){return this.state.failed?a.jsxs("p",{className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-1.5 text-xs text-destructive",children:["message render failed · ",this.props.itemKey]}):this.props.children}}const tk={type:"spring",stiffness:400,damping:30},V6={type:"tween",duration:.22,ease:[.2,0,0,1]},h9={initial:{height:0,opacity:0},animate:{height:"auto",opacity:1,transition:V6},exit:{height:0,opacity:0,transition:V6}};function gcn(e){return e.resizing?!0:e.previousConversationId!==void 0&&e.conversationId!==void 0&&e.previousConversationId!==e.conversationId}function k6t(e){return e.skip?{duration:0}:e.cover||e.targetW===0?V6:tk}const S6t={ts:hw,tsx:hw,js:hw,jsx:hw,mjs:hw,json:X4,html:cze,css:pz,scss:pz,md:Kp,sh:wT,bash:wT,yml:Md,yaml:Md,toml:Md},C6t={ts:"text-blue-500",tsx:"text-blue-500",js:"text-yellow-500",jsx:"text-yellow-500",mjs:"text-yellow-500",json:"text-yellow-600",html:"text-orange-500",css:"text-pink-500",scss:"text-pink-500",md:"text-sky-500",sh:"text-muted-foreground"};function E6t(e,t,n=!1){if(t)return n?Yu:Q4;const r=e.split(".").pop()?.toLowerCase()??"";return S6t[r]??Hze}function T6t(e,t){if(t)return"text-amber-500";const n=e.split(".").pop()?.toLowerCase()??"";return C6t[n]??"text-muted-foreground"}const A6t=y.lazy(()=>Be(()=>import("./ReadFileView-B24dkbc8.js"),[],import.meta.url).then(e=>({default:e.ReadFileView}))),N6t={artifacts:[],media:[]},p9=new Map,m9=new Map,I6t=new Set(["image","markdown","html","text"]),j6t=e=>e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`;function R6t(e){const t=JSON.stringify(e),[n,r]=y.useState(()=>p9.get(t)??N6t);return y.useEffect(()=>{if(p9.has(t))return;let s=!0;return window.electronAPI.bots.artifacts.list(JSON.parse(t)).then(o=>{if(!s||!o.ok)return;const i={artifacts:o.artifacts,media:o.media??[]};(i.artifacts.length>0||i.media.length>0)&&p9.set(t,i),r(i)}).catch(()=>{}),()=>{s=!1}},[t]),n}function M6t(e){const{t}=Se();return(n,r)=>{window.electronAPI.bots.artifacts.open({...e,rel:n.rel,action:r}).then(s=>{s.ok||Ht({type:"error",title:s.error==="not-openable"?t("This file type is only shown in Finder"):t("Could not open the file")})})}}function G6({target:e}){const{artifacts:t,media:n}=R6t(e);return a.jsxs(a.Fragment,{children:[n.length>0&&a.jsx(P6t,{target:e,media:n}),t.length>0&&a.jsx(D6t,{target:e,artifacts:t})]})}function _6t(){const{t:e}=Se();return({source:t,name:n})=>t==="upload"?"":t==="web"?e("Web screenshot"):t==="desktop"?e("Desktop screenshot"):n&&/^(?:\/|[A-Za-z]:[\\/])/.test(n)?e("This computer"):e("Workspace image")}function k5e(e,t,n){const r=JSON.stringify(e),s=t&&n==="thumb"?m9.get(t):void 0,[o,i]=y.useState(s?{ok:!0,kind:"image",dataUrl:s}:null);return y.useEffect(()=>{const l=t&&n==="thumb"?m9.get(t):void 0;if(i(l?{ok:!0,kind:"image",dataUrl:l}:null),!t||l)return;let c=!0;return window.electronAPI.bots.artifacts.read({...JSON.parse(r),mediaId:t,variant:n}).then(u=>{n==="thumb"&&u.ok&&u.kind==="image"&&m9.set(t,u.dataUrl),c&&i(u)}).catch(()=>c&&i({ok:!1,error:"unavailable"})),()=>{c=!1}},[r,t,n]),o}function P6t({target:e,media:t}){const{t:n}=Se(),r=_6t(),[s,o]=y.useState(null),i=t.some(l=>l.ok&&l.source==="desktop");return a.jsxs("div",{className:"mt-2","data-bot-media":"",children:[a.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.map((l,c)=>l.ok?a.jsx(L6t,{target:e,item:l,label:r(l),onOpen:()=>o(l)},l.mediaId):a.jsxs("div",{className:"flex w-40 flex-col gap-1 rounded-lg border border-destructive/60 border-dashed p-2 text-destructive text-xs",children:[a.jsxs("span",{className:"flex items-center gap-1 font-medium",children:[a.jsx(oM,{className:"h-3.5 w-3.5 shrink-0"}),a.jsx("span",{className:"truncate",children:l.name??r(l)})]}),a.jsx("span",{children:l.error==="quota"?n("Chat image storage is full (200 MiB); not saved"):n("Not sent: still over 10 MiB after compression")})]},`failed-${c}`))}),i&&a.jsx("p",{className:"mt-1 text-warning text-xs",children:n("Desktop screenshots may capture sensitive content from other windows.")}),a.jsx(O6t,{target:e,item:s,label:s?r(s):"",onClose:()=>o(null)})]})}function L6t({target:e,item:t,label:n,onOpen:r}){const s=k5e(e,t.mediaId,"thumb"),o=t.caption??t.name??n;return a.jsxs("button",{type:"button",title:o,onClick:r,className:"relative h-24 w-36 overflow-hidden rounded-lg border bg-muted",children:[s?.ok&&s.kind==="image"?a.jsx("img",{src:s.dataUrl,alt:o,className:"h-full w-full object-cover"}):s?a.jsx(oM,{className:"m-auto h-4 w-4 text-muted-foreground"}):a.jsx(Jn,{className:"m-auto h-4 w-4 animate-spin text-muted-foreground"}),n&&a.jsx("span",{className:ve("absolute top-1 left-1 rounded px-1 text-[10px] leading-4",t.source==="desktop"?"bg-warning text-warning-foreground":"bg-black/60 text-white"),children:n}),(t.caption||t.name)&&a.jsx("span",{className:"absolute inset-x-0 bottom-0 truncate bg-gradient-to-t from-black/70 to-transparent px-1.5 pt-3 pb-0.5 text-left text-[10px] text-white",children:t.caption??t.name})]})}function O6t({target:e,item:t,label:n,onClose:r}){const{t:s}=Se(),o=k5e(e,t?.mediaId??null,"full"),i=t?.caption??t?.name??n;return a.jsx(gr,{open:t!==null,onOpenChange:l=>!l&&r(),children:a.jsxs(vr,{className:"flex h-[80vh] max-w-4xl flex-col",children:[a.jsx(xr,{children:a.jsxs(dr,{className:"flex min-w-0 items-center gap-2 pr-8",children:[a.jsx("span",{className:"truncate",children:i}),a.jsx("span",{className:"shrink-0 font-normal text-muted-foreground text-xs",children:n})]})}),t?.source==="desktop"&&a.jsx("p",{className:"text-warning text-xs",children:s("Desktop screenshots may capture sensitive content from other windows.")}),t?.source==="file"&&a.jsx("p",{className:"text-muted-foreground text-xs",children:s("Copied into this chat: later edits or deletion of the original do not change it. Deleted together with the chat.")}),a.jsx(S5e,{name:i,content:o})]})})}function D6t({target:e,artifacts:t}){const{t:n}=Se(),r=M6t(e),[s,o]=y.useState(null);return a.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-1.5","data-bot-artifacts":"",children:[t.map(i=>{const l=E6t(i.name,!1),c=I6t.has(i.kind)||i.kind==="pdf";return a.jsxs("div",{"data-slot":"bot-card",className:"group/artifact flex max-w-64 items-center gap-1 rounded-lg border bg-card py-1 pr-1 pl-2 text-xs",children:[a.jsxs("button",{type:"button",title:i.rel,disabled:!c,onClick:()=>i.kind==="pdf"?r(i,"preview"):o(i),className:"flex min-w-0 items-center gap-1.5 text-left enabled:hover:underline disabled:cursor-default",children:[a.jsx(l,{className:ve("h-3.5 w-3.5 shrink-0",T6t(i.name,!1))}),a.jsx("span",{className:"truncate",children:i.name}),a.jsx("span",{className:"shrink-0 text-muted-foreground",children:j6t(i.size)})]}),a.jsx("button",{type:"button",title:n("Show in Finder"),onClick:()=>r(i,"reveal"),className:"rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground",children:a.jsx(Yu,{className:"h-3.5 w-3.5"})}),a.jsx("button",{type:"button",title:n("Open with default app"),onClick:()=>r(i,"open"),className:"rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground",children:a.jsx(dy,{className:"h-3.5 w-3.5"})})]},i.rel)}),a.jsx(B6t,{target:e,artifact:s,onOpen:r,onClose:()=>o(null)})]})}function B6t({target:e,artifact:t,onOpen:n,onClose:r}){const{t:s}=Se(),[o,i]=y.useState(null),l=t?.rel,c=JSON.stringify(e);return y.useEffect(()=>{if(i(null),!l)return;let u=!0;return window.electronAPI.bots.artifacts.read({...JSON.parse(c),rel:l}).then(d=>u&&i(d)).catch(()=>u&&i({ok:!1,error:"unavailable"})),()=>{u=!1}},[c,l]),a.jsx(gr,{open:t!==null,onOpenChange:u=>!u&&r(),children:a.jsxs(vr,{className:"flex h-[80vh] max-w-4xl flex-col",children:[a.jsx(xr,{children:a.jsxs(dr,{className:"flex min-w-0 items-center gap-2 pr-8",children:[a.jsx("span",{className:"truncate",children:t?.name}),a.jsx("span",{className:"truncate font-normal text-muted-foreground text-xs",children:t?.rel}),a.jsx("span",{className:"flex-1"}),t&&a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",title:s("Show in Finder"),onClick:()=>n(t,"reveal"),className:"rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground",children:a.jsx(Yu,{className:"h-4 w-4"})}),a.jsx("button",{type:"button",title:s("Open with default app"),onClick:()=>n(t,"open"),className:"rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground",children:a.jsx(dy,{className:"h-4 w-4"})})]})]})}),a.jsx(S5e,{name:t?.name??"",content:o})]})})}function S5e({name:e,content:t}){const{t:n}=Se();return a.jsxs("div",{className:"min-h-0 flex-1 select-text overflow-auto border-t","data-bot-artifact-preview":"",children:[!t&&a.jsx("div",{className:"flex justify-center p-6 text-muted-foreground",children:a.jsx(Jn,{className:"h-4 w-4 animate-spin"})}),t&&!t.ok&&a.jsx("p",{className:"p-6 text-muted-foreground text-sm",children:t.error==="too-large"?n("The file is too large to preview"):n("Could not open the file")}),t?.ok&&t.kind==="image"&&a.jsx("img",{src:t.dataUrl,alt:e,className:"mx-auto max-h-full max-w-full object-contain p-4"}),t?.ok&&t.kind==="markdown"&&a.jsx("div",{className:"px-6 py-4 text-sm",children:a.jsx(ua,{text:t.text})}),t?.ok&&t.kind==="html"&&a.jsx("iframe",{title:e,sandbox:"",srcDoc:t.text,className:"h-full w-full bg-white"}),t?.ok&&t.kind==="text"&&a.jsx("div",{className:"p-2 text-xs",children:a.jsx(y.Suspense,{fallback:null,children:a.jsx(A6t,{path:e,contents:t.text})})})]})}var fb={},uC={};var Yle;function F6t(){if(Yle)return uC;Yle=1;var e=Dy(),t=L4();function n(q){var $="https://react.dev/errors/"+q;if(1<arguments.length){$+="?args[]="+encodeURIComponent(arguments[1]);for(var ae=2;ae<arguments.length;ae++)$+="&args[]="+encodeURIComponent(arguments[ae])}return"Minified React error #"+q+"; visit "+$+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=Symbol.for("react.transitional.element"),s=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),u=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),v=Symbol.for("react.scope"),b=Symbol.for("react.activity"),x=Symbol.for("react.legacy_hidden"),S=Symbol.for("react.memo_cache_sentinel"),k=Symbol.for("react.view_transition"),C=Symbol.iterator;function A(q){return q===null||typeof q!="object"?null:(q=C&&q[C]||q["@@iterator"],typeof q=="function"?q:null)}var N=Array.isArray;function j(q,$){var ae=q.length&3,me=q.length-ae,Ee=$;for($=0;$<me;){var et=q.charCodeAt($)&255|(q.charCodeAt(++$)&255)<<8|(q.charCodeAt(++$)&255)<<16|(q.charCodeAt(++$)&255)<<24;++$,et=3432918353*(et&65535)+((3432918353*(et>>>16)&65535)<<16)&4294967295,et=et<<15|et>>>17,et=461845907*(et&65535)+((461845907*(et>>>16)&65535)<<16)&4294967295,Ee^=et,Ee=Ee<<13|Ee>>>19,Ee=5*(Ee&65535)+((5*(Ee>>>16)&65535)<<16)&4294967295,Ee=(Ee&65535)+27492+(((Ee>>>16)+58964&65535)<<16)}switch(et=0,ae){case 3:et^=(q.charCodeAt($+2)&255)<<16;case 2:et^=(q.charCodeAt($+1)&255)<<8;case 1:et^=q.charCodeAt($)&255,et=3432918353*(et&65535)+((3432918353*(et>>>16)&65535)<<16)&4294967295,et=et<<15|et>>>17,Ee^=461845907*(et&65535)+((461845907*(et>>>16)&65535)<<16)&4294967295}return Ee^=q.length,Ee^=Ee>>>16,Ee=2246822507*(Ee&65535)+((2246822507*(Ee>>>16)&65535)<<16)&4294967295,Ee^=Ee>>>13,Ee=3266489909*(Ee&65535)+((3266489909*(Ee>>>16)&65535)<<16)&4294967295,(Ee^Ee>>>16)>>>0}var I=Object.assign,_=Object.prototype.hasOwnProperty,L=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),M={},F={};function D(q){return _.call(F,q)?!0:_.call(M,q)?!1:L.test(q)?F[q]=!0:(M[q]=!0,!1)}var R=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" ")),z=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),B=/["'&<>]/;function H(q){if(typeof q=="boolean"||typeof q=="number"||typeof q=="bigint")return""+q;q=""+q;var $=B.exec(q);if($){var ae="",me,Ee=0;for(me=$.index;me<q.length;me++){switch(q.charCodeAt(me)){case 34:$="&quot;";break;case 38:$="&amp;";break;case 39:$="&#x27;";break;case 60:$="&lt;";break;case 62:$="&gt;";break;default:continue}Ee!==me&&(ae+=q.slice(Ee,me)),Ee=me+1,ae+=$}q=Ee!==me?ae+q.slice(Ee,me):ae}return q}var G=/([A-Z])/g,ne=/^ms-/,W=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function T(q){return W.test(""+q)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":q}var U=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P=t.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,K={pending:!1,data:null,method:null,action:null},J=P.d;P.d={f:J.f,r:J.r,D:lt,C:yt,L:Bt,m:Qt,X:pn,S:dn,M:Zt};var ee=[],X=null,te=/(<\/|<)(s)(cript)/gi;function Q(q,$,ae,me){return""+$+(ae==="s"?"\\u0073":"\\u0053")+me}function oe(q,$,ae,me,Ee){return{idPrefix:q===void 0?"":q,nextFormID:0,streamingFormat:0,bootstrapScriptContent:ae,bootstrapScripts:me,bootstrapModules:Ee,instructions:0,hasBody:!1,hasHtml:!1,unknownResources:{},dnsResources:{},connectResources:{default:{},anonymous:{},credentials:{}},imageResources:{},styleResources:{},scriptResources:{},moduleUnknownResources:{},moduleScriptResources:{}}}function de(q,$,ae,me){return{insertionMode:q,selectedValue:$,tagScope:ae,viewTransition:me}}function ie(q,$,ae){var me=q.tagScope&-25;switch($){case"noscript":return de(2,null,me|1,null);case"select":return de(2,ae.value!=null?ae.value:ae.defaultValue,me,null);case"svg":return de(4,null,me,null);case"picture":return de(2,null,me|2,null);case"math":return de(5,null,me,null);case"foreignObject":return de(2,null,me,null);case"table":return de(6,null,me,null);case"thead":case"tbody":case"tfoot":return de(7,null,me,null);case"colgroup":return de(9,null,me,null);case"tr":return de(8,null,me,null);case"head":if(2>q.insertionMode)return de(3,null,me,null);break;case"html":if(q.insertionMode===0)return de(1,null,me,null)}return 6<=q.insertionMode||2>q.insertionMode?de(2,null,me,null):q.tagScope!==me?de(q.insertionMode,q.selectedValue,me,null):q}function ue(q){return q===null?null:{update:q.update,enter:"none",exit:"none",share:q.update,name:q.autoName,autoName:q.autoName,nameIdx:0}}function xe(q,$){return $.tagScope&32&&(q.instructions|=128),de($.insertionMode,$.selectedValue,$.tagScope|12,ue($.viewTransition))}function ge(q,$){q=ue($.viewTransition);var ae=$.tagScope|16;return q!==null&&q.share!=="none"&&(ae|=64),de($.insertionMode,$.selectedValue,ae,q)}var Te=new Map;function De(q,$){if(typeof $!="object")throw Error(n(62));var ae=!0,me;for(me in $)if(_.call($,me)){var Ee=$[me];if(Ee!=null&&typeof Ee!="boolean"&&Ee!==""){if(me.indexOf("--")===0){var et=H(me);Ee=H((""+Ee).trim())}else et=Te.get(me),et===void 0&&(et=H(me.replace(G,"-$1").toLowerCase().replace(ne,"-ms-")),Te.set(me,et)),Ee=typeof Ee=="number"?Ee===0||R.has(me)?""+Ee:Ee+"px":H((""+Ee).trim());ae?(ae=!1,q.push(' style="',et,":",Ee)):q.push(";",et,":",Ee)}}ae||q.push('"')}function Me(q,$,ae){ae&&typeof ae!="function"&&typeof ae!="symbol"&&q.push(" ",$,'=""')}function ze(q,$,ae){typeof ae!="function"&&typeof ae!="symbol"&&typeof ae!="boolean"&&q.push(" ",$,'="',H(ae),'"')}var He=H("javascript:throw new Error('React form unexpectedly submitted.')");function tt(q,$){this.push('<input type="hidden"'),$e(q),ze(this,"name",$),ze(this,"value",q),this.push("/>")}function $e(q){if(typeof q!="string")throw Error(n(480))}function Ue(q,$){if(typeof $.$$FORM_ACTION=="function"){var ae=q.nextFormID++;q=q.idPrefix+ae;try{var me=$.$$FORM_ACTION(q);if(me){var Ee=me.data;Ee?.forEach($e)}return me}catch(et){if(typeof et=="object"&&et!==null&&typeof et.then=="function")throw et}}return null}function Pe(q,$,ae,me,Ee,et,ct,$t){var At=null;if(typeof me=="function"){var Kt=Ue($,me);Kt!==null?($t=Kt.name,me=Kt.action||"",Ee=Kt.encType,et=Kt.method,ct=Kt.target,At=Kt.data):(q.push(" ","formAction",'="',He,'"'),ct=et=Ee=me=$t=null,_e($,ae))}return $t!=null&&we(q,"name",$t),me!=null&&we(q,"formAction",me),Ee!=null&&we(q,"formEncType",Ee),et!=null&&we(q,"formMethod",et),ct!=null&&we(q,"formTarget",ct),At}function we(q,$,ae){switch($){case"className":ze(q,"class",ae);break;case"tabIndex":ze(q,"tabindex",ae);break;case"dir":case"role":case"viewBox":case"width":case"height":ze(q,$,ae);break;case"style":De(q,ae);break;case"src":case"href":if(ae==="")break;case"action":case"formAction":if(ae==null||typeof ae=="function"||typeof ae=="symbol"||typeof ae=="boolean")break;ae=T(""+ae),q.push(" ",$,'="',H(ae),'"');break;case"defaultValue":case"defaultChecked":case"innerHTML":case"suppressContentEditableWarning":case"suppressHydrationWarning":case"ref":break;case"autoFocus":case"multiple":case"muted":Me(q,$.toLowerCase(),ae);break;case"xlinkHref":if(typeof ae=="function"||typeof ae=="symbol"||typeof ae=="boolean")break;ae=T(""+ae),q.push(" ","xlink:href",'="',H(ae),'"');break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":typeof ae!="function"&&typeof ae!="symbol"&&q.push(" ",$,'="',H(ae),'"');break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":ae&&typeof ae!="function"&&typeof ae!="symbol"&&q.push(" ",$,'=""');break;case"capture":case"download":ae===!0?q.push(" ",$,'=""'):ae!==!1&&typeof ae!="function"&&typeof ae!="symbol"&&q.push(" ",$,'="',H(ae),'"');break;case"cols":case"rows":case"size":case"span":typeof ae!="function"&&typeof ae!="symbol"&&!isNaN(ae)&&1<=ae&&q.push(" ",$,'="',H(ae),'"');break;case"rowSpan":case"start":typeof ae=="function"||typeof ae=="symbol"||isNaN(ae)||q.push(" ",$,'="',H(ae),'"');break;case"xlinkActuate":ze(q,"xlink:actuate",ae);break;case"xlinkArcrole":ze(q,"xlink:arcrole",ae);break;case"xlinkRole":ze(q,"xlink:role",ae);break;case"xlinkShow":ze(q,"xlink:show",ae);break;case"xlinkTitle":ze(q,"xlink:title",ae);break;case"xlinkType":ze(q,"xlink:type",ae);break;case"xmlBase":ze(q,"xml:base",ae);break;case"xmlLang":ze(q,"xml:lang",ae);break;case"xmlSpace":ze(q,"xml:space",ae);break;default:if((!(2<$.length)||$[0]!=="o"&&$[0]!=="O"||$[1]!=="n"&&$[1]!=="N")&&($=z.get($)||$,D($))){switch(typeof ae){case"function":case"symbol":return;case"boolean":var me=$.toLowerCase().slice(0,5);if(me!=="data-"&&me!=="aria-")return}q.push(" ",$,'="',H(ae),'"')}}}function ye(q,$,ae){if($!=null){if(ae!=null)throw Error(n(60));if(typeof $!="object"||!("__html"in $))throw Error(n(61));$=$.__html,$!=null&&q.push(""+$)}}function Re(q){var $="";return e.Children.forEach(q,function(ae){ae!=null&&($+=ae)}),$}function _e(q,$){if((q.instructions&16)===0){q.instructions|=16;var ae=$.preamble,me=$.bootstrapChunks;(ae.htmlChunks||ae.headChunks)&&me.length===0?(me.push($.startInlineScript),yn(me,q),me.push(">",`addEventListener("submit",function(a){if(!a.defaultPrevented){var c=a.target,d=a.submitter,e=c.action,b=d;if(d){var f=d.getAttribute("formAction");null!=f&&(e=f,b=null)}"javascript:throw new Error('React form unexpectedly submitted.')"===e&&(a.preventDefault(),b?(a=document.createElement("input"),a.name=b.name,a.value=b.value,b.parentNode.insertBefore(a,b),b=new FormData(c),a.parentNode.removeChild(a)):b=new FormData(c),a=c.ownerDocument||c,(a.$$reactFormReplay=a.$$reactFormReplay||[]).push(c,d,b))}});`,"<\/script>")):me.unshift($.startInlineScript,">",`addEventListener("submit",function(a){if(!a.defaultPrevented){var c=a.target,d=a.submitter,e=c.action,b=d;if(d){var f=d.getAttribute("formAction");null!=f&&(e=f,b=null)}"javascript:throw new Error('React form unexpectedly submitted.')"===e&&(a.preventDefault(),b?(a=document.createElement("input"),a.name=b.name,a.value=b.value,b.parentNode.insertBefore(a,b),b=new FormData(c),a.parentNode.removeChild(a)):b=new FormData(c),a=c.ownerDocument||c,(a.$$reactFormReplay=a.$$reactFormReplay||[]).push(c,d,b))}});`,"<\/script>")}}function Ve(q,$){q.push(st("link"));for(var ae in $)if(_.call($,ae)){var me=$[ae];if(me!=null)switch(ae){case"children":case"dangerouslySetInnerHTML":throw Error(n(399,"link"));default:we(q,ae,me)}}return q.push("/>"),null}var he=/(<\/|<)(s)(tyle)/gi;function Ye(q,$,ae,me){return""+$+(ae==="s"?"\\73 ":"\\53 ")+me}function Le(q,$,ae){q.push(st(ae));for(var me in $)if(_.call($,me)){var Ee=$[me];if(Ee!=null)switch(me){case"children":case"dangerouslySetInnerHTML":throw Error(n(399,ae));default:we(q,me,Ee)}}return q.push("/>"),null}function Ne(q,$){q.push(st("title"));var ae=null,me=null,Ee;for(Ee in $)if(_.call($,Ee)){var et=$[Ee];if(et!=null)switch(Ee){case"children":ae=et;break;case"dangerouslySetInnerHTML":me=et;break;default:we(q,Ee,et)}}return q.push(">"),$=Array.isArray(ae)?2>ae.length?ae[0]:null:ae,typeof $!="function"&&typeof $!="symbol"&&$!==null&&$!==void 0&&q.push(H(""+$)),ye(q,me,ae),q.push(pt("title")),null}function Ge(q,$){q.push(st("script"));var ae=null,me=null,Ee;for(Ee in $)if(_.call($,Ee)){var et=$[Ee];if(et!=null)switch(Ee){case"children":ae=et;break;case"dangerouslySetInnerHTML":me=et;break;default:we(q,Ee,et)}}return q.push(">"),ye(q,me,ae),typeof ae=="string"&&q.push((""+ae).replace(te,Q)),q.push(pt("script")),null}function ft(q,$,ae){q.push(st(ae));var me=ae=null,Ee;for(Ee in $)if(_.call($,Ee)){var et=$[Ee];if(et!=null)switch(Ee){case"children":ae=et;break;case"dangerouslySetInnerHTML":me=et;break;default:we(q,Ee,et)}}return q.push(">"),ye(q,me,ae),ae}function Ze(q,$,ae){q.push(st(ae));var me=ae=null,Ee;for(Ee in $)if(_.call($,Ee)){var et=$[Ee];if(et!=null)switch(Ee){case"children":ae=et;break;case"dangerouslySetInnerHTML":me=et;break;default:we(q,Ee,et)}}return q.push(">"),ye(q,me,ae),typeof ae=="string"?(q.push(H(ae)),null):ae}var je=/^[a-zA-Z][a-zA-Z:_\.\-\d]*$/,Je=new Map;function st(q){var $=Je.get(q);if($===void 0){if(!je.test(q))throw Error(n(65,q));$="<"+q,Je.set(q,$)}return $}function gt(q,$,ae,me,Ee,et,ct,$t,At){switch($){case"div":case"span":case"svg":case"path":break;case"a":q.push(st("a"));var Kt=null,kn=null,rn;for(rn in ae)if(_.call(ae,rn)){var zn=ae[rn];if(zn!=null)switch(rn){case"children":Kt=zn;break;case"dangerouslySetInnerHTML":kn=zn;break;case"href":zn===""?ze(q,"href",""):we(q,rn,zn);break;default:we(q,rn,zn)}}if(q.push(">"),ye(q,kn,Kt),typeof Kt=="string"){q.push(H(Kt));var ir=null}else ir=Kt;return ir;case"g":case"p":case"li":break;case"select":q.push(st("select"));var cs=null,Qr=null,qr;for(qr in ae)if(_.call(ae,qr)){var Hr=ae[qr];if(Hr!=null)switch(qr){case"children":cs=Hr;break;case"dangerouslySetInnerHTML":Qr=Hr;break;case"defaultValue":case"value":break;default:we(q,qr,Hr)}}return q.push(">"),ye(q,Qr,cs),cs;case"option":var ts=$t.selectedValue;q.push(st("option"));var Ks=null,Go=null,ys=null,ws=null,Rs;for(Rs in ae)if(_.call(ae,Rs)){var Io=ae[Rs];if(Io!=null)switch(Rs){case"children":Ks=Io;break;case"selected":ys=Io;break;case"dangerouslySetInnerHTML":ws=Io;break;case"value":Go=Io;default:we(q,Rs,Io)}}if(ts!=null){var Ts=Go!==null?""+Go:Re(Ks);if(N(ts)){for(var Si=0;Si<ts.length;Si++)if(""+ts[Si]===Ts){q.push(' selected=""');break}}else""+ts===Ts&&q.push(' selected=""')}else ys&&q.push(' selected=""');return q.push(">"),ye(q,ws,Ks),Ks;case"textarea":q.push(st("textarea"));var Xs=null,ri=null,Do=null,jo;for(jo in ae)if(_.call(ae,jo)){var Ra=ae[jo];if(Ra!=null)switch(jo){case"children":Do=Ra;break;case"value":Xs=Ra;break;case"defaultValue":ri=Ra;break;case"dangerouslySetInnerHTML":throw Error(n(91));default:we(q,jo,Ra)}}if(Xs===null&&ri!==null&&(Xs=ri),q.push(">"),Do!=null){if(Xs!=null)throw Error(n(92));if(N(Do)){if(1<Do.length)throw Error(n(93));Xs=""+Do[0]}Xs=""+Do}return typeof Xs=="string"&&Xs[0]===`
386
386
  `&&q.push(`
387
387
  `),Xs!==null&&q.push(H(""+Xs)),null;case"input":q.push(st("input"));var sd=null,yl=null,Ma=null,Fc=null,Ci=null,Ka=null,Xa=null,hi=null,Oi=null,Qa;for(Qa in ae)if(_.call(ae,Qa)){var So=ae[Qa];if(So!=null)switch(Qa){case"children":case"dangerouslySetInnerHTML":throw Error(n(399,"input"));case"name":sd=So;break;case"formAction":yl=So;break;case"formEncType":Ma=So;break;case"formMethod":Fc=So;break;case"formTarget":Ci=So;break;case"defaultChecked":Oi=So;break;case"defaultValue":Xa=So;break;case"checked":hi=So;break;case"value":Ka=So;break;default:we(q,Qa,So)}}var _a=Pe(q,me,Ee,yl,Ma,Fc,Ci,sd);return hi!==null?Me(q,"checked",hi):Oi!==null&&Me(q,"checked",Oi),Ka!==null?we(q,"value",Ka):Xa!==null&&we(q,"value",Xa),q.push("/>"),_a?.forEach(tt,q),null;case"button":q.push(st("button"));var Hl=null,s0=null,bm=null,o0=null,i0=null,Ei=null,Ro=null,os;for(os in ae)if(_.call(ae,os)){var pa=ae[os];if(pa!=null)switch(os){case"children":Hl=pa;break;case"dangerouslySetInnerHTML":s0=pa;break;case"name":bm=pa;break;case"formAction":o0=pa;break;case"formEncType":i0=pa;break;case"formMethod":Ei=pa;break;case"formTarget":Ro=pa;break;default:we(q,os,pa)}}var ra=Pe(q,me,Ee,o0,i0,Ei,Ro,bm);if(q.push(">"),ra?.forEach(tt,q),ye(q,s0,Hl),typeof Hl=="string"){q.push(H(Hl));var Vh=null}else Vh=Hl;return Vh;case"form":q.push(st("form"));var Za=null,a0=null,Ul=null,wu=null,cc=null,Jd=null,od;for(od in ae)if(_.call(ae,od)){var zc=ae[od];if(zc!=null)switch(od){case"children":Za=zc;break;case"dangerouslySetInnerHTML":a0=zc;break;case"action":Ul=zc;break;case"encType":wu=zc;break;case"method":cc=zc;break;case"target":Jd=zc;break;default:we(q,od,zc)}}var id=null,Co=null;if(typeof Ul=="function"){var Ja=Ue(me,Ul);Ja!==null?(Ul=Ja.action||"",wu=Ja.encType,cc=Ja.method,Jd=Ja.target,id=Ja.data,Co=Ja.name):(q.push(" ","action",'="',He,'"'),Jd=cc=wu=Ul=null,_e(me,Ee))}if(Ul!=null&&we(q,"action",Ul),wu!=null&&we(q,"encType",wu),cc!=null&&we(q,"method",cc),Jd!=null&&we(q,"target",Jd),q.push(">"),Co!==null&&(q.push('<input type="hidden"'),ze(q,"name",Co),q.push("/>"),id?.forEach(tt,q)),ye(q,a0,Za),typeof Za=="string"){q.push(H(Za));var wl=null}else wl=Za;return wl;case"menuitem":q.push(st("menuitem"));for(var ku in ae)if(_.call(ae,ku)){var Gh=ae[ku];if(Gh!=null)switch(ku){case"children":case"dangerouslySetInnerHTML":throw Error(n(400));default:we(q,ku,Gh)}}return q.push(">"),null;case"object":q.push(st("object"));var ma=null,Hc=null,Vl;for(Vl in ae)if(_.call(ae,Vl)){var co=ae[Vl];if(co!=null)switch(Vl){case"children":ma=co;break;case"dangerouslySetInnerHTML":Hc=co;break;case"data":var Di=T(""+co);if(Di==="")break;q.push(" ","data",'="',H(Di),'"');break;default:we(q,Vl,co)}}if(q.push(">"),ye(q,Hc,ma),typeof ma=="string"){q.push(H(ma));var Wf=null}else Wf=ma;return Wf;case"title":var Pa=$t.tagScope&1,Rx=$t.tagScope&4;if($t.insertionMode===4||Pa||ae.itemProp!=null)var ym=Ne(q,ae);else Rx?ym=null:(Ne(Ee.hoistableChunks,ae),ym=void 0);return ym;case"link":var Wo=$t.tagScope&1,l0=$t.tagScope&4,Wh=ae.rel,Gl=ae.href,ad=ae.precedence;if($t.insertionMode===4||Wo||ae.itemProp!=null||typeof Wh!="string"||typeof Gl!="string"||Gl===""){Ve(q,ae);var Wl=null}else if(ae.rel==="stylesheet")if(typeof ad!="string"||ae.disabled!=null||ae.onLoad||ae.onError)Wl=Ve(q,ae);else{var pi=Ee.styles.get(ad),qh=me.styleResources.hasOwnProperty(Gl)?me.styleResources[Gl]:void 0;if(qh!==null){me.styleResources[Gl]=null,pi||(pi={precedence:H(ad),rules:[],hrefs:[],sheets:new Map},Ee.styles.set(ad,pi));var qf={state:0,props:I({},ae,{"data-precedence":ae.precedence,precedence:null})};if(qh){qh.length===2&&An(qf.props,qh);var c0=Ee.preloads.stylesheets.get(Gl);c0&&0<c0.length?c0.length=0:qf.state=1}pi.sheets.set(Gl,qf),ct&&ct.stylesheets.add(qf)}else if(pi){var wm=pi.sheets.get(Gl);wm&&ct&&ct.stylesheets.add(wm)}At&&q.push("<!-- -->"),Wl=null}else ae.onLoad||ae.onError?Wl=Ve(q,ae):(At&&q.push("<!-- -->"),Wl=l0?null:Ve(Ee.hoistableChunks,ae));return Wl;case"script":var ld=$t.tagScope&1,Yh=ae.async;if(typeof ae.src!="string"||!ae.src||!Yh||typeof Yh=="function"||typeof Yh=="symbol"||ae.onLoad||ae.onError||$t.insertionMode===4||ld||ae.itemProp!=null)var $h=Ge(q,ae);else{var mi=ae.src;if(ae.type==="module")var cd=me.moduleScriptResources,ef=Ee.preloads.moduleScripts;else cd=me.scriptResources,ef=Ee.preloads.scripts;var ud=cd.hasOwnProperty(mi)?cd[mi]:void 0;if(ud!==null){cd[mi]=null;var tf=ae;if(ud){ud.length===2&&(tf=I({},ae),An(tf,ud));var km=ef.get(mi);km&&(km.length=0)}var Kh=[];Ee.scripts.add(Kh),Ge(Kh,tf)}At&&q.push("<!-- -->"),$h=null}return $h;case"style":var Uc=$t.tagScope&1,el=ae.precedence,kl=ae.href,u0=ae.nonce;if($t.insertionMode===4||Uc||ae.itemProp!=null||typeof el!="string"||typeof kl!="string"||kl===""){q.push(st("style"));var ql=null,Yf=null,uc;for(uc in ae)if(_.call(ae,uc)){var Vc=ae[uc];if(Vc!=null)switch(uc){case"children":ql=Vc;break;case"dangerouslySetInnerHTML":Yf=Vc;break;default:we(q,uc,Vc)}}q.push(">");var dc=Array.isArray(ql)?2>ql.length?ql[0]:null:ql;typeof dc!="function"&&typeof dc!="symbol"&&dc!==null&&dc!==void 0&&q.push((""+dc).replace(he,Ye)),ye(q,Yf,ql),q.push(pt("style"));var $f=null}else{var tl=Ee.styles.get(el);if((me.styleResources.hasOwnProperty(kl)?me.styleResources[kl]:void 0)!==null){me.styleResources[kl]=null,tl||(tl={precedence:H(el),rules:[],hrefs:[],sheets:new Map},Ee.styles.set(el,tl));var d0=Ee.nonce.style;if(!d0||d0===u0){tl.hrefs.push(H(kl));var Su=tl.rules,Gc=null,Kf=null,Sl;for(Sl in ae)if(_.call(ae,Sl)){var La=ae[Sl];if(La!=null)switch(Sl){case"children":Gc=La;break;case"dangerouslySetInnerHTML":Kf=La}}var fc=Array.isArray(Gc)?2>Gc.length?Gc[0]:null:Gc;typeof fc!="function"&&typeof fc!="symbol"&&fc!==null&&fc!==void 0&&Su.push((""+fc).replace(he,Ye)),ye(Su,Kf,Gc)}}tl&&ct&&ct.styles.add(tl),At&&q.push("<!-- -->"),$f=void 0}return $f;case"meta":var Cl=$t.tagScope&1,Xh=$t.tagScope&4;if($t.insertionMode===4||Cl||ae.itemProp!=null)var Xf=Le(q,ae,"meta");else At&&q.push("<!-- -->"),Xf=Xh?null:typeof ae.charSet=="string"?Le(Ee.charsetChunks,ae,"meta"):ae.name==="viewport"?Le(Ee.viewportChunks,ae,"meta"):Le(Ee.hoistableChunks,ae,"meta");return Xf;case"listing":case"pre":q.push(st($));var Cu=null,V=null,Y;for(Y in ae)if(_.call(ae,Y)){var se=ae[Y];if(se!=null)switch(Y){case"children":Cu=se;break;case"dangerouslySetInnerHTML":V=se;break;default:we(q,Y,se)}}if(q.push(">"),V!=null){if(Cu!=null)throw Error(n(60));if(typeof V!="object"||!("__html"in V))throw Error(n(61));var pe=V.__html;pe!=null&&(typeof pe=="string"&&0<pe.length&&pe[0]===`
388
388
  `?q.push(`
@@ -784,7 +784,7 @@ Make sure your charset is UTF-8`);o=(o>>>8&255)*192+(o&255),r.put(o,13)}},x7=n,x
784
784
  The chosen QR Code version cannot contain this amount of data.
785
785
  Minimum version required to store current data is: `+M+`.
786
786
  `);const F=k(j,I,L),D=e.getSymbolSize(j),R=new r(D);return p(R,j),m(R),v(R,j),x(R,I,0),j>=7&&b(R,j),S(R,F),isNaN(_)&&(_=i.getBestMask(R,x.bind(null,R,I))),i.applyMask(_,R),x(R,I,_),{modules:R,version:j,errorCorrectionLevel:I,maskPattern:_,segments:L}}return t7.create=function(j,I){if(typeof j>"u"||j==="")throw new Error("No input text");let _=t.M,L,M;return typeof I<"u"&&(_=t.from(I.errorCorrectionLevel,t.M),L=u.from(I.version),M=i.from(I.maskPattern),I.toSJISFunc&&e.setToSJISFunction(I.toSJISFunc)),A(j,L,_,M)},t7}var y7={},w7={},Ude;function nMe(){return Ude||(Ude=1,(function(e){function t(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let r=n.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+n);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(o){return[o,o]}))),r.length===6&&r.push("F","F");const s=parseInt(r.join(""),16);return{r:s>>24&255,g:s>>16&255,b:s>>8&255,a:s&255,hex:"#"+r.slice(0,6).join("")}}e.getOptions=function(r){r||(r={}),r.color||(r.color={});const s=typeof r.margin>"u"||r.margin===null||r.margin<0?4:r.margin,o=r.width&&r.width>=21?r.width:void 0,i=r.scale||4;return{width:o,scale:o?4:i,margin:s,color:{dark:t(r.color.dark||"#000000ff"),light:t(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},e.getScale=function(r,s){return s.width&&s.width>=r+s.margin*2?s.width/(r+s.margin*2):s.scale},e.getImageWidth=function(r,s){const o=e.getScale(r,s);return Math.floor((r+s.margin*2)*o)},e.qrToImageData=function(r,s,o){const i=s.modules.size,l=s.modules.data,c=e.getScale(i,o),u=Math.floor((i+o.margin*2)*c),d=o.margin*c,f=[o.color.light,o.color.dark];for(let h=0;h<u;h++)for(let p=0;p<u;p++){let m=(h*u+p)*4,v=o.color.light;if(h>=d&&p>=d&&h<u-d&&p<u-d){const b=Math.floor((h-d)/c),x=Math.floor((p-d)/c);v=f[l[b*i+x]?1:0]}r[m++]=v.r,r[m++]=v.g,r[m++]=v.b,r[m]=v.a}}})(w7)),w7}var Vde;function vVt(){return Vde||(Vde=1,(function(e){const t=nMe();function n(s,o,i){s.clearRect(0,0,o.width,o.height),o.style||(o.style={}),o.height=i,o.width=i,o.style.height=i+"px",o.style.width=i+"px"}function r(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(o,i,l){let c=l,u=i;typeof c>"u"&&(!i||!i.getContext)&&(c=i,i=void 0),i||(u=r()),c=t.getOptions(c);const d=t.getImageWidth(o.modules.size,c),f=u.getContext("2d"),h=f.createImageData(d,d);return t.qrToImageData(h.data,o,c),n(f,u,d),f.putImageData(h,0,0),u},e.renderToDataURL=function(o,i,l){let c=l;typeof c>"u"&&(!i||!i.getContext)&&(c=i,i=void 0),c||(c={});const u=e.render(o,i,c),d=c.type||"image/png",f=c.rendererOpts||{};return u.toDataURL(d,f.quality)}})(y7)),y7}var k7={},Gde;function xVt(){if(Gde)return k7;Gde=1;const e=nMe();function t(s,o){const i=s.a/255,l=o+'="'+s.hex+'"';return i<1?l+" "+o+'-opacity="'+i.toFixed(2).slice(1)+'"':l}function n(s,o,i){let l=s+o;return typeof i<"u"&&(l+=" "+i),l}function r(s,o,i){let l="",c=0,u=!1,d=0;for(let f=0;f<s.length;f++){const h=Math.floor(f%o),p=Math.floor(f/o);!h&&!u&&(u=!0),s[f]?(d++,f>0&&h>0&&s[f-1]||(l+=u?n("M",h+i,.5+p+i):n("m",c,0),c=0,u=!1),h+1<o&&s[f+1]||(l+=n("h",d),d=0)):c++}return l}return k7.render=function(o,i,l){const c=e.getOptions(i),u=o.modules.size,d=o.modules.data,f=u+c.margin*2,h=c.color.light.a?"<path "+t(c.color.light,"fill")+' d="M0 0h'+f+"v"+f+'H0z"/>':"",p="<path "+t(c.color.dark,"stroke")+' d="'+r(d,u,c.margin)+'"/>',m='viewBox="0 0 '+f+" "+f+'"',b='<svg xmlns="http://www.w3.org/2000/svg" '+(c.width?'width="'+c.width+'" height="'+c.width+'" ':"")+m+' shape-rendering="crispEdges">'+h+p+`</svg>
787
- `;return typeof l=="function"&&l(null,b),b},k7}var Wde;function bVt(){if(Wde)return tw;Wde=1;const e=JUt(),t=gVt(),n=vVt(),r=xVt();function s(o,i,l,c,u){const d=[].slice.call(arguments,1),f=d.length,h=typeof d[f-1]=="function";if(!h&&!e())throw new Error("Callback required as last argument");if(h){if(f<2)throw new Error("Too few arguments provided");f===2?(u=l,l=i,i=c=void 0):f===3&&(i.getContext&&typeof u>"u"?(u=c,c=void 0):(u=c,c=l,l=i,i=void 0))}else{if(f<1)throw new Error("Too few arguments provided");return f===1?(l=i,i=c=void 0):f===2&&!i.getContext&&(c=l,l=i,i=void 0),new Promise(function(p,m){try{const v=t.create(l,c);p(o(v,i,c))}catch(v){m(v)}})}try{const p=t.create(l,c);u(null,o(p,i,c))}catch(p){u(p)}}return tw.create=t.create,tw.toCanvas=s.bind(null,n.render),tw.toDataURL=s.bind(null,n.renderToDataURL),tw.toString=s.bind(null,function(o,i,l){return r.render(o,l)}),tw}var yVt=bVt();const rMe=Oy(yVt);function wVt(e,t){const n=t.trim();if(n.length===0||n.length>512||n.startsWith("/")||n.startsWith("\\")||n.includes("\\")||n.includes("\0")||n.includes("?")||n.includes("#")||/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(n))return null;const r=EJ(e)&&e!=="."?e:e.split("/").pop()??"",s=r.lastIndexOf("/"),o=s===-1?"":r.slice(0,s),i=o?`${o}/${n}`:n,l=[];for(const u of i.split("/"))if(!(u===""||u===".")){if(u===".."){if(l.length===0)return null;l.pop();continue}l.push(u)}const c=l.join("/");return!c||!EJ(c)?null:c}function qde(e,t){const n=new RegExp(`\\b${t}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s"'=<>]+))`,"i").exec(e);return n?n[1]??n[2]??n[3]??"":null}function kVt(e,t,n){return e.replace(new RegExp(`\\b${t}\\s*=\\s*(?:"[^"]*"|'[^']*'|[^\\s"'=<>]+)`,"i"),`${t}="${n}"`)}function SVt(e){return e?.trim().toLowerCase().split(/\s+/).includes("stylesheet")??!1}function CVt(e){try{return new TextDecoder().decode(Uint8Array.from(atob(e),t=>t.charCodeAt(0)))}catch{return null}}function EVt(e,t){const n=[],r=(s,o,i,l)=>{const c=o[1]??"";if(!l(c))return;const u=qde(c,i);if(u===null)return;const d=wVt(t,u);d&&n.push({start:o.index,end:o.index+o[0].length,kind:s,rel:d,attrs:c,full:o[0]})};for(const s of e.matchAll(/<script\b([^>]*)>[\s\S]*?<\/script>/gi))r("script",s,"src",()=>!0);for(const s of e.matchAll(/<link\b([^>]*?)\/?>/gi))r("style",s,"href",o=>SVt(qde(o,"rel")));for(const s of e.matchAll(/<img\b([^>]*?)\/?>/gi))r("img",s,"src",()=>!0);return n.sort((s,o)=>s.start-o.start),n}async function TVt(e,t,n){const r=EVt(e,t),s=new Map;await Promise.all([...new Set(r.map(l=>l.rel))].map(async l=>{s.set(l,await n(l))}));let o=0,i="";for(const l of r){i+=e.slice(o,l.start),o=l.end;const c=s.get(l.rel);if(!c){i+=l.full;continue}if(l.kind==="img"){const d=c.mime||"application/octet-stream";i+=`<img${kVt(l.attrs,"src",`data:${d};base64,${c.base64}`)}>`;continue}const u=CVt(c.base64);if(u===null){i+=l.full;continue}i+=l.kind==="script"?`<script>${u.replace(/<\/script/gi,"<\\/script")}<\/script>`:`<style>${u.replace(/<\/style/gi,"<\\/style")}</style>`}return i+e.slice(o)}const AVt="plugin-view.html";function Yde(){return document.documentElement.classList.contains("dark")?"dark":"light"}function bcn({pluginId:e,viewId:t,sessionId:n}){const{t:r}=Se(),s=qGe().find(o=>o.pluginId===e&&o.id===t);return s?a.jsx(sMe,{pluginId:e,entry:s.entry,title:s.title,sessionId:n}):a.jsx("div",{className:"flex h-full items-center justify-center p-6 text-sm text-muted-foreground",children:r("Plugin is not enabled")})}function sMe({pluginId:e,entry:t,title:n,sessionId:r,file:s}){const o=y.useRef(null),[i,l]=y.useState(null),c=y.useRef(r);c.current=r;const u=it(b=>r?b.conversations[r]?.projectId??null:null),d=y.useRef(u);d.current=u;const f=y.useRef(s);f.current=s;const h=y.useRef(null),p=y.useRef(null);y.useEffect(()=>{const b=o.current;if(!b)return;l(null);let x=!1,S=null;const k=()=>{try{S?.port1.postMessage(UGe(Yde()))}catch{}},C=new MutationObserver(k);C.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]});const A=window.electronAPI.extensionPlugins.onViewEvent(I=>{if(!(I.pluginId!==e||typeof I.name!="string"))try{S?.port1.postMessage(VGe(I.name,I.data))}catch{}}),N=zGe(async(I,_)=>{const L=await window.electronAPI.extensionPlugins.call({pluginId:e,method:"renderer.call",payload:{method:I,args:_},sessionId:c.current});if(!L.ok)throw new Error(L.error);return L.value}),j=async I=>{if(I.source!==b.contentWindow||I.data?.type!=="enso-view-ready")return;S?.port1.close();const _=new MessageChannel;S=_,h.current=_,_.port1.onmessage=R=>{const z=HGe(R.data);if(z){window.electronAPI.extensionPlugins.viewStateSet(e,z);return}const B=WGe(R.data);if(B!==null){p.current=B,f.current?.onEdit(B);return}N(R.data).then(H=>{H&&!x&&S===_&&_.port1.postMessage(H)})};const[L,M]=await Promise.all([window.electronAPI.extensionPlugins.asset(e,t),window.electronAPI.extensionPlugins.viewStateGet(e)]);if(x||S!==_)return;if(!L.ok){l(L.error);return}const F=await TVt(VW(L.base64),t,async R=>{const z=await window.electronAPI.extensionPlugins.asset(e,R);return z.ok?{mime:z.mime,base64:z.base64}:null});if(x||S!==_)return;const D=f.current;b.contentWindow?.postMessage({type:"enso-view-init",html:F,theme:Yde(),storage:M.ok?M.state:{},session:ute(c.current,d.current),...D?{file:{rel:D.rel,text:D.text}}:{}},"*",[_.port2])};return window.addEventListener("message",j),b.src=new URL(AVt,document.baseURI).href,()=>{x=!0,C.disconnect(),A(),window.removeEventListener("message",j),S?.port1.close(),h.current=null,b.removeAttribute("src")}},[e,t]),y.useEffect(()=>{try{h.current?.port1.postMessage(ute(r,u))}catch{}},[r,u]);const m=s?.rel,v=s?.text;return y.useEffect(()=>{if(!(m===void 0||v===void 0)){if(p.current===v){p.current=null;return}try{h.current?.port1.postMessage(GGe(m,v))}catch{}}},[m,v]),a.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[i&&a.jsx("div",{className:"shrink-0 px-3 py-2 text-xs text-destructive",children:i}),a.jsx("iframe",{ref:o,title:n,className:"min-h-0 w-full flex-1 border-0 bg-background"})]})}const NVt="1",nw="inline-flex items-center gap-1.5 rounded-lg border border-border px-2.5 py-1.5 text-[12.5px] transition-colors hover:bg-muted disabled:opacity-50",$de={network:"Cannot reach api.telegram.org. Check the proxy.",unauthorized:"Telegram rejected this token",api:"Telegram returned an error","token-required":"Paste a bot token first","not-group":"This chat is not a group","invalid-chat-id":"Group chat IDs are numbers, e.g. -1001234567890","invalid-topic":"Pick at least one topic","route-conflict":"Another secretary already has this group or one of these topics"};function IVt({checked:e,disabled:t,label:n,onClick:r,enso:s}){return a.jsxs("button",{type:"button",role:"checkbox","aria-checked":e,"data-enso":s,disabled:t,onClick:r,className:"flex items-center gap-1.5 text-left text-[12px] disabled:opacity-50",children:[a.jsx("span",{className:ve("flex size-3.5 shrink-0 items-center justify-center rounded ring-1 ring-border",e&&"bg-foreground text-background ring-foreground"),children:e&&a.jsx(Is,{className:"size-2.5"})}),n]})}function Kde({checked:e,disabled:t,label:n,onClick:r,enso:s}){return a.jsx("button",{type:"button",role:"radio","aria-checked":e,"data-enso":s,disabled:t,onClick:r,className:ve("rounded-md px-2 py-0.5 text-[11.5px] transition-colors disabled:opacity-50",e?"bg-foreground text-background":"text-muted-foreground hover:bg-muted"),children:n})}function jVt({group:e,secretaryId:t,busy:n,onRemove:r,onSaved:s}){const{t:o}=Se(),[i,l]=y.useState(!1),[c,u]=y.useState({state:"idle"}),[d,f]=y.useState(e.topics.map(L=>L.id)),[h,p]=y.useState(!1),[m,v]=y.useState(null),b=L=>L.id===NVt?o("General (default topic)"):L.title??o("Topic #{{id}}",{id:L.id}),x=(L,M)=>{const F=o($de[L]??$de.api),D=L==="api"?` ${o("Make sure the bot is in this group.")}`:"";return`${F}${M?`: ${M}`:""}${D}`},S=()=>{u({state:"loading"}),window.electronAPI.secretary.contactTelegramTopics(e.id,t).then(L=>u(L.ok?{state:"ready",forum:L.forum,topics:L.topics}:{state:"error",error:L.error,...L.detail?{detail:L.detail}:{}}),()=>u({state:"error",error:"api"}))},k=()=>{f(e.topics.map(L=>L.id)),v(null),l(!0),S()},C=L=>{p(!0),v(null),window.electronAPI.secretary.contactSettings({telegramGroupScope:{chatId:e.id,scope:L}},t).then(M=>{M.ok?(l(!1),s()):v(M.error)},()=>v("api")).finally(()=>p(!1))},A=()=>{i&&l(!1),e.all||C("all")},N=e.title??e.id,j=c.state==="ready"?[...c.topics,...e.topics.filter(L=>!c.topics.some(M=>M.id===L.id))]:[],I=n||h,_=i||!e.all;return a.jsxs("li",{"data-enso":"secretary-contact-group",className:"flex flex-col gap-1.5",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsx("span",{"data-enso":"secretary-contact-group-name",className:"min-w-0 flex-1 truncate text-[12px]",children:e.title?a.jsxs(a.Fragment,{children:[e.title," ",a.jsx("span",{className:"font-mono text-[11px] text-muted-foreground",children:e.id})]}):a.jsx("span",{className:"font-mono text-[11.5px]",children:e.id})}),a.jsxs("div",{role:"radiogroup","aria-label":o("What {{name}} hands to this secretary",{name:N}),className:"inline-flex shrink-0 rounded-lg bg-muted p-0.5",children:[a.jsx(Kde,{enso:"secretary-contact-scope-all",checked:!_,disabled:I,label:o("Whole group"),onClick:A}),a.jsx(Kde,{enso:"secretary-contact-scope-topics",checked:_,disabled:I,label:o("Pick topics"),onClick:()=>{i||k()}})]}),a.jsx("button",{type:"button","data-enso":"secretary-contact-group-remove",disabled:n,"aria-label":o("Remove {{name}}",{name:N}),className:nw,onClick:r,children:a.jsx(Jr,{className:"size-3.5"})})]}),!e.all&&!i&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("span",{"data-enso":"secretary-contact-group-scope",className:"min-w-0 flex-1 truncate text-[11.5px] text-muted-foreground",children:o("Topics: {{names}}",{names:e.topics.map(b).join(", ")})}),a.jsxs("button",{type:"button","data-enso":"secretary-contact-group-topics",disabled:n,className:nw,onClick:k,children:[a.jsx(HHe,{className:"size-3.5"}),o("Change topics")]})]}),m&&!i&&a.jsx("p",{className:"text-[11.5px] text-destructive",children:x(m)}),i&&a.jsxs("div",{"data-enso":"secretary-contact-group-picker",className:"flex flex-col gap-1.5 rounded-lg bg-muted/40 px-2.5 py-2",children:[c.state==="loading"&&a.jsxs("p",{className:"flex items-center gap-1.5 text-[11.5px] text-muted-foreground",children:[a.jsx(Jn,{className:"size-3.5 animate-spin"}),o("Loading topics…")]}),c.state==="error"&&a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[a.jsx("p",{"data-enso":"secretary-contact-topics-error",className:"min-w-0 flex-1 text-[11.5px] text-destructive",children:o("Could not load topics: {{reason}}",{reason:x(c.error,c.detail)})}),a.jsxs("button",{type:"button","data-enso":"secretary-contact-topics-retry",className:nw,onClick:S,children:[a.jsx(bo,{className:"size-3.5"}),o("Retry")]})]}),c.state==="ready"&&(c.forum?a.jsxs(a.Fragment,{children:[j.map(L=>a.jsx(IVt,{enso:"secretary-contact-topic",checked:d.includes(L.id),disabled:I||!!L.owner&&!d.includes(L.id),label:L.owner?`${b(L)} · ${o("taken by {{owner}}",{owner:L.owner})}`:b(L),onClick:()=>f(M=>M.includes(L.id)?M.filter(F=>F!==L.id):[...M,L.id])},L.id)),a.jsx("p",{className:"text-[11px] text-subtle-foreground",children:o("Only topics the bot has seen are listed. If one is missing, send a message in that topic, then refresh. Topics you leave unchecked are ignored.")})]}):a.jsx("p",{className:"text-[11.5px] text-muted-foreground",children:o("This group has no topics, so it can only be bound as a whole.")})),m&&a.jsx("p",{className:"text-[11.5px] text-destructive",children:x(m)}),a.jsxs("div",{className:"flex gap-1.5",children:[c.state==="ready"&&c.forum&&a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button","data-enso":"secretary-contact-scope-save",disabled:I||d.length===0,className:nw,onClick:()=>C(d),children:[a.jsx(Is,{className:"size-3.5"}),o("Save")]}),a.jsxs("button",{type:"button","data-enso":"secretary-contact-topics-refresh",disabled:I,className:nw,onClick:S,children:[a.jsx(bo,{className:"size-3.5"}),o("Refresh")]})]}),a.jsx("button",{type:"button","data-enso":"secretary-contact-topics-cancel",disabled:h,className:nw,onClick:()=>l(!1),children:o("Cancel")})]})]})]})}const RVt="border-border border-b py-3",Xde="inline-flex items-center gap-1.5 rounded-lg border border-border px-2.5 py-1.5 text-[12.5px] transition-colors hover:bg-muted disabled:opacity-50",MVt="inline-flex items-center gap-1.5 rounded-lg bg-muted px-2.5 py-1.5 text-[12.5px] text-foreground transition-colors hover:bg-muted/80";function _Vt(e){return e?.find(t=>!t.self&&t.privateChat)?.name??null}const PVt={"private-owned":'Your private chat with this bot already belongs to secretary "{{owner}}". One person has only one private chat with a bot, so bind this secretary to a group or forum topic below, or give it a different bot.',"route-conflict":'That group or topic already belongs to secretary "{{owner}}". Send the code in another group or topic.',expired:"The code expired. Generate a new one.","missing-code":"The bot got /start without the code. Open the bot with the button or QR code (the link carries the code), or send /start {{code}} yourself."};function LVt({bind:e}){const{t}=Se(),n=e.rejected;return n?a.jsxs("p",{"data-enso":"secretary-contact-bind-rejected","data-reason":n.reason,className:"mt-2 flex gap-1.5 rounded-lg bg-warning/10 px-2.5 py-2 text-[11.5px] text-warning",children:[a.jsx(Nd,{className:"mt-px size-3.5 shrink-0"}),a.jsx("span",{children:t(PVt[n.reason],{owner:n.owner??"",code:e.code})})]}):null}function OVt({bind:e,bot:t,now:n,busy:r,onNewCode:s,onCopied:o}){const{t:i}=Se(),l=e?e.expiresAt<=n:!1,c=e?Math.max(0,Math.ceil((e.expiresAt-n)/6e4)):0,u=e?.topicCommand??(t?`/bind@${t} ${i("<code>")}`:null);return a.jsxs("ol",{"data-enso":"secretary-contact-bind-places",className:"mt-1.5 flex flex-col gap-1.5",children:[a.jsxs("li",{className:"flex flex-col gap-1 text-[11.5px] text-muted-foreground",children:[a.jsxs("span",{children:[a.jsx("span",{className:"font-medium text-foreground",children:"1."})," ",i("Add the bot to the group: tap the button, or add @{{bot}} as a member in Telegram. For a forum group, turn on Topics first.",{bot:t??"bot"})]}),e?.groupLink&&a.jsxs("a",{"data-enso":"secretary-contact-group-link",href:e.groupLink,target:"_blank",rel:"noreferrer",className:`${MVt} self-start`,children:[a.jsx(dy,{className:"size-3.5"}),i("Add the bot to a group")]})]}),a.jsxs("li",{className:"flex flex-col gap-1 text-[11.5px] text-muted-foreground",children:[a.jsxs("span",{children:[a.jsx("span",{className:"font-medium text-foreground",children:"2."})," ",i("Send this in the group to hand the whole group to this secretary, or inside a forum topic to hand over only that topic:")]}),u?a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("code",{"data-enso":"secretary-contact-topic-command",className:"min-w-0 flex-1 truncate rounded bg-muted px-1.5 py-1 font-mono text-[11.5px] text-foreground",children:u}),e&&!l&&a.jsx("button",{type:"button","data-enso":"secretary-contact-copy-topic-command",className:Xde,"aria-label":i("Copy"),onClick:()=>{navigator.clipboard.writeText(e.topicCommand??""),o()},children:a.jsx(zd,{className:"size-3.5"})})]}):a.jsx("span",{className:"text-subtle-foreground",children:i("Verify a bot above first; the binding code shows up here.")}),e&&a.jsxs("span",{"data-enso":"secretary-contact-groups-code",className:l?"text-warning":"text-subtle-foreground",children:[i("Binding code of this secretary: {{code}}",{code:e.code})," ·"," ",l?i("This code has expired"):i("Valid for {{minutes}} more minutes",{minutes:c})]}),t&&(!e||l)&&a.jsxs("button",{type:"button","data-enso":"secretary-contact-groups-new-code",disabled:r,className:`${Xde} self-start text-foreground`,onClick:s,children:[a.jsx(J4,{className:"size-3.5"}),i(e?"New code":"Get a binding code")]})]}),a.jsxs("li",{className:"text-[11.5px] text-muted-foreground",children:[a.jsx("span",{className:"font-medium text-foreground",children:"3."})," ",i("Bound groups show up in the list of this section, where you can switch between the whole group and picked topics.")]})]})}function DVt({shared:e}){const{t}=Se(),n=(e??[]).filter(r=>!r.self).flatMap(r=>r.groups.map(s=>({owner:r.name,group:s})));return n.length===0?null:a.jsxs("div",{className:"mt-2",children:[a.jsx("p",{className:"text-[11.5px] text-muted-foreground",children:t("Claimed by other secretaries on this bot (read only):")}),a.jsx("ul",{className:"mt-1 flex flex-col gap-0.5",children:n.map(({owner:r,group:s})=>a.jsxs("li",{"data-enso":"secretary-contact-group-other",className:"flex items-center gap-1.5 text-[12px] text-muted-foreground",children:[a.jsx(KHe,{className:"size-3 shrink-0"}),a.jsx("span",{className:"min-w-0 flex-1 truncate",children:BVt(s,t)}),a.jsx("span",{className:"shrink-0 text-[11px]",children:t("belongs to {{owner}}",{owner:r})})]},`${r}:${s.id}`))})]})}function BVt(e,t){const n=e.title??e.id;if(e.all)return`${n} · ${t("Whole group")}`;const r=e.topics.map(s=>s.id==="1"?t("General (default topic)"):s.title??t("Topic #{{id}}",{id:s.id})).join(", ");return`${n} · ${t("Topics: {{names}}",{names:r})}`}function FVt({shared:e,bot:t}){const{t:n}=Se();return a.jsxs("div",{"data-enso":"secretary-contact-shared",className:RVt,children:[a.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] font-medium text-muted-foreground",children:[a.jsx(Uv,{className:"size-3.5"}),n("@{{bot}} is shared by {{count}} secretaries",{bot:t??"",count:e.length})]}),a.jsx("p",{className:"mt-1 text-[11.5px] text-muted-foreground",children:n("Each private chat, group or forum topic belongs to one secretary. A topic bound on its own wins over the whole group. Places nobody bound get no reply.")}),a.jsx("ul",{className:"mt-1.5 flex flex-col gap-1.5",children:e.map(r=>{const s=[...r.privateChat?[n("Private chat with @{{name}}",{name:r.privateChat.username??String(r.privateChat.id)})]:[],...r.groups.length>0?[n("Groups and topics: {{count}}",{count:r.groups.length})]:[]];return a.jsxs("li",{"data-enso":"secretary-contact-shared-user","data-self":r.self||void 0,className:"text-[12px]",children:[a.jsx("span",{className:"font-medium",children:r.name}),r.self&&a.jsxs("span",{className:"ml-1 text-[11px] text-muted-foreground",children:["(",n("this secretary"),")"]}),!r.enabled&&a.jsxs("span",{className:"ml-1 text-[11px] text-subtle-foreground",children:["· ",n("Telegram off")]}),s.length===0?a.jsx("p",{className:"text-[11.5px] text-subtle-foreground",children:n("Nothing bound yet")}):a.jsx("ul",{className:"text-[11.5px] text-muted-foreground",children:s.map(o=>a.jsxs("li",{className:"truncate",children:["· ",o]},o))})]},r.secretaryId)})})]})}const zVt="https://t.me/BotFather",HVt={"token-invalid":"That does not look like a bot token",network:"Cannot reach api.telegram.org. Check the proxy.",unauthorized:"Telegram rejected this token",api:"Telegram returned an error","token-required":"Paste a bot token first","not-bound":"Not bound yet","not-found":"That task is already gone","no-secretary":"No secretary conversation is available","deliver-failed":"Could not reach the secretary session","invalid-chat-id":"Group chat IDs are numbers, e.g. -1001234567890","channel-paused":"Pushes to this channel are paused after repeated failures","invalid sender":"Not allowed from this window","invalid-github-login":"That is not a GitHub login"},Zm="border-border border-b py-3",Yc="inline-flex items-center gap-1.5 rounded-lg border border-border px-2.5 py-1.5 text-[12.5px] transition-colors hover:bg-muted disabled:opacity-50",UVt="inline-flex items-center gap-1.5 rounded-lg bg-muted px-2.5 py-1.5 text-[12.5px] text-foreground transition-colors hover:bg-muted/80",yR="inline-flex items-center gap-1.5 rounded-lg bg-foreground px-2.5 py-1.5 text-[12.5px] font-medium text-background transition-opacity hover:opacity-90 disabled:opacity-50";function S7({index:e,label:t}){return a.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] font-medium text-muted-foreground",children:[a.jsx("span",{className:"flex size-4 items-center justify-center rounded-full bg-muted text-[10px] tabular-nums",children:e}),t]})}const VVt={unconfigured:"Not set up",pending:"Waiting to bind",connected:"Connected",error:"Error"},GVt={unconfigured:"bg-muted text-muted-foreground",pending:"bg-warning/15 text-warning",connected:"bg-success/15 text-success",error:"bg-destructive/15 text-destructive"},oMe="enso.secretary.contact.collapsed";function WVt(){try{const e=JSON.parse(window.localStorage.getItem(oMe)??"{}");return!e||typeof e!="object"||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,t])=>t===!0))}catch{return{}}}function qVt(e){try{window.localStorage.setItem(oMe,JSON.stringify(e))}catch{}}function YVt({outbound:e,busy:t,onRetry:n}){const{t:r,locale:s}=Se(),o=Date.now(),i=e.state==="paused",l=i&&e.pausedUntil!==void 0&&e.pausedUntil>o;return a.jsxs("div",{"data-enso":"secretary-contact-outbound","data-state":e.state,className:ve("border-l-2 px-2.5 py-2 text-[12px]",i?"border-warning bg-warning/5":"border-destructive bg-destructive/5"),children:[a.jsxs("div",{className:ve("flex items-center gap-1.5 font-medium",i?"text-warning":"text-destructive"),children:[i?a.jsx($Fe,{className:"size-3.5 shrink-0"}):a.jsx(Rf,{className:"size-3.5 shrink-0"}),i?r("Pushes paused: {{count}} sends failed in a row",{count:e.consecutiveFailures}):r("The last send failed ({{count}} in a row)",{count:e.consecutiveFailures})]}),e.userMessage&&a.jsx("p",{"data-enso":"secretary-contact-outbound-hint",className:"mt-1 text-[12.5px]",children:e.userMessage}),a.jsx("p",{className:"mt-1 text-[11.5px] text-muted-foreground",children:r("Last failure: {{time}}",{time:`${Yce(e.lastErrorAt,s)} (${Ig(e.lastErrorAt,s,o)})`})}),e.detail&&a.jsx("p",{"data-enso":"secretary-contact-outbound-detail",className:"mt-0.5 break-all font-mono text-[11px] text-muted-foreground",children:e.detail}),i&&a.jsxs("p",{className:"mt-1 text-[11.5px] text-muted-foreground",children:[l?r("Next try at {{time}}. A message from this channel or Retry now resumes pushes right away.",{time:Yce(e.pausedUntil??o,s)}):r("The next push will try again."),e.suppressedCount>0&&` ${r("{{count}} pushes held back.",{count:e.suppressedCount})}`]}),a.jsxs("button",{type:"button","data-enso":"secretary-contact-outbound-retry",disabled:t,className:ve(Yc,"mt-1.5"),onClick:n,children:[a.jsx(bo,{className:"size-3.5"}),r("Retry now")]}),a.jsx("span",{className:"ml-2 text-[11px] text-subtle-foreground",children:r("Sends a test message to this channel.")})]})}const $Vt="enso.telegram";function F3({label:e,hint:t,checked:n,disabled:r,dataEnso:s,onChange:o}){return a.jsx("div",{"data-enso":s,children:a.jsx(vo,{label:e,description:t,children:a.jsx($r,{checked:n,disabled:r,onCheckedChange:o})})})}function KVt({channel:e,collapsed:t,busy:n,onToggle:r,onPrefs:s,onRetry:o,children:i}){const{t:l}=Se(),c=e.id==="telegram",{prefs:u,caps:d}=e,f=[!d.buttons&&l("No buttons: questions and cards arrive as numbered text."),!d.edit&&l("Cannot edit sent messages: answered questions are not marked there."),!d.typing&&l("No typing indicator.")].filter(h=>typeof h=="string");return a.jsxs("div",{"data-enso":"secretary-contact-channel","data-channel":e.id,className:"border-border border-b",children:[a.jsxs("div",{className:"flex items-center gap-2 py-2",children:[a.jsxs("button",{type:"button","data-enso":"secretary-contact-channel-toggle","aria-expanded":!t,className:"flex min-w-0 flex-1 items-center gap-2 text-left",onClick:r,children:[t?a.jsx(Bs,{className:"size-3.5 shrink-0 text-muted-foreground"}):a.jsx(Ho,{className:"size-3.5 shrink-0 text-muted-foreground"}),e.pluginId?a.jsx(YP,{pluginId:e.pluginId,icon:e.icon,className:"size-4"}):a.jsx(zy,{className:"size-4 shrink-0"}),a.jsx("span",{className:"truncate text-[13px] font-medium",children:e.title}),a.jsx("span",{className:"shrink-0 rounded bg-muted px-1 text-[10.5px] text-muted-foreground",children:e.builtin?l("Built-in"):l("Plugin")}),a.jsx("span",{"data-enso":"secretary-contact-channel-status",className:ve("shrink-0 rounded px-1 text-[10.5px]",GVt[e.status]),children:l(VVt[e.status])}),e.outbound&&a.jsx("span",{"data-enso":"secretary-contact-channel-outbound",className:ve("shrink-0 rounded px-1 text-[10.5px]",e.outbound.state==="paused"?"bg-warning/15 text-warning":"bg-destructive/15 text-destructive"),children:e.outbound.state==="paused"?l("Pushes paused"):l("Send failed")})]}),a.jsx(Xi,{"data-enso":"secretary-contact-channel-enabled",checked:u.enabled,disabled:n,"aria-label":l("Enable {{name}}",{name:e.title}),onCheckedChange:h=>s({enabled:h})})]}),!t&&a.jsxs("div",{className:"flex flex-col gap-2 border-border border-t py-2.5",children:[e.detail&&e.status==="error"&&a.jsx("p",{className:"text-[11.5px] text-destructive",children:e.detail}),e.outbound&&a.jsx(YVt,{outbound:e.outbound,busy:n,onRetry:o}),a.jsx(F3,{dataEnso:"secretary-contact-push",label:l("Push to this channel"),hint:l("Milestones, questions from the secretary, cards and approval notices go out here."),checked:u.push,disabled:n,onChange:h=>s({push:h})}),a.jsx(F3,{dataEnso:c?"secretary-contact-allow-dispatch":"secretary-contact-card-confirm",label:l(c?"Allow confirming cards from Telegram":"Confirm cards from the phone"),hint:c?l("On by default. A tap on your phone can confirm settings, skill, tool, takeover and cleanup cards. Those cards change which projects the secretary sees, what it may take over, which skills and tools it installs and what it cleans up. Approvals are never handled from Telegram."):d.buttons?l("Off by default. Approvals are never handled from the phone."):l('Off by default. Reply "confirm 1" to confirm a card. Approvals are never handled from the phone.'),checked:u.cardConfirm,disabled:n,onChange:h=>s({cardConfirm:h})}),a.jsx(F3,{dataEnso:"secretary-contact-mirror",label:l("Mirror every reply"),hint:l("Off by default. Every reply in the secretary conversation is sent here, not just milestones."),checked:u.syncMirror,disabled:n,onChange:h=>s({syncMirror:h})}),a.jsx(F3,{dataEnso:c?"secretary-contact-allow-memory":"secretary-contact-memory",label:l(c?"Allow viewing memory titles on Telegram":"Allow viewing memory titles"),hint:l("Off by default. /memory lists titles only, never the memory text."),checked:u.memory,disabled:n,onChange:h=>s({memory:h})}),f.length>0&&a.jsx("ul",{"data-enso":"secretary-contact-limits",className:"flex flex-col gap-0.5 text-[11.5px] text-subtle-foreground",children:f.map(h=>a.jsxs("li",{children:["· ",h]},h))}),i]})]})}function XVt({owner:e,secretaryId:t,busy:n,error:r,run:s,showHeading:o=!0}){const{t:i}=Se(),l=e.githubLogins.join(", "),c=e.githubLogins.length>0,[u,d]=y.useState(l),[f,h]=y.useState(!1),[p,m]=y.useState(null);y.useEffect(()=>{f||d(l)},[l,f]),y.useEffect(()=>{if(c){m(null);return}const b=window.electronAPI.secretary.contactGithubSuggest;if(!b)return;let x=!0;return b().then(S=>{x&&m(S.login)}),()=>{x=!1}},[c]);const v=b=>{h(!0),d(x=>{const S=x.split(/[\s,]+/).filter(Boolean);return S.some(k=>k.toLowerCase()===b.toLowerCase())?x:S.length>0?`${S.join(", ")}, ${b}`:b})};return a.jsxs("div",{"data-enso":"secretary-contact-owner",className:Zm,children:[o&&a.jsx("div",{className:"text-[12.5px] font-medium",children:i("Owner identity")}),a.jsx("p",{className:ve("text-[11.5px] text-muted-foreground",o&&"mt-1"),children:i("GitHub accounts that count as you. Events from anyone else are left to the agent unless you require confirmation.")}),a.jsx("label",{className:"mt-2 block text-[12px] text-muted-foreground",htmlFor:"secretary-github-logins",children:i("GitHub accounts")}),a.jsx("input",{id:"secretary-github-logins","data-enso":"secretary-contact-github-logins",value:u,disabled:n,placeholder:i("Comma or space separated"),className:"mt-1 w-full rounded-lg border border-border bg-transparent px-2.5 py-1.5 font-mono text-[12px] outline-none focus:border-foreground/40",onChange:b=>{h(!0),d(b.target.value)}}),p&&a.jsxs("div",{className:"mt-1.5 flex items-center justify-between gap-2",children:[a.jsx("span",{className:"min-w-0 text-[11.5px] text-muted-foreground",children:i("Detected the gh login {{login}} on this machine",{login:p})}),a.jsx("button",{type:"button","data-enso":"secretary-contact-github-fill",disabled:n,className:Yc,onClick:()=>v(p),children:i("Fill in")})]}),a.jsx("button",{type:"button","data-enso":"secretary-contact-github-save",disabled:n,className:ve(yR,"mt-2"),onClick:()=>{const b=u.split(/[\s,]+/).map(x=>x.trim()).filter(Boolean);s(async()=>{const x=await window.electronAPI.secretary.contactSettings({githubLogins:b},t);return x.ok&&h(!1),x})},children:i("Save GitHub accounts")}),r==="invalid-github-login"&&a.jsx("p",{className:"mt-1 text-[11.5px] text-destructive",children:i("That is not a GitHub login")}),a.jsx("div",{className:"mt-3 text-[12px] text-muted-foreground",children:i("Messages that are not from you")}),a.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:[a.jsx("button",{type:"button","data-enso":"secretary-contact-external-agent","aria-pressed":!e.externalConfirm,disabled:n,className:ve(Yc,!e.externalConfirm&&"bg-muted"),onClick:()=>{e.externalConfirm&&s(()=>window.electronAPI.secretary.contactSettings({externalConfirm:!1},t))},children:i("Let the agent decide")}),a.jsx("button",{type:"button","data-enso":"secretary-contact-external-confirm","aria-pressed":e.externalConfirm,disabled:n,className:ve(Yc,e.externalConfirm&&"bg-muted"),onClick:()=>{e.externalConfirm||s(()=>window.electronAPI.secretary.contactSettings({externalConfirm:!0},t))},children:i("Require your confirmation")})]})]})}function Qde({checked:e,disabled:t,label:n,onCheckedChange:r}){const s=Bg();return a.jsx(Xi,{...s,"data-enso":"secretary-contact-enabled",checked:e,disabled:t,"aria-label":s["aria-labelledby"]?void 0:n,onCheckedChange:r})}function QVt({secretaryId:e,frames:t}={}){const{t:n}=Se(),[r,s]=y.useState(null),[o,i]=y.useState(""),[l,c]=y.useState(!1),[u,d]=y.useState(null),[f,h]=y.useState(null),[p,m]=y.useState(null),[v,b]=y.useState(WVt),[x,S]=y.useState([]),[k,C]=y.useState(""),[A,N]=y.useState(()=>Date.now());y.useEffect(()=>{const ue=window.electronAPI.extensionPlugins,xe=()=>{ue.list().then(S).catch(()=>S([]))};return xe(),ue.onChanged(xe)},[]);const j=ue=>{b(xe=>{const ge={...xe};return ge[ue]?delete ge[ue]:ge[ue]=!0,qVt(ge),ge})},I=y.useCallback(()=>{window.electronAPI.secretary.contactState(e).then(s)},[e]);y.useEffect(()=>(I(),window.electronAPI.secretary.onContactChanged(ue=>{e&&ue.secretaryId&&ue.secretaryId!==e||s(ue)})),[I,e]);const _=r?.telegram.bind?.expiresAt;y.useEffect(()=>{if(_===void 0)return;N(Date.now());const ue=window.setInterval(()=>N(Date.now()),15e3);return()=>window.clearInterval(ue)},[_]);const L=r?.telegram.bind?.link;y.useEffect(()=>{if(!L){m(null);return}let ue=!0;return rMe.toDataURL(L,{width:320,margin:1}).then(xe=>{ue&&m(xe)}).catch(()=>m(null)),()=>{ue=!1}},[L]);const M=ue=>{c(!0),d(null),h(null),ue().then(xe=>{xe.ok||d(xe.error??"api")}).finally(()=>{c(!1),I()})};if(!r)return null;const F=r.telegram,D=r.channels??[],R=x.some(ue=>ue.id===$Vt&&ue.state==="enabled"),z=(ue,xe)=>M(()=>window.electronAPI.secretary.contactSettings({channelId:ue,prefs:xe},e)),B=ue=>M(()=>window.electronAPI.secretary.contactTest(e,ue).then(xe=>{if(xe.ok)h(n("Test message sent"));else if(["api","network","unauthorized","channel-paused"].includes(xe.error))return{ok:!0};return xe})),H=F.poll.state==="error"||F.poll.state==="backoff",G=F.poll.state!=="stopped"&&F.poll.state!=="error",ne=u==="network"&&G?null:u,W=F.groups??[],T=k.trim(),U=(ue,xe)=>M(()=>window.electronAPI.secretary.contactSettings({telegramGroup:{action:ue,chatId:xe}},e).then(ge=>(ge.ok&&ue==="add"&&C(""),ge))),P=F.bind?Math.max(0,Math.ceil((F.bind.expiresAt-A)/6e4)):0,K=F.bind?F.bind.expiresAt<=A:!1,J=F.chat?null:_Vt(F.shared),ee=a.jsx(OVt,{bind:F.bind,bot:F.bot?.username,now:A,busy:l,onNewCode:()=>M(()=>window.electronAPI.secretary.contactBind(void 0,e)),onCopied:()=>h(n("Copied"))}),X=a.jsxs("div",{"data-enso":"secretary-contact-groups",className:Zm,children:[a.jsx("div",{className:"text-[12px] font-medium text-muted-foreground",children:n("Groups and topics")}),a.jsx("p",{className:"mt-1 text-[11.5px] text-muted-foreground",children:n("Only groups on this list reach the secretary, and only messages from the bound account count. Messages from anyone else in the group are not received.")}),W.length===0?a.jsxs(a.Fragment,{children:[ee,a.jsx("p",{className:"mt-1.5 text-[11.5px] text-subtle-foreground",children:n("No groups yet: group messages are not received.")})]}):a.jsxs(a.Fragment,{children:[a.jsx("ul",{className:"mt-1.5 flex flex-col gap-1",children:W.map(ue=>a.jsx(jVt,{group:ue,secretaryId:e,busy:l,onRemove:()=>U("remove",ue.id),onSaved:I},ue.id))}),a.jsx("p",{className:"mt-2.5 text-[11.5px] font-medium text-muted-foreground",children:n("Bind another group or topic")}),ee]}),a.jsx(DVt,{shared:F.shared}),a.jsx("p",{className:"mt-2 text-[11px] text-subtle-foreground",children:n("Or add a group by its chat ID:")}),a.jsxs("form",{className:"mt-1 flex gap-1.5",onSubmit:ue=>{if(ue.preventDefault(),!!T){if(W.some(xe=>xe.id===T)){C("");return}U("add",T)}},children:[a.jsx("input",{"data-enso":"secretary-contact-group-input",value:k,spellCheck:!1,autoComplete:"off",placeholder:n("Group chat ID, e.g. -1001234567890"),onChange:ue=>C(ue.target.value),className:"min-w-0 flex-1 rounded-lg border border-border bg-transparent px-2.5 py-1.5 font-mono text-[12px] outline-none focus:border-foreground/40"}),a.jsxs("button",{type:"submit","data-enso":"secretary-contact-group-add",disabled:l||!T,className:Yc,children:[a.jsx(xs,{className:"size-3.5"}),n("Add group")]})]})]}),te=a.jsxs(a.Fragment,{children:[R&&a.jsx("p",{"data-enso":"secretary-contact-token-conflict",className:"text-[11.5px] text-warning",children:n("The Telegram remote plugin (enso.telegram) is enabled. Do not give both the same bot token: only one place can poll a bot, so they would steal each other's messages.")}),F.status==="bound"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{"data-enso":"secretary-contact-bound",className:Zm,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-full bg-success/15 text-success",children:a.jsx(Is,{className:"size-3.5"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"truncate text-[13px] font-medium",children:F.chat?n("Bound to @{{username}}",{username:F.chat.username??String(F.chat.id)}):n("Bound to groups and topics")}),a.jsxs("p",{className:"truncate text-[11.5px] text-muted-foreground",children:[n("Bot @{{bot}}",{bot:F.bot?.username??""}),F.tokenHint?` · ${F.tokenHint}`:""]})]})]}),a.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[a.jsxs("button",{type:"button","data-enso":"secretary-contact-test",disabled:l,className:Yc,onClick:()=>M(()=>window.electronAPI.secretary.contactTest(e).then(ue=>(ue.ok&&h(n("Test message sent")),ue))),children:[a.jsx(zy,{className:"size-3.5"}),n("Send a test message")]}),a.jsxs("button",{type:"button","data-enso":"secretary-contact-unbind",disabled:l,className:Yc,onClick:()=>M(()=>window.electronAPI.secretary.contactUnbind(e)),children:[a.jsx(OVe,{className:"size-3.5"}),n("Unbind")]}),a.jsxs("button",{type:"button","data-enso":"secretary-contact-replace",disabled:l,className:Yc,onClick:()=>M(()=>window.electronAPI.secretary.contactForgetBot(e)),children:[a.jsx(bo,{className:"size-3.5"}),n("Change bot")]})]})]}),X,a.jsx("div",{"data-enso":"secretary-contact-sync",className:ve(Zm,F.syncMirror&&"border-warning/50 bg-warning/5"),children:F.syncMirror?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-1.5 text-[12.5px] font-medium text-warning",children:[a.jsx(OUe,{className:"size-3.5 shrink-0"}),n("Mirroring every conversation to Telegram")]}),a.jsx("p",{className:"mt-1 text-[11.5px] text-muted-foreground",children:n("Every reply in the secretary conversation is sent to your phone, not just milestones. Silent turns arrive as a one-line summary. Telegram messages are not end-to-end encrypted and stay on Telegram servers. Send /sync off in Telegram to stop.")})]}):a.jsx("p",{className:"text-[11.5px] text-muted-foreground",children:n("Only milestones go to Telegram. Send /sync in Telegram to mirror every reply; /last replays the latest round.")})}),a.jsxs("div",{"data-enso":"secretary-contact-commands",className:Zm,children:[a.jsx("div",{className:"text-[12px] font-medium text-muted-foreground",children:n("Commands you can send")}),a.jsx("ul",{className:"mt-1 flex flex-col gap-0.5",children:ZUt.filter(ue=>!ue.gated||F.allowMemory).map(ue=>a.jsxs("li",{className:"text-[12px]",children:[a.jsxs("code",{className:"rounded bg-muted px-1 text-[11.5px]",children:["/",ue.name]})," ",a.jsx("span",{className:"text-muted-foreground",children:n(ue.en)})]},ue.name))}),a.jsx("p",{className:"mt-1.5 text-[11.5px] text-muted-foreground",children:n("Telegram messages are not end-to-end encrypted and stay on Telegram servers. /status, /board and /feed show titles and short summaries; /last and /sync send conversation text. Memory text and tool output never leave the app.")})]}),!F.secure&&a.jsx("p",{className:"px-1 text-[11.5px] text-warning",children:n("No system keychain available: the bot token is stored unencrypted on this machine.")})]}),F.status==="awaiting-start"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{"data-enso":"secretary-contact-verified",className:Zm,children:[a.jsx(S7,{index:2,label:n("Bot verified")}),a.jsxs("p",{className:"mt-1 text-[13px] font-medium",children:[F.bot?.name," ",a.jsxs("span",{className:"text-muted-foreground",children:["@",F.bot?.username]})]})]}),a.jsxs("div",{"data-enso":"secretary-contact-code",className:Zm,children:[a.jsx(S7,{index:3,label:n("Open the bot and press Start")}),a.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[p&&a.jsx("img",{"data-enso":"secretary-contact-qr",src:p,alt:n("Binding QR code"),className:"size-28 shrink-0 rounded-lg bg-white p-1"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-[11.5px] text-muted-foreground",children:n("Binding code")}),a.jsx("p",{"data-enso":"secretary-contact-code-value",className:"font-mono text-[22px] tracking-[0.2em] tabular-nums",children:F.bind?.code}),K?a.jsx("p",{"data-enso":"secretary-contact-code-expired",className:"mt-1 text-[11.5px] text-warning",children:n("This code has expired")}):a.jsx("p",{className:"mt-1 text-[11.5px] text-subtle-foreground",children:n("Valid for {{minutes}} more minutes",{minutes:P})})]})]}),a.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[a.jsxs("a",{"data-enso":"secretary-contact-open-bot",href:F.bind?.link,target:"_blank",rel:"noreferrer",className:yR,children:[a.jsx(dy,{className:"size-3.5"}),n("Open @{{bot}}",{bot:F.bot?.username??""})]}),a.jsxs("button",{type:"button","data-enso":"secretary-contact-copy",className:Yc,onClick:()=>{navigator.clipboard.writeText(F.bind?.link??""),h(n("Link copied"))},children:[a.jsx(zd,{className:"size-3.5"}),n("Copy link")]}),a.jsxs("button",{type:"button","data-enso":"secretary-contact-regenerate",disabled:l,className:K?yR:Yc,onClick:()=>M(()=>window.electronAPI.secretary.contactBind(void 0,e)),children:[a.jsx(bo,{className:"size-3.5"}),n("New code")]}),a.jsx("button",{type:"button","data-enso":"secretary-contact-cancel",disabled:l,className:Yc,onClick:()=>M(()=>window.electronAPI.secretary.contactCancel(e)),children:n("Cancel")})]}),F.bind&&a.jsx(LVt,{bind:F.bind}),J&&F.bind?.rejected?.reason!=="private-owned"&&a.jsx("p",{"data-enso":"secretary-contact-private-owned",className:"mt-2 text-[11.5px] text-warning",children:n('Your private chat with this bot already belongs to secretary "{{owner}}". Bind this secretary to a group or forum topic instead.',{owner:J})}),a.jsx("p",{className:"mt-2 text-[11.5px] text-subtle-foreground",children:n("The code works once. Press Start in a private chat with the bot, or send it in a group or forum topic to bind that place to this secretary instead.")})]}),X]}),F.shared&&F.status!=="unbound"&&a.jsx(FVt,{shared:F.shared,bot:F.bot?.username}),F.status==="unbound"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{"data-enso":"secretary-contact-step1",className:Zm,children:[a.jsx(S7,{index:1,label:n("Create a bot with @BotFather")}),a.jsx("p",{className:"mt-1 text-[11.5px] text-muted-foreground",children:n("Send /newbot, pick a name, and copy the token it gives you.")}),a.jsxs("a",{"data-enso":"secretary-contact-botfather",href:zVt,target:"_blank",rel:"noreferrer",className:ve(UVt,"mt-2"),children:[a.jsx(dy,{className:"size-3.5"}),n("Open @BotFather")]}),a.jsx("input",{"data-enso":"secretary-contact-token",type:"password",value:o,spellCheck:!1,autoComplete:"off",placeholder:n("Paste the bot token"),onChange:ue=>i(ue.target.value),className:"mt-2 w-full rounded-lg border border-border bg-transparent px-2.5 py-1.5 font-mono text-[12px] outline-none focus:border-foreground/40"}),a.jsxs("button",{type:"button","data-enso":"secretary-contact-verify",disabled:l||o.trim().length===0,className:ve(yR,"mt-2"),onClick:()=>M(()=>window.electronAPI.secretary.contactBind(o.trim(),e)),children:[l?a.jsx(Jn,{className:"size-3.5 animate-spin"}):a.jsx(Is,{className:"size-3.5"}),n("Verify and continue")]}),F.bot&&a.jsxs("button",{type:"button","data-enso":"secretary-contact-reconnect",disabled:l,className:ve(Yc,"mt-1.5"),onClick:()=>M(()=>window.electronAPI.secretary.contactBind(void 0,e)),children:[a.jsx(bo,{className:"size-3.5"}),n("Bind again with @{{bot}}",{bot:F.bot.username})]})]}),a.jsx("p",{className:"px-1 text-[11.5px] text-subtle-foreground",children:n("The token is stored with the system keychain and never written to logs.")}),X]})]}),Q=ue=>M(()=>window.electronAPI.secretary.contactSettings({enabled:ue},e)),oe=t?a.jsx("div",{"data-enso":"secretary-contact-master",children:a.jsx(jn,{label:n("Enable contacts"),children:a.jsx(Qde,{checked:r.enabled,disabled:l,label:n("Enable contacts"),onCheckedChange:Q})})}):a.jsxs("div",{"data-enso":"secretary-contact-master",className:"flex items-center justify-between gap-2 border-border border-b py-2",children:[a.jsx("span",{className:"text-[13px] font-medium",children:n("Enable contacts")}),a.jsx(Qde,{checked:r.enabled,disabled:l,label:n("Enable contacts"),onCheckedChange:Q})]}),de=a.jsx(XVt,{owner:r.owner,secretaryId:e,busy:l,error:u,run:M,showHeading:!t}),ie=r.enabled?a.jsxs(a.Fragment,{children:[(ne||H)&&a.jsxs("div",{"data-enso":"secretary-contact-error",className:"flex items-start gap-1.5 border-destructive border-l-2 bg-destructive/5 px-2.5 py-2 text-[12px] text-destructive",children:[a.jsx(Rf,{className:"mt-0.5 size-3.5 shrink-0"}),a.jsx("span",{className:"min-w-0 flex-1",children:n(ne?HVt[ne]??"Telegram returned an error":"Cannot reach api.telegram.org. Check the proxy.")})]}),f&&a.jsxs("div",{className:"flex items-center gap-1.5 border-success border-l-2 bg-success/5 px-2.5 py-2 text-[12px] text-success",children:[a.jsx(Is,{className:"size-3.5 shrink-0"}),a.jsx("span",{children:f})]}),D.map(ue=>a.jsx(KVt,{channel:ue,collapsed:v[ue.id]===!0,busy:l,onToggle:()=>j(ue.id),onPrefs:xe=>z(ue.id,xe),onRetry:()=>B(ue.id),children:ue.id==="telegram"?te:ue.pluginId&&ue.settingsView?a.jsx("div",{"data-enso":"secretary-contact-plugin-view",className:"h-72 overflow-hidden border-border border-y",children:a.jsx(sMe,{pluginId:ue.pluginId,entry:ue.settingsView,title:ue.title,sessionId:null})}):null},ue.id)),a.jsxs("div",{"data-enso":"secretary-contact-following",className:Zm,children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsx("div",{className:"text-[12.5px] font-medium",children:n("Followed from the phone: {{count}}",{count:F.following.length})}),F.following.length>0&&a.jsx("button",{type:"button","data-enso":"secretary-contact-following-clear",disabled:l,className:Yc,onClick:()=>M(()=>window.electronAPI.secretary.contactFollowing({action:"clear"},e)),children:n("Clear all")})]}),a.jsx("p",{className:"mt-1 text-[11.5px] text-muted-foreground",children:n("What you dispatch or schedule from the phone keeps reporting here until it finishes or fails once, even with /sync off.")}),F.following.length>0&&a.jsx("ul",{className:"mt-1.5 flex flex-col gap-1",children:F.following.map(ue=>a.jsxs("li",{className:"flex items-start justify-between gap-2",children:[a.jsxs("span",{className:"min-w-0 flex-1 text-[12px]",children:[a.jsxs("span",{className:"text-muted-foreground",children:[ue.kind==="schedule"?n("Scheduled"):n("Session")," ·"," "]}),ue.summary]}),a.jsx("button",{type:"button","data-enso":"secretary-contact-following-cancel",disabled:l,className:Yc,onClick:()=>M(()=>window.electronAPI.secretary.contactFollowing({action:"cancel",id:ue.id},e)),children:n("Drop")})]},ue.id))})]}),a.jsxs("button",{type:"button","data-enso":"secretary-contact-market",className:ve(Yc,t?"mt-3":"self-start"),onClick:()=>nu({category:"plugins",rowId:"plugins.enso",marketQuery:"contact"}),children:[a.jsx(su,{className:"size-3.5"}),n("Find more contact channels in the plugin market")]})]}):a.jsx("p",{className:t?"border-border border-b py-3 text-[13px] text-muted-foreground":"px-1 text-[11.5px] text-subtle-foreground",children:n("Contacts are off: nothing is sent or received on any channel.")});return t?a.jsxs("div",{"data-enso":"secretary-contact",children:[t.owner(de),t.channels(a.jsxs(a.Fragment,{children:[oe,ie]}))]}):a.jsxs("div",{"data-enso":"secretary-contact",className:"flex flex-col gap-2 px-3 py-3",children:[a.jsx("p",{className:"px-1 text-[11.5px] text-muted-foreground",children:n("Reach the secretary from your phone. Milestones go out; your replies come back.")}),oe,de,ie]})}function ZVt(){try{return localStorage.getItem(r4)??void 0}catch{return}}function iMe(){const[e,t]=y.useState([]),[n,r]=y.useState(ZVt),s=y.useCallback(async()=>{t(await window.electronAPI.secretary.list())},[]);y.useEffect(()=>(s(),window.electronAPI.secretary.onListChanged(t)),[s]),y.useEffect(()=>{const l=c=>{c.key===r4&&c.newValue&&r(c.newValue)};return window.addEventListener("storage",l),()=>window.removeEventListener("storage",l)},[]);const o=y.useCallback(l=>{r(l);try{l&&localStorage.setItem(r4,l)}catch{}},[]),i=e.find(l=>l.id===n)?.id??e[0]?.id??void 0;return{secretaries:e,setSecretaries:t,current:i,multiple:e.length>1,select:o,reload:s}}function aMe({secretaries:e,current:t,onSelect:n}){const{t:r}=Se();return e.map(s=>a.jsx("button",{type:"button","data-enso":"secretary-settings-pick","data-secretary-id":s.id,"data-selected":s.id===t||void 0,onClick:()=>n(s.id),className:ve("relative rounded-full px-2.5 py-1 text-xs ring-1 transition-colors",s.id===t?"bg-foreground/5 text-foreground ring-foreground/40":"text-muted-foreground ring-border hover:text-foreground"),children:s.name??r("Secretary")},s.id))}function JVt(){const{t:e}=Se(),{secretaries:t,current:n,multiple:r,select:s}=iMe();return a.jsxs(yi,{title:e("Contacts & owner"),description:e("Reach the secretary from your phone. Milestones go out; your replies come back."),children:[r&&a.jsx("div",{className:"mt-4 flex max-w-full flex-wrap items-center gap-1.5",children:a.jsx(aMe,{secretaries:t,current:n,onSelect:s})}),a.jsx(QVt,{secretaryId:n,frames:{owner:o=>a.jsx(Xn,{title:e("Owner identity"),rowId:"contacts.owner",children:o}),channels:o=>a.jsx(Xn,{title:e("Contact channels"),rowId:"contacts.channels",children:o})}},n??"single")]})}const eGt={body:"Body",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4–6",table:"Table",inlineCode:"Inline code",codeBlock:"Code block"},Zde=YW.map(e=>({value:String(e),label:String(e)}));function tGt(){const{t:e}=Se(),t=be(c=>c.chatTypography),n=be(c=>c.setChatTypography),r=be(c=>c.resetChatTypography),[s,o]=y.useState(t.body.size);y.useEffect(()=>{o(t.body.size)},[t.body.size]);const i=(c,u)=>{const d=be.getState().chatTypography;n({...d,[c]:{...d[c],size:u}})},l=(c,u)=>{const d=be.getState().chatTypography;n({...d,[c]:{...d[c],weight:u}})};return a.jsxs(Xn,{rowId:"appearance.chatTypography",title:e("Conversation typography"),description:e("Headings, tables and inline code scale with the body text"),children:[ET.map(c=>a.jsx(nGt,{role:c,label:e(eGt[c]),size:t[c].size,weight:t[c].weight,bodyPreview:s,onPreview:c==="body"?o:void 0,onCommit:u=>i(c,u),onWeight:u=>l(c,u)},c)),a.jsx("div",{className:"flex justify-end py-2",children:a.jsx(fn,{onClick:()=>r(),children:e("Reset to defaults")})})]})}function nGt({role:e,label:t,size:n,weight:r,bodyPreview:s,onPreview:o,onCommit:i,onWeight:l}){const c=xk[e],[u,d]=y.useState(n);y.useEffect(()=>{d(n)},[n]);const f=c.unit==="%"?`${(s*u/100).toFixed(1)}px`:void 0;return a.jsxs(jn,{label:t,children:[a.jsx("div",{className:"w-[140px] sm:w-[180px]",children:a.jsx(KK,{min:c.min,max:c.max,step:c.step,value:u,onValueChange:h=>{const p=Array.isArray(h)?h[0]:h;d(p),o?.(p)},onValueCommitted:h=>i(Array.isArray(h)?h[0]:h)})}),a.jsxs("span",{className:"shrink-0 text-right text-[12px] text-muted-foreground tabular-nums",children:[u,c.unit==="%"?"%":"px",f?` · ${f}`:""]}),a.jsxs(Ps,{items:Zde,value:String(r),onValueChange:h=>{const p=Number(h);YW.includes(p)&&l(p)},children:[a.jsx(Ls,{size:"sm",className:"w-24 max-w-full","aria-label":t,children:a.jsx(Os,{})}),a.jsx(Ds,{children:Zde.map(h=>a.jsx(ls,{value:h.value,children:h.label},h.value))})]})]})}function rGt({seconds:e,onCommit:t}){const{t:n}=Se(),[r,s]=y.useState(String(e));y.useEffect(()=>s(String(e)),[e]);const o=()=>{const i=Number(r);if(!Number.isInteger(i)){s(String(e));return}const l=XW(i);t(l),s(String(l))};return a.jsxs(jn,{rowId:"appearance.liveActivityFoldDelaySec",label:n("Wait before folding"),description:n("Seconds to wait after tools and thinking finish"),children:[a.jsx(En,{type:"number",min:1,max:60,value:r,onChange:i=>s(i.target.value),onBlur:o,onKeyDown:i=>{i.key==="Enter"&&(o(),i.currentTarget.blur())},className:"w-20 max-w-full"}),a.jsx("span",{className:"text-[12px] text-muted-foreground",children:n("sec")})]})}function cp({rowId:e,label:t,description:n,checked:r,onChange:s,extra:o}){return a.jsxs(jn,{rowId:e,label:t,description:n,children:[o,a.jsx($r,{checked:r,onCheckedChange:i=>s(i===!0)})]})}function sGt({revealRowId:e}={}){const{t}=Se(),n=be(M=>M.openChangesOnFileEdit),r=be(M=>M.setOpenChangesOnFileEdit),s=be(M=>M.compactReadOnlyTools),o=be(M=>M.setCompactReadOnlyTools),i=be(M=>M.expandLiveEdits),l=be(M=>M.setExpandLiveEdits),c=be(M=>M.expandLiveReasoning),u=be(M=>M.setExpandLiveReasoning),d=be(M=>M.autoCollapseTurns),f=be(M=>M.setAutoCollapseTurns),h=be(M=>M.quoteSelectionButton),p=be(M=>M.setQuoteSelectionButton),m=be(M=>M.collapseCompletedActivity),v=be(M=>M.setCollapseCompletedActivity),b=be(M=>M.collapseLiveActivity),x=be(M=>M.setCollapseLiveActivity),S=be(M=>M.liveActivityFoldDelaySec),k=be(M=>M.setLiveActivityFoldDelaySec),C=be(M=>M.pinUnfinishedTodos),A=be(M=>M.setPinUnfinishedTodos),N=be(M=>M.headerSessionTabs),j=be(M=>M.setHeaderSessionTabs),I=be(M=>M.headerRecentMinutes),_=be(M=>M.setHeaderRecentMinutes),L=M=>M===0?t("Off"):t("{{count}} min",{count:M});return a.jsxs(yi,{title:t("Conversation display"),children:[a.jsx(tGt,{}),a.jsxs(Xn,{children:[a.jsx(cp,{rowId:"appearance.openChangesOnFileEdit",label:t("Open Changes when files are edited"),description:t("Automatically show the side panel Changes tab after the agent edits a file"),checked:n,onChange:r}),a.jsx(cp,{rowId:"appearance.compactReadOnlyTools",label:t("Compact read-only tool calls"),description:t("Show read/grep/find/ls as one-line rows and fold consecutive tool calls while the agent is still running"),checked:s,onChange:o}),a.jsx(cp,{rowId:"appearance.expandLiveEdits",label:t("Expand file edits while running"),description:t("Automatically unfold diffs or written content from file modification tools while the agent is still running"),checked:i,onChange:l}),a.jsx(cp,{rowId:"appearance.expandLiveReasoning",label:t("Expand reasoning while streaming"),description:t("Automatically unfold the thinking block while the model is still reasoning. It collapses again when reasoning ends."),checked:c,onChange:u}),a.jsx(cp,{rowId:"appearance.autoCollapseTurns",label:t("Auto-collapse previous turns"),description:t("After you send a new message, fold earlier turns down to the question, timestamp and duration; the latest turn stays expanded"),checked:d,onChange:f}),a.jsx(cp,{rowId:"appearance.quoteSelectionButton",label:t("Quote button on text selection"),description:t("Show a floating Quote button when you select text in the conversation; click it to put the selection into the input box as a quote"),checked:h,onChange:p}),a.jsx(cp,{rowId:"appearance.collapseCompletedActivity",label:t("Collapse activity after reply"),description:t("When a reply finishes, fold consecutive thinking and tool calls (including edits and commands) into one summary row; failed calls stay visible"),checked:m,onChange:v}),a.jsx(cp,{rowId:"appearance.collapseLiveActivity",label:t("Collapse finished activity while replying"),description:t("While a reply is still running, wait a moment after tools and thinking finish, then fold that stretch into one row. Calls still running stay visible, and failed calls stay visible"),checked:b,onChange:x}),b||e==="appearance.liveActivityFoldDelaySec"?a.jsx(rGt,{seconds:S,onCommit:k}):null,a.jsx(cp,{rowId:"appearance.pinUnfinishedTodos",label:t("Pin unfinished todos"),description:t("Keep the latest todo list above the input while it has unfinished items, so it does not scroll away with the timeline"),checked:C,onChange:A}),a.jsx(cp,{rowId:"appearance.headerSessionTabs",label:t("Show active sessions in the title bar"),description:t("Show active conversations as tabs above the conversation. Hold ⌘/Ctrl to see number shortcuts. Hidden while Bot mode is enabled."),checked:N,onChange:j,extra:N?a.jsxs("div",{className:"flex min-w-0 flex-wrap items-center justify-end gap-2",children:[a.jsx("span",{className:"max-w-full text-[12px] text-muted-foreground",children:t("Also show recent conversations")}),a.jsxs(Ps,{items:Object.fromEntries(IT.map(M=>[String(M),L(M)])),value:String(I),onValueChange:M=>_(Number(M)),children:[a.jsx(Ls,{size:"sm",className:"w-28 max-w-full",children:a.jsx(Os,{})}),a.jsx(Ds,{children:IT.map(M=>a.jsx(ls,{value:String(M),children:L(M)},M))})]})]}):null})]})]})}const vA="text-muted-foreground";function oGt(){const{t:e}=Se();return a.jsxs(yi,{title:e("Devices"),children:[a.jsx(iGt,{}),!window.electronAPI.remote&&a.jsx(aGt,{}),a.jsx(uGt,{})]})}function iGt(){const{t:e}=Se(),[t,n]=y.useState(null),[r,s]=y.useState(null),[o,i]=y.useState(!1),[l,c]=y.useState(null),[u,d]=y.useState(null),[f,h]=y.useState(!1),p=t?.pairingExpiresAt;y.useEffect(()=>{if(!p){d(null);return}const x=()=>d(Math.max(0,Math.ceil((p-Date.now())/1e3)));x();const S=setInterval(x,1e3);return()=>clearInterval(S)},[p]);const m=x=>{navigator.clipboard.writeText(x).then(()=>{h(!0),setTimeout(()=>h(!1),1500)})};y.useEffect(()=>{if(!Mh())return window.electronAPI.pair.status().then(n),window.electronAPI.pair.onStatusChanged(x=>{n(x),(x.pairing||x.devices.length>0)&&c(null)})},[]),y.useEffect(()=>{const x=t?.inviteUri;if(!x){s(null);return}rMe.toDataURL(x,{width:320,margin:1}).then(s).catch(()=>{})},[t?.inviteUri]);const v=async()=>{i(!0),c(null);const x=await window.electronAPI.pair.start();i(!1),x.ok||c(x.error??e("Failed to start pairing"))},b=t?.devices??[];return a.jsxs(Xn,{rowId:"phone.root",title:e("Allow connections"),description:e("Let your phone or another EnsoCode desktop connect to this computer. Keep this app running."),actions:t?.pairing?a.jsx(fn,{onClick:()=>{window.electronAPI.pair.cancel()},children:e("Cancel pairing")}):a.jsxs(fn,{disabled:o,onClick:()=>{v()},children:[o?a.jsx(Jn,{className:"h-4 w-4 animate-spin"}):a.jsx(yT,{className:"h-4 w-4"}),e("Generate pairing code")]}),children:[t&&!t.secureStorage&&a.jsx(lMe,{}),l&&a.jsx("p",{className:"border-border border-b py-3 text-xs text-destructive",children:l}),t?.pairing&&a.jsxs("div",{className:"border-border border-b py-4 text-center",children:[r?a.jsx("img",{src:r,alt:e("Pairing QR code"),className:"mx-auto h-52 w-52"}):a.jsx(Jn,{className:"mx-auto h-5 w-5 animate-spin text-muted-foreground"}),a.jsx("p",{className:"mt-3 font-medium text-sm",children:e("Scan with your phone camera")}),a.jsx("p",{className:"mt-1 text-muted-foreground text-xs",children:e("Scanning opens the app and pairs it. To keep it handy, add it to your home screen.")}),a.jsx("p",{className:"mt-1 text-muted-foreground text-xs",children:e("On another EnsoCode desktop, paste the link below into Settings → Devices → Connect to a node.")}),a.jsx("p",{className:"mt-1 text-muted-foreground text-xs",children:u===null?e("The code expires in 60 seconds and can only be used once."):u>0?e("Expires in {{seconds}}s · single use",{seconds:u}):e("Code expired")}),t.inviteUri&&a.jsxs("div",{className:"mt-3 flex items-center gap-2 text-left",children:[a.jsx("code",{className:"min-w-0 flex-1 truncate bg-muted px-2 py-1.5 font-mono text-[11px] text-muted-foreground",children:t.inviteUri}),a.jsxs(fn,{className:"shrink-0",onClick:()=>m(t.inviteUri),children:[f?a.jsx(Is,{className:"h-3.5 w-3.5"}):a.jsx(zd,{className:"h-3.5 w-3.5"}),e(f?"Copied":"Copy")]})]})]}),a.jsx("p",{className:"border-border border-b py-3 font-medium text-[13px]",children:e("Paired devices")}),b.length===0?a.jsxs("div",{className:"border-border border-b py-8 text-center",children:[a.jsx(yT,{className:"mx-auto h-5 w-5 text-muted-foreground"}),a.jsx("p",{className:"mt-3 font-medium text-sm",children:e("No paired devices")}),a.jsx("p",{className:"mt-1 text-muted-foreground text-xs",children:e("Generate a pairing code to let a phone or another desktop connect.")})]}):b.map(x=>a.jsx(lGt,{device:x},x.pairId))]})}function lMe(){const{t:e}=Se();return a.jsxs("p",{className:"flex items-start gap-2 border-border border-b py-3 text-xs text-muted-foreground",children:[a.jsx(Nd,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),a.jsx("span",{children:e("Secure storage is unavailable on this system, so pairing keys are stored unencrypted.")})]})}function aGt(){const{t:e}=Se(),t=jd(i=>i.nodes),n=jd(i=>i.secureStorage),r=jd(i=>i.refresh),[s,o]=y.useState(!1);return y.useEffect(()=>jd.getState().bind(),[]),a.jsxs(Xn,{title:e("Connect to a node"),description:e("Browse and drive conversations on another EnsoCode desktop. Its agent, keys and history stay there."),actions:a.jsxs(fn,{onClick:()=>o(!0),children:[a.jsx(xs,{className:"h-4 w-4"}),e("Connect to a node")]}),children:[!n&&a.jsx(lMe,{}),a.jsx("p",{className:"border-border border-b py-3 font-medium text-[13px]",children:e("Connected nodes")}),t.length===0?a.jsxs("div",{className:"border-border border-b py-8 text-center",children:[a.jsx(e_,{className:"mx-auto h-5 w-5 text-muted-foreground"}),a.jsx("p",{className:"mt-3 font-medium text-sm",children:e("No connected nodes")}),a.jsx("p",{className:"mt-1 text-muted-foreground text-xs",children:e("Each connecting computer needs its own pairing code from the other desktop.")})]}):t.map(i=>a.jsx(cGt,{node:i,onChanged:()=>{r()}},i.nodeId)),a.jsx(TRe,{open:s,onOpenChange:o,switchOnSuccess:!1})]})}function cMe({transport:e,rttMs:t}){const{t:n}=Se(),r=e==="direct",s=pRe(t);return a.jsxs("span",{className:ve("shrink-0 rounded px-1.5 py-0.5 text-[10px] leading-none",r?"bg-success/15 text-success":"bg-muted text-muted-foreground"),children:[n(r?"Direct link":"Via relay"),s?` · ${s}`:""]})}function lGt({device:e}){const{t}=Se(),[n,r]=y.useState(null),s=async()=>{n!==null&&(n.trim()&&n.trim()!==e.deviceName&&await window.electronAPI.pair.rename(e.pairId,n),r(null))};return a.jsxs("div",{className:"group flex flex-wrap items-center justify-between gap-3 border-border border-b py-2",children:[a.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[a.jsx("span",{className:ve("h-2 w-2 shrink-0 rounded-full",e.phoneOnline?"bg-success":e.connected?"bg-warning":"bg-muted-foreground/40")}),n===null?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"truncate font-medium text-sm",children:e.deviceName}),a.jsx("span",{className:"shrink-0 text-muted-foreground text-xs",children:e.phoneOnline?t("Online"):e.connected?t("Waiting for device"):t("Offline")}),e.phoneOnline&&a.jsx(cMe,{transport:e.transport,rttMs:e.rttMs}),a.jsx("button",{type:"button",title:t("Click to switch: view-only devices cannot send, approve or stop."),onClick:()=>{window.electronAPI.pair.setScope(e.pairId,e.scope==="read"?"operate":"read")},className:ve("relative shrink-0 rounded px-1.5 py-0.5 text-[10px] leading-none transition-colors",e.scope==="read"?"bg-warning/15 text-warning hover:bg-warning/25":"bg-muted text-muted-foreground hover:bg-accent"),children:e.scope==="read"?t("View only"):t("Can operate")})]}):a.jsx(En,{value:n,autoFocus:!0,onChange:o=>r(o.target.value),onBlur:()=>{s()},onKeyDown:o=>{o.key==="Enter"&&s(),o.key==="Escape"&&r(null)},className:"h-7 w-full max-w-full text-sm sm:w-[220px]"})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-1 opacity-0 transition-opacity pointer-coarse:opacity-100 group-hover:opacity-100",children:[a.jsx(Ke,{variant:"ghost",size:"icon",className:vA,title:t("Rename"),onClick:()=>r(e.deviceName),children:a.jsx(Pi,{className:"h-3.5 w-3.5"})}),a.jsx(Ke,{variant:"ghost",size:"icon",className:ve(vA,"hover:text-destructive"),onClick:()=>{window.electronAPI.pair.revoke(e.pairId)},children:a.jsx(io,{className:"h-3.5 w-3.5"})})]})]})}function cGt({node:e,onChanged:t}){const{t:n}=Se(),[r,s]=y.useState(null),o=async()=>{r!==null&&(r.trim()&&r.trim()!==e.label&&(await window.electronAPI.nodes.rename(e.nodeId,r),t()),s(null))};return a.jsxs("div",{className:"group flex flex-wrap items-center justify-between gap-3 border-border border-b py-2",children:[a.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[a.jsx(LV,{node:e}),r===null?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"truncate font-medium text-sm",children:e.label}),e.hostname&&e.hostname!==e.label&&a.jsx("span",{className:"shrink-0 truncate font-mono text-[10px] text-muted-foreground",children:e.hostname}),a.jsx("span",{className:"shrink-0 text-muted-foreground text-xs",children:e.hostOnline?n("Online"):e.connected?n("Remote desktop is offline"):n("Offline")}),e.hostOnline&&a.jsx(cMe,{transport:e.transport,rttMs:e.rttMs})]}):a.jsx(En,{value:r,autoFocus:!0,onChange:i=>s(i.target.value),onBlur:()=>{o()},onKeyDown:i=>{i.key==="Enter"&&o(),i.key==="Escape"&&s(null)},className:"h-7 w-full max-w-full text-sm sm:w-[220px]"})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-1 opacity-0 transition-opacity pointer-coarse:opacity-100 group-hover:opacity-100",children:[a.jsx(Ke,{variant:"ghost",size:"icon",className:vA,title:n("Rename"),onClick:()=>s(e.label),children:a.jsx(Pi,{className:"h-3.5 w-3.5"})}),a.jsx(Ke,{variant:"ghost",size:"icon",className:ve(vA,"hover:text-destructive"),title:n("Disconnect"),onClick:()=>{window.electronAPI.nodes.remove(e.nodeId).then(t)},children:a.jsx(io,{className:"h-3.5 w-3.5"})})]})]})}function uGt(){const{t:e}=Se(),[t,n]=y.useState(null),[r,s]=y.useState(null);y.useEffect(()=>(window.electronAPI.pair.status().then(n),window.electronAPI.pair.onStatusChanged(n)),[]);const o=async()=>{r!==null&&(n(await window.electronAPI.pair.setRelayUrl(r)),s(null))};return a.jsx(Xn,{children:a.jsxs(jn,{label:e("Relay server"),description:e("The relay only forwards encrypted frames and cannot read your messages."),children:[a.jsx(En,{value:r??t?.relayUrl??"",onChange:i=>s(i.target.value),placeholder:"https://relay.example.com",className:"w-full font-mono text-xs sm:w-[220px]"}),r===null?a.jsx(Ke,{variant:"ghost",size:"icon-sm",className:vA,onClick:()=>s(t?.relayUrl??""),children:a.jsx(Pi,{className:"h-3.5 w-3.5"})}):a.jsxs(fn,{variant:"default",onClick:()=>{o()},children:[a.jsx(Is,{className:"h-3.5 w-3.5"}),e("Save")]})]})})}function dGt({onOpenBots:e}){const{t}=Se(),n=be(f=>f.botModeEnabled),r=be(f=>f.setBotModeEnabled),s=be(f=>f.scratchSessionsEnabled),o=be(f=>f.setScratchSessionsEnabled),i=be(f=>f.dropShelfEnabled),l=be(f=>f.setDropShelfEnabled),c=be(f=>f.secretaryEnabled),u=be(f=>f.setSecretaryEnabled),d=window.electronAPI.env.platform==="darwin"&&!window.electronAPI.remote;return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-medium",children:t("Experimental")}),a.jsx("p",{className:"text-sm text-muted-foreground",children:t("Features still being tested. They may change or be removed.")})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(jn,{rowId:"experimental.botMode",label:t("Bot mode"),description:t("Adds a Code | Bot switch to the sidebar. Create members with their own persona, model and tools, and chat with them alone or in groups."),children:a.jsx($r,{checked:n,onCheckedChange:r})}),n&&a.jsx(Ke,{variant:"outline",size:"sm",onClick:e,children:t("Bot mode settings")}),a.jsx(jn,{rowId:"experimental.scratchSessions",label:t("Temporary chats"),description:t("Chats that are not tied to a project. Tools follow your global settings."),children:a.jsx($r,{checked:s,onCheckedChange:o})}),d&&a.jsx(jn,{rowId:"experimental.dropShelf",label:t("Drop shelf"),description:t("When you drag files in Finder, a small panel appears at the top right of the screen. Drop them on it to reference them in the current conversation, or drop folders to open them as projects, even when EnsoCode is minimized or in the tray."),children:a.jsx($r,{checked:i,onCheckedChange:l})}),a.jsx(jn,{rowId:"experimental.secretary",label:t("Secretary"),description:t("A global agent that watches your projects and sessions, creates sessions to do the work, and reports results back to you."),children:a.jsx($r,{checked:c,onCheckedChange:u})})]})]})}const fGt=["pem","crt","cer"],hGt=[{category:"providers",label:"Model Providers"},{category:"presets",label:"Presets"},{category:"agentTypes",label:"Agent types"},{category:"skills",label:"Skills"},{category:"mcpServers",label:"MCP Servers"},{category:"instructions",label:"Instruction Files"},{category:"subagentModels",label:"Subagent Models"},{category:"settings",label:"Scalar settings"}];function pGt(){const{t:e}=Se(),[t,n]=y.useState(!1),[r,s]=y.useState(!1),[o,i]=y.useState(null),[l,c]=y.useState(null),u=()=>{i(null),n(!0)},d=async()=>{s(!0),i(null);try{const f=await window.electronAPI.configSync.openImport();if(!f.ok){i({kind:f.cancelled?"cancelled":"error",text:f.cancelled?e("Import cancelled."):e(f.error)});return}c(f)}catch{i({kind:"error",text:e("Could not open configuration package.")})}finally{s(!1)}};return a.jsxs(Xn,{rowId:"general.configSync",title:e("Configuration transfer"),description:e("Move models, presets, agent types, skills, MCP servers and instruction files between devices."),children:[a.jsxs(jn,{label:e("Portable Enso configuration"),description:a.jsxs(a.Fragment,{children:[e("Export a package or preview one before importing it.")," ",e("OAuth login sessions are never transferred. Skill, instruction, and system prompt contents require an encrypted export.")]}),children:[a.jsxs(fn,{disabled:r,onClick:()=>{d()},children:[r?a.jsx(Jn,{className:"h-3.5 w-3.5 animate-spin"}):a.jsx(Lf,{className:"h-3.5 w-3.5"}),e("Import configuration")]}),a.jsxs(fn,{variant:"default",disabled:r,onClick:u,children:[a.jsx(Lxe,{className:"h-3.5 w-3.5"}),e("Export configuration")]})]}),o&&a.jsx("p",{className:o.kind==="error"?"border-border border-b py-2 text-[12px] text-destructive":"border-border border-b py-2 text-[12px] text-muted-foreground",role:o.kind==="error"?"alert":"status",children:o.text}),a.jsx(mGt,{open:t,onOpenChange:n}),l&&a.jsx(gGt,{file:l,onClose:()=>c(null)})]})}function mGt({open:e,onOpenChange:t}){const{t:n}=Se(),[r,s]=y.useState(!1),[o,i]=y.useState(""),[l,c]=y.useState(""),[u,d]=y.useState(!1),[f,h]=y.useState(null),[p,m]=y.useState(!1),[v,b]=y.useState(null),[x,S]=y.useState([]);y.useEffect(()=>{e&&(s(!1),i(""),c(""),d(!1),h(null),m(!1),b(null),S([]))},[e]);const k=()=>{u||(i(""),c(""),t(!1))},C=async()=>{if(r&&o.length<8){h(n("Password must be at least 8 characters."));return}if(r&&o!==l){h(n("Passwords do not match."));return}d(!0),h(null),m(!1);try{const A=await window.electronAPI.configSync.exportConfig({includeSecrets:r,...r?{password:o}:{}});if(i(""),c(""),!A.ok){A.cancelled?m(!0):h(n(A.error));return}b(A.filePath),S(A.skippedInstructions??[])}catch{i(""),c(""),h(n("Could not export configuration."))}finally{d(!1)}};return a.jsx(gr,{open:e,onOpenChange:A=>!A&&k(),children:a.jsxs(vr,{className:"max-w-xl",showCloseButton:!u,children:[a.jsxs(xr,{children:[a.jsx(dr,{children:n("Export configuration")}),a.jsx(oo,{children:n("Create a portable .enso-config package for another device.")})]}),a.jsx(rr,{className:"max-h-[55vh] space-y-4",children:v?a.jsxs(a.Fragment,{children:[a.jsxs(kd,{variant:"success",children:[a.jsx(By,{}),a.jsx(Rw,{children:n("Configuration exported")}),a.jsxs(Sd,{children:[a.jsx("p",{children:n("Saved package:")}),a.jsx("p",{className:"break-all font-mono text-xs text-foreground",children:v})]})]}),x.length>0&&a.jsxs(kd,{variant:"warning",children:[a.jsx(Nd,{}),a.jsxs(Sd,{children:[a.jsx("p",{children:n("These instructions were skipped because their source files are missing or unreadable:")}),a.jsx("p",{className:"break-all text-foreground",children:x.join(", ")})]})]})]}):a.jsxs(a.Fragment,{children:[a.jsxs(kd,{variant:"warning",children:[a.jsx(Rf,{}),a.jsx(Rw,{children:n("File contents can be private")}),a.jsx(Sd,{children:n("Skill and instruction file contents may contain private data, so configurations containing them can only be exported with encryption.")})]}),a.jsxs("label",{className:"flex cursor-pointer items-start gap-3 border-border border-b py-3",children:[a.jsx(wo,{checked:r,onCheckedChange:A=>{const N=A===!0;s(N),h(null),N||(i(""),c(""))}}),a.jsxs("span",{className:"min-w-0",children:[a.jsx("span",{className:"block text-sm font-medium",children:n("Include sensitive configuration")}),a.jsx("span",{className:"mt-0.5 block text-xs text-muted-foreground",children:n("Encrypt the entire package with a password. OAuth login sessions are still excluded.")})]})]}),!r&&a.jsxs(kd,{variant:"info",children:[a.jsx(vg,{}),a.jsx(Sd,{children:n("API keys, provider account links, MCP arguments and environment values, plus credentials and private URL parts in MCP endpoints, will be omitted. Configurations containing skill or instruction files require encryption.")})]}),r&&a.jsxs("div",{className:"space-y-3 border-border border-t py-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[a.jsx(Cxe,{className:"h-4 w-4 text-muted-foreground"}),n("Encryption password")]}),a.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(aV,{htmlFor:"config-export-password",children:n("Password")}),a.jsx(En,{id:"config-export-password",type:"password",autoComplete:"new-password",value:o,"aria-invalid":!!(f&&o.length<8),onChange:A=>{i(A.target.value),h(null)}})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(aV,{htmlFor:"config-export-confirmation",children:n("Confirm password")}),a.jsx(En,{id:"config-export-confirmation",type:"password",autoComplete:"new-password",value:l,"aria-invalid":!!(f&&l!==o),onChange:A=>{c(A.target.value),h(null)}})]})]}),a.jsx("p",{className:"text-xs text-muted-foreground",children:n("Use at least 8 characters. This password cannot be recovered.")})]}),p&&a.jsx("p",{className:"text-xs text-muted-foreground",role:"status",children:n("Export cancelled.")}),f&&a.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-destructive",role:"alert",children:[a.jsx(qa,{className:"h-3.5 w-3.5 shrink-0"}),f]})]})}),a.jsx(Wr,{children:v?a.jsx(Ke,{size:"sm",onClick:k,children:n("Done")}):a.jsxs(a.Fragment,{children:[a.jsx(Ke,{variant:"outline",size:"sm",disabled:u,onClick:k,children:n("Cancel")}),a.jsxs(Ke,{size:"sm",disabled:u,onClick:()=>{C()},children:[u?a.jsx(Jn,{className:"h-3.5 w-3.5 animate-spin"}):a.jsx(Lxe,{className:"h-3.5 w-3.5"}),n(u?"Exporting…":"Export")]})]})})]})})}function gGt({file:e,onClose:t}){const{t:n}=Se(),[r,s]=y.useState(e.encrypted?"password":"preview"),[o,i]=y.useState(""),[l,c]=y.useState("merge"),[u,d]=y.useState(null),[f,h]=y.useState([]),[p,m]=y.useState(null),[v,b]=y.useState(!1),[x,S]=y.useState(null),[k,C]=y.useState(null),[A,N]=y.useState(!1),j=y.useRef(0),I=y.useCallback(async(R,z)=>{const B=++j.current;S("preview"),C(null),d(null),h([]);try{const H=await window.electronAPI.configSync.previewImport({token:e.token,mode:R,...z?{password:z}:{}});if(B!==j.current)return;if(i(""),!H.ok){C(n(H.error));return}c(H.mode),d(H.summary),h(H.warnings),s("preview")}catch{B===j.current&&(i(""),C(n("Could not preview configuration package.")))}finally{B===j.current&&S(null)}},[e.token,n]);y.useEffect(()=>{e.encrypted||I("merge")},[e.encrypted,I]);const _=()=>{x||(j.current+=1,N(!1),i(""),window.electronAPI.configSync.cancelImport(e.token).catch(()=>{}),t())},L=R=>{R===l||x||(c(R),I(R))},M=!!u?.some(R=>(R.category==="skills"||R.category==="mcpServers")&&R.added+R.updated+R.skipped>0),F=u!==null,D=async()=>{if(u){S("commit"),C(null);try{const R=await window.electronAPI.configSync.commitImport({token:e.token,mode:l});if(!R.ok){d(null),h([]),C(n(R.error));return}i("");try{await be.persist.rehydrate()}catch{b(!0)}h(R.warnings),m(R.backupPath),s("success")}catch{d(null),h([]),C(n("Could not import configuration."))}finally{S(null)}}};return a.jsxs(gr,{open:!0,onOpenChange:R=>!R&&_(),children:[a.jsxs(vr,{className:"max-w-2xl",showCloseButton:x===null,children:[a.jsxs(xr,{children:[a.jsx(dr,{children:n(r==="success"?"Configuration imported":"Import configuration")}),a.jsx(oo,{children:r==="success"?n(v?"Configuration was imported, but this window could not refresh automatically.":"This window has been refreshed with the imported settings."):n("Review {{fileName}} before changing this device.",{fileName:e.fileName})})]}),r==="password"&&a.jsxs(rr,{className:"space-y-4",children:[a.jsxs(kd,{variant:"info",children:[a.jsx(Cxe,{}),a.jsx(Rw,{children:n("Encrypted configuration package")}),a.jsx(Sd,{children:n("Enter the export password to decrypt and preview this package.")})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(aV,{htmlFor:"config-import-password",children:n("Password")}),a.jsx(En,{id:"config-import-password",type:"password",autoFocus:!0,autoComplete:"current-password",value:o,"aria-invalid":!!k,onChange:R=>{i(R.target.value),C(null)},onKeyDown:R=>{R.key==="Enter"&&o.length>0&&!x&&I("merge",o)}})]}),k&&a.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-destructive",role:"alert",children:[a.jsx(qa,{className:"h-3.5 w-3.5 shrink-0"}),k]})]}),r==="preview"&&a.jsxs(rr,{className:"max-h-[58vh] space-y-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-sm font-medium",children:n("Import mode")}),a.jsxs(hRe,{value:l,onValueChange:R=>L(R),className:"grid gap-2 sm:grid-cols-2","aria-label":n("Import mode"),children:[a.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5 border-border border-b py-3",children:[a.jsx(PV,{value:"merge",disabled:x!==null}),a.jsxs("span",{children:[a.jsx("span",{className:"block text-sm font-medium",children:n("Merge")}),a.jsx("span",{className:"block text-xs text-muted-foreground",children:n("Add and update matching items while keeping items only on this device.")})]})]}),a.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5 border-border border-b py-3",children:[a.jsx(PV,{value:"replace",disabled:x!==null}),a.jsxs("span",{children:[a.jsx("span",{className:"block text-sm font-medium",children:n("Replace")}),a.jsx("span",{className:"block text-xs text-muted-foreground",children:n("Replace transferred item categories, removing local-only items in them.")})]})]})]})]}),x==="preview"&&a.jsxs("div",{className:"flex items-center justify-center gap-2 py-6",children:[a.jsx(Jn,{className:"h-4 w-4 animate-spin text-muted-foreground"}),a.jsx("span",{className:"text-sm text-muted-foreground",children:n("Preparing preview…")})]}),!x&&u&&a.jsx("div",{className:"min-w-0 overflow-x-auto",children:a.jsxs("table",{className:"w-max min-w-full text-sm",children:[a.jsx("thead",{className:"text-xs text-muted-foreground",children:a.jsxs("tr",{className:"border-border border-b",children:[a.jsx("th",{scope:"col",className:"px-3 py-2 text-left font-medium",children:n("Category")}),a.jsx("th",{scope:"col",className:"px-3 py-2 text-right font-medium",children:n("Added")}),a.jsx("th",{scope:"col",className:"px-3 py-2 text-right font-medium",children:n("Updated")}),a.jsx("th",{scope:"col",className:"px-3 py-2 text-right font-medium",children:n("Skipped")}),a.jsx("th",{scope:"col",className:"px-3 py-2 text-right font-medium",children:n("Removed")})]})}),a.jsx("tbody",{children:hGt.map(({category:R,label:z})=>{const B=u.find(H=>H.category===R);return a.jsxs("tr",{className:"border-border border-t",children:[a.jsx("th",{scope:"row",className:"px-3 py-2 text-left font-medium",children:n(z)}),a.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:B?.added??0}),a.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:B?.updated??0}),a.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:B?.skipped??0}),a.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:B?.removed??0})]},R)})})]})}),!x&&u?.find(R=>R.category==="settings")?.fields?.length?a.jsxs("p",{className:"text-xs text-muted-foreground",children:[n("Portable settings changed:")," ",u.find(R=>R.category==="settings")?.fields?.join(", ")]}):null,l==="replace"&&u&&!x&&a.jsxs(kd,{variant:"error",children:[a.jsx(Nd,{}),a.jsx(Rw,{children:n("Local-only configuration will be deleted")}),a.jsx(Sd,{children:n("Items in transferred collections that exist only on this device will be removed. Removed counts are shown above. Included portable preferences are overwritten. A complete backup is created first.")})]}),f.map(R=>a.jsxs(kd,{variant:"warning",children:[a.jsx(Nd,{}),a.jsx(Sd,{children:n(R)})]},R)),u&&!x&&a.jsxs(kd,{variant:"warning",children:[a.jsx(Rf,{}),a.jsx(Rw,{children:n("Only import packages you trust")}),a.jsx(Sd,{children:n("An imported package can change portable preferences and configuration. Skills and MCP servers may also run commands later when you use them. Previewing does not execute them; continue only if you trust the package.")})]}),k&&a.jsxs(kd,{variant:"error",children:[a.jsx(qa,{}),a.jsx(Sd,{children:k})]})]}),r==="success"&&p&&a.jsxs(rr,{className:"space-y-4",children:[a.jsxs(kd,{variant:"success",children:[a.jsx(By,{}),a.jsx(Rw,{children:n("Import complete")}),a.jsxs(Sd,{children:[a.jsx("p",{children:n("Backup of previous settings:")}),a.jsx("p",{className:"break-all font-mono text-xs text-foreground",children:p})]})]}),v&&a.jsxs(kd,{variant:"warning",children:[a.jsx(Nd,{}),a.jsx(Sd,{children:n("Reopen Settings to load the imported configuration in this window.")})]}),f.map(R=>a.jsxs(kd,{variant:"warning",children:[a.jsx(Nd,{}),a.jsx(Sd,{children:n(R)})]},R))]}),a.jsxs(Wr,{children:[r==="password"&&a.jsxs(a.Fragment,{children:[a.jsx(Ke,{variant:"outline",size:"sm",disabled:x!==null,onClick:_,children:n("Cancel")}),a.jsxs(Ke,{size:"sm",disabled:x!==null||o.length===0,onClick:()=>{I("merge",o)},children:[x==="preview"&&a.jsx(Jn,{className:"h-3.5 w-3.5 animate-spin"}),n("Preview")]})]}),r==="preview"&&a.jsxs(a.Fragment,{children:[a.jsx(Ke,{variant:"outline",size:"sm",disabled:x!==null,onClick:_,children:n("Cancel")}),k&&!u?a.jsx(Ke,{size:"sm",disabled:x!==null,onClick:()=>{I(l)},children:n("Refresh preview")}):a.jsxs(Ke,{variant:l==="replace"?"destructive":"default",size:"sm",disabled:x!==null||!u,onClick:()=>{u&&(F?N(!0):D())},children:[x==="commit"?a.jsx(Jn,{className:"h-3.5 w-3.5 animate-spin"}):a.jsx(Lf,{className:"h-3.5 w-3.5"}),n(x==="commit"?"Importing…":"Import")]})]}),r==="success"&&a.jsx(Ke,{size:"sm",onClick:_,children:n("Done")})]})]}),a.jsx(vGt,{open:A,mode:l,hasImportedExecutableResources:M,onOpenChange:N,onConfirm:()=>{D()}})]})}function vGt({open:e,mode:t,hasImportedExecutableResources:n,onOpenChange:r,onConfirm:s}){const{t:o}=Se();return a.jsx(Jp,{open:e,onOpenChange:r,children:a.jsxs(em,{className:"sm:max-w-md",zIndexLevel:"nested",children:[a.jsxs(tm,{children:[a.jsxs(rm,{className:"flex items-start gap-2 text-base",children:[a.jsx(Nd,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),o("Confirm configuration import")]}),a.jsxs(sm,{className:"space-y-2",children:[a.jsx("span",{className:"block",children:o("This package can change portable preferences and configuration. Continue only if you trust this package.")}),n&&a.jsx("span",{className:"block",children:o("It includes skills or MCP servers that may execute commands when you use them.")}),t==="replace"&&a.jsx("span",{className:"block",children:o("Replace mode removes local-only items from transferred collections and overwrites included portable preferences. A complete backup will be created first.")}),a.jsx("span",{className:"block",children:o("Do you want to continue with this import?")})]})]}),a.jsxs(nm,{variant:"bare",children:[a.jsx(dx,{render:a.jsx(Ke,{variant:"outline",size:"sm"}),children:o("Cancel")}),a.jsx(Ke,{variant:t==="replace"?"destructive":"default",size:"sm",onClick:()=>{r(!1),s()},children:o("Confirm import")})]})]})})}function xGt({className:e,...t}){const n=Bg();return a.jsx(En,{size:"sm",...n,...t,className:ve("w-[220px] max-w-full",e)})}function bGt(){const{language:e,setLanguage:t}=be(),{t:n}=Se();return a.jsxs(yi,{title:n("General"),description:n("General application settings"),children:[a.jsxs(Xn,{title:n("Application"),children:[a.jsx(jn,{rowId:"general.language",label:n("Language"),children:a.jsx(Zo,{value:e,onValueChange:t,options:[{value:"en",label:"English"},{value:"zh",label:"简体中文"}]})}),a.jsx(yGt,{})]}),a.jsxs(Xn,{title:n("Network"),children:[a.jsx(wGt,{}),a.jsx(kGt,{})]}),a.jsx(pGt,{}),a.jsx(CGt,{}),window.electronAPI.env.platform==="darwin"&&!Mh()&&a.jsxs(Xn,{title:n("Integrations"),children:[a.jsx(Jde,{kind:"ensoCommand",title:n("'enso' terminal command"),description:n("Run `enso .` in a terminal to open the current folder in EnsoCode. Links the command into /usr/local/bin and may ask for your password.")}),a.jsx(Jde,{kind:"finderQuickAction",title:n("Finder Quick Action"),description:n("Right-click a folder in Finder and choose Services > Open with EnsoCode.")})]})]})}function Jde({kind:e,title:t,description:n}){const{t:r}=Se(),[s,o]=y.useState(!1),[i,l]=y.useState(!1);y.useEffect(()=>{let u=!0;const d=()=>{Mh()||window.electronAPI.window.shellIntegrationStatus().then(f=>{u&&o(f[e])})};return d(),window.addEventListener("focus",d),()=>{u=!1,window.removeEventListener("focus",d)}},[e]);const c=async()=>{l(!0);try{await window.electronAPI.window.installShellIntegration(e)}finally{try{const u=await window.electronAPI.window.shellIntegrationStatus();o(u[e])}finally{l(!1)}}};return a.jsx(jn,{rowId:`general.${e}`,label:t,description:n,children:a.jsx(fn,{disabled:i,onClick:()=>{c()},children:r(i?"In progress…":s?"Uninstall":"Install")})})}function yGt(){const{t:e}=Se(),t=be(r=>r.notifyMainAgentOnly),n=be(r=>r.setNotifyMainAgentOnly);return a.jsx(jn,{rowId:"general.notifyMainAgentOnly",label:e("Notify only for the main agent"),description:e("Skip coworker completion and failure notifications on this computer and the paired phone. Questions and approvals still notify."),children:a.jsx($r,{checked:t,onCheckedChange:n})})}function efe(e,t){window.electronAPI.proxy.apply({mode:e,customUrl:t})}function wGt(){const{t:e}=Se(),t=be(f=>f.proxyMode),n=be(f=>f.customProxyUrl),r=be(f=>f.setProxyMode),s=be(f=>f.setCustomProxyUrl),[o,i]=y.useState(n),[l,c]=y.useState(null);y.useEffect(()=>{i(n)},[n]);const u=f=>{r(f),efe(f,n)},d=()=>{const f=o.trim();if(f&&!eq(f)){c(e("Enter an http(s) proxy URL"));return}c(null),s(f),efe(t,f)};return a.jsxs("div",{"data-settings-row":"general.proxy",children:[a.jsx(jn,{label:e("Network proxy"),description:e("Used by model requests, the built-in browser, and agent tools"),children:a.jsx(Zo,{value:t,onValueChange:u,options:[{value:"system",label:e("Follow system proxy")},{value:"none",label:e("No proxy")},{value:"custom",label:e("Custom proxy")}]})}),t==="custom"&&a.jsx(jn,{label:e("Proxy URL"),children:a.jsxs("div",{className:"flex w-full max-w-[220px] flex-col items-end gap-1",children:[a.jsx(xGt,{value:o,placeholder:"http://127.0.0.1:7890",onChange:f=>i(f.target.value),onBlur:d,onKeyDown:f=>{f.key==="Enter"&&d()}}),l&&a.jsx("p",{className:"text-right text-[12px] text-destructive",children:l})]})})]})}function kGt(){const{t:e}=Se(),t=be(f=>f.customCaCertPath),n=be(f=>f.setCustomCaCertPath),[r,s]=y.useState(null),[o,i]=y.useState(!1);y.useEffect(()=>{let f=!0;return window.electronAPI.caCert.status().then(h=>{f&&s(h)}).catch(()=>{}),()=>{f=!1}},[]);const l=async f=>{n(f),i(!0);try{s(await window.electronAPI.caCert.apply(f))}catch{}finally{i(!1)}},c=async()=>{const f=await window.electronAPI.dialog.selectFile([...fGt]);f&&await l(f)},u={"not-absolute":e("Path must be absolute"),"not-found":e("File not found"),"not-file":e("Not a file"),"not-readable":e("File is not readable")},d=()=>r?r.source==="env"?e("Using NODE_EXTRA_CA_CERTS from the launch environment: {{path}}",{path:r.path}):r.source==="setting"?e("Set: {{path}}",{path:r.path}):r.source==="shell"?e("Not set; using NODE_EXTRA_CA_CERTS from the login shell: {{path}}",{path:r.path}):e("Not set"):"";return a.jsxs(jn,{rowId:"general.caCert",label:e("Custom CA certificate"),description:a.jsxs(a.Fragment,{children:[e("Trust an extra CA (PEM file) for model endpoints signed by a private CA. TLS verification stays on."),r?.error?a.jsx("span",{className:"mt-1 block break-all text-destructive",children:e("Certificate file unavailable ({{reason}}): {{path}}",{reason:u[r.error],path:r.settingPath})}):d()&&a.jsx("span",{className:"mt-1 block break-all",children:d()}),a.jsx("span",{className:"mt-1 block",children:e("Changes restart the agent process right away (running turns are interrupted). Requests made by the app main process take effect after restarting the app.")})]}),children:[a.jsx(fn,{disabled:o,onClick:()=>{c()},children:e("Choose certificate file")}),t&&a.jsx(fn,{variant:"ghost",disabled:o,onClick:()=>{l("")},children:e("Clear")})]})}function SGt(e,t,n){return e==="npm"?n("Server updates install the new version with npm and restart gracefully: running tasks finish first (up to a limit), then the server restarts and tasks resume."):a.jsxs(a.Fragment,{children:[n("This server must be updated on the machine itself."),a.jsxs("code",{"data-server-manual-command":!0,className:"mt-0.5 block",children:["npm i -g ",$qe(t)]})]})}const tfe="0.3.15-beta.244";function CGt(){const{t:e}=Se(),t=be(N=>N.autoUpdate),n=be(N=>N.setAutoUpdate),r=be(N=>N.autoRestartForUpdate),s=be(N=>N.setAutoRestartForUpdate),o=be(N=>N.updateChannel==="beta"?"beta":"stable"),i=be(N=>N.setUpdateChannel),[l,c]=y.useState(null),[u,d]=y.useState(null),[f,h]=y.useState(!1),[p,m]=y.useState(!1);y.useEffect(()=>{let N=!0;window.electronAPI.updater.getState().then(I=>{N&&(d(I),I.status&&c(_=>_??I.status))}).catch(()=>{});const j=window.electronAPI.updater.onStatus(c);return()=>{N=!1,j()}},[]);const v=u?.host==="server"?u:null,b=u?.host==="desktop"||v!==null&&v.mode!=="manual",x=(l?.status==="available"||l?.status==="downloaded")&&!!l.info,S=l?.status==="applying",C=(()=>{if(!l)return null;switch(l.status){case"checking":return e("Checking for updates…");case"available":return l.manualInstall?e("New version {{version}} found. This local build can't install it automatically.",{version:l.info?.version??""}):e("New version {{version}} found",{version:l.info?.version??""});case"not-available":return e("You are on the latest version");case"downloading":return e("Downloading update… {{percent}}%",{percent:Math.round(l.progress?.percent??0)});case"downloaded":return v?.restartMethod==="manual"?e("New version {{version}} is downloaded. Applying it installs and then stops the server — you will need to restart it externally (container or process manager).",{version:l.info?.version??""}):e("New version {{version}} is downloaded. Restarting waits for the current tool to finish; background commands keep running.",{version:l.info?.version??""});case"applying":{const N=l.applying?.stage;return N==="waiting-tasks"?e("Waiting for {{count}} running tasks to finish before installing…",{count:l.applying?.busyCount??0}):N==="installing"?e("Installing {{version}}…",{version:l.info?.version??""}):e("Restarting server…")}case"error":return l.manualInstall?e("This local build is signed differently from the release and can't install updates automatically. Download it manually."):v&&l.error?e("Update failed: {{error}}",{error:l.error}):e("Update check failed");default:return null}})(),A=l?.status==="checking"||l?.status==="downloading";return a.jsxs(Xn,{rowId:"general.updates",title:e("Updates"),description:v?SGt(v.mode,o,e):e("Application update settings"),children:[a.jsxs(jn,{label:a.jsxs(a.Fragment,{children:[e("Current version")," · ",tfe]}),description:C?a.jsx("span",{className:ve("block",!l?.manualInstall&&"truncate"),children:C}):void 0,children:[x&&a.jsx(fn,{variant:"ghost",onClick:()=>m(!0),children:e("Release notes")}),l?.manualInstall?a.jsx(UY,{manualInstall:l.manualInstall}):S?a.jsx(fn,{variant:"default",disabled:!0,children:e("Updating…")}):l?.status==="downloaded"?a.jsx(fn,{variant:"default",onClick:()=>{Q$(e)},children:e("Restart to update")}):b&&l?.status==="available"?a.jsx(fn,{variant:"default",onClick:()=>{window.electronAPI.updater.downloadUpdate()},children:e("Download update")}):a.jsx(fn,{disabled:A,onClick:()=>{window.electronAPI.updater.checkForUpdates()},children:e("Check for updates")}),a.jsx(bAe,{open:p,onOpenChange:m,status:l,canDownload:b})]}),v?.canRestart&&a.jsxs(jn,{label:e("Restart server"),description:e("Waits for running tasks to finish before restarting; this page reconnects after the server is back. Force restart does not wait."),children:[a.jsx(fn,{variant:"ghost",onClick:()=>{window.electronAPI.updater.restart(!0)},children:e("Restart now")}),a.jsx(fn,{onClick:()=>h(!0),children:e("Restart")}),a.jsx(ec,{open:f,onOpenChange:h,title:e("Restart server?"),description:e("Running tasks finish first, then the server restarts; this page reconnects when it is back."),confirmLabel:e("Restart"),onConfirm:()=>{h(!1),window.electronAPI.updater.restart()}})]}),a.jsx(jn,{label:e("Automatic updates"),description:v?.mode==="manual"?e("Not available for this install: it cannot update itself. Update manually instead."):e(v?"Download and install updates automatically: running tasks finish first, then the server restarts and they resume.":"Download and install updates automatically"),children:a.jsx($r,{checked:v?.mode==="manual"?!1:t,disabled:v?.mode==="manual",onCheckedChange:N=>{n(N),window.electronAPI.updater.setAutoUpdateEnabled(N)}})}),!v&&a.jsx("div",{className:t?void 0:"opacity-60",children:a.jsx(jn,{label:e("Restart automatically to apply updates"),description:e(r==="immediate"?"Restart as soon as the update is downloaded, even while agents are running or messages are queued. The restart happens after the current tool finishes, and running sessions keep going afterwards. It still waits while you're using the window (input in the last 2 minutes), while an input box has an unsent draft, or while a question or approval is pending.":r==="idle"?"After the update is downloaded, restart automatically if no agent is running, nothing is queued, and there are no pending questions or approvals. The idle state must last 5 minutes, and a focused window also blocks it.":"Only notify when an update is ready; never restart automatically."),children:a.jsx(Zo,{value:r,disabled:!t,onValueChange:N=>{hye(N)&&(s(N),window.electronAPI.updater.setAutoRestartMode(N))},options:[{value:"off",label:e("Off")},{value:"idle",label:e("When idle")},{value:"immediate",label:e("Don't wait for idle")}]})})}),(u?.host==="desktop"||u?.host==="server")&&a.jsx(jn,{rowId:"general.updateChannel",label:e("Update channel"),description:a.jsxs(a.Fragment,{children:[e(o==="beta"?"Beta builds come from the latest main branch and may be unstable. You get whichever of beta and stable is newer.":"Only stable releases."),o==="stable"&&Yqe(tfe)&&a.jsx("span",{className:"mt-0.5 block",children:e("You're on a beta build. Switching to stable doesn't downgrade; you'll move to the next stable release once it's out.")})]}),children:a.jsx(Zo,{value:o,onValueChange:N=>{const j=N==="beta"?"beta":"stable";i(j),window.electronAPI.updater.setChannel(j)},options:[{value:"stable",label:e("Stable")},{value:"beta",label:e("Beta")}]})})]})}function EGt({instruction:e,onClose:t}){const{t:n}=Se(),r=be(j=>j.addInstructions),s=be(j=>j.updateInstruction),o=e==="new",i=o||!e?null:e,[l,c]=y.useState(""),[u,d]=y.useState(""),[f,h]=y.useState(!1),[p,m]=y.useState(!1),[v,b]=y.useState(null),[x,S]=y.useState(!1),[k,C]=y.useState(!1);y.useEffect(()=>{if(e){if(e==="new"){c(""),d(""),S(!1),b(null),C(!1),h(!1);return}c(e.name),S(!1),b(null),C(!1),h(!0),window.electronAPI.instructions.read(e.id,e.local,e.sourcePath).then(j=>{j.ok?d(j.content):(d(""),b(j.error??n("Failed to read content")))}).finally(()=>h(!1))}},[e,n]);const A=!!(i&&!i.local&&i.sourcePath),N=async()=>{if(!e||!l.trim())return;if(m(!0),o){const I=crypto.randomUUID(),_=await window.electronAPI.instructions.write(I,u);if(!_.ok){m(!1),b(n("Failed to save"));return}const L=r([{id:I,name:l.trim(),source:"Manual",local:!0,bytes:_.bytes,enabled:!0}]);if(m(!1),L===0){window.electronAPI.instructions.delete(I),b(n("An instruction with this name already exists"));return}t();return}if(!i){m(!1);return}if(A&&k&&i.sourcePath){const I=await window.electronAPI.instructions.writeSource(i.id,i.sourcePath,u);if(m(!1),!I.ok){b(I.error??n("Failed to save"));return}s(i.id,{name:l.trim(),bytes:I.bytes}),t();return}const j=await window.electronAPI.instructions.write(i.id,u);if(m(!1),!j.ok){b(n("Failed to save"));return}s(i.id,{name:l.trim(),local:!0,bytes:j.bytes}),t()};return a.jsx(gr,{open:e!==null,onOpenChange:j=>!j&&t(),children:a.jsxs(vr,{className:"max-w-2xl",children:[a.jsx(xr,{children:a.jsx(dr,{children:n(o?"Add Instruction":"Edit Instruction")})}),a.jsxs(rr,{className:"space-y-4",children:[o?null:A?a.jsxs("div",{className:ve("w-full rounded-md px-3 py-2.5 transition-colors",k?"bg-destructive/8":"bg-amber-500/8"),children:[a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[k?a.jsx(Nd,{className:"h-3.5 w-3.5 shrink-0 text-destructive"}):a.jsx(vg,{className:"h-3.5 w-3.5 shrink-0 text-amber-600 dark:text-amber-500"}),a.jsx("span",{className:"font-medium text-xs",children:n("Write back to original file")})]}),a.jsx(Xi,{checked:k,onCheckedChange:C})]}),a.jsx("p",{className:"mt-1.5 pl-5.5 text-muted-foreground text-xs leading-relaxed",children:k?n("Saving overwrites {{path}} directly — {{source}} will pick up the change.",{path:i?.sourcePath??"",source:i?.source??""}):n("Saving creates a local copy — {{path}} is left untouched, and this entry stops following its updates.",{path:i?.sourcePath??""})})]}):a.jsxs("div",{className:"flex w-full items-start gap-2 rounded-md bg-muted/50 px-3 py-2",children:[a.jsx(vg,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),a.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:n("Local copy — edits stay in this app.")})]}),a.jsxs(Tr,{children:[a.jsx(jr,{children:n("Name")}),a.jsx(En,{value:l,onChange:j=>c(j.target.value)})]}),a.jsxs(Tr,{children:[a.jsx(jr,{children:n("Content")}),f?a.jsxs("div",{className:"flex w-full items-center justify-center gap-2 py-12",children:[a.jsx(Jn,{className:"h-4 w-4 animate-spin text-muted-foreground"}),a.jsx("span",{className:"text-muted-foreground text-xs",children:n("Loading...")})]}):a.jsx(_i,{value:u,onChange:j=>{d(j.target.value),S(!0)},rows:16,className:"font-mono text-xs"})]}),v&&a.jsxs("p",{className:"flex items-center gap-1.5 text-destructive text-xs",children:[a.jsx(qa,{className:"h-3.5 w-3.5 shrink-0"}),v]})]}),a.jsxs(Wr,{children:[a.jsx(Ke,{variant:"outline",size:"sm",onClick:t,children:n("Cancel")}),a.jsxs(Ke,{size:"sm",variant:A&&k?"destructive":"default",disabled:!l.trim()||f||p,onClick:N,children:[p&&a.jsx(Jn,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),n(A?k?"Overwrite original":x?"Save as local copy":"Save":"Save")]})]})]})})}const nfe=e=>e<1024?`${e} B`:`${(e/1024).toFixed(1)} KB`;function TGt(){const{t:e}=Se(),t=be(f=>f.instructions),n=be(f=>f.updateInstruction),r=be(f=>f.removeInstruction),[s,o]=y.useState(!1),[i,l]=y.useState(null),c=t.map(f=>f.id),u=xL(c,f=>window.electronAPI.assets.instructionOccupancy(f)),d=mL(t.filter(f=>f.enabled).map(f=>f.id),u.rows);return a.jsxs(yi,{rowId:"instructions.root",title:a.jsxs(a.Fragment,{children:[e("Instruction Files"),a.jsx(vL,{tokens:d}),a.jsx(Df,{})]}),description:e("Global CLAUDE.md / AGENTS.md style files from local AI tools"),actions:a.jsxs(a.Fragment,{children:[a.jsxs(fn,{onClick:()=>o(!0),children:[a.jsx(QA,{className:"h-4 w-4"}),e("Import from local apps")]}),a.jsxs(fn,{onClick:()=>l("new"),children:[a.jsx(xs,{className:"h-4 w-4"}),e("Add instruction")]})]}),children:[a.jsx("p",{className:"mt-1 text-[12px] text-muted-foreground",children:e("Only one file is active at a time; enabling one disables the others")}),a.jsx(Xn,{children:t.length===0?a.jsxs("div",{className:"border-border border-b py-8 text-center",children:[a.jsx(Kp,{className:"mx-auto h-5 w-5 text-muted-foreground"}),a.jsx("p",{className:"mt-3 font-medium text-[13px]",children:e("No instruction files yet")}),a.jsx("p",{className:"mt-1 text-muted-foreground text-xs",children:e("Import instruction files from local apps or add one manually to get started")})]}):t.map(f=>a.jsxs(jn,{rowId:`instructions.${f.id}`,label:a.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[a.jsx("span",{className:ve(!f.enabled&&"text-muted-foreground line-through"),children:f.name}),a.jsx($n,{variant:"secondary",className:"text-[11px]",children:f.source}),!f.local&&a.jsxs($n,{variant:"outline",className:"gap-1 text-[11px]",children:[a.jsx(kxe,{className:"h-3 w-3"}),e("Linked")]})]}),description:a.jsx("span",{className:"block truncate",children:f.local?`${e("Local copy")} · ${nfe(f.bytes)}`:`${f.sourcePath} · ${nfe(f.bytes)}`}),status:a.jsx(gL,{row:u.rows[f.id],pending:u.pending&&!u.rows[f.id]}),children:[a.jsx($r,{checked:f.enabled,onCheckedChange:h=>n(f.id,{enabled:h})}),a.jsx(Ke,{variant:"ghost",size:"icon-sm","aria-label":e("Edit"),className:"text-muted-foreground",onClick:()=>l(f),children:a.jsx(Pi,{className:"h-3.5 w-3.5"})}),a.jsx(Ke,{variant:"ghost",size:"icon-sm","aria-label":e("Delete"),className:"text-muted-foreground hover:text-destructive-text",onClick:()=>r(f.id),children:a.jsx(io,{className:"h-3.5 w-3.5"})})]},f.id))}),a.jsx(pL,{kind:"instruction",open:s,onOpenChange:o}),a.jsx(EGt,{instruction:i,onClose:()=>l(null)})]})}const AGt=(e,t)=>`plugin:${e}:${t}`;function uMe(e,t,n){const r=new Map;for(const[i,l]of Object.entries(n))l&&r.set(l,i);const s=new Map;return{rows:e.map(i=>{const l=AGt(i.pluginId,i.id),c=t[l]!==void 0,u=c?t[l]:i.key??"",d=u?r.get(u):void 0;return u&&!d&&(r.set(u,l),s.set(u,i)),{action:l,command:i,binding:u,custom:c,...d?{conflict:d}:{}}}),byBinding:s}}const dMe="relative inline-flex h-(--settings-control-h) min-w-14 items-center justify-center rounded-md px-1.5 transition-colors";function i4({title:e,onClick:t,children:n}){return a.jsx(Ke,{size:"icon-xs",variant:"ghost",title:e,onClick:t,className:"text-muted-foreground hover:text-foreground pointer-coarse:size-[44px]",children:n})}function NGt(){const{t:e}=Se();return a.jsxs(yi,{rowId:"shortcuts.root",title:e("Shortcuts"),description:e("Click a shortcut to rebind it. Backspace removes it; Esc cancels."),children:[a.jsx(RGt,{}),a.jsx(jGt,{})]})}function IGt(){const[e,t]=y.useState([]);return y.useEffect(()=>{const n=window.electronAPI.extensionPlugins;let r=!0;const s=()=>{n.list().then(i=>r&&t(Sje(i)))};s();const o=n.onChanged(s);return()=>{r=!1,o()}},[]),e}function jGt(){const{t:e}=Se(),t=IGt(),n=be(m=>m.keybindings),r=be(m=>m.setKeybinding),s=be(m=>m.resetKeybinding),[o,i]=y.useState(null),[l,c]=y.useState(null);if(t.length===0)return null;const u=Rh(n),{rows:d}=uMe(t,n,u),f=m=>d.find(v=>v.action===m)?.command.title??e(NH[m]??m),h=()=>{i(null),c(null)},p=(m,v,b)=>{if(m.preventDefault(),m.stopPropagation(),m.key==="Escape")return h();if(m.key==="Backspace"||m.key==="Delete")return r(v,""),h();const x=Yv(m);if(!x)return;const S=AH.find(k=>u[k]===x)??d.find(k=>k.action!==v&&!k.conflict&&k.binding===x)?.action;if(S)return c(S);x===b?s(v):r(v,x),h()};return a.jsx(Xn,{title:"插件命令",children:d.map(({action:m,command:v,binding:b,custom:x,conflict:S})=>{const k=o===m;return a.jsxs(jn,{label:v.title,description:a.jsxs(a.Fragment,{children:[v.pluginName,S&&!k&&a.jsx("span",{className:"ml-2 text-destructive-text",children:e('Already used by "{{label}}"',{label:f(S)})})]}),status:k&&l&&a.jsx("span",{className:"text-[12px] text-destructive-text",children:e('Already used by "{{label}}"',{label:f(l)})}),children:[b&&!k&&a.jsx(i4,{title:e("Remove shortcut"),onClick:()=>r(m,""),children:a.jsx(Jr,{className:"h-3.5 w-3.5"})}),x&&!k&&a.jsx(i4,{title:e("Reset to default"),onClick:()=>s(m),children:a.jsx($u,{className:"h-3.5 w-3.5"})}),a.jsx("button",{type:"button",onClick:()=>{i(m),c(null)},onKeyDown:k?C=>p(C,m,v.key):void 0,onBlur:()=>k&&h(),autoFocus:k,className:ve(dMe,k?"ring-1 ring-ring":"hover:bg-muted",S&&!k&&"opacity-50 line-through"),children:k?a.jsx("span",{className:"text-muted-foreground text-xs",children:e("Press shortcut…")}):b?a.jsx(Ed,{children:Fd(b)}):a.jsx("span",{className:"text-muted-foreground text-xs",children:e("No shortcut")})})]},m)})})}function RGt(){const{t:e}=Se(),t=be(d=>d.keybindings),n=be(d=>d.setKeybinding),r=be(d=>d.resetKeybinding),[s,o]=y.useState(null),[i,l]=y.useState(null),c=Rh(t),u=d=>{if(d.preventDefault(),d.stopPropagation(),!s)return;if(d.key==="Escape"){o(null),l(null);return}if(d.key==="Backspace"||d.key==="Delete"){n(s,""),o(null),l(null);return}const f=Yv(d,{allowBare:s==="send-message"});if(!f)return;const h=AH.find(p=>p!==s&&c[p]===f);if(h){l(h);return}f===u2e[s]?r(s):n(s,f),o(null),l(null)};return a.jsx(Xn,{children:AH.map(d=>{const f=s===d,h=t[d]!==void 0,p=c[d],m=oct[d];return a.jsxs(jn,{label:e(NH[d]),description:m&&e(m),status:f&&i&&a.jsx("span",{className:"text-[12px] text-destructive-text",children:e('Already used by "{{label}}"',{label:e(NH[i])})}),children:[p&&!f&&a.jsx(i4,{title:e("Remove shortcut"),onClick:()=>n(d,""),children:a.jsx(Jr,{className:"h-3.5 w-3.5"})}),h&&!f&&a.jsx(i4,{title:e("Reset to default"),onClick:()=>r(d),children:a.jsx($u,{className:"h-3.5 w-3.5"})}),a.jsx("button",{type:"button",onClick:()=>{o(d),l(null)},onKeyDown:f?u:void 0,onBlur:()=>{f&&(o(null),l(null))},autoFocus:f,className:ve(dMe,f?"ring-1 ring-ring":"hover:bg-muted"),children:f?a.jsx("span",{className:"text-xs text-muted-foreground",children:e("Press shortcut…")}):p?a.jsx(Ed,{children:Fd(p)}):a.jsx("span",{className:"text-xs text-muted-foreground",children:e("No shortcut")})})]},d)})})}const rfe=[1,6,24,72,168],MGt=24;function _Gt(){const{t:e}=Se();if(Mh())return null;const t=async()=>{try{const n=await window.electronAPI.window.openDevTools();if(n.ok)return;Ht({type:"error",title:e("Could not open developer tools"),description:n.error==="main-window-unavailable"?e("The main window is closed. Open it and try again."):n.error})}catch(n){Ht({type:"error",title:e("Could not open developer tools"),description:n instanceof Error?n.message:String(n)})}};return a.jsx(jn,{rowId:"logs.devTools",label:e("Developer tools"),description:e("Open the console of the main window to see errors and logs."),children:a.jsx(fn,{onClick:()=>{t()},children:e("Open")})})}const PGt={main:"Main process",agent:"Agent worker",plugin:"Plugin",mcp:"MCP"},LGt={main:"bg-sky-500/10 text-sky-600 dark:text-sky-400",agent:"bg-violet-500/10 text-violet-600 dark:text-violet-400",plugin:"bg-amber-500/10 text-amber-600 dark:text-amber-400",mcp:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400"},OGt={1:"Last hour",6:"Last 6 hours",24:"Last 24 hours",72:"Last 3 days",168:"Last 7 days"};function DGt(){const{t:e}=Se();return a.jsxs(yi,{title:e("Logs"),description:e("Recent errors and log export. API keys, tokens and passwords are masked."),children:[a.jsx(BGt,{}),a.jsx(FGt,{}),a.jsx(zGt,{}),a.jsx(Xn,{title:e("Troubleshooting"),children:a.jsx(_Gt,{})})]})}function BGt(){const{t:e}=Se(),t=be(o=>o.appLoggingEnabled===!0),n=be(o=>o.setAppLoggingEnabled),r=be(o=>o.pluginLoggingEnabled===!0),s=be(o=>o.setPluginLoggingEnabled);return a.jsxs(Xn,{children:[a.jsx(jn,{label:e("Record app logs"),description:e("Off by default. Write main process and agent logs to disk. Files needed for restart recovery are always kept."),children:a.jsx($r,{checked:t,onCheckedChange:n})}),a.jsx(jn,{label:e("Record plugin logs"),description:e("Off by default. Record plugin console output and runtime logs to disk. Startup failures and crashes are still shown."),children:a.jsx($r,{checked:r,onCheckedChange:s})})]})}function FGt(){const{t:e}=Se(),t=be(p=>p.appLoggingEnabled===!0),n=be(p=>p.setAppLoggingEnabled),[r,s]=y.useState("error"),[o,i]=y.useState(null),[l,c]=y.useState(!1),[u,d]=y.useState(null),f=y.useRef(0),h=y.useCallback(async p=>{const m=++f.current;c(!0);try{const v=await window.electronAPI.logs.errors(p);if(f.current!==m)return;i(v.map((b,x)=>({key:`${x}:${b.time}`,entry:b}))),d(null)}catch{if(f.current!==m)return;i([])}finally{f.current===m&&c(!1)}},[]);return y.useEffect(()=>{h(r)},[r,h]),a.jsxs(Xn,{title:e("Recent errors"),actions:a.jsxs(a.Fragment,{children:[a.jsx(nX,{"aria-label":e("Recent errors"),value:r,onValueChange:s,options:[{value:"error",label:e("Errors only")},{value:"warn",label:e("Warnings and errors")}]}),a.jsx(fn,{"aria-label":e("Refresh"),disabled:l,onClick:()=>{h(r)},children:a.jsx(bo,{className:ve("h-3.5 w-3.5",l&&"animate-spin")})})]}),children:[!t&&a.jsx(jn,{label:e("App logging is off"),description:e("New app logs are not recorded while off. Existing logs are kept below."),children:a.jsx(fn,{onClick:()=>n(!0),children:e("Enable app logging")})}),o&&o.length===0?a.jsx("p",{className:"border-border border-b py-6 text-center text-[13px] text-muted-foreground",children:e("No errors recorded.")}):a.jsx("ul",{children:(o??[]).map(({key:p,entry:m})=>{const v=u===p;return a.jsxs("li",{className:"border-border border-b",children:[a.jsxs("button",{type:"button",className:"-mx-2 flex min-h-[44px] w-[calc(100%+1rem)] items-center gap-2 rounded-md px-2 py-2 text-left text-[13px] hover:bg-accent/50","aria-expanded":v,onClick:()=>d(v?null:p),children:[a.jsx(Bs,{className:ve("h-3.5 w-3.5 shrink-0 transition-transform",v&&"rotate-90")}),a.jsx("span",{className:"shrink-0 tabular-nums text-xs text-muted-foreground",children:new Date(m.time).toLocaleString()}),a.jsx("span",{className:ve("shrink-0 rounded px-1.5 py-0.5 text-xs",LGt[m.source]),children:e(PGt[m.source])}),m.level==="warn"&&a.jsx("span",{className:"shrink-0 text-xs text-amber-600 dark:text-amber-400",children:e("Warning")}),a.jsx("span",{className:"min-w-0 flex-1 truncate",children:m.message})]}),v&&a.jsx("pre",{className:"mb-3 max-h-72 overflow-auto whitespace-pre-wrap break-all rounded-md bg-muted/40 px-3 py-2 font-mono text-xs",children:m.detail})]},p)})})]})}function zGt(){const{t:e}=Se(),t=be(l=>l.appLoggingEnabled===!0),[n,r]=y.useState(MGt),[s,o]=y.useState(!1),i=async()=>{o(!0);try{const l=await window.electronAPI.logs.export(n);l.ok?l.cancelled||Ht({type:"success",title:e("Logs exported"),description:l.path,actions:[{label:e("Show in folder"),onClick:()=>{window.electronAPI.logs.revealExport()}}]}):Ht({type:"error",title:e("Log export failed"),description:l.error})}finally{o(!1)}};return a.jsx(Xn,{title:e("Export logs"),description:e("Pack logs from the selected period into a zip file for troubleshooting."),children:a.jsxs(jn,{label:e("Time range"),description:t?void 0:e("App logging is off. The export only includes logs recorded earlier."),children:[a.jsx(Zo,{value:String(n),onValueChange:l=>{const c=rfe.find(u=>String(u)===l);c&&r(c)},options:rfe.map(l=>({value:String(l),label:e(OGt[l])}))}),a.jsxs(fn,{variant:"default",disabled:s,onClick:()=>{i()},children:[a.jsx(Lf,{className:"h-3.5 w-3.5"}),e(s?"Exporting...":"Export")]})]})})}function HGt(e){return e.serverId??e.serverName}function fMe(e,t){const n={...e};return t.serverId&&delete n[t.serverName],n[HGt(t)]={state:t.state,...t.toolCount!==void 0?{toolCount:t.toolCount}:{},...t.error?{error:t.error}:{}},n}function UGt(e){return e.reduce((t,n)=>fMe(t,n),{})}function VGt(e,t){return{...e,[t]:{state:"connecting"}}}function GGt(e,t,n){return{...e,[t]:{state:"error",...n?{error:n}:{}}}}const C7=(e,t)=>{const n={...e};return delete n[t],n},vb=di()((e,t)=>({statuses:{},authorized:{},pending:{},bind:()=>(window.electronAPI.mcp.authState().then(n=>e({authorized:n})).catch(()=>{}),window.electronAPI.mcp.statusSnapshot().then(n=>e({statuses:{...t().statuses,...UGt(n)}})).catch(()=>{}),window.electronAPI.mcp.onStatus(n=>{if(n.type==="mcp-status-cleared"){e({statuses:{}});return}e({statuses:fMe(t().statuses,n)}),window.electronAPI.mcp.authState().then(r=>e({authorized:r})).catch(()=>{})})),authorize:async n=>{e({statuses:VGt(t().statuses,n),pending:{...t().pending,[n]:!0}});let r;try{r=await window.electronAPI.mcp.authorize(n)}catch(s){r={ok:!1,error:s instanceof Error?s.message:String(s)}}e({pending:C7(t().pending,n),...r.ok?{authorized:{...t().authorized,[n]:!0}}:{statuses:GGt(t().statuses,n,r.error)}})},revoke:async n=>{await window.electronAPI.mcp.revoke(n),e({authorized:C7(t().authorized,n),statuses:C7(t().statuses,n)})}})),Hp=e=>typeof e=="string"?e.trim():"",WGt=e=>Array.isArray(e)?e.filter(t=>typeof t=="string"):[],hMe=e=>{if(!e||typeof e!="object")return{};const t={};for(const[n,r]of Object.entries(e))typeof r=="string"&&(t[n]=r);return t};function qGt(e){const t=hMe(e);return delete t[""],Object.keys(t).length>0?t:void 0}function sfe(e){const t={};for(const n of e.split(`
787
+ `;return typeof l=="function"&&l(null,b),b},k7}var Wde;function bVt(){if(Wde)return tw;Wde=1;const e=JUt(),t=gVt(),n=vVt(),r=xVt();function s(o,i,l,c,u){const d=[].slice.call(arguments,1),f=d.length,h=typeof d[f-1]=="function";if(!h&&!e())throw new Error("Callback required as last argument");if(h){if(f<2)throw new Error("Too few arguments provided");f===2?(u=l,l=i,i=c=void 0):f===3&&(i.getContext&&typeof u>"u"?(u=c,c=void 0):(u=c,c=l,l=i,i=void 0))}else{if(f<1)throw new Error("Too few arguments provided");return f===1?(l=i,i=c=void 0):f===2&&!i.getContext&&(c=l,l=i,i=void 0),new Promise(function(p,m){try{const v=t.create(l,c);p(o(v,i,c))}catch(v){m(v)}})}try{const p=t.create(l,c);u(null,o(p,i,c))}catch(p){u(p)}}return tw.create=t.create,tw.toCanvas=s.bind(null,n.render),tw.toDataURL=s.bind(null,n.renderToDataURL),tw.toString=s.bind(null,function(o,i,l){return r.render(o,l)}),tw}var yVt=bVt();const rMe=Oy(yVt);function wVt(e,t){const n=t.trim();if(n.length===0||n.length>512||n.startsWith("/")||n.startsWith("\\")||n.includes("\\")||n.includes("\0")||n.includes("?")||n.includes("#")||/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(n))return null;const r=EJ(e)&&e!=="."?e:e.split("/").pop()??"",s=r.lastIndexOf("/"),o=s===-1?"":r.slice(0,s),i=o?`${o}/${n}`:n,l=[];for(const u of i.split("/"))if(!(u===""||u===".")){if(u===".."){if(l.length===0)return null;l.pop();continue}l.push(u)}const c=l.join("/");return!c||!EJ(c)?null:c}function qde(e,t){const n=new RegExp(`\\b${t}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s"'=<>]+))`,"i").exec(e);return n?n[1]??n[2]??n[3]??"":null}function kVt(e,t,n){return e.replace(new RegExp(`\\b${t}\\s*=\\s*(?:"[^"]*"|'[^']*'|[^\\s"'=<>]+)`,"i"),`${t}="${n}"`)}function SVt(e){return e?.trim().toLowerCase().split(/\s+/).includes("stylesheet")??!1}function CVt(e){try{return new TextDecoder().decode(Uint8Array.from(atob(e),t=>t.charCodeAt(0)))}catch{return null}}function EVt(e,t){const n=[],r=(s,o,i,l)=>{const c=o[1]??"";if(!l(c))return;const u=qde(c,i);if(u===null)return;const d=wVt(t,u);d&&n.push({start:o.index,end:o.index+o[0].length,kind:s,rel:d,attrs:c,full:o[0]})};for(const s of e.matchAll(/<script\b([^>]*)>[\s\S]*?<\/script>/gi))r("script",s,"src",()=>!0);for(const s of e.matchAll(/<link\b([^>]*?)\/?>/gi))r("style",s,"href",o=>SVt(qde(o,"rel")));for(const s of e.matchAll(/<img\b([^>]*?)\/?>/gi))r("img",s,"src",()=>!0);return n.sort((s,o)=>s.start-o.start),n}async function TVt(e,t,n){const r=EVt(e,t),s=new Map;await Promise.all([...new Set(r.map(l=>l.rel))].map(async l=>{s.set(l,await n(l))}));let o=0,i="";for(const l of r){i+=e.slice(o,l.start),o=l.end;const c=s.get(l.rel);if(!c){i+=l.full;continue}if(l.kind==="img"){const d=c.mime||"application/octet-stream";i+=`<img${kVt(l.attrs,"src",`data:${d};base64,${c.base64}`)}>`;continue}const u=CVt(c.base64);if(u===null){i+=l.full;continue}i+=l.kind==="script"?`<script>${u.replace(/<\/script/gi,"<\\/script")}<\/script>`:`<style>${u.replace(/<\/style/gi,"<\\/style")}</style>`}return i+e.slice(o)}const AVt="plugin-view.html";function Yde(){return document.documentElement.classList.contains("dark")?"dark":"light"}function bcn({pluginId:e,viewId:t,sessionId:n}){const{t:r}=Se(),s=qGe().find(o=>o.pluginId===e&&o.id===t);return s?a.jsx(sMe,{pluginId:e,entry:s.entry,title:s.title,sessionId:n}):a.jsx("div",{className:"flex h-full items-center justify-center p-6 text-sm text-muted-foreground",children:r("Plugin is not enabled")})}function sMe({pluginId:e,entry:t,title:n,sessionId:r,file:s}){const o=y.useRef(null),[i,l]=y.useState(null),c=y.useRef(r);c.current=r;const u=it(b=>r?b.conversations[r]?.projectId??null:null),d=y.useRef(u);d.current=u;const f=y.useRef(s);f.current=s;const h=y.useRef(null),p=y.useRef(null);y.useEffect(()=>{const b=o.current;if(!b)return;l(null);let x=!1,S=null;const k=()=>{try{S?.port1.postMessage(UGe(Yde()))}catch{}},C=new MutationObserver(k);C.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]});const A=window.electronAPI.extensionPlugins.onViewEvent(I=>{if(!(I.pluginId!==e||typeof I.name!="string"))try{S?.port1.postMessage(VGe(I.name,I.data))}catch{}}),N=zGe(async(I,_)=>{const L=await window.electronAPI.extensionPlugins.call({pluginId:e,method:"renderer.call",payload:{method:I,args:_},sessionId:c.current});if(!L.ok)throw new Error(L.error);return L.value}),j=async I=>{if(I.source!==b.contentWindow||I.data?.type!=="enso-view-ready")return;S?.port1.close();const _=new MessageChannel;S=_,h.current=_,_.port1.onmessage=R=>{const z=HGe(R.data);if(z){window.electronAPI.extensionPlugins.viewStateSet(e,z);return}const B=WGe(R.data);if(B!==null){p.current=B,f.current?.onEdit(B);return}N(R.data).then(H=>{H&&!x&&S===_&&_.port1.postMessage(H)})};const[L,M]=await Promise.all([window.electronAPI.extensionPlugins.asset(e,t),window.electronAPI.extensionPlugins.viewStateGet(e)]);if(x||S!==_)return;if(!L.ok){l(L.error);return}const F=await TVt(VW(L.base64),t,async R=>{const z=await window.electronAPI.extensionPlugins.asset(e,R);return z.ok?{mime:z.mime,base64:z.base64}:null});if(x||S!==_)return;const D=f.current;b.contentWindow?.postMessage({type:"enso-view-init",html:F,theme:Yde(),storage:M.ok?M.state:{},session:ute(c.current,d.current),...D?{file:{rel:D.rel,text:D.text}}:{}},"*",[_.port2])};return window.addEventListener("message",j),b.src=new URL(AVt,document.baseURI).href,()=>{x=!0,C.disconnect(),A(),window.removeEventListener("message",j),S?.port1.close(),h.current=null,b.removeAttribute("src")}},[e,t]),y.useEffect(()=>{try{h.current?.port1.postMessage(ute(r,u))}catch{}},[r,u]);const m=s?.rel,v=s?.text;return y.useEffect(()=>{if(!(m===void 0||v===void 0)){if(p.current===v){p.current=null;return}try{h.current?.port1.postMessage(GGe(m,v))}catch{}}},[m,v]),a.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[i&&a.jsx("div",{className:"shrink-0 px-3 py-2 text-xs text-destructive",children:i}),a.jsx("iframe",{ref:o,title:n,className:"min-h-0 w-full flex-1 border-0 bg-background"})]})}const NVt="1",nw="inline-flex items-center gap-1.5 rounded-lg border border-border px-2.5 py-1.5 text-[12.5px] transition-colors hover:bg-muted disabled:opacity-50",$de={network:"Cannot reach api.telegram.org. Check the proxy.",unauthorized:"Telegram rejected this token",api:"Telegram returned an error","token-required":"Paste a bot token first","not-group":"This chat is not a group","invalid-chat-id":"Group chat IDs are numbers, e.g. -1001234567890","invalid-topic":"Pick at least one topic","route-conflict":"Another secretary already has this group or one of these topics"};function IVt({checked:e,disabled:t,label:n,onClick:r,enso:s}){return a.jsxs("button",{type:"button",role:"checkbox","aria-checked":e,"data-enso":s,disabled:t,onClick:r,className:"flex items-center gap-1.5 text-left text-[12px] disabled:opacity-50",children:[a.jsx("span",{className:ve("flex size-3.5 shrink-0 items-center justify-center rounded ring-1 ring-border",e&&"bg-foreground text-background ring-foreground"),children:e&&a.jsx(Is,{className:"size-2.5"})}),n]})}function Kde({checked:e,disabled:t,label:n,onClick:r,enso:s}){return a.jsx("button",{type:"button",role:"radio","aria-checked":e,"data-enso":s,disabled:t,onClick:r,className:ve("rounded-md px-2 py-0.5 text-[11.5px] transition-colors disabled:opacity-50",e?"bg-foreground text-background":"text-muted-foreground hover:bg-muted"),children:n})}function jVt({group:e,secretaryId:t,busy:n,onRemove:r,onSaved:s}){const{t:o}=Se(),[i,l]=y.useState(!1),[c,u]=y.useState({state:"idle"}),[d,f]=y.useState(e.topics.map(L=>L.id)),[h,p]=y.useState(!1),[m,v]=y.useState(null),b=L=>L.id===NVt?o("General (default topic)"):L.title??o("Topic #{{id}}",{id:L.id}),x=(L,M)=>{const F=o($de[L]??$de.api),D=L==="api"?` ${o("Make sure the bot is in this group.")}`:"";return`${F}${M?`: ${M}`:""}${D}`},S=()=>{u({state:"loading"}),window.electronAPI.secretary.contactTelegramTopics(e.id,t).then(L=>u(L.ok?{state:"ready",forum:L.forum,topics:L.topics}:{state:"error",error:L.error,...L.detail?{detail:L.detail}:{}}),()=>u({state:"error",error:"api"}))},k=()=>{f(e.topics.map(L=>L.id)),v(null),l(!0),S()},C=L=>{p(!0),v(null),window.electronAPI.secretary.contactSettings({telegramGroupScope:{chatId:e.id,scope:L}},t).then(M=>{M.ok?(l(!1),s()):v(M.error)},()=>v("api")).finally(()=>p(!1))},A=()=>{i&&l(!1),e.all||C("all")},N=e.title??e.id,j=c.state==="ready"?[...c.topics,...e.topics.filter(L=>!c.topics.some(M=>M.id===L.id))]:[],I=n||h,_=i||!e.all;return a.jsxs("li",{"data-enso":"secretary-contact-group",className:"flex flex-col gap-1.5",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsx("span",{"data-enso":"secretary-contact-group-name",className:"min-w-0 flex-1 truncate text-[12px]",children:e.title?a.jsxs(a.Fragment,{children:[e.title," ",a.jsx("span",{className:"font-mono text-[11px] text-muted-foreground",children:e.id})]}):a.jsx("span",{className:"font-mono text-[11.5px]",children:e.id})}),a.jsxs("div",{role:"radiogroup","aria-label":o("What {{name}} hands to this secretary",{name:N}),className:"inline-flex shrink-0 rounded-lg bg-muted p-0.5",children:[a.jsx(Kde,{enso:"secretary-contact-scope-all",checked:!_,disabled:I,label:o("Whole group"),onClick:A}),a.jsx(Kde,{enso:"secretary-contact-scope-topics",checked:_,disabled:I,label:o("Pick topics"),onClick:()=>{i||k()}})]}),a.jsx("button",{type:"button","data-enso":"secretary-contact-group-remove",disabled:n,"aria-label":o("Remove {{name}}",{name:N}),className:nw,onClick:r,children:a.jsx(Jr,{className:"size-3.5"})})]}),!e.all&&!i&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("span",{"data-enso":"secretary-contact-group-scope",className:"min-w-0 flex-1 truncate text-[11.5px] text-muted-foreground",children:o("Topics: {{names}}",{names:e.topics.map(b).join(", ")})}),a.jsxs("button",{type:"button","data-enso":"secretary-contact-group-topics",disabled:n,className:nw,onClick:k,children:[a.jsx(HHe,{className:"size-3.5"}),o("Change topics")]})]}),m&&!i&&a.jsx("p",{className:"text-[11.5px] text-destructive",children:x(m)}),i&&a.jsxs("div",{"data-enso":"secretary-contact-group-picker",className:"flex flex-col gap-1.5 rounded-lg bg-muted/40 px-2.5 py-2",children:[c.state==="loading"&&a.jsxs("p",{className:"flex items-center gap-1.5 text-[11.5px] text-muted-foreground",children:[a.jsx(Jn,{className:"size-3.5 animate-spin"}),o("Loading topics…")]}),c.state==="error"&&a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[a.jsx("p",{"data-enso":"secretary-contact-topics-error",className:"min-w-0 flex-1 text-[11.5px] text-destructive",children:o("Could not load topics: {{reason}}",{reason:x(c.error,c.detail)})}),a.jsxs("button",{type:"button","data-enso":"secretary-contact-topics-retry",className:nw,onClick:S,children:[a.jsx(bo,{className:"size-3.5"}),o("Retry")]})]}),c.state==="ready"&&(c.forum?a.jsxs(a.Fragment,{children:[j.map(L=>a.jsx(IVt,{enso:"secretary-contact-topic",checked:d.includes(L.id),disabled:I||!!L.owner&&!d.includes(L.id),label:L.owner?`${b(L)} · ${o("taken by {{owner}}",{owner:L.owner})}`:b(L),onClick:()=>f(M=>M.includes(L.id)?M.filter(F=>F!==L.id):[...M,L.id])},L.id)),a.jsx("p",{className:"text-[11px] text-subtle-foreground",children:o("Only topics the bot has seen are listed. If one is missing, send a message in that topic, then refresh. Topics you leave unchecked are ignored.")})]}):a.jsx("p",{className:"text-[11.5px] text-muted-foreground",children:o("This group has no topics, so it can only be bound as a whole.")})),m&&a.jsx("p",{className:"text-[11.5px] text-destructive",children:x(m)}),a.jsxs("div",{className:"flex gap-1.5",children:[c.state==="ready"&&c.forum&&a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button","data-enso":"secretary-contact-scope-save",disabled:I||d.length===0,className:nw,onClick:()=>C(d),children:[a.jsx(Is,{className:"size-3.5"}),o("Save")]}),a.jsxs("button",{type:"button","data-enso":"secretary-contact-topics-refresh",disabled:I,className:nw,onClick:S,children:[a.jsx(bo,{className:"size-3.5"}),o("Refresh")]})]}),a.jsx("button",{type:"button","data-enso":"secretary-contact-topics-cancel",disabled:h,className:nw,onClick:()=>l(!1),children:o("Cancel")})]})]})]})}const RVt="border-border border-b py-3",Xde="inline-flex items-center gap-1.5 rounded-lg border border-border px-2.5 py-1.5 text-[12.5px] transition-colors hover:bg-muted disabled:opacity-50",MVt="inline-flex items-center gap-1.5 rounded-lg bg-muted px-2.5 py-1.5 text-[12.5px] text-foreground transition-colors hover:bg-muted/80";function _Vt(e){return e?.find(t=>!t.self&&t.privateChat)?.name??null}const PVt={"private-owned":'Your private chat with this bot already belongs to secretary "{{owner}}". One person has only one private chat with a bot, so bind this secretary to a group or forum topic below, or give it a different bot.',"route-conflict":'That group or topic already belongs to secretary "{{owner}}". Send the code in another group or topic.',expired:"The code expired. Generate a new one.","missing-code":"The bot got /start without the code. Open the bot with the button or QR code (the link carries the code), or send /start {{code}} yourself."};function LVt({bind:e}){const{t}=Se(),n=e.rejected;return n?a.jsxs("p",{"data-enso":"secretary-contact-bind-rejected","data-reason":n.reason,className:"mt-2 flex gap-1.5 rounded-lg bg-warning/10 px-2.5 py-2 text-[11.5px] text-warning",children:[a.jsx(Nd,{className:"mt-px size-3.5 shrink-0"}),a.jsx("span",{children:t(PVt[n.reason],{owner:n.owner??"",code:e.code})})]}):null}function OVt({bind:e,bot:t,now:n,busy:r,onNewCode:s,onCopied:o}){const{t:i}=Se(),l=e?e.expiresAt<=n:!1,c=e?Math.max(0,Math.ceil((e.expiresAt-n)/6e4)):0,u=e?.topicCommand??(t?`/bind@${t} ${i("<code>")}`:null);return a.jsxs("ol",{"data-enso":"secretary-contact-bind-places",className:"mt-1.5 flex flex-col gap-1.5",children:[a.jsxs("li",{className:"flex flex-col gap-1 text-[11.5px] text-muted-foreground",children:[a.jsxs("span",{children:[a.jsx("span",{className:"font-medium text-foreground",children:"1."})," ",i("Add the bot to the group: tap the button, or add @{{bot}} as a member in Telegram. For a forum group, turn on Topics first.",{bot:t??"bot"})]}),e?.groupLink&&a.jsxs("a",{"data-enso":"secretary-contact-group-link",href:e.groupLink,target:"_blank",rel:"noreferrer",className:`${MVt} self-start`,children:[a.jsx(dy,{className:"size-3.5"}),i("Add the bot to a group")]})]}),a.jsxs("li",{className:"flex flex-col gap-1 text-[11.5px] text-muted-foreground",children:[a.jsxs("span",{children:[a.jsx("span",{className:"font-medium text-foreground",children:"2."})," ",i("Send this in the group to hand the whole group to this secretary, or inside a forum topic to hand over only that topic:")]}),u?a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("code",{"data-enso":"secretary-contact-topic-command",className:"min-w-0 flex-1 truncate rounded bg-muted px-1.5 py-1 font-mono text-[11.5px] text-foreground",children:u}),e&&!l&&a.jsx("button",{type:"button","data-enso":"secretary-contact-copy-topic-command",className:Xde,"aria-label":i("Copy"),onClick:()=>{navigator.clipboard.writeText(e.topicCommand??""),o()},children:a.jsx(zd,{className:"size-3.5"})})]}):a.jsx("span",{className:"text-subtle-foreground",children:i("Verify a bot above first; the binding code shows up here.")}),e&&a.jsxs("span",{"data-enso":"secretary-contact-groups-code",className:l?"text-warning":"text-subtle-foreground",children:[i("Binding code of this secretary: {{code}}",{code:e.code})," ·"," ",l?i("This code has expired"):i("Valid for {{minutes}} more minutes",{minutes:c})]}),t&&(!e||l)&&a.jsxs("button",{type:"button","data-enso":"secretary-contact-groups-new-code",disabled:r,className:`${Xde} self-start text-foreground`,onClick:s,children:[a.jsx(J4,{className:"size-3.5"}),i(e?"New code":"Get a binding code")]})]}),a.jsxs("li",{className:"text-[11.5px] text-muted-foreground",children:[a.jsx("span",{className:"font-medium text-foreground",children:"3."})," ",i("Bound groups show up in the list of this section, where you can switch between the whole group and picked topics.")]})]})}function DVt({shared:e}){const{t}=Se(),n=(e??[]).filter(r=>!r.self).flatMap(r=>r.groups.map(s=>({owner:r.name,group:s})));return n.length===0?null:a.jsxs("div",{className:"mt-2",children:[a.jsx("p",{className:"text-[11.5px] text-muted-foreground",children:t("Claimed by other secretaries on this bot (read only):")}),a.jsx("ul",{className:"mt-1 flex flex-col gap-0.5",children:n.map(({owner:r,group:s})=>a.jsxs("li",{"data-enso":"secretary-contact-group-other",className:"flex items-center gap-1.5 text-[12px] text-muted-foreground",children:[a.jsx(KHe,{className:"size-3 shrink-0"}),a.jsx("span",{className:"min-w-0 flex-1 truncate",children:BVt(s,t)}),a.jsx("span",{className:"shrink-0 text-[11px]",children:t("belongs to {{owner}}",{owner:r})})]},`${r}:${s.id}`))})]})}function BVt(e,t){const n=e.title??e.id;if(e.all)return`${n} · ${t("Whole group")}`;const r=e.topics.map(s=>s.id==="1"?t("General (default topic)"):s.title??t("Topic #{{id}}",{id:s.id})).join(", ");return`${n} · ${t("Topics: {{names}}",{names:r})}`}function FVt({shared:e,bot:t}){const{t:n}=Se();return a.jsxs("div",{"data-enso":"secretary-contact-shared",className:RVt,children:[a.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] font-medium text-muted-foreground",children:[a.jsx(Uv,{className:"size-3.5"}),n("@{{bot}} is shared by {{count}} secretaries",{bot:t??"",count:e.length})]}),a.jsx("p",{className:"mt-1 text-[11.5px] text-muted-foreground",children:n("Each private chat, group or forum topic belongs to one secretary. A topic bound on its own wins over the whole group. Places nobody bound get no reply.")}),a.jsx("ul",{className:"mt-1.5 flex flex-col gap-1.5",children:e.map(r=>{const s=[...r.privateChat?[n("Private chat with @{{name}}",{name:r.privateChat.username??String(r.privateChat.id)})]:[],...r.groups.length>0?[n("Groups and topics: {{count}}",{count:r.groups.length})]:[]];return a.jsxs("li",{"data-enso":"secretary-contact-shared-user","data-self":r.self||void 0,className:"text-[12px]",children:[a.jsx("span",{className:"font-medium",children:r.name}),r.self&&a.jsxs("span",{className:"ml-1 text-[11px] text-muted-foreground",children:["(",n("this secretary"),")"]}),!r.enabled&&a.jsxs("span",{className:"ml-1 text-[11px] text-subtle-foreground",children:["· ",n("Telegram off")]}),s.length===0?a.jsx("p",{className:"text-[11.5px] text-subtle-foreground",children:n("Nothing bound yet")}):a.jsx("ul",{className:"text-[11.5px] text-muted-foreground",children:s.map(o=>a.jsxs("li",{className:"truncate",children:["· ",o]},o))})]},r.secretaryId)})})]})}const zVt="https://t.me/BotFather",HVt={"token-invalid":"That does not look like a bot token",network:"Cannot reach api.telegram.org. Check the proxy.",unauthorized:"Telegram rejected this token",api:"Telegram returned an error","token-required":"Paste a bot token first","not-bound":"Not bound yet","not-found":"That task is already gone","no-secretary":"No secretary conversation is available","deliver-failed":"Could not reach the secretary session","invalid-chat-id":"Group chat IDs are numbers, e.g. -1001234567890","channel-paused":"Pushes to this channel are paused after repeated failures","invalid sender":"Not allowed from this window","invalid-github-login":"That is not a GitHub login"},Zm="border-border border-b py-3",Yc="inline-flex items-center gap-1.5 rounded-lg border border-border px-2.5 py-1.5 text-[12.5px] transition-colors hover:bg-muted disabled:opacity-50",UVt="inline-flex items-center gap-1.5 rounded-lg bg-muted px-2.5 py-1.5 text-[12.5px] text-foreground transition-colors hover:bg-muted/80",yR="inline-flex items-center gap-1.5 rounded-lg bg-foreground px-2.5 py-1.5 text-[12.5px] font-medium text-background transition-opacity hover:opacity-90 disabled:opacity-50";function S7({index:e,label:t}){return a.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] font-medium text-muted-foreground",children:[a.jsx("span",{className:"flex size-4 items-center justify-center rounded-full bg-muted text-[10px] tabular-nums",children:e}),t]})}const VVt={unconfigured:"Not set up",pending:"Waiting to bind",connected:"Connected",error:"Error"},GVt={unconfigured:"bg-muted text-muted-foreground",pending:"bg-warning/15 text-warning",connected:"bg-success/15 text-success",error:"bg-destructive/15 text-destructive"},oMe="enso.secretary.contact.collapsed";function WVt(){try{const e=JSON.parse(window.localStorage.getItem(oMe)??"{}");return!e||typeof e!="object"||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,t])=>t===!0))}catch{return{}}}function qVt(e){try{window.localStorage.setItem(oMe,JSON.stringify(e))}catch{}}function YVt({outbound:e,busy:t,onRetry:n}){const{t:r,locale:s}=Se(),o=Date.now(),i=e.state==="paused",l=i&&e.pausedUntil!==void 0&&e.pausedUntil>o;return a.jsxs("div",{"data-enso":"secretary-contact-outbound","data-state":e.state,className:ve("border-l-2 px-2.5 py-2 text-[12px]",i?"border-warning bg-warning/5":"border-destructive bg-destructive/5"),children:[a.jsxs("div",{className:ve("flex items-center gap-1.5 font-medium",i?"text-warning":"text-destructive"),children:[i?a.jsx($Fe,{className:"size-3.5 shrink-0"}):a.jsx(Rf,{className:"size-3.5 shrink-0"}),i?r("Pushes paused: {{count}} sends failed in a row",{count:e.consecutiveFailures}):r("The last send failed ({{count}} in a row)",{count:e.consecutiveFailures})]}),e.userMessage&&a.jsx("p",{"data-enso":"secretary-contact-outbound-hint",className:"mt-1 text-[12.5px]",children:e.userMessage}),a.jsx("p",{className:"mt-1 text-[11.5px] text-muted-foreground",children:r("Last failure: {{time}}",{time:`${Yce(e.lastErrorAt,s)} (${Ig(e.lastErrorAt,s,o)})`})}),e.detail&&a.jsx("p",{"data-enso":"secretary-contact-outbound-detail",className:"mt-0.5 break-all font-mono text-[11px] text-muted-foreground",children:e.detail}),i&&a.jsxs("p",{className:"mt-1 text-[11.5px] text-muted-foreground",children:[l?r("Next try at {{time}}. A message from this channel or Retry now resumes pushes right away.",{time:Yce(e.pausedUntil??o,s)}):r("The next push will try again."),e.suppressedCount>0&&` ${r("{{count}} pushes held back.",{count:e.suppressedCount})}`]}),a.jsxs("button",{type:"button","data-enso":"secretary-contact-outbound-retry",disabled:t,className:ve(Yc,"mt-1.5"),onClick:n,children:[a.jsx(bo,{className:"size-3.5"}),r("Retry now")]}),a.jsx("span",{className:"ml-2 text-[11px] text-subtle-foreground",children:r("Sends a test message to this channel.")})]})}const $Vt="enso.telegram";function F3({label:e,hint:t,checked:n,disabled:r,dataEnso:s,onChange:o}){return a.jsx("div",{"data-enso":s,children:a.jsx(vo,{label:e,description:t,children:a.jsx($r,{checked:n,disabled:r,onCheckedChange:o})})})}function KVt({channel:e,collapsed:t,busy:n,onToggle:r,onPrefs:s,onRetry:o,children:i}){const{t:l}=Se(),c=e.id==="telegram",{prefs:u,caps:d}=e,f=[!d.buttons&&l("No buttons: questions and cards arrive as numbered text."),!d.edit&&l("Cannot edit sent messages: answered questions are not marked there."),!d.typing&&l("No typing indicator.")].filter(h=>typeof h=="string");return a.jsxs("div",{"data-enso":"secretary-contact-channel","data-channel":e.id,className:"border-border border-b",children:[a.jsxs("div",{className:"flex items-center gap-2 py-2",children:[a.jsxs("button",{type:"button","data-enso":"secretary-contact-channel-toggle","aria-expanded":!t,className:"flex min-w-0 flex-1 items-center gap-2 text-left",onClick:r,children:[t?a.jsx(Bs,{className:"size-3.5 shrink-0 text-muted-foreground"}):a.jsx(Ho,{className:"size-3.5 shrink-0 text-muted-foreground"}),e.pluginId?a.jsx(YP,{pluginId:e.pluginId,icon:e.icon,className:"size-4"}):a.jsx(zy,{className:"size-4 shrink-0"}),a.jsx("span",{className:"truncate text-[13px] font-medium",children:e.title}),a.jsx("span",{className:"shrink-0 rounded bg-muted px-1 text-[10.5px] text-muted-foreground",children:e.builtin?l("Built-in"):l("Plugin")}),a.jsx("span",{"data-enso":"secretary-contact-channel-status",className:ve("shrink-0 rounded px-1 text-[10.5px]",GVt[e.status]),children:l(VVt[e.status])}),e.outbound&&a.jsx("span",{"data-enso":"secretary-contact-channel-outbound",className:ve("shrink-0 rounded px-1 text-[10.5px]",e.outbound.state==="paused"?"bg-warning/15 text-warning":"bg-destructive/15 text-destructive"),children:e.outbound.state==="paused"?l("Pushes paused"):l("Send failed")})]}),a.jsx(Xi,{"data-enso":"secretary-contact-channel-enabled",checked:u.enabled,disabled:n,"aria-label":l("Enable {{name}}",{name:e.title}),onCheckedChange:h=>s({enabled:h})})]}),!t&&a.jsxs("div",{className:"flex flex-col gap-2 border-border border-t py-2.5",children:[e.detail&&e.status==="error"&&a.jsx("p",{className:"text-[11.5px] text-destructive",children:e.detail}),e.outbound&&a.jsx(YVt,{outbound:e.outbound,busy:n,onRetry:o}),a.jsx(F3,{dataEnso:"secretary-contact-push",label:l("Push to this channel"),hint:l("Milestones, questions from the secretary, cards and approval notices go out here."),checked:u.push,disabled:n,onChange:h=>s({push:h})}),a.jsx(F3,{dataEnso:c?"secretary-contact-allow-dispatch":"secretary-contact-card-confirm",label:l(c?"Allow confirming cards from Telegram":"Confirm cards from the phone"),hint:c?l("On by default. A tap on your phone can confirm settings, skill, tool, takeover and cleanup cards. Those cards change which projects the secretary sees, what it may take over, which skills and tools it installs and what it cleans up. Approvals are never handled from Telegram."):d.buttons?l("Off by default. Approvals are never handled from the phone."):l('Off by default. Reply "confirm 1" to confirm a card. Approvals are never handled from the phone.'),checked:u.cardConfirm,disabled:n,onChange:h=>s({cardConfirm:h})}),a.jsx(F3,{dataEnso:"secretary-contact-mirror",label:l("Mirror every reply"),hint:l("Off by default. Every reply in the secretary conversation is sent here, not just milestones."),checked:u.syncMirror,disabled:n,onChange:h=>s({syncMirror:h})}),a.jsx(F3,{dataEnso:c?"secretary-contact-allow-memory":"secretary-contact-memory",label:l(c?"Allow viewing memory titles on Telegram":"Allow viewing memory titles"),hint:l("Off by default. /memory lists titles only, never the memory text."),checked:u.memory,disabled:n,onChange:h=>s({memory:h})}),f.length>0&&a.jsx("ul",{"data-enso":"secretary-contact-limits",className:"flex flex-col gap-0.5 text-[11.5px] text-subtle-foreground",children:f.map(h=>a.jsxs("li",{children:["· ",h]},h))}),i]})]})}function XVt({owner:e,secretaryId:t,busy:n,error:r,run:s,showHeading:o=!0}){const{t:i}=Se(),l=e.githubLogins.join(", "),c=e.githubLogins.length>0,[u,d]=y.useState(l),[f,h]=y.useState(!1),[p,m]=y.useState(null);y.useEffect(()=>{f||d(l)},[l,f]),y.useEffect(()=>{if(c){m(null);return}const b=window.electronAPI.secretary.contactGithubSuggest;if(!b)return;let x=!0;return b().then(S=>{x&&m(S.login)}),()=>{x=!1}},[c]);const v=b=>{h(!0),d(x=>{const S=x.split(/[\s,]+/).filter(Boolean);return S.some(k=>k.toLowerCase()===b.toLowerCase())?x:S.length>0?`${S.join(", ")}, ${b}`:b})};return a.jsxs("div",{"data-enso":"secretary-contact-owner",className:Zm,children:[o&&a.jsx("div",{className:"text-[12.5px] font-medium",children:i("Owner identity")}),a.jsx("p",{className:ve("text-[11.5px] text-muted-foreground",o&&"mt-1"),children:i("GitHub accounts that count as you. Events from anyone else are left to the agent unless you require confirmation.")}),a.jsx("label",{className:"mt-2 block text-[12px] text-muted-foreground",htmlFor:"secretary-github-logins",children:i("GitHub accounts")}),a.jsx("input",{id:"secretary-github-logins","data-enso":"secretary-contact-github-logins",value:u,disabled:n,placeholder:i("Comma or space separated"),className:"mt-1 w-full rounded-lg border border-border bg-transparent px-2.5 py-1.5 font-mono text-[12px] outline-none focus:border-foreground/40",onChange:b=>{h(!0),d(b.target.value)}}),p&&a.jsxs("div",{className:"mt-1.5 flex items-center justify-between gap-2",children:[a.jsx("span",{className:"min-w-0 text-[11.5px] text-muted-foreground",children:i("Detected the gh login {{login}} on this machine",{login:p})}),a.jsx("button",{type:"button","data-enso":"secretary-contact-github-fill",disabled:n,className:Yc,onClick:()=>v(p),children:i("Fill in")})]}),a.jsx("button",{type:"button","data-enso":"secretary-contact-github-save",disabled:n,className:ve(yR,"mt-2"),onClick:()=>{const b=u.split(/[\s,]+/).map(x=>x.trim()).filter(Boolean);s(async()=>{const x=await window.electronAPI.secretary.contactSettings({githubLogins:b},t);return x.ok&&h(!1),x})},children:i("Save GitHub accounts")}),r==="invalid-github-login"&&a.jsx("p",{className:"mt-1 text-[11.5px] text-destructive",children:i("That is not a GitHub login")}),a.jsx("div",{className:"mt-3 text-[12px] text-muted-foreground",children:i("Messages that are not from you")}),a.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:[a.jsx("button",{type:"button","data-enso":"secretary-contact-external-agent","aria-pressed":!e.externalConfirm,disabled:n,className:ve(Yc,!e.externalConfirm&&"bg-muted"),onClick:()=>{e.externalConfirm&&s(()=>window.electronAPI.secretary.contactSettings({externalConfirm:!1},t))},children:i("Let the agent decide")}),a.jsx("button",{type:"button","data-enso":"secretary-contact-external-confirm","aria-pressed":e.externalConfirm,disabled:n,className:ve(Yc,e.externalConfirm&&"bg-muted"),onClick:()=>{e.externalConfirm||s(()=>window.electronAPI.secretary.contactSettings({externalConfirm:!0},t))},children:i("Require your confirmation")})]})]})}function Qde({checked:e,disabled:t,label:n,onCheckedChange:r}){const s=Bg();return a.jsx(Xi,{...s,"data-enso":"secretary-contact-enabled",checked:e,disabled:t,"aria-label":s["aria-labelledby"]?void 0:n,onCheckedChange:r})}function QVt({secretaryId:e,frames:t}={}){const{t:n}=Se(),[r,s]=y.useState(null),[o,i]=y.useState(""),[l,c]=y.useState(!1),[u,d]=y.useState(null),[f,h]=y.useState(null),[p,m]=y.useState(null),[v,b]=y.useState(WVt),[x,S]=y.useState([]),[k,C]=y.useState(""),[A,N]=y.useState(()=>Date.now());y.useEffect(()=>{const ue=window.electronAPI.extensionPlugins,xe=()=>{ue.list().then(S).catch(()=>S([]))};return xe(),ue.onChanged(xe)},[]);const j=ue=>{b(xe=>{const ge={...xe};return ge[ue]?delete ge[ue]:ge[ue]=!0,qVt(ge),ge})},I=y.useCallback(()=>{window.electronAPI.secretary.contactState(e).then(s)},[e]);y.useEffect(()=>(I(),window.electronAPI.secretary.onContactChanged(ue=>{e&&ue.secretaryId&&ue.secretaryId!==e||s(ue)})),[I,e]);const _=r?.telegram.bind?.expiresAt;y.useEffect(()=>{if(_===void 0)return;N(Date.now());const ue=window.setInterval(()=>N(Date.now()),15e3);return()=>window.clearInterval(ue)},[_]);const L=r?.telegram.bind?.link;y.useEffect(()=>{if(!L){m(null);return}let ue=!0;return rMe.toDataURL(L,{width:320,margin:1}).then(xe=>{ue&&m(xe)}).catch(()=>m(null)),()=>{ue=!1}},[L]);const M=ue=>{c(!0),d(null),h(null),ue().then(xe=>{xe.ok||d(xe.error??"api")}).finally(()=>{c(!1),I()})};if(!r)return null;const F=r.telegram,D=r.channels??[],R=x.some(ue=>ue.id===$Vt&&ue.state==="enabled"),z=(ue,xe)=>M(()=>window.electronAPI.secretary.contactSettings({channelId:ue,prefs:xe},e)),B=ue=>M(()=>window.electronAPI.secretary.contactTest(e,ue).then(xe=>{if(xe.ok)h(n("Test message sent"));else if(["api","network","unauthorized","channel-paused"].includes(xe.error))return{ok:!0};return xe})),H=F.poll.state==="error"||F.poll.state==="backoff",G=F.poll.state!=="stopped"&&F.poll.state!=="error",ne=u==="network"&&G?null:u,W=F.groups??[],T=k.trim(),U=(ue,xe)=>M(()=>window.electronAPI.secretary.contactSettings({telegramGroup:{action:ue,chatId:xe}},e).then(ge=>(ge.ok&&ue==="add"&&C(""),ge))),P=F.bind?Math.max(0,Math.ceil((F.bind.expiresAt-A)/6e4)):0,K=F.bind?F.bind.expiresAt<=A:!1,J=F.chat?null:_Vt(F.shared),ee=a.jsx(OVt,{bind:F.bind,bot:F.bot?.username,now:A,busy:l,onNewCode:()=>M(()=>window.electronAPI.secretary.contactBind(void 0,e)),onCopied:()=>h(n("Copied"))}),X=a.jsxs("div",{"data-enso":"secretary-contact-groups",className:Zm,children:[a.jsx("div",{className:"text-[12px] font-medium text-muted-foreground",children:n("Groups and topics")}),a.jsx("p",{className:"mt-1 text-[11.5px] text-muted-foreground",children:n("Only groups on this list reach the secretary, and only messages from the bound account count. Messages from anyone else in the group are not received.")}),W.length===0?a.jsxs(a.Fragment,{children:[ee,a.jsx("p",{className:"mt-1.5 text-[11.5px] text-subtle-foreground",children:n("No groups yet: group messages are not received.")})]}):a.jsxs(a.Fragment,{children:[a.jsx("ul",{className:"mt-1.5 flex flex-col gap-1",children:W.map(ue=>a.jsx(jVt,{group:ue,secretaryId:e,busy:l,onRemove:()=>U("remove",ue.id),onSaved:I},ue.id))}),a.jsx("p",{className:"mt-2.5 text-[11.5px] font-medium text-muted-foreground",children:n("Bind another group or topic")}),ee]}),a.jsx(DVt,{shared:F.shared}),a.jsx("p",{className:"mt-2 text-[11px] text-subtle-foreground",children:n("Or add a group by its chat ID:")}),a.jsxs("form",{className:"mt-1 flex gap-1.5",onSubmit:ue=>{if(ue.preventDefault(),!!T){if(W.some(xe=>xe.id===T)){C("");return}U("add",T)}},children:[a.jsx("input",{"data-enso":"secretary-contact-group-input",value:k,spellCheck:!1,autoComplete:"off",placeholder:n("Group chat ID, e.g. -1001234567890"),onChange:ue=>C(ue.target.value),className:"min-w-0 flex-1 rounded-lg border border-border bg-transparent px-2.5 py-1.5 font-mono text-[12px] outline-none focus:border-foreground/40"}),a.jsxs("button",{type:"submit","data-enso":"secretary-contact-group-add",disabled:l||!T,className:Yc,children:[a.jsx(xs,{className:"size-3.5"}),n("Add group")]})]})]}),te=a.jsxs(a.Fragment,{children:[R&&a.jsx("p",{"data-enso":"secretary-contact-token-conflict",className:"text-[11.5px] text-warning",children:n("The Telegram remote plugin (enso.telegram) is enabled. Do not give both the same bot token: only one place can poll a bot, so they would steal each other's messages.")}),F.status==="bound"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{"data-enso":"secretary-contact-bound",className:Zm,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-full bg-success/15 text-success",children:a.jsx(Is,{className:"size-3.5"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"truncate text-[13px] font-medium",children:F.chat?n("Bound to @{{username}}",{username:F.chat.username??String(F.chat.id)}):n("Bound to groups and topics")}),a.jsxs("p",{className:"truncate text-[11.5px] text-muted-foreground",children:[n("Bot @{{bot}}",{bot:F.bot?.username??""}),F.tokenHint?` · ${F.tokenHint}`:""]})]})]}),a.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[a.jsxs("button",{type:"button","data-enso":"secretary-contact-test",disabled:l,className:Yc,onClick:()=>M(()=>window.electronAPI.secretary.contactTest(e).then(ue=>(ue.ok&&h(n("Test message sent")),ue))),children:[a.jsx(zy,{className:"size-3.5"}),n("Send a test message")]}),a.jsxs("button",{type:"button","data-enso":"secretary-contact-unbind",disabled:l,className:Yc,onClick:()=>M(()=>window.electronAPI.secretary.contactUnbind(e)),children:[a.jsx(OVe,{className:"size-3.5"}),n("Unbind")]}),a.jsxs("button",{type:"button","data-enso":"secretary-contact-replace",disabled:l,className:Yc,onClick:()=>M(()=>window.electronAPI.secretary.contactForgetBot(e)),children:[a.jsx(bo,{className:"size-3.5"}),n("Change bot")]})]})]}),X,a.jsx("div",{"data-enso":"secretary-contact-sync",className:ve(Zm,F.syncMirror&&"border-warning/50 bg-warning/5"),children:F.syncMirror?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-1.5 text-[12.5px] font-medium text-warning",children:[a.jsx(OUe,{className:"size-3.5 shrink-0"}),n("Mirroring every conversation to Telegram")]}),a.jsx("p",{className:"mt-1 text-[11.5px] text-muted-foreground",children:n("Every reply in the secretary conversation is sent to your phone, not just milestones. Silent turns arrive as a one-line summary. Telegram messages are not end-to-end encrypted and stay on Telegram servers. Send /sync off in Telegram to stop.")})]}):a.jsx("p",{className:"text-[11.5px] text-muted-foreground",children:n("Only milestones go to Telegram. Send /sync in Telegram to mirror every reply; /last replays the latest round.")})}),a.jsxs("div",{"data-enso":"secretary-contact-commands",className:Zm,children:[a.jsx("div",{className:"text-[12px] font-medium text-muted-foreground",children:n("Commands you can send")}),a.jsx("ul",{className:"mt-1 flex flex-col gap-0.5",children:ZUt.filter(ue=>!ue.gated||F.allowMemory).map(ue=>a.jsxs("li",{className:"text-[12px]",children:[a.jsxs("code",{className:"rounded bg-muted px-1 text-[11.5px]",children:["/",ue.name]})," ",a.jsx("span",{className:"text-muted-foreground",children:n(ue.en)})]},ue.name))}),a.jsx("p",{className:"mt-1.5 text-[11.5px] text-muted-foreground",children:n("Telegram messages are not end-to-end encrypted and stay on Telegram servers. /status, /board and /feed show titles and short summaries; /last and /sync send conversation text. Memory text and tool output never leave the app.")})]}),!F.secure&&a.jsx("p",{className:"px-1 text-[11.5px] text-warning",children:n("No system keychain available: the bot token is stored unencrypted on this machine.")})]}),F.status==="awaiting-start"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{"data-enso":"secretary-contact-verified",className:Zm,children:[a.jsx(S7,{index:2,label:n("Bot verified")}),a.jsxs("p",{className:"mt-1 text-[13px] font-medium",children:[F.bot?.name," ",a.jsxs("span",{className:"text-muted-foreground",children:["@",F.bot?.username]})]})]}),a.jsxs("div",{"data-enso":"secretary-contact-code",className:Zm,children:[a.jsx(S7,{index:3,label:n("Open the bot and press Start")}),a.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[p&&a.jsx("img",{"data-enso":"secretary-contact-qr",src:p,alt:n("Binding QR code"),className:"size-28 shrink-0 rounded-lg bg-white p-1"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-[11.5px] text-muted-foreground",children:n("Binding code")}),a.jsx("p",{"data-enso":"secretary-contact-code-value",className:"font-mono text-[22px] tracking-[0.2em] tabular-nums",children:F.bind?.code}),K?a.jsx("p",{"data-enso":"secretary-contact-code-expired",className:"mt-1 text-[11.5px] text-warning",children:n("This code has expired")}):a.jsx("p",{className:"mt-1 text-[11.5px] text-subtle-foreground",children:n("Valid for {{minutes}} more minutes",{minutes:P})})]})]}),a.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[a.jsxs("a",{"data-enso":"secretary-contact-open-bot",href:F.bind?.link,target:"_blank",rel:"noreferrer",className:yR,children:[a.jsx(dy,{className:"size-3.5"}),n("Open @{{bot}}",{bot:F.bot?.username??""})]}),a.jsxs("button",{type:"button","data-enso":"secretary-contact-copy",className:Yc,onClick:()=>{navigator.clipboard.writeText(F.bind?.link??""),h(n("Link copied"))},children:[a.jsx(zd,{className:"size-3.5"}),n("Copy link")]}),a.jsxs("button",{type:"button","data-enso":"secretary-contact-regenerate",disabled:l,className:K?yR:Yc,onClick:()=>M(()=>window.electronAPI.secretary.contactBind(void 0,e)),children:[a.jsx(bo,{className:"size-3.5"}),n("New code")]}),a.jsx("button",{type:"button","data-enso":"secretary-contact-cancel",disabled:l,className:Yc,onClick:()=>M(()=>window.electronAPI.secretary.contactCancel(e)),children:n("Cancel")})]}),F.bind&&a.jsx(LVt,{bind:F.bind}),J&&F.bind?.rejected?.reason!=="private-owned"&&a.jsx("p",{"data-enso":"secretary-contact-private-owned",className:"mt-2 text-[11.5px] text-warning",children:n('Your private chat with this bot already belongs to secretary "{{owner}}". Bind this secretary to a group or forum topic instead.',{owner:J})}),a.jsx("p",{className:"mt-2 text-[11.5px] text-subtle-foreground",children:n("The code works once. Press Start in a private chat with the bot, or send it in a group or forum topic to bind that place to this secretary instead.")})]}),X]}),F.shared&&F.status!=="unbound"&&a.jsx(FVt,{shared:F.shared,bot:F.bot?.username}),F.status==="unbound"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{"data-enso":"secretary-contact-step1",className:Zm,children:[a.jsx(S7,{index:1,label:n("Create a bot with @BotFather")}),a.jsx("p",{className:"mt-1 text-[11.5px] text-muted-foreground",children:n("Send /newbot, pick a name, and copy the token it gives you.")}),a.jsxs("a",{"data-enso":"secretary-contact-botfather",href:zVt,target:"_blank",rel:"noreferrer",className:ve(UVt,"mt-2"),children:[a.jsx(dy,{className:"size-3.5"}),n("Open @BotFather")]}),a.jsx("input",{"data-enso":"secretary-contact-token",type:"password",value:o,spellCheck:!1,autoComplete:"off",placeholder:n("Paste the bot token"),onChange:ue=>i(ue.target.value),className:"mt-2 w-full rounded-lg border border-border bg-transparent px-2.5 py-1.5 font-mono text-[12px] outline-none focus:border-foreground/40"}),a.jsxs("button",{type:"button","data-enso":"secretary-contact-verify",disabled:l||o.trim().length===0,className:ve(yR,"mt-2"),onClick:()=>M(()=>window.electronAPI.secretary.contactBind(o.trim(),e)),children:[l?a.jsx(Jn,{className:"size-3.5 animate-spin"}):a.jsx(Is,{className:"size-3.5"}),n("Verify and continue")]}),F.bot&&a.jsxs("button",{type:"button","data-enso":"secretary-contact-reconnect",disabled:l,className:ve(Yc,"mt-1.5"),onClick:()=>M(()=>window.electronAPI.secretary.contactBind(void 0,e)),children:[a.jsx(bo,{className:"size-3.5"}),n("Bind again with @{{bot}}",{bot:F.bot.username})]})]}),a.jsx("p",{className:"px-1 text-[11.5px] text-subtle-foreground",children:n("The token is stored with the system keychain and never written to logs.")}),X]})]}),Q=ue=>M(()=>window.electronAPI.secretary.contactSettings({enabled:ue},e)),oe=t?a.jsx("div",{"data-enso":"secretary-contact-master",children:a.jsx(jn,{label:n("Enable contacts"),children:a.jsx(Qde,{checked:r.enabled,disabled:l,label:n("Enable contacts"),onCheckedChange:Q})})}):a.jsxs("div",{"data-enso":"secretary-contact-master",className:"flex items-center justify-between gap-2 border-border border-b py-2",children:[a.jsx("span",{className:"text-[13px] font-medium",children:n("Enable contacts")}),a.jsx(Qde,{checked:r.enabled,disabled:l,label:n("Enable contacts"),onCheckedChange:Q})]}),de=a.jsx(XVt,{owner:r.owner,secretaryId:e,busy:l,error:u,run:M,showHeading:!t}),ie=r.enabled?a.jsxs(a.Fragment,{children:[(ne||H)&&a.jsxs("div",{"data-enso":"secretary-contact-error",className:"flex items-start gap-1.5 border-destructive border-l-2 bg-destructive/5 px-2.5 py-2 text-[12px] text-destructive",children:[a.jsx(Rf,{className:"mt-0.5 size-3.5 shrink-0"}),a.jsx("span",{className:"min-w-0 flex-1",children:n(ne?HVt[ne]??"Telegram returned an error":"Cannot reach api.telegram.org. Check the proxy.")})]}),f&&a.jsxs("div",{className:"flex items-center gap-1.5 border-success border-l-2 bg-success/5 px-2.5 py-2 text-[12px] text-success",children:[a.jsx(Is,{className:"size-3.5 shrink-0"}),a.jsx("span",{children:f})]}),D.map(ue=>a.jsx(KVt,{channel:ue,collapsed:v[ue.id]===!0,busy:l,onToggle:()=>j(ue.id),onPrefs:xe=>z(ue.id,xe),onRetry:()=>B(ue.id),children:ue.id==="telegram"?te:ue.pluginId&&ue.settingsView?a.jsx("div",{"data-enso":"secretary-contact-plugin-view",className:"h-72 overflow-hidden border-border border-y",children:a.jsx(sMe,{pluginId:ue.pluginId,entry:ue.settingsView,title:ue.title,sessionId:null})}):null},ue.id)),a.jsxs("div",{"data-enso":"secretary-contact-following",className:Zm,children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsx("div",{className:"text-[12.5px] font-medium",children:n("Followed from the phone: {{count}}",{count:F.following.length})}),F.following.length>0&&a.jsx("button",{type:"button","data-enso":"secretary-contact-following-clear",disabled:l,className:Yc,onClick:()=>M(()=>window.electronAPI.secretary.contactFollowing({action:"clear"},e)),children:n("Clear all")})]}),a.jsx("p",{className:"mt-1 text-[11.5px] text-muted-foreground",children:n("What you dispatch or schedule from the phone keeps reporting here until it finishes or fails once, even with /sync off.")}),F.following.length>0&&a.jsx("ul",{className:"mt-1.5 flex flex-col gap-1",children:F.following.map(ue=>a.jsxs("li",{className:"flex items-start justify-between gap-2",children:[a.jsxs("span",{className:"min-w-0 flex-1 text-[12px]",children:[a.jsxs("span",{className:"text-muted-foreground",children:[ue.kind==="schedule"?n("Scheduled"):n("Session")," ·"," "]}),ue.summary]}),a.jsx("button",{type:"button","data-enso":"secretary-contact-following-cancel",disabled:l,className:Yc,onClick:()=>M(()=>window.electronAPI.secretary.contactFollowing({action:"cancel",id:ue.id},e)),children:n("Drop")})]},ue.id))})]}),a.jsxs("button",{type:"button","data-enso":"secretary-contact-market",className:ve(Yc,t?"mt-3":"self-start"),onClick:()=>nu({category:"plugins",rowId:"plugins.enso",marketQuery:"contact"}),children:[a.jsx(su,{className:"size-3.5"}),n("Find more contact channels in the plugin market")]})]}):a.jsx("p",{className:t?"border-border border-b py-3 text-[13px] text-muted-foreground":"px-1 text-[11.5px] text-subtle-foreground",children:n("Contacts are off: nothing is sent or received on any channel.")});return t?a.jsxs("div",{"data-enso":"secretary-contact",children:[t.owner(de),t.channels(a.jsxs(a.Fragment,{children:[oe,ie]}))]}):a.jsxs("div",{"data-enso":"secretary-contact",className:"flex flex-col gap-2 px-3 py-3",children:[a.jsx("p",{className:"px-1 text-[11.5px] text-muted-foreground",children:n("Reach the secretary from your phone. Milestones go out; your replies come back.")}),oe,de,ie]})}function ZVt(){try{return localStorage.getItem(r4)??void 0}catch{return}}function iMe(){const[e,t]=y.useState([]),[n,r]=y.useState(ZVt),s=y.useCallback(async()=>{t(await window.electronAPI.secretary.list())},[]);y.useEffect(()=>(s(),window.electronAPI.secretary.onListChanged(t)),[s]),y.useEffect(()=>{const l=c=>{c.key===r4&&c.newValue&&r(c.newValue)};return window.addEventListener("storage",l),()=>window.removeEventListener("storage",l)},[]);const o=y.useCallback(l=>{r(l);try{l&&localStorage.setItem(r4,l)}catch{}},[]),i=e.find(l=>l.id===n)?.id??e[0]?.id??void 0;return{secretaries:e,setSecretaries:t,current:i,multiple:e.length>1,select:o,reload:s}}function aMe({secretaries:e,current:t,onSelect:n}){const{t:r}=Se();return e.map(s=>a.jsx("button",{type:"button","data-enso":"secretary-settings-pick","data-secretary-id":s.id,"data-selected":s.id===t||void 0,onClick:()=>n(s.id),className:ve("relative rounded-full px-2.5 py-1 text-xs ring-1 transition-colors",s.id===t?"bg-foreground/5 text-foreground ring-foreground/40":"text-muted-foreground ring-border hover:text-foreground"),children:s.name??r("Secretary")},s.id))}function JVt(){const{t:e}=Se(),{secretaries:t,current:n,multiple:r,select:s}=iMe();return a.jsxs(yi,{title:e("Contacts & owner"),description:e("Reach the secretary from your phone. Milestones go out; your replies come back."),children:[r&&a.jsx("div",{className:"mt-4 flex max-w-full flex-wrap items-center gap-1.5",children:a.jsx(aMe,{secretaries:t,current:n,onSelect:s})}),a.jsx(QVt,{secretaryId:n,frames:{owner:o=>a.jsx(Xn,{title:e("Owner identity"),rowId:"contacts.owner",children:o}),channels:o=>a.jsx(Xn,{title:e("Contact channels"),rowId:"contacts.channels",children:o})}},n??"single")]})}const eGt={body:"Body",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4–6",table:"Table",inlineCode:"Inline code",codeBlock:"Code block"},Zde=YW.map(e=>({value:String(e),label:String(e)}));function tGt(){const{t:e}=Se(),t=be(c=>c.chatTypography),n=be(c=>c.setChatTypography),r=be(c=>c.resetChatTypography),[s,o]=y.useState(t.body.size);y.useEffect(()=>{o(t.body.size)},[t.body.size]);const i=(c,u)=>{const d=be.getState().chatTypography;n({...d,[c]:{...d[c],size:u}})},l=(c,u)=>{const d=be.getState().chatTypography;n({...d,[c]:{...d[c],weight:u}})};return a.jsxs(Xn,{rowId:"appearance.chatTypography",title:e("Conversation typography"),description:e("Headings, tables and inline code scale with the body text"),children:[ET.map(c=>a.jsx(nGt,{role:c,label:e(eGt[c]),size:t[c].size,weight:t[c].weight,bodyPreview:s,onPreview:c==="body"?o:void 0,onCommit:u=>i(c,u),onWeight:u=>l(c,u)},c)),a.jsx("div",{className:"flex justify-end py-2",children:a.jsx(fn,{onClick:()=>r(),children:e("Reset to defaults")})})]})}function nGt({role:e,label:t,size:n,weight:r,bodyPreview:s,onPreview:o,onCommit:i,onWeight:l}){const c=xk[e],[u,d]=y.useState(n);y.useEffect(()=>{d(n)},[n]);const f=c.unit==="%"?`${(s*u/100).toFixed(1)}px`:void 0;return a.jsxs(jn,{label:t,children:[a.jsx("div",{className:"w-[140px] sm:w-[180px]",children:a.jsx(KK,{min:c.min,max:c.max,step:c.step,value:u,onValueChange:h=>{const p=Array.isArray(h)?h[0]:h;d(p),o?.(p)},onValueCommitted:h=>i(Array.isArray(h)?h[0]:h)})}),a.jsxs("span",{className:"shrink-0 text-right text-[12px] text-muted-foreground tabular-nums",children:[u,c.unit==="%"?"%":"px",f?` · ${f}`:""]}),a.jsxs(Ps,{items:Zde,value:String(r),onValueChange:h=>{const p=Number(h);YW.includes(p)&&l(p)},children:[a.jsx(Ls,{size:"sm",className:"w-24 max-w-full","aria-label":t,children:a.jsx(Os,{})}),a.jsx(Ds,{children:Zde.map(h=>a.jsx(ls,{value:h.value,children:h.label},h.value))})]})]})}function rGt({seconds:e,onCommit:t}){const{t:n}=Se(),[r,s]=y.useState(String(e));y.useEffect(()=>s(String(e)),[e]);const o=()=>{const i=Number(r);if(!Number.isInteger(i)){s(String(e));return}const l=XW(i);t(l),s(String(l))};return a.jsxs(jn,{rowId:"appearance.liveActivityFoldDelaySec",label:n("Wait before folding"),description:n("Seconds to wait after tools and thinking finish"),children:[a.jsx(En,{type:"number",min:1,max:60,value:r,onChange:i=>s(i.target.value),onBlur:o,onKeyDown:i=>{i.key==="Enter"&&(o(),i.currentTarget.blur())},className:"w-20 max-w-full"}),a.jsx("span",{className:"text-[12px] text-muted-foreground",children:n("sec")})]})}function cp({rowId:e,label:t,description:n,checked:r,onChange:s,extra:o}){return a.jsxs(jn,{rowId:e,label:t,description:n,children:[o,a.jsx($r,{checked:r,onCheckedChange:i=>s(i===!0)})]})}function sGt({revealRowId:e}={}){const{t}=Se(),n=be(M=>M.openChangesOnFileEdit),r=be(M=>M.setOpenChangesOnFileEdit),s=be(M=>M.compactReadOnlyTools),o=be(M=>M.setCompactReadOnlyTools),i=be(M=>M.expandLiveEdits),l=be(M=>M.setExpandLiveEdits),c=be(M=>M.expandLiveReasoning),u=be(M=>M.setExpandLiveReasoning),d=be(M=>M.autoCollapseTurns),f=be(M=>M.setAutoCollapseTurns),h=be(M=>M.quoteSelectionButton),p=be(M=>M.setQuoteSelectionButton),m=be(M=>M.collapseCompletedActivity),v=be(M=>M.setCollapseCompletedActivity),b=be(M=>M.collapseLiveActivity),x=be(M=>M.setCollapseLiveActivity),S=be(M=>M.liveActivityFoldDelaySec),k=be(M=>M.setLiveActivityFoldDelaySec),C=be(M=>M.pinUnfinishedTodos),A=be(M=>M.setPinUnfinishedTodos),N=be(M=>M.headerSessionTabs),j=be(M=>M.setHeaderSessionTabs),I=be(M=>M.headerRecentMinutes),_=be(M=>M.setHeaderRecentMinutes),L=M=>M===0?t("Off"):t("{{count}} min",{count:M});return a.jsxs(yi,{title:t("Conversation display"),children:[a.jsx(tGt,{}),a.jsxs(Xn,{children:[a.jsx(cp,{rowId:"appearance.openChangesOnFileEdit",label:t("Open Changes when files are edited"),description:t("Automatically show the side panel Changes tab after the agent edits a file"),checked:n,onChange:r}),a.jsx(cp,{rowId:"appearance.compactReadOnlyTools",label:t("Compact read-only tool calls"),description:t("Show read/grep/find/ls as one-line rows and fold consecutive tool calls while the agent is still running"),checked:s,onChange:o}),a.jsx(cp,{rowId:"appearance.expandLiveEdits",label:t("Expand file edits while running"),description:t("Automatically unfold diffs or written content from file modification tools while the agent is still running"),checked:i,onChange:l}),a.jsx(cp,{rowId:"appearance.expandLiveReasoning",label:t("Expand reasoning while streaming"),description:t("Automatically unfold the thinking block while the model is still reasoning. It collapses again when reasoning ends."),checked:c,onChange:u}),a.jsx(cp,{rowId:"appearance.autoCollapseTurns",label:t("Auto-collapse previous turns"),description:t("After you send a new message, fold earlier turns down to the question, timestamp and duration; the latest turn stays expanded"),checked:d,onChange:f}),a.jsx(cp,{rowId:"appearance.quoteSelectionButton",label:t("Quote button on text selection"),description:t("Show a floating Quote button when you select text in the conversation; click it to put the selection into the input box as a quote"),checked:h,onChange:p}),a.jsx(cp,{rowId:"appearance.collapseCompletedActivity",label:t("Collapse activity after reply"),description:t("When a reply finishes, fold consecutive thinking and tool calls (including edits and commands) into one summary row; failed calls stay visible"),checked:m,onChange:v}),a.jsx(cp,{rowId:"appearance.collapseLiveActivity",label:t("Collapse finished activity while replying"),description:t("While a reply is still running, wait a moment after tools and thinking finish, then fold that stretch into one row. Calls still running stay visible, and failed calls stay visible"),checked:b,onChange:x}),b||e==="appearance.liveActivityFoldDelaySec"?a.jsx(rGt,{seconds:S,onCommit:k}):null,a.jsx(cp,{rowId:"appearance.pinUnfinishedTodos",label:t("Pin unfinished todos"),description:t("Keep the latest todo list above the input while it has unfinished items, so it does not scroll away with the timeline"),checked:C,onChange:A}),a.jsx(cp,{rowId:"appearance.headerSessionTabs",label:t("Show active sessions in the title bar"),description:t("Show active conversations as tabs above the conversation. Hold ⌘/Ctrl to see number shortcuts. Hidden while Bot mode is enabled."),checked:N,onChange:j,extra:N?a.jsxs("div",{className:"flex min-w-0 flex-wrap items-center justify-end gap-2",children:[a.jsx("span",{className:"max-w-full text-[12px] text-muted-foreground",children:t("Also show recent conversations")}),a.jsxs(Ps,{items:Object.fromEntries(IT.map(M=>[String(M),L(M)])),value:String(I),onValueChange:M=>_(Number(M)),children:[a.jsx(Ls,{size:"sm",className:"w-28 max-w-full",children:a.jsx(Os,{})}),a.jsx(Ds,{children:IT.map(M=>a.jsx(ls,{value:String(M),children:L(M)},M))})]})]}):null})]})]})}const vA="text-muted-foreground";function oGt(){const{t:e}=Se();return a.jsxs(yi,{title:e("Devices"),children:[a.jsx(iGt,{}),!window.electronAPI.remote&&a.jsx(aGt,{}),a.jsx(uGt,{})]})}function iGt(){const{t:e}=Se(),[t,n]=y.useState(null),[r,s]=y.useState(null),[o,i]=y.useState(!1),[l,c]=y.useState(null),[u,d]=y.useState(null),[f,h]=y.useState(!1),p=t?.pairingExpiresAt;y.useEffect(()=>{if(!p){d(null);return}const x=()=>d(Math.max(0,Math.ceil((p-Date.now())/1e3)));x();const S=setInterval(x,1e3);return()=>clearInterval(S)},[p]);const m=x=>{navigator.clipboard.writeText(x).then(()=>{h(!0),setTimeout(()=>h(!1),1500)})};y.useEffect(()=>{if(!Mh())return window.electronAPI.pair.status().then(n),window.electronAPI.pair.onStatusChanged(x=>{n(x),(x.pairing||x.devices.length>0)&&c(null)})},[]),y.useEffect(()=>{const x=t?.inviteUri;if(!x){s(null);return}rMe.toDataURL(x,{width:320,margin:1}).then(s).catch(()=>{})},[t?.inviteUri]);const v=async()=>{i(!0),c(null);const x=await window.electronAPI.pair.start();i(!1),x.ok||c(x.error??e("Failed to start pairing"))},b=t?.devices??[];return a.jsxs(Xn,{rowId:"phone.root",title:e("Allow connections"),description:e("Let your phone or another EnsoCode desktop connect to this computer. Keep this app running."),actions:t?.pairing?a.jsx(fn,{onClick:()=>{window.electronAPI.pair.cancel()},children:e("Cancel pairing")}):a.jsxs(fn,{disabled:o,onClick:()=>{v()},children:[o?a.jsx(Jn,{className:"h-4 w-4 animate-spin"}):a.jsx(yT,{className:"h-4 w-4"}),e("Generate pairing code")]}),children:[t&&!t.secureStorage&&a.jsx(lMe,{}),l&&a.jsx("p",{className:"border-border border-b py-3 text-xs text-destructive",children:l}),t?.pairing&&a.jsxs("div",{className:"border-border border-b py-4 text-center",children:[r?a.jsx("img",{src:r,alt:e("Pairing QR code"),className:"mx-auto h-52 w-52"}):a.jsx(Jn,{className:"mx-auto h-5 w-5 animate-spin text-muted-foreground"}),a.jsx("p",{className:"mt-3 font-medium text-sm",children:e("Scan with your phone camera")}),a.jsx("p",{className:"mt-1 text-muted-foreground text-xs",children:e("Scanning opens the app and pairs it. To keep it handy, add it to your home screen.")}),a.jsx("p",{className:"mt-1 text-muted-foreground text-xs",children:e("On another EnsoCode desktop, paste the link below into Settings → Devices → Connect to a node.")}),a.jsx("p",{className:"mt-1 text-muted-foreground text-xs",children:u===null?e("The code expires in 60 seconds and can only be used once."):u>0?e("Expires in {{seconds}}s · single use",{seconds:u}):e("Code expired")}),t.inviteUri&&a.jsxs("div",{className:"mt-3 flex items-center gap-2 text-left",children:[a.jsx("code",{className:"min-w-0 flex-1 truncate bg-muted px-2 py-1.5 font-mono text-[11px] text-muted-foreground",children:t.inviteUri}),a.jsxs(fn,{className:"shrink-0",onClick:()=>m(t.inviteUri),children:[f?a.jsx(Is,{className:"h-3.5 w-3.5"}):a.jsx(zd,{className:"h-3.5 w-3.5"}),e(f?"Copied":"Copy")]})]})]}),a.jsx("p",{className:"border-border border-b py-3 font-medium text-[13px]",children:e("Paired devices")}),b.length===0?a.jsxs("div",{className:"border-border border-b py-8 text-center",children:[a.jsx(yT,{className:"mx-auto h-5 w-5 text-muted-foreground"}),a.jsx("p",{className:"mt-3 font-medium text-sm",children:e("No paired devices")}),a.jsx("p",{className:"mt-1 text-muted-foreground text-xs",children:e("Generate a pairing code to let a phone or another desktop connect.")})]}):b.map(x=>a.jsx(lGt,{device:x},x.pairId))]})}function lMe(){const{t:e}=Se();return a.jsxs("p",{className:"flex items-start gap-2 border-border border-b py-3 text-xs text-muted-foreground",children:[a.jsx(Nd,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),a.jsx("span",{children:e("Secure storage is unavailable on this system, so pairing keys are stored unencrypted.")})]})}function aGt(){const{t:e}=Se(),t=jd(i=>i.nodes),n=jd(i=>i.secureStorage),r=jd(i=>i.refresh),[s,o]=y.useState(!1);return y.useEffect(()=>jd.getState().bind(),[]),a.jsxs(Xn,{title:e("Connect to a node"),description:e("Browse and drive conversations on another EnsoCode desktop. Its agent, keys and history stay there."),actions:a.jsxs(fn,{onClick:()=>o(!0),children:[a.jsx(xs,{className:"h-4 w-4"}),e("Connect to a node")]}),children:[!n&&a.jsx(lMe,{}),a.jsx("p",{className:"border-border border-b py-3 font-medium text-[13px]",children:e("Connected nodes")}),t.length===0?a.jsxs("div",{className:"border-border border-b py-8 text-center",children:[a.jsx(e_,{className:"mx-auto h-5 w-5 text-muted-foreground"}),a.jsx("p",{className:"mt-3 font-medium text-sm",children:e("No connected nodes")}),a.jsx("p",{className:"mt-1 text-muted-foreground text-xs",children:e("Each connecting computer needs its own pairing code from the other desktop.")})]}):t.map(i=>a.jsx(cGt,{node:i,onChanged:()=>{r()}},i.nodeId)),a.jsx(TRe,{open:s,onOpenChange:o,switchOnSuccess:!1})]})}function cMe({transport:e,rttMs:t}){const{t:n}=Se(),r=e==="direct",s=pRe(t);return a.jsxs("span",{className:ve("shrink-0 rounded px-1.5 py-0.5 text-[10px] leading-none",r?"bg-success/15 text-success":"bg-muted text-muted-foreground"),children:[n(r?"Direct link":"Via relay"),s?` · ${s}`:""]})}function lGt({device:e}){const{t}=Se(),[n,r]=y.useState(null),s=async()=>{n!==null&&(n.trim()&&n.trim()!==e.deviceName&&await window.electronAPI.pair.rename(e.pairId,n),r(null))};return a.jsxs("div",{className:"group flex flex-wrap items-center justify-between gap-3 border-border border-b py-2",children:[a.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[a.jsx("span",{className:ve("h-2 w-2 shrink-0 rounded-full",e.phoneOnline?"bg-success":e.connected?"bg-warning":"bg-muted-foreground/40")}),n===null?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"truncate font-medium text-sm",children:e.deviceName}),a.jsx("span",{className:"shrink-0 text-muted-foreground text-xs",children:e.phoneOnline?t("Online"):e.connected?t("Waiting for device"):t("Offline")}),e.phoneOnline&&a.jsx(cMe,{transport:e.transport,rttMs:e.rttMs}),a.jsx("button",{type:"button",title:t("Click to switch: view-only devices cannot send, approve or stop."),onClick:()=>{window.electronAPI.pair.setScope(e.pairId,e.scope==="read"?"operate":"read")},className:ve("relative shrink-0 rounded px-1.5 py-0.5 text-[10px] leading-none transition-colors",e.scope==="read"?"bg-warning/15 text-warning hover:bg-warning/25":"bg-muted text-muted-foreground hover:bg-accent"),children:e.scope==="read"?t("View only"):t("Can operate")})]}):a.jsx(En,{value:n,autoFocus:!0,onChange:o=>r(o.target.value),onBlur:()=>{s()},onKeyDown:o=>{o.key==="Enter"&&s(),o.key==="Escape"&&r(null)},className:"h-7 w-full max-w-full text-sm sm:w-[220px]"})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-1 opacity-0 transition-opacity pointer-coarse:opacity-100 group-hover:opacity-100",children:[a.jsx(Ke,{variant:"ghost",size:"icon",className:vA,title:t("Rename"),onClick:()=>r(e.deviceName),children:a.jsx(Pi,{className:"h-3.5 w-3.5"})}),a.jsx(Ke,{variant:"ghost",size:"icon",className:ve(vA,"hover:text-destructive"),onClick:()=>{window.electronAPI.pair.revoke(e.pairId)},children:a.jsx(io,{className:"h-3.5 w-3.5"})})]})]})}function cGt({node:e,onChanged:t}){const{t:n}=Se(),[r,s]=y.useState(null),o=async()=>{r!==null&&(r.trim()&&r.trim()!==e.label&&(await window.electronAPI.nodes.rename(e.nodeId,r),t()),s(null))};return a.jsxs("div",{className:"group flex flex-wrap items-center justify-between gap-3 border-border border-b py-2",children:[a.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[a.jsx(LV,{node:e}),r===null?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"truncate font-medium text-sm",children:e.label}),e.hostname&&e.hostname!==e.label&&a.jsx("span",{className:"shrink-0 truncate font-mono text-[10px] text-muted-foreground",children:e.hostname}),a.jsx("span",{className:"shrink-0 text-muted-foreground text-xs",children:e.hostOnline?n("Online"):e.connected?n("Remote desktop is offline"):n("Offline")}),e.hostOnline&&a.jsx(cMe,{transport:e.transport,rttMs:e.rttMs})]}):a.jsx(En,{value:r,autoFocus:!0,onChange:i=>s(i.target.value),onBlur:()=>{o()},onKeyDown:i=>{i.key==="Enter"&&o(),i.key==="Escape"&&s(null)},className:"h-7 w-full max-w-full text-sm sm:w-[220px]"})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-1 opacity-0 transition-opacity pointer-coarse:opacity-100 group-hover:opacity-100",children:[a.jsx(Ke,{variant:"ghost",size:"icon",className:vA,title:n("Rename"),onClick:()=>s(e.label),children:a.jsx(Pi,{className:"h-3.5 w-3.5"})}),a.jsx(Ke,{variant:"ghost",size:"icon",className:ve(vA,"hover:text-destructive"),title:n("Disconnect"),onClick:()=>{window.electronAPI.nodes.remove(e.nodeId).then(t)},children:a.jsx(io,{className:"h-3.5 w-3.5"})})]})]})}function uGt(){const{t:e}=Se(),[t,n]=y.useState(null),[r,s]=y.useState(null);y.useEffect(()=>(window.electronAPI.pair.status().then(n),window.electronAPI.pair.onStatusChanged(n)),[]);const o=async()=>{r!==null&&(n(await window.electronAPI.pair.setRelayUrl(r)),s(null))};return a.jsx(Xn,{children:a.jsxs(jn,{label:e("Relay server"),description:e("The relay only forwards encrypted frames and cannot read your messages."),children:[a.jsx(En,{value:r??t?.relayUrl??"",onChange:i=>s(i.target.value),placeholder:"https://relay.example.com",className:"w-full font-mono text-xs sm:w-[220px]"}),r===null?a.jsx(Ke,{variant:"ghost",size:"icon-sm",className:vA,onClick:()=>s(t?.relayUrl??""),children:a.jsx(Pi,{className:"h-3.5 w-3.5"})}):a.jsxs(fn,{variant:"default",onClick:()=>{o()},children:[a.jsx(Is,{className:"h-3.5 w-3.5"}),e("Save")]})]})})}function dGt({onOpenBots:e}){const{t}=Se(),n=be(f=>f.botModeEnabled),r=be(f=>f.setBotModeEnabled),s=be(f=>f.scratchSessionsEnabled),o=be(f=>f.setScratchSessionsEnabled),i=be(f=>f.dropShelfEnabled),l=be(f=>f.setDropShelfEnabled),c=be(f=>f.secretaryEnabled),u=be(f=>f.setSecretaryEnabled),d=window.electronAPI.env.platform==="darwin"&&!window.electronAPI.remote;return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-medium",children:t("Experimental")}),a.jsx("p",{className:"text-sm text-muted-foreground",children:t("Features still being tested. They may change or be removed.")})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(jn,{rowId:"experimental.botMode",label:t("Bot mode"),description:t("Adds a Code | Bot switch to the sidebar. Create members with their own persona, model and tools, and chat with them alone or in groups."),children:a.jsx($r,{checked:n,onCheckedChange:r})}),n&&a.jsx(Ke,{variant:"outline",size:"sm",onClick:e,children:t("Bot mode settings")}),a.jsx(jn,{rowId:"experimental.scratchSessions",label:t("Temporary chats"),description:t("Chats that are not tied to a project. Tools follow your global settings."),children:a.jsx($r,{checked:s,onCheckedChange:o})}),d&&a.jsx(jn,{rowId:"experimental.dropShelf",label:t("Drop shelf"),description:t("When you drag files in Finder, a small panel appears at the top right of the screen. Drop them on it to reference them in the current conversation, or drop folders to open them as projects, even when EnsoCode is minimized or in the tray."),children:a.jsx($r,{checked:i,onCheckedChange:l})}),a.jsx(jn,{rowId:"experimental.secretary",label:t("Secretary"),description:t("A global agent that watches your projects and sessions, creates sessions to do the work, and reports results back to you."),children:a.jsx($r,{checked:c,onCheckedChange:u})})]})]})}const fGt=["pem","crt","cer"],hGt=[{category:"providers",label:"Model Providers"},{category:"presets",label:"Presets"},{category:"agentTypes",label:"Agent types"},{category:"skills",label:"Skills"},{category:"mcpServers",label:"MCP Servers"},{category:"instructions",label:"Instruction Files"},{category:"subagentModels",label:"Subagent Models"},{category:"settings",label:"Scalar settings"}];function pGt(){const{t:e}=Se(),[t,n]=y.useState(!1),[r,s]=y.useState(!1),[o,i]=y.useState(null),[l,c]=y.useState(null),u=()=>{i(null),n(!0)},d=async()=>{s(!0),i(null);try{const f=await window.electronAPI.configSync.openImport();if(!f.ok){i({kind:f.cancelled?"cancelled":"error",text:f.cancelled?e("Import cancelled."):e(f.error)});return}c(f)}catch{i({kind:"error",text:e("Could not open configuration package.")})}finally{s(!1)}};return a.jsxs(Xn,{rowId:"general.configSync",title:e("Configuration transfer"),description:e("Move models, presets, agent types, skills, MCP servers and instruction files between devices."),children:[a.jsxs(jn,{label:e("Portable Enso configuration"),description:a.jsxs(a.Fragment,{children:[e("Export a package or preview one before importing it.")," ",e("OAuth login sessions are never transferred. Skill, instruction, and system prompt contents require an encrypted export.")]}),children:[a.jsxs(fn,{disabled:r,onClick:()=>{d()},children:[r?a.jsx(Jn,{className:"h-3.5 w-3.5 animate-spin"}):a.jsx(Lf,{className:"h-3.5 w-3.5"}),e("Import configuration")]}),a.jsxs(fn,{variant:"default",disabled:r,onClick:u,children:[a.jsx(Lxe,{className:"h-3.5 w-3.5"}),e("Export configuration")]})]}),o&&a.jsx("p",{className:o.kind==="error"?"border-border border-b py-2 text-[12px] text-destructive":"border-border border-b py-2 text-[12px] text-muted-foreground",role:o.kind==="error"?"alert":"status",children:o.text}),a.jsx(mGt,{open:t,onOpenChange:n}),l&&a.jsx(gGt,{file:l,onClose:()=>c(null)})]})}function mGt({open:e,onOpenChange:t}){const{t:n}=Se(),[r,s]=y.useState(!1),[o,i]=y.useState(""),[l,c]=y.useState(""),[u,d]=y.useState(!1),[f,h]=y.useState(null),[p,m]=y.useState(!1),[v,b]=y.useState(null),[x,S]=y.useState([]);y.useEffect(()=>{e&&(s(!1),i(""),c(""),d(!1),h(null),m(!1),b(null),S([]))},[e]);const k=()=>{u||(i(""),c(""),t(!1))},C=async()=>{if(r&&o.length<8){h(n("Password must be at least 8 characters."));return}if(r&&o!==l){h(n("Passwords do not match."));return}d(!0),h(null),m(!1);try{const A=await window.electronAPI.configSync.exportConfig({includeSecrets:r,...r?{password:o}:{}});if(i(""),c(""),!A.ok){A.cancelled?m(!0):h(n(A.error));return}b(A.filePath),S(A.skippedInstructions??[])}catch{i(""),c(""),h(n("Could not export configuration."))}finally{d(!1)}};return a.jsx(gr,{open:e,onOpenChange:A=>!A&&k(),children:a.jsxs(vr,{className:"max-w-xl",showCloseButton:!u,children:[a.jsxs(xr,{children:[a.jsx(dr,{children:n("Export configuration")}),a.jsx(oo,{children:n("Create a portable .enso-config package for another device.")})]}),a.jsx(rr,{className:"max-h-[55vh] space-y-4",children:v?a.jsxs(a.Fragment,{children:[a.jsxs(kd,{variant:"success",children:[a.jsx(By,{}),a.jsx(Rw,{children:n("Configuration exported")}),a.jsxs(Sd,{children:[a.jsx("p",{children:n("Saved package:")}),a.jsx("p",{className:"break-all font-mono text-xs text-foreground",children:v})]})]}),x.length>0&&a.jsxs(kd,{variant:"warning",children:[a.jsx(Nd,{}),a.jsxs(Sd,{children:[a.jsx("p",{children:n("These instructions were skipped because their source files are missing or unreadable:")}),a.jsx("p",{className:"break-all text-foreground",children:x.join(", ")})]})]})]}):a.jsxs(a.Fragment,{children:[a.jsxs(kd,{variant:"warning",children:[a.jsx(Rf,{}),a.jsx(Rw,{children:n("File contents can be private")}),a.jsx(Sd,{children:n("Skill and instruction file contents may contain private data, so configurations containing them can only be exported with encryption.")})]}),a.jsxs("label",{className:"flex cursor-pointer items-start gap-3 border-border border-b py-3",children:[a.jsx(wo,{checked:r,onCheckedChange:A=>{const N=A===!0;s(N),h(null),N||(i(""),c(""))}}),a.jsxs("span",{className:"min-w-0",children:[a.jsx("span",{className:"block text-sm font-medium",children:n("Include sensitive configuration")}),a.jsx("span",{className:"mt-0.5 block text-xs text-muted-foreground",children:n("Encrypt the entire package with a password. OAuth login sessions are still excluded.")})]})]}),!r&&a.jsxs(kd,{variant:"info",children:[a.jsx(vg,{}),a.jsx(Sd,{children:n("API keys, provider account links, MCP arguments and environment values, plus credentials and private URL parts in MCP endpoints, will be omitted. Configurations containing skill or instruction files require encryption.")})]}),r&&a.jsxs("div",{className:"space-y-3 border-border border-t py-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[a.jsx(Cxe,{className:"h-4 w-4 text-muted-foreground"}),n("Encryption password")]}),a.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(aV,{htmlFor:"config-export-password",children:n("Password")}),a.jsx(En,{id:"config-export-password",type:"password",autoComplete:"new-password",value:o,"aria-invalid":!!(f&&o.length<8),onChange:A=>{i(A.target.value),h(null)}})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(aV,{htmlFor:"config-export-confirmation",children:n("Confirm password")}),a.jsx(En,{id:"config-export-confirmation",type:"password",autoComplete:"new-password",value:l,"aria-invalid":!!(f&&l!==o),onChange:A=>{c(A.target.value),h(null)}})]})]}),a.jsx("p",{className:"text-xs text-muted-foreground",children:n("Use at least 8 characters. This password cannot be recovered.")})]}),p&&a.jsx("p",{className:"text-xs text-muted-foreground",role:"status",children:n("Export cancelled.")}),f&&a.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-destructive",role:"alert",children:[a.jsx(qa,{className:"h-3.5 w-3.5 shrink-0"}),f]})]})}),a.jsx(Wr,{children:v?a.jsx(Ke,{size:"sm",onClick:k,children:n("Done")}):a.jsxs(a.Fragment,{children:[a.jsx(Ke,{variant:"outline",size:"sm",disabled:u,onClick:k,children:n("Cancel")}),a.jsxs(Ke,{size:"sm",disabled:u,onClick:()=>{C()},children:[u?a.jsx(Jn,{className:"h-3.5 w-3.5 animate-spin"}):a.jsx(Lxe,{className:"h-3.5 w-3.5"}),n(u?"Exporting…":"Export")]})]})})]})})}function gGt({file:e,onClose:t}){const{t:n}=Se(),[r,s]=y.useState(e.encrypted?"password":"preview"),[o,i]=y.useState(""),[l,c]=y.useState("merge"),[u,d]=y.useState(null),[f,h]=y.useState([]),[p,m]=y.useState(null),[v,b]=y.useState(!1),[x,S]=y.useState(null),[k,C]=y.useState(null),[A,N]=y.useState(!1),j=y.useRef(0),I=y.useCallback(async(R,z)=>{const B=++j.current;S("preview"),C(null),d(null),h([]);try{const H=await window.electronAPI.configSync.previewImport({token:e.token,mode:R,...z?{password:z}:{}});if(B!==j.current)return;if(i(""),!H.ok){C(n(H.error));return}c(H.mode),d(H.summary),h(H.warnings),s("preview")}catch{B===j.current&&(i(""),C(n("Could not preview configuration package.")))}finally{B===j.current&&S(null)}},[e.token,n]);y.useEffect(()=>{e.encrypted||I("merge")},[e.encrypted,I]);const _=()=>{x||(j.current+=1,N(!1),i(""),window.electronAPI.configSync.cancelImport(e.token).catch(()=>{}),t())},L=R=>{R===l||x||(c(R),I(R))},M=!!u?.some(R=>(R.category==="skills"||R.category==="mcpServers")&&R.added+R.updated+R.skipped>0),F=u!==null,D=async()=>{if(u){S("commit"),C(null);try{const R=await window.electronAPI.configSync.commitImport({token:e.token,mode:l});if(!R.ok){d(null),h([]),C(n(R.error));return}i("");try{await be.persist.rehydrate()}catch{b(!0)}h(R.warnings),m(R.backupPath),s("success")}catch{d(null),h([]),C(n("Could not import configuration."))}finally{S(null)}}};return a.jsxs(gr,{open:!0,onOpenChange:R=>!R&&_(),children:[a.jsxs(vr,{className:"max-w-2xl",showCloseButton:x===null,children:[a.jsxs(xr,{children:[a.jsx(dr,{children:n(r==="success"?"Configuration imported":"Import configuration")}),a.jsx(oo,{children:r==="success"?n(v?"Configuration was imported, but this window could not refresh automatically.":"This window has been refreshed with the imported settings."):n("Review {{fileName}} before changing this device.",{fileName:e.fileName})})]}),r==="password"&&a.jsxs(rr,{className:"space-y-4",children:[a.jsxs(kd,{variant:"info",children:[a.jsx(Cxe,{}),a.jsx(Rw,{children:n("Encrypted configuration package")}),a.jsx(Sd,{children:n("Enter the export password to decrypt and preview this package.")})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(aV,{htmlFor:"config-import-password",children:n("Password")}),a.jsx(En,{id:"config-import-password",type:"password",autoFocus:!0,autoComplete:"current-password",value:o,"aria-invalid":!!k,onChange:R=>{i(R.target.value),C(null)},onKeyDown:R=>{R.key==="Enter"&&o.length>0&&!x&&I("merge",o)}})]}),k&&a.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-destructive",role:"alert",children:[a.jsx(qa,{className:"h-3.5 w-3.5 shrink-0"}),k]})]}),r==="preview"&&a.jsxs(rr,{className:"max-h-[58vh] space-y-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-sm font-medium",children:n("Import mode")}),a.jsxs(hRe,{value:l,onValueChange:R=>L(R),className:"grid gap-2 sm:grid-cols-2","aria-label":n("Import mode"),children:[a.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5 border-border border-b py-3",children:[a.jsx(PV,{value:"merge",disabled:x!==null}),a.jsxs("span",{children:[a.jsx("span",{className:"block text-sm font-medium",children:n("Merge")}),a.jsx("span",{className:"block text-xs text-muted-foreground",children:n("Add and update matching items while keeping items only on this device.")})]})]}),a.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5 border-border border-b py-3",children:[a.jsx(PV,{value:"replace",disabled:x!==null}),a.jsxs("span",{children:[a.jsx("span",{className:"block text-sm font-medium",children:n("Replace")}),a.jsx("span",{className:"block text-xs text-muted-foreground",children:n("Replace transferred item categories, removing local-only items in them.")})]})]})]})]}),x==="preview"&&a.jsxs("div",{className:"flex items-center justify-center gap-2 py-6",children:[a.jsx(Jn,{className:"h-4 w-4 animate-spin text-muted-foreground"}),a.jsx("span",{className:"text-sm text-muted-foreground",children:n("Preparing preview…")})]}),!x&&u&&a.jsx("div",{className:"min-w-0 overflow-x-auto",children:a.jsxs("table",{className:"w-max min-w-full text-sm",children:[a.jsx("thead",{className:"text-xs text-muted-foreground",children:a.jsxs("tr",{className:"border-border border-b",children:[a.jsx("th",{scope:"col",className:"px-3 py-2 text-left font-medium",children:n("Category")}),a.jsx("th",{scope:"col",className:"px-3 py-2 text-right font-medium",children:n("Added")}),a.jsx("th",{scope:"col",className:"px-3 py-2 text-right font-medium",children:n("Updated")}),a.jsx("th",{scope:"col",className:"px-3 py-2 text-right font-medium",children:n("Skipped")}),a.jsx("th",{scope:"col",className:"px-3 py-2 text-right font-medium",children:n("Removed")})]})}),a.jsx("tbody",{children:hGt.map(({category:R,label:z})=>{const B=u.find(H=>H.category===R);return a.jsxs("tr",{className:"border-border border-t",children:[a.jsx("th",{scope:"row",className:"px-3 py-2 text-left font-medium",children:n(z)}),a.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:B?.added??0}),a.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:B?.updated??0}),a.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:B?.skipped??0}),a.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:B?.removed??0})]},R)})})]})}),!x&&u?.find(R=>R.category==="settings")?.fields?.length?a.jsxs("p",{className:"text-xs text-muted-foreground",children:[n("Portable settings changed:")," ",u.find(R=>R.category==="settings")?.fields?.join(", ")]}):null,l==="replace"&&u&&!x&&a.jsxs(kd,{variant:"error",children:[a.jsx(Nd,{}),a.jsx(Rw,{children:n("Local-only configuration will be deleted")}),a.jsx(Sd,{children:n("Items in transferred collections that exist only on this device will be removed. Removed counts are shown above. Included portable preferences are overwritten. A complete backup is created first.")})]}),f.map(R=>a.jsxs(kd,{variant:"warning",children:[a.jsx(Nd,{}),a.jsx(Sd,{children:n(R)})]},R)),u&&!x&&a.jsxs(kd,{variant:"warning",children:[a.jsx(Rf,{}),a.jsx(Rw,{children:n("Only import packages you trust")}),a.jsx(Sd,{children:n("An imported package can change portable preferences and configuration. Skills and MCP servers may also run commands later when you use them. Previewing does not execute them; continue only if you trust the package.")})]}),k&&a.jsxs(kd,{variant:"error",children:[a.jsx(qa,{}),a.jsx(Sd,{children:k})]})]}),r==="success"&&p&&a.jsxs(rr,{className:"space-y-4",children:[a.jsxs(kd,{variant:"success",children:[a.jsx(By,{}),a.jsx(Rw,{children:n("Import complete")}),a.jsxs(Sd,{children:[a.jsx("p",{children:n("Backup of previous settings:")}),a.jsx("p",{className:"break-all font-mono text-xs text-foreground",children:p})]})]}),v&&a.jsxs(kd,{variant:"warning",children:[a.jsx(Nd,{}),a.jsx(Sd,{children:n("Reopen Settings to load the imported configuration in this window.")})]}),f.map(R=>a.jsxs(kd,{variant:"warning",children:[a.jsx(Nd,{}),a.jsx(Sd,{children:n(R)})]},R))]}),a.jsxs(Wr,{children:[r==="password"&&a.jsxs(a.Fragment,{children:[a.jsx(Ke,{variant:"outline",size:"sm",disabled:x!==null,onClick:_,children:n("Cancel")}),a.jsxs(Ke,{size:"sm",disabled:x!==null||o.length===0,onClick:()=>{I("merge",o)},children:[x==="preview"&&a.jsx(Jn,{className:"h-3.5 w-3.5 animate-spin"}),n("Preview")]})]}),r==="preview"&&a.jsxs(a.Fragment,{children:[a.jsx(Ke,{variant:"outline",size:"sm",disabled:x!==null,onClick:_,children:n("Cancel")}),k&&!u?a.jsx(Ke,{size:"sm",disabled:x!==null,onClick:()=>{I(l)},children:n("Refresh preview")}):a.jsxs(Ke,{variant:l==="replace"?"destructive":"default",size:"sm",disabled:x!==null||!u,onClick:()=>{u&&(F?N(!0):D())},children:[x==="commit"?a.jsx(Jn,{className:"h-3.5 w-3.5 animate-spin"}):a.jsx(Lf,{className:"h-3.5 w-3.5"}),n(x==="commit"?"Importing…":"Import")]})]}),r==="success"&&a.jsx(Ke,{size:"sm",onClick:_,children:n("Done")})]})]}),a.jsx(vGt,{open:A,mode:l,hasImportedExecutableResources:M,onOpenChange:N,onConfirm:()=>{D()}})]})}function vGt({open:e,mode:t,hasImportedExecutableResources:n,onOpenChange:r,onConfirm:s}){const{t:o}=Se();return a.jsx(Jp,{open:e,onOpenChange:r,children:a.jsxs(em,{className:"sm:max-w-md",zIndexLevel:"nested",children:[a.jsxs(tm,{children:[a.jsxs(rm,{className:"flex items-start gap-2 text-base",children:[a.jsx(Nd,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),o("Confirm configuration import")]}),a.jsxs(sm,{className:"space-y-2",children:[a.jsx("span",{className:"block",children:o("This package can change portable preferences and configuration. Continue only if you trust this package.")}),n&&a.jsx("span",{className:"block",children:o("It includes skills or MCP servers that may execute commands when you use them.")}),t==="replace"&&a.jsx("span",{className:"block",children:o("Replace mode removes local-only items from transferred collections and overwrites included portable preferences. A complete backup will be created first.")}),a.jsx("span",{className:"block",children:o("Do you want to continue with this import?")})]})]}),a.jsxs(nm,{variant:"bare",children:[a.jsx(dx,{render:a.jsx(Ke,{variant:"outline",size:"sm"}),children:o("Cancel")}),a.jsx(Ke,{variant:t==="replace"?"destructive":"default",size:"sm",onClick:()=>{r(!1),s()},children:o("Confirm import")})]})]})})}function xGt({className:e,...t}){const n=Bg();return a.jsx(En,{size:"sm",...n,...t,className:ve("w-[220px] max-w-full",e)})}function bGt(){const{language:e,setLanguage:t}=be(),{t:n}=Se();return a.jsxs(yi,{title:n("General"),description:n("General application settings"),children:[a.jsxs(Xn,{title:n("Application"),children:[a.jsx(jn,{rowId:"general.language",label:n("Language"),children:a.jsx(Zo,{value:e,onValueChange:t,options:[{value:"en",label:"English"},{value:"zh",label:"简体中文"}]})}),a.jsx(yGt,{})]}),a.jsxs(Xn,{title:n("Network"),children:[a.jsx(wGt,{}),a.jsx(kGt,{})]}),a.jsx(pGt,{}),a.jsx(CGt,{}),window.electronAPI.env.platform==="darwin"&&!Mh()&&a.jsxs(Xn,{title:n("Integrations"),children:[a.jsx(Jde,{kind:"ensoCommand",title:n("'enso' terminal command"),description:n("Run `enso .` in a terminal to open the current folder in EnsoCode. Links the command into /usr/local/bin and may ask for your password.")}),a.jsx(Jde,{kind:"finderQuickAction",title:n("Finder Quick Action"),description:n("Right-click a folder in Finder and choose Services > Open with EnsoCode.")})]})]})}function Jde({kind:e,title:t,description:n}){const{t:r}=Se(),[s,o]=y.useState(!1),[i,l]=y.useState(!1);y.useEffect(()=>{let u=!0;const d=()=>{Mh()||window.electronAPI.window.shellIntegrationStatus().then(f=>{u&&o(f[e])})};return d(),window.addEventListener("focus",d),()=>{u=!1,window.removeEventListener("focus",d)}},[e]);const c=async()=>{l(!0);try{await window.electronAPI.window.installShellIntegration(e)}finally{try{const u=await window.electronAPI.window.shellIntegrationStatus();o(u[e])}finally{l(!1)}}};return a.jsx(jn,{rowId:`general.${e}`,label:t,description:n,children:a.jsx(fn,{disabled:i,onClick:()=>{c()},children:r(i?"In progress…":s?"Uninstall":"Install")})})}function yGt(){const{t:e}=Se(),t=be(r=>r.notifyMainAgentOnly),n=be(r=>r.setNotifyMainAgentOnly);return a.jsx(jn,{rowId:"general.notifyMainAgentOnly",label:e("Notify only for the main agent"),description:e("Skip coworker completion and failure notifications on this computer and the paired phone. Questions and approvals still notify."),children:a.jsx($r,{checked:t,onCheckedChange:n})})}function efe(e,t){window.electronAPI.proxy.apply({mode:e,customUrl:t})}function wGt(){const{t:e}=Se(),t=be(f=>f.proxyMode),n=be(f=>f.customProxyUrl),r=be(f=>f.setProxyMode),s=be(f=>f.setCustomProxyUrl),[o,i]=y.useState(n),[l,c]=y.useState(null);y.useEffect(()=>{i(n)},[n]);const u=f=>{r(f),efe(f,n)},d=()=>{const f=o.trim();if(f&&!eq(f)){c(e("Enter an http(s) proxy URL"));return}c(null),s(f),efe(t,f)};return a.jsxs("div",{"data-settings-row":"general.proxy",children:[a.jsx(jn,{label:e("Network proxy"),description:e("Used by model requests, the built-in browser, and agent tools"),children:a.jsx(Zo,{value:t,onValueChange:u,options:[{value:"system",label:e("Follow system proxy")},{value:"none",label:e("No proxy")},{value:"custom",label:e("Custom proxy")}]})}),t==="custom"&&a.jsx(jn,{label:e("Proxy URL"),children:a.jsxs("div",{className:"flex w-full max-w-[220px] flex-col items-end gap-1",children:[a.jsx(xGt,{value:o,placeholder:"http://127.0.0.1:7890",onChange:f=>i(f.target.value),onBlur:d,onKeyDown:f=>{f.key==="Enter"&&d()}}),l&&a.jsx("p",{className:"text-right text-[12px] text-destructive",children:l})]})})]})}function kGt(){const{t:e}=Se(),t=be(f=>f.customCaCertPath),n=be(f=>f.setCustomCaCertPath),[r,s]=y.useState(null),[o,i]=y.useState(!1);y.useEffect(()=>{let f=!0;return window.electronAPI.caCert.status().then(h=>{f&&s(h)}).catch(()=>{}),()=>{f=!1}},[]);const l=async f=>{n(f),i(!0);try{s(await window.electronAPI.caCert.apply(f))}catch{}finally{i(!1)}},c=async()=>{const f=await window.electronAPI.dialog.selectFile([...fGt]);f&&await l(f)},u={"not-absolute":e("Path must be absolute"),"not-found":e("File not found"),"not-file":e("Not a file"),"not-readable":e("File is not readable")},d=()=>r?r.source==="env"?e("Using NODE_EXTRA_CA_CERTS from the launch environment: {{path}}",{path:r.path}):r.source==="setting"?e("Set: {{path}}",{path:r.path}):r.source==="shell"?e("Not set; using NODE_EXTRA_CA_CERTS from the login shell: {{path}}",{path:r.path}):e("Not set"):"";return a.jsxs(jn,{rowId:"general.caCert",label:e("Custom CA certificate"),description:a.jsxs(a.Fragment,{children:[e("Trust an extra CA (PEM file) for model endpoints signed by a private CA. TLS verification stays on."),r?.error?a.jsx("span",{className:"mt-1 block break-all text-destructive",children:e("Certificate file unavailable ({{reason}}): {{path}}",{reason:u[r.error],path:r.settingPath})}):d()&&a.jsx("span",{className:"mt-1 block break-all",children:d()}),a.jsx("span",{className:"mt-1 block",children:e("Changes restart the agent process right away (running turns are interrupted). Requests made by the app main process take effect after restarting the app.")})]}),children:[a.jsx(fn,{disabled:o,onClick:()=>{c()},children:e("Choose certificate file")}),t&&a.jsx(fn,{variant:"ghost",disabled:o,onClick:()=>{l("")},children:e("Clear")})]})}function SGt(e,t,n){return e==="npm"?n("Server updates install the new version with npm and restart gracefully: running tasks finish first (up to a limit), then the server restarts and tasks resume."):a.jsxs(a.Fragment,{children:[n("This server must be updated on the machine itself."),a.jsxs("code",{"data-server-manual-command":!0,className:"mt-0.5 block",children:["npm i -g ",$qe(t)]})]})}const tfe="0.3.15-beta.245";function CGt(){const{t:e}=Se(),t=be(N=>N.autoUpdate),n=be(N=>N.setAutoUpdate),r=be(N=>N.autoRestartForUpdate),s=be(N=>N.setAutoRestartForUpdate),o=be(N=>N.updateChannel==="beta"?"beta":"stable"),i=be(N=>N.setUpdateChannel),[l,c]=y.useState(null),[u,d]=y.useState(null),[f,h]=y.useState(!1),[p,m]=y.useState(!1);y.useEffect(()=>{let N=!0;window.electronAPI.updater.getState().then(I=>{N&&(d(I),I.status&&c(_=>_??I.status))}).catch(()=>{});const j=window.electronAPI.updater.onStatus(c);return()=>{N=!1,j()}},[]);const v=u?.host==="server"?u:null,b=u?.host==="desktop"||v!==null&&v.mode!=="manual",x=(l?.status==="available"||l?.status==="downloaded")&&!!l.info,S=l?.status==="applying",C=(()=>{if(!l)return null;switch(l.status){case"checking":return e("Checking for updates…");case"available":return l.manualInstall?e("New version {{version}} found. This local build can't install it automatically.",{version:l.info?.version??""}):e("New version {{version}} found",{version:l.info?.version??""});case"not-available":return e("You are on the latest version");case"downloading":return e("Downloading update… {{percent}}%",{percent:Math.round(l.progress?.percent??0)});case"downloaded":return v?.restartMethod==="manual"?e("New version {{version}} is downloaded. Applying it installs and then stops the server — you will need to restart it externally (container or process manager).",{version:l.info?.version??""}):e("New version {{version}} is downloaded. Restarting waits for the current tool to finish; background commands keep running.",{version:l.info?.version??""});case"applying":{const N=l.applying?.stage;return N==="waiting-tasks"?e("Waiting for {{count}} running tasks to finish before installing…",{count:l.applying?.busyCount??0}):N==="installing"?e("Installing {{version}}…",{version:l.info?.version??""}):e("Restarting server…")}case"error":return l.manualInstall?e("This local build is signed differently from the release and can't install updates automatically. Download it manually."):v&&l.error?e("Update failed: {{error}}",{error:l.error}):e("Update check failed");default:return null}})(),A=l?.status==="checking"||l?.status==="downloading";return a.jsxs(Xn,{rowId:"general.updates",title:e("Updates"),description:v?SGt(v.mode,o,e):e("Application update settings"),children:[a.jsxs(jn,{label:a.jsxs(a.Fragment,{children:[e("Current version")," · ",tfe]}),description:C?a.jsx("span",{className:ve("block",!l?.manualInstall&&"truncate"),children:C}):void 0,children:[x&&a.jsx(fn,{variant:"ghost",onClick:()=>m(!0),children:e("Release notes")}),l?.manualInstall?a.jsx(UY,{manualInstall:l.manualInstall}):S?a.jsx(fn,{variant:"default",disabled:!0,children:e("Updating…")}):l?.status==="downloaded"?a.jsx(fn,{variant:"default",onClick:()=>{Q$(e)},children:e("Restart to update")}):b&&l?.status==="available"?a.jsx(fn,{variant:"default",onClick:()=>{window.electronAPI.updater.downloadUpdate()},children:e("Download update")}):a.jsx(fn,{disabled:A,onClick:()=>{window.electronAPI.updater.checkForUpdates()},children:e("Check for updates")}),a.jsx(bAe,{open:p,onOpenChange:m,status:l,canDownload:b})]}),v?.canRestart&&a.jsxs(jn,{label:e("Restart server"),description:e("Waits for running tasks to finish before restarting; this page reconnects after the server is back. Force restart does not wait."),children:[a.jsx(fn,{variant:"ghost",onClick:()=>{window.electronAPI.updater.restart(!0)},children:e("Restart now")}),a.jsx(fn,{onClick:()=>h(!0),children:e("Restart")}),a.jsx(ec,{open:f,onOpenChange:h,title:e("Restart server?"),description:e("Running tasks finish first, then the server restarts; this page reconnects when it is back."),confirmLabel:e("Restart"),onConfirm:()=>{h(!1),window.electronAPI.updater.restart()}})]}),a.jsx(jn,{label:e("Automatic updates"),description:v?.mode==="manual"?e("Not available for this install: it cannot update itself. Update manually instead."):e(v?"Download and install updates automatically: running tasks finish first, then the server restarts and they resume.":"Download and install updates automatically"),children:a.jsx($r,{checked:v?.mode==="manual"?!1:t,disabled:v?.mode==="manual",onCheckedChange:N=>{n(N),window.electronAPI.updater.setAutoUpdateEnabled(N)}})}),!v&&a.jsx("div",{className:t?void 0:"opacity-60",children:a.jsx(jn,{label:e("Restart automatically to apply updates"),description:e(r==="immediate"?"Restart as soon as the update is downloaded, even while agents are running or messages are queued. The restart happens after the current tool finishes, and running sessions keep going afterwards. It still waits while you're using the window (input in the last 2 minutes), while an input box has an unsent draft, or while a question or approval is pending.":r==="idle"?"After the update is downloaded, restart automatically if no agent is running, nothing is queued, and there are no pending questions or approvals. The idle state must last 5 minutes, and a focused window also blocks it.":"Only notify when an update is ready; never restart automatically."),children:a.jsx(Zo,{value:r,disabled:!t,onValueChange:N=>{hye(N)&&(s(N),window.electronAPI.updater.setAutoRestartMode(N))},options:[{value:"off",label:e("Off")},{value:"idle",label:e("When idle")},{value:"immediate",label:e("Don't wait for idle")}]})})}),(u?.host==="desktop"||u?.host==="server")&&a.jsx(jn,{rowId:"general.updateChannel",label:e("Update channel"),description:a.jsxs(a.Fragment,{children:[e(o==="beta"?"Beta builds come from the latest main branch and may be unstable. You get whichever of beta and stable is newer.":"Only stable releases."),o==="stable"&&Yqe(tfe)&&a.jsx("span",{className:"mt-0.5 block",children:e("You're on a beta build. Switching to stable doesn't downgrade; you'll move to the next stable release once it's out.")})]}),children:a.jsx(Zo,{value:o,onValueChange:N=>{const j=N==="beta"?"beta":"stable";i(j),window.electronAPI.updater.setChannel(j)},options:[{value:"stable",label:e("Stable")},{value:"beta",label:e("Beta")}]})})]})}function EGt({instruction:e,onClose:t}){const{t:n}=Se(),r=be(j=>j.addInstructions),s=be(j=>j.updateInstruction),o=e==="new",i=o||!e?null:e,[l,c]=y.useState(""),[u,d]=y.useState(""),[f,h]=y.useState(!1),[p,m]=y.useState(!1),[v,b]=y.useState(null),[x,S]=y.useState(!1),[k,C]=y.useState(!1);y.useEffect(()=>{if(e){if(e==="new"){c(""),d(""),S(!1),b(null),C(!1),h(!1);return}c(e.name),S(!1),b(null),C(!1),h(!0),window.electronAPI.instructions.read(e.id,e.local,e.sourcePath).then(j=>{j.ok?d(j.content):(d(""),b(j.error??n("Failed to read content")))}).finally(()=>h(!1))}},[e,n]);const A=!!(i&&!i.local&&i.sourcePath),N=async()=>{if(!e||!l.trim())return;if(m(!0),o){const I=crypto.randomUUID(),_=await window.electronAPI.instructions.write(I,u);if(!_.ok){m(!1),b(n("Failed to save"));return}const L=r([{id:I,name:l.trim(),source:"Manual",local:!0,bytes:_.bytes,enabled:!0}]);if(m(!1),L===0){window.electronAPI.instructions.delete(I),b(n("An instruction with this name already exists"));return}t();return}if(!i){m(!1);return}if(A&&k&&i.sourcePath){const I=await window.electronAPI.instructions.writeSource(i.id,i.sourcePath,u);if(m(!1),!I.ok){b(I.error??n("Failed to save"));return}s(i.id,{name:l.trim(),bytes:I.bytes}),t();return}const j=await window.electronAPI.instructions.write(i.id,u);if(m(!1),!j.ok){b(n("Failed to save"));return}s(i.id,{name:l.trim(),local:!0,bytes:j.bytes}),t()};return a.jsx(gr,{open:e!==null,onOpenChange:j=>!j&&t(),children:a.jsxs(vr,{className:"max-w-2xl",children:[a.jsx(xr,{children:a.jsx(dr,{children:n(o?"Add Instruction":"Edit Instruction")})}),a.jsxs(rr,{className:"space-y-4",children:[o?null:A?a.jsxs("div",{className:ve("w-full rounded-md px-3 py-2.5 transition-colors",k?"bg-destructive/8":"bg-amber-500/8"),children:[a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[k?a.jsx(Nd,{className:"h-3.5 w-3.5 shrink-0 text-destructive"}):a.jsx(vg,{className:"h-3.5 w-3.5 shrink-0 text-amber-600 dark:text-amber-500"}),a.jsx("span",{className:"font-medium text-xs",children:n("Write back to original file")})]}),a.jsx(Xi,{checked:k,onCheckedChange:C})]}),a.jsx("p",{className:"mt-1.5 pl-5.5 text-muted-foreground text-xs leading-relaxed",children:k?n("Saving overwrites {{path}} directly — {{source}} will pick up the change.",{path:i?.sourcePath??"",source:i?.source??""}):n("Saving creates a local copy — {{path}} is left untouched, and this entry stops following its updates.",{path:i?.sourcePath??""})})]}):a.jsxs("div",{className:"flex w-full items-start gap-2 rounded-md bg-muted/50 px-3 py-2",children:[a.jsx(vg,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),a.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:n("Local copy — edits stay in this app.")})]}),a.jsxs(Tr,{children:[a.jsx(jr,{children:n("Name")}),a.jsx(En,{value:l,onChange:j=>c(j.target.value)})]}),a.jsxs(Tr,{children:[a.jsx(jr,{children:n("Content")}),f?a.jsxs("div",{className:"flex w-full items-center justify-center gap-2 py-12",children:[a.jsx(Jn,{className:"h-4 w-4 animate-spin text-muted-foreground"}),a.jsx("span",{className:"text-muted-foreground text-xs",children:n("Loading...")})]}):a.jsx(_i,{value:u,onChange:j=>{d(j.target.value),S(!0)},rows:16,className:"font-mono text-xs"})]}),v&&a.jsxs("p",{className:"flex items-center gap-1.5 text-destructive text-xs",children:[a.jsx(qa,{className:"h-3.5 w-3.5 shrink-0"}),v]})]}),a.jsxs(Wr,{children:[a.jsx(Ke,{variant:"outline",size:"sm",onClick:t,children:n("Cancel")}),a.jsxs(Ke,{size:"sm",variant:A&&k?"destructive":"default",disabled:!l.trim()||f||p,onClick:N,children:[p&&a.jsx(Jn,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),n(A?k?"Overwrite original":x?"Save as local copy":"Save":"Save")]})]})]})})}const nfe=e=>e<1024?`${e} B`:`${(e/1024).toFixed(1)} KB`;function TGt(){const{t:e}=Se(),t=be(f=>f.instructions),n=be(f=>f.updateInstruction),r=be(f=>f.removeInstruction),[s,o]=y.useState(!1),[i,l]=y.useState(null),c=t.map(f=>f.id),u=xL(c,f=>window.electronAPI.assets.instructionOccupancy(f)),d=mL(t.filter(f=>f.enabled).map(f=>f.id),u.rows);return a.jsxs(yi,{rowId:"instructions.root",title:a.jsxs(a.Fragment,{children:[e("Instruction Files"),a.jsx(vL,{tokens:d}),a.jsx(Df,{})]}),description:e("Global CLAUDE.md / AGENTS.md style files from local AI tools"),actions:a.jsxs(a.Fragment,{children:[a.jsxs(fn,{onClick:()=>o(!0),children:[a.jsx(QA,{className:"h-4 w-4"}),e("Import from local apps")]}),a.jsxs(fn,{onClick:()=>l("new"),children:[a.jsx(xs,{className:"h-4 w-4"}),e("Add instruction")]})]}),children:[a.jsx("p",{className:"mt-1 text-[12px] text-muted-foreground",children:e("Only one file is active at a time; enabling one disables the others")}),a.jsx(Xn,{children:t.length===0?a.jsxs("div",{className:"border-border border-b py-8 text-center",children:[a.jsx(Kp,{className:"mx-auto h-5 w-5 text-muted-foreground"}),a.jsx("p",{className:"mt-3 font-medium text-[13px]",children:e("No instruction files yet")}),a.jsx("p",{className:"mt-1 text-muted-foreground text-xs",children:e("Import instruction files from local apps or add one manually to get started")})]}):t.map(f=>a.jsxs(jn,{rowId:`instructions.${f.id}`,label:a.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[a.jsx("span",{className:ve(!f.enabled&&"text-muted-foreground line-through"),children:f.name}),a.jsx($n,{variant:"secondary",className:"text-[11px]",children:f.source}),!f.local&&a.jsxs($n,{variant:"outline",className:"gap-1 text-[11px]",children:[a.jsx(kxe,{className:"h-3 w-3"}),e("Linked")]})]}),description:a.jsx("span",{className:"block truncate",children:f.local?`${e("Local copy")} · ${nfe(f.bytes)}`:`${f.sourcePath} · ${nfe(f.bytes)}`}),status:a.jsx(gL,{row:u.rows[f.id],pending:u.pending&&!u.rows[f.id]}),children:[a.jsx($r,{checked:f.enabled,onCheckedChange:h=>n(f.id,{enabled:h})}),a.jsx(Ke,{variant:"ghost",size:"icon-sm","aria-label":e("Edit"),className:"text-muted-foreground",onClick:()=>l(f),children:a.jsx(Pi,{className:"h-3.5 w-3.5"})}),a.jsx(Ke,{variant:"ghost",size:"icon-sm","aria-label":e("Delete"),className:"text-muted-foreground hover:text-destructive-text",onClick:()=>r(f.id),children:a.jsx(io,{className:"h-3.5 w-3.5"})})]},f.id))}),a.jsx(pL,{kind:"instruction",open:s,onOpenChange:o}),a.jsx(EGt,{instruction:i,onClose:()=>l(null)})]})}const AGt=(e,t)=>`plugin:${e}:${t}`;function uMe(e,t,n){const r=new Map;for(const[i,l]of Object.entries(n))l&&r.set(l,i);const s=new Map;return{rows:e.map(i=>{const l=AGt(i.pluginId,i.id),c=t[l]!==void 0,u=c?t[l]:i.key??"",d=u?r.get(u):void 0;return u&&!d&&(r.set(u,l),s.set(u,i)),{action:l,command:i,binding:u,custom:c,...d?{conflict:d}:{}}}),byBinding:s}}const dMe="relative inline-flex h-(--settings-control-h) min-w-14 items-center justify-center rounded-md px-1.5 transition-colors";function i4({title:e,onClick:t,children:n}){return a.jsx(Ke,{size:"icon-xs",variant:"ghost",title:e,onClick:t,className:"text-muted-foreground hover:text-foreground pointer-coarse:size-[44px]",children:n})}function NGt(){const{t:e}=Se();return a.jsxs(yi,{rowId:"shortcuts.root",title:e("Shortcuts"),description:e("Click a shortcut to rebind it. Backspace removes it; Esc cancels."),children:[a.jsx(RGt,{}),a.jsx(jGt,{})]})}function IGt(){const[e,t]=y.useState([]);return y.useEffect(()=>{const n=window.electronAPI.extensionPlugins;let r=!0;const s=()=>{n.list().then(i=>r&&t(Sje(i)))};s();const o=n.onChanged(s);return()=>{r=!1,o()}},[]),e}function jGt(){const{t:e}=Se(),t=IGt(),n=be(m=>m.keybindings),r=be(m=>m.setKeybinding),s=be(m=>m.resetKeybinding),[o,i]=y.useState(null),[l,c]=y.useState(null);if(t.length===0)return null;const u=Rh(n),{rows:d}=uMe(t,n,u),f=m=>d.find(v=>v.action===m)?.command.title??e(NH[m]??m),h=()=>{i(null),c(null)},p=(m,v,b)=>{if(m.preventDefault(),m.stopPropagation(),m.key==="Escape")return h();if(m.key==="Backspace"||m.key==="Delete")return r(v,""),h();const x=Yv(m);if(!x)return;const S=AH.find(k=>u[k]===x)??d.find(k=>k.action!==v&&!k.conflict&&k.binding===x)?.action;if(S)return c(S);x===b?s(v):r(v,x),h()};return a.jsx(Xn,{title:"插件命令",children:d.map(({action:m,command:v,binding:b,custom:x,conflict:S})=>{const k=o===m;return a.jsxs(jn,{label:v.title,description:a.jsxs(a.Fragment,{children:[v.pluginName,S&&!k&&a.jsx("span",{className:"ml-2 text-destructive-text",children:e('Already used by "{{label}}"',{label:f(S)})})]}),status:k&&l&&a.jsx("span",{className:"text-[12px] text-destructive-text",children:e('Already used by "{{label}}"',{label:f(l)})}),children:[b&&!k&&a.jsx(i4,{title:e("Remove shortcut"),onClick:()=>r(m,""),children:a.jsx(Jr,{className:"h-3.5 w-3.5"})}),x&&!k&&a.jsx(i4,{title:e("Reset to default"),onClick:()=>s(m),children:a.jsx($u,{className:"h-3.5 w-3.5"})}),a.jsx("button",{type:"button",onClick:()=>{i(m),c(null)},onKeyDown:k?C=>p(C,m,v.key):void 0,onBlur:()=>k&&h(),autoFocus:k,className:ve(dMe,k?"ring-1 ring-ring":"hover:bg-muted",S&&!k&&"opacity-50 line-through"),children:k?a.jsx("span",{className:"text-muted-foreground text-xs",children:e("Press shortcut…")}):b?a.jsx(Ed,{children:Fd(b)}):a.jsx("span",{className:"text-muted-foreground text-xs",children:e("No shortcut")})})]},m)})})}function RGt(){const{t:e}=Se(),t=be(d=>d.keybindings),n=be(d=>d.setKeybinding),r=be(d=>d.resetKeybinding),[s,o]=y.useState(null),[i,l]=y.useState(null),c=Rh(t),u=d=>{if(d.preventDefault(),d.stopPropagation(),!s)return;if(d.key==="Escape"){o(null),l(null);return}if(d.key==="Backspace"||d.key==="Delete"){n(s,""),o(null),l(null);return}const f=Yv(d,{allowBare:s==="send-message"});if(!f)return;const h=AH.find(p=>p!==s&&c[p]===f);if(h){l(h);return}f===u2e[s]?r(s):n(s,f),o(null),l(null)};return a.jsx(Xn,{children:AH.map(d=>{const f=s===d,h=t[d]!==void 0,p=c[d],m=oct[d];return a.jsxs(jn,{label:e(NH[d]),description:m&&e(m),status:f&&i&&a.jsx("span",{className:"text-[12px] text-destructive-text",children:e('Already used by "{{label}}"',{label:e(NH[i])})}),children:[p&&!f&&a.jsx(i4,{title:e("Remove shortcut"),onClick:()=>n(d,""),children:a.jsx(Jr,{className:"h-3.5 w-3.5"})}),h&&!f&&a.jsx(i4,{title:e("Reset to default"),onClick:()=>r(d),children:a.jsx($u,{className:"h-3.5 w-3.5"})}),a.jsx("button",{type:"button",onClick:()=>{o(d),l(null)},onKeyDown:f?u:void 0,onBlur:()=>{f&&(o(null),l(null))},autoFocus:f,className:ve(dMe,f?"ring-1 ring-ring":"hover:bg-muted"),children:f?a.jsx("span",{className:"text-xs text-muted-foreground",children:e("Press shortcut…")}):p?a.jsx(Ed,{children:Fd(p)}):a.jsx("span",{className:"text-xs text-muted-foreground",children:e("No shortcut")})})]},d)})})}const rfe=[1,6,24,72,168],MGt=24;function _Gt(){const{t:e}=Se();if(Mh())return null;const t=async()=>{try{const n=await window.electronAPI.window.openDevTools();if(n.ok)return;Ht({type:"error",title:e("Could not open developer tools"),description:n.error==="main-window-unavailable"?e("The main window is closed. Open it and try again."):n.error})}catch(n){Ht({type:"error",title:e("Could not open developer tools"),description:n instanceof Error?n.message:String(n)})}};return a.jsx(jn,{rowId:"logs.devTools",label:e("Developer tools"),description:e("Open the console of the main window to see errors and logs."),children:a.jsx(fn,{onClick:()=>{t()},children:e("Open")})})}const PGt={main:"Main process",agent:"Agent worker",plugin:"Plugin",mcp:"MCP"},LGt={main:"bg-sky-500/10 text-sky-600 dark:text-sky-400",agent:"bg-violet-500/10 text-violet-600 dark:text-violet-400",plugin:"bg-amber-500/10 text-amber-600 dark:text-amber-400",mcp:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400"},OGt={1:"Last hour",6:"Last 6 hours",24:"Last 24 hours",72:"Last 3 days",168:"Last 7 days"};function DGt(){const{t:e}=Se();return a.jsxs(yi,{title:e("Logs"),description:e("Recent errors and log export. API keys, tokens and passwords are masked."),children:[a.jsx(BGt,{}),a.jsx(FGt,{}),a.jsx(zGt,{}),a.jsx(Xn,{title:e("Troubleshooting"),children:a.jsx(_Gt,{})})]})}function BGt(){const{t:e}=Se(),t=be(o=>o.appLoggingEnabled===!0),n=be(o=>o.setAppLoggingEnabled),r=be(o=>o.pluginLoggingEnabled===!0),s=be(o=>o.setPluginLoggingEnabled);return a.jsxs(Xn,{children:[a.jsx(jn,{label:e("Record app logs"),description:e("Off by default. Write main process and agent logs to disk. Files needed for restart recovery are always kept."),children:a.jsx($r,{checked:t,onCheckedChange:n})}),a.jsx(jn,{label:e("Record plugin logs"),description:e("Off by default. Record plugin console output and runtime logs to disk. Startup failures and crashes are still shown."),children:a.jsx($r,{checked:r,onCheckedChange:s})})]})}function FGt(){const{t:e}=Se(),t=be(p=>p.appLoggingEnabled===!0),n=be(p=>p.setAppLoggingEnabled),[r,s]=y.useState("error"),[o,i]=y.useState(null),[l,c]=y.useState(!1),[u,d]=y.useState(null),f=y.useRef(0),h=y.useCallback(async p=>{const m=++f.current;c(!0);try{const v=await window.electronAPI.logs.errors(p);if(f.current!==m)return;i(v.map((b,x)=>({key:`${x}:${b.time}`,entry:b}))),d(null)}catch{if(f.current!==m)return;i([])}finally{f.current===m&&c(!1)}},[]);return y.useEffect(()=>{h(r)},[r,h]),a.jsxs(Xn,{title:e("Recent errors"),actions:a.jsxs(a.Fragment,{children:[a.jsx(nX,{"aria-label":e("Recent errors"),value:r,onValueChange:s,options:[{value:"error",label:e("Errors only")},{value:"warn",label:e("Warnings and errors")}]}),a.jsx(fn,{"aria-label":e("Refresh"),disabled:l,onClick:()=>{h(r)},children:a.jsx(bo,{className:ve("h-3.5 w-3.5",l&&"animate-spin")})})]}),children:[!t&&a.jsx(jn,{label:e("App logging is off"),description:e("New app logs are not recorded while off. Existing logs are kept below."),children:a.jsx(fn,{onClick:()=>n(!0),children:e("Enable app logging")})}),o&&o.length===0?a.jsx("p",{className:"border-border border-b py-6 text-center text-[13px] text-muted-foreground",children:e("No errors recorded.")}):a.jsx("ul",{children:(o??[]).map(({key:p,entry:m})=>{const v=u===p;return a.jsxs("li",{className:"border-border border-b",children:[a.jsxs("button",{type:"button",className:"-mx-2 flex min-h-[44px] w-[calc(100%+1rem)] items-center gap-2 rounded-md px-2 py-2 text-left text-[13px] hover:bg-accent/50","aria-expanded":v,onClick:()=>d(v?null:p),children:[a.jsx(Bs,{className:ve("h-3.5 w-3.5 shrink-0 transition-transform",v&&"rotate-90")}),a.jsx("span",{className:"shrink-0 tabular-nums text-xs text-muted-foreground",children:new Date(m.time).toLocaleString()}),a.jsx("span",{className:ve("shrink-0 rounded px-1.5 py-0.5 text-xs",LGt[m.source]),children:e(PGt[m.source])}),m.level==="warn"&&a.jsx("span",{className:"shrink-0 text-xs text-amber-600 dark:text-amber-400",children:e("Warning")}),a.jsx("span",{className:"min-w-0 flex-1 truncate",children:m.message})]}),v&&a.jsx("pre",{className:"mb-3 max-h-72 overflow-auto whitespace-pre-wrap break-all rounded-md bg-muted/40 px-3 py-2 font-mono text-xs",children:m.detail})]},p)})})]})}function zGt(){const{t:e}=Se(),t=be(l=>l.appLoggingEnabled===!0),[n,r]=y.useState(MGt),[s,o]=y.useState(!1),i=async()=>{o(!0);try{const l=await window.electronAPI.logs.export(n);l.ok?l.cancelled||Ht({type:"success",title:e("Logs exported"),description:l.path,actions:[{label:e("Show in folder"),onClick:()=>{window.electronAPI.logs.revealExport()}}]}):Ht({type:"error",title:e("Log export failed"),description:l.error})}finally{o(!1)}};return a.jsx(Xn,{title:e("Export logs"),description:e("Pack logs from the selected period into a zip file for troubleshooting."),children:a.jsxs(jn,{label:e("Time range"),description:t?void 0:e("App logging is off. The export only includes logs recorded earlier."),children:[a.jsx(Zo,{value:String(n),onValueChange:l=>{const c=rfe.find(u=>String(u)===l);c&&r(c)},options:rfe.map(l=>({value:String(l),label:e(OGt[l])}))}),a.jsxs(fn,{variant:"default",disabled:s,onClick:()=>{i()},children:[a.jsx(Lf,{className:"h-3.5 w-3.5"}),e(s?"Exporting...":"Export")]})]})})}function HGt(e){return e.serverId??e.serverName}function fMe(e,t){const n={...e};return t.serverId&&delete n[t.serverName],n[HGt(t)]={state:t.state,...t.toolCount!==void 0?{toolCount:t.toolCount}:{},...t.error?{error:t.error}:{}},n}function UGt(e){return e.reduce((t,n)=>fMe(t,n),{})}function VGt(e,t){return{...e,[t]:{state:"connecting"}}}function GGt(e,t,n){return{...e,[t]:{state:"error",...n?{error:n}:{}}}}const C7=(e,t)=>{const n={...e};return delete n[t],n},vb=di()((e,t)=>({statuses:{},authorized:{},pending:{},bind:()=>(window.electronAPI.mcp.authState().then(n=>e({authorized:n})).catch(()=>{}),window.electronAPI.mcp.statusSnapshot().then(n=>e({statuses:{...t().statuses,...UGt(n)}})).catch(()=>{}),window.electronAPI.mcp.onStatus(n=>{if(n.type==="mcp-status-cleared"){e({statuses:{}});return}e({statuses:fMe(t().statuses,n)}),window.electronAPI.mcp.authState().then(r=>e({authorized:r})).catch(()=>{})})),authorize:async n=>{e({statuses:VGt(t().statuses,n),pending:{...t().pending,[n]:!0}});let r;try{r=await window.electronAPI.mcp.authorize(n)}catch(s){r={ok:!1,error:s instanceof Error?s.message:String(s)}}e({pending:C7(t().pending,n),...r.ok?{authorized:{...t().authorized,[n]:!0}}:{statuses:GGt(t().statuses,n,r.error)}})},revoke:async n=>{await window.electronAPI.mcp.revoke(n),e({authorized:C7(t().authorized,n),statuses:C7(t().statuses,n)})}})),Hp=e=>typeof e=="string"?e.trim():"",WGt=e=>Array.isArray(e)?e.filter(t=>typeof t=="string"):[],hMe=e=>{if(!e||typeof e!="object")return{};const t={};for(const[n,r]of Object.entries(e))typeof r=="string"&&(t[n]=r);return t};function qGt(e){const t=hMe(e);return delete t[""],Object.keys(t).length>0?t:void 0}function sfe(e){const t={};for(const n of e.split(`
788
788
  `)){const r=n.indexOf(":"),s=r>0?n.slice(0,r).trim():"";s&&(t[s]=n.slice(r+1).trim())}return Object.keys(t).length>0?t:void 0}const ofe=e=>Object.entries(e??{}).map(([t,n])=>`${t}: ${n}`).join(`
789
789
  `);function YGt(e,t){const n=Hp(e).toLowerCase();return n==="sse"?"sse":n==="http"||n==="streamable-http"?"http":n==="stdio"?"stdio":t?"http":"stdio"}function ife(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,r]of Object.entries(e)){if(!r||typeof r!="object")continue;const s=r,o=Hp(s.url)||Hp(s.serverUrl),i=Hp(s.command);if(!i&&!o)continue;const l=i?void 0:qGt(s.headers);t.push({name:n,transport:YGt(s.type??s.transport,o),command:i||void 0,args:i?WGt(s.args):void 0,env:i?hMe(s.env):void 0,url:o||void 0,...l?{headers:l}:{}})}return t}const $Gt=e=>{const t=e.trim();return(t.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/i)?.[1]??t).trim()},KGt=e=>e.startsWith('"')&&!e.startsWith("{")&&!e.startsWith("[")?`{${e}}`:e,XGt=e=>{if(!e||typeof e!="object"||Array.isArray(e))return e;const t=e;if(t.mcpServers!=null)return t.mcpServers;if(t.mcp_servers!=null)return t.mcp_servers;if(t.servers!=null)return t.servers;const n=t.mcp;if(n&&typeof n=="object"&&!Array.isArray(n)){const r=n.servers;if(r!=null)return r}return e},QGt=e=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return!!(Hp(t.command)||Hp(t.url)||Hp(t.serverUrl))},ZGt=e=>{const t=Hp(e.command);return t&&t.split(/[\\/]/).pop()?.trim()||"mcp"},HV=e=>{if(Array.isArray(e))return e.flatMap(HV);if(QGt(e)){const t=Hp(e.name)||Hp(e.id)||ZGt(e);return ife({[t]:e})}return ife(e)};function E7(e){let t;try{t=JSON.parse(KGt($Gt(e)))}catch{return{ok:!1,error:"invalid-json"}}const n=Array.isArray(t)?t.flatMap(HV):HV(XGt(t));return n.length===0?{ok:!1,error:"empty"}:{ok:!0,servers:n}}const JGt=1e4,eWt=12e4,tWt=600,nWt=3600;function afe(e,t){let n;if(typeof e=="string"){const r=e.trim();if(!r||!/^\d+$/.test(r))return;n=Number(r)}else if(typeof e=="number")n=e;else return;if(!(!Number.isInteger(n)||n<=0))return t===void 0?n:Math.min(n,t)}const a4=10,l4=13,rWt=4,sWt=40;function YX(e){const t=[0];let n=e.indexOf("\r"),r=e.indexOf(`
790
790
  `),s=0,o=0;for(;n!==-1||r!==-1;){let i;if(n!==-1&&(r===-1||n<r)?r===n+1?(i=r+1,n=e.indexOf("\r",i),r=e.indexOf(`
@@ -3000,4 +3000,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
3000
3000
  ${l.waitingIds.join(`
3001
3001
  `)}`}),[n,...r]=t.split(`
3002
3002
  `).filter((i,l)=>l===0||i),s=Number(n);if(s===0&&r.length===0)return null;const o=[s>0?e("{{n}} sessions running",{n:s}):null,r.length>0?e("{{n}} waiting for you",{n:r.length}):null].filter(Boolean);return a.jsxs("button",{type:"button","data-enso":"settings-activity",onClick:()=>{lT();const i=r[0];i&&(oP(),it.getState().selectConversation(i))},className:"mx-2 mb-2 flex min-h-9 shrink-0 items-center gap-2 rounded-md px-2 text-left text-xs text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground max-md:min-h-11",children:[a.jsx("span",{"aria-hidden":!0,className:ve("h-1.5 w-1.5 shrink-0 rounded-full",r.length>0?"bg-amber-500":"bg-emerald-500")}),a.jsx("span",{className:"truncate",children:o.join(" · ")})]})}function Nan({navWidth:e,onNavResize:t,open:n}){const r=wc(l=>l.settings),s=wc(l=>l.lastCategory),o=wc(l=>l.mobileDetail);y.useEffect(()=>{if(!n)return;let l=!1;const c=d=>{d.key==="Escape"&&(l=hUt(document))},u=d=>{pUt(d,l)&&(d.preventDefault(),lT())};return window.addEventListener("keydown",c,!0),window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",c,!0),window.removeEventListener("keydown",u)}},[n]);const i=y.useMemo(()=>({initialCategory:s,onCategoryChange:gLe,mobileDetail:o,onMobileDetailChange:i0e,onBack:lT,navWidth:e,onNavResize:t,footer:a.jsx(Aan,{})}),[s,o,e,t]);return a.jsx(Tan,{link:r?.link??null,linkSeq:r?.linkSeq??0,embedded:i})}function PQ(){return Ql()&&it.persist.hasHydrated()&&be.persist.hasHydrated()}function Dge(e,t){PQ()&&e>0&&(async()=>(t&&await it.getState().refreshWorktreeStatuses(),await it.getState().autoArchiveStaleConversations()))()}function Bge(e){!PQ()||!(e>0)||it.getState().autoDeleteStaleArchived()}function Ian(){const e=be(r=>r.autoArchiveIdleDays),t=be(r=>r.autoArchiveMergedWorktrees),n=be(r=>r.autoDeleteArchivedDays);y.useEffect(()=>{if(PQ()){Dge(e,t),Bge(n);return}const r=()=>{Dge(e,t),Bge(n)},s=[it.persist.onFinishHydration(r),be.persist.onFinishHydration(r)];return()=>{for(const o of s)o()}},[e,t,n])}function jan(){const e=it(t=>Math.min(999,Det(t.order,RN(t.conversations))));y.useEffect(()=>{window.electronAPI.app.setBadgeCount(e)},[e])}function Ran(){const e=be(n=>n.generationStallTimeoutMin),{t}=Se();y.useEffect(()=>{if(e<=0)return;const n=new Set,r=new Set,s=new Map,o=setInterval(()=>{if(!Ql())return;const i=e*6e4,l=Date.now(),c=it.getState();for(const u of Object.values(c.conversations)){u.status==="running"&&u.lastOutputAt&&s.delete(u.id);const d=(u.coworkerIds??[]).some(h=>!!c.conversations[h]?.spawning),f=Con({shouldAbort:yon({status:u.status,spawning:u.spawning,lastOutputAt:Son(u,c.conversations),now:l,timeoutMs:i,hasLiveWork:kon({...won(u),spawningCoworker:d})}),status:u.status,spawning:u.spawning,pendingRetry:r.has(u.id),attempts:s.get(u.id)??0});if(f==="abort"){if(n.has(u.id))continue;n.add(u.id),r.add(u.id),window.electronAPI.agent.abort(u.id).finally(()=>{n.delete(u.id)}),Ht(Fge(u,t("No output for {{minutes}} minutes — retrying",{minutes:e})));continue}if(f==="retry"){r.delete(u.id),s.set(u.id,(s.get(u.id)??0)+1),c.retry(u.id);continue}f==="give-up"&&(r.delete(u.id),s.delete(u.id),Ht(Fge(u,t("Stopped after repeated stalls"))))}},1e3);return()=>clearInterval(o)},[e,t])}function Fge(e,t){const n=(e.coworkerName||e.title).split(`
3003
- `)[0].trim();return n?{type:"warning",title:n,description:t}:{type:"warning",title:t}}function Man(e){return{at:e.exitAt,kind:e.kind,unfinishedTools:[...e.unfinishedTools],...e.suppressedError?{suppressedError:e.suppressedError}:{}}}function _an(e){return e?e.status!=="running":!1}const Pan=3e4;function Lan(e,t=Pan){return e()?Promise.resolve(!0):new Promise(n=>{const r=l=>{clearTimeout(i);for(const c of o)c();n(l)},s=()=>e()&&r(!0),o=[it.subscribe(s),Ri.subscribe(s),be.subscribe(s)],i=setTimeout(()=>r(e()),t)})}function Oan(){const e=Ri.getState().snapshot.availability.status;return it.persist.hasHydrated()&&be.persist.hasHydrated()&&e!=="unloaded"&&e!=="loading"}function Dan(){const{t:e}=Se();y.useEffect(()=>{Ql()&&(async()=>{const t=await window.electronAPI.agent.takeInterruptedTurns().catch(()=>[]);if(t.length===0||!await Lan(Oan))return;const n=new Set;for(const r of t)_an(it.getState().conversations[r.conversationId])&&(n.add(r.conversationId),it.setState(s=>{const o=s.conversations[r.conversationId];return!o||o.status==="running"?s:{conversations:{...s.conversations,[r.conversationId]:{...o,status:"interrupted",interrupted:Man(r),error:void 0}}}}));n.size!==0&&Ht({type:"info",title:e("{{count}} conversation(s) interrupted by app exit",{count:n.size})})})()},[e])}const Ban=3e4;function Fan(e,t=Ban){return e()?Promise.resolve(!0):new Promise(n=>{const r=l=>{clearTimeout(i);for(const c of o)c();n(l)},s=()=>e()&&r(!0),o=[it.subscribe(s),be.subscribe(s)],i=setTimeout(()=>r(e()),t)})}function zan(){return it.persist.hasHydrated()&&be.persist.hasHydrated()}function Han(){const{t:e}=Se();y.useEffect(()=>{if(!Ql())return;const t=()=>{OH(async()=>{if(!await Fan(zan))return;const r=await window.electronAPI.window.takeOpenFolders().catch(()=>[]);let s=!1;for(const o of r)try{if(!await Y2e(o)){Ht({type:"error",title:e("Failed to add project")});continue}s=!0}catch(i){Ht({type:"error",title:e("Failed to add project"),description:i instanceof Error?i.message:String(i)})}s&&oP()})},n=window.electronAPI.window.onOpenFolderRequested(t);return t(),n},[e])}const zge="enso-win",D_e="enso-win-flush",pj="enso-win-pending",Hge="enso-win-native";function Uan(e,t,n){return{maximized:n.maximized?e.maximized:t.maximized,fullscreen:n.fullscreen?e.fullscreen:t.fullscreen}}function Van(e,t){return e||t}function Gan(e,t){document.documentElement.classList.toggle(D_e,Van(e,t))}function Wan(){y.useEffect(()=>{if(window.electronAPI?.env.platform!=="win32")return;const e=document.documentElement;e.classList.add(zge,pj),e.classList.add(Hge);let t={maximized:!1,fullscreen:!1};const n={maximized:0,fullscreen:0};let r=!1,s=0,o;const i=()=>Gan(t.maximized,t.fullscreen),l=window.electronAPI.window,c=()=>{const h=++s,p={...n};Promise.all([l.isMaximized(),l.isFullScreen()]).then(([m,v])=>{r||h!==s||(t=Uan(t,{maximized:m,fullscreen:v},{maximized:n.maximized!==p.maximized,fullscreen:n.fullscreen!==p.fullscreen}),e.classList.remove(pj),i())}).catch(()=>{!r&&h===s&&e.classList.remove(pj)})};c();const u=()=>{o&&clearTimeout(o),o=setTimeout(c,50)};window.addEventListener("resize",u);const d=l.onMaximizedChange(h=>{n.maximized+=1,t.maximized=h,i()}),f=l.onFullScreenChange(h=>{n.fullscreen+=1,t.fullscreen=h,i()});return()=>{r=!0,o&&clearTimeout(o),window.removeEventListener("resize",u),d(),f(),e.classList.remove(zge,D_e,pj,Hge)}},[])}function qan(e){const t=()=>{e.consumeSettingsDeepLink().then(n=>{n&&nu(n.link)})};return t(),e.onSettingsDeepLink(t)}const B_e="ensoSettingsDepth",Uge=e=>{const t=e?.[B_e];return typeof t=="number"?t:0};function Yan(e,t){let n=Uge(e.history.state),r=!1;const s=()=>{if(r)return;const l=t.depth();for(;n<l;)n+=1,e.history.pushState({[B_e]:n},"");n>l&&(r=!0,e.history.go(l-n))},o=l=>{if(n=Uge(l.state),r){r=!1,s();return}t.depth()!==n&&t.apply(n)};e.addEventListener("popstate",o);const i=t.subscribe(s);return s(),()=>{i(),e.removeEventListener("popstate",o)}}const Vge=new Set;function $an(e){return Vge.add(e),()=>Vge.delete(e)}const mj={duration:180,easing:"cubic-bezier(0.22, 1, 0.36, 1)",shift:10,underlayHold:.6};function Kan(e){let t=null,n=[];const r=()=>{for(const i of n)i.cancel();n=[]},s=()=>{t&&(n.push(...t.animations),t=null,e.onSettle())};return{run:(i,l)=>{if(e.reducedMotion())return s(),r(),{animating:!1,top:i};if(t){if(t.to!==i){t.to=i;for(const v of t.animations)v.reverse()}return{animating:!0,top:t.top}}r();const c=i==="settings"?"workbench":"settings",u=mj.shift*(i==="settings"?1:-1),d=v=>({duration:mj.duration,easing:v,fill:"both"}),f=d(mj.easing),h=v=>`translateX(${v}px)`,p=[l[c].sidebar?.animate([{opacity:1,transform:h(0)},{opacity:0,transform:h(-u)}],f),l[i].sidebar?.animate([{opacity:0,transform:h(u)},{opacity:1,transform:h(0)}],f),l[c].main?.animate([{opacity:1},{opacity:1,offset:mj.underlayHold},{opacity:0}],d("linear")),l[i].main?.animate([{opacity:0},{opacity:1}],f)].filter(v=>v!==void 0),m={to:i,top:i,animations:p};return t=m,Promise.all(p.map(v=>v.finished)).then(()=>{t===m&&s()},()=>{}),{animating:!0,top:i}},target:()=>t?.to??null,release:r,finish:()=>{s(),r()}}}function Xan(e){return{settingsMounted:e.open||e.shown||e.animating,workbenchHidden:e.open&&e.shown&&!e.animating}}const Qan=()=>typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;function Zan(e){return{category:"plugins",rowId:"plugins.enso",pluginId:e}}const FF=e=>typeof e=="string"&&e.length>0?e:null;function Jan(e){if(!e||typeof e!="object")return null;const t=e,n=FF(t.pluginId),r=FF(t.name);if(!n||!r)return null;if(t.kind==="inject-denied")return{type:"warning",titleKey:"{{name}} tried to message another session and was blocked",params:{name:r},actionKey:"Turn on",pluginId:n};const s=FF(t.version);return s?t.kind==="update-needs-approval"?{type:"warning",titleKey:"{{name}} {{version}} needs new permissions",params:{name:r,version:s},actionKey:"Review permissions",pluginId:n}:t.kind==="auto-updated"?{type:"success",titleKey:"{{name}} updated to {{version}}",params:{name:r,version:s},actionKey:"View",pluginId:n}:null:null}function eln(){const{t:e}=Se();return y.useEffect(()=>window.electronAPI.extensionPlugins.onNotice(t=>{const n=Jan(t);n&&Ht({type:n.type,title:e(n.titleKey,n.params),...n.actionKey?{actions:[{label:e(n.actionKey),onClick:()=>{nu(Zan(n.pluginId))}}]}:{}})}),[e]),null}function tln(e,t){const n=new Set,r=[];for(const s of e)for(const o of s.interceptBreakers??[]){const i=`${s.id}:${o.event}:${o.until}`;n.add(i),t.has(i)||r.push({pluginName:s.name,event:o.event})}t.clear();for(const s of n)t.add(s);return r}function nln(e,t){let n=0;for(const r of t)e.length>r.length&&e.endsWith(r)&&r.length>n&&(n=r.length);return n}function Ucn(e,t){const n=(e.split("/").at(-1)??"").toLowerCase();return t.map(r=>({viewer:r,length:nln(n,r.extensions)})).filter(r=>r.length>0).sort((r,s)=>s.length-r.length).map(r=>r.viewer)}const Vcn=e=>`${e.pluginId}:${e.id}`;let F_e=[];const LG=new Set;function Gge(e){F_e=e;for(const t of LG)t()}function rln(e){return LG.add(e),()=>LG.delete(e)}const Wge=()=>F_e;function Gcn(){return y.useSyncExternalStore(rln,Wge,Wge)}function qge(e){const t=e.permissions.includes("composer.draft")?"1":"0";return`${e.id}\0${e.version}\0${e.build}\0${e.renderer??""}\0${t}`}function z_e(e,t){try{t?.dispose()}catch(n){console.warn(`[plugin] ${e} 渲染模块卸载失败`,n)}}async function sln(e,t,n,r){if(!r())return;const s=new Map;for(const i of t)i.state==="enabled"&&i.renderer&&s.set(i.id,{...i,renderer:i.renderer});const o=[];for(const[i,l]of e){const c=s.get(i);(!c||qge(c)!==l.key)&&o.push(i)}for(const i of o)z_e(i,e.get(i)),e.delete(i);await Promise.allSettled([...s.values()].filter(i=>!e.has(i.id)).map(async i=>{if(!r())return;let l;try{l=await n(i)}catch(d){if(!r())return;console.warn(`[plugin] ${i.id} 渲染模块加载失败`,d);return}if(!r()){l.dispose();return}const c=qge(i),u=e.get(i.id);if(u?.key===c){l.dispose();return}u?.dispose(),e.set(i.id,{key:c,dispose:()=>l.dispose()})}))}const Kl=(e,t)=>({ok:!1,code:e,error:t});async function oln(e,t){if(e.op==="focusSession"){const i=e.payload.sessionId;if(typeof i!="string"||!i)return Kl("BAD_REQUEST","缺少会话 id");const l=t.conversation(i);if(l)return t.focus(l.parentId??i,i),{ok:!0,value:null};const c=i.indexOf("::");if(c>0){const u=i.slice(0,c);return t.conversation(u)?(t.focusSubagent(u,i),{ok:!0,value:null}):Kl("NOT_FOUND","会话不在本窗口")}return Kl("NOT_FOUND","会话不在本窗口")}if(e.op==="openChildRun"){const i=e.payload.parentId,l=e.payload.childId;return typeof i!="string"||!i?Kl("BAD_REQUEST","缺少父会话 id"):typeof l!="string"||!l?Kl("BAD_REQUEST","缺少子会话 id"):t.conversation(i)?(t.openChildRun(i,l),{ok:!0,value:null}):Kl("NOT_FOUND","会话不在本窗口")}if(e.op==="focusSubagent"){const i=e.payload.sessionId,l=e.payload.agentId;return typeof i!="string"||!t.conversation(i)?Kl("NOT_FOUND","会话不在本窗口"):typeof l!="string"||!l?Kl("BAD_REQUEST","缺少子代理 id"):(t.focusSubagent(i,l),{ok:!0,value:null})}if(e.op==="ensureSession"){const i=t.conversation(e.sessionId);if(!i)return Kl("NOT_FOUND","会话不在本窗口");if(i.parentId)return Kl("UNSUPPORTED","子会话随主会话恢复");const l=await t.ensure(e.sessionId);return l?Kl("SESSION_FAILED",l):{ok:!0,value:null}}if(e.op==="openPluginView"){if(!t.conversation(e.sessionId))return Kl("NOT_FOUND","会话不在本窗口");const{pluginId:i,viewId:l,title:c}=e.payload;return typeof i!="string"||!i||typeof l!="string"||!l||typeof c!="string"||!c?Kl("BAD_REQUEST","缺少视图标识"):(t.openPluginView?.(e.sessionId,{pluginId:i,viewId:l,title:c}),{ok:!0,value:null})}if(e.op==="closePluginView"){if(!t.conversation(e.sessionId))return Kl("NOT_FOUND","会话不在本窗口");const{pluginId:i,viewId:l}=e.payload;return typeof i!="string"||!i||typeof l!="string"||!l?Kl("BAD_REQUEST","缺少视图标识"):(t.closePluginView?.(e.sessionId,{pluginId:i,viewId:l}),{ok:!0,value:null})}const n=t.conversation(e.sessionId);if(!n)return Kl("NO_SESSION","发起调用的会话不在本窗口");const r=typeof e.payload.presetId=="string"?e.payload.presetId:void 0,s=await t.create(n.projectId,r);if(!s)return Kl("CREATE_FAILED","新建会话失败");const o=e.payload.text;return typeof o=="string"&&o&&t.prefill(s,o),{ok:!0,value:{sessionId:s}}}const iln={conversation:e=>it.getState().conversations[e]??null,focus:(e,t)=>{const n=it.getState();n.selectConversation(e),t!==e&&n.selectTab(e,t)},focusSubagent:(e,t)=>it.getState().focusSubagent(e,t),openChildRun:(e,t)=>it.getState().openChildRun(e,t),create:(e,t)=>it.getState().newConversation(e,t?{presetId:t}:void 0),prefill:Ewt,ensure:async e=>{const t=it.getState(),n=t.conversations[e];if(n?.started||n?.spawning)return null;await t.resumeConversation(e,{fresh:!0});const r=it.getState().conversations[e];return r?.started||r?.spawning?null:r?.error??"无法启动会话:请检查默认模型与登录状态"},openPluginView:(e,t)=>MEe({conversationId:e,...t}),closePluginView:(e,t)=>awt({conversationId:e,...t})};function aln(){return y.useEffect(()=>{const e=Nwt(()=>TDt(it.getState()));let t=0;const n=new Map,r=new Set,s=()=>{const l=++t;window.electronAPI.extensionPlugins.list().then(async c=>{if(l!==t)return;for(const{pluginName:d,event:f}of tln(c,r))Ht({type:"warning",title:`插件 ${d} 的检查连续失败,已临时放行`,description:`${f} 事件 30 秒内不再经过该插件;详情见设置里的插件日志`});const u=c.filter(d=>d.state==="enabled");vjt(Object.fromEntries(c.flatMap(d=>d.icon?[[d.id,d.icon]]:[]))),rue(Sje(c)),cue(w9t(c)),dte(u.flatMap(d=>d.views.map(f=>({pluginId:d.id,pluginName:d.name,...f})))),J1t(c),Gge(u.flatMap(d=>(d.fileViewers??[]).map(f=>({pluginId:d.id,pluginName:d.name,...f})))),fue(u.flatMap(d=>d.triggers.filter(f=>f.symbol==="#").map(f=>({pluginId:d.id,name:f.name})))),await sln(n,c,d=>jwt(d.id,d.renderer,e,{draft:d.permissions.includes("composer.draft")}),()=>l===t)})};s();const o=window.electronAPI.extensionPlugins.onChanged(s),i=window.electronAPI.extensionPlugins.onDraftRequest(l=>{if(l.op==="focusSession"||l.op==="focusSubagent"||l.op==="openChildRun"||l.op==="createSession"||l.op==="ensureSession"||l.op==="openPluginView"||l.op==="closePluginView"){oln(l,iln).catch(c=>({ok:!1,code:"SESSION_FAILED",error:c instanceof Error?c.message:String(c)})).then(c=>window.electronAPI.extensionPlugins.respondDraft({requestId:l.requestId,...c}));return}window.electronAPI.extensionPlugins.respondDraft({requestId:l.requestId,...PEe(l)})});return()=>{t+=1,o(),i(),rue([]),fue([]),dte([]),Gge([]),cue([]);for(const[l,c]of n)z_e(l,c);n.clear()}},[]),null}function lln(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var zF={exports:{}};const cln={},uln=Object.freeze(Object.defineProperty({__proto__:null,default:cln},Symbol.toStringTag,{value:"Module"})),dln=UPe(uln);var Yge;function fln(){return Yge||(Yge=1,(function(e){(function(t){var n=function(fe){var Ie,Ae=new Float64Array(16);if(fe)for(Ie=0;Ie<fe.length;Ie++)Ae[Ie]=fe[Ie];return Ae},r=function(){throw new Error("no PRNG")},s=new Uint8Array(16),o=new Uint8Array(32);o[0]=9;var i=n(),l=n([1]),c=n([56129,1]),u=n([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),d=n([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),f=n([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),h=n([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),p=n([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function m(fe,Ie,Ae,ce){fe[Ie]=Ae>>24&255,fe[Ie+1]=Ae>>16&255,fe[Ie+2]=Ae>>8&255,fe[Ie+3]=Ae&255,fe[Ie+4]=ce>>24&255,fe[Ie+5]=ce>>16&255,fe[Ie+6]=ce>>8&255,fe[Ie+7]=ce&255}function v(fe,Ie,Ae,ce,Oe){var dt,vt=0;for(dt=0;dt<Oe;dt++)vt|=fe[Ie+dt]^Ae[ce+dt];return(1&vt-1>>>8)-1}function b(fe,Ie,Ae,ce){return v(fe,Ie,Ae,ce,16)}function x(fe,Ie,Ae,ce){return v(fe,Ie,Ae,ce,32)}function S(fe,Ie,Ae,ce){for(var Oe=ce[0]&255|(ce[1]&255)<<8|(ce[2]&255)<<16|(ce[3]&255)<<24,dt=Ae[0]&255|(Ae[1]&255)<<8|(Ae[2]&255)<<16|(Ae[3]&255)<<24,vt=Ae[4]&255|(Ae[5]&255)<<8|(Ae[6]&255)<<16|(Ae[7]&255)<<24,Et=Ae[8]&255|(Ae[9]&255)<<8|(Ae[10]&255)<<16|(Ae[11]&255)<<24,Ct=Ae[12]&255|(Ae[13]&255)<<8|(Ae[14]&255)<<16|(Ae[15]&255)<<24,xn=ce[4]&255|(ce[5]&255)<<8|(ce[6]&255)<<16|(ce[7]&255)<<24,yn=Ie[0]&255|(Ie[1]&255)<<8|(Ie[2]&255)<<16|(Ie[3]&255)<<24,er=Ie[4]&255|(Ie[5]&255)<<8|(Ie[6]&255)<<16|(Ie[7]&255)<<24,Fe=Ie[8]&255|(Ie[9]&255)<<8|(Ie[10]&255)<<16|(Ie[11]&255)<<24,We=Ie[12]&255|(Ie[13]&255)<<8|(Ie[14]&255)<<16|(Ie[15]&255)<<24,lt=ce[8]&255|(ce[9]&255)<<8|(ce[10]&255)<<16|(ce[11]&255)<<24,yt=Ae[16]&255|(Ae[17]&255)<<8|(Ae[18]&255)<<16|(Ae[19]&255)<<24,Bt=Ae[20]&255|(Ae[21]&255)<<8|(Ae[22]&255)<<16|(Ae[23]&255)<<24,Qt=Ae[24]&255|(Ae[25]&255)<<8|(Ae[26]&255)<<16|(Ae[27]&255)<<24,dn=Ae[28]&255|(Ae[29]&255)<<8|(Ae[30]&255)<<16|(Ae[31]&255)<<24,pn=ce[12]&255|(ce[13]&255)<<8|(ce[14]&255)<<16|(ce[15]&255)<<24,Zt=Oe,An=dt,bn=vt,Ln=Et,Un=Ct,gn=xn,Tt=yn,Lt=er,nn=Fe,Ft=We,en=lt,Wt=yt,nt=Bt,Mn=Qt,Zn=dn,sr=pn,at,fr=0;fr<20;fr+=2)at=Zt+nt|0,Un^=at<<7|at>>>25,at=Un+Zt|0,nn^=at<<9|at>>>23,at=nn+Un|0,nt^=at<<13|at>>>19,at=nt+nn|0,Zt^=at<<18|at>>>14,at=gn+An|0,Ft^=at<<7|at>>>25,at=Ft+gn|0,Mn^=at<<9|at>>>23,at=Mn+Ft|0,An^=at<<13|at>>>19,at=An+Mn|0,gn^=at<<18|at>>>14,at=en+Tt|0,Zn^=at<<7|at>>>25,at=Zn+en|0,bn^=at<<9|at>>>23,at=bn+Zn|0,Tt^=at<<13|at>>>19,at=Tt+bn|0,en^=at<<18|at>>>14,at=sr+Wt|0,Ln^=at<<7|at>>>25,at=Ln+sr|0,Lt^=at<<9|at>>>23,at=Lt+Ln|0,Wt^=at<<13|at>>>19,at=Wt+Lt|0,sr^=at<<18|at>>>14,at=Zt+Ln|0,An^=at<<7|at>>>25,at=An+Zt|0,bn^=at<<9|at>>>23,at=bn+An|0,Ln^=at<<13|at>>>19,at=Ln+bn|0,Zt^=at<<18|at>>>14,at=gn+Un|0,Tt^=at<<7|at>>>25,at=Tt+gn|0,Lt^=at<<9|at>>>23,at=Lt+Tt|0,Un^=at<<13|at>>>19,at=Un+Lt|0,gn^=at<<18|at>>>14,at=en+Ft|0,Wt^=at<<7|at>>>25,at=Wt+en|0,nn^=at<<9|at>>>23,at=nn+Wt|0,Ft^=at<<13|at>>>19,at=Ft+nn|0,en^=at<<18|at>>>14,at=sr+Zn|0,nt^=at<<7|at>>>25,at=nt+sr|0,Mn^=at<<9|at>>>23,at=Mn+nt|0,Zn^=at<<13|at>>>19,at=Zn+Mn|0,sr^=at<<18|at>>>14;Zt=Zt+Oe|0,An=An+dt|0,bn=bn+vt|0,Ln=Ln+Et|0,Un=Un+Ct|0,gn=gn+xn|0,Tt=Tt+yn|0,Lt=Lt+er|0,nn=nn+Fe|0,Ft=Ft+We|0,en=en+lt|0,Wt=Wt+yt|0,nt=nt+Bt|0,Mn=Mn+Qt|0,Zn=Zn+dn|0,sr=sr+pn|0,fe[0]=Zt>>>0&255,fe[1]=Zt>>>8&255,fe[2]=Zt>>>16&255,fe[3]=Zt>>>24&255,fe[4]=An>>>0&255,fe[5]=An>>>8&255,fe[6]=An>>>16&255,fe[7]=An>>>24&255,fe[8]=bn>>>0&255,fe[9]=bn>>>8&255,fe[10]=bn>>>16&255,fe[11]=bn>>>24&255,fe[12]=Ln>>>0&255,fe[13]=Ln>>>8&255,fe[14]=Ln>>>16&255,fe[15]=Ln>>>24&255,fe[16]=Un>>>0&255,fe[17]=Un>>>8&255,fe[18]=Un>>>16&255,fe[19]=Un>>>24&255,fe[20]=gn>>>0&255,fe[21]=gn>>>8&255,fe[22]=gn>>>16&255,fe[23]=gn>>>24&255,fe[24]=Tt>>>0&255,fe[25]=Tt>>>8&255,fe[26]=Tt>>>16&255,fe[27]=Tt>>>24&255,fe[28]=Lt>>>0&255,fe[29]=Lt>>>8&255,fe[30]=Lt>>>16&255,fe[31]=Lt>>>24&255,fe[32]=nn>>>0&255,fe[33]=nn>>>8&255,fe[34]=nn>>>16&255,fe[35]=nn>>>24&255,fe[36]=Ft>>>0&255,fe[37]=Ft>>>8&255,fe[38]=Ft>>>16&255,fe[39]=Ft>>>24&255,fe[40]=en>>>0&255,fe[41]=en>>>8&255,fe[42]=en>>>16&255,fe[43]=en>>>24&255,fe[44]=Wt>>>0&255,fe[45]=Wt>>>8&255,fe[46]=Wt>>>16&255,fe[47]=Wt>>>24&255,fe[48]=nt>>>0&255,fe[49]=nt>>>8&255,fe[50]=nt>>>16&255,fe[51]=nt>>>24&255,fe[52]=Mn>>>0&255,fe[53]=Mn>>>8&255,fe[54]=Mn>>>16&255,fe[55]=Mn>>>24&255,fe[56]=Zn>>>0&255,fe[57]=Zn>>>8&255,fe[58]=Zn>>>16&255,fe[59]=Zn>>>24&255,fe[60]=sr>>>0&255,fe[61]=sr>>>8&255,fe[62]=sr>>>16&255,fe[63]=sr>>>24&255}function k(fe,Ie,Ae,ce){for(var Oe=ce[0]&255|(ce[1]&255)<<8|(ce[2]&255)<<16|(ce[3]&255)<<24,dt=Ae[0]&255|(Ae[1]&255)<<8|(Ae[2]&255)<<16|(Ae[3]&255)<<24,vt=Ae[4]&255|(Ae[5]&255)<<8|(Ae[6]&255)<<16|(Ae[7]&255)<<24,Et=Ae[8]&255|(Ae[9]&255)<<8|(Ae[10]&255)<<16|(Ae[11]&255)<<24,Ct=Ae[12]&255|(Ae[13]&255)<<8|(Ae[14]&255)<<16|(Ae[15]&255)<<24,xn=ce[4]&255|(ce[5]&255)<<8|(ce[6]&255)<<16|(ce[7]&255)<<24,yn=Ie[0]&255|(Ie[1]&255)<<8|(Ie[2]&255)<<16|(Ie[3]&255)<<24,er=Ie[4]&255|(Ie[5]&255)<<8|(Ie[6]&255)<<16|(Ie[7]&255)<<24,Fe=Ie[8]&255|(Ie[9]&255)<<8|(Ie[10]&255)<<16|(Ie[11]&255)<<24,We=Ie[12]&255|(Ie[13]&255)<<8|(Ie[14]&255)<<16|(Ie[15]&255)<<24,lt=ce[8]&255|(ce[9]&255)<<8|(ce[10]&255)<<16|(ce[11]&255)<<24,yt=Ae[16]&255|(Ae[17]&255)<<8|(Ae[18]&255)<<16|(Ae[19]&255)<<24,Bt=Ae[20]&255|(Ae[21]&255)<<8|(Ae[22]&255)<<16|(Ae[23]&255)<<24,Qt=Ae[24]&255|(Ae[25]&255)<<8|(Ae[26]&255)<<16|(Ae[27]&255)<<24,dn=Ae[28]&255|(Ae[29]&255)<<8|(Ae[30]&255)<<16|(Ae[31]&255)<<24,pn=ce[12]&255|(ce[13]&255)<<8|(ce[14]&255)<<16|(ce[15]&255)<<24,Zt=Oe,An=dt,bn=vt,Ln=Et,Un=Ct,gn=xn,Tt=yn,Lt=er,nn=Fe,Ft=We,en=lt,Wt=yt,nt=Bt,Mn=Qt,Zn=dn,sr=pn,at,fr=0;fr<20;fr+=2)at=Zt+nt|0,Un^=at<<7|at>>>25,at=Un+Zt|0,nn^=at<<9|at>>>23,at=nn+Un|0,nt^=at<<13|at>>>19,at=nt+nn|0,Zt^=at<<18|at>>>14,at=gn+An|0,Ft^=at<<7|at>>>25,at=Ft+gn|0,Mn^=at<<9|at>>>23,at=Mn+Ft|0,An^=at<<13|at>>>19,at=An+Mn|0,gn^=at<<18|at>>>14,at=en+Tt|0,Zn^=at<<7|at>>>25,at=Zn+en|0,bn^=at<<9|at>>>23,at=bn+Zn|0,Tt^=at<<13|at>>>19,at=Tt+bn|0,en^=at<<18|at>>>14,at=sr+Wt|0,Ln^=at<<7|at>>>25,at=Ln+sr|0,Lt^=at<<9|at>>>23,at=Lt+Ln|0,Wt^=at<<13|at>>>19,at=Wt+Lt|0,sr^=at<<18|at>>>14,at=Zt+Ln|0,An^=at<<7|at>>>25,at=An+Zt|0,bn^=at<<9|at>>>23,at=bn+An|0,Ln^=at<<13|at>>>19,at=Ln+bn|0,Zt^=at<<18|at>>>14,at=gn+Un|0,Tt^=at<<7|at>>>25,at=Tt+gn|0,Lt^=at<<9|at>>>23,at=Lt+Tt|0,Un^=at<<13|at>>>19,at=Un+Lt|0,gn^=at<<18|at>>>14,at=en+Ft|0,Wt^=at<<7|at>>>25,at=Wt+en|0,nn^=at<<9|at>>>23,at=nn+Wt|0,Ft^=at<<13|at>>>19,at=Ft+nn|0,en^=at<<18|at>>>14,at=sr+Zn|0,nt^=at<<7|at>>>25,at=nt+sr|0,Mn^=at<<9|at>>>23,at=Mn+nt|0,Zn^=at<<13|at>>>19,at=Zn+Mn|0,sr^=at<<18|at>>>14;fe[0]=Zt>>>0&255,fe[1]=Zt>>>8&255,fe[2]=Zt>>>16&255,fe[3]=Zt>>>24&255,fe[4]=gn>>>0&255,fe[5]=gn>>>8&255,fe[6]=gn>>>16&255,fe[7]=gn>>>24&255,fe[8]=en>>>0&255,fe[9]=en>>>8&255,fe[10]=en>>>16&255,fe[11]=en>>>24&255,fe[12]=sr>>>0&255,fe[13]=sr>>>8&255,fe[14]=sr>>>16&255,fe[15]=sr>>>24&255,fe[16]=Tt>>>0&255,fe[17]=Tt>>>8&255,fe[18]=Tt>>>16&255,fe[19]=Tt>>>24&255,fe[20]=Lt>>>0&255,fe[21]=Lt>>>8&255,fe[22]=Lt>>>16&255,fe[23]=Lt>>>24&255,fe[24]=nn>>>0&255,fe[25]=nn>>>8&255,fe[26]=nn>>>16&255,fe[27]=nn>>>24&255,fe[28]=Ft>>>0&255,fe[29]=Ft>>>8&255,fe[30]=Ft>>>16&255,fe[31]=Ft>>>24&255}function C(fe,Ie,Ae,ce){S(fe,Ie,Ae,ce)}function A(fe,Ie,Ae,ce){k(fe,Ie,Ae,ce)}var N=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function j(fe,Ie,Ae,ce,Oe,dt,vt){var Et=new Uint8Array(16),Ct=new Uint8Array(64),xn,yn;for(yn=0;yn<16;yn++)Et[yn]=0;for(yn=0;yn<8;yn++)Et[yn]=dt[yn];for(;Oe>=64;){for(C(Ct,Et,vt,N),yn=0;yn<64;yn++)fe[Ie+yn]=Ae[ce+yn]^Ct[yn];for(xn=1,yn=8;yn<16;yn++)xn=xn+(Et[yn]&255)|0,Et[yn]=xn&255,xn>>>=8;Oe-=64,Ie+=64,ce+=64}if(Oe>0)for(C(Ct,Et,vt,N),yn=0;yn<Oe;yn++)fe[Ie+yn]=Ae[ce+yn]^Ct[yn];return 0}function I(fe,Ie,Ae,ce,Oe){var dt=new Uint8Array(16),vt=new Uint8Array(64),Et,Ct;for(Ct=0;Ct<16;Ct++)dt[Ct]=0;for(Ct=0;Ct<8;Ct++)dt[Ct]=ce[Ct];for(;Ae>=64;){for(C(vt,dt,Oe,N),Ct=0;Ct<64;Ct++)fe[Ie+Ct]=vt[Ct];for(Et=1,Ct=8;Ct<16;Ct++)Et=Et+(dt[Ct]&255)|0,dt[Ct]=Et&255,Et>>>=8;Ae-=64,Ie+=64}if(Ae>0)for(C(vt,dt,Oe,N),Ct=0;Ct<Ae;Ct++)fe[Ie+Ct]=vt[Ct];return 0}function _(fe,Ie,Ae,ce,Oe){var dt=new Uint8Array(32);A(dt,ce,Oe,N);for(var vt=new Uint8Array(8),Et=0;Et<8;Et++)vt[Et]=ce[Et+16];return I(fe,Ie,Ae,vt,dt)}function L(fe,Ie,Ae,ce,Oe,dt,vt){var Et=new Uint8Array(32);A(Et,dt,vt,N);for(var Ct=new Uint8Array(8),xn=0;xn<8;xn++)Ct[xn]=dt[xn+16];return j(fe,Ie,Ae,ce,Oe,Ct,Et)}var M=function(fe){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var Ie,Ae,ce,Oe,dt,vt,Et,Ct;Ie=fe[0]&255|(fe[1]&255)<<8,this.r[0]=Ie&8191,Ae=fe[2]&255|(fe[3]&255)<<8,this.r[1]=(Ie>>>13|Ae<<3)&8191,ce=fe[4]&255|(fe[5]&255)<<8,this.r[2]=(Ae>>>10|ce<<6)&7939,Oe=fe[6]&255|(fe[7]&255)<<8,this.r[3]=(ce>>>7|Oe<<9)&8191,dt=fe[8]&255|(fe[9]&255)<<8,this.r[4]=(Oe>>>4|dt<<12)&255,this.r[5]=dt>>>1&8190,vt=fe[10]&255|(fe[11]&255)<<8,this.r[6]=(dt>>>14|vt<<2)&8191,Et=fe[12]&255|(fe[13]&255)<<8,this.r[7]=(vt>>>11|Et<<5)&8065,Ct=fe[14]&255|(fe[15]&255)<<8,this.r[8]=(Et>>>8|Ct<<8)&8191,this.r[9]=Ct>>>5&127,this.pad[0]=fe[16]&255|(fe[17]&255)<<8,this.pad[1]=fe[18]&255|(fe[19]&255)<<8,this.pad[2]=fe[20]&255|(fe[21]&255)<<8,this.pad[3]=fe[22]&255|(fe[23]&255)<<8,this.pad[4]=fe[24]&255|(fe[25]&255)<<8,this.pad[5]=fe[26]&255|(fe[27]&255)<<8,this.pad[6]=fe[28]&255|(fe[29]&255)<<8,this.pad[7]=fe[30]&255|(fe[31]&255)<<8};M.prototype.blocks=function(fe,Ie,Ae){for(var ce=this.fin?0:2048,Oe,dt,vt,Et,Ct,xn,yn,er,Fe,We,lt,yt,Bt,Qt,dn,pn,Zt,An,bn,Ln=this.h[0],Un=this.h[1],gn=this.h[2],Tt=this.h[3],Lt=this.h[4],nn=this.h[5],Ft=this.h[6],en=this.h[7],Wt=this.h[8],nt=this.h[9],Mn=this.r[0],Zn=this.r[1],sr=this.r[2],at=this.r[3],fr=this.r[4],hr=this.r[5],Xr=this.r[6],kr=this.r[7],Lr=this.r[8],pr=this.r[9];Ae>=16;)Oe=fe[Ie+0]&255|(fe[Ie+1]&255)<<8,Ln+=Oe&8191,dt=fe[Ie+2]&255|(fe[Ie+3]&255)<<8,Un+=(Oe>>>13|dt<<3)&8191,vt=fe[Ie+4]&255|(fe[Ie+5]&255)<<8,gn+=(dt>>>10|vt<<6)&8191,Et=fe[Ie+6]&255|(fe[Ie+7]&255)<<8,Tt+=(vt>>>7|Et<<9)&8191,Ct=fe[Ie+8]&255|(fe[Ie+9]&255)<<8,Lt+=(Et>>>4|Ct<<12)&8191,nn+=Ct>>>1&8191,xn=fe[Ie+10]&255|(fe[Ie+11]&255)<<8,Ft+=(Ct>>>14|xn<<2)&8191,yn=fe[Ie+12]&255|(fe[Ie+13]&255)<<8,en+=(xn>>>11|yn<<5)&8191,er=fe[Ie+14]&255|(fe[Ie+15]&255)<<8,Wt+=(yn>>>8|er<<8)&8191,nt+=er>>>5|ce,Fe=0,We=Fe,We+=Ln*Mn,We+=Un*(5*pr),We+=gn*(5*Lr),We+=Tt*(5*kr),We+=Lt*(5*Xr),Fe=We>>>13,We&=8191,We+=nn*(5*hr),We+=Ft*(5*fr),We+=en*(5*at),We+=Wt*(5*sr),We+=nt*(5*Zn),Fe+=We>>>13,We&=8191,lt=Fe,lt+=Ln*Zn,lt+=Un*Mn,lt+=gn*(5*pr),lt+=Tt*(5*Lr),lt+=Lt*(5*kr),Fe=lt>>>13,lt&=8191,lt+=nn*(5*Xr),lt+=Ft*(5*hr),lt+=en*(5*fr),lt+=Wt*(5*at),lt+=nt*(5*sr),Fe+=lt>>>13,lt&=8191,yt=Fe,yt+=Ln*sr,yt+=Un*Zn,yt+=gn*Mn,yt+=Tt*(5*pr),yt+=Lt*(5*Lr),Fe=yt>>>13,yt&=8191,yt+=nn*(5*kr),yt+=Ft*(5*Xr),yt+=en*(5*hr),yt+=Wt*(5*fr),yt+=nt*(5*at),Fe+=yt>>>13,yt&=8191,Bt=Fe,Bt+=Ln*at,Bt+=Un*sr,Bt+=gn*Zn,Bt+=Tt*Mn,Bt+=Lt*(5*pr),Fe=Bt>>>13,Bt&=8191,Bt+=nn*(5*Lr),Bt+=Ft*(5*kr),Bt+=en*(5*Xr),Bt+=Wt*(5*hr),Bt+=nt*(5*fr),Fe+=Bt>>>13,Bt&=8191,Qt=Fe,Qt+=Ln*fr,Qt+=Un*at,Qt+=gn*sr,Qt+=Tt*Zn,Qt+=Lt*Mn,Fe=Qt>>>13,Qt&=8191,Qt+=nn*(5*pr),Qt+=Ft*(5*Lr),Qt+=en*(5*kr),Qt+=Wt*(5*Xr),Qt+=nt*(5*hr),Fe+=Qt>>>13,Qt&=8191,dn=Fe,dn+=Ln*hr,dn+=Un*fr,dn+=gn*at,dn+=Tt*sr,dn+=Lt*Zn,Fe=dn>>>13,dn&=8191,dn+=nn*Mn,dn+=Ft*(5*pr),dn+=en*(5*Lr),dn+=Wt*(5*kr),dn+=nt*(5*Xr),Fe+=dn>>>13,dn&=8191,pn=Fe,pn+=Ln*Xr,pn+=Un*hr,pn+=gn*fr,pn+=Tt*at,pn+=Lt*sr,Fe=pn>>>13,pn&=8191,pn+=nn*Zn,pn+=Ft*Mn,pn+=en*(5*pr),pn+=Wt*(5*Lr),pn+=nt*(5*kr),Fe+=pn>>>13,pn&=8191,Zt=Fe,Zt+=Ln*kr,Zt+=Un*Xr,Zt+=gn*hr,Zt+=Tt*fr,Zt+=Lt*at,Fe=Zt>>>13,Zt&=8191,Zt+=nn*sr,Zt+=Ft*Zn,Zt+=en*Mn,Zt+=Wt*(5*pr),Zt+=nt*(5*Lr),Fe+=Zt>>>13,Zt&=8191,An=Fe,An+=Ln*Lr,An+=Un*kr,An+=gn*Xr,An+=Tt*hr,An+=Lt*fr,Fe=An>>>13,An&=8191,An+=nn*at,An+=Ft*sr,An+=en*Zn,An+=Wt*Mn,An+=nt*(5*pr),Fe+=An>>>13,An&=8191,bn=Fe,bn+=Ln*pr,bn+=Un*Lr,bn+=gn*kr,bn+=Tt*Xr,bn+=Lt*hr,Fe=bn>>>13,bn&=8191,bn+=nn*fr,bn+=Ft*at,bn+=en*sr,bn+=Wt*Zn,bn+=nt*Mn,Fe+=bn>>>13,bn&=8191,Fe=(Fe<<2)+Fe|0,Fe=Fe+We|0,We=Fe&8191,Fe=Fe>>>13,lt+=Fe,Ln=We,Un=lt,gn=yt,Tt=Bt,Lt=Qt,nn=dn,Ft=pn,en=Zt,Wt=An,nt=bn,Ie+=16,Ae-=16;this.h[0]=Ln,this.h[1]=Un,this.h[2]=gn,this.h[3]=Tt,this.h[4]=Lt,this.h[5]=nn,this.h[6]=Ft,this.h[7]=en,this.h[8]=Wt,this.h[9]=nt},M.prototype.finish=function(fe,Ie){var Ae=new Uint16Array(10),ce,Oe,dt,vt;if(this.leftover){for(vt=this.leftover,this.buffer[vt++]=1;vt<16;vt++)this.buffer[vt]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(ce=this.h[1]>>>13,this.h[1]&=8191,vt=2;vt<10;vt++)this.h[vt]+=ce,ce=this.h[vt]>>>13,this.h[vt]&=8191;for(this.h[0]+=ce*5,ce=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=ce,ce=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=ce,Ae[0]=this.h[0]+5,ce=Ae[0]>>>13,Ae[0]&=8191,vt=1;vt<10;vt++)Ae[vt]=this.h[vt]+ce,ce=Ae[vt]>>>13,Ae[vt]&=8191;for(Ae[9]-=8192,Oe=(ce^1)-1,vt=0;vt<10;vt++)Ae[vt]&=Oe;for(Oe=~Oe,vt=0;vt<10;vt++)this.h[vt]=this.h[vt]&Oe|Ae[vt];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,dt=this.h[0]+this.pad[0],this.h[0]=dt&65535,vt=1;vt<8;vt++)dt=(this.h[vt]+this.pad[vt]|0)+(dt>>>16)|0,this.h[vt]=dt&65535;fe[Ie+0]=this.h[0]>>>0&255,fe[Ie+1]=this.h[0]>>>8&255,fe[Ie+2]=this.h[1]>>>0&255,fe[Ie+3]=this.h[1]>>>8&255,fe[Ie+4]=this.h[2]>>>0&255,fe[Ie+5]=this.h[2]>>>8&255,fe[Ie+6]=this.h[3]>>>0&255,fe[Ie+7]=this.h[3]>>>8&255,fe[Ie+8]=this.h[4]>>>0&255,fe[Ie+9]=this.h[4]>>>8&255,fe[Ie+10]=this.h[5]>>>0&255,fe[Ie+11]=this.h[5]>>>8&255,fe[Ie+12]=this.h[6]>>>0&255,fe[Ie+13]=this.h[6]>>>8&255,fe[Ie+14]=this.h[7]>>>0&255,fe[Ie+15]=this.h[7]>>>8&255},M.prototype.update=function(fe,Ie,Ae){var ce,Oe;if(this.leftover){for(Oe=16-this.leftover,Oe>Ae&&(Oe=Ae),ce=0;ce<Oe;ce++)this.buffer[this.leftover+ce]=fe[Ie+ce];if(Ae-=Oe,Ie+=Oe,this.leftover+=Oe,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(Ae>=16&&(Oe=Ae-Ae%16,this.blocks(fe,Ie,Oe),Ie+=Oe,Ae-=Oe),Ae){for(ce=0;ce<Ae;ce++)this.buffer[this.leftover+ce]=fe[Ie+ce];this.leftover+=Ae}};function F(fe,Ie,Ae,ce,Oe,dt){var vt=new M(dt);return vt.update(Ae,ce,Oe),vt.finish(fe,Ie),0}function D(fe,Ie,Ae,ce,Oe,dt){var vt=new Uint8Array(16);return F(vt,0,Ae,ce,Oe,dt),b(fe,Ie,vt,0)}function R(fe,Ie,Ae,ce,Oe){var dt;if(Ae<32)return-1;for(L(fe,0,Ie,0,Ae,ce,Oe),F(fe,16,fe,32,Ae-32,fe),dt=0;dt<16;dt++)fe[dt]=0;return 0}function z(fe,Ie,Ae,ce,Oe){var dt,vt=new Uint8Array(32);if(Ae<32||(_(vt,0,32,ce,Oe),D(Ie,16,Ie,32,Ae-32,vt)!==0))return-1;for(L(fe,0,Ie,0,Ae,ce,Oe),dt=0;dt<32;dt++)fe[dt]=0;return 0}function B(fe,Ie){var Ae;for(Ae=0;Ae<16;Ae++)fe[Ae]=Ie[Ae]|0}function H(fe){var Ie,Ae,ce=1;for(Ie=0;Ie<16;Ie++)Ae=fe[Ie]+ce+65535,ce=Math.floor(Ae/65536),fe[Ie]=Ae-ce*65536;fe[0]+=ce-1+37*(ce-1)}function G(fe,Ie,Ae){for(var ce,Oe=~(Ae-1),dt=0;dt<16;dt++)ce=Oe&(fe[dt]^Ie[dt]),fe[dt]^=ce,Ie[dt]^=ce}function ne(fe,Ie){var Ae,ce,Oe,dt=n(),vt=n();for(Ae=0;Ae<16;Ae++)vt[Ae]=Ie[Ae];for(H(vt),H(vt),H(vt),ce=0;ce<2;ce++){for(dt[0]=vt[0]-65517,Ae=1;Ae<15;Ae++)dt[Ae]=vt[Ae]-65535-(dt[Ae-1]>>16&1),dt[Ae-1]&=65535;dt[15]=vt[15]-32767-(dt[14]>>16&1),Oe=dt[15]>>16&1,dt[14]&=65535,G(vt,dt,1-Oe)}for(Ae=0;Ae<16;Ae++)fe[2*Ae]=vt[Ae]&255,fe[2*Ae+1]=vt[Ae]>>8}function W(fe,Ie){var Ae=new Uint8Array(32),ce=new Uint8Array(32);return ne(Ae,fe),ne(ce,Ie),x(Ae,0,ce,0)}function T(fe){var Ie=new Uint8Array(32);return ne(Ie,fe),Ie[0]&1}function U(fe,Ie){var Ae;for(Ae=0;Ae<16;Ae++)fe[Ae]=Ie[2*Ae]+(Ie[2*Ae+1]<<8);fe[15]&=32767}function P(fe,Ie,Ae){for(var ce=0;ce<16;ce++)fe[ce]=Ie[ce]+Ae[ce]}function K(fe,Ie,Ae){for(var ce=0;ce<16;ce++)fe[ce]=Ie[ce]-Ae[ce]}function J(fe,Ie,Ae){var ce,Oe,dt=0,vt=0,Et=0,Ct=0,xn=0,yn=0,er=0,Fe=0,We=0,lt=0,yt=0,Bt=0,Qt=0,dn=0,pn=0,Zt=0,An=0,bn=0,Ln=0,Un=0,gn=0,Tt=0,Lt=0,nn=0,Ft=0,en=0,Wt=0,nt=0,Mn=0,Zn=0,sr=0,at=Ae[0],fr=Ae[1],hr=Ae[2],Xr=Ae[3],kr=Ae[4],Lr=Ae[5],pr=Ae[6],bs=Ae[7],ss=Ae[8],Cs=Ae[9],ms=Ae[10],Es=Ae[11],eo=Ae[12],Vs=Ae[13],ao=Ae[14],Er=Ae[15];ce=Ie[0],dt+=ce*at,vt+=ce*fr,Et+=ce*hr,Ct+=ce*Xr,xn+=ce*kr,yn+=ce*Lr,er+=ce*pr,Fe+=ce*bs,We+=ce*ss,lt+=ce*Cs,yt+=ce*ms,Bt+=ce*Es,Qt+=ce*eo,dn+=ce*Vs,pn+=ce*ao,Zt+=ce*Er,ce=Ie[1],vt+=ce*at,Et+=ce*fr,Ct+=ce*hr,xn+=ce*Xr,yn+=ce*kr,er+=ce*Lr,Fe+=ce*pr,We+=ce*bs,lt+=ce*ss,yt+=ce*Cs,Bt+=ce*ms,Qt+=ce*Es,dn+=ce*eo,pn+=ce*Vs,Zt+=ce*ao,An+=ce*Er,ce=Ie[2],Et+=ce*at,Ct+=ce*fr,xn+=ce*hr,yn+=ce*Xr,er+=ce*kr,Fe+=ce*Lr,We+=ce*pr,lt+=ce*bs,yt+=ce*ss,Bt+=ce*Cs,Qt+=ce*ms,dn+=ce*Es,pn+=ce*eo,Zt+=ce*Vs,An+=ce*ao,bn+=ce*Er,ce=Ie[3],Ct+=ce*at,xn+=ce*fr,yn+=ce*hr,er+=ce*Xr,Fe+=ce*kr,We+=ce*Lr,lt+=ce*pr,yt+=ce*bs,Bt+=ce*ss,Qt+=ce*Cs,dn+=ce*ms,pn+=ce*Es,Zt+=ce*eo,An+=ce*Vs,bn+=ce*ao,Ln+=ce*Er,ce=Ie[4],xn+=ce*at,yn+=ce*fr,er+=ce*hr,Fe+=ce*Xr,We+=ce*kr,lt+=ce*Lr,yt+=ce*pr,Bt+=ce*bs,Qt+=ce*ss,dn+=ce*Cs,pn+=ce*ms,Zt+=ce*Es,An+=ce*eo,bn+=ce*Vs,Ln+=ce*ao,Un+=ce*Er,ce=Ie[5],yn+=ce*at,er+=ce*fr,Fe+=ce*hr,We+=ce*Xr,lt+=ce*kr,yt+=ce*Lr,Bt+=ce*pr,Qt+=ce*bs,dn+=ce*ss,pn+=ce*Cs,Zt+=ce*ms,An+=ce*Es,bn+=ce*eo,Ln+=ce*Vs,Un+=ce*ao,gn+=ce*Er,ce=Ie[6],er+=ce*at,Fe+=ce*fr,We+=ce*hr,lt+=ce*Xr,yt+=ce*kr,Bt+=ce*Lr,Qt+=ce*pr,dn+=ce*bs,pn+=ce*ss,Zt+=ce*Cs,An+=ce*ms,bn+=ce*Es,Ln+=ce*eo,Un+=ce*Vs,gn+=ce*ao,Tt+=ce*Er,ce=Ie[7],Fe+=ce*at,We+=ce*fr,lt+=ce*hr,yt+=ce*Xr,Bt+=ce*kr,Qt+=ce*Lr,dn+=ce*pr,pn+=ce*bs,Zt+=ce*ss,An+=ce*Cs,bn+=ce*ms,Ln+=ce*Es,Un+=ce*eo,gn+=ce*Vs,Tt+=ce*ao,Lt+=ce*Er,ce=Ie[8],We+=ce*at,lt+=ce*fr,yt+=ce*hr,Bt+=ce*Xr,Qt+=ce*kr,dn+=ce*Lr,pn+=ce*pr,Zt+=ce*bs,An+=ce*ss,bn+=ce*Cs,Ln+=ce*ms,Un+=ce*Es,gn+=ce*eo,Tt+=ce*Vs,Lt+=ce*ao,nn+=ce*Er,ce=Ie[9],lt+=ce*at,yt+=ce*fr,Bt+=ce*hr,Qt+=ce*Xr,dn+=ce*kr,pn+=ce*Lr,Zt+=ce*pr,An+=ce*bs,bn+=ce*ss,Ln+=ce*Cs,Un+=ce*ms,gn+=ce*Es,Tt+=ce*eo,Lt+=ce*Vs,nn+=ce*ao,Ft+=ce*Er,ce=Ie[10],yt+=ce*at,Bt+=ce*fr,Qt+=ce*hr,dn+=ce*Xr,pn+=ce*kr,Zt+=ce*Lr,An+=ce*pr,bn+=ce*bs,Ln+=ce*ss,Un+=ce*Cs,gn+=ce*ms,Tt+=ce*Es,Lt+=ce*eo,nn+=ce*Vs,Ft+=ce*ao,en+=ce*Er,ce=Ie[11],Bt+=ce*at,Qt+=ce*fr,dn+=ce*hr,pn+=ce*Xr,Zt+=ce*kr,An+=ce*Lr,bn+=ce*pr,Ln+=ce*bs,Un+=ce*ss,gn+=ce*Cs,Tt+=ce*ms,Lt+=ce*Es,nn+=ce*eo,Ft+=ce*Vs,en+=ce*ao,Wt+=ce*Er,ce=Ie[12],Qt+=ce*at,dn+=ce*fr,pn+=ce*hr,Zt+=ce*Xr,An+=ce*kr,bn+=ce*Lr,Ln+=ce*pr,Un+=ce*bs,gn+=ce*ss,Tt+=ce*Cs,Lt+=ce*ms,nn+=ce*Es,Ft+=ce*eo,en+=ce*Vs,Wt+=ce*ao,nt+=ce*Er,ce=Ie[13],dn+=ce*at,pn+=ce*fr,Zt+=ce*hr,An+=ce*Xr,bn+=ce*kr,Ln+=ce*Lr,Un+=ce*pr,gn+=ce*bs,Tt+=ce*ss,Lt+=ce*Cs,nn+=ce*ms,Ft+=ce*Es,en+=ce*eo,Wt+=ce*Vs,nt+=ce*ao,Mn+=ce*Er,ce=Ie[14],pn+=ce*at,Zt+=ce*fr,An+=ce*hr,bn+=ce*Xr,Ln+=ce*kr,Un+=ce*Lr,gn+=ce*pr,Tt+=ce*bs,Lt+=ce*ss,nn+=ce*Cs,Ft+=ce*ms,en+=ce*Es,Wt+=ce*eo,nt+=ce*Vs,Mn+=ce*ao,Zn+=ce*Er,ce=Ie[15],Zt+=ce*at,An+=ce*fr,bn+=ce*hr,Ln+=ce*Xr,Un+=ce*kr,gn+=ce*Lr,Tt+=ce*pr,Lt+=ce*bs,nn+=ce*ss,Ft+=ce*Cs,en+=ce*ms,Wt+=ce*Es,nt+=ce*eo,Mn+=ce*Vs,Zn+=ce*ao,sr+=ce*Er,dt+=38*An,vt+=38*bn,Et+=38*Ln,Ct+=38*Un,xn+=38*gn,yn+=38*Tt,er+=38*Lt,Fe+=38*nn,We+=38*Ft,lt+=38*en,yt+=38*Wt,Bt+=38*nt,Qt+=38*Mn,dn+=38*Zn,pn+=38*sr,Oe=1,ce=dt+Oe+65535,Oe=Math.floor(ce/65536),dt=ce-Oe*65536,ce=vt+Oe+65535,Oe=Math.floor(ce/65536),vt=ce-Oe*65536,ce=Et+Oe+65535,Oe=Math.floor(ce/65536),Et=ce-Oe*65536,ce=Ct+Oe+65535,Oe=Math.floor(ce/65536),Ct=ce-Oe*65536,ce=xn+Oe+65535,Oe=Math.floor(ce/65536),xn=ce-Oe*65536,ce=yn+Oe+65535,Oe=Math.floor(ce/65536),yn=ce-Oe*65536,ce=er+Oe+65535,Oe=Math.floor(ce/65536),er=ce-Oe*65536,ce=Fe+Oe+65535,Oe=Math.floor(ce/65536),Fe=ce-Oe*65536,ce=We+Oe+65535,Oe=Math.floor(ce/65536),We=ce-Oe*65536,ce=lt+Oe+65535,Oe=Math.floor(ce/65536),lt=ce-Oe*65536,ce=yt+Oe+65535,Oe=Math.floor(ce/65536),yt=ce-Oe*65536,ce=Bt+Oe+65535,Oe=Math.floor(ce/65536),Bt=ce-Oe*65536,ce=Qt+Oe+65535,Oe=Math.floor(ce/65536),Qt=ce-Oe*65536,ce=dn+Oe+65535,Oe=Math.floor(ce/65536),dn=ce-Oe*65536,ce=pn+Oe+65535,Oe=Math.floor(ce/65536),pn=ce-Oe*65536,ce=Zt+Oe+65535,Oe=Math.floor(ce/65536),Zt=ce-Oe*65536,dt+=Oe-1+37*(Oe-1),Oe=1,ce=dt+Oe+65535,Oe=Math.floor(ce/65536),dt=ce-Oe*65536,ce=vt+Oe+65535,Oe=Math.floor(ce/65536),vt=ce-Oe*65536,ce=Et+Oe+65535,Oe=Math.floor(ce/65536),Et=ce-Oe*65536,ce=Ct+Oe+65535,Oe=Math.floor(ce/65536),Ct=ce-Oe*65536,ce=xn+Oe+65535,Oe=Math.floor(ce/65536),xn=ce-Oe*65536,ce=yn+Oe+65535,Oe=Math.floor(ce/65536),yn=ce-Oe*65536,ce=er+Oe+65535,Oe=Math.floor(ce/65536),er=ce-Oe*65536,ce=Fe+Oe+65535,Oe=Math.floor(ce/65536),Fe=ce-Oe*65536,ce=We+Oe+65535,Oe=Math.floor(ce/65536),We=ce-Oe*65536,ce=lt+Oe+65535,Oe=Math.floor(ce/65536),lt=ce-Oe*65536,ce=yt+Oe+65535,Oe=Math.floor(ce/65536),yt=ce-Oe*65536,ce=Bt+Oe+65535,Oe=Math.floor(ce/65536),Bt=ce-Oe*65536,ce=Qt+Oe+65535,Oe=Math.floor(ce/65536),Qt=ce-Oe*65536,ce=dn+Oe+65535,Oe=Math.floor(ce/65536),dn=ce-Oe*65536,ce=pn+Oe+65535,Oe=Math.floor(ce/65536),pn=ce-Oe*65536,ce=Zt+Oe+65535,Oe=Math.floor(ce/65536),Zt=ce-Oe*65536,dt+=Oe-1+37*(Oe-1),fe[0]=dt,fe[1]=vt,fe[2]=Et,fe[3]=Ct,fe[4]=xn,fe[5]=yn,fe[6]=er,fe[7]=Fe,fe[8]=We,fe[9]=lt,fe[10]=yt,fe[11]=Bt,fe[12]=Qt,fe[13]=dn,fe[14]=pn,fe[15]=Zt}function ee(fe,Ie){J(fe,Ie,Ie)}function X(fe,Ie){var Ae=n(),ce;for(ce=0;ce<16;ce++)Ae[ce]=Ie[ce];for(ce=253;ce>=0;ce--)ee(Ae,Ae),ce!==2&&ce!==4&&J(Ae,Ae,Ie);for(ce=0;ce<16;ce++)fe[ce]=Ae[ce]}function te(fe,Ie){var Ae=n(),ce;for(ce=0;ce<16;ce++)Ae[ce]=Ie[ce];for(ce=250;ce>=0;ce--)ee(Ae,Ae),ce!==1&&J(Ae,Ae,Ie);for(ce=0;ce<16;ce++)fe[ce]=Ae[ce]}function Q(fe,Ie,Ae){var ce=new Uint8Array(32),Oe=new Float64Array(80),dt,vt,Et=n(),Ct=n(),xn=n(),yn=n(),er=n(),Fe=n();for(vt=0;vt<31;vt++)ce[vt]=Ie[vt];for(ce[31]=Ie[31]&127|64,ce[0]&=248,U(Oe,Ae),vt=0;vt<16;vt++)Ct[vt]=Oe[vt],yn[vt]=Et[vt]=xn[vt]=0;for(Et[0]=yn[0]=1,vt=254;vt>=0;--vt)dt=ce[vt>>>3]>>>(vt&7)&1,G(Et,Ct,dt),G(xn,yn,dt),P(er,Et,xn),K(Et,Et,xn),P(xn,Ct,yn),K(Ct,Ct,yn),ee(yn,er),ee(Fe,Et),J(Et,xn,Et),J(xn,Ct,er),P(er,Et,xn),K(Et,Et,xn),ee(Ct,Et),K(xn,yn,Fe),J(Et,xn,c),P(Et,Et,yn),J(xn,xn,Et),J(Et,yn,Fe),J(yn,Ct,Oe),ee(Ct,er),G(Et,Ct,dt),G(xn,yn,dt);for(vt=0;vt<16;vt++)Oe[vt+16]=Et[vt],Oe[vt+32]=xn[vt],Oe[vt+48]=Ct[vt],Oe[vt+64]=yn[vt];var We=Oe.subarray(32),lt=Oe.subarray(16);return X(We,We),J(lt,lt,We),ne(fe,lt),0}function oe(fe,Ie){return Q(fe,Ie,o)}function de(fe,Ie){return r(Ie,32),oe(fe,Ie)}function ie(fe,Ie,Ae){var ce=new Uint8Array(32);return Q(ce,Ae,Ie),A(fe,s,ce,N)}var ue=R,xe=z;function ge(fe,Ie,Ae,ce,Oe,dt){var vt=new Uint8Array(32);return ie(vt,Oe,dt),ue(fe,Ie,Ae,ce,vt)}function Te(fe,Ie,Ae,ce,Oe,dt){var vt=new Uint8Array(32);return ie(vt,Oe,dt),xe(fe,Ie,Ae,ce,vt)}var De=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Me(fe,Ie,Ae,ce){for(var Oe=new Int32Array(16),dt=new Int32Array(16),vt,Et,Ct,xn,yn,er,Fe,We,lt,yt,Bt,Qt,dn,pn,Zt,An,bn,Ln,Un,gn,Tt,Lt,nn,Ft,en,Wt,nt=fe[0],Mn=fe[1],Zn=fe[2],sr=fe[3],at=fe[4],fr=fe[5],hr=fe[6],Xr=fe[7],kr=Ie[0],Lr=Ie[1],pr=Ie[2],bs=Ie[3],ss=Ie[4],Cs=Ie[5],ms=Ie[6],Es=Ie[7],eo=0;ce>=128;){for(Un=0;Un<16;Un++)gn=8*Un+eo,Oe[Un]=Ae[gn+0]<<24|Ae[gn+1]<<16|Ae[gn+2]<<8|Ae[gn+3],dt[Un]=Ae[gn+4]<<24|Ae[gn+5]<<16|Ae[gn+6]<<8|Ae[gn+7];for(Un=0;Un<80;Un++)if(vt=nt,Et=Mn,Ct=Zn,xn=sr,yn=at,er=fr,Fe=hr,We=Xr,lt=kr,yt=Lr,Bt=pr,Qt=bs,dn=ss,pn=Cs,Zt=ms,An=Es,Tt=Xr,Lt=Es,nn=Lt&65535,Ft=Lt>>>16,en=Tt&65535,Wt=Tt>>>16,Tt=(at>>>14|ss<<18)^(at>>>18|ss<<14)^(ss>>>9|at<<23),Lt=(ss>>>14|at<<18)^(ss>>>18|at<<14)^(at>>>9|ss<<23),nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Tt=at&fr^~at&hr,Lt=ss&Cs^~ss&ms,nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Tt=De[Un*2],Lt=De[Un*2+1],nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Tt=Oe[Un%16],Lt=dt[Un%16],nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Ft+=nn>>>16,en+=Ft>>>16,Wt+=en>>>16,bn=en&65535|Wt<<16,Ln=nn&65535|Ft<<16,Tt=bn,Lt=Ln,nn=Lt&65535,Ft=Lt>>>16,en=Tt&65535,Wt=Tt>>>16,Tt=(nt>>>28|kr<<4)^(kr>>>2|nt<<30)^(kr>>>7|nt<<25),Lt=(kr>>>28|nt<<4)^(nt>>>2|kr<<30)^(nt>>>7|kr<<25),nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Tt=nt&Mn^nt&Zn^Mn&Zn,Lt=kr&Lr^kr&pr^Lr&pr,nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Ft+=nn>>>16,en+=Ft>>>16,Wt+=en>>>16,We=en&65535|Wt<<16,An=nn&65535|Ft<<16,Tt=xn,Lt=Qt,nn=Lt&65535,Ft=Lt>>>16,en=Tt&65535,Wt=Tt>>>16,Tt=bn,Lt=Ln,nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Ft+=nn>>>16,en+=Ft>>>16,Wt+=en>>>16,xn=en&65535|Wt<<16,Qt=nn&65535|Ft<<16,Mn=vt,Zn=Et,sr=Ct,at=xn,fr=yn,hr=er,Xr=Fe,nt=We,Lr=lt,pr=yt,bs=Bt,ss=Qt,Cs=dn,ms=pn,Es=Zt,kr=An,Un%16===15)for(gn=0;gn<16;gn++)Tt=Oe[gn],Lt=dt[gn],nn=Lt&65535,Ft=Lt>>>16,en=Tt&65535,Wt=Tt>>>16,Tt=Oe[(gn+9)%16],Lt=dt[(gn+9)%16],nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,bn=Oe[(gn+1)%16],Ln=dt[(gn+1)%16],Tt=(bn>>>1|Ln<<31)^(bn>>>8|Ln<<24)^bn>>>7,Lt=(Ln>>>1|bn<<31)^(Ln>>>8|bn<<24)^(Ln>>>7|bn<<25),nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,bn=Oe[(gn+14)%16],Ln=dt[(gn+14)%16],Tt=(bn>>>19|Ln<<13)^(Ln>>>29|bn<<3)^bn>>>6,Lt=(Ln>>>19|bn<<13)^(bn>>>29|Ln<<3)^(Ln>>>6|bn<<26),nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Ft+=nn>>>16,en+=Ft>>>16,Wt+=en>>>16,Oe[gn]=en&65535|Wt<<16,dt[gn]=nn&65535|Ft<<16;Tt=nt,Lt=kr,nn=Lt&65535,Ft=Lt>>>16,en=Tt&65535,Wt=Tt>>>16,Tt=fe[0],Lt=Ie[0],nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Ft+=nn>>>16,en+=Ft>>>16,Wt+=en>>>16,fe[0]=nt=en&65535|Wt<<16,Ie[0]=kr=nn&65535|Ft<<16,Tt=Mn,Lt=Lr,nn=Lt&65535,Ft=Lt>>>16,en=Tt&65535,Wt=Tt>>>16,Tt=fe[1],Lt=Ie[1],nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Ft+=nn>>>16,en+=Ft>>>16,Wt+=en>>>16,fe[1]=Mn=en&65535|Wt<<16,Ie[1]=Lr=nn&65535|Ft<<16,Tt=Zn,Lt=pr,nn=Lt&65535,Ft=Lt>>>16,en=Tt&65535,Wt=Tt>>>16,Tt=fe[2],Lt=Ie[2],nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Ft+=nn>>>16,en+=Ft>>>16,Wt+=en>>>16,fe[2]=Zn=en&65535|Wt<<16,Ie[2]=pr=nn&65535|Ft<<16,Tt=sr,Lt=bs,nn=Lt&65535,Ft=Lt>>>16,en=Tt&65535,Wt=Tt>>>16,Tt=fe[3],Lt=Ie[3],nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Ft+=nn>>>16,en+=Ft>>>16,Wt+=en>>>16,fe[3]=sr=en&65535|Wt<<16,Ie[3]=bs=nn&65535|Ft<<16,Tt=at,Lt=ss,nn=Lt&65535,Ft=Lt>>>16,en=Tt&65535,Wt=Tt>>>16,Tt=fe[4],Lt=Ie[4],nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Ft+=nn>>>16,en+=Ft>>>16,Wt+=en>>>16,fe[4]=at=en&65535|Wt<<16,Ie[4]=ss=nn&65535|Ft<<16,Tt=fr,Lt=Cs,nn=Lt&65535,Ft=Lt>>>16,en=Tt&65535,Wt=Tt>>>16,Tt=fe[5],Lt=Ie[5],nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Ft+=nn>>>16,en+=Ft>>>16,Wt+=en>>>16,fe[5]=fr=en&65535|Wt<<16,Ie[5]=Cs=nn&65535|Ft<<16,Tt=hr,Lt=ms,nn=Lt&65535,Ft=Lt>>>16,en=Tt&65535,Wt=Tt>>>16,Tt=fe[6],Lt=Ie[6],nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Ft+=nn>>>16,en+=Ft>>>16,Wt+=en>>>16,fe[6]=hr=en&65535|Wt<<16,Ie[6]=ms=nn&65535|Ft<<16,Tt=Xr,Lt=Es,nn=Lt&65535,Ft=Lt>>>16,en=Tt&65535,Wt=Tt>>>16,Tt=fe[7],Lt=Ie[7],nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Ft+=nn>>>16,en+=Ft>>>16,Wt+=en>>>16,fe[7]=Xr=en&65535|Wt<<16,Ie[7]=Es=nn&65535|Ft<<16,eo+=128,ce-=128}return ce}function ze(fe,Ie,Ae){var ce=new Int32Array(8),Oe=new Int32Array(8),dt=new Uint8Array(256),vt,Et=Ae;for(ce[0]=1779033703,ce[1]=3144134277,ce[2]=1013904242,ce[3]=2773480762,ce[4]=1359893119,ce[5]=2600822924,ce[6]=528734635,ce[7]=1541459225,Oe[0]=4089235720,Oe[1]=2227873595,Oe[2]=4271175723,Oe[3]=1595750129,Oe[4]=2917565137,Oe[5]=725511199,Oe[6]=4215389547,Oe[7]=327033209,Me(ce,Oe,Ie,Ae),Ae%=128,vt=0;vt<Ae;vt++)dt[vt]=Ie[Et-Ae+vt];for(dt[Ae]=128,Ae=256-128*(Ae<112?1:0),dt[Ae-9]=0,m(dt,Ae-8,Et/536870912|0,Et<<3),Me(ce,Oe,dt,Ae),vt=0;vt<8;vt++)m(fe,8*vt,ce[vt],Oe[vt]);return 0}function He(fe,Ie){var Ae=n(),ce=n(),Oe=n(),dt=n(),vt=n(),Et=n(),Ct=n(),xn=n(),yn=n();K(Ae,fe[1],fe[0]),K(yn,Ie[1],Ie[0]),J(Ae,Ae,yn),P(ce,fe[0],fe[1]),P(yn,Ie[0],Ie[1]),J(ce,ce,yn),J(Oe,fe[3],Ie[3]),J(Oe,Oe,d),J(dt,fe[2],Ie[2]),P(dt,dt,dt),K(vt,ce,Ae),K(Et,dt,Oe),P(Ct,dt,Oe),P(xn,ce,Ae),J(fe[0],vt,Et),J(fe[1],xn,Ct),J(fe[2],Ct,Et),J(fe[3],vt,xn)}function tt(fe,Ie,Ae){var ce;for(ce=0;ce<4;ce++)G(fe[ce],Ie[ce],Ae)}function $e(fe,Ie){var Ae=n(),ce=n(),Oe=n();X(Oe,Ie[2]),J(Ae,Ie[0],Oe),J(ce,Ie[1],Oe),ne(fe,ce),fe[31]^=T(Ae)<<7}function Ue(fe,Ie,Ae){var ce,Oe;for(B(fe[0],i),B(fe[1],l),B(fe[2],l),B(fe[3],i),Oe=255;Oe>=0;--Oe)ce=Ae[Oe/8|0]>>(Oe&7)&1,tt(fe,Ie,ce),He(Ie,fe),He(fe,fe),tt(fe,Ie,ce)}function Pe(fe,Ie){var Ae=[n(),n(),n(),n()];B(Ae[0],f),B(Ae[1],h),B(Ae[2],l),J(Ae[3],f,h),Ue(fe,Ae,Ie)}function we(fe,Ie,Ae){var ce=new Uint8Array(64),Oe=[n(),n(),n(),n()],dt;for(Ae||r(Ie,32),ze(ce,Ie,32),ce[0]&=248,ce[31]&=127,ce[31]|=64,Pe(Oe,ce),$e(fe,Oe),dt=0;dt<32;dt++)Ie[dt+32]=fe[dt];return 0}var ye=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function Re(fe,Ie){var Ae,ce,Oe,dt;for(ce=63;ce>=32;--ce){for(Ae=0,Oe=ce-32,dt=ce-12;Oe<dt;++Oe)Ie[Oe]+=Ae-16*Ie[ce]*ye[Oe-(ce-32)],Ae=Math.floor((Ie[Oe]+128)/256),Ie[Oe]-=Ae*256;Ie[Oe]+=Ae,Ie[ce]=0}for(Ae=0,Oe=0;Oe<32;Oe++)Ie[Oe]+=Ae-(Ie[31]>>4)*ye[Oe],Ae=Ie[Oe]>>8,Ie[Oe]&=255;for(Oe=0;Oe<32;Oe++)Ie[Oe]-=Ae*ye[Oe];for(ce=0;ce<32;ce++)Ie[ce+1]+=Ie[ce]>>8,fe[ce]=Ie[ce]&255}function _e(fe){var Ie=new Float64Array(64),Ae;for(Ae=0;Ae<64;Ae++)Ie[Ae]=fe[Ae];for(Ae=0;Ae<64;Ae++)fe[Ae]=0;Re(fe,Ie)}function Ve(fe,Ie,Ae,ce){var Oe=new Uint8Array(64),dt=new Uint8Array(64),vt=new Uint8Array(64),Et,Ct,xn=new Float64Array(64),yn=[n(),n(),n(),n()];ze(Oe,ce,32),Oe[0]&=248,Oe[31]&=127,Oe[31]|=64;var er=Ae+64;for(Et=0;Et<Ae;Et++)fe[64+Et]=Ie[Et];for(Et=0;Et<32;Et++)fe[32+Et]=Oe[32+Et];for(ze(vt,fe.subarray(32),Ae+32),_e(vt),Pe(yn,vt),$e(fe,yn),Et=32;Et<64;Et++)fe[Et]=ce[Et];for(ze(dt,fe,Ae+64),_e(dt),Et=0;Et<64;Et++)xn[Et]=0;for(Et=0;Et<32;Et++)xn[Et]=vt[Et];for(Et=0;Et<32;Et++)for(Ct=0;Ct<32;Ct++)xn[Et+Ct]+=dt[Et]*Oe[Ct];return Re(fe.subarray(32),xn),er}function he(fe,Ie){var Ae=n(),ce=n(),Oe=n(),dt=n(),vt=n(),Et=n(),Ct=n();return B(fe[2],l),U(fe[1],Ie),ee(Oe,fe[1]),J(dt,Oe,u),K(Oe,Oe,fe[2]),P(dt,fe[2],dt),ee(vt,dt),ee(Et,vt),J(Ct,Et,vt),J(Ae,Ct,Oe),J(Ae,Ae,dt),te(Ae,Ae),J(Ae,Ae,Oe),J(Ae,Ae,dt),J(Ae,Ae,dt),J(fe[0],Ae,dt),ee(ce,fe[0]),J(ce,ce,dt),W(ce,Oe)&&J(fe[0],fe[0],p),ee(ce,fe[0]),J(ce,ce,dt),W(ce,Oe)?-1:(T(fe[0])===Ie[31]>>7&&K(fe[0],i,fe[0]),J(fe[3],fe[0],fe[1]),0)}function Ye(fe,Ie,Ae,ce){var Oe,dt=new Uint8Array(32),vt=new Uint8Array(64),Et=[n(),n(),n(),n()],Ct=[n(),n(),n(),n()];if(Ae<64||he(Ct,ce))return-1;for(Oe=0;Oe<Ae;Oe++)fe[Oe]=Ie[Oe];for(Oe=0;Oe<32;Oe++)fe[Oe+32]=ce[Oe];if(ze(vt,fe,Ae),_e(vt),Ue(Et,Ct,vt),Pe(Ct,Ie.subarray(32)),He(Et,Ct),$e(dt,Et),Ae-=64,x(Ie,0,dt,0)){for(Oe=0;Oe<Ae;Oe++)fe[Oe]=0;return-1}for(Oe=0;Oe<Ae;Oe++)fe[Oe]=Ie[Oe+64];return Ae}var Le=32,Ne=24,Ge=32,ft=16,Ze=32,je=32,Je=32,st=32,gt=32,ut=Ne,pt=Ge,It=ft,kt=64,ln=32,qt=64,Jt=32,cn=64;t.lowlevel={crypto_core_hsalsa20:A,crypto_stream_xor:L,crypto_stream:_,crypto_stream_salsa20_xor:j,crypto_stream_salsa20:I,crypto_onetimeauth:F,crypto_onetimeauth_verify:D,crypto_verify_16:b,crypto_verify_32:x,crypto_secretbox:R,crypto_secretbox_open:z,crypto_scalarmult:Q,crypto_scalarmult_base:oe,crypto_box_beforenm:ie,crypto_box_afternm:ue,crypto_box:ge,crypto_box_open:Te,crypto_box_keypair:de,crypto_hash:ze,crypto_sign:Ve,crypto_sign_keypair:we,crypto_sign_open:Ye,crypto_secretbox_KEYBYTES:Le,crypto_secretbox_NONCEBYTES:Ne,crypto_secretbox_ZEROBYTES:Ge,crypto_secretbox_BOXZEROBYTES:ft,crypto_scalarmult_BYTES:Ze,crypto_scalarmult_SCALARBYTES:je,crypto_box_PUBLICKEYBYTES:Je,crypto_box_SECRETKEYBYTES:st,crypto_box_BEFORENMBYTES:gt,crypto_box_NONCEBYTES:ut,crypto_box_ZEROBYTES:pt,crypto_box_BOXZEROBYTES:It,crypto_sign_BYTES:kt,crypto_sign_PUBLICKEYBYTES:ln,crypto_sign_SECRETKEYBYTES:qt,crypto_sign_SEEDBYTES:Jt,crypto_hash_BYTES:cn,gf:n,D:u,L:ye,pack25519:ne,unpack25519:U,M:J,A:P,S:ee,Z:K,pow2523:te,add:He,set25519:B,modL:Re,scalarmult:Ue,scalarbase:Pe};function hn(fe,Ie){if(fe.length!==Le)throw new Error("bad key size");if(Ie.length!==Ne)throw new Error("bad nonce size")}function St(fe,Ie){if(fe.length!==Je)throw new Error("bad public key size");if(Ie.length!==st)throw new Error("bad secret key size")}function wt(){for(var fe=0;fe<arguments.length;fe++)if(!(arguments[fe]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function Dt(fe){for(var Ie=0;Ie<fe.length;Ie++)fe[Ie]=0}t.randomBytes=function(fe){var Ie=new Uint8Array(fe);return r(Ie,fe),Ie},t.secretbox=function(fe,Ie,Ae){wt(fe,Ie,Ae),hn(Ae,Ie);for(var ce=new Uint8Array(Ge+fe.length),Oe=new Uint8Array(ce.length),dt=0;dt<fe.length;dt++)ce[dt+Ge]=fe[dt];return R(Oe,ce,ce.length,Ie,Ae),Oe.subarray(ft)},t.secretbox.open=function(fe,Ie,Ae){wt(fe,Ie,Ae),hn(Ae,Ie);for(var ce=new Uint8Array(ft+fe.length),Oe=new Uint8Array(ce.length),dt=0;dt<fe.length;dt++)ce[dt+ft]=fe[dt];return ce.length<32||z(Oe,ce,ce.length,Ie,Ae)!==0?null:Oe.subarray(Ge)},t.secretbox.keyLength=Le,t.secretbox.nonceLength=Ne,t.secretbox.overheadLength=ft,t.scalarMult=function(fe,Ie){if(wt(fe,Ie),fe.length!==je)throw new Error("bad n size");if(Ie.length!==Ze)throw new Error("bad p size");var Ae=new Uint8Array(Ze);return Q(Ae,fe,Ie),Ae},t.scalarMult.base=function(fe){if(wt(fe),fe.length!==je)throw new Error("bad n size");var Ie=new Uint8Array(Ze);return oe(Ie,fe),Ie},t.scalarMult.scalarLength=je,t.scalarMult.groupElementLength=Ze,t.box=function(fe,Ie,Ae,ce){var Oe=t.box.before(Ae,ce);return t.secretbox(fe,Ie,Oe)},t.box.before=function(fe,Ie){wt(fe,Ie),St(fe,Ie);var Ae=new Uint8Array(gt);return ie(Ae,fe,Ie),Ae},t.box.after=t.secretbox,t.box.open=function(fe,Ie,Ae,ce){var Oe=t.box.before(Ae,ce);return t.secretbox.open(fe,Ie,Oe)},t.box.open.after=t.secretbox.open,t.box.keyPair=function(){var fe=new Uint8Array(Je),Ie=new Uint8Array(st);return de(fe,Ie),{publicKey:fe,secretKey:Ie}},t.box.keyPair.fromSecretKey=function(fe){if(wt(fe),fe.length!==st)throw new Error("bad secret key size");var Ie=new Uint8Array(Je);return oe(Ie,fe),{publicKey:Ie,secretKey:new Uint8Array(fe)}},t.box.publicKeyLength=Je,t.box.secretKeyLength=st,t.box.sharedKeyLength=gt,t.box.nonceLength=ut,t.box.overheadLength=t.secretbox.overheadLength,t.sign=function(fe,Ie){if(wt(fe,Ie),Ie.length!==qt)throw new Error("bad secret key size");var Ae=new Uint8Array(kt+fe.length);return Ve(Ae,fe,fe.length,Ie),Ae},t.sign.open=function(fe,Ie){if(wt(fe,Ie),Ie.length!==ln)throw new Error("bad public key size");var Ae=new Uint8Array(fe.length),ce=Ye(Ae,fe,fe.length,Ie);if(ce<0)return null;for(var Oe=new Uint8Array(ce),dt=0;dt<Oe.length;dt++)Oe[dt]=Ae[dt];return Oe},t.sign.detached=function(fe,Ie){for(var Ae=t.sign(fe,Ie),ce=new Uint8Array(kt),Oe=0;Oe<ce.length;Oe++)ce[Oe]=Ae[Oe];return ce},t.sign.detached.verify=function(fe,Ie,Ae){if(wt(fe,Ie,Ae),Ie.length!==kt)throw new Error("bad signature size");if(Ae.length!==ln)throw new Error("bad public key size");var ce=new Uint8Array(kt+fe.length),Oe=new Uint8Array(kt+fe.length),dt;for(dt=0;dt<kt;dt++)ce[dt]=Ie[dt];for(dt=0;dt<fe.length;dt++)ce[dt+kt]=fe[dt];return Ye(Oe,ce,ce.length,Ae)>=0},t.sign.keyPair=function(){var fe=new Uint8Array(ln),Ie=new Uint8Array(qt);return we(fe,Ie),{publicKey:fe,secretKey:Ie}},t.sign.keyPair.fromSecretKey=function(fe){if(wt(fe),fe.length!==qt)throw new Error("bad secret key size");for(var Ie=new Uint8Array(ln),Ae=0;Ae<Ie.length;Ae++)Ie[Ae]=fe[32+Ae];return{publicKey:Ie,secretKey:new Uint8Array(fe)}},t.sign.keyPair.fromSeed=function(fe){if(wt(fe),fe.length!==Jt)throw new Error("bad seed size");for(var Ie=new Uint8Array(ln),Ae=new Uint8Array(qt),ce=0;ce<32;ce++)Ae[ce]=fe[ce];return we(Ie,Ae,!0),{publicKey:Ie,secretKey:Ae}},t.sign.publicKeyLength=ln,t.sign.secretKeyLength=qt,t.sign.seedLength=Jt,t.sign.signatureLength=kt,t.hash=function(fe){wt(fe);var Ie=new Uint8Array(cn);return ze(Ie,fe,fe.length),Ie},t.hash.hashLength=cn,t.verify=function(fe,Ie){return wt(fe,Ie),fe.length===0||Ie.length===0||fe.length!==Ie.length?!1:v(fe,0,Ie,0,fe.length)===0},t.setPRNG=function(fe){r=fe},(function(){var fe=typeof self<"u"?self.crypto||self.msCrypto:null;if(fe&&fe.getRandomValues){var Ie=65536;t.setPRNG(function(Ae,ce){var Oe,dt=new Uint8Array(ce);for(Oe=0;Oe<ce;Oe+=Ie)fe.getRandomValues(dt.subarray(Oe,Oe+Math.min(ce-Oe,Ie)));for(Oe=0;Oe<ce;Oe++)Ae[Oe]=dt[Oe];Dt(dt)})}else typeof lln<"u"&&(fe=dln,fe&&fe.randomBytes&&t.setPRNG(function(Ae,ce){var Oe,dt=fe.randomBytes(ce);for(Oe=0;Oe<ce;Oe++)Ae[Oe]=dt[Oe];Dt(dt)}))})()})(e.exports?e.exports:self.nacl=self.nacl||{})})(zF)),zF.exports}fln();new TextEncoder;new TextDecoder;function hln(e){return{id:e.id,name:e.name,path:e.path,...e.alias?.trim()?{alias:e.alias.trim()}:{},...e.groupId?{groupId:e.groupId}:{},...e.kind==="ssh"?{kind:"ssh",...e.sshConnectionName?{sshConnectionName:e.sshConnectionName}:{},...e.sshHost?{sshHost:e.sshHost}:{}}:{}}}const pln=4096;BigInt(pln);function mln(e,t){const n=jN(e);if(n)return n.failed?{status:"queued",queueFailed:n.failed.error}:{status:"queued",queuePosition:t??1}}function gln(e,t,n){if(!(e.status==="running"||e.spawning))return ph(e.goal)?"upstream":t&&r1e(t,n)?"reminder":void 0}function vln(e,t=[]){return JSON.stringify({pinnedOrder:t,entries:e.map(n=>{const{updatedAt:r,...s}=n;return s})})}function xln(e){return JSON.stringify(e)}function bln(e,t,n=[]){const r=iq(e,t).map(o=>({id:o.id,name:o.name,models:o.models.map(i=>({id:i.id,...i.label?{label:i.label}:{}}))})),s=n.filter(o=>o.enabled&&r.some(i=>i.id===o.primary.providerId&&i.models.some(l=>l.id===o.primary.modelId)));return s.length>0&&r.unshift({id:Nv,name:"Auto",models:s.map(o=>({id:o.id,label:o.name}))}),r}function yln(e,t,n=[]){const r=bln(e,t,n),s=t.availability.status,o=s==="unloaded"||s==="loading",i=e.some(l=>l.enabled&&l.oauthAccountKey);return{entries:r,settled:!(o&&i&&r.length===0)}}function wln(e){return e!=="scratch"&&e!=="secretary"}function kln(e,t){return new Set(e.filter(n=>n.kind==="secretary"||!t&&n.kind==="scratch").map(n=>n.id))}const Sln=300;let gj=null,$ge=!1,OG=null;function Cln(){const e=be.getState(),t=it.getState(),r=zX(e.projects,jp(qj)).filter(N=>wln(N.kind)),s=new Set(jp(ng)),o=JA(c2(e.language),"Temporary chats"),i=new Map(e.projects.map(N=>[N.id,N.kind==="scratch"?o:Ta(N)])),l=new Map(e.projects.map(N=>[N.id,N.path])),c=new Map(e.projects.map(N=>[N.id,N.kind])),u=N=>{const j=(N.parentId?t.conversations[N.parentId]:void 0)??N;return c.get(j.projectId)==="scratch"?jT({kind:"scratch",canonicalPath:l.get(j.projectId)??"",conversationId:j.id})??void 0:j.worktree?.path??l.get(N.projectId)},d=e.skills.filter(N=>N.enabled!==!1).map(N=>({name:`/skill:${N.name}`,description:N.description})),f=K_(t.conversations),h=Sk.getState().byConversation,p=Date.now(),m=N=>{const j=mln(N,f.get(N.id)),I=gln(N,h[N.id],p),_=Vje(N.occupancy,N.contextWindow),L={id:N.id,title:N.parentId&&N.coworkerName||N.title,projectName:i.get(N.projectId)??"",projectId:N.projectId,...u(N)?{cwd:u(N)}:{},status:j?.status??(N.spawning?"running":N.status),updatedAt:py(N),...N.parentId?{parentId:N.parentId}:{},...N.pinned===!0?{pinned:!0}:{},...N.archived===!0?{archived:!0}:{},...N.muted===!0?{muted:!0}:{},...N.lastProviderId?{providerId:N.lastProviderId}:{},...N.lastModelId?{modelId:N.lastModelId}:{},...N.reasoningEnabled!==void 0?{reasoningEnabled:N.reasoningEnabled}:{},...N.thinkingLevel?{thinkingLevel:N.thinkingLevel}:{},...N.unread===!0?{unread:!0}:{},...yg(N.pendingAsks)>0?{pendingAskCount:yg(N.pendingAsks)}:{},...N.pendingApprovals&&N.pendingApprovals.length>0?{pendingApprovalCount:N.pendingApprovals.length}:{},...N.queuedMessages?.length?{queued:N.queuedMessages.map(M=>({id:M.id,text:M.text,...M.images?.length?{hasImages:!0}:{}}))}:{},...N.goal?{goal:{text:N.goal.text,status:N.goal.status,...N.goal.note?{note:N.goal.note}:{},autoTurns:N.goal.autoTurns}}:{},...I?{parked:I}:{},...d.length?{slashCommands:d}:{},..._?{context:_}:{},...N.usageTotals?{usageTotals:N.usageTotals}:{}};return j&&"queuePosition"in j&&Object.assign(L,{queuePosition:j.queuePosition}),j&&"queueFailed"in j&&Object.assign(L,{queueFailed:j.queueFailed}),L},v=t.order.map(N=>t.conversations[N]).filter(N=>!!N),b=new Set(t.order),x=Object.values(t.conversations).filter(N=>!!(N?.parentId&&b.has(N.parentId))),S=[...v,...x].map(m),k=kln(e.projects,e.scratchSessionsEnabled),C=S.filter(N=>!k.has(N.projectId)),A=yln(MM(),Ri.getState().snapshot,e.virtualModels);return{catalog:C,pinnedOrder:jp(MH),projects:r.map(N=>({...hln(N),...s.has(N.id)?{archived:!0}:{}})),projectGroups:e.projectGroups,providers:A.entries,providersSettled:A.settled,projectPaths:e.projects.map(N=>({id:N.id,path:N.path})),theme:e.theme,terminal:rN(e.terminalTheme),terminalFontFamily:e.terminalFontFamily,compactReadOnlyTools:e.compactReadOnlyTools,expandLiveEdits:e.expandLiveEdits,expandLiveReasoning:e.expandLiveReasoning,autoCollapseTurns:e.autoCollapseTurns,collapseCompletedActivity:e.collapseCompletedActivity,collapseLiveActivity:e.collapseLiveActivity,pinUnfinishedTodos:e.pinUnfinishedTodos}}function Eln(e){return xln({catalog:vln(e.catalog,e.pinnedOrder??[]),projects:e.projects,projectGroups:e.projectGroups,providers:e.providers,providersSettled:e.providersSettled,projectPaths:e.projectPaths,theme:e.theme,terminal:e.terminal,terminalFontFamily:e.terminalFontFamily,compactReadOnlyTools:e.compactReadOnlyTools,expandLiveEdits:e.expandLiveEdits,expandLiveReasoning:e.expandLiveReasoning,autoCollapseTurns:e.autoCollapseTurns,collapseCompletedActivity:e.collapseCompletedActivity,collapseLiveActivity:e.collapseLiveActivity,pinUnfinishedTodos:e.pinUnfinishedTodos})}function Tln(){return it.persist.hasHydrated()&&be.persist.hasHydrated()}function hp(){gj&&clearTimeout(gj),gj=setTimeout(()=>{if(gj=null,!Ql()||!Tln())return;const e=Cln(),t=Eln(e);t!==OG&&(OG=t,window.electronAPI.pair.pushCatalog(e))},Sln)}function Aln(){$ge||($ge=!0,hp(),it.persist.onFinishHydration(hp),be.persist.onFinishHydration(hp),it.subscribe((e,t)=>{(e.conversations!==t.conversations||e.order!==t.order)&&hp()}),Ri.subscribe((e,t)=>{e.snapshot!==t.snapshot&&hp()}),Sk.subscribe((e,t)=>{e.byConversation!==t.byConversation&&hp()}),Mf.subscribe((e,t)=>{e.snapshot!==t.snapshot&&hp()}),be.subscribe((e,t)=>{(e.projects!==t.projects||e.projectGroups!==t.projectGroups||e.providers!==t.providers||e.theme!==t.theme||e.terminalTheme!==t.terminalTheme||e.terminalFontFamily!==t.terminalFontFamily||e.compactReadOnlyTools!==t.compactReadOnlyTools||e.expandLiveEdits!==t.expandLiveEdits||e.expandLiveReasoning!==t.expandLiveReasoning||e.autoCollapseTurns!==t.autoCollapseTurns||e.collapseCompletedActivity!==t.collapseCompletedActivity||e.collapseLiveActivity!==t.collapseLiveActivity||e.pinUnfinishedTodos!==t.pinUnfinishedTodos||e.skills!==t.skills)&&hp()}),V2e(hp),ret(e=>{e&&(OG=null,hp())}),window.electronAPI.pair.onResumeSession(e=>{nre(e),Ql()&&(it.getState().markConversationRead(e),it.getState().resumeConversation(e))}),window.electronAPI.pair.onSessionCreated(e=>{nre(e.sessionId),Ql()&&it.getState().adoptPairSession(e)}),window.electronAPI.pair.onSessionConfig(e=>{if(!Ql())return;const t=it.getState();e.type==="set-model"?t.setModel(e.sessionId,e.providerId,e.modelId):e.type==="set-reasoning"?t.setReasoning(e.sessionId,e.enabled):t.setThinking(e.sessionId,e.level)}),window.electronAPI.pair.onQueueAction(e=>{if(!Ql())return;const t=it.getState();switch(e.type){case"enqueue":t.enqueueMessage(e.sessionId,e.text,e.images);break;case"queue-remove":t.removeQueuedMessage(e.sessionId,e.messageId);break;case"queue-update":t.updateQueuedMessage(e.sessionId,e.messageId,e.text);break;case"queue-send-now":t.sendQueuedNow(e.sessionId,e.messageId);break;case"queue-interrupt-send":t.interruptAndSendQueued(e.sessionId,e.messageId);break;case"goal-pause":t.pauseGoal(e.sessionId);break;case"goal-resume":t.resumeGoal(e.sessionId);break;case"goal-clear":t.clearGoal(e.sessionId);break;case"goal-set":t.setGoal(e.sessionId,e.text);break;case"compact":t.compact(e.sessionId,e.instructions,{quiet:!0});break;case"rewind":t.rewind(e.sessionId,e.userIndexFromEnd,e.restoreFiles);break;case"retry":t.retry(e.sessionId);break;case"task-stop":window.electronAPI.agent.stopTask(e.sessionId,e.taskId);break;case"subagent-stop":window.electronAPI.agent.stopSubagent(e.sessionId,e.agentId);break}}))}const Nln=3e4;async function Iln(e,t=Date.now()){const{order:n,conversations:r,activeId:s}=it.getState(),o=n.flatMap(d=>{const f=r[d];return!f||f.parentId?[]:(d===s||f.status==="running"||f.spawning===!0||f.workspaceMigrating===!0||(f.pendingAsks?.length??0)>0||(f.pendingApprovals?.length??0)>0)&&e.kind==="stale"?[]:[{id:d,projectId:f.projectId,archived:f.archived,archivedAt:f.archivedAt,pinned:f.pinned,lastActiveAt:py(f)}]}),i=k1e(o,e,t),l=it.getState();for(const d of i)l.removeConversation(d);const c=Date.now()+Nln,u=()=>i.filter(d=>it.getState().conversations[d]);for(;u().length>0&&Date.now()<c;)await new Promise(d=>setTimeout(d,200));return i.length-u().length}const jln=y.lazy(()=>Be(()=>import("./SidePanel-BzHQWaD_.js"),__vite__mapDeps([127,126,128]),import.meta.url).then(e=>({default:e.SidePanel}))),Rln=e=>{const t=qLe(e);return t.length>0?t:f0e(e)},Kge="enso-sidebar-width",Xge="enso-sidebar-collapsed";function vj(){const e=it.getState(),n=(e.activeId?e.conversations[e.activeId]:null)?.projectId??be.getState().projects[0]?.id;n&&e.newConversation(n)}const xj="no-drag flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",Qge=200,Zge=420;function Mln(){const e=be(he=>he.onboarded),t=y.useSyncExternalStore(he=>be.persist?.onFinishHydration?.(he)??(()=>{}),()=>be.persist?.hasHydrated?.()??!0);GXe(),Ran(),Ian(),Dan(),Han(),jan();const[n,r]=y.useState(!1),[s,o]=y.useState(null);Wan();const[i,l]=y.useState(()=>{const he=Number(localStorage.getItem(Kge));return Number.isFinite(he)&&he>=Qge?Math.min(he,Zge):280}),[c,u]=y.useState(()=>localStorage.getItem(Xge)==="1"),d=Qp(),f=KXe(),[h,p]=y.useState(!1),m=y.useCallback(()=>p(!1),[]);y.useEffect(()=>{d||p(!1)},[d]),y.useEffect(()=>it.subscribe((he,Ye)=>{he.activeId!==Ye.activeId&&p(!1)}),[]);const{t:v}=Se(),b=be(he=>he.chatWide),x=it(he=>he.activeId),S=Bq(x),k=fs(he=>he.uiByConversation[x??""]?.width??he.lastWidth),C=fs(he=>he.fullscreen),A=fs(he=>he.toggleOpen),N=_t(he=>he.panelOpen),j=_t(he=>he.togglePanel);y.useEffect(()=>{C&&!S&&fs.getState().setFullscreen(!1)},[S,C]),y.useEffect(()=>ust(),[]),y.useEffect(()=>(document.documentElement.classList.add("enso-main-shell"),()=>document.documentElement.classList.remove("enso-main-shell")),[]),y.useEffect(()=>window.electronAPI.app.onCloseRequest(o),[]),y.useEffect(()=>window.electronAPI.app.onFlushPersist(he=>{RXe().finally(()=>{window.electronAPI.app.respondFlushPersist(he)})}),[]);const I=he=>{const Ye=s;Ye&&(o(null),window.electronAPI.app.respondCloseRequest(Ye,{action:he}))},_=y.useCallback(()=>{$Xe(window.innerWidth)?p(he=>!he):u(he=>!he)},[]),L=y.useCallback(()=>{window.electronAPI.env.platform==="darwin"&&window.setTimeout(()=>window.electronAPI.window.refreshDragRegions(),400)},[]),M=y.useCallback(()=>{_(),L()},[_,L]);y.useEffect(()=>$an(M),[M]),y.useEffect(()=>window.electronAPI.window.onToggleSidebar(M),[M]);const[F,D]=y.useState(!1),R=y.useRef(null);y.useEffect(()=>{localStorage.setItem(Kge,String(i))},[i]),y.useEffect(()=>{localStorage.setItem(Xge,c?"1":"0")},[c]),y.useEffect(()=>window.electronAPI.resources.onSessionsCleanRequest(({requestId:he,request:Ye})=>{Iln(Ye).catch(()=>0).then(Le=>window.electronAPI.resources.sessionsCleanDone(he,Le))}),[]),y.useEffect(()=>{Aln()},[]),y.useEffect(()=>{const he=window.electronAPI.remote;return he&&!he.nativePlatform?void 0:jd.getState().bind()},[]);const z=jd(he=>he.pairDialogOpen),B=ift(),H=be(he=>he.botModeEnabled),G=be(he=>he.headerSessionTabs),ne=mg(he=>he.mode);y.useEffect(()=>{const he=be.persist?.hasHydrated?.()??!0;ne==="bot"&&he&&!H&&mg.getState().setMode("code")},[ne,H]),y.useEffect(()=>{if(!H)return;const he=_t.getState().bind(),Ye=window.electronAPI.bots.onEvent(Le=>{Le.kind==="open"&&aft(Le)});return()=>{he(),Ye()}},[H]);const W=be(he=>he.secretaryEnabled),T=Pr(he=>he.welcomeOpen),U=Ey(he=>he.open);y.useEffect(()=>W?Pr.getState().bind():void 0,[W]),y.useEffect(()=>window.electronAPI.agent.onFocusSession(he=>{it.getState().conversations[he]&&oP()}),[]);const P=y.useCallback(he=>{l(Ye=>Math.min(Zge,Math.max(Qge,Ye+he)))},[]),K=be(he=>he.keybindings);y.useEffect(()=>{const he=Rh(K),Ye=Ne=>{const Ge=it.getState(),ft=Ge.activeId?Ge.conversations[Ge.activeId]:null;if(!ft)return;const Ze=[void 0,...ft.coworkerIds??[]];if(Ze.length<=1)return;const je=Ze.indexOf(ft.activeTabId);Ge.selectTab(ft.id,Ze[(je+Ne+Ze.length)%Ze.length])},Le=Ne=>{const Ge=Yv(Ne);if(!Ge)return;if(Ge===he["open-settings"]){Ne.preventDefault(),mLe();return}if(wc.getState().settings)return;if(Ge===he["toggle-app-mode"]){if(!be.getState().botModeEnabled)return;Ne.preventDefault();const je=mg.getState();je.setMode(je.mode==="bot"?"code":"bot");return}const ft=loe();if(ft&&Ge===he["toggle-side-panel"]){Ne.preventDefault(),_t.getState().togglePanel();return}if(ft&&Ge===he["search-workspace"]){Ne.preventDefault(),_t.getState().setSearchOpen(!0);return}if(!(ft&&["new-conversation","next-tab","prev-tab","toggle-side-panel","toggle-side-panel-fullscreen","new-side-tab","new-btw-tab","close-side-tab","find-in-chat","search-workspace","open-secretary"].some(Ze=>Ge===he[Ze]))){if(Ge===he["toggle-sidebar"]){if(Ne.preventDefault(),act(Ne,Ge))return;M()}else if(Ge===he["open-secretary"])be.getState().secretaryEnabled&&(Ne.preventDefault(),xR());else if(Ge===he["new-conversation"])Ne.preventDefault(),vj();else if(Ge===he["new-side-tab"])Ne.preventDefault(),ict(Ne.target)?ewt():vj();else if(Ge===he["new-btw-tab"])Ne.preventDefault(),rwt();else if(Ge===he["next-tab"])Ne.preventDefault(),Ye(1);else if(Ge===he["prev-tab"])Ne.preventDefault(),Ye(-1);else if(Ge===he["toggle-side-panel"])Ne.preventDefault(),fs.getState().toggleOpen();else if(Ge===he["toggle-side-panel-fullscreen"])Ne.preventDefault(),fs.getState().toggleFullscreen();else if(Ge===he["close-side-tab"])Ne.preventDefault(),lwt();else if(Ge===he["focus-composer"])Ne.preventDefault(),b2();else if(Ge===he["find-in-chat"])Ne.preventDefault(),vje();else if(Ge===he["search-workspace"])Ne.preventDefault(),r(!0);else if(!ft){const Ze=uMe(kje(),K,he).byBinding.get(Ge);if(!Ze)return;Ne.preventDefault();const je=it.getState(),Je=je.activeId?je.conversations[je.activeId]:null;MX(Ze,Je?Je.activeTabId??Je.id:null).then(st=>{st&&Ht({type:"error",title:Ze.title,description:st})})}}};return window.addEventListener("keydown",Le),()=>window.removeEventListener("keydown",Le)},[K,M]),y.useEffect(()=>{if(!S||!C)return;const he=Ye=>{Ye.key==="Escape"&&(loe()||wc.getState().settings||(Ye.preventDefault(),fs.getState().setFullscreen(!1)))};return window.addEventListener("keydown",he),()=>window.removeEventListener("keydown",he)},[S,C]);const J=DLe(OLe(GG,{activationConstraint:{distance:6}})),ee=bLe(),X=y.useRef(null),te=y.useRef(null),Q=y.useRef(null),[oe,de]=y.useState(null),[ie]=y.useState(()=>Kan({reducedMotion:Qan,onSettle:()=>de(null)})),[ue,xe]=y.useState(ee);y.useLayoutEffect(()=>{if(ue===ee)return;xe(ee);const he=X.current,Ye=Ne=>he?.querySelector(`[data-enso="${Ne}"]`)??null,Le=ie.run(ee?"settings":"workbench",{workbench:{sidebar:d?null:Q.current,main:B?te.current:R.current},settings:d?{sidebar:he,main:null}:{sidebar:Ye("settings-nav"),main:Ye("settings-content")}});de(Le.animating?{top:Le.top}:null)},[ee,ue,ie,d,B]),y.useEffect(()=>()=>ie.finish(),[ie]),y.useLayoutEffect(()=>{oe===null&&ie.release()},[oe,ie]);const{settingsMounted:ge,workbenchHidden:Te}=Xan({open:ee,shown:ue,animating:oe!==null});y.useLayoutEffect(()=>vLe(ge),[ge]),y.useEffect(()=>{ee&&p(!1)},[ee]),y.useEffect(()=>qan(window.electronAPI.window),[]);const De=y.useRef(d);De.current=d,y.useEffect(()=>{if(window.electronAPI.remote)return Yan(window,{depth:()=>xLe(wc.getState(),De.current),apply:he=>{if(he===0){lT();return}nu(),i0e(he===2)},subscribe:he=>wc.subscribe(he)})},[]);const Me=ge?a.jsx("div",{ref:X,"data-enso":"settings-view",inert:!ee,className:ve("absolute inset-0 flex",d&&"bg-background",oe?.top==="workbench"?"z-0":"z-[2]"),children:a.jsx(Nan,{navWidth:i,onNavResize:P,open:ee})}):null,ze=iP(),He=ze!=="mobile"&&!B,tt=y.useCallback(he=>{const Ye=R.current;if(!Ye)return;const Le=getComputedStyle(Ye),Ne=Ye.clientWidth-parseFloat(Le.paddingLeft)-parseFloat(Le.paddingRight);fs.getState().nudgeWidth(-he,Ne,He?ost:lN)},[He]),$e=H?a.jsx(hDt,{}):null,Ue=He&&(ze==="mac"||ze==="windows"||ze==="web"),Pe=Ue&&S&&!d&&!B,we=G&&!ee&&He&&!H&&!(Pe&&C)?a.jsx(kct,{onNew:vj}):null,ye=a.jsx("button",{type:"button",className:ve("flex items-center justify-center rounded-md transition-colors hover:bg-accent/50",d?"h-9 w-9":He?xj:"h-7 w-7",(B?N:S)?"text-foreground":"text-muted-foreground"),onClick:B?j:A,"aria-label":v("Toggle side panel"),title:v("Toggle side panel"),children:a.jsx(CUe,{className:"h-4 w-4"})}),Re=a.jsx("button",{type:"button",className:ve("flex h-7 w-7 items-center justify-center rounded-md transition-colors hover:bg-accent/50",b?"text-foreground":"text-muted-foreground",d&&"hidden"),onClick:()=>be.getState().setChatWide(!b),"aria-label":v(b?"Use reading width":"Use full chat width"),title:v(b?"Use reading width":"Use full chat width"),children:b?a.jsx($ze,{className:"h-4 w-4"}):a.jsx(PVe,{className:"h-4 w-4"})}),_e=a.jsxs(a.Fragment,{children:[Re,ye]}),Ve=He?{trailing:Re}:null;return a.jsxs("div",{"data-enso":"canvas",className:ve("relative isolate flex flex-col",d?"h-dvh":"h-screen"),children:[a.jsx(U2e,{}),a.jsx(eln,{}),a.jsx(fst,{}),a.jsx(fft,{}),a.jsx(Czt,{}),ze!=="mobile"?a.jsx(foe,{leading:a.jsxs("div",{className:"flex items-center gap-0.5",children:[a.jsx("div",{className:ve(ze!=="mac"&&"flex justify-center",ze!=="mac"&&(He?"w-[48px]":"w-12")),children:a.jsx("button",{type:"button","data-enso":"sidebar-toggle",className:ve(xj,ee&&"pointer-events-none opacity-40"),disabled:ee,onClick:M,title:v(c?"Expand sidebar":"Collapse sidebar"),children:c?a.jsx(Nxe,{className:"h-4 w-4"}):a.jsx(MW,{className:"h-4 w-4"})})}),He&&!ee&&a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button","data-enso":"search-button",className:xj,onClick:()=>r(!0),title:v("Search anything"),children:a.jsx(su,{className:"h-4 w-4"})}),a.jsx("button",{type:"button","data-enso":"new-session",className:xj,onClick:vj,title:v("New conversation"),children:a.jsx(hVe,{className:"h-4 w-4"})})]})]}),centered:(Pe&&C?null:$e)??void 0,middle:we,className:ve(ze!=="mac"&&"pl-0",He&&"border-b-0",He&&"bg-transparent",He&&ze==="mac"&&"pr-4"),actions:ee?void 0:He?Pe?void 0:ye:_e}):a.jsx(foe,{title:"EnsoCode",centered:$e??void 0,leading:d&&!B?a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("button",{type:"button","data-enso":"sidebar-toggle",className:"-ml-1.5 flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",onClick:()=>p(!0),"aria-label":v("Conversations"),title:v("Conversations"),children:a.jsx(nUe,{className:"h-5 w-5"})}),!$e&&a.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"EnsoCode"})]}):void 0,actions:_e}),!He&&a.jsx(doe,{}),!He&&a.jsx(jae,{}),!He&&a.jsx(Rae,{}),a.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[a.jsx("div",{ref:te,"data-enso":"workbench",inert:Te,className:ve("flex min-h-0 min-w-0 flex-1",Te&&"invisible",oe?.top==="workbench"&&"z-[1]"),children:B?a.jsx(lDt,{sidebarWidth:i,collapsed:c,onToggleCollapse:M,onResize:P}):a.jsxs(B8e,{sensors:J,collisionDetection:Rln,children:[d?a.jsxs(a.Fragment,{children:[a.jsx(hE,{children:h&&a.jsx(hf.div,{className:"fixed inset-0 bg-black/40",style:{zIndex:_r.MOBILE_DRAWER},initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:m},"drawer-backdrop")}),a.jsx(hf.div,{className:"fixed inset-y-0 left-0 flex bg-background shadow-xl",style:{zIndex:_r.MOBILE_DRAWER},initial:!1,animate:{x:h?0:"-105%"},transition:tk,inert:!h,children:a.jsx(Que,{width:Math.min(320,Math.round(f*.85)),collapsed:!1,onToggleCollapse:m,onOpenSearch:()=>r(!0),onNavigate:m})})]}):a.jsxs("div",{ref:Q,className:"flex min-h-0 shrink-0",children:[a.jsx(Que,{width:c?void 0:i,collapsed:c,onToggleCollapse:M,onOpenSearch:()=>r(!0)}),!c&&a.jsx(tA,{edge:He,onResize:P})]}),a.jsxs("div",{ref:R,className:ve("relative flex min-h-0 min-w-0 flex-1",Ue?"overflow-x-clip":"overflow-hidden",He&&"-mt-px -ml-px pt-px pr-[8px] pb-[8px] pl-px"),children:[a.jsxs("div",{"data-enso":"main",className:ve("relative flex min-h-0 min-w-0 flex-1 flex-col bg-background",He&&"overflow-hidden rounded-[10px] shadow-surface",Pe&&"rounded-r-none"),style:S&&C?{visibility:"hidden",transition:`visibility 0s ${V6.duration}s`}:void 0,children:[a.jsx(aln,{}),a.jsx(iot,{hidden:W&&T||U,children:a.jsx(cSe.Provider,{value:Ve,children:a.jsx(ABt,{})})}),He&&a.jsx(doe,{}),He&&a.jsx(jae,{}),He&&a.jsx(Rae,{}),W&&T&&a.jsx(YHt,{}),U&&a.jsx(HAt,{})]}),!C&&!d&&a.jsx(tA,{gap:He&&!Ue,inactive:!S,onResize:tt,onResizingChange:D}),a.jsx(y.Suspense,{fallback:null,children:a.jsx(jln,{width:k,resizing:F,card:He,titleRow:Ue})})]})]})}),!d&&Me]}),d&&Me,t&&!e&&!window.electronAPI.remote&&a.jsx(fHt,{}),a.jsx(qHt,{open:n,onOpenChange:r}),a.jsx(uUt,{}),a.jsx(TRe,{open:z,onOpenChange:jd.getState().setPairDialogOpen}),a.jsx(Jp,{open:s!==null,onOpenChange:he=>{!he&&s&&I("cancel")},children:a.jsxs(em,{className:"sm:max-w-sm",children:[a.jsxs(tm,{children:[a.jsx(rm,{className:"text-base",children:v("Confirm exit")}),a.jsx(sm,{children:v("Exit closes the app completely, so your phone can no longer connect. Minimize to tray keeps the app running in the background so your phone can still connect.")})]}),a.jsxs(nm,{variant:"bare",children:[a.jsx(dx,{render:a.jsx(Ke,{variant:"outline",size:"sm"}),children:v("Cancel")}),a.jsx(Ke,{size:"sm",onClick:()=>I("tray"),children:v("Minimize to tray")}),a.jsx(Ke,{variant:"destructive",size:"sm",onClick:()=>I("quit"),children:v("Exit")})]})]})}),a.jsx(Eft,{})]})}function _ln(e){return new Worker(""+new URL("worker-DsKBD11i.js",import.meta.url).href,{type:"module",name:e?.name})}const Pln={workerFactory:()=>new _ln,poolSize:2},Lln={theme:v4,langs:[...x6e],preferredHighlighter:"shiki-js"};function Oln({children:e}){return a.jsx(Y$t,{poolOptions:Pln,highlighterOptions:Lln,children:e})}function Dln(e=document,t=800){const n=new Map,r=s=>{const o=s.target,i=o&&o.nodeType===9?o.documentElement:o;!i||typeof i.setAttribute!="function"||(i.setAttribute("data-scrolling",""),clearTimeout(n.get(i)),n.set(i,setTimeout(()=>{n.delete(i),i.removeAttribute("data-scrolling")},t)))};return e.addEventListener("scroll",r,{capture:!0,passive:!0}),()=>{e.removeEventListener("scroll",r,{capture:!0});for(const s of n.values())clearTimeout(s);n.clear()}}function Jge({conversations:e,activeId:t}){const n=document.documentElement.dataset,r=WBt(e),s=nRe(t?e[t]:void 0,e);n.ensoActivity!==r&&(n.ensoActivity=r),n.ensoSession!==s&&(n.ensoSession=s)}function Bln(){Jge(it.getState()),it.subscribe((e,t)=>{(e.conversations!==t.conversations||e.activeId!==t.activeId)&&Jge(e)})}VXe();Bln();Dln();M2e();QPe.createRoot(document.getElementById("root")).render(a.jsx(y.StrictMode,{children:a.jsx(Oln,{children:a.jsx(Mln,{})})}));export{hKt as $,Ecn as A,wcn as B,v4 as C,PMe as D,k3e as E,cXt as F,RYt as G,Lcn as H,Tcn as I,wL as J,kL as K,G3 as L,M2 as M,Bcn as N,Fcn as O,zfe as P,Qo as Q,Gk as R,kcn as S,sG as T,Cc as U,lhe as V,a6e as W,r$t as X,Ffe as Y,V3 as Z,_cn as _,QEt as a,QKt as a$,che as a0,Icn as a1,m4 as a2,wKt as a3,ru as a4,g$t as a5,Rfe as a6,f6e as a7,ahe as a8,bKt as a9,CKt as aA,LMe as aB,OMe as aC,DMe as aD,jKt as aE,_Kt as aF,cG as aG,zKt as aH,LKt as aI,GV as aJ,FKt as aK,BKt as aL,TKt as aM,VKt as aN,PKt as aO,sg as aP,v$t as aQ,aG as aR,ehe as aS,$$t as aT,Mt as aU,Acn as aV,Ncn as aW,jcn as aX,Rcn as aY,Mcn as aZ,ycn as a_,O$t as aa,S$t as ab,y$t as ac,Dfe as ad,pKt as ae,_v as af,c6e as ag,K$t as ah,gKt as ai,Ofe as aj,a$t as ak,DKt as al,aKt as am,Z$t as an,the as ao,d5 as ap,xA as aq,UKt as ar,fYt as as,Ocn as at,Dcn as au,iG as av,Al as aw,NKt as ax,IKt as ay,Jfe as az,aXt as b,uct as b$,lG as b0,Zfe as b1,Ea as b2,MYt as b3,Hn as b4,kLe as b5,ve as b6,kW as b7,Bs as b8,Ho as b9,wrn as bA,grn as bB,be as bC,i3t as bD,kk as bE,$u as bF,r2 as bG,xcn as bH,io as bI,mT as bJ,FUe as bK,ua as bL,L3t as bM,xs as bN,Rf as bO,kNe as bP,IN as bQ,By as bR,UDt as bS,dK as bT,fK as bU,cA as bV,zy as bW,Pi as bX,n_ as bY,jN as bZ,K_ as b_,jW as ba,it as bb,D6 as bc,vrn as bd,Is as be,kT as bf,Jr as bg,Fy as bh,bq as bi,v_ as bj,kxe as bk,tUt as bl,Yce as bm,ojt as bn,P2 as bo,mx as bp,tK as bq,rK as br,eK as bs,sK as bt,L2 as bu,Pr as bv,Ig as bw,KHe as bx,krn as by,Srn as bz,tx as c,xo as c$,Hue as c0,XN as c1,YFt as c2,Md as c3,szt as c4,Hd as c5,Ri as c6,fu as c7,fcn as c8,xz as c9,Hcn as cA,nu as cB,Ysn as cC,Sxe as cD,Yu as cE,Q4 as cF,Kp as cG,w4t as cH,Xp as cI,wf as cJ,Lf as cK,Y4 as cL,KA as cM,bo as cN,z2 as cO,U2 as cP,H2 as cQ,Txe as cR,Bp as cS,Fp as cT,zp as cU,zr as cV,YT as cW,_i as cX,Qu as cY,Zu as cZ,Ju as c_,TT as ca,mM as cb,Vv as cc,bg as cd,hcn as ce,met as cf,pcn as cg,Cje as ch,vz as ci,Dg as cj,S3e as ck,nBt as cl,f7t as cm,r7t as cn,sc as co,HIe as cp,G7t as cq,mcn as cr,f2e as cs,Ht as ct,b2 as cu,Mh as cv,Ke as cw,Jn as cx,du as cy,ec as cz,jYt as d,jxe as d$,t1 as d0,fs as d1,Vln as d2,jT as d3,Pq as d4,K4 as d5,qa as d6,Exe as d7,fUe as d8,En as d9,Qln as dA,R$ as dB,kse as dC,IYt as dD,su as dE,tA as dF,hv as dG,K1t as dH,aze as dI,xT as dJ,sMe as dK,iXt as dL,Wp as dM,NYt as dN,I0e as dO,Bq as dP,qGe as dQ,T_ as dR,Nd as dS,IEe as dT,Tie as dU,$4 as dV,cq as dW,rN as dX,Hln as dY,tet as dZ,AW as d_,Vze as da,E6t as db,T6t as dc,Kln as dd,mie as de,FN as df,zP as dg,R2 as dh,$Se as di,$xt as dj,sbt as dk,sEe as dl,aWe as dm,i_ as dn,Yln as dp,qln as dq,$ln as dr,C4t as ds,Gcn as dt,Qp as du,gre as dv,Ucn as dw,Vcn as dx,Xln as dy,cg as dz,uXt as e,_W as e0,MM as e1,Uln as e2,rcn as e3,$j as e4,ocn as e5,swt as e6,icn as e7,dcn as e8,gcn as e9,CUe as eA,Tft as eB,scn as eC,bcn as eD,I4t as eE,vcn as eF,Be as eG,hf as ea,k6t as eb,Cwe as ec,hH as ed,WXe as ee,ost as ef,lN as eg,ucn as eh,zln as ei,Jln as ej,ecn as ek,ncn as el,Z1t as em,twt as en,Wln as eo,Zln as ep,tcn as eq,Q1t as er,Gln as es,dHe as et,r_ as eu,YP as ev,zv as ew,_g as ex,vf as ey,iP as ez,nrn as f,zMe as g,l6e as h,r1 as i,a as j,ccn as k,njt as l,Oy as m,_fe as n,tQ as o,Uk as p,Pcn as q,y as r,i6e as s,JKt as t,Se as u,Ccn as v,Scn as w,g4 as x,p4 as y,wA as z};
3003
+ `)[0].trim();return n?{type:"warning",title:n,description:t}:{type:"warning",title:t}}function Man(e){return{at:e.exitAt,kind:e.kind,unfinishedTools:[...e.unfinishedTools],...e.suppressedError?{suppressedError:e.suppressedError}:{}}}function _an(e){return e?e.status!=="running":!1}const Pan=3e4;function Lan(e,t=Pan){return e()?Promise.resolve(!0):new Promise(n=>{const r=l=>{clearTimeout(i);for(const c of o)c();n(l)},s=()=>e()&&r(!0),o=[it.subscribe(s),Ri.subscribe(s),be.subscribe(s)],i=setTimeout(()=>r(e()),t)})}function Oan(){const e=Ri.getState().snapshot.availability.status;return it.persist.hasHydrated()&&be.persist.hasHydrated()&&e!=="unloaded"&&e!=="loading"}function Dan(){const{t:e}=Se();y.useEffect(()=>{Ql()&&(async()=>{const t=await window.electronAPI.agent.takeInterruptedTurns().catch(()=>[]);if(t.length===0||!await Lan(Oan))return;const n=new Set;for(const r of t)_an(it.getState().conversations[r.conversationId])&&(n.add(r.conversationId),it.setState(s=>{const o=s.conversations[r.conversationId];return!o||o.status==="running"?s:{conversations:{...s.conversations,[r.conversationId]:{...o,status:"interrupted",interrupted:Man(r),error:void 0}}}}));n.size!==0&&Ht({type:"info",title:e("{{count}} conversation(s) interrupted by app exit",{count:n.size})})})()},[e])}const Ban=3e4;function Fan(e,t=Ban){return e()?Promise.resolve(!0):new Promise(n=>{const r=l=>{clearTimeout(i);for(const c of o)c();n(l)},s=()=>e()&&r(!0),o=[it.subscribe(s),be.subscribe(s)],i=setTimeout(()=>r(e()),t)})}function zan(){return it.persist.hasHydrated()&&be.persist.hasHydrated()}function Han(){const{t:e}=Se();y.useEffect(()=>{if(!Ql())return;const t=()=>{OH(async()=>{if(!await Fan(zan))return;const r=await window.electronAPI.window.takeOpenFolders().catch(()=>[]);let s=!1;for(const o of r)try{if(!await Y2e(o)){Ht({type:"error",title:e("Failed to add project")});continue}s=!0}catch(i){Ht({type:"error",title:e("Failed to add project"),description:i instanceof Error?i.message:String(i)})}s&&oP()})},n=window.electronAPI.window.onOpenFolderRequested(t);return t(),n},[e])}const zge="enso-win",D_e="enso-win-flush",pj="enso-win-pending",Hge="enso-win-native";function Uan(e,t,n){return{maximized:n.maximized?e.maximized:t.maximized,fullscreen:n.fullscreen?e.fullscreen:t.fullscreen}}function Van(e,t){return e||t}function Gan(e,t){document.documentElement.classList.toggle(D_e,Van(e,t))}function Wan(){y.useEffect(()=>{if(window.electronAPI?.env.platform!=="win32")return;const e=document.documentElement;e.classList.add(zge,pj),e.classList.add(Hge);let t={maximized:!1,fullscreen:!1};const n={maximized:0,fullscreen:0};let r=!1,s=0,o;const i=()=>Gan(t.maximized,t.fullscreen),l=window.electronAPI.window,c=()=>{const h=++s,p={...n};Promise.all([l.isMaximized(),l.isFullScreen()]).then(([m,v])=>{r||h!==s||(t=Uan(t,{maximized:m,fullscreen:v},{maximized:n.maximized!==p.maximized,fullscreen:n.fullscreen!==p.fullscreen}),e.classList.remove(pj),i())}).catch(()=>{!r&&h===s&&e.classList.remove(pj)})};c();const u=()=>{o&&clearTimeout(o),o=setTimeout(c,50)};window.addEventListener("resize",u);const d=l.onMaximizedChange(h=>{n.maximized+=1,t.maximized=h,i()}),f=l.onFullScreenChange(h=>{n.fullscreen+=1,t.fullscreen=h,i()});return()=>{r=!0,o&&clearTimeout(o),window.removeEventListener("resize",u),d(),f(),e.classList.remove(zge,D_e,pj,Hge)}},[])}function qan(e){const t=()=>{e.consumeSettingsDeepLink().then(n=>{n&&nu(n.link)})};return t(),e.onSettingsDeepLink(t)}const B_e="ensoSettingsDepth",Uge=e=>{const t=e?.[B_e];return typeof t=="number"?t:0};function Yan(e,t){let n=Uge(e.history.state),r=!1;const s=()=>{if(r)return;const l=t.depth();for(;n<l;)n+=1,e.history.pushState({[B_e]:n},"");n>l&&(r=!0,e.history.go(l-n))},o=l=>{if(n=Uge(l.state),r){r=!1,s();return}t.depth()!==n&&t.apply(n)};e.addEventListener("popstate",o);const i=t.subscribe(s);return s(),()=>{i(),e.removeEventListener("popstate",o)}}const Vge=new Set;function $an(e){return Vge.add(e),()=>Vge.delete(e)}const mj={duration:180,easing:"cubic-bezier(0.22, 1, 0.36, 1)",shift:10,underlayHold:.6};function Kan(e){let t=null,n=[];const r=()=>{for(const i of n)i.cancel();n=[]},s=()=>{t&&(n.push(...t.animations),t=null,e.onSettle())};return{run:(i,l)=>{if(e.reducedMotion())return s(),r(),{animating:!1,top:i};if(t){if(t.to!==i){t.to=i;for(const v of t.animations)v.reverse()}return{animating:!0,top:t.top}}r();const c=i==="settings"?"workbench":"settings",u=mj.shift*(i==="settings"?1:-1),d=v=>({duration:mj.duration,easing:v,fill:"both"}),f=d(mj.easing),h=v=>`translateX(${v}px)`,p=[l[c].sidebar?.animate([{opacity:1,transform:h(0)},{opacity:0,transform:h(-u)}],f),l[i].sidebar?.animate([{opacity:0,transform:h(u)},{opacity:1,transform:h(0)}],f),l[c].main?.animate([{opacity:1},{opacity:1,offset:mj.underlayHold},{opacity:0}],d("linear")),l[i].main?.animate([{opacity:0},{opacity:1}],f)].filter(v=>v!==void 0),m={to:i,top:i,animations:p};return t=m,Promise.all(p.map(v=>v.finished)).then(()=>{t===m&&s()},()=>{}),{animating:!0,top:i}},target:()=>t?.to??null,release:r,finish:()=>{s(),r()}}}function Xan(e){return{settingsMounted:e.open||e.shown||e.animating,workbenchHidden:e.open&&e.shown&&!e.animating}}const Qan=()=>typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;function Zan(e){return{category:"plugins",rowId:"plugins.enso",pluginId:e}}const FF=e=>typeof e=="string"&&e.length>0?e:null;function Jan(e){if(!e||typeof e!="object")return null;const t=e,n=FF(t.pluginId),r=FF(t.name);if(!n||!r)return null;if(t.kind==="inject-denied")return{type:"warning",titleKey:"{{name}} tried to message another session and was blocked",params:{name:r},actionKey:"Turn on",pluginId:n};const s=FF(t.version);return s?t.kind==="update-needs-approval"?{type:"warning",titleKey:"{{name}} {{version}} needs new permissions",params:{name:r,version:s},actionKey:"Review permissions",pluginId:n}:t.kind==="auto-updated"?{type:"success",titleKey:"{{name}} updated to {{version}}",params:{name:r,version:s},actionKey:"View",pluginId:n}:null:null}function eln(){const{t:e}=Se();return y.useEffect(()=>window.electronAPI.extensionPlugins.onNotice(t=>{const n=Jan(t);n&&Ht({type:n.type,title:e(n.titleKey,n.params),...n.actionKey?{actions:[{label:e(n.actionKey),onClick:()=>{nu(Zan(n.pluginId))}}]}:{}})}),[e]),null}function tln(e,t){const n=new Set,r=[];for(const s of e)for(const o of s.interceptBreakers??[]){const i=`${s.id}:${o.event}:${o.until}`;n.add(i),t.has(i)||r.push({pluginName:s.name,event:o.event})}t.clear();for(const s of n)t.add(s);return r}function nln(e,t){let n=0;for(const r of t)e.length>r.length&&e.endsWith(r)&&r.length>n&&(n=r.length);return n}function Ucn(e,t){const n=(e.split("/").at(-1)??"").toLowerCase();return t.map(r=>({viewer:r,length:nln(n,r.extensions)})).filter(r=>r.length>0).sort((r,s)=>s.length-r.length).map(r=>r.viewer)}const Vcn=e=>`${e.pluginId}:${e.id}`;let F_e=[];const LG=new Set;function Gge(e){F_e=e;for(const t of LG)t()}function rln(e){return LG.add(e),()=>LG.delete(e)}const Wge=()=>F_e;function Gcn(){return y.useSyncExternalStore(rln,Wge,Wge)}function qge(e){const t=e.permissions.includes("composer.draft")?"1":"0";return`${e.id}\0${e.version}\0${e.build}\0${e.renderer??""}\0${t}`}function z_e(e,t){try{t?.dispose()}catch(n){console.warn(`[plugin] ${e} 渲染模块卸载失败`,n)}}async function sln(e,t,n,r){if(!r())return;const s=new Map;for(const i of t)i.state==="enabled"&&i.renderer&&s.set(i.id,{...i,renderer:i.renderer});const o=[];for(const[i,l]of e){const c=s.get(i);(!c||qge(c)!==l.key)&&o.push(i)}for(const i of o)z_e(i,e.get(i)),e.delete(i);await Promise.allSettled([...s.values()].filter(i=>!e.has(i.id)).map(async i=>{if(!r())return;let l;try{l=await n(i)}catch(d){if(!r())return;console.warn(`[plugin] ${i.id} 渲染模块加载失败`,d);return}if(!r()){l.dispose();return}const c=qge(i),u=e.get(i.id);if(u?.key===c){l.dispose();return}u?.dispose(),e.set(i.id,{key:c,dispose:()=>l.dispose()})}))}const Kl=(e,t)=>({ok:!1,code:e,error:t});async function oln(e,t){if(e.op==="focusSession"){const i=e.payload.sessionId;if(typeof i!="string"||!i)return Kl("BAD_REQUEST","缺少会话 id");const l=t.conversation(i);if(l)return t.focus(l.parentId??i,i),{ok:!0,value:null};const c=i.indexOf("::");if(c>0){const u=i.slice(0,c);return t.conversation(u)?(t.focusSubagent(u,i),{ok:!0,value:null}):Kl("NOT_FOUND","会话不在本窗口")}return Kl("NOT_FOUND","会话不在本窗口")}if(e.op==="openChildRun"){const i=e.payload.parentId,l=e.payload.childId;return typeof i!="string"||!i?Kl("BAD_REQUEST","缺少父会话 id"):typeof l!="string"||!l?Kl("BAD_REQUEST","缺少子会话 id"):t.conversation(i)?(t.openChildRun(i,l),{ok:!0,value:null}):Kl("NOT_FOUND","会话不在本窗口")}if(e.op==="focusSubagent"){const i=e.payload.sessionId,l=e.payload.agentId;return typeof i!="string"||!t.conversation(i)?Kl("NOT_FOUND","会话不在本窗口"):typeof l!="string"||!l?Kl("BAD_REQUEST","缺少子代理 id"):(t.focusSubagent(i,l),{ok:!0,value:null})}if(e.op==="ensureSession"){const i=t.conversation(e.sessionId);if(!i)return Kl("NOT_FOUND","会话不在本窗口");if(i.parentId)return Kl("UNSUPPORTED","子会话随主会话恢复");const l=await t.ensure(e.sessionId);return l?Kl("SESSION_FAILED",l):{ok:!0,value:null}}if(e.op==="openPluginView"){if(!t.conversation(e.sessionId))return Kl("NOT_FOUND","会话不在本窗口");const{pluginId:i,viewId:l,title:c}=e.payload;return typeof i!="string"||!i||typeof l!="string"||!l||typeof c!="string"||!c?Kl("BAD_REQUEST","缺少视图标识"):(t.openPluginView?.(e.sessionId,{pluginId:i,viewId:l,title:c}),{ok:!0,value:null})}if(e.op==="closePluginView"){if(!t.conversation(e.sessionId))return Kl("NOT_FOUND","会话不在本窗口");const{pluginId:i,viewId:l}=e.payload;return typeof i!="string"||!i||typeof l!="string"||!l?Kl("BAD_REQUEST","缺少视图标识"):(t.closePluginView?.(e.sessionId,{pluginId:i,viewId:l}),{ok:!0,value:null})}const n=t.conversation(e.sessionId);if(!n)return Kl("NO_SESSION","发起调用的会话不在本窗口");const r=typeof e.payload.presetId=="string"?e.payload.presetId:void 0,s=await t.create(n.projectId,r);if(!s)return Kl("CREATE_FAILED","新建会话失败");const o=e.payload.text;return typeof o=="string"&&o&&t.prefill(s,o),{ok:!0,value:{sessionId:s}}}const iln={conversation:e=>it.getState().conversations[e]??null,focus:(e,t)=>{const n=it.getState();n.selectConversation(e),t!==e&&n.selectTab(e,t)},focusSubagent:(e,t)=>it.getState().focusSubagent(e,t),openChildRun:(e,t)=>it.getState().openChildRun(e,t),create:(e,t)=>it.getState().newConversation(e,t?{presetId:t}:void 0),prefill:Ewt,ensure:async e=>{const t=it.getState(),n=t.conversations[e];if(n?.started||n?.spawning)return null;await t.resumeConversation(e,{fresh:!0});const r=it.getState().conversations[e];return r?.started||r?.spawning?null:r?.error??"无法启动会话:请检查默认模型与登录状态"},openPluginView:(e,t)=>MEe({conversationId:e,...t}),closePluginView:(e,t)=>awt({conversationId:e,...t})};function aln(){return y.useEffect(()=>{const e=Nwt(()=>TDt(it.getState()));let t=0;const n=new Map,r=new Set,s=()=>{const l=++t;window.electronAPI.extensionPlugins.list().then(async c=>{if(l!==t)return;for(const{pluginName:d,event:f}of tln(c,r))Ht({type:"warning",title:`插件 ${d} 的检查连续失败,已临时放行`,description:`${f} 事件 30 秒内不再经过该插件;详情见设置里的插件日志`});const u=c.filter(d=>d.state==="enabled");vjt(Object.fromEntries(c.flatMap(d=>d.icon?[[d.id,d.icon]]:[]))),rue(Sje(c)),cue(w9t(c)),dte(u.flatMap(d=>d.views.map(f=>({pluginId:d.id,pluginName:d.name,...f})))),J1t(c),Gge(u.flatMap(d=>(d.fileViewers??[]).map(f=>({pluginId:d.id,pluginName:d.name,...f})))),fue(u.flatMap(d=>d.triggers.filter(f=>f.symbol==="#").map(f=>({pluginId:d.id,name:f.name})))),await sln(n,c,d=>jwt(d.id,d.renderer,e,{draft:d.permissions.includes("composer.draft")}),()=>l===t)})};s();const o=window.electronAPI.extensionPlugins.onChanged(s),i=window.electronAPI.extensionPlugins.onDraftRequest(l=>{if(l.op==="focusSession"||l.op==="focusSubagent"||l.op==="openChildRun"||l.op==="createSession"||l.op==="ensureSession"||l.op==="openPluginView"||l.op==="closePluginView"){oln(l,iln).catch(c=>({ok:!1,code:"SESSION_FAILED",error:c instanceof Error?c.message:String(c)})).then(c=>window.electronAPI.extensionPlugins.respondDraft({requestId:l.requestId,...c}));return}window.electronAPI.extensionPlugins.respondDraft({requestId:l.requestId,...PEe(l)})});return()=>{t+=1,o(),i(),rue([]),fue([]),dte([]),Gge([]),cue([]);for(const[l,c]of n)z_e(l,c);n.clear()}},[]),null}function lln(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var zF={exports:{}};const cln={},uln=Object.freeze(Object.defineProperty({__proto__:null,default:cln},Symbol.toStringTag,{value:"Module"})),dln=UPe(uln);var Yge;function fln(){return Yge||(Yge=1,(function(e){(function(t){var n=function(fe){var Ie,Ae=new Float64Array(16);if(fe)for(Ie=0;Ie<fe.length;Ie++)Ae[Ie]=fe[Ie];return Ae},r=function(){throw new Error("no PRNG")},s=new Uint8Array(16),o=new Uint8Array(32);o[0]=9;var i=n(),l=n([1]),c=n([56129,1]),u=n([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),d=n([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),f=n([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),h=n([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),p=n([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function m(fe,Ie,Ae,ce){fe[Ie]=Ae>>24&255,fe[Ie+1]=Ae>>16&255,fe[Ie+2]=Ae>>8&255,fe[Ie+3]=Ae&255,fe[Ie+4]=ce>>24&255,fe[Ie+5]=ce>>16&255,fe[Ie+6]=ce>>8&255,fe[Ie+7]=ce&255}function v(fe,Ie,Ae,ce,Oe){var dt,vt=0;for(dt=0;dt<Oe;dt++)vt|=fe[Ie+dt]^Ae[ce+dt];return(1&vt-1>>>8)-1}function b(fe,Ie,Ae,ce){return v(fe,Ie,Ae,ce,16)}function x(fe,Ie,Ae,ce){return v(fe,Ie,Ae,ce,32)}function S(fe,Ie,Ae,ce){for(var Oe=ce[0]&255|(ce[1]&255)<<8|(ce[2]&255)<<16|(ce[3]&255)<<24,dt=Ae[0]&255|(Ae[1]&255)<<8|(Ae[2]&255)<<16|(Ae[3]&255)<<24,vt=Ae[4]&255|(Ae[5]&255)<<8|(Ae[6]&255)<<16|(Ae[7]&255)<<24,Et=Ae[8]&255|(Ae[9]&255)<<8|(Ae[10]&255)<<16|(Ae[11]&255)<<24,Ct=Ae[12]&255|(Ae[13]&255)<<8|(Ae[14]&255)<<16|(Ae[15]&255)<<24,xn=ce[4]&255|(ce[5]&255)<<8|(ce[6]&255)<<16|(ce[7]&255)<<24,yn=Ie[0]&255|(Ie[1]&255)<<8|(Ie[2]&255)<<16|(Ie[3]&255)<<24,er=Ie[4]&255|(Ie[5]&255)<<8|(Ie[6]&255)<<16|(Ie[7]&255)<<24,Fe=Ie[8]&255|(Ie[9]&255)<<8|(Ie[10]&255)<<16|(Ie[11]&255)<<24,We=Ie[12]&255|(Ie[13]&255)<<8|(Ie[14]&255)<<16|(Ie[15]&255)<<24,lt=ce[8]&255|(ce[9]&255)<<8|(ce[10]&255)<<16|(ce[11]&255)<<24,yt=Ae[16]&255|(Ae[17]&255)<<8|(Ae[18]&255)<<16|(Ae[19]&255)<<24,Bt=Ae[20]&255|(Ae[21]&255)<<8|(Ae[22]&255)<<16|(Ae[23]&255)<<24,Qt=Ae[24]&255|(Ae[25]&255)<<8|(Ae[26]&255)<<16|(Ae[27]&255)<<24,dn=Ae[28]&255|(Ae[29]&255)<<8|(Ae[30]&255)<<16|(Ae[31]&255)<<24,pn=ce[12]&255|(ce[13]&255)<<8|(ce[14]&255)<<16|(ce[15]&255)<<24,Zt=Oe,An=dt,bn=vt,Ln=Et,Un=Ct,gn=xn,Tt=yn,Lt=er,nn=Fe,Ft=We,en=lt,Wt=yt,nt=Bt,Mn=Qt,Zn=dn,sr=pn,at,fr=0;fr<20;fr+=2)at=Zt+nt|0,Un^=at<<7|at>>>25,at=Un+Zt|0,nn^=at<<9|at>>>23,at=nn+Un|0,nt^=at<<13|at>>>19,at=nt+nn|0,Zt^=at<<18|at>>>14,at=gn+An|0,Ft^=at<<7|at>>>25,at=Ft+gn|0,Mn^=at<<9|at>>>23,at=Mn+Ft|0,An^=at<<13|at>>>19,at=An+Mn|0,gn^=at<<18|at>>>14,at=en+Tt|0,Zn^=at<<7|at>>>25,at=Zn+en|0,bn^=at<<9|at>>>23,at=bn+Zn|0,Tt^=at<<13|at>>>19,at=Tt+bn|0,en^=at<<18|at>>>14,at=sr+Wt|0,Ln^=at<<7|at>>>25,at=Ln+sr|0,Lt^=at<<9|at>>>23,at=Lt+Ln|0,Wt^=at<<13|at>>>19,at=Wt+Lt|0,sr^=at<<18|at>>>14,at=Zt+Ln|0,An^=at<<7|at>>>25,at=An+Zt|0,bn^=at<<9|at>>>23,at=bn+An|0,Ln^=at<<13|at>>>19,at=Ln+bn|0,Zt^=at<<18|at>>>14,at=gn+Un|0,Tt^=at<<7|at>>>25,at=Tt+gn|0,Lt^=at<<9|at>>>23,at=Lt+Tt|0,Un^=at<<13|at>>>19,at=Un+Lt|0,gn^=at<<18|at>>>14,at=en+Ft|0,Wt^=at<<7|at>>>25,at=Wt+en|0,nn^=at<<9|at>>>23,at=nn+Wt|0,Ft^=at<<13|at>>>19,at=Ft+nn|0,en^=at<<18|at>>>14,at=sr+Zn|0,nt^=at<<7|at>>>25,at=nt+sr|0,Mn^=at<<9|at>>>23,at=Mn+nt|0,Zn^=at<<13|at>>>19,at=Zn+Mn|0,sr^=at<<18|at>>>14;Zt=Zt+Oe|0,An=An+dt|0,bn=bn+vt|0,Ln=Ln+Et|0,Un=Un+Ct|0,gn=gn+xn|0,Tt=Tt+yn|0,Lt=Lt+er|0,nn=nn+Fe|0,Ft=Ft+We|0,en=en+lt|0,Wt=Wt+yt|0,nt=nt+Bt|0,Mn=Mn+Qt|0,Zn=Zn+dn|0,sr=sr+pn|0,fe[0]=Zt>>>0&255,fe[1]=Zt>>>8&255,fe[2]=Zt>>>16&255,fe[3]=Zt>>>24&255,fe[4]=An>>>0&255,fe[5]=An>>>8&255,fe[6]=An>>>16&255,fe[7]=An>>>24&255,fe[8]=bn>>>0&255,fe[9]=bn>>>8&255,fe[10]=bn>>>16&255,fe[11]=bn>>>24&255,fe[12]=Ln>>>0&255,fe[13]=Ln>>>8&255,fe[14]=Ln>>>16&255,fe[15]=Ln>>>24&255,fe[16]=Un>>>0&255,fe[17]=Un>>>8&255,fe[18]=Un>>>16&255,fe[19]=Un>>>24&255,fe[20]=gn>>>0&255,fe[21]=gn>>>8&255,fe[22]=gn>>>16&255,fe[23]=gn>>>24&255,fe[24]=Tt>>>0&255,fe[25]=Tt>>>8&255,fe[26]=Tt>>>16&255,fe[27]=Tt>>>24&255,fe[28]=Lt>>>0&255,fe[29]=Lt>>>8&255,fe[30]=Lt>>>16&255,fe[31]=Lt>>>24&255,fe[32]=nn>>>0&255,fe[33]=nn>>>8&255,fe[34]=nn>>>16&255,fe[35]=nn>>>24&255,fe[36]=Ft>>>0&255,fe[37]=Ft>>>8&255,fe[38]=Ft>>>16&255,fe[39]=Ft>>>24&255,fe[40]=en>>>0&255,fe[41]=en>>>8&255,fe[42]=en>>>16&255,fe[43]=en>>>24&255,fe[44]=Wt>>>0&255,fe[45]=Wt>>>8&255,fe[46]=Wt>>>16&255,fe[47]=Wt>>>24&255,fe[48]=nt>>>0&255,fe[49]=nt>>>8&255,fe[50]=nt>>>16&255,fe[51]=nt>>>24&255,fe[52]=Mn>>>0&255,fe[53]=Mn>>>8&255,fe[54]=Mn>>>16&255,fe[55]=Mn>>>24&255,fe[56]=Zn>>>0&255,fe[57]=Zn>>>8&255,fe[58]=Zn>>>16&255,fe[59]=Zn>>>24&255,fe[60]=sr>>>0&255,fe[61]=sr>>>8&255,fe[62]=sr>>>16&255,fe[63]=sr>>>24&255}function k(fe,Ie,Ae,ce){for(var Oe=ce[0]&255|(ce[1]&255)<<8|(ce[2]&255)<<16|(ce[3]&255)<<24,dt=Ae[0]&255|(Ae[1]&255)<<8|(Ae[2]&255)<<16|(Ae[3]&255)<<24,vt=Ae[4]&255|(Ae[5]&255)<<8|(Ae[6]&255)<<16|(Ae[7]&255)<<24,Et=Ae[8]&255|(Ae[9]&255)<<8|(Ae[10]&255)<<16|(Ae[11]&255)<<24,Ct=Ae[12]&255|(Ae[13]&255)<<8|(Ae[14]&255)<<16|(Ae[15]&255)<<24,xn=ce[4]&255|(ce[5]&255)<<8|(ce[6]&255)<<16|(ce[7]&255)<<24,yn=Ie[0]&255|(Ie[1]&255)<<8|(Ie[2]&255)<<16|(Ie[3]&255)<<24,er=Ie[4]&255|(Ie[5]&255)<<8|(Ie[6]&255)<<16|(Ie[7]&255)<<24,Fe=Ie[8]&255|(Ie[9]&255)<<8|(Ie[10]&255)<<16|(Ie[11]&255)<<24,We=Ie[12]&255|(Ie[13]&255)<<8|(Ie[14]&255)<<16|(Ie[15]&255)<<24,lt=ce[8]&255|(ce[9]&255)<<8|(ce[10]&255)<<16|(ce[11]&255)<<24,yt=Ae[16]&255|(Ae[17]&255)<<8|(Ae[18]&255)<<16|(Ae[19]&255)<<24,Bt=Ae[20]&255|(Ae[21]&255)<<8|(Ae[22]&255)<<16|(Ae[23]&255)<<24,Qt=Ae[24]&255|(Ae[25]&255)<<8|(Ae[26]&255)<<16|(Ae[27]&255)<<24,dn=Ae[28]&255|(Ae[29]&255)<<8|(Ae[30]&255)<<16|(Ae[31]&255)<<24,pn=ce[12]&255|(ce[13]&255)<<8|(ce[14]&255)<<16|(ce[15]&255)<<24,Zt=Oe,An=dt,bn=vt,Ln=Et,Un=Ct,gn=xn,Tt=yn,Lt=er,nn=Fe,Ft=We,en=lt,Wt=yt,nt=Bt,Mn=Qt,Zn=dn,sr=pn,at,fr=0;fr<20;fr+=2)at=Zt+nt|0,Un^=at<<7|at>>>25,at=Un+Zt|0,nn^=at<<9|at>>>23,at=nn+Un|0,nt^=at<<13|at>>>19,at=nt+nn|0,Zt^=at<<18|at>>>14,at=gn+An|0,Ft^=at<<7|at>>>25,at=Ft+gn|0,Mn^=at<<9|at>>>23,at=Mn+Ft|0,An^=at<<13|at>>>19,at=An+Mn|0,gn^=at<<18|at>>>14,at=en+Tt|0,Zn^=at<<7|at>>>25,at=Zn+en|0,bn^=at<<9|at>>>23,at=bn+Zn|0,Tt^=at<<13|at>>>19,at=Tt+bn|0,en^=at<<18|at>>>14,at=sr+Wt|0,Ln^=at<<7|at>>>25,at=Ln+sr|0,Lt^=at<<9|at>>>23,at=Lt+Ln|0,Wt^=at<<13|at>>>19,at=Wt+Lt|0,sr^=at<<18|at>>>14,at=Zt+Ln|0,An^=at<<7|at>>>25,at=An+Zt|0,bn^=at<<9|at>>>23,at=bn+An|0,Ln^=at<<13|at>>>19,at=Ln+bn|0,Zt^=at<<18|at>>>14,at=gn+Un|0,Tt^=at<<7|at>>>25,at=Tt+gn|0,Lt^=at<<9|at>>>23,at=Lt+Tt|0,Un^=at<<13|at>>>19,at=Un+Lt|0,gn^=at<<18|at>>>14,at=en+Ft|0,Wt^=at<<7|at>>>25,at=Wt+en|0,nn^=at<<9|at>>>23,at=nn+Wt|0,Ft^=at<<13|at>>>19,at=Ft+nn|0,en^=at<<18|at>>>14,at=sr+Zn|0,nt^=at<<7|at>>>25,at=nt+sr|0,Mn^=at<<9|at>>>23,at=Mn+nt|0,Zn^=at<<13|at>>>19,at=Zn+Mn|0,sr^=at<<18|at>>>14;fe[0]=Zt>>>0&255,fe[1]=Zt>>>8&255,fe[2]=Zt>>>16&255,fe[3]=Zt>>>24&255,fe[4]=gn>>>0&255,fe[5]=gn>>>8&255,fe[6]=gn>>>16&255,fe[7]=gn>>>24&255,fe[8]=en>>>0&255,fe[9]=en>>>8&255,fe[10]=en>>>16&255,fe[11]=en>>>24&255,fe[12]=sr>>>0&255,fe[13]=sr>>>8&255,fe[14]=sr>>>16&255,fe[15]=sr>>>24&255,fe[16]=Tt>>>0&255,fe[17]=Tt>>>8&255,fe[18]=Tt>>>16&255,fe[19]=Tt>>>24&255,fe[20]=Lt>>>0&255,fe[21]=Lt>>>8&255,fe[22]=Lt>>>16&255,fe[23]=Lt>>>24&255,fe[24]=nn>>>0&255,fe[25]=nn>>>8&255,fe[26]=nn>>>16&255,fe[27]=nn>>>24&255,fe[28]=Ft>>>0&255,fe[29]=Ft>>>8&255,fe[30]=Ft>>>16&255,fe[31]=Ft>>>24&255}function C(fe,Ie,Ae,ce){S(fe,Ie,Ae,ce)}function A(fe,Ie,Ae,ce){k(fe,Ie,Ae,ce)}var N=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function j(fe,Ie,Ae,ce,Oe,dt,vt){var Et=new Uint8Array(16),Ct=new Uint8Array(64),xn,yn;for(yn=0;yn<16;yn++)Et[yn]=0;for(yn=0;yn<8;yn++)Et[yn]=dt[yn];for(;Oe>=64;){for(C(Ct,Et,vt,N),yn=0;yn<64;yn++)fe[Ie+yn]=Ae[ce+yn]^Ct[yn];for(xn=1,yn=8;yn<16;yn++)xn=xn+(Et[yn]&255)|0,Et[yn]=xn&255,xn>>>=8;Oe-=64,Ie+=64,ce+=64}if(Oe>0)for(C(Ct,Et,vt,N),yn=0;yn<Oe;yn++)fe[Ie+yn]=Ae[ce+yn]^Ct[yn];return 0}function I(fe,Ie,Ae,ce,Oe){var dt=new Uint8Array(16),vt=new Uint8Array(64),Et,Ct;for(Ct=0;Ct<16;Ct++)dt[Ct]=0;for(Ct=0;Ct<8;Ct++)dt[Ct]=ce[Ct];for(;Ae>=64;){for(C(vt,dt,Oe,N),Ct=0;Ct<64;Ct++)fe[Ie+Ct]=vt[Ct];for(Et=1,Ct=8;Ct<16;Ct++)Et=Et+(dt[Ct]&255)|0,dt[Ct]=Et&255,Et>>>=8;Ae-=64,Ie+=64}if(Ae>0)for(C(vt,dt,Oe,N),Ct=0;Ct<Ae;Ct++)fe[Ie+Ct]=vt[Ct];return 0}function _(fe,Ie,Ae,ce,Oe){var dt=new Uint8Array(32);A(dt,ce,Oe,N);for(var vt=new Uint8Array(8),Et=0;Et<8;Et++)vt[Et]=ce[Et+16];return I(fe,Ie,Ae,vt,dt)}function L(fe,Ie,Ae,ce,Oe,dt,vt){var Et=new Uint8Array(32);A(Et,dt,vt,N);for(var Ct=new Uint8Array(8),xn=0;xn<8;xn++)Ct[xn]=dt[xn+16];return j(fe,Ie,Ae,ce,Oe,Ct,Et)}var M=function(fe){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var Ie,Ae,ce,Oe,dt,vt,Et,Ct;Ie=fe[0]&255|(fe[1]&255)<<8,this.r[0]=Ie&8191,Ae=fe[2]&255|(fe[3]&255)<<8,this.r[1]=(Ie>>>13|Ae<<3)&8191,ce=fe[4]&255|(fe[5]&255)<<8,this.r[2]=(Ae>>>10|ce<<6)&7939,Oe=fe[6]&255|(fe[7]&255)<<8,this.r[3]=(ce>>>7|Oe<<9)&8191,dt=fe[8]&255|(fe[9]&255)<<8,this.r[4]=(Oe>>>4|dt<<12)&255,this.r[5]=dt>>>1&8190,vt=fe[10]&255|(fe[11]&255)<<8,this.r[6]=(dt>>>14|vt<<2)&8191,Et=fe[12]&255|(fe[13]&255)<<8,this.r[7]=(vt>>>11|Et<<5)&8065,Ct=fe[14]&255|(fe[15]&255)<<8,this.r[8]=(Et>>>8|Ct<<8)&8191,this.r[9]=Ct>>>5&127,this.pad[0]=fe[16]&255|(fe[17]&255)<<8,this.pad[1]=fe[18]&255|(fe[19]&255)<<8,this.pad[2]=fe[20]&255|(fe[21]&255)<<8,this.pad[3]=fe[22]&255|(fe[23]&255)<<8,this.pad[4]=fe[24]&255|(fe[25]&255)<<8,this.pad[5]=fe[26]&255|(fe[27]&255)<<8,this.pad[6]=fe[28]&255|(fe[29]&255)<<8,this.pad[7]=fe[30]&255|(fe[31]&255)<<8};M.prototype.blocks=function(fe,Ie,Ae){for(var ce=this.fin?0:2048,Oe,dt,vt,Et,Ct,xn,yn,er,Fe,We,lt,yt,Bt,Qt,dn,pn,Zt,An,bn,Ln=this.h[0],Un=this.h[1],gn=this.h[2],Tt=this.h[3],Lt=this.h[4],nn=this.h[5],Ft=this.h[6],en=this.h[7],Wt=this.h[8],nt=this.h[9],Mn=this.r[0],Zn=this.r[1],sr=this.r[2],at=this.r[3],fr=this.r[4],hr=this.r[5],Xr=this.r[6],kr=this.r[7],Lr=this.r[8],pr=this.r[9];Ae>=16;)Oe=fe[Ie+0]&255|(fe[Ie+1]&255)<<8,Ln+=Oe&8191,dt=fe[Ie+2]&255|(fe[Ie+3]&255)<<8,Un+=(Oe>>>13|dt<<3)&8191,vt=fe[Ie+4]&255|(fe[Ie+5]&255)<<8,gn+=(dt>>>10|vt<<6)&8191,Et=fe[Ie+6]&255|(fe[Ie+7]&255)<<8,Tt+=(vt>>>7|Et<<9)&8191,Ct=fe[Ie+8]&255|(fe[Ie+9]&255)<<8,Lt+=(Et>>>4|Ct<<12)&8191,nn+=Ct>>>1&8191,xn=fe[Ie+10]&255|(fe[Ie+11]&255)<<8,Ft+=(Ct>>>14|xn<<2)&8191,yn=fe[Ie+12]&255|(fe[Ie+13]&255)<<8,en+=(xn>>>11|yn<<5)&8191,er=fe[Ie+14]&255|(fe[Ie+15]&255)<<8,Wt+=(yn>>>8|er<<8)&8191,nt+=er>>>5|ce,Fe=0,We=Fe,We+=Ln*Mn,We+=Un*(5*pr),We+=gn*(5*Lr),We+=Tt*(5*kr),We+=Lt*(5*Xr),Fe=We>>>13,We&=8191,We+=nn*(5*hr),We+=Ft*(5*fr),We+=en*(5*at),We+=Wt*(5*sr),We+=nt*(5*Zn),Fe+=We>>>13,We&=8191,lt=Fe,lt+=Ln*Zn,lt+=Un*Mn,lt+=gn*(5*pr),lt+=Tt*(5*Lr),lt+=Lt*(5*kr),Fe=lt>>>13,lt&=8191,lt+=nn*(5*Xr),lt+=Ft*(5*hr),lt+=en*(5*fr),lt+=Wt*(5*at),lt+=nt*(5*sr),Fe+=lt>>>13,lt&=8191,yt=Fe,yt+=Ln*sr,yt+=Un*Zn,yt+=gn*Mn,yt+=Tt*(5*pr),yt+=Lt*(5*Lr),Fe=yt>>>13,yt&=8191,yt+=nn*(5*kr),yt+=Ft*(5*Xr),yt+=en*(5*hr),yt+=Wt*(5*fr),yt+=nt*(5*at),Fe+=yt>>>13,yt&=8191,Bt=Fe,Bt+=Ln*at,Bt+=Un*sr,Bt+=gn*Zn,Bt+=Tt*Mn,Bt+=Lt*(5*pr),Fe=Bt>>>13,Bt&=8191,Bt+=nn*(5*Lr),Bt+=Ft*(5*kr),Bt+=en*(5*Xr),Bt+=Wt*(5*hr),Bt+=nt*(5*fr),Fe+=Bt>>>13,Bt&=8191,Qt=Fe,Qt+=Ln*fr,Qt+=Un*at,Qt+=gn*sr,Qt+=Tt*Zn,Qt+=Lt*Mn,Fe=Qt>>>13,Qt&=8191,Qt+=nn*(5*pr),Qt+=Ft*(5*Lr),Qt+=en*(5*kr),Qt+=Wt*(5*Xr),Qt+=nt*(5*hr),Fe+=Qt>>>13,Qt&=8191,dn=Fe,dn+=Ln*hr,dn+=Un*fr,dn+=gn*at,dn+=Tt*sr,dn+=Lt*Zn,Fe=dn>>>13,dn&=8191,dn+=nn*Mn,dn+=Ft*(5*pr),dn+=en*(5*Lr),dn+=Wt*(5*kr),dn+=nt*(5*Xr),Fe+=dn>>>13,dn&=8191,pn=Fe,pn+=Ln*Xr,pn+=Un*hr,pn+=gn*fr,pn+=Tt*at,pn+=Lt*sr,Fe=pn>>>13,pn&=8191,pn+=nn*Zn,pn+=Ft*Mn,pn+=en*(5*pr),pn+=Wt*(5*Lr),pn+=nt*(5*kr),Fe+=pn>>>13,pn&=8191,Zt=Fe,Zt+=Ln*kr,Zt+=Un*Xr,Zt+=gn*hr,Zt+=Tt*fr,Zt+=Lt*at,Fe=Zt>>>13,Zt&=8191,Zt+=nn*sr,Zt+=Ft*Zn,Zt+=en*Mn,Zt+=Wt*(5*pr),Zt+=nt*(5*Lr),Fe+=Zt>>>13,Zt&=8191,An=Fe,An+=Ln*Lr,An+=Un*kr,An+=gn*Xr,An+=Tt*hr,An+=Lt*fr,Fe=An>>>13,An&=8191,An+=nn*at,An+=Ft*sr,An+=en*Zn,An+=Wt*Mn,An+=nt*(5*pr),Fe+=An>>>13,An&=8191,bn=Fe,bn+=Ln*pr,bn+=Un*Lr,bn+=gn*kr,bn+=Tt*Xr,bn+=Lt*hr,Fe=bn>>>13,bn&=8191,bn+=nn*fr,bn+=Ft*at,bn+=en*sr,bn+=Wt*Zn,bn+=nt*Mn,Fe+=bn>>>13,bn&=8191,Fe=(Fe<<2)+Fe|0,Fe=Fe+We|0,We=Fe&8191,Fe=Fe>>>13,lt+=Fe,Ln=We,Un=lt,gn=yt,Tt=Bt,Lt=Qt,nn=dn,Ft=pn,en=Zt,Wt=An,nt=bn,Ie+=16,Ae-=16;this.h[0]=Ln,this.h[1]=Un,this.h[2]=gn,this.h[3]=Tt,this.h[4]=Lt,this.h[5]=nn,this.h[6]=Ft,this.h[7]=en,this.h[8]=Wt,this.h[9]=nt},M.prototype.finish=function(fe,Ie){var Ae=new Uint16Array(10),ce,Oe,dt,vt;if(this.leftover){for(vt=this.leftover,this.buffer[vt++]=1;vt<16;vt++)this.buffer[vt]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(ce=this.h[1]>>>13,this.h[1]&=8191,vt=2;vt<10;vt++)this.h[vt]+=ce,ce=this.h[vt]>>>13,this.h[vt]&=8191;for(this.h[0]+=ce*5,ce=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=ce,ce=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=ce,Ae[0]=this.h[0]+5,ce=Ae[0]>>>13,Ae[0]&=8191,vt=1;vt<10;vt++)Ae[vt]=this.h[vt]+ce,ce=Ae[vt]>>>13,Ae[vt]&=8191;for(Ae[9]-=8192,Oe=(ce^1)-1,vt=0;vt<10;vt++)Ae[vt]&=Oe;for(Oe=~Oe,vt=0;vt<10;vt++)this.h[vt]=this.h[vt]&Oe|Ae[vt];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,dt=this.h[0]+this.pad[0],this.h[0]=dt&65535,vt=1;vt<8;vt++)dt=(this.h[vt]+this.pad[vt]|0)+(dt>>>16)|0,this.h[vt]=dt&65535;fe[Ie+0]=this.h[0]>>>0&255,fe[Ie+1]=this.h[0]>>>8&255,fe[Ie+2]=this.h[1]>>>0&255,fe[Ie+3]=this.h[1]>>>8&255,fe[Ie+4]=this.h[2]>>>0&255,fe[Ie+5]=this.h[2]>>>8&255,fe[Ie+6]=this.h[3]>>>0&255,fe[Ie+7]=this.h[3]>>>8&255,fe[Ie+8]=this.h[4]>>>0&255,fe[Ie+9]=this.h[4]>>>8&255,fe[Ie+10]=this.h[5]>>>0&255,fe[Ie+11]=this.h[5]>>>8&255,fe[Ie+12]=this.h[6]>>>0&255,fe[Ie+13]=this.h[6]>>>8&255,fe[Ie+14]=this.h[7]>>>0&255,fe[Ie+15]=this.h[7]>>>8&255},M.prototype.update=function(fe,Ie,Ae){var ce,Oe;if(this.leftover){for(Oe=16-this.leftover,Oe>Ae&&(Oe=Ae),ce=0;ce<Oe;ce++)this.buffer[this.leftover+ce]=fe[Ie+ce];if(Ae-=Oe,Ie+=Oe,this.leftover+=Oe,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(Ae>=16&&(Oe=Ae-Ae%16,this.blocks(fe,Ie,Oe),Ie+=Oe,Ae-=Oe),Ae){for(ce=0;ce<Ae;ce++)this.buffer[this.leftover+ce]=fe[Ie+ce];this.leftover+=Ae}};function F(fe,Ie,Ae,ce,Oe,dt){var vt=new M(dt);return vt.update(Ae,ce,Oe),vt.finish(fe,Ie),0}function D(fe,Ie,Ae,ce,Oe,dt){var vt=new Uint8Array(16);return F(vt,0,Ae,ce,Oe,dt),b(fe,Ie,vt,0)}function R(fe,Ie,Ae,ce,Oe){var dt;if(Ae<32)return-1;for(L(fe,0,Ie,0,Ae,ce,Oe),F(fe,16,fe,32,Ae-32,fe),dt=0;dt<16;dt++)fe[dt]=0;return 0}function z(fe,Ie,Ae,ce,Oe){var dt,vt=new Uint8Array(32);if(Ae<32||(_(vt,0,32,ce,Oe),D(Ie,16,Ie,32,Ae-32,vt)!==0))return-1;for(L(fe,0,Ie,0,Ae,ce,Oe),dt=0;dt<32;dt++)fe[dt]=0;return 0}function B(fe,Ie){var Ae;for(Ae=0;Ae<16;Ae++)fe[Ae]=Ie[Ae]|0}function H(fe){var Ie,Ae,ce=1;for(Ie=0;Ie<16;Ie++)Ae=fe[Ie]+ce+65535,ce=Math.floor(Ae/65536),fe[Ie]=Ae-ce*65536;fe[0]+=ce-1+37*(ce-1)}function G(fe,Ie,Ae){for(var ce,Oe=~(Ae-1),dt=0;dt<16;dt++)ce=Oe&(fe[dt]^Ie[dt]),fe[dt]^=ce,Ie[dt]^=ce}function ne(fe,Ie){var Ae,ce,Oe,dt=n(),vt=n();for(Ae=0;Ae<16;Ae++)vt[Ae]=Ie[Ae];for(H(vt),H(vt),H(vt),ce=0;ce<2;ce++){for(dt[0]=vt[0]-65517,Ae=1;Ae<15;Ae++)dt[Ae]=vt[Ae]-65535-(dt[Ae-1]>>16&1),dt[Ae-1]&=65535;dt[15]=vt[15]-32767-(dt[14]>>16&1),Oe=dt[15]>>16&1,dt[14]&=65535,G(vt,dt,1-Oe)}for(Ae=0;Ae<16;Ae++)fe[2*Ae]=vt[Ae]&255,fe[2*Ae+1]=vt[Ae]>>8}function W(fe,Ie){var Ae=new Uint8Array(32),ce=new Uint8Array(32);return ne(Ae,fe),ne(ce,Ie),x(Ae,0,ce,0)}function T(fe){var Ie=new Uint8Array(32);return ne(Ie,fe),Ie[0]&1}function U(fe,Ie){var Ae;for(Ae=0;Ae<16;Ae++)fe[Ae]=Ie[2*Ae]+(Ie[2*Ae+1]<<8);fe[15]&=32767}function P(fe,Ie,Ae){for(var ce=0;ce<16;ce++)fe[ce]=Ie[ce]+Ae[ce]}function K(fe,Ie,Ae){for(var ce=0;ce<16;ce++)fe[ce]=Ie[ce]-Ae[ce]}function J(fe,Ie,Ae){var ce,Oe,dt=0,vt=0,Et=0,Ct=0,xn=0,yn=0,er=0,Fe=0,We=0,lt=0,yt=0,Bt=0,Qt=0,dn=0,pn=0,Zt=0,An=0,bn=0,Ln=0,Un=0,gn=0,Tt=0,Lt=0,nn=0,Ft=0,en=0,Wt=0,nt=0,Mn=0,Zn=0,sr=0,at=Ae[0],fr=Ae[1],hr=Ae[2],Xr=Ae[3],kr=Ae[4],Lr=Ae[5],pr=Ae[6],bs=Ae[7],ss=Ae[8],Cs=Ae[9],ms=Ae[10],Es=Ae[11],eo=Ae[12],Vs=Ae[13],ao=Ae[14],Er=Ae[15];ce=Ie[0],dt+=ce*at,vt+=ce*fr,Et+=ce*hr,Ct+=ce*Xr,xn+=ce*kr,yn+=ce*Lr,er+=ce*pr,Fe+=ce*bs,We+=ce*ss,lt+=ce*Cs,yt+=ce*ms,Bt+=ce*Es,Qt+=ce*eo,dn+=ce*Vs,pn+=ce*ao,Zt+=ce*Er,ce=Ie[1],vt+=ce*at,Et+=ce*fr,Ct+=ce*hr,xn+=ce*Xr,yn+=ce*kr,er+=ce*Lr,Fe+=ce*pr,We+=ce*bs,lt+=ce*ss,yt+=ce*Cs,Bt+=ce*ms,Qt+=ce*Es,dn+=ce*eo,pn+=ce*Vs,Zt+=ce*ao,An+=ce*Er,ce=Ie[2],Et+=ce*at,Ct+=ce*fr,xn+=ce*hr,yn+=ce*Xr,er+=ce*kr,Fe+=ce*Lr,We+=ce*pr,lt+=ce*bs,yt+=ce*ss,Bt+=ce*Cs,Qt+=ce*ms,dn+=ce*Es,pn+=ce*eo,Zt+=ce*Vs,An+=ce*ao,bn+=ce*Er,ce=Ie[3],Ct+=ce*at,xn+=ce*fr,yn+=ce*hr,er+=ce*Xr,Fe+=ce*kr,We+=ce*Lr,lt+=ce*pr,yt+=ce*bs,Bt+=ce*ss,Qt+=ce*Cs,dn+=ce*ms,pn+=ce*Es,Zt+=ce*eo,An+=ce*Vs,bn+=ce*ao,Ln+=ce*Er,ce=Ie[4],xn+=ce*at,yn+=ce*fr,er+=ce*hr,Fe+=ce*Xr,We+=ce*kr,lt+=ce*Lr,yt+=ce*pr,Bt+=ce*bs,Qt+=ce*ss,dn+=ce*Cs,pn+=ce*ms,Zt+=ce*Es,An+=ce*eo,bn+=ce*Vs,Ln+=ce*ao,Un+=ce*Er,ce=Ie[5],yn+=ce*at,er+=ce*fr,Fe+=ce*hr,We+=ce*Xr,lt+=ce*kr,yt+=ce*Lr,Bt+=ce*pr,Qt+=ce*bs,dn+=ce*ss,pn+=ce*Cs,Zt+=ce*ms,An+=ce*Es,bn+=ce*eo,Ln+=ce*Vs,Un+=ce*ao,gn+=ce*Er,ce=Ie[6],er+=ce*at,Fe+=ce*fr,We+=ce*hr,lt+=ce*Xr,yt+=ce*kr,Bt+=ce*Lr,Qt+=ce*pr,dn+=ce*bs,pn+=ce*ss,Zt+=ce*Cs,An+=ce*ms,bn+=ce*Es,Ln+=ce*eo,Un+=ce*Vs,gn+=ce*ao,Tt+=ce*Er,ce=Ie[7],Fe+=ce*at,We+=ce*fr,lt+=ce*hr,yt+=ce*Xr,Bt+=ce*kr,Qt+=ce*Lr,dn+=ce*pr,pn+=ce*bs,Zt+=ce*ss,An+=ce*Cs,bn+=ce*ms,Ln+=ce*Es,Un+=ce*eo,gn+=ce*Vs,Tt+=ce*ao,Lt+=ce*Er,ce=Ie[8],We+=ce*at,lt+=ce*fr,yt+=ce*hr,Bt+=ce*Xr,Qt+=ce*kr,dn+=ce*Lr,pn+=ce*pr,Zt+=ce*bs,An+=ce*ss,bn+=ce*Cs,Ln+=ce*ms,Un+=ce*Es,gn+=ce*eo,Tt+=ce*Vs,Lt+=ce*ao,nn+=ce*Er,ce=Ie[9],lt+=ce*at,yt+=ce*fr,Bt+=ce*hr,Qt+=ce*Xr,dn+=ce*kr,pn+=ce*Lr,Zt+=ce*pr,An+=ce*bs,bn+=ce*ss,Ln+=ce*Cs,Un+=ce*ms,gn+=ce*Es,Tt+=ce*eo,Lt+=ce*Vs,nn+=ce*ao,Ft+=ce*Er,ce=Ie[10],yt+=ce*at,Bt+=ce*fr,Qt+=ce*hr,dn+=ce*Xr,pn+=ce*kr,Zt+=ce*Lr,An+=ce*pr,bn+=ce*bs,Ln+=ce*ss,Un+=ce*Cs,gn+=ce*ms,Tt+=ce*Es,Lt+=ce*eo,nn+=ce*Vs,Ft+=ce*ao,en+=ce*Er,ce=Ie[11],Bt+=ce*at,Qt+=ce*fr,dn+=ce*hr,pn+=ce*Xr,Zt+=ce*kr,An+=ce*Lr,bn+=ce*pr,Ln+=ce*bs,Un+=ce*ss,gn+=ce*Cs,Tt+=ce*ms,Lt+=ce*Es,nn+=ce*eo,Ft+=ce*Vs,en+=ce*ao,Wt+=ce*Er,ce=Ie[12],Qt+=ce*at,dn+=ce*fr,pn+=ce*hr,Zt+=ce*Xr,An+=ce*kr,bn+=ce*Lr,Ln+=ce*pr,Un+=ce*bs,gn+=ce*ss,Tt+=ce*Cs,Lt+=ce*ms,nn+=ce*Es,Ft+=ce*eo,en+=ce*Vs,Wt+=ce*ao,nt+=ce*Er,ce=Ie[13],dn+=ce*at,pn+=ce*fr,Zt+=ce*hr,An+=ce*Xr,bn+=ce*kr,Ln+=ce*Lr,Un+=ce*pr,gn+=ce*bs,Tt+=ce*ss,Lt+=ce*Cs,nn+=ce*ms,Ft+=ce*Es,en+=ce*eo,Wt+=ce*Vs,nt+=ce*ao,Mn+=ce*Er,ce=Ie[14],pn+=ce*at,Zt+=ce*fr,An+=ce*hr,bn+=ce*Xr,Ln+=ce*kr,Un+=ce*Lr,gn+=ce*pr,Tt+=ce*bs,Lt+=ce*ss,nn+=ce*Cs,Ft+=ce*ms,en+=ce*Es,Wt+=ce*eo,nt+=ce*Vs,Mn+=ce*ao,Zn+=ce*Er,ce=Ie[15],Zt+=ce*at,An+=ce*fr,bn+=ce*hr,Ln+=ce*Xr,Un+=ce*kr,gn+=ce*Lr,Tt+=ce*pr,Lt+=ce*bs,nn+=ce*ss,Ft+=ce*Cs,en+=ce*ms,Wt+=ce*Es,nt+=ce*eo,Mn+=ce*Vs,Zn+=ce*ao,sr+=ce*Er,dt+=38*An,vt+=38*bn,Et+=38*Ln,Ct+=38*Un,xn+=38*gn,yn+=38*Tt,er+=38*Lt,Fe+=38*nn,We+=38*Ft,lt+=38*en,yt+=38*Wt,Bt+=38*nt,Qt+=38*Mn,dn+=38*Zn,pn+=38*sr,Oe=1,ce=dt+Oe+65535,Oe=Math.floor(ce/65536),dt=ce-Oe*65536,ce=vt+Oe+65535,Oe=Math.floor(ce/65536),vt=ce-Oe*65536,ce=Et+Oe+65535,Oe=Math.floor(ce/65536),Et=ce-Oe*65536,ce=Ct+Oe+65535,Oe=Math.floor(ce/65536),Ct=ce-Oe*65536,ce=xn+Oe+65535,Oe=Math.floor(ce/65536),xn=ce-Oe*65536,ce=yn+Oe+65535,Oe=Math.floor(ce/65536),yn=ce-Oe*65536,ce=er+Oe+65535,Oe=Math.floor(ce/65536),er=ce-Oe*65536,ce=Fe+Oe+65535,Oe=Math.floor(ce/65536),Fe=ce-Oe*65536,ce=We+Oe+65535,Oe=Math.floor(ce/65536),We=ce-Oe*65536,ce=lt+Oe+65535,Oe=Math.floor(ce/65536),lt=ce-Oe*65536,ce=yt+Oe+65535,Oe=Math.floor(ce/65536),yt=ce-Oe*65536,ce=Bt+Oe+65535,Oe=Math.floor(ce/65536),Bt=ce-Oe*65536,ce=Qt+Oe+65535,Oe=Math.floor(ce/65536),Qt=ce-Oe*65536,ce=dn+Oe+65535,Oe=Math.floor(ce/65536),dn=ce-Oe*65536,ce=pn+Oe+65535,Oe=Math.floor(ce/65536),pn=ce-Oe*65536,ce=Zt+Oe+65535,Oe=Math.floor(ce/65536),Zt=ce-Oe*65536,dt+=Oe-1+37*(Oe-1),Oe=1,ce=dt+Oe+65535,Oe=Math.floor(ce/65536),dt=ce-Oe*65536,ce=vt+Oe+65535,Oe=Math.floor(ce/65536),vt=ce-Oe*65536,ce=Et+Oe+65535,Oe=Math.floor(ce/65536),Et=ce-Oe*65536,ce=Ct+Oe+65535,Oe=Math.floor(ce/65536),Ct=ce-Oe*65536,ce=xn+Oe+65535,Oe=Math.floor(ce/65536),xn=ce-Oe*65536,ce=yn+Oe+65535,Oe=Math.floor(ce/65536),yn=ce-Oe*65536,ce=er+Oe+65535,Oe=Math.floor(ce/65536),er=ce-Oe*65536,ce=Fe+Oe+65535,Oe=Math.floor(ce/65536),Fe=ce-Oe*65536,ce=We+Oe+65535,Oe=Math.floor(ce/65536),We=ce-Oe*65536,ce=lt+Oe+65535,Oe=Math.floor(ce/65536),lt=ce-Oe*65536,ce=yt+Oe+65535,Oe=Math.floor(ce/65536),yt=ce-Oe*65536,ce=Bt+Oe+65535,Oe=Math.floor(ce/65536),Bt=ce-Oe*65536,ce=Qt+Oe+65535,Oe=Math.floor(ce/65536),Qt=ce-Oe*65536,ce=dn+Oe+65535,Oe=Math.floor(ce/65536),dn=ce-Oe*65536,ce=pn+Oe+65535,Oe=Math.floor(ce/65536),pn=ce-Oe*65536,ce=Zt+Oe+65535,Oe=Math.floor(ce/65536),Zt=ce-Oe*65536,dt+=Oe-1+37*(Oe-1),fe[0]=dt,fe[1]=vt,fe[2]=Et,fe[3]=Ct,fe[4]=xn,fe[5]=yn,fe[6]=er,fe[7]=Fe,fe[8]=We,fe[9]=lt,fe[10]=yt,fe[11]=Bt,fe[12]=Qt,fe[13]=dn,fe[14]=pn,fe[15]=Zt}function ee(fe,Ie){J(fe,Ie,Ie)}function X(fe,Ie){var Ae=n(),ce;for(ce=0;ce<16;ce++)Ae[ce]=Ie[ce];for(ce=253;ce>=0;ce--)ee(Ae,Ae),ce!==2&&ce!==4&&J(Ae,Ae,Ie);for(ce=0;ce<16;ce++)fe[ce]=Ae[ce]}function te(fe,Ie){var Ae=n(),ce;for(ce=0;ce<16;ce++)Ae[ce]=Ie[ce];for(ce=250;ce>=0;ce--)ee(Ae,Ae),ce!==1&&J(Ae,Ae,Ie);for(ce=0;ce<16;ce++)fe[ce]=Ae[ce]}function Q(fe,Ie,Ae){var ce=new Uint8Array(32),Oe=new Float64Array(80),dt,vt,Et=n(),Ct=n(),xn=n(),yn=n(),er=n(),Fe=n();for(vt=0;vt<31;vt++)ce[vt]=Ie[vt];for(ce[31]=Ie[31]&127|64,ce[0]&=248,U(Oe,Ae),vt=0;vt<16;vt++)Ct[vt]=Oe[vt],yn[vt]=Et[vt]=xn[vt]=0;for(Et[0]=yn[0]=1,vt=254;vt>=0;--vt)dt=ce[vt>>>3]>>>(vt&7)&1,G(Et,Ct,dt),G(xn,yn,dt),P(er,Et,xn),K(Et,Et,xn),P(xn,Ct,yn),K(Ct,Ct,yn),ee(yn,er),ee(Fe,Et),J(Et,xn,Et),J(xn,Ct,er),P(er,Et,xn),K(Et,Et,xn),ee(Ct,Et),K(xn,yn,Fe),J(Et,xn,c),P(Et,Et,yn),J(xn,xn,Et),J(Et,yn,Fe),J(yn,Ct,Oe),ee(Ct,er),G(Et,Ct,dt),G(xn,yn,dt);for(vt=0;vt<16;vt++)Oe[vt+16]=Et[vt],Oe[vt+32]=xn[vt],Oe[vt+48]=Ct[vt],Oe[vt+64]=yn[vt];var We=Oe.subarray(32),lt=Oe.subarray(16);return X(We,We),J(lt,lt,We),ne(fe,lt),0}function oe(fe,Ie){return Q(fe,Ie,o)}function de(fe,Ie){return r(Ie,32),oe(fe,Ie)}function ie(fe,Ie,Ae){var ce=new Uint8Array(32);return Q(ce,Ae,Ie),A(fe,s,ce,N)}var ue=R,xe=z;function ge(fe,Ie,Ae,ce,Oe,dt){var vt=new Uint8Array(32);return ie(vt,Oe,dt),ue(fe,Ie,Ae,ce,vt)}function Te(fe,Ie,Ae,ce,Oe,dt){var vt=new Uint8Array(32);return ie(vt,Oe,dt),xe(fe,Ie,Ae,ce,vt)}var De=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Me(fe,Ie,Ae,ce){for(var Oe=new Int32Array(16),dt=new Int32Array(16),vt,Et,Ct,xn,yn,er,Fe,We,lt,yt,Bt,Qt,dn,pn,Zt,An,bn,Ln,Un,gn,Tt,Lt,nn,Ft,en,Wt,nt=fe[0],Mn=fe[1],Zn=fe[2],sr=fe[3],at=fe[4],fr=fe[5],hr=fe[6],Xr=fe[7],kr=Ie[0],Lr=Ie[1],pr=Ie[2],bs=Ie[3],ss=Ie[4],Cs=Ie[5],ms=Ie[6],Es=Ie[7],eo=0;ce>=128;){for(Un=0;Un<16;Un++)gn=8*Un+eo,Oe[Un]=Ae[gn+0]<<24|Ae[gn+1]<<16|Ae[gn+2]<<8|Ae[gn+3],dt[Un]=Ae[gn+4]<<24|Ae[gn+5]<<16|Ae[gn+6]<<8|Ae[gn+7];for(Un=0;Un<80;Un++)if(vt=nt,Et=Mn,Ct=Zn,xn=sr,yn=at,er=fr,Fe=hr,We=Xr,lt=kr,yt=Lr,Bt=pr,Qt=bs,dn=ss,pn=Cs,Zt=ms,An=Es,Tt=Xr,Lt=Es,nn=Lt&65535,Ft=Lt>>>16,en=Tt&65535,Wt=Tt>>>16,Tt=(at>>>14|ss<<18)^(at>>>18|ss<<14)^(ss>>>9|at<<23),Lt=(ss>>>14|at<<18)^(ss>>>18|at<<14)^(at>>>9|ss<<23),nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Tt=at&fr^~at&hr,Lt=ss&Cs^~ss&ms,nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Tt=De[Un*2],Lt=De[Un*2+1],nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Tt=Oe[Un%16],Lt=dt[Un%16],nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Ft+=nn>>>16,en+=Ft>>>16,Wt+=en>>>16,bn=en&65535|Wt<<16,Ln=nn&65535|Ft<<16,Tt=bn,Lt=Ln,nn=Lt&65535,Ft=Lt>>>16,en=Tt&65535,Wt=Tt>>>16,Tt=(nt>>>28|kr<<4)^(kr>>>2|nt<<30)^(kr>>>7|nt<<25),Lt=(kr>>>28|nt<<4)^(nt>>>2|kr<<30)^(nt>>>7|kr<<25),nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Tt=nt&Mn^nt&Zn^Mn&Zn,Lt=kr&Lr^kr&pr^Lr&pr,nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Ft+=nn>>>16,en+=Ft>>>16,Wt+=en>>>16,We=en&65535|Wt<<16,An=nn&65535|Ft<<16,Tt=xn,Lt=Qt,nn=Lt&65535,Ft=Lt>>>16,en=Tt&65535,Wt=Tt>>>16,Tt=bn,Lt=Ln,nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Ft+=nn>>>16,en+=Ft>>>16,Wt+=en>>>16,xn=en&65535|Wt<<16,Qt=nn&65535|Ft<<16,Mn=vt,Zn=Et,sr=Ct,at=xn,fr=yn,hr=er,Xr=Fe,nt=We,Lr=lt,pr=yt,bs=Bt,ss=Qt,Cs=dn,ms=pn,Es=Zt,kr=An,Un%16===15)for(gn=0;gn<16;gn++)Tt=Oe[gn],Lt=dt[gn],nn=Lt&65535,Ft=Lt>>>16,en=Tt&65535,Wt=Tt>>>16,Tt=Oe[(gn+9)%16],Lt=dt[(gn+9)%16],nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,bn=Oe[(gn+1)%16],Ln=dt[(gn+1)%16],Tt=(bn>>>1|Ln<<31)^(bn>>>8|Ln<<24)^bn>>>7,Lt=(Ln>>>1|bn<<31)^(Ln>>>8|bn<<24)^(Ln>>>7|bn<<25),nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,bn=Oe[(gn+14)%16],Ln=dt[(gn+14)%16],Tt=(bn>>>19|Ln<<13)^(Ln>>>29|bn<<3)^bn>>>6,Lt=(Ln>>>19|bn<<13)^(bn>>>29|Ln<<3)^(Ln>>>6|bn<<26),nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Ft+=nn>>>16,en+=Ft>>>16,Wt+=en>>>16,Oe[gn]=en&65535|Wt<<16,dt[gn]=nn&65535|Ft<<16;Tt=nt,Lt=kr,nn=Lt&65535,Ft=Lt>>>16,en=Tt&65535,Wt=Tt>>>16,Tt=fe[0],Lt=Ie[0],nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Ft+=nn>>>16,en+=Ft>>>16,Wt+=en>>>16,fe[0]=nt=en&65535|Wt<<16,Ie[0]=kr=nn&65535|Ft<<16,Tt=Mn,Lt=Lr,nn=Lt&65535,Ft=Lt>>>16,en=Tt&65535,Wt=Tt>>>16,Tt=fe[1],Lt=Ie[1],nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Ft+=nn>>>16,en+=Ft>>>16,Wt+=en>>>16,fe[1]=Mn=en&65535|Wt<<16,Ie[1]=Lr=nn&65535|Ft<<16,Tt=Zn,Lt=pr,nn=Lt&65535,Ft=Lt>>>16,en=Tt&65535,Wt=Tt>>>16,Tt=fe[2],Lt=Ie[2],nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Ft+=nn>>>16,en+=Ft>>>16,Wt+=en>>>16,fe[2]=Zn=en&65535|Wt<<16,Ie[2]=pr=nn&65535|Ft<<16,Tt=sr,Lt=bs,nn=Lt&65535,Ft=Lt>>>16,en=Tt&65535,Wt=Tt>>>16,Tt=fe[3],Lt=Ie[3],nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Ft+=nn>>>16,en+=Ft>>>16,Wt+=en>>>16,fe[3]=sr=en&65535|Wt<<16,Ie[3]=bs=nn&65535|Ft<<16,Tt=at,Lt=ss,nn=Lt&65535,Ft=Lt>>>16,en=Tt&65535,Wt=Tt>>>16,Tt=fe[4],Lt=Ie[4],nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Ft+=nn>>>16,en+=Ft>>>16,Wt+=en>>>16,fe[4]=at=en&65535|Wt<<16,Ie[4]=ss=nn&65535|Ft<<16,Tt=fr,Lt=Cs,nn=Lt&65535,Ft=Lt>>>16,en=Tt&65535,Wt=Tt>>>16,Tt=fe[5],Lt=Ie[5],nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Ft+=nn>>>16,en+=Ft>>>16,Wt+=en>>>16,fe[5]=fr=en&65535|Wt<<16,Ie[5]=Cs=nn&65535|Ft<<16,Tt=hr,Lt=ms,nn=Lt&65535,Ft=Lt>>>16,en=Tt&65535,Wt=Tt>>>16,Tt=fe[6],Lt=Ie[6],nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Ft+=nn>>>16,en+=Ft>>>16,Wt+=en>>>16,fe[6]=hr=en&65535|Wt<<16,Ie[6]=ms=nn&65535|Ft<<16,Tt=Xr,Lt=Es,nn=Lt&65535,Ft=Lt>>>16,en=Tt&65535,Wt=Tt>>>16,Tt=fe[7],Lt=Ie[7],nn+=Lt&65535,Ft+=Lt>>>16,en+=Tt&65535,Wt+=Tt>>>16,Ft+=nn>>>16,en+=Ft>>>16,Wt+=en>>>16,fe[7]=Xr=en&65535|Wt<<16,Ie[7]=Es=nn&65535|Ft<<16,eo+=128,ce-=128}return ce}function ze(fe,Ie,Ae){var ce=new Int32Array(8),Oe=new Int32Array(8),dt=new Uint8Array(256),vt,Et=Ae;for(ce[0]=1779033703,ce[1]=3144134277,ce[2]=1013904242,ce[3]=2773480762,ce[4]=1359893119,ce[5]=2600822924,ce[6]=528734635,ce[7]=1541459225,Oe[0]=4089235720,Oe[1]=2227873595,Oe[2]=4271175723,Oe[3]=1595750129,Oe[4]=2917565137,Oe[5]=725511199,Oe[6]=4215389547,Oe[7]=327033209,Me(ce,Oe,Ie,Ae),Ae%=128,vt=0;vt<Ae;vt++)dt[vt]=Ie[Et-Ae+vt];for(dt[Ae]=128,Ae=256-128*(Ae<112?1:0),dt[Ae-9]=0,m(dt,Ae-8,Et/536870912|0,Et<<3),Me(ce,Oe,dt,Ae),vt=0;vt<8;vt++)m(fe,8*vt,ce[vt],Oe[vt]);return 0}function He(fe,Ie){var Ae=n(),ce=n(),Oe=n(),dt=n(),vt=n(),Et=n(),Ct=n(),xn=n(),yn=n();K(Ae,fe[1],fe[0]),K(yn,Ie[1],Ie[0]),J(Ae,Ae,yn),P(ce,fe[0],fe[1]),P(yn,Ie[0],Ie[1]),J(ce,ce,yn),J(Oe,fe[3],Ie[3]),J(Oe,Oe,d),J(dt,fe[2],Ie[2]),P(dt,dt,dt),K(vt,ce,Ae),K(Et,dt,Oe),P(Ct,dt,Oe),P(xn,ce,Ae),J(fe[0],vt,Et),J(fe[1],xn,Ct),J(fe[2],Ct,Et),J(fe[3],vt,xn)}function tt(fe,Ie,Ae){var ce;for(ce=0;ce<4;ce++)G(fe[ce],Ie[ce],Ae)}function $e(fe,Ie){var Ae=n(),ce=n(),Oe=n();X(Oe,Ie[2]),J(Ae,Ie[0],Oe),J(ce,Ie[1],Oe),ne(fe,ce),fe[31]^=T(Ae)<<7}function Ue(fe,Ie,Ae){var ce,Oe;for(B(fe[0],i),B(fe[1],l),B(fe[2],l),B(fe[3],i),Oe=255;Oe>=0;--Oe)ce=Ae[Oe/8|0]>>(Oe&7)&1,tt(fe,Ie,ce),He(Ie,fe),He(fe,fe),tt(fe,Ie,ce)}function Pe(fe,Ie){var Ae=[n(),n(),n(),n()];B(Ae[0],f),B(Ae[1],h),B(Ae[2],l),J(Ae[3],f,h),Ue(fe,Ae,Ie)}function we(fe,Ie,Ae){var ce=new Uint8Array(64),Oe=[n(),n(),n(),n()],dt;for(Ae||r(Ie,32),ze(ce,Ie,32),ce[0]&=248,ce[31]&=127,ce[31]|=64,Pe(Oe,ce),$e(fe,Oe),dt=0;dt<32;dt++)Ie[dt+32]=fe[dt];return 0}var ye=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function Re(fe,Ie){var Ae,ce,Oe,dt;for(ce=63;ce>=32;--ce){for(Ae=0,Oe=ce-32,dt=ce-12;Oe<dt;++Oe)Ie[Oe]+=Ae-16*Ie[ce]*ye[Oe-(ce-32)],Ae=Math.floor((Ie[Oe]+128)/256),Ie[Oe]-=Ae*256;Ie[Oe]+=Ae,Ie[ce]=0}for(Ae=0,Oe=0;Oe<32;Oe++)Ie[Oe]+=Ae-(Ie[31]>>4)*ye[Oe],Ae=Ie[Oe]>>8,Ie[Oe]&=255;for(Oe=0;Oe<32;Oe++)Ie[Oe]-=Ae*ye[Oe];for(ce=0;ce<32;ce++)Ie[ce+1]+=Ie[ce]>>8,fe[ce]=Ie[ce]&255}function _e(fe){var Ie=new Float64Array(64),Ae;for(Ae=0;Ae<64;Ae++)Ie[Ae]=fe[Ae];for(Ae=0;Ae<64;Ae++)fe[Ae]=0;Re(fe,Ie)}function Ve(fe,Ie,Ae,ce){var Oe=new Uint8Array(64),dt=new Uint8Array(64),vt=new Uint8Array(64),Et,Ct,xn=new Float64Array(64),yn=[n(),n(),n(),n()];ze(Oe,ce,32),Oe[0]&=248,Oe[31]&=127,Oe[31]|=64;var er=Ae+64;for(Et=0;Et<Ae;Et++)fe[64+Et]=Ie[Et];for(Et=0;Et<32;Et++)fe[32+Et]=Oe[32+Et];for(ze(vt,fe.subarray(32),Ae+32),_e(vt),Pe(yn,vt),$e(fe,yn),Et=32;Et<64;Et++)fe[Et]=ce[Et];for(ze(dt,fe,Ae+64),_e(dt),Et=0;Et<64;Et++)xn[Et]=0;for(Et=0;Et<32;Et++)xn[Et]=vt[Et];for(Et=0;Et<32;Et++)for(Ct=0;Ct<32;Ct++)xn[Et+Ct]+=dt[Et]*Oe[Ct];return Re(fe.subarray(32),xn),er}function he(fe,Ie){var Ae=n(),ce=n(),Oe=n(),dt=n(),vt=n(),Et=n(),Ct=n();return B(fe[2],l),U(fe[1],Ie),ee(Oe,fe[1]),J(dt,Oe,u),K(Oe,Oe,fe[2]),P(dt,fe[2],dt),ee(vt,dt),ee(Et,vt),J(Ct,Et,vt),J(Ae,Ct,Oe),J(Ae,Ae,dt),te(Ae,Ae),J(Ae,Ae,Oe),J(Ae,Ae,dt),J(Ae,Ae,dt),J(fe[0],Ae,dt),ee(ce,fe[0]),J(ce,ce,dt),W(ce,Oe)&&J(fe[0],fe[0],p),ee(ce,fe[0]),J(ce,ce,dt),W(ce,Oe)?-1:(T(fe[0])===Ie[31]>>7&&K(fe[0],i,fe[0]),J(fe[3],fe[0],fe[1]),0)}function Ye(fe,Ie,Ae,ce){var Oe,dt=new Uint8Array(32),vt=new Uint8Array(64),Et=[n(),n(),n(),n()],Ct=[n(),n(),n(),n()];if(Ae<64||he(Ct,ce))return-1;for(Oe=0;Oe<Ae;Oe++)fe[Oe]=Ie[Oe];for(Oe=0;Oe<32;Oe++)fe[Oe+32]=ce[Oe];if(ze(vt,fe,Ae),_e(vt),Ue(Et,Ct,vt),Pe(Ct,Ie.subarray(32)),He(Et,Ct),$e(dt,Et),Ae-=64,x(Ie,0,dt,0)){for(Oe=0;Oe<Ae;Oe++)fe[Oe]=0;return-1}for(Oe=0;Oe<Ae;Oe++)fe[Oe]=Ie[Oe+64];return Ae}var Le=32,Ne=24,Ge=32,ft=16,Ze=32,je=32,Je=32,st=32,gt=32,ut=Ne,pt=Ge,It=ft,kt=64,ln=32,qt=64,Jt=32,cn=64;t.lowlevel={crypto_core_hsalsa20:A,crypto_stream_xor:L,crypto_stream:_,crypto_stream_salsa20_xor:j,crypto_stream_salsa20:I,crypto_onetimeauth:F,crypto_onetimeauth_verify:D,crypto_verify_16:b,crypto_verify_32:x,crypto_secretbox:R,crypto_secretbox_open:z,crypto_scalarmult:Q,crypto_scalarmult_base:oe,crypto_box_beforenm:ie,crypto_box_afternm:ue,crypto_box:ge,crypto_box_open:Te,crypto_box_keypair:de,crypto_hash:ze,crypto_sign:Ve,crypto_sign_keypair:we,crypto_sign_open:Ye,crypto_secretbox_KEYBYTES:Le,crypto_secretbox_NONCEBYTES:Ne,crypto_secretbox_ZEROBYTES:Ge,crypto_secretbox_BOXZEROBYTES:ft,crypto_scalarmult_BYTES:Ze,crypto_scalarmult_SCALARBYTES:je,crypto_box_PUBLICKEYBYTES:Je,crypto_box_SECRETKEYBYTES:st,crypto_box_BEFORENMBYTES:gt,crypto_box_NONCEBYTES:ut,crypto_box_ZEROBYTES:pt,crypto_box_BOXZEROBYTES:It,crypto_sign_BYTES:kt,crypto_sign_PUBLICKEYBYTES:ln,crypto_sign_SECRETKEYBYTES:qt,crypto_sign_SEEDBYTES:Jt,crypto_hash_BYTES:cn,gf:n,D:u,L:ye,pack25519:ne,unpack25519:U,M:J,A:P,S:ee,Z:K,pow2523:te,add:He,set25519:B,modL:Re,scalarmult:Ue,scalarbase:Pe};function hn(fe,Ie){if(fe.length!==Le)throw new Error("bad key size");if(Ie.length!==Ne)throw new Error("bad nonce size")}function St(fe,Ie){if(fe.length!==Je)throw new Error("bad public key size");if(Ie.length!==st)throw new Error("bad secret key size")}function wt(){for(var fe=0;fe<arguments.length;fe++)if(!(arguments[fe]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function Dt(fe){for(var Ie=0;Ie<fe.length;Ie++)fe[Ie]=0}t.randomBytes=function(fe){var Ie=new Uint8Array(fe);return r(Ie,fe),Ie},t.secretbox=function(fe,Ie,Ae){wt(fe,Ie,Ae),hn(Ae,Ie);for(var ce=new Uint8Array(Ge+fe.length),Oe=new Uint8Array(ce.length),dt=0;dt<fe.length;dt++)ce[dt+Ge]=fe[dt];return R(Oe,ce,ce.length,Ie,Ae),Oe.subarray(ft)},t.secretbox.open=function(fe,Ie,Ae){wt(fe,Ie,Ae),hn(Ae,Ie);for(var ce=new Uint8Array(ft+fe.length),Oe=new Uint8Array(ce.length),dt=0;dt<fe.length;dt++)ce[dt+ft]=fe[dt];return ce.length<32||z(Oe,ce,ce.length,Ie,Ae)!==0?null:Oe.subarray(Ge)},t.secretbox.keyLength=Le,t.secretbox.nonceLength=Ne,t.secretbox.overheadLength=ft,t.scalarMult=function(fe,Ie){if(wt(fe,Ie),fe.length!==je)throw new Error("bad n size");if(Ie.length!==Ze)throw new Error("bad p size");var Ae=new Uint8Array(Ze);return Q(Ae,fe,Ie),Ae},t.scalarMult.base=function(fe){if(wt(fe),fe.length!==je)throw new Error("bad n size");var Ie=new Uint8Array(Ze);return oe(Ie,fe),Ie},t.scalarMult.scalarLength=je,t.scalarMult.groupElementLength=Ze,t.box=function(fe,Ie,Ae,ce){var Oe=t.box.before(Ae,ce);return t.secretbox(fe,Ie,Oe)},t.box.before=function(fe,Ie){wt(fe,Ie),St(fe,Ie);var Ae=new Uint8Array(gt);return ie(Ae,fe,Ie),Ae},t.box.after=t.secretbox,t.box.open=function(fe,Ie,Ae,ce){var Oe=t.box.before(Ae,ce);return t.secretbox.open(fe,Ie,Oe)},t.box.open.after=t.secretbox.open,t.box.keyPair=function(){var fe=new Uint8Array(Je),Ie=new Uint8Array(st);return de(fe,Ie),{publicKey:fe,secretKey:Ie}},t.box.keyPair.fromSecretKey=function(fe){if(wt(fe),fe.length!==st)throw new Error("bad secret key size");var Ie=new Uint8Array(Je);return oe(Ie,fe),{publicKey:Ie,secretKey:new Uint8Array(fe)}},t.box.publicKeyLength=Je,t.box.secretKeyLength=st,t.box.sharedKeyLength=gt,t.box.nonceLength=ut,t.box.overheadLength=t.secretbox.overheadLength,t.sign=function(fe,Ie){if(wt(fe,Ie),Ie.length!==qt)throw new Error("bad secret key size");var Ae=new Uint8Array(kt+fe.length);return Ve(Ae,fe,fe.length,Ie),Ae},t.sign.open=function(fe,Ie){if(wt(fe,Ie),Ie.length!==ln)throw new Error("bad public key size");var Ae=new Uint8Array(fe.length),ce=Ye(Ae,fe,fe.length,Ie);if(ce<0)return null;for(var Oe=new Uint8Array(ce),dt=0;dt<Oe.length;dt++)Oe[dt]=Ae[dt];return Oe},t.sign.detached=function(fe,Ie){for(var Ae=t.sign(fe,Ie),ce=new Uint8Array(kt),Oe=0;Oe<ce.length;Oe++)ce[Oe]=Ae[Oe];return ce},t.sign.detached.verify=function(fe,Ie,Ae){if(wt(fe,Ie,Ae),Ie.length!==kt)throw new Error("bad signature size");if(Ae.length!==ln)throw new Error("bad public key size");var ce=new Uint8Array(kt+fe.length),Oe=new Uint8Array(kt+fe.length),dt;for(dt=0;dt<kt;dt++)ce[dt]=Ie[dt];for(dt=0;dt<fe.length;dt++)ce[dt+kt]=fe[dt];return Ye(Oe,ce,ce.length,Ae)>=0},t.sign.keyPair=function(){var fe=new Uint8Array(ln),Ie=new Uint8Array(qt);return we(fe,Ie),{publicKey:fe,secretKey:Ie}},t.sign.keyPair.fromSecretKey=function(fe){if(wt(fe),fe.length!==qt)throw new Error("bad secret key size");for(var Ie=new Uint8Array(ln),Ae=0;Ae<Ie.length;Ae++)Ie[Ae]=fe[32+Ae];return{publicKey:Ie,secretKey:new Uint8Array(fe)}},t.sign.keyPair.fromSeed=function(fe){if(wt(fe),fe.length!==Jt)throw new Error("bad seed size");for(var Ie=new Uint8Array(ln),Ae=new Uint8Array(qt),ce=0;ce<32;ce++)Ae[ce]=fe[ce];return we(Ie,Ae,!0),{publicKey:Ie,secretKey:Ae}},t.sign.publicKeyLength=ln,t.sign.secretKeyLength=qt,t.sign.seedLength=Jt,t.sign.signatureLength=kt,t.hash=function(fe){wt(fe);var Ie=new Uint8Array(cn);return ze(Ie,fe,fe.length),Ie},t.hash.hashLength=cn,t.verify=function(fe,Ie){return wt(fe,Ie),fe.length===0||Ie.length===0||fe.length!==Ie.length?!1:v(fe,0,Ie,0,fe.length)===0},t.setPRNG=function(fe){r=fe},(function(){var fe=typeof self<"u"?self.crypto||self.msCrypto:null;if(fe&&fe.getRandomValues){var Ie=65536;t.setPRNG(function(Ae,ce){var Oe,dt=new Uint8Array(ce);for(Oe=0;Oe<ce;Oe+=Ie)fe.getRandomValues(dt.subarray(Oe,Oe+Math.min(ce-Oe,Ie)));for(Oe=0;Oe<ce;Oe++)Ae[Oe]=dt[Oe];Dt(dt)})}else typeof lln<"u"&&(fe=dln,fe&&fe.randomBytes&&t.setPRNG(function(Ae,ce){var Oe,dt=fe.randomBytes(ce);for(Oe=0;Oe<ce;Oe++)Ae[Oe]=dt[Oe];Dt(dt)}))})()})(e.exports?e.exports:self.nacl=self.nacl||{})})(zF)),zF.exports}fln();new TextEncoder;new TextDecoder;function hln(e){return{id:e.id,name:e.name,path:e.path,...e.alias?.trim()?{alias:e.alias.trim()}:{},...e.groupId?{groupId:e.groupId}:{},...e.kind==="ssh"?{kind:"ssh",...e.sshConnectionName?{sshConnectionName:e.sshConnectionName}:{},...e.sshHost?{sshHost:e.sshHost}:{}}:{}}}const pln=4096;BigInt(pln);function mln(e,t){const n=jN(e);if(n)return n.failed?{status:"queued",queueFailed:n.failed.error}:{status:"queued",queuePosition:t??1}}function gln(e,t,n){if(!(e.status==="running"||e.spawning))return ph(e.goal)?"upstream":t&&r1e(t,n)?"reminder":void 0}function vln(e,t=[]){return JSON.stringify({pinnedOrder:t,entries:e.map(n=>{const{updatedAt:r,...s}=n;return s})})}function xln(e){return JSON.stringify(e)}function bln(e,t,n=[]){const r=iq(e,t).map(o=>({id:o.id,name:o.name,models:o.models.map(i=>({id:i.id,...i.label?{label:i.label}:{}}))})),s=n.filter(o=>o.enabled&&r.some(i=>i.id===o.primary.providerId&&i.models.some(l=>l.id===o.primary.modelId)));return s.length>0&&r.unshift({id:Nv,name:"Auto",models:s.map(o=>({id:o.id,label:o.name}))}),r}function yln(e,t,n=[]){const r=bln(e,t,n),s=t.availability.status,o=s==="unloaded"||s==="loading",i=e.some(l=>l.enabled&&l.oauthAccountKey);return{entries:r,settled:!(o&&i&&r.length===0)}}function wln(e){return e!=="scratch"&&e!=="secretary"}function kln(e,t){return new Set(e.filter(n=>n.kind==="secretary"||!t&&n.kind==="scratch").map(n=>n.id))}const Sln=300;let gj=null,$ge=!1,OG=null;function Cln(){const e=be.getState(),t=it.getState(),r=zX(e.projects,jp(qj)).filter(N=>wln(N.kind)),s=new Set(jp(ng)),o=JA(c2(e.language),"Temporary chats"),i=new Map(e.projects.map(N=>[N.id,N.kind==="scratch"?o:Ta(N)])),l=new Map(e.projects.map(N=>[N.id,N.path])),c=new Map(e.projects.map(N=>[N.id,N.kind])),u=N=>{const j=(N.parentId?t.conversations[N.parentId]:void 0)??N;return c.get(j.projectId)==="scratch"?jT({kind:"scratch",canonicalPath:l.get(j.projectId)??"",conversationId:j.id})??void 0:j.worktree?.path??l.get(N.projectId)},d=e.skills.filter(N=>N.enabled!==!1).map(N=>({name:`/skill:${N.name}`,description:N.description})),f=K_(t.conversations),h=Sk.getState().byConversation,p=Date.now(),m=N=>{const j=mln(N,f.get(N.id)),I=gln(N,h[N.id],p),_=Vje(N.occupancy,N.contextWindow),L={id:N.id,title:N.parentId&&N.coworkerName||N.title,projectName:i.get(N.projectId)??"",projectId:N.projectId,...u(N)?{cwd:u(N)}:{},status:j?.status??(N.spawning?"running":N.status),updatedAt:py(N),...N.parentId?{parentId:N.parentId}:{},...N.pinned===!0?{pinned:!0}:{},...N.archived===!0?{archived:!0}:{},...N.muted===!0?{muted:!0}:{},...N.lastProviderId?{providerId:N.lastProviderId}:{},...N.lastModelId?{modelId:N.lastModelId}:{},...N.reasoningEnabled!==void 0?{reasoningEnabled:N.reasoningEnabled}:{},...N.thinkingLevel?{thinkingLevel:N.thinkingLevel}:{},...N.unread===!0?{unread:!0}:{},...yg(N.pendingAsks)>0?{pendingAskCount:yg(N.pendingAsks)}:{},...N.pendingApprovals&&N.pendingApprovals.length>0?{pendingApprovalCount:N.pendingApprovals.length}:{},...N.queuedMessages?.length?{queued:N.queuedMessages.map(M=>({id:M.id,text:M.text,...M.images?.length?{hasImages:!0}:{}}))}:{},...N.goal?{goal:{text:N.goal.text,status:N.goal.status,...N.goal.note?{note:N.goal.note}:{},autoTurns:N.goal.autoTurns}}:{},...I?{parked:I}:{},...d.length?{slashCommands:d}:{},..._?{context:_}:{},...N.usageTotals?{usageTotals:N.usageTotals}:{}};return j&&"queuePosition"in j&&Object.assign(L,{queuePosition:j.queuePosition}),j&&"queueFailed"in j&&Object.assign(L,{queueFailed:j.queueFailed}),L},v=t.order.map(N=>t.conversations[N]).filter(N=>!!N),b=new Set(t.order),x=Object.values(t.conversations).filter(N=>!!(N?.parentId&&b.has(N.parentId))),S=[...v,...x].map(m),k=kln(e.projects,e.scratchSessionsEnabled),C=S.filter(N=>!k.has(N.projectId)),A=yln(MM(),Ri.getState().snapshot,e.virtualModels);return{catalog:C,pinnedOrder:jp(MH),projects:r.map(N=>({...hln(N),...s.has(N.id)?{archived:!0}:{}})),projectGroups:e.projectGroups,providers:A.entries,providersSettled:A.settled,projectPaths:e.projects.map(N=>({id:N.id,path:N.path})),theme:e.theme,terminal:rN(e.terminalTheme),terminalFontFamily:e.terminalFontFamily,compactReadOnlyTools:e.compactReadOnlyTools,expandLiveEdits:e.expandLiveEdits,expandLiveReasoning:e.expandLiveReasoning,autoCollapseTurns:e.autoCollapseTurns,collapseCompletedActivity:e.collapseCompletedActivity,collapseLiveActivity:e.collapseLiveActivity,pinUnfinishedTodos:e.pinUnfinishedTodos}}function Eln(e){return xln({catalog:vln(e.catalog,e.pinnedOrder??[]),projects:e.projects,projectGroups:e.projectGroups,providers:e.providers,providersSettled:e.providersSettled,projectPaths:e.projectPaths,theme:e.theme,terminal:e.terminal,terminalFontFamily:e.terminalFontFamily,compactReadOnlyTools:e.compactReadOnlyTools,expandLiveEdits:e.expandLiveEdits,expandLiveReasoning:e.expandLiveReasoning,autoCollapseTurns:e.autoCollapseTurns,collapseCompletedActivity:e.collapseCompletedActivity,collapseLiveActivity:e.collapseLiveActivity,pinUnfinishedTodos:e.pinUnfinishedTodos})}function Tln(){return it.persist.hasHydrated()&&be.persist.hasHydrated()}function hp(){gj&&clearTimeout(gj),gj=setTimeout(()=>{if(gj=null,!Ql()||!Tln())return;const e=Cln(),t=Eln(e);t!==OG&&(OG=t,window.electronAPI.pair.pushCatalog(e))},Sln)}function Aln(){$ge||($ge=!0,hp(),it.persist.onFinishHydration(hp),be.persist.onFinishHydration(hp),it.subscribe((e,t)=>{(e.conversations!==t.conversations||e.order!==t.order)&&hp()}),Ri.subscribe((e,t)=>{e.snapshot!==t.snapshot&&hp()}),Sk.subscribe((e,t)=>{e.byConversation!==t.byConversation&&hp()}),Mf.subscribe((e,t)=>{e.snapshot!==t.snapshot&&hp()}),be.subscribe((e,t)=>{(e.projects!==t.projects||e.projectGroups!==t.projectGroups||e.providers!==t.providers||e.theme!==t.theme||e.terminalTheme!==t.terminalTheme||e.terminalFontFamily!==t.terminalFontFamily||e.compactReadOnlyTools!==t.compactReadOnlyTools||e.expandLiveEdits!==t.expandLiveEdits||e.expandLiveReasoning!==t.expandLiveReasoning||e.autoCollapseTurns!==t.autoCollapseTurns||e.collapseCompletedActivity!==t.collapseCompletedActivity||e.collapseLiveActivity!==t.collapseLiveActivity||e.pinUnfinishedTodos!==t.pinUnfinishedTodos||e.skills!==t.skills)&&hp()}),V2e(hp),ret(e=>{e&&(OG=null,hp())}),window.electronAPI.pair.onResumeSession(e=>{nre(e),Ql()&&(it.getState().markConversationRead(e),it.getState().resumeConversation(e))}),window.electronAPI.pair.onSessionCreated(e=>{nre(e.sessionId),Ql()&&it.getState().adoptPairSession(e)}),window.electronAPI.pair.onSessionConfig(e=>{if(!Ql())return;const t=it.getState();e.type==="set-model"?t.setModel(e.sessionId,e.providerId,e.modelId):e.type==="set-reasoning"?t.setReasoning(e.sessionId,e.enabled):t.setThinking(e.sessionId,e.level)}),window.electronAPI.pair.onQueueAction(e=>{if(!Ql())return;const t=it.getState();switch(e.type){case"enqueue":t.enqueueMessage(e.sessionId,e.text,e.images);break;case"queue-remove":t.removeQueuedMessage(e.sessionId,e.messageId);break;case"queue-update":t.updateQueuedMessage(e.sessionId,e.messageId,e.text);break;case"queue-send-now":t.sendQueuedNow(e.sessionId,e.messageId);break;case"queue-interrupt-send":t.interruptAndSendQueued(e.sessionId,e.messageId);break;case"goal-pause":t.pauseGoal(e.sessionId);break;case"goal-resume":t.resumeGoal(e.sessionId);break;case"goal-clear":t.clearGoal(e.sessionId);break;case"goal-set":t.setGoal(e.sessionId,e.text);break;case"compact":t.compact(e.sessionId,e.instructions,{quiet:!0});break;case"rewind":t.rewind(e.sessionId,e.userIndexFromEnd,e.restoreFiles);break;case"retry":t.retry(e.sessionId);break;case"task-stop":window.electronAPI.agent.stopTask(e.sessionId,e.taskId);break;case"subagent-stop":window.electronAPI.agent.stopSubagent(e.sessionId,e.agentId);break}}))}const Nln=3e4;async function Iln(e,t=Date.now()){const{order:n,conversations:r,activeId:s}=it.getState(),o=n.flatMap(d=>{const f=r[d];return!f||f.parentId?[]:(d===s||f.status==="running"||f.spawning===!0||f.workspaceMigrating===!0||(f.pendingAsks?.length??0)>0||(f.pendingApprovals?.length??0)>0)&&e.kind==="stale"?[]:[{id:d,projectId:f.projectId,archived:f.archived,archivedAt:f.archivedAt,pinned:f.pinned,lastActiveAt:py(f)}]}),i=k1e(o,e,t),l=it.getState();for(const d of i)l.removeConversation(d);const c=Date.now()+Nln,u=()=>i.filter(d=>it.getState().conversations[d]);for(;u().length>0&&Date.now()<c;)await new Promise(d=>setTimeout(d,200));return i.length-u().length}const jln=y.lazy(()=>Be(()=>import("./SidePanel-HvFay_uK.js"),__vite__mapDeps([127,126,128]),import.meta.url).then(e=>({default:e.SidePanel}))),Rln=e=>{const t=qLe(e);return t.length>0?t:f0e(e)},Kge="enso-sidebar-width",Xge="enso-sidebar-collapsed";function vj(){const e=it.getState(),n=(e.activeId?e.conversations[e.activeId]:null)?.projectId??be.getState().projects[0]?.id;n&&e.newConversation(n)}const xj="no-drag flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",Qge=200,Zge=420;function Mln(){const e=be(he=>he.onboarded),t=y.useSyncExternalStore(he=>be.persist?.onFinishHydration?.(he)??(()=>{}),()=>be.persist?.hasHydrated?.()??!0);GXe(),Ran(),Ian(),Dan(),Han(),jan();const[n,r]=y.useState(!1),[s,o]=y.useState(null);Wan();const[i,l]=y.useState(()=>{const he=Number(localStorage.getItem(Kge));return Number.isFinite(he)&&he>=Qge?Math.min(he,Zge):280}),[c,u]=y.useState(()=>localStorage.getItem(Xge)==="1"),d=Qp(),f=KXe(),[h,p]=y.useState(!1),m=y.useCallback(()=>p(!1),[]);y.useEffect(()=>{d||p(!1)},[d]),y.useEffect(()=>it.subscribe((he,Ye)=>{he.activeId!==Ye.activeId&&p(!1)}),[]);const{t:v}=Se(),b=be(he=>he.chatWide),x=it(he=>he.activeId),S=Bq(x),k=fs(he=>he.uiByConversation[x??""]?.width??he.lastWidth),C=fs(he=>he.fullscreen),A=fs(he=>he.toggleOpen),N=_t(he=>he.panelOpen),j=_t(he=>he.togglePanel);y.useEffect(()=>{C&&!S&&fs.getState().setFullscreen(!1)},[S,C]),y.useEffect(()=>ust(),[]),y.useEffect(()=>(document.documentElement.classList.add("enso-main-shell"),()=>document.documentElement.classList.remove("enso-main-shell")),[]),y.useEffect(()=>window.electronAPI.app.onCloseRequest(o),[]),y.useEffect(()=>window.electronAPI.app.onFlushPersist(he=>{RXe().finally(()=>{window.electronAPI.app.respondFlushPersist(he)})}),[]);const I=he=>{const Ye=s;Ye&&(o(null),window.electronAPI.app.respondCloseRequest(Ye,{action:he}))},_=y.useCallback(()=>{$Xe(window.innerWidth)?p(he=>!he):u(he=>!he)},[]),L=y.useCallback(()=>{window.electronAPI.env.platform==="darwin"&&window.setTimeout(()=>window.electronAPI.window.refreshDragRegions(),400)},[]),M=y.useCallback(()=>{_(),L()},[_,L]);y.useEffect(()=>$an(M),[M]),y.useEffect(()=>window.electronAPI.window.onToggleSidebar(M),[M]);const[F,D]=y.useState(!1),R=y.useRef(null);y.useEffect(()=>{localStorage.setItem(Kge,String(i))},[i]),y.useEffect(()=>{localStorage.setItem(Xge,c?"1":"0")},[c]),y.useEffect(()=>window.electronAPI.resources.onSessionsCleanRequest(({requestId:he,request:Ye})=>{Iln(Ye).catch(()=>0).then(Le=>window.electronAPI.resources.sessionsCleanDone(he,Le))}),[]),y.useEffect(()=>{Aln()},[]),y.useEffect(()=>{const he=window.electronAPI.remote;return he&&!he.nativePlatform?void 0:jd.getState().bind()},[]);const z=jd(he=>he.pairDialogOpen),B=ift(),H=be(he=>he.botModeEnabled),G=be(he=>he.headerSessionTabs),ne=mg(he=>he.mode);y.useEffect(()=>{const he=be.persist?.hasHydrated?.()??!0;ne==="bot"&&he&&!H&&mg.getState().setMode("code")},[ne,H]),y.useEffect(()=>{if(!H)return;const he=_t.getState().bind(),Ye=window.electronAPI.bots.onEvent(Le=>{Le.kind==="open"&&aft(Le)});return()=>{he(),Ye()}},[H]);const W=be(he=>he.secretaryEnabled),T=Pr(he=>he.welcomeOpen),U=Ey(he=>he.open);y.useEffect(()=>W?Pr.getState().bind():void 0,[W]),y.useEffect(()=>window.electronAPI.agent.onFocusSession(he=>{it.getState().conversations[he]&&oP()}),[]);const P=y.useCallback(he=>{l(Ye=>Math.min(Zge,Math.max(Qge,Ye+he)))},[]),K=be(he=>he.keybindings);y.useEffect(()=>{const he=Rh(K),Ye=Ne=>{const Ge=it.getState(),ft=Ge.activeId?Ge.conversations[Ge.activeId]:null;if(!ft)return;const Ze=[void 0,...ft.coworkerIds??[]];if(Ze.length<=1)return;const je=Ze.indexOf(ft.activeTabId);Ge.selectTab(ft.id,Ze[(je+Ne+Ze.length)%Ze.length])},Le=Ne=>{const Ge=Yv(Ne);if(!Ge)return;if(Ge===he["open-settings"]){Ne.preventDefault(),mLe();return}if(wc.getState().settings)return;if(Ge===he["toggle-app-mode"]){if(!be.getState().botModeEnabled)return;Ne.preventDefault();const je=mg.getState();je.setMode(je.mode==="bot"?"code":"bot");return}const ft=loe();if(ft&&Ge===he["toggle-side-panel"]){Ne.preventDefault(),_t.getState().togglePanel();return}if(ft&&Ge===he["search-workspace"]){Ne.preventDefault(),_t.getState().setSearchOpen(!0);return}if(!(ft&&["new-conversation","next-tab","prev-tab","toggle-side-panel","toggle-side-panel-fullscreen","new-side-tab","new-btw-tab","close-side-tab","find-in-chat","search-workspace","open-secretary"].some(Ze=>Ge===he[Ze]))){if(Ge===he["toggle-sidebar"]){if(Ne.preventDefault(),act(Ne,Ge))return;M()}else if(Ge===he["open-secretary"])be.getState().secretaryEnabled&&(Ne.preventDefault(),xR());else if(Ge===he["new-conversation"])Ne.preventDefault(),vj();else if(Ge===he["new-side-tab"])Ne.preventDefault(),ict(Ne.target)?ewt():vj();else if(Ge===he["new-btw-tab"])Ne.preventDefault(),rwt();else if(Ge===he["next-tab"])Ne.preventDefault(),Ye(1);else if(Ge===he["prev-tab"])Ne.preventDefault(),Ye(-1);else if(Ge===he["toggle-side-panel"])Ne.preventDefault(),fs.getState().toggleOpen();else if(Ge===he["toggle-side-panel-fullscreen"])Ne.preventDefault(),fs.getState().toggleFullscreen();else if(Ge===he["close-side-tab"])Ne.preventDefault(),lwt();else if(Ge===he["focus-composer"])Ne.preventDefault(),b2();else if(Ge===he["find-in-chat"])Ne.preventDefault(),vje();else if(Ge===he["search-workspace"])Ne.preventDefault(),r(!0);else if(!ft){const Ze=uMe(kje(),K,he).byBinding.get(Ge);if(!Ze)return;Ne.preventDefault();const je=it.getState(),Je=je.activeId?je.conversations[je.activeId]:null;MX(Ze,Je?Je.activeTabId??Je.id:null).then(st=>{st&&Ht({type:"error",title:Ze.title,description:st})})}}};return window.addEventListener("keydown",Le),()=>window.removeEventListener("keydown",Le)},[K,M]),y.useEffect(()=>{if(!S||!C)return;const he=Ye=>{Ye.key==="Escape"&&(loe()||wc.getState().settings||(Ye.preventDefault(),fs.getState().setFullscreen(!1)))};return window.addEventListener("keydown",he),()=>window.removeEventListener("keydown",he)},[S,C]);const J=DLe(OLe(GG,{activationConstraint:{distance:6}})),ee=bLe(),X=y.useRef(null),te=y.useRef(null),Q=y.useRef(null),[oe,de]=y.useState(null),[ie]=y.useState(()=>Kan({reducedMotion:Qan,onSettle:()=>de(null)})),[ue,xe]=y.useState(ee);y.useLayoutEffect(()=>{if(ue===ee)return;xe(ee);const he=X.current,Ye=Ne=>he?.querySelector(`[data-enso="${Ne}"]`)??null,Le=ie.run(ee?"settings":"workbench",{workbench:{sidebar:d?null:Q.current,main:B?te.current:R.current},settings:d?{sidebar:he,main:null}:{sidebar:Ye("settings-nav"),main:Ye("settings-content")}});de(Le.animating?{top:Le.top}:null)},[ee,ue,ie,d,B]),y.useEffect(()=>()=>ie.finish(),[ie]),y.useLayoutEffect(()=>{oe===null&&ie.release()},[oe,ie]);const{settingsMounted:ge,workbenchHidden:Te}=Xan({open:ee,shown:ue,animating:oe!==null});y.useLayoutEffect(()=>vLe(ge),[ge]),y.useEffect(()=>{ee&&p(!1)},[ee]),y.useEffect(()=>qan(window.electronAPI.window),[]);const De=y.useRef(d);De.current=d,y.useEffect(()=>{if(window.electronAPI.remote)return Yan(window,{depth:()=>xLe(wc.getState(),De.current),apply:he=>{if(he===0){lT();return}nu(),i0e(he===2)},subscribe:he=>wc.subscribe(he)})},[]);const Me=ge?a.jsx("div",{ref:X,"data-enso":"settings-view",inert:!ee,className:ve("absolute inset-0 flex",d&&"bg-background",oe?.top==="workbench"?"z-0":"z-[2]"),children:a.jsx(Nan,{navWidth:i,onNavResize:P,open:ee})}):null,ze=iP(),He=ze!=="mobile"&&!B,tt=y.useCallback(he=>{const Ye=R.current;if(!Ye)return;const Le=getComputedStyle(Ye),Ne=Ye.clientWidth-parseFloat(Le.paddingLeft)-parseFloat(Le.paddingRight);fs.getState().nudgeWidth(-he,Ne,He?ost:lN)},[He]),$e=H?a.jsx(hDt,{}):null,Ue=He&&(ze==="mac"||ze==="windows"||ze==="web"),Pe=Ue&&S&&!d&&!B,we=G&&!ee&&He&&!H&&!(Pe&&C)?a.jsx(kct,{onNew:vj}):null,ye=a.jsx("button",{type:"button",className:ve("flex items-center justify-center rounded-md transition-colors hover:bg-accent/50",d?"h-9 w-9":He?xj:"h-7 w-7",(B?N:S)?"text-foreground":"text-muted-foreground"),onClick:B?j:A,"aria-label":v("Toggle side panel"),title:v("Toggle side panel"),children:a.jsx(CUe,{className:"h-4 w-4"})}),Re=a.jsx("button",{type:"button",className:ve("flex h-7 w-7 items-center justify-center rounded-md transition-colors hover:bg-accent/50",b?"text-foreground":"text-muted-foreground",d&&"hidden"),onClick:()=>be.getState().setChatWide(!b),"aria-label":v(b?"Use reading width":"Use full chat width"),title:v(b?"Use reading width":"Use full chat width"),children:b?a.jsx($ze,{className:"h-4 w-4"}):a.jsx(PVe,{className:"h-4 w-4"})}),_e=a.jsxs(a.Fragment,{children:[Re,ye]}),Ve=He?{trailing:Re}:null;return a.jsxs("div",{"data-enso":"canvas",className:ve("relative isolate flex flex-col",d?"h-dvh":"h-screen"),children:[a.jsx(U2e,{}),a.jsx(eln,{}),a.jsx(fst,{}),a.jsx(fft,{}),a.jsx(Czt,{}),ze!=="mobile"?a.jsx(foe,{leading:a.jsxs("div",{className:"flex items-center gap-0.5",children:[a.jsx("div",{className:ve(ze!=="mac"&&"flex justify-center",ze!=="mac"&&(He?"w-[48px]":"w-12")),children:a.jsx("button",{type:"button","data-enso":"sidebar-toggle",className:ve(xj,ee&&"pointer-events-none opacity-40"),disabled:ee,onClick:M,title:v(c?"Expand sidebar":"Collapse sidebar"),children:c?a.jsx(Nxe,{className:"h-4 w-4"}):a.jsx(MW,{className:"h-4 w-4"})})}),He&&!ee&&a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button","data-enso":"search-button",className:xj,onClick:()=>r(!0),title:v("Search anything"),children:a.jsx(su,{className:"h-4 w-4"})}),a.jsx("button",{type:"button","data-enso":"new-session",className:xj,onClick:vj,title:v("New conversation"),children:a.jsx(hVe,{className:"h-4 w-4"})})]})]}),centered:(Pe&&C?null:$e)??void 0,middle:we,className:ve(ze!=="mac"&&"pl-0",He&&"border-b-0",He&&"bg-transparent",He&&ze==="mac"&&"pr-4"),actions:ee?void 0:He?Pe?void 0:ye:_e}):a.jsx(foe,{title:"EnsoCode",centered:$e??void 0,leading:d&&!B?a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("button",{type:"button","data-enso":"sidebar-toggle",className:"-ml-1.5 flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",onClick:()=>p(!0),"aria-label":v("Conversations"),title:v("Conversations"),children:a.jsx(nUe,{className:"h-5 w-5"})}),!$e&&a.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"EnsoCode"})]}):void 0,actions:_e}),!He&&a.jsx(doe,{}),!He&&a.jsx(jae,{}),!He&&a.jsx(Rae,{}),a.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[a.jsx("div",{ref:te,"data-enso":"workbench",inert:Te,className:ve("flex min-h-0 min-w-0 flex-1",Te&&"invisible",oe?.top==="workbench"&&"z-[1]"),children:B?a.jsx(lDt,{sidebarWidth:i,collapsed:c,onToggleCollapse:M,onResize:P}):a.jsxs(B8e,{sensors:J,collisionDetection:Rln,children:[d?a.jsxs(a.Fragment,{children:[a.jsx(hE,{children:h&&a.jsx(hf.div,{className:"fixed inset-0 bg-black/40",style:{zIndex:_r.MOBILE_DRAWER},initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:m},"drawer-backdrop")}),a.jsx(hf.div,{className:"fixed inset-y-0 left-0 flex bg-background shadow-xl",style:{zIndex:_r.MOBILE_DRAWER},initial:!1,animate:{x:h?0:"-105%"},transition:tk,inert:!h,children:a.jsx(Que,{width:Math.min(320,Math.round(f*.85)),collapsed:!1,onToggleCollapse:m,onOpenSearch:()=>r(!0),onNavigate:m})})]}):a.jsxs("div",{ref:Q,className:"flex min-h-0 shrink-0",children:[a.jsx(Que,{width:c?void 0:i,collapsed:c,onToggleCollapse:M,onOpenSearch:()=>r(!0)}),!c&&a.jsx(tA,{edge:He,onResize:P})]}),a.jsxs("div",{ref:R,className:ve("relative flex min-h-0 min-w-0 flex-1",Ue?"overflow-x-clip":"overflow-hidden",He&&"-mt-px -ml-px pt-px pr-[8px] pb-[8px] pl-px"),children:[a.jsxs("div",{"data-enso":"main",className:ve("relative flex min-h-0 min-w-0 flex-1 flex-col bg-background",He&&"overflow-hidden rounded-[10px] shadow-surface",Pe&&"rounded-r-none"),style:S&&C?{visibility:"hidden",transition:`visibility 0s ${V6.duration}s`}:void 0,children:[a.jsx(aln,{}),a.jsx(iot,{hidden:W&&T||U,children:a.jsx(cSe.Provider,{value:Ve,children:a.jsx(ABt,{})})}),He&&a.jsx(doe,{}),He&&a.jsx(jae,{}),He&&a.jsx(Rae,{}),W&&T&&a.jsx(YHt,{}),U&&a.jsx(HAt,{})]}),!C&&!d&&a.jsx(tA,{gap:He&&!Ue,inactive:!S,onResize:tt,onResizingChange:D}),a.jsx(y.Suspense,{fallback:null,children:a.jsx(jln,{width:k,resizing:F,card:He,titleRow:Ue})})]})]})}),!d&&Me]}),d&&Me,t&&!e&&!window.electronAPI.remote&&a.jsx(fHt,{}),a.jsx(qHt,{open:n,onOpenChange:r}),a.jsx(uUt,{}),a.jsx(TRe,{open:z,onOpenChange:jd.getState().setPairDialogOpen}),a.jsx(Jp,{open:s!==null,onOpenChange:he=>{!he&&s&&I("cancel")},children:a.jsxs(em,{className:"sm:max-w-sm",children:[a.jsxs(tm,{children:[a.jsx(rm,{className:"text-base",children:v("Confirm exit")}),a.jsx(sm,{children:v("Exit closes the app completely, so your phone can no longer connect. Minimize to tray keeps the app running in the background so your phone can still connect.")})]}),a.jsxs(nm,{variant:"bare",children:[a.jsx(dx,{render:a.jsx(Ke,{variant:"outline",size:"sm"}),children:v("Cancel")}),a.jsx(Ke,{size:"sm",onClick:()=>I("tray"),children:v("Minimize to tray")}),a.jsx(Ke,{variant:"destructive",size:"sm",onClick:()=>I("quit"),children:v("Exit")})]})]})}),a.jsx(Eft,{})]})}function _ln(e){return new Worker(""+new URL("worker-DsKBD11i.js",import.meta.url).href,{type:"module",name:e?.name})}const Pln={workerFactory:()=>new _ln,poolSize:2},Lln={theme:v4,langs:[...x6e],preferredHighlighter:"shiki-js"};function Oln({children:e}){return a.jsx(Y$t,{poolOptions:Pln,highlighterOptions:Lln,children:e})}function Dln(e=document,t=800){const n=new Map,r=s=>{const o=s.target,i=o&&o.nodeType===9?o.documentElement:o;!i||typeof i.setAttribute!="function"||(i.setAttribute("data-scrolling",""),clearTimeout(n.get(i)),n.set(i,setTimeout(()=>{n.delete(i),i.removeAttribute("data-scrolling")},t)))};return e.addEventListener("scroll",r,{capture:!0,passive:!0}),()=>{e.removeEventListener("scroll",r,{capture:!0});for(const s of n.values())clearTimeout(s);n.clear()}}function Jge({conversations:e,activeId:t}){const n=document.documentElement.dataset,r=WBt(e),s=nRe(t?e[t]:void 0,e);n.ensoActivity!==r&&(n.ensoActivity=r),n.ensoSession!==s&&(n.ensoSession=s)}function Bln(){Jge(it.getState()),it.subscribe((e,t)=>{(e.conversations!==t.conversations||e.activeId!==t.activeId)&&Jge(e)})}VXe();Bln();Dln();M2e();QPe.createRoot(document.getElementById("root")).render(a.jsx(y.StrictMode,{children:a.jsx(Oln,{children:a.jsx(Mln,{})})}));export{hKt as $,Ecn as A,wcn as B,v4 as C,PMe as D,k3e as E,cXt as F,RYt as G,Lcn as H,Tcn as I,wL as J,kL as K,G3 as L,M2 as M,Bcn as N,Fcn as O,zfe as P,Qo as Q,Gk as R,kcn as S,sG as T,Cc as U,lhe as V,a6e as W,r$t as X,Ffe as Y,V3 as Z,_cn as _,QEt as a,QKt as a$,che as a0,Icn as a1,m4 as a2,wKt as a3,ru as a4,g$t as a5,Rfe as a6,f6e as a7,ahe as a8,bKt as a9,CKt as aA,LMe as aB,OMe as aC,DMe as aD,jKt as aE,_Kt as aF,cG as aG,zKt as aH,LKt as aI,GV as aJ,FKt as aK,BKt as aL,TKt as aM,VKt as aN,PKt as aO,sg as aP,v$t as aQ,aG as aR,ehe as aS,$$t as aT,Mt as aU,Acn as aV,Ncn as aW,jcn as aX,Rcn as aY,Mcn as aZ,ycn as a_,O$t as aa,S$t as ab,y$t as ac,Dfe as ad,pKt as ae,_v as af,c6e as ag,K$t as ah,gKt as ai,Ofe as aj,a$t as ak,DKt as al,aKt as am,Z$t as an,the as ao,d5 as ap,xA as aq,UKt as ar,fYt as as,Ocn as at,Dcn as au,iG as av,Al as aw,NKt as ax,IKt as ay,Jfe as az,aXt as b,uct as b$,lG as b0,Zfe as b1,Ea as b2,MYt as b3,Hn as b4,kLe as b5,ve as b6,kW as b7,Bs as b8,Ho as b9,wrn as bA,grn as bB,be as bC,i3t as bD,kk as bE,$u as bF,r2 as bG,xcn as bH,io as bI,mT as bJ,FUe as bK,ua as bL,L3t as bM,xs as bN,Rf as bO,kNe as bP,IN as bQ,By as bR,UDt as bS,dK as bT,fK as bU,cA as bV,zy as bW,Pi as bX,n_ as bY,jN as bZ,K_ as b_,jW as ba,it as bb,D6 as bc,vrn as bd,Is as be,kT as bf,Jr as bg,Fy as bh,bq as bi,v_ as bj,kxe as bk,tUt as bl,Yce as bm,ojt as bn,P2 as bo,mx as bp,tK as bq,rK as br,eK as bs,sK as bt,L2 as bu,Pr as bv,Ig as bw,KHe as bx,krn as by,Srn as bz,tx as c,xo as c$,Hue as c0,XN as c1,YFt as c2,Md as c3,szt as c4,Hd as c5,Ri as c6,fu as c7,fcn as c8,xz as c9,Hcn as cA,nu as cB,Ysn as cC,Sxe as cD,Yu as cE,Q4 as cF,Kp as cG,w4t as cH,Xp as cI,wf as cJ,Lf as cK,Y4 as cL,KA as cM,bo as cN,z2 as cO,U2 as cP,H2 as cQ,Txe as cR,Bp as cS,Fp as cT,zp as cU,zr as cV,YT as cW,_i as cX,Qu as cY,Zu as cZ,Ju as c_,TT as ca,mM as cb,Vv as cc,bg as cd,hcn as ce,met as cf,pcn as cg,Cje as ch,vz as ci,Dg as cj,S3e as ck,nBt as cl,f7t as cm,r7t as cn,sc as co,HIe as cp,G7t as cq,mcn as cr,f2e as cs,Ht as ct,b2 as cu,Mh as cv,Ke as cw,Jn as cx,du as cy,ec as cz,jYt as d,jxe as d$,t1 as d0,fs as d1,Vln as d2,jT as d3,Pq as d4,K4 as d5,qa as d6,Exe as d7,fUe as d8,En as d9,Qln as dA,R$ as dB,kse as dC,IYt as dD,su as dE,tA as dF,hv as dG,K1t as dH,aze as dI,xT as dJ,sMe as dK,iXt as dL,Wp as dM,NYt as dN,I0e as dO,Bq as dP,qGe as dQ,T_ as dR,Nd as dS,IEe as dT,Tie as dU,$4 as dV,cq as dW,rN as dX,Hln as dY,tet as dZ,AW as d_,Vze as da,E6t as db,T6t as dc,Kln as dd,mie as de,FN as df,zP as dg,R2 as dh,$Se as di,$xt as dj,sbt as dk,sEe as dl,aWe as dm,i_ as dn,Yln as dp,qln as dq,$ln as dr,C4t as ds,Gcn as dt,Qp as du,gre as dv,Ucn as dw,Vcn as dx,Xln as dy,cg as dz,uXt as e,_W as e0,MM as e1,Uln as e2,rcn as e3,$j as e4,ocn as e5,swt as e6,icn as e7,dcn as e8,gcn as e9,CUe as eA,Tft as eB,scn as eC,bcn as eD,I4t as eE,vcn as eF,Be as eG,hf as ea,k6t as eb,Cwe as ec,hH as ed,WXe as ee,ost as ef,lN as eg,ucn as eh,zln as ei,Jln as ej,ecn as ek,ncn as el,Z1t as em,twt as en,Wln as eo,Zln as ep,tcn as eq,Q1t as er,Gln as es,dHe as et,r_ as eu,YP as ev,zv as ew,_g as ex,vf as ey,iP as ez,nrn as f,zMe as g,l6e as h,r1 as i,a as j,ccn as k,njt as l,Oy as m,_fe as n,tQ as o,Uk as p,Pcn as q,y as r,i6e as s,JKt as t,Se as u,Ccn as v,Scn as w,g4 as x,p4 as y,wA as z};