@tickernelz/wardmote-ui 2026.1118.1 → 2026.1118.2

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 (119) hide show
  1. package/dist/assets/{AdapterManager-1binbhYj.js → AdapterManager-DvntZ2AW.js} +1 -1
  2. package/dist/assets/{AdvancedToolsRoute-DUyXR4Xj.js → AdvancedToolsRoute-CUW8D9Ux.js} +1 -1
  3. package/dist/assets/{AgentActionButtons-DSmnGirw.js → AgentActionButtons-CQLGCtfu.js} +1 -1
  4. package/dist/assets/{AgentChat-Dj952aW1.js → AgentChat-DCwwZA2b.js} +1 -1
  5. package/dist/assets/{AgentChats-Fv5j4CM9.js → AgentChats-DMMLdo-o.js} +1 -1
  6. package/dist/assets/{AgentDetail-CffT38lI.js → AgentDetail-BMVWOVp-.js} +1 -1
  7. package/dist/assets/{AgentTodoCard-De5ZJbUa.js → AgentTodoCard-C4BfJg4x.js} +1 -1
  8. package/dist/assets/{Agents-CDDoQ4Ds.js → Agents-C0IDC6KD.js} +3 -3
  9. package/dist/assets/{AppDetail-DnTOxWEY.js → AppDetail-DzEGsx94.js} +1 -1
  10. package/dist/assets/{AppNotConnected-CgnmB3mH.js → AppNotConnected-BVL32B49.js} +1 -1
  11. package/dist/assets/{ApprovalCard-D6X8gzHU.js → ApprovalCard-DCQ49PuW.js} +1 -1
  12. package/dist/assets/{ApprovalDetail-CWxiqPs6.js → ApprovalDetail-B0J70llD.js} +1 -1
  13. package/dist/assets/{ApprovalPayload-DFsO21LC.js → ApprovalPayload-8lqBw-XQ.js} +1 -1
  14. package/dist/assets/{Approvals-BW3osPe0.js → Approvals-BkiVjx0M.js} +1 -1
  15. package/dist/assets/{AppsReview-4g3PeYWn.js → AppsReview-CeXp22cE.js} +1 -1
  16. package/dist/assets/{ArtifactCard-BoIqK207.js → ArtifactCard-BV82tDLI.js} +1 -1
  17. package/dist/assets/{Artifacts-DDdlgUkk.js → Artifacts-CL5ZmZ3m.js} +1 -1
  18. package/dist/assets/{AssistantConnection-B7yxIifb.js → AssistantConnection-C5rmoEsm.js} +1 -1
  19. package/dist/assets/{AttentionInteractionResolver-BdcCqDXe.js → AttentionInteractionResolver-DxZpuIIF.js} +1 -1
  20. package/dist/assets/{AuditHub-CI0zjHie.js → AuditHub-DDPFGvHG.js} +1 -1
  21. package/dist/assets/{BoardChat--69z_C0h.js → BoardChat-DlaNGzcQ.js} +1 -1
  22. package/dist/assets/{BootstrapSetupUxLab-UIxdNUcO.js → BootstrapSetupUxLab-B2tOIzXd.js} +1 -1
  23. package/dist/assets/{Browse-VPYhJopu.js → Browse-xEc9mGl7.js} +1 -1
  24. package/dist/assets/{BudgetPolicyCard-45TwMzp3.js → BudgetPolicyCard-Ccr3EX5M.js} +1 -1
  25. package/dist/assets/{CaseDetail-CRN2rF4k.js → CaseDetail-CvMk_M-F.js} +1 -1
  26. package/dist/assets/{Cases-CFqnLAMq.js → Cases-H1Y4Oipe.js} +1 -1
  27. package/dist/assets/{ChatEndpointDetail-BTYAtutu.js → ChatEndpointDetail-CjDVQWl8.js} +1 -1
  28. package/dist/assets/{ChatEndpointSetup-CzrgHmvH.js → ChatEndpointSetup-BfohtKVM.js} +1 -1
  29. package/dist/assets/{Companies-C-U5WI6o.js → Companies-C4ObCu9j.js} +1 -1
  30. package/dist/assets/{CompanyAccess-DLgvUIoB.js → CompanyAccess-J5Vwnko2.js} +1 -1
  31. package/dist/assets/{CompanyActivity-8CeynedM.js → CompanyActivity-B7-kMNmz.js} +1 -1
  32. package/dist/assets/{CompanyConnections-BjMmsqei.js → CompanyConnections-D2N6UWXk.js} +1 -1
  33. package/dist/assets/{CompanyEnvironments-D6p-TNkv.js → CompanyEnvironments-ChSu4gxW.js} +1 -1
  34. package/dist/assets/{CompanyExport-Dw0QDMvs.js → CompanyExport-B_opHRSJ.js} +1 -1
  35. package/dist/assets/{CompanyImport-OSi3fM2l.js → CompanyImport-DZAMEBBy.js} +1 -1
  36. package/dist/assets/{CompanySettings-B-aPUQpY.js → CompanySettings-Rz8cwgKC.js} +1 -1
  37. package/dist/assets/{CompanySettingsPluginPage-Kp7iOUP1.js → CompanySettingsPluginPage-CM-ViPwj.js} +1 -1
  38. package/dist/assets/{CompanySkills-HZqJ5DZ8.js → CompanySkills-BnwPuZze.js} +1 -1
  39. package/dist/assets/{ConfigureBuiltInAgentModal-DL3wv3Mb.js → ConfigureBuiltInAgentModal-BAfoTveX.js} +1 -1
  40. package/dist/assets/{CopyableGatewayUrl-BLjhj10P.js → CopyableGatewayUrl-D90Bjxj0.js} +1 -1
  41. package/dist/assets/{Dashboard-DTmjsaEr.js → Dashboard-DepIxrje.js} +1 -1
  42. package/dist/assets/{DecisionDateChips-Br5r2jWZ.js → DecisionDateChips-89KkV4mo.js} +1 -1
  43. package/dist/assets/{DecisionQueuePage-zWDMjHf9.js → DecisionQueuePage-nU9qXzln.js} +1 -1
  44. package/dist/assets/{DesignGuide-BsH97scx.js → DesignGuide-40TixHZ-.js} +1 -1
  45. package/dist/assets/{EmailEndpointSetup-C7PhFwBy.js → EmailEndpointSetup-D7-8f1XV.js} +1 -1
  46. package/dist/assets/{ExecutionWorkspaceDetail-CTDvazWh.js → ExecutionWorkspaceDetail-CnUD3jLO.js} +1 -1
  47. package/dist/assets/{GatewayDetail-BtpnGGIB.js → GatewayDetail-Bg7GU-1a.js} +1 -1
  48. package/dist/assets/{GatewaysList-DrRfNyqk.js → GatewaysList-4vvZCBkY.js} +1 -1
  49. package/dist/assets/{GoalDetail-D5QqhxMg.js → GoalDetail-h7WsjaOO.js} +1 -1
  50. package/dist/assets/{GoalTree-CDexmAKW.js → GoalTree-yPtfejUx.js} +1 -1
  51. package/dist/assets/{Goals-CZinws4s.js → Goals-DOi3E4DX.js} +1 -1
  52. package/dist/assets/{ImageGalleryModal-VT9I4D2p.js → ImageGalleryModal-D_VQgcBt.js} +1 -1
  53. package/dist/assets/{Inbox-BiE243MO.js → Inbox-COKxRKhR.js} +1 -1
  54. package/dist/assets/{InstanceAdvanced-D_iqUmgn.js → InstanceAdvanced-DlMlwZbU.js} +1 -1
  55. package/dist/assets/{InviteLanding-LR84Xv76.js → InviteLanding-BGvJMHKw.js} +1 -1
  56. package/dist/assets/{IssueChatLongThreadPerf-BHdYa83T.js → IssueChatLongThreadPerf-C3U2FZKJ.js} +1 -1
  57. package/dist/assets/{IssueChatThread-Cno8fLc-.js → IssueChatThread-CDKaIB6v.js} +1 -1
  58. package/dist/assets/{IssueDetail-BWZWLO4k.js → IssueDetail-BCwHANTn.js} +1 -1
  59. package/dist/assets/{IssueOutputSection-BuwP0RQx.js → IssueOutputSection-BzXRmoV7.js} +1 -1
  60. package/dist/assets/{IssueRecoveryActionCard-O4GRNsPc.js → IssueRecoveryActionCard-BYtbaP-M.js} +1 -1
  61. package/dist/assets/{IssueReferencePill-EbOs3MtQ.js → IssueReferencePill-BT7NBEy_.js} +1 -1
  62. package/dist/assets/{IssueThreadInteractionCard-BUIzNywc.js → IssueThreadInteractionCard-Btd0rZ23.js} +1 -1
  63. package/dist/assets/{Issues-mVYaoqsX.js → Issues-XKf7zemQ.js} +1 -1
  64. package/dist/assets/{LiveNowTodoLine-DP95vmnd.js → LiveNowTodoLine-CoL6ZNuK.js} +1 -1
  65. package/dist/assets/{ManagedAiConnectionDetails-ZByBvcqo.js → ManagedAiConnectionDetails-CebBi-Tw.js} +1 -1
  66. package/dist/assets/{McpConnect-D42jtK1S.js → McpConnect-ByorZN7G.js} +1 -1
  67. package/dist/assets/{MembershipAction-Df2Qlkdz.js → MembershipAction-De0MBfgb.js} +1 -1
  68. package/dist/assets/{ModelsAndProviders-BzUob8BB.js → ModelsAndProviders-BqM4UJc7.js} +1 -1
  69. package/dist/assets/{NewAgent-BywRvCR0.js → NewAgent-pMTQYNxn.js} +1 -1
  70. package/dist/assets/{PipelineSettings-DFjxoW4i.js → PipelineSettings-C2k3BzLQ.js} +1 -1
  71. package/dist/assets/{Pipelines-CSW-En3n.js → Pipelines-Cr6Xs32p.js} +1 -1
  72. package/dist/assets/{PixelsOffice-B2b8M6LM.js → PixelsOffice-Dfd4XKSj.js} +1 -1
  73. package/dist/assets/{PluginPage-CfSIAMQa.js → PluginPage-fPlWyFSc.js} +1 -1
  74. package/dist/assets/{PluginSettings-TewUkGUA.js → PluginSettings-X_VHvvo5.js} +1 -1
  75. package/dist/assets/{ProfileDetailRoute-CCbLcj8f.js → ProfileDetailRoute-PAsWmN-1.js} +1 -1
  76. package/dist/assets/{ProfileSettings-D1D_hKPu.js → ProfileSettings-BACxlGZS.js} +1 -1
  77. package/dist/assets/{ProfileWizardRoute-BzFGrQkr.js → ProfileWizardRoute-Dbq0n7If.js} +1 -1
  78. package/dist/assets/{ProjectDetail-CEjUARCN.js → ProjectDetail-DOJZUIWu.js} +1 -1
  79. package/dist/assets/{ProjectWorkspaceDetail-7fFllUMH.js → ProjectWorkspaceDetail-ZNnaHnuA.js} +1 -1
  80. package/dist/assets/{ProjectWorkspacesContent-S4UUfVU1.js → ProjectWorkspacesContent-DrWfnTJY.js} +1 -1
  81. package/dist/assets/{Projects-NrtT8d2x.js → Projects-CCzxmEZ8.js} +1 -1
  82. package/dist/assets/{PublicIssueSharePage-CfQDHmOe.js → PublicIssueSharePage-BUSkP1Js.js} +1 -1
  83. package/dist/assets/{ReviewQueueCard-CksOubye.js → ReviewQueueCard-CrCN_30c.js} +1 -1
  84. package/dist/assets/{RichWorkProductCard-XPJ4R-il.js → RichWorkProductCard-DndJn4LV.js} +1 -1
  85. package/dist/assets/{RoutineDetail-AcrnXhjR.js → RoutineDetail-B5MzV_74.js} +1 -1
  86. package/dist/assets/{RoutineRunVariablesDialog-CtSVwZjy.js → RoutineRunVariablesDialog-kGyQVBid.js} +1 -1
  87. package/dist/assets/{Routines-B19G6Lkw.js → Routines-B2zX9h3J.js} +1 -1
  88. package/dist/assets/{ScrollToBottom-csHqjOIa.js → ScrollToBottom-Dd3SpeJi.js} +1 -1
  89. package/dist/assets/{Search-CnO6qC0m.js → Search-D4W3cZZf.js} +1 -1
  90. package/dist/assets/{Secrets-Xz6WSEnG.js → Secrets-C4nbuMIh.js} +1 -1
  91. package/dist/assets/{SkillSourceTree-BC2Ycl7g.js → SkillSourceTree-BvGzMa2u.js} +1 -1
  92. package/dist/assets/{SkillSources-BMogH_qp.js → SkillSources-DL2tNkcr.js} +1 -1
  93. package/dist/assets/{SkillStudio-HekOqqo_.js → SkillStudio-BnZ2cfDq.js} +1 -1
  94. package/dist/assets/{SourceTrustBadge-CXZGc8G4.js → SourceTrustBadge-CCPQEGrC.js} +1 -1
  95. package/dist/assets/{StatusCards-CL-RC2Mf.js → StatusCards-BkE-9R8F.js} +1 -1
  96. package/dist/assets/{SummarySlotCard-BJmo-gDJ.js → SummarySlotCard-D1EyiciB.js} +1 -1
  97. package/dist/assets/{TaskChatLab-CIZVb5Ed.js → TaskChatLab-D3PsNRr5.js} +1 -1
  98. package/dist/assets/{TaskChatMarker-CdRbWeYc.js → TaskChatMarker-DEF88_sr.js} +1 -1
  99. package/dist/assets/{TaskChatProtocolCard-C_A2mV-g.js → TaskChatProtocolCard-Ba_vhDxn.js} +1 -1
  100. package/dist/assets/{TaskChatThreadView-Bd3E40e0.js → TaskChatThreadView-BsPvbxiA.js} +1 -1
  101. package/dist/assets/{TaskTreeControls-DK6EZXLI.js → TaskTreeControls-BKOIbilg.js} +1 -1
  102. package/dist/assets/{Terminal-BcD_c9Om.js → Terminal-1uPX7VEe.js} +1 -1
  103. package/dist/assets/{TerminalView-XV2mBbcS.js → TerminalView-DDv6s-R_.js} +1 -1
  104. package/dist/assets/{TrustPresetSection-Ev8RdYhN.js → TrustPresetSection-BDb0N4Pe.js} +1 -1
  105. package/dist/assets/{UserProfile-C_BKVfMQ.js → UserProfile-DqPRuGWk.js} +1 -1
  106. package/dist/assets/{WhatNeedsMe-CYs2iX06.js → WhatNeedsMe-DtBxgH24.js} +1 -1
  107. package/dist/assets/{Workspaces-B8Wwbx8B.js → Workspaces-BQOyG5HK.js} +1 -1
  108. package/dist/assets/{connection-owner-Ca1nfKiA.js → connection-owner-CPrMcD3t.js} +1 -1
  109. package/dist/assets/{index-LM7k1NmC.js → index-QhteFtm-.js} +3 -3
  110. package/dist/assets/{issue-properties-CKLKB9AO.js → issue-properties--M7WE6Ot.js} +1 -1
  111. package/dist/assets/{issue-workspace-selection-CJYasFEQ.js → issue-workspace-selection-pUdSkrJA.js} +1 -1
  112. package/dist/assets/{pipeline-stage-presentation-BzvR-f05.js → pipeline-stage-presentation-Dv1xgEPW.js} +1 -1
  113. package/dist/assets/{shared-CMP5lH_Q.js → shared-B75ClBUg.js} +1 -1
  114. package/dist/assets/{system-notice-comment-BUfjKy0_.js → system-notice-comment-D0I6rz8Y.js} +1 -1
  115. package/dist/assets/{transcript-adapter-DiPtVkEm.js → transcript-adapter-ClaGWYVL.js} +1 -1
  116. package/dist/assets/{useSummaryDraftStream-uMW1O0Ga.js → useSummaryDraftStream-BDuMgNcA.js} +1 -1
  117. package/dist/index.html +1 -1
  118. package/dist/sw.js +1 -1
  119. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- var xm=Object.defineProperty;var a=(e,s)=>xm(e,"name",{value:s,configurable:!0});import{i as Eo,n as ym}from"./rolldown-runtime-ZpX3ckPj.js";import{A as vm,Ci as bm,Kn as km,O as hr,Ti as nd,_ as dl,_i as wm,h as jm,k as Im,l as ue,la as Nm,m as Sm,p as Cm,t as gr,ua as Am,x as zs,zi as go}from"./createLucideIcon-CgrPXnTY.js";import{l as Rm}from"./dist-DYoIyA63.js";import{_ as ad,a as di,h as ui,n as mi,o as ul,r as Tm,v as Em}from"./star-eem0qj3E.js";import{X as ks,_ as Pe,d as _m,g as qm,n as Hs,r as ml,t as R,u as Mm,v as ye}from"./queryKeys-BzT8CD34.js";import{t as Pm}from"./useInfiniteQuery-DTEIZ1gz.js";import{t as rd}from"./useQueries-K6OPYBvC.js";import{o as Fm}from"./companies-query-BEdFiAhG.js";import{j as Dm}from"./ConnectionSetupFlow-8alK3I_h.js";import{r as $m}from"./ArtifactCard-BoIqK207.js";import{t as Lm}from"./issue-attribution-DfN_3u2W.js";import{n as Bm,r as Om}from"./responsible-user-denial-Dyl0BwU5.js";import{n as Km,t as Um}from"./IssueWriteDenialNotice-Bf0ZFSBV.js";import{a as Qm,i as Wm,n as zm,t as Hm}from"./IssueDocumentAnnotations-DpFXlkRb.js";import{t as pl}from"./execution-projection-BGI5f3kX.js";import{d as Vm,f as Gm}from"./connection-identity-ch7QDvun.js";import{n as Ym,r as Jm,t as Xm}from"./workspace-restore-BIbDC_O8.js";import{a as fl,i as Zm,n as hl,r as ep,t as tp}from"./TerminalView-XV2mBbcS.js";import{n as sp}from"./CompanyContext-fQCNWI_f.js";import{A as np,At as ap,Bt as gl,D as rp,Dt as ip,Et as op,Ft as id,G as lp,Gt as cp,It as dp,Jt as up,Kt as Ki,Lt as mp,Mt as pp,Nt as Lr,Ot as xl,Pt as yl,Rt as nr,St as fp,T as hp,Tt as vl,Ut as fa,Wt as bl,Yt as gp,at as pi,et as od,jt as xp,kt as yp,o as fi,on as vp,ot as bp,qt as kl,t as ls,v as Xr,vt as xo,wt as kp,zt as xe}from"./router-CJbFZfVR.js";import{a as hi,c as gi,i as xi,l as wp,n as _o,o as yi,r as vi,s as bi,t as ki}from"./alert-dialog-DNbnZgRz.js";import{a as yo,n as vo,r as jp,t as bo}from"./avatar-qO_h93F8.js";import{t as qo}from"./checkbox-Cf2_HXDG.js";import{i as wl,p as Ip,r as Np,t as Sp}from"./dropdown-menu-rUbU8QKw.js";import{t as Cp}from"./label-B707hSFt.js";import{n as Br,t as Ap}from"./tabs-CjHzZxtD.js";import{c as Rp,i as Tp}from"./MarkdownEditor-ubJimjUH.js";import{o as xr,r as yr,t as vr}from"./popover-CWlBonqy.js";import{t as ld}from"./archive-CvT6i844.js";import{t as cd}from"./arrow-left-CnGEiANj.js";import{t as Ep}from"./arrow-up-down-Ci6AcwB0.js";import{t as Wn}from"./check-Bis3vECb.js";import{t as br}from"./chevron-down-nRcQ7bok.js";import{t as _p}from"./chevron-left-DnUVccc_.js";import{t as kr}from"./chevron-right-BP8JjEC_.js";import{t as dd}from"./chevron-up-C1TOE3pP.js";import{t as qp}from"./SearchableSelect-BbuRtdzg.js";import{t as ud}from"./circle-alert-C7T1cdKm.js";import{a as Mp,c as Pp,d as md,i as Fp,n as Dp,r as $p,t as Lp,u as pd}from"./ScrollToBottom-csHqjOIa.js";import{t as fd}from"./circle-question-mark-CasEGiDp.js";import{t as Zr}from"./circle-DCDVf2v0.js";import{t as Mo}from"./clock-D2UFngg7.js";import{A as Bp,E as Op,M as jl,N as Kp,T as Up,a as Qp,c as Wp,d as zp,f as Hp,g as Il,h as Vp,i as Gp,j as Yp,k as Jp,l as Xp,m as hd,n as Zp,s as ef,t as bs,u as tf,v as hn,x as sf,y as nf}from"./MarkdownBody-cPGkwwjq.js";import{t as gd}from"./cloud-DX1fkQ6i.js";import{t as wr}from"./copy-C1cfcpxY.js";import{t as af}from"./ellipsis-vertical-DzWImTnI.js";import{t as xd}from"./ellipsis-DyXbAp4P.js";import{t as Po}from"./external-link-BIcMNNSN.js";import{t as ko}from"./eye-off-DTXvEIMp.js";import{t as rf}from"./eye-D8HiVtuU.js";import{a as yd,c as of,i as vd,o as lf,s as cf}from"./TaskChatMarker-CdRbWeYc.js";import{t as Ua}from"./file-code-corner-CwcL9g2p.js";import{t as df}from"./file-question-mark-BCVjQ2mM.js";import{t as uf}from"./file-search-Ccb88q3t.js";import{t as dr}from"./file-text-CsPKrMTp.js";import{t as mf}from"./file-CcVMTQhg.js";import{i as Nl}from"./RichWorkProductCard-XPJ4R-il.js";import{t as bd}from"./flag-i_D610oD.js";import{t as Rn}from"./folder-open-Dkshp3J4.js";import{t as pf}from"./folder-search-B_Hz17IO.js";import{a as ff,c as kd,d as Cn,f as hf,g as gf,h as Fo,l as wd,m as xf,o as yf,p as vf,s as bf,t as kf,u as jd}from"./issue-properties-CKLKB9AO.js";import{a as Ui,c as Id,i as Nd,l as wf,o as Sd,r as Ds,s as Cd,t as jf}from"./QuestionForm-MfSDsey7.js";import{t as Ad}from"./link-2-Cn4f4xsG.js";import{t as Do}from"./list-todo-DfkI9JDS.js";import{r as It,t as ne}from"./button-DI4w5WP7.js";import{a as If,c as Nf,d as Sf,f as Rd,g as Cf,h as lr,i as Td,l as Ed,m as _d,n as Af,o as Rf,s as qd,t as Sl,u as Tf}from"./IssueThreadInteractionCard-BUIzNywc.js";import{t as Ef}from"./minus-BttANimQ.js";import{n as $o}from"./TaskChatProtocolCard-C_A2mV-g.js";import{t as _f}from"./pause-B6AkvDer.js";import{t as qf}from"./play-Czm7OCYh.js";import{t as Mf}from"./plug-UFf0xCI3.js";import{t as Lo}from"./plus-CwNlqadt.js";import{t as Pf}from"./radio-BqjASC1E.js";import{t as Md}from"./repeat-DzPORJjX.js";import{t as Ff}from"./rotate-ccw-DpzLJhXT.js";import{_ as Pd,b as Df,c as ei,d as $f,f as Fd,g as Lf,h as Bf,l as Dd,m as Of,n as Kf,p as Uf,r as Cl,t as Qf,u as Wf,v as zf,y as Hf}from"./TaskChatThreadView-Bd3E40e0.js";import{t as ti}from"./search-CgZSuGC8.js";import{t as Vf}from"./settings-DuRZr7gk.js";import{t as Gf}from"./shield-check-RPyaLAc-.js";import{t as Bo}from"./trash-QxFF084e.js";import{t as nn}from"./triangle-alert-CnHMpmva.js";import{t as Yf}from"./users-CEZ1U5q9.js";import{t as Qa}from"./x-6E1yeU3Q.js";import{r as $d}from"./SidebarContext-bEtg0ItG.js";import{i as Oo,n as Ko,r as Ld,t as Uo}from"./tooltip-CW50mEoC.js";import{t as Qn}from"./badge-jeXr866I.js";import{t as Vr}from"./Identity-8eG_HXAH.js";import{t as ur}from"./AgentAvatar-BZiiDlCN.js";import{a as ya,i as Jf}from"./ToastContext-DyVJ6bCh.js";import{t as ga}from"./agents-B8n-p0aX.js";import{t as Al}from"./instanceSettings-D1nNVWU0.js";import{n as Xf,t as Zf}from"./useSharedPolling-CFeiZe2t.js";import{a as Rl,d as Qi,f as Tl,i as El,l as eh,n as _l,o as th,p as sh,r as ql,u as Ml}from"./inboxArchiveCache-CxaLM1R8.js";import{t as wi}from"./projects-l3kQxnTp.js";import{t as nh}from"./useAgentChatEnabled-DMbd4JDE.js";import{a as Qo,i as ah,n as Wo,r as zo,s as Ho,t as Vo}from"./dialog-CeH7rDcv.js";import{t as jr}from"./input-BBNGmECW.js";import{t as mr}from"./access-DhB95qNC.js";import{n as rh,r as ih,t as oh,u as Pl}from"./issue-filters-Ce8v1l6U.js";import{i as Fl,o as lh,t as ch}from"./assignees-DkQNbPzi.js";import{n as Dl,o as dh,t as uh}from"./slots-B7lwlN1w.js";import{t as jt}from"./skeleton-BAAoD7cz.js";import{t as wo}from"./chatEndpoints-Bj-keCuw.js";import{t as mh}from"./AppLogo-BLq8BpKi.js";import{t as zn}from"./activity-CudcEDwO.js";import{n as ph}from"./BreadcrumbContext-DNbB7zWn.js";import{t as fh}from"./AgentIdentity-DBHRFgMM.js";import{t as va}from"./textarea-CTx68BDs.js";import{t as $l}from"./attachment-icon-_1iz_saB.js";import{n as ji,t as hh}from"./presentation-mode-ZjtUUsSS.js";import{_ as Ii,a as Ni,f as Si,i as gh,n as xh,r as yh}from"./TaskChatComposerTakeoverContext-C68QVO36.js";import{n as vh}from"./useMobileEntityPickerViewportStyle-BG2vZMIz.js";import{t as bh}from"./InlineBanner-DeTqU5Gp.js";import{t as Go}from"./clipboard-CTLKYvRL.js";import{t as kh}from"./AgentSetupPrompt-CaafK5_w.js";import{t as wh}from"./use-copy-action-DFzauB4H.js";import{n as jh,t as Ih}from"./segmented-tuNVx49H.js";import{t as si}from"./StatusIcon-Cs1RbJGu.js";import{f as ni,h as Nh,p as Sh,r as Ch,t as Ah,v as Rh}from"./issue-blockers-t3wlvg4M.js";import{$t as Th,Aa as Yo,Ar as Ll,Da as Bd,Dr as Eh,Er as _h,Fa as qh,Ga as Mh,Gn as Ph,Ha as Od,K as Bl,Kn as Fh,Kr as Dh,La as ai,Ma as ri,Mr as $h,Na as Lh,Or as Bh,Qn as Oh,S as Kh,Ua as Jo,W as Uh,Xt as Ol,Y as Qh,Za as Xo,Zn as Wh,_a as vs,ar as zh,ba as Hh,bi as Vh,ca as Kl,ci as Gh,di as Yh,fi as Jh,fr as Xh,g as Zh,gi as eg,gr as tg,hi as sg,ht as ng,ir as ag,jr as rg,kr as ig,l as og,li as lg,mi as cg,nr as dg,or as ug,ot as mg,q as jo,qa as pg,rr as fg,si as hg,tn as gg,u as xg,ua as Wi,ui as yg,vi as Ul,wr as vg,xi as bg,y as kg,yi as wg,zr as jg}from"./index-LM7k1NmC.js";import{f as Ig,g as Ng,l as Sg,m as Cg,s as Ag,u as Rg}from"./system-notice-comment-BUfjKy0_.js";import{a as Tg,n as Eg,o as _g,r as qg,t as Ql}from"./AccessSelectIdentity-C-iVX_EX.js";import{a as Mg,c as Pg,d as Kd,t as Fg,u as Zo}from"./ImageGalleryModal-VT9I4D2p.js";import{a as Ud,i as Dg,o as $g,r as Lg,t as Bg}from"./AgentTodoCard-De5ZJbUa.js";import{t as Oa}from"./browser-use-BwBUHG71.js";import{i as Og,t as Qd}from"./IssueReferencePill-EbOs3MtQ.js";import{c as Kg,i as Ug,l as Wd,n as Qg,o as zd,r as Wg,s as zg,t as Hg,u as Vg}from"./TaskTreeControls-DK6EZXLI.js";import{t as Gg}from"./email-hX48MODm.js";import{a as Yg,c as Jg,d as Xg,f as Zg,i as ex,l as tx,m as sx,o as nx,p as ax,r as rx,s as ix,t as ox,u as lx}from"./IssueChatThread-Cno8fLc-.js";import{t as Kt}from"./query-placeholder-data-Bg4z2kcq.js";import{n as cx,t as dx}from"./issueActiveRun-s6f-GUHq.js";import{t as ux}from"./ApprovalCard-D6X8gzHU.js";import{t as mx}from"./FoldCurtain-H4DNjYLl.js";import{t as Hd}from"./InlineEditor-4ew5gxf0.js";import{t as Vd}from"./useSecondTick-BRYNTPNI.js";import{i as px,n as fx}from"./SourceTrustBadge-CXZGc8G4.js";import{n as hx}from"./interaction-audience-B74UGNaN.js";import{t as gx}from"./runRetryState-p_i4Mh7u.js";import{n as xx}from"./model-fallback-CwykjJWn.js";import{_ as yx,a as vx,c as xa,d as bx,f as zi,g as Or,h as Wl,i as Gd,l as kx,m as zl,n as wx,o as Hi,p as Vi,r as Gi,t as jx,u as Ix,v as ir,y as Io}from"./transcript-adapter-DiPtVkEm.js";import{n as Nx,o as Sx,s as Cx}from"./issue-output-BM-lLts2.js";import{t as Gr}from"./issue-share-W3K_cYZY.js";import{o as Ax,r as Rx,s as Tx,t as Ex}from"./sheet-D5sUsyfT.js";import{t as _x}from"./artifacts-4t_LL-lA.js";import{t as qx}from"./ResponsibleUserDenialNotice-dXyOLtYP.js";import{n as Mx}from"./activity-format-CYYHRbLo.js";var Px=new Set(["archived","cleanup_failed"]);function Fx(e){return!e||e.mode!=="isolated_workspace"?!1:e.closedAt!=null||Px.has(e.status)}a(Fx,"isClosedIsolatedExecutionWorkspace");var Yd={name:"corner-down-right",size:24,node:[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]]};Yd.node;var Yi=gr(Yd),Jd={name:"refresh-ccw",size:24,node:[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]]};Jd.node;var cr=gr(Jd),Xd={name:"scan-eye",size:24,node:[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0",key:"11ak4c"}]]};Xd.node;var Dx=gr(Xd),Zd={name:"ungroup",size:24,node:[["rect",{x:"11",y:"14",width:"10",height:"7",rx:"2",key:"nfm8rk"}],["rect",{x:"3",y:"3",width:"10",height:"7",rx:"2",key:"1ljebb"}]]};Zd.node;var $x=gr(Zd),eu={name:"video",size:24,node:[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]};eu.node;var Lx=gr(eu),l=Eo(Am(),1);function tu(e){return ye({queryKey:["task-browsers",e],queryFn:a(()=>Oa.list(e),"queryFn"),enabled:!!e&&!e?.startsWith("chat:"),refetchInterval:3e3,retry:!1})}a(tu,"useTaskBrowsers");function Bx(e,s,n){const r=JSON.stringify([e,s]),[i,o]=(0,l.useState)(null),u=(0,l.useRef)(new Set),m=(0,l.useCallback)(v=>`wardmote:browser-arrival:v2:${e}:${s}:${v}`,[e,s]),p=i?.scope===r?i:null;(0,l.useEffect)(()=>{if(!s||p)return;const v=n?.find(k=>{if(k.status!=="running"&&k.status!=="idle")return!1;const N=m(k.sessionId);if(u.current.has(N))return!1;try{return!sessionStorage.getItem(N)}catch{return!0}});v&&o({scope:r,browserId:v.id,sessionId:v.sessionId})},[n,p,s,m,r]);const h=(0,l.useCallback)(()=>{if(p){if(p.sessionId){const v=m(p.sessionId);u.current.add(v);try{sessionStorage.setItem(v,"1")}catch{}}o(v=>v===p?null:v)}},[p,m]),d=(0,l.useCallback)(v=>{o({scope:r,browserId:v,sessionId:n?.find(k=>k.id===v)?.sessionId})},[n,r]);return{openBrowserId:p?.browserId??null,openBrowser:d,acknowledgeBrowserOpened:h}}a(Bx,"useBrowserArrivals");var t=Eo(Nm(),1);function Ox({issueId:e,action:s,canManage:n,onQueued:r,className:i}){const o=(0,l.useId)(),[u,m]=(0,l.useState)(""),[p,h]=(0,l.useState)(null),d=Pe({mutationFn:a(()=>xe.retryWorkspaceExport(e,{actionId:s.id,runId:s.evidence.runId,repairNote:u.trim()}),"mutationFn"),onSuccess:a(()=>{h(String(s.updatedAt)),r()},"onSuccess")});if(!s||!Ym(s.cause)||s.ownerType!=="board"||!["active","escalated"].includes(s.status)||typeof s.evidence.runId!="string")return null;const v=p===String(s.updatedAt)||s.wakePolicy?.kind==="resume_native_run";return(0,t.jsxs)("section",{"aria-label":"Workspace export repair",className:ue("task-context-notice flex flex-col gap-2",i),children:[(0,t.jsx)("p",{className:"font-medium",children:"Workspace export needs repair"}),v?(0,t.jsx)("p",{role:"status",children:"Export is queued for the saved result. The agent will not repeat its work."}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"text-ink-3",children:"Automatic workspace export retries stopped. Inspect the export failure, restore provider or destination availability, and preserve the saved files in the retained sandbox. Retry export here when the cause is resolved."}),n?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Cp,{htmlFor:o,children:"Repair performed"}),(0,t.jsx)(va,{id:o,value:u,onChange:a(k=>m(k.target.value),"onChange"),maxLength:12e3,placeholder:"Describe the repair and how the saved workspace files were preserved.",disabled:d.isPending}),(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)(ne,{onClick:a(()=>d.mutate(),"onClick"),disabled:d.isPending||u.trim().length<20,children:d.isPending?"Queueing export…":"Retry workspace export"})})]}):(0,t.jsx)("p",{className:"text-ink-3",children:"A board member with runtime access can retry this export after repair."}),d.isError&&(0,t.jsx)("p",{role:"alert",className:"text-bad",children:d.error instanceof Error?d.error.message:"Could not queue export. Refresh the task and inspect its run."})]})]})}a(Ox,"WorkspaceExportRecovery");function Kx(e){try{localStorage.removeItem(`wardmote:agent-chat-pending:${e}`)}catch{}}a(Kx,"clearLegacyChatMessageRequests");function Ux(e,s="standard"){return{id:`chat:${e.id}`,companyId:e.companyId,title:`Chat with ${e.name}`,conversationAgentId:e.id,conversationUserId:"draft",conversationState:"waiting",status:"in_review",workMode:s,priority:"medium",reviewPolicy:null,projectId:null,projectWorkspaceId:null,goalId:null,parentId:null,description:null,assigneeAgentId:e.id,assigneeUserId:null,checkoutRunId:null,executionRunId:null,executionAgentNameKey:null,executionLockedAt:null,createdByAgentId:null,createdByUserId:null,responsibleUserId:null,issueNumber:null,identifier:null,requestDepth:0,billingCode:null,assigneeAdapterOverrides:null,executionWorkspaceId:null,executionWorkspacePreference:null,executionWorkspaceSettings:null,startedAt:null,completedAt:null,cancelledAt:null,hiddenAt:null,createdAt:new Date(0),updatedAt:new Date(0),documentSummaries:[],labels:[]}}a(Ux,"agentChatDraft");function Qx({companyId:e,issueId:s,blocker:n,onRetried:r,className:i}){const o=ks(),{data:u,error:m}=ye({queryKey:R.issues.runs(s),queryFn:a(()=>zn.runsForIssue(s),"queryFn")}),p=u?.find(k=>k.runId===n.runId&&["failed","timed_out"].includes(k.status)),h=p?.errorCode==="native_provider_model_rejected",d=n.cause==="native_continuation_requires_reconciliation"||n.cause==="native_session_cleanup_quarantined",v=Pe({mutationFn:a(()=>ga.retryFailedRun(n.agentId,n.runId,e),"mutationFn"),onSuccess:a(()=>{r();for(const k of[R.issues.detail(s),R.issues.runs(s),R.issues.liveRuns(s),R.issues.activeRun(s)])o.invalidateQueries({queryKey:k})},"onSuccess")});return(0,t.jsxs)("div",{role:"status","aria-label":"Task recovery",className:ue("task-context-notice flex flex-wrap items-center justify-between gap-2",i),children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1 break-words",children:[(0,t.jsxs)("p",{children:[h?"Model unavailable.":"Recovery needed.",n.runError?` ${n.runError}`:""]}),h&&(0,t.jsx)("p",{children:"Choose a supported model or clear the task's model override, then retry."}),(0,t.jsx)("p",{children:n.nextAction}),!!n.savedMessageCount&&(0,t.jsxs)("p",{children:[n.savedMessageCount," saved ",n.savedMessageCount===1?"message is":"messages are"," waiting for recovery."]})]}),n.agentId&&n.runId&&(0,t.jsx)(ne,{variant:"secondary",size:"sm",asChild:!0,children:(0,t.jsx)(ls,{to:`/agents/${n.agentId}/runs/${n.runId}`,children:"Inspect run"})}),!n.workspaceRepairRequired&&(!d||n.canRetry)&&n.agentId&&n.runId&&(n.cause==="legacy_execution_requires_reconciliation"&&p||n.canContinue||n.canRetry)&&(0,t.jsx)(ne,{variant:"secondary",size:"sm",disabled:v.isPending,onClick:a(()=>v.mutate(),"onClick"),children:v.isPending?"Starting…":n.canContinue?"Continue":"Retry"}),v.isError&&(0,t.jsx)("p",{role:"alert",className:"w-full text-bad",children:v.error.message}),m&&(0,t.jsx)("p",{role:"alert",className:"w-full text-bad",children:m.message})]})}a(Qx,"ExecutionBlockerNotice");function Wx({companyId:e,issueId:s}){const n=ks(),r=["email-thread",e,s],i=!!(e&&s)&&!s.startsWith("chat:"),o=Ig(e,s);if(!i)return null;const u=o.data,m=u?.messages.filter(h=>!h.commentId)??[],p=u?.publications.filter(h=>!h.providerMessageId||h.outcome==="uncertain")??[];return!o.error&&!m.length&&!p.length?null:(0,t.jsxs)("div",{className:"space-y-3",children:[o.error&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-bad",children:o.error.message}),m.map(h=>(0,t.jsx)(Sg,{contextNotice:!0,issueId:s,message:h,publication:u?.publications.find(d=>d.providerMessageId===h.providerMessageId)},h.id)),p.map(h=>(0,t.jsx)(zx,{companyId:e,publication:h,onResolved:a(()=>{n.invalidateQueries({queryKey:r})},"onResolved")},h.id))]})}a(Wx,"EmailTaskActivity");function zx({companyId:e,publication:s,onResolved:n}){const[r,i]=(0,l.useState)(""),o=Pe({mutationFn:a(u=>Gg.resolve(e,s.id,u,r||void 0),"mutationFn"),onSuccess:n});return(0,t.jsxs)("div",{className:"space-y-2 text-xs text-ink-3",children:[s.request&&!s.providerMessageId&&(0,t.jsxs)("article",{"aria-label":"Email send intent",className:"task-context-notice space-y-3",children:[(0,t.jsx)("p",{className:"font-semibold",children:s.request.subject??"Email reply"}),s.request.to&&(0,t.jsxs)("p",{children:["To: ",s.request.to.join(", ")]}),(0,t.jsx)("div",{className:"whitespace-pre-wrap break-words text-sm text-ink",children:s.request.text})]}),(0,t.jsxs)("p",{children:["Email ",s.outcome,s.error?` — ${s.error}`:""]}),s.outcome==="uncertain"&&(0,t.jsxs)("details",{children:[(0,t.jsx)("summary",{className:"cursor-pointer",children:"Resolve delivery after checking AgentMail"}),(0,t.jsxs)("div",{className:"space-y-2 py-2",children:[(0,t.jsx)("p",{children:"Confirm the outcome in AgentMail before resolving. This action does not resend."}),(0,t.jsx)(jr,{"aria-label":"Provider message ID",value:r,onChange:a(u=>i(u.target.value),"onChange"),placeholder:"Provider message ID"}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(ne,{size:"sm",variant:"secondary",disabled:!r||o.isPending,onClick:a(()=>o.mutate("sent"),"onClick"),children:"Confirm sent"}),(0,t.jsx)(ne,{size:"sm",variant:"secondary",disabled:o.isPending,onClick:a(()=>o.mutate("failed"),"onClick"),children:"Confirm not sent"})]}),o.error&&(0,t.jsx)("p",{role:"alert",className:"text-bad",children:o.error.message})]})]})]})}a(zx,"EmailDelivery");var su=Eo(Rm(),1);function ar(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}a(ar,"record$2");var Hx=new Set(["available","unsupported","temporarily_unavailable"]),Vx=new Set(["deferred","queued"]);function Hl(e,s){const n=ar(e),r=new Set,i=(Array.isArray(n?.entries)?n.entries:[]).flatMap((p,h)=>{const d=ar(p),v=ar(d?.comment),k=typeof v?.id=="string"?v.id:"",N=typeof v?.body=="string"?v.body:null;if(!k||N===null||r.has(k))return[];r.add(k);const A=typeof d?.position=="number"&&Number.isFinite(d.position)?d.position:h,E=ar(d?.source);return[{comment:v,position:A,...E?.kind==="interaction"&&typeof E.interactionId=="string"&&typeof E.interactionKind=="string"?{source:{kind:"interaction",interactionId:E.interactionId,interactionKind:E.interactionKind,requiresFreshSession:E.requiresFreshSession===!0}}:{},canEdit:d?.canEdit===!0,canDiscard:d?.canDiscard===!0}]}).sort((p,h)=>p.position-h.position).map((p,h)=>({...p,position:h})),o=n?.steeringDisposition,u=n?.state,m=ar(n?.executionWait);return{issueId:typeof n?.issueId=="string"?n.issueId:s,queueId:typeof n?.queueId=="string"?n.queueId:null,state:typeof u=="string"&&Vx.has(u)?u:null,targetRunId:typeof n?.targetRunId=="string"?n.targetRunId:null,revision:typeof n?.revision=="string"?n.revision:"unavailable",protocol:n?.protocol==="wardmote_runner_v1"?"wardmote_runner_v1":"legacy",steeringDisposition:typeof o=="string"&&Hx.has(o)?o:"unsupported",entries:i,executionWait:typeof m?.reason=="string"&&typeof m?.message=="string"?{reason:m.reason,message:m.message}:null}}a(Hl,"normalizeIssueQueuedCommentQueue");function Gx(e){return new Set((e?.entries??[]).flatMap(s=>s.source?.kind==="interaction"?[s.source.interactionId]:[]))}a(Gx,"queuedInteractionResponseIds");function Yx(e){const s=e.authoritativeQueue?.entries??[],n=new Set(s.map(d=>d.comment.id)),r=e.pendingComments.filter(({comment:d})=>!n.has(d.id)).map(({comment:d},v)=>({comment:d,position:s.length+v,canEdit:!1,canDiscard:!0})),i=[...s,...r].map((d,v)=>({...d,position:v}));if(i.length===0)return null;const o=r.length===0,u=!!e.authoritativeQueue?.queueId,m=e.pendingComments.find(d=>d.targetRunId)?.targetRunId??null,p=u?e.authoritativeQueue.protocol:e.fallbackProtocol,h=u?e.authoritativeQueue?.targetRunId??null:m;return{issueId:e.authoritativeQueue?.issueId??e.issueId,queueId:o?e.authoritativeQueue?.queueId??null:null,state:e.authoritativeQueue?.state??(h?"deferred":null),targetRunId:h,revision:e.authoritativeQueue?.revision??"awaiting-server",protocol:p,steeringDisposition:(u?e.authoritativeQueue?.steeringDisposition:void 0)??(p==="wardmote_runner_v1"&&h?"temporarily_unavailable":"unsupported"),entries:i,executionWait:e.authoritativeQueue?.executionWait??null}}a(Yx,"mergePendingIssueQueuedComments");function Jx(e,s){return Promise.all([e.prefetchQuery({queryKey:R.issues.activity(s),queryFn:a(()=>zn.forIssue(s),"queryFn"),staleTime:3e4}),e.prefetchQuery({queryKey:R.issues.runs(s),queryFn:a(()=>zn.runsForIssue(s),"queryFn"),staleTime:3e4})])}a(Jx,"prefetchIssueThread");var ii="issue-detail:navigate",nu="issue-detail:header-paint",au="issue-detail:content-paint",ru="issue-detail:navigate→header-paint",iu="issue-detail:navigate→content-paint",Yr=0;function ou(){return typeof window<"u"&&typeof performance<"u"&&typeof performance.mark=="function"}a(ou,"supportsPerformanceMarks");function Xx(){if(Yr+=1,!ou())return;performance.clearMarks(ii),performance.clearMarks(nu),performance.clearMarks(au),performance.clearMeasures(ru),performance.clearMeasures(iu);const e=window.__WARDMOTE_ISSUE_DETAIL_NAVIGATE_START__;delete window.__WARDMOTE_ISSUE_DETAIL_NAVIGATE_START__,performance.mark(ii,{startTime:typeof e=="number"?e:performance.now()})}a(Xx,"beginIssueDetailNavigation");function lu(e,s){if(!ou()||performance.getEntriesByName(s).length>0)return;const n=Yr;requestAnimationFrame(()=>{n===Yr&&requestAnimationFrame(()=>{n===Yr&&(performance.getEntriesByName(s).length>0||(performance.getEntriesByName("issue-detail:navigate").length===0&&performance.mark(ii),performance.mark(e),performance.measure(s,ii,e)))})})}a(lu,"scheduleIssueDetailPaintMeasure");function Zx(e){const s=[e.savedPlan?"Workspace restore failed after the plan was saved. The saved plan is available.":"Workspace restore failed."];s.push("Workspace files need recovery."),!e.hasResponse&&e.result?.finalResponseRecorded===!1&&s.push("No final response was recorded.");const n=Jm(e.result?.workspaceRestorePath);return n&&s.push(`Affected path: ${n}.`),s.join(" ")}a(Zx,"workspaceRestoreMarkerDetail");function Vl(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}a(Vl,"object");function e0(e,s,n){if(!e||e.status!=="failed")return;const r=Vl(e.resultJson?.configurationIncomplete);if(r.selectionFailure!=="ai_connection_credential_not_shared"&&e.error!=="This credential is not shared with the responsible user")return;const i=Vl(r.credentialAccess),o=typeof r.responsibleUserId=="string"?r.responsibleUserId:e.responsibleUserId;return{agentName:e.agentName?.trim()||"This agent",credentialName:typeof i.connectionName=="string"&&i.connectionName.trim()?i.connectionName:void 0,deniedUser:o&&o===s?"you":o&&n?.get(o)||"the person this task runs for",settingsHref:`/agents/${encodeURIComponent(e.agentId)}/runtime`}}a(e0,"credentialAccessNotice");function Gl(e,s=[]){const n=new Set;return e.flatMap(r=>{if(r.action!=="project.created"||r.entityType!=="project"||n.has(r.entityId))return[];const i=r.details??{};if(typeof i.name!="string")return[];n.add(r.entityId);const o=s.find(h=>h.id===r.entityId&&h.companyId===r.companyId),u=o?o.workspaces.map(h=>({id:h.id,name:h.name,url:h.repoUrl})):i.repositories,m=new Set,p=Array.isArray(u)?u.flatMap(h=>{if(!h||typeof h!="object")return[];const d=h;return typeof d.id!="string"||typeof d.name!="string"||typeof d.url!="string"||!/^https:\/\//.test(d.url)?[]:m.has(d.url)?[]:(m.add(d.url),[{id:d.id,name:d.name,url:d.url}])}):[];return[{id:`project-created:${r.entityId}`,kind:"project_created",projectId:r.entityId,name:i.name,description:typeof i.description=="string"?i.description:null,repositories:p,timestamp:new Date(r.createdAt).toISOString()}]})}a(Gl,"projectCreatedItems");function t0(e){return e.flatMap(s=>s.isSuccess?[s.data]:[])}a(t0,"availableProjects");function s0(e,s){const n=(0,l.useMemo)(()=>Gl(e),[e]),r=rd({queries:n.map(i=>({queryKey:R.projects.detail(i.projectId),queryFn:a(()=>wi.get(i.projectId,s),"queryFn"),enabled:!!s,retry:!1})),combine:t0});return(0,l.useMemo)(()=>Gl(e,r),[e,r])}a(s0,"useProjectCreatedItems");function n0(e){const s=new Set;return e.flatMap(n=>{if(n.action!=="company.skill_created"||n.entityType!=="company_skill"||s.has(n.entityId))return[];const r=n.details??{};return typeof r.name!="string"?[]:(s.add(n.entityId),[{id:`skill-created:${n.entityId}`,kind:"skill_created",skillId:n.entityId,name:r.name,description:typeof r.description=="string"?r.description:null,slug:typeof r.slug=="string"?r.slug:null,versionId:typeof r.versionId=="string"?r.versionId:null,timestamp:new Date(n.createdAt).toISOString()}])})}a(n0,"skillCreatedItems");function ut(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}a(ut,"record$1");function ae(e){return typeof e=="string"&&e.length>0?e:null}a(ae,"text");function Un(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:0}a(Un,"finiteNumber");function Wa(e){return ut(e.item)??e}a(Wa,"normalizedItem");function a0(e){const s=Wa(e);return(ae(e.kind)??ae(s.kind)??ae(s.type)??"").replaceAll("_","").toLowerCase()}a(a0,"normalizedItemKind");function Ji(e){return e==="agentmessage"||e==="assistantmessage"}a(Ji,"isAssistantItemKind");function Yl(e,s){const n=Wa(s);return ae(e.itemId)??ae(s.itemId)??ae(n.id)}a(Yl,"normalizedItemId");function Fa(e){const s=Wa(e);return ae(e.text)??ae(s.text)}a(Fa,"normalizedItemText");function r0(e,s="unknown"){const n=Wa(e),r=ae(e.channel)??ae(n.channel);return r==="progress"||r==="final"||r==="unknown"?r:s}a(r0,"assistantChannel");function i0(e,s="unknown"){const n=Wa(e),r=ae(e.channel)??ae(n.channel);return r==="summary"||r==="detail"||r==="unknown"?r:s}a(i0,"reasoningChannel");function Jl(e,s){return{kind:a0(e)||s?.kind||"",assistantChannel:r0(e,s?.assistantChannel),reasoningChannel:i0(e,s?.reasoningChannel)}}a(Jl,"resolveItemIdentity");function Xi(e){return e==="item.started"||e==="item.delta"||e==="item.completed"}a(Xi,"isItemIdentityEvent");var o0="wardmote.tool.execution.v1",l0="wardmote.run_result.v1",c0="wardmote.prp.terminal.v1";function d0(e){const s=ut(e);return!s||s.schema!=="wardmote.question_set.v1"||!Array.isArray(s.questions)||s.questions.length===0?null:s.questions.every(n=>{const r=ut(n);return!!(r&&ae(r.id)&&ae(r.prompt)&&typeof r.required=="boolean"&&(r.answerMode==="single_select"||r.answerMode==="multi_select"||r.answerMode==="text"))})?structuredClone(s):null}a(d0,"canonicalQuestionSet");function u0(e){const s=ut(e);return s&&s.schema==="wardmote.question_response.v1"&&ut(s.answers)?structuredClone(s):null}a(u0,"canonicalQuestionResponse");function m0(e){return e==="passed"||e==="failed"?e:"not_run"}a(m0,"verificationStatus");function p0(e){const s=ut(e.payload.request)??e.payload,n=ae(s.requestId)??ae(e.payload.requestId);if(!n)return null;const r=e.eventType.split(".").at(-1),i=r==="resolved"||r==="expired"||r==="cancelled"?r:ae(s.status)??r,o=ae(s.action)??ae(e.payload.action)??e.previous?.resolvedAction??null,u=i==="resolved"||i==="expired"||i==="cancelled"?i:"pending",m=u==="resolved"&&(o==="cancel"||o==="decline")?"cancelled":u,p=ae(s.requestKind)??e.previous?.requestKind??null,h=p==="runtime"||p==="command_approval"||p==="file_approval"||p==="permission_approval"||p==="user_input"||p==="elicitation"?p:null,d=ae(s.type)??e.previous?.requestType??"permission",v=h==="user_input"||h==="elicitation"||d==="input"||d.includes("input")||d.includes("elicitation")?"input":"permission",k=(Array.isArray(s.choices)?s.choices:[]).map(ut).flatMap(E=>{const _=ae(E?.key),q=ae(E?.label);return _&&q?[{key:_,label:q}]:[]}).slice(0,32),N=ut(s.details),A=(Array.isArray(N?.fields)?N.fields:[]).map(ut).flatMap((E,_)=>{const q=ae(E?.name)??`answer_${_+1}`,O=ae(E?.label)??ae(E?.name)??`Answer ${_+1}`;return q&&O?[{name:q.slice(0,160),label:O.slice(0,240),placeholder:ae(E?.placeholder)?.slice(0,500)??null}]:[]}).slice(0,16);return{kind:"runtime_request",ts:e.ts,requestId:n,requestKind:h,turnId:ae(s.turnId)??ae(e.payload.turnId)??ae(e.envelope.turnId)??e.previous?.turnId??null,requestType:v,status:m,prompt:ae(s.prompt)??e.previous?.prompt??"Runtime approval requested",choices:k.length>0?k:e.previous?.choices??[],fields:A.length>0?A:e.previous?.fields??[],questionSet:d0(s.input)??e.previous?.questionSet??null,resolvedAction:o,response:u0(s.response??e.payload.response)??e.previous?.response??null}}a(p0,"runtimeRequestEntry");function f0(e,s){const n=ut(e.completionClaim)??{},r=ut(e.blocker),i=ae(e.reportedWorkDisposition);return{kind:"run_result",ts:s,disposition:i==="blocked"||i==="needs_review"||i==="yielded"?i:"done",summary:ae(e.summary)??"Run completed",objectiveSatisfied:typeof n.objectiveSatisfied=="boolean"?n.objectiveSatisfied:null,verification:(Array.isArray(e.verification)?e.verification:[]).map(ut).flatMap(o=>o?[{commandOrCheck:ae(o.commandOrCheck)??"Verification",status:m0(o.status),...ae(o.detail)?{detail:ae(o.detail)}:{},...ae(o.artifactRef)?{artifactRef:ae(o.artifactRef)}:{}}]:[]).slice(0,64),remainingWork:(Array.isArray(n.remainingWork)?n.remainingWork:[]).map(ut).flatMap(o=>o&&ae(o.description)?[{description:ae(o.description),blocksCompletion:o.blocksCompletion===!0}]:[]).slice(0,64),blocker:r?{reasonCode:ae(r.reasonCode)??"blocked",unblockAction:ae(r.unblockAction)??"Resolve the blocker to continue.",scope:r.scope==="task_wide"?"task_wide":"current_track"}:null,artifacts:(Array.isArray(e.artifacts)?e.artifacts:[]).map(ut).flatMap(o=>o&&ae(o.ref)?[{kind:ae(o.kind)??"artifact",ref:ae(o.ref),...ae(o.title)?{title:ae(o.title)}:{}}]:[]).slice(0,64)}}a(f0,"runResultEntry");function h0(e,s){if(e.schema!==c0)return null;const n=ae(e.turnTerminalState),r=ae(e.runTerminalState),i=ae(e.reportedWorkDisposition);if(!n||!["completed","failed","interrupted","cancelled"].includes(n)||!r||!["succeeded","failed","cancelled"].includes(r)||!i||!["done","blocked","needs_review","yielded"].includes(i))return null;const o=ut(e.stopReason);return{kind:"run_terminal",ts:s,turnState:n,runState:r,disposition:i,...ae(o?.message)||ae(o?.code)?{stopReason:ae(o?.message)??ae(o?.code)}:{}}}a(h0,"runTerminalEntry");var Xl={"plan.updated":{schema:"wardmote.plan.updated.v1",idKey:"planId",name:"plan",summaryKeys:["explanation"]},"research.started":{schema:"wardmote.research.v1",idKey:"researchId",name:"research",summaryKeys:["query","pattern","url"]},"research.progressed":{schema:"wardmote.research.v1",idKey:"researchId",name:"research",summaryKeys:["query","pattern","url"]},"research.completed":{schema:"wardmote.research.v1",idKey:"researchId",name:"research",summaryKeys:["query","pattern","url"]},"delegation.started":{schema:"wardmote.delegation.v1",idKey:"delegationId",name:"delegation",summaryKeys:["action"]},"delegation.updated":{schema:"wardmote.delegation.v1",idKey:"delegationId",name:"delegation",summaryKeys:["action"]},"delegation.completed":{schema:"wardmote.delegation.v1",idKey:"delegationId",name:"delegation",summaryKeys:["action"]},"model.route.changed":{schema:"wardmote.model.route_changed.v1",idKey:"routeId",name:"model",summaryKeys:["reason","effectiveModel"]},"model.verification.updated":{schema:"wardmote.model.verification.v1",idKey:"verificationId",name:"model",summaryKeys:["summary"]},"context.compacted":{schema:"wardmote.context.compacted.v1",idKey:"compactionId",name:"context",summaryKeys:["reason"]},"artifact.viewed":{schema:"wardmote.artifact.viewed.v1",idKey:"artifactId",name:"artifact",summaryKeys:["title","reference"]},"artifact.generated":{schema:"wardmote.artifact.generated.v1",idKey:"artifactId",name:"artifact",summaryKeys:["failure","reference"]},"review.mode.changed":{schema:"wardmote.review.mode_changed.v1",idKey:"reviewId",name:"review",summaryKeys:["scope","state"]},"hook.started":{schema:"wardmote.hook.v1",idKey:"hookId",name:"hook",summaryKeys:["summary","event"]},"hook.completed":{schema:"wardmote.hook.v1",idKey:"hookId",name:"hook",summaryKeys:["summary","event"]},"memory.citation.referenced":{schema:"wardmote.memory.citation.v1",idKey:"citationId",name:"memory",summaryKeys:["label"]},"safety.review.started":{schema:"wardmote.safety.review.v1",idKey:"reviewId",name:"safety",summaryKeys:["summary","decision"]},"safety.review.completed":{schema:"wardmote.safety.review.v1",idKey:"reviewId",name:"safety",summaryKeys:["summary","decision"]},"terminal.input.sent":{schema:"wardmote.terminal.input_sent.v1",idKey:"executionId",name:"terminal",summaryKeys:["inputClass"]},"wait.started":{schema:"wardmote.wait.v1",idKey:"waitId",name:"wait",summaryKeys:["reason"]},"wait.completed":{schema:"wardmote.wait.v1",idKey:"waitId",name:"wait",summaryKeys:["reason"]},"provider.notice.recorded":{schema:"wardmote.provider.notice.v1",idKey:"noticeId",name:"Provider notice",summaryKeys:["summary"]}},g0=new Set(["running","pending","in_progress","waiting"]),x0=new Set(["completed","failed","cancelled","interrupted","closed","denied"]);function y0(e,s){if(!Object.prototype.hasOwnProperty.call(Xl,e.eventType))return null;const n=Xl[e.eventType];if(!n||s.schema!==n.schema)return null;const r=ae(s[n.idKey]);if(!r)return null;const i=n.summaryKeys.map(p=>ae(s[p])).find(p=>p!==null)??e.eventType,o=ae(s.status),u=o==="failed"||o==="denied"||s.severity==="error",m=u?!0:g0.has(o??"")?!1:x0.has(o??"")||e.eventType.endsWith(".completed")||e.eventType.endsWith(".failed")||!e.eventType.endsWith(".started")&&!e.eventType.endsWith(".progressed");return{id:`${e.eventType.split(".")[0]}:${r}`,name:n.name,summary:i,terminal:m,failed:u}}a(y0,"providerActivityPresentation");function Zl(e,s){const n=ae(s.emittedAt);if(n)return n;const r=e.createdAt instanceof Date?e.createdAt.toISOString():String(e.createdAt);return Number.isNaN(Date.parse(r))?new Date(0).toISOString():r}a(Zl,"timestamp$1");function ec(e){const s=Wa(e),n=(ae(s.type)??"").replaceAll("_","").toLowerCase();return n!=="tooluse"&&n!=="toolresult"?null:{id:n==="toolresult"?ae(s.tool_use_id)??ae(s.id):ae(s.id),kind:n,details:{name:ae(s.name),...Object.prototype.hasOwnProperty.call(s,"input")?{input:s.input}:{},...Object.prototype.hasOwnProperty.call(s,"result")?{result:s.result}:{},isError:s.isError===!0||s.is_error===!0}}}a(ec,"nativeToolItemDetails");function tc(e){if(e.result===void 0)return"";try{return JSON.stringify(e.result)??""}catch{return"Tool result could not be serialized"}}a(tc,"serializedNativeToolResult");function sc(e,s){const n=ae(e.transport),r=ae(e.operation),i=ae(e.name)??s?.name??null;return n==="process"?{name:"Bash",input:i?{command:i}:{operation:r??"execute"}}:{name:i??r??"Tool",input:s?.input??{...r?{operation:r}:{},...ae(e.namespace)?{namespace:ae(e.namespace)}:{},...ae(e.target)?{target:ae(e.target)}:{}}}}a(sc,"toolPresentation");function v0(e){const s=[],n=new Set,r=new Set;let i=!1,o=null,u=null,m=null;const p=new Set,h=[...e].sort((S,P)=>S.seq-P.seq).filter(S=>{const P=ae(ut(S.payload?.prpEvent)?.sourceEventId);return P?p.has(P)?!1:(p.add(P),!0):!0}).flatMap(S=>{const P=ut(S.payload?.prpEvent),j=ut(P?.payload);return!P||P.eventType!==S.eventType||!/^(item|turn|session)\.(completed|failed|cancelled|interrupted|closed)$/.test(S.eventType)||!Array.isArray(j?.outputTails)?[S]:[...j.outputTails.flatMap((f,w)=>{const W=ut(f),M=ut(W?.payload);return!M||typeof M.text!="string"?[]:[{...S,eventType:"item.delta",payload:{prpEvent:{...P,eventType:"item.delta",itemId:W?.itemId,sourceEventId:`${P.sourceEventId}:output-tail:${w}`,payload:M}}}]}),S]}),d=h.some(S=>S.eventType==="run.result.accepted"),v=new Map;let k=!1,N=null;const A=new Map,E=new Map,_=new Set,q=new Set,O=new Map,F=new Map;for(const S of h){if(!Xi(S.eventType))continue;const P=ut(S.payload?.prpEvent);if(!P||P.schema!=="wardmote.prp.event.v1"||P.schemaVersion!==1||P.runId!==S.runId||P.eventType!==S.eventType)continue;const j=ut(P?.payload);if(!j)continue;const f=Yl(P,j);if(!f)continue;const w=ec(j);if(w){const $=w.id??f,K=F.get($);F.set($,{name:w.details.name??K?.name??null,...w.details.input!==void 0?{input:w.details.input}:K?.input!==void 0?{input:K.input}:{},...w.details.result!==void 0?{result:w.details.result}:K?.result!==void 0?{result:K.result}:{},isError:w.details.isError||K?.isError===!0})}const W=Jl(j,O.get(f));if(W.kind&&O.set(f,W),S.eventType!=="item.completed")continue;const M=W.kind;Ji(M)&&f&&Fa(j)&&_.add(f),M==="reasoning"&&f&&Fa(j)&&q.add(f)}const C=new Map;for(const S of h){const P=xx(S.eventType,S.payload);if(P){s.push({kind:"system",ts:Zl(S,{}),text:S.message?.trim()||P});continue}const j=ut(S.payload?.prpEvent);if(!j||j.schema!=="wardmote.prp.event.v1"||j.schemaVersion!==1||j.runId!==S.runId||j.eventType!==S.eventType)continue;const f=ut(j.payload);if(!f)continue;const w=Zl(S,j),W=Yl(j,f),M=Jl(f,W?C.get(W):void 0);W&&M.kind&&Xi(S.eventType)&&C.set(W,M);const $=M.kind;if(S.eventType==="item.delta"&&Ji($)){const y=Fa(f);if(!y||!W||_.has(W))continue;const z=M.assistantChannel;z!=="progress"&&(i=!0),s.push({kind:"assistant",ts:w,text:y,delta:!0,channel:z,itemId:W});continue}if(S.eventType==="item.completed"&&Ji($)){const y=Fa(f);if(!y)continue;const z=M.assistantChannel;z!=="progress"&&(i=!0),s.push({kind:"assistant",ts:w,text:y,channel:z,...W?{itemId:W}:{}});continue}if(S.eventType==="item.delta"&&$==="reasoning"){const y=Fa(f);if(!y||!W||q.has(W))continue;s.push({kind:"thinking",ts:w,text:y,delta:!0,lifecycle:"started",channel:M.reasoningChannel,itemId:W});continue}if(S.eventType==="item.completed"&&$==="reasoning"){const y=Fa(f);if(!y)continue;s.push({kind:"thinking",ts:w,text:y,lifecycle:"completed",channel:M.reasoningChannel,...W?{itemId:W}:{}});continue}const K=Xi(S.eventType)?ec(f):null;if(K){const y=K.id??W;if(!y)continue;const z=F.get(y)??K.details,se=sc({},z);n.has(y)||(n.add(y),s.push({kind:"tool_call",ts:w,name:se.name,input:se.input,toolUseId:y})),S.eventType==="item.completed"&&(K.kind==="toolresult"||K.details.result!==void 0)&&!r.has(y)&&(r.add(y),s.push({kind:"tool_result",ts:w,toolUseId:y,toolName:se.name,content:tc(z),isError:z.isError}));continue}if(S.eventType==="provider.notice.recorded"&&f.schema==="wardmote.provider.notice.v1"){if(Dm(S.eventType,f))continue;s.push({kind:"provider_activity",ts:w,family:"provider_notice",eventType:S.eventType,status:f.severity==="error"?"failed":"informational",title:"Provider notice",summary:ae(f.summary)?.trim()||ae(f.message)?.trim()||"Provider notice",payload:f});continue}const le=y0(S,f);if(le){n.has(le.id)||(n.add(le.id),s.push({kind:"tool_call",ts:w,name:le.name,toolUseId:le.id,input:{eventType:S.eventType,summary:le.summary}})),le.terminal&&s.push({kind:"tool_result",ts:w,toolUseId:le.id,toolName:le.name,content:le.summary,isError:le.failed});continue}if(S.eventType==="tool.execution.started"||S.eventType==="tool.execution.completed"){if(f.schema!==o0)continue;const y=ae(f.executionId);if(!y)continue;const z=F.get(y),se=sc(f,z);if(n.has(y)||(n.add(y),s.push({kind:"tool_call",ts:w,name:se.name,input:se.input,toolUseId:y})),S.eventType==="tool.execution.completed"&&!r.has(y)){r.add(y);const de=ae(f.output)??(z?tc(z):"");s.push({kind:"tool_result",ts:w,toolUseId:y,toolName:se.name,content:de,isError:f.status==="failed"||z?.isError===!0})}continue}if(S.eventType==="usage.reported"){if(f.runDeltaAvailable!==!0){const se=ut(f.cumulative);se&&(u={ts:w,inputTokens:Un(se.inputTokens),outputTokens:Un(se.outputTokens),cachedTokens:Un(se.cacheReadTokens),costUsd:Un(se.providerCostUsd)});continue}const y=ut(f.runDelta);if(!y)continue;const z={ts:w,inputTokens:Un(y.inputTokens),outputTokens:Un(y.outputTokens),cachedTokens:Un(y.cacheReadTokens),costUsd:Un(y.providerCostUsd)};o=o?{ts:w,inputTokens:o.inputTokens+z.inputTokens,outputTokens:o.outputTokens+z.outputTokens,cachedTokens:o.cachedTokens+z.cachedTokens,costUsd:o.costUsd+z.costUsd}:z;continue}if(S.eventType.startsWith("runtime_request.")){const y=ae((ut(f.request)??f).requestId)??ae(f.requestId),z=p0({eventType:S.eventType,envelope:j,payload:f,ts:w,...y?{previous:v.get(y)}:{}});z&&(v.set(z.requestId,z),s.push(z));continue}if(S.eventType==="run.terminal"){const y=h0(f,w);y&&(s.push(y),E.set(S.runId,{entry:y,seq:S.seq,envelope:j}));continue}if(S.eventType==="run.result.proposed"||S.eventType==="run.result.accepted"){if(S.eventType==="run.result.proposed"&&d)continue;const y=S.eventType==="run.result.accepted"?ut(f.result):f;if(!y||y.schema!==l0)continue;if(S.eventType==="run.result.accepted"&&A.set(S.runId,(A.get(S.runId)??0)+1),!k){const se=f0(y,w);s.push(se);const de=ut(y.continuation),me=ae(j.sourceEventId),oe=ae(j.sourceInstanceId),ve=ae(j.normalizedSessionId);S.eventType==="run.result.accepted"&&j.sourceKind==="control_plane"&&se.disposition==="yielded"&&ae(y.summary)?.trim()&&de?.kind==="response_wake"&&ae(de.idempotencyKey)?.trim()&&Array.isArray(y.attentionRequests)&&y.attentionRequests.length===0&&me?.trim()&&oe?.trim()&&ve?.trim()&&(N={entry:se,runId:S.runId,sourceEventId:me,sourceInstanceId:oe,normalizedSessionId:ve,turnId:ae(j.turnId),seq:S.seq}),k=!0}const z=ae(y.summary);!i&&z&&!m&&(m={ts:w,text:z});continue}}if(N){const S=N,P=E.get(S.runId);A.get(S.runId)===1&&P&&P.seq>S.seq&&P.envelope.sourceKind==="control_plane"&&ae(P.envelope.sourceEventId)?.trim()&&P.envelope.sourceInstanceId===S.sourceInstanceId&&P.envelope.normalizedSessionId===S.normalizedSessionId&&ae(P.envelope.turnId)===S.turnId&&P.entry.runState==="succeeded"&&P.entry.turnState==="completed"&&P.entry.disposition==="yielded"&&![...v.values()].some(j=>j.status==="pending")&&(S.entry.acceptedResponseWake={runId:S.runId,sourceEventId:S.sourceEventId})}return!i&&m&&s.push({kind:"assistant",ts:m.ts,text:m.text,channel:"final"}),o?s.push({kind:"result",...o,text:"",subtype:"wardmote_runner_usage",isError:!1,errors:[]}):u&&s.push({kind:"result",...u,text:"Provider-reported session-cumulative usage; a per-run delta was unavailable.",subtype:"wardmote_runner_session_usage",isError:!1,errors:[]}),s}a(v0,"nativeRunEventsToTranscript");var nc=1e3,b0=2e3;function k0(e){return e==="queued"||e==="running"}a(k0,"isLive");function w0(e){const s=e.filter(A=>A.runtimeMode==="native").map(A=>`${A.id}:${A.status}`).sort().join(","),n=(0,l.useMemo)(()=>e.filter(A=>A.runtimeMode==="native").map(A=>({...A})),[s]),[r,i]=(0,l.useState)(new Map),[o,u]=(0,l.useState)(new Map),[m,p]=(0,l.useState)(new Set),[h,d]=(0,l.useState)(0),v=(0,l.useCallback)(()=>d(A=>A+1),[]),k=(0,l.useRef)(new Map),N=(0,l.useRef)(new Map);return(0,l.useEffect)(()=>{let A=!1;const E=new AbortController,_=new Set,q=new Set(n.map(C=>C.id)),O=a(C=>{const S=new Map([...C].filter(([P])=>q.has(P)));return S.size===C.size?C:S},"retainMap");i(O),u(O),p(C=>{const S=new Set([...C].filter(P=>q.has(P)));return S.size===C.size?C:S});for(const C of N.current.keys())q.has(C)||N.current.delete(C);const F=a(async C=>{let S=!1;try{let P=N.current.get(C.id)??0;const j=[];for(;;){const f=await Zg(M=>vs.events(C.id,P,nc,{signal:M}),E.signal);if(A)return;const w=f.at(-1),W=w?Math.max(P,w.seq):P;if(j.push(...f.filter(M=>M.seq>P)),f.length<nc||W===P){P=W;break}P=W}N.current.set(C.id,P),j.length>0&&i(f=>{const w=new Map(f);return w.set(C.id,[...f.get(C.id)??[],...j]),w}),u(f=>{if(!f.has(C.id))return f;const w=new Map(f);return w.delete(C.id),w})}catch(P){if(A)return;S=!0,u(j=>{if(j.has(C.id))return j;const f=new Map(j);return f.set(C.id,{message:P instanceof Error?P.message:"Native run activity could not be loaded",failedAt:new Date().toISOString()}),f})}if(!A&&(p(P=>P.has(C.id)?P:new Set([...P,C.id])),k0(C.status)||S)){const P=window.setTimeout(()=>{_.delete(P),F(C)},b0);_.add(P)}},"refreshRun");for(const C of n)F(C);return()=>{A=!0,E.abort();for(const C of _)window.clearTimeout(C)}},[n,h]),{transcriptByRun:(0,l.useMemo)(()=>{const A=new Map;for(const E of n){const _=r.get(E.id);if(!_)continue;let q=k.current.get(E.id);(!q||q.events!==_)&&(q={events:_,transcript:v0(_)},k.current.set(E.id,q)),A.set(E.id,q.transcript)}for(const E of k.current.keys())A.has(E)||k.current.delete(E);return A},[r,n]),errorsByRun:o,hydratedRunIds:m,retry:v,isInitialHydrating:n.some(A=>!m.has(A.id))}}a(w0,"useNativeRunTranscripts");function j0({items:e,turnId:s="turn",emptyMessage:n,excludeFinal:r=!1,onRuntimeRequestDecision:i}){const o=(0,l.useMemo)(()=>{const u=r?e.filter(h=>h.kind!=="message"||h.interstitial):e,m=Gd(u,!0,s),p=yd(m.filter(h=>h.kind==="activity_phase"));return m.map(h=>I0(h,p,i)).filter(h=>h!=null)},[e,r,i,s]);return o.length===0?n?(0,t.jsx)("div",{className:"px-1 py-1 text-xs text-ink-3/70",children:n}):null:(0,t.jsx)("div",{className:"flex flex-col gap-2",children:o})}a(j0,"TaskChatLiveTail");function I0(e,s,n){switch(e.kind){case"message":return e.text.trim()?(0,t.jsx)("div",{className:"px-1 text-sm text-ink/90","data-testid":"task-chat-live-text",children:(0,t.jsx)(bs,{softBreaks:!0,linkIssueReferences:!0,children:e.text})},e.id):null;case"tool":return(0,t.jsx)("div",{children:(0,t.jsx)(Of,{item:e})},e.id);case"usage":return(0,t.jsx)("div",{children:(0,t.jsx)(lf,{item:e})},e.id);case"thinking":return(0,t.jsx)(Uf,{item:e},e.id);case"activity_phase":return(0,t.jsx)(vd,{item:e,openActivityIds:s},e.id);case"todo":return(0,t.jsx)(Fd,{item:e},e.id);case"protocol":return(0,t.jsx)($o,{item:e,onRuntimeRequestDecision:n},e.id);default:return null}}a(I0,"renderTailRow");function or(e){return e.authorAgentId??e.derivedAuthorAgentId??null}a(or,"effectiveAgentId");function N0(e){return e.presentation?.kind==="system_notice"||e.authorType==="system"?"system":or(e)?"agent":e.authorType==="user"?"human":"agent"}a(N0,"authorKind");function el(e){if(!e)return;const s=e instanceof Date?e:new Date(e);if(!Number.isNaN(s.getTime()))return s.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}a(el,"formatTaskChatTimestamp");function S0(e,s){return el(e.createdAt)}a(S0,"formatTaskChatCommentTimestamp");function C0(e,s={}){const n=[];for(const r of e){if(r.deletedAt)continue;if(r.conversationSessionGeneration!=null){n.push({id:r.id,kind:"marker",variant:"session_start",label:"New session",detail:"Earlier messages and files are still available.",createdAtIso:new Date(r.createdAt).toISOString()});continue}const i=N0(r);let o,u,m;const p=i==="human"?Ag({authorUserId:r.authorUserId,authorName:r.authorUserId?s.userLabelMap?.get(r.authorUserId):null,currentUserId:s.currentUserId,userProfileMap:s.userProfileMap}):void 0;if(i==="agent"){const N=or(r);o=N&&s.agentMap?.get(N)?.name||"Agent",u=N?s.agentMap?.get(N)?.icon:void 0,m=Yg({authorAgentId:N,onBehalfOfUserId:r.onBehalfOfUserId??null,issueAssigneeAgentId:s.issueAssigneeAgentId,resolveUserLabel:a(A=>s.userLabelMap?.get(A),"resolveUserLabel")})?.userName}else i==="human"&&(o=p.authorName);const h=r.queueState==="queued"||r.clientStatus==="queued",d=h?"queued":r.clientStatus==="pending"?"pending":void 0,v=r.createdAt instanceof Date?r.createdAt.toISOString():r.createdAt?String(r.createdAt):void 0,k=r.createdByRunId??r.runId??r.derivedCreatedByRunId??null;n.push({id:r.id||r.clientId||`${r.createdAt}`,renderKey:r.clientId??r.id,kind:"message",author:i,authorName:o,...p?{authorUserId:r.authorUserId,authorAvatarUrl:p.avatarUrl,isCurrentUser:p.isCurrentUser}:{},agent:or(r)?s.agentMap?.get(or(r))??{id:or(r)}:void 0,text:r.body,origin:r.origin??"comment",sourceChannel:i==="human"?r.metadata?.sourceChannel:void 0,timestamp:S0(r,i),optimistic:d,queueTargetRunId:h?r.queueTargetRunId??null:null,verificationCaveats:k?s.verificationCaveatsByRunId?.get(k):void 0,agentIcon:u,onBehalfOfUserName:m,presentation:i==="system"?r.presentation??null:void 0,metadata:i==="system"?r.metadata??null:void 0,runAgentId:i==="system"?r.runAgentId??null:void 0,createdAtIso:i==="system"?v:void 0})}return n}a(C0,"commentsToTaskChatItems");function A0(e){let s=-1;for(let n=e.length-1;n>=0;n-=1){const r=e[n];if(r.kind==="message"||r.kind==="plan_document"||r.kind==="protocol"&&(r.surface==="runtime_request"||r.surface==="run_result"||r.surface==="run_terminal")){s=n;break}}return e.slice(s+1)}a(A0,"currentActivityStatusItems");function R0(e){if(e==null||!Number.isFinite(e))return null;const s=Math.max(0,Math.floor(e/1e3));if(s<60)return`${s}s`;const n=Math.floor(s/60),r=s%60;return r===0?`${n}m`:`${n}m ${r}s`}a(R0,"formatCompactDuration");function T0(e){return e==="failed"||e==="cancelled"||e==="timed_out"||e==="interrupted"}a(T0,"terminalStatusFailed");function E0({status:e,startedAtMs:s,finishedAtMs:n,continuedAfterSteering:r=!1}){const i=xa(e);Vd(!i&&s!=null);const o=s==null?null:Math.max(0,(i?n??Date.now():Date.now())-s),u=R0(o),m=T0(e),p=i?m?"Stopped":"Worked":"Working",h=i?u?`${p} ${m?"after":"for"} ${u}`:p:`${p} for ${u??"0s"}`,d=r?`Continued after steering · ${h}`:h,v=o==null?p:`${p} ${m?"after":"for"} ${o<6e4?"less than a minute":`${Math.max(1,Math.round(o/6e4))} minutes`}`;return(0,t.jsxs)("span",{className:"min-w-0 truncate text-sm font-normal text-ink-3","data-testid":"task-chat-turn-status-header","data-turn-position":"identity","aria-live":"polite","aria-atomic":"true",children:[(0,t.jsx)("span",{"aria-hidden":"true",children:d}),(0,t.jsxs)("span",{className:"sr-only",children:[r?"Continued after steering. ":"",v]})]})}a(E0,"RunnerTurnStatus");function _0({status:e}){return xa(e)?null:(0,t.jsx)("div",{className:"mt-2 flex min-h-8 min-w-0 items-center gap-2 px-1 py-1 text-xs text-ink-3","data-testid":"task-chat-current-activity","data-turn-position":"tail",children:(0,t.jsx)("span",{className:"shimmer-text shimmer-text-muted","aria-live":"polite","data-testid":"task-chat-current-activity-label",children:"Thinking"})})}a(_0,"RunnerCurrentActivityTail");function q0({runId:e,turnId:s=e??"turn",agentName:n,agentIcon:r,agent:i,items:o,status:u,startedAtMs:m,finishedAtMs:p,activityUnavailable:h=!1,suppressFinal:d=!1,continuedAfterSteering:v=!1,onRuntimeRequestDecision:k}){const N=xa(u),A=(0,l.useMemo)(()=>{const w=d?void 0:ir(o,{allowFallback:N});return{timelineItems:Io(o),yielded:o.some(W=>W.kind==="protocol"&&W.surface==="run_result"&&W.disposition==="yielded"),observedFinal:w,observedProviderText:!!(w&&o.some(W=>W.kind==="message"&&W.id===w.id&&W.channel!=="progress"))}},[o,d,N]),{observedFinal:E,observedProviderText:_}=A,q=(0,l.useRef)({runId:e});q.current.runId!==e&&(q.current={runId:e}),(A.yielded||d)&&(q.current={runId:e}),E&&(!q.current.item||_&&!q.current.providerText||_===!!q.current.providerText&&E.text.length>=q.current.item.text.length)&&(q.current.item=E,q.current.providerText=_);const O=q.current.item,F=O?.text,C=(0,l.useMemo)(()=>s??e??"turn",[s,e]),S=(0,l.useMemo)(()=>A0(A.timelineItems),[A]),P=(0,l.useMemo)(()=>Gd(kx(A.timelineItems,F),!N,C),[A,F,N,C]),j=(0,l.useMemo)(()=>yd(N?[]:P.filter(w=>w.kind==="activity_phase")),[P,N]),f=(0,l.useMemo)(()=>P.length===0?null:(0,t.jsx)("div",{className:"flex min-w-0 flex-col gap-2 py-1","data-testid":"task-chat-turn-timeline",children:P.map(w=>(0,t.jsx)("div",{className:"min-w-0","data-testid":"task-chat-turn-timeline-row","data-timeline-row-id":w.id,"data-thread-anchor":w.id,children:w.kind==="activity_phase"?(0,t.jsx)(vd,{item:w,openActivityIds:j}):w.kind==="plan_document"?(0,t.jsx)(ei,{source:{kind:"saved",document:w.document},testId:w.placement==="fallback"?"task-chat-plan-preview-fallback":"task-chat-plan-preview"}):w.kind==="todo"?(0,t.jsx)(Fd,{item:w}):w.kind==="protocol"?(0,t.jsx)($o,{item:w,onRuntimeRequestDecision:k}):null},`${e??"run"}:${w.id}`))}),[P,e,k,j]);return(0,t.jsxs)("div",{className:"flex min-w-0 flex-col","data-testid":"task-chat-runner-turn","data-phase":u==="queued"?"startup":void 0,children:[(0,t.jsxs)("div",{className:ue("flex min-h-8 min-w-0 items-center gap-2",u==="queued"?"pb-1":"pb-1 pt-2"),"data-testid":"task-chat-runner-identity-row",children:[n?(0,t.jsx)(Wf,{agentName:n,agentIcon:r,agent:i}):null,(0,t.jsx)(E0,{status:u,startedAtMs:m,finishedAtMs:p,continuedAfterSteering:v})]}),h?(0,t.jsx)("div",{className:"px-1 py-1 text-xs text-ink-3",role:"status","data-testid":"task-chat-activity-unavailable",children:"Live runner activity is temporarily unavailable. Retrying…"}):null,f,O?(0,t.jsx)("div",{className:"w-full","data-testid":"task-chat-final-response",children:(0,t.jsx)($f,{item:{...O,authorName:n??void 0,agentIcon:r,agent:i,timestamp:O.timestamp??el(O.atMs)},animateEntry:!1,hideAgentIdentity:!v,actions:(0,t.jsx)(Dd,{copyText:O.text})})}):null,!O&&S.length===0?(0,t.jsx)(_0,{status:u}):null]})}a(q0,"TaskChatRunnerTurn");function M0(e){let s=null,n=-1;for(const[r,i]of e.entries()){if(i.kind!=="protocol"||i.surface!=="provider_activity"||i.family!=="plan")continue;const o=i.transcriptIndex??r;o>=n&&(s=i,n=o)}return s}a(M0,"latestPlan");function P0(e){let s=null;for(const n of e)n.kind==="protocol"&&n.surface==="workspace_change"&&(s=n);return s}a(P0,"latestWorkspaceDiff");function F0(e){const s=e.findIndex(i=>i.status==="in_progress");if(s>=0)return s;const n=e.findIndex(i=>i.status==="blocked"||i.status==="failed");if(n>=0)return n;const r=e.findIndex(i=>i.status==="pending");return r>=0?r:Math.max(0,e.length-1)}a(F0,"currentStepIndex");function D0(e){const s=[],n=M0(e);n&&n.steps.length>0&&s.push({kind:"plan",steps:n.steps,currentStepIndex:F0(n.steps),complete:n.steps.every(o=>o.status==="completed")});const r=P0(e),i=r?r.totals.files||r.files.length:0;return r&&i>0&&s.push({kind:"workspace_diff",files:i,additions:r.totals.additions,deletions:r.totals.deletions}),s.length>0?{segments:s}:null}a(D0,"taskChatTurnStatusModel");function $0(e){const s=e.steps[e.currentStepIndex]?.status;return e.complete?(0,t.jsx)(di,{className:"size-4 text-(--status-task-icon-done)","aria-hidden":!0}):s==="blocked"||s==="failed"?(0,t.jsx)(ud,{className:"size-4 text-(--status-task-icon-blocked)","aria-hidden":!0}):(0,t.jsx)(It,{className:"size-4 text-(--status-agent-running) motion-safe:animate-spin","aria-hidden":!0})}a($0,"planIcon");function L0(e){return e.status==="completed"?(0,t.jsx)(di,{className:"mt-0.5 size-4 shrink-0 text-(--status-task-icon-done)","aria-hidden":!0}):e.status==="in_progress"?(0,t.jsx)(It,{className:"mt-0.5 size-4 shrink-0 text-(--status-agent-running) motion-safe:animate-spin","aria-hidden":!0}):e.status==="blocked"||e.status==="failed"?(0,t.jsx)(ud,{className:"mt-0.5 size-4 shrink-0 text-(--status-task-icon-blocked)","aria-hidden":!0}):(0,t.jsx)(Zr,{className:"mt-0.5 size-4 shrink-0 text-ink-3","aria-hidden":!0})}a(L0,"checklistIcon");function cu(e){return`${e} ${e===1?"file":"files"} changed`}a(cu,"fileCountLabel");function ac({model:e}){const s=e.segments.find(r=>r.kind==="plan"),n=e.segments.find(r=>r.kind==="workspace_diff");return(0,t.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[s?(0,t.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[$0(s),(0,t.jsxs)("span",{className:"font-mono text-sm tabular-nums","aria-live":"polite","aria-atomic":"true",children:["Step ",s.currentStepIndex+1," / ",s.steps.length,(0,t.jsxs)("span",{className:"sr-only",children:[": ",s.steps[s.currentStepIndex]?.label]})]})]}):null,s&&n?(0,t.jsx)("span",{className:"text-ink-3","aria-hidden":!0,children:"·"}):null,n?(0,t.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,t.jsx)("span",{className:"min-w-0 truncate text-sm text-ink-3",children:cu(n.files)}),n.additions!=null?(0,t.jsxs)("span",{className:"shrink-0 font-mono text-sm tabular-nums text-(--status-task-icon-done)",children:["+",n.additions]}):null,n.deletions!=null?(0,t.jsxs)("span",{className:"shrink-0 font-mono text-sm tabular-nums text-(--status-task-icon-blocked)",children:["−",n.deletions]}):null]}):null]})}a(ac,"IslandBody");function B0(e){const s=[];for(const n of e.segments)if(n.kind==="plan"){const r=n.steps[n.currentStepIndex];s.push(`Step ${n.currentStepIndex+1} of ${n.steps.length}${r?`: ${r.label}`:""}`)}else s.push(cu(n.files)),n.additions!=null&&s.push(`${n.additions} additions`),n.deletions!=null&&s.push(`${n.deletions} deletions`);return s.join(", ")}a(B0,"islandLabel");var rc="mx-auto flex min-h-10 max-w-(--sz-turn-status-island) items-center overflow-hidden rounded-full border border-line bg-bg-2/95 px-4 py-2 text-ink shadow-sm backdrop-blur",O0=100;function K0({model:e}){const s=e.segments.find(h=>h.kind==="plan"),[n,r]=(0,l.useState)(!1),[i,o]=(0,l.useState)(!1),u=(0,l.useRef)(null);(0,l.useEffect)(()=>()=>{u.current&&clearTimeout(u.current)},[]);const m=a(()=>{u.current&&clearTimeout(u.current),u.current=null},"cancelClose"),p=a(()=>{m(),!i&&(u.current=setTimeout(()=>r(!1),O0))},"scheduleClose");return s?(0,t.jsxs)(vr,{open:n,onOpenChange:a(h=>{r(h),h||o(!1)},"onOpenChange"),children:[(0,t.jsx)(xr,{asChild:!0,children:(0,t.jsx)("button",{type:"button","aria-label":B0(e),className:ue(rc,"cursor-pointer transition-colors hover:bg-bg-3/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus focus-visible:ring-offset-2 focus-visible:ring-offset-bg motion-reduce:transition-none"),"data-testid":"task-chat-turn-status-island",onPointerEnter:a(h=>{h.pointerType==="mouse"&&(m(),r(!0))},"onPointerEnter"),onPointerLeave:a(h=>{h.pointerType==="mouse"&&p()},"onPointerLeave"),onFocus:a(()=>r(!0),"onFocus"),onClick:a(h=>{h.preventDefault();const d=!i;o(d),r(d)},"onClick"),children:(0,t.jsx)(ac,{model:e})})}),(0,t.jsx)(yr,{side:"top",align:"center",sideOffset:8,className:"w-(--sz-turn-status-popover) p-2","aria-label":"Turn plan",onPointerEnter:a(h=>{h.pointerType==="mouse"&&m()},"onPointerEnter"),onPointerLeave:a(h=>{h.pointerType==="mouse"&&p()},"onPointerLeave"),onEscapeKeyDown:a(()=>o(!1),"onEscapeKeyDown"),onInteractOutside:a(()=>o(!1),"onInteractOutside"),children:(0,t.jsx)("ol",{className:"flex flex-col gap-1","aria-label":"Within-turn checklist",children:s.steps.map((h,d)=>(0,t.jsxs)("li",{className:ue("flex items-start gap-2 rounded-md px-2 py-1.5 text-sm leading-5",d===s.currentStepIndex&&"bg-bg-3",h.status==="completed"&&"text-ink-3"),"aria-current":d===s.currentStepIndex?"step":void 0,children:[L0(h),(0,t.jsx)("span",{className:"min-w-0 break-words",children:h.label})]},h.id))})})]}):(0,t.jsx)("div",{className:rc,role:"status","data-testid":"task-chat-turn-status-island",children:(0,t.jsx)(ac,{model:e})})}a(K0,"TaskChatTurnStatusIsland");function Kr(e){return e==null?NaN:new Date(e).getTime()}a(Kr,"timestamp");function ic(e){return e.status==="cancelled"&&!e.startedAt&&["execution_reconciliation_required","workspace_busy","issue_not_in_progress","issue_terminal_status"].includes(e.errorCode??"")}a(ic,"isAdmissionWait");function U0(e,s,n){const r=jo(e),i=new Map;for(const h of s){const d=i.get(h.id);i.set(h.id,{...d,...h,execution:h.execution??d?.execution})}const o=new Map,u=new Map;for(const h of i.values()){const d=Kr(h.createdAt),v=Number.isFinite(d)?d:Kr(h.startedAt);Number.isFinite(v)&&(o.set(h.agentId,Math.max(o.get(h.agentId)??-1/0,v)),ic(h)||u.set(h.agentId,Math.max(u.get(h.agentId)??-1/0,v)))}const m=a(h=>{if(r)return!0;const d=i.get(h);if(!d)return!1;if(d.execution?.successorRunId||d.execution?.phase==="completed")return!0;const v=d.resultJson?.executionWait;if(n&&v&&typeof v=="object"&&"recoveryActionId"in v&&v.recoveryActionId===n.id)return n.status==="resolved"||n.status==="cancelled";if(d.execution?.phase==="recovery_needed")return!1;const k=Kr(d.createdAt);return(Number.isFinite(k)?k:Kr(d.startedAt))<((ic(d)?o:u).get(d.agentId)??-1/0)},"isHistoricalRun");return{isHistoricalRun:m,isHistoricalNotice:a(h=>{if(h.conversationSessionGeneration!=null||h.authorType!=="system"&&h.presentation?.kind!=="system_notice")return!1;const d=h.metadata?.sourceRunId??h.createdByRunId??h.runId??h.derivedCreatedByRunId,v=h.metadata?.recovery?.actionId;return!d&&!v?!1:r?!0:v===n?.id&&n?n.status==="resolved"||n.status==="cancelled":d?m(d):!1},"isHistoricalNotice")}}a(U0,"taskChatStatusRelevance");function Q0(e){return e.filter(s=>s.kind==="marker"||s.kind==="status"?!1:s.kind==="message"?s.author!=="system":s.kind!=="protocol"?!0:s.surface==="run_terminal"||s.surface==="run_result"?!1:s.surface!=="provider_activity"||!["terminal","wait","provider_notice"].includes(s.family))}a(Q0,"withoutHistoricalRunStatus");var W0=240;function z0({brief:e}){const[s,n]=(0,l.useState)(!1),r=e.author==="human",i=e.description.trim().length>0;if(s)return(0,t.jsx)("div",{className:"tc-enter-bubble w-full rounded-lg border border-line bg-bg-2 px-2 py-1","data-testid":"task-chat-description-editor",children:(0,t.jsx)(Hd,{value:e.description,onSave:e.onSave,as:"p",className:"text-sm leading-7 text-ink",placeholder:"Add a description...",multiline:!0,defaultEditing:!0,onEditingChange:a(u=>{u||n(!1)},"onEditingChange"),mentions:e.mentions,externalReferences:e.externalReferences,imageUploadHandler:e.imageUploadHandler,onDropFile:e.onDropFile})});if(!i)return(0,t.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1.5 rounded-lg px-1 py-1.5 text-left text-sm text-ink-3/70 transition-colors hover:bg-bg-3/20 hover:text-ink-3",onClick:a(()=>n(!0),"onClick"),"data-testid":"task-chat-description-ghost",children:[(0,t.jsx)(ai,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),"Add a description..."]});const o=el(e.createdAt);return(0,t.jsxs)("div",{className:ue("tc-enter-bubble group/brief flex w-full flex-col gap-1",r?"items-end":"items-start"),"data-testid":"task-chat-description-bubble","data-author":e.author,children:[!r&&e.authorName?(0,t.jsxs)("span",{className:"flex items-center gap-2 px-1",children:[(0,t.jsx)(ur,{agent:e.agent,name:e.authorName,size:24}),(0,t.jsx)("span",{className:"text-sm font-semibold text-ink",children:e.authorName})]}):null,(0,t.jsxs)("div",{className:ue("flex w-full items-start gap-1.5",r?"flex-row-reverse":"flex-row"),children:[(0,t.jsx)("div",{className:ue("max-w-(--pct-85) break-words px-3.5 py-2 text-sm",r?"rounded-2xl rounded-br-sm bg-(--liveness-blue) text-white":"rounded-2xl rounded-bl-sm bg-(--bubble-agent) text-ink"),children:(0,t.jsx)(mx,{collapsedHeight:W0,toggleClassName:r?"text-white/80 hover:text-white hover:bg-white/10":void 0,children:(0,t.jsx)(bs,{className:r?"wardmote-markdown-on-accent":void 0,softBreaks:!0,linkIssueReferences:!0,externalReferences:e.externalReferences,children:e.description})})}),r?null:(0,t.jsx)("button",{type:"button",className:"mt-1 shrink-0 rounded-md p-1 text-ink-3 opacity-0 transition-opacity hover:bg-bg-3/50 hover:text-ink focus-visible:opacity-100 group-hover/brief:opacity-100",onClick:a(()=>n(!0),"onClick"),"aria-label":"Edit description","data-testid":"task-chat-description-edit",children:(0,t.jsx)(ai,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),o?(0,t.jsx)("span",{className:"px-1 text-(length:--text-micro) text-ink-3",children:o}):null]})}a(z0,"TaskChatDescriptionBubble");function H0(e){const s=new Set;let n=0,r=0;for(const o of e)if(o.kind==="tool_call"){if(o.toolUseId){if(s.has(o.toolUseId))continue;s.add(o.toolUseId)}lx(o.name,o.input)?n+=1:r+=1}const i=[];return n>0&&i.push(`ran ${n} command${n===1?"":"s"}`),r>0&&i.push(`called ${r} tool${r===1?"":"s"}`),i.length>0?i.join(", "):null}a(H0,"toolCountSummaryFromEntries");function V0({status:e,startedAtMs:s,finishedAtMs:n,toolSummary:r}){const i=!xa(e);Vd(i&&s!=null);const o=s==null?null:(i?Date.now():n??Date.now())-s,u=o!=null?ix(o):null,m=["failed","timed_out","cancelled","interrupted"].includes(e),p=i?"Working":m?"Stopped":"Worked",h=u?`for ${u}`:null;return(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 py-2","data-testid":"task-chat-live-run-pill",children:[(0,t.jsxs)("span",{className:"inline-flex items-center gap-2 text-sm font-medium text-ink/80",children:[i?(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center",children:(0,t.jsx)(It,{className:"size-4 animate-spin text-ink-3"})}):(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center",children:(0,t.jsx)("span",{className:ue("h-1.5 w-1.5 rounded-full",m||i?"bg-ink-3/40":"bg-emerald-500/70")})}),i?(0,t.jsx)("span",{className:ue("shimmer-text"),children:p}):p]}),h?(0,t.jsx)("span",{className:"text-xs text-ink-3/60",children:h}):null,r?(0,t.jsxs)("span",{className:"text-xs text-ink-3/40",children:["· ",r]}):null]})}a(V0,"TaskChatLiveRunPill");function G0(e){const s=new Set;for(let n=e.length-1;n>=0;n-=1){const r=e[n];if(r.kind!=="protocol"||r.surface!=="runtime_request")continue;const i=`${r.runId}:${r.requestId}`;if(!s.has(i)&&(s.add(i),r.status==="pending"))return r}return null}a(G0,"latestPendingRuntimeRequest");function Y0(e){return e.choices.some(s=>{const n=s.key.trim().toLowerCase(),r=s.label.trim().toLowerCase();return["deny","decline","reject"].includes(n)||/^(deny|decline|reject)(\b|\s)/.test(r)})}a(Y0,"runtimeRequestReplacesComposerSkip");var Ci="min-h-16 resize-y border-0 bg-bg-3/35 text-sm shadow-none focus-visible:ring-0 focus-visible:ring-offset-0",du={suggest_tasks:{fallbackTitle:"Suggested tasks",label:"Tasks",icon:bp},ask_user_questions:{fallbackTitle:"Questions",label:"Questions",icon:fd},request_confirmation:{fallbackTitle:"Confirmation",label:"Confirmation",icon:di},request_checkbox_confirmation:{fallbackTitle:"Choose options",label:"Selection",icon:Jo},request_item_verdicts:{fallbackTitle:"Review items",label:"Review",icon:Cf},connection_intent:{fallbackTitle:"Connect service",label:"Connection",icon:Mf}};function J0(e){return e.replaceAll("_"," ")}a(J0,"statusLabel$1");function Ur(e){return e==="pending"?"text-(--status-agent-running)":e==="accepted"||e==="answered"?"text-(--status-task-icon-done)":e==="rejected"||e==="failed"?"text-bad":"text-ink-3"}a(Ur,"statusTone");function X0({status:e}){return e==="pending"?(0,t.jsx)(Zr,{"aria-hidden":!0,className:ue("h-3.5 w-3.5 fill-current",Ur(e))}):e==="accepted"||e==="answered"?(0,t.jsx)(Wn,{"aria-hidden":!0,className:ue("h-3.5 w-3.5",Ur(e))}):e==="rejected"||e==="failed"?(0,t.jsx)(Qa,{"aria-hidden":!0,className:ue("h-3.5 w-3.5",Ur(e))}):(0,t.jsx)(Zr,{"aria-hidden":!0,className:ue("h-3.5 w-3.5",Ur(e))})}a(X0,"StatusIcon");function Z0({interaction:e,audienceLabel:s,presentation:n,children:r}){const i=du[e.kind],o=i.icon,u=(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,t.jsx)(o,{"aria-hidden":!0,className:"h-4 w-4 shrink-0 text-ink-3"}),(0,t.jsx)("strong",{className:"min-w-0 truncate text-sm font-medium text-ink",children:e.title??i.fallbackTitle}),e.kind==="request_confirmation"&&e.payload.target?.type==="issue_document"&&e.payload.target.key==="plan"?(0,t.jsx)(sl,{interaction:e}):null,e.status!=="pending"?(0,t.jsxs)("span",{className:"inline-flex shrink-0 items-center gap-1 text-xs capitalize text-ink-3","data-testid":"interaction-status-badge",children:[(0,t.jsx)(X0,{status:e.status}),J0(e.status)]}):null]});return(0,t.jsxs)("article",{className:ue(n==="timeline"?"overflow-hidden rounded-md border border-line bg-bg-2/60":"overflow-clip"),children:[n==="takeover"?(0,t.jsx)(yh,{children:u}):(0,t.jsx)("header",{className:"flex min-w-0 items-start gap-2 px-3 py-2.5",children:(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[u,s?(0,t.jsx)("p",{className:"mt-0.5 pl-6 text-xs text-ink-3",children:s}):null]})}),(0,t.jsx)("div",{className:n==="timeline"?"border-t border-line/70 px-3 py-3":void 0,children:r})]})}a(Z0,"InteractionShell");function Ai({message:e}){return(0,t.jsx)("div",{"aria-live":"assertive","data-testid":"interaction-action-error",children:e?(0,t.jsx)("div",{className:"mt-2 rounded-sm border border-bad/60 bg-bad/10 px-2.5 py-2 text-sm text-bad",children:e}):null})}a(Ai,"InteractionActionError");function tl({children:e}){return e?(0,t.jsxs)("details",{className:"mt-2",children:[(0,t.jsxs)("summary",{className:"flex cursor-pointer list-none items-center gap-1 text-xs font-medium text-ink-3",children:[(0,t.jsx)(br,{"aria-hidden":!0,className:"h-3.5 w-3.5"})," Details"]}),(0,t.jsx)("div",{className:"mt-2 max-h-(--sz-28dvh) overflow-y-auto overscroll-contain rounded-sm bg-bg-3/40 px-2.5 py-2 text-sm text-ink-3 scrollbar-auto-hide",children:e})]}):null}a(tl,"Details");function Ri({children:e,hint:s}){const n=_m();return(0,t.jsxs)("fieldset",{disabled:n,title:n?Mm:void 0,className:"m-0 mt-3 flex min-w-0 flex-wrap items-center gap-2 border-0 p-0","data-slot":"task-chat-takeover-actions",children:[s?(0,t.jsx)("span",{className:"mr-auto text-xs text-ink-3",children:s}):(0,t.jsx)("span",{className:"mr-auto"}),e]})}a(Ri,"ActionRow");function ey(e){const s=e.payload.target;return s?[s.label??(s.type==="issue_document",s.key),s.revisionNumber==null?null:`v${s.revisionNumber}`].filter(Boolean).join(" · "):null}a(ey,"targetLabel");function sl({interaction:e}){const s=e.payload.target,n=ey(e);if(!s||!n)return null;const r=s.href?_d(s.href):null;return r?(0,t.jsx)("a",{href:r,className:"inline-flex rounded-sm border border-line px-2 py-0.5 font-mono text-xs text-ink hover:bg-bg-3/60",children:n}):(0,t.jsx)("span",{className:"inline-flex rounded-sm border border-line px-2 py-0.5 font-mono text-xs text-ink-3",children:n})}a(sl,"CompactTarget");function uu({interaction:e,planDocument:s}){const n=e.payload.target;if(n?.type!=="issue_document"||n.key!=="plan")return null;const r=n.revisionId??null,i=n.revisionNumber??null,o=!!(s&&(r!=null?s.latestRevisionId===r:i==null||s.latestRevisionNumber===i));return(0,t.jsx)(ei,{source:{kind:"saved",document:o?s:null,revision:i,fallbackTitle:n.label},href:"#document-plan",testId:"plan-review-preview",ariaLabel:`Open ${n.label??(i==null?"plan":`plan revision ${i}`)}`})}a(uu,"PlanReviewPreview");function ty(e){const s=e.result;return s?"reason"in s&&typeof s.reason=="string"?s.reason:e.kind==="ask_user_questions"?e.result?.cancellationReason??e.result?.expirationReason?.replaceAll("_"," ")??null:null:null}a(ty,"receiptReason");function oc({interaction:e,externalReferences:s,compact:n=!1}){const r=ty(e)??(e.kind==="suggest_tasks"?e.result?.rejectionReason??null:null);let i;if(e.kind==="ask_user_questions"){const u=mu(e),m=pu(e,u);i=(0,t.jsxs)("div",{className:"grid gap-3",children:[u.description?(0,t.jsx)("div",{className:"text-sm text-ink-3",children:(0,t.jsx)(Ds,{children:u.description})}):null,u.questions.map(p=>{const h=m?.answers[p.id],d=e.result?.answers.find(k=>k.questionId===p.id)?.note,v=[...(h?.selectedOptionIds??[]).map(k=>p.options?.find(N=>N.id===k)?.label??k),h?.text,h?.customText].filter(k=>!!k);return(0,t.jsxs)("div",{children:[p.header?(0,t.jsx)("p",{className:"text-xs font-medium text-ink-3",children:p.header}):null,(0,t.jsx)("div",{className:"text-sm text-ink",children:(0,t.jsx)(Ds,{children:p.prompt})}),p.helpText?(0,t.jsx)("div",{className:"mt-0.5 text-xs text-ink-3",children:(0,t.jsx)(Ds,{children:p.helpText})}):null,(0,t.jsxs)("div",{className:"mt-1 flex gap-1 text-sm font-medium text-ink",children:[(0,t.jsx)("span",{className:"shrink-0",children:"Answer:"}),v.length>0?(0,t.jsx)(Ds,{className:"min-w-0 flex-1",children:v.join(", ")}):(0,t.jsx)("span",{children:"No answer"})]}),(0,t.jsx)(Ui,{note:d,externalReferences:s,className:"mt-1"})]},p.id)})]})}else if(e.kind==="request_checkbox_confirmation"){const u=new Set(e.result?.selectedOptionIds??[]),m=e.payload.options.filter(p=>u.has(p.id)).map(p=>p.label);i=(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm text-ink",children:(0,t.jsx)(Ds,{children:e.payload.prompt})}),e.status==="accepted"?(0,t.jsxs)("div",{className:"mt-1 flex gap-1 text-sm font-medium text-ink",children:[(0,t.jsx)("span",{className:"shrink-0",children:"Answer:"}),m.length>0?(0,t.jsx)(Ds,{className:"min-w-0 flex-1",children:m.join(", ")}):(0,t.jsx)("span",{children:"No options selected"})]}):null,(0,t.jsx)(Ui,{note:e.result?.note,externalReferences:s,className:"mt-1"}),e.payload.detailsMarkdown?(0,t.jsx)("div",{className:"mt-2 text-sm",children:(0,t.jsx)(bs,{externalReferences:s,children:e.payload.detailsMarkdown})}):null]})}else if(e.kind==="request_item_verdicts"){const u=new Map((e.result?.items??[]).map(p=>[p.id,p])),m=e.payload.items.filter(p=>u.has(p.id));i=(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm text-ink",children:e.payload.prompt}),m.length>0?(0,t.jsx)("ul",{className:"mt-2 grid gap-1 text-sm",children:m.map(p=>{const h=u.get(p.id);return(0,t.jsxs)("li",{children:[(0,t.jsx)("span",{className:"font-medium",children:p.label})," ·"," ",h?.verdict,h?.reason?` — ${h.reason}`:""]},p.id)})}):(0,t.jsx)("p",{className:"mt-1 text-sm font-medium text-ink",children:"No verdicts submitted"}),e.payload.detailsMarkdown?(0,t.jsx)("div",{className:"mt-2 text-sm",children:(0,t.jsx)(bs,{externalReferences:s,children:e.payload.detailsMarkdown})}):null]})}else if(e.kind==="suggest_tasks"){const u=new Set(e.result?.createdTasks?.map(p=>p.clientKey)??[]),m=e.payload.tasks.filter(p=>u.has(p.clientKey));i=(0,t.jsx)("div",{children:m.length>0?(0,t.jsx)("ul",{className:"grid gap-1 text-sm",children:m.map(p=>(0,t.jsx)("li",{className:"font-medium",children:p.title},p.clientKey))}):e.status==="accepted"?(0,t.jsx)("p",{className:"text-sm font-medium text-ink",children:"No tasks created"}):null})}else e.kind==="connection_intent"?i=(0,t.jsxs)("p",{className:"text-sm text-ink",children:[e.payload.requestingAgentName," requested access to"," ",e.payload.serviceName,"."]}):i=(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)("div",{className:"text-sm text-ink",children:(0,t.jsx)(Ds,{children:e.payload.prompt})}),(0,t.jsx)(Ui,{note:e.result?.note,externalReferences:s}),e.payload.detailsMarkdown?(0,t.jsx)("div",{className:"text-sm",children:(0,t.jsx)(bs,{externalReferences:s,children:e.payload.detailsMarkdown})}):null,e.payload.toolAction?(0,t.jsxs)("div",{className:"rounded-sm bg-bg-3/45 px-3 py-2.5 text-sm",children:[(0,t.jsxs)("p",{children:[(0,t.jsx)("strong",{children:e.payload.toolAction.toolDisplayName})," ","· ",e.payload.toolAction.risk," risk"]}),(0,t.jsxs)("p",{className:"mt-1",children:["Expires"," ",new Date(e.payload.toolAction.expiresAt).toLocaleString()]}),(0,t.jsx)("div",{className:"mt-2",children:(0,t.jsx)(bs,{externalReferences:s,children:e.payload.toolAction.previewMarkdown})}),(0,t.jsx)("pre",{className:"mt-2 max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-xs",children:e.payload.toolAction.argumentsSummaryJson}),(0,t.jsx)("p",{className:"mt-1 break-all font-mono text-xs text-ink-3",children:e.payload.toolAction.argumentsHash})]}):null,e.payload.secretProposal?(0,t.jsxs)("dl",{className:"grid gap-1 rounded-sm bg-bg-3/45 px-3 py-2.5 text-sm",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs text-ink-3",children:"Secret"}),(0,t.jsx)("dd",{children:e.payload.secretProposal.sourceSecretLabel})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs text-ink-3",children:"Binding"}),(0,t.jsxs)("dd",{className:"font-mono text-xs",children:[e.payload.secretProposal.configPath," →"," ",e.payload.secretProposal.targetAgentName]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs text-ink-3",children:"Why"}),(0,t.jsx)("dd",{children:e.payload.secretProposal.justification})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs text-ink-3",children:"Expires"}),(0,t.jsx)("dd",{children:new Date(e.payload.secretProposal.expiresAt).toLocaleString()})]})]}):null]});const o=(0,t.jsxs)("div",{className:n?"space-y-3 pb-3 pl-7 pr-1":"mt-2 space-y-3 border-t border-line/60 pt-3",children:[i,r?(0,t.jsxs)("div",{className:"flex gap-1 text-sm text-ink-3",children:[(0,t.jsx)("span",{className:"shrink-0 font-medium",children:"Reason:"}),(0,t.jsx)(Ds,{className:"min-w-0 flex-1",children:r})]}):null]});if(n){const u=du[e.kind].icon,m=e.kind==="ask_user_questions"&&e.status==="answered"?"Questions answered":qd(e);return(0,t.jsxs)("details",{className:"group","data-testid":e.kind==="ask_user_questions"&&e.status==="answered"?"task-chat-answered-questions-receipt":"task-chat-interaction-receipt",children:[(0,t.jsxs)("summary",{className:"flex min-h-8 cursor-pointer list-none items-center gap-2 rounded-sm px-1 py-1.5 text-sm leading-5 text-ink-3 transition-colors hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus",children:[(0,t.jsx)("span",{className:"flex w-6 shrink-0 items-center justify-center","data-testid":"task-chat-interaction-receipt-icon-slot",children:(0,t.jsx)(u,{"aria-hidden":!0,className:"h-3.5 w-3.5 shrink-0 text-ink-3","data-testid":"task-chat-interaction-receipt-icon"})}),(0,t.jsx)("span",{children:m}),(0,t.jsx)(kr,{"aria-hidden":!0,className:"ml-auto h-3 w-3 shrink-0 text-ink-3 opacity-0 transition-[opacity,transform] group-hover:opacity-70 group-focus-visible:opacity-70 group-open:rotate-90","data-testid":"task-chat-interaction-receipt-caret"})]}),o]})}return(0,t.jsxs)("details",{className:"mt-2",children:[(0,t.jsx)("summary",{className:"cursor-pointer text-xs font-medium text-ink-3",children:"View original request and resolution"}),o]})}a(oc,"ReceiptDisclosure");function mu(e){return e.payload.questionSet?e.payload.questionSet:{schema:"wardmote.question_set.v1",...e.title?{title:e.title}:{},...e.payload.submitLabel?{submitLabel:e.payload.submitLabel}:{},questions:e.payload.questions.map(s=>{const n=s.options.find(r=>r.freeText===!0);return{id:s.id,prompt:s.prompt,...s.helpText?{helpText:s.helpText}:{},required:s.required===!0,answerMode:s.selectionMode==="multi"?"multi_select":"single_select",options:s.options.filter(r=>r.freeText!==!0).map(r=>({id:r.id,label:r.label,...r.description?{description:r.description}:{}})),...n?{customAnswer:{enabled:!0,label:n.label,...n.description?{placeholder:n.description}:{}}}:{}}})}}a(mu,"questionSetForInteraction");function pu(e,s){return e.result?.answers?{schema:"wardmote.question_response.v1",answers:Object.fromEntries(e.result.answers.map(n=>{const r=s.questions.find(i=>i.id===n.questionId);return[n.questionId,r?.answerMode==="text"?{...n.otherText?{text:n.otherText}:{}}:{selectedOptionIds:n.optionIds,...n.otherText?{customText:n.otherText}:{}}]}))}:null}a(pu,"questionResponseForInteraction");function sy({interaction:e,onSubmitInteractionAnswers:s,onCancelInteraction:n,errorMessage:r,draftKey:i,onUploadImage:o,mentions:u}){const m=mu(e),p=pu(e,m);return(0,t.jsx)(jf,{id:e.id,questionSet:m,initialResponse:p,implicitCustomAnswer:e.payload.questionSet===void 0,draftKey:i,disabled:!s,imageUploadHandler:o,mentions:u,notesEnabled:Sd(e),onSubmit:a(async(h,d)=>{const v=m.questions.map(k=>{const N=h.answers[k.id],A=k.answerMode==="text"?e.payload.questionSet?N?.text:N?.text?.trim():N?.customText?.trim(),E=d[k.id];return{questionId:k.id,optionIds:k.answerMode==="text"?[]:N?.selectedOptionIds??[],...A?{otherText:A}:{},...E?{note:E}:{}}});try{await s?.(e,v)}catch(k){throw new Error(r(k))}},"onSubmit"),onCancel:n?async()=>{try{await n(e)}catch(h){throw new Error(r(h))}}:void 0})}a(sy,"AskUserQuestionsCard");function ny({interaction:e,planDocument:s,onAcceptInteraction:n,onRejectInteraction:r,externalReferences:i,errorMessage:o,draftKey:u,showPlanPreview:m,onUploadImage:p,mentions:h}){const d=Rd(e),v=Sd(e),[k,N]=(0,l.useState)(!1),[A]=(0,l.useState)(()=>{const y=u?Si(u,""):"";return typeof y=="string"?{reason:y,note:""}:{reason:y.reason??"",note:y.note??""}}),[E,_]=(0,l.useState)(A.reason),[q,O]=(0,l.useState)(A.note),[F,C]=(0,l.useState)(null),[S,P]=(0,l.useState)(null),[j,f]=(0,l.useState)(!1),[w,W]=(0,l.useState)(!1),M=v&&(w||Cd(q)),$=!!(e.payload.rejectRequiresReason||e.payload.allowDeclineReason||e.payload.declineReasonPlaceholder),K=e.payload.target?.type==="issue_document"&&e.payload.target.key==="plan";(0,l.useEffect)(()=>{u&&Ii(u,{reason:E,note:q})},[u,q,E]);async function le(y){if(y==="reject"&&e.payload.rejectRequiresReason&&!E.trim()||M)return;const z=v?Id(q):void 0;C(y),P(null);try{y==="accept"?await(z?n?.(e,void 0,void 0,void 0,z):n?.(e)):await(z?r?.(e,E.trim()||void 0,z):r?.(e,E.trim()||void 0)),u&&Ni(u)}catch(se){P(o(se))}finally{C(null)}}return a(le,"resolve"),(0,t.jsxs)("div",{children:[K&&m?(0,t.jsx)(uu,{interaction:e,planDocument:s}):K&&k?null:(0,t.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[(0,t.jsx)("div",{className:"min-w-0 flex-1 text-sm leading-5 text-ink",children:K?"Do you accept this plan?":(0,t.jsx)(Ds,{children:e.payload.prompt})}),K?null:(0,t.jsx)(sl,{interaction:e})]}),!K&&e.payload.detailsMarkdown?(0,t.jsx)(tl,{children:(0,t.jsx)(bs,{externalReferences:i,children:e.payload.detailsMarkdown})}):null,e.payload.toolAction?(0,t.jsxs)("div",{className:"mt-3 space-y-2 rounded-sm bg-bg-3/45 px-3 py-2.5 text-sm",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("strong",{children:e.payload.toolAction.toolDisplayName}),(0,t.jsxs)("span",{className:ue("text-xs font-medium capitalize",e.payload.toolAction.risk==="destructive"?"text-bad":"text-ink-3"),children:[e.payload.toolAction.risk," risk"]}),(0,t.jsxs)("span",{className:"ml-auto text-xs text-ink-3",children:["Expires"," ",new Date(e.payload.toolAction.expiresAt).toLocaleString()]})]}),(0,t.jsx)(bs,{externalReferences:i,children:e.payload.toolAction.previewMarkdown}),(0,t.jsxs)("details",{children:[(0,t.jsx)("summary",{className:"cursor-pointer text-xs font-medium text-ink-3",children:"Arguments and audit hash"}),(0,t.jsx)("pre",{className:"mt-2 max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-xs text-ink",children:e.payload.toolAction.argumentsSummaryJson}),(0,t.jsx)("p",{className:"mt-1 break-all font-mono text-xs text-ink-3",children:e.payload.toolAction.argumentsHash})]})]}):null,e.payload.secretProposal?(0,t.jsxs)("dl",{className:"mt-3 grid gap-2 rounded-sm bg-bg-3/45 px-3 py-2.5 text-sm",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs text-ink-3",children:"Secret"}),(0,t.jsx)("dd",{children:e.payload.secretProposal.sourceSecretLabel})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs text-ink-3",children:"Binding"}),(0,t.jsxs)("dd",{className:"font-mono text-xs",children:[e.payload.secretProposal.configPath," →"," ",e.payload.secretProposal.targetAgentName]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs text-ink-3",children:"Why"}),(0,t.jsx)("dd",{children:e.payload.secretProposal.justification})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs text-ink-3",children:"Expires"}),(0,t.jsx)("dd",{children:new Date(e.payload.secretProposal.expiresAt).toLocaleString()})]})]}):null,k?(0,t.jsxs)("div",{className:ue("space-y-2",!K&&"mt-3"),children:[(0,t.jsxs)("p",{id:`${e.id}-reject-reason-label`,className:"text-xs font-medium leading-4 text-ink",children:[e.payload.rejectReasonLabel??"What should change?",e.payload.rejectRequiresReason?"":" (optional)"]}),K?(0,t.jsx)(wf,{value:E,onChange:_,placeholder:e.payload.declineReasonPlaceholder??"Describe what should change",imageUploadHandler:p,mentions:h,disabled:F!==null,autoFocus:!0,onUploadingChange:f,onSubmit:a(()=>{j||le("reject")},"onSubmit"),ariaLabelledBy:`${e.id}-reject-reason-label`,testId:"plan-revision-composer",showImageAttachControls:!1}):(0,t.jsx)(va,{id:`${e.id}-reject-reason`,value:E,onChange:a(y=>_(y.target.value),"onChange"),placeholder:e.payload.declineReasonPlaceholder??"Add a short note",className:Ci,autoFocus:!0})]}):null,v?(0,t.jsx)("div",{className:"mt-3",children:(0,t.jsx)(Nd,{value:q,onChange:O,imageUploadHandler:p,mentions:h,disabled:F!==null,onUploadingChange:W})}):null,(0,t.jsx)(Ai,{message:S}),d?(0,t.jsx)(Td,{}):null,(0,t.jsx)(Ri,{children:k?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ne,{type:"button",size:"sm",variant:"ghost",disabled:F!==null,onClick:a(()=>{N(!1)},"onClick"),children:"Back"}),(0,t.jsxs)(ne,{type:"button",size:"sm",variant:"secondary",disabled:F!==null||j||M||!!e.payload.rejectRequiresReason&&!E.trim()||!r,onClick:a(()=>{le("reject")},"onClick"),children:[F==="reject"?(0,t.jsx)(It,{"aria-hidden":!0,className:"h-4 w-4 animate-spin"}):null,e.payload.rejectLabel??"Reject"]})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ne,{type:"button",size:"sm",variant:"ghost",disabled:F!==null||!r||!$&&M,onClick:a(()=>$?N(!0):void le("reject"),"onClick"),children:e.payload.rejectLabel??"Reject"}),(0,t.jsxs)(ne,{type:"button",size:"sm",disabled:F!==null||d||M||!n,onClick:a(()=>{le("accept")},"onClick"),children:[F==="accept"?(0,t.jsx)(It,{"aria-hidden":!0,className:"h-4 w-4 animate-spin"}):null,e.payload.acceptLabel??"Approve"]})]})})]})}a(ny,"ConfirmationCard");function ay({interaction:e,onAcceptInteraction:s,onRejectInteraction:n,externalReferences:r,errorMessage:i,draftKey:o,onUploadImage:u,mentions:m}){const p=o?Si(o,{selected:e.payload.defaultSelectedOptionIds??[],reason:""}):null,[h,d]=(0,l.useState)(()=>new Set(p?.selected??e.payload.defaultSelectedOptionIds??[])),v=Rd(e),[k,N]=(0,l.useState)(!1),[A,E]=(0,l.useState)(p?.reason??""),[_,q]=(0,l.useState)(p?.note??""),[O,F]=(0,l.useState)(!1),C=O||Cd(_),[S,P]=(0,l.useState)(""),[j,f]=(0,l.useState)(null),[w,W]=(0,l.useState)(null),M=!!(e.payload.rejectRequiresReason||e.payload.allowDeclineReason||e.payload.declineReasonPlaceholder),$=e.payload.minSelected??0,K=e.payload.maxSelected??Number.POSITIVE_INFINITY,le=h.size>=$&&h.size<=K,y=e.payload.options.filter(me=>{const oe=S.trim().toLowerCase();return!oe||me.label.toLowerCase().includes(oe)||me.description?.toLowerCase().includes(oe)});(0,l.useEffect)(()=>{o&&Ii(o,{selected:[...h],reason:A,note:_})},[o,_,A,h]);function z(me){d(oe=>{const ve=new Set(oe);return ve.has(me)?ve.delete(me):ve.size<K&&ve.add(me),ve})}a(z,"toggle");async function se(me){if(me==="accept"&&!le||me==="reject"&&e.payload.rejectRequiresReason&&!A.trim()||C)return;const oe=Id(_);f(me),W(null);try{me==="accept"?await(oe?s?.(e,void 0,[...h],void 0,oe):s?.(e,void 0,[...h])):await(oe?n?.(e,A.trim()||void 0,oe):n?.(e,A.trim()||void 0)),o&&Ni(o)}catch(ve){W(i(ve))}finally{f(null)}}a(se,"resolve");const de=K<Number.POSITIVE_INFINITY?`${h.size} selected · choose ${$}–${K}`:$>0?`${h.size} selected · at least ${$}`:`${h.size} selected`;return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[(0,t.jsx)("div",{className:"min-w-0 flex-1 text-sm leading-5 text-ink",children:(0,t.jsx)(Ds,{children:e.payload.prompt})}),(0,t.jsx)(sl,{interaction:e})]}),(0,t.jsxs)("div",{className:"mt-3 grid gap-1",role:"group","aria-label":e.payload.prompt,children:[e.payload.options.length>10?(0,t.jsxs)("label",{className:"relative mb-1 block",children:[(0,t.jsx)(ti,{className:"pointer-events-none absolute left-2.5 top-2.5 h-4 w-4 text-ink-3","aria-hidden":!0}),(0,t.jsx)(jr,{value:S,onChange:a(me=>P(me.target.value),"onChange"),placeholder:"Filter options","aria-label":"Filter options",className:"pl-8"})]}):null,y.map(me=>(0,t.jsxs)("label",{className:"flex cursor-pointer items-start gap-2 rounded-sm px-2 py-1.5 hover:bg-bg-3/50",children:[(0,t.jsx)(qo,{checked:h.has(me.id),onCheckedChange:a(()=>z(me.id),"onCheckedChange"),className:"mt-0.5"}),(0,t.jsxs)("span",{className:"min-w-0",children:[(0,t.jsx)("span",{className:"block text-sm leading-5 text-ink",children:(0,t.jsx)(Ds,{children:me.label})}),me.description?(0,t.jsx)("span",{className:"block text-xs leading-4 text-ink-3",children:(0,t.jsx)(Ds,{children:me.description})}):null]})]},me.id))]}),e.payload.detailsMarkdown?(0,t.jsx)(tl,{children:(0,t.jsx)(bs,{externalReferences:r,children:e.payload.detailsMarkdown})}):null,k?(0,t.jsxs)("div",{className:"mt-3 space-y-1.5",children:[(0,t.jsxs)("label",{htmlFor:`${e.id}-reject-reason`,className:"text-xs font-medium text-ink",children:[e.payload.rejectReasonLabel??"What should change?",e.payload.rejectRequiresReason?"":" (optional)"]}),(0,t.jsx)(va,{id:`${e.id}-reject-reason`,value:A,onChange:a(me=>E(me.target.value),"onChange"),placeholder:e.payload.declineReasonPlaceholder??"Add a short note",className:Ci,autoFocus:!0})]}):null,(0,t.jsx)("div",{className:"mt-3",children:(0,t.jsx)(Nd,{value:_,onChange:q,imageUploadHandler:u,mentions:m,disabled:j!==null,onUploadingChange:F})}),(0,t.jsx)(Ai,{message:w}),v?(0,t.jsx)(Td,{}):null,(0,t.jsx)(Ri,{hint:de,children:k?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ne,{type:"button",size:"sm",variant:"ghost",disabled:j!==null,onClick:a(()=>N(!1),"onClick"),children:"Back"}),(0,t.jsxs)(ne,{type:"button",size:"sm",variant:"secondary",disabled:j!==null||C||!!e.payload.rejectRequiresReason&&!A.trim()||!n,onClick:a(()=>{se("reject")},"onClick"),children:[j==="reject"?(0,t.jsx)(It,{"aria-hidden":!0,className:"h-4 w-4 animate-spin"}):null,e.payload.rejectLabel??"Decline"]})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ne,{type:"button",size:"sm",variant:"ghost",disabled:j!==null||!n||!M&&C,onClick:a(()=>M?N(!0):void se("reject"),"onClick"),children:e.payload.rejectLabel??"Decline"}),(0,t.jsxs)(ne,{type:"button",size:"sm",disabled:j!==null||v||C||!le||!s,onClick:a(()=>{se("accept")},"onClick"),children:[j==="accept"?(0,t.jsx)(It,{"aria-hidden":!0,className:"h-4 w-4 animate-spin"}):null,e.payload.acceptLabel??"Confirm selection"]})]})})]})}a(ay,"CheckboxConfirmationCard");function fu({node:e,selected:s,onToggle:n}){if(e.task.hiddenInPreview)return null;const r=Ed(e).filter(i=>i!==e.task.clientKey&&e.children.some(o=>o.task.clientKey===i&&o.task.hiddenInPreview)).length;return(0,t.jsxs)("li",{children:[(0,t.jsxs)("label",{className:"flex cursor-pointer items-start gap-2 rounded-sm px-2 py-1.5 hover:bg-bg-3/50",children:[(0,t.jsx)(qo,{checked:s.has(e.task.clientKey),onCheckedChange:a(()=>n(e),"onCheckedChange"),className:"mt-0.5"}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block text-sm leading-5 text-ink",children:e.task.title}),r>0?(0,t.jsxs)("span",{className:"block text-xs text-ink-3",children:["+ ",r," hidden follow-up"]}):null]})]}),e.children.length>0?(0,t.jsx)("ul",{className:"ml-4 border-l border-line/80 pl-2",children:e.children.map(i=>(0,t.jsx)(fu,{node:i,selected:s,onToggle:n},i.task.clientKey))}):null]})}a(fu,"SuggestedTaskRow");function ry({interaction:e,onAcceptInteraction:s,onRejectInteraction:n,errorMessage:r,draftKey:i}){const o=(0,l.useMemo)(()=>Nf(e.payload.tasks),[e.payload.tasks]),u=(0,l.useMemo)(()=>new Map(e.payload.tasks.map(j=>[j.clientKey,j])),[e.payload.tasks]),m=i?Si(i,{selected:e.payload.tasks.map(j=>j.clientKey),reason:""}):null,[p,h]=(0,l.useState)(()=>new Set(m?.selected??e.payload.tasks.map(j=>j.clientKey))),[d,v]=(0,l.useState)(!1),[k,N]=(0,l.useState)(m?.reason??""),[A,E]=(0,l.useState)(""),[_,q]=(0,l.useState)(null),[O,F]=(0,l.useState)(null);(0,l.useEffect)(()=>{i&&Ii(i,{selected:[...p],reason:k})},[i,k,p]);const C=(0,l.useMemo)(()=>{const j=A.trim().toLowerCase();if(!j)return o;function f(w){const W=w.children.map(f).filter(M=>M!==null);return w.task.title.toLowerCase().includes(j)||w.task.description?.toLowerCase().includes(j)||W.length>0?{...w,children:W}:null}return a(f,"retain"),o.map(f).filter(w=>w!==null)},[A,o]);function S(j){h(f=>{const w=new Set(f),W=Ed(j);if(w.has(j.task.clientKey))W.forEach(M=>w.delete(M));else{W.forEach($=>w.add($));let M=j.task.parentClientKey;for(;M;)w.add(M),M=u.get(M)?.parentClientKey}return w})}a(S,"toggle");async function P(j){q(j),F(null);try{j==="accept"?await s?.(e,[...p]):await n?.(e,k.trim()||void 0),i&&Ni(i)}catch(f){F(r(f))}finally{q(null)}}return a(P,"resolve"),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm leading-5 text-ink",children:"Select the tasks to create."}),e.payload.tasks.length>10?(0,t.jsxs)("label",{className:"relative mt-3 block",children:[(0,t.jsx)(ti,{className:"pointer-events-none absolute left-2.5 top-2.5 h-4 w-4 text-ink-3","aria-hidden":!0}),(0,t.jsx)(jr,{value:A,onChange:a(j=>E(j.target.value),"onChange"),placeholder:"Filter suggested tasks","aria-label":"Filter suggested tasks",className:"pl-8"})]}):null,(0,t.jsx)("ul",{className:"mt-2 max-h-(--sz-28dvh) overflow-y-auto scrollbar-auto-hide","aria-label":"Suggested tasks",children:C.map(j=>(0,t.jsx)(fu,{node:j,selected:p,onToggle:S},j.task.clientKey))}),d?(0,t.jsxs)("div",{className:"mt-3 space-y-1.5",children:[(0,t.jsx)("label",{htmlFor:`${e.id}-reject-reason`,className:"text-xs font-medium text-ink",children:"Why should these tasks change? (optional)"}),(0,t.jsx)(va,{id:`${e.id}-reject-reason`,value:k,onChange:a(j=>N(j.target.value),"onChange"),placeholder:"Add a short note",className:Ci,autoFocus:!0})]}):null,(0,t.jsx)(Ai,{message:O}),(0,t.jsx)(Ri,{hint:`${p.size} of ${e.payload.tasks.length} selected`,children:d?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ne,{type:"button",size:"sm",variant:"ghost",disabled:_!==null,onClick:a(()=>v(!1),"onClick"),children:"Back"}),(0,t.jsxs)(ne,{type:"button",size:"sm",variant:"secondary",disabled:_!==null||!n,onClick:a(()=>{P("reject")},"onClick"),children:[_==="reject"?(0,t.jsx)(It,{"aria-hidden":!0,className:"h-4 w-4 animate-spin"}):null,"Send back"]})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ne,{type:"button",size:"sm",variant:"ghost",disabled:_!==null||!n,onClick:a(()=>v(!0),"onClick"),children:"Revise"}),(0,t.jsxs)(ne,{type:"button",size:"sm",disabled:_!==null||p.size===0||!s,onClick:a(()=>{P("accept")},"onClick"),children:[_==="accept"?(0,t.jsx)(It,{"aria-hidden":!0,className:"h-4 w-4 animate-spin"}):null,"Create selected"]})]})})]})}a(ry,"SuggestedTasksCard");function iy({interaction:e,onSubmitInteractionVerdicts:s,externalReferences:n,errorMessage:r,draftKey:i}){const o=gh(),u=e.payload.items,m=(0,l.useMemo)(()=>new Map((e.result?.items??[]).map(y=>[y.id,y])),[e.result]),p=Math.max(u.findIndex(y=>!m.has(y.id)),0),h=i?Si(i,{page:p,drafts:[]}):null,[d,v]=(0,l.useState)(h?.page??p),[k,N]=(0,l.useState)(()=>new Map(h?.drafts??[])),[A,E]=(0,l.useState)(!1),[_,q]=(0,l.useState)(null),O=e.payload.verdicts??["approve","reject"],F=new Set(e.payload.requireReasonOn??["reject"]);(0,l.useEffect)(()=>v(y=>Math.min(y,Math.max(u.length-1,0))),[u.length]),(0,l.useEffect)(()=>{N(z=>{const se=new Map(z);let de=!1;for(const me of m.keys())se.delete(me)&&(de=!0);return de?se:z});const y=u.findIndex(z=>!m.has(z.id));y>=0&&v(y)},[u,m]),(0,l.useEffect)(()=>{i&&Ii(i,{page:d,drafts:[...k]})},[i,k,d]);const C=u[d];if(!C)return(0,t.jsx)("p",{className:"text-sm text-ink-3",children:"No review items were provided."});const S=m.get(C.id),P=k.get(C.id),j=C.href?_d(C.href):null,f=!!(!S&&P&&F.has(P.verdict)&&(!P.reason.trim()||P.confirmed===!1));function w(){v(y=>Math.min(y+1,u.length-1))}a(w,"advance");function W(y){N(z=>{const se=new Map(z),de=se.get(C.id);return se.set(C.id,{verdict:y,reason:de?.verdict===y?de.reason:"",confirmed:!F.has(y)}),se}),F.has(y)||w()}a(W,"setVerdict");function M(y){N(z=>{const se=new Map(z),de=se.get(C.id);return de&&se.set(C.id,{...de,reason:y,confirmed:!1}),se})}a(M,"setReason");function $(){P?.reason.trim()&&(N(y=>{const z=new Map(y),se=z.get(C.id);return se&&z.set(C.id,{...se,confirmed:!0}),z}),w())}a($,"confirmRejectionReason");async function K(){if(!s)return;const y=[...k].map(([z,se])=>({id:z,verdict:se.verdict,...se.reason.trim()?{reason:se.reason.trim()}:{}}));if(!(y.length===0||y.some(z=>F.has(z.verdict)&&!z.reason))){E(!0),q(null);try{await s(e,y),i&&Ni(i)}catch(z){q(r(z))}finally{E(!1)}}}a(K,"submit");const le=k.size>0&&[...k.values()].every(y=>!F.has(y.verdict)||!!(y.reason.trim()&&y.confirmed!==!1));return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"mb-2 flex items-center text-xs text-ink-3",children:[(0,t.jsxs)("span",{children:[k.size+m.size," decided"]}),(0,t.jsx)(xh,{children:(0,t.jsxs)("nav",{className:"flex shrink-0 items-center gap-1","aria-label":"Item pagination",children:[(0,t.jsx)(ne,{type:"button",size:"icon-xs",variant:"ghost","aria-label":"Previous item",disabled:A||d===0,onClick:a(()=>v(y=>y-1),"onClick"),children:(0,t.jsx)(_p,{"aria-hidden":!0})}),(0,t.jsxs)("span",{className:"min-w-10 text-center tabular-nums",children:[d+1," of ",u.length]}),(0,t.jsx)(ne,{type:"button",size:"icon-xs",variant:"ghost","aria-label":"Next item",disabled:A||d===u.length-1||f,onClick:a(()=>v(y=>y+1),"onClick"),children:(0,t.jsx)(kr,{"aria-hidden":!0})})]})})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("p",{className:"text-sm font-medium leading-5 text-ink",children:C.label}),C.description?(0,t.jsx)("p",{className:"text-xs leading-4 text-ink-3",children:C.description}):null]}),j?(0,t.jsx)("a",{href:j,className:"text-xs font-medium text-accent hover:underline",children:"Open"}):null]}),C.previewMarkdown?(0,t.jsx)("div",{className:"mt-2 rounded-sm bg-bg-3/40 px-2.5 py-2 text-xs",children:(0,t.jsx)(bs,{externalReferences:n,children:C.previewMarkdown})}):null,S?(0,t.jsxs)("p",{className:"mt-3 inline-flex rounded-sm border border-line px-2 py-1 text-xs capitalize text-ink-3",children:[S.verdict,S.reason?` · ${S.reason}`:""]}):(0,t.jsx)(Ih,{className:"mt-3 flex-wrap","aria-label":`Verdict for ${C.label}`,children:O.map(y=>(0,t.jsxs)(jh,{selected:P?.verdict===y,onClick:a(()=>W(y),"onClick"),className:"min-w-24 capitalize",children:[y==="approve"?(0,t.jsx)(Wn,{"aria-hidden":!0,className:"h-4 w-4"}):null,y==="reject"?(0,t.jsx)(Qa,{"aria-hidden":!0,className:"h-4 w-4"}):null,y]},y))}),!S&&P&&F.has(P.verdict)?(0,t.jsxs)("div",{className:"mt-2 space-y-1.5",children:[(0,t.jsx)("label",{htmlFor:`${e.id}-${C.id}-reason`,className:"text-xs font-medium text-ink",children:e.payload.reasonLabel??"Reason"}),(0,t.jsx)(va,{id:`${e.id}-${C.id}-reason`,value:P.reason,onChange:a(y=>M(y.target.value),"onChange"),placeholder:"Add a short reason",className:Ci,autoFocus:!0}),(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)(ne,{type:"button",size:"sm",variant:"secondary",disabled:!P.reason.trim()||A,onClick:$,children:"Submit rejection reason"})})]}):null,e.payload.detailsMarkdown?(0,t.jsx)(tl,{children:(0,t.jsx)(bs,{externalReferences:n,children:e.payload.detailsMarkdown})}):null,(0,t.jsx)(Ai,{message:_}),(0,t.jsxs)(Ri,{children:[o?.skipButton,(0,t.jsxs)(ne,{type:"button",size:"sm",disabled:!le||A||!s,onClick:a(()=>{K()},"onClick"),children:[A?(0,t.jsx)(It,{"aria-hidden":!0,className:"h-4 w-4 animate-spin"}):null,k.size>0?`Apply ${k.size}`:"Apply decisions"]})]})]})}a(iy,"ItemVerdictsCard");function lc({interaction:e,planDocument:s,showPlanPreview:n=!0,agentMap:r,currentUserId:i,userLabelMap:o,onAcceptInteraction:u,onRejectInteraction:m,onSubmitInteractionAnswers:p,onCancelInteraction:h,onSubmitInteractionVerdicts:d,onUploadImage:v,externalReferences:k,presentation:N="timeline",draftKey:A,mentions:E}){const _=e.createdByAgentId?r?.get(e.createdByAgentId)?.name:e.createdByUserId?e.createdByUserId===i?"You":o?.get(e.createdByUserId):null,q=e.addresseeAgentId?r?.get(e.addresseeAgentId)?.name:e.addresseeUserId?e.addresseeUserId===i?"You":o?.get(e.addresseeUserId)??e.addresseeUserId:null,O=hx({interaction:e,creatorLabel:_,addresseeLabel:q}),F=a(P=>If(P,O),"errorMessage"),C=e.status==="pending"&&!O.isOpen?O.shortSummary:null,S=n&&e.status!=="pending"&&e.kind==="request_confirmation"&&e.payload.target?.type==="issue_document"&&e.payload.target.key==="plan";return e.kind==="connection_intent"?(0,t.jsx)(Af,{interaction:e,currentUserId:i,addresseeLabel:q??"the addressed user",addresseeName:e.addresseeUserId?o?.get(e.addresseeUserId):void 0}):N==="timeline"&&e.status!=="pending"?(0,t.jsxs)(t.Fragment,{children:[S?(0,t.jsx)("div",{className:"mb-2",children:(0,t.jsx)(uu,{interaction:e,planDocument:s})}):null,(0,t.jsx)(oc,{interaction:e,externalReferences:k,compact:!0})]}):(0,t.jsx)(Z0,{interaction:e,audienceLabel:C,presentation:N,children:e.status!=="pending"?(0,t.jsx)(oc,{interaction:e,externalReferences:k}):e.kind==="ask_user_questions"?(0,t.jsx)(sy,{interaction:e,onSubmitInteractionAnswers:p,onCancelInteraction:N==="timeline"?h:void 0,errorMessage:F,draftKey:A,onUploadImage:v,mentions:E}):e.kind==="request_confirmation"?(0,t.jsx)(ny,{interaction:e,planDocument:s,onAcceptInteraction:u,onRejectInteraction:m,externalReferences:k,errorMessage:F,draftKey:A,showPlanPreview:n&&N==="timeline",onUploadImage:v,mentions:E}):e.kind==="request_checkbox_confirmation"?(0,t.jsx)(ay,{interaction:e,onAcceptInteraction:u,onRejectInteraction:m,externalReferences:k,errorMessage:F,draftKey:A,onUploadImage:v,mentions:E}):e.kind==="suggest_tasks"?(0,t.jsx)(ry,{interaction:e,onAcceptInteraction:u,onRejectInteraction:m,errorMessage:F,draftKey:A}):(0,t.jsx)(iy,{interaction:e,onSubmitInteractionVerdicts:d,externalReferences:k,errorMessage:F,draftKey:A})})}a(lc,"TaskChatCompactInteractionCard");function cc({item:e,onReviewRequest:s,showUnansweredQuestion:n=!1,planDocument:r,showPlanPreview:i=!0,presentation:o="timeline",draftKey:u,...m}){const p=e.interaction;if(o==="timeline"&&n&&!lr(p)&&p.kind==="ask_user_questions"&&p.status==="pending"){const k=p.payload.questionSet?.questions[0]?.prompt??p.payload.questions[0]?.prompt??p.title??"Question";return(0,t.jsxs)("button",{type:"button",id:`interaction-${p.id}`,"data-testid":"task-chat-unanswered-question","aria-label":`Answer question: ${k}`,disabled:!s,onClick:a(()=>s?.(p.id),"onClick"),className:"group flex w-full items-center gap-2 rounded-sm px-1 py-1.5 text-left text-sm text-ink-3 transition-colors hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus",children:[(0,t.jsx)(fd,{"aria-hidden":!0,className:"h-3.5 w-3.5 shrink-0"}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block text-xs",children:"Unanswered question"}),(0,t.jsx)(Ds,{className:"line-clamp-1",children:k.split(/\n\s*\n/)[0]??k})]}),(0,t.jsx)(kr,{"aria-hidden":!0,className:"h-3 w-3 shrink-0"})]})}if(p.kind==="request_confirmation"&&p.payload.toolAction){const k=p.payload.toolAction;return o==="takeover"?(0,t.jsx)(Sl,{interaction:p,...m}):(0,t.jsx)("div",{id:`interaction-${p.id}`,"data-testid":"task-chat-tool-review",className:"w-full space-y-2",children:p.status==="pending"?(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[(0,t.jsx)(mh,{name:k.appDisplayName||k.toolDisplayName,size:36}),(0,t.jsx)("div",{className:"min-w-0 flex-1",children:(0,t.jsx)(bs,{children:k.previewMarkdown.split(/\n\s*\n/)[0]||k.toolDisplayName})}),(0,t.jsx)(ne,{className:"ml-auto",size:"sm",variant:"secondary",disabled:!s,onClick:a(()=>s?.(p.id),"onClick"),children:"Review request"})]}):(0,t.jsx)(Sl,{interaction:p,...m})})}const h=p.kind==="ask_user_questions"&&p.status!=="pending"&&p.result?.expirationReason==="superseded_by_newer_interaction";if(lr(p)&&!h)return null;if(o==="timeline"&&p.status==="pending"&&p.kind!=="connection_intent")return!(p.kind==="request_confirmation"&&p.sourceRunId&&p.payload.target?.type==="issue_document"&&p.payload.target.key==="plan"&&r&&(r?.latestRevisionId?p.payload.target.revisionId===r.latestRevisionId:p.payload.target.revisionNumber===r?.latestRevisionNumber))||!i?null:(0,t.jsx)("div",{id:`interaction-${p.id}`,"data-testid":"task-chat-interaction",children:(0,t.jsx)(ei,{source:{kind:"saved",document:r},testId:"plan-review-preview"})});const d=o==="timeline"&&p.kind==="request_confirmation"&&(p.status==="accepted"||p.status==="rejected")&&p.payload.target?.type==="issue_document"&&p.payload.target.key==="plan",v=d&&r!=null&&(r.latestRevisionId?p.payload.target?.revisionId===r.latestRevisionId:p.payload.target?.revisionNumber===r.latestRevisionNumber);return d?v&&i&&r?(0,t.jsx)("div",{id:`interaction-${p.id}`,"data-testid":"task-chat-interaction",children:(0,t.jsx)(ei,{source:{kind:"saved",document:r},testId:"plan-review-preview"})}):null:o==="timeline"&&p.status!=="pending"?(0,t.jsx)("div",{id:`interaction-${p.id}`,className:"tc-enter-bubble w-full","data-testid":"task-chat-interaction",children:(0,t.jsx)(lc,{interaction:p,planDocument:r,showPlanPreview:i,presentation:"timeline",draftKey:u,...m})}):(0,t.jsx)("div",{id:`interaction-${p.id}`,className:"tc-enter-bubble w-full","data-testid":"task-chat-interaction",children:(0,t.jsx)(lc,{interaction:p,planDocument:r,showPlanPreview:i,presentation:o,draftKey:u,...m})})}a(cc,"TaskChatInteractionCard");var hu=new Set(["request_confirmation","request_checkbox_confirmation","request_item_verdicts"]),oy=new Set(["withdrawn","superseded_by_comment","superseded_by_newer_request"]);function ly(e){const s=e.result;return s&&"outcome"in s&&typeof s.outcome=="string"?s.outcome:null}a(ly,"interactionOutcome");function dc(e){if(e.kind==="request_confirmation"&&e.payload.secretProposal||!hu.has(e.kind))return!1;const s=ly(e);return s!=null&&oy.has(s)}a(dc,"isSuppressedThreadInteraction");function cy(e,s){if(e.status==="pending"||!hu.has(e.kind)||!e.resolvedAt)return s;const n=e.resolvedAt instanceof Date?e.resolvedAt.getTime():new Date(e.resolvedAt).getTime();return Number.isFinite(n)?Math.max(s,n):s}a(cy,"interactionThreadAnchorMs");var dy={starting:"Starting",editing:"Saving",replacing:"Replacing",pausing:"Pausing after current turn",resuming:"Resuming",clearing:"Clearing",continuing:"Continuing in a new run"};function uy(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`goal_${Date.now()}_${Math.random().toString(36).slice(2)}`}a(uy,"requestId");function my(e){if(e<60)return`${e}s`;const s=Math.floor(e/60);return s<60?`${s}m`:`${Math.floor(s/60)}h ${s%60}m`}a(my,"formatDuration$1");function uc(e){return e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(e)}a(uc,"formatTokens");function py(e,s){const n=ks(),[r,i]=(0,l.useState)(!1),[o,u]=(0,l.useState)(null),[m,p]=(0,l.useState)(null);(0,l.useEffect)(()=>{i(!1),u(null),p(null)},[e,s]);const h=R.issues.runnerGoal(e??"__none__",s),d=ye({queryKey:h,queryFn:a(()=>xe.getRunnerGoal(e,s),"queryFn"),enabled:!!e,refetchOnReconnect:!0,refetchOnWindowFocus:!0,refetchInterval:a(C=>C.state.data?.goal?.status==="active"?3e4:!1,"refetchInterval")}),v=Pe({mutationFn:a(C=>xe.actOnRunnerGoal(e,C),"mutationFn"),onSuccess:a(C=>{n.setQueryData(h,C.projection),i(C.projection.goal!=null)},"onSuccess")}),k=(0,l.useRef)({query:d,mutation:v});k.current={query:d,mutation:v},ng(C=>{if(C.type!=="agent.session.goal.changed")return;const S=C.payload;if(S.issueId!==e||s&&S.agentId!==s)return;const P=n.getQueryData(h);if(P&&S.revision>P.revision+1){k.current.query.refetch();return}(!P||S.revision>=P.revision)&&n.setQueryData(h,S)});const N=(0,l.useCallback)(async(C,S,P=!1,j)=>{const{query:f,mutation:w}=k.current;p(null);try{const W=f.data??(await f.refetch()).data;if(!W?.agentId)throw new Error(W?.capability.reason??"Select an agent to use /goal.");if(W.capability.availability!=="available")throw new Error(W.capability.reason??"Session goals are unsupported by this agent.");await w.mutateAsync({requestId:uy(),agentId:W.agentId,expectedRevision:j??W.revision,action:C,...S?{objective:S}:{},...C==="replace"?{confirmReplace:P}:{}})}catch(W){throw p(W instanceof Error?W.message:"The goal action could not be applied."),W}},[]),A=(0,l.useCallback)(async()=>{const{query:C,mutation:S}=k.current,P=C.data??(await C.refetch()).data;if(!P?.goal)throw new Error("There is no current session goal to edit.");S.reset(),p(null),i(!0),u({action:"edit",objective:P.goal.objective,revision:P.revision})},[]),E=(0,l.useCallback)(async C=>{const{query:S,mutation:P}=k.current;if(C.action==="focus"){const j=S.data??(await S.refetch()).data;if(!j?.goal&&!j?.pendingAction)throw new Error("Add an objective after /goal to start a goal.");i(!0);return}if(C.action==="edit"){await A();return}if(C.action==="create"){const j=S.data??(await S.refetch()).data;j?.goal&&j.goal.status!=="complete"?(P.reset(),p(null),i(!0),u({action:"replace",objective:C.objective,revision:j.revision})):await N("create",C.objective);return}await N(C.action)},[A,N]),_=(0,l.useCallback)(async()=>{if(!o||k.current.mutation.isPending)return;const C=o.objective.trim();if(!(!C||C.length>4e3))try{await N(o.action,C,o.action==="replace",o.revision),u(null)}catch{}},[o,N]),q=d.data,O=v.isPending,F=m??(v.error instanceof Error?v.error.message:v.error?"The goal action could not be applied.":null);return(0,l.useMemo)(()=>({data:q,expanded:r,setExpanded:i,dialog:o,setDialog:u,submitDialog:_,saving:O,mutationError:F,executeAction:N,edit:A,executeComposerCommand:E}),[q,r,o,_,O,F,N,A,E])}a(py,"useRunnerGoalControl");function fy({control:e}){const s=e.data,n=s?.goal??null,r=s?.capability,i=a(p=>r?.availability==="available"&&r.actions.includes(p),"can"),o=n&&["paused","blocked","limited","usage_limited"].includes(n.status),u=s?.pendingAction?dy[s.pendingAction]:null,m=e.mutationError;return!n&&!s?.pendingAction&&!e.dialog&&!m?null:(0,t.jsxs)("section",{className:"rounded-xl border border-line/80 bg-bg-2/95 px-3 py-2 shadow-sm","aria-label":"Agent session goal","data-testid":"runner-goal-widget",children:[(0,t.jsxs)("div",{className:"flex items-start gap-2",children:[(0,t.jsx)(bd,{className:"mt-0.5 h-4 w-4 shrink-0 text-accent","aria-hidden":!0}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-xs font-semibold",children:"Session goal"}),n?(0,t.jsx)("span",{className:"rounded-full bg-bg-3 px-1.5 py-0.5 text-xs font-medium capitalize",role:"status",children:n.status.replaceAll("_"," ")}):null,n?.workingNow?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs text-accent",role:"status",children:[(0,t.jsx)("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-accent"})," Working now"]}):null,u?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs text-ink-3",role:"status",children:[(0,t.jsx)(It,{className:"h-3 w-3 animate-spin","aria-hidden":!0})," ",u]}):null]}),n?(0,t.jsx)("p",{className:ue("mt-1 text-sm leading-snug",e.expanded?"max-h-40 overflow-auto":"line-clamp-2"),children:n.objective}):(0,t.jsx)("p",{className:"mt-1 text-xs text-ink-3",children:r?.reason??"Type /goal followed by an objective to pursue work across turns."}),n?(0,t.jsxs)("div",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-1 text-xs text-ink-3",children:[(0,t.jsx)("span",{children:my(n.elapsedSeconds)}),r?.usageReporting?(0,t.jsxs)("span",{children:[uc(n.tokensUsed)," tokens",n.tokenBudget?` / ${uc(n.tokenBudget)}`:""]}):null,n.iterations>0?(0,t.jsxs)("span",{children:[n.iterations," iterations"]}):null,n.lastReason?(0,t.jsx)("span",{className:"truncate",children:n.lastReason}):null]}):null]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[n&&i("set")?(0,t.jsx)(ne,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:a(()=>{e.edit().catch(()=>{})},"onClick"),"aria-label":"Edit goal",children:(0,t.jsx)(ai,{className:"h-3.5 w-3.5","aria-hidden":!0})}):null,n?.status==="active"&&i("pause")?(0,t.jsx)(ne,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:a(()=>{e.executeAction("pause").catch(()=>{})},"onClick"),"aria-label":"Pause goal",children:(0,t.jsx)(_f,{className:"h-3.5 w-3.5","aria-hidden":!0})}):null,o&&i("resume")?(0,t.jsx)(ne,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:a(()=>{e.executeAction("resume").catch(()=>{})},"onClick"),"aria-label":"Resume goal",children:(0,t.jsx)(qf,{className:"h-3.5 w-3.5","aria-hidden":!0})}):null,n&&i("clear")?(0,t.jsx)(ne,{size:"icon",variant:"ghost",className:ue("h-7 w-7"," "),onClick:a(()=>{e.executeAction("clear").catch(()=>{})},"onClick"),"aria-label":"Clear goal",children:(0,t.jsx)(Bo,{className:"h-3.5 w-3.5","aria-hidden":!0})}):null]})]}),m?(0,t.jsx)("p",{className:"mt-1 text-xs text-bad",role:"alert",children:m}):null,(0,t.jsx)(Vo,{open:!!e.dialog,onOpenChange:a(p=>{!p&&!e.saving&&e.setDialog(null)},"onOpenChange"),children:(0,t.jsx)(Wo,{showCloseButton:!e.saving,children:(0,t.jsxs)("form",{className:"space-y-4",onSubmit:a(p=>{p.preventDefault(),e.submitDialog()},"onSubmit"),children:[(0,t.jsxs)(Qo,{children:[(0,t.jsx)(Ho,{children:e.dialog?.action==="replace"?"Replace session goal?":"Edit session goal"}),(0,t.jsx)(zo,{children:e.dialog?.action==="replace"?"This clears the unfinished goal and starts a new goal with the objective below.":"Update the objective without clearing the goal's progress."})]}),(0,t.jsxs)("label",{className:"block space-y-2",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:"Goal objective"}),(0,t.jsx)(va,{value:e.dialog?.objective??"",maxLength:4e3,required:!0,disabled:e.saving,onChange:a(p=>{const h=p.target.value;e.setDialog(d=>d?{...d,objective:h}:null)},"onChange"),onKeyDown:a(p=>{p.key==="Enter"&&(p.metaKey||p.ctrlKey)&&(p.preventDefault(),p.currentTarget.form?.requestSubmit())},"onKeyDown")})]}),m?(0,t.jsx)("p",{className:"text-sm text-bad",role:"alert",children:m}):null,(0,t.jsxs)(ah,{children:[(0,t.jsx)(ne,{type:"button",variant:"secondary",disabled:e.saving,onClick:a(()=>e.setDialog(null),"onClick"),children:"Cancel"}),(0,t.jsx)(ne,{type:"submit",disabled:!e.dialog?.objective.trim()||e.saving,children:e.saving?"Saving…":e.dialog?.action==="replace"?"Replace goal":"Save goal"})]})]})})})]})}a(fy,"RunnerGoalWidgetBase");var hy=(0,l.memo)(fy);function gy(e,s,n){if(e.some(o=>o.source?.kind==="interaction"))return null;const r=e.findIndex(o=>o.comment.id===s),i=e.findIndex(o=>o.comment.id===n);return r<0||i<0||r===i?null:Gh(e,r,i).map((o,u)=>({...o,position:u}))}a(gy,"reorderQueuedMessageEntries");function mc(e){if(typeof e!="object"||e===null)return null;const s=e.body;if(typeof s!="object"||s===null)return null;const n=s.code;if(typeof n=="string")return n;const r=s.details;if(typeof r!="object"||r===null)return null;const i=r.code;return typeof i=="string"?i:null}a(mc,"queueActionErrorCode");function xy({entry:e,count:s,queue:n,busy:r,queueMutationDisabled:i,action:o,onEdit:u,onSteer:m,onInterrupt:p,onDiscard:h,onShowIndividually:d}){const v=e.source?.kind==="interaction",k=v?e.comment.body.split(`
1
+ var xm=Object.defineProperty;var a=(e,s)=>xm(e,"name",{value:s,configurable:!0});import{i as Eo,n as ym}from"./rolldown-runtime-ZpX3ckPj.js";import{A as vm,Ci as bm,Kn as km,O as hr,Ti as nd,_ as dl,_i as wm,h as jm,k as Im,l as ue,la as Nm,m as Sm,p as Cm,t as gr,ua as Am,x as zs,zi as go}from"./createLucideIcon-CgrPXnTY.js";import{l as Rm}from"./dist-DYoIyA63.js";import{_ as ad,a as di,h as ui,n as mi,o as ul,r as Tm,v as Em}from"./star-eem0qj3E.js";import{X as ks,_ as Pe,d as _m,g as qm,n as Hs,r as ml,t as R,u as Mm,v as ye}from"./queryKeys-BzT8CD34.js";import{t as Pm}from"./useInfiniteQuery-DTEIZ1gz.js";import{t as rd}from"./useQueries-K6OPYBvC.js";import{o as Fm}from"./companies-query-BEdFiAhG.js";import{j as Dm}from"./ConnectionSetupFlow-8alK3I_h.js";import{r as $m}from"./ArtifactCard-BV82tDLI.js";import{t as Lm}from"./issue-attribution-DfN_3u2W.js";import{n as Bm,r as Om}from"./responsible-user-denial-Dyl0BwU5.js";import{n as Km,t as Um}from"./IssueWriteDenialNotice-Bf0ZFSBV.js";import{a as Qm,i as Wm,n as zm,t as Hm}from"./IssueDocumentAnnotations-DpFXlkRb.js";import{t as pl}from"./execution-projection-BGI5f3kX.js";import{d as Vm,f as Gm}from"./connection-identity-ch7QDvun.js";import{n as Ym,r as Jm,t as Xm}from"./workspace-restore-BIbDC_O8.js";import{a as fl,i as Zm,n as hl,r as ep,t as tp}from"./TerminalView-DDv6s-R_.js";import{n as sp}from"./CompanyContext-fQCNWI_f.js";import{A as np,At as ap,Bt as gl,D as rp,Dt as ip,Et as op,Ft as id,G as lp,Gt as cp,It as dp,Jt as up,Kt as Ki,Lt as mp,Mt as pp,Nt as Lr,Ot as xl,Pt as yl,Rt as nr,St as fp,T as hp,Tt as vl,Ut as fa,Wt as bl,Yt as gp,at as pi,et as od,jt as xp,kt as yp,o as fi,on as vp,ot as bp,qt as kl,t as ls,v as Xr,vt as xo,wt as kp,zt as xe}from"./router-CJbFZfVR.js";import{a as hi,c as gi,i as xi,l as wp,n as _o,o as yi,r as vi,s as bi,t as ki}from"./alert-dialog-DNbnZgRz.js";import{a as yo,n as vo,r as jp,t as bo}from"./avatar-qO_h93F8.js";import{t as qo}from"./checkbox-Cf2_HXDG.js";import{i as wl,p as Ip,r as Np,t as Sp}from"./dropdown-menu-rUbU8QKw.js";import{t as Cp}from"./label-B707hSFt.js";import{n as Br,t as Ap}from"./tabs-CjHzZxtD.js";import{c as Rp,i as Tp}from"./MarkdownEditor-ubJimjUH.js";import{o as xr,r as yr,t as vr}from"./popover-CWlBonqy.js";import{t as ld}from"./archive-CvT6i844.js";import{t as cd}from"./arrow-left-CnGEiANj.js";import{t as Ep}from"./arrow-up-down-Ci6AcwB0.js";import{t as Wn}from"./check-Bis3vECb.js";import{t as br}from"./chevron-down-nRcQ7bok.js";import{t as _p}from"./chevron-left-DnUVccc_.js";import{t as kr}from"./chevron-right-BP8JjEC_.js";import{t as dd}from"./chevron-up-C1TOE3pP.js";import{t as qp}from"./SearchableSelect-BbuRtdzg.js";import{t as ud}from"./circle-alert-C7T1cdKm.js";import{a as Mp,c as Pp,d as md,i as Fp,n as Dp,r as $p,t as Lp,u as pd}from"./ScrollToBottom-Dd3SpeJi.js";import{t as fd}from"./circle-question-mark-CasEGiDp.js";import{t as Zr}from"./circle-DCDVf2v0.js";import{t as Mo}from"./clock-D2UFngg7.js";import{A as Bp,E as Op,M as jl,N as Kp,T as Up,a as Qp,c as Wp,d as zp,f as Hp,g as Il,h as Vp,i as Gp,j as Yp,k as Jp,l as Xp,m as hd,n as Zp,s as ef,t as bs,u as tf,v as hn,x as sf,y as nf}from"./MarkdownBody-cPGkwwjq.js";import{t as gd}from"./cloud-DX1fkQ6i.js";import{t as wr}from"./copy-C1cfcpxY.js";import{t as af}from"./ellipsis-vertical-DzWImTnI.js";import{t as xd}from"./ellipsis-DyXbAp4P.js";import{t as Po}from"./external-link-BIcMNNSN.js";import{t as ko}from"./eye-off-DTXvEIMp.js";import{t as rf}from"./eye-D8HiVtuU.js";import{a as yd,c as of,i as vd,o as lf,s as cf}from"./TaskChatMarker-DEF88_sr.js";import{t as Ua}from"./file-code-corner-CwcL9g2p.js";import{t as df}from"./file-question-mark-BCVjQ2mM.js";import{t as uf}from"./file-search-Ccb88q3t.js";import{t as dr}from"./file-text-CsPKrMTp.js";import{t as mf}from"./file-CcVMTQhg.js";import{i as Nl}from"./RichWorkProductCard-DndJn4LV.js";import{t as bd}from"./flag-i_D610oD.js";import{t as Rn}from"./folder-open-Dkshp3J4.js";import{t as pf}from"./folder-search-B_Hz17IO.js";import{a as ff,c as kd,d as Cn,f as hf,g as gf,h as Fo,l as wd,m as xf,o as yf,p as vf,s as bf,t as kf,u as jd}from"./issue-properties--M7WE6Ot.js";import{a as Ui,c as Id,i as Nd,l as wf,o as Sd,r as Ds,s as Cd,t as jf}from"./QuestionForm-MfSDsey7.js";import{t as Ad}from"./link-2-Cn4f4xsG.js";import{t as Do}from"./list-todo-DfkI9JDS.js";import{r as It,t as ne}from"./button-DI4w5WP7.js";import{a as If,c as Nf,d as Sf,f as Rd,g as Cf,h as lr,i as Td,l as Ed,m as _d,n as Af,o as Rf,s as qd,t as Sl,u as Tf}from"./IssueThreadInteractionCard-Btd0rZ23.js";import{t as Ef}from"./minus-BttANimQ.js";import{n as $o}from"./TaskChatProtocolCard-Ba_vhDxn.js";import{t as _f}from"./pause-B6AkvDer.js";import{t as qf}from"./play-Czm7OCYh.js";import{t as Mf}from"./plug-UFf0xCI3.js";import{t as Lo}from"./plus-CwNlqadt.js";import{t as Pf}from"./radio-BqjASC1E.js";import{t as Md}from"./repeat-DzPORJjX.js";import{t as Ff}from"./rotate-ccw-DpzLJhXT.js";import{_ as Pd,b as Df,c as ei,d as $f,f as Fd,g as Lf,h as Bf,l as Dd,m as Of,n as Kf,p as Uf,r as Cl,t as Qf,u as Wf,v as zf,y as Hf}from"./TaskChatThreadView-BsPvbxiA.js";import{t as ti}from"./search-CgZSuGC8.js";import{t as Vf}from"./settings-DuRZr7gk.js";import{t as Gf}from"./shield-check-RPyaLAc-.js";import{t as Bo}from"./trash-QxFF084e.js";import{t as nn}from"./triangle-alert-CnHMpmva.js";import{t as Yf}from"./users-CEZ1U5q9.js";import{t as Qa}from"./x-6E1yeU3Q.js";import{r as $d}from"./SidebarContext-bEtg0ItG.js";import{i as Oo,n as Ko,r as Ld,t as Uo}from"./tooltip-CW50mEoC.js";import{t as Qn}from"./badge-jeXr866I.js";import{t as Vr}from"./Identity-8eG_HXAH.js";import{t as ur}from"./AgentAvatar-BZiiDlCN.js";import{a as ya,i as Jf}from"./ToastContext-DyVJ6bCh.js";import{t as ga}from"./agents-B8n-p0aX.js";import{t as Al}from"./instanceSettings-D1nNVWU0.js";import{n as Xf,t as Zf}from"./useSharedPolling-CFeiZe2t.js";import{a as Rl,d as Qi,f as Tl,i as El,l as eh,n as _l,o as th,p as sh,r as ql,u as Ml}from"./inboxArchiveCache-CxaLM1R8.js";import{t as wi}from"./projects-l3kQxnTp.js";import{t as nh}from"./useAgentChatEnabled-DMbd4JDE.js";import{a as Qo,i as ah,n as Wo,r as zo,s as Ho,t as Vo}from"./dialog-CeH7rDcv.js";import{t as jr}from"./input-BBNGmECW.js";import{t as mr}from"./access-DhB95qNC.js";import{n as rh,r as ih,t as oh,u as Pl}from"./issue-filters-Ce8v1l6U.js";import{i as Fl,o as lh,t as ch}from"./assignees-DkQNbPzi.js";import{n as Dl,o as dh,t as uh}from"./slots-B7lwlN1w.js";import{t as jt}from"./skeleton-BAAoD7cz.js";import{t as wo}from"./chatEndpoints-Bj-keCuw.js";import{t as mh}from"./AppLogo-BLq8BpKi.js";import{t as zn}from"./activity-CudcEDwO.js";import{n as ph}from"./BreadcrumbContext-DNbB7zWn.js";import{t as fh}from"./AgentIdentity-DBHRFgMM.js";import{t as va}from"./textarea-CTx68BDs.js";import{t as $l}from"./attachment-icon-_1iz_saB.js";import{n as ji,t as hh}from"./presentation-mode-ZjtUUsSS.js";import{_ as Ii,a as Ni,f as Si,i as gh,n as xh,r as yh}from"./TaskChatComposerTakeoverContext-C68QVO36.js";import{n as vh}from"./useMobileEntityPickerViewportStyle-BG2vZMIz.js";import{t as bh}from"./InlineBanner-DeTqU5Gp.js";import{t as Go}from"./clipboard-CTLKYvRL.js";import{t as kh}from"./AgentSetupPrompt-CaafK5_w.js";import{t as wh}from"./use-copy-action-DFzauB4H.js";import{n as jh,t as Ih}from"./segmented-tuNVx49H.js";import{t as si}from"./StatusIcon-Cs1RbJGu.js";import{f as ni,h as Nh,p as Sh,r as Ch,t as Ah,v as Rh}from"./issue-blockers-t3wlvg4M.js";import{$t as Th,Aa as Yo,Ar as Ll,Da as Bd,Dr as Eh,Er as _h,Fa as qh,Ga as Mh,Gn as Ph,Ha as Od,K as Bl,Kn as Fh,Kr as Dh,La as ai,Ma as ri,Mr as $h,Na as Lh,Or as Bh,Qn as Oh,S as Kh,Ua as Jo,W as Uh,Xt as Ol,Y as Qh,Za as Xo,Zn as Wh,_a as vs,ar as zh,ba as Hh,bi as Vh,ca as Kl,ci as Gh,di as Yh,fi as Jh,fr as Xh,g as Zh,gi as eg,gr as tg,hi as sg,ht as ng,ir as ag,jr as rg,kr as ig,l as og,li as lg,mi as cg,nr as dg,or as ug,ot as mg,q as jo,qa as pg,rr as fg,si as hg,tn as gg,u as xg,ua as Wi,ui as yg,vi as Ul,wr as vg,xi as bg,y as kg,yi as wg,zr as jg}from"./index-QhteFtm-.js";import{f as Ig,g as Ng,l as Sg,m as Cg,s as Ag,u as Rg}from"./system-notice-comment-D0I6rz8Y.js";import{a as Tg,n as Eg,o as _g,r as qg,t as Ql}from"./AccessSelectIdentity-C-iVX_EX.js";import{a as Mg,c as Pg,d as Kd,t as Fg,u as Zo}from"./ImageGalleryModal-D_VQgcBt.js";import{a as Ud,i as Dg,o as $g,r as Lg,t as Bg}from"./AgentTodoCard-C4BfJg4x.js";import{t as Oa}from"./browser-use-BwBUHG71.js";import{i as Og,t as Qd}from"./IssueReferencePill-BT7NBEy_.js";import{c as Kg,i as Ug,l as Wd,n as Qg,o as zd,r as Wg,s as zg,t as Hg,u as Vg}from"./TaskTreeControls-BKOIbilg.js";import{t as Gg}from"./email-hX48MODm.js";import{a as Yg,c as Jg,d as Xg,f as Zg,i as ex,l as tx,m as sx,o as nx,p as ax,r as rx,s as ix,t as ox,u as lx}from"./IssueChatThread-CDKaIB6v.js";import{t as Kt}from"./query-placeholder-data-Bg4z2kcq.js";import{n as cx,t as dx}from"./issueActiveRun-s6f-GUHq.js";import{t as ux}from"./ApprovalCard-DCQ49PuW.js";import{t as mx}from"./FoldCurtain-H4DNjYLl.js";import{t as Hd}from"./InlineEditor-4ew5gxf0.js";import{t as Vd}from"./useSecondTick-BRYNTPNI.js";import{i as px,n as fx}from"./SourceTrustBadge-CCPQEGrC.js";import{n as hx}from"./interaction-audience-B74UGNaN.js";import{t as gx}from"./runRetryState-p_i4Mh7u.js";import{n as xx}from"./model-fallback-CwykjJWn.js";import{_ as yx,a as vx,c as xa,d as bx,f as zi,g as Or,h as Wl,i as Gd,l as kx,m as zl,n as wx,o as Hi,p as Vi,r as Gi,t as jx,u as Ix,v as ir,y as Io}from"./transcript-adapter-ClaGWYVL.js";import{n as Nx,o as Sx,s as Cx}from"./issue-output-BM-lLts2.js";import{t as Gr}from"./issue-share-W3K_cYZY.js";import{o as Ax,r as Rx,s as Tx,t as Ex}from"./sheet-D5sUsyfT.js";import{t as _x}from"./artifacts-4t_LL-lA.js";import{t as qx}from"./ResponsibleUserDenialNotice-dXyOLtYP.js";import{n as Mx}from"./activity-format-CYYHRbLo.js";var Px=new Set(["archived","cleanup_failed"]);function Fx(e){return!e||e.mode!=="isolated_workspace"?!1:e.closedAt!=null||Px.has(e.status)}a(Fx,"isClosedIsolatedExecutionWorkspace");var Yd={name:"corner-down-right",size:24,node:[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]]};Yd.node;var Yi=gr(Yd),Jd={name:"refresh-ccw",size:24,node:[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]]};Jd.node;var cr=gr(Jd),Xd={name:"scan-eye",size:24,node:[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0",key:"11ak4c"}]]};Xd.node;var Dx=gr(Xd),Zd={name:"ungroup",size:24,node:[["rect",{x:"11",y:"14",width:"10",height:"7",rx:"2",key:"nfm8rk"}],["rect",{x:"3",y:"3",width:"10",height:"7",rx:"2",key:"1ljebb"}]]};Zd.node;var $x=gr(Zd),eu={name:"video",size:24,node:[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]};eu.node;var Lx=gr(eu),l=Eo(Am(),1);function tu(e){return ye({queryKey:["task-browsers",e],queryFn:a(()=>Oa.list(e),"queryFn"),enabled:!!e&&!e?.startsWith("chat:"),refetchInterval:3e3,retry:!1})}a(tu,"useTaskBrowsers");function Bx(e,s,n){const r=JSON.stringify([e,s]),[i,o]=(0,l.useState)(null),u=(0,l.useRef)(new Set),m=(0,l.useCallback)(v=>`wardmote:browser-arrival:v2:${e}:${s}:${v}`,[e,s]),p=i?.scope===r?i:null;(0,l.useEffect)(()=>{if(!s||p)return;const v=n?.find(k=>{if(k.status!=="running"&&k.status!=="idle")return!1;const N=m(k.sessionId);if(u.current.has(N))return!1;try{return!sessionStorage.getItem(N)}catch{return!0}});v&&o({scope:r,browserId:v.id,sessionId:v.sessionId})},[n,p,s,m,r]);const h=(0,l.useCallback)(()=>{if(p){if(p.sessionId){const v=m(p.sessionId);u.current.add(v);try{sessionStorage.setItem(v,"1")}catch{}}o(v=>v===p?null:v)}},[p,m]),d=(0,l.useCallback)(v=>{o({scope:r,browserId:v,sessionId:n?.find(k=>k.id===v)?.sessionId})},[n,r]);return{openBrowserId:p?.browserId??null,openBrowser:d,acknowledgeBrowserOpened:h}}a(Bx,"useBrowserArrivals");var t=Eo(Nm(),1);function Ox({issueId:e,action:s,canManage:n,onQueued:r,className:i}){const o=(0,l.useId)(),[u,m]=(0,l.useState)(""),[p,h]=(0,l.useState)(null),d=Pe({mutationFn:a(()=>xe.retryWorkspaceExport(e,{actionId:s.id,runId:s.evidence.runId,repairNote:u.trim()}),"mutationFn"),onSuccess:a(()=>{h(String(s.updatedAt)),r()},"onSuccess")});if(!s||!Ym(s.cause)||s.ownerType!=="board"||!["active","escalated"].includes(s.status)||typeof s.evidence.runId!="string")return null;const v=p===String(s.updatedAt)||s.wakePolicy?.kind==="resume_native_run";return(0,t.jsxs)("section",{"aria-label":"Workspace export repair",className:ue("task-context-notice flex flex-col gap-2",i),children:[(0,t.jsx)("p",{className:"font-medium",children:"Workspace export needs repair"}),v?(0,t.jsx)("p",{role:"status",children:"Export is queued for the saved result. The agent will not repeat its work."}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"text-ink-3",children:"Automatic workspace export retries stopped. Inspect the export failure, restore provider or destination availability, and preserve the saved files in the retained sandbox. Retry export here when the cause is resolved."}),n?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Cp,{htmlFor:o,children:"Repair performed"}),(0,t.jsx)(va,{id:o,value:u,onChange:a(k=>m(k.target.value),"onChange"),maxLength:12e3,placeholder:"Describe the repair and how the saved workspace files were preserved.",disabled:d.isPending}),(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)(ne,{onClick:a(()=>d.mutate(),"onClick"),disabled:d.isPending||u.trim().length<20,children:d.isPending?"Queueing export…":"Retry workspace export"})})]}):(0,t.jsx)("p",{className:"text-ink-3",children:"A board member with runtime access can retry this export after repair."}),d.isError&&(0,t.jsx)("p",{role:"alert",className:"text-bad",children:d.error instanceof Error?d.error.message:"Could not queue export. Refresh the task and inspect its run."})]})]})}a(Ox,"WorkspaceExportRecovery");function Kx(e){try{localStorage.removeItem(`wardmote:agent-chat-pending:${e}`)}catch{}}a(Kx,"clearLegacyChatMessageRequests");function Ux(e,s="standard"){return{id:`chat:${e.id}`,companyId:e.companyId,title:`Chat with ${e.name}`,conversationAgentId:e.id,conversationUserId:"draft",conversationState:"waiting",status:"in_review",workMode:s,priority:"medium",reviewPolicy:null,projectId:null,projectWorkspaceId:null,goalId:null,parentId:null,description:null,assigneeAgentId:e.id,assigneeUserId:null,checkoutRunId:null,executionRunId:null,executionAgentNameKey:null,executionLockedAt:null,createdByAgentId:null,createdByUserId:null,responsibleUserId:null,issueNumber:null,identifier:null,requestDepth:0,billingCode:null,assigneeAdapterOverrides:null,executionWorkspaceId:null,executionWorkspacePreference:null,executionWorkspaceSettings:null,startedAt:null,completedAt:null,cancelledAt:null,hiddenAt:null,createdAt:new Date(0),updatedAt:new Date(0),documentSummaries:[],labels:[]}}a(Ux,"agentChatDraft");function Qx({companyId:e,issueId:s,blocker:n,onRetried:r,className:i}){const o=ks(),{data:u,error:m}=ye({queryKey:R.issues.runs(s),queryFn:a(()=>zn.runsForIssue(s),"queryFn")}),p=u?.find(k=>k.runId===n.runId&&["failed","timed_out"].includes(k.status)),h=p?.errorCode==="native_provider_model_rejected",d=n.cause==="native_continuation_requires_reconciliation"||n.cause==="native_session_cleanup_quarantined",v=Pe({mutationFn:a(()=>ga.retryFailedRun(n.agentId,n.runId,e),"mutationFn"),onSuccess:a(()=>{r();for(const k of[R.issues.detail(s),R.issues.runs(s),R.issues.liveRuns(s),R.issues.activeRun(s)])o.invalidateQueries({queryKey:k})},"onSuccess")});return(0,t.jsxs)("div",{role:"status","aria-label":"Task recovery",className:ue("task-context-notice flex flex-wrap items-center justify-between gap-2",i),children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1 break-words",children:[(0,t.jsxs)("p",{children:[h?"Model unavailable.":"Recovery needed.",n.runError?` ${n.runError}`:""]}),h&&(0,t.jsx)("p",{children:"Choose a supported model or clear the task's model override, then retry."}),(0,t.jsx)("p",{children:n.nextAction}),!!n.savedMessageCount&&(0,t.jsxs)("p",{children:[n.savedMessageCount," saved ",n.savedMessageCount===1?"message is":"messages are"," waiting for recovery."]})]}),n.agentId&&n.runId&&(0,t.jsx)(ne,{variant:"secondary",size:"sm",asChild:!0,children:(0,t.jsx)(ls,{to:`/agents/${n.agentId}/runs/${n.runId}`,children:"Inspect run"})}),!n.workspaceRepairRequired&&(!d||n.canRetry)&&n.agentId&&n.runId&&(n.cause==="legacy_execution_requires_reconciliation"&&p||n.canContinue||n.canRetry)&&(0,t.jsx)(ne,{variant:"secondary",size:"sm",disabled:v.isPending,onClick:a(()=>v.mutate(),"onClick"),children:v.isPending?"Starting…":n.canContinue?"Continue":"Retry"}),v.isError&&(0,t.jsx)("p",{role:"alert",className:"w-full text-bad",children:v.error.message}),m&&(0,t.jsx)("p",{role:"alert",className:"w-full text-bad",children:m.message})]})}a(Qx,"ExecutionBlockerNotice");function Wx({companyId:e,issueId:s}){const n=ks(),r=["email-thread",e,s],i=!!(e&&s)&&!s.startsWith("chat:"),o=Ig(e,s);if(!i)return null;const u=o.data,m=u?.messages.filter(h=>!h.commentId)??[],p=u?.publications.filter(h=>!h.providerMessageId||h.outcome==="uncertain")??[];return!o.error&&!m.length&&!p.length?null:(0,t.jsxs)("div",{className:"space-y-3",children:[o.error&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-bad",children:o.error.message}),m.map(h=>(0,t.jsx)(Sg,{contextNotice:!0,issueId:s,message:h,publication:u?.publications.find(d=>d.providerMessageId===h.providerMessageId)},h.id)),p.map(h=>(0,t.jsx)(zx,{companyId:e,publication:h,onResolved:a(()=>{n.invalidateQueries({queryKey:r})},"onResolved")},h.id))]})}a(Wx,"EmailTaskActivity");function zx({companyId:e,publication:s,onResolved:n}){const[r,i]=(0,l.useState)(""),o=Pe({mutationFn:a(u=>Gg.resolve(e,s.id,u,r||void 0),"mutationFn"),onSuccess:n});return(0,t.jsxs)("div",{className:"space-y-2 text-xs text-ink-3",children:[s.request&&!s.providerMessageId&&(0,t.jsxs)("article",{"aria-label":"Email send intent",className:"task-context-notice space-y-3",children:[(0,t.jsx)("p",{className:"font-semibold",children:s.request.subject??"Email reply"}),s.request.to&&(0,t.jsxs)("p",{children:["To: ",s.request.to.join(", ")]}),(0,t.jsx)("div",{className:"whitespace-pre-wrap break-words text-sm text-ink",children:s.request.text})]}),(0,t.jsxs)("p",{children:["Email ",s.outcome,s.error?` — ${s.error}`:""]}),s.outcome==="uncertain"&&(0,t.jsxs)("details",{children:[(0,t.jsx)("summary",{className:"cursor-pointer",children:"Resolve delivery after checking AgentMail"}),(0,t.jsxs)("div",{className:"space-y-2 py-2",children:[(0,t.jsx)("p",{children:"Confirm the outcome in AgentMail before resolving. This action does not resend."}),(0,t.jsx)(jr,{"aria-label":"Provider message ID",value:r,onChange:a(u=>i(u.target.value),"onChange"),placeholder:"Provider message ID"}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(ne,{size:"sm",variant:"secondary",disabled:!r||o.isPending,onClick:a(()=>o.mutate("sent"),"onClick"),children:"Confirm sent"}),(0,t.jsx)(ne,{size:"sm",variant:"secondary",disabled:o.isPending,onClick:a(()=>o.mutate("failed"),"onClick"),children:"Confirm not sent"})]}),o.error&&(0,t.jsx)("p",{role:"alert",className:"text-bad",children:o.error.message})]})]})]})}a(zx,"EmailDelivery");var su=Eo(Rm(),1);function ar(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}a(ar,"record$2");var Hx=new Set(["available","unsupported","temporarily_unavailable"]),Vx=new Set(["deferred","queued"]);function Hl(e,s){const n=ar(e),r=new Set,i=(Array.isArray(n?.entries)?n.entries:[]).flatMap((p,h)=>{const d=ar(p),v=ar(d?.comment),k=typeof v?.id=="string"?v.id:"",N=typeof v?.body=="string"?v.body:null;if(!k||N===null||r.has(k))return[];r.add(k);const A=typeof d?.position=="number"&&Number.isFinite(d.position)?d.position:h,E=ar(d?.source);return[{comment:v,position:A,...E?.kind==="interaction"&&typeof E.interactionId=="string"&&typeof E.interactionKind=="string"?{source:{kind:"interaction",interactionId:E.interactionId,interactionKind:E.interactionKind,requiresFreshSession:E.requiresFreshSession===!0}}:{},canEdit:d?.canEdit===!0,canDiscard:d?.canDiscard===!0}]}).sort((p,h)=>p.position-h.position).map((p,h)=>({...p,position:h})),o=n?.steeringDisposition,u=n?.state,m=ar(n?.executionWait);return{issueId:typeof n?.issueId=="string"?n.issueId:s,queueId:typeof n?.queueId=="string"?n.queueId:null,state:typeof u=="string"&&Vx.has(u)?u:null,targetRunId:typeof n?.targetRunId=="string"?n.targetRunId:null,revision:typeof n?.revision=="string"?n.revision:"unavailable",protocol:n?.protocol==="wardmote_runner_v1"?"wardmote_runner_v1":"legacy",steeringDisposition:typeof o=="string"&&Hx.has(o)?o:"unsupported",entries:i,executionWait:typeof m?.reason=="string"&&typeof m?.message=="string"?{reason:m.reason,message:m.message}:null}}a(Hl,"normalizeIssueQueuedCommentQueue");function Gx(e){return new Set((e?.entries??[]).flatMap(s=>s.source?.kind==="interaction"?[s.source.interactionId]:[]))}a(Gx,"queuedInteractionResponseIds");function Yx(e){const s=e.authoritativeQueue?.entries??[],n=new Set(s.map(d=>d.comment.id)),r=e.pendingComments.filter(({comment:d})=>!n.has(d.id)).map(({comment:d},v)=>({comment:d,position:s.length+v,canEdit:!1,canDiscard:!0})),i=[...s,...r].map((d,v)=>({...d,position:v}));if(i.length===0)return null;const o=r.length===0,u=!!e.authoritativeQueue?.queueId,m=e.pendingComments.find(d=>d.targetRunId)?.targetRunId??null,p=u?e.authoritativeQueue.protocol:e.fallbackProtocol,h=u?e.authoritativeQueue?.targetRunId??null:m;return{issueId:e.authoritativeQueue?.issueId??e.issueId,queueId:o?e.authoritativeQueue?.queueId??null:null,state:e.authoritativeQueue?.state??(h?"deferred":null),targetRunId:h,revision:e.authoritativeQueue?.revision??"awaiting-server",protocol:p,steeringDisposition:(u?e.authoritativeQueue?.steeringDisposition:void 0)??(p==="wardmote_runner_v1"&&h?"temporarily_unavailable":"unsupported"),entries:i,executionWait:e.authoritativeQueue?.executionWait??null}}a(Yx,"mergePendingIssueQueuedComments");function Jx(e,s){return Promise.all([e.prefetchQuery({queryKey:R.issues.activity(s),queryFn:a(()=>zn.forIssue(s),"queryFn"),staleTime:3e4}),e.prefetchQuery({queryKey:R.issues.runs(s),queryFn:a(()=>zn.runsForIssue(s),"queryFn"),staleTime:3e4})])}a(Jx,"prefetchIssueThread");var ii="issue-detail:navigate",nu="issue-detail:header-paint",au="issue-detail:content-paint",ru="issue-detail:navigate→header-paint",iu="issue-detail:navigate→content-paint",Yr=0;function ou(){return typeof window<"u"&&typeof performance<"u"&&typeof performance.mark=="function"}a(ou,"supportsPerformanceMarks");function Xx(){if(Yr+=1,!ou())return;performance.clearMarks(ii),performance.clearMarks(nu),performance.clearMarks(au),performance.clearMeasures(ru),performance.clearMeasures(iu);const e=window.__WARDMOTE_ISSUE_DETAIL_NAVIGATE_START__;delete window.__WARDMOTE_ISSUE_DETAIL_NAVIGATE_START__,performance.mark(ii,{startTime:typeof e=="number"?e:performance.now()})}a(Xx,"beginIssueDetailNavigation");function lu(e,s){if(!ou()||performance.getEntriesByName(s).length>0)return;const n=Yr;requestAnimationFrame(()=>{n===Yr&&requestAnimationFrame(()=>{n===Yr&&(performance.getEntriesByName(s).length>0||(performance.getEntriesByName("issue-detail:navigate").length===0&&performance.mark(ii),performance.mark(e),performance.measure(s,ii,e)))})})}a(lu,"scheduleIssueDetailPaintMeasure");function Zx(e){const s=[e.savedPlan?"Workspace restore failed after the plan was saved. The saved plan is available.":"Workspace restore failed."];s.push("Workspace files need recovery."),!e.hasResponse&&e.result?.finalResponseRecorded===!1&&s.push("No final response was recorded.");const n=Jm(e.result?.workspaceRestorePath);return n&&s.push(`Affected path: ${n}.`),s.join(" ")}a(Zx,"workspaceRestoreMarkerDetail");function Vl(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}a(Vl,"object");function e0(e,s,n){if(!e||e.status!=="failed")return;const r=Vl(e.resultJson?.configurationIncomplete);if(r.selectionFailure!=="ai_connection_credential_not_shared"&&e.error!=="This credential is not shared with the responsible user")return;const i=Vl(r.credentialAccess),o=typeof r.responsibleUserId=="string"?r.responsibleUserId:e.responsibleUserId;return{agentName:e.agentName?.trim()||"This agent",credentialName:typeof i.connectionName=="string"&&i.connectionName.trim()?i.connectionName:void 0,deniedUser:o&&o===s?"you":o&&n?.get(o)||"the person this task runs for",settingsHref:`/agents/${encodeURIComponent(e.agentId)}/runtime`}}a(e0,"credentialAccessNotice");function Gl(e,s=[]){const n=new Set;return e.flatMap(r=>{if(r.action!=="project.created"||r.entityType!=="project"||n.has(r.entityId))return[];const i=r.details??{};if(typeof i.name!="string")return[];n.add(r.entityId);const o=s.find(h=>h.id===r.entityId&&h.companyId===r.companyId),u=o?o.workspaces.map(h=>({id:h.id,name:h.name,url:h.repoUrl})):i.repositories,m=new Set,p=Array.isArray(u)?u.flatMap(h=>{if(!h||typeof h!="object")return[];const d=h;return typeof d.id!="string"||typeof d.name!="string"||typeof d.url!="string"||!/^https:\/\//.test(d.url)?[]:m.has(d.url)?[]:(m.add(d.url),[{id:d.id,name:d.name,url:d.url}])}):[];return[{id:`project-created:${r.entityId}`,kind:"project_created",projectId:r.entityId,name:i.name,description:typeof i.description=="string"?i.description:null,repositories:p,timestamp:new Date(r.createdAt).toISOString()}]})}a(Gl,"projectCreatedItems");function t0(e){return e.flatMap(s=>s.isSuccess?[s.data]:[])}a(t0,"availableProjects");function s0(e,s){const n=(0,l.useMemo)(()=>Gl(e),[e]),r=rd({queries:n.map(i=>({queryKey:R.projects.detail(i.projectId),queryFn:a(()=>wi.get(i.projectId,s),"queryFn"),enabled:!!s,retry:!1})),combine:t0});return(0,l.useMemo)(()=>Gl(e,r),[e,r])}a(s0,"useProjectCreatedItems");function n0(e){const s=new Set;return e.flatMap(n=>{if(n.action!=="company.skill_created"||n.entityType!=="company_skill"||s.has(n.entityId))return[];const r=n.details??{};return typeof r.name!="string"?[]:(s.add(n.entityId),[{id:`skill-created:${n.entityId}`,kind:"skill_created",skillId:n.entityId,name:r.name,description:typeof r.description=="string"?r.description:null,slug:typeof r.slug=="string"?r.slug:null,versionId:typeof r.versionId=="string"?r.versionId:null,timestamp:new Date(n.createdAt).toISOString()}])})}a(n0,"skillCreatedItems");function ut(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}a(ut,"record$1");function ae(e){return typeof e=="string"&&e.length>0?e:null}a(ae,"text");function Un(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:0}a(Un,"finiteNumber");function Wa(e){return ut(e.item)??e}a(Wa,"normalizedItem");function a0(e){const s=Wa(e);return(ae(e.kind)??ae(s.kind)??ae(s.type)??"").replaceAll("_","").toLowerCase()}a(a0,"normalizedItemKind");function Ji(e){return e==="agentmessage"||e==="assistantmessage"}a(Ji,"isAssistantItemKind");function Yl(e,s){const n=Wa(s);return ae(e.itemId)??ae(s.itemId)??ae(n.id)}a(Yl,"normalizedItemId");function Fa(e){const s=Wa(e);return ae(e.text)??ae(s.text)}a(Fa,"normalizedItemText");function r0(e,s="unknown"){const n=Wa(e),r=ae(e.channel)??ae(n.channel);return r==="progress"||r==="final"||r==="unknown"?r:s}a(r0,"assistantChannel");function i0(e,s="unknown"){const n=Wa(e),r=ae(e.channel)??ae(n.channel);return r==="summary"||r==="detail"||r==="unknown"?r:s}a(i0,"reasoningChannel");function Jl(e,s){return{kind:a0(e)||s?.kind||"",assistantChannel:r0(e,s?.assistantChannel),reasoningChannel:i0(e,s?.reasoningChannel)}}a(Jl,"resolveItemIdentity");function Xi(e){return e==="item.started"||e==="item.delta"||e==="item.completed"}a(Xi,"isItemIdentityEvent");var o0="wardmote.tool.execution.v1",l0="wardmote.run_result.v1",c0="wardmote.prp.terminal.v1";function d0(e){const s=ut(e);return!s||s.schema!=="wardmote.question_set.v1"||!Array.isArray(s.questions)||s.questions.length===0?null:s.questions.every(n=>{const r=ut(n);return!!(r&&ae(r.id)&&ae(r.prompt)&&typeof r.required=="boolean"&&(r.answerMode==="single_select"||r.answerMode==="multi_select"||r.answerMode==="text"))})?structuredClone(s):null}a(d0,"canonicalQuestionSet");function u0(e){const s=ut(e);return s&&s.schema==="wardmote.question_response.v1"&&ut(s.answers)?structuredClone(s):null}a(u0,"canonicalQuestionResponse");function m0(e){return e==="passed"||e==="failed"?e:"not_run"}a(m0,"verificationStatus");function p0(e){const s=ut(e.payload.request)??e.payload,n=ae(s.requestId)??ae(e.payload.requestId);if(!n)return null;const r=e.eventType.split(".").at(-1),i=r==="resolved"||r==="expired"||r==="cancelled"?r:ae(s.status)??r,o=ae(s.action)??ae(e.payload.action)??e.previous?.resolvedAction??null,u=i==="resolved"||i==="expired"||i==="cancelled"?i:"pending",m=u==="resolved"&&(o==="cancel"||o==="decline")?"cancelled":u,p=ae(s.requestKind)??e.previous?.requestKind??null,h=p==="runtime"||p==="command_approval"||p==="file_approval"||p==="permission_approval"||p==="user_input"||p==="elicitation"?p:null,d=ae(s.type)??e.previous?.requestType??"permission",v=h==="user_input"||h==="elicitation"||d==="input"||d.includes("input")||d.includes("elicitation")?"input":"permission",k=(Array.isArray(s.choices)?s.choices:[]).map(ut).flatMap(E=>{const _=ae(E?.key),q=ae(E?.label);return _&&q?[{key:_,label:q}]:[]}).slice(0,32),N=ut(s.details),A=(Array.isArray(N?.fields)?N.fields:[]).map(ut).flatMap((E,_)=>{const q=ae(E?.name)??`answer_${_+1}`,O=ae(E?.label)??ae(E?.name)??`Answer ${_+1}`;return q&&O?[{name:q.slice(0,160),label:O.slice(0,240),placeholder:ae(E?.placeholder)?.slice(0,500)??null}]:[]}).slice(0,16);return{kind:"runtime_request",ts:e.ts,requestId:n,requestKind:h,turnId:ae(s.turnId)??ae(e.payload.turnId)??ae(e.envelope.turnId)??e.previous?.turnId??null,requestType:v,status:m,prompt:ae(s.prompt)??e.previous?.prompt??"Runtime approval requested",choices:k.length>0?k:e.previous?.choices??[],fields:A.length>0?A:e.previous?.fields??[],questionSet:d0(s.input)??e.previous?.questionSet??null,resolvedAction:o,response:u0(s.response??e.payload.response)??e.previous?.response??null}}a(p0,"runtimeRequestEntry");function f0(e,s){const n=ut(e.completionClaim)??{},r=ut(e.blocker),i=ae(e.reportedWorkDisposition);return{kind:"run_result",ts:s,disposition:i==="blocked"||i==="needs_review"||i==="yielded"?i:"done",summary:ae(e.summary)??"Run completed",objectiveSatisfied:typeof n.objectiveSatisfied=="boolean"?n.objectiveSatisfied:null,verification:(Array.isArray(e.verification)?e.verification:[]).map(ut).flatMap(o=>o?[{commandOrCheck:ae(o.commandOrCheck)??"Verification",status:m0(o.status),...ae(o.detail)?{detail:ae(o.detail)}:{},...ae(o.artifactRef)?{artifactRef:ae(o.artifactRef)}:{}}]:[]).slice(0,64),remainingWork:(Array.isArray(n.remainingWork)?n.remainingWork:[]).map(ut).flatMap(o=>o&&ae(o.description)?[{description:ae(o.description),blocksCompletion:o.blocksCompletion===!0}]:[]).slice(0,64),blocker:r?{reasonCode:ae(r.reasonCode)??"blocked",unblockAction:ae(r.unblockAction)??"Resolve the blocker to continue.",scope:r.scope==="task_wide"?"task_wide":"current_track"}:null,artifacts:(Array.isArray(e.artifacts)?e.artifacts:[]).map(ut).flatMap(o=>o&&ae(o.ref)?[{kind:ae(o.kind)??"artifact",ref:ae(o.ref),...ae(o.title)?{title:ae(o.title)}:{}}]:[]).slice(0,64)}}a(f0,"runResultEntry");function h0(e,s){if(e.schema!==c0)return null;const n=ae(e.turnTerminalState),r=ae(e.runTerminalState),i=ae(e.reportedWorkDisposition);if(!n||!["completed","failed","interrupted","cancelled"].includes(n)||!r||!["succeeded","failed","cancelled"].includes(r)||!i||!["done","blocked","needs_review","yielded"].includes(i))return null;const o=ut(e.stopReason);return{kind:"run_terminal",ts:s,turnState:n,runState:r,disposition:i,...ae(o?.message)||ae(o?.code)?{stopReason:ae(o?.message)??ae(o?.code)}:{}}}a(h0,"runTerminalEntry");var Xl={"plan.updated":{schema:"wardmote.plan.updated.v1",idKey:"planId",name:"plan",summaryKeys:["explanation"]},"research.started":{schema:"wardmote.research.v1",idKey:"researchId",name:"research",summaryKeys:["query","pattern","url"]},"research.progressed":{schema:"wardmote.research.v1",idKey:"researchId",name:"research",summaryKeys:["query","pattern","url"]},"research.completed":{schema:"wardmote.research.v1",idKey:"researchId",name:"research",summaryKeys:["query","pattern","url"]},"delegation.started":{schema:"wardmote.delegation.v1",idKey:"delegationId",name:"delegation",summaryKeys:["action"]},"delegation.updated":{schema:"wardmote.delegation.v1",idKey:"delegationId",name:"delegation",summaryKeys:["action"]},"delegation.completed":{schema:"wardmote.delegation.v1",idKey:"delegationId",name:"delegation",summaryKeys:["action"]},"model.route.changed":{schema:"wardmote.model.route_changed.v1",idKey:"routeId",name:"model",summaryKeys:["reason","effectiveModel"]},"model.verification.updated":{schema:"wardmote.model.verification.v1",idKey:"verificationId",name:"model",summaryKeys:["summary"]},"context.compacted":{schema:"wardmote.context.compacted.v1",idKey:"compactionId",name:"context",summaryKeys:["reason"]},"artifact.viewed":{schema:"wardmote.artifact.viewed.v1",idKey:"artifactId",name:"artifact",summaryKeys:["title","reference"]},"artifact.generated":{schema:"wardmote.artifact.generated.v1",idKey:"artifactId",name:"artifact",summaryKeys:["failure","reference"]},"review.mode.changed":{schema:"wardmote.review.mode_changed.v1",idKey:"reviewId",name:"review",summaryKeys:["scope","state"]},"hook.started":{schema:"wardmote.hook.v1",idKey:"hookId",name:"hook",summaryKeys:["summary","event"]},"hook.completed":{schema:"wardmote.hook.v1",idKey:"hookId",name:"hook",summaryKeys:["summary","event"]},"memory.citation.referenced":{schema:"wardmote.memory.citation.v1",idKey:"citationId",name:"memory",summaryKeys:["label"]},"safety.review.started":{schema:"wardmote.safety.review.v1",idKey:"reviewId",name:"safety",summaryKeys:["summary","decision"]},"safety.review.completed":{schema:"wardmote.safety.review.v1",idKey:"reviewId",name:"safety",summaryKeys:["summary","decision"]},"terminal.input.sent":{schema:"wardmote.terminal.input_sent.v1",idKey:"executionId",name:"terminal",summaryKeys:["inputClass"]},"wait.started":{schema:"wardmote.wait.v1",idKey:"waitId",name:"wait",summaryKeys:["reason"]},"wait.completed":{schema:"wardmote.wait.v1",idKey:"waitId",name:"wait",summaryKeys:["reason"]},"provider.notice.recorded":{schema:"wardmote.provider.notice.v1",idKey:"noticeId",name:"Provider notice",summaryKeys:["summary"]}},g0=new Set(["running","pending","in_progress","waiting"]),x0=new Set(["completed","failed","cancelled","interrupted","closed","denied"]);function y0(e,s){if(!Object.prototype.hasOwnProperty.call(Xl,e.eventType))return null;const n=Xl[e.eventType];if(!n||s.schema!==n.schema)return null;const r=ae(s[n.idKey]);if(!r)return null;const i=n.summaryKeys.map(p=>ae(s[p])).find(p=>p!==null)??e.eventType,o=ae(s.status),u=o==="failed"||o==="denied"||s.severity==="error",m=u?!0:g0.has(o??"")?!1:x0.has(o??"")||e.eventType.endsWith(".completed")||e.eventType.endsWith(".failed")||!e.eventType.endsWith(".started")&&!e.eventType.endsWith(".progressed");return{id:`${e.eventType.split(".")[0]}:${r}`,name:n.name,summary:i,terminal:m,failed:u}}a(y0,"providerActivityPresentation");function Zl(e,s){const n=ae(s.emittedAt);if(n)return n;const r=e.createdAt instanceof Date?e.createdAt.toISOString():String(e.createdAt);return Number.isNaN(Date.parse(r))?new Date(0).toISOString():r}a(Zl,"timestamp$1");function ec(e){const s=Wa(e),n=(ae(s.type)??"").replaceAll("_","").toLowerCase();return n!=="tooluse"&&n!=="toolresult"?null:{id:n==="toolresult"?ae(s.tool_use_id)??ae(s.id):ae(s.id),kind:n,details:{name:ae(s.name),...Object.prototype.hasOwnProperty.call(s,"input")?{input:s.input}:{},...Object.prototype.hasOwnProperty.call(s,"result")?{result:s.result}:{},isError:s.isError===!0||s.is_error===!0}}}a(ec,"nativeToolItemDetails");function tc(e){if(e.result===void 0)return"";try{return JSON.stringify(e.result)??""}catch{return"Tool result could not be serialized"}}a(tc,"serializedNativeToolResult");function sc(e,s){const n=ae(e.transport),r=ae(e.operation),i=ae(e.name)??s?.name??null;return n==="process"?{name:"Bash",input:i?{command:i}:{operation:r??"execute"}}:{name:i??r??"Tool",input:s?.input??{...r?{operation:r}:{},...ae(e.namespace)?{namespace:ae(e.namespace)}:{},...ae(e.target)?{target:ae(e.target)}:{}}}}a(sc,"toolPresentation");function v0(e){const s=[],n=new Set,r=new Set;let i=!1,o=null,u=null,m=null;const p=new Set,h=[...e].sort((S,P)=>S.seq-P.seq).filter(S=>{const P=ae(ut(S.payload?.prpEvent)?.sourceEventId);return P?p.has(P)?!1:(p.add(P),!0):!0}).flatMap(S=>{const P=ut(S.payload?.prpEvent),j=ut(P?.payload);return!P||P.eventType!==S.eventType||!/^(item|turn|session)\.(completed|failed|cancelled|interrupted|closed)$/.test(S.eventType)||!Array.isArray(j?.outputTails)?[S]:[...j.outputTails.flatMap((f,w)=>{const W=ut(f),M=ut(W?.payload);return!M||typeof M.text!="string"?[]:[{...S,eventType:"item.delta",payload:{prpEvent:{...P,eventType:"item.delta",itemId:W?.itemId,sourceEventId:`${P.sourceEventId}:output-tail:${w}`,payload:M}}}]}),S]}),d=h.some(S=>S.eventType==="run.result.accepted"),v=new Map;let k=!1,N=null;const A=new Map,E=new Map,_=new Set,q=new Set,O=new Map,F=new Map;for(const S of h){if(!Xi(S.eventType))continue;const P=ut(S.payload?.prpEvent);if(!P||P.schema!=="wardmote.prp.event.v1"||P.schemaVersion!==1||P.runId!==S.runId||P.eventType!==S.eventType)continue;const j=ut(P?.payload);if(!j)continue;const f=Yl(P,j);if(!f)continue;const w=ec(j);if(w){const $=w.id??f,K=F.get($);F.set($,{name:w.details.name??K?.name??null,...w.details.input!==void 0?{input:w.details.input}:K?.input!==void 0?{input:K.input}:{},...w.details.result!==void 0?{result:w.details.result}:K?.result!==void 0?{result:K.result}:{},isError:w.details.isError||K?.isError===!0})}const W=Jl(j,O.get(f));if(W.kind&&O.set(f,W),S.eventType!=="item.completed")continue;const M=W.kind;Ji(M)&&f&&Fa(j)&&_.add(f),M==="reasoning"&&f&&Fa(j)&&q.add(f)}const C=new Map;for(const S of h){const P=xx(S.eventType,S.payload);if(P){s.push({kind:"system",ts:Zl(S,{}),text:S.message?.trim()||P});continue}const j=ut(S.payload?.prpEvent);if(!j||j.schema!=="wardmote.prp.event.v1"||j.schemaVersion!==1||j.runId!==S.runId||j.eventType!==S.eventType)continue;const f=ut(j.payload);if(!f)continue;const w=Zl(S,j),W=Yl(j,f),M=Jl(f,W?C.get(W):void 0);W&&M.kind&&Xi(S.eventType)&&C.set(W,M);const $=M.kind;if(S.eventType==="item.delta"&&Ji($)){const y=Fa(f);if(!y||!W||_.has(W))continue;const z=M.assistantChannel;z!=="progress"&&(i=!0),s.push({kind:"assistant",ts:w,text:y,delta:!0,channel:z,itemId:W});continue}if(S.eventType==="item.completed"&&Ji($)){const y=Fa(f);if(!y)continue;const z=M.assistantChannel;z!=="progress"&&(i=!0),s.push({kind:"assistant",ts:w,text:y,channel:z,...W?{itemId:W}:{}});continue}if(S.eventType==="item.delta"&&$==="reasoning"){const y=Fa(f);if(!y||!W||q.has(W))continue;s.push({kind:"thinking",ts:w,text:y,delta:!0,lifecycle:"started",channel:M.reasoningChannel,itemId:W});continue}if(S.eventType==="item.completed"&&$==="reasoning"){const y=Fa(f);if(!y)continue;s.push({kind:"thinking",ts:w,text:y,lifecycle:"completed",channel:M.reasoningChannel,...W?{itemId:W}:{}});continue}const K=Xi(S.eventType)?ec(f):null;if(K){const y=K.id??W;if(!y)continue;const z=F.get(y)??K.details,se=sc({},z);n.has(y)||(n.add(y),s.push({kind:"tool_call",ts:w,name:se.name,input:se.input,toolUseId:y})),S.eventType==="item.completed"&&(K.kind==="toolresult"||K.details.result!==void 0)&&!r.has(y)&&(r.add(y),s.push({kind:"tool_result",ts:w,toolUseId:y,toolName:se.name,content:tc(z),isError:z.isError}));continue}if(S.eventType==="provider.notice.recorded"&&f.schema==="wardmote.provider.notice.v1"){if(Dm(S.eventType,f))continue;s.push({kind:"provider_activity",ts:w,family:"provider_notice",eventType:S.eventType,status:f.severity==="error"?"failed":"informational",title:"Provider notice",summary:ae(f.summary)?.trim()||ae(f.message)?.trim()||"Provider notice",payload:f});continue}const le=y0(S,f);if(le){n.has(le.id)||(n.add(le.id),s.push({kind:"tool_call",ts:w,name:le.name,toolUseId:le.id,input:{eventType:S.eventType,summary:le.summary}})),le.terminal&&s.push({kind:"tool_result",ts:w,toolUseId:le.id,toolName:le.name,content:le.summary,isError:le.failed});continue}if(S.eventType==="tool.execution.started"||S.eventType==="tool.execution.completed"){if(f.schema!==o0)continue;const y=ae(f.executionId);if(!y)continue;const z=F.get(y),se=sc(f,z);if(n.has(y)||(n.add(y),s.push({kind:"tool_call",ts:w,name:se.name,input:se.input,toolUseId:y})),S.eventType==="tool.execution.completed"&&!r.has(y)){r.add(y);const de=ae(f.output)??(z?tc(z):"");s.push({kind:"tool_result",ts:w,toolUseId:y,toolName:se.name,content:de,isError:f.status==="failed"||z?.isError===!0})}continue}if(S.eventType==="usage.reported"){if(f.runDeltaAvailable!==!0){const se=ut(f.cumulative);se&&(u={ts:w,inputTokens:Un(se.inputTokens),outputTokens:Un(se.outputTokens),cachedTokens:Un(se.cacheReadTokens),costUsd:Un(se.providerCostUsd)});continue}const y=ut(f.runDelta);if(!y)continue;const z={ts:w,inputTokens:Un(y.inputTokens),outputTokens:Un(y.outputTokens),cachedTokens:Un(y.cacheReadTokens),costUsd:Un(y.providerCostUsd)};o=o?{ts:w,inputTokens:o.inputTokens+z.inputTokens,outputTokens:o.outputTokens+z.outputTokens,cachedTokens:o.cachedTokens+z.cachedTokens,costUsd:o.costUsd+z.costUsd}:z;continue}if(S.eventType.startsWith("runtime_request.")){const y=ae((ut(f.request)??f).requestId)??ae(f.requestId),z=p0({eventType:S.eventType,envelope:j,payload:f,ts:w,...y?{previous:v.get(y)}:{}});z&&(v.set(z.requestId,z),s.push(z));continue}if(S.eventType==="run.terminal"){const y=h0(f,w);y&&(s.push(y),E.set(S.runId,{entry:y,seq:S.seq,envelope:j}));continue}if(S.eventType==="run.result.proposed"||S.eventType==="run.result.accepted"){if(S.eventType==="run.result.proposed"&&d)continue;const y=S.eventType==="run.result.accepted"?ut(f.result):f;if(!y||y.schema!==l0)continue;if(S.eventType==="run.result.accepted"&&A.set(S.runId,(A.get(S.runId)??0)+1),!k){const se=f0(y,w);s.push(se);const de=ut(y.continuation),me=ae(j.sourceEventId),oe=ae(j.sourceInstanceId),ve=ae(j.normalizedSessionId);S.eventType==="run.result.accepted"&&j.sourceKind==="control_plane"&&se.disposition==="yielded"&&ae(y.summary)?.trim()&&de?.kind==="response_wake"&&ae(de.idempotencyKey)?.trim()&&Array.isArray(y.attentionRequests)&&y.attentionRequests.length===0&&me?.trim()&&oe?.trim()&&ve?.trim()&&(N={entry:se,runId:S.runId,sourceEventId:me,sourceInstanceId:oe,normalizedSessionId:ve,turnId:ae(j.turnId),seq:S.seq}),k=!0}const z=ae(y.summary);!i&&z&&!m&&(m={ts:w,text:z});continue}}if(N){const S=N,P=E.get(S.runId);A.get(S.runId)===1&&P&&P.seq>S.seq&&P.envelope.sourceKind==="control_plane"&&ae(P.envelope.sourceEventId)?.trim()&&P.envelope.sourceInstanceId===S.sourceInstanceId&&P.envelope.normalizedSessionId===S.normalizedSessionId&&ae(P.envelope.turnId)===S.turnId&&P.entry.runState==="succeeded"&&P.entry.turnState==="completed"&&P.entry.disposition==="yielded"&&![...v.values()].some(j=>j.status==="pending")&&(S.entry.acceptedResponseWake={runId:S.runId,sourceEventId:S.sourceEventId})}return!i&&m&&s.push({kind:"assistant",ts:m.ts,text:m.text,channel:"final"}),o?s.push({kind:"result",...o,text:"",subtype:"wardmote_runner_usage",isError:!1,errors:[]}):u&&s.push({kind:"result",...u,text:"Provider-reported session-cumulative usage; a per-run delta was unavailable.",subtype:"wardmote_runner_session_usage",isError:!1,errors:[]}),s}a(v0,"nativeRunEventsToTranscript");var nc=1e3,b0=2e3;function k0(e){return e==="queued"||e==="running"}a(k0,"isLive");function w0(e){const s=e.filter(A=>A.runtimeMode==="native").map(A=>`${A.id}:${A.status}`).sort().join(","),n=(0,l.useMemo)(()=>e.filter(A=>A.runtimeMode==="native").map(A=>({...A})),[s]),[r,i]=(0,l.useState)(new Map),[o,u]=(0,l.useState)(new Map),[m,p]=(0,l.useState)(new Set),[h,d]=(0,l.useState)(0),v=(0,l.useCallback)(()=>d(A=>A+1),[]),k=(0,l.useRef)(new Map),N=(0,l.useRef)(new Map);return(0,l.useEffect)(()=>{let A=!1;const E=new AbortController,_=new Set,q=new Set(n.map(C=>C.id)),O=a(C=>{const S=new Map([...C].filter(([P])=>q.has(P)));return S.size===C.size?C:S},"retainMap");i(O),u(O),p(C=>{const S=new Set([...C].filter(P=>q.has(P)));return S.size===C.size?C:S});for(const C of N.current.keys())q.has(C)||N.current.delete(C);const F=a(async C=>{let S=!1;try{let P=N.current.get(C.id)??0;const j=[];for(;;){const f=await Zg(M=>vs.events(C.id,P,nc,{signal:M}),E.signal);if(A)return;const w=f.at(-1),W=w?Math.max(P,w.seq):P;if(j.push(...f.filter(M=>M.seq>P)),f.length<nc||W===P){P=W;break}P=W}N.current.set(C.id,P),j.length>0&&i(f=>{const w=new Map(f);return w.set(C.id,[...f.get(C.id)??[],...j]),w}),u(f=>{if(!f.has(C.id))return f;const w=new Map(f);return w.delete(C.id),w})}catch(P){if(A)return;S=!0,u(j=>{if(j.has(C.id))return j;const f=new Map(j);return f.set(C.id,{message:P instanceof Error?P.message:"Native run activity could not be loaded",failedAt:new Date().toISOString()}),f})}if(!A&&(p(P=>P.has(C.id)?P:new Set([...P,C.id])),k0(C.status)||S)){const P=window.setTimeout(()=>{_.delete(P),F(C)},b0);_.add(P)}},"refreshRun");for(const C of n)F(C);return()=>{A=!0,E.abort();for(const C of _)window.clearTimeout(C)}},[n,h]),{transcriptByRun:(0,l.useMemo)(()=>{const A=new Map;for(const E of n){const _=r.get(E.id);if(!_)continue;let q=k.current.get(E.id);(!q||q.events!==_)&&(q={events:_,transcript:v0(_)},k.current.set(E.id,q)),A.set(E.id,q.transcript)}for(const E of k.current.keys())A.has(E)||k.current.delete(E);return A},[r,n]),errorsByRun:o,hydratedRunIds:m,retry:v,isInitialHydrating:n.some(A=>!m.has(A.id))}}a(w0,"useNativeRunTranscripts");function j0({items:e,turnId:s="turn",emptyMessage:n,excludeFinal:r=!1,onRuntimeRequestDecision:i}){const o=(0,l.useMemo)(()=>{const u=r?e.filter(h=>h.kind!=="message"||h.interstitial):e,m=Gd(u,!0,s),p=yd(m.filter(h=>h.kind==="activity_phase"));return m.map(h=>I0(h,p,i)).filter(h=>h!=null)},[e,r,i,s]);return o.length===0?n?(0,t.jsx)("div",{className:"px-1 py-1 text-xs text-ink-3/70",children:n}):null:(0,t.jsx)("div",{className:"flex flex-col gap-2",children:o})}a(j0,"TaskChatLiveTail");function I0(e,s,n){switch(e.kind){case"message":return e.text.trim()?(0,t.jsx)("div",{className:"px-1 text-sm text-ink/90","data-testid":"task-chat-live-text",children:(0,t.jsx)(bs,{softBreaks:!0,linkIssueReferences:!0,children:e.text})},e.id):null;case"tool":return(0,t.jsx)("div",{children:(0,t.jsx)(Of,{item:e})},e.id);case"usage":return(0,t.jsx)("div",{children:(0,t.jsx)(lf,{item:e})},e.id);case"thinking":return(0,t.jsx)(Uf,{item:e},e.id);case"activity_phase":return(0,t.jsx)(vd,{item:e,openActivityIds:s},e.id);case"todo":return(0,t.jsx)(Fd,{item:e},e.id);case"protocol":return(0,t.jsx)($o,{item:e,onRuntimeRequestDecision:n},e.id);default:return null}}a(I0,"renderTailRow");function or(e){return e.authorAgentId??e.derivedAuthorAgentId??null}a(or,"effectiveAgentId");function N0(e){return e.presentation?.kind==="system_notice"||e.authorType==="system"?"system":or(e)?"agent":e.authorType==="user"?"human":"agent"}a(N0,"authorKind");function el(e){if(!e)return;const s=e instanceof Date?e:new Date(e);if(!Number.isNaN(s.getTime()))return s.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}a(el,"formatTaskChatTimestamp");function S0(e,s){return el(e.createdAt)}a(S0,"formatTaskChatCommentTimestamp");function C0(e,s={}){const n=[];for(const r of e){if(r.deletedAt)continue;if(r.conversationSessionGeneration!=null){n.push({id:r.id,kind:"marker",variant:"session_start",label:"New session",detail:"Earlier messages and files are still available.",createdAtIso:new Date(r.createdAt).toISOString()});continue}const i=N0(r);let o,u,m;const p=i==="human"?Ag({authorUserId:r.authorUserId,authorName:r.authorUserId?s.userLabelMap?.get(r.authorUserId):null,currentUserId:s.currentUserId,userProfileMap:s.userProfileMap}):void 0;if(i==="agent"){const N=or(r);o=N&&s.agentMap?.get(N)?.name||"Agent",u=N?s.agentMap?.get(N)?.icon:void 0,m=Yg({authorAgentId:N,onBehalfOfUserId:r.onBehalfOfUserId??null,issueAssigneeAgentId:s.issueAssigneeAgentId,resolveUserLabel:a(A=>s.userLabelMap?.get(A),"resolveUserLabel")})?.userName}else i==="human"&&(o=p.authorName);const h=r.queueState==="queued"||r.clientStatus==="queued",d=h?"queued":r.clientStatus==="pending"?"pending":void 0,v=r.createdAt instanceof Date?r.createdAt.toISOString():r.createdAt?String(r.createdAt):void 0,k=r.createdByRunId??r.runId??r.derivedCreatedByRunId??null;n.push({id:r.id||r.clientId||`${r.createdAt}`,renderKey:r.clientId??r.id,kind:"message",author:i,authorName:o,...p?{authorUserId:r.authorUserId,authorAvatarUrl:p.avatarUrl,isCurrentUser:p.isCurrentUser}:{},agent:or(r)?s.agentMap?.get(or(r))??{id:or(r)}:void 0,text:r.body,origin:r.origin??"comment",sourceChannel:i==="human"?r.metadata?.sourceChannel:void 0,timestamp:S0(r,i),optimistic:d,queueTargetRunId:h?r.queueTargetRunId??null:null,verificationCaveats:k?s.verificationCaveatsByRunId?.get(k):void 0,agentIcon:u,onBehalfOfUserName:m,presentation:i==="system"?r.presentation??null:void 0,metadata:i==="system"?r.metadata??null:void 0,runAgentId:i==="system"?r.runAgentId??null:void 0,createdAtIso:i==="system"?v:void 0})}return n}a(C0,"commentsToTaskChatItems");function A0(e){let s=-1;for(let n=e.length-1;n>=0;n-=1){const r=e[n];if(r.kind==="message"||r.kind==="plan_document"||r.kind==="protocol"&&(r.surface==="runtime_request"||r.surface==="run_result"||r.surface==="run_terminal")){s=n;break}}return e.slice(s+1)}a(A0,"currentActivityStatusItems");function R0(e){if(e==null||!Number.isFinite(e))return null;const s=Math.max(0,Math.floor(e/1e3));if(s<60)return`${s}s`;const n=Math.floor(s/60),r=s%60;return r===0?`${n}m`:`${n}m ${r}s`}a(R0,"formatCompactDuration");function T0(e){return e==="failed"||e==="cancelled"||e==="timed_out"||e==="interrupted"}a(T0,"terminalStatusFailed");function E0({status:e,startedAtMs:s,finishedAtMs:n,continuedAfterSteering:r=!1}){const i=xa(e);Vd(!i&&s!=null);const o=s==null?null:Math.max(0,(i?n??Date.now():Date.now())-s),u=R0(o),m=T0(e),p=i?m?"Stopped":"Worked":"Working",h=i?u?`${p} ${m?"after":"for"} ${u}`:p:`${p} for ${u??"0s"}`,d=r?`Continued after steering · ${h}`:h,v=o==null?p:`${p} ${m?"after":"for"} ${o<6e4?"less than a minute":`${Math.max(1,Math.round(o/6e4))} minutes`}`;return(0,t.jsxs)("span",{className:"min-w-0 truncate text-sm font-normal text-ink-3","data-testid":"task-chat-turn-status-header","data-turn-position":"identity","aria-live":"polite","aria-atomic":"true",children:[(0,t.jsx)("span",{"aria-hidden":"true",children:d}),(0,t.jsxs)("span",{className:"sr-only",children:[r?"Continued after steering. ":"",v]})]})}a(E0,"RunnerTurnStatus");function _0({status:e}){return xa(e)?null:(0,t.jsx)("div",{className:"mt-2 flex min-h-8 min-w-0 items-center gap-2 px-1 py-1 text-xs text-ink-3","data-testid":"task-chat-current-activity","data-turn-position":"tail",children:(0,t.jsx)("span",{className:"shimmer-text shimmer-text-muted","aria-live":"polite","data-testid":"task-chat-current-activity-label",children:"Thinking"})})}a(_0,"RunnerCurrentActivityTail");function q0({runId:e,turnId:s=e??"turn",agentName:n,agentIcon:r,agent:i,items:o,status:u,startedAtMs:m,finishedAtMs:p,activityUnavailable:h=!1,suppressFinal:d=!1,continuedAfterSteering:v=!1,onRuntimeRequestDecision:k}){const N=xa(u),A=(0,l.useMemo)(()=>{const w=d?void 0:ir(o,{allowFallback:N});return{timelineItems:Io(o),yielded:o.some(W=>W.kind==="protocol"&&W.surface==="run_result"&&W.disposition==="yielded"),observedFinal:w,observedProviderText:!!(w&&o.some(W=>W.kind==="message"&&W.id===w.id&&W.channel!=="progress"))}},[o,d,N]),{observedFinal:E,observedProviderText:_}=A,q=(0,l.useRef)({runId:e});q.current.runId!==e&&(q.current={runId:e}),(A.yielded||d)&&(q.current={runId:e}),E&&(!q.current.item||_&&!q.current.providerText||_===!!q.current.providerText&&E.text.length>=q.current.item.text.length)&&(q.current.item=E,q.current.providerText=_);const O=q.current.item,F=O?.text,C=(0,l.useMemo)(()=>s??e??"turn",[s,e]),S=(0,l.useMemo)(()=>A0(A.timelineItems),[A]),P=(0,l.useMemo)(()=>Gd(kx(A.timelineItems,F),!N,C),[A,F,N,C]),j=(0,l.useMemo)(()=>yd(N?[]:P.filter(w=>w.kind==="activity_phase")),[P,N]),f=(0,l.useMemo)(()=>P.length===0?null:(0,t.jsx)("div",{className:"flex min-w-0 flex-col gap-2 py-1","data-testid":"task-chat-turn-timeline",children:P.map(w=>(0,t.jsx)("div",{className:"min-w-0","data-testid":"task-chat-turn-timeline-row","data-timeline-row-id":w.id,"data-thread-anchor":w.id,children:w.kind==="activity_phase"?(0,t.jsx)(vd,{item:w,openActivityIds:j}):w.kind==="plan_document"?(0,t.jsx)(ei,{source:{kind:"saved",document:w.document},testId:w.placement==="fallback"?"task-chat-plan-preview-fallback":"task-chat-plan-preview"}):w.kind==="todo"?(0,t.jsx)(Fd,{item:w}):w.kind==="protocol"?(0,t.jsx)($o,{item:w,onRuntimeRequestDecision:k}):null},`${e??"run"}:${w.id}`))}),[P,e,k,j]);return(0,t.jsxs)("div",{className:"flex min-w-0 flex-col","data-testid":"task-chat-runner-turn","data-phase":u==="queued"?"startup":void 0,children:[(0,t.jsxs)("div",{className:ue("flex min-h-8 min-w-0 items-center gap-2",u==="queued"?"pb-1":"pb-1 pt-2"),"data-testid":"task-chat-runner-identity-row",children:[n?(0,t.jsx)(Wf,{agentName:n,agentIcon:r,agent:i}):null,(0,t.jsx)(E0,{status:u,startedAtMs:m,finishedAtMs:p,continuedAfterSteering:v})]}),h?(0,t.jsx)("div",{className:"px-1 py-1 text-xs text-ink-3",role:"status","data-testid":"task-chat-activity-unavailable",children:"Live runner activity is temporarily unavailable. Retrying…"}):null,f,O?(0,t.jsx)("div",{className:"w-full","data-testid":"task-chat-final-response",children:(0,t.jsx)($f,{item:{...O,authorName:n??void 0,agentIcon:r,agent:i,timestamp:O.timestamp??el(O.atMs)},animateEntry:!1,hideAgentIdentity:!v,actions:(0,t.jsx)(Dd,{copyText:O.text})})}):null,!O&&S.length===0?(0,t.jsx)(_0,{status:u}):null]})}a(q0,"TaskChatRunnerTurn");function M0(e){let s=null,n=-1;for(const[r,i]of e.entries()){if(i.kind!=="protocol"||i.surface!=="provider_activity"||i.family!=="plan")continue;const o=i.transcriptIndex??r;o>=n&&(s=i,n=o)}return s}a(M0,"latestPlan");function P0(e){let s=null;for(const n of e)n.kind==="protocol"&&n.surface==="workspace_change"&&(s=n);return s}a(P0,"latestWorkspaceDiff");function F0(e){const s=e.findIndex(i=>i.status==="in_progress");if(s>=0)return s;const n=e.findIndex(i=>i.status==="blocked"||i.status==="failed");if(n>=0)return n;const r=e.findIndex(i=>i.status==="pending");return r>=0?r:Math.max(0,e.length-1)}a(F0,"currentStepIndex");function D0(e){const s=[],n=M0(e);n&&n.steps.length>0&&s.push({kind:"plan",steps:n.steps,currentStepIndex:F0(n.steps),complete:n.steps.every(o=>o.status==="completed")});const r=P0(e),i=r?r.totals.files||r.files.length:0;return r&&i>0&&s.push({kind:"workspace_diff",files:i,additions:r.totals.additions,deletions:r.totals.deletions}),s.length>0?{segments:s}:null}a(D0,"taskChatTurnStatusModel");function $0(e){const s=e.steps[e.currentStepIndex]?.status;return e.complete?(0,t.jsx)(di,{className:"size-4 text-(--status-task-icon-done)","aria-hidden":!0}):s==="blocked"||s==="failed"?(0,t.jsx)(ud,{className:"size-4 text-(--status-task-icon-blocked)","aria-hidden":!0}):(0,t.jsx)(It,{className:"size-4 text-(--status-agent-running) motion-safe:animate-spin","aria-hidden":!0})}a($0,"planIcon");function L0(e){return e.status==="completed"?(0,t.jsx)(di,{className:"mt-0.5 size-4 shrink-0 text-(--status-task-icon-done)","aria-hidden":!0}):e.status==="in_progress"?(0,t.jsx)(It,{className:"mt-0.5 size-4 shrink-0 text-(--status-agent-running) motion-safe:animate-spin","aria-hidden":!0}):e.status==="blocked"||e.status==="failed"?(0,t.jsx)(ud,{className:"mt-0.5 size-4 shrink-0 text-(--status-task-icon-blocked)","aria-hidden":!0}):(0,t.jsx)(Zr,{className:"mt-0.5 size-4 shrink-0 text-ink-3","aria-hidden":!0})}a(L0,"checklistIcon");function cu(e){return`${e} ${e===1?"file":"files"} changed`}a(cu,"fileCountLabel");function ac({model:e}){const s=e.segments.find(r=>r.kind==="plan"),n=e.segments.find(r=>r.kind==="workspace_diff");return(0,t.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[s?(0,t.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[$0(s),(0,t.jsxs)("span",{className:"font-mono text-sm tabular-nums","aria-live":"polite","aria-atomic":"true",children:["Step ",s.currentStepIndex+1," / ",s.steps.length,(0,t.jsxs)("span",{className:"sr-only",children:[": ",s.steps[s.currentStepIndex]?.label]})]})]}):null,s&&n?(0,t.jsx)("span",{className:"text-ink-3","aria-hidden":!0,children:"·"}):null,n?(0,t.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,t.jsx)("span",{className:"min-w-0 truncate text-sm text-ink-3",children:cu(n.files)}),n.additions!=null?(0,t.jsxs)("span",{className:"shrink-0 font-mono text-sm tabular-nums text-(--status-task-icon-done)",children:["+",n.additions]}):null,n.deletions!=null?(0,t.jsxs)("span",{className:"shrink-0 font-mono text-sm tabular-nums text-(--status-task-icon-blocked)",children:["−",n.deletions]}):null]}):null]})}a(ac,"IslandBody");function B0(e){const s=[];for(const n of e.segments)if(n.kind==="plan"){const r=n.steps[n.currentStepIndex];s.push(`Step ${n.currentStepIndex+1} of ${n.steps.length}${r?`: ${r.label}`:""}`)}else s.push(cu(n.files)),n.additions!=null&&s.push(`${n.additions} additions`),n.deletions!=null&&s.push(`${n.deletions} deletions`);return s.join(", ")}a(B0,"islandLabel");var rc="mx-auto flex min-h-10 max-w-(--sz-turn-status-island) items-center overflow-hidden rounded-full border border-line bg-bg-2/95 px-4 py-2 text-ink shadow-sm backdrop-blur",O0=100;function K0({model:e}){const s=e.segments.find(h=>h.kind==="plan"),[n,r]=(0,l.useState)(!1),[i,o]=(0,l.useState)(!1),u=(0,l.useRef)(null);(0,l.useEffect)(()=>()=>{u.current&&clearTimeout(u.current)},[]);const m=a(()=>{u.current&&clearTimeout(u.current),u.current=null},"cancelClose"),p=a(()=>{m(),!i&&(u.current=setTimeout(()=>r(!1),O0))},"scheduleClose");return s?(0,t.jsxs)(vr,{open:n,onOpenChange:a(h=>{r(h),h||o(!1)},"onOpenChange"),children:[(0,t.jsx)(xr,{asChild:!0,children:(0,t.jsx)("button",{type:"button","aria-label":B0(e),className:ue(rc,"cursor-pointer transition-colors hover:bg-bg-3/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus focus-visible:ring-offset-2 focus-visible:ring-offset-bg motion-reduce:transition-none"),"data-testid":"task-chat-turn-status-island",onPointerEnter:a(h=>{h.pointerType==="mouse"&&(m(),r(!0))},"onPointerEnter"),onPointerLeave:a(h=>{h.pointerType==="mouse"&&p()},"onPointerLeave"),onFocus:a(()=>r(!0),"onFocus"),onClick:a(h=>{h.preventDefault();const d=!i;o(d),r(d)},"onClick"),children:(0,t.jsx)(ac,{model:e})})}),(0,t.jsx)(yr,{side:"top",align:"center",sideOffset:8,className:"w-(--sz-turn-status-popover) p-2","aria-label":"Turn plan",onPointerEnter:a(h=>{h.pointerType==="mouse"&&m()},"onPointerEnter"),onPointerLeave:a(h=>{h.pointerType==="mouse"&&p()},"onPointerLeave"),onEscapeKeyDown:a(()=>o(!1),"onEscapeKeyDown"),onInteractOutside:a(()=>o(!1),"onInteractOutside"),children:(0,t.jsx)("ol",{className:"flex flex-col gap-1","aria-label":"Within-turn checklist",children:s.steps.map((h,d)=>(0,t.jsxs)("li",{className:ue("flex items-start gap-2 rounded-md px-2 py-1.5 text-sm leading-5",d===s.currentStepIndex&&"bg-bg-3",h.status==="completed"&&"text-ink-3"),"aria-current":d===s.currentStepIndex?"step":void 0,children:[L0(h),(0,t.jsx)("span",{className:"min-w-0 break-words",children:h.label})]},h.id))})})]}):(0,t.jsx)("div",{className:rc,role:"status","data-testid":"task-chat-turn-status-island",children:(0,t.jsx)(ac,{model:e})})}a(K0,"TaskChatTurnStatusIsland");function Kr(e){return e==null?NaN:new Date(e).getTime()}a(Kr,"timestamp");function ic(e){return e.status==="cancelled"&&!e.startedAt&&["execution_reconciliation_required","workspace_busy","issue_not_in_progress","issue_terminal_status"].includes(e.errorCode??"")}a(ic,"isAdmissionWait");function U0(e,s,n){const r=jo(e),i=new Map;for(const h of s){const d=i.get(h.id);i.set(h.id,{...d,...h,execution:h.execution??d?.execution})}const o=new Map,u=new Map;for(const h of i.values()){const d=Kr(h.createdAt),v=Number.isFinite(d)?d:Kr(h.startedAt);Number.isFinite(v)&&(o.set(h.agentId,Math.max(o.get(h.agentId)??-1/0,v)),ic(h)||u.set(h.agentId,Math.max(u.get(h.agentId)??-1/0,v)))}const m=a(h=>{if(r)return!0;const d=i.get(h);if(!d)return!1;if(d.execution?.successorRunId||d.execution?.phase==="completed")return!0;const v=d.resultJson?.executionWait;if(n&&v&&typeof v=="object"&&"recoveryActionId"in v&&v.recoveryActionId===n.id)return n.status==="resolved"||n.status==="cancelled";if(d.execution?.phase==="recovery_needed")return!1;const k=Kr(d.createdAt);return(Number.isFinite(k)?k:Kr(d.startedAt))<((ic(d)?o:u).get(d.agentId)??-1/0)},"isHistoricalRun");return{isHistoricalRun:m,isHistoricalNotice:a(h=>{if(h.conversationSessionGeneration!=null||h.authorType!=="system"&&h.presentation?.kind!=="system_notice")return!1;const d=h.metadata?.sourceRunId??h.createdByRunId??h.runId??h.derivedCreatedByRunId,v=h.metadata?.recovery?.actionId;return!d&&!v?!1:r?!0:v===n?.id&&n?n.status==="resolved"||n.status==="cancelled":d?m(d):!1},"isHistoricalNotice")}}a(U0,"taskChatStatusRelevance");function Q0(e){return e.filter(s=>s.kind==="marker"||s.kind==="status"?!1:s.kind==="message"?s.author!=="system":s.kind!=="protocol"?!0:s.surface==="run_terminal"||s.surface==="run_result"?!1:s.surface!=="provider_activity"||!["terminal","wait","provider_notice"].includes(s.family))}a(Q0,"withoutHistoricalRunStatus");var W0=240;function z0({brief:e}){const[s,n]=(0,l.useState)(!1),r=e.author==="human",i=e.description.trim().length>0;if(s)return(0,t.jsx)("div",{className:"tc-enter-bubble w-full rounded-lg border border-line bg-bg-2 px-2 py-1","data-testid":"task-chat-description-editor",children:(0,t.jsx)(Hd,{value:e.description,onSave:e.onSave,as:"p",className:"text-sm leading-7 text-ink",placeholder:"Add a description...",multiline:!0,defaultEditing:!0,onEditingChange:a(u=>{u||n(!1)},"onEditingChange"),mentions:e.mentions,externalReferences:e.externalReferences,imageUploadHandler:e.imageUploadHandler,onDropFile:e.onDropFile})});if(!i)return(0,t.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1.5 rounded-lg px-1 py-1.5 text-left text-sm text-ink-3/70 transition-colors hover:bg-bg-3/20 hover:text-ink-3",onClick:a(()=>n(!0),"onClick"),"data-testid":"task-chat-description-ghost",children:[(0,t.jsx)(ai,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),"Add a description..."]});const o=el(e.createdAt);return(0,t.jsxs)("div",{className:ue("tc-enter-bubble group/brief flex w-full flex-col gap-1",r?"items-end":"items-start"),"data-testid":"task-chat-description-bubble","data-author":e.author,children:[!r&&e.authorName?(0,t.jsxs)("span",{className:"flex items-center gap-2 px-1",children:[(0,t.jsx)(ur,{agent:e.agent,name:e.authorName,size:24}),(0,t.jsx)("span",{className:"text-sm font-semibold text-ink",children:e.authorName})]}):null,(0,t.jsxs)("div",{className:ue("flex w-full items-start gap-1.5",r?"flex-row-reverse":"flex-row"),children:[(0,t.jsx)("div",{className:ue("max-w-(--pct-85) break-words px-3.5 py-2 text-sm",r?"rounded-2xl rounded-br-sm bg-(--liveness-blue) text-white":"rounded-2xl rounded-bl-sm bg-(--bubble-agent) text-ink"),children:(0,t.jsx)(mx,{collapsedHeight:W0,toggleClassName:r?"text-white/80 hover:text-white hover:bg-white/10":void 0,children:(0,t.jsx)(bs,{className:r?"wardmote-markdown-on-accent":void 0,softBreaks:!0,linkIssueReferences:!0,externalReferences:e.externalReferences,children:e.description})})}),r?null:(0,t.jsx)("button",{type:"button",className:"mt-1 shrink-0 rounded-md p-1 text-ink-3 opacity-0 transition-opacity hover:bg-bg-3/50 hover:text-ink focus-visible:opacity-100 group-hover/brief:opacity-100",onClick:a(()=>n(!0),"onClick"),"aria-label":"Edit description","data-testid":"task-chat-description-edit",children:(0,t.jsx)(ai,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),o?(0,t.jsx)("span",{className:"px-1 text-(length:--text-micro) text-ink-3",children:o}):null]})}a(z0,"TaskChatDescriptionBubble");function H0(e){const s=new Set;let n=0,r=0;for(const o of e)if(o.kind==="tool_call"){if(o.toolUseId){if(s.has(o.toolUseId))continue;s.add(o.toolUseId)}lx(o.name,o.input)?n+=1:r+=1}const i=[];return n>0&&i.push(`ran ${n} command${n===1?"":"s"}`),r>0&&i.push(`called ${r} tool${r===1?"":"s"}`),i.length>0?i.join(", "):null}a(H0,"toolCountSummaryFromEntries");function V0({status:e,startedAtMs:s,finishedAtMs:n,toolSummary:r}){const i=!xa(e);Vd(i&&s!=null);const o=s==null?null:(i?Date.now():n??Date.now())-s,u=o!=null?ix(o):null,m=["failed","timed_out","cancelled","interrupted"].includes(e),p=i?"Working":m?"Stopped":"Worked",h=u?`for ${u}`:null;return(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 py-2","data-testid":"task-chat-live-run-pill",children:[(0,t.jsxs)("span",{className:"inline-flex items-center gap-2 text-sm font-medium text-ink/80",children:[i?(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center",children:(0,t.jsx)(It,{className:"size-4 animate-spin text-ink-3"})}):(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center",children:(0,t.jsx)("span",{className:ue("h-1.5 w-1.5 rounded-full",m||i?"bg-ink-3/40":"bg-emerald-500/70")})}),i?(0,t.jsx)("span",{className:ue("shimmer-text"),children:p}):p]}),h?(0,t.jsx)("span",{className:"text-xs text-ink-3/60",children:h}):null,r?(0,t.jsxs)("span",{className:"text-xs text-ink-3/40",children:["· ",r]}):null]})}a(V0,"TaskChatLiveRunPill");function G0(e){const s=new Set;for(let n=e.length-1;n>=0;n-=1){const r=e[n];if(r.kind!=="protocol"||r.surface!=="runtime_request")continue;const i=`${r.runId}:${r.requestId}`;if(!s.has(i)&&(s.add(i),r.status==="pending"))return r}return null}a(G0,"latestPendingRuntimeRequest");function Y0(e){return e.choices.some(s=>{const n=s.key.trim().toLowerCase(),r=s.label.trim().toLowerCase();return["deny","decline","reject"].includes(n)||/^(deny|decline|reject)(\b|\s)/.test(r)})}a(Y0,"runtimeRequestReplacesComposerSkip");var Ci="min-h-16 resize-y border-0 bg-bg-3/35 text-sm shadow-none focus-visible:ring-0 focus-visible:ring-offset-0",du={suggest_tasks:{fallbackTitle:"Suggested tasks",label:"Tasks",icon:bp},ask_user_questions:{fallbackTitle:"Questions",label:"Questions",icon:fd},request_confirmation:{fallbackTitle:"Confirmation",label:"Confirmation",icon:di},request_checkbox_confirmation:{fallbackTitle:"Choose options",label:"Selection",icon:Jo},request_item_verdicts:{fallbackTitle:"Review items",label:"Review",icon:Cf},connection_intent:{fallbackTitle:"Connect service",label:"Connection",icon:Mf}};function J0(e){return e.replaceAll("_"," ")}a(J0,"statusLabel$1");function Ur(e){return e==="pending"?"text-(--status-agent-running)":e==="accepted"||e==="answered"?"text-(--status-task-icon-done)":e==="rejected"||e==="failed"?"text-bad":"text-ink-3"}a(Ur,"statusTone");function X0({status:e}){return e==="pending"?(0,t.jsx)(Zr,{"aria-hidden":!0,className:ue("h-3.5 w-3.5 fill-current",Ur(e))}):e==="accepted"||e==="answered"?(0,t.jsx)(Wn,{"aria-hidden":!0,className:ue("h-3.5 w-3.5",Ur(e))}):e==="rejected"||e==="failed"?(0,t.jsx)(Qa,{"aria-hidden":!0,className:ue("h-3.5 w-3.5",Ur(e))}):(0,t.jsx)(Zr,{"aria-hidden":!0,className:ue("h-3.5 w-3.5",Ur(e))})}a(X0,"StatusIcon");function Z0({interaction:e,audienceLabel:s,presentation:n,children:r}){const i=du[e.kind],o=i.icon,u=(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,t.jsx)(o,{"aria-hidden":!0,className:"h-4 w-4 shrink-0 text-ink-3"}),(0,t.jsx)("strong",{className:"min-w-0 truncate text-sm font-medium text-ink",children:e.title??i.fallbackTitle}),e.kind==="request_confirmation"&&e.payload.target?.type==="issue_document"&&e.payload.target.key==="plan"?(0,t.jsx)(sl,{interaction:e}):null,e.status!=="pending"?(0,t.jsxs)("span",{className:"inline-flex shrink-0 items-center gap-1 text-xs capitalize text-ink-3","data-testid":"interaction-status-badge",children:[(0,t.jsx)(X0,{status:e.status}),J0(e.status)]}):null]});return(0,t.jsxs)("article",{className:ue(n==="timeline"?"overflow-hidden rounded-md border border-line bg-bg-2/60":"overflow-clip"),children:[n==="takeover"?(0,t.jsx)(yh,{children:u}):(0,t.jsx)("header",{className:"flex min-w-0 items-start gap-2 px-3 py-2.5",children:(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[u,s?(0,t.jsx)("p",{className:"mt-0.5 pl-6 text-xs text-ink-3",children:s}):null]})}),(0,t.jsx)("div",{className:n==="timeline"?"border-t border-line/70 px-3 py-3":void 0,children:r})]})}a(Z0,"InteractionShell");function Ai({message:e}){return(0,t.jsx)("div",{"aria-live":"assertive","data-testid":"interaction-action-error",children:e?(0,t.jsx)("div",{className:"mt-2 rounded-sm border border-bad/60 bg-bad/10 px-2.5 py-2 text-sm text-bad",children:e}):null})}a(Ai,"InteractionActionError");function tl({children:e}){return e?(0,t.jsxs)("details",{className:"mt-2",children:[(0,t.jsxs)("summary",{className:"flex cursor-pointer list-none items-center gap-1 text-xs font-medium text-ink-3",children:[(0,t.jsx)(br,{"aria-hidden":!0,className:"h-3.5 w-3.5"})," Details"]}),(0,t.jsx)("div",{className:"mt-2 max-h-(--sz-28dvh) overflow-y-auto overscroll-contain rounded-sm bg-bg-3/40 px-2.5 py-2 text-sm text-ink-3 scrollbar-auto-hide",children:e})]}):null}a(tl,"Details");function Ri({children:e,hint:s}){const n=_m();return(0,t.jsxs)("fieldset",{disabled:n,title:n?Mm:void 0,className:"m-0 mt-3 flex min-w-0 flex-wrap items-center gap-2 border-0 p-0","data-slot":"task-chat-takeover-actions",children:[s?(0,t.jsx)("span",{className:"mr-auto text-xs text-ink-3",children:s}):(0,t.jsx)("span",{className:"mr-auto"}),e]})}a(Ri,"ActionRow");function ey(e){const s=e.payload.target;return s?[s.label??(s.type==="issue_document",s.key),s.revisionNumber==null?null:`v${s.revisionNumber}`].filter(Boolean).join(" · "):null}a(ey,"targetLabel");function sl({interaction:e}){const s=e.payload.target,n=ey(e);if(!s||!n)return null;const r=s.href?_d(s.href):null;return r?(0,t.jsx)("a",{href:r,className:"inline-flex rounded-sm border border-line px-2 py-0.5 font-mono text-xs text-ink hover:bg-bg-3/60",children:n}):(0,t.jsx)("span",{className:"inline-flex rounded-sm border border-line px-2 py-0.5 font-mono text-xs text-ink-3",children:n})}a(sl,"CompactTarget");function uu({interaction:e,planDocument:s}){const n=e.payload.target;if(n?.type!=="issue_document"||n.key!=="plan")return null;const r=n.revisionId??null,i=n.revisionNumber??null,o=!!(s&&(r!=null?s.latestRevisionId===r:i==null||s.latestRevisionNumber===i));return(0,t.jsx)(ei,{source:{kind:"saved",document:o?s:null,revision:i,fallbackTitle:n.label},href:"#document-plan",testId:"plan-review-preview",ariaLabel:`Open ${n.label??(i==null?"plan":`plan revision ${i}`)}`})}a(uu,"PlanReviewPreview");function ty(e){const s=e.result;return s?"reason"in s&&typeof s.reason=="string"?s.reason:e.kind==="ask_user_questions"?e.result?.cancellationReason??e.result?.expirationReason?.replaceAll("_"," ")??null:null:null}a(ty,"receiptReason");function oc({interaction:e,externalReferences:s,compact:n=!1}){const r=ty(e)??(e.kind==="suggest_tasks"?e.result?.rejectionReason??null:null);let i;if(e.kind==="ask_user_questions"){const u=mu(e),m=pu(e,u);i=(0,t.jsxs)("div",{className:"grid gap-3",children:[u.description?(0,t.jsx)("div",{className:"text-sm text-ink-3",children:(0,t.jsx)(Ds,{children:u.description})}):null,u.questions.map(p=>{const h=m?.answers[p.id],d=e.result?.answers.find(k=>k.questionId===p.id)?.note,v=[...(h?.selectedOptionIds??[]).map(k=>p.options?.find(N=>N.id===k)?.label??k),h?.text,h?.customText].filter(k=>!!k);return(0,t.jsxs)("div",{children:[p.header?(0,t.jsx)("p",{className:"text-xs font-medium text-ink-3",children:p.header}):null,(0,t.jsx)("div",{className:"text-sm text-ink",children:(0,t.jsx)(Ds,{children:p.prompt})}),p.helpText?(0,t.jsx)("div",{className:"mt-0.5 text-xs text-ink-3",children:(0,t.jsx)(Ds,{children:p.helpText})}):null,(0,t.jsxs)("div",{className:"mt-1 flex gap-1 text-sm font-medium text-ink",children:[(0,t.jsx)("span",{className:"shrink-0",children:"Answer:"}),v.length>0?(0,t.jsx)(Ds,{className:"min-w-0 flex-1",children:v.join(", ")}):(0,t.jsx)("span",{children:"No answer"})]}),(0,t.jsx)(Ui,{note:d,externalReferences:s,className:"mt-1"})]},p.id)})]})}else if(e.kind==="request_checkbox_confirmation"){const u=new Set(e.result?.selectedOptionIds??[]),m=e.payload.options.filter(p=>u.has(p.id)).map(p=>p.label);i=(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm text-ink",children:(0,t.jsx)(Ds,{children:e.payload.prompt})}),e.status==="accepted"?(0,t.jsxs)("div",{className:"mt-1 flex gap-1 text-sm font-medium text-ink",children:[(0,t.jsx)("span",{className:"shrink-0",children:"Answer:"}),m.length>0?(0,t.jsx)(Ds,{className:"min-w-0 flex-1",children:m.join(", ")}):(0,t.jsx)("span",{children:"No options selected"})]}):null,(0,t.jsx)(Ui,{note:e.result?.note,externalReferences:s,className:"mt-1"}),e.payload.detailsMarkdown?(0,t.jsx)("div",{className:"mt-2 text-sm",children:(0,t.jsx)(bs,{externalReferences:s,children:e.payload.detailsMarkdown})}):null]})}else if(e.kind==="request_item_verdicts"){const u=new Map((e.result?.items??[]).map(p=>[p.id,p])),m=e.payload.items.filter(p=>u.has(p.id));i=(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm text-ink",children:e.payload.prompt}),m.length>0?(0,t.jsx)("ul",{className:"mt-2 grid gap-1 text-sm",children:m.map(p=>{const h=u.get(p.id);return(0,t.jsxs)("li",{children:[(0,t.jsx)("span",{className:"font-medium",children:p.label})," ·"," ",h?.verdict,h?.reason?` — ${h.reason}`:""]},p.id)})}):(0,t.jsx)("p",{className:"mt-1 text-sm font-medium text-ink",children:"No verdicts submitted"}),e.payload.detailsMarkdown?(0,t.jsx)("div",{className:"mt-2 text-sm",children:(0,t.jsx)(bs,{externalReferences:s,children:e.payload.detailsMarkdown})}):null]})}else if(e.kind==="suggest_tasks"){const u=new Set(e.result?.createdTasks?.map(p=>p.clientKey)??[]),m=e.payload.tasks.filter(p=>u.has(p.clientKey));i=(0,t.jsx)("div",{children:m.length>0?(0,t.jsx)("ul",{className:"grid gap-1 text-sm",children:m.map(p=>(0,t.jsx)("li",{className:"font-medium",children:p.title},p.clientKey))}):e.status==="accepted"?(0,t.jsx)("p",{className:"text-sm font-medium text-ink",children:"No tasks created"}):null})}else e.kind==="connection_intent"?i=(0,t.jsxs)("p",{className:"text-sm text-ink",children:[e.payload.requestingAgentName," requested access to"," ",e.payload.serviceName,"."]}):i=(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)("div",{className:"text-sm text-ink",children:(0,t.jsx)(Ds,{children:e.payload.prompt})}),(0,t.jsx)(Ui,{note:e.result?.note,externalReferences:s}),e.payload.detailsMarkdown?(0,t.jsx)("div",{className:"text-sm",children:(0,t.jsx)(bs,{externalReferences:s,children:e.payload.detailsMarkdown})}):null,e.payload.toolAction?(0,t.jsxs)("div",{className:"rounded-sm bg-bg-3/45 px-3 py-2.5 text-sm",children:[(0,t.jsxs)("p",{children:[(0,t.jsx)("strong",{children:e.payload.toolAction.toolDisplayName})," ","· ",e.payload.toolAction.risk," risk"]}),(0,t.jsxs)("p",{className:"mt-1",children:["Expires"," ",new Date(e.payload.toolAction.expiresAt).toLocaleString()]}),(0,t.jsx)("div",{className:"mt-2",children:(0,t.jsx)(bs,{externalReferences:s,children:e.payload.toolAction.previewMarkdown})}),(0,t.jsx)("pre",{className:"mt-2 max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-xs",children:e.payload.toolAction.argumentsSummaryJson}),(0,t.jsx)("p",{className:"mt-1 break-all font-mono text-xs text-ink-3",children:e.payload.toolAction.argumentsHash})]}):null,e.payload.secretProposal?(0,t.jsxs)("dl",{className:"grid gap-1 rounded-sm bg-bg-3/45 px-3 py-2.5 text-sm",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs text-ink-3",children:"Secret"}),(0,t.jsx)("dd",{children:e.payload.secretProposal.sourceSecretLabel})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs text-ink-3",children:"Binding"}),(0,t.jsxs)("dd",{className:"font-mono text-xs",children:[e.payload.secretProposal.configPath," →"," ",e.payload.secretProposal.targetAgentName]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs text-ink-3",children:"Why"}),(0,t.jsx)("dd",{children:e.payload.secretProposal.justification})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs text-ink-3",children:"Expires"}),(0,t.jsx)("dd",{children:new Date(e.payload.secretProposal.expiresAt).toLocaleString()})]})]}):null]});const o=(0,t.jsxs)("div",{className:n?"space-y-3 pb-3 pl-7 pr-1":"mt-2 space-y-3 border-t border-line/60 pt-3",children:[i,r?(0,t.jsxs)("div",{className:"flex gap-1 text-sm text-ink-3",children:[(0,t.jsx)("span",{className:"shrink-0 font-medium",children:"Reason:"}),(0,t.jsx)(Ds,{className:"min-w-0 flex-1",children:r})]}):null]});if(n){const u=du[e.kind].icon,m=e.kind==="ask_user_questions"&&e.status==="answered"?"Questions answered":qd(e);return(0,t.jsxs)("details",{className:"group","data-testid":e.kind==="ask_user_questions"&&e.status==="answered"?"task-chat-answered-questions-receipt":"task-chat-interaction-receipt",children:[(0,t.jsxs)("summary",{className:"flex min-h-8 cursor-pointer list-none items-center gap-2 rounded-sm px-1 py-1.5 text-sm leading-5 text-ink-3 transition-colors hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus",children:[(0,t.jsx)("span",{className:"flex w-6 shrink-0 items-center justify-center","data-testid":"task-chat-interaction-receipt-icon-slot",children:(0,t.jsx)(u,{"aria-hidden":!0,className:"h-3.5 w-3.5 shrink-0 text-ink-3","data-testid":"task-chat-interaction-receipt-icon"})}),(0,t.jsx)("span",{children:m}),(0,t.jsx)(kr,{"aria-hidden":!0,className:"ml-auto h-3 w-3 shrink-0 text-ink-3 opacity-0 transition-[opacity,transform] group-hover:opacity-70 group-focus-visible:opacity-70 group-open:rotate-90","data-testid":"task-chat-interaction-receipt-caret"})]}),o]})}return(0,t.jsxs)("details",{className:"mt-2",children:[(0,t.jsx)("summary",{className:"cursor-pointer text-xs font-medium text-ink-3",children:"View original request and resolution"}),o]})}a(oc,"ReceiptDisclosure");function mu(e){return e.payload.questionSet?e.payload.questionSet:{schema:"wardmote.question_set.v1",...e.title?{title:e.title}:{},...e.payload.submitLabel?{submitLabel:e.payload.submitLabel}:{},questions:e.payload.questions.map(s=>{const n=s.options.find(r=>r.freeText===!0);return{id:s.id,prompt:s.prompt,...s.helpText?{helpText:s.helpText}:{},required:s.required===!0,answerMode:s.selectionMode==="multi"?"multi_select":"single_select",options:s.options.filter(r=>r.freeText!==!0).map(r=>({id:r.id,label:r.label,...r.description?{description:r.description}:{}})),...n?{customAnswer:{enabled:!0,label:n.label,...n.description?{placeholder:n.description}:{}}}:{}}})}}a(mu,"questionSetForInteraction");function pu(e,s){return e.result?.answers?{schema:"wardmote.question_response.v1",answers:Object.fromEntries(e.result.answers.map(n=>{const r=s.questions.find(i=>i.id===n.questionId);return[n.questionId,r?.answerMode==="text"?{...n.otherText?{text:n.otherText}:{}}:{selectedOptionIds:n.optionIds,...n.otherText?{customText:n.otherText}:{}}]}))}:null}a(pu,"questionResponseForInteraction");function sy({interaction:e,onSubmitInteractionAnswers:s,onCancelInteraction:n,errorMessage:r,draftKey:i,onUploadImage:o,mentions:u}){const m=mu(e),p=pu(e,m);return(0,t.jsx)(jf,{id:e.id,questionSet:m,initialResponse:p,implicitCustomAnswer:e.payload.questionSet===void 0,draftKey:i,disabled:!s,imageUploadHandler:o,mentions:u,notesEnabled:Sd(e),onSubmit:a(async(h,d)=>{const v=m.questions.map(k=>{const N=h.answers[k.id],A=k.answerMode==="text"?e.payload.questionSet?N?.text:N?.text?.trim():N?.customText?.trim(),E=d[k.id];return{questionId:k.id,optionIds:k.answerMode==="text"?[]:N?.selectedOptionIds??[],...A?{otherText:A}:{},...E?{note:E}:{}}});try{await s?.(e,v)}catch(k){throw new Error(r(k))}},"onSubmit"),onCancel:n?async()=>{try{await n(e)}catch(h){throw new Error(r(h))}}:void 0})}a(sy,"AskUserQuestionsCard");function ny({interaction:e,planDocument:s,onAcceptInteraction:n,onRejectInteraction:r,externalReferences:i,errorMessage:o,draftKey:u,showPlanPreview:m,onUploadImage:p,mentions:h}){const d=Rd(e),v=Sd(e),[k,N]=(0,l.useState)(!1),[A]=(0,l.useState)(()=>{const y=u?Si(u,""):"";return typeof y=="string"?{reason:y,note:""}:{reason:y.reason??"",note:y.note??""}}),[E,_]=(0,l.useState)(A.reason),[q,O]=(0,l.useState)(A.note),[F,C]=(0,l.useState)(null),[S,P]=(0,l.useState)(null),[j,f]=(0,l.useState)(!1),[w,W]=(0,l.useState)(!1),M=v&&(w||Cd(q)),$=!!(e.payload.rejectRequiresReason||e.payload.allowDeclineReason||e.payload.declineReasonPlaceholder),K=e.payload.target?.type==="issue_document"&&e.payload.target.key==="plan";(0,l.useEffect)(()=>{u&&Ii(u,{reason:E,note:q})},[u,q,E]);async function le(y){if(y==="reject"&&e.payload.rejectRequiresReason&&!E.trim()||M)return;const z=v?Id(q):void 0;C(y),P(null);try{y==="accept"?await(z?n?.(e,void 0,void 0,void 0,z):n?.(e)):await(z?r?.(e,E.trim()||void 0,z):r?.(e,E.trim()||void 0)),u&&Ni(u)}catch(se){P(o(se))}finally{C(null)}}return a(le,"resolve"),(0,t.jsxs)("div",{children:[K&&m?(0,t.jsx)(uu,{interaction:e,planDocument:s}):K&&k?null:(0,t.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[(0,t.jsx)("div",{className:"min-w-0 flex-1 text-sm leading-5 text-ink",children:K?"Do you accept this plan?":(0,t.jsx)(Ds,{children:e.payload.prompt})}),K?null:(0,t.jsx)(sl,{interaction:e})]}),!K&&e.payload.detailsMarkdown?(0,t.jsx)(tl,{children:(0,t.jsx)(bs,{externalReferences:i,children:e.payload.detailsMarkdown})}):null,e.payload.toolAction?(0,t.jsxs)("div",{className:"mt-3 space-y-2 rounded-sm bg-bg-3/45 px-3 py-2.5 text-sm",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("strong",{children:e.payload.toolAction.toolDisplayName}),(0,t.jsxs)("span",{className:ue("text-xs font-medium capitalize",e.payload.toolAction.risk==="destructive"?"text-bad":"text-ink-3"),children:[e.payload.toolAction.risk," risk"]}),(0,t.jsxs)("span",{className:"ml-auto text-xs text-ink-3",children:["Expires"," ",new Date(e.payload.toolAction.expiresAt).toLocaleString()]})]}),(0,t.jsx)(bs,{externalReferences:i,children:e.payload.toolAction.previewMarkdown}),(0,t.jsxs)("details",{children:[(0,t.jsx)("summary",{className:"cursor-pointer text-xs font-medium text-ink-3",children:"Arguments and audit hash"}),(0,t.jsx)("pre",{className:"mt-2 max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-xs text-ink",children:e.payload.toolAction.argumentsSummaryJson}),(0,t.jsx)("p",{className:"mt-1 break-all font-mono text-xs text-ink-3",children:e.payload.toolAction.argumentsHash})]})]}):null,e.payload.secretProposal?(0,t.jsxs)("dl",{className:"mt-3 grid gap-2 rounded-sm bg-bg-3/45 px-3 py-2.5 text-sm",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs text-ink-3",children:"Secret"}),(0,t.jsx)("dd",{children:e.payload.secretProposal.sourceSecretLabel})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs text-ink-3",children:"Binding"}),(0,t.jsxs)("dd",{className:"font-mono text-xs",children:[e.payload.secretProposal.configPath," →"," ",e.payload.secretProposal.targetAgentName]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs text-ink-3",children:"Why"}),(0,t.jsx)("dd",{children:e.payload.secretProposal.justification})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs text-ink-3",children:"Expires"}),(0,t.jsx)("dd",{children:new Date(e.payload.secretProposal.expiresAt).toLocaleString()})]})]}):null,k?(0,t.jsxs)("div",{className:ue("space-y-2",!K&&"mt-3"),children:[(0,t.jsxs)("p",{id:`${e.id}-reject-reason-label`,className:"text-xs font-medium leading-4 text-ink",children:[e.payload.rejectReasonLabel??"What should change?",e.payload.rejectRequiresReason?"":" (optional)"]}),K?(0,t.jsx)(wf,{value:E,onChange:_,placeholder:e.payload.declineReasonPlaceholder??"Describe what should change",imageUploadHandler:p,mentions:h,disabled:F!==null,autoFocus:!0,onUploadingChange:f,onSubmit:a(()=>{j||le("reject")},"onSubmit"),ariaLabelledBy:`${e.id}-reject-reason-label`,testId:"plan-revision-composer",showImageAttachControls:!1}):(0,t.jsx)(va,{id:`${e.id}-reject-reason`,value:E,onChange:a(y=>_(y.target.value),"onChange"),placeholder:e.payload.declineReasonPlaceholder??"Add a short note",className:Ci,autoFocus:!0})]}):null,v?(0,t.jsx)("div",{className:"mt-3",children:(0,t.jsx)(Nd,{value:q,onChange:O,imageUploadHandler:p,mentions:h,disabled:F!==null,onUploadingChange:W})}):null,(0,t.jsx)(Ai,{message:S}),d?(0,t.jsx)(Td,{}):null,(0,t.jsx)(Ri,{children:k?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ne,{type:"button",size:"sm",variant:"ghost",disabled:F!==null,onClick:a(()=>{N(!1)},"onClick"),children:"Back"}),(0,t.jsxs)(ne,{type:"button",size:"sm",variant:"secondary",disabled:F!==null||j||M||!!e.payload.rejectRequiresReason&&!E.trim()||!r,onClick:a(()=>{le("reject")},"onClick"),children:[F==="reject"?(0,t.jsx)(It,{"aria-hidden":!0,className:"h-4 w-4 animate-spin"}):null,e.payload.rejectLabel??"Reject"]})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ne,{type:"button",size:"sm",variant:"ghost",disabled:F!==null||!r||!$&&M,onClick:a(()=>$?N(!0):void le("reject"),"onClick"),children:e.payload.rejectLabel??"Reject"}),(0,t.jsxs)(ne,{type:"button",size:"sm",disabled:F!==null||d||M||!n,onClick:a(()=>{le("accept")},"onClick"),children:[F==="accept"?(0,t.jsx)(It,{"aria-hidden":!0,className:"h-4 w-4 animate-spin"}):null,e.payload.acceptLabel??"Approve"]})]})})]})}a(ny,"ConfirmationCard");function ay({interaction:e,onAcceptInteraction:s,onRejectInteraction:n,externalReferences:r,errorMessage:i,draftKey:o,onUploadImage:u,mentions:m}){const p=o?Si(o,{selected:e.payload.defaultSelectedOptionIds??[],reason:""}):null,[h,d]=(0,l.useState)(()=>new Set(p?.selected??e.payload.defaultSelectedOptionIds??[])),v=Rd(e),[k,N]=(0,l.useState)(!1),[A,E]=(0,l.useState)(p?.reason??""),[_,q]=(0,l.useState)(p?.note??""),[O,F]=(0,l.useState)(!1),C=O||Cd(_),[S,P]=(0,l.useState)(""),[j,f]=(0,l.useState)(null),[w,W]=(0,l.useState)(null),M=!!(e.payload.rejectRequiresReason||e.payload.allowDeclineReason||e.payload.declineReasonPlaceholder),$=e.payload.minSelected??0,K=e.payload.maxSelected??Number.POSITIVE_INFINITY,le=h.size>=$&&h.size<=K,y=e.payload.options.filter(me=>{const oe=S.trim().toLowerCase();return!oe||me.label.toLowerCase().includes(oe)||me.description?.toLowerCase().includes(oe)});(0,l.useEffect)(()=>{o&&Ii(o,{selected:[...h],reason:A,note:_})},[o,_,A,h]);function z(me){d(oe=>{const ve=new Set(oe);return ve.has(me)?ve.delete(me):ve.size<K&&ve.add(me),ve})}a(z,"toggle");async function se(me){if(me==="accept"&&!le||me==="reject"&&e.payload.rejectRequiresReason&&!A.trim()||C)return;const oe=Id(_);f(me),W(null);try{me==="accept"?await(oe?s?.(e,void 0,[...h],void 0,oe):s?.(e,void 0,[...h])):await(oe?n?.(e,A.trim()||void 0,oe):n?.(e,A.trim()||void 0)),o&&Ni(o)}catch(ve){W(i(ve))}finally{f(null)}}a(se,"resolve");const de=K<Number.POSITIVE_INFINITY?`${h.size} selected · choose ${$}–${K}`:$>0?`${h.size} selected · at least ${$}`:`${h.size} selected`;return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[(0,t.jsx)("div",{className:"min-w-0 flex-1 text-sm leading-5 text-ink",children:(0,t.jsx)(Ds,{children:e.payload.prompt})}),(0,t.jsx)(sl,{interaction:e})]}),(0,t.jsxs)("div",{className:"mt-3 grid gap-1",role:"group","aria-label":e.payload.prompt,children:[e.payload.options.length>10?(0,t.jsxs)("label",{className:"relative mb-1 block",children:[(0,t.jsx)(ti,{className:"pointer-events-none absolute left-2.5 top-2.5 h-4 w-4 text-ink-3","aria-hidden":!0}),(0,t.jsx)(jr,{value:S,onChange:a(me=>P(me.target.value),"onChange"),placeholder:"Filter options","aria-label":"Filter options",className:"pl-8"})]}):null,y.map(me=>(0,t.jsxs)("label",{className:"flex cursor-pointer items-start gap-2 rounded-sm px-2 py-1.5 hover:bg-bg-3/50",children:[(0,t.jsx)(qo,{checked:h.has(me.id),onCheckedChange:a(()=>z(me.id),"onCheckedChange"),className:"mt-0.5"}),(0,t.jsxs)("span",{className:"min-w-0",children:[(0,t.jsx)("span",{className:"block text-sm leading-5 text-ink",children:(0,t.jsx)(Ds,{children:me.label})}),me.description?(0,t.jsx)("span",{className:"block text-xs leading-4 text-ink-3",children:(0,t.jsx)(Ds,{children:me.description})}):null]})]},me.id))]}),e.payload.detailsMarkdown?(0,t.jsx)(tl,{children:(0,t.jsx)(bs,{externalReferences:r,children:e.payload.detailsMarkdown})}):null,k?(0,t.jsxs)("div",{className:"mt-3 space-y-1.5",children:[(0,t.jsxs)("label",{htmlFor:`${e.id}-reject-reason`,className:"text-xs font-medium text-ink",children:[e.payload.rejectReasonLabel??"What should change?",e.payload.rejectRequiresReason?"":" (optional)"]}),(0,t.jsx)(va,{id:`${e.id}-reject-reason`,value:A,onChange:a(me=>E(me.target.value),"onChange"),placeholder:e.payload.declineReasonPlaceholder??"Add a short note",className:Ci,autoFocus:!0})]}):null,(0,t.jsx)("div",{className:"mt-3",children:(0,t.jsx)(Nd,{value:_,onChange:q,imageUploadHandler:u,mentions:m,disabled:j!==null,onUploadingChange:F})}),(0,t.jsx)(Ai,{message:w}),v?(0,t.jsx)(Td,{}):null,(0,t.jsx)(Ri,{hint:de,children:k?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ne,{type:"button",size:"sm",variant:"ghost",disabled:j!==null,onClick:a(()=>N(!1),"onClick"),children:"Back"}),(0,t.jsxs)(ne,{type:"button",size:"sm",variant:"secondary",disabled:j!==null||C||!!e.payload.rejectRequiresReason&&!A.trim()||!n,onClick:a(()=>{se("reject")},"onClick"),children:[j==="reject"?(0,t.jsx)(It,{"aria-hidden":!0,className:"h-4 w-4 animate-spin"}):null,e.payload.rejectLabel??"Decline"]})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ne,{type:"button",size:"sm",variant:"ghost",disabled:j!==null||!n||!M&&C,onClick:a(()=>M?N(!0):void se("reject"),"onClick"),children:e.payload.rejectLabel??"Decline"}),(0,t.jsxs)(ne,{type:"button",size:"sm",disabled:j!==null||v||C||!le||!s,onClick:a(()=>{se("accept")},"onClick"),children:[j==="accept"?(0,t.jsx)(It,{"aria-hidden":!0,className:"h-4 w-4 animate-spin"}):null,e.payload.acceptLabel??"Confirm selection"]})]})})]})}a(ay,"CheckboxConfirmationCard");function fu({node:e,selected:s,onToggle:n}){if(e.task.hiddenInPreview)return null;const r=Ed(e).filter(i=>i!==e.task.clientKey&&e.children.some(o=>o.task.clientKey===i&&o.task.hiddenInPreview)).length;return(0,t.jsxs)("li",{children:[(0,t.jsxs)("label",{className:"flex cursor-pointer items-start gap-2 rounded-sm px-2 py-1.5 hover:bg-bg-3/50",children:[(0,t.jsx)(qo,{checked:s.has(e.task.clientKey),onCheckedChange:a(()=>n(e),"onCheckedChange"),className:"mt-0.5"}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block text-sm leading-5 text-ink",children:e.task.title}),r>0?(0,t.jsxs)("span",{className:"block text-xs text-ink-3",children:["+ ",r," hidden follow-up"]}):null]})]}),e.children.length>0?(0,t.jsx)("ul",{className:"ml-4 border-l border-line/80 pl-2",children:e.children.map(i=>(0,t.jsx)(fu,{node:i,selected:s,onToggle:n},i.task.clientKey))}):null]})}a(fu,"SuggestedTaskRow");function ry({interaction:e,onAcceptInteraction:s,onRejectInteraction:n,errorMessage:r,draftKey:i}){const o=(0,l.useMemo)(()=>Nf(e.payload.tasks),[e.payload.tasks]),u=(0,l.useMemo)(()=>new Map(e.payload.tasks.map(j=>[j.clientKey,j])),[e.payload.tasks]),m=i?Si(i,{selected:e.payload.tasks.map(j=>j.clientKey),reason:""}):null,[p,h]=(0,l.useState)(()=>new Set(m?.selected??e.payload.tasks.map(j=>j.clientKey))),[d,v]=(0,l.useState)(!1),[k,N]=(0,l.useState)(m?.reason??""),[A,E]=(0,l.useState)(""),[_,q]=(0,l.useState)(null),[O,F]=(0,l.useState)(null);(0,l.useEffect)(()=>{i&&Ii(i,{selected:[...p],reason:k})},[i,k,p]);const C=(0,l.useMemo)(()=>{const j=A.trim().toLowerCase();if(!j)return o;function f(w){const W=w.children.map(f).filter(M=>M!==null);return w.task.title.toLowerCase().includes(j)||w.task.description?.toLowerCase().includes(j)||W.length>0?{...w,children:W}:null}return a(f,"retain"),o.map(f).filter(w=>w!==null)},[A,o]);function S(j){h(f=>{const w=new Set(f),W=Ed(j);if(w.has(j.task.clientKey))W.forEach(M=>w.delete(M));else{W.forEach($=>w.add($));let M=j.task.parentClientKey;for(;M;)w.add(M),M=u.get(M)?.parentClientKey}return w})}a(S,"toggle");async function P(j){q(j),F(null);try{j==="accept"?await s?.(e,[...p]):await n?.(e,k.trim()||void 0),i&&Ni(i)}catch(f){F(r(f))}finally{q(null)}}return a(P,"resolve"),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm leading-5 text-ink",children:"Select the tasks to create."}),e.payload.tasks.length>10?(0,t.jsxs)("label",{className:"relative mt-3 block",children:[(0,t.jsx)(ti,{className:"pointer-events-none absolute left-2.5 top-2.5 h-4 w-4 text-ink-3","aria-hidden":!0}),(0,t.jsx)(jr,{value:A,onChange:a(j=>E(j.target.value),"onChange"),placeholder:"Filter suggested tasks","aria-label":"Filter suggested tasks",className:"pl-8"})]}):null,(0,t.jsx)("ul",{className:"mt-2 max-h-(--sz-28dvh) overflow-y-auto scrollbar-auto-hide","aria-label":"Suggested tasks",children:C.map(j=>(0,t.jsx)(fu,{node:j,selected:p,onToggle:S},j.task.clientKey))}),d?(0,t.jsxs)("div",{className:"mt-3 space-y-1.5",children:[(0,t.jsx)("label",{htmlFor:`${e.id}-reject-reason`,className:"text-xs font-medium text-ink",children:"Why should these tasks change? (optional)"}),(0,t.jsx)(va,{id:`${e.id}-reject-reason`,value:k,onChange:a(j=>N(j.target.value),"onChange"),placeholder:"Add a short note",className:Ci,autoFocus:!0})]}):null,(0,t.jsx)(Ai,{message:O}),(0,t.jsx)(Ri,{hint:`${p.size} of ${e.payload.tasks.length} selected`,children:d?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ne,{type:"button",size:"sm",variant:"ghost",disabled:_!==null,onClick:a(()=>v(!1),"onClick"),children:"Back"}),(0,t.jsxs)(ne,{type:"button",size:"sm",variant:"secondary",disabled:_!==null||!n,onClick:a(()=>{P("reject")},"onClick"),children:[_==="reject"?(0,t.jsx)(It,{"aria-hidden":!0,className:"h-4 w-4 animate-spin"}):null,"Send back"]})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ne,{type:"button",size:"sm",variant:"ghost",disabled:_!==null||!n,onClick:a(()=>v(!0),"onClick"),children:"Revise"}),(0,t.jsxs)(ne,{type:"button",size:"sm",disabled:_!==null||p.size===0||!s,onClick:a(()=>{P("accept")},"onClick"),children:[_==="accept"?(0,t.jsx)(It,{"aria-hidden":!0,className:"h-4 w-4 animate-spin"}):null,"Create selected"]})]})})]})}a(ry,"SuggestedTasksCard");function iy({interaction:e,onSubmitInteractionVerdicts:s,externalReferences:n,errorMessage:r,draftKey:i}){const o=gh(),u=e.payload.items,m=(0,l.useMemo)(()=>new Map((e.result?.items??[]).map(y=>[y.id,y])),[e.result]),p=Math.max(u.findIndex(y=>!m.has(y.id)),0),h=i?Si(i,{page:p,drafts:[]}):null,[d,v]=(0,l.useState)(h?.page??p),[k,N]=(0,l.useState)(()=>new Map(h?.drafts??[])),[A,E]=(0,l.useState)(!1),[_,q]=(0,l.useState)(null),O=e.payload.verdicts??["approve","reject"],F=new Set(e.payload.requireReasonOn??["reject"]);(0,l.useEffect)(()=>v(y=>Math.min(y,Math.max(u.length-1,0))),[u.length]),(0,l.useEffect)(()=>{N(z=>{const se=new Map(z);let de=!1;for(const me of m.keys())se.delete(me)&&(de=!0);return de?se:z});const y=u.findIndex(z=>!m.has(z.id));y>=0&&v(y)},[u,m]),(0,l.useEffect)(()=>{i&&Ii(i,{page:d,drafts:[...k]})},[i,k,d]);const C=u[d];if(!C)return(0,t.jsx)("p",{className:"text-sm text-ink-3",children:"No review items were provided."});const S=m.get(C.id),P=k.get(C.id),j=C.href?_d(C.href):null,f=!!(!S&&P&&F.has(P.verdict)&&(!P.reason.trim()||P.confirmed===!1));function w(){v(y=>Math.min(y+1,u.length-1))}a(w,"advance");function W(y){N(z=>{const se=new Map(z),de=se.get(C.id);return se.set(C.id,{verdict:y,reason:de?.verdict===y?de.reason:"",confirmed:!F.has(y)}),se}),F.has(y)||w()}a(W,"setVerdict");function M(y){N(z=>{const se=new Map(z),de=se.get(C.id);return de&&se.set(C.id,{...de,reason:y,confirmed:!1}),se})}a(M,"setReason");function $(){P?.reason.trim()&&(N(y=>{const z=new Map(y),se=z.get(C.id);return se&&z.set(C.id,{...se,confirmed:!0}),z}),w())}a($,"confirmRejectionReason");async function K(){if(!s)return;const y=[...k].map(([z,se])=>({id:z,verdict:se.verdict,...se.reason.trim()?{reason:se.reason.trim()}:{}}));if(!(y.length===0||y.some(z=>F.has(z.verdict)&&!z.reason))){E(!0),q(null);try{await s(e,y),i&&Ni(i)}catch(z){q(r(z))}finally{E(!1)}}}a(K,"submit");const le=k.size>0&&[...k.values()].every(y=>!F.has(y.verdict)||!!(y.reason.trim()&&y.confirmed!==!1));return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"mb-2 flex items-center text-xs text-ink-3",children:[(0,t.jsxs)("span",{children:[k.size+m.size," decided"]}),(0,t.jsx)(xh,{children:(0,t.jsxs)("nav",{className:"flex shrink-0 items-center gap-1","aria-label":"Item pagination",children:[(0,t.jsx)(ne,{type:"button",size:"icon-xs",variant:"ghost","aria-label":"Previous item",disabled:A||d===0,onClick:a(()=>v(y=>y-1),"onClick"),children:(0,t.jsx)(_p,{"aria-hidden":!0})}),(0,t.jsxs)("span",{className:"min-w-10 text-center tabular-nums",children:[d+1," of ",u.length]}),(0,t.jsx)(ne,{type:"button",size:"icon-xs",variant:"ghost","aria-label":"Next item",disabled:A||d===u.length-1||f,onClick:a(()=>v(y=>y+1),"onClick"),children:(0,t.jsx)(kr,{"aria-hidden":!0})})]})})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("p",{className:"text-sm font-medium leading-5 text-ink",children:C.label}),C.description?(0,t.jsx)("p",{className:"text-xs leading-4 text-ink-3",children:C.description}):null]}),j?(0,t.jsx)("a",{href:j,className:"text-xs font-medium text-accent hover:underline",children:"Open"}):null]}),C.previewMarkdown?(0,t.jsx)("div",{className:"mt-2 rounded-sm bg-bg-3/40 px-2.5 py-2 text-xs",children:(0,t.jsx)(bs,{externalReferences:n,children:C.previewMarkdown})}):null,S?(0,t.jsxs)("p",{className:"mt-3 inline-flex rounded-sm border border-line px-2 py-1 text-xs capitalize text-ink-3",children:[S.verdict,S.reason?` · ${S.reason}`:""]}):(0,t.jsx)(Ih,{className:"mt-3 flex-wrap","aria-label":`Verdict for ${C.label}`,children:O.map(y=>(0,t.jsxs)(jh,{selected:P?.verdict===y,onClick:a(()=>W(y),"onClick"),className:"min-w-24 capitalize",children:[y==="approve"?(0,t.jsx)(Wn,{"aria-hidden":!0,className:"h-4 w-4"}):null,y==="reject"?(0,t.jsx)(Qa,{"aria-hidden":!0,className:"h-4 w-4"}):null,y]},y))}),!S&&P&&F.has(P.verdict)?(0,t.jsxs)("div",{className:"mt-2 space-y-1.5",children:[(0,t.jsx)("label",{htmlFor:`${e.id}-${C.id}-reason`,className:"text-xs font-medium text-ink",children:e.payload.reasonLabel??"Reason"}),(0,t.jsx)(va,{id:`${e.id}-${C.id}-reason`,value:P.reason,onChange:a(y=>M(y.target.value),"onChange"),placeholder:"Add a short reason",className:Ci,autoFocus:!0}),(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)(ne,{type:"button",size:"sm",variant:"secondary",disabled:!P.reason.trim()||A,onClick:$,children:"Submit rejection reason"})})]}):null,e.payload.detailsMarkdown?(0,t.jsx)(tl,{children:(0,t.jsx)(bs,{externalReferences:n,children:e.payload.detailsMarkdown})}):null,(0,t.jsx)(Ai,{message:_}),(0,t.jsxs)(Ri,{children:[o?.skipButton,(0,t.jsxs)(ne,{type:"button",size:"sm",disabled:!le||A||!s,onClick:a(()=>{K()},"onClick"),children:[A?(0,t.jsx)(It,{"aria-hidden":!0,className:"h-4 w-4 animate-spin"}):null,k.size>0?`Apply ${k.size}`:"Apply decisions"]})]})]})}a(iy,"ItemVerdictsCard");function lc({interaction:e,planDocument:s,showPlanPreview:n=!0,agentMap:r,currentUserId:i,userLabelMap:o,onAcceptInteraction:u,onRejectInteraction:m,onSubmitInteractionAnswers:p,onCancelInteraction:h,onSubmitInteractionVerdicts:d,onUploadImage:v,externalReferences:k,presentation:N="timeline",draftKey:A,mentions:E}){const _=e.createdByAgentId?r?.get(e.createdByAgentId)?.name:e.createdByUserId?e.createdByUserId===i?"You":o?.get(e.createdByUserId):null,q=e.addresseeAgentId?r?.get(e.addresseeAgentId)?.name:e.addresseeUserId?e.addresseeUserId===i?"You":o?.get(e.addresseeUserId)??e.addresseeUserId:null,O=hx({interaction:e,creatorLabel:_,addresseeLabel:q}),F=a(P=>If(P,O),"errorMessage"),C=e.status==="pending"&&!O.isOpen?O.shortSummary:null,S=n&&e.status!=="pending"&&e.kind==="request_confirmation"&&e.payload.target?.type==="issue_document"&&e.payload.target.key==="plan";return e.kind==="connection_intent"?(0,t.jsx)(Af,{interaction:e,currentUserId:i,addresseeLabel:q??"the addressed user",addresseeName:e.addresseeUserId?o?.get(e.addresseeUserId):void 0}):N==="timeline"&&e.status!=="pending"?(0,t.jsxs)(t.Fragment,{children:[S?(0,t.jsx)("div",{className:"mb-2",children:(0,t.jsx)(uu,{interaction:e,planDocument:s})}):null,(0,t.jsx)(oc,{interaction:e,externalReferences:k,compact:!0})]}):(0,t.jsx)(Z0,{interaction:e,audienceLabel:C,presentation:N,children:e.status!=="pending"?(0,t.jsx)(oc,{interaction:e,externalReferences:k}):e.kind==="ask_user_questions"?(0,t.jsx)(sy,{interaction:e,onSubmitInteractionAnswers:p,onCancelInteraction:N==="timeline"?h:void 0,errorMessage:F,draftKey:A,onUploadImage:v,mentions:E}):e.kind==="request_confirmation"?(0,t.jsx)(ny,{interaction:e,planDocument:s,onAcceptInteraction:u,onRejectInteraction:m,externalReferences:k,errorMessage:F,draftKey:A,showPlanPreview:n&&N==="timeline",onUploadImage:v,mentions:E}):e.kind==="request_checkbox_confirmation"?(0,t.jsx)(ay,{interaction:e,onAcceptInteraction:u,onRejectInteraction:m,externalReferences:k,errorMessage:F,draftKey:A,onUploadImage:v,mentions:E}):e.kind==="suggest_tasks"?(0,t.jsx)(ry,{interaction:e,onAcceptInteraction:u,onRejectInteraction:m,errorMessage:F,draftKey:A}):(0,t.jsx)(iy,{interaction:e,onSubmitInteractionVerdicts:d,externalReferences:k,errorMessage:F,draftKey:A})})}a(lc,"TaskChatCompactInteractionCard");function cc({item:e,onReviewRequest:s,showUnansweredQuestion:n=!1,planDocument:r,showPlanPreview:i=!0,presentation:o="timeline",draftKey:u,...m}){const p=e.interaction;if(o==="timeline"&&n&&!lr(p)&&p.kind==="ask_user_questions"&&p.status==="pending"){const k=p.payload.questionSet?.questions[0]?.prompt??p.payload.questions[0]?.prompt??p.title??"Question";return(0,t.jsxs)("button",{type:"button",id:`interaction-${p.id}`,"data-testid":"task-chat-unanswered-question","aria-label":`Answer question: ${k}`,disabled:!s,onClick:a(()=>s?.(p.id),"onClick"),className:"group flex w-full items-center gap-2 rounded-sm px-1 py-1.5 text-left text-sm text-ink-3 transition-colors hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus",children:[(0,t.jsx)(fd,{"aria-hidden":!0,className:"h-3.5 w-3.5 shrink-0"}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block text-xs",children:"Unanswered question"}),(0,t.jsx)(Ds,{className:"line-clamp-1",children:k.split(/\n\s*\n/)[0]??k})]}),(0,t.jsx)(kr,{"aria-hidden":!0,className:"h-3 w-3 shrink-0"})]})}if(p.kind==="request_confirmation"&&p.payload.toolAction){const k=p.payload.toolAction;return o==="takeover"?(0,t.jsx)(Sl,{interaction:p,...m}):(0,t.jsx)("div",{id:`interaction-${p.id}`,"data-testid":"task-chat-tool-review",className:"w-full space-y-2",children:p.status==="pending"?(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[(0,t.jsx)(mh,{name:k.appDisplayName||k.toolDisplayName,size:36}),(0,t.jsx)("div",{className:"min-w-0 flex-1",children:(0,t.jsx)(bs,{children:k.previewMarkdown.split(/\n\s*\n/)[0]||k.toolDisplayName})}),(0,t.jsx)(ne,{className:"ml-auto",size:"sm",variant:"secondary",disabled:!s,onClick:a(()=>s?.(p.id),"onClick"),children:"Review request"})]}):(0,t.jsx)(Sl,{interaction:p,...m})})}const h=p.kind==="ask_user_questions"&&p.status!=="pending"&&p.result?.expirationReason==="superseded_by_newer_interaction";if(lr(p)&&!h)return null;if(o==="timeline"&&p.status==="pending"&&p.kind!=="connection_intent")return!(p.kind==="request_confirmation"&&p.sourceRunId&&p.payload.target?.type==="issue_document"&&p.payload.target.key==="plan"&&r&&(r?.latestRevisionId?p.payload.target.revisionId===r.latestRevisionId:p.payload.target.revisionNumber===r?.latestRevisionNumber))||!i?null:(0,t.jsx)("div",{id:`interaction-${p.id}`,"data-testid":"task-chat-interaction",children:(0,t.jsx)(ei,{source:{kind:"saved",document:r},testId:"plan-review-preview"})});const d=o==="timeline"&&p.kind==="request_confirmation"&&(p.status==="accepted"||p.status==="rejected")&&p.payload.target?.type==="issue_document"&&p.payload.target.key==="plan",v=d&&r!=null&&(r.latestRevisionId?p.payload.target?.revisionId===r.latestRevisionId:p.payload.target?.revisionNumber===r.latestRevisionNumber);return d?v&&i&&r?(0,t.jsx)("div",{id:`interaction-${p.id}`,"data-testid":"task-chat-interaction",children:(0,t.jsx)(ei,{source:{kind:"saved",document:r},testId:"plan-review-preview"})}):null:o==="timeline"&&p.status!=="pending"?(0,t.jsx)("div",{id:`interaction-${p.id}`,className:"tc-enter-bubble w-full","data-testid":"task-chat-interaction",children:(0,t.jsx)(lc,{interaction:p,planDocument:r,showPlanPreview:i,presentation:"timeline",draftKey:u,...m})}):(0,t.jsx)("div",{id:`interaction-${p.id}`,className:"tc-enter-bubble w-full","data-testid":"task-chat-interaction",children:(0,t.jsx)(lc,{interaction:p,planDocument:r,showPlanPreview:i,presentation:o,draftKey:u,...m})})}a(cc,"TaskChatInteractionCard");var hu=new Set(["request_confirmation","request_checkbox_confirmation","request_item_verdicts"]),oy=new Set(["withdrawn","superseded_by_comment","superseded_by_newer_request"]);function ly(e){const s=e.result;return s&&"outcome"in s&&typeof s.outcome=="string"?s.outcome:null}a(ly,"interactionOutcome");function dc(e){if(e.kind==="request_confirmation"&&e.payload.secretProposal||!hu.has(e.kind))return!1;const s=ly(e);return s!=null&&oy.has(s)}a(dc,"isSuppressedThreadInteraction");function cy(e,s){if(e.status==="pending"||!hu.has(e.kind)||!e.resolvedAt)return s;const n=e.resolvedAt instanceof Date?e.resolvedAt.getTime():new Date(e.resolvedAt).getTime();return Number.isFinite(n)?Math.max(s,n):s}a(cy,"interactionThreadAnchorMs");var dy={starting:"Starting",editing:"Saving",replacing:"Replacing",pausing:"Pausing after current turn",resuming:"Resuming",clearing:"Clearing",continuing:"Continuing in a new run"};function uy(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`goal_${Date.now()}_${Math.random().toString(36).slice(2)}`}a(uy,"requestId");function my(e){if(e<60)return`${e}s`;const s=Math.floor(e/60);return s<60?`${s}m`:`${Math.floor(s/60)}h ${s%60}m`}a(my,"formatDuration$1");function uc(e){return e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(e)}a(uc,"formatTokens");function py(e,s){const n=ks(),[r,i]=(0,l.useState)(!1),[o,u]=(0,l.useState)(null),[m,p]=(0,l.useState)(null);(0,l.useEffect)(()=>{i(!1),u(null),p(null)},[e,s]);const h=R.issues.runnerGoal(e??"__none__",s),d=ye({queryKey:h,queryFn:a(()=>xe.getRunnerGoal(e,s),"queryFn"),enabled:!!e,refetchOnReconnect:!0,refetchOnWindowFocus:!0,refetchInterval:a(C=>C.state.data?.goal?.status==="active"?3e4:!1,"refetchInterval")}),v=Pe({mutationFn:a(C=>xe.actOnRunnerGoal(e,C),"mutationFn"),onSuccess:a(C=>{n.setQueryData(h,C.projection),i(C.projection.goal!=null)},"onSuccess")}),k=(0,l.useRef)({query:d,mutation:v});k.current={query:d,mutation:v},ng(C=>{if(C.type!=="agent.session.goal.changed")return;const S=C.payload;if(S.issueId!==e||s&&S.agentId!==s)return;const P=n.getQueryData(h);if(P&&S.revision>P.revision+1){k.current.query.refetch();return}(!P||S.revision>=P.revision)&&n.setQueryData(h,S)});const N=(0,l.useCallback)(async(C,S,P=!1,j)=>{const{query:f,mutation:w}=k.current;p(null);try{const W=f.data??(await f.refetch()).data;if(!W?.agentId)throw new Error(W?.capability.reason??"Select an agent to use /goal.");if(W.capability.availability!=="available")throw new Error(W.capability.reason??"Session goals are unsupported by this agent.");await w.mutateAsync({requestId:uy(),agentId:W.agentId,expectedRevision:j??W.revision,action:C,...S?{objective:S}:{},...C==="replace"?{confirmReplace:P}:{}})}catch(W){throw p(W instanceof Error?W.message:"The goal action could not be applied."),W}},[]),A=(0,l.useCallback)(async()=>{const{query:C,mutation:S}=k.current,P=C.data??(await C.refetch()).data;if(!P?.goal)throw new Error("There is no current session goal to edit.");S.reset(),p(null),i(!0),u({action:"edit",objective:P.goal.objective,revision:P.revision})},[]),E=(0,l.useCallback)(async C=>{const{query:S,mutation:P}=k.current;if(C.action==="focus"){const j=S.data??(await S.refetch()).data;if(!j?.goal&&!j?.pendingAction)throw new Error("Add an objective after /goal to start a goal.");i(!0);return}if(C.action==="edit"){await A();return}if(C.action==="create"){const j=S.data??(await S.refetch()).data;j?.goal&&j.goal.status!=="complete"?(P.reset(),p(null),i(!0),u({action:"replace",objective:C.objective,revision:j.revision})):await N("create",C.objective);return}await N(C.action)},[A,N]),_=(0,l.useCallback)(async()=>{if(!o||k.current.mutation.isPending)return;const C=o.objective.trim();if(!(!C||C.length>4e3))try{await N(o.action,C,o.action==="replace",o.revision),u(null)}catch{}},[o,N]),q=d.data,O=v.isPending,F=m??(v.error instanceof Error?v.error.message:v.error?"The goal action could not be applied.":null);return(0,l.useMemo)(()=>({data:q,expanded:r,setExpanded:i,dialog:o,setDialog:u,submitDialog:_,saving:O,mutationError:F,executeAction:N,edit:A,executeComposerCommand:E}),[q,r,o,_,O,F,N,A,E])}a(py,"useRunnerGoalControl");function fy({control:e}){const s=e.data,n=s?.goal??null,r=s?.capability,i=a(p=>r?.availability==="available"&&r.actions.includes(p),"can"),o=n&&["paused","blocked","limited","usage_limited"].includes(n.status),u=s?.pendingAction?dy[s.pendingAction]:null,m=e.mutationError;return!n&&!s?.pendingAction&&!e.dialog&&!m?null:(0,t.jsxs)("section",{className:"rounded-xl border border-line/80 bg-bg-2/95 px-3 py-2 shadow-sm","aria-label":"Agent session goal","data-testid":"runner-goal-widget",children:[(0,t.jsxs)("div",{className:"flex items-start gap-2",children:[(0,t.jsx)(bd,{className:"mt-0.5 h-4 w-4 shrink-0 text-accent","aria-hidden":!0}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-xs font-semibold",children:"Session goal"}),n?(0,t.jsx)("span",{className:"rounded-full bg-bg-3 px-1.5 py-0.5 text-xs font-medium capitalize",role:"status",children:n.status.replaceAll("_"," ")}):null,n?.workingNow?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs text-accent",role:"status",children:[(0,t.jsx)("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-accent"})," Working now"]}):null,u?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs text-ink-3",role:"status",children:[(0,t.jsx)(It,{className:"h-3 w-3 animate-spin","aria-hidden":!0})," ",u]}):null]}),n?(0,t.jsx)("p",{className:ue("mt-1 text-sm leading-snug",e.expanded?"max-h-40 overflow-auto":"line-clamp-2"),children:n.objective}):(0,t.jsx)("p",{className:"mt-1 text-xs text-ink-3",children:r?.reason??"Type /goal followed by an objective to pursue work across turns."}),n?(0,t.jsxs)("div",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-1 text-xs text-ink-3",children:[(0,t.jsx)("span",{children:my(n.elapsedSeconds)}),r?.usageReporting?(0,t.jsxs)("span",{children:[uc(n.tokensUsed)," tokens",n.tokenBudget?` / ${uc(n.tokenBudget)}`:""]}):null,n.iterations>0?(0,t.jsxs)("span",{children:[n.iterations," iterations"]}):null,n.lastReason?(0,t.jsx)("span",{className:"truncate",children:n.lastReason}):null]}):null]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[n&&i("set")?(0,t.jsx)(ne,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:a(()=>{e.edit().catch(()=>{})},"onClick"),"aria-label":"Edit goal",children:(0,t.jsx)(ai,{className:"h-3.5 w-3.5","aria-hidden":!0})}):null,n?.status==="active"&&i("pause")?(0,t.jsx)(ne,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:a(()=>{e.executeAction("pause").catch(()=>{})},"onClick"),"aria-label":"Pause goal",children:(0,t.jsx)(_f,{className:"h-3.5 w-3.5","aria-hidden":!0})}):null,o&&i("resume")?(0,t.jsx)(ne,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:a(()=>{e.executeAction("resume").catch(()=>{})},"onClick"),"aria-label":"Resume goal",children:(0,t.jsx)(qf,{className:"h-3.5 w-3.5","aria-hidden":!0})}):null,n&&i("clear")?(0,t.jsx)(ne,{size:"icon",variant:"ghost",className:ue("h-7 w-7"," "),onClick:a(()=>{e.executeAction("clear").catch(()=>{})},"onClick"),"aria-label":"Clear goal",children:(0,t.jsx)(Bo,{className:"h-3.5 w-3.5","aria-hidden":!0})}):null]})]}),m?(0,t.jsx)("p",{className:"mt-1 text-xs text-bad",role:"alert",children:m}):null,(0,t.jsx)(Vo,{open:!!e.dialog,onOpenChange:a(p=>{!p&&!e.saving&&e.setDialog(null)},"onOpenChange"),children:(0,t.jsx)(Wo,{showCloseButton:!e.saving,children:(0,t.jsxs)("form",{className:"space-y-4",onSubmit:a(p=>{p.preventDefault(),e.submitDialog()},"onSubmit"),children:[(0,t.jsxs)(Qo,{children:[(0,t.jsx)(Ho,{children:e.dialog?.action==="replace"?"Replace session goal?":"Edit session goal"}),(0,t.jsx)(zo,{children:e.dialog?.action==="replace"?"This clears the unfinished goal and starts a new goal with the objective below.":"Update the objective without clearing the goal's progress."})]}),(0,t.jsxs)("label",{className:"block space-y-2",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:"Goal objective"}),(0,t.jsx)(va,{value:e.dialog?.objective??"",maxLength:4e3,required:!0,disabled:e.saving,onChange:a(p=>{const h=p.target.value;e.setDialog(d=>d?{...d,objective:h}:null)},"onChange"),onKeyDown:a(p=>{p.key==="Enter"&&(p.metaKey||p.ctrlKey)&&(p.preventDefault(),p.currentTarget.form?.requestSubmit())},"onKeyDown")})]}),m?(0,t.jsx)("p",{className:"text-sm text-bad",role:"alert",children:m}):null,(0,t.jsxs)(ah,{children:[(0,t.jsx)(ne,{type:"button",variant:"secondary",disabled:e.saving,onClick:a(()=>e.setDialog(null),"onClick"),children:"Cancel"}),(0,t.jsx)(ne,{type:"submit",disabled:!e.dialog?.objective.trim()||e.saving,children:e.saving?"Saving…":e.dialog?.action==="replace"?"Replace goal":"Save goal"})]})]})})})]})}a(fy,"RunnerGoalWidgetBase");var hy=(0,l.memo)(fy);function gy(e,s,n){if(e.some(o=>o.source?.kind==="interaction"))return null;const r=e.findIndex(o=>o.comment.id===s),i=e.findIndex(o=>o.comment.id===n);return r<0||i<0||r===i?null:Gh(e,r,i).map((o,u)=>({...o,position:u}))}a(gy,"reorderQueuedMessageEntries");function mc(e){if(typeof e!="object"||e===null)return null;const s=e.body;if(typeof s!="object"||s===null)return null;const n=s.code;if(typeof n=="string")return n;const r=s.details;if(typeof r!="object"||r===null)return null;const i=r.code;return typeof i=="string"?i:null}a(mc,"queueActionErrorCode");function xy({entry:e,count:s,queue:n,busy:r,queueMutationDisabled:i,action:o,onEdit:u,onSteer:m,onInterrupt:p,onDiscard:h,onShowIndividually:d}){const v=e.source?.kind==="interaction",k=v?e.comment.body.split(`
2
2
  `)[0]:e.comment.body,N=yg({id:e.comment.id,disabled:i||v}),A={transform:Vh.Transform.toString(N.transform),transition:N.transition},E=i||n.steeringDisposition!=="available",_=n.steeringDisposition==="unsupported"?"This runner does not support steering":n.steeringDisposition==="temporarily_unavailable"?"Steering is temporarily unavailable":"Steer this message into the active turn";return(0,t.jsxs)("div",{ref:N.setNodeRef,style:A,className:ue("group flex h-11 min-w-0 items-center gap-1 border-b border-line/55 bg-bg-2/95 px-2.5 text-sm last:border-b-0",N.isDragging&&"relative z-20 rounded-lg border border-line shadow-lg"),"data-testid":`task-chat-queued-message-${e.comment.id}`,children:[(0,t.jsx)("button",{type:"button",ref:N.setActivatorNodeRef,...N.attributes,...N.listeners,disabled:i||v,"aria-label":`Reorder queued message: ${e.comment.body}`,className:"flex h-7 w-7 shrink-0 cursor-grab items-center justify-center rounded-md text-ink-3/70 transition-colors hover:bg-bg-3 hover:text-ink active:cursor-grabbing disabled:cursor-default disabled:opacity-40",children:(0,t.jsx)(pg,{className:"h-3.5 w-3.5","aria-hidden":!0})}),(0,t.jsx)(Yi,{className:"h-3.5 w-3.5 shrink-0 text-ink-3","aria-hidden":!0}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate px-1",title:e.comment.body,children:k}),s>1?(0,t.jsxs)("span",{className:"shrink-0 rounded-md bg-bg-3 px-1.5 text-xs font-medium tabular-nums text-ink-3",title:`${s} identical queued messages`,"data-testid":`task-chat-queued-count-${e.comment.id}`,children:["×",s]}):null,n.protocol==="legacy"||e.source?.requiresFreshSession?(0,t.jsxs)("button",{type:"button",onClick:p,disabled:r||!n.queueId||!p,title:n.targetRunId?"Interrupt the active turn and send queued messages":"Send queued messages now",className:"flex h-7 shrink-0 items-center gap-1.5 rounded-md px-2 text-xs font-medium text-ink-3 transition-colors hover:bg-bg-3 hover:text-ink disabled:opacity-40","data-testid":`task-chat-queued-interrupt-${e.comment.id}`,children:[o==="interrupt"?(0,t.jsx)(It,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):(0,t.jsx)(Yi,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Interrupt"]}):(0,t.jsxs)("button",{type:"button",onClick:m,disabled:E,title:_,className:"flex h-7 shrink-0 items-center gap-1.5 rounded-md px-2 text-xs font-medium text-ink-3 transition-colors hover:bg-bg-3 hover:text-ink disabled:opacity-40","data-testid":`task-chat-queued-steer-${e.comment.id}`,children:[o==="steer"?(0,t.jsx)(It,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):(0,t.jsx)(Yi,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Steer"]}),(0,t.jsx)("button",{type:"button",onClick:h,disabled:r||!n.queueId&&!e.comment.id.startsWith("optimistic-")||!e.canDiscard,title:"Discard queued message","aria-label":`Discard queued message: ${e.comment.body}`,className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-ink-3 transition-colors hover:bg-bad/10 hover:text-bad disabled:opacity-40","data-testid":`task-chat-queued-discard-${e.comment.id}`,children:o==="discard"?(0,t.jsx)(It,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):(0,t.jsx)(Bo,{className:"h-3.5 w-3.5","aria-hidden":!0})}),(0,t.jsxs)(Sp,{children:[(0,t.jsx)(Ip,{asChild:!0,children:(0,t.jsx)("button",{type:"button",disabled:i||v,title:"Queued message actions","aria-label":`Queued message actions: ${e.comment.body}`,className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-ink-3 transition-colors hover:bg-bg-3 hover:text-ink disabled:opacity-40",children:(0,t.jsx)(xd,{className:"h-4 w-4","aria-hidden":!0})})}),(0,t.jsxs)(Np,{align:"end",className:"w-44",children:[(0,t.jsxs)(wl,{disabled:!e.canEdit,onSelect:u,children:[(0,t.jsx)(ai,{className:"h-4 w-4","aria-hidden":!0}),"Edit message"]}),d?(0,t.jsxs)(wl,{onSelect:d,children:[(0,t.jsx)($x,{className:"h-4 w-4","aria-hidden":!0}),"Show individually"]}):null]})]})]})}a(xy,"SortableQueuedMessage");var yy=3;function pc(e){return e.source?.kind!=="interaction"&&e.comment.authorType!=="system"}a(pc,"groupableEntry");function vy(e,s,n){const r=[];for(const i of e){const o=r.at(-1);n&&o&&o.entry.comment.body===i.comment.body&&o.entry.comment.authorType===i.comment.authorType&&o.entry.comment.authorUserId===i.comment.authorUserId&&o.entry.comment.authorAgentId===i.comment.authorAgentId&&pc(o.entry)&&pc(i)&&!s.has(o.entry.comment.id)&&!s.has(i.comment.id)?o.commentIds.push(i.comment.id):r.push({entry:i,commentIds:[i.comment.id]})}return r}a(vy,"groupQueuedMessageRows");function by({queue:e,onEdit:s,onReorder:n,onSteer:r,onInterrupt:i,onDiscard:o}){const[u,m]=(0,l.useState)(e.entries),p=(0,l.useRef)(e);p.current=e;const h=(0,l.useRef)(new Set),[d,v]=(0,l.useState)(null),[k,N]=(0,l.useState)(!1),[A,E]=(0,l.useState)(!1),[_,q]=(0,l.useState)(!1),[O,F]=(0,l.useState)(()=>new Set),[C,S]=(0,l.useState)(!1),[P,j]=(0,l.useState)(""),[f,w]=(0,l.useState)(null),W=(0,l.useRef)({revision:e.revision,onDiscard:o}),M=(0,l.useId)(),$=wg(Ul(sg,{activationConstraint:{distance:4}}),Ul(cg,{coordinateGetter:lg}));(0,l.useEffect)(()=>{W.current={revision:e.revision,onDiscard:o}},[e.revision,o]),(0,l.useEffect)(()=>{m(e.entries.filter(ie=>!h.current.has(ie.comment.id)))},[e.entries,e.revision]);const K=(0,l.useMemo)(()=>vy(u,O,!A),[u,O,A]),le=u.length>yy,y=le&&!_?K.slice(0,1):K,z=(0,l.useMemo)(()=>y.map(ie=>ie.entry.comment.id),[y]),se=u.filter(ie=>ie.canDiscard&&!ie.comment.id.startsWith("optimistic-")).map(ie=>ie.comment.id);async function de(ie){const{active:ge,over:Ie}=ie;if(!e.queueId||!Ie||ge.id===Ie.id||k||d)return;const De=u,$e=gy(u,String(ge.id),String(Ie.id));if(!$e)return;const Be=$e.map(Se=>Se.comment.id),Fe=String(ge.id),re=$e.findIndex(Se=>Se.comment.id===Fe);m($e),N(!0),w(null),j(`Moved queued message to position ${re+1} of ${$e.length}.`);try{await n(Be,e.revision)}catch(Se){m(De),j(""),w(mc(Se)==="queued_comment_revision_conflict"?"The queue changed in another session. Its latest order has been restored.":"Couldn’t reorder. Previous order restored.")}finally{N(!1)}}a(de,"handleDragEnd");async function me(ie,ge,Ie="row"){const[De]=ie;if(!De)return;const $e=ge==="discard"&&ie.every(re=>re.startsWith("optimistic-"));if(d||k||!e.queueId&&ge!=="interrupt"&&!$e)return;const Be=ge==="discard"&&ie.length>1,Fe=ge==="interrupt"?u.map(re=>re.comment.id):ge==="steer"?[De]:[];for(const re of Fe)h.current.add(re);Fe.length&&m(re=>re.filter(Se=>!h.current.has(Se.comment.id))),v({commentIds:ie,action:ge,scope:Ie}),w(null),j(ge==="steer"?"Steering queued message.":ge==="interrupt"?"Sending queued messages.":Be?"Discarding queued messages.":"Discarding queued message.");try{if(ge==="steer")await r(De,W.current.revision);else if(ge==="interrupt")await i?.();else for(const re of ie)await W.current.onDiscard(re,W.current.revision),m(Se=>Se.filter(Ve=>Ve.comment.id!==re));j(ge==="steer"?"Message steered into the active turn.":ge==="interrupt"?"Queued messages will be sent when the previous run has stopped.":Be?`${ie.length} queued messages discarded.`:"Queued message discarded.")}catch(re){for(const Ve of Fe)h.current.delete(Ve);Fe.length&&m(p.current.entries.filter(Ve=>!h.current.has(Ve.comment.id))),j("");const Se=mc(re);w(Se==="queued_comment_already_dispatching"?"Too late to discard: this message is already being sent.":Se==="steering_identity_mismatch"?"This message answers to a different user than the running turn. It stays queued for the next turn.":ge==="steer"?"Couldn’t steer. Message is still queued.":ge==="interrupt"?"Couldn’t interrupt. Message is still queued.":Se==="queued_comment_revision_conflict"?"The queue changed in another session. Review it and try again.":"Couldn’t discard. Message is still queued.")}finally{v(null)}}if(a(me,"runRowAction"),u.length===0&&!f)return null;const oe=!!(d||k),ve=!!(!e.queueId||d||k);return(0,t.jsxs)(Fh,{"data-testid":"task-chat-queued-messages","aria-label":"Queued messages",children:[(0,t.jsxs)("div",{className:"flex h-8 min-w-0 items-center gap-1 border-b border-line/55 pl-3 pr-1.5 text-xs text-ink-3","data-testid":"task-chat-queued-header",children:[(0,t.jsxs)("span",{className:"min-w-0 flex-1 truncate font-medium",children:[u.length," queued"]}),le?(0,t.jsxs)(ne,{type:"button",variant:"ghost",size:"xs","aria-expanded":_,"aria-controls":M,onClick:a(()=>q(ie=>!ie),"onClick"),"data-testid":"task-chat-queued-toggle",children:[_?(0,t.jsx)(dd,{"aria-hidden":!0}):(0,t.jsx)(br,{"aria-hidden":!0}),_?"Show less":`Show all ${u.length}`]}):null,(0,t.jsxs)(ne,{type:"button",variant:"ghost",size:"xs",onClick:a(()=>S(!0),"onClick"),disabled:oe||!e.queueId||se.length===0,"data-testid":"task-chat-queued-discard-all",children:[d?.scope==="all"?(0,t.jsx)(It,{className:"animate-spin","aria-hidden":!0}):(0,t.jsx)(Bo,{"aria-hidden":!0}),"Discard all"]})]}),e.executionWait&&(0,t.jsx)("div",{role:"status","aria-live":"polite",className:"px-3 py-1.5 text-xs text-ink-3",children:e.executionWait.message}),(0,t.jsx)("div",{id:M,className:"max-h-44 overflow-y-auto overscroll-contain","data-testid":"task-chat-queued-list",children:(0,t.jsx)(Jh,{sensors:$,collisionDetection:eg,onDragStart:a(()=>E(!0),"onDragStart"),onDragCancel:a(()=>E(!1),"onDragCancel"),onDragEnd:a(ie=>{E(!1),de(ie)},"onDragEnd"),children:(0,t.jsx)(hg,{items:z,strategy:Yh,children:y.map(ie=>{const{entry:ge,commentIds:Ie}=ie,De=d?.scope==="row"&&d.commentIds.includes(ge.comment.id)?d.action:null;return(0,t.jsx)(xy,{entry:ge,count:Ie.length,queue:e,busy:oe,queueMutationDisabled:ve,action:De,onEdit:a(()=>s(ge.comment.id),"onEdit"),onSteer:a(()=>{me([ge.comment.id],"steer")},"onSteer"),onInterrupt:i?()=>{me([ge.comment.id],"interrupt")}:void 0,onDiscard:a(()=>{me(Ie,"discard")},"onDiscard"),onShowIndividually:Ie.length>1?()=>F($e=>new Set([...$e,...Ie])):void 0},ge.comment.id)})})})}),f?(0,t.jsx)("div",{role:"status","aria-live":"polite",className:"border-t border-bad/20 bg-bad/5 px-3 py-1.5 text-xs text-bad",children:f}):null,(0,t.jsx)("div",{className:"sr-only","aria-live":"polite","aria-atomic":"true",children:P}),(0,t.jsx)(ki,{open:C,onOpenChange:S,children:(0,t.jsxs)(xi,{"data-testid":"task-chat-queued-discard-all-dialog",children:[(0,t.jsxs)(bi,{children:[(0,t.jsx)(gi,{children:"Discard all queued messages?"}),(0,t.jsx)(hi,{children:se.length===1?"1 queued message will be removed and never sent.":`${se.length} queued messages will be removed and never sent.`})]}),(0,t.jsxs)(yi,{children:[(0,t.jsx)(vi,{children:"Cancel"}),(0,t.jsx)(_o,{className:"bg-bad text-accent-ink hover:bg-bad/90",onClick:a(()=>{me(se,"discard","all")},"onClick"),"data-testid":"task-chat-queued-discard-all-confirm",children:"Discard all"})]})]})})]})}a(by,"TaskChatQueuedMessages");var ky=48;function oi(){return document.scrollingElement??document.documentElement}a(oi,"scrollingElement");function fc(){const e=oi();return e?e.scrollHeight-window.scrollY-window.innerHeight<=ky:!0}a(fc,"windowPinned");function Zi(){const e=oi();if(!e)return;const s=Math.max(0,e.scrollHeight-window.innerHeight);Math.abs(window.scrollY-s)<1||window.scrollTo({top:e.scrollHeight,left:0,behavior:"auto"})}a(Zi,"scrollWindowToBottom");function wy(e,s){const n=(0,l.useRef)(!0),r=(0,l.useRef)(window.scrollY),i=zf(),o=(0,l.useRef)(!1),u=(0,l.useRef)({key:i.key,hash:i.hash}),m=(0,l.useRef)(null),p=a(()=>{r.current=window.scrollY;const d=document.querySelector('[data-testid="task-chat-thread"]');d&&(m.current=Hf(d,0,window.innerHeight)),o.current&&i.remember(window.scrollY,m.current)},"rememberAnchor"),h=a(()=>{if(n.current)Zi();else{const d=document.querySelector('[data-testid="task-chat-thread"]');if(d){const v=Df(d,m.current,0);v&&window.scrollTo({top:window.scrollY+v,behavior:"auto"})}}p()},"reconcile");(0,l.useEffect)(()=>{if(!s)return;const d=a(()=>{n.current=fc()||n.current&&window.scrollY>=r.current,p()},"onScroll");return window.addEventListener("scroll",d,{passive:!0}),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",d),window.removeEventListener("resize",h)}},[s,i.key,i.hash,i.ready]),(0,l.useEffect)(()=>{if(!s)return;const d=window.visualViewport;if(!d)return;let v=0;const k=a(()=>{n.current&&(Zi(),window.cancelAnimationFrame(v),v=window.requestAnimationFrame(()=>{v=window.requestAnimationFrame(()=>{n.current&&Zi()})}))},"onViewportChange");return d.addEventListener("resize",k),()=>{window.cancelAnimationFrame(v),d.removeEventListener("resize",k)}},[s]),(0,l.useLayoutEffect)(()=>{if(!s||typeof ResizeObserver>"u")return;let d=oi()?.scrollHeight??null;const v=new ResizeObserver(()=>{const N=oi()?.scrollHeight??null;N==null||N===d||(d=N,h())});v.observe(document.body);const k=document.querySelector('[data-testid="task-chat-thread"]');return k&&v.observe(k),()=>v.disconnect()},[s,i.key,i.hash,i.ready]),(0,l.useLayoutEffect)(()=>{if(s){if((u.current.key!==i.key||u.current.hash!==i.hash)&&(u.current={key:i.key,hash:i.hash},o.current=!1),i.ready&&!o.current){const d=document.querySelector('[data-testid="task-chat-thread"]'),v=d?i.initialPosition(d,0,window.scrollY):null;v!==null&&(window.scrollTo({top:v,behavior:"auto"}),n.current=fc(),p()),o.current=!0}h()}},[e,s,i.key,i.hash,i.ready]),(0,l.useLayoutEffect)(()=>{if(!s)return;const d=window.history.scrollRestoration;return window.history.scrollRestoration="manual",document.documentElement.classList.add("task-chat-window-scroll"),()=>{document.documentElement.classList.remove("task-chat-window-scroll"),window.history.scrollRestoration=d}},[s])}a(wy,"useWindowAutoFollow");function jy({contentKey:e,enabled:s}){return wy(e,s),null}a(jy,"TaskChatWindowScroll");function Iy({isMobile:e}){return ue("sticky",e?"bottom-(--tc-composer-dock-bottom) z-20":"bottom-0 z-10","mx-auto flex w-full max-w-(--tc-shell-max-w) flex-col gap-2 px-1 pb-1 md:px-4 md:pb-2","md:px-0 md:pb-0",e&&"bg-bg/80 pt-1 backdrop-blur supports-[backdrop-filter]:bg-bg/60 dark:bg-transparent dark:backdrop-blur-none dark:supports-[backdrop-filter]:bg-transparent")}a(Iy,"composerDockClassName");var Ny=(0,l.forwardRef)(a(function({children:s,mobile:n,reserve:r,concealed:i=!1},o){return(0,t.jsx)("div",{ref:o,"data-testid":"task-chat-composer-dock","data-composer-reserve":r,inert:i,"aria-hidden":i||void 0,className:ue(Iy({isMobile:n}),i&&"invisible"),children:s})},"TaskChatComposerDock")),hc="--tc-composer-reserve";function Sy(e){const[s,n]=(0,l.useState)(null),[r,i]=(0,l.useState)(0);return(0,l.useEffect)(()=>{if(!e||!s){i(0);return}const o=a(()=>{i(Math.ceil(s.getBoundingClientRect().height))},"measure");if(o(),typeof ResizeObserver>"u")return;const u=new ResizeObserver(o);return u.observe(s),()=>u.disconnect()},[e,s]),(0,l.useEffect)(()=>{if(!e)return;const o=document.documentElement.style;return o.setProperty(hc,`${r}px`),()=>{o.removeProperty(hc)}},[e,r]),{dockRef:n,reserve:r}}a(Sy,"useComposerDockReserve");function eo(e){try{const s=JSON.parse(e?localStorage.getItem(e)??"[]":"[]");return new Set(Array.isArray(s)?s.filter(n=>typeof n=="string"):[])}catch{return new Set}}a(eo,"loadDismissedQuestions");function Cy(e,s){const n=e?`wardmote:task-question-dismissals:${s??"board"}:${e}`:null,[r,i]=(0,l.useState)(()=>({storageKey:n,ids:eo(n)})),o=(0,l.useMemo)(()=>r.storageKey===n?r.ids:eo(n),[r,n]);return{dismissedQuestionIds:o,dismissQuestion:(0,l.useCallback)(u=>{const m=new Set([...eo(n),...o]);m.add(u);try{n&&localStorage.setItem(n,JSON.stringify([...m]))}catch{}i({storageKey:n,ids:m})},[o,n])}}a(Cy,"useDismissedTaskQuestions");function gc(e){return e.status!=="done"&&e.status!=="cancelled"}a(gc,"isUnresolved");function Ay(e,s,n,r){const i=e.filter(gc);if(i.length===0)return null;const o=n?i.find(p=>p.id===n):s?i.find(p=>p.id===s||p.terminalBlockers?.some(h=>h.id===s)):i[0];if(!o)return r?{directBlocker:r,ultimateBlocker:null}:null;const u=o.terminalBlockers?.filter(gc)??[],m=s?r?.id===s?r:u.find(p=>p.id===s)??null:u[0]??null;return{directBlocker:o,ultimateBlocker:m?.id===o.id?null:m}}a(Ay,"resolveTaskChatBlockers");function Ry(e,s,n){if(e.length===0)return null;const r=Ch(e,s),i=new Set(r.map(p=>p.blocker.id)),o=[];for(const p of e)o.push(...p.terminalBlockers??[]);n&&o.push(n);const u=[],m=new Set;for(const p of o)!s.has(p.id)||i.has(p.id)||m.has(p.id)||(m.add(p.id),u.push(p));return!r.some(p=>p.status==="running")&&u.length===0?null:{steps:r,nowRunning:u}}a(Ry,"resolveTaskChatLiveWork");function xc({label:e,blocker:s}){const n=ji(),r=s.identifier??s.id;return n?(0,t.jsxs)(ls,{to:fa(r),className:"flex min-w-0 items-baseline gap-1.5 rounded px-1 py-0.5 text-amber-800 underline-offset-2 transition-colors hover:bg-bg-3/50 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus dark:text-amber-200",title:`${s.identifier??s.id.slice(0,8)} — ${s.title}`,children:[(0,t.jsx)("span",{className:"shrink-0 font-medium",children:e}),(0,t.jsx)("span",{className:"shrink-0 font-mono",children:s.identifier??s.id.slice(0,8)}),(0,t.jsx)("span",{className:"truncate text-amber-700/80 dark:text-amber-300/80",children:s.title})]}):(0,t.jsxs)("div",{className:"flex min-w-0 items-baseline gap-1.5 whitespace-nowrap",children:[(0,t.jsx)("span",{className:"shrink-0 font-medium",children:e}),(0,t.jsxs)(ls,{to:fa(r),className:"flex min-w-0 items-baseline gap-1 text-amber-800 underline-offset-2 hover:underline dark:text-amber-200",title:`${s.identifier??s.id.slice(0,8)} — ${s.title}`,children:[(0,t.jsx)("span",{className:"shrink-0 font-mono",children:s.identifier??s.id.slice(0,8)}),(0,t.jsx)("span",{className:"truncate text-amber-700/80 dark:text-amber-300/80",children:s.title})]})]})}a(xc,"BlockerRow");function gu({status:e}){const s=e==="done"?"Done":e==="running"?"Running":"Waiting";return e==="done"?(0,t.jsx)(di,{className:"h-3.5 w-3.5 text-blue-500 dark:text-blue-400",role:"img","aria-label":s}):e==="running"?(0,t.jsx)("span",{className:"flex h-3.5 w-3.5 items-center justify-center",role:"img","aria-label":s,children:(0,t.jsx)("span",{className:"h-2.5 w-2.5 animate-pulse rounded-full bg-blue-400","aria-hidden":!0})}):(0,t.jsx)(Zr,{className:"h-3.5 w-3.5 text-blue-300 dark:text-blue-500/50",role:"img","aria-label":s})}a(gu,"LiveWorkGlyph");function to({blocker:e,status:s,label:n}){const r=ji(),i=e.identifier??e.id;return(0,t.jsxs)(ls,{to:fa(i),className:r?"flex min-w-0 items-center gap-1.5 rounded px-1 py-0.5 text-blue-800 underline-offset-2 transition-colors hover:bg-bg-3/50 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus dark:text-blue-200":"flex min-w-0 items-baseline gap-1 text-blue-800 underline-offset-2 hover:underline dark:text-blue-200",title:`${e.identifier??e.id.slice(0,8)} — ${e.title}`,children:[r&&n?(0,t.jsx)("span",{className:"shrink-0 font-medium",children:n}):null,r?(0,t.jsx)(gu,{status:s}):null,(0,t.jsx)("span",{className:"shrink-0 font-mono",children:e.identifier??e.id.slice(0,8)}),(0,t.jsx)("span",{className:"truncate text-blue-700/80 dark:text-blue-300/80",children:e.title})]})}a(to,"LiveWorkLink");function yc({directBlocker:e,ultimateBlocker:s,placement:n}){const r=ji();return(0,t.jsxs)("div",{"aria-label":"Task blockers","data-placement":n,"data-testid":"task-chat-blocker-links",className:"flex min-w-0 flex-col gap-1 overflow-hidden text-(length:--text-micro) leading-4 text-amber-700 dark:text-amber-300",children:[(0,t.jsx)(xc,{label:r&&n==="bottom"?"Still blocked by":"Blocked by",blocker:e}),s?(0,t.jsx)(xc,{label:r?n==="bottom"?"Root blocker remains":"Root blocker":"Ultimately blocked by",blocker:s}):null]})}a(yc,"TaskChatBlockerLinks");function vc({liveWork:e,placement:s}){const n=ji();return(0,t.jsxs)("div",{"aria-label":"Tasks waiting on live work","data-placement":s,"data-testid":"task-chat-live-work-links",className:"flex min-w-0 flex-col gap-1.5 overflow-hidden text-(length:--text-micro) leading-4 text-blue-700 dark:text-blue-300",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 font-medium",children:[(0,t.jsx)("span",{className:"flex h-3.5 w-3.5 items-center justify-center","aria-hidden":!0,children:(0,t.jsx)("span",{className:"h-2.5 w-2.5 animate-pulse rounded-full bg-blue-400"})}),n&&s==="bottom"?"Still waiting on live work":"Waiting on live work"]}),(0,t.jsx)("ol",{className:"flex min-w-0 flex-col gap-1",children:e.steps.map(({blocker:r,status:i},o)=>(0,t.jsxs)("li",{"data-testid":"task-chat-live-work-step",className:n?"min-w-0 whitespace-nowrap":"flex min-w-0 items-center gap-1.5 whitespace-nowrap",children:[n?null:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("span",{className:"w-4 shrink-0 text-right font-mono text-blue-500/80","aria-hidden":!0,children:[o+1,"."]}),(0,t.jsx)(gu,{status:i})]}),(0,t.jsx)(to,{blocker:r,status:i})]},r.id))}),e.nowRunning.map(r=>n?(0,t.jsx)(to,{blocker:r,status:"running",label:"Now running"},r.id):(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5 whitespace-nowrap",children:[(0,t.jsx)("span",{className:"shrink-0 font-medium",children:"Now running"}),(0,t.jsx)(to,{blocker:r,status:"running"})]},r.id))]})}a(vc,"TaskChatLiveWorkLinks");var Ty=[];function Ne(e){if(!e)return 0;const s=new Date(e).getTime();return Number.isNaN(s)?0:s}a(Ne,"toMs");function bc(e){return(e??"").trim().replace(/\s+/g," ")}a(bc,"normalizedMessageText");function kc(e){if(!e)return null;if(e.startsWith("/")||e.startsWith("#"))return e;try{const s=new URL(e);return s.protocol==="http:"||s.protocol==="https:"?e:null}catch{return null}}a(kc,"safeResourceHref");function Ey(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}a(Ey,"formatResourceBytes");function Jr(e,s){if(e.kind!=="request_confirmation")return!1;const n=e.payload.target;return n?.type!=="issue_document"||n.key!=="plan"||n.issueId&&n.issueId!==s.issueId?!1:s.latestRevisionId?n.revisionId===s.latestRevisionId:n.revisionNumber===s.latestRevisionNumber}a(Jr,"interactionTargetsPlanRevision");function _y(e){return e.kind==="request_confirmation"&&(e.status==="accepted"||e.status==="rejected")&&e.payload.target?.type==="issue_document"&&e.payload.target.key==="plan"}a(_y,"isResolvedPlanConfirmation");function qy(e,s,n){if(!e.sourceRunId||e.kind!=="request_confirmation")return!1;const r=e.payload.target;return r?.type==="issue_document"&&r.key==="plan"&&(s.has(e.sourceRunId)||n===e.sourceRunId)}a(qy,"runnerTurnOwnsPlanPreview");function My(e,s,n,r,i){return!s||!Jr(e,s)?!1:n?qy(e,r,i):!0}a(My,"threadOwnsPlanPreview");function wc(e){const{comment:s,runId:n,runStartedAtMs:r,finalText:i}=e;if(s.deletedAt||s.authorType==="user")return!1;if(s.runId===n)return!0;if(s.runId||!i)return!1;const o=Ne(s.createdAt);return r!=null&&o<r-5e3?!1:bc(s.body)===bc(i)}a(wc,"isRunnerResponseComment");var Py=15e3,Fy=15e3,Dy=new Set,$y=4;function Ly(e){return e.filter(s=>s.kind==="brief"||s.kind==="interaction"||s.kind==="message"&&!s.interstitial).length>=$y}a(Ly,"shouldRepeatTaskChatBlockers");function Fs(e){return e?.runtimeMode==="native"&&e.adapterType==="wardmote_runner"}a(Fs,"isNativeWardmoteRunnerRun");var By="Run completed. Agent did not post a summary comment this run (transcript withheld — see run log).";function nl(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const s=e,n=s.semanticResult,r=[s.nativeResult,s.acceptedResult,n&&typeof n=="object"&&!Array.isArray(n)?n.result:null];for(const i of r){if(!i||typeof i!="object"||Array.isArray(i))continue;const o=i;if(o.schema==="wardmote.run_result.v1")return o}return null}a(nl,"acceptedSemanticResult");function jc(e){const s=nl(e);return typeof s?.summary=="string"&&s.summary.trim()?s.summary:null}a(jc,"acceptedSemanticResultSummary");function so(e){const s=nl(e);return typeof s?.reportedWorkDisposition=="string"?s.reportedWorkDisposition:null}a(so,"acceptedSemanticResultDisposition");function Oy(e){if(!e||typeof e!="object"||Array.isArray(e))return;const s=e.presentationDecision;if(!s||typeof s!="object"||Array.isArray(s))return;const n=s;if(n.schema==="wardmote.run_presentation_decision.v1")return typeof n.commentId=="string"&&n.commentId.trim()?n.commentId:null}a(Oy,"presentationDecisionCommentId");function Ky(e){if(!e||typeof e!="object"||Array.isArray(e))return new Set;const s=e.semanticToolReceipts;if(!s||typeof s!="object"||Array.isArray(s))return new Set;const n=new Set;for(const r of Object.values(s)){if(!r||typeof r!="object"||Array.isArray(r))continue;const i=r;if(i.operationId!=="report_progress")continue;const o=i.result;if(!o||typeof o!="object"||Array.isArray(o))continue;const u=o.commentId;typeof u=="string"&&u&&n.add(u)}return n}a(Ky,"semanticProgressCommentIds");function Uy(e){const s=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n=Array.isArray(s.verificationCaveats)?s.verificationCaveats:[];if(n.length>0)return n.flatMap(i=>{if(!i||typeof i!="object"||Array.isArray(i))return[];const o=i;return typeof o.commandOrCheck!="string"?[]:[{commandOrCheck:o.commandOrCheck,reasonCode:typeof o.reasonCode=="string"?o.reasonCode:null,detail:typeof o.detail=="string"?o.detail:null}]});const r=nl(e);return(Array.isArray(r?.verification)?r.verification:[]).flatMap(i=>{if(!i||typeof i!="object"||Array.isArray(i))return[];const o=i;return o.status!=="not_run"||typeof o.commandOrCheck!="string"?[]:[{commandOrCheck:o.commandOrCheck,reasonCode:typeof o.reasonCode=="string"?o.reasonCode:null,detail:typeof o.detail=="string"?o.detail:null}]})}a(Uy,"acceptedSemanticResultVerificationCaveats");function Qy(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const s=e.presentationDecision;return!!(s&&typeof s=="object"&&!Array.isArray(s)&&s.schema==="wardmote.run_presentation_decision.v1"&&s.chosenSource==="none")}a(Qy,"resolvedWithoutUserFacingResponse");function Wy(e){return e.kind==="ask_user_questions"?e.title??"Questions":e.kind==="suggest_tasks"?e.title??"Suggested tasks":e.kind==="request_checkbox_confirmation"?e.title??"Choose options":e.kind==="request_item_verdicts"?e.title??"Review items":e.kind==="connection_intent"?e.title??"Connect service":e.payload.target?.type==="issue_document"&&e.payload.target.key==="plan"?e.title??"Review plan":e.payload.toolAction?e.title??"Approve tool action":e.payload.secretProposal?e.title??"Review secret proposal":e.title??"Confirmation"}a(Wy,"durableInputLabel");function zy(e){const{initialHistoryPending:s=!1,initialHistoryError:n=!1,onRetryInitialHistory:r,comments:i,interactions:o,documents:u=[],workProducts:m=[],attachments:p=[],timelineEvents:h,issueId:d=null,agentMap:v,userLabelMap:k,userProfileMap:N,currentUserId:A,onAdd:E,onReviewConversation:_,onCancelRun:q,stopPending:O,stopScope:F,issueWorkMode:C="standard",onWorkModeChange:S,composerAccessory:P,footer:j,showComposer:f=!0,composerPause:w,composerDisabledReason:W,emptyMessage:M="No messages yet.",companyId:$,linkedRuns:K,liveRuns:le,activeRun:y,onAttachImage:z,imageUploadHandler:se,mentions:de,enableReassign:me,conversationMode:oe,pendingIssue:ve,reassignOptions:ie,currentAssigneeValue:ge,issueStatus:Ie,issueAssigneeAgentId:De=null,onAcceptInteraction:$e,onRejectInteraction:Be,onSubmitInteractionAnswers:Fe,onCancelInteraction:re,onSkipInteraction:Se,onSubmitInteractionVerdicts:Ve,externalReferences:Je,threadHeader:ft,threadHeaderActions:Ze,browsers:Te=Ty,onOpenBrowser:Nt,hasOlderComments:vt=!1,issueBrief:Ut,feedbackVotes:Y,feedbackDataSharingPreference:Ae="prompt",feedbackTermsUrl:ht=null,onVote:U,onSetCommentPublicShare:Ue,draftKey:St,onInterruptQueued:_e,onCancelQueued:et,interruptingQueuedRunId:rt,onTryAgainNoLiveExecutionPath:us,tryAgainNoLiveExecutionPathPending:Vs=!1,onRetryFailedRun:Rt,retryFailedRunId:xt=null,queuedCommentQueue:Qt,onEditQueuedComment:Ct,onReorderQueuedComments:ts,onSteerQueuedComment:$t,onDiscardQueuedComment:ms,blockedBy:Wt=[],blockerAttention:lt,liveIssueIds:$s,onResumeAssignee:ps,resumeAssigneePending:Gs=!1,onOpenSkill:Ys}=e,yt=jo(Ie)||o?.some(x=>x.status==="pending")||pl(e.recoveryAction?.cause)||e.scheduledRetry||K?.some(x=>x.runtimeMode==="legacy"&&(x.status==="failed"||x.status==="timed_out")&&x.execution?.phase==="recovery_needed"&&x.execution.cause==="legacy_execution_requires_reconciliation"&&x.adapterType==="omp_local"?!1:["working","retry_scheduled","reconnecting","finishing","queued","recovery_needed"].includes(x.execution?.phase??""))?void 0:Rt,fs=!!yt,Q=ks(),ke=s0(e.creationActivity??[],$),tt=(0,l.useMemo)(()=>n0(e.creationActivity??[]),[e.creationActivity]),[be,it]=(0,l.useState)(null),Js=be===null?De:be.startsWith("agent:")&&be.slice(6)||null,ws=py(d,Js);(0,l.useEffect)(()=>{it(null)},[ge,d]);const Hn=(0,l.useCallback)(async x=>{if(!d)throw new Error("The task is not available for reassignment.");await xe.update(d,{...x,deferWakeForGoal:!0}),await Q.invalidateQueries({queryKey:R.issues.detail(d)})},[d,Q]),Dt=Qt&&Qt.entries.length>0?Qt:null,Vn=(0,l.useMemo)(()=>({issueId:d??"",queueId:null,state:null,targetRunId:null,revision:"empty",protocol:"wardmote_runner_v1",steeringDisposition:"temporarily_unavailable",entries:[]}),[d]),an=(0,l.useMemo)(()=>new Set(Dt?.entries.map(x=>x.comment.id)??[]),[Dt]),[g,Et]=(0,l.useState)(null),D=(0,l.useCallback)(x=>{const T=Dt?.entries.find(X=>X.comment.id===x);!T?.canEdit||!Dt||Et({commentId:x,body:T.comment.body,revision:Dt.revision})},[Dt]),ee=(0,l.useCallback)(async(x,T)=>{if(!g||g.commentId!==x)throw new Error("This queued message is no longer editable.");if(g.stale){await E(T);return}if(!Ct)throw new Error("This queued message is no longer editable.");try{await Ct(x,T,g.revision)}catch(X){const L=typeof X=="object"&&X!==null?X:null,J=typeof L?.body=="object"&&L.body!==null?L.body:null,je=typeof J?.details=="object"&&J.details!==null?J.details:null,Xe=typeof je?.code=="string"?je.code:typeof J?.code=="string"?J.code:null;throw L?.status===409&&(Xe==="queued_comment_stale_target"||Xe==="queued_comment_not_pending")&&Et(Jt=>Jt?.commentId===x?{...Jt,stale:!0}:Jt),X}},[E,Ct,g]);(0,l.useEffect)(()=>{!g||g.stale||(Dt?.entries.some(x=>x.comment.id===g.commentId)?Dt&&g.revision!==Dt.revision&&Et(x=>x&&{...x,revision:Dt.revision}):Et(x=>x&&{...x,stale:!0}))},[g,Dt]);const H=(0,l.useMemo)(()=>Ie==="blocked"&&lt?.state==="covered"?Ry(Wt,$s??Dy,lt.terminalBlocker):null,[Wt,lt?.state,lt?.terminalBlocker,Ie,$s]),st=(0,l.useMemo)(()=>Ie==="blocked"&&!H?Ay(Wt,lt?.terminalBlockerIssueId,lt?.directBlockerIssueId,lt?.terminalBlocker):null,[Wt,lt?.directBlockerIssueId,lt?.terminalBlocker,lt?.terminalBlockerIssueId,Ie,H]),zt=ft||st||H?(0,t.jsxs)(t.Fragment,{children:[ft,H?(0,t.jsx)(vc,{liveWork:H,placement:"top"}):st?(0,t.jsx)(yc,{directBlocker:st.directBlocker,ultimateBlocker:st.ultimateBlocker,placement:"top"}):null]}):void 0,qe=(0,l.useMemo)(()=>{const x=new Map;for(const T of K??[])x.set(T.runId,T);return x},[K]),Le=(0,l.useMemo)(()=>{const x=new Set;for(const T of K??[])T.retryOfRunId&&x.add(T.retryOfRunId);return x},[K]),Tn=(0,l.useMemo)(()=>U0(Ie,[...(K??[]).map(x=>({...x,id:x.runId})),...le??[],...y?[y]:[]],e.recoveryAction),[Ie,K,le,y,e.recoveryAction]),Gn=(0,l.useMemo)(()=>{const x=new Map;for(const T of K??[]){const X=Uy(T.resultJson);X.length>0&&x.set(T.runId,X)}return x},[K]),Ht=(0,l.useMemo)(()=>i.flatMap(x=>{if(Tn.isHistoricalNotice(x))return[];if(Jg(x,o))return[];if(x.body!==By||!x.runId)return[x];const T=qe.get(x.runId)?.resultJson;if(so(T)==="yielded")return[];const X=jc(T);return[X?{...x,body:X}:x]}),[i,o,qe,Tn]),_t=(0,l.useMemo)(()=>C0(Ht,{agentMap:v,userLabelMap:k,userProfileMap:N,currentUserId:A,issueAssigneeAgentId:De,verificationCaveatsByRunId:Gn}),[Ht,v,k,N,A,De,Gn]),We=(0,l.useMemo)(()=>{const x=new Map;for(const T of K??[])x.set(T.runId,{id:T.runId,status:T.status,adapterType:T.adapterType??"",runtimeMode:T.runtimeMode,hasStoredOutput:T.hasStoredOutput,logBytes:T.logBytes});for(const T of le??[])x.set(T.id,{id:T.id,status:T.status,adapterType:T.adapterType,runtimeMode:T.runtimeMode,hasStoredOutput:x.get(T.id)?.hasStoredOutput,logBytes:T.logBytes,lastOutputBytes:T.lastOutputBytes});return y&&x.set(y.id,{id:y.id,status:y.status,adapterType:y.adapterType,runtimeMode:y.runtimeMode,logBytes:y.logBytes,lastOutputBytes:y.lastOutputBytes}),[...x.values()]},[K,le,y]),Rs=(0,l.useMemo)(()=>We.filter(x=>x.runtimeMode==="native"),[We]),{transcriptByRun:Ls,errorsByRun:ss,isInitialHydrating:Xs,hydratedRunIds:gn,retry:Yn}=w0(Rs),ba=(0,l.useMemo)(()=>We.filter(x=>x.runtimeMode!=="native"||x.status==="running"||x.status==="queued"||ss.has(x.id)||gn?.has(x.id)&&(Ls.get(x.id)?.length??0)===0),[We,ss,gn,Ls]),{transcriptByRun:Ts,isInitialHydrating:ka,hydratedRunIds:wa,errorsByRun:za,retry:Vt}=Xg({runs:ba,companyId:$}),xn=(0,l.useRef)(new Map),js=(0,l.useMemo)(()=>{const x=new Map(Ts);for(const T of Rs){const X=Ls.get(T.id)??[],L=Ts.get(T.id)??[];ss.has(T.id)&&L.length>0&&xn.current.set(T.id,L);const J=xn.current.get(T.id),je=a(Xe=>Xe.reduce((Jt,Dn)=>Math.max(Jt,Ne(Dn.ts)),0),"lastTimestamp");J&&(ss.has(T.id)||je(X)<je(J))?x.set(T.id,J):X.length>0&&(xn.current.delete(T.id),x.set(T.id,X))}for(const T of xn.current.keys())Rs.some(X=>X.id===T)||xn.current.delete(T);return x},[Ts,Rs,Ls,ss]),pe=(0,l.useMemo)(()=>jo(Ie)?null:y&&Bl(y,Ie)?y:(le??[]).find(x=>Bl(x,Ie))??null,[y,Ie,le]),[Ge,En]=(0,l.useState)(null),Jn=(0,l.useRef)(null);(0,l.useLayoutEffect)(()=>{if(pe){Jn.current=pe,En(T=>T&&T.id!==pe.id?null:T);return}const x=Jn.current;Jn.current=null,x&&En({id:x.id,startedAtMs:(x.startedAt?Ne(x.startedAt):null)??Ne(x.createdAt)})},[pe]);const Gt=pe&&Fs(pe)?pe.id:Ge&&Fs(We.find(x=>x.id===Ge.id))?Ge.id:null,_n=pe&&Gt===pe.id?(pe.startedAt?Ne(pe.startedAt):null)??Ne(pe.createdAt):Ge?.startedAtMs??null,rn=(0,l.useMemo)(()=>{if(!Gt)return null;const x=js.get(Gt)??[];for(let T=x.length-1;T>=0;T-=1){const X=x[T];if(X.kind==="assistant"&&X.channel==="final"&&X.text.trim())return X.text}return null},[Gt,js]),yn=(0,l.useRef)(new Set);(0,l.useEffect)(()=>{pe&&yn.current.add(pe.id)},[pe]);const Is=(0,l.useMemo)(()=>{const x=new Map;for(const T of Ht)T.deletedAt||!T.runId||!T.id||x.set(T.runId,T.id);for(const T of Ht){const X=T.steeredIntoRunId;!T.deletedAt&&X&&T.conversationAnchorAt&&x.delete(X)}return x},[Ht]),ns=(0,l.useMemo)(()=>{const x=new Map;for(const T of i){const X=T.steeredIntoRunId;if(T.deletedAt||!X||!T.conversationAnchorAt)continue;const L=Ne(T.conversationAnchorAt);if(!Number.isFinite(L))continue;const J=x.get(X)??[];J.includes(L)||J.push(L),x.set(X,J)}for(const T of x.values())T.sort((X,L)=>X-L);return x},[i]),{data:Me,isLoading:vn,isError:on,refetch:Xn}=Fo(d),Yt=(0,l.useMemo)(()=>{if(!Me)return null;const x=new Map;for(const J of K??[])x.set(J.runId,{...J,id:J.runId,adapterType:J.adapterType??""});for(const J of le??[])x.set(J.id,J);y&&x.set(y.id,y);const T=(o??[]).find(J=>J.sourceRunId?Fs(x.get(J.sourceRunId))&&Jr(J,Me):!1);if(T?.sourceRunId)return T.sourceRunId;const X=Ne(Me.updatedAt),L=[...x.values()].filter(J=>{if(!Fs(J)||Me.updatedByAgentId&&J.agentId&&Me.updatedByAgentId!==J.agentId)return!1;const je=Ne(J.startedAt??J.createdAt),Xe=J.finishedAt?Ne(J.finishedAt):Number.POSITIVE_INFINITY;return je<=X+1e3&&X<=Xe+1e3});return L.sort((J,je)=>Ne(je.startedAt??je.createdAt)-Ne(J.startedAt??J.createdAt)),L[0]?.id??null},[y,o,K,le,Me]),Ns=(0,l.useMemo)(()=>!Me||!Yt?null:{id:`plan-doc:${Me.latestRevisionId??Me.id}`,kind:"plan_document",document:Me},[Me,Yt]),Lt=(0,l.useMemo)(()=>{const x=[],T=Ht.filter(L=>!L.deletedAt);T.forEach((L,J)=>{if(an.has(L.id)||Gt&&wc({comment:L,runId:Gt,runStartedAtMs:_n,finalText:rn}))return;const je=_t[J];je&&x.push({ms:L.conversationAnchorAt?Ne(L.conversationAnchorAt):Ne(L.createdAt),order:1+Math.min(L.conversationAnchorSequence??0,999)/1e3,id:je.id,item:je})});for(const L of o??[]){if(dc(L))continue;const J=L.kind==="ask_user_questions"&&L.status!=="pending"&&L.result?.expirationReason==="superseded_by_newer_interaction";if(lr(L)&&!J||L.status==="pending"&&Me&&Yt===L.sourceRunId&&Jr(L,Me))continue;const je=Ne(L.createdAt),Xe=L.kind==="request_confirmation"&&L.sourceRunId?tx({interactionCreatedAtMs:je,sourceRunId:L.sourceRunId,comments:i,timelineEvents:h??[],linkedRuns:K??[],liveRuns:le??[]}):null,Jt=`interaction:${L.id}`;x.push({ms:_y(L)?Xe??je:cy(L,Xe??je),order:2,id:Jt,item:{id:Jt,kind:"interaction",interaction:L}})}for(const L of u){if(L.key==="plan")continue;const J=`resource:document:${L.id}`;x.push({ms:Ne(L.updatedAt),order:3,id:J,item:{id:J,kind:"protocol",surface:"resource",resourceKind:"document",title:Cn(L),subtitle:`Document · rev ${L.latestRevisionNumber}`,href:Wm({documentKey:L.key,threadId:null,commentId:null}),timestamp:new Date(L.updatedAt).toISOString(),document:L}})}for(const L of m){const J=`resource:deliverable:${L.id}`,je=xf(L);x.push({ms:Ne(L.createdAt),order:3,id:J,item:{id:J,kind:"protocol",surface:"resource",resourceKind:"deliverable",title:L.title,subtitle:[L.type.replaceAll("_"," "),L.status,L.reviewState!=="none"?L.reviewState:null].filter(Boolean).join(" · "),href:kc(je),timestamp:new Date(L.createdAt).toISOString(),workProduct:L}})}for(const L of vf(p,m)){const J=`resource:attachment:${L.id}`;x.push({ms:Ne(L.createdAt),order:3,id:J,item:{id:J,kind:"protocol",surface:"resource",resourceKind:"attachment",title:L.originalFilename??"Agent attachment",subtitle:`${L.contentType} · ${Ey(L.byteSize)}`,href:kc(L.openPath??L.contentPath),timestamp:new Date(L.createdAt).toISOString(),attachment:L}})}if(Me&&!Yt){const L=`plan-doc:${Me.latestRevisionId??Me.id}`;x.push({ms:Ne(Me.updatedAt),order:0,id:L,item:{id:L,kind:"plan_document",document:Me}})}for(const L of ke)x.push({id:L.id,item:L,ms:Ne(L.timestamp),order:2});for(const L of tt)x.push({id:L.id,item:L,ms:Ne(L.timestamp),order:2});const X=vt?Math.min(...T.map(L=>Ne(L.conversationAnchorAt??L.createdAt))):-1/0;for(const[L,J]of Te.entries()){if(Ne(J.createdAt)<X)continue;const je=`browser:${J.sessionId}`;x.push({id:je,ms:Ne(J.createdAt),order:2,item:{id:je,kind:"browser",browser:J,label:Te.length>1?`Browser ${L+1}`:"Browser",timestamp:J.createdAt}})}return x.sort((L,J)=>L.ms-J.ms||L.order-J.order||L.id.localeCompare(J.id))},[ke,tt,Te,vt,i,Ht,_t,o,u,m,p,h,K,le,Me,Yt,Gt,_n,rn,an]),bn=(0,l.useMemo)(()=>{const x=new Map;for(const X of K??[])x.set(X.runId,{adapterType:X.adapterType??"",runtimeMode:X.runtimeMode,startMs:Ne(X.startedAt??X.createdAt),endMs:X.finishedAt?Ne(X.finishedAt):Number.POSITIVE_INFINITY});for(const X of le??[])x.set(X.id,{adapterType:X.adapterType,runtimeMode:X.runtimeMode,startMs:Ne(X.startedAt??X.createdAt),endMs:X.finishedAt?Ne(X.finishedAt):Number.POSITIVE_INFINITY});y&&x.set(y.id,{adapterType:y.adapterType,runtimeMode:y.runtimeMode,startMs:Ne(y.startedAt??y.createdAt),endMs:y.finishedAt?Ne(y.finishedAt):Number.POSITIVE_INFINITY});const T=new Map;for(const[X,L]of x){if(Fs(L)||!Number.isFinite(L.startMs))continue;const J=Lt.map(je=>je.ms).filter(je=>Number.isFinite(je)&&je>L.startMs&&je<=L.endMs);J.length>0&&T.set(X,[...new Set(J)].sort((je,Xe)=>je-Xe))}return T},[y,K,le,Lt]),ja=!!Ut,{items:ln,settledRunIds:cn,settledReplyRunIds:Zn}=(0,l.useMemo)(()=>{const x=new Set,T=new Set,X=[...Lt],L=[],J=new Map;let je=null;for(const V of We){if(!xa(V.status)||pe&&V.id===pe.id)continue;const pt=js.get(V.id)??[],te=qe.get(V.id),_s=e0(te?{...te,agentName:te.agentName||v?.get(te.agentId)?.name}:void 0,A,k),qs=Tn.isHistoricalRun(V.id);if(V.status==="cancelled"&&te?.errorCode==="workspace_busy"){x.add(V.id);continue}if(te?.resultJson?.conversationReset===!0){x.add(V.id);continue}if(V.status==="cancelled"&&pt.length===0&&(te?.errorCode==="issue_not_in_progress"||te?.errorCode==="issue_terminal_status"&&!te.startedAt)){x.add(V.id);continue}if(V.status==="cancelled"&&!te?.startedAt&&te?.errorCode==="execution_reconciliation_required"&&pt.length===0&&!Is.has(V.id)){if(x.add(V.id),qs)continue;const fe=te?.resultJson?.executionWait,Zt=fe&&typeof fe=="object"&&"recoveryActionId"in fe?String(fe.recoveryActionId):"execution_reconciliation_required";if(je!==Zt){const dt=`${V.id}:execution-wait`;X.push({ms:Ne(te?.finishedAt??te?.createdAt),order:3,id:dt,item:{id:dt,kind:"marker",variant:"interrupted",tone:"neutral",label:"Waiting to resume",detail:"The previous execution needs to be checked before work can continue. See the task’s execution hold for the next action. Individual checks remain in the run history."}})}je=Zt;continue}je=null;const Ws=jc(te?.resultJson),os=Or(pt,{runId:V.id,agentName:te?.agentName,running:!1}),In=(o??[]).some(fe=>fe.sourceRunId===V.id&&fe.status==="pending"),$n=V.status==="succeeded"&&!In&&yx(os,V.id),fn=(so(te?.resultJson)==="yielded"||pt.some(fe=>fe.kind==="run_result"&&fe.disposition==="yielded"))&&!$n,Xt=Fs(V),Nn=Oy(te?.resultJson),qr=Ky(te?.resultJson),en=Nn===void 0?[...Ht].reverse().find(fe=>!fe.deletedAt&&fe.runId===V.id&&!qr.has(fe.id))?.id??null:Nn!==null&&Ht.some(fe=>!fe.deletedAt&&fe.runId===V.id&&fe.id===Nn)?Nn:null,ds=en!==null,Ms=en?Ht.find(fe=>fe.id===en)?.body??null:null,tr=Xt&&!fn&&(ds||!!Ws||pt.some(fe=>fe.kind==="assistant"&&fe.channel!=="progress"&&!!fe.text.trim()||fe.kind==="run_result"&&!!fe.summary.trim())),oa=Xt&&(V.status==="failed"||V.status==="timed_out"||V.status==="cancelled"||V.status==="interrupted");if(oa){x.add(V.id);const fe=te?.errorCode??(V.status==="timed_out"?"native_runner_timed_out":"native_runner_process_exited"),Zt=fe==="native_provider_model_rejected"&&V.status==="failed"?"Model unavailable":fe==="native_provider_approval_required"&&V.status==="failed"?"Approval required":fe==="native_provider_usage_limit"&&V.status==="failed"?"Usage limit reached":V.status==="cancelled"?"Run cancelled":V.status==="interrupted"?"Run interrupted":V.status==="timed_out"?"Run timed out":"Run failed",dt=tr?" after returning a final response":"",xs=V.status==="cancelled"?`The run was cancelled${dt}.`:V.status==="interrupted"?`The run was interrupted${dt}.`:fe==="native_provider_approval_required"?"This operation requires approval, but this runner has no interactive approval handler. Review the operation and update the agent's permission setting before retrying.":fe==="native_provider_model_rejected"?`${te?.error||"The provider rejected the selected model."} Choose a supported model or clear the task's model override, then retry.`:fe==="native_provider_usage_limit"&&V.status==="failed"?"The model provider has reached its current usage limit. Try again after the limit resets.":fe==="provider_frame_too_large"?"Provider output exceeded the safe limit.":V.status==="timed_out"?`The runner timed out${dt} (${fe}).`:`The runner stopped${dt} (${fe}).`,As=`${V.id}:failure`,Ps=te?.agentId?v?.get(te.agentId):void 0,tn=te?.finishedAt??te?.startedAt??te?.createdAt;qs||X.push({ms:Ne(tn),order:3,id:As,item:{id:As,kind:"marker",variant:"interrupted",tone:V.status==="cancelled"?"neutral":"error",label:Zt,detail:xs,retryable:fe!=="native_session_cleanup_quarantined",..._s?{credentialAccess:_s,retryable:!1}:{},collapsible:!0,runId:V.id,createdAtIso:tn?new Date(tn).toISOString():void 0,runHref:Ps?`/agents/${encodeURIComponent(Ps.urlKey)}/runs/${encodeURIComponent(V.id)}`:_s&&te?.agentId?`/agents/${encodeURIComponent(te.agentId)}/runs/${encodeURIComponent(V.id)}`:void 0}})}const Ln=!Xt&&(V.status==="failed"||V.status==="timed_out"||V.status==="cancelled"&&pt.length===0);if(Ln){x.add(V.id);const fe=te?.errorCode??"native_runner_process_exited",Zt=te?.scheduledRetryAt||Le.has(V.id)?"Retry scheduled automatically.":fs?"You can retry this message now.":"Your message is preserved.",dt=Xm(te?.resultJson),xs=te?.resultJson?.configurationIncomplete?.reason==="workspace_base_ref_unresolved",As=!!(Me&&(te?.resultJson?.savedPlanRevisionId===Me.latestRevisionId||o?.some(sn=>sn.sourceRunId===V.id&&Jr(sn,Me)))),Ps=o?.find(sn=>sn.kind==="connection_intent"&&sn.payload.purpose==="ai"&&sn.sourceRunId===V.id),tn=xs?"Repair the starting branch below before retrying.":dt?Zx({result:te?.resultJson,savedPlan:As,hasResponse:ds||!!Ws}):Ps?Ps.status==="pending"?"Use the connection card below to continue.":"This run stopped because its AI account was unavailable.":V.status==="cancelled"?fe==="execution_reconciliation_required"?"The previous execution must be checked before this task can continue. Your message is preserved. View the stopped run for details.":"Execution was stopped.":fe==="provider_frame_too_large"?`Provider output exceeded the safe limit. ${Zt}`:fe.startsWith("workspace_git_scan_")?`Workspace setup failed before the agent started. ${Zt}`:`The run failed (${fe}). ${Zt}`,ua=`${V.id}:failure`;qs||X.push({ms:Ne(te?.finishedAt??te?.startedAt??te?.createdAt),order:3,id:ua,item:{id:ua,kind:"marker",variant:"interrupted",label:xs?"Starting branch unavailable":dt?"Workspace restore failed":Ps?.status==="pending"?"AI connection needed":V.status==="cancelled"?te?.startedAt?"Stopped":"Couldn't start":"Run failed",runId:V.status==="cancelled"?void 0:V.id,...xs||Ps?.status==="pending"?{retryable:!1}:{},...dt?{retryable:te?.resultJson?.workspaceRestoreFailure!=="restore_unsafe_archive",collapsible:!0,runHref:te?.agentId?`/agents/${encodeURIComponent(v?.get(te.agentId)?.urlKey??te.agentId)}/runs/${encodeURIComponent(V.id)}`:void 0,planHref:As?"#document-plan":void 0}:{},..._s?{credentialAccess:_s,retryable:!1,runHref:`/agents/${encodeURIComponent(te?.agentId??"")}/runs/${encodeURIComponent(V.id)}`}:{},tone:V.status==="cancelled"||Ps?.status==="pending"?"neutral":"error",detail:tn}})}if(pt.length===0){if(Xt&&fn){x.add(V.id);continue}if(Fs(V)&&Ws&&!ds){const fe=Ne(te?.startedAt??te?.createdAt),Zt=Ne(te?.finishedAt),dt=fe>0&&Zt>0?Math.max(0,Zt-fe):void 0,xs=V.status!=="succeeded",As=`${V.id}:turn`;J.set(As,{agentKey:te?.agentId??"",agentName:te?.agentName,parts:[{entries:pt,durationMs:dt,failed:xs}]}),L.push({turn:{id:As,kind:"turn",settled:!0,historical:qs,agentName:te?.agentName??(te?.agentId?v?.get(te.agentId)?.name:void 0),agent:te?.agentId?v?.get(te.agentId)??{id:te.agentId}:void 0,agentIcon:te?.agentId?v?.get(te.agentId)?.icon:void 0,standaloneHeader:!0,animateFold:yn.current.has(V.id),items:[],finalResponse:ir([],{runId:V.id,agentName:te?.agentName,fallbackSummary:Ws}),summary:Gi(pt,{durationMs:dt,failed:xs})},anchorCommentId:null,startMs:fe>0?fe:Number.POSITIVE_INFINITY}),x.add(V.id),T.add(V.id)}else if(!oa&&!Ln&&!Is.has(V.id)){x.add(V.id);const fe=`${V.id}:terminal-notice`;qs||X.push({ms:Ne(te?.finishedAt??te?.startedAt??te?.createdAt),order:3,id:fe,item:{id:fe,kind:"marker",variant:"turn_boundary",label:V.status==="cancelled"?"Stopped":"Run completed",detail:V.status==="cancelled"?"This turn was cancelled before it returned a response.":"The runner returned no user-facing response."}})}continue}const Mr=te?.startedAt?new Date(te.startedAt).getTime():NaN,Bn=te?.finishedAt?new Date(te.finishedAt).getTime():NaN,la=Number.isFinite(Mr)&&Number.isFinite(Bn)?Math.max(0,Bn-Mr):void 0;if(V.status==="succeeded"&&!ds&&Qy(te?.resultJson)&&!tr){const fe=`${V.id}:terminal-notice`;qs||X.push({ms:Ne(te?.finishedAt??te?.startedAt??te?.createdAt),order:3,id:fe,item:{id:fe,kind:"marker",variant:"turn_boundary",label:"Run completed",detail:"The runner returned no user-facing response."}})}const Ta=V.status!=="succeeded",Ea=te?.startedAt??te?.createdAt,_a=Ea?Ne(Ea):Number.POSITIVE_INFINITY,Pr=Xt?ns.get(V.id)??[]:bn.get(V.id)??[],sr=Wl(pt,_a,Pr),ca=Vi(pt,{runId:V.id,agentName:te?.agentName,running:!1}),On=sr.map(fe=>{const Zt=zi(Or(fe.entries,{runId:V.id,agentName:te?.agentName,running:!1}),fe.entries,ca),dt=V.id===Yt&&Ns?Hi(Zt,Ns):Zt,xs=qs?Q0(dt):dt;return{segment:fe,parsed:dt,timelineItems:Xt?Io(xs):xs}}),Fr=Xt&&!fn?Ms??ir(os,{runId:V.id,agentName:te?.agentName,fallbackSummary:Ws})?.text:void 0,qa=Xt?Ix(On.map(({timelineItems:fe})=>fe),Fr):On.map(({timelineItems:fe})=>fe);let da=-1;for(let fe=On.length-1;fe>=0;fe-=1)if((On[fe]?.segment.entries.length??0)>0){da=fe;break}for(const[fe,Zt]of On.entries()){const{segment:dt,parsed:xs}=Zt;if(dt.entries.length===0)continue;const As=Xt&&!fn&&!ds?$n?fe===da?ir(os,{runId:V.id,agentName:te?.agentName}):void 0:ir(xs,{runId:V.id,agentName:te?.agentName,fallbackSummary:fe===da?Ws:void 0}):void 0,Ps=Pr.length>0,tn=Ps?`${V.id}:turn:${fe}`:`${V.id}:turn`,ua=zl(qa[fe]??[],tn);if(ua.length===0&&!As&&!Xt)continue;x.add(V.id),As&&T.add(V.id);const sn=Number.isFinite(dt.endMs)?dt.endMs:Bn,Dr=Number.isFinite(dt.startMs)&&Number.isFinite(sn)?Math.max(0,sn-dt.startMs):la;J.set(tn,{agentKey:te?.agentId??"",agentName:te?.agentName,parts:[{entries:dt.entries,durationMs:Dr,failed:Ta}]}),L.push({turn:{id:tn,kind:"turn",settled:!0,historical:qs,agentName:te?.agentName??(te?.agentId?v?.get(te.agentId)?.name:void 0),agent:te?.agentId?v?.get(te.agentId)??{id:te.agentId}:void 0,agentIcon:te?.agentId?v?.get(te.agentId)?.icon:void 0,standaloneHeader:Xt,continuedAfterSteering:Xt&&fe>0,animateFold:yn.current.has(V.id),items:ua,finalResponse:As,summary:Gi(dt.entries,{durationMs:Dr,failed:Ta})},anchorCommentId:Ps?null:Xt?ds?en:null:Is.get(V.id)??null,startMs:dt.startMs})}}if(pe){const V=Fs(pe)?ns.get(pe.id)??[]:bn.get(pe.id)??[];if(V.length>0){const pt=js.get(pe.id)??[],te=(pe.startedAt?Ne(pe.startedAt):null)??Ne(pe.createdAt),_s=Wl(pt,te,V),qs=Vi(pt,{runId:pe.id,agentName:pe.agentName,running:!0});for(const[Ws,os]of _s.slice(0,-1).entries()){if(os.entries.length===0)continue;const In=zi(Or(os.entries,{runId:pe.id,agentName:pe.agentName,running:!1}),os.entries,qs),$n=pe.id===Yt&&Ns?Hi(In,Ns):In,fn=`${pe.id}:turn:${Ws}`,Xt=zl(Fs(pe)?Io($n):$n,fn);if(Xt.length===0)continue;const Nn=Number.isFinite(os.startMs)&&Number.isFinite(os.endMs)?Math.max(0,os.endMs-os.startMs):void 0;J.set(fn,{agentKey:pe.agentId??"",agentName:pe.agentName,parts:[{entries:os.entries,durationMs:Nn,failed:!1}]}),L.push({turn:{id:fn,kind:"turn",settled:!0,agentName:pe.agentName??(pe.agentId?v?.get(pe.agentId)?.name:void 0),agent:pe.agentId?v?.get(pe.agentId)??{id:pe.agentId}:void 0,agentIcon:pe.agentId?v?.get(pe.agentId)?.icon:void 0,standaloneHeader:Fs(pe),continuedAfterSteering:Fs(pe)&&Ws>0,items:Xt,summary:Gi(os.entries,{durationMs:Nn})},anchorCommentId:null,startMs:os.startMs})}}}L.sort((V,pt)=>V.startMs<pt.startMs?-1:V.startMs>pt.startMs?1:0);const Xe=new Map,Jt=[];for(const{turn:V,anchorCommentId:pt,startMs:te}of L)if(pt){const _s=Xe.get(pt)??[];_s.push(V),Xe.set(pt,_s)}else Jt.push({turn:V,startMs:te});X.sort((V,pt)=>V.ms-pt.ms||V.order-pt.order||V.id.localeCompare(pt.id));const Dn=jx(X,Xe,Jt);return{items:bx(wx(vx(Dn,J),J),ja),settledRunIds:x,settledReplyRunIds:T}},[Lt,Tn,fs,o,We,pe,js,qe,Le,Is,i,Ht,ns,bn,ja,Me,Yt,Ns,v,A,k]),Ia=Ge!=null&&Fs(We.find(x=>x.id===Ge.id)),Bs=Ge!=null&&i.some(x=>Ia?wc({comment:x,runId:Ge.id,runStartedAtMs:Ge.startedAtMs,finalText:rn}):x.runId===Ge.id&&!x.deletedAt),Os=Ge!=null&&(o??[]).some(x=>x.sourceRunId===Ge.id&&!dc(x)&&!lr(x)),as=Ge!=null&&(Ia?cn.has(Ge.id)&&(Bs||Os||Zn.has(Ge.id)):Bs||cn.has(Ge.id));(0,l.useEffect)(()=>{if(!Ge)return;if(as){En(null);return}const x=window.setTimeout(()=>En(null),Py);return()=>window.clearTimeout(x)},[Ge,as]);const Ss=!pe&&Ge!=null&&!as&&(js.get(Ge.id)?.length??0)>0,Re=pe?pe.id:Ss?Ge.id:null,qt=!!pe,Qe=Fs(Re?We.find(x=>x.id===Re):void 0),kn=!!(Qe&&(so(Re?qe.get(Re)?.resultJson:null)==="yielded"||(o??[]).some(x=>x.sourceRunId===Re&&x.status==="pending"))),At=Re?js.get(Re)??[]:[],Bt=!!(Re&&ss.has(Re)&&(Ts.get(Re)?.length??0)===0&&!ka),Ks=Re?Qe?ns.get(Re)??[]:bn.get(Re)??[]:[],Es=Re?Ks.length>0?`${Re}:turn:${Ks.length}`:`${Re}:turn`:null,rs=Ks.length>0?Ks[Ks.length-1]:null,qn=rs==null?At:At.filter(x=>Ne(x.ts)>=rs),wn=Re===Yt?Ns:null,ea=At.reduce((x,T)=>{const X="text"in T?T.text:"",L="content"in T?T.content:"",J="channel"in T?T.channel??"":"",je="lifecycle"in T?T.lifecycle??"":"",Xe="isError"in T?T.isError?"error":"ok":"",Jt=T.kind==="result"?`${T.subtype}:${T.inputTokens}:${T.outputTokens}:${T.cachedTokens}:${T.costUsd}`:"",Dn=T.kind==="runtime_request"?JSON.stringify(T):"";return`${x}|${T.kind}:${J}:${je}:${Xe}:${Jt}:${X}:${L}:${Dn}`},String(At.length)),dn=`${rs??"run-start"}:${ea}`,Na=st?`${st.directBlocker.id}:${st.ultimateBlocker?.id??""}`:H?`live:${H.steps.map(x=>`${x.blocker.id}:${x.status}`).join(",")}:${H.nowRunning.map(x=>x.id).join(",")}`:"",Mn=wn?`${wn.id}:${wn.document.body.length}`:"",Pn=`${Kf(ln)}:${dn}:${Mn}:${Na}`,un=Ly(ln)?H?(0,t.jsx)(vc,{liveWork:H,placement:"bottom"}):st?(0,t.jsx)(yc,{directBlocker:st.directBlocker,ultimateBlocker:st.ultimateBlocker,placement:"bottom"}):null:null,he=Ge?qe.get(Ge.id)?.finishedAt:void 0,ze=pe?pe.status:We.find(x=>x.id===Ge?.id)?.status??"succeeded",gt=rs??(pe?(pe.startedAt?Ne(pe.startedAt):null)??Ne(pe.createdAt):Ge?.startedAtMs??null),Ee=pe?pe.finishedAt?Ne(pe.finishedAt):null:he?Ne(he):null,Oe=(0,l.useMemo)(()=>Re?H0(qn):null,[Re,dn]),He=pe?.agentName??qe.get(Re??"")?.agentName,nt=pe?.agentId??qe.get(Re??"")?.agentId??De,Tt=nt?v?.get(nt):void 0,mn=He??Tt?.name??null,Ha=Tt?.icon??null,Us=(0,l.useMemo)(()=>{if(!Re)return[];const x=Vi(At,{runId:Re,agentName:He,running:qt}),T=zi(Or(qn,{runId:Re,agentName:He,running:qt}),qn,x,qt);return wn?Hi(T,wn):T},[Re,dn,qt,He,Mn]),ta=(0,l.useMemo)(()=>xa(ze)?null:D0(Us),[Us,ze]),ot=G0(Us),Z=(0,l.useCallback)(async(x,T)=>{const X=(o??[]).find(J=>J.kind==="ask_user_questions"&&J.sourceRunId===x.runId&&J.payload.runtimeRequestId===x.requestId);if(X?.kind==="ask_user_questions"){if(X.status!=="pending")throw new Error("This question has already been answered or closed.");if(T.action==="cancel"){if(!re)throw new Error("Cancelling this question is unavailable.");await re(X);return}if(T.action!=="submit"||!("response"in T)||!X.payload.questionSet||!Fe)throw new Error("Submit the answer through the saved question card.");const J=T.response;await Fe(X,X.payload.questionSet.questions.map(je=>{const Xe=J.answers[je.id],Jt=je.answerMode==="text"?Xe?.text?.trim():Xe?.customText?.trim();return{questionId:je.id,optionIds:je.answerMode==="text"?[]:Xe?.selectedOptionIds??[],...Jt?{otherText:Jt}:{}}}));return}if(!x.turnId||!x.requestKind)throw new Error("This runtime request is missing the provider turn identity needed to resolve it.");let L;if(T.action!=="submit")L=T;else if("response"in T)L={action:"submit",response:T.response};else if(x.requestKind==="user_input")L={action:"submit",answers:Object.fromEntries(Object.entries(T.values).map(([J,je])=>[J,{answers:[je]}]))};else if(x.requestKind==="elicitation")L={action:"submit",content:T.values};else throw new Error("This runtime permission does not accept submitted form data.");await vs.resolveRuntimeRequest({runId:x.runId,requestId:x.requestId,turnId:x.turnId,requestKind:x.requestKind,resolution:L})},[o,Fe,re]),we=(0,l.useMemo)(()=>{const x=[],T=ot?`runtime:${ot.runId}:${ot.requestId}`:null,X=ot&&(o??[]).some(J=>J.kind==="ask_user_questions"&&J.sourceRunId===ot.runId&&J.payload.runtimeRequestId===ot.requestId);ot&&T&&!X&&x.push({key:T,kind:"runtime",item:ot,label:ot.questionSet?.title??(ot.requestType==="permission"?"Runtime permission":"Runtime input")});const L=(o??[]).filter(J=>J.status==="pending"&&J.kind!=="connection_intent"&&!lr(J)).sort((J,je)=>Ne(je.createdAt)-Ne(J.createdAt));for(const J of L){const je=(J.kind==="ask_user_questions"&&J.sourceRunId&&J.payload.runtimeRequestId?`runtime:${J.sourceRunId}:${J.payload.runtimeRequestId}`:null)??`interaction:${J.id}`;x.push({key:je,kind:"durable",interaction:J,label:Wy(J)})}return x},[o,ot]),Ke=(0,l.useMemo)(()=>we.filter(x=>!(x.kind==="durable"&&x.interaction.kind==="ask_user_questions")),[we]),{dismissedQuestionIds:at,dismissQuestion:bt}=Cy(d,A),Mt=(0,l.useMemo)(()=>i.filter(x=>!x.deletedAt&&x.authorUserId&&!x.authorAgentId&&!x.createdByRunId).reduce((x,T)=>!x||Ne(T.createdAt)>=Ne(x.createdAt)?T:x,null),[i]),kt=Mt?.id??null,is=(0,l.useMemo)(()=>we.filter(x=>!(x.kind==="durable"&&x.interaction.kind==="ask_user_questions"&&(at.has(x.interaction.id)||Mt&&Ne(x.interaction.createdAt)<Ne(Mt.createdAt)))),[we,at,Mt]),Qs=(0,l.useMemo)(()=>new Set(is.map(x=>x.key)),[is]),[hs,wt]=(0,l.useState)("open"),[gs,Ot]=(0,l.useState)(null),sa=(0,l.useRef)(new Set),pn=(0,l.useRef)(kt);(0,l.useEffect)(()=>{const x=new Set(we.map(L=>L.key)),T=we.some(L=>Qs.has(L.key)&&!sa.current.has(L.key)),X=pn.current!==kt;pn.current=kt,sa.current=x,Ot(L=>L&&x.has(L)&&!(X&&!Qs.has(L))?L:is[0]?.key??null),T&&wt("open")},[we,kt,is,Qs]);const Ye=we.find(x=>x.key===gs)??is[0]??null,Va=Ye?`wardmote:task-input:${d??"unknown"}:${Ye.key}`:void 0,na=(0,l.useCallback)(()=>{Ke.some(x=>x.key===Ye?.key)||Ot(Ke[0]?.key??null),wt("open")},[Ke,Ye]),Ti=(0,l.useCallback)(()=>{if(Ke.length<2)return;const x=Ke.findIndex(T=>T.key===Ye?.key);Ot(Ke[(x+1)%Ke.length]?.key??null)},[Ke,Ye?.key]),Ga=(0,l.useCallback)(async x=>{if(x.kind==="runtime")await Z(x.item,{action:"cancel"});else{if(!Se)throw new Error("Skipping this interaction is unavailable.");await Se(x.interaction)}wt("normal")},[Z,Se]),Ir=W??void 0,Ya=!!(De&&v?.get(De)?.adapterType==="wardmote_runner"),[aa,ra]=(0,l.useState)(!1);(0,l.useEffect)(()=>{Re&&ra(!1)},[Re]),(0,l.useEffect)(()=>{if(!aa||Re)return;const x=window.setTimeout(()=>ra(!1),1e4);return()=>window.clearTimeout(x)},[aa,Re]);const Sa=(0,l.useCallback)(async(...x)=>{Ya&&ra(!0);try{const T=await E(...x);return Ye?.kind==="durable"&&Ye.interaction.kind==="ask_user_questions"&&(bt(Ye.interaction.id),Ot(null),wt("normal")),T}catch(T){throw ra(!1),T}},[Ya,E,Ye,bt]),Ca=Ya&&!Re&&(aa||_t.some(x=>x.kind==="message"&&x.author==="human"&&x.optimistic==="pending")),Nr=(0,l.useMemo)(()=>{const x=new Map;for(const T of Y??[])T.targetType==="issue_comment"&&x.set(T.targetId,T.vote);return x},[Y]),Sr=(0,l.useMemo)(()=>{const x=new Map;for(const T of i)x.set(T.id,{visible:T.publicShareVisible===!0,userAuthored:T.authorType==="user"&&!T.authorAgentId&&!T.runAgentId&&!T.derivedAuthorAgentId&&!T.deletedAt});return x},[i]),Ei=(0,l.useCallback)(x=>{if(x.optimistic)return null;if(x.author==="human"){const T=Sr.get(x.id);if(!T?.userAuthored)return null;const X=!!Ue;return!T.visible&&!X?null:(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[T.visible?(0,t.jsx)(rx,{}):null,X?(0,t.jsx)(ex,{visible:T.visible,onToggle:a(L=>{Ue?.(x.id,L)},"onToggle")}):null]})}return x.author!=="agent"?null:(0,t.jsx)(Dd,{copyText:x.text,fastResponse:x.origin==="fast_response",feedback:U?{activeVote:Nr.get(x.id)??null,sharingPreference:Ae,termsUrl:ht,onVote:a((T,X)=>U(x.id,T,X),"onVote")}:null})},[U,Nr,Ae,ht,Sr,Ue]),Cr=(0,l.useCallback)(x=>{const T=x.queueTargetRunId;if(w||x.optimistic!=="queued"||!T||!_e)return null;const X=rt===T;return(0,t.jsx)(ne,{type:"button",variant:"link",className:"h-auto p-0 text-(length:--text-micro)",disabled:X,onClick:a(()=>{_e(T)},"onClick"),children:X?"Interrupting…":"Interrupt"})},[w,rt,_e]),Ja=(0,l.useCallback)(x=>{Ot(we.find(T=>T.kind==="durable"&&T.interaction.id===x)?.key??`interaction:${x}`),wt("open")},[we]),Aa=(0,l.useCallback)(x=>(0,t.jsx)(cc,{item:x,onReviewRequest:Ja,showUnansweredQuestion:!0,planDocument:Me,showPlanPreview:!My(x.interaction,Me,Yt,cn,Re),agentMap:v,currentUserId:A,userLabelMap:k,onAcceptInteraction:$e,onRejectInteraction:Be,onSubmitInteractionAnswers:Fe,onCancelInteraction:re,onSubmitInteractionVerdicts:Ve,onUploadImage:se,mentions:de,externalReferences:Je}),[v,A,k,$e,Be,Fe,re,Ve,se,de,Je,Me,Yt,cn,Re,Ja]),Ar=(0,l.useCallback)(()=>Ut?(0,t.jsx)(z0,{brief:Ut}):null,[Ut]),Ra=(0,l.useMemo)(()=>{if(!ge?.startsWith("agent:"))return null;const x=ge.slice(6);return v?.get(x)??null},[v,ge]),Xa=Ye?Ye.kind==="runtime"?(0,t.jsx)($o,{item:Ye.item,presentation:"takeover",draftKey:Va,imageUploadHandler:se,mentions:de,onRuntimeRequestDecision:Z}):(0,t.jsx)(cc,{item:{id:`interaction:${Ye.interaction.id}`,kind:"interaction",interaction:Ye.interaction},presentation:"takeover",draftKey:Va,planDocument:Me,agentMap:v,currentUserId:A,userLabelMap:k,onAcceptInteraction:$e,onRejectInteraction:Be,onSubmitInteractionAnswers:Fe,onSubmitInteractionVerdicts:Ve,onUploadImage:se,mentions:de,externalReferences:Je}):null,Cs=hs==="open"&&Ye&&Xa?{id:Ye.key,label:Ye.label,hideLabel:Ye.kind==="durable"&&Ye.interaction.kind==="request_confirmation"&&!!Ye.interaction.payload.toolAction,pendingCount:Math.max(1,Ke.length),content:Xa,onDismiss:a(()=>{Ye.kind==="durable"&&Ye.interaction.kind==="ask_user_questions"&&(bt(Ye.interaction.id),Ot(null)),wt("normal")},"onDismiss"),onSkip:a(()=>Ga(Ye),"onSkip"),onShowNext:Ti,inlineSkip:Ye.kind==="durable"?Ye.interaction.kind==="ask_user_questions"||Ye.interaction.kind==="request_item_verdicts":Ye.item.requestType==="input"&&!!Ye.item.questionSet,hideSkip:Ye.kind==="durable"?Sf(Ye.interaction):Y0(Ye.item)}:null,Pt=of(d),jn=`${Pn}:${Cs?.id??"composer"}`,{isMobile:mt}=$d(),{dockRef:_i,reserve:Rr}=Sy(mt&&f);vh(mt);const ia=(0,l.useRef)(null);!ia.current&&i.length>0&&(ia.current={oldestAt:Math.min(...i.map(x=>Ne(x.createdAt))),ids:new Set(i.map(x=>x.id))});const Tr=new Set(i.filter(x=>ia.current?.ids.has(x.id)).flatMap(x=>[x.runId,x.createdByRunId,x.derivedCreatedByRunId])),Za=We.filter(x=>{if(!ia.current||!xa(x.status)||Tr.has(x.id))return!0;const T=qe.get(x.id);return!T||Ne(T.finishedAt??T.startedAt??T.createdAt)>=ia.current.oldestAt}).some(x=>x.status==="scheduled_retry"?!1:x.runtimeMode==="native"&&(gn?!gn.has(x.id):Xs)?!0:x.runtimeMode==="native"&&(Ls.get(x.id)?.length??0)>0?!1:x.status!=="queued"&&wa?!wa.has(x.id):ka),ct=s||vn||Za,er=n||on||We.some(x=>x.runtimeMode==="native"?ss.has(x.id)&&(Ts.get(x.id)?.length??0)===0:!!za?.has(x.id)),[Fn,Er]=(0,l.useState)(()=>ct?void 0:d),Ft=Fn===d,[_r,cs]=(0,l.useState)(null),Zs=_r!==null&&_r.issueId===d;(0,l.useEffect)(()=>{if(Ft)return;const x=window.setTimeout(()=>{cs({issueId:d}),Er(d)},Fy);return()=>window.clearTimeout(x)},[Ft,d]),(0,l.useEffect)(()=>{if(Ft||ct)return;const x=requestAnimationFrame(()=>Er(d));return()=>cancelAnimationFrame(x)},[ct,Ft,d]),(0,l.useEffect)(()=>{!Ft||!d||lu(au,iu)},[Ft,d]);const qi=a(()=>{r?.(),Vt?.(),Yn?.(),Xn()},"retryHistory");return(0,t.jsx)(cf.Provider,{value:Pt,children:(0,t.jsxs)(Lf.Provider,{value:!ct||Zs,children:[(0,t.jsx)(jy,{contentKey:mt?`${jn}:${Rr}`:0,enabled:mt&&Ft}),(0,t.jsx)(hh,{mode:"streamlined",children:(0,t.jsxs)("div",{className:ue("flex flex-col",!mt&&"min-h-0 flex-1",mt&&!Ft&&"task-chat-history-pending"),"data-testid":"task-chat-thread",children:[(0,t.jsx)(Bg,{issueId:d,frameClassName:ue("mx-auto w-full max-w-(--tc-shell-max-w) shrink-0 px-4",mt?"pt-4":"pt-3","md:px-0")}),(0,t.jsxs)("div",{className:ue("relative flex flex-col",(!mt||!Ft)&&"min-h-0 flex-1"),"aria-busy":!Ft,children:[er||ct&&Zs?(0,t.jsxs)("div",{role:"status",className:"absolute inset-x-0 top-0 z-20 mx-auto flex w-full max-w-(--tc-shell-max-w) items-center gap-2 border border-line bg-bg px-4 py-2 text-sm text-ink-3",children:[er?"Some task history could not be loaded.":"Some task history is still loading.",er?(0,t.jsx)(ne,{variant:"ghost",size:"sm",onClick:qi,children:"Retry"}):null]}):null,Ft?null:(0,t.jsx)("div",{className:"absolute inset-0 z-10 overflow-hidden bg-bg","data-testid":"task-chat-history-loading",role:"status","aria-label":"Loading conversation",children:(0,t.jsxs)("div",{className:"mx-auto flex w-full max-w-(--tc-shell-max-w) flex-col gap-4 px-4 py-3",children:[Ze?(0,t.jsx)(Cl,{className:"-mb-4",children:Ze}):null,ft,(0,t.jsx)(jt,{className:"h-16 w-3/4 animate-none"}),(0,t.jsx)(jt,{className:"h-24 w-4/5 self-end animate-none"}),(0,t.jsx)(jt,{className:"h-16 w-3/4 animate-none"})]})}),(0,t.jsx)("div",{"data-testid":"task-chat-history-content",className:ue("flex flex-col",!mt&&"min-h-0 flex-1",!Ft&&"invisible"),inert:!Ft,children:ln.length===0&&!Re?(0,t.jsxs)("div",{className:mt?void 0:"min-h-0 flex-1 overflow-y-auto",children:[zt?(0,t.jsxs)("div",{className:ue("mx-auto flex w-full max-w-(--tc-shell-max-w) flex-col gap-6 px-4",mt?"pt-4":"pt-3","md:px-0"),"data-testid":"task-chat-thread-header",children:[Ze&&Ft?(0,t.jsx)(Cl,{className:ue("-mb-6",!mt&&"top-3"),children:Ze}):null,zt]}):null,(0,t.jsx)("div",{className:"px-3 py-10 text-center text-sm text-ink-3",children:M}),un?(0,t.jsx)("div",{className:ue("mx-auto w-full max-w-(--tc-shell-max-w) px-4 pb-4","md:px-0"),children:un}):null]}):(0,t.jsx)(Qf,{items:ln,attachments:p,header:zt,headerActions:Ft?Ze:void 0,renderInteraction:Aa,renderBrief:Ar,renderMessageActions:Ei,renderQueuedAction:Cr,onTryAgainNoLiveExecutionPath:Ie==="blocked"&&!pl(e.recoveryAction?.cause)&&!K?.some(x=>x.execution?.phase==="recovery_needed")?us:void 0,tryAgainNoLiveExecutionPathPending:Vs,onRetryFailedRun:yt,retryFailedRunId:xt,onOpenSkill:Ys,onOpenBrowser:Nt,tail:Re||Ca||un?(0,t.jsxs)(t.Fragment,{children:[Re||Ca?(0,t.jsx)("div",{"data-testid":"task-chat-live-transcript",children:Qe||Ca?(0,t.jsx)(q0,{runId:Re,turnId:Es,execution:pe?.id===Re?pe.execution:null,agentName:mn,agentIcon:Ha,agent:Tt??(nt?{id:nt}:void 0),items:Us,status:Ca?"queued":ze,startedAtMs:gt,finishedAtMs:Ee,activityUnavailable:Bt,suppressFinal:kn,continuedAfterSteering:Qe&&Ks.length>0,onRuntimeRequestDecision:Z}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(V0,{status:ze,execution:pe?.id===Re?pe.execution:null,startedAtMs:gt,finishedAtMs:Ee,toolSummary:Oe}),(0,t.jsx)(j0,{items:Us,turnId:Es??void 0,emptyMessage:ze==="queued"?"Waiting to start...":(pe&&pe.id===Re?pe.currentStatusMessage:null)||(ze==="failed"?qe.get(Re??"")?.errorCode?.startsWith("workspace_git_scan_")?"Workspace setup failed before the agent started.":"This run stopped before a response was available. Review the task’s connection or recovery action below.":"Waiting for transcript...")})]})}):null,un]}):null,contentKey:`${jn}:${Ft}`,className:mt?void 0:"pt-3",scroll:!mt})})]}),Ra?.status==="paused"?(0,t.jsx)("div",{className:"mx-auto w-full max-w-(--tc-shell-max-w) px-4 pt-2",children:(0,t.jsx)(ox,{agent:Ra,onResume:ps,resuming:Gs})}):null,f?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(Ny,{ref:mt?_i:void 0,mobile:mt,reserve:mt?Rr:void 0,concealed:!Ft,children:[P,(0,t.jsx)(kg,{issueId:d,run:pe,companyId:$,className:"self-start"}),ta?(0,t.jsx)(K0,{model:ta}):null,(0,t.jsx)(hy,{control:ws}),(0,t.jsxs)("div",{className:"relative isolate flex flex-col","data-testid":"task-chat-composer-stack",children:[w?null:(0,t.jsx)(by,{queue:Dt??Vn,onEdit:D,onReorder:a(async(x,T)=>{if(!ts)throw new Error("Queue reordering is unavailable.");await ts(x,T)},"onReorder"),onSteer:a(async(x,T)=>{if(!$t)throw new Error("Steering is unavailable.");await $t(x,T)},"onSteer"),onInterrupt:_e&&Dt?.queueId?async()=>{await _e(Dt.targetRunId)}:void 0,onDiscard:a(async(x,T)=>{if(x.startsWith("optimistic-")){if(!et)throw new Error("Discard is unavailable.");et(x);return}if(!ms)throw new Error("Discard is unavailable.");await ms(x,T),g?.commentId===x&&Et(null)},"onDiscard")},d),(0,t.jsx)("div",{className:"relative z-10",children:(0,t.jsx)(Ph,{onAdd:Sa,confirmedSubmissionIds:new Set(i.filter(x=>x.authorUserId===A&&x.clientRequestId&&!("clientStatus"in x&&x.clientStatus)).map(x=>x.clientRequestId)),onReviewConversation:_,onStop:pe?q:void 0,stopPending:O,stopScope:F,workMode:C,onWorkModeChange:S,disabled:!!Ir,disabledReason:Ir,onAttachImage:z,onImageUpload:se,mentions:de,enableReassign:me,conversationMode:oe,pendingIssue:ve,reassignOptions:ie,agentMap:v,userProfileMap:N,currentAssigneeValue:ge,companyId:$,onPendingAssigneeChange:it,issueStatus:Ie,issueId:d,mobile:mt,draftKey:St,queuedEdit:g,onSaveQueuedEdit:ee,onCancelQueuedEdit:a(()=>Et(null),"onCancelQueuedEdit"),pause:w,takeover:Cs,runnerGoalCapability:ws.data?.capability??null,onRunnerGoalCommand:ws.executeComposerCommand,onRunnerGoalReassign:Hn,pendingTakeover:Ke.length>0?{count:Ke.length,label:`${Ke.length} pending input${Ke.length===1?"":"s"}`,onOpen:na}:null})})]}),j]}),mt?(0,t.jsx)("div",{"aria-hidden":!0,"data-testid":"task-chat-keyboard-spacer",className:"shrink-0",style:{height:"var(--mobile-viewport-inset-bottom, 0px)"}}):null]}):null]})})]})})}a(zy,"TaskChatThread");function Hy({document:e,focusSignal:s=0,externalReferences:n}){const[r,i]=(0,l.useState)(!1),[o,u]=(0,l.useState)(!1),m=(0,l.useRef)(null);if((0,l.useEffect)(()=>{if(!e||s<=0)return;i(!0),u(!0),m.current?.scrollIntoView({behavior:"smooth",block:"center"});const h=setTimeout(()=>u(!1),3e3);return()=>clearTimeout(h)},[e,s]),!e)return null;const p=e.title?.trim()||"Continuation handoff";return(0,t.jsxs)("div",{ref:m,id:`document-${go}`,className:ue("mb-3 rounded-lg border border-line bg-bg-3/20 p-3 transition-colors duration-1000",o&&"border-accent/50 bg-accent/5"),children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("button",{type:"button",className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-ink-3 transition-colors hover:bg-bg-3/60 hover:text-ink",onClick:a(()=>i(h=>!h),"onClick"),"aria-label":r?"Collapse continuation handoff":"Expand continuation handoff","aria-expanded":r,children:r?(0,t.jsx)(br,{className:"h-3.5 w-3.5"}):(0,t.jsx)(kr,{className:"h-3.5 w-3.5"})}),(0,t.jsx)(qh,{className:"h-4 w-4 text-ink-3"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("span",{className:"text-sm font-medium text-ink",children:p}),(0,t.jsx)(Qn,{variant:"outline",className:"border-line font-mono text-(length:--text-nano) uppercase text-ink-3",children:"handoff"})]}),(0,t.jsxs)("div",{className:"text-(length:--text-micro) text-ink-3",children:["Updated ",hr(e.updatedAt),e.latestRevisionNumber>0?` - revision ${e.latestRevisionNumber}`:""]})]}),(0,t.jsx)(kh,{prompt:e.body,label:"Continue with an agent",title:"Task handoff",description:"Paste this into your agent to continue from this handoff.",align:"end"})]}),r?(0,t.jsx)("div",{className:"mt-3 rounded-md border border-line bg-bg/80 p-3",children:(0,t.jsx)(bs,{className:"wardmote-edit-in-place-content text-sm leading-6",softBreaks:!1,externalReferences:n,children:e.body})}):null]})}a(Hy,"IssueContinuationHandoff");function Vy({issueId:e}){const[s,n]=(0,l.useState)(!1),[r,i]=(0,l.useState)(!1),o=ks(),{pushToast:u}=ya(),{copied:m,failed:p,copy:h}=wh(2e3),d=R.issues.shareLink(e),v=ye({queryKey:d,queryFn:a(()=>Gr.getShareLink(e),"queryFn"),enabled:s}),k=Pe({mutationFn:a(()=>Gr.createShareLink(e),"mutationFn"),onSuccess:a(E=>{o.setQueryData(d,E)},"onSuccess"),onError:a(E=>{u({title:"Couldn't create public link",body:E instanceof Error?E.message:"Try again in a moment.",tone:"error"})},"onError")}),N=Pe({mutationFn:a(()=>Gr.revokeShareLink(e),"mutationFn"),onSuccess:a(()=>{o.setQueryData(d,null),i(!1),u({title:"Public link revoked",body:"Anyone holding the old link can no longer open it.",tone:"success"})},"onSuccess"),onError:a(E=>{u({title:"Couldn't revoke public link",body:E instanceof Error?E.message:"Try again in a moment.",tone:"error"})},"onError")}),A=v.data??null;return(0,t.jsxs)(vr,{open:s,onOpenChange:a(E=>{n(E),E||i(!1)},"onOpenChange"),children:[(0,t.jsx)(xr,{asChild:!0,children:(0,t.jsxs)(ne,{variant:"ghost",size:"xs",className:"shrink-0","aria-label":"Share task",title:"Share task",children:[(0,t.jsx)(Lh,{className:"size-4"}),(0,t.jsx)("span",{className:"hidden md:inline",children:"Share"})]})}),(0,t.jsxs)(yr,{className:"w-80 space-y-3 p-3",align:"end",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:"Public link"}),(0,t.jsx)("p",{className:"text-xs text-ink-3",children:"Anyone with the link can view this task and its directly related tasks without signing in. Internal comments stay hidden."})]}),v.isPending?(0,t.jsx)("p",{className:"text-xs text-ink-3",children:"Loading…"}):v.isError?(0,t.jsx)("p",{className:"text-xs text-bad",children:"Couldn't load the share link."}):A?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(jr,{readOnly:!0,value:A.url,"aria-label":"Public link",className:"h-8 text-xs",onFocus:a(E=>E.currentTarget.select(),"onFocus")}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)(ne,{size:"sm",variant:"secondary",onClick:a(()=>{h(A.url)},"onClick"),children:[m?(0,t.jsx)(Wn,{className:"h-3.5 w-3.5"}):(0,t.jsx)(wr,{className:"h-3.5 w-3.5"}),p?"Copy failed":m?"Copied":"Copy link"]}),(0,t.jsx)(ne,{size:"sm",variant:"secondary",asChild:!0,children:(0,t.jsxs)("a",{href:A.url,target:"_blank",rel:"noopener noreferrer",children:[(0,t.jsx)(Po,{className:"h-3.5 w-3.5"}),"Open"]})}),r?null:(0,t.jsx)(ne,{size:"sm",variant:"danger",onClick:a(()=>i(!0),"onClick"),children:"Revoke"})]}),r?(0,t.jsxs)("div",{className:"space-y-2 rounded-md border border-line p-2",children:[(0,t.jsx)("p",{className:"text-xs text-ink-3",children:"Revoke this link? It stops working immediately and cannot be restored."}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(ne,{size:"sm",variant:"danger",disabled:N.isPending,onClick:a(()=>N.mutate(),"onClick"),children:N.isPending?"Revoking…":"Revoke link"}),(0,t.jsx)(ne,{size:"sm",variant:"ghost",onClick:a(()=>i(!1),"onClick"),children:"Cancel"})]})]}):null]}):(0,t.jsxs)(ne,{size:"sm",className:"w-full",disabled:k.isPending,onClick:a(()=>k.mutate(),"onClick"),children:[(0,t.jsx)(Ad,{className:"h-3.5 w-3.5"}),k.isPending?"Creating…":"Create public link"]})]})]})}a(Vy,"IssueShareControl");var Ic={listLive:a(e=>ml.get(`/companies/${e}/autonomy-windows`),"listLive"),close:a(e=>ml.delete(`/autonomy-windows/${e}`),"close")};function Gy(e,s,n,r=Date.now()){const i=new Set([s,...n]);return e.filter(o=>o.status==="live"&&i.has(o.rootIssueId)&&new Date(o.expiresAt).getTime()>r&&(o.maxAccepts===null||o.acceptCount<o.maxAccepts)).sort((o,u)=>new Date(u.expiresAt).getTime()-new Date(o.expiresAt).getTime())[0]??null}a(Gy,"coveringAutonomyWindow");function Yy({companyId:e,issueId:s,ancestors:n}){const r=ks(),{pushToast:i}=ya(),o=R.autonomyWindows(e),{data:u}=ye({queryKey:o,queryFn:a(()=>Ic.listLive(e),"queryFn"),staleTime:6e4}),m=(0,l.useMemo)(()=>Gy(u?.windows??[],s,(n??[]).map(d=>d.id)),[u,s,n]),p=Pe({mutationFn:a(d=>Ic.close(d),"mutationFn"),onSuccess:a(()=>r.invalidateQueries({queryKey:o}),"onSuccess"),onError:a(d=>{i({title:"Couldn't close the autonomy window",body:d instanceof Error?d.message:"Try again in a moment.",tone:"error"})},"onError")});if(!m)return null;const h=m.rootIssueIdentifier??m.rootIssueId.slice(0,8);return(0,t.jsxs)("span",{className:"inline-flex shrink-0 items-center gap-1","data-testid":"issue-autonomy-window",children:[(0,t.jsxs)(Uo,{children:[(0,t.jsx)(Oo,{asChild:!0,children:(0,t.jsxs)(Qn,{variant:"outline",className:"gap-1 border-accent/40 bg-accent/10 text-(length:--text-nano) text-accent",children:[(0,t.jsx)(Gf,{className:"h-3 w-3"}),"Autonomy until ",Cm(m.expiresAt)]})}),(0,t.jsxs)(Ko,{side:"bottom",className:"max-w-xs text-xs",children:["Plain confirmations in ",h," and its sub-issues are accepted automatically until ",jm(m.expiresAt),m.maxAccepts===null?"":` (${m.acceptCount} of ${m.maxAccepts} used)`,". Questions, reviews, governed approvals and destructive steps still wait for a person."]})]}),(0,t.jsx)(ne,{variant:"ghost",size:"icon-xs","aria-label":"Close autonomy window",disabled:p.isPending,onClick:a(()=>p.mutate(m.id),"onClick"),children:(0,t.jsx)(Qa,{})})]})}a(Yy,"IssueAutonomyWindowBadge");function Nc(e,s){const n=e?.[s];return Array.isArray(n)?n.filter(r=>!!r&&typeof r=="object"):[]}a(Nc,"readIssueReferences");function Sc({label:e,icon:s,items:n,strikethrough:r}){return n.length===0?null:(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,t.jsxs)("span",{"aria-label":e,className:"inline-flex items-center gap-1 text-xs text-ink-3",children:[s,(0,t.jsx)("span",{className:"sr-only",children:e})]}),n.map(i=>(0,t.jsx)(Qd,{strikethrough:r,issue:{id:i.id,identifier:i.identifier??null,title:i.title??i.identifier??i.id}},`${e}:${i.id}`))]})}a(Sc,"Section$1");function Jy({event:e}){const s=Nc(e.details,"addedReferencedIssues"),n=Nc(e.details,"removedReferencedIssues");return s.length===0&&n.length===0?null:(0,t.jsxs)("div",{className:"mt-2 space-y-1",children:[(0,t.jsx)(Sc,{label:"Added references",icon:(0,t.jsx)(Lo,{className:"h-3 w-3 text-green-600 dark:text-green-400","aria-hidden":"true"}),items:s}),(0,t.jsx)(Sc,{label:"Removed references",icon:(0,t.jsx)(Ef,{className:"h-3 w-3 text-red-600 dark:text-red-400","aria-hidden":"true"}),items:n,strikethrough:!0})]})}a(Jy,"IssueReferenceActivitySummary");var Xy={"issue.cross_issue_influence_cap_rejected":"cross_issue_influence_cap_exceeded","issue.attribution_spoof_rejected":"issue_write_attribution_spoof_rejected"};function Zy(e,s,n={}){const r=Xy[e];return r?{code:r,context:{...n,issueIdentifier:typeof s?.identifier=="string"?s.identifier:null,cap:typeof s?.cap=="number"?s.cap:null,count:typeof s?.count=="number"?s.count:null,enforceAt:typeof s?.enforceAt=="string"?s.enforceAt:null}}:null}a(Zy,"issueWriteDenialForActivity");function ev(e){if(!e)return null;try{const s=new URL(e);if(s.hostname!=="github.com")return null;const[,n,r,i,o]=s.pathname.split("/");return!n||!r||!o?null:i==="pull"?`PR ${o}`:i==="issues"?`Issue ${o}`:null}catch{return null}}a(ev,"githubObjectLabel");function tv(e,s,n){const r=(e.providerKey==="github"?ev(e.url):null)??e.displayTitle?.trim()??s;return n?`${r} - ${n}`:r}a(tv,"externalObjectValueLabel");function xu(e,s){return e.statusIconKey==="git-merge"||s.toLowerCase()==="merged"}a(xu,"isMergedExternalObject");function sv(e,s){return xu(e,s)?"text-violet-600 border-violet-600 dark:text-violet-400 dark:border-violet-400":np[e.statusCategory]??"text-ink-3 border-ink-3"}a(sv,"externalObjectPillTone");function nv(e,s){return xu(e,s)?e.statusIconKey??"git-merge":e.statusIconKey}a(nv,"externalObjectStatusIconKey");function av({object:e,sourceCount:s,sourceSummary:n,className:r,children:i,inert:o,showProviderIcon:u=!0}){const m=rp[e.liveness]??"",p=Yp(e.providerKey);Kp(e.objectType);const h=Up(e.providerKey,e.objectType,e.displayKey),d=Op(e),v=sv(e,d),k=tv(e,h,d),N=nv(e,d),A=Bp(e.liveness),E=Jp(e.iconKey),_=`${h} — ${d}${e.liveness==="fresh"||e.liveness==="unknown"?"":` (${A})`}${e.displayTitle?`: ${e.displayTitle}`:""}`,q=!o&&!!e.url,O=ue("wardmote-mention-chip wardmote-mention-chip--external-object","inline-flex max-w-full items-center gap-1 rounded-full border border-line px-2 py-0.5 text-xs no-underline",v.split(" ").filter(P=>P.startsWith("text-")).join(" "),m,q&&"hover:bg-bg-3/50 focus-visible:outline-none focus-visible:ring-(length:--rad-3) focus-visible:ring-focus",r),F=n?`${e.displayTitle??h} — ${n}`:e.displayTitle??h,C=i??(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Zp,{category:e.statusCategory,liveness:e.liveness,statusIconKey:N,sizeClassName:"h-3 w-3",label:`${p}: ${d}`}),(0,t.jsx)("span",{className:"max-w-(--sz-16rem) truncate font-medium",children:k})]}),S=(0,t.jsxs)(t.Fragment,{children:[u&&E?(0,t.jsx)(E,{"aria-hidden":"true",className:"h-3 w-3 shrink-0"}):null,(0,t.jsx)("span",{className:"inline-flex min-w-0 items-center gap-1",children:C}),typeof s=="number"&&s>1?(0,t.jsxs)("span",{className:"tabular-nums text-(length:--text-nano) font-medium opacity-80",children:["×",s]}):null]});return q&&e.url?(0,t.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer","data-mention-kind":"external-object","data-external-status":e.statusCategory,"data-external-liveness":e.liveness,className:O,title:F,"aria-label":_,children:S}):(0,t.jsx)("span",{"data-mention-kind":"external-object","data-external-status":e.statusCategory,"data-external-liveness":e.liveness,className:O,title:F,"aria-label":_,children:S})}a(av,"ExternalObjectPill");function rv(e){const s=new Map;for(const n of e){const r=s.get(n.label);r?r.count+=1:s.set(n.label,{label:n.label,count:1,sampleMatchedText:n.matchedText??null})}return Array.from(s.values())}a(rv,"groupSourcesByLabel");function Cc({title:e,description:s,items:n,emptyLabel:r}){return(0,t.jsxs)("section",{className:"space-y-3 rounded-lg border border-line p-3",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold",children:e}),(0,t.jsx)("p",{className:"text-xs text-ink-3",children:s})]}),n.length===0?(0,t.jsx)("p",{className:"text-xs text-ink-3",children:r}):(0,t.jsx)("ul",{className:"-mx-1 flex flex-col",children:n.map(i=>{const o=rv(i.sources),u=i.issue.identifier!==i.issue.title;return(0,t.jsxs)("li",{className:"flex flex-wrap items-center gap-x-2 gap-y-1.5 rounded-md px-1 py-1.5 hover:bg-bg-3/40",children:[(0,t.jsx)(Qd,{issue:i.issue}),u?(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm text-ink-3",children:i.issue.title}):null,(0,t.jsx)("div",{className:"flex flex-wrap items-center gap-1.5",children:o.map(m=>(0,t.jsxs)(Qn,{variant:"outline",className:"border-line bg-bg-3/40 text-ink-3",title:m.sampleMatchedText??void 0,children:[(0,t.jsx)("span",{children:m.label}),m.count>1?(0,t.jsxs)("span",{className:"tabular-nums text-(length:--text-nano) font-medium opacity-80",children:["×",m.count]}):null]},`${i.issue.id}:${m.label}`))})]},i.issue.id)})})]})}a(Cc,"Section");function iv({groups:e,isLoading:s,isError:n,onRetry:r}){const i=[...e].sort((o,u)=>{const m=jl(o.pill.statusCategory?o.group.object?.statusTone??null:null),p=jl(u.pill.statusCategory?u.group.object?.statusTone??null:null);if(m!==p)return p-m;const h=o.group.object?.lastChangedAt??o.group.object?.lastResolvedAt??"",d=u.group.object?.lastChangedAt??u.group.object?.lastResolvedAt??"";return h<d?1:h>d?-1:0});return(0,t.jsxs)("section",{className:"space-y-3 rounded-lg border border-line p-3",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold",children:"External objects"}),(0,t.jsx)("p",{className:"text-xs text-ink-3",children:"Remote work referenced from this issue — pull requests, deployments, tickets in other systems, and more."})]}),n?(0,t.jsxs)("p",{className:"text-xs text-ink-3",children:["Couldn't load external objects."," ",r?(0,t.jsx)("button",{type:"button",onClick:r,className:"text-accent underline-offset-2 hover:underline",children:"Retry"}):null]}):s?(0,t.jsx)("p",{className:"text-xs text-ink-3",children:"Loading external objects…"}):i.length===0?(0,t.jsx)("p",{className:"text-xs text-ink-3",children:"This issue does not reference any external objects yet."}):(0,t.jsx)("ul",{className:"-mx-1 flex flex-col",children:i.map(({pill:o,mentionCount:u,sourceLabels:m,group:p})=>{const h=p.object;return(0,t.jsxs)("li",{className:"flex flex-wrap items-center gap-x-2 gap-y-1.5 rounded-md px-1 py-1.5 hover:bg-bg-3/40",children:[(0,t.jsx)(av,{object:o,sourceCount:u,sourceSummary:m.join(", ")}),o.displayTitle?(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm text-ink-3",children:o.displayTitle}):null,(0,t.jsx)("div",{className:"flex flex-wrap items-center gap-1.5",children:m.map(d=>(0,t.jsx)(Qn,{variant:"outline",className:"border-line bg-bg-3/40 text-ink-3",children:(0,t.jsx)("span",{children:d})},`${h?.id??o.url??d}:${d}`))})]},h?.id??`${o.providerKey}:${o.objectType}:${o.url??"anon"}`)})})]})}a(iv,"ExternalObjectsSection");function ov({relatedWork:e,externalObjectsEnabled:s=!0,externalObjects:n,externalObjectsLoading:r,externalObjectsError:i,onRetryExternalObjects:o}){const u=e?.outbound??[],m=e?.inbound??[];return(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(Cc,{title:"References",description:"Other tasks this task currently points at in its title, description, comments, or documents.",items:u,emptyLabel:"This task does not reference any other tasks yet."}),s?(0,t.jsx)(iv,{groups:n??[],isLoading:!!r,isError:!!i,onRetry:o}):null,(0,t.jsx)(Cc,{title:"Referenced by",description:"Other tasks that currently point at this task.",items:m,emptyLabel:"No other tasks reference this task yet."})]})}a(ov,"IssueRelatedWorkPanel");var lv=["scheduled","retrying","due-now","overdue"];function yu(e){return lv.includes(e)}a(yu,"isWaitingMonitorState");function cv(e){const s=ni(e);return yu(s.state)&&s.nextCheckAt!==null}a(cv,"hasVisibleMonitorSurface");function dv(e){return e.length===0?e:`${e.charAt(0).toUpperCase()}${e.slice(1)}`}a(dv,"capitalize");function uv(e,s,n,r=0){if(!yu(e.state)||!e.nextCheckAt)return null;if(e.source==="scheduled-retry"&&n==="workspace_busy")return{bannerTitle:"Waiting for workspace",stripTitle:"Waiting for workspace",bannerMeta:["Another task is using this workspace. Work starts automatically when it is available."],stripMeta:["Work starts automatically when the workspace is available."],collapsedTitle:"Waiting for workspace",tone:"info",workspaceWait:!0};const i=Nh(e.nextCheckAt,s),o=Sh(e.nextCheckAt,{},s);if(e.source==="monitor"&&e.serviceName?.toLowerCase()==="github"&&r>0)return{bannerTitle:"Pull request review requested",stripTitle:"Pull request review requested",bannerMeta:[`Next check ${i} · ${o} (your time)`],stripMeta:[`Next check ${i} · ${o}`],collapsedTitle:`PR review · next check ${i}`,tone:e.state==="overdue"?"warning":"info",pullRequestReview:!0};const u=e.source==="scheduled-retry";let m,p,h=null;switch(e.state){case"scheduled":case"retrying":m=u?`Agent resumes ${i}`:`Waiting on monitor — resumes ${i}`,p=`Resumes ${i}`;break;case"due-now":m=u?"Agent retry due now":"Waiting on monitor — due now",p="Due now",h="Checking momentarily…";break;default:m=u?`Agent retry ${i}`:`Waiting on monitor — ${i}`,p=dv(i),h="Fires on next tick"}const d=e.attemptCount>=1?`Attempt ${e.attemptCount}`:null,v=e.serviceName?`Watching: ${e.serviceName}`:null,k=[h,`${o} (your time)`,d,v].filter(A=>!!A),N=[h,o,d,v].filter(A=>!!A);return{bannerTitle:m,stripTitle:p,bannerMeta:k,stripMeta:N,collapsedTitle:p,tone:e.state==="overdue"?"warning":"info",scheduledRetry:u}}a(uv,"buildMonitorSurfaceCopy");function vu(e,s){const n=(0,l.useMemo)(()=>ni(e).nextCheckAt,[e]),r=Rh(n);return(0,l.useMemo)(()=>uv(ni(e,r),r,e.scheduledRetry?.scheduledRetryReason,s),[e,r,s])}a(vu,"useMonitorSurfaceCopy");var No="wardmote:issue-monitor-collapsed";function bu(e){return`wardmote:issue-monitor-collapsed:${e}`}a(bu,"collapseStorageKey");function mv(e){try{const s=window.localStorage.getItem(bu(e));return s===null?null:s==="1"}catch{return null}}a(mv,"readStoredCollapse");function pv(e){return window.addEventListener(No,e),window.addEventListener("storage",e),()=>{window.removeEventListener(No,e),window.removeEventListener("storage",e)}}a(pv,"subscribeStoredCollapse");function ku(e,s){const n=(0,l.useSyncExternalStore)(pv,()=>e?mv(e):null,()=>null),[r,i]=(0,l.useState)(null),o=(r&&r.issueId===e?r.collapsed:null)??n??s;return[o,(0,l.useCallback)(()=>{const u=!o;if(!e){i({issueId:e,collapsed:u});return}try{window.localStorage.setItem(bu(e),u?"1":"0")}catch{i({issueId:e,collapsed:u})}window.dispatchEvent(new Event(No))},[o,e])]}a(ku,"useMonitorCollapsed");function wu({collapsed:e,onToggle:s,controlsId:n}){const r=e?"Expand monitor details":"Minimize monitor details";return(0,t.jsx)(ne,{type:"button",variant:"ghost",size:"icon-sm",className:"shrink-0","aria-expanded":!e,"aria-controls":e?void 0:n,"aria-label":r,title:r,onClick:s,children:e?(0,t.jsx)(br,{className:"h-4 w-4","aria-hidden":"true"}):(0,t.jsx)(dd,{className:"h-4 w-4","aria-hidden":"true"})})}a(wu,"CollapseToggleButton");function Ac({onCheckNow:e,checkingNow:s,reviewRequested:n=!1,retry:r=!1,compact:i=!1}){const o=r?"Retry now":n?"Check status":"Check now";return(0,t.jsx)(ne,{type:"button",variant:"secondary",size:i?"xs":"sm",className:ue("shrink-0 shadow-none",i&&"h-7"),onClick:e,disabled:s,"data-testid":r?"issue-wait-retry-now":void 0,children:s?r?"Retrying…":"Checking…":o})}a(Ac,"CheckNowButton");function li({copy:e,onCheckNow:s,checkingNow:n,onRetryNow:r,retryingNow:i,compact:o=!1}){return e.workspaceWait?null:e.scheduledRetry?r?(0,t.jsx)(Ac,{onCheckNow:r,checkingNow:i,retry:!0,compact:o}):null:s?(0,t.jsx)(Ac,{onCheckNow:s,checkingNow:n,reviewRequested:e.pullRequestReview,compact:o}):null}a(li,"WaitActionButton");function fv({onCancel:e}){const[s,n]=(0,l.useState)(!1),[r,i]=(0,l.useState)(!1),[o,u]=(0,l.useState)(null),m=a(async()=>{i(!0),u(null);try{await e(),n(!1)}catch(p){u(p instanceof Error?p.message:"Unable to cancel the monitor. Try again.")}finally{i(!1)}},"cancel");return(0,t.jsxs)(ki,{open:s,onOpenChange:a(p=>{r||(n(p),u(null))},"onOpenChange"),children:[(0,t.jsx)(wp,{asChild:!0,children:(0,t.jsx)(ne,{type:"button",variant:"ghost",size:"icon-sm",className:"shrink-0","aria-label":"Cancel monitor",title:"Cancel monitor",children:(0,t.jsx)(Qa,{className:"h-4 w-4","aria-hidden":"true"})})}),(0,t.jsxs)(xi,{children:[(0,t.jsxs)(bi,{children:[(0,t.jsx)(gi,{children:"Cancel monitor?"}),(0,t.jsx)(hi,{children:"This removes the scheduled monitor check. The agent will no longer resume from this monitor. You can send a message to continue the task."})]}),o?(0,t.jsx)("p",{role:"alert",className:"text-sm text-bad",children:o}):null,(0,t.jsxs)(yi,{children:[(0,t.jsx)(vi,{disabled:r,children:"Keep monitor"}),(0,t.jsx)(ne,{type:"button",variant:"danger",disabled:r,onClick:a(()=>{m()},"onClick"),children:r?"Cancelling…":"Cancel monitor"})]})]})]})}a(fv,"CancelMonitorButton");function ju({copy:e,meta:s,action:n,toggle:r,trailing:i,actionError:o,className:u,testId:m}){return(0,t.jsxs)("div",{role:"note","data-testid":m,"data-collapsed":"",className:ue("rounded-lg border py-1 pl-3 pr-1",u),children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,t.jsx)(Mo,{className:"h-4 w-4 shrink-0 opacity-80","aria-hidden":"true"}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",title:[e.collapsedTitle,...s].join(" · "),children:e.collapsedTitle}),n,r,i]}),o?(0,t.jsx)("p",{role:"alert",className:"pb-1 text-sm text-bad",children:o}):null]})}a(ju,"CollapsedMonitorRow");function hv({issue:e,onCheckNow:s=null,checkingNow:n=!1,onRetryNow:r=null,retryingNow:i=!1,retryError:o,workProducts:u,checkError:m,onCancelMonitor:p,defaultCollapsed:h=!1}){const d=(0,l.useId)(),v=wd(u).filter(jd),k=vu(e,v.length),[N,A]=ku(e.id,h);if(!k)return null;const E=k.scheduledRetry?o:m,_=p&&ni(e).source==="monitor",q=(0,t.jsx)(wu,{collapsed:N,onToggle:A,controlsId:d}),O=_?(0,t.jsx)(fv,{onCancel:p},e.id):null;return N?(0,t.jsx)(ju,{testId:"issue-monitor-banner",copy:k,meta:k.bannerMeta,className:ue("my-3",hp[k.tone]),action:(0,t.jsx)(li,{copy:k,onCheckNow:s,checkingNow:n,onRetryNow:r,retryingNow:i,compact:!0}),toggle:q,trailing:O,actionError:E}):(0,t.jsx)("div",{"data-testid":"issue-monitor-banner",className:"my-3",children:(0,t.jsxs)(bh,{tone:k.tone,icon:Mo,title:k.bannerTitle,className:ue("relative",_?"pr-22":"pr-12"),actions:(0,t.jsx)(li,{copy:k,onCheckNow:s,checkingNow:n,onRetryNow:r,retryingNow:i}),children:[(0,t.jsxs)("div",{className:"absolute right-2 top-2 flex items-center",children:[q,O]}),(0,t.jsxs)("div",{id:d,className:"flex flex-col gap-2",children:[k.pullRequestReview?(0,t.jsx)(kd,{products:v}):null,(0,t.jsx)("span",{children:k.bannerMeta.join(" · ")}),E?(0,t.jsx)("p",{role:"alert",children:E}):null]})]})})}a(hv,"IssueMonitorBanner");function gv({issue:e,onCheckNow:s=null,checkingNow:n=!1,onRetryNow:r=null,retryingNow:i=!1,retryError:o,workProducts:u,checkError:m,className:p,defaultCollapsed:h=!1}){const d=(0,l.useId)(),v=wd(u).filter(jd),k=vu(e,v.length),[N,A]=ku(e.id,h);if(!k)return null;const E=k.scheduledRetry?o:m,_=(0,t.jsx)(wu,{collapsed:N,onToggle:A,controlsId:d});return N?(0,t.jsx)(ju,{testId:"issue-monitor-composer-strip",copy:k,meta:k.stripMeta,className:ue("border-line bg-[color-mix(in_oklab,var(--bg-3)_30%,var(--bg))] text-ink",p),action:(0,t.jsx)(li,{copy:k,onCheckNow:s,checkingNow:n,onRetryNow:r,retryingNow:i,compact:!0}),toggle:_,actionError:E}):(0,t.jsxs)("div",{role:"note","data-testid":"issue-monitor-composer-strip",className:ue("relative max-h-[40dvh] overflow-y-auto rounded-lg border border-line bg-[color-mix(in_oklab,var(--bg-3)_30%,var(--bg))] py-2 pl-3 pr-11",p),children:[(0,t.jsx)("div",{className:"absolute right-1 top-1",children:_}),(0,t.jsxs)("div",{id:d,children:[(0,t.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-start gap-2",children:[(0,t.jsx)(Mo,{className:"mt-0.5 h-4 w-4 shrink-0 text-ink-3","aria-hidden":"true"}),(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-2",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-ink",children:k.stripTitle}),k.pullRequestReview?(0,t.jsx)(kd,{products:v}):null,(0,t.jsx)("div",{className:"text-xs text-ink-3",children:k.stripMeta.join(" · ")})]})]}),(0,t.jsx)(li,{copy:k,onCheckNow:s,checkingNow:n,onRetryNow:r,retryingNow:i})]}),(0,t.jsx)("p",{className:"mt-1.5 text-xs text-ink-3",children:k.pullRequestReview?"Review on GitHub, then check status to have the agent verify the result.":k.workspaceWait?"You can keep sending instructions while the agent waits.":"Sending a reply wakes the agent now — before the scheduled check."}),E?(0,t.jsx)("p",{role:"alert",className:"text-sm text-bad",children:E}):null]})]})}a(gv,"IssueMonitorComposerStrip");function Iu(e,s){if(!e||typeof e!="object"||Array.isArray(e))return!1;const n=e;return n.code==="chat_board_send_attachments_already_bound"&&Array.isArray(n.attachmentIds)&&n.attachmentIds.length>0&&new Set(n.attachmentIds).size===n.attachmentIds.length&&n.attachmentIds.every(r=>typeof r=="string"&&s.includes(r))}a(Iu,"isBoardSendRejection");function xv(e,s){if(!(e instanceof Hs)||e.status!==409||!e.body||typeof e.body!="object")return null;const n=e.body.details;if(!Iu(n,s.attachmentIds))return null;const r=n;return r.endpointId!==s.endpointId||r.conversationId!==s.conversationId||r.idempotencyKey!==s.idempotencyKey?null:{code:n.code,attachmentIds:[...n.attachmentIds]}}a(xv,"readBoardSendRejection");function Nu(e,s,n,r){return`wardmote:board-send:v1:${JSON.stringify([e,s,n,r])}`}a(Nu,"boardSendDraftKey");function yv(e){const s=sessionStorage.getItem(e);if(!s)return null;const n=JSON.parse(s);if(!n||typeof n!="object"||typeof n.body!="string"||!n.body.trim()||n.body.length>1e5||typeof n.idempotencyKey!="string"||n.idempotencyKey.length<16||n.idempotencyKey.length>200||!Array.isArray(n.attachmentIds)||n.attachmentIds.length>20||!n.attachmentIds.every(r=>typeof r=="string")||n.rejection!==void 0&&(n.publication!==null||!Iu(n.rejection,n.attachmentIds))||n.attachmentNames!==void 0&&(!Array.isArray(n.attachmentNames)||n.attachmentNames.length!==n.attachmentIds.length||new Set(n.attachmentNames.map(r=>r?.id)).size!==n.attachmentNames.length||!n.attachmentNames.every(r=>r&&typeof r.id=="string"&&n.attachmentIds.includes(r.id)&&typeof r.name=="string"))||n.publication!==null&&(!n.publication||typeof n.publication.id!="string"||!n.publication.id||!km.includes(n.publication.state)||!Number.isSafeInteger(n.publication.attempts)||n.publication.attempts<0))throw new Error("Saved channel delivery identity could not be read. Check Activity before starting another send.");return n}a(yv,"readBoardSendDraft");function no(e,s){sessionStorage.setItem(e,JSON.stringify(s))}a(no,"writeBoardSendDraft");function ao(e){sessionStorage.removeItem(e)}a(ao,"clearBoardSendDraft");function Rc(e){if(!e||e.canDismiss!==!0||!Number.isSafeInteger(e.total)||e.total<=0)return!1;const s=[e.published,e.declined,e.expired,e.cancelled];return s.every(n=>typeof n=="number"&&Number.isSafeInteger(n)&&n>=0)?e.settled===e.total&&e.awaitingConsent===0&&s.reduce((n,r)=>n+r,0)===e.total&&(!e.parts||e.parts.length===e.total&&e.parts.every(n=>n.state==="published"||n.state==="cancelled"&&(!n.fileTransfer||["declined","expired","cancelled"].includes(n.fileTransfer.phase)))):!1}a(Rc,"canDismissBoardSendBatch");var Tc={speko:"Speko",slack:"Slack",github:"GitHub",discord:"Discord","microsoft-teams":"Microsoft Teams",telegram:"Telegram",agentmail:"AgentMail","imessage-photon":"iMessage Photon",openwa:"OpenWA"},ro={awaiting_consent:{title:"Waiting for file consent",body:"The recipient must accept the file card in Microsoft Teams. The file is not delivered yet; this send identity is kept while Wardmote waits.",tone:"info"},published:{title:"Sent to channel",body:"The board update was published to the connected conversation.",tone:"success"},pending:{title:"Queued for channel",body:"Delivery is still pending. Your draft is kept until Wardmote confirms publication.",tone:"info"},streaming:{title:"Publishing to channel",body:"Delivery is still in progress. Your draft is kept until Wardmote confirms publication.",tone:"info"},retry:{title:"Delivery retry scheduled",body:"Wardmote will retry this publication. Your draft and retry identity are kept.",tone:"warn"},delivery_unknown:{title:"Delivery not confirmed",body:"The provider may have accepted this update. Resolve it in Activity before trying again to avoid a duplicate.",tone:"warn"},failed:{title:"Channel delivery failed",body:"Your draft is kept. Open Activity to retry this same publication safely.",tone:"error"},cancelled:{title:"Channel delivery cancelled",body:"Your draft is kept. Some parts may already have been published; check Activity before starting a new send.",tone:"info"}},vv={consent_pending:"Consent card queued",consent_sending:"Sending consent card",consent_unknown:"Consent card delivery not confirmed",awaiting_consent:"Awaiting consent",upload_pending:"Upload queued",uploading:"Uploading file",upload_unknown:"File upload not confirmed",file_info_pending:"File notification queued",file_info_sending:"Sending file notification",file_info_unknown:"File notification not confirmed",delivered:"Delivered",declined:"Declined",expired:"Consent expired",cancelled:"Cancelled; remote bytes may remain",conflict:"File delivery needs review"};function bv(e,s){const{enabled:n,githubEnabled:r}=Gm(),i=(n||r)&&!!(e&&s)&&!s.startsWith("chat:"),o=ye({queryKey:["issue-chat-binding",e,s],queryFn:a(()=>wo.getIssueBinding(s),"queryFn"),enabled:i});return{binding:i&&Vm(o.data?.provider,n,r)?o.data??null:null,isLoading:i&&o.isLoading}}a(bv,"useIssueChatBinding");function kv(e){const{binding:s}=bv(e.companyId,e.issueId);return!s||s.provider==="agentmail"?null:(0,t.jsx)(wv,{...e,binding:s},Nu(e.companyId,e.issueId,s.endpointId,s.conversationId))}a(kv,"ExternallyConnectedTaskBanner");function wv({className:e,attachments:s=[],companyId:n,issueId:r,issueCacheRefs:i,binding:o}){const{pushToast:u}=Jf(),m=ks(),[p,h]=(0,l.useState)(!1),[d,v]=(0,l.useState)(""),[k,N]=(0,l.useState)([]),[A,E]=(0,l.useState)(null),_=(0,l.useRef)(null),q=(0,l.useRef)(null),O=(0,l.useRef)(null),[F,C]=(0,l.useState)(!1),[S,P]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[w,W]=(0,l.useState)(!1),[M,$]=(0,l.useState)(null),K=(0,l.useRef)(null),le=(0,l.useRef)(!1),y=(0,l.useRef)(!0),[z,se]=(0,l.useState)(!1),[de,me]=(0,l.useState)(null),[oe,ve]=(0,l.useState)([]);(0,l.useEffect)(()=>(y.current=!0,()=>{y.current=!1}),[]);const ie=o?Nu(n,r,o.endpointId,o.conversationId):null,ge=(0,l.useRef)(null);(0,l.useEffect)(()=>{if(!(!ie||ge.current===ie)){ge.current=ie;try{const Y=yv(ie);O.current=ie,q.current=Y,_.current=Y?.idempotencyKey??null,v(Y?.body??""),N(Y?.attachmentIds??[]),E(Y?.publication??null),C(!!(Y&&!Y.publication&&!Y.rejection)),P(Y?.rejection??null),h(!!Y),$(null)}catch{$("Saved delivery identity could not be read. Check Activity and restore browser storage before starting another send."),h(!0)}}},[ie]);const Ie=!!(ie&&ge.current===ie&&O.current===ie),De=(0,l.useCallback)(()=>{for(const Y of new Set([r,...i??[]]))for(const Ae of[R.issues.comments(Y),R.issues.attachments(Y),R.issues.detail(Y),R.issues.activity(Y)])m.invalidateQueries({queryKey:Ae})},[r,i,m]),$e=(0,l.useCallback)(()=>{if(ie)try{ao(ie)}catch{}q.current=null,C(!1),P(null),W(!1),E(null),_.current=null,v(""),N([]),ve([]),me(null),h(!1),De(),u(ro.published)},[De,u,ie]),Be=ye({queryKey:["chat-publication-batch",n,o?.endpointId,o?.conversationId,A?.id],queryFn:a(()=>wo.getPublicationBatchStatus(o.endpointId,o.conversationId,A.id),"queryFn"),enabled:Ie&&!!A,staleTime:0,refetchInterval:2e3,refetchIntervalInBackground:!1,retry:!1});(0,l.useEffect)(()=>{const Y=Be.data;A&&Y&&Y.total>0&&Y.published===Y.total&&Y.publication.state==="published"&&$e()},[A,Be.data,$e]);const Fe=Pe({mutationFn:a(Y=>wo.publishBoardMessage(Y.endpointId,Y.conversationId,Y.body,Y.idempotencyKey,Y.attachmentIds),"mutationFn"),onSuccess:a(Y=>{De();const Ae=ro[Y.state];if(E(Y.state==="published"?null:Y),Y.state==="published"){$e();return}if(C(!1),ie&&q.current){q.current={...q.current,publication:{id:Y.id,state:Y.state,attempts:Y.attempts}};try{no(ie,q.current)}catch{}}u({...Ae,action:{label:"View activity",href:`/apps/chat/${o.endpointId}/activity`}})},"onSuccess"),onError:a((Y,Ae)=>{const ht=xv(Y,Ae);if(ht&&q.current&&ie){const U={...q.current,rejection:ht};try{no(ie,U)}catch{$("The rejected send could not be saved. Restore browser storage, then retry this same request to recover its receipt.");return}q.current=U,P(ht),C(!1),De(),u({title:"Update was not sent",body:"A selected file already belongs to another comment. Edit the rejected send to correct the selection.",tone:"error"});return}u({title:"Couldn't confirm channel delivery",body:Y instanceof Error?`${Y.message} Your draft is kept; retrying here reuses the same request identity.`:"Your draft is kept; retrying here reuses the same request identity.",tone:"error"})},"onError")}),re=!!(q.current||A||Fe.isPending||Fe.isError||F||M||!Ie||z);async function Se(Y){if(!(re||le.current||q.current)){le.current=!0,se(!0),me(null);try{const Ae=await xe.uploadAttachment(n,r,Y);if(!y.current)return;ve(ht=>[...ht,Ae]),N(ht=>[...ht,Ae.id]),_.current=null}catch(Ae){y.current&&me(`${Ae instanceof Error?Ae.message:"Upload could not be confirmed."} No channel message was sent. Check task files before retrying the upload.`)}finally{le.current=!1,y.current&&se(!1),De()}}}a(Se,"uploadFile");const Ve=[...new Map([...oe,...s].map(Y=>[Y.id,Y])).values()];(0,l.useEffect)(()=>{if(q.current)return;const Y=s.filter(Ae=>Ae.issueCommentId!==null).map(Ae=>Ae.id);k.some(Ae=>Y.includes(Ae))&&(N(Ae=>Ae.filter(ht=>!Y.includes(ht))),W(!0),_.current=null)},[s,k]);const Je=!!q.current,ft=q.current?q.current.attachmentIds.map(Y=>({id:Y,originalFilename:q.current?.attachmentNames?.find(Ae=>Ae.id===Y)?.name??Ve.find(Ae=>Ae.id===Y)?.originalFilename??"Selected task file (details unavailable)"})):Ve.filter(Y=>Y.issueCommentId===null&&!j.includes(Y.id)),Ze=Be.data?.publication??A,Te=Be.data,Nt=!Be.isError&&!Be.isFetching&&Rc(Te),vt=Rc(Te)&&Te.published<Te.total?{title:"Delivery settled with mixed outcomes",body:"Not every part was confirmed delivered. Review the outcomes below; dismissing this receipt does not resend anything.",tone:"info"}:Ze?.state==="cancelled"&&(Te?.awaitingConsent??0)>0?{title:"Waiting for remaining file consent",body:"Some parts have settled. The remaining file cards still need the recipient's response; this send stays locked until the whole batch is resolved.",tone:"info"}:Ze?ro[Ze.state]:null,Ut=`/apps/chat/${o.endpointId}/activity`;return(0,t.jsxs)("section",{"aria-label":"External conversation",className:ue("task-context-notice space-y-3",e),children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 basis-64 items-center gap-3",children:[(0,t.jsx)(Pf,{className:"h-4 w-4 shrink-0 text-ink-3"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("p",{className:"font-medium",children:["Connected to ",Tc[o.provider]]}),(0,t.jsxs)("p",{className:"truncate text-xs text-ink-3",children:[o.externalLabel," · ",o.provider==="slack"?"Messages you send here and agent replies are also posted to Slack.":"Agent assignment is fixed for this external task."]})]})]}),(0,t.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[o.externalUrl&&(0,t.jsx)(ne,{asChild:!0,size:"sm",variant:"secondary",children:(0,t.jsxs)("a",{href:o.externalUrl,target:"_blank",rel:"noreferrer",children:["Open ",Tc[o.provider]," ",(0,t.jsx)(Po,{})]})}),(0,t.jsx)(ne,{size:"sm",variant:"secondary",onClick:a(()=>h(Y=>!Y),"onClick"),children:"Send to channel"}),(0,t.jsx)(ne,{asChild:!0,size:"sm",variant:"ghost",children:(0,t.jsx)(ls,{to:`/apps/chat/${o.endpointId}/conversations`,children:"Connection"})})]})]}),p&&(0,t.jsxs)("div",{className:"space-y-2 border-t border-line pt-3",children:[(0,t.jsx)("label",{className:"text-xs font-medium",htmlFor:"external-board-update",children:"Board update"}),(0,t.jsx)(va,{id:"external-board-update",value:d,disabled:!!A||!!S||Fe.isError||F||!!M||!Ie,onChange:a(Y=>{v(Y.target.value),_.current=null,Fe.reset()},"onChange"),placeholder:"Write only what should be visible in the provider conversation."}),k.length>0&&!d.trim()&&(0,t.jsx)("p",{className:"text-xs text-ink-3",children:"Add a message to send with your files."}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("input",{ref:K,type:"file",className:"hidden","aria-label":"Attach file to channel update",disabled:re,onChange:a(Y=>{const Ae=Y.target.files?.[0];Y.target.value="",Ae&&Se(Ae)},"onChange")}),(0,t.jsxs)(ne,{type:"button",size:"sm",variant:"secondary",disabled:re,onClick:a(()=>K.current?.click(),"onClick"),children:[(0,t.jsx)($l,{}),z?"Uploading…":"Attach file"]}),(0,t.jsx)("p",{className:"text-xs text-ink-3",children:"Files stay on this task until you send them to the channel."})]}),de&&(0,t.jsx)("p",{role:"alert",className:"text-xs text-bad",children:de}),w&&(0,t.jsx)("p",{role:"status",className:"text-xs text-ink-3",children:"A file already attached to another comment was removed from this selection. Attach a new copy or share the task link; your message is unchanged."}),ft.length>0&&(0,t.jsxs)("fieldset",{className:"space-y-2 rounded-md border border-line bg-bg p-3",disabled:Je||!!A||Fe.isError||F||!!M||!Ie,children:[(0,t.jsx)("legend",{className:"px-1 text-xs font-medium",children:Je?"Files in this send":"Include task files"}),(0,t.jsx)("p",{className:"text-xs text-ink-3",children:o.provider==="github"?"GitHub Apps cannot upload file bytes in comments. Checked files stay on the Wardmote task; GitHub receives an authenticated task link when this Board has a public URL, or a private-task notice otherwise.":o.provider==="microsoft-teams"&&!Je?"In personal Teams chats, recipients accept each file before upload. Channels and group chats receive supported images directly; other files stay on the task, with a task link or private-task notice.":Je?"These are the files selected for this send. Selection is locked until delivery is resolved.":"Only checked files will be published to the external conversation."}),(0,t.jsx)("div",{className:"space-y-2",children:ft.map(Y=>{const Ae=Y.originalFilename??"Unnamed attachment";return(0,t.jsxs)("label",{className:"flex items-center gap-2 text-xs",children:[(0,t.jsx)(qo,{disabled:Je,checked:k.includes(Y.id),onCheckedChange:a(ht=>{N(U=>ht===!0?[...U,Y.id]:U.filter(Ue=>Ue!==Y.id)),_.current=null,Fe.reset()},"onCheckedChange")}),(0,t.jsx)($l,{className:"h-3.5 w-3.5 text-ink-3"}),(0,t.jsx)("span",{className:"truncate",children:Ae})]},Y.id)})})]}),M&&(0,t.jsx)("p",{role:"alert",className:"text-xs text-bad",children:M}),S&&(0,t.jsxs)("div",{role:"alert",className:"space-y-1 rounded-md border border-line bg-bg p-3 text-xs",children:[(0,t.jsx)("p",{className:"font-medium",children:"Update was not sent"}),(0,t.jsx)("p",{className:"text-ink-3",children:"A selected file already belongs to another comment. This request was rejected before any channel message was queued. Your exact draft is kept."}),(0,t.jsx)(ne,{size:"sm",variant:"secondary",disabled:!!M,onClick:a(()=>{if(!ie||!q.current?.rejection)return;try{ao(ie)}catch{$("Saved rejection could not be cleared. Restore browser storage before editing this send.");return}const Y=q.current.rejection.attachmentIds;f(Ae=>[...new Set([...Ae,...Y])]),N(Ae=>Ae.filter(ht=>!Y.includes(ht))),ve(Ae=>Ae.filter(ht=>!Y.includes(ht.id))),q.current=null,_.current=null,P(null),C(!1),W(!0),Fe.reset()},"onClick"),children:"Edit rejected send"})]}),!S&&(Fe.isError||F)&&!Fe.isPending&&!A&&(0,t.jsxs)("div",{role:"alert",className:"space-y-1 rounded-md border border-line bg-bg p-3 text-xs",children:[(0,t.jsx)("p",{className:"font-medium",children:"Delivery result not confirmed"}),(0,t.jsx)("p",{className:"text-ink-3",children:"Your exact draft and request identity are kept. Retry safely to learn the authoritative publication state without creating a duplicate."}),(0,t.jsx)(ls,{className:"inline-block font-medium underline underline-offset-4",to:Ut,children:"Open Activity"})]}),A&&Ze&&vt&&(0,t.jsxs)("div",{role:Ze.state==="failed"||Ze.state==="delivery_unknown"?"alert":"status",className:"space-y-1 rounded-md border border-line bg-bg p-3 text-xs",children:[(0,t.jsx)("p",{className:"font-medium",children:vt.title}),(0,t.jsx)("p",{className:"text-ink-3",children:vt.body}),Te&&(0,t.jsx)("p",{className:"text-ink-3",children:Te.declined!==void 0&&Te.expired!==void 0&&Te.cancelled!==void 0&&Te.awaitingConsent!==void 0?[`${Te.published} published`,...Te.awaitingConsent?[`${Te.awaitingConsent} awaiting consent`]:[],...Te.declined?[`${Te.declined} declined`]:[],...Te.expired?[`${Te.expired} expired`]:[],...Te.cancelled?[`${Te.cancelled} cancelled`]:[]].join(" · "):`${Te.published} of ${Te.total} parts published.`}),Te?.parts?.some(Y=>Y.fileTransfer)&&(0,t.jsx)("ul",{className:"space-y-1 text-ink-3","aria-label":"File delivery outcomes",children:Te.parts.filter(Y=>Y.fileTransfer).map(Y=>(0,t.jsxs)("li",{children:[Y.fileTransfer.filename," —"," ",vv[Y.fileTransfer.phase]]},Y.id))}),Be.isError&&(0,t.jsx)("p",{role:"alert",className:"text-ink-3",children:"Delivery status could not be refreshed. Your draft is kept; Wardmote will check again without sending another update."}),Ze.redactedError&&(0,t.jsxs)("p",{className:"text-ink-3",children:["Provider detail: ",Ze.redactedError]}),(0,t.jsx)(ls,{className:"inline-block font-medium underline underline-offset-4",to:Ut,children:"Open Activity"}),Nt&&(0,t.jsx)(ne,{className:"ml-3",size:"sm",variant:"ghost",onClick:a(()=>{if(ie)try{ao(ie)}catch{$("Saved delivery identity could not be cleared. Restore browser storage before starting another send.");return}$(null),q.current=null,C(!1),E(null),v(""),N([]),ve([]),me(null),_.current=null,Fe.reset()},"onClick"),children:"Dismiss delivery receipt"})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("p",{className:"text-xs text-ink-3",children:o.provider==="slack"?"Your message is posted to Slack with your name and starts the agent.":"Ordinary board comments remain Wardmote-only."}),(0,t.jsx)(ne,{size:"sm",disabled:!d.trim()||Fe.isPending||z||!!A||!!S||!!M||!Ie,onClick:a(()=>{if(le.current||!ie||ge.current!==ie||O.current!==ie)return;_.current??=crypto.randomUUID();const Y=q.current??{attachmentIds:k,attachmentNames:k.map(Ae=>({id:Ae,name:Ve.find(ht=>ht.id===Ae)?.originalFilename??"Unnamed attachment"})),body:d.trim(),idempotencyKey:_.current,publication:null};try{if(!ie)throw new Error("Missing delivery scope");no(ie,Y)}catch{$("Browser storage could not preserve this delivery identity. No update was sent. Restore browser storage, then reload to try again.");return}q.current=Y,C(!0),Fe.mutate({...Y,endpointId:o.endpointId,conversationId:o.conversationId})},"onClick"),children:Fe.isPending?"Sending…":!S&&(Fe.isError||F)?"Retry safely":"Send to channel"})]})]})]})}a(wv,"ConnectedTaskComposer");var jv=250,Iv=8e3;function Nv(e,s,n){if(s-=n,e<1||s<1)return null;const r=Math.min(1,6144/e,3456/s);return{width:Math.max(1,Math.round(e*r)),height:Math.max(1,Math.round(s*r))}}a(Nv,"browserPaneSize");function Sv({issueId:e,browserId:s,enabled:n,active:r,frameRef:i}){const[o]=(0,l.useState)(()=>crypto.randomUUID()),[u,m]=(0,l.useState)({preset:"fit"}),p=(0,l.useRef)(u),[h,d]=(0,l.useState)(null),[v,k]=(0,l.useState)(!1),N=(0,l.useRef)(0),A=(0,l.useRef)(Promise.resolve()),E=(0,l.useRef)(()=>{}),_=(0,l.useRef)(()=>{}),q=(0,l.useCallback)((O,F)=>{F===N.current&&(p.current=O,m(O),_.current())},[]);return(0,l.useEffect)(()=>{N.current++,p.current={preset:"fit"},m(p.current),d(null)},[s]),(0,l.useEffect)(()=>{const O=i.current;if(!n||!r||!s||!O)return;let F=!1,C=!1,S=!1,P=p.current.preset,j=null,f=null,w;const W=a(()=>!F&&document.visibilityState!=="hidden"&&O.getClientRects().length>0&&(!O.checkVisibility||O.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0})),"visible"),M=a(()=>{const ve=O.getBoundingClientRect(),ie=parseFloat(getComputedStyle(O).getPropertyValue("--browser-use-viewer-chrome-height"))||0;return W()?Nv(ve.width,ve.height,ie):null},"measure"),$=a(()=>{A.current=A.current.catch(()=>{}).then(()=>Oa.releaseViewport(e,s,o)).catch(()=>{})},"release"),K=a(()=>{S||!j||!W()||(S=!0,A.current=A.current.catch(()=>{}).then(async()=>{for(;j&&W();){const ve=j;j=null;const ie=N.current;ve.preset==="fit"&&!ve.takeControl||k(!0);try{const ge=await Oa.resize(e,s,ve);if(F||ie!==N.current)continue;p.current=ge,P=ge.preset,m(ge),d(null)}catch{!F&&ie===N.current&&(C=!0,P=p.current.preset,j=null,d("Browser size could not be changed. Choose a size in Browser options to try again."))}finally{ie===N.current&&N.current++,F||k(!1)}}}).finally(()=>{S=!1,!F&&j&&K()}))},"pump"),le=a(ve=>{ve.preset==="fit"&&j?.preset==="fit"&&j.takeControl&&(ve={...ve,takeControl:!0}),j=ve,N.current++,K()},"enqueue"),y=a((ve=!1)=>{const ie=M();!ie||!ve&&(C||P!=="fit")||le({preset:"fit",...ie,viewerId:o,...ve?{takeControl:!0}:{}})},"fit"),z=a(()=>{const ve=M();if(!ve){clearTimeout(w),j=null,f=null,$();return}f&&Math.abs(ve.width-f.width)<2&&Math.abs(ve.height-f.height)<2||(f=ve,clearTimeout(w),w=setTimeout(()=>{w=void 0,y()},jv))},"resized");E.current=ve=>{clearTimeout(w),w=void 0,j=null,C=!1,P=ve,d(null),ve==="fit"?y(!0):le({preset:ve,viewerId:o})},_.current=()=>{P=p.current.preset};const se=a(()=>{clearTimeout(w),j=null,N.current++,W()?(f=null,z()):$()},"visibility"),de=new ResizeObserver(z);de.observe(O),document.addEventListener("visibilitychange",se);const me=a(()=>{clearTimeout(w),j=null,$()},"pagehide");window.addEventListener("pagehide",me);const oe=setInterval(()=>{w||y()},Iv);return z(),()=>{F=!0,N.current++,j=null,clearTimeout(w),clearInterval(oe),de.disconnect(),document.removeEventListener("visibilitychange",se),window.removeEventListener("pagehide",me),E.current=()=>{},_.current=()=>{},k(!1),$()}},[e,s,n,r,i,o]),{state:u,error:h,resizing:v,viewerId:o,version:N,receive:q,select:(0,l.useCallback)(O=>E.current(O),[])}}a(Sv,"useBrowserViewport");function Cv({issueId:e,browser:s,accessError:n=!1,active:r=!0,onOpenActiveBrowser:i}){const o=ks(),[u,m]=(0,l.useState)(null),[p,h]=(0,l.useState)(null),[d,v]=(0,l.useState)(0),k=(0,l.useRef)(0),N=a(()=>{k.current=0,v(M=>M+1)},"reconnect"),[A,E]=(0,l.useState)("loading"),[_,q]=(0,l.useState)(Date.now()),O=(0,l.useRef)(null),F=s&&["running","idle"].includes(s.status)&&!n,C=Sv({issueId:e,browserId:s?.id,enabled:!!(F&&u&&A==="loaded"),active:r,frameRef:O});(0,l.useEffect)(()=>{const M=setInterval(()=>q(Date.now()),1e3);return()=>clearInterval(M)},[]),(0,l.useEffect)(()=>{if(m(null),h(null),!F||!s)return;let M=!1;const $=new AbortController,K=a(()=>{const y=C.version.current;return Oa.viewer(e,s.id,$.signal,C.viewerId).then(z=>{M||(m(z.url),h(null),C.receive(z.viewportState??{preset:z.viewport??"fit"},y))}).catch(()=>{M||(m(null),h("The live view disconnected. Use Reconnect view in Browser options to try again."))})},"load");K();const le=setInterval(()=>{K()},15e3);return()=>{M=!0,$.abort(),clearInterval(le)}},[e,s?.id,F,d]),(0,l.useEffect)(()=>{E("loading")},[u,d]),(0,l.useEffect)(()=>{k.current=0},[s?.id]),(0,l.useEffect)(()=>{if(!r||!u||A!=="loading")return;const M=setTimeout(()=>{k.current===0?(k.current+=1,v($=>$+1)):E("timed-out")},15e3);return()=>clearTimeout(M)},[r,u,d,A]);const[S,P]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(!r||!F||!u||!s||s.status!=="idle")return;let M=!1,$=!1;const K=a(async()=>{const y=O.current;if(!($||document.visibilityState==="hidden"||!y||!y.getClientRects().length||y.checkVisibility&&!y.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0}))){$=!0;try{const z=await Oa.presence(e,s.id);!M&&z.accepted&&P(!1)}catch{M||P(!0)}finally{$=!1}}},"renew");K();const le=setInterval(()=>{K()},3e4);return document.addEventListener("visibilitychange",K),()=>{M=!0,clearInterval(le),document.removeEventListener("visibilitychange",K)}},[r,F,u,s?.id,s?.status,e]);const j=Pe({mutationFn:a(M=>Oa.control(e,s.id,M),"mutationFn"),onSuccess:a(()=>{o.invalidateQueries({queryKey:["task-browsers",e]})},"onSuccess"),onError:a(()=>h("The browser action failed. Try again."),"onError")}),f=n?"You no longer have access to this browser.":s?.error??p,w=n?"Browser access unavailable":s?.status==="starting"?"Starting browser…":s?.status==="stopping"?"Closing browser…":s?.status==="closed"?"Browser closed":s?.status==="failed"?"Browser could not start":p?"Live view disconnected":F?"Connecting to browser…":"No browser open",W=!f&&(s?.status==="starting"||s?.status==="stopping"||F);return(0,t.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[F&&u?(0,t.jsxs)("div",{className:"relative min-h-0 flex-1",children:[(0,t.jsx)("iframe",{ref:O,title:"Live Browser Use browser",src:u,onLoad:a(()=>E("loaded"),"onLoad"),referrerPolicy:"no-referrer",allow:"autoplay; clipboard-write",className:"absolute inset-0 h-full w-full border-0"},d),A!=="loaded"&&(0,t.jsx)("div",{role:A==="timed-out"?"alert":"status",className:"absolute inset-0 flex flex-col items-center justify-center gap-3 bg-bg p-6 text-center",children:A==="loading"?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(It,{className:"size-5 animate-spin text-ink-3 motion-reduce:animate-none","aria-hidden":"true"}),(0,t.jsx)("p",{className:"text-sm",children:"Connecting to browser…"})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:"The live view did not load"}),(0,t.jsx)("p",{className:"max-w-sm text-sm text-ink-3",children:"Reconnect the view or open this task in another browser. The remote browser is still running."}),(0,t.jsx)(ne,{variant:"secondary",size:"sm",onClick:N,children:"Reconnect view"})]})})]}):(0,t.jsxs)("div",{role:f?"alert":"status",className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-3 overflow-auto p-6 text-center",children:[W?(0,t.jsx)(It,{className:"size-5 animate-spin text-ink-3 motion-reduce:animate-none","aria-hidden":"true"}):(0,t.jsx)(pi,{className:"size-5 text-ink-3","aria-hidden":"true"}),(0,t.jsxs)("div",{className:"max-w-sm space-y-2",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:w}),(0,t.jsx)("p",{className:"text-sm text-ink-3",children:f??(s?.status==="closed"?i?"Another browser is still open on this task.":"Send a task message to ask the agent to open another browser.":s?.status==="starting"?"The live view will appear here when it is ready.":s?.status==="stopping"?"Waiting for Browser Use to confirm shutdown.":F?null:"Ask the agent to browse a website in a task message.")})]}),s?.status==="closed"&&!n&&i&&(0,t.jsx)(ne,{variant:"secondary",size:"sm",onClick:i,children:"Open active browser"})]}),F&&u&&f&&(0,t.jsx)("p",{role:"alert",className:"px-3 py-2 text-xs text-bad",children:f}),F&&S&&(0,t.jsx)("p",{role:"alert",className:"px-3 py-2 text-xs text-bad",children:"Could not keep this browser open. Check your connection before the timer runs out."}),F&&C.error&&(0,t.jsx)("p",{role:"alert",className:"px-3 py-2 text-xs text-bad",children:C.error}),s&&!n&&(0,t.jsx)(Wg,{browser:s,now:_,disabled:j.isPending,onControl:a(M=>j.mutate(M),"onControl"),onReconnect:N,viewport:C.state.preset,controlledElsewhere:C.state.controlledElsewhere,resizing:C.resizing,resizeAvailable:A==="loaded",onResize:C.select})]})}a(Cv,"TaskBrowserPanel");var Da=100;function pr(e){const s=e.lastIndexOf("/");return s<0?e:e.slice(s+1)}a(pr,"basename$1");function Av(e){if(!e)return"";const s=e.replace(/^\/+/,"").replace(/\/+$/,"");return s?`${s}/`:""}a(Av,"normalizeFolderPrefix");function So(e){const s=e?.replace(/^\/+/,"").replace(/\/+$/,"");if(!s)return null;const n=s.lastIndexOf("/");return n>0?s.slice(0,n):null}a(So,"parentFolderPath");function Co(e){return e?.replace(/^\/+/,"").replace(/\/+$/,"")??""}a(Co,"folderKey");function Rv(e,s){const n=So(e);if(!n)return[];const r=Co(s),i=n.split("/").filter(Boolean),o=r?r.split("/").filter(Boolean):[];if(o.some((m,p)=>i[p]!==m))return[];const u=[];for(let m=o.length;m<i.length;m+=1)u.push(i.slice(0,m+1).join("/"));return u}a(Rv,"selectedAncestorFolders");function Ec(e){const s=e.toLowerCase();return s.includes("remote")?{icon:(0,t.jsx)(gd,{"aria-hidden":"true",className:"h-5 w-5 text-ink-3"}),title:"Remote workspace preview not supported",body:"This workspace is hosted remotely and is not available for inline preview yet."}:s.includes("no_workspace")||s.includes("no_local")?{icon:(0,t.jsx)(Rn,{"aria-hidden":"true",className:"h-5 w-5 text-ink-3"}),title:"No workspace yet",body:"This issue does not have a workspace to browse. Files appear here once a run creates one."}:s.includes("archiv")||s.includes("cleaned")||s.includes("unavailable")?{icon:(0,t.jsx)(Rn,{"aria-hidden":"true",className:"h-5 w-5 text-ink-3"}),title:"Workspace is no longer available",body:"The isolated worktree for this issue has been cleaned up, so files cannot be previewed."}:{icon:(0,t.jsx)(nn,{"aria-hidden":"true",className:"h-5 w-5 text-amber-500"}),title:"Workspace unavailable",body:"These workspace files can't be browsed right now."}}a(Ec,"describeUnavailable");function $a({icon:e,title:s,body:n,actions:r}){return(0,t.jsxs)("div",{className:"flex items-start gap-3 px-1 py-8 text-sm",children:[e,(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("p",{className:"font-medium text-ink",children:s}),n?(0,t.jsx)("p",{className:"text-ink-3",children:n}):null,r?(0,t.jsx)("div",{className:"pt-1",children:r}):null]})]})}a($a,"StateMessage");function Tv({rootLabel:e,folderPath:s,onOpenFolder:n}){const r=s?.split("/").filter(Boolean)??[];return!e&&r.length===0?null:(0,t.jsx)("nav",{"aria-label":"Current folder",className:"min-w-0 overflow-hidden text-(length:--text-micro) text-ink-3",children:(0,t.jsxs)("ol",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[e?(0,t.jsx)("li",{className:"min-w-0 shrink",children:(0,t.jsx)("button",{type:"button",onClick:a(()=>n(null),"onClick"),className:"max-w-full truncate rounded px-1 py-0.5 text-left hover:bg-bg-3 hover:text-ink",title:e,children:e})}):null,r.map((i,o)=>{const u=r.slice(0,o+1).join("/");return(0,t.jsxs)("li",{className:"flex min-w-0 shrink items-center gap-1",children:[(0,t.jsx)("span",{"aria-hidden":"true",className:"shrink-0 opacity-50",children:"/"}),(0,t.jsx)("button",{type:"button",onClick:a(()=>n(u),"onClick"),className:"max-w-full truncate rounded px-1 py-0.5 text-left font-mono hover:bg-bg-3 hover:text-ink",title:u,children:i})]},u)})]})})}a(Tv,"WorkspaceFileBreadcrumbs");function Ev({item:e,treeItemId:s,selected:n,highlighted:r,depth:i,onOpen:o,onHover:u,downloadUrl:m}){const p=pr(e.relativePath);return(0,t.jsxs)("div",{id:s,role:"treeitem","aria-selected":n,onClick:o,onMouseEnter:u,title:e.displayPath,className:ue("flex min-h-(--sz-36px) cursor-pointer items-center gap-2 rounded-md py-1.5 pr-2 sm:min-h-0",n?"bg-bg-3 text-ink":r?"bg-bg-3/50":"hover:bg-bg-3/60"),style:{paddingLeft:`${.5+i*.875}rem`},children:[(0,t.jsx)(Ua,{"aria-hidden":"true",className:"h-3.5 w-3.5 shrink-0 text-ink-3"}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-ink",children:p}),m?(0,t.jsx)("a",{href:m,download:p,"aria-label":`Download ${p}`,title:`Download ${p}`,onClick:a(h=>h.stopPropagation(),"onClick"),className:"ml-auto inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-ink-3 opacity-70 hover:bg-bg/70 hover:text-ink hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus",children:(0,t.jsx)(Xo,{"aria-hidden":"true",className:"h-3.5 w-3.5"})}):null]})}a(Ev,"WorkspaceFileRow");function Ba(e){return`${e.kind}:${e.workspaceId}:${e.relativePath}`}a(Ba,"itemKey");function Su(e,s){if(e.kind!==s.kind)return e.kind==="folder"?-1:1;const n=e.kind==="folder"?e.name:pr(e.item.relativePath),r=s.kind==="folder"?s.name:pr(s.item.relativePath);return n.localeCompare(r)}a(Su,"compareTreeNodes");function Cu(e){const s=[...Array.from(e.folders.values()).map(Cu),...e.files];return s.sort(Su),{kind:"folder",key:e.key,name:e.name,depth:e.depth,children:s,lazy:!1}}a(Cu,"finalizeTreeFolder");function _v(e,s){const n=Av(s),r={kind:"folder",key:"__root__",name:"",depth:-1,folders:new Map,files:[]};for(const i of e){if(i.kind!=="file")continue;const o=(i.relativePath.startsWith(n)?i.relativePath.slice(n.length):i.relativePath).split("/").filter(Boolean),u=o.pop()??pr(i.relativePath);let m=r,p=n.replace(/\/$/,"");for(const h of o){p=p?`${p}/${h}`:h;let d=m.folders.get(h);d||(d={kind:"folder",key:p,name:h,depth:m.depth+1,folders:new Map,files:[]},m.folders.set(h,d)),m=d}m.files.push({kind:"file",key:Ba(i),item:{...i,title:u},depth:m.depth+1})}return Cu(r).children}a(_v,"buildWorkspaceFileTree");function _c(e){const s=e.map(n=>n.kind==="directory"?{kind:"folder",key:n.relativePath,name:pr(n.relativePath),depth:0,children:[],lazy:!0}:{kind:"file",key:Ba(n),item:n,depth:0});return s.sort(Su),s}a(_c,"buildWorkspaceDirectoryTree");function qv({nodes:e,listboxId:s,highlightedItemKey:n,selectedItemKey:r,collapsedFolders:i,expandedLazyFolders:o,forcedExpandedFolders:u,getLazyChildren:m,isLazyFolderFetching:p,isLazyFolderTruncated:h,onLoadMoreFolder:d,onToggleFolder:v,onOpen:k,onHoverFile:N,getDownloadUrl:A}){function E(_){if(_.kind==="folder"){const q=_.lazy?u.has(_.key)||o.has(_.key):u.has(_.key)||!i.has(_.key),O=_.lazy?m?.(_.key,_.depth+1)??[]:_.children,F=_.lazy&&p?.(_.key),C=_.lazy&&h?.(_.key);return(0,t.jsxs)("div",{children:[(0,t.jsxs)("button",{type:"button",role:"treeitem","aria-expanded":q,title:_.key,onClick:a(()=>v(_.key),"onClick"),className:"flex min-h-(--sz-32px) w-full items-center gap-1.5 rounded-md py-1 pr-2 text-left hover:bg-bg-3/60",style:{paddingLeft:`${.25+_.depth*.875}rem`},children:[q?(0,t.jsx)(br,{"aria-hidden":"true",className:"h-3.5 w-3.5 shrink-0 text-ink-3"}):(0,t.jsx)(kr,{"aria-hidden":"true",className:"h-3.5 w-3.5 shrink-0 text-ink-3"}),(0,t.jsx)(Rn,{"aria-hidden":"true",className:"h-3.5 w-3.5 shrink-0 text-ink-3"}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-ink",children:_.name})]}),q?(0,t.jsxs)(t.Fragment,{children:[O.map(E),F?(0,t.jsxs)("div",{className:"flex min-h-(--sz-30px) items-center gap-2 py-1 pr-2 text-xs text-ink-3",style:{paddingLeft:`${1+(_.depth+1)*.875}rem`},children:[(0,t.jsx)(It,{"aria-hidden":"true",className:"h-3.5 w-3.5 animate-spin"}),(0,t.jsx)("span",{children:"Loading folder…"})]}):null,C?(0,t.jsxs)("button",{type:"button",onClick:a(()=>d?.(_.key),"onClick"),className:"flex min-h-(--sz-30px) w-full items-center gap-2 rounded-md py-1 pr-2 text-left text-xs text-ink-3 hover:bg-bg-3/60 hover:text-ink",style:{paddingLeft:`${1+(_.depth+1)*.875}rem`},children:[(0,t.jsx)("span",{className:"h-3.5 w-3.5 shrink-0"}),(0,t.jsx)("span",{children:"Load more from this folder"})]}):null]}):null]},_.key)}return(0,t.jsx)(Ev,{item:_.item,treeItemId:`${s}-file-${_.key}`,selected:_.key===r,highlighted:_.key===n,depth:_.depth,onOpen:a(()=>k(_.item),"onOpen"),onHover:a(()=>N(_.item),"onHover"),downloadUrl:A(_.item)},_.key)}return a(E,"renderNode"),(0,t.jsx)("div",{role:"tree",id:s,"aria-label":"Workspace files",className:"space-y-0.5 py-1",children:e.map(E)})}a(qv,"WorkspaceFileTree");function Ao({issueId:e,companyId:s,onOpen:n,onBrowseStateChange:r,initialQuery:i,initialFolderPath:o,initialProjectId:u,initialWorkspaceId:m,autoFocusSearch:p=!0,selectedPath:h,selectedProjectId:d,selectedWorkspaceId:v,active:k=!0,className:N}){const A=ks(),{visible:E}=qm(),_=u&&m?"other":"current",q="auto",O=(0,l.useMemo)(()=>So(h),[h]),F=(0,l.useMemo)(()=>typeof o<"u"?o:i?.trim()?null:O,[o,i,O]),[C,S]=(0,l.useState)(u??null),[P,j]=(0,l.useState)(m??null),[f,w]=(0,l.useState)(F??null),[W,M]=(0,l.useState)(i??""),[$,K]=(0,l.useState)(i?.trim()??""),[le,y]=(0,l.useState)(!1),[z,se]=(0,l.useState)(-1),[de,me]=(0,l.useState)(()=>new Set),[oe,ve]=(0,l.useState)(()=>new Set),[ie,ge]=(0,l.useState)({}),Ie=(0,l.useId)(),De=(0,l.useRef)(null),$e=(0,l.useRef)(null),Be=ye({queryKey:s?R.projects.list(s):["projects","__none__"],queryFn:a(()=>wi.list(s),"queryFn"),enabled:_==="other"&&!!s,retry:!1,staleTime:3e4}),Fe=(0,l.useMemo)(()=>Array.isArray(Be.data)?Be.data:[],[Be.data]),re=(0,l.useMemo)(()=>Fe.filter(D=>D.workspaces.length>0),[Fe]),Se=(0,l.useMemo)(()=>re.find(D=>D.id===C)??null,[re,C]),Ve=(0,l.useMemo)(()=>Se?.workspaces.find(D=>D.id===P)??null,[Se,P]);(0,l.useEffect)(()=>{if(_!=="other"||!Be.data)return;const D=Se??re[0]??null;if(!D){S(null),j(null);return}C!==D.id&&S(D.id);const ee=D.workspaces.find(H=>H.id===P)??D.primaryWorkspace??D.workspaces[0]??null;j(ee?.id??null)},[Be.data,re,Se,C,P,_]),(0,l.useEffect)(()=>{S(u??null),j(m??null)},[u,m]),(0,l.useEffect)(()=>{w(F??null),M(i??""),K(i?.trim()??"")},[F,i]),(0,l.useEffect)(()=>{const D=window.setTimeout(()=>K(W.trim()),150);return()=>window.clearTimeout(D)},[W]),(0,l.useEffect)(()=>{y(!1)},[q,_,C,P,f]),(0,l.useEffect)(()=>{ve(new Set),ge({})},[q,_,C,P,f,$]);const Je=$||null,ft=Je!==null,Ze=f||ft||h||le?"all":"changed",Te=_==="other"?C:null,Nt=_==="other"?P:null,vt=_==="other"?"project":q,Ut=_==="current"||!!(Te&&Nt),Y=k&&E&&Ut,Ae=Te&&Nt?{projectId:Te,workspaceId:Nt}:{};(0,l.useEffect)(()=>{r?.({q:W.trim()||null,folderPath:f,projectId:Te,workspaceId:Nt})},[f,r,W,Te,Nt]);const ht=(0,l.useMemo)(()=>R.issues.fileResources(e,{workspace:vt,projectId:Te,workspaceId:Nt,mode:Ze,q:Je,limit:Da,offset:0,path:f}),[vt,f,e,Ze,Je,Te,Nt]),U=ye({queryKey:ht,queryFn:a(({signal:D})=>hn.list(e,{workspace:vt,projectId:Te,workspaceId:Nt,mode:Ze,q:Je,limit:Da,offset:0,path:f},{signal:D}),"queryFn"),enabled:Y,retry:!1,staleTime:15e3,refetchOnWindowFocus:!1,refetchOnReconnect:!1});(0,l.useEffect)(()=>{k&&E||A.cancelQueries({queryKey:["issues","file-resources",e,"list"]})},[k,e,E,A]);const Ue=U.data,St=(0,l.useMemo)(()=>Ue?.items??[],[Ue]),_e=Ue?.workspace?.workspaceLabel??null,et=Ue?.query.mode==="all"&&!Je,rt=Co(f),us=(0,l.useMemo)(()=>Rv(h,f),[f,h]),Vs=(0,l.useMemo)(()=>new Set(us),[us]),Rt=(0,l.useMemo)(()=>et?Array.from(new Set([...oe,...us])).filter(D=>D!==rt).sort():[],[rt,oe,et,us]),xt=(0,l.useMemo)(()=>{if(!Ut||!et)return[];const D=[];for(const H of Rt){const st=ie[H]??1;for(let zt=0;zt<st;zt+=1)D.push({path:H,pageIndex:zt,offset:zt*Da})}const ee=ie[rt]??1;for(let H=1;H<ee;H+=1)D.push({path:rt,pageIndex:H,offset:H*Da});return D},[Ut,rt,ie,et,Rt]),Qt=rd({queries:xt.map(D=>({queryKey:R.issues.fileResources(e,{workspace:vt,projectId:Te,workspaceId:Nt,mode:"all",q:null,limit:Da,offset:D.offset,path:D.path||null}),queryFn:a(({signal:ee})=>hn.list(e,{workspace:vt,projectId:Te,workspaceId:Nt,mode:"all",q:null,limit:Da,offset:D.offset,path:D.path||null},{signal:ee}),"queryFn"),enabled:Y&&et,retry:!1,staleTime:15e3,refetchOnWindowFocus:!1,refetchOnReconnect:!1}))}),Ct=(0,l.useMemo)(()=>{const D=new Map;return et&&D.set(rt,[...St]),xt.forEach((ee,H)=>{const st=Qt[H]?.data;if(!st||st.state!=="available")return;const zt=D.get(ee.path)??[];zt.push(...st.items),D.set(ee.path,zt)}),D},[rt,Qt,xt,et,St]),ts=(0,l.useMemo)(()=>{const D=new Map;et&&D.set(rt,{pageIndex:0,truncated:!!Ue?.truncated}),xt.forEach((H,st)=>{const zt=Qt[st]?.data;if(!zt)return;const qe=D.get(H.path);(!qe||H.pageIndex>=qe.pageIndex)&&D.set(H.path,{pageIndex:H.pageIndex,truncated:zt.truncated})});const ee=new Set;for(const[H,st]of D)st.truncated&&ee.add(H);return ee},[rt,Ue?.truncated,Qt,xt,et]),$t=(0,l.useMemo)(()=>{const D=new Set;return xt.forEach((ee,H)=>{Qt[H]?.isFetching&&D.add(ee.path)}),D},[Qt,xt]),ms=(0,l.useMemo)(()=>{const D=new Set;return xt.forEach((ee,H)=>{Qt[H]?.isError&&D.add(ee.path)}),D},[Qt,xt]),Wt=(0,l.useMemo)(()=>et?Array.from(Ct.values()).flat():St,[et,St,Ct]),lt=(0,l.useMemo)(()=>Wt.filter(D=>D.kind==="file"),[Wt]),$s=(0,l.useMemo)(()=>et?_c(Ct.get(rt)??St):_v(St,f),[rt,f,et,St,Ct]),ps=h?lt.findIndex(D=>D.relativePath===h&&(d?D.projectId===d:!0)&&(v?D.workspaceId===v:!0)):-1;(0,l.useEffect)(()=>{!ft&&Ue?.state==="unavailable"&&(Ue.unavailableReason??"").toLowerCase().includes("changed")&&y(!0)},[Ue,ft]),(0,l.useEffect)(()=>{if(h){se(ps>=0?ps:-1);return}se(lt.length>0?0:-1)},[lt.length,Je,q,_,C,P,f,h,ps]),(0,l.useEffect)(()=>{if(!h||!et)return;const D=Co(So(h));D!==rt&&!Rt.includes(D)||ts.has(D)&&($t.has(D)||ms.has(D)||(Ct.get(D)??[]).some(ee=>ee.kind==="file"&&ee.relativePath===h&&(d?ee.projectId===d:!0)&&(v?ee.workspaceId===v:!0))||ge(ee=>({...ee,[D]:(ee[D]??1)+1})))},[d,v,rt,et,ms,$t,Ct,ts,Rt,h]);const Gs=(0,l.useMemo)(()=>U.isFetching?"Loading workspace files…":U.isError?"Unable to load workspace files.":Ue?.state==="unavailable"?Ec(Ue.unavailableReason??"").title:St.length===0?"No matching files.":`${St.length} item${St.length===1?"":"s"} found.`,[Ue,St.length,U.isError,U.isFetching]);function Ys(){const D=W.trim();if(!D)return;const ee=nf(D),H={workspace:vt,...Ae};ee?.resourceKind==="directory"?(w(ee.path),M(""),K("")):n(ee?{path:ee.path,...H,line:ee.line,column:ee.column,browseFolderPath:f,browseQuery:W.trim()||null}:{path:D,...H,browseFolderPath:f,browseQuery:W.trim()||null})}a(Ys,"openTypedPath");function yt(D){if(D.key==="ArrowDown")D.preventDefault(),se(ee=>lt.length===0?-1:Math.min(lt.length-1,ee+1));else if(D.key==="ArrowUp")D.preventDefault(),se(ee=>lt.length===0?-1:Math.max(0,ee-1));else if(D.key==="Enter"){D.preventDefault();const ee=z>=0?lt[z]:void 0;if(ee){const H=ee.projectId?{projectId:ee.projectId,workspaceId:ee.workspaceId}:Ae;n({path:ee.relativePath,workspace:vt,...H,browseFolderPath:f,browseQuery:W.trim()||null})}else Ys()}}a(yt,"handleSearchKeyDown");const fs=z>=0?lt[z]:void 0,Q=fs?Ba(fs):null,ke=ps>=0?lt[ps]:null,tt=ke?Ba(ke):null,be=tt?`${Ie}-file-${tt}`:null,it=Q?`${Ie}-file-${Q}`:void 0;(0,l.useEffect)(()=>{if(!be)return;const D=$e.current,ee=document.getElementById(be);if(!D||!ee)return;const H=D.getBoundingClientRect(),st=ee.getBoundingClientRect();(st.top<H.top||st.bottom>H.bottom)&&ee.scrollIntoView({block:"nearest"})},[f,lt,be]);function Js(D){w(D),M(""),K("")}a(Js,"openFolder");function ws(D){const ee=D.projectId?{projectId:D.projectId,workspaceId:D.workspaceId}:Ae;n({path:D.relativePath,workspace:vt,...ee,browseFolderPath:f,browseQuery:W.trim()||null})}a(ws,"openItem");function Hn(D){if(et){ve(ee=>{const H=new Set(ee);return H.has(D)?H.delete(D):H.add(D),H});return}me(ee=>{const H=new Set(ee);return H.has(D)?H.delete(D):H.add(D),H})}a(Hn,"toggleFolder");function Dt(D){ge(ee=>({...ee,[D]:(ee[D]??1)+1}))}a(Dt,"loadMoreFolder");function Vn(D){const ee=Ba(D),H=lt.findIndex(st=>Ba(st)===ee);H>=0&&se(H)}a(Vn,"handleHoverFile");function an(D){if(!D.capabilities.download)return null;const ee=D.projectId?{projectId:D.projectId,workspaceId:D.workspaceId}:Ae;return hn.downloadUrl(e,{path:D.relativePath,workspace:vt,...ee})}a(an,"getDownloadUrl");function g(D,ee){return _c(Ct.get(D)??[]).map(H=>({...H,depth:ee}))}a(g,"lazyChildren");let Et;if(_==="other"&&!s)Et=(0,t.jsx)($a,{icon:(0,t.jsx)(Rn,{"aria-hidden":"true",className:"h-5 w-5 text-ink-3"}),title:"No organization selected",body:"Choose an organization before browsing another project workspace."});else if(_==="other"&&Be.isFetching&&re.length===0)Et=(0,t.jsx)($a,{icon:(0,t.jsx)(It,{"aria-hidden":"true",className:"h-5 w-5 animate-spin text-ink-3"}),title:"Loading project workspaces",body:"Registered workspaces will appear here."});else if(_==="other"&&!Ut)Et=(0,t.jsx)($a,{icon:(0,t.jsx)(Rn,{"aria-hidden":"true",className:"h-5 w-5 text-ink-3"}),title:"No project workspaces",body:"No same-organization project has a registered workspace to browse."});else if(U.isFetching&&!Ue)Et=(0,t.jsx)("div",{className:"space-y-1.5 py-2","aria-busy":"true",children:Array.from({length:6}).map((D,ee)=>(0,t.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[(0,t.jsx)("div",{className:"h-3.5 w-3.5 shrink-0 rounded bg-bg-3"}),(0,t.jsx)("div",{className:"h-3 flex-1 rounded bg-bg-3",style:{maxWidth:`${80-ee*8}%`}})]},ee))});else if(U.isError){const D=U.error instanceof Hs?U.error.status:0,ee=U.error instanceof Hs&&U.error.body&&typeof U.error.body=="object"?U.error.body.code:null,H=Ze==="changed"&&(D===503||D===504||ee==="workspace_git_scan_saturated"||ee==="workspace_git_scan_timeout");Et=(0,t.jsx)($a,{icon:(0,t.jsx)(nn,{"aria-hidden":"true",className:"h-5 w-5 text-amber-500"}),title:H?"Changed files temporarily unavailable":"Couldn't load files",body:H?"Wardmote is limiting workspace scans to keep the server responsive. Try again in a moment.":D===404?"Workspace browsing isn't available for this issue.":"Something went wrong loading workspace files.",actions:H?(0,t.jsxs)(ne,{type:"button",variant:"secondary",size:"sm",disabled:!Y,onClick:a(()=>{U.refetch()},"onClick"),children:[(0,t.jsx)(cr,{"aria-hidden":"true",className:"mr-1 h-3 w-3"})," Retry"]}):null})}else if(Ue?.state==="unavailable"){const D=Ec(Ue.unavailableReason??"");Et=(0,t.jsx)($a,{icon:D.icon,title:D.title,body:D.body})}else St.length===0?Et=(0,t.jsx)($a,{icon:(0,t.jsx)(ti,{"aria-hidden":"true",className:"h-5 w-5 text-ink-3"}),title:ft?`No files match “${Je}”`:"No recently changed files yet",body:"Try searching by name or path."}):Et=(0,t.jsx)(qv,{nodes:$s,listboxId:Ie,highlightedItemKey:Q,selectedItemKey:tt,collapsedFolders:de,expandedLazyFolders:oe,forcedExpandedFolders:Vs,getLazyChildren:g,isLazyFolderFetching:a(D=>$t.has(D),"isLazyFolderFetching"),isLazyFolderTruncated:a(D=>ts.has(D),"isLazyFolderTruncated"),onLoadMoreFolder:Dt,onToggleFolder:Hn,onOpen:ws,onHoverFile:Vn,getDownloadUrl:an});return(0,t.jsxs)("div",{className:ue("flex min-h-0 min-w-0 flex-col gap-2",N),children:[(0,t.jsxs)("div",{className:"flex min-w-0 max-w-full items-center gap-1 overflow-hidden",children:[(0,t.jsxs)("div",{className:"relative min-w-0 flex-1",children:[(0,t.jsx)(ti,{"aria-hidden":"true",className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-ink-3"}),(0,t.jsx)(jr,{ref:De,type:"search",value:W,onChange:a(D=>M(D.target.value),"onChange"),onKeyDown:yt,placeholder:"Search files by name or path…","aria-label":"Search workspace files",role:"combobox","aria-expanded":St.length>0,"aria-controls":St.length>0?Ie:void 0,"aria-activedescendant":it,autoFocus:p,autoComplete:"off",spellCheck:!1,className:"h-8 w-full max-w-full min-w-0 pl-8 font-mono text-xs"})]}),(0,t.jsx)(ne,{type:"button",variant:"ghost",size:"icon-sm",onClick:a(()=>{U.refetch()},"onClick"),disabled:!Y||U.isFetching,"aria-label":"Refresh workspace files",title:"Refresh workspace files",className:"h-8 w-8 shrink-0",children:(0,t.jsx)(cr,{"aria-hidden":"true",className:ue("h-3.5 w-3.5",U.isFetching&&"animate-spin")})})]}),(0,t.jsx)(Tv,{rootLabel:Se&&Ve?`${Se.name} / ${Ve.name}`:_e,folderPath:f,onOpenFolder:Js}),(0,t.jsx)("div",{"aria-live":"polite",className:"sr-only",children:Gs}),(0,t.jsx)("div",{ref:$e,className:"min-h-0 flex-1 overflow-y-auto",children:Et}),ts.has(rt)||Ue?.truncated&&!et?(0,t.jsx)("div",{className:"border-t border-line pt-2 text-(length:--text-micro) text-ink-3",children:et?(0,t.jsx)("button",{type:"button",onClick:a(()=>Dt(rt),"onClick"),className:"rounded px-1 py-0.5 text-left hover:bg-bg-3 hover:text-ink",children:"Load more from this folder"}):(0,t.jsxs)(t.Fragment,{children:["Showing first ",St.length," — refine the search to narrow."]})}):null]})}a(Ao,"WorkspaceFileBrowser");var rr=200,Mv=["status","priority","project","updated","is"],Pv={raw:"",q:"",filters:{}},Fv=100,Dv=5,$v=[["updated","Last updated"],["created","Created"],["status","Status"],["title","Title"]];function Lv(e,s,n){const r=n==="asc"?1:-1;return[...e].sort((i,o)=>{switch(s){case"status":return r*(Pl.indexOf(i.status)-Pl.indexOf(o.status));case"title":return r*i.title.localeCompare(o.title);case"created":return r*(new Date(i.createdAt).getTime()-new Date(o.createdAt).getTime());default:return r*(new Date(i.updatedAt).getTime()-new Date(o.updatedAt).getTime())}})}a(Lv,"sortAgentTasks");function ha({children:e,tone:s="muted"}){return(0,t.jsx)("p",{className:ue("px-1 py-6 text-center text-sm",s==="error"?"text-bad":"text-ink-3"),children:e})}a(ha,"PanelMessage");var Au="flex flex-col gap-1 rounded-lg border border-line bg-bg-2 p-3 transition-colors hover:border-ink/20 hover:bg-bg-3/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus";function Bv({task:e}){return(0,t.jsxs)(ls,{to:`/issues/${e.identifier??e.id}`,disableIssueQuicklook:!0,target:"_blank",rel:"noreferrer","data-testid":"agent-task-card",className:Au,children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-start gap-2",children:[(0,t.jsx)(si,{status:e.status,blockerAttention:e.blockerAttention,className:"mt-0.5 shrink-0"}),(0,t.jsx)("span",{className:"min-w-0 flex-1 line-clamp-2 text-sm font-medium text-ink",children:e.title})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 pl-6 text-xs text-ink-3",children:[(0,t.jsx)("span",{className:"font-mono",children:e.identifier??e.id.slice(0,8)}),(0,t.jsx)("span",{"aria-hidden":!0,children:"·"}),(0,t.jsx)("time",{dateTime:new Date(e.updatedAt).toISOString(),title:new Date(e.updatedAt).toLocaleString(),children:hr(e.updatedAt)})]})]})}a(Bv,"AgentTaskCard");function Ov({companyId:e,agentId:s,excludeIssueId:n}){const[r,i]=(0,l.useState)(Pv),[o,u]=(0,l.useState)(ih),[m,p]=(0,l.useState)("updated"),[h,d]=(0,l.useState)("desc"),[v,k]=(0,l.useState)(!1),N=r.q.length>0||tg(r.filters),A=(0,l.useMemo)(()=>vg(r.filters),[r.filters]),E=ye({queryKey:R.issues.listParticipatedByAgent(e,s),queryFn:a(()=>xe.list(e,{participantAgentId:s,sortField:"updated",sortDir:"desc",limit:rr}),"queryFn")}),_=ye({queryKey:[...R.issues.listParticipatedByAgent(e,s),"search",r.q,A],queryFn:a(()=>xe.list(e,{...A,participantAgentId:s,...r.q?{q:r.q}:{},limit:rr}),"queryFn"),enabled:N,placeholderData:a(f=>f,"placeholderData")}),q=ye({queryKey:R.projects.list(e),queryFn:a(()=>wi.list(e),"queryFn")}),O=(0,l.useMemo)(()=>({projects:q.data}),[q.data]),F=N?_.data:E.data,C=(0,l.useMemo)(()=>{const f=oh((F??[]).filter(w=>w.id!==n),o);return N&&!v?f:Lv(f,m,h)},[F,n,o,N,v,m,h]),S=rh(o),P=(E.data??[]).filter(f=>f.id!==n).length,j=!N&&(E.data?.length??0)>=rr;return(0,t.jsxs)("section",{className:"flex flex-col gap-3","aria-label":"Agent tasks",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)(Qh,{value:r.raw,onChange:a(f=>{i(f),k(!1)},"onChange"),context:O,operatorKeys:Mv,placeholder:"Search tasks",ariaLabel:"Search tasks",className:"min-w-0 flex-1"}),(0,t.jsx)(Kh,{state:o,onChange:a(f=>u(w=>({...w,...f})),"onChange"),activeFilterCount:S,projects:q.data?.map(f=>({id:f.id,name:f.name})),enableExternalObjectFilters:!1,buttonVariant:"secondary",iconOnly:!0,presentation:"streamlined"}),(0,t.jsxs)(vr,{children:[(0,t.jsx)(xr,{asChild:!0,children:(0,t.jsx)(ne,{variant:"secondary",size:"icon",className:"h-8 w-8 shrink-0",title:"Sort","aria-label":"Sort tasks",children:(0,t.jsx)(Ep,{className:"h-3.5 w-3.5"})})}),(0,t.jsx)(yr,{align:"end",className:"w-48 p-0",children:(0,t.jsx)("div",{className:"space-y-0.5 p-2",children:$v.map(([f,w])=>(0,t.jsxs)("button",{type:"button",className:ue("flex w-full items-center justify-between rounded-sm px-2 py-1.5 text-sm",m===f?"bg-bg-3/50 text-ink":"text-ink-3 hover:bg-bg-3/50"),onClick:a(()=>{k(!0),m===f?d(h==="asc"?"desc":"asc"):(p(f),d(f==="updated"||f==="created"?"desc":"asc"))},"onClick"),children:[(0,t.jsx)("span",{children:w}),m===f?(0,t.jsx)("span",{className:"text-xs text-ink-3",children:h==="asc"?"↑":"↓"}):null]},f))})})]})]}),E.isPending||N&&_.isPending?(0,t.jsx)(ha,{children:"Loading tasks…"}):E.isError?(0,t.jsx)(ha,{tone:"error",children:"Could not load this agent's tasks."}):P===0?(0,t.jsx)(ha,{children:"This agent hasn't worked on any tasks yet."}):C.length===0?(0,t.jsx)(ha,{children:j?`No tasks match these filters among the ${rr} most recently updated.`:"No tasks match these filters."}):(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[C.map(f=>(0,t.jsx)(Bv,{task:f},f.id)),j?(0,t.jsxs)("p",{className:"px-1 text-xs text-ink-3",children:["Showing the ",rr," most recently updated tasks."]}):null]})]})}a(Ov,"AgentTasksPanel");function Kv({artifact:e}){const s="mt-0.5 h-4 w-4 shrink-0 text-ink-3";switch(e.mediaKind){case"image":return(0,t.jsx)(Mh,{className:s,"aria-hidden":!0});case"video":return(0,t.jsx)(Lx,{className:s,"aria-hidden":!0});case"text":case"document":return(0,t.jsx)(dr,{className:s,"aria-hidden":!0});default:return(0,t.jsx)(mf,{className:s,"aria-hidden":!0})}}a(Kv,"ArtifactKindIcon");function Uv({artifact:e}){return(0,t.jsxs)(ls,{to:e.href,disableIssueQuicklook:!0,target:"_blank",rel:"noreferrer","data-testid":"agent-artifact-card",className:Au,children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-start gap-2",children:[(0,t.jsx)(Kv,{artifact:e}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-ink",title:e.title,children:e.title})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 pl-6 text-xs text-ink-3",children:[(0,t.jsxs)("span",{children:["Updated ",Sm(e.updatedAt)]}),(0,t.jsx)("span",{"aria-hidden":!0,children:"·"}),(0,t.jsx)("span",{className:"font-mono",children:e.issue.identifier})]})]})}a(Uv,"AgentArtifactCard");async function Qv(e,s){const n=[];let r;for(let i=0;i<Dv;i+=1){const o=await _x.list(e,{agentId:s,limit:Fv,cursor:r});if(n.push(...o.artifacts),!o.nextCursor)return{artifacts:n,truncated:!1};r=o.nextCursor}return{artifacts:n,truncated:!0}}a(Qv,"listAgentArtifacts");function Wv({companyId:e,agentId:s}){const n=ye({queryKey:R.artifacts.byAgent(e,s),queryFn:a(()=>Qv(e,s),"queryFn")});if(n.isPending)return(0,t.jsx)(ha,{children:"Loading artifacts…"});if(n.isError)return(0,t.jsx)(ha,{tone:"error",children:"Could not load this agent's artifacts."});const{artifacts:r,truncated:i}=n.data;return r.length===0?(0,t.jsx)(ha,{children:"This agent hasn't produced any artifacts yet."}):(0,t.jsxs)("section",{className:"flex flex-col gap-2","aria-label":"Agent artifacts",children:[r.map(o=>(0,t.jsx)(Uv,{artifact:o},o.id)),i?(0,t.jsxs)("p",{className:"px-1 text-xs text-ink-3",children:["Showing this agent's ",r.length," most recent artifacts."]}):null]})}a(Wv,"AgentArtifactsPanel");var pa=1,zv=50;function Hv(e){return!e.deferredPlanAvailable&&!e.panelBeforePlanOverride}a(Hv,"shouldSuppressTaskPanelUntilPlan");function Vv(e,s,n,r){return{skill:s,panelBeforePlanOverrideIssueId:r&&n?n:e.panelBeforePlanOverrideIssueId}}a(Vv,"openSkillPanelState");function Ru(e,s){return`wardmote:task-side-panel:v${pa}:${e}:${s}`}a(Ru,"storageKey");function Ka(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}a(Ka,"record");function La(e){return e===null?null:typeof e=="string"?e:void 0}a(La,"nullableString");function qc(e){return e===null?null:typeof e=="number"&&Number.isInteger(e)&&e>0?e:void 0}a(qc,"positiveInteger");function Gv(e){const s=Ka(e);if(!s)return null;const n=s.kind;if(n==="browser")return typeof s.browserId=="string"&&/^[0-9a-f-]{36}$/i.test(s.browserId)?{kind:n,browserId:s.browserId}:null;if(n==="properties")return{kind:n};if(n==="subtasks")return{kind:n};if(n==="artifacts")return{kind:n};if(n==="agent-tasks")return{kind:n};if(n==="todo")return{kind:n};if(n==="terminal")return{kind:n};if(n==="attachment")return typeof s.attachmentId=="string"&&s.attachmentId.length>0?{kind:n,attachmentId:s.attachmentId}:null;if(n==="skill")return typeof s.skillId=="string"&&s.skillId.length>0?{kind:n,skillId:s.skillId}:null;if(n==="issue-document")return typeof s.documentKey=="string"&&s.documentKey.length>0?{kind:n,documentKey:s.documentKey}:null;if(n==="files-browser"){const r=La(s.query),i=La(s.folderPath),o=La(s.projectId),u=La(s.workspaceId);return[r,i,o,u].some(m=>typeof m>"u")?null:{kind:n,query:r,folderPath:i,projectId:o,workspaceId:u}}if(n==="workspace-file"){if(typeof s.path!="string"||s.path.length===0)return null;const r=s.workspace==="execution"||s.workspace==="project"?s.workspace:"auto",i=La(s.projectId),o=La(s.workspaceId),u=qc(s.line),m=qc(s.column);return[i,o,u,m].some(p=>typeof p>"u")?null:{kind:n,path:s.path,workspace:r,projectId:i,workspaceId:o,line:u,column:m}}return null}a(Gv,"parsePayload");function Yv(e,s){const n=Ka(e);if(!n||typeof n.id!="string"||typeof n.type!="string"||typeof n.label!="string")return null;const r=Gv(n.payload);return!r||!s&&(r.kind==="files-browser"||r.kind==="workspace-file")?null:{id:n.id,type:n.type,label:n.label,ariaLabel:typeof n.ariaLabel=="string"?n.ariaLabel:void 0,closable:typeof n.closable=="boolean"?n.closable:!0,contentMode:n.contentMode==="full-bleed"||n.contentMode==="prose"?n.contentMode:"padded",payload:r}}a(Yv,"parseTab");function Jv(e,s){const n=Ka(e),r=Ka(n?.state);if(!n||!r||!Array.isArray(r.tabs))return null;const i=new Set,o=r.tabs.flatMap(m=>{const p=Yv(m,s);return!p||i.has(p.id)?[]:(i.add(p.id),[p])}),u=typeof r.activeTabId=="string"?r.activeTabId:null;return{state:{tabs:o,activeTabId:u&&i.has(u)?u:o[0]?.id??null},launcherOpen:n.launcherOpen===!0,userInteracted:n.userInteracted===!0,autoPlanHandled:n.autoPlanHandled===!0,updatedAt:typeof n.updatedAt=="number"&&Number.isFinite(n.updatedAt)?n.updatedAt:0}}a(Jv,"parseEntry");function Tu(e,s){if(typeof window>"u")return{version:pa,tasks:{}};try{const n=Ka(JSON.parse(window.localStorage.getItem(Ru(e,s))??"null"));return n?.version!==pa||!Ka(n.tasks)?{version:pa,tasks:{}}:{version:pa,tasks:n.tasks}}catch{return{version:pa,tasks:{}}}}a(Tu,"readStore");function Mc(e,s,n,r){return Jv(Tu(e,s).tasks[n],r)}a(Mc,"readTaskSidePanelState");function Xv(e,s,n,r){if(!(typeof window>"u"))try{const i={...Tu(e,s).tasks,[n]:r},o=Object.entries(i).sort((u,m)=>(m[1].updatedAt??0)-(u[1].updatedAt??0)).slice(0,zv);window.localStorage.setItem(Ru(e,s),JSON.stringify({version:pa,tasks:Object.fromEntries(o)}))}catch{}}a(Xv,"writeTaskSidePanelState");function Pc(){return{id:"properties",type:"properties",label:"Properties",closable:!0,contentMode:"padded",payload:{kind:"properties"}}}a(Pc,"taskPanelPropertiesTab");function Zv(){return{id:"subtasks",type:"subtasks",label:"Subtasks",closable:!0,contentMode:"padded",payload:{kind:"subtasks"}}}a(Zv,"taskPanelSubtasksTab");function Fc(){return{id:"todo",type:"todo",label:"Todo",closable:!0,contentMode:"padded",payload:{kind:"todo"}}}a(Fc,"taskPanelAgentTodoTab");function io(){return{id:"agent-tasks",type:"agent-tasks",label:"Tasks",closable:!0,contentMode:"padded",payload:{kind:"agent-tasks"}}}a(io,"taskPanelAgentTasksTab");function Qr(){return{id:"artifacts",type:"artifacts",label:"Artifacts",closable:!0,contentMode:"padded",payload:{kind:"artifacts"}}}a(Qr,"taskPanelArtifactsTab");function eb(e,s="Skill"){return{id:`skill:${e}`,type:"skill",label:s,closable:!0,contentMode:"prose",payload:{kind:"skill",skillId:e}}}a(eb,"taskPanelSkillTab");function Wr(e,s){return{id:`document:${e}`,type:"issue-document",label:s,closable:!0,contentMode:"prose",payload:{kind:"issue-document",documentKey:e}}}a(Wr,"taskPanelDocumentTab");function Dc(){return{id:"files",type:"files-browser",label:"Files",closable:!0,contentMode:"full-bleed",payload:{kind:"files-browser",query:null,folderPath:null,projectId:null,workspaceId:null}}}a(Dc,"taskPanelFilesTab");function $c(e){const s=e.projectId??null,n=e.workspaceId??null;return{id:`workspace-file:${s&&n?`${s}:${n}`:e.workspace??"auto"}:${e.path}`,type:"workspace-file",label:e.path.split("/").filter(Boolean).at(-1)??e.path,ariaLabel:e.path,closable:!0,contentMode:"full-bleed",payload:{kind:"workspace-file",path:e.path,workspace:e.workspace??"auto",projectId:s,workspaceId:n,line:e.line??null,column:e.column??null}}}a($c,"taskPanelWorkspaceFileTab");function Lc(e,s){return{id:`attachment:${e}`,type:"attachment",label:s,closable:!0,contentMode:"full-bleed",payload:{kind:"attachment",attachmentId:e}}}a(Lc,"taskPanelAttachmentTab");function tb(){return{id:"terminal",type:"terminal",label:"Terminal",closable:!0,contentMode:"full-bleed",payload:{kind:"terminal"}}}a(tb,"taskPanelTerminalTab");function oo(e){return{id:`browser:${e}`,type:"browser",label:"Browser",closable:!0,contentMode:"full-bleed",payload:{kind:"browser",browserId:e}}}a(oo,"taskPanelBrowserTab");function sb({issueId:e}){const s=Ud(e);if(s.isLoading)return(0,t.jsxs)("div",{className:"flex items-center gap-2 py-8 text-sm text-ink-3",role:"status",children:[(0,t.jsx)(It,{className:"size-4 animate-spin","aria-hidden":!0}),"Loading agent todo…"]});if(s.isError)return(0,t.jsx)("div",{className:"py-8 text-sm text-ink-3",role:"alert",children:"The agent todo could not be loaded. Refresh the task to try again."});const n=s.data;return n?(0,t.jsxs)("article",{className:"flex flex-col gap-4","aria-label":"Agent todo","data-testid":"task-agent-todo-panel",children:[(0,t.jsxs)("header",{className:"flex flex-col gap-2",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold",children:"Agent todo"}),(0,t.jsx)(Dg,{snapshot:n})]}),(0,t.jsx)(Lg,{snapshot:n})]}):(0,t.jsxs)("div",{className:"flex items-start gap-3 py-8 text-sm",role:"status",children:[(0,t.jsx)(Do,{className:"mt-0.5 size-5 shrink-0 text-ink-3","aria-hidden":!0}),(0,t.jsx)("p",{className:"text-ink-3",children:"No agent todo yet. It appears here once an agent plans its work with the todo tool."})]})}a(sb,"TaskAgentTodoPanel");function nb({issueId:e,documentKey:s,initialDocument:n}){const r=ui(),[i,o]=(0,l.useState)(!1),u=ye({queryKey:[...R.issues.documents(e),s],queryFn:a(async()=>{try{return await xe.getDocument(e,s)}catch(p){if(p instanceof Hs&&p.status===404)return null;throw p}},"queryFn"),initialData:n});if(u.isLoading)return(0,t.jsxs)("div",{className:"flex items-center gap-2 py-8 text-sm text-ink-3",role:"status",children:[(0,t.jsx)(It,{className:"size-4 animate-spin","aria-hidden":!0}),"Loading document…"]});if(u.isError)return(0,t.jsx)("div",{className:"py-8 text-sm text-ink-3",role:"alert",children:"The document could not be loaded. Retry from the tab launcher or refresh the task."});const m=u.data;return m?(0,t.jsxs)("article",{className:"space-y-4",children:[(0,t.jsxs)("header",{className:"space-y-1",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsx)("h2",{className:"min-w-0 flex-1 text-lg font-semibold",children:Cn(m)}),(0,t.jsx)($m,{className:"shrink-0",issueId:e,documentKey:m.key,title:Cn(m),format:m.format,body:m.body})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1 text-xs text-ink-3",children:[(0,t.jsx)("span",{children:`Revision ${m.latestRevisionNumber??1}`}),(0,t.jsx)("span",{"aria-hidden":!0,children:"·"}),(0,t.jsx)("span",{children:`Updated ${new Date(m.updatedAt).toLocaleString()}`}),(0,t.jsx)(Hm,{issueId:e,docKey:m.key,panelOpen:i,onToggle:a(()=>o(p=>!p),"onToggle")})]})]}),m.body.trim()?(0,t.jsx)(zm,{issueId:e,doc:m,bodyMarkdown:m.body,draftDirty:!1,draftConflicted:!1,historicalPreview:!1,locationHash:r.hash,panelOpen:i,onPanelOpenChange:o,panelPlacement:"popover",children:(0,t.jsx)(bs,{children:m.body})}):(0,t.jsx)("p",{className:"text-sm text-ink-3",children:"Document is empty."})]}):(0,t.jsxs)("div",{className:"flex items-start gap-3 py-8 text-sm",role:"status",children:[(0,t.jsx)(df,{className:"mt-0.5 size-5 shrink-0 text-ink-3","aria-hidden":!0}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("p",{className:"font-medium",children:"Document no longer available"}),(0,t.jsx)("p",{className:"text-ink-3",children:"This tab is preserved so the missing resource is explicit. Close it or choose another document."})]})]})}a(nb,"TaskDocumentPanel");var Bc="wardmote-file-viewer-title",Oc="wardmote-file-viewer-description",lo=220,co=520;function ci(e){if(e instanceof Hs){const s=e.body??null,n=typeof s?.code=="string"?s.code:"";return{status:e.status,code:n,message:typeof s?.error=="string"?s.error:e.message}}return e instanceof Error?{status:0,code:"",message:e.message}:{status:0,code:"",message:"Something went wrong."}}a(ci,"normalizeError");function Kc(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}a(Kc,"formatBytes");function ab(e){if(e==="")return[""];const s=e.replace(/\r\n?/g,`
3
3
  `).split(`
4
4
  `);return s.length>0&&s[s.length-1]===""&&s.pop(),s.length>0?s:[""]}a(ab,"splitContentIntoLines");function Uc(e){const s=e.lastIndexOf("/");return s<0?e:e.slice(s+1)}a(Uc,"basename");function rb(e,s=80){if(e.length<=s)return e;const n=e.slice(0,Math.floor(s/2)-1);return`${n}…${e.slice(e.length-(s-n.length-1))}`}a(rb,"middleTruncatePath");function ib(e){if((e.contentType?.toLowerCase()??"").includes("markdown"))return!0;const s=(e.displayPath||e.title).toLowerCase();return/\.(md|markdown|mdown|mkdn|mkd)$/.test(s)}a(ib,"isMarkdownResource");function uo(e,s){const n=e.toLowerCase();return n.includes("policy")||n.includes("denied")||n.includes("sensitive")?{icon:(0,t.jsx)(mi,{"aria-hidden":"true",className:"h-6 w-6 text-amber-500"}),title:"Viewer blocked for this file",body:"This file is not available through the viewer because it may contain sensitive data."}:n.includes("outside")||n.includes("traversal")?{icon:(0,t.jsx)(ul,{"aria-hidden":"true",className:"h-6 w-6 text-red-500"}),title:"Path is outside the workspace",body:"The viewer can only open files that live under the issue's workspace."}:n.includes("archive")||n.includes("cleaned")?{icon:(0,t.jsx)(Rn,{"aria-hidden":"true",className:"h-6 w-6 text-ink-3"}),title:"Workspace is no longer available",body:"The isolated worktree for this issue has been cleaned up, so files cannot be previewed."}:n.includes("remote")?{icon:(0,t.jsx)(nn,{"aria-hidden":"true",className:"h-6 w-6 text-amber-500"}),title:"Remote workspace preview not supported",body:"This workspace is hosted remotely and is not available for inline preview yet."}:n.includes("too_large")||n.includes("size")?{icon:(0,t.jsx)(nn,{"aria-hidden":"true",className:"h-6 w-6 text-amber-500"}),title:"File is too large to preview",body:"This file exceeds the supported preview size."}:n.includes("binary")||n.includes("unsupported")?{icon:(0,t.jsx)(nn,{"aria-hidden":"true",className:"h-6 w-6 text-amber-500"}),title:"Preview not supported for this file type",body:"This file does not have a text, image, or video preview available."}:{icon:(0,t.jsx)(ul,{"aria-hidden":"true",className:"h-6 w-6 text-red-500"}),title:"Can't preview this file",body:s||"The viewer was unable to load this file."}}a(uo,"describeDenial");function An({icon:e,title:s,body:n,secondary:r,actions:i}){return(0,t.jsxs)("div",{className:"flex flex-col items-start gap-3 p-6 text-sm",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[e,(0,t.jsxs)("div",{className:"flex-1 space-y-1",children:[(0,t.jsx)("p",{className:"font-medium text-ink",children:s}),n?(0,t.jsx)("p",{className:"text-ink-3",children:n}):null,r]})]}),i?(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:i}):null]})}a(An,"FileViewerStateView");function Eu({resolvedResource:e,state:s}){return(0,t.jsx)("div",{className:"flex min-h-(--sz-18px) flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-ink-3",children:e?(0,t.jsxs)(t.Fragment,{children:[e.previewKind?(0,t.jsx)("span",{className:"capitalize",children:e.previewKind}):null,Kc(e.byteSize)?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{"aria-hidden":"true",className:"opacity-50",children:"·"}),(0,t.jsx)("span",{children:Kc(e.byteSize)})]}):null,s?.line?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{"aria-hidden":"true",className:"opacity-50",children:"·"}),(0,t.jsxs)("span",{children:["Line ",s.line,s.column?`, Col ${s.column}`:""]})]}):null]}):s?(0,t.jsx)("span",{className:"h-3 w-28 rounded bg-bg-3 animate-pulse","aria-label":"Loading file details"}):null})}a(Eu,"FileViewerMetadataRow");function ob({content:e,highlightedLine:s,onLoaded:n,previewMode:r,htmlMode:i="rendered"}){const{resource:o}=e,u=o.previewKind==="text"&&e.content.encoding==="utf8"&&ib(o),m=o.previewKind==="text"&&e.content.encoding==="utf8"&&Wd(o.displayPath||o.title,o.contentType??""),[p,h]=(0,l.useState)("rendered"),d=u||m?r??p:"raw",v=o.previewKind==="text"&&e.content.encoding==="utf8"&&Zo(o.contentType,o.displayPath||o.title),k=m?"CSV":"Markdown",N=(0,l.useMemo)(()=>o.previewKind==="text"?ab(e.content.data):null,[e.content.data,o.previewKind]),A=(0,l.useRef)(null),E=(0,l.useRef)(null);if((0,l.useEffect)(()=>{h(u||m?"rendered":"raw")},[u,m,o.displayPath,o.title,o.contentType]),(0,l.useEffect)(()=>{N&&n?.(`File loaded, ${N.length} ${N.length===1?"line":"lines"}.`)},[N,n]),(0,l.useEffect)(()=>{d==="raw"&&(!s||!E.current||E.current.scrollIntoView({block:"center",behavior:"auto"}))},[s,d,i,r]),o.previewKind==="image"){const O=e.content.encoding==="base64"?`data:${o.contentType??"application/octet-stream"};base64,${e.content.data}`:null;return O?(0,t.jsx)("div",{className:"flex items-center justify-center overflow-auto bg-bg-3/40 p-4",children:(0,t.jsx)("img",{src:O,alt:o.title,className:"max-h-full max-w-full rounded border border-line object-contain"})}):(0,t.jsx)(An,{icon:(0,t.jsx)(nn,{"aria-hidden":"true",className:"h-6 w-6 text-amber-500"}),title:"Image preview unavailable"})}if(o.previewKind==="video"){const O=e.content.encoding==="base64"?`data:${o.contentType??"application/octet-stream"};base64,${e.content.data}`:null;return O?(0,t.jsx)("div",{className:"flex flex-1 items-center justify-center overflow-auto bg-black p-4",children:(0,t.jsx)("video",{src:O,controls:!0,preload:"metadata",playsInline:!0,"aria-label":`Video preview: ${o.title}`,className:"max-h-full max-w-full rounded border border-white/10 bg-black"})}):(0,t.jsx)(An,{icon:(0,t.jsx)(nn,{"aria-hidden":"true",className:"h-6 w-6 text-amber-500"}),title:"Video preview unavailable"})}if(o.previewKind==="unsupported"||!N)return(0,t.jsx)(An,{icon:(0,t.jsx)(nn,{"aria-hidden":"true",className:"h-6 w-6 text-amber-500"}),title:"Preview not supported for this file type",body:o.contentType?`Content type: ${o.contentType}`:void 0});const _=`calc(${Math.max(4,String(N.length).length)}ch + 2rem)`,q=(0,t.jsx)("div",{ref:A,role:"region","aria-label":`${o.title} source`,tabIndex:0,className:"wardmote-file-viewer-code flex-1 overflow-auto bg-(--code-bg-resolved) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus focus-visible:ring-inset",children:(0,t.jsx)("pre",{className:"m-0 font-mono text-xs leading-5",children:N.map((O,F)=>{const C=F+1,S=C===s;return(0,t.jsxs)("div",{ref:S?E:void 0,"data-line-number":C,className:ue("grid grid-cols-(--gtc-5)",S&&"bg-(--code-highlight-bg-resolved)"),children:[(0,t.jsx)("span",{"aria-hidden":"true",className:ue("sticky left-0 z-10 shrink-0 select-none pl-3 pr-4 text-right text-(--code-gutter-fg-resolved) opacity-70","bg-(--code-bg-resolved)",S&&"opacity-100 bg-(--code-highlight-bg-resolved) border-l-2 border-(--code-highlight-border-resolved)"),style:{width:_,minWidth:_},children:C}),(0,t.jsx)("code",{className:"min-w-0 whitespace-pre-wrap break-words pr-4",children:O.length===0?"​":O})]},C)})})});return v?(r??i)==="raw"?q:(0,t.jsx)(zg,{html:e.content.data,title:o.title}):!u&&!m?q:(0,t.jsxs)("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[r===void 0&&(0,t.jsx)("div",{className:"absolute right-3 top-3 z-20",children:(0,t.jsxs)("div",{role:"group","aria-label":`${k} preview mode`,className:"inline-flex rounded-md border border-line bg-bg/95 p-0.5 shadow-sm backdrop-blur",children:[(0,t.jsx)(ne,{type:"button",variant:d==="rendered"?"secondary":"ghost",size:"icon-sm","aria-label":`Show rendered ${k}`,title:`Rendered ${k}`,"aria-pressed":d==="rendered",onClick:a(()=>h("rendered"),"onClick"),className:ue("h-7 w-7 rounded-sm"),children:(0,t.jsx)(rf,{"aria-hidden":"true",className:"h-3.5 w-3.5"})}),(0,t.jsx)(ne,{type:"button",variant:d==="raw"?"secondary":"ghost",size:"icon-sm","aria-label":`Show raw ${k}`,title:`Raw ${k}`,"aria-pressed":d==="raw",onClick:a(()=>h("raw"),"onClick"),className:ue("h-7 w-7 rounded-sm"),children:(0,t.jsx)(Ua,{"aria-hidden":"true",className:"h-3.5 w-3.5"})})]})}),d==="raw"?q:m?(0,t.jsx)(Kg,{text:e.content.data,title:o.title}):(0,t.jsx)("div",{role:"region","aria-label":`${o.title} rendered Markdown`,tabIndex:0,className:"flex-1 overflow-auto bg-bg p-5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus focus-visible:ring-inset",children:(0,t.jsx)(nx,{softBreaks:!1,children:e.content.data})})]})}a(ob,"FileContentViewer");function Qc({elapsedMs:e}){return e<100?(0,t.jsx)("div",{className:"flex-1","aria-hidden":"true"}):e<400?(0,t.jsxs)("div",{className:"flex-1 space-y-2 p-6","aria-busy":"true","aria-live":"polite",children:[(0,t.jsx)("span",{className:"sr-only",children:"Loading file preview"}),Array.from({length:10}).map((s,n)=>(0,t.jsx)("div",{className:"h-3 rounded bg-bg-3 animate-pulse",style:{width:`${90-n*6}%`}},n))]}):(0,t.jsx)("div",{className:"flex flex-1 flex-col items-start justify-start gap-3 p-6 text-sm",role:"status","aria-live":"polite",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 text-ink-3",children:[(0,t.jsx)(It,{"aria-hidden":"true",className:"h-4 w-4 animate-spin"}),"Loading file preview..."]})})}a(Qc,"LoadingView");function lb({issueId:e,companyId:s,state:n,showPromptWhenEmpty:r=!1,open:i,onOpenChange:o}){const u=hd(),m=typeof n<"u"?n:u.state,p=m===null&&(r||u.browse),h=m!==null&&u.browse,d=typeof i=="boolean"?i:m!==null||r||u.browse,[v,k]=(0,l.useState)(0),[N,A]=(0,l.useState)("rendered");(0,l.useEffect)(()=>A("rendered"),[m?.path,m?.workspace,m?.workspaceId,m?.projectId]);const[E,_]=(0,l.useState)(null),[q,O]=(0,l.useState)(null),[F,C]=(0,l.useState)(""),[S,P]=(0,l.useState)(""),[j,f]=(0,l.useState)(288),w=(0,l.useRef)(null),W=(0,l.useRef)(null),M=ye({queryKey:m?R.issues.fileResource(e,m):["issues","file-resources",e,"resolve","__closed__"],queryFn:a(()=>hn.resolve(e,m),"queryFn"),enabled:!!m&&d,retry:!1,staleTime:3e4}),$=M.data,K=$?.capabilities.preview??!1,le=m&&$?.capabilities.download?hn.downloadUrl(e,m):null,y=ye({queryKey:m?R.issues.fileResourceContent(e,m):["issues","file-resources",e,"content","__closed__"],queryFn:a(()=>hn.content(e,m),"queryFn"),enabled:!!m&&d&&K,retry:!1,staleTime:3e4}),z=M.isFetching&&!M.data||K&&y.isFetching&&!y.data;(0,l.useEffect)(()=>{if(!m){k(0);return}if(!z)return;const re=Date.now();k(0);const Se=window.setInterval(()=>{k(Date.now()-re)},75);return()=>window.clearInterval(Se)},[m?.path,m?.workspace,m?.projectId,m?.workspaceId,z]),(0,l.useEffect)(()=>{if(M.isError){const re=ci(M.error);P(re.message||"Unable to load file.")}},[M.isError,M.error]),(0,l.useEffect)(()=>{if(y.isError){const re=ci(y.error);P(re.message||"Unable to load file content.")}},[y.isError,y.error]),(0,l.useEffect)(()=>()=>{w.current&&window.clearTimeout(w.current),W.current?.()},[]);const se=(0,l.useCallback)(re=>{if(o){o(re);return}re||u.close()},[o,u]),de=(0,l.useCallback)(re=>{u.open({path:re.path,line:re.line??null,column:re.column??null,workspace:re.workspace,projectId:re.projectId??null,workspaceId:re.workspaceId??null},{fromBrowse:!0,browseState:{folderPath:re.browseFolderPath??null,q:re.browseQuery??null}})},[u]),me=(0,l.useCallback)(re=>{u.updateBrowseState(re)},[u]),oe=(0,l.useCallback)((re,Se)=>{_(re),C(Se),P(Se),w.current&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>{_(Ve=>Ve===re?null:Ve),C(""),w.current=null},1800)},[]),ve=(0,l.useCallback)(async(re,Se,Ve)=>{try{O(Se),await Go(re),oe(Se,Ve)}catch{oe(null,"Copy failed")}finally{O(Je=>Je===Se?null:Je)}},[oe]),ie=(0,l.useCallback)(()=>{m&&(async()=>{let re=y.data;if(!re&&K&&(re=(await y.refetch()).data),!re){oe(null,"File contents unavailable");return}const Se=re.content.encoding==="base64"?"Copied file data":"Copied contents";await ve(re.content.data,"content",Se)})()},[K,y,ve,oe,m]),ge=(0,l.useCallback)(()=>{typeof window>"u"||ve(window.location.href,"link","Copied link")},[ve]),Ie=(0,l.useCallback)(()=>{M.refetch(),K&&y.refetch()},[K,y,M]),De=(0,l.useCallback)(re=>{re.preventDefault(),W.current?.();const Se=re.clientX,Ve=j,Je=a(Ze=>{const Te=Math.min(co,Math.max(lo,Ve+Ze.clientX-Se));f(Te)},"handlePointerMove"),ft=a(()=>{document.removeEventListener("pointermove",Je),document.removeEventListener("pointerup",ft),W.current=null},"cleanup");W.current=ft,document.addEventListener("pointermove",Je),document.addEventListener("pointerup",ft,{once:!0})},[j]),$e=(0,l.useCallback)(re=>{re.key!=="ArrowLeft"&&re.key!=="ArrowRight"||(re.preventDefault(),f(Se=>{const Ve=re.key==="ArrowLeft"?-24:24;return Math.min(co,Math.max(lo,Se+Ve))}))},[]),Be=m?Uc(m.path):"Browse workspace",Fe=m?rb(m.path):"Search and preview files from this issue's workspace.";return(0,t.jsx)(Vo,{open:d,onOpenChange:se,children:(0,t.jsxs)(Wo,{className:"flex h-(--sz-calc-3) w-(--sz-calc-4) max-w-(--sz-calc-5) flex-col gap-0 overflow-hidden p-0 sm:w-(--sz-94vw) sm:max-w-(--sz-1280px)","aria-labelledby":Bc,"aria-describedby":Oc,showCloseButton:!1,onEscapeKeyDown:a(re=>{h&&(re.preventDefault(),u.backToFiles())},"onEscapeKeyDown"),children:[(0,t.jsxs)(Qo,{className:"border-b border-line gap-1 p-3",children:[(0,t.jsxs)("div",{className:"grid min-w-0 grid-cols-(--gtc-6) items-start gap-2",children:[p?(0,t.jsx)(pf,{"aria-hidden":"true",className:"mt-0.5 h-4 w-4 shrink-0 text-ink-3"}):(0,t.jsx)(Ua,{"aria-hidden":"true",className:"mt-0.5 h-4 w-4 shrink-0 text-ink-3"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)(Ho,{id:Bc,className:"truncate text-sm leading-5",children:Be}),(0,t.jsx)(zo,{id:Oc,className:ue("truncate font-mono text-xs",!(!m||Fe!==Be)&&"sr-only"),title:m?.path,children:Fe})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-1 self-start",children:[(0,t.jsx)("span",{className:"hidden min-w-28 text-right text-xs text-ink-3 sm:inline",role:"status","aria-live":"polite",children:F}),h?(0,t.jsxs)(ne,{type:"button",variant:"ghost",size:"sm",onClick:a(()=>u.backToFiles(),"onClick"),className:"h-7 gap-1 px-2 text-xs","aria-label":"Back to files",children:[(0,t.jsx)(cd,{className:"h-3.5 w-3.5"}),"Back to files"]}):null,y.data?.resource.previewKind==="text"&&y.data.content.encoding==="utf8"&&Zo(y.data.resource.contentType,y.data.resource.displayPath||y.data.resource.title)?(0,t.jsx)(zd,{mode:N,onChange:A,label:"HTML view"}):null,m&&le?(0,t.jsx)(ne,{asChild:!0,variant:"ghost",size:"icon-sm",className:"h-7 w-7",children:(0,t.jsx)("a",{href:le,download:$?.title??Uc(m.path),"aria-label":"Download file",title:"Download file",children:(0,t.jsx)(Xo,{className:"h-4 w-4"})})}):null,m?(0,t.jsx)(ne,{type:"button",variant:"ghost",size:"icon-sm",onClick:ie,"aria-label":E==="content"?"Copied file contents":"Copy file contents",title:E==="content"?"Copied contents":"Copy file contents",className:"h-7 w-7",children:q==="content"?(0,t.jsx)(It,{className:"h-4 w-4 animate-spin"}):E==="content"?(0,t.jsx)(Wn,{className:"h-4 w-4 text-green-500"}):(0,t.jsx)(wr,{className:"h-4 w-4"})}):null,m?(0,t.jsx)(ne,{type:"button",variant:"ghost",size:"icon-sm",onClick:ge,"aria-label":E==="link"?"Copied file view link":"Copy link to this file view",title:E==="link"?"Copied link":"Copy link",className:"h-7 w-7",children:q==="link"?(0,t.jsx)(It,{className:"h-4 w-4 animate-spin"}):E==="link"?(0,t.jsx)(Wn,{className:"h-4 w-4 text-green-500"}):(0,t.jsx)(Ad,{className:"h-4 w-4"})}):null,(0,t.jsx)(ne,{type:"button",variant:"ghost",size:"icon-sm",onClick:a(()=>se(!1),"onClick"),className:"h-7 w-7","aria-label":"Close file viewer",title:"Close",children:(0,t.jsx)(Qa,{className:"h-4 w-4"})})]})]}),(0,t.jsx)(Eu,{resolvedResource:$,state:m})]}),(0,t.jsxs)("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[(0,t.jsx)("div",{"aria-live":"polite",className:"sr-only",children:S}),m?(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 gap-3 bg-bg-3/30 p-3",children:[(0,t.jsx)("aside",{className:"hidden min-h-0 shrink-0 overflow-hidden sm:flex",style:{width:j},children:(0,t.jsx)(Ao,{issueId:e,companyId:s,onOpen:de,onBrowseStateChange:h?me:void 0,initialQuery:h?u.query:null,initialFolderPath:h?u.folderPath:void 0,initialProjectId:m.projectId??(h?u.browseProjectId:null),initialWorkspaceId:m.workspaceId??(h?u.browseWorkspaceId:null),autoFocusSearch:!1,compact:!0,selectedPath:m.path,selectedProjectId:m.projectId,selectedWorkspaceId:m.workspaceId,active:d,className:"min-h-0 flex-1 p-2"},`${m.projectId??""}:${m.workspaceId??""}`)}),(0,t.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize file tree","aria-valuemin":lo,"aria-valuemax":co,"aria-valuenow":j,tabIndex:0,onPointerDown:De,onKeyDown:$e,className:"hidden w-1 shrink-0 cursor-col-resize rounded-full bg-line transition-colors hover:bg-ink-3/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus sm:block"}),(0,t.jsx)("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:(0,t.jsx)(_u,{resolveQuery:M,contentQuery:y,elapsedMs:v,canPreview:K,highlightedLine:m.line??null,htmlMode:N,onRetry:Ie,onSetAnnouncement:P,onFallbackToProject:m.workspace!=="project"&&!m.projectId&&!m.workspaceId?()=>u.open({path:m.path,line:m.line,column:m.column,workspace:"project",projectId:null,workspaceId:null}):null})})]}):p?(0,t.jsx)(Ao,{issueId:e,companyId:s,onOpen:de,onBrowseStateChange:me,initialQuery:u.query,initialFolderPath:u.folderPath,initialProjectId:u.browseProjectId,initialWorkspaceId:u.browseWorkspaceId,active:d,className:"min-h-0 flex-1 p-4"}):null]})]})})}a(lb,"FileViewerSheet");function _u({resolveQuery:e,contentQuery:s,elapsedMs:n,canPreview:r,highlightedLine:i,onRetry:o,onSetAnnouncement:u,onFallbackToProject:m,previewMode:p,htmlMode:h}){if(e.isFetching&&!e.data)return(0,t.jsx)(Qc,{elapsedMs:n});if(e.isError){const v=ci(e.error);if(v.status===404)return(0,t.jsx)(An,{icon:(0,t.jsx)(uf,{"aria-hidden":"true",className:"h-6 w-6 text-ink-3"}),title:"File not found",body:"That file was not found in the active workspace.",actions:(0,t.jsxs)(t.Fragment,{children:[m?(0,t.jsx)(ne,{type:"button",variant:"secondary",size:"sm",onClick:m,children:"Try project workspace"}):null,(0,t.jsxs)(ne,{type:"button",variant:"ghost",size:"sm",onClick:o,children:[(0,t.jsx)(cr,{"aria-hidden":"true",className:"mr-1 h-3 w-3"})," Retry"]})]})});if(v.status===422)return(0,t.jsx)(An,{icon:(0,t.jsx)(Rn,{"aria-hidden":"true",className:"h-6 w-6 text-ink-3"}),title:"No workspace available",body:"This issue does not have a workspace that supports preview yet."});const k=uo(v.code,v.message);return(0,t.jsx)(An,{icon:k.icon,title:k.title,body:k.body,actions:(0,t.jsxs)(ne,{type:"button",variant:"ghost",size:"sm",onClick:o,children:[(0,t.jsx)(cr,{"aria-hidden":"true",className:"mr-1 h-3 w-3"})," Retry"]})})}const d=e.data;if(!d)return null;if(d.kind==="remote_resource")return(0,t.jsx)(An,{icon:(0,t.jsx)(gd,{"aria-hidden":"true",className:"h-6 w-6 text-ink-3"}),title:"Remote workspace preview coming soon",body:"This workspace is hosted remotely; inline previews are not supported yet."});if(!r){const v=uo(d.denialReason??"","");return(0,t.jsx)(An,{icon:v.icon,title:v.title,body:v.body})}if(s.isFetching&&!s.data)return(0,t.jsx)(Qc,{elapsedMs:n});if(s.isError){const v=ci(s.error),k=uo(v.code,v.message);return(0,t.jsx)(An,{icon:k.icon,title:k.title,body:k.body,actions:(0,t.jsxs)(ne,{type:"button",variant:"ghost",size:"sm",onClick:o,children:[(0,t.jsx)(cr,{"aria-hidden":"true",className:"mr-1 h-3 w-3"})," Retry"]})})}return s.data?(0,t.jsx)(ob,{content:s.data,highlightedLine:i,previewMode:p,onLoaded:u,htmlMode:h}):null}a(_u,"FileViewerBody");function cb({issueId:e,payload:s,onFallbackToProject:n}){const[r,i]=(0,l.useState)("rendered");(0,l.useEffect)(()=>i("rendered"),[s.path,s.workspace,s.workspaceId,s.projectId]);const[o,u]=(0,l.useState)(!1),[m,p]=(0,l.useState)(""),h={path:s.path,workspace:s.workspace,projectId:s.projectId,workspaceId:s.workspaceId,line:s.line,column:s.column},d=ye({queryKey:R.issues.fileResource(e,h),queryFn:a(()=>hn.resolve(e,h),"queryFn"),retry:!1}),v=d.data,k=ye({queryKey:R.issues.fileResourceContent(e,h),queryFn:a(()=>hn.content(e,h),"queryFn"),enabled:v?.capabilities.preview===!0,retry:!1}),N=v?.capabilities.download?hn.downloadUrl(e,h):null,A=v&&(Zo(v.contentType,v.displayPath||v.title)||Wd(v.displayPath||v.title,v.contentType??"")||/\.(md|markdown|mdown|mkdn|mkd)$/i.test(v.displayPath||v.title)||v.contentType?.includes("markdown"));return(0,t.jsxs)("div",{className:"flex h-full min-h-0 flex-col bg-bg-3/20",children:[(0,t.jsxs)("header",{className:"flex min-w-0 items-start gap-2 border-b border-line bg-bg-2 px-3 py-2",children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("h2",{className:"truncate text-sm font-medium",title:s.path,children:v?.title??s.path}),(0,t.jsx)("p",{className:"truncate font-mono text-xs text-ink-3",title:s.path,children:s.path}),(0,t.jsx)(Eu,{resolvedResource:v,state:h})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[k.data?(0,t.jsx)(ne,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Copy file contents",title:o?"Copied":"Copy file contents",onClick:a(()=>{Go(k.data.content.data).then(()=>{u(!0),window.setTimeout(()=>u(!1),1800)})},"onClick"),children:o?(0,t.jsx)(Wn,{"aria-hidden":!0}):(0,t.jsx)(wr,{"aria-hidden":!0})}):null,A&&k.data?(0,t.jsx)(zd,{mode:r,onChange:i,label:"File preview mode"}):null,N?(0,t.jsx)(ne,{asChild:!0,variant:"ghost",size:"icon-sm",children:(0,t.jsx)("a",{href:N,download:v?.title,"aria-label":"Download file",title:"Download file",children:(0,t.jsx)(Xo,{"aria-hidden":!0})})}):null]})]}),(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[(0,t.jsx)("div",{className:"sr-only","aria-live":"polite",children:m}),(0,t.jsx)(_u,{previewMode:r,resolveQuery:d,contentQuery:k,elapsedMs:0,canPreview:v?.capabilities.preview??!1,highlightedLine:s.line,onRetry:a(()=>{d.refetch(),v?.capabilities.preview&&k.refetch()},"onRetry"),onSetAnnouncement:p,onFallbackToProject:n??null})]})]})}a(cb,"TaskWorkspaceFilePanel");function db({companyId:e,skillId:s}){const n=fi(),r=ye({queryKey:R.companySkills.detail(e,s),queryFn:a(()=>Rp.detail(e,s),"queryFn"),retry:!1,refetchOnWindowFocus:!0,refetchOnMount:"always"});if(r.isLoading)return(0,t.jsxs)("div",{className:"flex items-center gap-2 py-8 text-sm text-ink-3",role:"status",children:[(0,t.jsx)(It,{className:"size-4 animate-spin","aria-hidden":!0}),"Loading skill…"]});if(r.isError){const u=r.error instanceof Hs?r.error.status:null;return u===404?(0,t.jsx)("div",{className:"py-8 text-sm text-ink-3",role:"status",children:"Skill no longer available."}):u===403?(0,t.jsx)("div",{className:"py-8 text-sm text-ink-3",role:"alert",children:"You do not have access to this skill."}):(0,t.jsxs)("div",{className:"space-y-3 py-8 text-sm text-ink-3",role:"alert",children:[(0,t.jsx)("p",{children:"The skill could not be loaded."}),(0,t.jsx)(ne,{variant:"secondary",size:"sm",onClick:a(()=>{r.refetch()},"onClick"),disabled:r.isFetching,children:r.isFetching?"Retrying…":"Retry"})]})}if(!r.data)return(0,t.jsx)("div",{className:"py-8 text-sm text-ink-3",role:"status",children:"Skill no longer available."});const i=r.data,o=wm(i.markdown).body;return(0,t.jsxs)("article",{className:"space-y-4",children:[(0,t.jsxs)("header",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(lp,{className:"size-4 text-ink-3","aria-hidden":!0}),(0,t.jsx)("h2",{className:"text-lg font-semibold",children:i.name})]}),(0,t.jsxs)(ne,{variant:"secondary",size:"sm",onClick:a(()=>n(`/skills/studio/${encodeURIComponent(i.id)}`),"onClick"),children:[(0,t.jsx)(Po,{className:"mr-1.5 size-3.5","aria-hidden":!0}),"Open in Skill Studio"]})]}),(0,t.jsxs)("p",{className:"text-xs text-ink-3",children:[i.slug," · ",i.currentVersion?`Revision ${i.currentVersion.revisionNumber}`:"Current version"]})]}),i.description?(0,t.jsx)("p",{className:"text-sm text-ink-3",children:i.description}):null,(0,t.jsxs)("section",{className:"space-y-2",children:[(0,t.jsxs)("h3",{className:"flex items-center gap-2 text-xs font-medium text-ink-3",children:[(0,t.jsx)(dr,{className:"size-3.5","aria-hidden":!0}),"Skill instructions"]}),(0,t.jsx)(bs,{children:o||"Skill instructions are empty."})]})]})}a(db,"TaskSkillPanel");function ub(e,s,n=new Set){return(e??[]).filter(r=>r.issueId===s&&r.kind==="local"&&r.status==="running"&&!n.has(r.id)).sort((r,i)=>i.lastActivityAt.localeCompare(r.lastActivityAt))[0]??null}a(ub,"findTaskTerminalSession");function mb({issue:e,active:s}){const n=ks(),r=(0,l.useMemo)(()=>ep.sessions(e.companyId),[e.companyId]),i=ye({queryKey:r,queryFn:a(()=>hl.list(e.companyId),"queryFn"),refetchOnMount:"always"}),[o,u]=(0,l.useState)(null),[m,p]=(0,l.useState)(!1),[h,d]=(0,l.useState)(null),v=(0,l.useRef)(!1),k=(0,l.useRef)(new Set),N=(0,l.useCallback)(async()=>{if(!v.current){v.current=!0,d(null);try{const q=await hl.create(e.companyId,{kind:"local",issueId:e.id,title:e.identifier??e.title});n.setQueryData(r,(O=[])=>[...O.filter(F=>F.id!==q.id),q]),p(!1),u(q.id)}catch(q){d(fl(q,"Could not open a terminal for this task."))}finally{v.current=!1}}},[e.companyId,e.id,e.identifier,e.title,n,r]),A=i.isSuccess&&i.isFetchedAfterMount&&!i.isFetching;(0,l.useEffect)(()=>{if(o||m||h||!A)return;const q=ub(i.data,e.id,k.current);q?u(q.id):N()},[h,m,A,e.id,o,i.data,N]);const E=(0,l.useCallback)(()=>{u(q=>(q&&k.current.add(q),null)),n.invalidateQueries({queryKey:r})},[n,r]),_=i.isError?fl(i.error,"Terminal sessions could not be loaded."):h;return _?(0,t.jsxs)("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-6 text-center","data-testid":"task-terminal-error",children:[(0,t.jsx)(Yo,{className:"size-6 text-ink-3","aria-hidden":!0}),(0,t.jsx)("p",{className:"text-sm font-medium text-ink",children:"Terminal unavailable"}),(0,t.jsx)("p",{className:"max-w-md text-sm text-ink-3",children:_}),h?(0,t.jsx)(ne,{type:"button",variant:"secondary",size:"sm",onClick:a(()=>{N()},"onClick"),children:"Try again"}):null]}):o?(0,t.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,t.jsx)(tp,{companyId:e.companyId,sessionId:o,active:s,onExit:a(()=>p(!0),"onExit"),onUnavailable:E},o),m?(0,t.jsxs)("div",{className:"flex shrink-0 items-center justify-between gap-2 border-t border-line px-3 py-2 text-xs text-ink-3",children:[(0,t.jsx)("span",{children:"The shell for this task has ended."}),(0,t.jsx)(ne,{type:"button",variant:"secondary",size:"xs",onClick:a(()=>{u(null),N()},"onClick"),children:"New terminal"})]}):null]}):(0,t.jsx)("p",{className:"p-4 text-sm text-ink-3",children:"Opening a terminal in the task workspace…"})}a(mb,"TaskTerminalPanel");var pb=[];function fb(e){switch(e.payload.kind){case"browser":return(0,t.jsx)(pi,{});case"properties":return(0,t.jsx)(ri,{});case"subtasks":return(0,t.jsx)(Od,{});case"artifacts":return(0,t.jsx)(xo,{});case"agent-tasks":return(0,t.jsx)(Jo,{});case"todo":return(0,t.jsx)(Do,{});case"attachment":return(0,t.jsx)(dr,{});case"files-browser":return(0,t.jsx)(Rn,{});case"workspace-file":return(0,t.jsx)(Ua,{});case"terminal":return(0,t.jsx)(Yo,{});case"issue-document":return e.payload.documentKey==="plan"?(0,t.jsx)(od,{}):(0,t.jsx)(dr,{})}}a(fb,"tabIcon");function mo(e){if(e.some(r=>r.id==="subtasks"))return e;const s=e.findIndex(r=>r.id==="properties"),n=[...e];return n.splice(s<0?0:s+1,0,Zv()),n}a(mo,"insertSubtasksAfterProperties");function hb(e){return e==="execution_workspace"?"execution":"project"}a(hb,"selectorForWorkspaceKind");function gb(){const e=ui(),s=fi(),n=(0,l.useMemo)(()=>zp(e.search),[e.search]),r=(0,l.useMemo)(()=>tf(e.search),[e.search]),i=(0,l.useCallback)((h,d=!1)=>{Hp(h,e.search)&&s({pathname:e.pathname,hash:e.hash,search:h},{...ef,replace:d,state:e.state})},[e.hash,e.pathname,e.search,e.state,s]),o=(0,l.useCallback)((h,d)=>{let v=Il(e.search,h);if(d?.fromBrowse){const k=new URLSearchParams(v),N=new URLSearchParams(e.search);k.set("browse","1");const A=Object.prototype.hasOwnProperty.call(d.browseState??{},"q")?d.browseState?.q:N.get("q"),E=Object.prototype.hasOwnProperty.call(d.browseState??{},"folderPath")?d.browseState?.folderPath:N.get("folder");A?k.set("q",A):k.delete("q"),E?k.set("folder",E):k.delete("folder"),v=k.toString()?`?${k.toString()}`:""}i(v)},[e.search,i]),u=(0,l.useCallback)(h=>{const d=new URLSearchParams(e.search);d.delete("file"),d.delete("line"),d.delete("column"),d.delete("folder"),d.set("browse","1"),h?.q?d.set("q",h.q):d.delete("q"),i(d.toString()?`?${d.toString()}`:"")},[e.search,i]),m=(0,l.useCallback)(h=>{i(Vp(e.search,h),!0)},[e.search,i]),p=(0,l.useCallback)(()=>{const h=Xp(e.search),d=new URLSearchParams(Il(h,null).replace(/^\?/,""));d.delete("browse"),d.delete("q"),d.delete("folder"),i(d.toString()?`?${d.toString()}`:"")},[e.search,i]);return{state:n,browse:r!==null,query:r?.q??null,folderPath:r?.folderPath??null,browseProjectId:r?.projectId??null,browseWorkspaceId:r?.workspaceId??null,open:o,openBrowse:u,updateBrowseState:m,close:p}}a(gb,"useTaskSidePanelFileRouting");function Wc({openBrowserId:e,onBrowserOpened:s,issue:n,accountScope:r,childIssues:i=[],issueLinkState:o,onAddSubIssue:u,onUpdate:m,inline:p=!1,mobile:h=!1,hasActiveRun:d=!1,externalObjects:v,externalObjectsLoading:k,externalObjectsError:N,onRetryExternalObjects:A,onCheckMonitorNow:E,checkingMonitorNow:_=!1,fileTabsEnabled:q,documentDeepLink:O,artifactsOpenRequestId:F,onArtifactsOpened:C,onRequestClose:S,streamlinedTabs:P=!1,showSubtasksTab:j=!1,tasksTab:f,openAttachment:w,onAttachmentOpened:W,openAgentTodoRequestId:M,onAgentTodoOpened:$,openSkillId:K,openSkillName:le,onSkillOpened:y}){const z=$h(),{enabled:se}=nh(),de=se?n.conversationAgentId??null:null,me=j&&!de,oe=gb(),{data:ve}=bf(n.id),ie=ve??pb,{data:ge}=Fo(n.id),{data:Ie}=Ud(n.id),De=(0,l.useRef)(Mc(r,n.companyId,n.id,q)),$e=f?.count??i.length,Be=f?"Tasks":"Subtasks",Fe=(0,l.useRef)(me&&($e>0||f?.hasError===!0)),re=(0,l.useRef)(De.current?.userInteracted===!0&&De.current.state.tabs.length===0),[Se,Ve]=(0,l.useState)(De.current?.launcherOpen??!1),[Je,ft]=(0,l.useState)(null),Ze=(0,l.useRef)(null),Te=(0,l.useRef)(new Map),Nt=(0,l.useRef)(De.current?.userInteracted??!1),vt=(0,l.useRef)(De.current?.autoPlanHandled??!1),Ut=(0,l.useRef)(void 0),Y=(0,l.useRef)(void 0),Ae=(0,l.useMemo)(()=>{const Q=De.current?.state;let ke=Q?.tabs??(de?[io()]:n.conversationAgentId?[Qr()]:[Pc()]);if(!de){const be=ke.filter(it=>it.payload.kind!=="agent-tasks");be.length===0&&ke.length>0&&n.conversationAgentId?ke=[Qr()]:ke=be}de&&!De.current?.userInteracted&&ke.length===1&&ke[0].id==="artifacts"&&(ke=[io()]),Fe.current?re.current||(ke=mo(ke)):ke=ke.filter(be=>be.payload.kind!=="subtasks");const tt=Q?.activeTabId??"properties";return{tabs:ke,activeTabId:ke.some(be=>be.id===tt)?tt:ke[0]?.id??null}},[]),ht=(0,l.useCallback)(Q=>{Xv(r,n.companyId,n.id,{state:Q,launcherOpen:Se,userInteracted:Nt.current,autoPlanHandled:vt.current,updatedAt:Date.now()})},[r,n.companyId,n.id,Se]),U=Eh({initialState:Ae,onStateChange:ht}),Ue=tu(n.id),St=Ue.data?.findLast(Q=>Q.status==="running"||Q.status==="idle");(0,l.useEffect)(()=>{e&&(Ve(!1),U.openTab(oo(e)))},[e,U.openTab]),(0,l.useEffect)(()=>{e&&U.activeTabId===`browser:${e}`&&Mc(r,n.companyId,n.id,q)?.state.activeTabId===U.activeTabId&&s?.()},[e,U.activeTabId,s,r,n.companyId,n.id,q]);const _e=U.tabs.find(Q=>Q.id===U.activeTabId)??null,et=me&&($e>0||f?.hasError===!0),rt=U.tabs.some(Q=>Q.id==="subtasks");(0,l.useEffect)(()=>{K&&(Ve(!1),U.openTab(eb(K,le??"Skill")),y?.(K))},[U.openTab,y,K,le]),(0,l.useEffect)(()=>{if(!et){re.current=!1,rt&&U.closeTab("subtasks");return}!rt&&!re.current&&U.resetTabs({tabs:mo(U.tabs),activeTabId:U.activeTabId})},[U.activeTabId,U.closeTab,U.resetTabs,U.tabs,rt,et]),(0,l.useEffect)(()=>{if(p){ft(null);return}ft(document.getElementById(_h))},[p]),(0,l.useEffect)(()=>{ge!==null||!U.tabs.some(Q=>Q.id==="document:plan")||(vt.current=!1,U.closeTab("document:plan"))},[U.closeTab,U.tabs,ge]),(0,l.useEffect)(()=>{!ge||vt.current||Nt.current||(vt.current=!0,U.openTab(Wr("plan",Cn(ge))))},[U.openTab,ge]),(0,l.useEffect)(()=>{if(!O||Y.current===O.requestId||O.documentKey==="plan"&&ge===null)return;const Q=ie.find(tt=>tt.key===O.documentKey),ke=Q?Cn(Q):O.documentKey==="plan"?"Plan":O.documentKey;Y.current=O.requestId,U.openTab(Wr(O.documentKey,ke))},[U.openTab,O,ie,ge]),(0,l.useEffect)(()=>{q&&(oe.state?U.openTab($c(oe.state)):oe.browse&&(U.openTab(Dc()),U.updateTab("files",{payload:{kind:"files-browser",query:oe.query,folderPath:oe.folderPath,projectId:oe.browseProjectId,workspaceId:oe.browseWorkspaceId}})))},[U.openTab,U.updateTab,q,oe.browse,oe.browseProjectId,oe.browseWorkspaceId,oe.folderPath,oe.query,oe.state]),(0,l.useEffect)(()=>{F===void 0||Ut.current===F||(Ut.current=F,U.openTab(Qr(),!1),C?.(F))},[F,U.openTab,C]),(0,l.useEffect)(()=>{w&&(Nt.current=!0,Ve(!1),U.openTab(Lc(w.id,w.title)),(oe.state||oe.browse)&&oe.close(),W?.())},[U.openTab,w,W]),(0,l.useEffect)(()=>{M&&(Nt.current=!0,Ve(!1),U.openTab(Fc()),(oe.state||oe.browse)&&oe.close(),$?.())},[U.openTab,M,$]);const us=ye({queryKey:R.access.currentBoardAccess,queryFn:a(()=>mr.getCurrentBoardAccess(),"queryFn")}),Vs=Zm(us.data),Rt=ye({queryKey:R.issues.fileResources(n.id,{workspace:"auto",mode:"recent",limit:5,offset:0}),queryFn:a(()=>hn.list(n.id,{workspace:"auto",mode:"recent",limit:5,offset:0}),"queryFn"),enabled:q&&(Se||!_e),retry:!1,staleTime:15e3});function xt(){Nt.current=!0}a(xt,"markInteracted");function Qt(){U.activeTabId&&Ze.current&&Te.current.set(U.activeTabId,Ze.current.scrollTop)}a(Qt,"captureScroll");function Ct(Q){Qt(),xt(),U.selectTab(Q);const ke=U.tabs.find(tt=>tt.id===Q);ke&&(ke.payload.kind==="workspace-file"?oe.open(ke.payload):ke.payload.kind==="files-browser"?oe.openBrowse({q:ke.payload.query??void 0}):(oe.state||oe.browse)&&oe.close())}a(Ct,"selectTab"),(0,l.useEffect)(()=>{const Q=U.activeTabId?Te.current.get(U.activeTabId)??0:0;window.requestAnimationFrame(()=>Ze.current?.scrollTo({top:Q,behavior:"auto"}))},[U.activeTabId]),(0,l.useEffect)(()=>{_e||window.requestAnimationFrame(()=>{Ze.current?.querySelector('input[aria-label="Search tabs and resources…"]')?.focus()})},[_e]);function ts(Q){xt(),Q==="subtasks"&&(re.current=!0);const ke=U.tabs.find(tt=>tt.id===Q);U.closeTab(Q),Q===U.activeTabId&&(ke?.payload.kind==="workspace-file"||ke?.payload.kind==="files-browser")&&oe.close()}a(ts,"closeTab");function $t(Q){xt(),U.openTab(Wr(Q.key,Cn(Q)))}a($t,"openDocument");function ms(Q){xt();const ke=$c(Q);U.openTab(ke),oe?.open({...Q,projectId:Q.projectId??null,workspaceId:Q.workspaceId??null,line:Q.line??null,column:Q.column??null},{fromBrowse:!0})}a(ms,"openWorkspaceFile");const Wt=(0,l.useMemo)(()=>new Map(ie.map(Q=>[Q.key,Q])),[ie]),lt=(0,l.useMemo)(()=>U.tabs.map(Q=>{const ke=Q.payload.kind==="issue-document"?Wt.get(Q.payload.documentKey):null,tt=Ue.data?.findIndex(it=>Q.payload.kind==="browser"&&(it.id===Q.payload.browserId||it.sessionId===Q.payload.browserId))??-1,be=tt>=0&&(Ue.data?.length??0)>1?`Browser ${tt+1}`:null;return{id:Q.id,type:Q.type,label:be??(Q.payload.kind==="subtasks"&&f?"Tasks":ke?Cn(ke):Q.label),ariaLabel:Q.payload.kind==="subtasks"?Be:Q.ariaLabel,closable:!0,contentMode:Q.contentMode,icon:fb(Q)}}),[U.tabs,Wt,$e,Be,f,Ue.data]),$s=(0,l.useMemo)(()=>{const Q=de?[{id:"agent-tasks",label:"Tasks",description:"Tasks this agent worked on",icon:(0,t.jsx)(Jo,{}),alreadyOpen:U.tabs.some(be=>be.id==="agent-tasks")},{id:"artifacts",label:"Artifacts",description:"Files this agent produced",icon:(0,t.jsx)(xo,{}),alreadyOpen:U.tabs.some(be=>be.id==="artifacts")},{id:"properties",label:"Properties",icon:(0,t.jsx)(ri,{}),alreadyOpen:U.tabs.some(be=>be.id==="properties")}]:[{id:"properties",label:"Properties",icon:(0,t.jsx)(ri,{}),alreadyOpen:U.tabs.some(be=>be.id==="properties")},...et?[{id:"subtasks",label:Be,description:f?.hasError?"Could not load all tasks":`${$e} total`,icon:(0,t.jsx)(Od,{}),alreadyOpen:U.tabs.some(be=>be.id==="subtasks")}]:[],{id:"artifacts",label:"Artifacts",icon:(0,t.jsx)(xo,{}),alreadyOpen:U.tabs.some(be=>be.id==="artifacts")}];Ie&&Q.push({id:"todo",label:"Todo",description:`${Ie.counts.completed}/${Ie.counts.total} done`,icon:(0,t.jsx)(Do,{}),alreadyOpen:U.tabs.some(be=>be.id==="todo")});for(const[be,it]of(Ue.data??[]).entries())Q.push({id:`browser:${it.id}`,label:(Ue.data?.length??0)>1?`Browser ${be+1}`:"Browser",description:it.status,icon:(0,t.jsx)(pi,{}),alreadyOpen:U.tabs.some(Js=>Js.id===`browser:${it.id}`)});q&&Q.push({id:"files",label:"Files",icon:(0,t.jsx)(Rn,{}),shortcut:"G F",alreadyOpen:U.tabs.some(be=>be.id==="files")}),Vs&&Q.push({id:"terminal",label:"Terminal",description:"Shell in the task workspace",icon:(0,t.jsx)(Yo,{}),alreadyOpen:U.tabs.some(be=>be.id==="terminal")});const ke=[...ge?[{id:"document:plan",label:Cn(ge),description:`Revision ${ge.latestRevisionNumber??1}`,icon:(0,t.jsx)(od,{}),alreadyOpen:U.tabs.some(be=>be.id==="document:plan")}]:[],...ie.filter(be=>be.key!=="plan"&&!nd(be.key)).sort((be,it)=>new Date(it.updatedAt).getTime()-new Date(be.updatedAt).getTime()).map(be=>({id:`document:${be.key}`,label:Cn(be),description:`Revision ${be.latestRevisionNumber??1}`,icon:(0,t.jsx)(dr,{}),alreadyOpen:U.tabs.some(it=>it.id===`document:${be.key}`)}))],tt=[{id:"open",label:"Open",items:Q}];if(ke.length>0&&tt.push({id:"documents",label:"Task documents",items:ke}),q){const be=Rt.data?.state==="available"?Rt.data.items.filter(it=>it.kind==="file").slice(0,5).map(it=>({id:`recent-file:${it.workspaceId}:${it.relativePath}`,label:it.title,description:it.displayPath,searchText:it.relativePath,icon:(0,t.jsx)(Ua,{})})):[];tt.push({id:"recent-files",label:"Recent workspace files",items:be,loading:Rt.isLoading,error:Rt.isError?"Recent files are temporarily unavailable.":null})}return tt},[Ie,Ue.data,de,$e,Be,f?.hasError,U.tabs,ie,q,ge,Rt.data,Rt.isError,Rt.isLoading,et,Vs]);function ps(Q){if(xt(),Q.id.startsWith("browser:"))U.openTab(oo(Q.id.slice(8)));else if(Q.id==="properties")U.openTab(Pc());else if(Q.id==="subtasks")re.current=!1,U.resetTabs({tabs:mo(U.tabs),activeTabId:"subtasks"});else if(Q.id==="artifacts")U.openTab(Qr());else if(Q.id==="agent-tasks")U.openTab(io());else if(Q.id==="todo")U.openTab(Fc());else if(Q.id==="terminal")U.openTab(tb());else if(Q.id==="files")U.openTab(Dc()),oe.openBrowse();else if(Q.id.startsWith("document:")){const ke=Q.id.slice(9);U.openTab(Wr(ke,Q.label))}else if(Q.id.startsWith("recent-file:")&&Rt.data?.state==="available"){const ke=Rt.data.items.find(tt=>Q.id===`recent-file:${tt.workspaceId}:${tt.relativePath}`);ke?.kind==="file"&&ms({path:ke.relativePath,workspace:hb(ke.workspaceKind),projectId:ke.projectId??null,workspaceId:ke.workspaceId})}}a(ps,"selectLauncherItem");const Gs=(0,t.jsx)(Ll,{sections:$s,onSelect:ps,presentation:"popover",open:Se,onOpenChange:Ve,trigger:(0,t.jsx)(ne,{type:"button",variant:"ghost",size:"icon-sm",className:ue("shrink-0",h?"size-(--sz-44px) rounded-md":P?"h-(--side-panel-tab-height) w-(--side-panel-tab-height) rounded-md":"h-(--side-panel-tab-height) w-(--side-panel-tab-height) rounded-(--side-panel-control-radius)"),"aria-label":"Open a new tab",children:(0,t.jsx)(Lo,{"aria-hidden":!0})})}),Ys=h?(0,t.jsx)(Bh,{tabs:lt,activeTabId:U.activeTabId,onActiveTabChange:Ct,onCloseTab:ts,addControl:Gs}):(0,t.jsx)(ig,{tabs:lt,activeTabId:U.activeTabId,onActiveTabChange:Ct,onCloseTab:ts,onReorderTabs:a(Q=>{xt(),U.reorderTabs(Q)},"onReorderTabs"),addControl:Gs,appearance:P?"streamlined-task":"default"});let yt;if(!_e)yt=(0,t.jsx)(Ll,{sections:$s,onSelect:ps});else if(_e.payload.kind==="browser"||_e.payload.kind==="terminal")yt=null;else if(_e.payload.kind==="properties")yt=(0,t.jsx)(kf,{issue:n,childIssues:i,issueLinkState:o,onAddSubIssue:u,onUpdate:m,inline:p,hasActiveRun:d,externalObjects:v,externalObjectsLoading:k,externalObjectsError:N,onRetryExternalObjects:A,onCheckMonitorNow:E,checkingMonitorNow:_,sidePanelContentOnly:!0});else if(_e.payload.kind==="subtasks")yt=f?.content??(0,t.jsx)(Og,{items:i,onAddSubtask:u,issueLinkState:o});else if(_e.payload.kind==="todo")yt=(0,t.jsx)(sb,{issueId:n.id});else if(_e.payload.kind==="agent-tasks")yt=de?(0,t.jsx)(Ov,{companyId:n.companyId,agentId:de,excludeIssueId:n.id}):null;else if(_e.payload.kind==="artifacts"&&de)yt=(0,t.jsx)(Wv,{companyId:n.companyId,agentId:de});else if(_e.payload.kind==="artifacts")yt=(0,t.jsx)(Kd.Provider,{value:a((Q,ke)=>{xt(),U.openTab(Lc(Q,ke)),(oe.state||oe.browse)&&oe.close()},"value"),children:(0,t.jsx)(ff,{issue:n,onOpenDocument:$t})});else if(_e.payload.kind==="issue-document")yt=_e.payload.documentKey==="plan"?(0,t.jsx)(yf,{issue:n,inline:p}):(0,t.jsx)(nb,{issueId:n.id,documentKey:_e.payload.documentKey,initialDocument:Wt.get(_e.payload.documentKey)});else if(_e.payload.kind==="attachment")yt=(0,t.jsx)(Ug,{issueId:n.id,attachmentId:_e.payload.attachmentId},_e.payload.attachmentId);else if(_e.payload.kind==="skill")yt=(0,t.jsx)(db,{companyId:n.companyId,skillId:_e.payload.skillId});else if(_e.payload.kind==="files-browser")yt=(0,t.jsx)(Ao,{issueId:n.id,companyId:n.companyId,onOpen:ms,onBrowseStateChange:a(Q=>{U.updateTab(_e.id,{payload:{kind:"files-browser",query:Q.q,folderPath:Q.folderPath,projectId:Q.projectId,workspaceId:Q.workspaceId}}),oe.updateBrowseState(Q)},"onBrowseStateChange"),initialQuery:_e.payload.query,initialFolderPath:_e.payload.folderPath,initialProjectId:_e.payload.projectId,initialWorkspaceId:_e.payload.workspaceId,active:!0,className:"h-full min-h-0 p-3"});else{const Q=_e.payload;yt=(0,t.jsx)(cb,{issueId:n.id,payload:Q,onFallbackToProject:Q.workspace!=="project"&&!Q.projectId&&!Q.workspaceId?()=>ms({...Q,workspace:"project"}):void 0})}const fs=_e?.contentMode??"full-bleed";return(0,t.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[Je?(0,su.createPortal)(Ys,Je):(0,t.jsxs)("div",{className:"flex h-(--side-panel-header-height) shrink-0 items-center gap-1 px-2",children:[Ys,S?h?(0,t.jsx)(ne,{variant:"ghost",size:"icon",className:"size-(--sz-44px) shrink-0","aria-label":"Close side panel",onClick:S,children:(0,t.jsx)(Qa,{"aria-hidden":!0})}):(0,t.jsx)(rg,{open:!0,onToggle:S}):null]}),(0,t.jsxs)("div",{ref:Ze,"data-side-panel-content-viewport":"true",onScroll:z,role:_e?"tabpanel":void 0,id:_e?`side-panel-content-${_e.id}`:void 0,"aria-labelledby":_e?`side-panel-tab-${_e.id}`:void 0,className:ue("min-h-0 flex-1",fs==="full-bleed"?"overflow-hidden":"overflow-auto",fs!=="full-bleed"&&"scrollbar-while-scrolling",fs==="padded"&&"p-4"),children:[U.tabs.map(Q=>Q.payload.kind==="browser"?(0,t.jsx)("div",{hidden:Q.id!==U.activeTabId,className:ue("h-full min-h-0",Q.id!==U.activeTabId&&"hidden"),children:(0,t.jsx)(Cv,{active:Q.id===U.activeTabId,issueId:n.id,browser:Ue.data?.find(ke=>Q.payload.kind==="browser"&&(ke.id===Q.payload.browserId||ke.sessionId===Q.payload.browserId)),accessError:Ue.isError,onOpenActiveBrowser:St?()=>U.openTab(oo(St.id)):void 0})},Q.id):null),U.tabs.map(Q=>Q.payload.kind==="terminal"?(0,t.jsx)("div",{hidden:Q.id!==U.activeTabId,className:ue("h-full min-h-0",Q.id!==U.activeTabId&&"hidden"),children:(0,t.jsx)(mb,{issue:n,active:Q.id===U.activeTabId})},Q.id):null),fs==="prose"?(0,t.jsx)("div",{"data-side-panel-prose-content":"true",className:"mx-auto w-full max-w-4xl px-6 py-4",children:yt}):yt]})]})}a(Wc,"TaskSidePanel");var xb=new Set(["queued","running","scheduled_retry"]);async function zc(e,s={}){const n=s.getRun??vs.get,r=Date.now()+(s.timeoutMs??3e4);let i=[...new Set(e)];for(;i.length>0;){let o,u;try{o=await Promise.race([Promise.all(i.map(m=>n(m))),new Promise((m,p)=>{u=setTimeout(()=>p(new Error("Stop verification timed out")),Math.max(0,r-Date.now()))})])}catch{throw new Error("The stop was requested, but stopping could not be verified. Refresh and try Stop again if work is still running.")}finally{clearTimeout(u)}if(i=o.filter(m=>{if(xb.has(m.status))return!0;const p=m.resultJson?.executionCancellation;if(p&&typeof p=="object"&&"state"in p&&p.state!=="acknowledged")return!0;if(!("runtimeMode"in m)||m.runtimeMode!=="native"||m.status!=="cancelled")return!1;const h=m.resultJson?.nativeCancellation;return!h||typeof h!="object"||!("dispatchState"in h)||h.dispatchState!=="acknowledged"}).map(m=>m.id),i.length===0)return;if(Date.now()>=r)throw new Error("The stop was requested, but work is still stopping. Try Stop again if it continues.");await new Promise(m=>setTimeout(m,s.intervalMs??500))}}a(zc,"waitForStoppedRuns");function yb({issueId:e,attachments:s,workProducts:n,documents:r,onArrival:i}){const o=(0,l.useRef)({issueId:void 0,ids:new Set});(0,l.useEffect)(()=>{if(o.current.issueId!==e&&(o.current={issueId:e,ids:new Set}),!e)return;const u={attachments:s?.filter(hf).map(h=>`attachment:${h.id}`),workProducts:n?.map(h=>{const d=bm(h);return d?`attachment:${d.attachmentId}`:`work-product:${h.id}`}),documents:r?.filter(h=>h.key!=="plan"&&!nd(h.key)).map(h=>`document:${h.id}`)},m=o.current;let p=!1;for(const h of Object.values(u))if(h)for(const d of h)m.ids.has(d)||(p=!0),m.ids.add(d);p&&i()},[e,s,n,r,i])}a(yb,"useTaskArtifactArrival");var vb={completed:{label:"Completed",tone:"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300",description:"Task reached a terminal state."},advanced:{label:"Advanced",tone:"border-cyan-500/30 bg-cyan-500/10 text-cyan-700 dark:text-cyan-300",description:"Run produced concrete evidence of progress."},plan_only:{label:"Plan only",tone:"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300",description:"Run described future work without concrete action evidence."},empty_response:{label:"Empty response",tone:"border-orange-500/30 bg-orange-500/10 text-orange-700 dark:text-orange-300",description:"Run finished without useful output."},blocked:{label:"Blocked",tone:"border-yellow-500/30 bg-yellow-500/10 text-yellow-700 dark:text-yellow-300",description:"Run or task declared a blocker."},failed:{label:"Failed",tone:"border-red-500/30 bg-red-500/10 text-red-700 dark:text-red-300",description:"Run ended unsuccessfully."},needs_followup:{label:"Needs follow-up",tone:"border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300",description:"Run produced useful output but did not prove concrete progress."}},bb={label:"Checks after finish",tone:"border-line bg-bg text-ink-3",description:"Liveness is evaluated after the run finishes."},kb={label:"Retry pending",tone:"border-blue-500/30 bg-blue-500/10 text-blue-700 dark:text-blue-300",description:"Wardmote queued an automatic retry that has not started yet."},wb={label:"No liveness data",tone:"border-line bg-bg text-ink-3",description:"This run has no persisted liveness classification."},jb=new Set(["done","cancelled"]),Ib=new Set(["queued","running"]),po={suspicious:{label:"Output silence",tone:"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300"},critical:{label:"Critical silence",tone:"border-red-500/30 bg-red-500/10 text-red-700 dark:text-red-300"},snoozed:{label:"Silence snoozed",tone:"border-cyan-500/30 bg-cyan-500/10 text-cyan-700 dark:text-cyan-300"}};function qu(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}a(qu,"asRecord$1");function Mu(e){return typeof e=="string"&&e.trim().length>0?e.trim():null}a(Mu,"readString");function Nb(e){return typeof e=="number"&&Number.isFinite(e)?e:null}a(Nb,"readNumber");function Sb(e,s){if(!e)return null;const n=new Date(e).getTime(),r=s?new Date(s).getTime():Date.now();if(!Number.isFinite(n)||!Number.isFinite(r))return null;const i=Math.max(0,Math.round((r-n)/1e3));if(i<60)return`${i}s`;const o=Math.floor(i/60),u=i%60;if(o<60)return u>0?`${o}m ${u}s`:`${o}m`;const m=Math.floor(o/60),p=o%60;return p>0?`${m}h ${p}m`:`${m}h`}a(Sb,"formatDuration");function fo(e){return e?e instanceof Date?e.toISOString():e:null}a(fo,"toIsoString");function Hc(e){return{runId:e.id,status:e.status,agentId:e.agentId,agentName:e.agentName,adapterType:e.adapterType,startedAt:fo(e.startedAt),finishedAt:fo(e.finishedAt),createdAt:fo(e.createdAt)??new Date().toISOString(),invocationSource:e.invocationSource,usageJson:null,resultJson:null,isLive:e.status==="queued"||e.status==="running",outputSilence:e.outputSilence}}a(Hc,"liveRunToLedgerRun");function Cb(e,s,n){const r=new Map;for(const i of e)r.set(i.runId,i);for(const i of s??[]){const o=r.get(i.id);r.set(i.id,o?{...o,isLive:!0,agentName:i.agentName,outputSilence:i.outputSilence}:Hc(i))}if(n){const i=r.get(n.id);i?r.set(n.id,{...i,isLive:fr(i)||fr(n),agentName:n.agentName,outputSilence:n.outputSilence}):r.set(n.id,Hc(n))}return[...r.values()].sort((i,o)=>{const u=new Date(i.startedAt??i.createdAt).getTime(),m=new Date(o.startedAt??o.createdAt).getTime();return u!==m?m-u:o.runId.localeCompare(i.runId)})}a(Cb,"mergeRuns");function Ro(e){return e.replace(/_/g," ")}a(Ro,"statusLabel");function fr(e){return e.isLive||Ib.has(e.status)}a(fr,"isActiveRun");function Ab(e,s){const n=Pu(e,s);return e.status==="running"?`Running now by ${n}`:e.status==="queued"?`Queued for ${n}`:e.status==="scheduled_retry"?`Automatic retry scheduled for ${n}`:`${Ro(e.status)} by ${n}`}a(Ab,"runSummary");function Rb(e){return e.status==="scheduled_retry"?kb:e.livenessState?vb[e.livenessState]:fr(e)?bb:wb}a(Rb,"livenessCopyForRun");function Tb(e){const s=qu(e.resultJson),n=Mu(s?.stopReason),r=s?.timeoutFired===!0,i=Nb(s?.effectiveTimeoutSec),o=i&&i>0?`${i}s timeout`:null;return r||n==="timeout"?o?`timeout (${o})`:"timeout":n==="max_turns_exhausted"||n==="turn_limit_exhausted"?"max turns exhausted":n==="budget_paused"?"budget paused":n==="cancelled"?"cancelled":n==="paused"?"paused by board":n==="process_lost"?"process lost":n==="unmanaged_background_task_stopped"?"unmanaged background task stopped":n==="adapter_failed"?"adapter failed":n==="completed"?o?`completed (${o})`:"completed":o}a(Tb,"stopReasonLabel");function Eb(e,s){return s||(e.status==="scheduled_retry"?"Retry pending":e.status==="queued"?"Waiting to start":e.status==="running"?"Still running":e.livenessState?"No stop reason":"Unavailable")}a(Eb,"stopStatusLabel");function _b(e){return e.status==="scheduled_retry"?"Waiting for next attempt":e.lastUsefulActionAt?hr(e.lastUsefulActionAt):fr(e)?"No action recorded yet":e.livenessState==="plan_only"||e.livenessState==="needs_followup"?"No concrete action":e.livenessState==="empty_response"?"No useful output":e.livenessState?"None recorded":"Unavailable"}a(_b,"lastUsefulActionLabel");function qb(e){return!e.continuationAttempt||e.continuationAttempt<=0?null:`Continuation attempt ${e.continuationAttempt}`}a(qb,"continuationLabel");function Mb(e){return/continuation attempts exhausted/i.test(e.livenessReason??"")}a(Mb,"hasExhaustedContinuation");function Pb(e){return{active:e.filter(s=>!jb.has(s.status)),done:e.filter(s=>s.status==="done").length,cancelled:e.filter(s=>s.status==="cancelled").length,total:e.length}}a(Pb,"childIssueSummary");function Pu(e,s){return e.agentName??s.get(e.agentId)?.name??e.agentId.slice(0,8)}a(Pu,"compactAgentName");function Fb(e){if(!e||e<=0)return null;const s=Math.floor(e/6e4);if(s<1)return"under 1 minute";if(s<60)return`${s} minute${s===1?"":"s"}`;const n=Math.floor(s/60),r=s%60;return r===0?`${n} hour${n===1?"":"s"}`:`${n}h ${r}m`}a(Fb,"formatSilenceAge");function Db(e,s){if(!s)return!1;if(s.source==="local_implicit"||s.isInstanceAdmin)return!0;const n=s.memberships?.find(r=>r.companyId===e&&r.status==="active");return n?n.membershipRole!=="viewer"&&n.membershipRole!==null:s.companyIds.includes(e)&&!s.memberships}a(Db,"canBoardRecordWatchdogDecision");function $b(e){return e instanceof Hs&&e.status===403?"Only the board or the assigned recovery owner can record watchdog decisions":e instanceof Error&&e.message.trim().length>0?e.message:"Wardmote could not record the watchdog decision."}a($b,"watchdogDecisionErrorMessage");function Lb({issueId:e,companyId:s,issueStatus:n,childIssues:r,agentMap:i,hasLiveRuns:o,activityEvents:u,renderActivityEvent:m,resolveUserLabel:p}){const h=ks(),{pushToast:d}=ya(),[v,k]=(0,l.useState)(null),{data:N}=ye({queryKey:R.access.currentBoardAccess,queryFn:a(()=>mr.getCurrentBoardAccess(),"queryFn"),retry:!1}),{data:A}=ye({queryKey:R.issues.runs(e),queryFn:a(()=>zn.runsForIssue(e),"queryFn"),refetchInterval:o||n==="in_progress"?5e3:!1,placeholderData:Kt(e)}),{data:E}=ye({queryKey:R.issues.liveRuns(e),queryFn:a(()=>vs.liveRunsForIssue(e),"queryFn"),enabled:o,refetchInterval:3e3,placeholderData:Kt(e)}),{data:_=null}=ye({queryKey:R.issues.activeRun(e),queryFn:a(()=>vs.activeRunForIssue(e),"queryFn"),enabled:o||n==="in_progress",refetchInterval:o?!1:3e3,placeholderData:Kt(e)}),q=(0,l.useMemo)(()=>(A??[]).slice(0,100).map(j=>j.runId),[A]),O=N?.source==="local_implicit"||N?.isInstanceAdmin===!0,{data:F}=ye({queryKey:R.providerTraceMetadata(s,q),queryFn:a(()=>vs.providerTraceMetadata(s,q),"queryFn"),enabled:O&&q.length>0,retry:!1}),C=(0,l.useMemo)(()=>new Map((F??[]).map(j=>[j.runId,j])),[F]),S=Pe({mutationFn:a(j=>vs.recordWatchdogDecision(j),"mutationFn"),onMutate:a(()=>{k(null)},"onMutate"),onSuccess:a(()=>{k(null),h.invalidateQueries({queryKey:R.issues.activeRun(e)}),h.invalidateQueries({queryKey:R.issues.liveRuns(e)})},"onSuccess"),onError:a(j=>{const f=$b(j),w=j instanceof Hs?String(j.status):"error";k(f),d({title:"Watchdog decision not recorded",body:f,tone:"error",dedupeKey:`watchdog-decision:${e}:${w}`})},"onError")}),P=Pe({mutationFn:a(async j=>{const f=qu(j.contextSnapshot),w={};for(const M of["issueId","taskId","taskKey"]){const $=Mu(f?.[M]);$&&(w[M]=$)}const W=await ga.wakeup(j.agentId,{source:"on_demand",triggerDetail:"manual",reason:"rerun_with_provider_trace",payload:w,debug:{providerTrace:"raw"}},s);if(!("id"in W))throw new Error(W.message??"Trace re-run was skipped.");return W},"mutationFn"),onSuccess:a(()=>{h.invalidateQueries({queryKey:R.issues.runs(e)}),h.invalidateQueries({queryKey:R.issues.liveRuns(e)})},"onSuccess"),onError:a(j=>d({title:"Trace re-run not started",body:j instanceof Error?j.message:"Wardmote could not start the trace re-run.",tone:"error",dedupeKey:`provider-trace-rerun:${e}`}),"onError")});return(0,t.jsx)(Bb,{runs:A??[],liveRuns:E,activeRun:_,issueStatus:n,childIssues:r,agentMap:i,activityEvents:u,renderActivityEvent:m,resolveUserLabel:p,pendingWatchdogDecision:S.variables?.decision??null,canRecordWatchdogDecisions:Db(s,N),watchdogDecisionError:v,onWatchdogDecision:a(j=>S.mutate(j),"onWatchdogDecision"),onRerunWithTrace:O?j=>P.mutate(j):void 0,providerTraceMetadata:C})}a(Lb,"IssueRunLedger");function Bb({runs:e,liveRuns:s,activeRun:n,issueStatus:r,childIssues:i,agentMap:o,activityEvents:u,renderActivityEvent:m,resolveUserLabel:p,pendingWatchdogDecision:h,canRecordWatchdogDecisions:d=!0,watchdogDecisionError:v,onWatchdogDecision:k,onRerunWithTrace:N,providerTraceMetadata:A=new Map}){const[E,_]=(0,l.useState)(null),q=(0,l.useMemo)(()=>Cb(e,s,n),[n,s,e]);(0,l.useEffect)(()=>{if(E||typeof window>"u")return;const j=new URLSearchParams(window.location.search).get("inspectRun");if(!j)return;const f=q.find(w=>w.runId===j);f&&_(f)},[E,q]);const O=q[0]??null,F=(0,l.useMemo)(()=>q.find(j=>fr(j)&&(j.outputSilence?.level==="critical"||j.outputSilence?.level==="suspicious"))??null,[q]),C=Pb(i),S=!!m,P=(0,l.useMemo)(()=>{const j=[];for(const f of q)j.push({kind:"run",id:f.runId,timestamp:f.startedAt??f.createdAt,run:f});if(S)for(const f of u??[])j.push({kind:"activity",id:f.id,timestamp:f.createdAt instanceof Date?f.createdAt.toISOString():String(f.createdAt),event:f});return j.sort((f,w)=>{const W=new Date(f.timestamp).getTime(),M=new Date(w.timestamp).getTime();return W!==M?M-W:f.kind!==w.kind?f.kind==="run"?-1:1:w.id.localeCompare(f.id)})},[u,S,q]);return(0,t.jsxs)("section",{className:"space-y-3","aria-label":"Task run ledger",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-ink-3",children:"Run ledger"}),(0,t.jsx)("p",{className:"text-xs text-ink-3",children:O?Ab(O,o):r==="in_progress"?"Waiting for the first run record.":"No runs linked yet."})]}),O?(0,t.jsx)(ls,{to:`/agents/${O.agentId}/runs/${O.runId}`,className:"shrink-0 rounded-md border border-line px-2 py-1 text-xs text-ink-3 hover:text-ink",children:"Latest run"}):null]}),C.total>0?(0,t.jsxs)("div",{className:"rounded-md border border-line/70 px-3 py-2",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[(0,t.jsx)("span",{className:"font-medium text-ink",children:"Child work"}),(0,t.jsx)("span",{className:"text-ink-3",children:C.active.length>0?`${C.active.length} active, ${C.done} done, ${C.cancelled} cancelled`:`all ${C.total} terminal (${C.done} done, ${C.cancelled} cancelled)`})]}),C.active.length>0?(0,t.jsxs)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[C.active.slice(0,4).map(j=>(0,t.jsxs)(ls,{to:`/issues/${j.identifier??j.id}`,className:"inline-flex min-w-0 max-w-full items-center gap-1 rounded-md border border-line bg-bg px-2 py-1 text-(length:--text-micro) hover:bg-bg-3/40",children:[(0,t.jsx)("span",{className:"shrink-0 font-mono text-ink-3",children:j.identifier??j.id.slice(0,8)}),(0,t.jsx)("span",{className:"truncate",children:j.title}),(0,t.jsx)("span",{className:"shrink-0 text-ink-3",children:Ro(j.status)})]},j.id)),C.active.length>4?(0,t.jsxs)("span",{className:"rounded-md border border-line px-2 py-1 text-(length:--text-micro) text-ink-3",children:["+",C.active.length-4," more"]}):null]}):null]}):null,F?.outputSilence?(0,t.jsxs)("div",{className:ue("rounded-md border px-3 py-2 text-xs",F.outputSilence.level==="critical"?"border-red-500/30 bg-red-500/10 text-red-900 dark:text-red-200":"border-amber-500/30 bg-amber-500/10 text-amber-900 dark:text-amber-200"),children:[(0,t.jsx)("p",{className:"font-medium",children:F.outputSilence.level==="critical"?"Critical output silence":"Output silence watchdog warning"}),(0,t.jsxs)("p",{className:"mt-1",children:["Latest active run has been silent for"," ",Fb(F.outputSilence.silenceAgeMs)??"an extended period",".",F.outputSilence.evaluationIssueIdentifier?(0,t.jsxs)(t.Fragment,{children:[" ","Review"," ",(0,t.jsx)(ls,{to:`/issues/${F.outputSilence.evaluationIssueIdentifier}`,className:"font-medium underline underline-offset-2",children:F.outputSilence.evaluationIssueIdentifier})," ","for recovery context."]}):null]}),(0,t.jsx)("p",{className:"mt-1",children:F.outputSilence.evaluationIssueIdentifier?"This signal is informational. Wardmote did not create new delegated recovery work.":"This signal is informational. Wardmote did not create or assign a recovery task."}),k&&d?(0,t.jsxs)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[(0,t.jsx)("button",{type:"button",className:"rounded-md border border-line bg-bg/80 px-2 py-1 text-(length:--text-micro) text-ink hover:bg-bg",onClick:a(()=>k({runId:F.runId,decision:"continue",evaluationIssueId:F.outputSilence?.evaluationIssueId??null}),"onClick"),disabled:h!=null,children:"Continue monitoring"}),(0,t.jsx)("button",{type:"button",className:"rounded-md border border-line bg-bg/80 px-2 py-1 text-(length:--text-micro) text-ink hover:bg-bg",onClick:a(()=>k({runId:F.runId,decision:"snooze",evaluationIssueId:F.outputSilence?.evaluationIssueId??null,snoozedUntil:new Date(Date.now()+36e5).toISOString(),reason:"Snoozed from issue run ledger"}),"onClick"),disabled:h!=null,children:"Snooze 1h"}),(0,t.jsx)("button",{type:"button",className:"rounded-md border border-line bg-bg/80 px-2 py-1 text-(length:--text-micro) text-ink hover:bg-bg",onClick:a(()=>k({runId:F.runId,decision:"dismissed_false_positive",evaluationIssueId:F.outputSilence?.evaluationIssueId??null,reason:"Dismissed from issue run ledger"}),"onClick"),disabled:h!=null,children:"Mark false positive"})]}):null,v?(0,t.jsx)("p",{className:"mt-2 rounded-md border border-red-500/30 bg-red-500/10 px-2 py-1 text-(length:--text-micro) text-red-900 dark:text-red-200",children:v}):null]}):null,P.length===0?(0,t.jsx)("div",{className:"rounded-md border border-dashed border-line px-3 py-3 text-sm text-ink-3",children:m?"Runs and activity will appear here once this task has history.":"Historical runs without liveness metadata will appear here once linked to this task."}):(0,t.jsxs)("div",{className:"space-y-1.5",children:[P.slice(0,20).map(j=>{if(j.kind==="activity")return(0,t.jsx)("div",{children:m?.(j.event)},`activity:${j.id}`);const f=j.run,w=Rb(f),W=Tb(f),M=Sb(f.startedAt,f.finishedAt),$=Mb(f),K=qb(f),le=gx(f),y=Pu(f,o),z=f.responsibleUserId?Om(p?.(f.responsibleUserId)):null,se=Bm(f.errorCode)?f.errorCode:null,de=Pp(f.resultJson);return(0,t.jsxs)("article",{className:"space-y-1.5 rounded-lg border border-line/60 px-3 py-2 text-xs text-ink-3",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,t.jsx)("span",{className:"font-medium text-ink",children:"Run"}),(0,t.jsx)(ls,{to:`/agents/${f.agentId}/runs/${f.runId}`,className:"min-w-0 max-w-full truncate font-mono text-ink hover:underline",children:f.runId.slice(0,8)}),(0,t.jsxs)("span",{children:["by ",y]}),z?(0,t.jsxs)("span",{"data-testid":"run-on-behalf-of",className:"min-w-0 max-w-full truncate text-ink-3",title:`Acting on behalf of ${z}`,children:["on behalf of"," ",(0,t.jsx)("span",{className:"text-ink",children:z})]}):null,(0,t.jsx)("span",{className:"rounded-md border border-line px-1.5 py-0.5 text-(length:--text-micro) capitalize text-ink-3",children:Ro(f.status)}),f.isLive?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-md border border-blue-500/30 bg-blue-500/10 px-1.5 py-0.5 text-(length:--text-micro) text-blue-700 dark:text-blue-300",children:[(0,t.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-blue-500"}),"live"]}):null,(0,t.jsx)(Dp,{trace:A.get(f.runId),requested:$p(f.contextSnapshot),showOff:!0}),(0,t.jsx)("span",{className:ue("rounded-md border px-1.5 py-0.5 text-(length:--text-micro) font-medium",w.tone),title:w.description,children:w.label}),$?(0,t.jsx)("span",{className:"rounded-md border border-red-500/30 bg-red-500/10 px-1.5 py-0.5 text-(length:--text-micro) font-medium text-red-700 dark:text-red-300",children:"Exhausted"}):null,K?(0,t.jsx)("span",{className:"text-(length:--text-micro) text-ink-3",children:K}):null,le?(0,t.jsx)("span",{className:ue("rounded-md border px-1.5 py-0.5 text-(length:--text-micro) font-medium",le.tone),children:le.badgeLabel}):null,f.outputSilence&&po[f.outputSilence.level]?(0,t.jsx)("span",{className:ue("rounded-md border px-1.5 py-0.5 text-(length:--text-micro) font-medium",po[f.outputSilence.level]?.tone),children:po[f.outputSilence.level]?.label}):null,de?(0,t.jsx)(Mp,{}):null,(0,t.jsx)("span",{className:"ml-auto shrink-0",children:hr(j.timestamp)}),(0,t.jsx)("button",{type:"button",className:"rounded-md border border-line px-1.5 py-0.5 text-(length:--text-micro) text-ink hover:bg-bg-3/40",onClick:a(()=>_(f),"onClick"),children:"Inspect run"})]}),(0,t.jsxs)("div",{className:"grid gap-2 text-xs text-ink-3 sm:grid-cols-3",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("span",{className:"text-ink",children:"Elapsed"})," ",M??"unknown"]}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("span",{className:"text-ink",children:"Last useful action"})," ",_b(f)]}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("span",{className:"text-ink",children:"Stop"})," ",Eb(f,W)]})]}),le?(0,t.jsxs)("div",{className:"rounded-md border border-line/70 bg-bg-3/20 px-2 py-2 text-xs leading-5 text-ink-3",children:[le.detail?(0,t.jsx)("p",{children:le.detail}):null,le.secondary?(0,t.jsx)("p",{children:le.secondary}):null,le.retryOfRunId?(0,t.jsxs)("p",{children:["Retry of"," ",(0,t.jsx)(ls,{to:`/agents/${f.agentId}/runs/${le.retryOfRunId}`,className:"font-mono text-ink hover:underline",children:le.retryOfRunId.slice(0,8)})]}):null]}):null,f.livenessReason?(0,t.jsx)("p",{className:"min-w-0 break-words text-xs leading-5 text-ink-3",children:f.livenessReason}):null,se?(0,t.jsx)(qx,{code:se,userName:f.responsibleUserId?p?.(f.responsibleUserId):null}):null,f.nextAction?(0,t.jsxs)("div",{className:"min-w-0 rounded-md bg-bg-3/40 px-2 py-1.5 text-xs leading-5",children:[(0,t.jsxs)("span",{className:"font-medium text-ink",children:["Next action:"," "]}),(0,t.jsx)("span",{className:"break-words text-ink-3",children:f.nextAction})]}):null]},`run:${f.runId}`)}),P.length>20?(0,t.jsxs)("div",{className:"px-3 py-2 text-xs text-ink-3",children:[P.length-20," older items not shown"]}):null]}),E?(0,t.jsx)(Fp,{runId:E.runId,run:E,open:!0,onOpenChange:a(j=>{j||_(null)},"onOpenChange"),onRerunWithTrace:!["queued","running"].includes(E.status)&&N?()=>N(E):void 0}):null]})}a(Bb,"IssueRunLedgerContent");function Ob(e,s){return e?JSON.stringify({id:e.id,status:e.status,priority:e.priority,assigneeAgentId:e.assigneeAgentId,assigneeUserId:e.assigneeUserId,projectId:e.projectId,projectWorkspaceId:e.projectWorkspaceId,parentId:e.parentId,createdByUserId:e.createdByUserId,hiddenAt:e.hiddenAt,labelIds:e.labelIds??[],executionWorkspaceId:e.executionWorkspaceId,executionWorkspacePreference:e.executionWorkspacePreference,executionWorkspaceSettings:e.executionWorkspaceSettings??null,currentExecutionWorkspace:e.currentExecutionWorkspace?{id:e.currentExecutionWorkspace.id,mode:e.currentExecutionWorkspace.mode,status:e.currentExecutionWorkspace.status,projectWorkspaceId:e.currentExecutionWorkspace.projectWorkspaceId,branchName:e.currentExecutionWorkspace.branchName,cwd:e.currentExecutionWorkspace.cwd,runtimeServices:(e.currentExecutionWorkspace.runtimeServices??[]).map(n=>({id:n.id,status:n.status,url:n.url}))}:null,executionPolicy:e.executionPolicy??null,executionState:e.executionState?{status:e.executionState.status,currentStageType:e.executionState.currentStageType,currentParticipant:e.executionState.currentParticipant,returnAssignee:e.executionState.returnAssignee}:null,blocks:(e.blocks??[]).map(n=>({id:n.id,identifier:n.identifier??null,title:n.title,status:n.status})),blockedBy:(e.blockedBy??[]).map(n=>({id:n.id,identifier:n.identifier??null,title:n.title,status:n.status})),watchdog:e.watchdog?{id:e.watchdog.id,watchdogAgentId:e.watchdog.watchdogAgentId,instructions:e.watchdog.instructions??null,status:e.watchdog.status,watchdogIssueId:e.watchdog.watchdogIssueId??null}:null,scheduledRetry:e.scheduledRetry?{runId:e.scheduledRetry.runId,status:e.scheduledRetry.status,scheduledRetryAt:e.scheduledRetry.scheduledRetryAt?String(e.scheduledRetry.scheduledRetryAt):null,scheduledRetryAttempt:e.scheduledRetry.scheduledRetryAttempt}:null,parentSummary:e.ancestors?.[0]?{id:e.ancestors[0].id,identifier:e.ancestors[0].identifier??null,title:e.ancestors[0].title}:null,childIssues:s.map(n=>({id:n.id,updatedAt:String(n.updatedAt),identifier:n.identifier??null,title:n.title}))}):""}a(Ob,"buildIssuePropertiesPanelKey");function To(e){const s=Qm(e);if(!s)return null;if(s.documentKey==="continuation-summary")return{kind:"continuation-summary"};const n=s.viewer==="full";return s.documentKey==="plan"?{kind:"properties-pane",tab:"plans",documentKey:"plan",maximize:n}:{kind:"properties-pane",tab:"document",documentKey:s.documentKey,maximize:n}}a(To,"resolveIssueDocumentDeepLink");function Kb(e,s,n){let r;try{r=new URL(e,s)}catch{return null}if(r.origin!==s.origin||r.search!==s.search||!To(r.hash))return null;if(r.pathname===s.pathname)return r.hash;const i=/^(?:\/([^/]+))?\/issues\/([^/]+)\/?$/,o=s.pathname.match(i),u=r.pathname.match(i);if(!o||!u||u[1]&&u[1]!==o[1])return null;try{const m=decodeURIComponent(u[2]).toLowerCase();return n.some(p=>p.toLowerCase()===m)?r.hash:null}catch{return null}}a(Kb,"sameIssueDocumentHash");var Ub={owner:{label:"task owner",icon:mi,className:"border-line bg-bg-3 text-ink-3"},explicit:{label:"shared directly",icon:Bd,className:"border-accent/30 bg-accent/10 text-accent"},assignment:{label:"via assignment",icon:Wn,className:"border-line bg-bg-3 text-ink"},project:{label:"via project",icon:Tm,className:"border-line bg-bg-3 text-ink"}};function Qb({source:e}){const s=Ub[e],n=s.icon;return(0,t.jsxs)("span",{"data-testid":`grant-source-badge-${e}`,"data-source":e,className:ue("inline-flex shrink-0 items-center gap-1 rounded-md border px-1.5 py-0.5 text-(length:--text-nano) font-medium leading-tight",s.className),children:[(0,t.jsx)(n,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),s.label]})}a(Qb,"SourceBadge");function Vc({displayName:e,avatarUrl:s,initials:n}){return(0,t.jsxs)(bo,{size:"sm",className:"mt-0.5","aria-hidden":"true",children:[s?(0,t.jsx)(yo,{src:s,alt:""}):null,(0,t.jsx)(vo,{children:n??e.slice(0,2).toUpperCase()})]})}a(Vc,"PrincipalAvatar");function Gc({avatar:e,title:s,subtitle:n,badge:r,action:i}){return(0,t.jsxs)("div",{className:"flex items-start gap-2.5 py-2",children:[e,(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,t.jsx)("span",{className:"truncate text-sm font-medium",children:s}),r]}),n?(0,t.jsx)("div",{className:"truncate text-xs text-ink-3",children:n}):null]}),i?(0,t.jsx)("div",{className:"shrink-0 self-center",children:i}):null]})}a(Gc,"RowShell");function Wb({issueId:e,companyId:s,canManage:n,open:r,onOpenChange:i,aclDescription:o="Sharing grants access to this task and its descendants, including comments, documents, and run history. Parents and siblings need separate access.",implicitPrincipals:u=[],initialView:m="list",initialAddSelection:p=""}){const h=ks(),{pushToast:d}=ya(),[v,k]=(0,l.useState)(m),[N,A]=(0,l.useState)(p),[E,_]=(0,l.useState)(null),q=ye({queryKey:R.issues.accessGrants(e),queryFn:a(()=>xe.listAccessGrants(e),"queryFn"),enabled:r}),O=ye({queryKey:R.access.companyUserDirectory(s),queryFn:a(()=>mr.listUserDirectory(s),"queryFn"),enabled:r&&v==="add"&&n}),F=ye({queryKey:R.agents.list(s),queryFn:a(()=>ga.list(s),"queryFn"),enabled:r&&v==="add"&&n}),C=(0,l.useMemo)(()=>(q.data??[]).filter(y=>y.revokedAt===null),[q.data]),S=(0,l.useMemo)(()=>new Set(C.filter(y=>!y.inherited&&y.source!=="project").map(y=>`${y.subjectType}:${y.subjectId}`)),[C]),P=Pe({mutationFn:a(y=>xe.createAccessGrant(e,y),"mutationFn"),onSuccess:a(()=>{h.invalidateQueries({queryKey:["issues"]}),A(""),k("list"),d({title:"Access granted",tone:"success"})},"onSuccess"),onError:a(y=>{d({title:"Couldn't add access",body:y.message,tone:"error"})},"onError")}),j=Pe({mutationFn:a(y=>xe.revokeAccessGrant(e,y.id),"mutationFn"),onSuccess:a(()=>{h.invalidateQueries({queryKey:["issues"]}),_(null),d({title:"Access revoked",tone:"success"})},"onSuccess"),onError:a(y=>{d({title:"Couldn't revoke access",body:y.message,tone:"error"})},"onError")}),f=(0,l.useMemo)(()=>{const y=(O.data?.users??[]).filter(de=>de.user&&!S.has(`user:${de.user.id}`)).map(de=>({key:`user:${de.user.id}`,value:`user:${de.user.id}`,label:de.user.name??de.user.email??"Unknown user",searchText:[de.user.name,de.user.email].filter(Boolean).join(" "),identity:(0,t.jsx)(Vr,{name:de.user.name??de.user.email??"Unknown user",avatarUrl:de.user.image,size:"sm"})})),z=(F.data??[]).filter(de=>!S.has(`agent:${de.id}`)).map(de=>({key:`agent:${de.id}`,value:`agent:${de.id}`,label:de.name,searchText:de.name,identity:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ur,{agent:de,size:24}),(0,t.jsx)("span",{className:"truncate",children:de.name})]})})),se=[];return y.length>0&&se.push({id:"people",label:"People",options:y}),z.length>0&&se.push({id:"agents",label:"Agents",options:z}),se},[O.data,F.data,S]),w=(0,l.useMemo)(()=>{if(!N.startsWith("agent:"))return null;const y=N.slice(6),z=(F.data??[]).find(se=>se.id===y);return z&&_g(Eg(z.permissions))?z.name:null},[N,F.data]);function W(y){y||(k("list"),A(""),_(null)),i(y)}a(W,"resetAndClose");function M(){if(!N)return;const[y,z]=N.split(/:(.+)/);z&&P.mutate({subjectType:y,subjectId:z})}a(M,"submitAdd");const $=q.isLoading,K=q.isError,le=!$&&!K&&C.length===0&&u.length===0;return(0,t.jsxs)(Vo,{open:r,onOpenChange:W,children:[(0,t.jsxs)(Wo,{className:"sm:max-w-md",children:[(0,t.jsxs)(Qo,{children:[(0,t.jsxs)(Ho,{className:"flex items-center gap-2",children:[(0,t.jsx)(mi,{className:"h-4 w-4 shrink-0 text-ink-3","aria-hidden":"true"}),"Who can access this task"]}),(0,t.jsx)(zo,{children:o})]}),v==="list"?(0,t.jsxs)("div",{className:"space-y-1",children:[$?(0,t.jsx)("div",{className:"space-y-2 py-1","data-testid":"share-sheet-loading",children:[0,1,2].map(y=>(0,t.jsxs)("div",{className:"flex items-center gap-2.5 py-1",children:[(0,t.jsx)(jt,{className:"h-6 w-6 rounded-full"}),(0,t.jsxs)("div",{className:"flex-1 space-y-1.5",children:[(0,t.jsx)(jt,{className:"h-3 w-32"}),(0,t.jsx)(jt,{className:"h-2.5 w-20"})]})]},y))}):K?(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-md border border-bad/30 bg-bad/5 px-3 py-2 text-sm text-bad","data-testid":"share-sheet-error",children:[(0,t.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(nn,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),"Couldn't load access."]}),(0,t.jsxs)(ne,{variant:"ghost",size:"sm",onClick:a(()=>q.refetch(),"onClick"),children:[(0,t.jsx)(Ff,{className:"h-3.5 w-3.5","aria-hidden":"true"})," Retry"]})]}):le?(0,t.jsx)("p",{className:"py-3 text-sm text-ink-3","data-testid":"share-sheet-empty",children:"Only you can see this task."}):(0,t.jsxs)("div",{className:"divide-y divide-line/60",children:[u.filter(y=>!C.some(z=>z.subjectId===y.id||`${z.subjectType}:${z.subjectId}`===y.id)).map(y=>(0,t.jsx)(Gc,{avatar:(0,t.jsx)(Vc,{displayName:y.displayName,avatarUrl:y.avatarUrl,initials:y.initials}),title:y.displayName,subtitle:y.subtitle??void 0,badge:(0,t.jsx)("span",{className:"inline-flex shrink-0 items-center rounded-md border border-line bg-bg-3/50 px-1.5 py-0.5 text-(length:--text-nano) font-medium text-ink-3",children:y.roleLabel})},`implicit:${y.id}`)),C.map(y=>{const z=y.subjectDisplayName??"Unknown",se=u.find(oe=>oe.id===`${y.subjectType}:${y.subjectId}`),de=n&&!y.inherited&&Tg(y.source),me=y.source==="explicit"?"Shared":"Granted";return(0,t.jsx)(Gc,{avatar:(0,t.jsx)(Vc,{displayName:z,avatarUrl:y.subjectAvatarUrl,initials:y.subjectInitials}),title:z,subtitle:se?`${se.roleLabel} — access remains while this role applies`:y.inherited?"Inherited access — managed at its source":`${me} ${vp(y.createdAt)}`,badge:(0,t.jsx)(Qb,{source:y.source}),action:de?(0,t.jsx)(ne,{variant:"ghost",size:"sm",onClick:a(()=>_(y),"onClick"),children:se?"Remove saved grant":"Revoke"}):y.source==="project"?(0,t.jsx)("span",{className:"text-(length:--text-nano) text-ink-3",children:"project-managed"}):null},y.id)})]}),n?(0,t.jsx)("div",{className:"pt-2",children:(0,t.jsxs)(ne,{variant:"secondary",size:"sm",className:"w-full",onClick:a(()=>k("add"),"onClick"),disabled:$,children:[(0,t.jsx)(Bd,{className:"h-3.5 w-3.5","aria-hidden":"true"})," Add someone"]})}):null]}):(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(qp,{value:N,groups:f,renderValue:a(y=>y?Ql(y):"Choose a person or agent…","renderValue"),renderOption:Ql,onValueChange:a(y=>A(y),"onValueChange"),placeholder:"Choose a person or agent…",searchPlaceholder:"Search people and agents…",loading:O.isLoading||F.isLoading,loadingMessage:"Loading directory…",emptyMessage:"No one left to add.",triggerClassName:"w-full"}),w?(0,t.jsxs)("div",{role:"note","aria-label":"Shared agent caution","data-testid":"shared-agent-caution",className:"flex items-start gap-2 rounded-md border border-line bg-bg-3 px-3 py-2 text-xs leading-relaxed text-ink",children:[(0,t.jsx)(nn,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),(0,t.jsxs)("span",{children:[(0,t.jsx)("span",{className:"font-semibold",children:"Shared agent."})," ",w,"'s memory & workspace may carry residual private context from this task into its later runs for other people. Grant only if that's acceptable."]})]}):null,(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 pt-1",children:[(0,t.jsx)(ne,{variant:"ghost",size:"sm",onClick:a(()=>{k("list"),A("")},"onClick"),children:"Back"}),(0,t.jsx)(ne,{size:"sm",onClick:M,disabled:!N||P.isPending,children:P.isPending?"Adding…":"Add"})]})]})]}),(0,t.jsx)(ki,{open:E!==null,onOpenChange:a(y=>{y||_(null)},"onOpenChange"),children:(0,t.jsxs)(xi,{children:[(0,t.jsxs)(bi,{children:[(0,t.jsxs)(gi,{children:["Remove ",E?.subjectDisplayName??"this subject","'s saved grant?"]}),(0,t.jsxs)(hi,{children:["This removes this grant and the access it supplies to this task's descendants. Ownership, current assignment, project membership, inherited access, or another grant can still provide access. Revoking access does ",(0,t.jsx)("span",{className:"font-semibold",children:"not"})," erase content already seen or retained in an agent's memory."]})]}),(0,t.jsxs)(yi,{children:[(0,t.jsx)(vi,{children:"Cancel"}),(0,t.jsx)(_o,{className:"bg-bad text-accent-ink hover:bg-bad/90",onClick:a(y=>{y.preventDefault(),E&&j.mutate(E)},"onClick"),disabled:j.isPending,children:j.isPending?"Removing…":"Remove grant"})]})]})})]})}a(Wb,"IssueShareSheet");var zr="flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-bg-3/50 disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent",zb="Only the task owner or an admin can change who can see this task.";function Hb({issue:e,companyId:s,canManage:n,closeMenu:r,implicitPrincipals:i=[],children:o}){const u=ks(),{pushToast:m}=ya(),[p,h]=(0,l.useState)(!1),[d,v]=(0,l.useState)(!1),k=e.visibility==="private",N=ye({queryKey:[...R.issues.privacyConstraints(e.id),e.privacyParentIssueId??null,e.projectId??null],queryFn:a(()=>xe.privacyConstraints(e.id),"queryFn"),enabled:n&&k}),A=N.isError?"Couldn't check task privacy. Retry before making this task public.":!N.data||N.isFetching?"Checking task privacy…":N.data.publicBlockedBy==="parent"?"Move this task out of its private parent before making it public.":N.data.publicBlockedBy==="project"?"Move this task out of its private project before making it public.":null,E=Pe({mutationFn:a(q=>xe.setVisibility(e.id,q),"mutationFn"),onSuccess:a((q,O)=>{u.invalidateQueries({queryKey:["issues"]}),u.invalidateQueries({queryKey:R.projects.all(s)}),e.identifier&&u.invalidateQueries({queryKey:R.issues.detail(e.identifier)}),u.invalidateQueries({queryKey:R.issues.accessGrants(e.id)}),v(!1),m({title:O==="private"?"Task is now private":"Task is now public",tone:"success"})},"onSuccess"),onError:a(q=>{m({title:"Couldn't change visibility",body:q.message,tone:"error"})},"onError")});function _(q,O){return n&&!O?q:(0,t.jsxs)(Uo,{children:[(0,t.jsx)(Oo,{asChild:!0,children:(0,t.jsx)("span",{className:"block w-full",tabIndex:0,children:q})}),(0,t.jsx)(Ko,{className:"max-w-xs text-xs",children:n?O:zb})]})}return a(_,"withTooltip"),(0,t.jsxs)(Ld,{children:[o(k?(0,t.jsxs)(t.Fragment,{children:[_((0,t.jsxs)("button",{type:"button",className:zr,disabled:!n,onClick:a(()=>{r(),h(!0)},"onClick"),children:[(0,t.jsx)(Yf,{className:"h-4 w-4","aria-hidden":"true"})," Share…"]})),_((0,t.jsxs)("button",{type:"button",className:ue(zr,"text-bad"),disabled:!n||!!A,onClick:a(()=>{r(),v(!0)},"onClick"),children:[(0,t.jsx)(pi,{className:"h-4 w-4","aria-hidden":"true"})," Make public"]}),A),n&&N.isError?(0,t.jsx)("button",{type:"button",className:zr,onClick:a(()=>{N.refetch()},"onClick"),children:"Retry access check"}):null]}):_((0,t.jsxs)("button",{type:"button",className:zr,disabled:!n||E.isPending,onClick:a(()=>{r(),E.mutate("private")},"onClick"),children:[(0,t.jsx)(mi,{className:"h-4 w-4","aria-hidden":"true"})," Make private"]}))),(0,t.jsx)(Wb,{issueId:e.id,companyId:s,canManage:n,open:p,onOpenChange:h,implicitPrincipals:i}),(0,t.jsx)(ki,{open:d,onOpenChange:v,children:(0,t.jsxs)(xi,{children:[(0,t.jsxs)(bi,{children:[(0,t.jsx)(gi,{children:"Make this task public?"}),(0,t.jsxs)(hi,{children:["Everyone in the company will be able to read this task, its comments, documents, and run history. Existing private subtasks keep their privacy."," ",N.data?.leavesPersonalProject?"This task will also leave its personal project. ":null,(0,t.jsx)("span",{className:"font-semibold text-ink",children:"Content already seen by others cannot be taken back."})]})]}),(0,t.jsxs)(yi,{children:[(0,t.jsx)(vi,{children:"Keep private"}),(0,t.jsx)(_o,{className:"bg-bad text-accent-ink hover:bg-bad/90",onClick:a(q=>{q.preventDefault(),E.mutate("open")},"onClick"),disabled:E.isPending||!!A,children:E.isPending?"Making public…":"Make public"})]})]})})]})}a(Hb,"IssuePrivacyActions");var lI=ym({IssueDetail:a(()=>hk,"IssueDetail"),TaskDetailSurface:a(()=>Lu,"TaskDetailSurface"),canBoardManageRuntime:a(()=>pd,"canBoardManageRuntime"),canBoardResolveRecoveryAction:a(()=>Fu,"canBoardResolveRecoveryAction"),readRecoveryReconcileWorkspaceId:a(()=>md,"readRecoveryReconcileWorkspaceId"),shouldScrollIssueDetailToTopOnNavigation:a(()=>Du,"shouldScrollIssueDetailToTopOnNavigation")}),Yc=[];function Vb(e){const s=e instanceof Error?`Run was stopped, but updating the task failed: ${e.message}`:"Run was stopped, but updating the task failed. Retry the task status update.",n=new Error(s);return n.runCancelledBeforeStatusUpdateFailed=!0,n}a(Vb,"createRunCancelledStatusUpdateError");function Gb(e){return e instanceof Error&&e.runCancelledBeforeStatusUpdateFailed===!0}a(Gb,"didRunCancelBeforeStatusUpdateFail");function Jc(e){return e.kind==="request_confirmation"&&e.payload.target?.type==="issue_document"&&e.payload.target.key==="plan"}a(Jc,"isPlanConfirmationInteraction");function Yb(e){if(e.status==="accepted")return"Approved plan";const s=e.result?.reason?.trim();return s?`Requested changes