@intent-hq/web 2.384.1 → 2.385.0

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 (327) hide show
  1. package/package.json +1 -1
  2. package/web/app/immutable/chunks/{BiM95_Ol.js → 0RCk28l5.js} +1 -1
  3. package/web/app/immutable/chunks/{DQdjZnba.js → 0oyPeRI9.js} +1 -1
  4. package/web/app/immutable/chunks/{Tk34IzPH.js → 2zSj5_GV.js} +1 -1
  5. package/web/app/immutable/chunks/{gZ0nGq7V.js → 3VhO4Wn2.js} +1 -1
  6. package/web/app/immutable/chunks/{6n7e2aNB.js → 3qVSmuIV.js} +1 -1
  7. package/web/app/immutable/chunks/{D59epBkG.js → 40W1U6K5.js} +1 -1
  8. package/web/app/immutable/chunks/{BZidc-yX.js → 418Agcsp.js} +1 -1
  9. package/web/app/immutable/chunks/{BTtAt-Pu.js → 4PAYwk2I.js} +1 -1
  10. package/web/app/immutable/chunks/{DXdFemRu.js → 4g_iHoQm.js} +1 -1
  11. package/web/app/immutable/chunks/{B7eTEd5f.js → 4poQ2xKW.js} +1 -1
  12. package/web/app/immutable/chunks/{CXul4WJt.js → 5-0LQoqd.js} +1 -1
  13. package/web/app/immutable/chunks/{BTc_j7Dt.js → 7KxcPj98.js} +1 -1
  14. package/web/app/immutable/chunks/{CpMQqUEz.js → 7OH6WUSt.js} +1 -1
  15. package/web/app/immutable/chunks/{BwLxx4IG.js → 7y3Z0Q49.js} +3 -3
  16. package/web/app/immutable/chunks/{B4mHWFlW.js → 8jMQM9h0.js} +1 -1
  17. package/web/app/immutable/chunks/{xmnalplU.js → 94vL4WlW.js} +1 -1
  18. package/web/app/immutable/chunks/{BVlMQ1xQ.js → 9GO97JAL.js} +1 -1
  19. package/web/app/immutable/chunks/{CpimfPxg.js → A0KsbysW.js} +1 -1
  20. package/web/app/immutable/chunks/{wsPxCWV4.js → B-E_4dSm.js} +2 -2
  21. package/web/app/immutable/chunks/{DaXosNFA.js → B0qb2Ymj.js} +1 -1
  22. package/web/app/immutable/chunks/{BFBQinse.js → B22zVGFP.js} +1 -1
  23. package/web/app/immutable/chunks/{k863GLf6.js → B2CniqS1.js} +1 -1
  24. package/web/app/immutable/chunks/{CQ9fljqW.js → B2XeuV1l.js} +1 -1
  25. package/web/app/immutable/chunks/{CmImGhNY.js → B433f4mk.js} +1 -1
  26. package/web/app/immutable/chunks/{BJ1Bk8co.js → B5pL-E-o.js} +1 -1
  27. package/web/app/immutable/chunks/{55FYKQCf.js → B5qiyEpH.js} +1 -1
  28. package/web/app/immutable/chunks/{BNN0vAFF.js → B5tvpTFB.js} +1 -1
  29. package/web/app/immutable/chunks/{CE0jr9sE.js → B6FGs8l2.js} +1 -1
  30. package/web/app/immutable/chunks/{CdhlQsS3.js → B6QnBRPC.js} +1 -1
  31. package/web/app/immutable/chunks/{Di3TE7pQ.js → B6d1Nolc.js} +1 -1
  32. package/web/app/immutable/chunks/{B4PfEXaO.js → B6eTPmJH.js} +1 -1
  33. package/web/app/immutable/chunks/{B7JHU89G.js → B8HnjSSF.js} +1 -1
  34. package/web/app/immutable/chunks/{xeMXLCBg.js → B8QvP_8b.js} +1 -1
  35. package/web/app/immutable/chunks/{eZPmVSmq.js → B9ka1bX8.js} +2 -2
  36. package/web/app/immutable/chunks/{CDVdEpeY.js → BBYtaKSX.js} +1 -1
  37. package/web/app/immutable/chunks/{I8XhKsSY.js → BByf3ILj.js} +1 -1
  38. package/web/app/immutable/chunks/{BMPSP6zy.js → BCLFORRd.js} +1 -1
  39. package/web/app/immutable/chunks/{leDczq9h.js → BD9db4FR.js} +1 -1
  40. package/web/app/immutable/chunks/{DLvrhtSt.js → BDsciJGp.js} +1 -1
  41. package/web/app/immutable/chunks/{X-wIiWCo.js → BECK4OaG.js} +1 -1
  42. package/web/app/immutable/chunks/{HP51nVq8.js → BGspyNwk.js} +1 -1
  43. package/web/app/immutable/chunks/{Cr6ukNck.js → BHEogMS0.js} +2 -2
  44. package/web/app/immutable/chunks/{BAdVoGAI.js → BHqp2vwo.js} +1 -1
  45. package/web/app/immutable/chunks/{CIU_APaR.js → BIGqOuh0.js} +1 -1
  46. package/web/app/immutable/chunks/{DilOhRAO.js → BJO0de_7.js} +1 -1
  47. package/web/app/immutable/chunks/{BDPP0w0q.js → BJgwBOBz.js} +1 -1
  48. package/web/app/immutable/chunks/{DxDZbRkP.js → BLKFshyr.js} +1 -1
  49. package/web/app/immutable/chunks/{XzLIP4y8.js → BNX4ri6c.js} +3 -3
  50. package/web/app/immutable/chunks/{D2Rapl2X.js → BNa9zzEx.js} +1 -1
  51. package/web/app/immutable/chunks/{C1GvdDuD.js → BO4b6Ny-.js} +2 -2
  52. package/web/app/immutable/chunks/{CVoQx6Vw.js → BO8Bp7Ht.js} +1 -1
  53. package/web/app/immutable/chunks/{DUhda8VE.js → BORk03Sd.js} +1 -1
  54. package/web/app/immutable/chunks/{B4T9RExk.js → BP1fPIN6.js} +1 -1
  55. package/web/app/immutable/chunks/{rNjiZ_3W.js → BPuz5cN_.js} +2 -2
  56. package/web/app/immutable/chunks/{Bygp72Wl.js → BSUnflvl.js} +1 -1
  57. package/web/app/immutable/chunks/{CQhRmQZt.js → BSWVBeG0.js} +1 -1
  58. package/web/app/immutable/chunks/{Df4fyHSB.js → BSgFpkqa.js} +1 -1
  59. package/web/app/immutable/chunks/{BOpszErG.js → BSntxgH1.js} +1 -1
  60. package/web/app/immutable/chunks/{4Pag07jF.js → BT8hDSo1.js} +1 -1
  61. package/web/app/immutable/chunks/{BX_Jr21Z.js → BU1Gcrkq.js} +1 -1
  62. package/web/app/immutable/chunks/{Cb6nJOfB.js → BV1ayWTC.js} +1 -1
  63. package/web/app/immutable/chunks/{DA6dl8M4.js → BV47Ledo.js} +1 -1
  64. package/web/app/immutable/chunks/{CGmFuvv3.js → BVctKbNy.js} +1 -1
  65. package/web/app/immutable/chunks/{CIzFSDuO.js → BVkAOJlr.js} +1 -1
  66. package/web/app/immutable/chunks/{Bosi029J.js → BVl79jmM.js} +1 -1
  67. package/web/app/immutable/chunks/{iVHs_bWz.js → BVuLEX_p.js} +1 -1
  68. package/web/app/immutable/chunks/{uAXEbxa8.js → BW1iql_y.js} +1 -1
  69. package/web/app/immutable/chunks/{DDnDtSlm.js → BXJzIaQM.js} +1 -1
  70. package/web/app/immutable/chunks/{C41iTvQS.js → BYLCAn5f.js} +1 -1
  71. package/web/app/immutable/chunks/{Mh0PqgbP.js → B_4WsP9b.js} +1 -1
  72. package/web/app/immutable/chunks/{D5-RCLzi.js → B_75gRww.js} +1 -1
  73. package/web/app/immutable/chunks/{CQZUFyS7.js → BbLh3POL.js} +1 -1
  74. package/web/app/immutable/chunks/{D5q2XDzo.js → BbuLzldI.js} +1 -1
  75. package/web/app/immutable/chunks/{72S4_8Fo.js → Bc1vJq_Z.js} +1 -1
  76. package/web/app/immutable/chunks/{KmGBeLVg.js → BcEkxi5l.js} +1 -1
  77. package/web/app/immutable/chunks/{BTtqZJEI.js → BcKrkXju.js} +1 -1
  78. package/web/app/immutable/chunks/{DTdAlnvg.js → Bd1Doib5.js} +5 -5
  79. package/web/app/immutable/chunks/{6kZoubzS.js → BdEtT3Ti.js} +1 -1
  80. package/web/app/immutable/chunks/{MEhQGTPs.js → BeJRU38G.js} +3 -3
  81. package/web/app/immutable/chunks/{ClyQ7g2p.js → BeU-lAdJ.js} +1 -1
  82. package/web/app/immutable/chunks/{BXE_7Biv.js → Bf_nrOhg.js} +1 -1
  83. package/web/app/immutable/chunks/{CwHPdS9l.js → BgDnzAo4.js} +1 -1
  84. package/web/app/immutable/chunks/{CfE9G-Vk.js → BhD_8q1J.js} +1 -1
  85. package/web/app/immutable/chunks/{Cm60YBNN.js → Bhb3isek.js} +4 -4
  86. package/web/app/immutable/chunks/{CjsT6P1W.js → Bi-y50ry.js} +1 -1
  87. package/web/app/immutable/chunks/{0tWsVa0y.js → Bi_Yd73A.js} +1 -1
  88. package/web/app/immutable/chunks/{CEjK2ich.js → BjlMkd10.js} +1 -1
  89. package/web/app/immutable/chunks/{BxiKdHSR.js → BlDwsvYd.js} +1 -1
  90. package/web/app/immutable/chunks/{RWWlGLMu.js → BlIRL_82.js} +1 -1
  91. package/web/app/immutable/chunks/{BbV6R15i.js → BmF8Qq3w.js} +1 -1
  92. package/web/app/immutable/chunks/{Bmn4uqsd.js → BoIbJp9v.js} +1 -1
  93. package/web/app/immutable/chunks/{D5reO2Y0.js → BpYEdDT4.js} +1 -1
  94. package/web/app/immutable/chunks/BsdyWfPQ.js +2 -0
  95. package/web/app/immutable/chunks/{CMbvNZma.js → BtBQ5qfh.js} +1 -1
  96. package/web/app/immutable/chunks/{CZDat5YW.js → Bt_vaAcw.js} +1 -1
  97. package/web/app/immutable/chunks/{CcmN1reb.js → Bu-RLSv9.js} +1 -1
  98. package/web/app/immutable/chunks/{CXrVII1G.js → BuFDqZnJ.js} +1 -1
  99. package/web/app/immutable/chunks/{DSTc-o8X.js → BuPmvT2w.js} +1 -1
  100. package/web/app/immutable/chunks/{-31r5MID.js → BupDQr_B.js} +2 -2
  101. package/web/app/immutable/chunks/{CJoPlWyA.js → Bv_xG3nA.js} +1 -1
  102. package/web/app/immutable/chunks/{eTRx_lEs.js → BvbZcfOT.js} +1 -1
  103. package/web/app/immutable/chunks/{Djz9uuuA.js → BvbeTrka.js} +1 -1
  104. package/web/app/immutable/chunks/{JD0Hsmjx.js → BvzO6hxM.js} +1 -1
  105. package/web/app/immutable/chunks/{BACpI8G6.js → BwC--T1G.js} +1 -1
  106. package/web/app/immutable/chunks/{4jB5IsVV.js → BwPwF85e.js} +1 -1
  107. package/web/app/immutable/chunks/{BMW8QkkW.js → Bwx5QwNp.js} +1 -1
  108. package/web/app/immutable/chunks/{B1DQbauY.js → BxU4EAMe.js} +1 -1
  109. package/web/app/immutable/chunks/{E92QiCEr.js → ByZMA8RF.js} +1 -1
  110. package/web/app/immutable/chunks/{IxfPVMNO.js → C-G2u0Oe.js} +1 -1
  111. package/web/app/immutable/chunks/{0v4yIgtg.js → C-PQQ8rb.js} +1 -1
  112. package/web/app/immutable/chunks/{D400ElMz.js → C-zB-6G6.js} +1 -1
  113. package/web/app/immutable/chunks/{YtoDeXhM.js → C0Zo7HuP.js} +1 -1
  114. package/web/app/immutable/chunks/{ump_SWLl.js → C1AUaRa8.js} +1 -1
  115. package/web/app/immutable/chunks/{COB2k0Aa.js → C2F2Vd1P.js} +1 -1
  116. package/web/app/immutable/chunks/{Rz920YbF.js → C2Hs8n0u.js} +1 -1
  117. package/web/app/immutable/chunks/{Dkgk_rvZ.js → C3-81PRC.js} +4 -4
  118. package/web/app/immutable/chunks/{8eQog6L5.js → C3gIkQxX.js} +1 -1
  119. package/web/app/immutable/chunks/{BltFs6ST.js → C412Y6ti.js} +2 -2
  120. package/web/app/immutable/chunks/{BgPJ_lbZ.js → C4Py2-C-.js} +1 -1
  121. package/web/app/immutable/chunks/{CCej7AMq.js → C4UnZ5aI.js} +1 -1
  122. package/web/app/immutable/chunks/{C6g7LzDB.js → C50zlWbZ.js} +1 -1
  123. package/web/app/immutable/chunks/{CmbheRhJ.js → C63WwVct.js} +1 -1
  124. package/web/app/immutable/chunks/{CJW4jhjq.js → C8LrJXqa.js} +1 -1
  125. package/web/app/immutable/chunks/{Bb9tq6rt.js → C9ew0Hx2.js} +1 -1
  126. package/web/app/immutable/chunks/{DpChblex.js → C9p4fddz.js} +1 -1
  127. package/web/app/immutable/chunks/{3BCyU2N-.js → CA8JHp72.js} +1 -1
  128. package/web/app/immutable/chunks/{C0fFeGdB.js → CAfPEsZt.js} +1 -1
  129. package/web/app/immutable/chunks/CAtVH-rJ.js +158 -0
  130. package/web/app/immutable/chunks/CCIZBeez.js +1 -0
  131. package/web/app/immutable/chunks/{BhVPbMnV.js → CD-M_2xD.js} +1 -1
  132. package/web/app/immutable/chunks/{cKonll34.js → CDAnHxmJ.js} +1 -1
  133. package/web/app/immutable/chunks/{DJEkkAqR.js → CDBHtmaA.js} +1 -1
  134. package/web/app/immutable/chunks/{CzG_0Mji.js → CE9_m5Rd.js} +1 -1
  135. package/web/app/immutable/chunks/{AYsHMWH3.js → CEEUgGO1.js} +1 -1
  136. package/web/app/immutable/chunks/{DvjmmZhh.js → CEfkJpk7.js} +1 -1
  137. package/web/app/immutable/chunks/{DETS1-K4.js → CGYPBD6G.js} +1 -1
  138. package/web/app/immutable/chunks/{C0CrTfQC.js → CHto7_WH.js} +1 -1
  139. package/web/app/immutable/chunks/{KMO8sO00.js → CI0C7_h-.js} +1 -1
  140. package/web/app/immutable/chunks/{DnQOpOtg.js → CIWky03S.js} +3 -3
  141. package/web/app/immutable/chunks/{CHMwcoWM.js → CIaruUrd.js} +1 -1
  142. package/web/app/immutable/chunks/{BzqJYEOZ.js → CJB-ebPL.js} +1 -1
  143. package/web/app/immutable/chunks/{DtO9zNSi.js → CJNNcGWg.js} +1 -1
  144. package/web/app/immutable/chunks/{rjhGooNa.js → CLlFdy2p.js} +1 -1
  145. package/web/app/immutable/chunks/{BWM_jjc6.js → CLo9TzNK.js} +1 -1
  146. package/web/app/immutable/chunks/{CegXgKbh.js → CNSshwg_.js} +1 -1
  147. package/web/app/immutable/chunks/{BvGyYsBI.js → COflq_3N.js} +3 -3
  148. package/web/app/immutable/chunks/{O63l2zGE.js → COgn_CzG.js} +1 -1
  149. package/web/app/immutable/chunks/{BWtgRgi0.js → CPI5xBWX.js} +1 -1
  150. package/web/app/immutable/chunks/{BswbJQ0U.js → CPaH4fRt.js} +1 -1
  151. package/web/app/immutable/chunks/{ByYwSpDO.js → CQMFoUkp.js} +1 -1
  152. package/web/app/immutable/chunks/{BmALJKBY.js → CR-JVxLD.js} +1 -1
  153. package/web/app/immutable/chunks/CT9qg5pc.js +1 -0
  154. package/web/app/immutable/chunks/{DpmMYKqt.js → CTW83wJs.js} +1 -1
  155. package/web/app/immutable/chunks/{DMrypNw-.js → CV2tdNDf.js} +1 -1
  156. package/web/app/immutable/chunks/{CFjwzuFW.js → CVU_1O7c.js} +1 -1
  157. package/web/app/immutable/chunks/{C2jf24pz.js → CVs9CHtI.js} +1 -1
  158. package/web/app/immutable/chunks/{C9fPgzDG.js → CWOQ_pUA.js} +1 -1
  159. package/web/app/immutable/chunks/{Di0D97hw.js → CWTUGfLW.js} +1 -1
  160. package/web/app/immutable/chunks/{CWwAStwx.js → CXDUvPYf.js} +1 -1
  161. package/web/app/immutable/chunks/{_Tye__BB.js → CYSndAne.js} +1 -1
  162. package/web/app/immutable/chunks/{DnHJL326.js → C_SKcJv7.js} +1 -1
  163. package/web/app/immutable/chunks/{d7CFoqrB.js → Cbb4o3qj.js} +1 -1
  164. package/web/app/immutable/chunks/{esAd2hCU.js → CbxBZqC_.js} +1 -1
  165. package/web/app/immutable/chunks/{C-srtNB0.js → CdbRvoG6.js} +1 -1
  166. package/web/app/immutable/chunks/{BGN2EuCq.js → ClNMpui4.js} +1 -1
  167. package/web/app/immutable/chunks/{edw8TVSr.js → CletI6Pa.js} +1 -1
  168. package/web/app/immutable/chunks/{CcNZQwT1.js → Clez3uTU.js} +3 -3
  169. package/web/app/immutable/chunks/{CwTWayd0.js → Clo7aK1n.js} +1 -1
  170. package/web/app/immutable/chunks/{B57eLsJv.js → Cnl_O3ZO.js} +1 -1
  171. package/web/app/immutable/chunks/{CWezNj5-.js → CoJyxFcH.js} +1 -1
  172. package/web/app/immutable/chunks/{DCP9TL-A.js → Cp02CBjf.js} +1 -1
  173. package/web/app/immutable/chunks/{BaJfBXet.js → Cp7Byf5d.js} +1 -1
  174. package/web/app/immutable/chunks/{C7OV0KqB.js → CqrCSb8W.js} +1 -1
  175. package/web/app/immutable/chunks/{DRg21hWl.js → Cr2Op5yp.js} +2 -2
  176. package/web/app/immutable/chunks/{DvdS-8it.js → Cr5QjekU.js} +1 -1
  177. package/web/app/immutable/chunks/{lDDdxVqt.js → CrEMns9K.js} +1 -1
  178. package/web/app/immutable/chunks/{DXB4L22V.js → CrsbEWnE.js} +1 -1
  179. package/web/app/immutable/chunks/{BYIgLpGQ.js → Csh6XB2J.js} +1 -1
  180. package/web/app/immutable/chunks/{ZAUoxjxb.js → CsyhqW-P.js} +1 -1
  181. package/web/app/immutable/chunks/{DOuyIvfN.js → CuPx_r7k.js} +1 -1
  182. package/web/app/immutable/chunks/{BD47nZkr.js → Cy9hcA7q.js} +1 -1
  183. package/web/app/immutable/chunks/{CjZEyjv4.js → D-rRuAXZ.js} +1 -1
  184. package/web/app/immutable/chunks/{D5i4Tktw.js → D0R3sca1.js} +1 -1
  185. package/web/app/immutable/chunks/{Dc7e-OgI.js → D20kqX2U.js} +2 -2
  186. package/web/app/immutable/chunks/{CKc3ivIh.js → D2mnZ9kC.js} +2 -2
  187. package/web/app/immutable/chunks/{DAUcVagO.js → D5Tu5Sg8.js} +1 -1
  188. package/web/app/immutable/chunks/{DTU57FsX.js → D7Dfbf5g.js} +1 -1
  189. package/web/app/immutable/chunks/{C8veqOP9.js → D8XzixBC.js} +1 -1
  190. package/web/app/immutable/chunks/{CPel99qV.js → DDb9H7X6.js} +3 -3
  191. package/web/app/immutable/chunks/{DUkL2vjQ.js → DDrpCbke.js} +1 -1
  192. package/web/app/immutable/chunks/{BQXu3XXC.js → DEDo4DeD.js} +4 -4
  193. package/web/app/immutable/chunks/{CEaHYCM5.js → DErxk4N4.js} +1 -1
  194. package/web/app/immutable/chunks/{DfOxl3xY.js → DEs9kPtf.js} +1 -1
  195. package/web/app/immutable/chunks/{DhHLTWgE.js → DGMrUmNq.js} +1 -1
  196. package/web/app/immutable/chunks/{5ibcqblv.js → DGVdJiQ7.js} +1 -1
  197. package/web/app/immutable/chunks/{CTKlTmjI.js → DHf7N1bI.js} +1 -1
  198. package/web/app/immutable/chunks/{CvxVjZLu.js → DI71nFp4.js} +1 -1
  199. package/web/app/immutable/chunks/{AXE1aiRo.js → DJPIUVkw.js} +1 -1
  200. package/web/app/immutable/chunks/{BWmYJDmC.js → DLCFUd4s.js} +1 -1
  201. package/web/app/immutable/chunks/{2V6-Yhg-.js → DM1_VFfD.js} +1 -1
  202. package/web/app/immutable/chunks/{Dh_uOrf0.js → DMeCi1eF.js} +1 -1
  203. package/web/app/immutable/chunks/{Bs8vOu-_.js → DPR_clFy.js} +1 -1
  204. package/web/app/immutable/chunks/{ClNWpSoj.js → DPY-p9P3.js} +2 -2
  205. package/web/app/immutable/chunks/{7Em2EC6e.js → DQT1hnTe.js} +1 -1
  206. package/web/app/immutable/chunks/{CMn1nNPl.js → DR6M_MBd.js} +1 -1
  207. package/web/app/immutable/chunks/{D0I7VQ8a.js → DSiGyv9Y.js} +1 -1
  208. package/web/app/immutable/chunks/{B80lqB7E.js → DTDtxEAk.js} +1 -1
  209. package/web/app/immutable/chunks/{CvCS8OAf.js → DUAtqTLU.js} +1 -1
  210. package/web/app/immutable/chunks/{CU89eAKc.js → DV7x43jt.js} +1 -1
  211. package/web/app/immutable/chunks/{BEvFtidS.js → DWa-2rkZ.js} +1 -1
  212. package/web/app/immutable/chunks/{CRFehAxF.js → DX9N1RQz.js} +1 -1
  213. package/web/app/immutable/chunks/{DB4f78Ip.js → D_VvdZe2.js} +1 -1
  214. package/web/app/immutable/chunks/{BNm3whw0.js → Da-Blgd9.js} +1 -1
  215. package/web/app/immutable/chunks/{BXT21uPn.js → DcOkWaeN.js} +1 -1
  216. package/web/app/immutable/chunks/{8uGKFevW.js → DgJnzjEh.js} +1 -1
  217. package/web/app/immutable/chunks/{Jh2BVut2.js → DiURwJNX.js} +1 -1
  218. package/web/app/immutable/chunks/{C5tAJtyd.js → DlU1rxYV.js} +1 -1
  219. package/web/app/immutable/chunks/{BQ1b28aV.js → DlUpt_0u.js} +1 -1
  220. package/web/app/immutable/chunks/{DneGzq7o.js → DlWS0XX3.js} +1 -1
  221. package/web/app/immutable/chunks/{CRGZeiHP.js → DmhHa5tp.js} +1 -1
  222. package/web/app/immutable/chunks/{CeOHBQlu.js → Dmn1abz2.js} +1 -1
  223. package/web/app/immutable/chunks/{BXClhyCJ.js → DnLmeVJZ.js} +1 -1
  224. package/web/app/immutable/chunks/{1MN-thc1.js → Do2KlQU0.js} +1 -1
  225. package/web/app/immutable/chunks/DoOue2dc.js +2 -0
  226. package/web/app/immutable/chunks/{2ndYjFQq.js → Dp8FVKoA.js} +1 -1
  227. package/web/app/immutable/chunks/{CrjK8LH9.js → DqAYkzSz.js} +1 -1
  228. package/web/app/immutable/chunks/{D2rdAIDv.js → DrTTxENT.js} +1 -1
  229. package/web/app/immutable/chunks/{BqCuw50f.js → DsfORPYa.js} +1 -1
  230. package/web/app/immutable/chunks/{CcSZrbR4.js → DtqPBHQj.js} +1 -1
  231. package/web/app/immutable/chunks/{jzrltQdi.js → DtyEiVnc.js} +1 -1
  232. package/web/app/immutable/chunks/{CXCw-Jw-.js → DuAAGnM9.js} +1 -1
  233. package/web/app/immutable/chunks/{CAmQkXZq.js → Dval4sTX.js} +1 -1
  234. package/web/app/immutable/chunks/{CJtFSxbf.js → Dvi4g0xk.js} +1 -1
  235. package/web/app/immutable/chunks/Dws-34a7.js +1 -0
  236. package/web/app/immutable/chunks/{qAXb8ucI.js → Dx3P5K2z.js} +1 -1
  237. package/web/app/immutable/chunks/{BdnR40vX.js → DxC0zTSc.js} +1 -1
  238. package/web/app/immutable/chunks/{Cxz7a3ln.js → DxPvfI2H.js} +4 -4
  239. package/web/app/immutable/chunks/{DbDI5c8r.js → Dxfvrgme.js} +1 -1
  240. package/web/app/immutable/chunks/{Cj5p8V3Z.js → DyZa5hX5.js} +1 -1
  241. package/web/app/immutable/chunks/{Bc3o0U_Z.js → Ex_x2wO5.js} +1 -1
  242. package/web/app/immutable/chunks/{0_OkSok2.js → GIVowYni.js} +1 -1
  243. package/web/app/immutable/chunks/{DM_kAcca.js → Gt7Fxn5w.js} +1 -1
  244. package/web/app/immutable/chunks/{C0A3yiL9.js → HU1Ksz8U.js} +1 -1
  245. package/web/app/immutable/chunks/{zJz5NUAZ.js → IIW6JGdD.js} +1 -1
  246. package/web/app/immutable/chunks/{BvFRd1je.js → JM7CQkWC.js} +1 -1
  247. package/web/app/immutable/chunks/{lma_Aa_Q.js → K8u-JjT9.js} +1 -1
  248. package/web/app/immutable/chunks/{D8mJ0i4V.js → L7Esr5Id.js} +1 -1
  249. package/web/app/immutable/chunks/{CGaMCAik.js → LQRHF1eM.js} +1 -1
  250. package/web/app/immutable/chunks/{x019Lcmv.js → OGqbAD_O.js} +1 -1
  251. package/web/app/immutable/chunks/{DnkGrT83.js → OrN9D77d.js} +3 -3
  252. package/web/app/immutable/chunks/{DZEg_JlV.js → PhAbES0t.js} +1 -1
  253. package/web/app/immutable/chunks/{BaJMqkSd.js → QRUY44Ff.js} +1 -1
  254. package/web/app/immutable/chunks/{9Bk8hwX5.js → RHSH5iZ7.js} +1 -1
  255. package/web/app/immutable/chunks/{C9aF-Sor.js → SbTG0nwQ.js} +1 -1
  256. package/web/app/immutable/chunks/{CyYfX9fz.js → TT8yXpG-.js} +1 -1
  257. package/web/app/immutable/chunks/{C4VXXfVL.js → U7dpdlAf.js} +1 -1
  258. package/web/app/immutable/chunks/{Bcb1iqQJ.js → VeUh5OMZ.js} +1 -1
  259. package/web/app/immutable/chunks/Whej1Dge.js +1 -0
  260. package/web/app/immutable/chunks/{P9PnSQNh.js → Z9NyJp9w.js} +3 -3
  261. package/web/app/immutable/chunks/{D_DdTIu0.js → ZRNKCUqe.js} +47 -47
  262. package/web/app/immutable/chunks/{IjcPbG76.js → _2VCBG9z.js} +1 -1
  263. package/web/app/immutable/chunks/{DZAKdz0-.js → ada9rZfE.js} +1 -1
  264. package/web/app/immutable/chunks/{BtBv0U_D.js → d8NijX_Z.js} +2 -2
  265. package/web/app/immutable/chunks/{BLZhAOLT.js → deEweluJ.js} +1 -1
  266. package/web/app/immutable/chunks/{Do6vtrQf.js → dmZv6JOg.js} +1 -1
  267. package/web/app/immutable/chunks/{ByNdLM3c.js → e9nNeD_8.js} +1 -1
  268. package/web/app/immutable/chunks/{BJHkJxQ6.js → fHygQTSC.js} +1 -1
  269. package/web/app/immutable/chunks/{CbqBbwIN.js → gU2qspu9.js} +1 -1
  270. package/web/app/immutable/chunks/{-J-Hmuck.js → h8JtxU_T.js} +1 -1
  271. package/web/app/immutable/chunks/{Bk1CZ_aH.js → hNQ1u1TD.js} +1 -1
  272. package/web/app/immutable/chunks/{BegKMnH4.js → hYcAQyax.js} +1 -1
  273. package/web/app/immutable/chunks/{gIt--5se.js → i0UHQwRY.js} +1 -1
  274. package/web/app/immutable/chunks/{HQDMr2H7.js → iCWz6IE9.js} +1 -1
  275. package/web/app/immutable/chunks/{CbaFGz2w.js → jBG7W4tL.js} +1 -1
  276. package/web/app/immutable/chunks/{oRcurxpq.js → lTwh0Wzj.js} +1 -1
  277. package/web/app/immutable/chunks/{DyHx5QFY.js → nwO3KCpP.js} +1 -1
  278. package/web/app/immutable/chunks/{05jEdw2V.js → pMP23LzB.js} +1 -1
  279. package/web/app/immutable/chunks/{BJTYazIn.js → pomj9evG.js} +1 -1
  280. package/web/app/immutable/chunks/{evy8DaDH.js → rEslErv9.js} +1 -1
  281. package/web/app/immutable/chunks/{x_GKKTQV.js → rXKOJqUt.js} +1 -1
  282. package/web/app/immutable/chunks/{Ue4xifLs.js → sOF-qTei.js} +1 -1
  283. package/web/app/immutable/chunks/{BXyd6A9p.js → sSXTMg2P.js} +1 -1
  284. package/web/app/immutable/chunks/{B0fUscDD.js → tLFaYuVN.js} +1 -1
  285. package/web/app/immutable/chunks/{BkUPUOzV.js → tuKjkgzS.js} +1 -1
  286. package/web/app/immutable/chunks/{CZ56JG-R.js → v3_7O0A0.js} +1 -1
  287. package/web/app/immutable/chunks/{DVuQpyKc.js → vdylZNCS.js} +1 -1
  288. package/web/app/immutable/chunks/{BHXs-6um.js → vyUklWDK.js} +1 -1
  289. package/web/app/immutable/chunks/{DU4sJYad.js → wiGlLVr-.js} +1 -1
  290. package/web/app/immutable/chunks/{CCPr9hs_.js → yDmmPu6L.js} +1 -1
  291. package/web/app/immutable/chunks/{Dv-bjgEk.js → zB9UbdEg.js} +1 -1
  292. package/web/app/immutable/entry/{app.BN9LppoE.js → app.DEnhhDc1.js} +3 -3
  293. package/web/app/immutable/entry/start.Cmawmwgw.js +1 -0
  294. package/web/app/immutable/nodes/{0.DuuUT7lf.js → 0.DLkagS9u.js} +1 -1
  295. package/web/app/immutable/nodes/{1.CuKU_s85.js → 1.ChB9puqR.js} +1 -1
  296. package/web/app/immutable/nodes/10.B3YEuSxS.js +39 -0
  297. package/web/app/immutable/nodes/{11.DswJjpxi.js → 11.rgOqEz2U.js} +1 -1
  298. package/web/app/immutable/nodes/{12.iQywXLwT.js → 12.D6rxlIQy.js} +1 -1
  299. package/web/app/immutable/nodes/{13.m6xe0bMv.js → 13.CHYsmiD_.js} +1 -1
  300. package/web/app/immutable/nodes/{14.CyaNpqAL.js → 14.mG-YN9pn.js} +3 -3
  301. package/web/app/immutable/nodes/{15.CDuV6cP7.js → 15.CgSxPoXZ.js} +1 -1
  302. package/web/app/immutable/nodes/{16.MUmBS-bv.js → 16.BsFtzH0D.js} +1 -1
  303. package/web/app/immutable/nodes/{17.C_k1qpf6.js → 17.me_aOx8O.js} +1 -1
  304. package/web/app/immutable/nodes/{18.BjTfofOz.js → 18.BO1oZWgm.js} +1 -1
  305. package/web/app/immutable/nodes/{19.DvjAcoWG.js → 19.DS0Anfm0.js} +2 -2
  306. package/web/app/immutable/nodes/{2.r_yCTdWa.js → 2.BB55cMHs.js} +4 -4
  307. package/web/app/immutable/nodes/{20.DuDV-BZU.js → 20.LbRPieV_.js} +1 -1
  308. package/web/app/immutable/nodes/{3.BzmP3XDj.js → 3.B1suR6zI.js} +1 -1
  309. package/web/app/immutable/nodes/{4.BPX7a1xw.js → 4.BdkLcCps.js} +1 -1
  310. package/web/app/immutable/nodes/{5.CbH1sau-.js → 5.DlFTrLdG.js} +1 -1
  311. package/web/app/immutable/nodes/{6.DXN3u4yU.js → 6.EdJoOCRv.js} +1 -1
  312. package/web/app/immutable/nodes/{7.BAFpN-hf.js → 7.iPBOmxFo.js} +1 -1
  313. package/web/app/immutable/nodes/{8.COZNLTaW.js → 8.BRpg5Nn-.js} +1 -1
  314. package/web/app/immutable/nodes/9.CeyWcdBf.js +14 -0
  315. package/web/app/version.json +1 -1
  316. package/web/generated/paraglide.js +49 -49
  317. package/web/index.html +18 -18
  318. package/web/app/immutable/chunks/0vzGySSF.js +0 -1
  319. package/web/app/immutable/chunks/4rRlR2tp.js +0 -2
  320. package/web/app/immutable/chunks/BV8D9pH6.js +0 -158
  321. package/web/app/immutable/chunks/C0P2MUJp.js +0 -1
  322. package/web/app/immutable/chunks/KU76P7cR.js +0 -1
  323. package/web/app/immutable/chunks/XS67_4Nj.js +0 -2
  324. package/web/app/immutable/chunks/hY0rMePc.js +0 -1
  325. package/web/app/immutable/entry/start.Dyk9KswN.js +0 -1
  326. package/web/app/immutable/nodes/10.DkGJji_v.js +0 -39
  327. package/web/app/immutable/nodes/9.VZM4RxD5.js +0 -14
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["/app/immutable/chunks/DyHx5QFY.js","/app/immutable/chunks/x_GKKTQV.js","/app/immutable/chunks/Bqd7fdCF.js","/app/immutable/chunks/CIyUrgF0.js","/app/immutable/chunks/hY0rMePc.js","/app/immutable/chunks/3SdAC2_C.js","/app/immutable/chunks/BWmYJDmC.js","/app/immutable/chunks/leDczq9h.js","/app/immutable/chunks/CjZEyjv4.js","/app/immutable/assets/spinner.D_TRo5Hy.css","/app/immutable/chunks/CIU_APaR.js","/app/immutable/chunks/Dn334wJv.js","/app/immutable/chunks/D400ElMz.js","/app/immutable/chunks/rNjiZ_3W.js","/app/immutable/chunks/BTc_j7Dt.js","/app/immutable/chunks/uXuxG9cN.js","/app/immutable/assets/button.-yaUNjRS.css","/app/immutable/chunks/BNN0vAFF.js","/app/immutable/chunks/CXul4WJt.js","/app/immutable/chunks/B7JHU89G.js","/app/immutable/chunks/BXT21uPn.js","/app/immutable/chunks/DXdFemRu.js","/app/immutable/chunks/Dms_DO28.js","/app/immutable/chunks/ChTqQfQN.js","/app/immutable/chunks/B4mHWFlW.js","/app/immutable/chunks/DxwfiAWm.js","/app/immutable/chunks/D9tVylVS.js","/app/immutable/chunks/DETS1-K4.js","/app/immutable/chunks/72S4_8Fo.js","/app/immutable/chunks/DU3vNstz.js","/app/immutable/chunks/XJv96NUg.js","/app/immutable/assets/notify.B1j5oT2y.css","/app/immutable/chunks/CwTWayd0.js","/app/immutable/chunks/B4PfEXaO.js"])))=>i.map(i=>d[i]);
2
- var Fh=Object.defineProperty;var Nh=(t,e,i)=>e in t?Fh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var P=(t,e,i)=>Nh(t,typeof e!="symbol"?e+"":e,i);import{cd as zh}from"./3SdAC2_C.js";import{bm as $s,_ as Dn}from"./hY0rMePc.js";import{a as Xi}from"./BdWqymET.js";import{i as Fs}from"./BBWuirRW.js";import{f as Wh}from"./AXE1aiRo.js";import{t as Hh}from"./Bygp72Wl.js";import{d as Hi}from"./B0Z-1lwJ.js";import{c as Uh}from"./ChTqQfQN.js";import{s as Wt}from"./CQ409-Pj.js";import{H as Kh}from"./rNjiZ_3W.js";import{Jx as _t,KC as Bn,gE as qh,a$ as Vh,CD as Gh,AQ as Yh,sk as Xh}from"./DXdFemRu.js";import{O as An,S as Pn,J as On,B as In}from"./Bqd7fdCF.js";import{g as jh}from"./CAmQkXZq.js";import{f as Zh,l as Jh}from"./05jEdw2V.js";/**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["/app/immutable/chunks/nwO3KCpP.js","/app/immutable/chunks/rXKOJqUt.js","/app/immutable/chunks/Bqd7fdCF.js","/app/immutable/chunks/CIyUrgF0.js","/app/immutable/chunks/Dws-34a7.js","/app/immutable/chunks/3SdAC2_C.js","/app/immutable/chunks/DLCFUd4s.js","/app/immutable/chunks/BD9db4FR.js","/app/immutable/chunks/D-rRuAXZ.js","/app/immutable/assets/spinner.D_TRo5Hy.css","/app/immutable/chunks/BIGqOuh0.js","/app/immutable/chunks/Dn334wJv.js","/app/immutable/chunks/C-zB-6G6.js","/app/immutable/chunks/BPuz5cN_.js","/app/immutable/chunks/7KxcPj98.js","/app/immutable/chunks/uXuxG9cN.js","/app/immutable/assets/button.-yaUNjRS.css","/app/immutable/chunks/B5tvpTFB.js","/app/immutable/chunks/5-0LQoqd.js","/app/immutable/chunks/B8HnjSSF.js","/app/immutable/chunks/DcOkWaeN.js","/app/immutable/chunks/4g_iHoQm.js","/app/immutable/chunks/Dms_DO28.js","/app/immutable/chunks/ChTqQfQN.js","/app/immutable/chunks/8jMQM9h0.js","/app/immutable/chunks/DxwfiAWm.js","/app/immutable/chunks/D9tVylVS.js","/app/immutable/chunks/CGYPBD6G.js","/app/immutable/chunks/Bc1vJq_Z.js","/app/immutable/chunks/DU3vNstz.js","/app/immutable/chunks/XJv96NUg.js","/app/immutable/assets/notify.B1j5oT2y.css","/app/immutable/chunks/Clo7aK1n.js","/app/immutable/chunks/B6eTPmJH.js"])))=>i.map(i=>d[i]);
2
+ var Fh=Object.defineProperty;var Nh=(t,e,i)=>e in t?Fh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var P=(t,e,i)=>Nh(t,typeof e!="symbol"?e+"":e,i);import{cd as zh}from"./3SdAC2_C.js";import{bm as $s,_ as Dn}from"./Dws-34a7.js";import{a as Xi}from"./BdWqymET.js";import{i as Fs}from"./BBWuirRW.js";import{f as Wh}from"./DJPIUVkw.js";import{t as Hh}from"./BSUnflvl.js";import{d as Hi}from"./B0Z-1lwJ.js";import{c as Uh}from"./ChTqQfQN.js";import{s as Wt}from"./CQ409-Pj.js";import{H as Kh}from"./BPuz5cN_.js";import{Jx as _t,KC as Bn,gE as qh,a$ as Vh,CD as Gh,AQ as Yh,sk as Xh}from"./4g_iHoQm.js";import{O as An,S as Pn,J as On,B as In}from"./Bqd7fdCF.js";import{g as jh}from"./Dval4sTX.js";import{f as Zh,l as Jh}from"./pMP23LzB.js";/**
3
3
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
4
4
  * @license MIT
5
5
  *
@@ -141,6 +141,6 @@ void main() {
141
141
  `))}},df=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},uf=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},_f=0,dr=class{constructor(t){this.value=t,this.id=_f++}},ff=2,gf,ut=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new lf(t?.onListenerError??cr,this._options?.leakWarningThreshold??hf):void 0,this._perfMon=this._options?._profName?new af(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(t,e,i)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let o=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(o);let a=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],l=new uf(`${o}. HINT: Stack shows most frequent listener (${a[1]}-times)`,a[0]);return(this._options?.onListenerError||cr)(l),Kt.None}if(this._disposed)return Kt.None;e&&(t=t.bind(e));let s=new dr(t),r;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=cf.create(),r=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof dr?(this._deliveryQueue??=new pf,this._listeners=[this._listeners,s]):this._listeners.push(s):(this._options?.onWillAddFirstListener?.(this),this._listeners=s,this._options?.onDidAddFirstListener?.(this)),this._size++;let n=Ci(()=>{r?.(),this._removeListener(s)});return i instanceof xn?i.add(n):Array.isArray(i)&&i.push(n),n},this._event}_removeListener(t){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let e=this._listeners,i=e.indexOf(t);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,e[i]=void 0;let s=this._deliveryQueue.current===this;if(this._size*ff<=e.length){let r=0;for(let n=0;n<e.length;n++)e[n]?e[r++]=e[n]:s&&(this._deliveryQueue.end--,r<this._deliveryQueue.i&&this._deliveryQueue.i--);e.length=r}}_deliver(t,e){if(!t)return;let i=this._options?.onListenerError||cr;if(!i){t.value(e);return}try{t.value(e)}catch(s){i(s)}}_deliverQueue(t){let e=t.current._listeners;for(;t.i<t.end;)this._deliver(e[t.i++],t.value);t.reset()}fire(t){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof dr)this._deliver(this._listeners,t);else{let e=this._deliveryQueue;e.enqueue(this,t,this._listeners.length),this._deliverQueue(e)}this._perfMon?.stop()}hasListeners(){return this._size>0}},pf=class{constructor(){this.i=-1,this.end=0}enqueue(t,e,i){this.i=0,this.end=i,this.current=t,this.value=e}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Ph=Object.freeze(function(t,e){let i=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(i)}}}),mf;(t=>{function e(i){return i===t.None||i===t.Cancelled||i instanceof vf?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:kn.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Ph})})(mf||={});var vf=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?Ph:(this._emitter||(this._emitter=new ut),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},pi="en",ur=!1,cs,bs=pi,oa=pi,Sf,Et,ri=globalThis,Ge;typeof ri.vscode<"u"&&typeof ri.vscode.process<"u"?Ge=ri.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(Ge=process);var wf=typeof Ge?.versions?.electron=="string",bf=wf&&Ge?.type==="renderer";if(typeof Ge=="object"){Ge.platform,Ge.platform,ur=Ge.platform==="linux",ur&&Ge.env.SNAP&&Ge.env.SNAP_REVISION,Ge.env.CI||Ge.env.BUILD_ARTIFACTSTAGINGDIRECTORY,cs=pi,bs=pi;let t=Ge.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);cs=e.userLocale,oa=e.osLocale,bs=e.resolvedLanguage||pi,Sf=e.languagePack?.translationsConfigFile}catch{}}else typeof navigator=="object"&&!bf?(Et=navigator.userAgent,Et.indexOf("Windows")>=0,Et.indexOf("Macintosh")>=0,(Et.indexOf("Macintosh")>=0||Et.indexOf("iPad")>=0||Et.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,ur=Et.indexOf("Linux")>=0,Et?.indexOf("Mobi")>=0,bs=globalThis._VSCODE_NLS_LANGUAGE||pi,cs=navigator.language.toLowerCase(),oa=cs):console.error("Unable to resolve platform.");var vt=Et,$t=bs,Cf;(t=>{function e(){return $t}t.value=e;function i(){return $t.length===2?$t==="en":$t.length>=3?$t[0]==="e"&&$t[1]==="n"&&$t[2]==="-":!1}t.isDefaultVariant=i;function s(){return $t==="en"}t.isDefault=s})(Cf||={});var yf=typeof ri.postMessage=="function"&&!ri.importScripts;(()=>{if(yf){let t=[];ri.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,r=t.length;s<r;s++){let n=t[s];if(n.id===i.data.vscodeScheduleAsyncWork){t.splice(s,1),n.callback();return}}});let e=0;return i=>{let s=++e;t.push({id:s,callback:i}),ri.postMessage({vscodeScheduleAsyncWork:s},"*")}}return t=>setTimeout(t)})();var xf=!!(vt&&vt.indexOf("Chrome")>=0);vt&&vt.indexOf("Firefox")>=0;!xf&&vt&&vt.indexOf("Safari")>=0;vt&&vt.indexOf("Edg/")>=0;vt&&vt.indexOf("Android")>=0;function Oh(t,e=0,i){let s=setTimeout(()=>{t()},e);return Ci(()=>{clearTimeout(s)})}var kf;(t=>{async function e(s){let r,n=await Promise.all(s.map(o=>o.then(a=>a,a=>{r||(r=a)})));if(typeof r<"u")throw r;return n}t.settled=e;function i(s){return new Promise(async(r,n)=>{try{await s(r,n)}catch(o){n(o)}})}t.withAsyncBody=i})(kf||={});var aa=class Qe{static fromArray(e){return new Qe(i=>{i.emitMany(e)})}static fromPromise(e){return new Qe(async i=>{i.emitMany(await e)})}static fromPromises(e){return new Qe(async i=>{await Promise.all(e.map(async s=>i.emitOne(await s)))})}static merge(e){return new Qe(async i=>{await Promise.all(e.map(async s=>{for await(let r of s)i.emitOne(r)}))})}constructor(e,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new ut,queueMicrotask(async()=>{let s={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(e(s)),this.resolve()}catch(r){this.reject(r)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await kn.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(e,i){return new Qe(async s=>{for await(let r of e)s.emitOne(i(r))})}map(e){return Qe.map(this,e)}static filter(e,i){return new Qe(async s=>{for await(let r of e)i(r)&&s.emitOne(r)})}filter(e){return Qe.filter(this,e)}static coalesce(e){return Qe.filter(e,i=>!!i)}coalesce(){return Qe.coalesce(this)}static async toPromise(e){let i=[];for await(let s of e)i.push(s);return i}toPromise(){return Qe.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};aa.EMPTY=aa.fromArray([]);var Lf=class extends Kt{constructor(t){super(),this._terminal=t,this._linesCacheTimeout=this._register(new Ts),this._linesCacheDisposables=this._register(new Ts),this._register(Ci(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=new Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=Eh(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=Oh(()=>this._destroyLinesCache(),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(t){return this._linesCache?.[t]}setLineInCache(t,e){this._linesCache&&(this._linesCache[t]=e)}translateBufferLineToStringWithWrap(t,e){let i=[],s=[0],r=this._terminal.buffer.active.getLine(t);for(;r;){let n=this._terminal.buffer.active.getLine(t+1),o=n?n.isWrapped:!1,a=r.translateToString(!o&&e);if(o&&n){let l=r.getCell(r.length-1);l&&l.getCode()===0&&l.getWidth()===1&&n.getCell(0)?.getWidth()===2&&(a=a.slice(0,-1))}if(i.push(a),o)s.push(s[s.length-1]+a.length);else break;t++,r=n}return[i.join(""),s]}},Ef=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(t){this._cachedSearchTerm=t}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(t){this._lastSearchOptions=t}isValidSearchTerm(t){return!!(t&&t.length>0)}didOptionsChange(t){return this._lastSearchOptions?t?this._lastSearchOptions.caseSensitive!==t.caseSensitive||this._lastSearchOptions.regex!==t.regex||this._lastSearchOptions.wholeWord!==t.wholeWord:!1:!0}shouldUpdateHighlighting(t,e){return e?.decorations?this._cachedSearchTerm===void 0||t!==this._cachedSearchTerm||this.didOptionsChange(e):!1}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},Mf=class{constructor(t,e){this._terminal=t,this._lineCache=e}find(t,e,i,s){if(!t||t.length===0){this._terminal.clearSelection();return}if(i>this._terminal.cols)throw new Error(`Invalid col: ${i} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let r={startRow:e,startCol:i},n=this._findInLine(t,r,s);if(!n)for(let o=e+1;o<this._terminal.buffer.active.baseY+this._terminal.rows&&(r.startRow=o,r.startCol=0,n=this._findInLine(t,r,s),!n);o++);return n}findNextWithSelection(t,e,i){if(!t||t.length===0){this._terminal.clearSelection();return}let s=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=0,n=0;s&&(i===t?(r=s.end.x,n=s.end.y):(r=s.start.x,n=s.start.y)),this._lineCache.initLinesCache();let o={startRow:n,startCol:r},a=this._findInLine(t,o,e);if(!a)for(let l=n+1;l<this._terminal.buffer.active.baseY+this._terminal.rows&&(o.startRow=l,o.startCol=0,a=this._findInLine(t,o,e),!a);l++);if(!a&&n!==0)for(let l=0;l<n&&(o.startRow=l,o.startCol=0,a=this._findInLine(t,o,e),!a);l++);return!a&&s&&(o.startRow=s.start.y,o.startCol=0,a=this._findInLine(t,o,e)),a}findPreviousWithSelection(t,e,i){if(!t||t.length===0){this._terminal.clearSelection();return}let s=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=this._terminal.buffer.active.baseY+this._terminal.rows-1,n=this._terminal.cols,o=!0;this._lineCache.initLinesCache();let a={startRow:r,startCol:n},l;if(s&&(a.startRow=r=s.start.y,a.startCol=n=s.start.x,i!==t&&(l=this._findInLine(t,a,e,!1),l||(a.startRow=r=s.end.y,a.startCol=n=s.end.x))),l||(l=this._findInLine(t,a,e,o)),!l){a.startCol=Math.max(a.startCol,this._terminal.cols);for(let h=r-1;h>=0&&(a.startRow=h,l=this._findInLine(t,a,e,o),!l);h--);}if(!l&&r!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let h=this._terminal.buffer.active.baseY+this._terminal.rows-1;h>=r&&(a.startRow=h,l=this._findInLine(t,a,e,o),!l);h--);return l}_isWholeWord(t,e,i){return(t===0||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(e[t-1]))&&(t+i.length===e.length||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(e[t+i.length]))}_findInLine(t,e,i={},s=!1){let r=e.startRow,n=e.startCol;if(this._terminal.buffer.active.getLine(r)?.isWrapped){if(s){e.startCol+=this._terminal.cols;return}return e.startRow--,e.startCol+=this._terminal.cols,this._findInLine(t,e,i)}let o=this._lineCache.getLineFromCache(r);o||(o=this._lineCache.translateBufferLineToStringWithWrap(r,!0),this._lineCache.setLineInCache(r,o));let[a,l]=o,h=this._bufferColsToStringOffset(r,n),c=t,d=a;i.regex||(c=i.caseSensitive?t:t.toLowerCase(),d=i.caseSensitive?a:a.toLowerCase());let u=-1;if(i.regex){let f=RegExp(c,i.caseSensitive?"g":"gi"),g;if(s)for(;g=f.exec(d.slice(0,h));)u=f.lastIndex-g[0].length,t=g[0],f.lastIndex-=t.length-1;else g=f.exec(d.slice(h)),g&&g[0].length>0&&(u=h+(f.lastIndex-g[0].length),t=g[0])}else s?h-c.length>=0&&(u=d.lastIndexOf(c,h-c.length)):u=d.indexOf(c,h);if(u>=0){if(i.wholeWord&&!this._isWholeWord(u,d,t))return;let f=0;for(;f<l.length-1&&u>=l[f+1];)f++;let g=f;for(;g<l.length-1&&u+t.length>=l[g+1];)g++;let C=u-l[f],L=u+t.length-l[g],D=this._stringLengthToBufferSize(r+f,C),B=this._stringLengthToBufferSize(r+g,L)-D+this._terminal.cols*(g-f);return{term:t,col:D,row:r+f,size:B}}}_stringLengthToBufferSize(t,e){let i=this._terminal.buffer.active.getLine(t);if(!i)return 0;for(let s=0;s<e;s++){let r=i.getCell(s);if(!r)break;let n=r.getChars();n.length>1&&(e-=n.length-1);let o=i.getCell(s+1);o&&o.getWidth()===0&&e++}return e}_bufferColsToStringOffset(t,e){let i=t,s=0,r=this._terminal.buffer.active.getLine(i);for(;e>0&&r;){for(let n=0;n<e&&n<this._terminal.cols;n++){let o=r.getCell(n);if(!o)break;o.getWidth()&&(s+=o.getCode()===0?1:o.getChars().length)}if(i++,r=this._terminal.buffer.active.getLine(i),r&&!r.isWrapped)break;e-=this._terminal.cols}return s}},Tf=class extends Kt{constructor(t){super(),this._terminal=t,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(Ci(()=>this.clearHighlightDecorations()))}createHighlightDecorations(t,e){this.clearHighlightDecorations();for(let i of t){let s=this._createResultDecorations(i,e,!1);if(s)for(let r of s)this._storeDecoration(r,i)}}createActiveDecoration(t,e){let i=this._createResultDecorations(t,e,!0);if(i)return{decorations:i,match:t,dispose(){Ki(i)}}}clearHighlightDecorations(){Ki(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(t,e){this._highlightedLines.add(t.marker.line),this._highlightDecorations.push({decoration:t,match:e,dispose(){t.dispose()}})}_applyStyles(t,e,i){t.classList.contains("xterm-find-result-decoration")||(t.classList.add("xterm-find-result-decoration"),e&&(t.style.outline=`1px solid ${e}`)),i&&t.classList.add("xterm-find-active-result-decoration")}_createResultDecorations(t,e,i){let s=[],r=t.col,n=t.size,o=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+t.row;for(;n>0;){let l=Math.min(this._terminal.cols-r,n);s.push([o,r,l]),r=0,n-=l,o++}let a=[];for(let l of s){let h=this._terminal.registerMarker(l[0]),c=this._terminal.registerDecoration({marker:h,x:l[1],width:l[2],backgroundColor:i?e.activeMatchBackground:e.matchBackground,overviewRulerOptions:this._highlightedLines.has(h.line)?void 0:{color:i?e.activeMatchColorOverviewRuler:e.matchOverviewRuler,position:"center"}});if(c){let d=[];d.push(h),d.push(c.onRender(u=>this._applyStyles(u,i?e.activeMatchBorder:e.matchBorder,!1))),d.push(c.onDispose(()=>Ki(d))),a.push(c)}}return a.length===0?void 0:a}},Rf=class extends Kt{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new ut)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(t){this._selectedDecoration=t}updateResults(t,e){this._searchResults=t.slice(0,e)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&(this._selectedDecoration.dispose(),this._selectedDecoration=void 0)}findResultIndex(t){for(let e=0;e<this._searchResults.length;e++){let i=this._searchResults[e];if(i.row===t.row&&i.col===t.col&&i.size===t.size)return e}return-1}fireResultsChanged(t){if(!t)return;let e=-1;this._selectedDecoration&&(e=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:e,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},Df=class extends Kt{constructor(t){super(),this._highlightTimeout=this._register(new Ts),this._lineCache=this._register(new Ts),this._state=new Ef,this._resultTracker=this._register(new Rf),this._highlightLimit=t?.highlightLimit??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(t){this._terminal=t,this._lineCache.value=new Lf(t),this._engine=new Mf(t,this._lineCache.value),this._decorationManager=new Tf(t),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(Ci(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=Oh(()=>{let t=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(t,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(t){this._resultTracker.clearSelectedDecoration(),this._decorationManager?.clearHighlightDecorations(),this._resultTracker.clearResults(),t||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(t,e,i){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=e,this._state.shouldUpdateHighlighting(t,e)&&this._highlightAllMatches(t,e);let s=this._findNextAndSelect(t,e,i);return this._fireResults(e),this._state.cachedSearchTerm=t,s}_highlightAllMatches(t,e){if(!this._terminal||!this._engine||!this._decorationManager)throw new Error("Cannot use addon until it has been loaded");if(!this._state.isValidSearchTerm(t)){this.clearDecorations();return}this.clearDecorations(!0);let i=[],s,r=this._engine.find(t,0,0,e);for(;r&&(s?.row!==r.row||s?.col!==r.col)&&!(i.length>=this._highlightLimit);)s=r,i.push(s),r=this._engine.find(t,s.col+s.term.length>=this._terminal.cols?s.row+1:s.row,s.col+s.term.length>=this._terminal.cols?0:s.col+1,e);this._resultTracker.updateResults(i,this._highlightLimit),e.decorations&&this._decorationManager.createHighlightDecorations(i,e.decorations)}_findNextAndSelect(t,e,i){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(t))return this._terminal.clearSelection(),this.clearDecorations(),!1;let s=this._engine.findNextWithSelection(t,e,this._state.cachedSearchTerm);return this._selectResult(s,e?.decorations,i?.noScroll)}findPrevious(t,e,i){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=e,this._state.shouldUpdateHighlighting(t,e)&&this._highlightAllMatches(t,e);let s=this._findPreviousAndSelect(t,e,i);return this._fireResults(e),this._state.cachedSearchTerm=t,s}_fireResults(t){this._resultTracker.fireResultsChanged(!!t?.decorations)}_findPreviousAndSelect(t,e,i){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(t))return this._terminal.clearSelection(),this.clearDecorations(),!1;let s=this._engine.findPreviousWithSelection(t,e,this._state.cachedSearchTerm);return this._selectResult(s,e?.decorations,i?.noScroll)}_selectResult(t,e,i){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!t)return this._terminal.clearSelection(),!1;if(this._terminal.select(t.col,t.row,t.size),e){let s=this._decorationManager.createActiveDecoration(t,e);s&&(this._resultTracker.selectedDecoration=s)}if(!i&&(t.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||t.row<this._terminal.buffer.active.viewportY)){let s=t.row-this._terminal.buffer.active.viewportY;s-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(s)}return!0}};const Gt=new Xi("TerminalStateMachine");var et=(t=>(t.UNINITIALIZED="uninitialized",t.INITIALIZING="initializing",t.CONNECTING="connecting",t.CONNECTED="connected",t.RECONNECTING="reconnecting",t.DISCONNECTED="disconnected",t.ERROR="error",t.DISPOSED="disposed",t))(et||{});class Bf{constructor(e){P(this,"currentState","uninitialized");P(this,"stateListeners",new Map);P(this,"transitionListeners",new Set);P(this,"errorHandlers",new Set);P(this,"transitions",[{from:["uninitialized"],to:"initializing",action:"initialize"},{from:["initializing"],to:"connecting",action:"connect"},{from:["connecting"],to:"connected",action:"connected"},{from:["disconnected","error"],to:"reconnecting",action:"reconnect"},{from:["reconnecting"],to:"connected",action:"reconnected"},{from:["connected","connecting"],to:"disconnected",action:"disconnect"},{from:["initializing","connecting","connected","reconnecting"],to:"error",action:"error"},{from:["uninitialized","initializing","connecting","connected","reconnecting","disconnected","error"],to:"disposed",action:"dispose"}]);this.terminalId=e}getState(){return this.currentState}canTransition(e){const i=this.transitions.find(s=>s.action===e&&s.from.includes(this.currentState));return!(!i||i.guard&&!i.guard())}transition(e){const i=this.transitions.find(r=>r.action===e&&r.from.includes(this.currentState));if(!i)return Gt.warn(`Invalid transition: ${e} from ${this.currentState}`),!1;if(i.guard&&!i.guard())return Gt.warn(`Guard failed for transition: ${e}`),!1;const s=this.currentState;return this.currentState=i.to,Gt.info(`Terminal ${this.terminalId}: ${s} -> ${this.currentState} (${e})`),this.notifyStateListeners(this.currentState),this.notifyTransitionListeners(s,this.currentState),!0}onStateChange(e,i){let s=this.stateListeners.get(e);return s||(s=new Set,this.stateListeners.set(e,s)),s.add(i),()=>{this.stateListeners.get(e)?.delete(i)}}onTransition(e){return this.transitionListeners.add(e),()=>{this.transitionListeners.delete(e)}}onError(e){return this.errorHandlers.add(e),()=>{this.errorHandlers.delete(e)}}reportError(e){Gt.error(`Terminal ${this.terminalId} error:`,e),this.errorHandlers.forEach(i=>{try{i(e)}catch(s){Gt.error("Error handler threw exception:",s)}}),this.currentState!=="disposed"&&this.transition("error")}isHealthy(){return["connected","connecting","reconnecting"].includes(this.currentState)}canAcceptInput(){return this.currentState==="connected"}isDisposed(){return this.currentState==="disposed"}notifyStateListeners(e){this.stateListeners.get(e)?.forEach(i=>{try{i()}catch(s){Gt.error("Error in state listener:",s)}})}notifyTransitionListeners(e,i){this.transitionListeners.forEach(s=>{try{s(e,i)}catch(r){Gt.error("Error in transition listener:",r)}})}dispose(){this.isDisposed()||this.transition("dispose"),this.stateListeners.clear(),this.transitionListeners.clear(),this.errorHandlers.clear()}}const ct=new Xi("TerminalBufferManager"),Ln="terminal-buffer-index";let Zt=null,an=0;const Af=5e3;function En(){const t=Date.now();if(Zt&&t-an<Af)return Zt;try{const e=localStorage.getItem(Ln);if(e){const i=JSON.parse(e);Zt=new Map(i.map(s=>[s.key,s.timestamp]))}else Zt=new Map}catch{Zt=new Map}return an=t,Zt}function Mn(t){try{const e=Array.from(t.entries()).map(([i,s])=>({key:i,timestamp:s}));localStorage.setItem(Ln,JSON.stringify(e)),Zt=t,an=Date.now()}catch{}}function ha(t,e){const i=En();i.set(t,e),Mn(i)}function la(t){const e=En();e.delete(t),Mn(e)}const $e=class $e{constructor(e,i){P(this,"storageKey");P(this,"fallbackStorage",new Map);this.workspaceId=e,this.terminalId=i,this.storageKey=`terminal-buffer-${e}-${i}`}async saveBuffer(e,i,s){try{const n={lines:this.trimBuffer(e),cursorX:i,cursorY:s,timestamp:Date.now(),version:$e.BUFFER_VERSION};if(await this.hasStorageSpace(n))try{return localStorage.setItem(this.storageKey,JSON.stringify(n)),ha(this.storageKey,n.timestamp),ct.debug(`Saved buffer for terminal ${this.terminalId}`),!0}catch(o){return ct.warn("localStorage failed, using fallback storage:",o),this.fallbackStorage.set(this.storageKey,n),!0}else{await this.cleanupOldBuffers();try{return localStorage.setItem(this.storageKey,JSON.stringify(n)),ha(this.storageKey,n.timestamp),!0}catch{return this.fallbackStorage.set(this.storageKey,n),!0}}}catch(r){return ct.error("Failed to save buffer:",r),!1}}async restoreBuffer(){try{const e=localStorage.getItem(this.storageKey);if(e){const s=JSON.parse(e);if(this.isValidSnapshot(s))return ct.debug(`Restored buffer for terminal ${this.terminalId}`),s;localStorage.removeItem(this.storageKey)}const i=this.fallbackStorage.get(this.storageKey);return i&&this.isValidSnapshot(i)?i:null}catch(e){return ct.error("Failed to restore buffer:",e),null}}async clearBuffer(){try{localStorage.removeItem(this.storageKey),this.fallbackStorage.delete(this.storageKey),la(this.storageKey)}catch(e){ct.error("Failed to clear buffer:",e)}}trimBuffer(e){for(;e.length>0&&!e[e.length-1].trim();)e.pop();return e.length>$e.MAX_BUFFER_SIZE&&(e=e.slice(-1e4)),e.map(i=>i.length>$e.MAX_LINE_LENGTH?`${i.substring(0,$e.MAX_LINE_LENGTH)}…`:i)}isValidSnapshot(e){return!(e.version!==$e.BUFFER_VERSION||Date.now()-e.timestamp>$e.RETENTION_PERIOD||!Array.isArray(e.lines))}async hasStorageSpace(e){try{const i=JSON.stringify(e).length;if("storage"in navigator&&"estimate"in navigator.storage){const s=await navigator.storage.estimate();return(s.quota||0)-(s.usage||0)>i+$e.STORAGE_QUOTA_BUFFER}return!0}catch{return!0}}async cleanupOldBuffers(){try{const e=[],i=Date.now(),s=En();for(const[r,n]of s)i-n>$e.RETENTION_PERIOD&&e.push(r);for(const r of e)localStorage.removeItem(r),la(r),ct.debug(`Cleaned up old buffer: ${r}`);s.size===0&&await this.rebuildBufferIndex()}catch(e){ct.error("Failed to cleanup old buffers:",e)}}async rebuildBufferIndex(){try{const e=new Map;for(let i=0;i<localStorage.length;i++){const s=localStorage.key(i);if(s?.startsWith("terminal-buffer-")&&s!==Ln)try{const r=localStorage.getItem(s);if(r){const n=JSON.parse(r);e.set(s,n.timestamp)}}catch{}}e.size>0&&(Mn(e),ct.debug(`Rebuilt buffer index with ${e.size} entries`))}catch(e){ct.error("Failed to rebuild buffer index:",e)}}getStats(){try{const e=localStorage.getItem(this.storageKey);if(e){const i=JSON.parse(e);return{size:e.length,lineCount:i.lines.length,age:Date.now()-i.timestamp}}return null}catch{return null}}};P($e,"BUFFER_VERSION",1),P($e,"MAX_BUFFER_SIZE",1e4),P($e,"MAX_LINE_LENGTH",1e3),P($e,"RETENTION_PERIOD",1440*60*1e3),P($e,"STORAGE_QUOTA_BUFFER",100*1024);let Rs=$e;const Pi=new Xi("TerminalThemeManager"),Se=class Se{constructor(e){P(this,"currentTheme");P(this,"customTerminalTheme",null);P(this,"themeObserver",null);P(this,"transitionTimeout",null);P(this,"darkModeQuery",null);P(this,"darkModeChangeHandler",null);P(this,"themeChangeHandler",null);this.container=e,this.currentTheme=this.detectSystemTheme(),this.setContainer(this.container??null),this.setupThemeObserver()}setContainer(e){this.transitionTimeout&&(clearTimeout(this.transitionTimeout),this.transitionTimeout=null),this.container&&this.container!==e&&(this.container.style.transition=""),this.container=e,this.container&&(this.container.style.backgroundColor=this.currentTheme.background||"transparent")}getCurrentTheme(){return this.currentTheme}applyTheme(e,i){const s=i||this.detectSystemTheme();if(s.name!==this.currentTheme.name)try{this.container&&(this.container.style.transition=`background-color ${Se.TRANSITION_DURATION}ms ease`),e.options.theme=s,this.container&&(this.container.style.backgroundColor=s.background||"transparent"),e.refresh(0,e.rows-1),this.currentTheme=s,Pi.debug(`Applied theme: ${s.name}`),this.transitionTimeout&&clearTimeout(this.transitionTimeout),this.transitionTimeout=setTimeout(()=>{this.container&&(this.container.style.transition="")},Se.TRANSITION_DURATION)}catch(r){Pi.error("Failed to apply theme:",r)}}detectSystemTheme(){if(this.customTerminalTheme)return this.customTerminalTheme;const e=document.documentElement.classList.contains("dark"),i=document.documentElement.classList.contains("light");if(e)return Se.DARK_THEME;if(i)return Se.LIGHT_THEME;const s=document.documentElement.getAttribute("data-theme");if(s==="dark")return Se.DARK_THEME;if(s==="light")return Se.LIGHT_THEME;const n=getComputedStyle(document.documentElement).getPropertyValue("--background").trim();return n&&this.isColorDark(n)||Hh.isDark()?Se.DARK_THEME:Se.LIGHT_THEME}isColorDark(e){const i=this.colorToRgb(e);return i?(.299*i.r+.587*i.g+.114*i.b)/255<.5:!1}colorToRgb(e){if(e.startsWith("#")){const s=e.slice(1);if(s.length===3)return{r:parseInt(s[0]+s[0],16),g:parseInt(s[1]+s[1],16),b:parseInt(s[2]+s[2],16)};if(s.length===6)return{r:parseInt(s.slice(0,2),16),g:parseInt(s.slice(2,4),16),b:parseInt(s.slice(4,6),16)}}const i=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);return i?{r:parseInt(i[1]),g:parseInt(i[2]),b:parseInt(i[3])}:null}setupThemeObserver(){typeof window>"u"||(this.themeObserver=new MutationObserver(e=>{for(const i of e)if(i.type==="attributes"){const s=i.attributeName;if(s==="class"||s==="data-theme"){const r=this.detectSystemTheme();r.name!==this.currentTheme.name&&(Pi.debug(`Theme change detected: ${this.currentTheme.name} -> ${r.name}`),Hi("terminal-theme-changed",{theme:r}))}}}),this.themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme"]}),this.darkModeQuery=window.matchMedia("(prefers-color-scheme: dark)"),this.darkModeChangeHandler=()=>{Pi.debug("System theme preference changed");const e=this.detectSystemTheme();e.name!==this.currentTheme.name&&Hi("terminal-theme-changed",{theme:e})},this.darkModeQuery.addEventListener("change",this.darkModeChangeHandler),this.themeChangeHandler=e=>{const i=e.detail?.isDark,s=e.detail?.terminalColors;let r;s&&Object.keys(s).length>0?(r={...i?Se.DARK_THEME:Se.LIGHT_THEME,...s,name:"custom",isDark:i},this.customTerminalTheme=r):(this.customTerminalTheme=null,r=i?Se.DARK_THEME:Se.LIGHT_THEME),(r.name!==this.currentTheme.name||s)&&(Pi.debug(`App theme changed to ${r.name}`),Hi("terminal-theme-changed",{theme:r}))},window.addEventListener("theme-changed",this.themeChangeHandler))}dispose(){this.themeObserver&&(this.themeObserver.disconnect(),this.themeObserver=null),this.darkModeQuery&&this.darkModeChangeHandler&&(this.darkModeQuery.removeEventListener("change",this.darkModeChangeHandler),this.darkModeQuery=null,this.darkModeChangeHandler=null),this.themeChangeHandler&&(window.removeEventListener("theme-changed",this.themeChangeHandler),this.themeChangeHandler=null),this.transitionTimeout&&(clearTimeout(this.transitionTimeout),this.transitionTimeout=null),this.setContainer(null)}};P(Se,"TRANSITION_DURATION",200),P(Se,"DARK_THEME",{name:"sleek-dark",isDark:!0,background:"#0B0B0E",foreground:"#e4e4e7",cursor:"#fbbf24",cursorAccent:"#1a1a1a",selectionBackground:"#3f3f46",selectionForeground:"#F7F7F7",selectionInactiveBackground:"#27272a",black:"#18181b",red:"#ef4444",green:"#22c55e",yellow:"#eab308",blue:"#3b82f6",magenta:"#a855f7",cyan:"#06b6d4",white:"#d4d4d8",brightBlack:"#52525b",brightRed:"#f87171",brightGreen:"#4ade80",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#c084fc",brightCyan:"#22d3ee",brightWhite:"#f4f4f5"}),P(Se,"LIGHT_THEME",{name:"sleek-light",isDark:!1,background:"#F7F7F8",foreground:"#18181b",cursor:"#f59e0b",cursorAccent:"#F7F7F7",selectionBackground:"#e4e4e7",selectionForeground:"#09090b",selectionInactiveBackground:"#f4f4f5",black:"#18181b",red:"#dc2626",green:"#16a34a",yellow:"#ca8a04",blue:"#2563eb",magenta:"#9333ea",cyan:"#0891b2",white:"#e4e4e7",brightBlack:"#71717a",brightRed:"#ef4444",brightGreen:"#22c55e",brightYellow:"#eab308",brightBlue:"#3b82f6",brightMagenta:"#a855f7",brightCyan:"#06b6d4",brightWhite:"#F7F7F7"});let hn=Se;const Yt=Uh("TerminalHistoryTracker"),Jt=class Jt{constructor(){P(this,"histories",new Map);P(this,"MAX_HISTORY_SIZE",10);P(this,"MAX_OUTPUT_LENGTH",500);P(this,"STORAGE_PREFIX","terminal-history-");P(this,"_updateCounter",zh(0));P(this,"updateCounter",{subscribe:this._updateCounter.subscribe});this.loadHistories()}notifyUpdate(){this._updateCounter.update(e=>e+1)}static getInstance(){return Jt.instance||(Jt.instance=new Jt),Jt.instance}getOrCreateHistory(e,i){let s=this.histories.get(e);return s||(s={terminalId:e,workspaceId:i,commands:[],currentOutput:"",isExecuting:!1},this.histories.set(e,s)),s}onCommandStart(e,i,s){const r=this.getOrCreateHistory(e,i),n=Wt(s);r.currentCommand=n,r.currentOutput="",r.isExecuting=!0,r.lastCommand=n,this.notifyUpdate(),Yt.debug(`Command started for terminal ${e}: ${n}`)}onOutput(e,i,s){const r=this.getOrCreateHistory(e,i);r.currentOutput.length<this.MAX_OUTPUT_LENGTH&&(r.currentOutput+=s,r.currentOutput.length>this.MAX_OUTPUT_LENGTH&&(r.currentOutput=`${r.currentOutput.substring(0,this.MAX_OUTPUT_LENGTH)}...`))}onCommandFinish(e,i){const s=this.getOrCreateHistory(e,i);if(s.currentCommand){const r=Wt(s.currentCommand),n={command:r,timestamp:Date.now(),output:s.currentOutput};s.commands.push(n),s.commands.length>this.MAX_HISTORY_SIZE&&(s.commands=s.commands.slice(-this.MAX_HISTORY_SIZE)),s.lastCommand=r,s.lastOutput=s.currentOutput,this.saveHistory(e,s),Yt.debug(`Command finished for terminal ${e}: ${r}`)}s.currentCommand=void 0,s.currentOutput="",s.isExecuting=!1,this.notifyUpdate()}getHistory(e){return this.histories.get(e)}getHistoriesForWorkspace(e){return Array.from(this.histories.values()).filter(i=>i.workspaceId===e)}getLastCommand(e){return this.histories.get(e)?.lastCommand}getLastOutput(e){return this.histories.get(e)?.lastOutput}saveHistory(e,i){try{const s=`${this.STORAGE_PREFIX}${e}`,r={terminalId:i.terminalId,workspaceId:i.workspaceId,commands:i.commands.slice(-5).map(n=>({...n,command:Wt(n.command)})),lastCommand:i.lastCommand?Wt(i.lastCommand):void 0,lastOutput:i.lastOutput?.substring(0,200)};localStorage.setItem(s,JSON.stringify(r))}catch(s){Yt.warn("Failed to save terminal history:",s)}}loadHistories(){try{const e=Object.keys(localStorage).filter(i=>i.startsWith(this.STORAGE_PREFIX));for(const i of e)try{const s=localStorage.getItem(i);if(s){const r=JSON.parse(s);r.terminalId&&this.histories.set(r.terminalId,{...r,currentOutput:"",isExecuting:!1,commands:r.commands||[]})}}catch(s){Yt.warn(`Failed to load terminal history for ${i}:`,s)}Yt.info(`Loaded ${this.histories.size} terminal histories from localStorage`)}catch(e){Yt.error("Failed to load terminal histories:",e)}}clearHistory(e){this.histories.delete(e);try{localStorage.removeItem(`${this.STORAGE_PREFIX}${e}`)}catch(i){Yt.warn("Failed to clear terminal history:",i)}}clearWorkspaceHistories(e){const i=[];for(const[s,r]of this.histories.entries())r.workspaceId===e&&i.push(s);for(const s of i)this.clearHistory(s)}};P(Jt,"instance");let ln=Jt;const Oi=ln.getInstance();function Pf(t,e){return setTimeout(()=>{try{t.dispose()}catch(i){if(e)e(i);else throw i}},0)}const Of=["panel.focus-next-column","panel.focus-previous-column","global.next-space-alt","global.previous-space-alt","navigation.go-to-tab","navigation.recent-agents"];function If(t,e,i,s=!1){const r=o=>An(o,e),n=s?r("navigation.go-to-device"):An("navigation.go-to-tab",e)===Pn["navigation.go-to-tab"]?Pn["navigation.go-to-device"]:null;return n&&On(t,n,i)>=0&&!In("navigation.go-to-device",t,r,i)?!0:Of.some(o=>On(t,r(o),i)>=0&&(o!=="navigation.go-to-tab"||!In(o,t,r,i)))}const $f=Df,I=new Xi("TerminalAdapter"),Ff=typeof process<"u"&&process.platform==="win32",Nf=100,Ae=class Ae{constructor(e){P(this,"xterm");P(this,"fitAddon");P(this,"searchAddon");P(this,"webLinksAddon");P(this,"webglAddon",null);P(this,"stateMachine");P(this,"bufferManager");P(this,"themeManager");P(this,"terminalId");P(this,"workspaceId");P(this,"container");P(this,"eventListeners",[]);P(this,"resizeObserver",null);P(this,"reattachFitObserver",null);P(this,"reattachFitTimer",null);P(this,"visibilityObserver",null);P(this,"wasVisible",!0);P(this,"isVisible",!0);P(this,"lastFittedSize",null);P(this,"resizeDebounceTimer",null);P(this,"bufferSaveTimer",null);P(this,"dataDisposable",null);P(this,"resizeDisposable",null);P(this,"selectionDisposable",null);P(this,"ipcCleanup",null);P(this,"themeCleanup",null);P(this,"webglContextLostCleanup",null);P(this,"isDisposed",!1);P(this,"isXtermOpened",!1);P(this,"autoReconnectTimer",null);P(this,"autoReconnectAttempts",0);P(this,"heartbeatTimer",null);P(this,"webglRecoveryAttempts",0);P(this,"exitedNormally",!1);P(this,"lastCwd");P(this,"isExecuting",!1);P(this,"startTime",Date.now());P(this,"commandBuffer","");P(this,"currentLineBuffer","");P(this,"isAtPrompt",!1);P(this,"callbacks");P(this,"terminals");this.workspaceId=e.workspaceId,this.terminalId=e.terminalId||`terminal-${Date.now()}-${Math.random().toString(36).substring(2,11)}`,this.container=e.container,this.terminals=(e.appClient??Wh).terminals,this.callbacks={onReady:e.onReady,onExit:e.onExit,onCommandStart:e.onCommandStart,onCommandFinished:e.onCommandFinished,onCwdChanged:e.onCwdChanged,onError:e.onError,onToggleSearch:e.onToggleSearch},this.stateMachine=new Bf(this.terminalId),this.setupStateMachineListeners(),this.bufferManager=new Rs(this.workspaceId,this.terminalId),this.themeManager=new hn(this.container);const i=e.fontFamily??jh.select(_t.state);this.xterm=new au({allowProposedApi:!0,linkHandler:{activate:(s,r)=>this.handleLinkClick(r)},fontFamily:i,fontSize:13,lineHeight:1.2,letterSpacing:0,cursorBlink:!0,cursorStyle:"block",cursorWidth:1,scrollback:1e4,allowTransparency:!0,windowsPty:Ff?{backend:"conpty"}:void 0,macOptionIsMeta:!0,rightClickSelectsWord:!0,convertEol:!0,drawBoldTextInBrightColors:!0,scrollSensitivity:1,theme:this.themeManager.getCurrentTheme()}),this.fitAddon=new cu,this.xterm.loadAddon(this.fitAddon),this.webLinksAddon=new pu((s,r)=>{this.handleLinkClick(r)}),this.xterm.loadAddon(this.webLinksAddon),this.searchAddon=new $f,this.xterm.loadAddon(this.searchAddon),this.searchAddon.onDidChangeResults(s=>{this.callbacks.onSearchResultsChange?.(s.resultIndex,s.resultCount)})}getSearchDecorations(){return{matchBackground:"#515c6a",matchBorder:"#515c6a",matchOverviewRuler:"#515c6a",activeMatchBackground:"#eab308",activeMatchBorder:"#ca8a04",activeMatchColorOverviewRuler:"#eab308"}}setupStateMachineListeners(){this.stateMachine.onTransition((e,i)=>{i===et.ERROR&&this.handleError(new Error(`Terminal entered error state from ${e}`)),(i===et.DISCONNECTED||i===et.ERROR)&&(this.stopHeartbeat(),this.exitedNormally||this.scheduleAutoReconnect()),i===et.CONNECTED&&(this.autoReconnectAttempts=0,this.cancelAutoReconnect(),this.startHeartbeat())}),this.stateMachine.onError(e=>{this.handleError(e)})}async initialize(e=!1){if(this.isDisposed)throw new Error("Cannot initialize disposed terminal");if(!this.container)throw new Error("Cannot initialize terminal without a container");const i=this.container;if(!this.stateMachine.canTransition("initialize"))throw new Error(`Cannot initialize terminal in state ${this.stateMachine.getState()}`);this.stateMachine.transition("initialize");try{this.isXtermOpened?I.warn(`[initialize] XTerm already opened for terminal ${this.terminalId}, skipping open()`):(this.xterm.open(i),this.isXtermOpened=!0,I.info(`[initialize] XTerm opened for terminal ${this.terminalId}`)),this.themeManager.getCurrentTheme().isDark?this.loadWebglAddon():I.debug("[Renderer] Using Canvas renderer for light theme (better anti-aliasing)"),this.themeManager.applyTheme(this.xterm),this.fitTerminalToContainer()||(I.warn("Container has no dimensions, delaying fit"),setTimeout(()=>{this.fitTerminalToContainer()},100)),this.setupResizeObserver(),this.setupXTermEventHandlers(),this.setupThemeChangeListener();const r=this.xterm.cols,n=this.xterm.rows,o=await this.findBackendTerminal(),a=o!==null;if(!e)if(a)try{const l=await this.terminals.getBuffer(this.terminalId,void 0,this.workspaceId);l&&(I.info(`Restoring ${l.length} bytes of buffered output from backend`),this.xterm.write(l),this.parseTerminalOutput(l))}catch(l){I.warn("Could not restore terminal buffer from backend:",l)}else{const l=await this.bufferManager.restoreBuffer();l&&(I.info("Restoring terminal buffer from local storage"),this.restoreFromSnapshot(l))}this.startBufferAutoSave(),this.stateMachine.transition("connect"),a?(this.setupIpcEventHandlers(),this.stateMachine.transition("connected"),this.resize(r,n),o?.isExecuting===!1&&this.hideCursorOnExit(),this.callbacks.onReady?.()):(I.debug(`[initialize] Terminal ${this.terminalId} creating new PTY`),await this.openPtyConnection(r,n)),requestAnimationFrame(()=>{!this.isDisposed&&this.isVisible&&this.xterm.focus()})}catch(s){throw this.stateMachine.reportError(s),s}}async openPtyConnection(e,i){try{const s=await this.terminals.create({workspaceId:this.workspaceId,cols:e,rows:i});if(!s.success)throw new Error(s.error||$s.terminal_adapter_openFailed_error());s.id&&(this.terminalId=s.id),this.setupIpcEventHandlers(),this.stateMachine.transition("connected"),this.restoreCursor(),this.callbacks.onReady?.()}catch(s){throw this.stateMachine.reportError(s),s}}async findBackendTerminal(){try{const{terminals:e}=await this.terminals.list(this.workspaceId);return e.find(i=>i.id===this.terminalId)??null}catch(e){return I.warn("Could not check terminal existence:",e),null}}async terminalExistsOnBackend(){return await this.findBackendTerminal()!==null}hideCursorOnExit(){this.isDisposed||(this.xterm.options.cursorBlink=!1,this.xterm.write("\x1B[?25l"))}restoreCursor(){this.isDisposed||(this.xterm.options.cursorBlink=!0,this.xterm.write("\x1B[?25h"))}setupXTermEventHandlers(){this.container&&(this.dataDisposable&&(this.dataDisposable.dispose(),this.dataDisposable=null),this.resizeDisposable&&(this.resizeDisposable.dispose(),this.resizeDisposable=null),this.selectionDisposable&&(this.selectionDisposable.dispose(),this.selectionDisposable=null),this.xterm.attachCustomKeyEventHandler(e=>{const i=navigator.platform.toUpperCase().includes("MAC"),s=i?e.metaKey:e.ctrlKey;return e.metaKey&&e.key==="k"&&!e.ctrlKey&&!e.shiftKey&&!e.altKey?(e.type==="keydown"&&this.clear(),!1):s&&e.key==="j"&&!e.shiftKey&&!e.altKey?(e.type==="keydown"&&_t.dispatch(Bn(this.workspaceId)),!1):s&&e.key==="f"&&!e.shiftKey&&!e.altKey?(e.type==="keydown"&&this.callbacks.onToggleSearch?.(),!1):s&&(e.key==="t"||e.key==="T")&&!e.shiftKey&&!e.altKey?(e.type==="keydown"&&Hi("workspace:new-terminal",{workspaceId:this.workspaceId}),!1):s&&(e.key==="w"||e.key==="W")&&!e.shiftKey&&!e.altKey?(e.type==="keydown"&&_t.dispatch(qh(this.workspaceId)),!1):If(e,_t.state.userPreferences?.shortcutOverrides??{},i,_t.state.machineRail?.enabled??!1)||s&&e.shiftKey&&!e.altKey&&(e.key==="]"||e.key==="}"||e.key==="["||e.key==="{")?!1:e.ctrlKey&&!e.metaKey&&!e.altKey&&(e.key==="`"||e.key==="~")?(e.type==="keydown"&&(e.shiftKey||e.key==="~"?Hi("workspace:new-terminal",{workspaceId:this.workspaceId}):_t.dispatch(Bn(this.workspaceId))),!1):!0}),this.dataDisposable=this.xterm.onData(e=>{this.isDisposed||this.write(e)}),this.resizeDisposable=this.xterm.onResize(({cols:e,rows:i})=>{!this.isDisposed&&this.stateMachine.canAcceptInput()&&this.resize(e,i)}),this.selectionDisposable=this.xterm.onSelectionChange(()=>{}))}setupIpcEventHandlers(){this.ipcCleanup&&(this.ipcCleanup(),this.ipcCleanup=null);let e=!1;const i=this.terminals.subscribeEvents(this.terminalId,{onData:({chunk:s})=>{e||this.isDisposed||this.stateMachine.canAcceptInput()&&(this.xterm.write(s),this.parseTerminalOutput(s))},onExit:({exitCode:s})=>{e||this.isDisposed||(this.exitedNormally=!0,this.hideCursorOnExit(),this.callbacks.onExit?.(s),this.stateMachine.transition("disconnect"))},onCwd:({cwd:s})=>{e||this.isDisposed||(this.lastCwd=s,this.callbacks.onCwdChanged?.(s))}},this.workspaceId);this.ipcCleanup=()=>{e=!0;try{i()}catch(s){I.warn("Failed to unsubscribe terminal events:",s)}}}setupResizeObserver(){if(!this.container||!this.isVisible)return;const e=this.container;this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.resizeDebounceTimer&&(clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=null),this.resizeObserver=new ResizeObserver(()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=setTimeout(()=>{this.fitTerminalToContainer()},100)}),this.resizeObserver.observe(e),this.setupVisibilityObserver()}setupVisibilityObserver(){if(!this.container)return;const e=this.container;this.visibilityObserver&&(this.visibilityObserver.disconnect(),this.visibilityObserver=null),this.visibilityObserver=new IntersectionObserver(i=>{for(const s of i){const r=s.isIntersecting;r&&!this.wasVisible&&(I.debug(`[visibility] Terminal ${this.terminalId} became visible, reconnecting ResizeObserver`),this.resizeObserver||(this.resizeObserver=new ResizeObserver(()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=setTimeout(()=>{this.fitTerminalToContainer()},100)}),this.resizeObserver.observe(e)),this.fitTerminalToContainer()),this.wasVisible=r}}),this.visibilityObserver.observe(e)}loadWebglAddon(){this.disposeWebglAddon();try{this.webglAddon=new Z_,this.xterm.loadAddon(this.webglAddon);const e=this.xterm.element?.querySelector("canvas");if(e){const i=s=>{s.preventDefault(),I.warn(`[WebGL] Context lost for terminal ${this.terminalId}, recovering...`),!this.isDisposed&&(this.disposeWebglAddon(),setTimeout(()=>{if(this.isDisposed)return;if(!this.themeManager.getCurrentTheme().isDark){I.info("[WebGL] Skipping WebGL recovery on light theme, using Canvas renderer");return}if(this.webglRecoveryAttempts>=Ae.MAX_WEBGL_RECOVERY_ATTEMPTS){I.warn(`[WebGL] Max recovery attempts (${Ae.MAX_WEBGL_RECOVERY_ATTEMPTS}) reached for terminal ${this.terminalId}, staying on Canvas renderer`);return}this.webglRecoveryAttempts++;try{this.loadWebglAddon(),I.info(`[WebGL] Successfully recovered from context loss (attempt ${this.webglRecoveryAttempts})`)}catch(n){I.warn("[WebGL] Failed to recover from context loss, falling back to Canvas renderer:",n),this.webglAddon=null}},100))};e.addEventListener("webglcontextlost",i),this.webglContextLostCleanup=()=>{e.removeEventListener("webglcontextlost",i)}}}catch(e){I.warn("Failed to load WebGL renderer, falling back to Canvas renderer:",e),this.webglAddon=null}}disposeWebglAddon(){if(this.webglContextLostCleanup&&(this.webglContextLostCleanup(),this.webglContextLostCleanup=null),this.webglAddon){try{this.webglAddon.dispose()}catch(e){I.warn("Error disposing WebGL addon:",e)}this.webglAddon=null}}setupThemeChangeListener(){this.themeCleanup&&(this.themeCleanup(),this.themeCleanup=null);const e=i=>{const s=i.detail?.theme;s&&this.xterm&&(I.info(`[Theme] Theme changed to: ${s.name} (isDark: ${s.isDark})`),this.themeManager.applyTheme(this.xterm,s),s.isDark?this.webglAddon||this.loadWebglAddon():this.webglAddon&&(this.disposeWebglAddon(),I.info("[WebGL] Disposed WebGL addon for light theme (using Canvas renderer)")))};window.addEventListener("terminal-theme-changed",e),this.themeCleanup=()=>{window.removeEventListener("terminal-theme-changed",e)}}parseTerminalOutput(e){Oi.onOutput(this.terminalId,this.workspaceId,e),e.includes("\x1B]133;C\x07")?(this.isExecuting&&(this.isExecuting=!1,this.callbacks.onCommandFinished?.(),Oi.onCommandFinish(this.terminalId,this.workspaceId)),this.commandBuffer="",this.isAtPrompt=!0):e.includes("\x1B]133;A\x07")&&(this.isExecuting||(this.isExecuting=!0,this.callbacks.onCommandStart?.()),this.isAtPrompt=!0,this.commandBuffer="");const i=/[\$%]\s*$/,s=/^.*[\$%]\s+(.+)$/,r=e.split(/\r?\n/);for(const o of r){const a=o.replace(/\x1b\[[0-9;?]*[a-zA-Z]/g,"").replace(/\x1b\][^\x07]*\x07/g,"").replace(/\x1b\][^\x1b]*\x1b\\/g,"").replace(/\x1b[()][AB0-2]/g,"").replace(/\x1b[=>]/g,"").replace(/\x1b[78]/g,"").replace(/\x1b[DME]/g,"").replace(/\x1b[HZ]/g,"").replace(/\x1b[c]/g,"").replace(/\[\?[0-9;]*[a-zA-Z]/g,"").replace(/\x07/g,"").replace(/\x00-\x08\x0b\x0c\x0e-\x1f/g,"").trim();if(!a||/^\[[\?0-9;]*[a-zA-Z]$/.test(a))continue;const l=a.match(s);if(l&&l[1]){const h=l[1].trim(),c=/^[a-zA-Z0-9.\/~]/.test(h);h.length>0&&!this.isExecuting&&c?(I.info(`[TerminalAdapter] Detected command from output: ${Wt(h)}`),Oi.onCommandStart(this.terminalId,this.workspaceId,h),this.isExecuting=!0,this.callbacks.onCommandStart?.()):h.length>0&&!c&&I.debug(`[TerminalAdapter] Skipping suspicious command detection: ${Wt(h)}`)}i.test(a)&&!l&&(this.isExecuting&&(this.isExecuting=!1,this.callbacks.onCommandFinished?.(),Oi.onCommandFinish(this.terminalId,this.workspaceId),I.debug(`[TerminalAdapter] Command finished, prompt detected: ${Wt(a)}`)),this.isAtPrompt=!0,this.commandBuffer="")}const n=e.match(/\x1b\]7;file:\/\/[^/]*([^\x07]*)\x07/);if(n){const o=decodeURIComponent(n[1]);o!==this.lastCwd&&(this.lastCwd=o,this.callbacks.onCwdChanged?.(o))}}startBufferAutoSave(){this.bufferSaveTimer=setInterval(()=>{this.stateMachine?.canAcceptInput()&&this.saveBuffer()},5e3)}async saveBuffer(){try{const e=this.xterm.buffer.active,i=[];for(let s=0;s<e.length;s++){const r=e.getLine(s);r&&i.push(r.translateToString(!0))}await this.bufferManager.saveBuffer(i,e.cursorX,e.cursorY)}catch(e){I.error("Failed to save buffer:",e)}}restoreFromSnapshot(e){if(e.lines&&e.lines.length>0){this.xterm.clear();const i=[...e.lines];for(;i.length>0&&i[i.length-1].trim()==="";)i.pop();const s=/[\$>#%]\s*$/,r=/@[\w-]+/;if(i.length>0){const n=i[i.length-1],o=i.length>1?i[i.length-2]:"";if(s.test(n)&&r.test(n))i.pop();else if(s.test(n)&&n.trim().length<80)i.pop(),i.length>0&&r.test(i[i.length-1])&&i.pop();else if(i.length>=2){const a=o+n;s.test(a)&&r.test(a)&&(i.pop(),i.pop())}}for(let n=0;n<i.length;n++)n<i.length-1?this.xterm.writeln(i[n]):i[n].trim()&&this.xterm.writeln(i[n]);I.debug(`Restored terminal buffer for ${this.terminalId} with ${i.length} lines (prompt removed)`)}}getCommandFromXtermBuffer(){try{const e=this.xterm.buffer.active,i=e.cursorY+e.baseY,s=e.getLine(i);if(!s)return null;const r=s.translateToString(!0);if(!r||!r.trim())return null;const n=r.replace(/\x1b\[[0-9;?]*[a-zA-Z]/g,"").replace(/\x1b\][^\x07]*\x07/g,"").replace(/\x1b[()][AB0-2]/g,"").replace(/\x07/g,"").trim();if(!n)return null;const o=n.match(/^.*[\$%#❯➜]\s+(.+)$/);return o&&o[1]?o[1].trim():null}catch{return null}}write(e){if(!(this.isDisposed||!this.stateMachine.canAcceptInput())){if(e==="\r"||e===`
142
142
  `){const i=this.getCommandFromXtermBuffer(),s=i||this.commandBuffer.trim();s&&(Oi.onCommandStart(this.terminalId,this.workspaceId,s),this.isExecuting=!0,I.debug(`Command executed: ${Wt(s)}${i?" (from xterm buffer)":" (from keystroke buffer)"}`)),this.commandBuffer="",this.currentLineBuffer=""}else e===""||e==="\b"?this.commandBuffer.length>0&&(this.commandBuffer=this.commandBuffer.slice(0,-1)):e===""?(this.commandBuffer="",this.currentLineBuffer=""):e===""?(this.commandBuffer="",this.currentLineBuffer=""):e.match(/[\x00-\x1F\x7F]/)||(this.commandBuffer+=e,this.currentLineBuffer+=e);this.terminals.write(this.terminalId,e,this.workspaceId).then(i=>{i.success||I.error(`[write] Terminal ${this.terminalId}: write failed - ${i.error}`)}).catch(i=>{I.error(`[write] Terminal ${this.terminalId}: transport error - ${i}`),this.isDisposed||this.stateMachine.reportError(i)})}}resize(e,i){this.isDisposed||!this.stateMachine.canAcceptInput()||this.terminals.resize(this.terminalId,e,i,this.workspaceId).catch(s=>{I.error("Failed to resize terminal:",s)})}focus(){!this.isDisposed&&this.isVisible&&this.xterm.focus()}blur(){this.isDisposed||this.xterm.blur()}setVisible(e){if(!(this.isDisposed||this.isVisible===e)){if(this.isVisible=e,this.wasVisible=e,!e){this.xterm.blur(),this.disconnectLayoutObservers();return}this.setupResizeObserver(),requestAnimationFrame(()=>this.fitTerminalToContainer())}}fitTerminalToContainer(){if(this.isDisposed||!this.isVisible||!this.container)return!1;const{width:e,height:i}=this.container.getBoundingClientRect();return e<=0||i<=0?!1:(this.lastFittedSize?.width===e&&this.lastFittedSize.height===i||(this.fitAddon.fit(),this.lastFittedSize={width:e,height:i}),!0)}disconnectLayoutObservers(){this.resizeObserver?.disconnect(),this.resizeObserver=null,this.visibilityObserver?.disconnect(),this.visibilityObserver=null,this.resizeDebounceTimer&&(clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=null)}fitAfterReattach(e){if(this.cancelReattachFit(),this.fitReattachedContainer(e))return;const i=new ResizeObserver(()=>{if(this.reattachFitObserver!==i){i.disconnect();return}this.hasReattachedContainerBox(e)&&(this.reattachFitTimer&&clearTimeout(this.reattachFitTimer),this.reattachFitTimer=setTimeout(()=>{this.reattachFitTimer=null,this.fitReattachedContainer(e)&&this.cancelReattachFit()},Nf))});this.reattachFitObserver=i,i.observe(e)}fitReattachedContainer(e){if(this.isDisposed||this.container!==e)return!0;if(!this.hasReattachedContainerBox(e))return!1;const{width:i,height:s}=e.getBoundingClientRect();return this.fitAddon.fit(),this.lastFittedSize={width:i,height:s},this.xterm.refresh(0,this.xterm.rows-1),!0}hasReattachedContainerBox(e){if(!this.isVisible)return!1;const{width:i,height:s}=e.getBoundingClientRect();return i>0&&s>0}cancelReattachFit(){this.reattachFitObserver?.disconnect(),this.reattachFitObserver=null,this.reattachFitTimer&&(clearTimeout(this.reattachFitTimer),this.reattachFitTimer=null)}clear(){this.isDisposed||this.xterm.clear()}async reattach(e){if(this.isDisposed||this.stateMachine.isDisposed())throw new Error("Cannot reattach disposed terminal");this.cancelAutoReconnect(),this.autoReconnectAttempts=0,this.webglRecoveryAttempts=0,this.exitedNormally=!1,this.setupIpcEventHandlers();const i=this.stateMachine.getState();if(i!==et.CONNECTED){I.info(`[reattach] Terminal ${this.terminalId} not in CONNECTED state (${i}), attempting to restore`);const n=await this.findBackendTerminal();n&&(i===et.DISCONNECTED||i===et.ERROR?(this.stateMachine.transition("reconnect"),this.stateMachine.transition("reconnected")):i===et.CONNECTING&&this.stateMachine.transition("connected"),n.isExecuting===!1&&this.hideCursorOnExit(),I.info(`[reattach] Terminal ${this.terminalId} state restored to ${this.stateMachine.getState()}`))}const s=this.xterm.element;if(s){e.appendChild(s),this.container=e,this.themeManager.setContainer(e),this.disposeWebglAddon(),this.themeManager.applyTheme(this.xterm),this.themeManager.getCurrentTheme().isDark?this.loadWebglAddon():I.debug("[Renderer] Using Canvas renderer after move (light theme)"),this.fitAfterReattach(e),this.setupResizeObserver(),this.setupXTermEventHandlers(),this.commandBuffer="",this.currentLineBuffer="",this.isAtPrompt=!1,this.startHeartbeat(),requestAnimationFrame(()=>{!this.isDisposed&&this.isVisible&&this.xterm.focus()});return}I.warn(`Could not move terminal element, recreating for terminal ${this.terminalId}`),this.container&&(this.container.innerHTML=""),this.disposeWebglAddon(),this.dataDisposable&&(this.dataDisposable.dispose(),this.dataDisposable=null),this.container=e,this.themeManager.setContainer(e),this.isXtermOpened&&I.warn(`[reattach] XTerm was already opened for terminal ${this.terminalId}, calling open() again may cause duplicate handlers`),this.xterm.open(e),this.isXtermOpened=!0,this.themeManager.applyTheme(this.xterm),this.themeManager.getCurrentTheme().isDark?this.loadWebglAddon():I.debug("[Renderer] Using Canvas renderer on reattach (light theme)"),this.fitAfterReattach(e),this.setupXTermEventHandlers(),this.setupResizeObserver(),this.commandBuffer="",this.currentLineBuffer="",this.isAtPrompt=!1,this.startHeartbeat(),requestAnimationFrame(()=>{!this.isDisposed&&this.isVisible&&this.xterm.focus()})}updateCallbacks(e){Object.assign(this.callbacks,e)}updateFontFamily(e){this.isDisposed||this.xterm.options.fontFamily!==e&&(this.xterm.options.fontFamily=e)}findNext(e,i){return this.searchAddon.findNext(e,{caseSensitive:i?.caseSensitive??!1,wholeWord:i?.wholeWord??!1,regex:i?.regex??!1,incremental:!1,decorations:this.getSearchDecorations()})}findPrevious(e,i){return this.searchAddon.findPrevious(e,{caseSensitive:i?.caseSensitive??!1,wholeWord:i?.wholeWord??!1,regex:i?.regex??!1,incremental:!1,decorations:this.getSearchDecorations()})}clearSearch(){this.searchAddon.clearDecorations()}getSelection(){return this.xterm.getSelection()}getInfo(){const e=this.bufferManager.getStats();return{id:this.terminalId,workspaceId:this.workspaceId,state:this.stateMachine.getState(),cwd:this.lastCwd,isExecuting:this.isExecuting,stats:e?{bufferSize:e.size,lineCount:e.lineCount,uptime:Date.now()-this.startTime}:void 0}}startHeartbeat(){this.heartbeatTimer||this.isDisposed||(I.debug(`[heartbeat] Starting for terminal ${this.terminalId} (every ${Ae.HEARTBEAT_INTERVAL_MS}ms)`),this.heartbeatTimer=setInterval(()=>{this.performHealthCheck()},Ae.HEARTBEAT_INTERVAL_MS))}stopHeartbeat(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null,I.debug(`[heartbeat] Stopped for terminal ${this.terminalId}`))}async performHealthCheck(){if(this.isDisposed||!this.ipcCleanup||this.stateMachine.getState()!==et.CONNECTED)return;let e=null;try{const i=await Promise.race([this.terminalExistsOnBackend(),new Promise((s,r)=>{e=setTimeout(()=>r(new Error("Heartbeat timeout")),Ae.HEARTBEAT_TIMEOUT_MS)})]);if(e&&clearTimeout(e),this.isDisposed)return;i||(I.warn(`[heartbeat] Terminal ${this.terminalId}: PTY not found on backend, transitioning to DISCONNECTED`),this.stopHeartbeat(),this.stateMachine.transition("disconnect"))}catch(i){if(e&&clearTimeout(e),this.isDisposed)return;I.warn(`[heartbeat] Terminal ${this.terminalId}: health check failed:`,i),this.stopHeartbeat(),this.stateMachine.transition("disconnect")}}scheduleAutoReconnect(){if(this.isDisposed)return;if(this.autoReconnectAttempts>=Ae.MAX_RECONNECT_ATTEMPTS){I.warn(`[auto-reconnect] Terminal ${this.terminalId}: max reconnect attempts (${Ae.MAX_RECONNECT_ATTEMPTS}) reached, giving up`);return}this.cancelAutoReconnect();const e=Ae.BASE_RECONNECT_DELAY_MS*Math.pow(2,this.autoReconnectAttempts);this.autoReconnectAttempts++,I.info(`[auto-reconnect] Terminal ${this.terminalId}: scheduling attempt ${this.autoReconnectAttempts}/${Ae.MAX_RECONNECT_ATTEMPTS} in ${e}ms`),this.autoReconnectTimer=setTimeout(()=>{this.autoReconnectTimer=null,this.attemptAutoReconnect()},e)}cancelAutoReconnect(){this.autoReconnectTimer&&(clearTimeout(this.autoReconnectTimer),this.autoReconnectTimer=null)}async attemptAutoReconnect(){if(this.isDisposed)return;const e=this.stateMachine.getState();if(e!==et.DISCONNECTED&&e!==et.ERROR){I.debug(`[auto-reconnect] Terminal ${this.terminalId}: skipping, state is ${e}`);return}this.exitedNormally=!1,I.info(`[auto-reconnect] Terminal ${this.terminalId}: attempting reconnect (attempt ${this.autoReconnectAttempts})`);try{const i=await this.findBackendTerminal();if(this.isDisposed)return;i?(I.info(`[auto-reconnect] Terminal ${this.terminalId}: PTY exists on backend, re-establishing connection`),this.setupIpcEventHandlers(),this.stateMachine.transition("reconnect"),this.stateMachine.transition("reconnected"),this.xterm.cols&&this.xterm.rows&&this.resize(this.xterm.cols,this.xterm.rows),i.isExecuting===!1&&this.hideCursorOnExit(),this.callbacks.onReady?.(),I.info(`[auto-reconnect] Terminal ${this.terminalId}: reconnected successfully`)):(I.info(`[auto-reconnect] Terminal ${this.terminalId}: PTY not found, creating new PTY`),await this.reconnect(),I.info(`[auto-reconnect] Terminal ${this.terminalId}: new PTY created successfully`))}catch(i){I.error(`[auto-reconnect] Terminal ${this.terminalId}: attempt ${this.autoReconnectAttempts} failed:`,i),this.scheduleAutoReconnect()}}handleError(e){I.error(`Terminal ${this.terminalId} error:`,e),this.callbacks.onError?.(e),this.isDisposed||this.xterm.writeln(`\r
143
143
  \x1B[31m${$s.terminal_adapter_errorLine_label({message:e.message})}\x1B[0m\r
144
- `)}handleLinkClick(e){try{if(Kh(e)||this.workspaceId===Vh){I.debug("Opening terminal link in external browser",{uri:e,workspaceId:this.workspaceId}),Fs("shell:openExternal",{url:e});return}Dn(async()=>{const{resolveBrowserLinkForOpen:i}=await import("./DyHx5QFY.js").then(s=>s.b);return{resolveBrowserLinkForOpen:i}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]),import.meta.url).then(({resolveBrowserLinkForOpen:i})=>i(e)).catch(()=>({url:e})).then(i=>{Dn(async()=>{const{getPanelLayoutManager:s}=await import("./CwTWayd0.js").then(r=>r.p);return{getPanelLayoutManager:s}},__vite__mapDeps([32,21,22,5,23,24,3,8,4,25,15,2,33]),import.meta.url).then(({getPanelLayoutManager:s})=>{s(this.workspaceId).openBrowserPanel(i.url,void 0,void 0,i.requestedUrl),I.debug("Opened URL in browser panel",{uri:e,resolvedUrl:i.url,workspaceId:this.workspaceId})}).catch(s=>{I.warn("Failed to open URL in browser panel, falling back to external browser",{uri:e,error:s}),Fs("shell:openExternal",{url:i.url})})})}catch(i){I.warn("Failed to handle link click",{uri:e,error:i}),Fs("shell:openExternal",{url:e})}}async reconnect(){if(this.isDisposed)throw new Error("Cannot reconnect disposed terminal");if(!this.stateMachine.canTransition("reconnect"))throw new Error(`Cannot reconnect in state ${this.stateMachine.getState()}`);this.exitedNormally=!1,this.stateMachine.transition("reconnect");try{const e=this.xterm.cols,i=this.xterm.rows,s=await this.terminals.create({workspaceId:this.workspaceId,cols:e,rows:i});if(!s.success)throw new Error(s.error||$s.terminal_adapter_reconnectFailed_error());s.id&&(this.terminalId=s.id),this.setupIpcEventHandlers(),this.stateMachine.transition("reconnected"),this.restoreCursor(),this.callbacks.onReady?.()}catch(e){throw this.stateMachine.reportError(e),e}}detach(){this.ipcCleanup&&(this.ipcCleanup(),this.ipcCleanup=null),this.stopHeartbeat(),this.cancelAutoReconnect(),this.cancelReattachFit(),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.visibilityObserver&&(this.visibilityObserver.disconnect(),this.visibilityObserver=null),this.resizeDebounceTimer&&(clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=null);const e=this.xterm.element;e&&e.parentNode&&e.parentNode.removeChild(e),this.themeManager.setContainer(null),this.container=null}dispose(e={}){if(!(this.isDisposed||this.stateMachine.isDisposed())){if(this.isDisposed=!0,this.cancelAutoReconnect(),this.stopHeartbeat(),this.cancelReattachFit(),this.stateMachine.transition("dispose"),this.saveBuffer().catch(()=>{}),this.resizeDebounceTimer&&(clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=null),this.bufferSaveTimer&&(clearInterval(this.bufferSaveTimer),this.bufferSaveTimer=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.visibilityObserver&&(this.visibilityObserver.disconnect(),this.visibilityObserver=null),this.dataDisposable){try{this.dataDisposable.dispose()}catch(i){I.error("Error disposing data handler:",i)}this.dataDisposable=null}if(this.resizeDisposable){try{this.resizeDisposable.dispose()}catch(i){I.error("Error disposing resize handler:",i)}this.resizeDisposable=null}if(this.selectionDisposable){try{this.selectionDisposable.dispose()}catch(i){I.error("Error disposing selection handler:",i)}this.selectionDisposable=null}if(this.ipcCleanup){try{this.ipcCleanup()}catch(i){I.error("Error cleaning up IPC handlers:",i)}this.ipcCleanup=null}if(this.themeCleanup){try{this.themeCleanup()}catch(i){I.error("Error cleaning up theme listener:",i)}this.themeCleanup=null}this.eventListeners.forEach(i=>{try{i()}catch(s){I.error("Error cleaning up event listener:",s)}}),this.eventListeners=[],e.killPty!==!1&&this.terminals.kill(this.terminalId,this.workspaceId).catch(i=>{I.error("Error killing PTY connection:",i)});try{this.searchAddon?.dispose&&this.searchAddon.dispose(),this.webLinksAddon?.dispose&&this.webLinksAddon.dispose(),this.disposeWebglAddon(),this.fitAddon?.dispose&&this.fitAddon.dispose()}catch(i){I.error("Error disposing addons:",i)}try{this.themeManager.dispose()}catch(i){I.error("Error disposing theme manager:",i)}try{this.stateMachine.dispose()}catch(i){I.error("Error disposing state machine:",i)}Pf(this.xterm,i=>{I.error("Error disposing xterm:",i)})}}};P(Ae,"MAX_RECONNECT_ATTEMPTS",5),P(Ae,"BASE_RECONNECT_DELAY_MS",1e3),P(Ae,"HEARTBEAT_INTERVAL_MS",3e4),P(Ae,"HEARTBEAT_TIMEOUT_MS",1e4),P(Ae,"MAX_WEBGL_RECOVERY_ATTEMPTS",3);let cn=Ae;const le=new Xi("TerminalManager");class zf{constructor(){P(this,"terminals",new Map)}saveTerminalMetadata(e,i,s){try{_t.dispatch(Gh(i,e,s,new Date().toISOString())),le.debug(`[RendererTerminalManager] Saved terminal metadata for ${e}`)}catch(r){le.error("[RendererTerminalManager] Failed to save terminal metadata:",r)}}loadTerminalMetadata(e){try{return Zh.select(_t.state,e).map(i=>({terminalId:i.id,workspaceId:i.workspaceId??e,createdAt:i.createdAt??"",title:i.customName||Jh(i.name)}))}catch(i){le.error("[RendererTerminalManager] Failed to load terminal metadata:",i)}return[]}removeTerminalMetadata(e,i){try{_t.dispatch(Yh(i,e)),le.debug(`[RendererTerminalManager] Removed terminal metadata for ${e}`)}catch(s){le.error("[RendererTerminalManager] Failed to remove terminal metadata:",s)}}hasTerminal(e){return this.terminals.has(e)}async getOrCreateTerminal(e,i,s,r,n=!1){let o=this.terminals.get(e);if(n&&o&&(le.info(`[RendererTerminalManager] Force creating new terminal, disposing existing: ${e}`),this.disposeTerminal(e),o=void 0),o)if(o.workspaceId!==i)le.warn(`[RendererTerminalManager] Terminal ${e} has mismatched workspaceId (has: ${o.workspaceId}, requested: ${i}). Disposing and recreating.`),this.disposeTerminal(e),o=void 0;else return le.info(`[RendererTerminalManager] Reattaching to existing terminal: ${e} (was attached: ${o.isAttached})`),o.container=s,o.isAttached=!0,await o.adapter.reattach(s),r&&(o.adapter.updateCallbacks(r),r.onReady?.()),le.info(`[RendererTerminalManager] Successfully reattached terminal: ${e}`),o.adapter;le.info(`[RendererTerminalManager] Creating new terminal: ${e}`);const a=new cn({workspaceId:i,terminalId:e,container:s,...r});return o={adapter:a,terminalId:e,workspaceId:i,isAttached:!0,container:s},this.terminals.set(e,o),this.saveTerminalMetadata(e,i),await a.initialize(n),a}isAttachedTo(e,i){const s=this.terminals.get(e);return!!s&&s.isAttached&&s.container===i}detachTerminal(e,i){const s=this.terminals.get(e);if(s){if(i&&s.container!==i){le.info(`[RendererTerminalManager] Ignoring detach from a stale surface: ${e}`);return}le.info(`[RendererTerminalManager] Detaching terminal: ${e}`),s.isAttached=!1,s.adapter.detach(),s.container=null}}disposeTerminal(e,i){const s=this.terminals.get(e);s?(le.info(`[RendererTerminalManager] Disposing terminal: ${e}`),s.adapter.dispose(),this.terminals.delete(e),this.removeTerminalMetadata(e,s.workspaceId)):_t.dispatch(Xh(e,i))}disposeExitedTerminal(e){const i=this.terminals.get(e);i&&(le.info(`[RendererTerminalManager] Disposing exited terminal: ${e}`),i.adapter.dispose({killPty:!1}),this.terminals.delete(e))}clearTerminal(e){const i=this.terminals.get(e);i&&(le.info(`[RendererTerminalManager] Clearing terminal: ${e}`),i.adapter.clear())}getTerminalInfo(e){const i=this.terminals.get(e);return i?i.adapter.getInfo():null}async getBufferContent(e,i){const s=this.terminals.get(e);if(s?.adapter)try{const r=s.adapter.xterm;if(r?.buffer?.active){const n=r.buffer.active,o=[];for(let a=0;a<n.length;a++){const l=n.getLine(a);l&&o.push(l.translateToString(!0))}for(;o.length>0&&!o[o.length-1].trim();)o.pop();if(o.length>0)return o.join(`
144
+ `)}handleLinkClick(e){try{if(Kh(e)||this.workspaceId===Vh){I.debug("Opening terminal link in external browser",{uri:e,workspaceId:this.workspaceId}),Fs("shell:openExternal",{url:e});return}Dn(async()=>{const{resolveBrowserLinkForOpen:i}=await import("./nwO3KCpP.js").then(s=>s.b);return{resolveBrowserLinkForOpen:i}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]),import.meta.url).then(({resolveBrowserLinkForOpen:i})=>i(e)).catch(()=>({url:e})).then(i=>{Dn(async()=>{const{getPanelLayoutManager:s}=await import("./Clo7aK1n.js").then(r=>r.p);return{getPanelLayoutManager:s}},__vite__mapDeps([32,21,22,5,23,24,3,8,4,25,15,2,33]),import.meta.url).then(({getPanelLayoutManager:s})=>{s(this.workspaceId).openBrowserPanel(i.url,void 0,void 0,i.requestedUrl),I.debug("Opened URL in browser panel",{uri:e,resolvedUrl:i.url,workspaceId:this.workspaceId})}).catch(s=>{I.warn("Failed to open URL in browser panel, falling back to external browser",{uri:e,error:s}),Fs("shell:openExternal",{url:i.url})})})}catch(i){I.warn("Failed to handle link click",{uri:e,error:i}),Fs("shell:openExternal",{url:e})}}async reconnect(){if(this.isDisposed)throw new Error("Cannot reconnect disposed terminal");if(!this.stateMachine.canTransition("reconnect"))throw new Error(`Cannot reconnect in state ${this.stateMachine.getState()}`);this.exitedNormally=!1,this.stateMachine.transition("reconnect");try{const e=this.xterm.cols,i=this.xterm.rows,s=await this.terminals.create({workspaceId:this.workspaceId,cols:e,rows:i});if(!s.success)throw new Error(s.error||$s.terminal_adapter_reconnectFailed_error());s.id&&(this.terminalId=s.id),this.setupIpcEventHandlers(),this.stateMachine.transition("reconnected"),this.restoreCursor(),this.callbacks.onReady?.()}catch(e){throw this.stateMachine.reportError(e),e}}detach(){this.ipcCleanup&&(this.ipcCleanup(),this.ipcCleanup=null),this.stopHeartbeat(),this.cancelAutoReconnect(),this.cancelReattachFit(),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.visibilityObserver&&(this.visibilityObserver.disconnect(),this.visibilityObserver=null),this.resizeDebounceTimer&&(clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=null);const e=this.xterm.element;e&&e.parentNode&&e.parentNode.removeChild(e),this.themeManager.setContainer(null),this.container=null}dispose(e={}){if(!(this.isDisposed||this.stateMachine.isDisposed())){if(this.isDisposed=!0,this.cancelAutoReconnect(),this.stopHeartbeat(),this.cancelReattachFit(),this.stateMachine.transition("dispose"),this.saveBuffer().catch(()=>{}),this.resizeDebounceTimer&&(clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=null),this.bufferSaveTimer&&(clearInterval(this.bufferSaveTimer),this.bufferSaveTimer=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.visibilityObserver&&(this.visibilityObserver.disconnect(),this.visibilityObserver=null),this.dataDisposable){try{this.dataDisposable.dispose()}catch(i){I.error("Error disposing data handler:",i)}this.dataDisposable=null}if(this.resizeDisposable){try{this.resizeDisposable.dispose()}catch(i){I.error("Error disposing resize handler:",i)}this.resizeDisposable=null}if(this.selectionDisposable){try{this.selectionDisposable.dispose()}catch(i){I.error("Error disposing selection handler:",i)}this.selectionDisposable=null}if(this.ipcCleanup){try{this.ipcCleanup()}catch(i){I.error("Error cleaning up IPC handlers:",i)}this.ipcCleanup=null}if(this.themeCleanup){try{this.themeCleanup()}catch(i){I.error("Error cleaning up theme listener:",i)}this.themeCleanup=null}this.eventListeners.forEach(i=>{try{i()}catch(s){I.error("Error cleaning up event listener:",s)}}),this.eventListeners=[],e.killPty!==!1&&this.terminals.kill(this.terminalId,this.workspaceId).catch(i=>{I.error("Error killing PTY connection:",i)});try{this.searchAddon?.dispose&&this.searchAddon.dispose(),this.webLinksAddon?.dispose&&this.webLinksAddon.dispose(),this.disposeWebglAddon(),this.fitAddon?.dispose&&this.fitAddon.dispose()}catch(i){I.error("Error disposing addons:",i)}try{this.themeManager.dispose()}catch(i){I.error("Error disposing theme manager:",i)}try{this.stateMachine.dispose()}catch(i){I.error("Error disposing state machine:",i)}Pf(this.xterm,i=>{I.error("Error disposing xterm:",i)})}}};P(Ae,"MAX_RECONNECT_ATTEMPTS",5),P(Ae,"BASE_RECONNECT_DELAY_MS",1e3),P(Ae,"HEARTBEAT_INTERVAL_MS",3e4),P(Ae,"HEARTBEAT_TIMEOUT_MS",1e4),P(Ae,"MAX_WEBGL_RECOVERY_ATTEMPTS",3);let cn=Ae;const le=new Xi("TerminalManager");class zf{constructor(){P(this,"terminals",new Map)}saveTerminalMetadata(e,i,s){try{_t.dispatch(Gh(i,e,s,new Date().toISOString())),le.debug(`[RendererTerminalManager] Saved terminal metadata for ${e}`)}catch(r){le.error("[RendererTerminalManager] Failed to save terminal metadata:",r)}}loadTerminalMetadata(e){try{return Zh.select(_t.state,e).map(i=>({terminalId:i.id,workspaceId:i.workspaceId??e,createdAt:i.createdAt??"",title:i.customName||Jh(i.name)}))}catch(i){le.error("[RendererTerminalManager] Failed to load terminal metadata:",i)}return[]}removeTerminalMetadata(e,i){try{_t.dispatch(Yh(i,e)),le.debug(`[RendererTerminalManager] Removed terminal metadata for ${e}`)}catch(s){le.error("[RendererTerminalManager] Failed to remove terminal metadata:",s)}}hasTerminal(e){return this.terminals.has(e)}async getOrCreateTerminal(e,i,s,r,n=!1){let o=this.terminals.get(e);if(n&&o&&(le.info(`[RendererTerminalManager] Force creating new terminal, disposing existing: ${e}`),this.disposeTerminal(e),o=void 0),o)if(o.workspaceId!==i)le.warn(`[RendererTerminalManager] Terminal ${e} has mismatched workspaceId (has: ${o.workspaceId}, requested: ${i}). Disposing and recreating.`),this.disposeTerminal(e),o=void 0;else return le.info(`[RendererTerminalManager] Reattaching to existing terminal: ${e} (was attached: ${o.isAttached})`),o.container=s,o.isAttached=!0,await o.adapter.reattach(s),r&&(o.adapter.updateCallbacks(r),r.onReady?.()),le.info(`[RendererTerminalManager] Successfully reattached terminal: ${e}`),o.adapter;le.info(`[RendererTerminalManager] Creating new terminal: ${e}`);const a=new cn({workspaceId:i,terminalId:e,container:s,...r});return o={adapter:a,terminalId:e,workspaceId:i,isAttached:!0,container:s},this.terminals.set(e,o),this.saveTerminalMetadata(e,i),await a.initialize(n),a}isAttachedTo(e,i){const s=this.terminals.get(e);return!!s&&s.isAttached&&s.container===i}detachTerminal(e,i){const s=this.terminals.get(e);if(s){if(i&&s.container!==i){le.info(`[RendererTerminalManager] Ignoring detach from a stale surface: ${e}`);return}le.info(`[RendererTerminalManager] Detaching terminal: ${e}`),s.isAttached=!1,s.adapter.detach(),s.container=null}}disposeTerminal(e,i){const s=this.terminals.get(e);s?(le.info(`[RendererTerminalManager] Disposing terminal: ${e}`),s.adapter.dispose(),this.terminals.delete(e),this.removeTerminalMetadata(e,s.workspaceId)):_t.dispatch(Xh(e,i))}disposeExitedTerminal(e){const i=this.terminals.get(e);i&&(le.info(`[RendererTerminalManager] Disposing exited terminal: ${e}`),i.adapter.dispose({killPty:!1}),this.terminals.delete(e))}clearTerminal(e){const i=this.terminals.get(e);i&&(le.info(`[RendererTerminalManager] Clearing terminal: ${e}`),i.adapter.clear())}getTerminalInfo(e){const i=this.terminals.get(e);return i?i.adapter.getInfo():null}async getBufferContent(e,i){const s=this.terminals.get(e);if(s?.adapter)try{const r=s.adapter.xterm;if(r?.buffer?.active){const n=r.buffer.active,o=[];for(let a=0;a<n.length;a++){const l=n.getLine(a);l&&o.push(l.translateToString(!0))}for(;o.length>0&&!o[o.length-1].trim();)o.pop();if(o.length>0)return o.join(`
145
145
  `)}}catch(r){le.warn("[RendererTerminalManager] Failed to read live buffer, falling back:",r)}try{const n=await new Rs(i,e).restoreBuffer();if(n&&n.lines.length>0){const o=[...n.lines];for(;o.length>0&&!o[o.length-1].trim();)o.pop();return o.join(`
146
146
  `)}}catch(r){le.error("[RendererTerminalManager] Failed to read persisted buffer:",r)}return null}disposeWorkspaceTerminals(e){const i=[];for(const[s,r]of this.terminals)r.workspaceId===e&&i.push(s);if(i.length>0){le.info(`[RendererTerminalManager] Disposing ${i.length} terminals for workspace ${e}`);for(const s of i)try{const r=this.terminals.get(s);r&&(r.adapter.dispose(),this.terminals.delete(s))}catch(r){le.error(`[RendererTerminalManager] Failed to dispose terminal ${s}:`,r)}}}disposeAll(){le.info(`[RendererTerminalManager] Disposing all ${this.terminals.size} terminals`);for(const[e,i]of this.terminals)try{i.adapter.dispose()}catch(s){le.error(`[RendererTerminalManager] Failed to dispose terminal ${e}:`,s)}this.terminals.clear()}}typeof window<"u"&&!window.__terminalManager&&(window.__terminalManager=new zf);const Wf=window.__terminalManager,Tp=Object.freeze(Object.defineProperty({__proto__:null,terminalManager:Wf},Symbol.toStringTag,{value:"Module"}));export{au as D,pu as L,hn as T,Wf as a,Tp as b,Pf as d,cu as o,Oi as t};
@@ -1 +1 @@
1
- import"./3SdAC2_C.js";import{p as r}from"./DTdAlnvg.js";const t={get error(){return r.error},get params(){return r.params},get state(){return r.state},get status(){return r.status},get url(){return r.url}},s=t;export{s as p};
1
+ import"./3SdAC2_C.js";import{p as r}from"./Bd1Doib5.js";const t={get error(){return r.error},get params(){return r.params},get state(){return r.state},get status(){return r.status},get url(){return r.url}},s=t;export{s as p};
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["/app/immutable/chunks/KMO8sO00.js","/app/immutable/chunks/DXdFemRu.js","/app/immutable/chunks/Dms_DO28.js","/app/immutable/chunks/3SdAC2_C.js","/app/immutable/chunks/ChTqQfQN.js","/app/immutable/chunks/B4mHWFlW.js","/app/immutable/chunks/CIyUrgF0.js","/app/immutable/chunks/CjZEyjv4.js","/app/immutable/chunks/hY0rMePc.js","/app/immutable/chunks/DxwfiAWm.js","/app/immutable/chunks/uXuxG9cN.js","/app/immutable/chunks/Bqd7fdCF.js","/app/immutable/chunks/C9aF-Sor.js","/app/immutable/chunks/DETS1-K4.js","/app/immutable/chunks/BNN0vAFF.js","/app/immutable/chunks/BWmYJDmC.js","/app/immutable/chunks/leDczq9h.js","/app/immutable/assets/spinner.D_TRo5Hy.css","/app/immutable/chunks/D400ElMz.js","/app/immutable/chunks/DypB-Dwi.js","/app/immutable/chunks/rNjiZ_3W.js","/app/immutable/chunks/BTc_j7Dt.js","/app/immutable/assets/button.-yaUNjRS.css","/app/immutable/chunks/CAmQkXZq.js","/app/immutable/chunks/B7JHU89G.js","/app/immutable/chunks/CcSZrbR4.js","/app/immutable/chunks/B0fUscDD.js","/app/immutable/chunks/B4PfEXaO.js","/app/immutable/chunks/x_GKKTQV.js","/app/immutable/chunks/CIU_APaR.js","/app/immutable/chunks/Dn334wJv.js","/app/immutable/chunks/CXul4WJt.js","/app/immutable/chunks/BXT21uPn.js","/app/immutable/chunks/D9tVylVS.js","/app/immutable/chunks/72S4_8Fo.js","/app/immutable/chunks/DU3vNstz.js","/app/immutable/chunks/XJv96NUg.js","/app/immutable/assets/notify.B1j5oT2y.css","/app/immutable/chunks/BQ1b28aV.js","/app/immutable/chunks/CMiilI_P.js","/app/immutable/chunks/B_QPRXJ5.js","/app/immutable/chunks/AXE1aiRo.js","/app/immutable/chunks/B5aYN90J.js","/app/immutable/chunks/BdWqymET.js","/app/immutable/chunks/BBWuirRW.js","/app/immutable/chunks/DONrLvvt.js"])))=>i.map(i=>d[i]);
2
- var Rt=Object.defineProperty;var xt=(e,t,n)=>t in e?Rt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Pe=(e,t,n)=>xt(e,typeof t!="symbol"?t+"":t,n);import{Jx as M,m as be,nY as R,wt as Pt,Cr as Ge,wv as Bt,DF as Ye,cK as Lt,cL as Ot,nZ as Je,nL as Ut,i as ke,fV as $t,ma as Nt,cS as Ht}from"./DXdFemRu.js";import{J as Ft,Z as Kt,dW as Be,cU as pe,dH as Wt,ax as qt,be as Xe,I as jt,e8 as Vt}from"./C9aF-Sor.js";import{e as zt,b as ae,F as Gt,y as re,_ as _e,G as Yt,C as Jt,W as Qe,v as Xt,u as Qt,M as Zt}from"./B4mHWFlW.js";import{D as Le,a as en,d as tn}from"./CQcEqK4G.js";import{m as nn,g as Ze,r as an,k as rn,D as sn}from"./BXyd6A9p.js";import{e as on}from"./CL3a4Hm1.js";import{z as et,O as cn,R as ln}from"./Bqd7fdCF.js";import{a as dn}from"./4jB5IsVV.js";import{f as un}from"./edw8TVSr.js";import{bm as h,_ as fe}from"./hY0rMePc.js";import{a8 as tt,aA as se,I as he,a as nt,n as at,cS as rt,e as st,aI as ot,M as mn,aa as pn,aV as Oe,d as le,C as fn,cT as hn,U as gn,a4 as yn,aJ as wn,b_ as bn}from"./3BCyU2N-.js";import{W as kn,L as _n,w as vn,R as Sn,h as it,M as An}from"./rNjiZ_3W.js";import{l as H,i as Mn,n as In}from"./B7JHU89G.js";import{b as Tn}from"./AXE1aiRo.js";import{K as Cn,P as En,as as Dn,aC as Rn}from"./Dkgk_rvZ.js";import{a as Ue,b as xn,g as Pn}from"./DypB-Dwi.js";import{m as Bn}from"./Mh0PqgbP.js";import{m as Ln}from"./x_GKKTQV.js";import"./3SdAC2_C.js";import"./leDczq9h.js";import"./CjZEyjv4.js";import"./ChTqQfQN.js";import"./BXT21uPn.js";import{i as ct}from"./Dms_DO28.js";import{C as On}from"./B5aYN90J.js";import{i as Un}from"./CegXgKbh.js";import{o as O,e as $n,l as z,s as C,n as ce,b as Nn,d as Hn,c as Fn}from"./CIyUrgF0.js";const Vr=M.createSelector((e,t)=>e.unreadTracking.dividerSessionByAgentId[t]??null),zr=M.createSelector(e=>e.unreadTracking.currentlyViewedAgentId),Gr=M.createSelector(e=>{const t=[];for(const s of Object.values(e.panelLayout.byWorkspaceId))for(const o of Object.values(s.panels))for(const i of o.tabs)i.type==="agent"&&i.agentId&&t.push(i.agentId);const n=Object.keys(e.unreadTracking.dividerSessionByAgentId),a=new Set(e.agentSessions.agentIdsByWorkspace[be]??[]);return{chiefCardVisible:e.sidebarNav.panelItem==="chief",chiefSessionAgentIds:n.filter(s=>a.has(s)),dividerSessionAgentIds:n,openAgentTabIds:t}});function Yr(e,t){if(e)return e.model}function Kn({messages:e,pendingInitialPrompt:t,pendingContextReferenceCount:n=0}){return e.length>0||!!t||n>0}function Jr({session:e,messages:t,pendingInitialPrompt:n,pendingContextReferenceCount:a=0}){return!(e?Ft(e):!1)&&!Kn({messages:t,pendingInitialPrompt:n,pendingContextReferenceCount:a})}function Xr(e){return Kt(e.messageMetadata)}function Wn(e){return{id:e.id,appMessageId:e.appMessageId,role:"user",timestamp:new Date(e.createdAt??0).toISOString(),contentBlocks:[...e.content?[{type:"text",text:e.content}]:[],...e.imageBlocks??[],...e.fileBlocks??[]],metadata:e.messageMetadata,...e.author!==void 0?{author:e.author}:{}}}function Qr(e){return Wn({...e,createdAt:Date.parse(e.queuedAt)})}const qn=8*1024*1024,jn=3*1024*1024;function Vn(e){return Math.ceil(Math.max(0,e)/3)*4}function zn(e){const t=e.promptBase64Bytes;return e.mimeType==="image/jpeg"&&Number.isSafeInteger(e.size)&&e.size>0&&e.size<=jn&&typeof t=="number"&&t===Vn(e.size)?t:null}async function lt(e,t,n,a,r=()=>{}){const s=()=>{if(!a())throw new Error("media-send-retired")};if(s(),r("overlay-render"),!n.exportMedia)throw new Error("media-export-unavailable");const o=dn(e.source,e.saved);if(o.length>1e4)throw new Error("media-animation-layer-limit");const i=[];for(const c of o)s(),i.push({...c,png:await nn(e.source,e.saved,c.atMs)});s(),r("export");const l=await n.exportMedia({outputVersion:zt,jobId:t,media:e,layers:i});if(s(),!l.ok)throw new Error(["media-export-failed",l.error].filter(Boolean).join(":"));return{jobId:t,value:l.value}}const ve={CLIPBOARD_WRITE:"dock-media:clipboard-write",CLIPBOARD_READ:"dock-media:clipboard-read",MENU:"dock-media:menu"};function $e(e,t){return Math.max(0,(e.pausedAt??t)-e.startedAt-(e.pausedMs??0))}function ge(e,t){if(!t?.startsWith(".intent/attachments/"))return;const n=t.split("/").map(encodeURIComponent).join("/"),a=tt(`intent://local/file/${n}`,e);return a?.kind==="video"?a.url:void 0}function Gn(e){const t=e.video==="full"?h.dock_captureEditor_videoFull_label():h.dock_captureEditor_videoHighlights_label(),n=e.voice==="audio"?h.dock_captureEditor_voiceAudio_label():e.voice==="transcript"?h.dock_captureEditor_voiceTranscript_label():h.dock_captureEditor_voiceOff_summary();return`${t} · ${n}`}function Yn(e,t,n,a){if(a?.error==="permission")return a.kind==="pick"?"accessibility":"screen";if(e==="permission"||t==="permission")return"screen";if(n?.startsWith("microphone-permission"))return"microphone";if(n?.startsWith("speech-permission"))return"speech"}const V=un;function Zr(e){const{view:t,items:n,local:a,labels:r,copy:s}=e,o=t.speech.error??t.speech.capability?.reason??null,i=Yn(t.captureError,t.clips.find(y=>y.status==="failed"&&y.error==="permission")?.error??null,o,t.annotationIssue),l=t.annotationIssue?.error==="unavailable"?s?.annotationUnavailable:void 0,c=t.annotationIssue,d=t.captureError==="permission",u=c?.error==="permission"&&c.kind!=="pick",g=c?.error==="permission"&&c.kind==="pick",p=o?.startsWith("speech-permission")?"speech":o?.startsWith("microphone-permission")||o==="permission"?"microphone":void 0,m={},w={},f=(y,D,$)=>{m[y]=D,$&&(w[y]=$)};s&&(d&&(f("capture",s.permission,"screen"),t.recording||f("record",s.permission,"screen")),u&&!t.annotating&&f("annotate",s.permission,"screen"),g&&(f("pick",s.accessibilityPermission,"accessibility"),t.tool==="pick"&&!t.annotating&&f("annotate",s.accessibilityPermission,"accessibility")),p&&!t.dictation&&f("mic",(o&&r.speechError?.(o))??s.speechPermission,p));const k=y=>{const D=w[y];D&&e.actions.onOpenSettings(D)},_=new Set(t.evidenceOwnedItemIds),I=t.clips.find(y=>y.status==="recording"),S=t.clips.length>=ae.clips,v=t.capabilities,B=t.speech.available,E=new Set(t.clips.filter(y=>y.status==="recording"||y.status==="placing"||!!y.media).flatMap(y=>y.captureHistory?.map(D=>D.image.id)??[])),P=[...t.tiles.filter(({image:y,marks:D})=>!!y.media||y.source!=="annotate"||!E.has(y.id)||D.some(({mark:$})=>!$.clipId)).map(({image:y,marks:D})=>({kind:"image",id:y.contextItemId,url:a.previews[y.id]??"",markCount:D.length,owner:"evidence",...a.previews[y.id]?{}:{status:"placing"}})),...t.clips.filter(y=>!y.discarding).map(y=>({kind:"clip",id:y.contextItemId??y.id,duration:V(y.status==="recording"?$e(y,a.now):y.durationMs),recording:y.status==="recording",...y.media?.saved?{summary:Gn(y.media.saved)}:{},...y.status==="ready"&&ge(e.workspaceId,y.path)?{url:ge(e.workspaceId,y.path)}:{},owner:"evidence",...y.status==="placing"?{status:"placing"}:{},...y.status==="failed"?{status:"failed",...y.error==="limit"?{error:h.dock_composer_clipTooLarge_error()}:{}}:{}})),...n.filter(y=>!_.has(y.id)).map(y=>({...y.imageData&&y.imageMimeType?{kind:"image",id:y.id,url:`data:${y.imageMimeType};base64,${y.imageData}`,markCount:0,file:{name:y.label,imageData:y.imageData,imageMimeType:y.imageMimeType}}:{kind:"file",id:y.id,name:y.label},owner:"attachment",...y.placementStatus==="placing"?{status:"placing"}:{},...y.placementStatus==="failed"?{status:"failed",error:y.placementError}:{}}))];return{mediaStatus:t.recording?{kind:"recording",label:r.recording}:t.annotating?{kind:"annotating",label:r.annotating}:void 0,...i?{settingsPane:i}:{},...l?{annotationNotice:l}:{},labels:r,attachments:P,...s?{placeholder:t.dictation?"":s.idle}:{},state:{captureRevision:t.captureAccepted,capturePending:t.capturePending,captureDisabled:!v.capture||t.captureDisabled,...t.captureDisabled?{captureTooltip:r.captureLimit}:{},captureMode:t.evidence?.annotation?"fullscreen":t.captureMode,captureModesAvailable:!!v.captureModes&&!t.evidence?.annotation,annotationActive:t.annotating,tool:t.tool,toolUsed:t.toolUsed,annotationDisabled:!v.annotate,recording:t.recording&&!I?.discarding,recordingDisabled:!!I?.discarding||!t.recording&&(!v.record||S),...S&&!t.recording?{recordingTooltip:r.clipLimit}:{},recordingTime:V(I?$e(I,a.now):0),dictating:!!t.dictation,dictationPending:t.speech.pending||t.dictation?.status==="transcribing",dictationDisabled:!B&&!t.dictation&&!m.mic,...t.speech.error&&r.speechError?{dictationTooltip:r.speechError(t.speech.error)}:{},dictationTime:t.dictation?V(a.now-t.dictation.startedAt):V(0),inputLevels:t.speech.levels,...Object.keys(m).length?{alerts:m}:{}},...e.actions,...t.fileAttachmentsEnabled===!1?{onEdit:void 0}:{},onAlert:k,beforeSubmit:e.beforeSubmit}}const Se=()=>globalThis.electronAPI,Jn=["image/png","image/jpeg","image/webp"],Ne=e=>Jn.includes(e??"")?e:null;function He(e){const t=atob(e),n=new Uint8Array(t.length);for(let a=0;a<t.length;a+=1)n[a]=t.charCodeAt(a);return n}async function es(e,t){const{view:n,items:a,previews:r}=t,s=n.tiles.find(({image:c})=>c.id===e||c.contextItemId===e);if(s){const c=a.find(p=>p.id===s.image.contextItemId),d=s.image.media;if(s.image.mediaError)return null;if(d?.saved){if(!t.createSavedPreviewUrl||!t.revokeUrl)return null;const p={...d,saved:d.saved},m=await t.createSavedPreviewUrl(t.workspaceId,p);try{const w=await t.fetchBytes(m),f=p.saved.crop;return{kind:"image",name:c?.label||"screenshot.png",mimeType:"image/png",bytes:w,intent:{pixels:{mimeType:"image/png",width:Math.max(1,Math.round(f?.w??p.source.width)),height:Math.max(1,Math.round(f?.h??p.source.height)),displayScale:s.image.displayScale,capturedAt:s.image.capturedAt},raw:w,marks:[]}}}finally{t.revokeUrl(m)}}const u=Ne(c?.imageMimeType),g=r[s.image.id];return!c?.imageData||!u||!g?null:{kind:"image",name:c.label||"screenshot.png",mimeType:"image/png",bytes:await t.fetchBytes(g),intent:{pixels:{mimeType:u,width:s.image.width,height:s.image.height,displayScale:s.image.displayScale,capturedAt:s.image.capturedAt,...s.image.hash?{hash:s.image.hash}:{}},raw:He(c.imageData),marks:s.marks.map(({mark:p})=>({tool:p.tool,geometry:p.geometry,bounds:p.bounds,element:p.element}))}}}const o=n.clips.find(c=>c.id===e||c.contextItemId===e);if(o){const c=o.status==="ready"?ge(t.workspaceId,o.path):null;if(!c)return null;const d=a.find(g=>g.id===o.contextItemId),u=await t.fetchBytes(c);if(!Qn(u))throw new Error("Not a recording file");return{kind:"clip",name:d?.label||`recording-${o.id.slice(0,8)}.mp4`,mimeType:d?.attachmentMimeType||"video/mp4",bytes:u,durationMs:o.durationMs,hasMicAudio:o.hasMicAudio}}const i=a.find(c=>c.id===e),l=Ne(i?.imageMimeType);return i?.imageData&&l?{kind:"image",name:i.label||"image",mimeType:l,bytes:He(i.imageData)}:null}async function Xn(e){const t=await fetch(e);if(!t.ok)throw new Error(`Media request failed (${t.status})`);const n=new Uint8Array(await t.arrayBuffer()),a=Number(t.headers.get("content-length")??Number.NaN);if(n.byteLength===0||Number.isFinite(a)&&a!==n.byteLength)throw new Error("Media response was incomplete");return n}function Qn(e){return e.byteLength>8&&String.fromCharCode(...e.subarray(4,8))==="ftyp"}async function ts(e){try{return(await Se()?.invoke(ve.CLIPBOARD_WRITE,e))?.ok===!0}catch{return!1}}async function Zn(){try{return await Se()?.invoke(ve.CLIPBOARD_READ,{})??null}catch{return null}}async function ns(e){try{const t=await Se()?.invoke(ve.MENU,{canCut:e});return t?.action==="copy"||t?.action==="cut"?t.action:null}catch{return null}}const Fe=new WeakSet;async function ea(e,t){const[n]=e;if(e.length!==1||!n||n.size!==t.size)return!1;try{const a=await crypto.subtle.digest("SHA-256",await n.arrayBuffer());return Array.from(new Uint8Array(a),s=>s.toString(16).padStart(2,"0")).join("")===t.sha256}catch{return!1}}function as(e,{onIntentMedia:t,isCurrent:n,read:a=Zn}){const r=e.clipboardData;if(Fe.has(e)||!r||r.files.length===0)return!1;const s=e.target,o=Array.from(r.files),i=r.types.filter(l=>l!=="Files").map(l=>[l,r.getData(l)]);return e.preventDefault(),e.stopImmediatePropagation(),a().catch(()=>null).then(async l=>{if(!n())return;if(l&&await ea(o,l)){n()&&t(l);return}if(!n()||!(s instanceof Node)||!s.isConnected)return;const c=new DataTransfer;for(const u of o)c.items.add(u);for(const[u,g]of i)c.setData(u,g);const d=new ClipboardEvent("paste",{clipboardData:c,bubbles:!0,cancelable:!0});Fe.add(d),s.dispatchEvent(d)}),!0}function ta(e){const t=atob(e),n=new Uint8Array(t.length);for(let a=0;a<t.length;a++)n[a]=t.charCodeAt(a);return n}function na(e){let t="";for(let a=0;a<e.length;a+=32768)t+=String.fromCharCode(...e.subarray(a,a+32768));return btoa(t)}function dt(e){let t=0;return e.endsWith("==")?t=2:e.endsWith("=")&&(t=1),Math.floor(e.length*3/4)-t}async function aa(e){const t=await crypto.subtle.digest("SHA-256",e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength));return Array.from(new Uint8Array(t)).map(n=>n.toString(16).padStart(2,"0")).join("")}const ut={placeAttachment:ot,beginAttachmentUpload:st,sendAttachmentUploadChunk:rt,commitAttachmentUpload:at,abortAttachmentUpload:nt,getAttachmentInfo:he,mintIdempotencyKey:se};async function Ae(e,t,n,a=ut){const{idempotencyKey:r}=n,s={...r!==void 0?{idempotencyKey:r}:{},...n.rawScreenshot!==void 0?{rawScreenshot:n.rawScreenshot}:{}},o=async m=>hn(m,r)?Oe(e,r,a.getAttachmentInfo):void 0;if(dt(n.data)<=mn)try{return await a.placeAttachment(e,t,{data:n.data,mimeType:n.mimeType,...s})}catch(m){const w=await o(m);if(w)return w;throw m}const i=ta(n.data),l=await aa(i);let c,d;try{({uploadId:c,maxChunkBytes:d}=await a.beginAttachmentUpload(e,t,i.byteLength,l,{mimeType:n.mimeType,...s}))}catch(m){if(r!==void 0&&pn(m)){const w=await Oe(e,r,a.getAttachmentInfo);if(w)return w}throw m}const u=Math.min(gn,d),g=Math.ceil(i.byteLength/u);let p=!1;try{for(let m=0;m<g;m++){const w=i.subarray(m*u,(m+1)*u);await a.sendAttachmentUploadChunk(c,m,na(w),e)}return p=!0,await a.commitAttachmentUpload(c,e)}catch(m){const w=p?await o(m):void 0;if(w)return w;throw await a.abortAttachmentUpload(c,e).catch(()=>{}),m}}function ra(e,t){return yn(e,`image-${Date.now()}-${t+1}`)}class Me extends Error{constructor(n,a){super(n);Pe(this,"retryBlocks");this.name="ImagePlacementError",this.retryBlocks=a}}function sa(e,t){return e instanceof Me?e.retryBlocks:t}async function oa(e,t,n=ut,a=()=>!0){const r=l=>(...c)=>(le(a),l(...c));n={placeAttachment:r(n.placeAttachment),beginAttachmentUpload:r(n.beginAttachmentUpload),sendAttachmentUploadChunk:r(n.sendAttachmentUploadChunk),commitAttachmentUpload:r(n.commitAttachmentUpload),abortAttachmentUpload:r(n.abortAttachmentUpload),getAttachmentInfo:r(n.getAttachmentInfo),mintIdempotencyKey:r(n.mintIdempotencyKey)};const s=[],o=[],i=[];for(let l=0;l<t.length;l++){le(a);const c=t[l];if("attachmentId"in c&&c.attachmentId){const p={type:"image",attachmentId:c.attachmentId,...c.mimeType?{mimeType:c.mimeType}:{}};s.push(p),o.push(p);continue}const d=c,u=d.placementFileName??ra(d.mimeType,l),g=n.mintIdempotencyKey(d.placementIdempotencyKey);try{const p=await Ae(e,u,{data:d.data,mimeType:d.mimeType,...g!==void 0?{idempotencyKey:g}:{}},n),m={type:"image",attachmentId:p.attachmentId,...p.mimeType??d.mimeType?{mimeType:p.mimeType??d.mimeType}:{}};s.push(m),o.push(m)}catch(p){const m=fn(p);i.push(m?`${u} (${m})`:u),o.push(g!==void 0?{...d,placementIdempotencyKey:g,placementFileName:u}:d)}}if(i.length>0)throw new Me(h.chat_imagePlacement_failed_error({names:i.join(", ")}),o);return le(a),s}const rs=Object.freeze(Object.defineProperty({__proto__:null,ImagePlacementError:Me,base64DecodedBytes:dt,imageRetryBlocks:sa,placeImageAttachment:Ae,toImageReferenceBlocks:oa},Symbol.toStringTag,{value:"Module"}));function mt(){try{return kn()}catch{return null}}function ia(){return{backendId:M.state.connections.windowBackendId??null,generation:M.state.daemonHealth.connectionGeneration,transport:mt()}}class Ie extends Error{constructor(){super("dock-evidence-backend-changed")}}function N(e,t){return async(...n)=>{e();const a=await t(...n);return e(),a}}const K={current:e=>mt()===e.transport&&M.state.daemonHealth.connectionGeneration===e.generation&&(M.state.connections.windowBackendId??null)===e.backendId,capabilities:()=>_n(),placeImage:(e,t,n,a)=>Ae(e,t,n,{placeAttachment:N(a,ot),beginAttachmentUpload:N(a,st),sendAttachmentUploadChunk:N(a,rt),commitAttachmentUpload:N(a,at),abortAttachmentUpload:N(a,nt),getAttachmentInfo:N(a,he),mintIdempotencyKey:se}),lookup:(e,t)=>he({workspaceId:e,idempotencyKey:t}),mintKey:se};function Y(e){return K.current(e)}function ca(e,t){const n=M.state.dockConversation;return{generation:n.generation,authority:n.authority,clearRevision:R(n.drafts,Gt(e,t))?.clearRevision??0,binding:ia()}}function ss(e,t,n){const a=ca(e,t);return a.generation===n.generation&&a.authority===n.authority&&a.clearRevision===n.clearRevision&&Y(n.binding)}function pt(e,t){return()=>{if(!e.current(t))throw new Ie}}const ft=Object.freeze({rawRetention:!1,chiefAttachments:!1});function os(e){return e!==ft}const de=new Map;function ht(e,t=K){const n=`${e.backendId}:${e.generation}`;let a=de.get(n);if(!a){const r=pt(t,e);a=(async()=>{r();const o=await t.capabilities();r();const i=o?.server?.capabilities;if(!i||typeof i!="object")throw new Error("unobserved");return{rawRetention:i.rawScreenshotRetention===1,chiefAttachments:i.chiefAttachments===1}})().catch(()=>(de.delete(n),ft)),de.set(n,a)}return a}class ee extends Error{constructor(t){super(`dock-raw-retention-contract:${t}`),this.reason=t}}function gt(e){const{rpcCode:t,code:n}=e??{};return t===-32602||n==="INVALID_PARAMS"}function la(e){const t=String(e?.message??"");return gt(e)&&(t.includes("rawScreenshotExpired:")||/expired at .*not renewable/i.test(t))}function da(e,t,n){const a=e.rawScreenshot;if(!a||a.compositeAttachmentId!==t)return null;const r=Date.parse(a.expiresAt);return Number.isFinite(r)?a.expired||r<=n?"expired":{attachmentId:e.attachmentId,expiresAt:a.expiresAt}:null}function Ke(e){return{ok:!0,path:e.path,fileName:e.fileName,size:e.size,attachmentId:e.attachmentId,...e.mimeType?{mimeType:e.mimeType}:{},uploadedAt:e.uploadedAt,replayed:!0,...e.rawScreenshot?{rawScreenshot:e.rawScreenshot}:{}}}class ua extends Error{constructor(t,n){super("dock-evidence-placement-failed"),this.imageId=t,this.failure=n}}const We=e=>e.split("/")[1]?.replace("jpeg","jpg")||"png";async function ma(e){const t=e.api??K,n=e.now??Date.now,a=pt(t,e.binding);a();const r=await ht(e.binding,t);a();const s=r.rawRetention&&(e.workspaceId!==be||r.chiefAttachments),o=[];for(const i of e.images){const l=e.records[i.image.id];let c=l&&l.signature===i.signature&&l.workspaceId===e.workspaceId&&l.backendId===e.binding.backendId?l:{imageId:i.image.id,signature:i.signature,workspaceId:e.workspaceId,backendId:e.binding.backendId,compositeKey:null,rawKey:null,composite:null,raw:null,rawSettled:!1};const d=u=>{c=u,e.onRecord(u)};try{if(!c.composite){const g=c.compositeKey,p=t.mintKey(g??void 0)??null;p!==c.compositeKey&&d({...c,compositeKey:p});let m;g&&p===g&&(a(),m=await t.lookup(e.workspaceId,p).then(Ke).catch(()=>{}),a()),m||(a(),m=await t.placeImage(e.workspaceId,`screenshot-${i.image.id.slice(0,8)}.${We(i.composite.mimeType)}`,{data:i.composite.base64,mimeType:i.composite.mimeType,...p?{idempotencyKey:p}:{}},a),a()),d({...c,composite:{attachmentId:m.attachmentId,mimeType:m.mimeType??i.composite.mimeType}})}const u=c.composite.attachmentId;if(s&&i.raw&&!c.raw&&!c.rawSettled){const g=c.rawKey,p=t.mintKey(g??void 0);if(p){p!==c.rawKey&&d({...c,rawKey:p});let m;g&&p===g&&(a(),m=await t.lookup(e.workspaceId,p).then(Ke).catch(()=>{}),a());try{m||(a(),m=await t.placeImage(e.workspaceId,`screenshot-${i.image.id.slice(0,8)}-original.${We(i.raw.mimeType)}`,{data:i.raw.base64,mimeType:i.raw.mimeType,idempotencyKey:p,rawScreenshot:{compositeAttachmentId:u}},a),a());const w=da(m,u,n());if(w==="expired")d({...c,rawSettled:!0});else if(w)d({...c,raw:w});else throw new ee("echo")}catch(w){if(la(w))d({...c,rawSettled:!0});else throw w instanceof ee?w:gt(w)?new ee("refused"):w}}else throw new ee("unkeyed")}}catch(u){throw u instanceof Ie?u:new ua(i.image.id,u)}o.push(c)}return o}async function is(e,t,n,a){const r=()=>{if(!K.current(a))throw new Ie};r();const s=await K.placeImage(e,t,{...n,idempotencyKey:K.mintKey()},r);return r(),s}const pa=new Set(["invalid-saved-edit","media-send-retired","transcript-unavailable","transcript-pending","invalid-edit","stale-source","legacy-baked-marks","timing-unavailable","audio-unavailable","media-source-unavailable","media-export-unavailable","media-animation-layer-limit","media-export-failed","legacy-original-unavailable","capture-render-unavailable","capture-blur-unavailable","stale-source-pixels","not-a-screenshot","not-admitted","unavailable","dock-evidence-missing-pixels","draft-restore-failed","image-budget-exceeded"]),fa=new Set(["unavailable","permission","failed","busy","cancelled","limit"]);class L extends Error{constructor(t,n){super(n),this.stage=t,this.code=n,this.name="DockSendError"}}function oe(e){const t=e instanceof Error?e.message:typeof e=="string"?e:"";if(t.length>64)return"unclassified";const[n,...a]=t.split(":");return!pa.has(n)||a.length>2?"unclassified":n!=="media-export-failed"?a.length?"unclassified":n:[n,...a.map(r=>fa.has(r)?r:"other")].join(":")}function cs(e,t){return e instanceof L?{stage:e.stage,code:oe(e.code)}:{stage:t,code:oe(e)}}function W(e){if(!e||e.source.kind!=="recording")return!1;const t=e.source,n=e.saved??re(t,t.capturedMarks??[],e.transcript);if(n.video!=="full"||n.voice!=="audio"||n.crop||n.blurRegions.length||n.blurStrokes?.length)return!1;const a=_e(n,t,e.transcript);return t.visuals==="clean"?!a.errors.length&&!a.muted&&n.cuts.length===0&&!n.marks.some(r=>r.included)&&a.marks.length===0&&a.transcript===null&&a.kept.length===1&&a.kept[0].startMs===0&&a.kept[0].endMs===t.durationMs&&a.clips.length===1&&a.clips[0].startMs===0&&a.clips[0].endMs===t.durationMs:!a.errors.length&&!a.muted&&a.clips.length===1&&a.clips[0].startMs===0&&a.clips[0].endMs>=t.durationMs}async function ha(e,t,n,a,r,s){const o={images:{},files:[],frames:[],framePromptBytes:[],metadata:[]};let i="validate";try{const l=()=>{if(!r()||!Y(n))throw new Error("media-send-retired")};for(const c of[...t.images,...t.clips]){if(i="validate",s?.stage(i),c.mediaError)throw new Error("invalid-saved-edit");if(!c.media||W(c.media))continue;l();const d=structuredClone(c.media),u=d.source;let g=d.saved??re(u,u.capturedMarks??[],d.transcript),p=crypto.randomUUID();try{if(u.kind==="recording"&&g.voice==="transcript"&&d.transcript?.status!=="ready"){if(i="transcribe",s?.stage(i),!a?.transcribeMedia)throw new Error("transcript-unavailable");const f=await a.transcribeMedia({jobId:p,media:d});if(l(),!f.ok)throw new Error("transcript-unavailable");d.transcript=f.value,d.saved||(g=re(u,u.capturedMarks??[],d.transcript))}i="plan",s?.stage(i);const m=_e(g,u,d.transcript);if(m.errors.length)throw new Error(m.errors[0]);const w={id:c.id,kind:u.kind,video:g.video,voice:g.voice,transcript:m.transcript,batches:u.batches,marks:m.marks.map(({n:f,mark:k,frameAtMs:_})=>({n:f,id:k.id,at_ms:_,kind:k.kind,label:k.label,note:k.note,context:k.context,geometry:k.geometry}))};if(u.kind==="screenshot"){i="screenshot-source",s?.stage(i);const f=u.path.split("/").map(encodeURIComponent).join("/"),k=tt(`intent://local/file/${f}`,e);if(!k||k.kind!=="image")throw new Error("media-source-unavailable");const _=await Xn(k.url);l();const I={base64:Ze(_.buffer.slice(_.byteOffset,_.byteOffset+_.byteLength)),mimeType:/\.jpe?g$/i.test(u.path)?"image/jpeg":/\.webp$/i.test(u.path)?"image/webp":"image/png"};i="screenshot-render",s?.stage(i),o.images[c.id]=await an(u,g,I),l()}else{if(!m.clips.length){w.video_attachment_id=null,w.frames=[],w.kept_ms=[],o.metadata.push(w);continue}const f={...d,saved:g};let k=await a?.takePreparedRecording?.(f);if(k&&(p=k.jobId),l(),!k){if(!a)throw new Error("media-export-unavailable");k=await lt(f,p,a,()=>r()&&Y(n),S=>{i=S,s?.stage(S),S==="export"&&s?.exportAttempt(p)})}p=k.jobId,i="placement",s?.stage(i);const _=[k.value.video,...k.value.frames],I=[];for(let S=0;S<_.length;S++){l();const v=_[S],B=`capture-${c.id.slice(0,12)}-${S}.${S===0?"mp4":v.mimeType==="image/jpeg"?"jpg":"png"}`,E=await wn(e,B,{sourcePath:v.sourcePath,mimeType:v.mimeType,idempotencyKey:se()},void 0,void 0,()=>r()&&Y(n));l(),S===0?o.files.push({type:"file",attachmentId:E.attachmentId,fileName:B,mimeType:E.mimeType??v.mimeType,size:E.size}):(o.frames.push({type:"image",attachmentId:E.attachmentId,mimeType:v.mimeType==="image/jpeg"?"image/jpeg":"image/png"}),o.framePromptBytes.push(zn(v))),I.push(E.attachmentId)}w.video_attachment_id=I[0],w.frames=k.value.frames.map((S,v)=>({mark_id:S.markId,attachment_id:I[v+1]})),w.kept_ms=m.clips}o.metadata.push(w)}finally{s?.stage("release"),await a?.releaseMediaJob?.(p).catch(()=>{})}}return o}catch(l){throw l instanceof L?l:new L(i,oe(l))}}const ue=1568,ga=.85;async function ya(e,t){const n=Math.round(e.length*3/4/1024),a=await wa(e,t),{width:r,height:s}=a,o=r>ue||s>ue;let i=r,l=s;if(o){const f=ue/Math.max(r,s);i=Math.round(r*f),l=Math.round(s*f)}const c=new OffscreenCanvas(i,l),d=c.getContext("2d");if(!d)throw new Error("Failed to get 2D canvas context for image resize");d.drawImage(a,0,0,i,l);let u=t;ba(d,i,l)||(u="image/jpeg");const g=await c.convertToBlob({type:u,quality:u==="image/jpeg"?ga:void 0}),p=g.type||u,m=await ka(g),w=Math.round(m.length*3/4/1024);return console.debug(`[image-resize] ${r}×${s} → ${i}×${l} | ${t} → ${p} | ${n} KB → ${w} KB`),{base64:m,mimeType:p}}async function wa(e,t){const n=atob(e),a=new Uint8Array(n.length);for(let s=0;s<n.length;s++)a[s]=n.charCodeAt(s);const r=new Blob([a],{type:t});return createImageBitmap(r)}function ba(e,t,n){const r=e.getImageData(0,0,t,n).data;for(let s=3;s<r.length;s+=4)if(r[s]<255)return!0;return!1}async function ka(e){const t=await e.arrayBuffer(),n=new Uint8Array(t);let a="";for(let r=0;r<n.length;r++)a+=String.fromCharCode(n[r]);return btoa(a)}const T={...Le,badge:Le.badgeRadius*2};function _a(e,t,n=1,a=0){const r=Math.max(1,e.displayScale)*n,s=[],o=i=>i*n;for(const{n:i,mark:l}of t){const c=l.geometry;if(c.kind==="rect")s.push({kind:"rect",x:o(c.x),y:o(c.y),w:o(c.w),h:o(c.h),width:T.stroke*r});else if(c.kind==="path")s.push({kind:"path",points:c.points.map(m=>({x:o(m.x),y:o(m.y)})),width:T.pen*r});else{const m={x:o(c.from.x),y:o(c.from.y)},w={x:o(c.to.x),y:o(c.to.y)};s.push({kind:"arrow",from:m,to:w,head:Ia(m,w,T.arrowHead*r),width:T.stroke*r})}if(!T.showNumbers)continue;const d=Math.max(a,T.badge/2*r),u=o(l.bounds.x+l.bounds.w),g=o(l.bounds.y),p=tn({x:o(l.bounds.x),y:g,w:u-o(l.bounds.x),h:o(l.bounds.h)},{x:0,y:0,w:o(e.width),h:o(e.height)},r,d);s.push({kind:"badge",...p,radius:d,label:String(i),font:d*T.badgeTextScale})}return s}function va(e,t){"letterSpacing"in e&&(e.letterSpacing="0px"),"wordSpacing"in e&&(e.wordSpacing="0px");const n=(a,r,s)=>{e.strokeStyle=T.halo,e.lineWidth=a+T.haloWidth*r,s(),e.strokeStyle=T.accent,e.lineWidth=a,s()};e.strokeStyle=T.accent,e.lineCap="round",e.lineJoin="round";for(const a of t)if(a.kind==="rect")n(a.width,a.width/T.stroke,()=>e.strokeRect(a.x,a.y,a.w,a.h));else if(a.kind==="path"||a.kind==="arrow"){e.lineWidth=a.width,e.beginPath();const r=a.kind==="path"?a.points:[a.from,a.to];a.kind==="arrow"&&r.forEach((o,i)=>i?e.lineTo(o.x,o.y):e.moveTo(o.x,o.y)),a.kind==="arrow"&&(e.moveTo(a.head.left.x,a.head.left.y),e.lineTo(a.to.x,a.to.y),e.lineTo(a.head.right.x,a.head.right.y));const s=a.kind==="path"?new Path2D(en(a.points)):null;n(a.width,a.width/(a.kind==="path"?T.pen:T.stroke),()=>s?e.stroke(s):e.stroke())}else e.fillStyle=T.paper,e.beginPath(),e.arc(a.x,a.y,a.radius,0,Math.PI*2),e.closePath(),e.fill(),e.strokeStyle=T.accent,e.lineWidth=T.badgeOutline*a.radius/T.badgeRadius,e.stroke(),e.fillStyle=T.ink,e.font=`600 ${a.font}px ${T.badgeFontFamily}`,e.textAlign="center",e.textBaseline="middle",e.fillText(a.label,a.x,a.y)}async function Sa(e,t){const n=Uint8Array.from(atob(e),a=>a.charCodeAt(0));return createImageBitmap(new Blob([n],{type:t}))}async function Aa(e){const t=await e.convertToBlob({type:"image/png"});return Ze(await t.arrayBuffer())}async function yt(e,t,n,a,r=0){await rn();const s=await Sa(e.base64,e.mimeType);try{const o=Math.min(1,a/Math.max(t.width,t.height)),i=new OffscreenCanvas(Math.max(1,Math.round(t.width*o)),Math.max(1,Math.round(t.height*o))),l=i.getContext("2d");if(!l)throw new Error("dock-evidence-canvas-unavailable");return l.drawImage(s,0,0,i.width,i.height),va(l,_a(t,n,o,r)),i}finally{s.close()}}async function Ma(e,t,n){const a=await yt(e,t,n,Math.max(t.width,t.height));return ya(await Aa(a),"image/png")}async function ls(e,t,n,a=384){const r=await yt(e,t,n,a,a/32);return URL.createObjectURL(await r.convertToBlob({type:"image/png"}))}function Ia(e,t,n=T.arrowHead){const a=Math.atan2(t.y-e.y,t.x-e.x),r=T.arrowSpread;return{left:{x:t.x-n*Math.cos(a-r),y:t.y-n*Math.sin(a-r)},right:{x:t.x-n*Math.cos(a+r),y:t.y-n*Math.sin(a+r)}}}function ds(e,t){const n=Yt(t??void 0),a=new Set(t?.clips.filter(r=>!!r.media&&!W(r.media)).map(r=>r.contextItemId));return e.filter(r=>!n.has(r.id)&&!a.has(r.id))}async function us({workspaceId:e,agentId:t,evidence:n,clickedItems:a,sendItems:r,clickedPayload:s,binding:o,service:i,current:l,onRecord:c,timing:d}){const u=()=>{if(!l()||!Y(o))throw new L("validate","media-send-retired")};if(u(),n?.images.some(b=>b.mediaError)||n?.clips.some(b=>b.mediaError))throw new L("validate","invalid-saved-edit");const g=b=>!!b.media&&!W(b.media),p=n?{workspaceId:e,agentId:t,appUrl:`intent://local/workspace/${encodeURIComponent(e)}`,clipAttachmentIds:Object.fromEntries(n.clips.map(b=>[b.id,a.find(A=>A.id===b.contextItemId)?.attachmentId??null]))}:null;for(const b of n?.clips??[]){if(!b.media||!W(b.media))continue;const A=a.find(Q=>Q.id===b.contextItemId);if(!A||A.attachmentId!==b.media.source.attachmentId||A.path!==b.media.source.path||A.placementStatus!==void 0&&A.placementStatus!=="placed")throw new L("validate","legacy-original-unavailable")}const m=n?await ha(e,n,o,i,l,d):{images:{},files:[],frames:[],framePromptBytes:[],metadata:[]},w=new Set(n?.clips.filter(b=>g(b)||!!b.media&&W(b.media)).map(b=>b.id)),f=new Set(n?.clips.filter(b=>w.has(b.id)).flatMap(b=>(b.captureHistory??[]).map(A=>A.image.id))),k=(n?.images??[]).filter(b=>b.source!=="annotate"||!!b.media||!f.has(b.id)||n.marks.some(A=>A.imageId===b.id&&!(A.clipId&&w.has(A.clipId))));d?.stage("burn");let _=[];try{_=n?await Ta({...n,images:k},a,m.images):[]}catch(b){throw new L("burn",oe(b))}if(m.framePromptBytes.reduce((b,A)=>b+(A??0),0)>qn)throw new L("validate","image-budget-exceeded");const S=new Set(n?.images.filter(b=>b.media).map(b=>b.id)),v=n?{...n,images:k.map(b=>m.images[b.id]?{...b,width:m.images[b.id].width,height:m.images[b.id].height}:b),clips:n.clips.filter(b=>!g(b)),marks:n.marks.filter(b=>!S.has(b.imageId)&&!n.clips.some(A=>g(A)&&A.id===b.clipId))}:null;u();const B=m.metadata.some(b=>typeof b.transcript=="string"&&b.transcript.trim());if(!s.text.trim()&&!r.length&&!s.workspaceContextStr?.trim()&&!_.length&&!m.files.length&&!m.frames.length&&!s.imageBlocks?.length&&!s.fileBlocks?.length&&!B)return null;let E=_,P=null;d?.stage("placement");const xe=n?await ht(o):null;if(u(),n&&(e!==be||xe?.chiefAttachments)){const b=await ma({workspaceId:e,binding:o,images:k.map((A,Q)=>{const Z=a.find(Dt=>Dt.id===A.contextItemId);return{image:A,signature:Jt(n,A.id),composite:{base64:_[Q].data,mimeType:_[Q].mimeType},raw:!A.media&&Z?.imageData&&Z.imageMimeType?{base64:Z.imageData,mimeType:Z.imageMimeType}:null}}),records:n?.placements??{},onRecord:c});u(),E=b.map(A=>({type:"image",attachmentId:A.composite.attachmentId,mimeType:A.composite.mimeType})),P=Object.fromEntries(b.map(A=>[A.imageId,{attachmentId:A.composite.attachmentId,raw:A.raw}]))}const y=new Map(n?Qe(n).map(({n:b,mark:A})=>[A.id,b]):[]),D=p&&P?{...p,imageAttachments:P,markNumbers:y}:p&&{...p,markNumbers:y},$=n&&D?{...s,imageBlocks:[...E,...m.frames,...s.imageBlocks??[]],fileBlocks:[...s.fileBlocks??[],...m.files],workspaceContextStr:[Qt(v,D),m.metadata.length?`[Edited capture outputs]
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["/app/immutable/chunks/CI0C7_h-.js","/app/immutable/chunks/4g_iHoQm.js","/app/immutable/chunks/Dms_DO28.js","/app/immutable/chunks/3SdAC2_C.js","/app/immutable/chunks/ChTqQfQN.js","/app/immutable/chunks/8jMQM9h0.js","/app/immutable/chunks/CIyUrgF0.js","/app/immutable/chunks/D-rRuAXZ.js","/app/immutable/chunks/Dws-34a7.js","/app/immutable/chunks/DxwfiAWm.js","/app/immutable/chunks/uXuxG9cN.js","/app/immutable/chunks/Bqd7fdCF.js","/app/immutable/chunks/SbTG0nwQ.js","/app/immutable/chunks/CGYPBD6G.js","/app/immutable/chunks/B5tvpTFB.js","/app/immutable/chunks/DLCFUd4s.js","/app/immutable/chunks/BD9db4FR.js","/app/immutable/assets/spinner.D_TRo5Hy.css","/app/immutable/chunks/C-zB-6G6.js","/app/immutable/chunks/DypB-Dwi.js","/app/immutable/chunks/BPuz5cN_.js","/app/immutable/chunks/7KxcPj98.js","/app/immutable/assets/button.-yaUNjRS.css","/app/immutable/chunks/Dval4sTX.js","/app/immutable/chunks/B8HnjSSF.js","/app/immutable/chunks/DtqPBHQj.js","/app/immutable/chunks/tLFaYuVN.js","/app/immutable/chunks/B6eTPmJH.js","/app/immutable/chunks/rXKOJqUt.js","/app/immutable/chunks/BIGqOuh0.js","/app/immutable/chunks/Dn334wJv.js","/app/immutable/chunks/5-0LQoqd.js","/app/immutable/chunks/DcOkWaeN.js","/app/immutable/chunks/D9tVylVS.js","/app/immutable/chunks/Bc1vJq_Z.js","/app/immutable/chunks/DU3vNstz.js","/app/immutable/chunks/XJv96NUg.js","/app/immutable/assets/notify.B1j5oT2y.css","/app/immutable/chunks/DlUpt_0u.js","/app/immutable/chunks/CMiilI_P.js","/app/immutable/chunks/B_QPRXJ5.js","/app/immutable/chunks/DJPIUVkw.js","/app/immutable/chunks/B5aYN90J.js","/app/immutable/chunks/BdWqymET.js","/app/immutable/chunks/BBWuirRW.js","/app/immutable/chunks/DONrLvvt.js"])))=>i.map(i=>d[i]);
2
+ var Rt=Object.defineProperty;var xt=(e,t,n)=>t in e?Rt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Pe=(e,t,n)=>xt(e,typeof t!="symbol"?t+"":t,n);import{Jx as M,m as be,nY as R,wt as Pt,Cr as Ge,wv as Bt,DF as Ye,cK as Lt,cL as Ot,nZ as Je,nL as Ut,i as ke,fV as $t,ma as Nt,cS as Ht}from"./4g_iHoQm.js";import{J as Ft,Z as Kt,dW as Be,cU as pe,dH as Wt,ax as qt,be as Xe,I as jt,e8 as Vt}from"./SbTG0nwQ.js";import{e as zt,b as ae,F as Gt,y as re,_ as _e,G as Yt,C as Jt,W as Qe,v as Xt,u as Qt,M as Zt}from"./8jMQM9h0.js";import{D as Le,a as en,d as tn}from"./CQcEqK4G.js";import{m as nn,g as Ze,r as an,k as rn,D as sn}from"./sSXTMg2P.js";import{e as on}from"./CL3a4Hm1.js";import{z as et,O as cn,R as ln}from"./Bqd7fdCF.js";import{a as dn}from"./BwPwF85e.js";import{f as un}from"./CletI6Pa.js";import{bm as h,_ as fe}from"./Dws-34a7.js";import{a8 as tt,aA as se,I as he,a as nt,n as at,cS as rt,e as st,aI as ot,M as mn,aa as pn,aV as Oe,d as le,C as fn,cT as hn,U as gn,a4 as yn,aJ as wn,b_ as bn}from"./CA8JHp72.js";import{W as kn,L as _n,w as vn,R as Sn,h as it,M as An}from"./BPuz5cN_.js";import{l as H,i as Mn,n as In}from"./B8HnjSSF.js";import{b as Tn}from"./DJPIUVkw.js";import{K as Cn,P as En,as as Dn,aC as Rn}from"./C3-81PRC.js";import{a as Ue,b as xn,g as Pn}from"./DypB-Dwi.js";import{m as Bn}from"./B_4WsP9b.js";import{m as Ln}from"./rXKOJqUt.js";import"./3SdAC2_C.js";import"./BD9db4FR.js";import"./D-rRuAXZ.js";import"./ChTqQfQN.js";import"./DcOkWaeN.js";import{i as ct}from"./Dms_DO28.js";import{C as On}from"./B5aYN90J.js";import{i as Un}from"./CNSshwg_.js";import{o as O,e as $n,l as z,s as C,n as ce,b as Nn,d as Hn,c as Fn}from"./CIyUrgF0.js";const Vr=M.createSelector((e,t)=>e.unreadTracking.dividerSessionByAgentId[t]??null),zr=M.createSelector(e=>e.unreadTracking.currentlyViewedAgentId),Gr=M.createSelector(e=>{const t=[];for(const s of Object.values(e.panelLayout.byWorkspaceId))for(const o of Object.values(s.panels))for(const i of o.tabs)i.type==="agent"&&i.agentId&&t.push(i.agentId);const n=Object.keys(e.unreadTracking.dividerSessionByAgentId),a=new Set(e.agentSessions.agentIdsByWorkspace[be]??[]);return{chiefCardVisible:e.sidebarNav.panelItem==="chief",chiefSessionAgentIds:n.filter(s=>a.has(s)),dividerSessionAgentIds:n,openAgentTabIds:t}});function Yr(e,t){if(e)return e.model}function Kn({messages:e,pendingInitialPrompt:t,pendingContextReferenceCount:n=0}){return e.length>0||!!t||n>0}function Jr({session:e,messages:t,pendingInitialPrompt:n,pendingContextReferenceCount:a=0}){return!(e?Ft(e):!1)&&!Kn({messages:t,pendingInitialPrompt:n,pendingContextReferenceCount:a})}function Xr(e){return Kt(e.messageMetadata)}function Wn(e){return{id:e.id,appMessageId:e.appMessageId,role:"user",timestamp:new Date(e.createdAt??0).toISOString(),contentBlocks:[...e.content?[{type:"text",text:e.content}]:[],...e.imageBlocks??[],...e.fileBlocks??[]],metadata:e.messageMetadata,...e.author!==void 0?{author:e.author}:{}}}function Qr(e){return Wn({...e,createdAt:Date.parse(e.queuedAt)})}const qn=8*1024*1024,jn=3*1024*1024;function Vn(e){return Math.ceil(Math.max(0,e)/3)*4}function zn(e){const t=e.promptBase64Bytes;return e.mimeType==="image/jpeg"&&Number.isSafeInteger(e.size)&&e.size>0&&e.size<=jn&&typeof t=="number"&&t===Vn(e.size)?t:null}async function lt(e,t,n,a,r=()=>{}){const s=()=>{if(!a())throw new Error("media-send-retired")};if(s(),r("overlay-render"),!n.exportMedia)throw new Error("media-export-unavailable");const o=dn(e.source,e.saved);if(o.length>1e4)throw new Error("media-animation-layer-limit");const i=[];for(const c of o)s(),i.push({...c,png:await nn(e.source,e.saved,c.atMs)});s(),r("export");const l=await n.exportMedia({outputVersion:zt,jobId:t,media:e,layers:i});if(s(),!l.ok)throw new Error(["media-export-failed",l.error].filter(Boolean).join(":"));return{jobId:t,value:l.value}}const ve={CLIPBOARD_WRITE:"dock-media:clipboard-write",CLIPBOARD_READ:"dock-media:clipboard-read",MENU:"dock-media:menu"};function $e(e,t){return Math.max(0,(e.pausedAt??t)-e.startedAt-(e.pausedMs??0))}function ge(e,t){if(!t?.startsWith(".intent/attachments/"))return;const n=t.split("/").map(encodeURIComponent).join("/"),a=tt(`intent://local/file/${n}`,e);return a?.kind==="video"?a.url:void 0}function Gn(e){const t=e.video==="full"?h.dock_captureEditor_videoFull_label():h.dock_captureEditor_videoHighlights_label(),n=e.voice==="audio"?h.dock_captureEditor_voiceAudio_label():e.voice==="transcript"?h.dock_captureEditor_voiceTranscript_label():h.dock_captureEditor_voiceOff_summary();return`${t} · ${n}`}function Yn(e,t,n,a){if(a?.error==="permission")return a.kind==="pick"?"accessibility":"screen";if(e==="permission"||t==="permission")return"screen";if(n?.startsWith("microphone-permission"))return"microphone";if(n?.startsWith("speech-permission"))return"speech"}const V=un;function Zr(e){const{view:t,items:n,local:a,labels:r,copy:s}=e,o=t.speech.error??t.speech.capability?.reason??null,i=Yn(t.captureError,t.clips.find(y=>y.status==="failed"&&y.error==="permission")?.error??null,o,t.annotationIssue),l=t.annotationIssue?.error==="unavailable"?s?.annotationUnavailable:void 0,c=t.annotationIssue,d=t.captureError==="permission",u=c?.error==="permission"&&c.kind!=="pick",g=c?.error==="permission"&&c.kind==="pick",p=o?.startsWith("speech-permission")?"speech":o?.startsWith("microphone-permission")||o==="permission"?"microphone":void 0,m={},w={},f=(y,D,$)=>{m[y]=D,$&&(w[y]=$)};s&&(d&&(f("capture",s.permission,"screen"),t.recording||f("record",s.permission,"screen")),u&&!t.annotating&&f("annotate",s.permission,"screen"),g&&(f("pick",s.accessibilityPermission,"accessibility"),t.tool==="pick"&&!t.annotating&&f("annotate",s.accessibilityPermission,"accessibility")),p&&!t.dictation&&f("mic",(o&&r.speechError?.(o))??s.speechPermission,p));const k=y=>{const D=w[y];D&&e.actions.onOpenSettings(D)},_=new Set(t.evidenceOwnedItemIds),I=t.clips.find(y=>y.status==="recording"),S=t.clips.length>=ae.clips,v=t.capabilities,B=t.speech.available,E=new Set(t.clips.filter(y=>y.status==="recording"||y.status==="placing"||!!y.media).flatMap(y=>y.captureHistory?.map(D=>D.image.id)??[])),P=[...t.tiles.filter(({image:y,marks:D})=>!!y.media||y.source!=="annotate"||!E.has(y.id)||D.some(({mark:$})=>!$.clipId)).map(({image:y,marks:D})=>({kind:"image",id:y.contextItemId,url:a.previews[y.id]??"",markCount:D.length,owner:"evidence",...a.previews[y.id]?{}:{status:"placing"}})),...t.clips.filter(y=>!y.discarding).map(y=>({kind:"clip",id:y.contextItemId??y.id,duration:V(y.status==="recording"?$e(y,a.now):y.durationMs),recording:y.status==="recording",...y.media?.saved?{summary:Gn(y.media.saved)}:{},...y.status==="ready"&&ge(e.workspaceId,y.path)?{url:ge(e.workspaceId,y.path)}:{},owner:"evidence",...y.status==="placing"?{status:"placing"}:{},...y.status==="failed"?{status:"failed",...y.error==="limit"?{error:h.dock_composer_clipTooLarge_error()}:{}}:{}})),...n.filter(y=>!_.has(y.id)).map(y=>({...y.imageData&&y.imageMimeType?{kind:"image",id:y.id,url:`data:${y.imageMimeType};base64,${y.imageData}`,markCount:0,file:{name:y.label,imageData:y.imageData,imageMimeType:y.imageMimeType}}:{kind:"file",id:y.id,name:y.label},owner:"attachment",...y.placementStatus==="placing"?{status:"placing"}:{},...y.placementStatus==="failed"?{status:"failed",error:y.placementError}:{}}))];return{mediaStatus:t.recording?{kind:"recording",label:r.recording}:t.annotating?{kind:"annotating",label:r.annotating}:void 0,...i?{settingsPane:i}:{},...l?{annotationNotice:l}:{},labels:r,attachments:P,...s?{placeholder:t.dictation?"":s.idle}:{},state:{captureRevision:t.captureAccepted,capturePending:t.capturePending,captureDisabled:!v.capture||t.captureDisabled,...t.captureDisabled?{captureTooltip:r.captureLimit}:{},captureMode:t.evidence?.annotation?"fullscreen":t.captureMode,captureModesAvailable:!!v.captureModes&&!t.evidence?.annotation,annotationActive:t.annotating,tool:t.tool,toolUsed:t.toolUsed,annotationDisabled:!v.annotate,recording:t.recording&&!I?.discarding,recordingDisabled:!!I?.discarding||!t.recording&&(!v.record||S),...S&&!t.recording?{recordingTooltip:r.clipLimit}:{},recordingTime:V(I?$e(I,a.now):0),dictating:!!t.dictation,dictationPending:t.speech.pending||t.dictation?.status==="transcribing",dictationDisabled:!B&&!t.dictation&&!m.mic,...t.speech.error&&r.speechError?{dictationTooltip:r.speechError(t.speech.error)}:{},dictationTime:t.dictation?V(a.now-t.dictation.startedAt):V(0),inputLevels:t.speech.levels,...Object.keys(m).length?{alerts:m}:{}},...e.actions,...t.fileAttachmentsEnabled===!1?{onEdit:void 0}:{},onAlert:k,beforeSubmit:e.beforeSubmit}}const Se=()=>globalThis.electronAPI,Jn=["image/png","image/jpeg","image/webp"],Ne=e=>Jn.includes(e??"")?e:null;function He(e){const t=atob(e),n=new Uint8Array(t.length);for(let a=0;a<t.length;a+=1)n[a]=t.charCodeAt(a);return n}async function es(e,t){const{view:n,items:a,previews:r}=t,s=n.tiles.find(({image:c})=>c.id===e||c.contextItemId===e);if(s){const c=a.find(p=>p.id===s.image.contextItemId),d=s.image.media;if(s.image.mediaError)return null;if(d?.saved){if(!t.createSavedPreviewUrl||!t.revokeUrl)return null;const p={...d,saved:d.saved},m=await t.createSavedPreviewUrl(t.workspaceId,p);try{const w=await t.fetchBytes(m),f=p.saved.crop;return{kind:"image",name:c?.label||"screenshot.png",mimeType:"image/png",bytes:w,intent:{pixels:{mimeType:"image/png",width:Math.max(1,Math.round(f?.w??p.source.width)),height:Math.max(1,Math.round(f?.h??p.source.height)),displayScale:s.image.displayScale,capturedAt:s.image.capturedAt},raw:w,marks:[]}}}finally{t.revokeUrl(m)}}const u=Ne(c?.imageMimeType),g=r[s.image.id];return!c?.imageData||!u||!g?null:{kind:"image",name:c.label||"screenshot.png",mimeType:"image/png",bytes:await t.fetchBytes(g),intent:{pixels:{mimeType:u,width:s.image.width,height:s.image.height,displayScale:s.image.displayScale,capturedAt:s.image.capturedAt,...s.image.hash?{hash:s.image.hash}:{}},raw:He(c.imageData),marks:s.marks.map(({mark:p})=>({tool:p.tool,geometry:p.geometry,bounds:p.bounds,element:p.element}))}}}const o=n.clips.find(c=>c.id===e||c.contextItemId===e);if(o){const c=o.status==="ready"?ge(t.workspaceId,o.path):null;if(!c)return null;const d=a.find(g=>g.id===o.contextItemId),u=await t.fetchBytes(c);if(!Qn(u))throw new Error("Not a recording file");return{kind:"clip",name:d?.label||`recording-${o.id.slice(0,8)}.mp4`,mimeType:d?.attachmentMimeType||"video/mp4",bytes:u,durationMs:o.durationMs,hasMicAudio:o.hasMicAudio}}const i=a.find(c=>c.id===e),l=Ne(i?.imageMimeType);return i?.imageData&&l?{kind:"image",name:i.label||"image",mimeType:l,bytes:He(i.imageData)}:null}async function Xn(e){const t=await fetch(e);if(!t.ok)throw new Error(`Media request failed (${t.status})`);const n=new Uint8Array(await t.arrayBuffer()),a=Number(t.headers.get("content-length")??Number.NaN);if(n.byteLength===0||Number.isFinite(a)&&a!==n.byteLength)throw new Error("Media response was incomplete");return n}function Qn(e){return e.byteLength>8&&String.fromCharCode(...e.subarray(4,8))==="ftyp"}async function ts(e){try{return(await Se()?.invoke(ve.CLIPBOARD_WRITE,e))?.ok===!0}catch{return!1}}async function Zn(){try{return await Se()?.invoke(ve.CLIPBOARD_READ,{})??null}catch{return null}}async function ns(e){try{const t=await Se()?.invoke(ve.MENU,{canCut:e});return t?.action==="copy"||t?.action==="cut"?t.action:null}catch{return null}}const Fe=new WeakSet;async function ea(e,t){const[n]=e;if(e.length!==1||!n||n.size!==t.size)return!1;try{const a=await crypto.subtle.digest("SHA-256",await n.arrayBuffer());return Array.from(new Uint8Array(a),s=>s.toString(16).padStart(2,"0")).join("")===t.sha256}catch{return!1}}function as(e,{onIntentMedia:t,isCurrent:n,read:a=Zn}){const r=e.clipboardData;if(Fe.has(e)||!r||r.files.length===0)return!1;const s=e.target,o=Array.from(r.files),i=r.types.filter(l=>l!=="Files").map(l=>[l,r.getData(l)]);return e.preventDefault(),e.stopImmediatePropagation(),a().catch(()=>null).then(async l=>{if(!n())return;if(l&&await ea(o,l)){n()&&t(l);return}if(!n()||!(s instanceof Node)||!s.isConnected)return;const c=new DataTransfer;for(const u of o)c.items.add(u);for(const[u,g]of i)c.setData(u,g);const d=new ClipboardEvent("paste",{clipboardData:c,bubbles:!0,cancelable:!0});Fe.add(d),s.dispatchEvent(d)}),!0}function ta(e){const t=atob(e),n=new Uint8Array(t.length);for(let a=0;a<t.length;a++)n[a]=t.charCodeAt(a);return n}function na(e){let t="";for(let a=0;a<e.length;a+=32768)t+=String.fromCharCode(...e.subarray(a,a+32768));return btoa(t)}function dt(e){let t=0;return e.endsWith("==")?t=2:e.endsWith("=")&&(t=1),Math.floor(e.length*3/4)-t}async function aa(e){const t=await crypto.subtle.digest("SHA-256",e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength));return Array.from(new Uint8Array(t)).map(n=>n.toString(16).padStart(2,"0")).join("")}const ut={placeAttachment:ot,beginAttachmentUpload:st,sendAttachmentUploadChunk:rt,commitAttachmentUpload:at,abortAttachmentUpload:nt,getAttachmentInfo:he,mintIdempotencyKey:se};async function Ae(e,t,n,a=ut){const{idempotencyKey:r}=n,s={...r!==void 0?{idempotencyKey:r}:{},...n.rawScreenshot!==void 0?{rawScreenshot:n.rawScreenshot}:{}},o=async m=>hn(m,r)?Oe(e,r,a.getAttachmentInfo):void 0;if(dt(n.data)<=mn)try{return await a.placeAttachment(e,t,{data:n.data,mimeType:n.mimeType,...s})}catch(m){const w=await o(m);if(w)return w;throw m}const i=ta(n.data),l=await aa(i);let c,d;try{({uploadId:c,maxChunkBytes:d}=await a.beginAttachmentUpload(e,t,i.byteLength,l,{mimeType:n.mimeType,...s}))}catch(m){if(r!==void 0&&pn(m)){const w=await Oe(e,r,a.getAttachmentInfo);if(w)return w}throw m}const u=Math.min(gn,d),g=Math.ceil(i.byteLength/u);let p=!1;try{for(let m=0;m<g;m++){const w=i.subarray(m*u,(m+1)*u);await a.sendAttachmentUploadChunk(c,m,na(w),e)}return p=!0,await a.commitAttachmentUpload(c,e)}catch(m){const w=p?await o(m):void 0;if(w)return w;throw await a.abortAttachmentUpload(c,e).catch(()=>{}),m}}function ra(e,t){return yn(e,`image-${Date.now()}-${t+1}`)}class Me extends Error{constructor(n,a){super(n);Pe(this,"retryBlocks");this.name="ImagePlacementError",this.retryBlocks=a}}function sa(e,t){return e instanceof Me?e.retryBlocks:t}async function oa(e,t,n=ut,a=()=>!0){const r=l=>(...c)=>(le(a),l(...c));n={placeAttachment:r(n.placeAttachment),beginAttachmentUpload:r(n.beginAttachmentUpload),sendAttachmentUploadChunk:r(n.sendAttachmentUploadChunk),commitAttachmentUpload:r(n.commitAttachmentUpload),abortAttachmentUpload:r(n.abortAttachmentUpload),getAttachmentInfo:r(n.getAttachmentInfo),mintIdempotencyKey:r(n.mintIdempotencyKey)};const s=[],o=[],i=[];for(let l=0;l<t.length;l++){le(a);const c=t[l];if("attachmentId"in c&&c.attachmentId){const p={type:"image",attachmentId:c.attachmentId,...c.mimeType?{mimeType:c.mimeType}:{}};s.push(p),o.push(p);continue}const d=c,u=d.placementFileName??ra(d.mimeType,l),g=n.mintIdempotencyKey(d.placementIdempotencyKey);try{const p=await Ae(e,u,{data:d.data,mimeType:d.mimeType,...g!==void 0?{idempotencyKey:g}:{}},n),m={type:"image",attachmentId:p.attachmentId,...p.mimeType??d.mimeType?{mimeType:p.mimeType??d.mimeType}:{}};s.push(m),o.push(m)}catch(p){const m=fn(p);i.push(m?`${u} (${m})`:u),o.push(g!==void 0?{...d,placementIdempotencyKey:g,placementFileName:u}:d)}}if(i.length>0)throw new Me(h.chat_imagePlacement_failed_error({names:i.join(", ")}),o);return le(a),s}const rs=Object.freeze(Object.defineProperty({__proto__:null,ImagePlacementError:Me,base64DecodedBytes:dt,imageRetryBlocks:sa,placeImageAttachment:Ae,toImageReferenceBlocks:oa},Symbol.toStringTag,{value:"Module"}));function mt(){try{return kn()}catch{return null}}function ia(){return{backendId:M.state.connections.windowBackendId??null,generation:M.state.daemonHealth.connectionGeneration,transport:mt()}}class Ie extends Error{constructor(){super("dock-evidence-backend-changed")}}function N(e,t){return async(...n)=>{e();const a=await t(...n);return e(),a}}const K={current:e=>mt()===e.transport&&M.state.daemonHealth.connectionGeneration===e.generation&&(M.state.connections.windowBackendId??null)===e.backendId,capabilities:()=>_n(),placeImage:(e,t,n,a)=>Ae(e,t,n,{placeAttachment:N(a,ot),beginAttachmentUpload:N(a,st),sendAttachmentUploadChunk:N(a,rt),commitAttachmentUpload:N(a,at),abortAttachmentUpload:N(a,nt),getAttachmentInfo:N(a,he),mintIdempotencyKey:se}),lookup:(e,t)=>he({workspaceId:e,idempotencyKey:t}),mintKey:se};function Y(e){return K.current(e)}function ca(e,t){const n=M.state.dockConversation;return{generation:n.generation,authority:n.authority,clearRevision:R(n.drafts,Gt(e,t))?.clearRevision??0,binding:ia()}}function ss(e,t,n){const a=ca(e,t);return a.generation===n.generation&&a.authority===n.authority&&a.clearRevision===n.clearRevision&&Y(n.binding)}function pt(e,t){return()=>{if(!e.current(t))throw new Ie}}const ft=Object.freeze({rawRetention:!1,chiefAttachments:!1});function os(e){return e!==ft}const de=new Map;function ht(e,t=K){const n=`${e.backendId}:${e.generation}`;let a=de.get(n);if(!a){const r=pt(t,e);a=(async()=>{r();const o=await t.capabilities();r();const i=o?.server?.capabilities;if(!i||typeof i!="object")throw new Error("unobserved");return{rawRetention:i.rawScreenshotRetention===1,chiefAttachments:i.chiefAttachments===1}})().catch(()=>(de.delete(n),ft)),de.set(n,a)}return a}class ee extends Error{constructor(t){super(`dock-raw-retention-contract:${t}`),this.reason=t}}function gt(e){const{rpcCode:t,code:n}=e??{};return t===-32602||n==="INVALID_PARAMS"}function la(e){const t=String(e?.message??"");return gt(e)&&(t.includes("rawScreenshotExpired:")||/expired at .*not renewable/i.test(t))}function da(e,t,n){const a=e.rawScreenshot;if(!a||a.compositeAttachmentId!==t)return null;const r=Date.parse(a.expiresAt);return Number.isFinite(r)?a.expired||r<=n?"expired":{attachmentId:e.attachmentId,expiresAt:a.expiresAt}:null}function Ke(e){return{ok:!0,path:e.path,fileName:e.fileName,size:e.size,attachmentId:e.attachmentId,...e.mimeType?{mimeType:e.mimeType}:{},uploadedAt:e.uploadedAt,replayed:!0,...e.rawScreenshot?{rawScreenshot:e.rawScreenshot}:{}}}class ua extends Error{constructor(t,n){super("dock-evidence-placement-failed"),this.imageId=t,this.failure=n}}const We=e=>e.split("/")[1]?.replace("jpeg","jpg")||"png";async function ma(e){const t=e.api??K,n=e.now??Date.now,a=pt(t,e.binding);a();const r=await ht(e.binding,t);a();const s=r.rawRetention&&(e.workspaceId!==be||r.chiefAttachments),o=[];for(const i of e.images){const l=e.records[i.image.id];let c=l&&l.signature===i.signature&&l.workspaceId===e.workspaceId&&l.backendId===e.binding.backendId?l:{imageId:i.image.id,signature:i.signature,workspaceId:e.workspaceId,backendId:e.binding.backendId,compositeKey:null,rawKey:null,composite:null,raw:null,rawSettled:!1};const d=u=>{c=u,e.onRecord(u)};try{if(!c.composite){const g=c.compositeKey,p=t.mintKey(g??void 0)??null;p!==c.compositeKey&&d({...c,compositeKey:p});let m;g&&p===g&&(a(),m=await t.lookup(e.workspaceId,p).then(Ke).catch(()=>{}),a()),m||(a(),m=await t.placeImage(e.workspaceId,`screenshot-${i.image.id.slice(0,8)}.${We(i.composite.mimeType)}`,{data:i.composite.base64,mimeType:i.composite.mimeType,...p?{idempotencyKey:p}:{}},a),a()),d({...c,composite:{attachmentId:m.attachmentId,mimeType:m.mimeType??i.composite.mimeType}})}const u=c.composite.attachmentId;if(s&&i.raw&&!c.raw&&!c.rawSettled){const g=c.rawKey,p=t.mintKey(g??void 0);if(p){p!==c.rawKey&&d({...c,rawKey:p});let m;g&&p===g&&(a(),m=await t.lookup(e.workspaceId,p).then(Ke).catch(()=>{}),a());try{m||(a(),m=await t.placeImage(e.workspaceId,`screenshot-${i.image.id.slice(0,8)}-original.${We(i.raw.mimeType)}`,{data:i.raw.base64,mimeType:i.raw.mimeType,idempotencyKey:p,rawScreenshot:{compositeAttachmentId:u}},a),a());const w=da(m,u,n());if(w==="expired")d({...c,rawSettled:!0});else if(w)d({...c,raw:w});else throw new ee("echo")}catch(w){if(la(w))d({...c,rawSettled:!0});else throw w instanceof ee?w:gt(w)?new ee("refused"):w}}else throw new ee("unkeyed")}}catch(u){throw u instanceof Ie?u:new ua(i.image.id,u)}o.push(c)}return o}async function is(e,t,n,a){const r=()=>{if(!K.current(a))throw new Ie};r();const s=await K.placeImage(e,t,{...n,idempotencyKey:K.mintKey()},r);return r(),s}const pa=new Set(["invalid-saved-edit","media-send-retired","transcript-unavailable","transcript-pending","invalid-edit","stale-source","legacy-baked-marks","timing-unavailable","audio-unavailable","media-source-unavailable","media-export-unavailable","media-animation-layer-limit","media-export-failed","legacy-original-unavailable","capture-render-unavailable","capture-blur-unavailable","stale-source-pixels","not-a-screenshot","not-admitted","unavailable","dock-evidence-missing-pixels","draft-restore-failed","image-budget-exceeded"]),fa=new Set(["unavailable","permission","failed","busy","cancelled","limit"]);class L extends Error{constructor(t,n){super(n),this.stage=t,this.code=n,this.name="DockSendError"}}function oe(e){const t=e instanceof Error?e.message:typeof e=="string"?e:"";if(t.length>64)return"unclassified";const[n,...a]=t.split(":");return!pa.has(n)||a.length>2?"unclassified":n!=="media-export-failed"?a.length?"unclassified":n:[n,...a.map(r=>fa.has(r)?r:"other")].join(":")}function cs(e,t){return e instanceof L?{stage:e.stage,code:oe(e.code)}:{stage:t,code:oe(e)}}function W(e){if(!e||e.source.kind!=="recording")return!1;const t=e.source,n=e.saved??re(t,t.capturedMarks??[],e.transcript);if(n.video!=="full"||n.voice!=="audio"||n.crop||n.blurRegions.length||n.blurStrokes?.length)return!1;const a=_e(n,t,e.transcript);return t.visuals==="clean"?!a.errors.length&&!a.muted&&n.cuts.length===0&&!n.marks.some(r=>r.included)&&a.marks.length===0&&a.transcript===null&&a.kept.length===1&&a.kept[0].startMs===0&&a.kept[0].endMs===t.durationMs&&a.clips.length===1&&a.clips[0].startMs===0&&a.clips[0].endMs===t.durationMs:!a.errors.length&&!a.muted&&a.clips.length===1&&a.clips[0].startMs===0&&a.clips[0].endMs>=t.durationMs}async function ha(e,t,n,a,r,s){const o={images:{},files:[],frames:[],framePromptBytes:[],metadata:[]};let i="validate";try{const l=()=>{if(!r()||!Y(n))throw new Error("media-send-retired")};for(const c of[...t.images,...t.clips]){if(i="validate",s?.stage(i),c.mediaError)throw new Error("invalid-saved-edit");if(!c.media||W(c.media))continue;l();const d=structuredClone(c.media),u=d.source;let g=d.saved??re(u,u.capturedMarks??[],d.transcript),p=crypto.randomUUID();try{if(u.kind==="recording"&&g.voice==="transcript"&&d.transcript?.status!=="ready"){if(i="transcribe",s?.stage(i),!a?.transcribeMedia)throw new Error("transcript-unavailable");const f=await a.transcribeMedia({jobId:p,media:d});if(l(),!f.ok)throw new Error("transcript-unavailable");d.transcript=f.value,d.saved||(g=re(u,u.capturedMarks??[],d.transcript))}i="plan",s?.stage(i);const m=_e(g,u,d.transcript);if(m.errors.length)throw new Error(m.errors[0]);const w={id:c.id,kind:u.kind,video:g.video,voice:g.voice,transcript:m.transcript,batches:u.batches,marks:m.marks.map(({n:f,mark:k,frameAtMs:_})=>({n:f,id:k.id,at_ms:_,kind:k.kind,label:k.label,note:k.note,context:k.context,geometry:k.geometry}))};if(u.kind==="screenshot"){i="screenshot-source",s?.stage(i);const f=u.path.split("/").map(encodeURIComponent).join("/"),k=tt(`intent://local/file/${f}`,e);if(!k||k.kind!=="image")throw new Error("media-source-unavailable");const _=await Xn(k.url);l();const I={base64:Ze(_.buffer.slice(_.byteOffset,_.byteOffset+_.byteLength)),mimeType:/\.jpe?g$/i.test(u.path)?"image/jpeg":/\.webp$/i.test(u.path)?"image/webp":"image/png"};i="screenshot-render",s?.stage(i),o.images[c.id]=await an(u,g,I),l()}else{if(!m.clips.length){w.video_attachment_id=null,w.frames=[],w.kept_ms=[],o.metadata.push(w);continue}const f={...d,saved:g};let k=await a?.takePreparedRecording?.(f);if(k&&(p=k.jobId),l(),!k){if(!a)throw new Error("media-export-unavailable");k=await lt(f,p,a,()=>r()&&Y(n),S=>{i=S,s?.stage(S),S==="export"&&s?.exportAttempt(p)})}p=k.jobId,i="placement",s?.stage(i);const _=[k.value.video,...k.value.frames],I=[];for(let S=0;S<_.length;S++){l();const v=_[S],B=`capture-${c.id.slice(0,12)}-${S}.${S===0?"mp4":v.mimeType==="image/jpeg"?"jpg":"png"}`,E=await wn(e,B,{sourcePath:v.sourcePath,mimeType:v.mimeType,idempotencyKey:se()},void 0,void 0,()=>r()&&Y(n));l(),S===0?o.files.push({type:"file",attachmentId:E.attachmentId,fileName:B,mimeType:E.mimeType??v.mimeType,size:E.size}):(o.frames.push({type:"image",attachmentId:E.attachmentId,mimeType:v.mimeType==="image/jpeg"?"image/jpeg":"image/png"}),o.framePromptBytes.push(zn(v))),I.push(E.attachmentId)}w.video_attachment_id=I[0],w.frames=k.value.frames.map((S,v)=>({mark_id:S.markId,attachment_id:I[v+1]})),w.kept_ms=m.clips}o.metadata.push(w)}finally{s?.stage("release"),await a?.releaseMediaJob?.(p).catch(()=>{})}}return o}catch(l){throw l instanceof L?l:new L(i,oe(l))}}const ue=1568,ga=.85;async function ya(e,t){const n=Math.round(e.length*3/4/1024),a=await wa(e,t),{width:r,height:s}=a,o=r>ue||s>ue;let i=r,l=s;if(o){const f=ue/Math.max(r,s);i=Math.round(r*f),l=Math.round(s*f)}const c=new OffscreenCanvas(i,l),d=c.getContext("2d");if(!d)throw new Error("Failed to get 2D canvas context for image resize");d.drawImage(a,0,0,i,l);let u=t;ba(d,i,l)||(u="image/jpeg");const g=await c.convertToBlob({type:u,quality:u==="image/jpeg"?ga:void 0}),p=g.type||u,m=await ka(g),w=Math.round(m.length*3/4/1024);return console.debug(`[image-resize] ${r}×${s} → ${i}×${l} | ${t} → ${p} | ${n} KB → ${w} KB`),{base64:m,mimeType:p}}async function wa(e,t){const n=atob(e),a=new Uint8Array(n.length);for(let s=0;s<n.length;s++)a[s]=n.charCodeAt(s);const r=new Blob([a],{type:t});return createImageBitmap(r)}function ba(e,t,n){const r=e.getImageData(0,0,t,n).data;for(let s=3;s<r.length;s+=4)if(r[s]<255)return!0;return!1}async function ka(e){const t=await e.arrayBuffer(),n=new Uint8Array(t);let a="";for(let r=0;r<n.length;r++)a+=String.fromCharCode(n[r]);return btoa(a)}const T={...Le,badge:Le.badgeRadius*2};function _a(e,t,n=1,a=0){const r=Math.max(1,e.displayScale)*n,s=[],o=i=>i*n;for(const{n:i,mark:l}of t){const c=l.geometry;if(c.kind==="rect")s.push({kind:"rect",x:o(c.x),y:o(c.y),w:o(c.w),h:o(c.h),width:T.stroke*r});else if(c.kind==="path")s.push({kind:"path",points:c.points.map(m=>({x:o(m.x),y:o(m.y)})),width:T.pen*r});else{const m={x:o(c.from.x),y:o(c.from.y)},w={x:o(c.to.x),y:o(c.to.y)};s.push({kind:"arrow",from:m,to:w,head:Ia(m,w,T.arrowHead*r),width:T.stroke*r})}if(!T.showNumbers)continue;const d=Math.max(a,T.badge/2*r),u=o(l.bounds.x+l.bounds.w),g=o(l.bounds.y),p=tn({x:o(l.bounds.x),y:g,w:u-o(l.bounds.x),h:o(l.bounds.h)},{x:0,y:0,w:o(e.width),h:o(e.height)},r,d);s.push({kind:"badge",...p,radius:d,label:String(i),font:d*T.badgeTextScale})}return s}function va(e,t){"letterSpacing"in e&&(e.letterSpacing="0px"),"wordSpacing"in e&&(e.wordSpacing="0px");const n=(a,r,s)=>{e.strokeStyle=T.halo,e.lineWidth=a+T.haloWidth*r,s(),e.strokeStyle=T.accent,e.lineWidth=a,s()};e.strokeStyle=T.accent,e.lineCap="round",e.lineJoin="round";for(const a of t)if(a.kind==="rect")n(a.width,a.width/T.stroke,()=>e.strokeRect(a.x,a.y,a.w,a.h));else if(a.kind==="path"||a.kind==="arrow"){e.lineWidth=a.width,e.beginPath();const r=a.kind==="path"?a.points:[a.from,a.to];a.kind==="arrow"&&r.forEach((o,i)=>i?e.lineTo(o.x,o.y):e.moveTo(o.x,o.y)),a.kind==="arrow"&&(e.moveTo(a.head.left.x,a.head.left.y),e.lineTo(a.to.x,a.to.y),e.lineTo(a.head.right.x,a.head.right.y));const s=a.kind==="path"?new Path2D(en(a.points)):null;n(a.width,a.width/(a.kind==="path"?T.pen:T.stroke),()=>s?e.stroke(s):e.stroke())}else e.fillStyle=T.paper,e.beginPath(),e.arc(a.x,a.y,a.radius,0,Math.PI*2),e.closePath(),e.fill(),e.strokeStyle=T.accent,e.lineWidth=T.badgeOutline*a.radius/T.badgeRadius,e.stroke(),e.fillStyle=T.ink,e.font=`600 ${a.font}px ${T.badgeFontFamily}`,e.textAlign="center",e.textBaseline="middle",e.fillText(a.label,a.x,a.y)}async function Sa(e,t){const n=Uint8Array.from(atob(e),a=>a.charCodeAt(0));return createImageBitmap(new Blob([n],{type:t}))}async function Aa(e){const t=await e.convertToBlob({type:"image/png"});return Ze(await t.arrayBuffer())}async function yt(e,t,n,a,r=0){await rn();const s=await Sa(e.base64,e.mimeType);try{const o=Math.min(1,a/Math.max(t.width,t.height)),i=new OffscreenCanvas(Math.max(1,Math.round(t.width*o)),Math.max(1,Math.round(t.height*o))),l=i.getContext("2d");if(!l)throw new Error("dock-evidence-canvas-unavailable");return l.drawImage(s,0,0,i.width,i.height),va(l,_a(t,n,o,r)),i}finally{s.close()}}async function Ma(e,t,n){const a=await yt(e,t,n,Math.max(t.width,t.height));return ya(await Aa(a),"image/png")}async function ls(e,t,n,a=384){const r=await yt(e,t,n,a,a/32);return URL.createObjectURL(await r.convertToBlob({type:"image/png"}))}function Ia(e,t,n=T.arrowHead){const a=Math.atan2(t.y-e.y,t.x-e.x),r=T.arrowSpread;return{left:{x:t.x-n*Math.cos(a-r),y:t.y-n*Math.sin(a-r)},right:{x:t.x-n*Math.cos(a+r),y:t.y-n*Math.sin(a+r)}}}function ds(e,t){const n=Yt(t??void 0),a=new Set(t?.clips.filter(r=>!!r.media&&!W(r.media)).map(r=>r.contextItemId));return e.filter(r=>!n.has(r.id)&&!a.has(r.id))}async function us({workspaceId:e,agentId:t,evidence:n,clickedItems:a,sendItems:r,clickedPayload:s,binding:o,service:i,current:l,onRecord:c,timing:d}){const u=()=>{if(!l()||!Y(o))throw new L("validate","media-send-retired")};if(u(),n?.images.some(b=>b.mediaError)||n?.clips.some(b=>b.mediaError))throw new L("validate","invalid-saved-edit");const g=b=>!!b.media&&!W(b.media),p=n?{workspaceId:e,agentId:t,appUrl:`intent://local/workspace/${encodeURIComponent(e)}`,clipAttachmentIds:Object.fromEntries(n.clips.map(b=>[b.id,a.find(A=>A.id===b.contextItemId)?.attachmentId??null]))}:null;for(const b of n?.clips??[]){if(!b.media||!W(b.media))continue;const A=a.find(Q=>Q.id===b.contextItemId);if(!A||A.attachmentId!==b.media.source.attachmentId||A.path!==b.media.source.path||A.placementStatus!==void 0&&A.placementStatus!=="placed")throw new L("validate","legacy-original-unavailable")}const m=n?await ha(e,n,o,i,l,d):{images:{},files:[],frames:[],framePromptBytes:[],metadata:[]},w=new Set(n?.clips.filter(b=>g(b)||!!b.media&&W(b.media)).map(b=>b.id)),f=new Set(n?.clips.filter(b=>w.has(b.id)).flatMap(b=>(b.captureHistory??[]).map(A=>A.image.id))),k=(n?.images??[]).filter(b=>b.source!=="annotate"||!!b.media||!f.has(b.id)||n.marks.some(A=>A.imageId===b.id&&!(A.clipId&&w.has(A.clipId))));d?.stage("burn");let _=[];try{_=n?await Ta({...n,images:k},a,m.images):[]}catch(b){throw new L("burn",oe(b))}if(m.framePromptBytes.reduce((b,A)=>b+(A??0),0)>qn)throw new L("validate","image-budget-exceeded");const S=new Set(n?.images.filter(b=>b.media).map(b=>b.id)),v=n?{...n,images:k.map(b=>m.images[b.id]?{...b,width:m.images[b.id].width,height:m.images[b.id].height}:b),clips:n.clips.filter(b=>!g(b)),marks:n.marks.filter(b=>!S.has(b.imageId)&&!n.clips.some(A=>g(A)&&A.id===b.clipId))}:null;u();const B=m.metadata.some(b=>typeof b.transcript=="string"&&b.transcript.trim());if(!s.text.trim()&&!r.length&&!s.workspaceContextStr?.trim()&&!_.length&&!m.files.length&&!m.frames.length&&!s.imageBlocks?.length&&!s.fileBlocks?.length&&!B)return null;let E=_,P=null;d?.stage("placement");const xe=n?await ht(o):null;if(u(),n&&(e!==be||xe?.chiefAttachments)){const b=await ma({workspaceId:e,binding:o,images:k.map((A,Q)=>{const Z=a.find(Dt=>Dt.id===A.contextItemId);return{image:A,signature:Jt(n,A.id),composite:{base64:_[Q].data,mimeType:_[Q].mimeType},raw:!A.media&&Z?.imageData&&Z.imageMimeType?{base64:Z.imageData,mimeType:Z.imageMimeType}:null}}),records:n?.placements??{},onRecord:c});u(),E=b.map(A=>({type:"image",attachmentId:A.composite.attachmentId,mimeType:A.composite.mimeType})),P=Object.fromEntries(b.map(A=>[A.imageId,{attachmentId:A.composite.attachmentId,raw:A.raw}]))}const y=new Map(n?Qe(n).map(({n:b,mark:A})=>[A.id,b]):[]),D=p&&P?{...p,imageAttachments:P,markNumbers:y}:p&&{...p,markNumbers:y},$=n&&D?{...s,imageBlocks:[...E,...m.frames,...s.imageBlocks??[]],fileBlocks:[...s.fileBlocks??[],...m.files],workspaceContextStr:[Qt(v,D),m.metadata.length?`[Edited capture outputs]
3
3
  ${JSON.stringify(m.metadata)}`:"",s.workspaceContextStr].filter(Boolean).join(`
4
4
 
5
5
  `),messageMetadata:{...s.messageMetadata,...Xt(v,D),edited_captures:m.metadata}}:s;return u(),$}async function Ta(e,t,n={}){const a=Qe(e);return Promise.all(e.images.map(async r=>{if(n[r.id])return{type:"image",...n[r.id]};const s=t.find(i=>i.id===r.contextItemId);if(!s?.imageData||!s.imageMimeType)throw new Error("dock-evidence-missing-pixels");const o=await Ma({base64:s.imageData,mimeType:s.imageMimeType},r,a.filter(({mark:i})=>i.imageId===r.id));return{type:"image",data:o.base64,mimeType:o.mimeType}}))}function Ca(){return et()}function ms(e){const{clip:t}=e;if(t.status!=="ready"||!t.path)return null;const n=e.marks.filter(s=>s.clipId===t.id&&typeof s.clipMs=="number").sort((s,o)=>s.clipMs-o.clipMs).map(s=>({id:s.id,tool:s.tool,atMs:s.clipMs,...s.element?.name?{label:s.element.name.slice(0,200)}:{}})),a=Zt(e.evidence??void 0,t.id),r=a?t.media:void 0;return{kind:"recording",workspaceId:e.workspaceId,agentId:e.agentId,attachmentId:a?.attachmentId??t.id,sourceRevision:a?`${a.id}:${a.revision}`:t.path,attachmentPath:t.path,title:"",durationMs:t.durationMs,marks:n,provenance:a?{...a.audio==="unknown"?{}:{hasMicAudio:a.audio==="available"},visuals:a.visuals}:{hasMicAudio:t.hasMicAudio,visuals:n.length>0?"baked-marks":"clean"},...a&&r?{source:a,saved:r.saved??null,transcript:r.transcript??null}:{}}}async function ps(e){if(!Ca())return{ok:!1,error:"unavailable"};try{return await on().invoke(sn.OPEN,e)??{ok:!1,error:"unavailable"}}catch{return{ok:!1,error:"transport"}}}function fs(e){let t=null,n=null;const a=i=>e.releaseMediaJob?.(i).catch(()=>{});function r(){const i=t;t=null,!(!i||i.taken||i.stopped)&&(i.stopped=!0,clearTimeout(i.timer),a(i.id))}function s(i,l,c){if(t?.key===i||n===i||(r(),n=null,!e.adoptMediaJob||!e.exportMedia||!c()||W(l)))return;const d=structuredClone(l),u=d.saved??re(d.source,d.source.capturedMarks??[],d.transcript),g=_e(u,d.source,d.transcript);if(d.source.kind!=="recording"||d.source.visuals!=="clean"||g.errors.length||!g.clips.length||u.voice==="transcript"&&d.transcript?.status!=="ready")return;const p={...d,saved:u},m=crypto.randomUUID(),w={key:i,mediaKey:JSON.stringify(p),id:m,current:c,taken:!1,stopped:!1,settled:!1,failed:!1,timer:setTimeout(()=>{t===w&&(n=i,r())},3e4),result:Promise.resolve({error:new Error("not-started")})};t=w,w.result=lt(p,m,e,()=>!w.stopped&&w.current()).then(async f=>w.stopped||!w.current()?(await a(m),{error:new Error("media-send-retired")}):{value:f},async f=>(w.failed=!0,t===w&&(n=i),await a(m),{error:f})).finally(()=>{w.settled=!0})}async function o(i,l,c){const d=t;if(!d||d.key!==i||d.mediaKey!==JSON.stringify(l)||d.stopped||d.taken||!c())return null;if(d.failed&&d.settled)return r(),null;d.taken=!0,d.current=c,clearTimeout(d.timer),t=null;const u=await d.result;if("error"in u)throw u.error;try{if(!c())throw new Error("media-send-retired");const g=await e.adoptMediaJob?.(d.id);if(!c())throw new Error("media-send-retired");return!g?.ok||!g.value?(await a(d.id),null):u.value}catch(g){throw await a(d.id),g}}return{warm:s,take:o,cancel:r}}function hs(e={}){const t=a=>cn(a,typeof e=="function"?e():e),n=a=>vn(t(a));return{actionHints:{get capture(){return{label:h.dock_composer_screenshotAction_label(),shortcut:t("dock.capture")}},get record(){return{label:h.ui_shortcuts_dockRecord_label(),shortcut:t("dock.record")}},get dictate(){return{label:h.dock_shortcut_dictate_label()}}},get capture(){return h.dock_composer_capture_tooltip({shortcut:n("dock.capture")})},captureMode:{get window(){return h.dock_composer_captureWindow_tooltip({shortcut:n("dock.capture")})},get region(){return h.dock_composer_captureRegion_tooltip({shortcut:n("dock.capture")})}},captureModes:{fullscreen:h.dock_composer_captureFullscreen_label(),window:h.dock_composer_captureWindow_label(),region:h.dock_composer_captureRegion_label()},captureOptions:h.dock_composer_captureModes_ariaLabel(),captureLimit:h.dock_composer_captureLimit_tooltip(),clipLimit:h.dock_composer_clipLimit_tooltip({limit:H(ae.clips)}),get record(){return h.dock_composer_record_tooltip({shortcut:n("dock.record")})},stopRecording:h.dock_composer_stopRecording_tooltip(),annotationTools:h.annotation_toolbar_ariaLabel(),annotateCurrent:a=>h.dock_composer_annotate_ariaLabel({tool:a}),tools:{pick:h.dock_composer_pick_label(),box:h.dock_composer_box_label(),pen:h.dock_composer_pen_label(),arrow:h.annotation_arrow_label()},get dictate(){return h.dock_shortcut_dictate_label()},stopDictating:h.dock_composer_stopDictating_tooltip(),annotating:h.dock_composer_annotating_status(),recording:h.dock_composer_recording_status(),markUp:h.dock_composer_markUp_label(),remove:h.chat_contextChip_remove_label(),play:h.dock_composer_play_label(),edit:h.dock_composer_edit_label(),done:h.dock_composer_done_label(),attachments:h.context_attachments_title_label(),retry:h.chat_shared_retry_label(),attachmentPending:h.dock_composer_attachmentPending_status(),attachmentFailed:h.dock_composer_attachmentFailed_error(),image:a=>h.dock_composer_image_ariaLabel({n:H(a)}),clip:a=>h.dock_composer_clip_ariaLabel({duration:a}),recordingReference:(a,r)=>r?h.dock_composer_recordingEnd_chip({n:H(a)}):h.dock_composer_recordingStart_chip({n:H(a)}),speechError:a=>a.includes("permission")?h.dock_composer_speechPermission_error():["unsupported-platform","helper-missing","recognizer-unavailable","locale-unsupported","assets-unavailable","unavailable"].includes(a)?h.dock_composer_speechUnavailable_error():h.dock_composer_speechFailed_error()}}function gs(e,t){return{enabled:e,limit:ae.files,excludedIds:t,unavailableMessage:h.dock_composer_filesUnavailable_error(),limitMessage:h.dock_composer_fileLimit_error({limit:H(ae.files)})}}function Ea(e){try{return new URL(e.pageUrl).hostname||e.pageUrl}catch{return e.pageUrl}}function ys(e,t){return e.targetAgentId===t}function ws(e){const t=e.element,n=e.viewport,a=Ea(e),r=t?`<${t.tagName.toLowerCase()}> · ${a}`:e.title||a,s=["<browser-element-capture>",`Page URL: ${e.pageUrl}`,`Page title: ${e.title}`,...t?[`DOM path: ${t.domPath}`,`CSS selector: ${t.selector}`,`Text snippet: ${t.textSnippet}`,...t.sourceRef?[`Source ref: ${t.sourceRef}`]:[],...n?[`Viewport: ${n.width}×${n.height}`]:[],`Element bounds: ${t.rect.width}×${t.rect.height} at (${t.rect.x}, ${t.rect.y})`]:[],"</browser-element-capture>"].join(`
@@ -8,5 +8,5 @@ ${JSON.stringify(m.metadata)}`:"",s.workspaceContextStr].filter(Boolean).join(`
8
8
  \`\`\`
9
9
  ${o}
10
10
  \`\`\`]`)}return Da(a.join(`
11
- `),e)}function bs(e,t,n){if(e==="suggested-prompt")return{fields:{},hasAttachments:!1,cleanup:{clearInput:!1,followBottom:!0,historyText:null}};const a=n(),{imageBlocks:r,fileBlocks:s}=Ra(a.contextItems);return{fields:{contextItems:a.contextItems,workspaceContextStr:xa(a.contextItems,a.checkedPanels,a.checkedSelections),noteIds:a.noteIds,...r.length>0?{imageBlocks:r}:{},...s.length>0?{fileBlocks:s}:{},...a.pickedMentions?{messageMetadata:a.pickedMentions}:{}},hasAttachments:r.length>0||s.length>0,cleanup:{clearInput:!0,followBottom:!0,historyText:t}}}function ks(e){switch(e.kind){case"tooLong":return h.chat_goal_tooLong_error({max:H(Tn)});case"attachments":return h.chat_goal_attachments_error();case"retired":return h.chat_goal_retired_error();case"workspaceRetired":return h.chat_goal_workspaceRetired_error();case"invalid":case"failed":return h.chat_goal_failed_error()}}const Pa="chat-read:",q=new Map,ye=new Set;function _s(e,t){let n=q.get(e);n||(n=new Set,q.set(e,n)),n.add(t)}function vs(e,t){const n=q.get(e);if(!(!n||!n.delete(t))&&n.size===0){q.delete(e);for(const a of[...ye])a(e)}}function Ss(e){return ye.add(e),()=>ye.delete(e)}function As(e){return q.has(e)}function Ms(e){const t=q.get(e);if(!t)return!1;for(const n of t)if(!n.startsWith(Pa))return!0;return!1}function Ba(e,t,n){const a=e.state.pendingSubmissions.byAgentId[t.agentId];if(!a||!Ge(a.scope,t))return null;const r={...structuredClone(n),id:crypto.randomUUID(),createdAt:Date.now()};e.dispatch(Bt(t,r));const s=e.state.pendingSubmissions.byAgentId[t.agentId];return s&&R(s.submissions,r.id)?r:null}function La(e,t,n,a,r){const s=Be.select(e.state,n),o=pe.select(e.state)?.principal.id,i=Ue(e.state);if(!s||!o||!i)return null;const l=Cn(t,n),c={agentId:t,workspaceId:n,principalId:o,participation:s,authority:i,owner:l.key,lifetime:e.state.pendingSubmissions.byAgentId[t]?.scope.lifetime??crypto.randomUUID()},d=()=>l.isCurrent(e.state.agentSessions?.byAgentId[t]?.workspaceId)&&Be.select(e.state,n)===s&&pe.select(e.state)?.principal.id===o&&Ue(e.state)===i;if(!d())return null;e.dispatch(Pt(c,a,Wt.select(e.state,n)));const u=Ba(e,c,r);return u?{scope:c,submission:u,isCurrent:()=>{const g=e.state.pendingSubmissions.byAgentId[t];return d()&&!!g&&Ge(g.scope,c)&&(!!R(g.operations,u.id)||!!R(g.submissions,u.id))}}:null}function we(e,t,n){if(!n.text.trim()&&!n.imageBlocks?.length&&!n.fileBlocks?.length)return null;const a=n.userAppMessageId??En();return La(e,t,n.wsId,pe.select(e.state)?.capabilities.submissionCorrelation,{content:n.text.trim(),appMessageId:a,destination:!n.forceSubmit&&qt.select(e.state,t)?"queue":"conversation",contextItems:n.contextItems,imageBlocks:n.imageBlocks,fileBlocks:n.fileBlocks,messageMetadata:n.messageMetadata})}function Oa(e,t,n){const a=we(e,t,n);return a?(e.dispatch(Ye(t,{...n,userAppMessageId:a.submission.appMessageId,submission:{scope:a.scope,id:a.submission.id}})),!0):!1}async function Ua(e,t,n,a){const r=n.submission;if(!r)return"legacy";const s=r.reference,o=()=>s.scope.agentId===e&&s.scope.workspaceId===t&&Xe.select(M.state,e)===n?bn.select(M.state,s.scope):void 0,i=o();if(!i)return null;if(!i.supported)return"legacy";const l={wsId:t,text:n.text,imageBlocks:n.options?.imageBlocks,fileBlocks:n.options?.fileBlocks,noteIds:n.options?.noteIds,messageMetadata:n.options?.messageMetadata,model:a??n.options?.model};if(r.outcome==="rejected"){const p=R(i.tombstones,s.id);return R(i.submissions,s.id)||p&&p.reason!=="rejected"?null:we(M,e,l)}if(r.outcome==="accepted")return we(M,e,l);await Promise.all([Dn(e,t).catch(()=>{}),Rn(e,t).catch(()=>{})]);const c=o();if(!c||R(c.submissions,s.id)?.status!=="uncertain")return null;const{notify:d}=await fe(async()=>{const{notify:p}=await import("./KMO8sO00.js").then(m=>m.i);return{notify:p}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37]),import.meta.url);if(o()!==c)return null;let u=!1;const g=()=>{u=!0};return d.warning(h.agent_chatSend_uncertainRetry_description(),{key:`submission-retry:${t}:${e}:${s.id}`,duration:Number.POSITIVE_INFINITY,action:{label:h.agent_chatSend_resend_label(),onClick:()=>{if(u)return;u=!0;const p=o();!p||p.generation!==c.generation||p.submissions!==c.submissions||p.observationVersion!==c.observationVersion||R(p.submissions,s.id)?.status!=="uncertain"||Oa(M,e,l)}},cancel:{label:h.chat_richInput_cancel_label(),onClick:g},onDismiss:g}),null}async function Is(e,t,n){const a=Xe.select(M.state,e),r=a?.submission?await Ua(e,t,a,n):"legacy";if(r){if(r==="legacy"){await M.dispatch(n===void 0?Lt(e,t):Ot(e,t,n));return}!r.isCurrent()||!a||M.dispatch(Ye(e,{wsId:t,text:a.text,imageBlocks:a.options?.imageBlocks,fileBlocks:a.options?.fileBlocks,noteIds:a.options?.noteIds,messageMetadata:a.options?.messageMetadata,model:n??a.options?.model,userAppMessageId:r.submission.appMessageId,submission:{scope:r.scope,id:r.submission.id}}))}}const Ts=M.createSelector((e,t)=>{const n=R(e.chatDrafts.owners,t);return n?{restore:n.restore,saves:Je(n.saves),shared:n.restore?e.chatDrafts.shared[JSON.stringify([n.restore.workspaceId,n.restore.agentId])]:void 0}:void 0});function $a(e,t){return t.workspaceId===e&&!t.retiredAt&&!t.pendingDeleteAt&&t.status!==ke.Deleted&&!t.notificationsMuted&&$t(t)==="topLevel"}function Na(e){const t=e.metadata?.pendingQuestionsMessageId;return typeof t=="string"&&t.length>0&&!Bn(e.metadata,t)?t:null}function Ha(e){return e.status===ke.Error&&!jt(Vt(e))}function Cs(e,t){return t.filter(n=>$a(e,n)).flatMap(n=>{const a=Ut(n),r=Na(n),s=n.status===ke.Error;if(!a&&!r&&!s)return[];const o=a?.timestamp??(s?n.stopReasonTimestamp:void 0);return[{agentId:n.id,agentName:n.name,kind:a?.kind??(s?"failed":"question"),reason:a?.reason,timestamp:o&&Number.isFinite(Date.parse(o))?o:void 0,questionMessageId:r,canRetry:Ha(n)}]})}function Es(e){return e.displayStatus==="failed"?"failed":e.displayStatus==="blocked"?"blocked":e.attention==="review_required"?"review":e.displayStatus==="needs_attention"?"question":e.activity==="agent_running"||e.displayStatus==="in_progress"?"running":e.scriptsRunning===!0?"scripts_running":e.backgroundTasksRunning===!0?"background_tasks_running":e.displayStatus==="pr_ready"?"pr_ready":e.displayStatus==="pr_merged"?"merged":e.displayStatus==="complete"?"complete":e.attention==="unread"?"unread":e.displayStatus==="pr_open"||e.displayStatus==="pr_queued"?e.displayStatus:"idle"}function Ds(e){const t=e.kind==="prs"?e.organization?.trim().toLowerCase():void 0;return{key:JSON.stringify([e.kind,e.workspaceId,t||null,[...new Set((t?[]:e.repositories).map(n=>JSON.stringify([n.key,n.owner,n.name])))].sort()]),hasGitHubRepositories:!!t||e.repositories.some(n=>!!n.owner),hasLocalRepositories:!t&&e.repositories.some(n=>!n.owner)}}function Te(e){const t=Sn(e);if(t?.kind!=="pr"||!Number.isSafeInteger(t.number)||t.number<=0)return null;const n=t.owner.toLowerCase(),a=t.repo.toLowerCase();return{owner:n,repo:a,number:t.number,id:`${n}/${a}#${t.number}`,url:`https://github.com/${n}/${a}/pull/${t.number}`}}function Rs(e,t,n,a){const r=e.filter(s=>a?a.includes(s.id):n?s.repositoryOwner?.toLowerCase()===n.toLowerCase():t.some(o=>o.owner?.toLowerCase()===s.repositoryOwner?.toLowerCase()&&o.name.toLowerCase()===s.repositoryName?.toLowerCase()));return[...new Map(r.flatMap(s=>[...(s.pullRequests??[]).map(o=>o.url),s.activePullRequest?.url,s.prUrl]).flatMap(s=>{const o=s?Te(s):null;return o?[[o.id,{owner:o.owner,repo:o.repo,number:o.number}]]:[]})).values()].sort((s,o)=>`${s.owner}/${s.repo}#${s.number}`.localeCompare(`${o.owner}/${o.repo}#${o.number}`))}function xs(e,t){const[n]=t;return t.length!==1||e.owner?.toLowerCase()!==n?.owner?.toLowerCase()||e.repo?.toLowerCase()!==n?.name.toLowerCase()}const Ps=M.createSelector(e=>e.homeIntegrations),Bs=M.createSelector(e=>{const t=e.homeIntegrations;return!t.linkedItems||!Object.keys(t.linkedItems).length?t:{...t,items:[...new Map([...Object.values(t.linkedItems),...t.items].map(n=>[n.id,n])).values()].sort((n,a)=>(a.updatedAt??"").localeCompare(n.updatedAt??""))}}),wt=M.createSelector(e=>Je(e.workspace.workspaces).flatMap(t=>[...(t.pullRequests??[]).map(n=>n.url),t.activePullRequest?.url,t.prUrl].filter(n=>!!n).map(n=>({url:Te(n)?.url??n.replace(/\/$/,"").toLowerCase(),workspaceId:t.id,name:t.title||t.id})))),Ls=M.createSelector(e=>{const t=e.homeIntegrations.detail?.url,n=t?Te(t)?.url??t.replace(/\/$/,"").toLowerCase():void 0;return wt.select(e).find(a=>a.url===n)??null}),Os=M.createSelector(e=>wt.select(e).map(t=>t.url)),Fa=["setup-retry-not-remote","setup-retry-not-failed","setup-retry-shared-checkout","setup-retry-no-script","agent-busy","agent-not-running","machine-update-required","machine-unreachable"];function Us(e,t){return e&&t?.state==="failed"}function Ka(e){const t=e??{},n=typeof t.message=="string"?t.message:"";if(t.rpcCode===-32601||t.code==="METHOD_NOT_FOUND")return{ok:!1,code:"unsupported",message:n};const a=typeof t.data?.code=="string"?t.data.code:t.code;return{ok:!1,code:Fa.find(s=>s===a)??"unknown",message:n}}async function $s(e,t=it){try{const n=await t("agent.retrySetup",{workspaceId:e.workspaceId,agentId:e.agentId}),a=ln.safeParse(n?.setup);return{ok:!0,setup:a.success?a.data:null}}catch(n){return Ka(n)}}function Wa(e){return e.code==="unsupported"?h.remoteAgent_setupRetry_unsupported_error():e.message.trim()||h.remoteAgent_setupRetry_generic_error()}function Ns(e,t){Ln.error(h.remoteAgent_setupRetry_failed_title({machine:e}),{description:Wa(t)})}let te=null;function Hs(e){return te=e,()=>{te===e&&(te=null)}}function Fs(){return te}function Ks(e){return[...e.groups.length>0?e.groups.filter(n=>n.expanded).flatMap(n=>n.items):e.workspaces,...e.asideExpanded?e.aside:[]].map(n=>n.id)}function Ws(e,t,n){if(e.length===0)return null;const a=t===null?-1:e.indexOf(t);return a===-1?e[0]:e[a+(n==="clockwise"?1:-1)]??null}let F=[];function qs(e,t={}){const n={source:e,fallback:t.fallback===!0};return F=[...F,n],()=>{F=F.filter(a=>a!==n)}}function js(){const e=F.findLast(n=>!n.fallback);return e?e.source:F.findLast(n=>n.fallback&&(n.source.available?.()??!0))?.source??null}function Vs(e){if(!e?.isConnected||e.closest("[inert]"))return!1;const t=e.ownerDocument.querySelectorAll('[aria-modal="true"]');return Array.from(t).every(n=>n.contains(e))}const zs=ct("conversationGoal/commandSend","conversationGoal/commandSendRequested"),Gs=ct("conversationGoal/set","conversationGoal/setRequested");function Ys(e){return In(e)}function qa(e){return Mn(e)}function ja(e,t){return!e||!t?!1:e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function me(e){if(e.length===0)return[];const t=[];let n=null;for(const a of e){const r=a.timestamp?typeof a.timestamp=="string"?new Date(a.timestamp):a.timestamp:new Date;(!n||!ja(n.date,r))&&(n={date:r,label:qa(r),messages:[]},t.push(n)),n.messages.push(a)}return t}function Js(e){const t=new Map;return e.map(({date:n})=>{const a=`${n.getFullYear()}-${n.getMonth()+1}-${n.getDate()}`,r=t.get(a)??0;return t.set(a,r+1),r===0?a:`${a}#${r}`})}function Xs(e,t){const n=new Map;let a=t?null:void 0;for(const r of e.groups)for(const s of r.messages)a!==void 0&&n.set(s.id,a),s.role==="user"&&!Un(s)&&(a=s);return n}function Va(e){return`${e.getFullYear()}-${e.getMonth()+1}-${e.getDate()}`}function qe(e,t){const n=new Map;return e.map(a=>{const r=`${t}-${Va(a.date)}`,s=(n.get(r)??0)+1;return n.set(r,s),{...a,groupKey:s===1?r:`${r}-${s}`}})}function za(e,t){if(e.length===0||t.length===0)return e;const n=new Set(t.map(s=>s.id)),a=new Set(t.map(s=>s.appMessageId).filter(s=>typeof s=="string"&&s.length>0)),r=e.filter(s=>!n.has(s.id)&&!(typeof s.appMessageId=="string"&&s.appMessageId.length>0&&a.has(s.appMessageId)));return r.length===e.length?e:r}function Qs(e,t,n){return e=za(e,t),e.length===0?{groups:me(t),detached:!1,hiddenTail:[]}:n?{groups:qe(me(e),"h"),detached:!0,hiddenTail:t}:{groups:qe(me([...e,...t]),"d"),detached:!1,hiddenTail:[]}}function Zs(e){const{scrollTop:t,threshold:n,fetching:a,exhausted:r,historyCount:s,tailCount:o,tailTruncated:i,totalMessages:l,spacerAbove:c=0}=e;return t>n+c||a||r?!1:s>0||i||l>o+s}const eo=300;function to(e){const{fetching:t,chainEvaluationPending:n,visible:a,hideArmed:r}=e;return t||n?a&&!r?"none":"show":a&&!r?"arm-hide":"none"}const je=24,Ga=320;function Ce(e){return Number.isFinite(e)?Math.min(Ga,Math.max(je,e)):je}const Ya=.2,Ja=.12;function Xa(e,t,n=Ya){const a=Ce(t);return e===null||!Number.isFinite(e)?a:e+n*(a-e)}function no(e,t){const n=Ce(t??Number.NaN);return{above:Math.round(Math.max(0,e.above)*n),below:Math.round(Math.max(0,e.below)*n)}}function ao(e){const{totalMessages:t,residentCount:n,exhausted:a,residentContentHeight:r,currentSpacerHeight:s,viewportHeight:o}=e;let i=e.rowHeightEma;n>0&&r>0&&(i=Xa(i,r/n));const l=e.unloadedRows??t-n,d=a||t<=0||n<=0||l<=0||i===null?0:Math.round(l*i),u=Math.abs(d-s);return u===0?{spacerHeight:s,rowHeightEma:i,applied:!1,scrollTopDelta:0}:d===0||s===0||u>s*Ja||o>0&&u>o?{spacerHeight:d,rowHeightEma:i,applied:!0,scrollTopDelta:d-s}:{spacerHeight:s,rowHeightEma:i,applied:!1,scrollTopDelta:0}}const Qa=On,Za=2;function ro(e){const{scrollTop:t,spacerAboveHeight:n,rowHeightEstimate:a,pageSize:r=Qa,nearPages:s=Za}=e;if(n<=0||t>=n)return"serial";const o=Ce(a??Number.NaN);return(n-Math.max(0,t))/o>s*r?"seek":"serial"}const bt=200,er=1;function so(e,t,n=bt){const a=t.timestamp-n;return[...e.filter(r=>r.timestamp>=a),t]}function oo(e){const{samples:t,viewportHeight:n,windowMs:a=bt,viewportFactor:r=er}=e;if(n<=0||t.length<2)return"gentle";const s=t[t.length-1].timestamp-a,o=t.filter(l=>l.timestamp>=s);if(o.length<2)return"gentle";let i=0;for(let l=1;l<o.length;l+=1)i+=Math.abs(o[l].scrollTop-o[l-1].scrollTop);return i>n*r?"rapid":"gentle"}function io(e){const{scrollTop:t,spacerAboveHeight:n,unloadedRowsAbove:a}=e;if(a<=0||n<=0)return 0;const r=Math.min(1,Math.max(0,t/n));return Math.min(a-1,Math.max(0,Math.floor(r*a)))}function co(e){const{totalMessages:t,residentCount:n,exhausted:a,startOrdinalEstimate:r,detachedFromTail:s}=e,o=Math.max(0,t-n);if(!s)return{above:a?0:o,below:0};const i=Math.max(0,e.hiddenTailCount??0);if(a)return{above:0,below:o+i};if(r!==null){const c=Math.min(o,Math.max(0,Math.round(r)));return{above:c,below:o-c+i}}const l=Math.min(o,Math.max(0,Math.round(e.holeRowsEstimate??0)));return{above:o-l,below:l+i}}function lo(e){const{exhausted:t,historyCount:n,tailCount:a,tailTruncated:r,totalMessages:s}=e;return t?!0:n>0?!1:!r&&s<=a}const tr="intent.drafts.sync",nr="intent.drafts.changed",ar=O({id:C(),type:C(),label:C(),description:C().optional(),content:C().optional(),path:C().optional(),imageData:C().optional(),imageMimeType:C().optional(),attachmentId:C().optional(),attachmentMimeType:C().optional(),attachmentSize:ce().optional(),sourcePath:C().optional(),placementStatus:z("failed").optional(),screen:$n().optional()}),kt=O({text:C(),attachments:Nn(ar)}),G={provenance:C().min(1),workspaceId:C().min(1),agentId:C().min(1)},ne={lifetime:C(),revision:ce().int().nonnegative()};Hn("kind",[O({...G,kind:z("read")}),O({...G,...ne,kind:z("edit"),origin:C().min(1),sequence:ce().int().positive(),snapshot:kt}),O({...G,...ne,kind:z("flush")}),O({...G,...ne,kind:z("clear"),origin:C().min(1)})]);const _t=O({...G,...ne,origin:C(),sequence:ce().int().nonnegative(),snapshot:kt}),rr=O({accepted:Fn(),draft:_t});function sr(e,t,n=t){const a=new Map,r=new Set,s=crypto.randomUUID();let o=0,i=!1;const l=()=>{const f=t();if(i||!f)throw new Error("draft-authority-unavailable");return f},c=()=>{const f=n();if(!f||i)throw new Error("draft-authority-unavailable");return()=>{if(i||n()!==f)throw new Error("draft-authority-changed")}},d=(f,k,_)=>{const I=JSON.stringify([f,k,_]);let S=a.get(I);return S||(S={dirty:0},a.set(I,S)),S},u=(f,k)=>{if(i||f.provenance!==t())return;const _=d(f.provenance,f.workspaceId,f.agentId);if(!(_.value?.lifetime===f.lifetime&&_.value.revision>f.revision)&&(_.value=f,k&&_.dirty===0))for(const I of r)I(f)},g=e.subscribe(f=>{const k=_t.safeParse(f);k.success&&u(k.data,!0)}),p=async(f,k)=>{k();const _=rr.parse(await e.request(f));if(k(),f.provenance!==l()||_.draft.provenance!==f.provenance)throw new Error("draft-authority-changed");if(!_.accepted)throw u(_.draft,!1),new Error("draft-changed-in-another-editor");return _.draft},m=async(f,k)=>{const _=l(),I=c(),S=d(_,f,k);S.tail&&await S.tail;const v=await p({kind:"read",provenance:_,workspaceId:f,agentId:k},I);return u(v,!1),v},w=(f,k,_)=>{const I=l(),S=c(),v=d(I,f,k),B=v.tail??(v.value?Promise.resolve(v.value):p({kind:"read",provenance:I,workspaceId:f,agentId:k},S));v.dirty+=1;const E=B.then(P=>p(_(P),S));return v.tail=E,E.then(P=>{v.dirty-=1,v.tail===E&&(v.tail=void 0),u(P,!0)},()=>{v.dirty-=1,v.tail===E&&(v.tail=void 0)}),E};return{authority:()=>i?null:n(),read:m,async edit(f,k,_,I){const S=++o;return w(k,_,v=>({kind:"edit",provenance:v.provenance,workspaceId:k,agentId:_,lifetime:v.lifetime,revision:v.revision,origin:f,sequence:S,snapshot:I}))},async flush(f,k){const _=l(),I=c(),S=d(_,f,k),v=await(S.tail??(S.value?Promise.resolve(S.value):m(f,k)));await p({kind:"flush",provenance:_,workspaceId:f,agentId:k,lifetime:v.lifetime,revision:v.revision},I)},async clear(f,k){await w(f,k,_=>({kind:"clear",provenance:_.provenance,workspaceId:f,agentId:k,lifetime:_.lifetime,revision:_.revision,origin:s}))},subscribe(f){return r.add(f),()=>{r.delete(f)}},dispose(){i=!0,g(),r.clear(),a.clear()}}}let U=null;async function uo(e,t,n,a,r){const s=U;if(!s)throw new Error("draft-shared-transport-unavailable");const o=()=>{if(U!==s||s.authority()!==r)throw new Error("draft-authority-changed")};o(),await s.edit(e,t,n,a),o(),await s.flush(t,n),o()}async function mo(e,t){await Promise.resolve(),U&&await U.flush(e,t)}function po(){if(!et())return null;const e=sr({request:n=>it(tr,n),subscribe:n=>An(a=>{a.method===nr&&n(a.params)})},()=>xn(M.state),()=>Pn(M.state));U=e;const t=e.dispose;return e.dispose=()=>{U===e&&(U=null),t()},e}const vt=new Map;function St(e,t){return`${e}\0${t}`}function fo(e,t){return vt.get(St(e,t))}function ho(e,t,n){vt.set(St(e,t),n)}const go=M.createSelector((e,t,n)=>{const a=e.chatPanelUi.byWorkspaceId[t];return a?R(a.userMessageIndexes,n):void 0}),yo=M.createSelector((e,t,n)=>{const a=e.chatPanelUi.byWorkspaceId[t];return a?R(a.retryAgents,n):void 0});function or(e){e=Math.max(0,e);const t=Math.floor(e/1e3);if(t<10){const s=e/1e3,o=s.toFixed(1);return o.endsWith(".0")?`${Math.round(s)}s`:`${o}s`}if(t<60)return`${t}s`;const n=Math.floor(t/3600),a=Math.floor(t%3600/60),r=t%60;return n>0?`${n}h ${a}m ${r}s`:`${a}m ${r}s`}function wo(e){return or(Math.max(1e3,Math.round(e/1e3)*1e3))}const ir=new Set(["launch","init","session-create","session-load","prompt"]),cr=new Set(["tool-call","tool-waiting"]);function lr(e){let t=null;for(const n of e)(!t||n.timestamp>=t.timestamp)&&(t=n);return t}function bo(e){return e&&ir.has(e)?"pulse":e&&cr.has(e)?"twist":"bloom"}const At="stalled";function ko(e,t){const n=lr(e);return!n||n.phase!==At||typeof t=="number"&&t>n.timestamp?null:n}function _o(e){let t=null;for(const n of e)n.phase!==At&&(!t||n.timestamp>=t.timestamp)&&(t=n);return t}const Ve={get title(){return h.chat_streamingStatus_sessionCorrupted_title()},get message(){return h.chat_streamingStatus_sessionCorrupted_message()}},dr=/^session\/[a-z_]+(?: failed)?:\s*/i;function ur(e){const n=(e.split(`
12
- `).map(a=>a.trim()).find(Boolean)??"").replace(dr,"");return n.charAt(0).toUpperCase()+n.slice(1)}function vo(e,t){return e?t===!0?{corrupted:!0,title:Ve.title,message:Ve.message,detail:e}:{corrupted:!1,title:h.chat_streamingStatus_responseFailed_label(),message:ur(e),detail:null}:null}const So=M.createSelector((e,t)=>R(e.questionUi.consumers,t)),mr=3e4,J=new Map;function Ao(e,t){const n=J.get(e);n&&clearTimeout(n.timer);const a=setTimeout(()=>J.delete(e),mr);J.set(e,{value:t,timer:a})}function Mo(e){const t=J.get(e);if(t)return clearTimeout(t.timer),J.delete(e),t.value}const Mt=M.createSelector((e,t,n)=>e.agentWorkers?.byKey[Ht(t,n)]??Nt),pr=M.createSelector((e,t,n)=>{const a=Mt.select(e,t,n);return a.status==="unsupported"?[]:(a.snapshot?.workers??[]).filter(r=>r.status==="running"||r.status==="unknown")}),Io=M.createSelector((e,t,n)=>{const a=Mt.select(e,t,n);return a.status==="failed"?!0:a.status!=="ready"||!a.snapshot?!1:a.snapshot.truncated?!0:a.snapshot.support.status!=="supported"&&pr.select(e,t,n).length>0}),fr=1e3,It={requireViewedAndFocused:!0,requireAssistantTail:!0},X=new Map,x=new Map;let j=null;function Ee(e){(e===void 0||j===e)&&(j=null)}const hr=200;function gr(e,t){if(x.delete(e),x.set(e,t),x.size>hr){const n=x.keys().next().value;n!==void 0&&x.delete(n)}}function Tt(e){for(let t=e.length-1;t>=0;t--){const n=e[t];if(!n.isStreaming&&typeof n.id=="string"&&n.id.length>0)return n}return null}function To(e){return Tt(e)?.id??null}function Co(e){De(e,{requireViewedAndFocused:!0})}function Eo(e){De(e,{requireViewedAndFocused:!1})}function Do(e){Ee(),De(e,It)}function Ro(e){j===e&&(X.has(e)||(j=null,Re(e,It)))}function xo(e){for(const t of e)typeof t!="string"||t.length===0||(Ct(t),Ee(t),Re(t,{requireViewedAndFocused:!1}))}function Ct(e){const t=X.get(e);t&&(clearTimeout(t.timer),X.delete(e))}function De(e,t){Ct(e),Ee(e);const n=setTimeout(()=>{X.delete(e),Re(e,t)},fr);X.set(e,{timer:n,gates:t})}let ze=null;function yr(){return ze??=Promise.all([fe(()=>import("./BQ1b28aV.js"),__vite__mapDeps([38,1,2,3,4,5,6,7,8,9,10,11,39,40]),import.meta.url),fe(()=>import("./AXE1aiRo.js").then(e=>e.s),__vite__mapDeps([41,42,8,3,1,2,4,5,6,7,9,10,11,20,21,16,17,22,43,44,45,19,26]),import.meta.url)]).then(([e,t])=>({appStore:e.store,appClient:t.appClient})),ze}async function Re(e,t){let n=null;try{const{appStore:a,appClient:r}=await yr(),s=a.state;if(t.requireViewedAndFocused&&(s.unreadTracking?.currentlyViewedAgentId!==e||typeof document<"u"&&!document.hasFocus()))return;const o=s.agentSessions?.byAgentId[e];if(!o)return;const i=typeof o.workspaceId=="string"?o.workspaceId:"";if(i.length===0)return;if(t.requireAssistantTail&&s.chatState?.byAgentId[e]?.initialHistoryPending){j=e;return}const l=Tt(o.messages??[]);if(!l){t.requireAssistantTail&&(j=e);return}if(t.requireAssistantTail&&l.role!=="assistant")return;const c=l.id;if(x.get(e)===c)return;gr(e,c),n=c,!(await r.agents.markSeen({workspaceId:i,agentId:e,messageId:c})).success&&x.get(e)===n&&x.delete(e)}catch{n!==null&&x.get(e)===n&&x.delete(e)}}const ie=new Map;function Et(e,t){return`${e}\0${t}`}function Po(e,t){return ie.get(Et(e,t))}function Bo(e,t,n){ie.set(Et(e,t),n)}function Lo(e){if(e.length===0)return;const t=new Set(e);for(const n of[...ie.keys()]){const a=n.slice(n.indexOf("\0")+1);t.has(a)&&ie.delete(n)}}export{ks as $,Gn as A,es as B,ms as C,L as D,cs as E,za as F,ds as G,Pa as H,Ra as I,Xn as J,mo as K,wo as L,fr as M,Ys as N,eo as O,ko as P,Po as Q,bt as R,fo as S,js as T,Cs as U,je as V,Fs as W,Es as X,_o as Y,bo as Z,zs as _,_s as a,Ao as a$,Gs as a0,As as a1,Ms as a2,Ks as a3,rs as a4,sa as a5,Xs as a6,as as a7,lo as a8,Y as a9,vs as aA,Ee as aB,Is as aC,Yr as aD,no as aE,$s as aF,pr as aG,Mt as aH,Io as aI,Ts as aJ,zr as aK,Gr as aL,Vr as aM,Ps as aN,Ls as aO,Bs as aP,Os as aQ,wt as aR,So as aS,yo as aT,go as aU,Bo as aV,ho as aW,Zs as aX,ns as aY,xs as aZ,co as a_,os as aa,ss as ab,Vs as ac,Xr as ad,io as ae,xo as af,Ro as ag,Co as ah,Eo as ai,Do as aj,To as ak,Ns as al,to as am,Ss as an,ps as ao,Wn as ap,uo as aq,is as ar,bs as as,us as at,Ua as au,ht as av,Qr as aw,qs as ax,ao as ay,Hs as az,we as b,Ws as b0,Oa as b1,Mo as b2,oa as b3,ts as b4,so as c,ys as d,ws as e,Js as f,Zr as g,xa as h,Jr as i,Us as j,ca as k,ia as l,oo as m,ro as n,Lo as o,Rs as p,Qs as q,gs as r,hs as s,ls as t,po as u,fs as v,vo as w,Ds as x,Ca as y,ge as z};
11
+ `),e)}function bs(e,t,n){if(e==="suggested-prompt")return{fields:{},hasAttachments:!1,cleanup:{clearInput:!1,followBottom:!0,historyText:null}};const a=n(),{imageBlocks:r,fileBlocks:s}=Ra(a.contextItems);return{fields:{contextItems:a.contextItems,workspaceContextStr:xa(a.contextItems,a.checkedPanels,a.checkedSelections),noteIds:a.noteIds,...r.length>0?{imageBlocks:r}:{},...s.length>0?{fileBlocks:s}:{},...a.pickedMentions?{messageMetadata:a.pickedMentions}:{}},hasAttachments:r.length>0||s.length>0,cleanup:{clearInput:!0,followBottom:!0,historyText:t}}}function ks(e){switch(e.kind){case"tooLong":return h.chat_goal_tooLong_error({max:H(Tn)});case"attachments":return h.chat_goal_attachments_error();case"retired":return h.chat_goal_retired_error();case"workspaceRetired":return h.chat_goal_workspaceRetired_error();case"invalid":case"failed":return h.chat_goal_failed_error()}}const Pa="chat-read:",q=new Map,ye=new Set;function _s(e,t){let n=q.get(e);n||(n=new Set,q.set(e,n)),n.add(t)}function vs(e,t){const n=q.get(e);if(!(!n||!n.delete(t))&&n.size===0){q.delete(e);for(const a of[...ye])a(e)}}function Ss(e){return ye.add(e),()=>ye.delete(e)}function As(e){return q.has(e)}function Ms(e){const t=q.get(e);if(!t)return!1;for(const n of t)if(!n.startsWith(Pa))return!0;return!1}function Ba(e,t,n){const a=e.state.pendingSubmissions.byAgentId[t.agentId];if(!a||!Ge(a.scope,t))return null;const r={...structuredClone(n),id:crypto.randomUUID(),createdAt:Date.now()};e.dispatch(Bt(t,r));const s=e.state.pendingSubmissions.byAgentId[t.agentId];return s&&R(s.submissions,r.id)?r:null}function La(e,t,n,a,r){const s=Be.select(e.state,n),o=pe.select(e.state)?.principal.id,i=Ue(e.state);if(!s||!o||!i)return null;const l=Cn(t,n),c={agentId:t,workspaceId:n,principalId:o,participation:s,authority:i,owner:l.key,lifetime:e.state.pendingSubmissions.byAgentId[t]?.scope.lifetime??crypto.randomUUID()},d=()=>l.isCurrent(e.state.agentSessions?.byAgentId[t]?.workspaceId)&&Be.select(e.state,n)===s&&pe.select(e.state)?.principal.id===o&&Ue(e.state)===i;if(!d())return null;e.dispatch(Pt(c,a,Wt.select(e.state,n)));const u=Ba(e,c,r);return u?{scope:c,submission:u,isCurrent:()=>{const g=e.state.pendingSubmissions.byAgentId[t];return d()&&!!g&&Ge(g.scope,c)&&(!!R(g.operations,u.id)||!!R(g.submissions,u.id))}}:null}function we(e,t,n){if(!n.text.trim()&&!n.imageBlocks?.length&&!n.fileBlocks?.length)return null;const a=n.userAppMessageId??En();return La(e,t,n.wsId,pe.select(e.state)?.capabilities.submissionCorrelation,{content:n.text.trim(),appMessageId:a,destination:!n.forceSubmit&&qt.select(e.state,t)?"queue":"conversation",contextItems:n.contextItems,imageBlocks:n.imageBlocks,fileBlocks:n.fileBlocks,messageMetadata:n.messageMetadata})}function Oa(e,t,n){const a=we(e,t,n);return a?(e.dispatch(Ye(t,{...n,userAppMessageId:a.submission.appMessageId,submission:{scope:a.scope,id:a.submission.id}})),!0):!1}async function Ua(e,t,n,a){const r=n.submission;if(!r)return"legacy";const s=r.reference,o=()=>s.scope.agentId===e&&s.scope.workspaceId===t&&Xe.select(M.state,e)===n?bn.select(M.state,s.scope):void 0,i=o();if(!i)return null;if(!i.supported)return"legacy";const l={wsId:t,text:n.text,imageBlocks:n.options?.imageBlocks,fileBlocks:n.options?.fileBlocks,noteIds:n.options?.noteIds,messageMetadata:n.options?.messageMetadata,model:a??n.options?.model};if(r.outcome==="rejected"){const p=R(i.tombstones,s.id);return R(i.submissions,s.id)||p&&p.reason!=="rejected"?null:we(M,e,l)}if(r.outcome==="accepted")return we(M,e,l);await Promise.all([Dn(e,t).catch(()=>{}),Rn(e,t).catch(()=>{})]);const c=o();if(!c||R(c.submissions,s.id)?.status!=="uncertain")return null;const{notify:d}=await fe(async()=>{const{notify:p}=await import("./CI0C7_h-.js").then(m=>m.i);return{notify:p}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37]),import.meta.url);if(o()!==c)return null;let u=!1;const g=()=>{u=!0};return d.warning(h.agent_chatSend_uncertainRetry_description(),{key:`submission-retry:${t}:${e}:${s.id}`,duration:Number.POSITIVE_INFINITY,action:{label:h.agent_chatSend_resend_label(),onClick:()=>{if(u)return;u=!0;const p=o();!p||p.generation!==c.generation||p.submissions!==c.submissions||p.observationVersion!==c.observationVersion||R(p.submissions,s.id)?.status!=="uncertain"||Oa(M,e,l)}},cancel:{label:h.chat_richInput_cancel_label(),onClick:g},onDismiss:g}),null}async function Is(e,t,n){const a=Xe.select(M.state,e),r=a?.submission?await Ua(e,t,a,n):"legacy";if(r){if(r==="legacy"){await M.dispatch(n===void 0?Lt(e,t):Ot(e,t,n));return}!r.isCurrent()||!a||M.dispatch(Ye(e,{wsId:t,text:a.text,imageBlocks:a.options?.imageBlocks,fileBlocks:a.options?.fileBlocks,noteIds:a.options?.noteIds,messageMetadata:a.options?.messageMetadata,model:n??a.options?.model,userAppMessageId:r.submission.appMessageId,submission:{scope:r.scope,id:r.submission.id}}))}}const Ts=M.createSelector((e,t)=>{const n=R(e.chatDrafts.owners,t);return n?{restore:n.restore,saves:Je(n.saves),shared:n.restore?e.chatDrafts.shared[JSON.stringify([n.restore.workspaceId,n.restore.agentId])]:void 0}:void 0});function $a(e,t){return t.workspaceId===e&&!t.retiredAt&&!t.pendingDeleteAt&&t.status!==ke.Deleted&&!t.notificationsMuted&&$t(t)==="topLevel"}function Na(e){const t=e.metadata?.pendingQuestionsMessageId;return typeof t=="string"&&t.length>0&&!Bn(e.metadata,t)?t:null}function Ha(e){return e.status===ke.Error&&!jt(Vt(e))}function Cs(e,t){return t.filter(n=>$a(e,n)).flatMap(n=>{const a=Ut(n),r=Na(n),s=n.status===ke.Error;if(!a&&!r&&!s)return[];const o=a?.timestamp??(s?n.stopReasonTimestamp:void 0);return[{agentId:n.id,agentName:n.name,kind:a?.kind??(s?"failed":"question"),reason:a?.reason,timestamp:o&&Number.isFinite(Date.parse(o))?o:void 0,questionMessageId:r,canRetry:Ha(n)}]})}function Es(e){return e.displayStatus==="failed"?"failed":e.displayStatus==="blocked"?"blocked":e.attention==="review_required"?"review":e.displayStatus==="needs_attention"?"question":e.activity==="agent_running"||e.displayStatus==="in_progress"?"running":e.scriptsRunning===!0?"scripts_running":e.backgroundTasksRunning===!0?"background_tasks_running":e.displayStatus==="pr_ready"?"pr_ready":e.displayStatus==="pr_merged"?"merged":e.displayStatus==="complete"?"complete":e.attention==="unread"?"unread":e.displayStatus==="pr_open"||e.displayStatus==="pr_queued"?e.displayStatus:"idle"}function Ds(e){const t=e.kind==="prs"?e.organization?.trim().toLowerCase():void 0;return{key:JSON.stringify([e.kind,e.workspaceId,t||null,[...new Set((t?[]:e.repositories).map(n=>JSON.stringify([n.key,n.owner,n.name])))].sort()]),hasGitHubRepositories:!!t||e.repositories.some(n=>!!n.owner),hasLocalRepositories:!t&&e.repositories.some(n=>!n.owner)}}function Te(e){const t=Sn(e);if(t?.kind!=="pr"||!Number.isSafeInteger(t.number)||t.number<=0)return null;const n=t.owner.toLowerCase(),a=t.repo.toLowerCase();return{owner:n,repo:a,number:t.number,id:`${n}/${a}#${t.number}`,url:`https://github.com/${n}/${a}/pull/${t.number}`}}function Rs(e,t,n,a){const r=e.filter(s=>a?a.includes(s.id):n?s.repositoryOwner?.toLowerCase()===n.toLowerCase():t.some(o=>o.owner?.toLowerCase()===s.repositoryOwner?.toLowerCase()&&o.name.toLowerCase()===s.repositoryName?.toLowerCase()));return[...new Map(r.flatMap(s=>[...(s.pullRequests??[]).map(o=>o.url),s.activePullRequest?.url,s.prUrl]).flatMap(s=>{const o=s?Te(s):null;return o?[[o.id,{owner:o.owner,repo:o.repo,number:o.number}]]:[]})).values()].sort((s,o)=>`${s.owner}/${s.repo}#${s.number}`.localeCompare(`${o.owner}/${o.repo}#${o.number}`))}function xs(e,t){const[n]=t;return t.length!==1||e.owner?.toLowerCase()!==n?.owner?.toLowerCase()||e.repo?.toLowerCase()!==n?.name.toLowerCase()}const Ps=M.createSelector(e=>e.homeIntegrations),Bs=M.createSelector(e=>{const t=e.homeIntegrations;return!t.linkedItems||!Object.keys(t.linkedItems).length?t:{...t,items:[...new Map([...Object.values(t.linkedItems),...t.items].map(n=>[n.id,n])).values()].sort((n,a)=>(a.updatedAt??"").localeCompare(n.updatedAt??""))}}),wt=M.createSelector(e=>Je(e.workspace.workspaces).flatMap(t=>[...(t.pullRequests??[]).map(n=>n.url),t.activePullRequest?.url,t.prUrl].filter(n=>!!n).map(n=>({url:Te(n)?.url??n.replace(/\/$/,"").toLowerCase(),workspaceId:t.id,name:t.title||t.id})))),Ls=M.createSelector(e=>{const t=e.homeIntegrations.detail?.url,n=t?Te(t)?.url??t.replace(/\/$/,"").toLowerCase():void 0;return wt.select(e).find(a=>a.url===n)??null}),Os=M.createSelector(e=>wt.select(e).map(t=>t.url)),Fa=["setup-retry-not-remote","setup-retry-not-failed","setup-retry-shared-checkout","setup-retry-no-script","agent-busy","agent-not-running","machine-update-required","machine-unreachable"];function Us(e,t){return e&&t?.state==="failed"}function Ka(e){const t=e??{},n=typeof t.message=="string"?t.message:"";if(t.rpcCode===-32601||t.code==="METHOD_NOT_FOUND")return{ok:!1,code:"unsupported",message:n};const a=typeof t.data?.code=="string"?t.data.code:t.code;return{ok:!1,code:Fa.find(s=>s===a)??"unknown",message:n}}async function $s(e,t=it){try{const n=await t("agent.retrySetup",{workspaceId:e.workspaceId,agentId:e.agentId}),a=ln.safeParse(n?.setup);return{ok:!0,setup:a.success?a.data:null}}catch(n){return Ka(n)}}function Wa(e){return e.code==="unsupported"?h.remoteAgent_setupRetry_unsupported_error():e.message.trim()||h.remoteAgent_setupRetry_generic_error()}function Ns(e,t){Ln.error(h.remoteAgent_setupRetry_failed_title({machine:e}),{description:Wa(t)})}let te=null;function Hs(e){return te=e,()=>{te===e&&(te=null)}}function Fs(){return te}function Ks(e){return[...e.groups.length>0?e.groups.filter(n=>n.expanded).flatMap(n=>n.items):e.workspaces,...e.asideExpanded?e.aside:[]].map(n=>n.id)}function Ws(e,t,n){if(e.length===0)return null;const a=t===null?-1:e.indexOf(t);return a===-1?e[0]:e[a+(n==="clockwise"?1:-1)]??null}let F=[];function qs(e,t={}){const n={source:e,fallback:t.fallback===!0};return F=[...F,n],()=>{F=F.filter(a=>a!==n)}}function js(){const e=F.findLast(n=>!n.fallback);return e?e.source:F.findLast(n=>n.fallback&&(n.source.available?.()??!0))?.source??null}function Vs(e){if(!e?.isConnected||e.closest("[inert]"))return!1;const t=e.ownerDocument.querySelectorAll('[aria-modal="true"]');return Array.from(t).every(n=>n.contains(e))}const zs=ct("conversationGoal/commandSend","conversationGoal/commandSendRequested"),Gs=ct("conversationGoal/set","conversationGoal/setRequested");function Ys(e){return In(e)}function qa(e){return Mn(e)}function ja(e,t){return!e||!t?!1:e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function me(e){if(e.length===0)return[];const t=[];let n=null;for(const a of e){const r=a.timestamp?typeof a.timestamp=="string"?new Date(a.timestamp):a.timestamp:new Date;(!n||!ja(n.date,r))&&(n={date:r,label:qa(r),messages:[]},t.push(n)),n.messages.push(a)}return t}function Js(e){const t=new Map;return e.map(({date:n})=>{const a=`${n.getFullYear()}-${n.getMonth()+1}-${n.getDate()}`,r=t.get(a)??0;return t.set(a,r+1),r===0?a:`${a}#${r}`})}function Xs(e,t){const n=new Map;let a=t?null:void 0;for(const r of e.groups)for(const s of r.messages)a!==void 0&&n.set(s.id,a),s.role==="user"&&!Un(s)&&(a=s);return n}function Va(e){return`${e.getFullYear()}-${e.getMonth()+1}-${e.getDate()}`}function qe(e,t){const n=new Map;return e.map(a=>{const r=`${t}-${Va(a.date)}`,s=(n.get(r)??0)+1;return n.set(r,s),{...a,groupKey:s===1?r:`${r}-${s}`}})}function za(e,t){if(e.length===0||t.length===0)return e;const n=new Set(t.map(s=>s.id)),a=new Set(t.map(s=>s.appMessageId).filter(s=>typeof s=="string"&&s.length>0)),r=e.filter(s=>!n.has(s.id)&&!(typeof s.appMessageId=="string"&&s.appMessageId.length>0&&a.has(s.appMessageId)));return r.length===e.length?e:r}function Qs(e,t,n){return e=za(e,t),e.length===0?{groups:me(t),detached:!1,hiddenTail:[]}:n?{groups:qe(me(e),"h"),detached:!0,hiddenTail:t}:{groups:qe(me([...e,...t]),"d"),detached:!1,hiddenTail:[]}}function Zs(e){const{scrollTop:t,threshold:n,fetching:a,exhausted:r,historyCount:s,tailCount:o,tailTruncated:i,totalMessages:l,spacerAbove:c=0}=e;return t>n+c||a||r?!1:s>0||i||l>o+s}const eo=300;function to(e){const{fetching:t,chainEvaluationPending:n,visible:a,hideArmed:r}=e;return t||n?a&&!r?"none":"show":a&&!r?"arm-hide":"none"}const je=24,Ga=320;function Ce(e){return Number.isFinite(e)?Math.min(Ga,Math.max(je,e)):je}const Ya=.2,Ja=.12;function Xa(e,t,n=Ya){const a=Ce(t);return e===null||!Number.isFinite(e)?a:e+n*(a-e)}function no(e,t){const n=Ce(t??Number.NaN);return{above:Math.round(Math.max(0,e.above)*n),below:Math.round(Math.max(0,e.below)*n)}}function ao(e){const{totalMessages:t,residentCount:n,exhausted:a,residentContentHeight:r,currentSpacerHeight:s,viewportHeight:o}=e;let i=e.rowHeightEma;n>0&&r>0&&(i=Xa(i,r/n));const l=e.unloadedRows??t-n,d=a||t<=0||n<=0||l<=0||i===null?0:Math.round(l*i),u=Math.abs(d-s);return u===0?{spacerHeight:s,rowHeightEma:i,applied:!1,scrollTopDelta:0}:d===0||s===0||u>s*Ja||o>0&&u>o?{spacerHeight:d,rowHeightEma:i,applied:!0,scrollTopDelta:d-s}:{spacerHeight:s,rowHeightEma:i,applied:!1,scrollTopDelta:0}}const Qa=On,Za=2;function ro(e){const{scrollTop:t,spacerAboveHeight:n,rowHeightEstimate:a,pageSize:r=Qa,nearPages:s=Za}=e;if(n<=0||t>=n)return"serial";const o=Ce(a??Number.NaN);return(n-Math.max(0,t))/o>s*r?"seek":"serial"}const bt=200,er=1;function so(e,t,n=bt){const a=t.timestamp-n;return[...e.filter(r=>r.timestamp>=a),t]}function oo(e){const{samples:t,viewportHeight:n,windowMs:a=bt,viewportFactor:r=er}=e;if(n<=0||t.length<2)return"gentle";const s=t[t.length-1].timestamp-a,o=t.filter(l=>l.timestamp>=s);if(o.length<2)return"gentle";let i=0;for(let l=1;l<o.length;l+=1)i+=Math.abs(o[l].scrollTop-o[l-1].scrollTop);return i>n*r?"rapid":"gentle"}function io(e){const{scrollTop:t,spacerAboveHeight:n,unloadedRowsAbove:a}=e;if(a<=0||n<=0)return 0;const r=Math.min(1,Math.max(0,t/n));return Math.min(a-1,Math.max(0,Math.floor(r*a)))}function co(e){const{totalMessages:t,residentCount:n,exhausted:a,startOrdinalEstimate:r,detachedFromTail:s}=e,o=Math.max(0,t-n);if(!s)return{above:a?0:o,below:0};const i=Math.max(0,e.hiddenTailCount??0);if(a)return{above:0,below:o+i};if(r!==null){const c=Math.min(o,Math.max(0,Math.round(r)));return{above:c,below:o-c+i}}const l=Math.min(o,Math.max(0,Math.round(e.holeRowsEstimate??0)));return{above:o-l,below:l+i}}function lo(e){const{exhausted:t,historyCount:n,tailCount:a,tailTruncated:r,totalMessages:s}=e;return t?!0:n>0?!1:!r&&s<=a}const tr="intent.drafts.sync",nr="intent.drafts.changed",ar=O({id:C(),type:C(),label:C(),description:C().optional(),content:C().optional(),path:C().optional(),imageData:C().optional(),imageMimeType:C().optional(),attachmentId:C().optional(),attachmentMimeType:C().optional(),attachmentSize:ce().optional(),sourcePath:C().optional(),placementStatus:z("failed").optional(),screen:$n().optional()}),kt=O({text:C(),attachments:Nn(ar)}),G={provenance:C().min(1),workspaceId:C().min(1),agentId:C().min(1)},ne={lifetime:C(),revision:ce().int().nonnegative()};Hn("kind",[O({...G,kind:z("read")}),O({...G,...ne,kind:z("edit"),origin:C().min(1),sequence:ce().int().positive(),snapshot:kt}),O({...G,...ne,kind:z("flush")}),O({...G,...ne,kind:z("clear"),origin:C().min(1)})]);const _t=O({...G,...ne,origin:C(),sequence:ce().int().nonnegative(),snapshot:kt}),rr=O({accepted:Fn(),draft:_t});function sr(e,t,n=t){const a=new Map,r=new Set,s=crypto.randomUUID();let o=0,i=!1;const l=()=>{const f=t();if(i||!f)throw new Error("draft-authority-unavailable");return f},c=()=>{const f=n();if(!f||i)throw new Error("draft-authority-unavailable");return()=>{if(i||n()!==f)throw new Error("draft-authority-changed")}},d=(f,k,_)=>{const I=JSON.stringify([f,k,_]);let S=a.get(I);return S||(S={dirty:0},a.set(I,S)),S},u=(f,k)=>{if(i||f.provenance!==t())return;const _=d(f.provenance,f.workspaceId,f.agentId);if(!(_.value?.lifetime===f.lifetime&&_.value.revision>f.revision)&&(_.value=f,k&&_.dirty===0))for(const I of r)I(f)},g=e.subscribe(f=>{const k=_t.safeParse(f);k.success&&u(k.data,!0)}),p=async(f,k)=>{k();const _=rr.parse(await e.request(f));if(k(),f.provenance!==l()||_.draft.provenance!==f.provenance)throw new Error("draft-authority-changed");if(!_.accepted)throw u(_.draft,!1),new Error("draft-changed-in-another-editor");return _.draft},m=async(f,k)=>{const _=l(),I=c(),S=d(_,f,k);S.tail&&await S.tail;const v=await p({kind:"read",provenance:_,workspaceId:f,agentId:k},I);return u(v,!1),v},w=(f,k,_)=>{const I=l(),S=c(),v=d(I,f,k),B=v.tail??(v.value?Promise.resolve(v.value):p({kind:"read",provenance:I,workspaceId:f,agentId:k},S));v.dirty+=1;const E=B.then(P=>p(_(P),S));return v.tail=E,E.then(P=>{v.dirty-=1,v.tail===E&&(v.tail=void 0),u(P,!0)},()=>{v.dirty-=1,v.tail===E&&(v.tail=void 0)}),E};return{authority:()=>i?null:n(),read:m,async edit(f,k,_,I){const S=++o;return w(k,_,v=>({kind:"edit",provenance:v.provenance,workspaceId:k,agentId:_,lifetime:v.lifetime,revision:v.revision,origin:f,sequence:S,snapshot:I}))},async flush(f,k){const _=l(),I=c(),S=d(_,f,k),v=await(S.tail??(S.value?Promise.resolve(S.value):m(f,k)));await p({kind:"flush",provenance:_,workspaceId:f,agentId:k,lifetime:v.lifetime,revision:v.revision},I)},async clear(f,k){await w(f,k,_=>({kind:"clear",provenance:_.provenance,workspaceId:f,agentId:k,lifetime:_.lifetime,revision:_.revision,origin:s}))},subscribe(f){return r.add(f),()=>{r.delete(f)}},dispose(){i=!0,g(),r.clear(),a.clear()}}}let U=null;async function uo(e,t,n,a,r){const s=U;if(!s)throw new Error("draft-shared-transport-unavailable");const o=()=>{if(U!==s||s.authority()!==r)throw new Error("draft-authority-changed")};o(),await s.edit(e,t,n,a),o(),await s.flush(t,n),o()}async function mo(e,t){await Promise.resolve(),U&&await U.flush(e,t)}function po(){if(!et())return null;const e=sr({request:n=>it(tr,n),subscribe:n=>An(a=>{a.method===nr&&n(a.params)})},()=>xn(M.state),()=>Pn(M.state));U=e;const t=e.dispose;return e.dispose=()=>{U===e&&(U=null),t()},e}const vt=new Map;function St(e,t){return`${e}\0${t}`}function fo(e,t){return vt.get(St(e,t))}function ho(e,t,n){vt.set(St(e,t),n)}const go=M.createSelector((e,t,n)=>{const a=e.chatPanelUi.byWorkspaceId[t];return a?R(a.userMessageIndexes,n):void 0}),yo=M.createSelector((e,t,n)=>{const a=e.chatPanelUi.byWorkspaceId[t];return a?R(a.retryAgents,n):void 0});function or(e){e=Math.max(0,e);const t=Math.floor(e/1e3);if(t<10){const s=e/1e3,o=s.toFixed(1);return o.endsWith(".0")?`${Math.round(s)}s`:`${o}s`}if(t<60)return`${t}s`;const n=Math.floor(t/3600),a=Math.floor(t%3600/60),r=t%60;return n>0?`${n}h ${a}m ${r}s`:`${a}m ${r}s`}function wo(e){return or(Math.max(1e3,Math.round(e/1e3)*1e3))}const ir=new Set(["launch","init","session-create","session-load","prompt"]),cr=new Set(["tool-call","tool-waiting"]);function lr(e){let t=null;for(const n of e)(!t||n.timestamp>=t.timestamp)&&(t=n);return t}function bo(e){return e&&ir.has(e)?"pulse":e&&cr.has(e)?"twist":"bloom"}const At="stalled";function ko(e,t){const n=lr(e);return!n||n.phase!==At||typeof t=="number"&&t>n.timestamp?null:n}function _o(e){let t=null;for(const n of e)n.phase!==At&&(!t||n.timestamp>=t.timestamp)&&(t=n);return t}const Ve={get title(){return h.chat_streamingStatus_sessionCorrupted_title()},get message(){return h.chat_streamingStatus_sessionCorrupted_message()}},dr=/^session\/[a-z_]+(?: failed)?:\s*/i;function ur(e){const n=(e.split(`
12
+ `).map(a=>a.trim()).find(Boolean)??"").replace(dr,"");return n.charAt(0).toUpperCase()+n.slice(1)}function vo(e,t){return e?t===!0?{corrupted:!0,title:Ve.title,message:Ve.message,detail:e}:{corrupted:!1,title:h.chat_streamingStatus_responseFailed_label(),message:ur(e),detail:null}:null}const So=M.createSelector((e,t)=>R(e.questionUi.consumers,t)),mr=3e4,J=new Map;function Ao(e,t){const n=J.get(e);n&&clearTimeout(n.timer);const a=setTimeout(()=>J.delete(e),mr);J.set(e,{value:t,timer:a})}function Mo(e){const t=J.get(e);if(t)return clearTimeout(t.timer),J.delete(e),t.value}const Mt=M.createSelector((e,t,n)=>e.agentWorkers?.byKey[Ht(t,n)]??Nt),pr=M.createSelector((e,t,n)=>{const a=Mt.select(e,t,n);return a.status==="unsupported"?[]:(a.snapshot?.workers??[]).filter(r=>r.status==="running"||r.status==="unknown")}),Io=M.createSelector((e,t,n)=>{const a=Mt.select(e,t,n);return a.status==="failed"?!0:a.status!=="ready"||!a.snapshot?!1:a.snapshot.truncated?!0:a.snapshot.support.status!=="supported"&&pr.select(e,t,n).length>0}),fr=1e3,It={requireViewedAndFocused:!0,requireAssistantTail:!0},X=new Map,x=new Map;let j=null;function Ee(e){(e===void 0||j===e)&&(j=null)}const hr=200;function gr(e,t){if(x.delete(e),x.set(e,t),x.size>hr){const n=x.keys().next().value;n!==void 0&&x.delete(n)}}function Tt(e){for(let t=e.length-1;t>=0;t--){const n=e[t];if(!n.isStreaming&&typeof n.id=="string"&&n.id.length>0)return n}return null}function To(e){return Tt(e)?.id??null}function Co(e){De(e,{requireViewedAndFocused:!0})}function Eo(e){De(e,{requireViewedAndFocused:!1})}function Do(e){Ee(),De(e,It)}function Ro(e){j===e&&(X.has(e)||(j=null,Re(e,It)))}function xo(e){for(const t of e)typeof t!="string"||t.length===0||(Ct(t),Ee(t),Re(t,{requireViewedAndFocused:!1}))}function Ct(e){const t=X.get(e);t&&(clearTimeout(t.timer),X.delete(e))}function De(e,t){Ct(e),Ee(e);const n=setTimeout(()=>{X.delete(e),Re(e,t)},fr);X.set(e,{timer:n,gates:t})}let ze=null;function yr(){return ze??=Promise.all([fe(()=>import("./DlUpt_0u.js"),__vite__mapDeps([38,1,2,3,4,5,6,7,8,9,10,11,39,40]),import.meta.url),fe(()=>import("./DJPIUVkw.js").then(e=>e.s),__vite__mapDeps([41,42,8,3,1,2,4,5,6,7,9,10,11,20,21,16,17,22,43,44,45,19,26]),import.meta.url)]).then(([e,t])=>({appStore:e.store,appClient:t.appClient})),ze}async function Re(e,t){let n=null;try{const{appStore:a,appClient:r}=await yr(),s=a.state;if(t.requireViewedAndFocused&&(s.unreadTracking?.currentlyViewedAgentId!==e||typeof document<"u"&&!document.hasFocus()))return;const o=s.agentSessions?.byAgentId[e];if(!o)return;const i=typeof o.workspaceId=="string"?o.workspaceId:"";if(i.length===0)return;if(t.requireAssistantTail&&s.chatState?.byAgentId[e]?.initialHistoryPending){j=e;return}const l=Tt(o.messages??[]);if(!l){t.requireAssistantTail&&(j=e);return}if(t.requireAssistantTail&&l.role!=="assistant")return;const c=l.id;if(x.get(e)===c)return;gr(e,c),n=c,!(await r.agents.markSeen({workspaceId:i,agentId:e,messageId:c})).success&&x.get(e)===n&&x.delete(e)}catch{n!==null&&x.get(e)===n&&x.delete(e)}}const ie=new Map;function Et(e,t){return`${e}\0${t}`}function Po(e,t){return ie.get(Et(e,t))}function Bo(e,t,n){ie.set(Et(e,t),n)}function Lo(e){if(e.length===0)return;const t=new Set(e);for(const n of[...ie.keys()]){const a=n.slice(n.indexOf("\0")+1);t.has(a)&&ie.delete(n)}}export{ks as $,Gn as A,es as B,ms as C,L as D,cs as E,za as F,ds as G,Pa as H,Ra as I,Xn as J,mo as K,wo as L,fr as M,Ys as N,eo as O,ko as P,Po as Q,bt as R,fo as S,js as T,Cs as U,je as V,Fs as W,Es as X,_o as Y,bo as Z,zs as _,_s as a,Ao as a$,Gs as a0,As as a1,Ms as a2,Ks as a3,rs as a4,sa as a5,Xs as a6,as as a7,lo as a8,Y as a9,vs as aA,Ee as aB,Is as aC,Yr as aD,no as aE,$s as aF,pr as aG,Mt as aH,Io as aI,Ts as aJ,zr as aK,Gr as aL,Vr as aM,Ps as aN,Ls as aO,Bs as aP,Os as aQ,wt as aR,So as aS,yo as aT,go as aU,Bo as aV,ho as aW,Zs as aX,ns as aY,xs as aZ,co as a_,os as aa,ss as ab,Vs as ac,Xr as ad,io as ae,xo as af,Ro as ag,Co as ah,Eo as ai,Do as aj,To as ak,Ns as al,to as am,Ss as an,ps as ao,Wn as ap,uo as aq,is as ar,bs as as,us as at,Ua as au,ht as av,Qr as aw,qs as ax,ao as ay,Hs as az,we as b,Ws as b0,Oa as b1,Mo as b2,oa as b3,ts as b4,so as c,ys as d,ws as e,Js as f,Zr as g,xa as h,Jr as i,Us as j,ca as k,ia as l,oo as m,ro as n,Lo as o,Rs as p,Qs as q,gs as r,hs as s,ls as t,po as u,fs as v,vo as w,Ds as x,Ca as y,ge as z};