@hearsay-tools/squawk 0.19.0-dev.9220 → 0.19.0-dev.9235

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 (160) hide show
  1. package/dist/activity/read-model.js +5 -2
  2. package/dist/activity/read-model.js.map +1 -1
  3. package/dist/contract/hosts.d.ts +3 -0
  4. package/dist/contract/index.d.ts +1 -0
  5. package/dist/contract/index.js +2257 -1939
  6. package/dist/contract/projects.d.ts +6 -0
  7. package/dist/contract/runs.d.ts +117 -0
  8. package/dist/contract/task-result.d.ts +1075 -0
  9. package/dist/core/forge-registry.d.ts +8 -0
  10. package/dist/core/forge-registry.js +36 -13
  11. package/dist/core/forge-registry.js.map +1 -1
  12. package/dist/delegation/readiness.d.ts +8 -5
  13. package/dist/delegation/readiness.js +23 -9
  14. package/dist/delegation/readiness.js.map +1 -1
  15. package/dist/delegation/routes.d.ts +4 -4
  16. package/dist/delegation/service.js +4 -2
  17. package/dist/delegation/service.js.map +1 -1
  18. package/dist/delegation/worker-cleanup.js +1 -1
  19. package/dist/delegation/worker-cleanup.js.map +1 -1
  20. package/dist/features/hosts/routes.d.ts +2 -0
  21. package/dist/features/webhooks/routes.d.ts +3 -0
  22. package/dist/project-migration/journal.d.ts +2 -0
  23. package/dist/project-migration/journal.js +1 -1
  24. package/dist/project-migration/journal.js.map +1 -1
  25. package/dist/project-migration/plan.js +2 -0
  26. package/dist/project-migration/plan.js.map +1 -1
  27. package/dist/runs/legacy-run-rows.d.ts +1 -1
  28. package/dist/runs/legacy-run-rows.js +7 -3
  29. package/dist/runs/legacy-run-rows.js.map +1 -1
  30. package/dist/runs/ports.d.ts +16 -1
  31. package/dist/runs/project-run-connection.d.ts +3 -0
  32. package/dist/runs/project-run-connection.js +57 -10
  33. package/dist/runs/project-run-connection.js.map +1 -1
  34. package/dist/runs/project-run-sources.d.ts +6 -0
  35. package/dist/runs/project-run-sources.js +20 -0
  36. package/dist/runs/project-run-sources.js.map +1 -1
  37. package/dist/runs/run-archive.d.ts +19 -0
  38. package/dist/runs/run-decode.d.ts +58 -0
  39. package/dist/runs/run-decode.js +10 -0
  40. package/dist/runs/run-decode.js.map +1 -1
  41. package/dist/runs/run-exits.d.ts +114 -0
  42. package/dist/runs/run-retention.d.ts +2 -0
  43. package/dist/runs/run-retention.js +11 -2
  44. package/dist/runs/run-retention.js.map +1 -1
  45. package/dist/runs/store.d.ts +3 -0
  46. package/dist/runs/store.js +11 -5
  47. package/dist/runs/store.js.map +1 -1
  48. package/dist/runs/task-result-commit.d.ts +24 -0
  49. package/dist/runs/task-result-commit.js +114 -0
  50. package/dist/runs/task-result-commit.js.map +1 -0
  51. package/dist/runs/task-results.d.ts +61 -0
  52. package/dist/runs/task-results.js +220 -0
  53. package/dist/runs/task-results.js.map +1 -0
  54. package/dist/runs/worker-result-commit.d.ts +12 -12
  55. package/dist/runs/worker-result-commit.js +77 -55
  56. package/dist/runs/worker-result-commit.js.map +1 -1
  57. package/dist/runs/worker-results.d.ts +10 -26
  58. package/dist/runs/worker-results.js +11 -73
  59. package/dist/runs/worker-results.js.map +1 -1
  60. package/dist/server/projects-routes.d.ts +6 -0
  61. package/dist/server/runs-routes.d.ts +189 -18
  62. package/dist/server/server.d.ts +1666 -1318
  63. package/dist/workflows/continuation-admission.d.ts +91 -72
  64. package/dist/workflows/input-acknowledgement.d.ts +24 -24
  65. package/dist/workflows/run/completion-gate.js +10 -4
  66. package/dist/workflows/run/completion-gate.js.map +1 -1
  67. package/dist/workflows/run/wait-engine.d.ts +91 -72
  68. package/dist/workspace/projects.d.ts +5 -0
  69. package/dist/workspace/projects.js +8 -2
  70. package/dist/workspace/projects.js.map +1 -1
  71. package/package.json +4 -4
  72. package/web/dist/assets/accounts-section-BOZ9JyE6.js +1 -0
  73. package/web/dist/assets/{activity-motion-CXlbNrMI.js → activity-motion-D48R7Vry.js} +1 -1
  74. package/web/dist/assets/{activity-route-BL-QWLNp.js → activity-route-jcGRtnMT.js} +1 -1
  75. package/web/dist/assets/{agent-accounts-Du8CHfFX.js → agent-accounts-CUthX0Yh.js} +1 -1
  76. package/web/dist/assets/{agent-config-section-BzMSlPK0.js → agent-config-section-BvwoyNZb.js} +1 -1
  77. package/web/dist/assets/{agent-defaults-section-CqEVmRK0.js → agent-defaults-section-Hb-jy4TN.js} +1 -1
  78. package/web/dist/assets/{appearance-vI6ae_So.js → appearance-EXKzoghV.js} +1 -1
  79. package/web/dist/assets/{archive-on-merge-field-C4hrO55O.js → archive-on-merge-field-Ni7bKGkG.js} +1 -1
  80. package/web/dist/assets/{ask-card-hEb8IHjL.js → ask-card-CkE44gm3.js} +3 -3
  81. package/web/dist/assets/automations-route-3bhtdTy3.js +2 -0
  82. package/web/dist/assets/{commit-list-Jr1_04RS.js → commit-list-DSw7qvVY.js} +1 -1
  83. package/web/dist/assets/{diff-BOF9OXhn.js → diff-BidPzsVK.js} +2 -2
  84. package/web/dist/assets/{diff-controls-CkxtRrbB.js → diff-controls-DeMSGYln.js} +1 -1
  85. package/web/dist/assets/{diff-view-Chu6rn_i.js → diff-view-BqU4sJld.js} +1 -1
  86. package/web/dist/assets/{discard-changes-dialog-BB47RqdX.js → discard-changes-dialog-B1AO0GSt.js} +1 -1
  87. package/web/dist/assets/{file-preview-DNM-krBZ.js → file-preview-BIZXTzkp.js} +1 -1
  88. package/web/dist/assets/{folder-browser-TNWat5kt.js → folder-browser-C9Phl0rS.js} +1 -1
  89. package/web/dist/assets/{git-toolbar-CoKBTzNV.js → git-toolbar-BBon1yHh.js} +1 -1
  90. package/web/dist/assets/{github-t611QkCi.js → github-QOB5Qi4v.js} +1 -1
  91. package/web/dist/assets/{global-activity-route-B9DMoviv.js → global-activity-route-lSnYAZE9.js} +1 -1
  92. package/web/dist/assets/{host-context-iTMFRMT5.js → host-context-KsSKxKbI.js} +1 -1
  93. package/web/dist/assets/host-storage-BHtMSWBL.js +1 -0
  94. package/web/dist/assets/{hosts-rdWe_OBc.js → hosts-DDwDUxT9.js} +1 -1
  95. package/web/dist/assets/{image-preview-C_xACQXI.js → image-preview-CvcSCCBU.js} +1 -1
  96. package/web/dist/assets/index-BuR9xHfb.js +21 -0
  97. package/web/dist/assets/index-DZXi-K2N.css +1 -0
  98. package/web/dist/assets/{label-B_s8eiYA.js → label-D6vgq5lF.js} +1 -1
  99. package/web/dist/assets/{markdown-Bmdr6MIa.js → markdown-A6dvDky9.js} +1 -1
  100. package/web/dist/assets/{open-in-menu-DkFneOWr.js → open-in-menu-Bb_jc7pm.js} +1 -1
  101. package/web/dist/assets/{option-select-BxTmKg8G.js → option-select-CCpypHbW.js} +1 -1
  102. package/web/dist/assets/{preferences-section-B_yl_o-g.js → preferences-section-B75Zx0mY.js} +1 -1
  103. package/web/dist/assets/{preview-D3zYSmIA.js → preview-DiBpgf-5.js} +1 -1
  104. package/web/dist/assets/{preview-pane-connected-s9LvCVbp.js → preview-pane-connected-BVu2oO0V.js} +2 -2
  105. package/web/dist/assets/{project-location-BczZtNyO.js → project-location-D1etWKHg.js} +1 -1
  106. package/web/dist/assets/{project-router-CfEuKuz1.js → project-router-yoWCTDaT.js} +1 -1
  107. package/web/dist/assets/project-scope-context-hfRzPMZ4.js +4 -0
  108. package/web/dist/assets/{projects-section-C6DnyUa2.js → projects-section-BRnIJ47e.js} +1 -1
  109. package/web/dist/assets/{prompt-templates-section-BQvKWcaX.js → prompt-templates-section-D7JLM5BM.js} +2 -2
  110. package/web/dist/assets/queries-ChH9ctc-.js +1 -0
  111. package/web/dist/assets/{reference-chip-e-fG4-yW.js → reference-chip-BPRZm7Kb.js} +1 -1
  112. package/web/dist/assets/{remote-settings-notice-CUqI2DdF.js → remote-settings-notice-Ip6H5hLU.js} +1 -1
  113. package/web/dist/assets/{repo-git-NG_TxE7N.js → repo-git-Wf30akEt.js} +1 -1
  114. package/web/dist/assets/{report-reader-LYNHrAe-.js → report-reader-DhcZcNql.js} +1 -1
  115. package/web/dist/assets/{report-selection-nUbQVjJu.js → report-selection-CwPw7vbG.js} +1 -1
  116. package/web/dist/assets/{reports-DuT4m7i5.js → reports-DPKDwzxY.js} +1 -1
  117. package/web/dist/assets/{resources-section-CT48TCXY.js → resources-section-DaWcyqur.js} +1 -1
  118. package/web/dist/assets/{review-notes-drafts-C7HCRebB.js → review-notes-drafts-D7QuBuTL.js} +1 -1
  119. package/web/dist/assets/{review-panel-BffLSkRo.js → review-panel-Bpxl4TvO.js} +1 -1
  120. package/web/dist/assets/{review-strip-COa0ir6V.js → review-strip-Da5n1k8s.js} +1 -1
  121. package/web/dist/assets/{run-detail-refresh-Db5HOGMX.js → run-detail-refresh-CVSK_VKG.js} +1 -1
  122. package/web/dist/assets/{run-diff-DldSY8BJ.js → run-diff-CPuNFD3X.js} +1 -1
  123. package/web/dist/assets/run-header-B8EAOHFc.js +2 -0
  124. package/web/dist/assets/{select-Cd8wvwvm.js → select-xjUzLrk9.js} +1 -1
  125. package/web/dist/assets/{session-context-section-CW8DS0dW.js → session-context-section-C7OTexKU.js} +1 -1
  126. package/web/dist/assets/{settings-agent-picker-an3ysM1B.js → settings-agent-picker-mESK-hj4.js} +1 -1
  127. package/web/dist/assets/{settings-save-bar-BiHFQ4c0.js → settings-save-bar-BUaa1kHw.js} +1 -1
  128. package/web/dist/assets/{settings-shell-KZ801oLH.js → settings-shell-BKSsBxqQ.js} +1 -1
  129. package/web/dist/assets/{sidebar-section-BRMO7aY4.js → sidebar-section-BFBZlQ-x.js} +1 -1
  130. package/web/dist/assets/{skills-DHkLoxXb.js → skills-BSqszv5g.js} +1 -1
  131. package/web/dist/assets/{status-dot-Da1M54kK.js → status-dot-Fp5SnPHI.js} +1 -1
  132. package/web/dist/assets/{tab-link-DL1UtKVR.js → tab-link-j06AaWSU.js} +1 -1
  133. package/web/dist/assets/{task-changes-CQhwyj0L.js → task-changes-B4KFHxVa.js} +2 -2
  134. package/web/dist/assets/{task-commits-CTP8izpc.js → task-commits-D-UAUoZ5.js} +1 -1
  135. package/web/dist/assets/{task-file-scope-CDIfOvl-.js → task-file-scope-BhWG35a8.js} +1 -1
  136. package/web/dist/assets/{task-files-CGlRH86B.js → task-files-BOCx_Lp0.js} +1 -1
  137. package/web/dist/assets/{task-github-item-ChgjULzj.js → task-github-item-CZqaaxNv.js} +1 -1
  138. package/web/dist/assets/task-thread-D3d419VX.js +2 -0
  139. package/web/dist/assets/{thread-state-D2KJrZ1o.js → thread-state-B0pz2Y8K.js} +1 -1
  140. package/web/dist/assets/{use-finish-run-DifixlCM.js → use-finish-run-TX3pIPCS.js} +1 -1
  141. package/web/dist/assets/{use-hand-to-agent-state-Bjh1EnB3.js → use-hand-to-agent-state-D2oChRzw.js} +1 -1
  142. package/web/dist/assets/use-path-bases-DFxEHoyU.js +1 -0
  143. package/web/dist/assets/use-workspace-config-save-DR8brU5p.js +1 -0
  144. package/web/dist/assets/{workflows-BDc-MpiC.js → workflows-BwzNhxT0.js} +1 -1
  145. package/web/dist/assets/{workspace-tools-D7kUSb-0.js → workspace-tools-Be_j9oke.js} +1 -1
  146. package/web/dist/assets/{worktrees-section-Cv65NBgq.js → worktrees-section-cnibWU5-.js} +4 -4
  147. package/web/dist/assets/{zoomable-image-DJ1lJEMc.js → zoomable-image-Dv85Vr4A.js} +1 -1
  148. package/web/dist/index.html +17 -17
  149. package/web/dist/live-worker.js +1 -1
  150. package/web/dist/assets/accounts-section-s6sAdUT8.js +0 -1
  151. package/web/dist/assets/automations-route-Bd6crv15.js +0 -2
  152. package/web/dist/assets/host-storage-Cr_NKfWy.js +0 -1
  153. package/web/dist/assets/index-C3kap2_j.js +0 -21
  154. package/web/dist/assets/index-CWmMYQdT.css +0 -1
  155. package/web/dist/assets/project-scope-context-DNrHbqd2.js +0 -4
  156. package/web/dist/assets/queries-DD_9iITj.js +0 -1
  157. package/web/dist/assets/run-header-DxpN6yVQ.js +0 -2
  158. package/web/dist/assets/task-thread-Cj9B2ISO.js +0 -2
  159. package/web/dist/assets/use-path-bases-AV9YYh2B.js +0 -1
  160. package/web/dist/assets/use-workspace-config-save-02qlUK8v.js +0 -1
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{g as n,m as r,n as i}from"./host-context-KsSKxKbI.js";import{$ as a,$i as o,$n as s,$t as c,A as l,An as u,Ar as d,Bi as f,Br as ee,C as te,Ci as p,Cn as ne,Ct as re,D as m,Dn as h,Dt as g,E as _,Er as v,Et as ie,F as ae,Fn as y,Fr as b,G as x,Gi as oe,Gr as se,Hi as ce,Hr as le,Ht as S,Ir as ue,It as de,J as fe,Ji as pe,Jt as me,K as he,Ki as ge,Kt as C,L as w,Lr as _e,Mn as T,Mt as ve,N as ye,Nn as be,Nr as xe,Nt as Se,O as Ce,On as E,Or as we,Ot as Te,Pr as Ee,Pt as De,Q as Oe,Qi as D,Qt as ke,Ri as Ae,Rr as je,S as Me,Sn as Ne,St as Pe,Tn as Fe,Ui as Ie,Ur as Le,Vi as O,Vr as Re,Vt as ze,Wi as Be,Wr as Ve,Wt as He,X as Ue,Xt as We,Y as Ge,Yi as Ke,Yt as qe,Zn as Je,Zt as Ye,_n as Xe,_t as Ze,a as Qe,aa as $e,an as et,ar as tt,b as nt,bn as rt,bt as it,cn as at,ct as ot,en as st,er as ct,et as lt,fa as k,fi as ut,fn as dt,gn as ft,gt as pt,h as mt,ha as ht,hn as gt,in as _t,ji as A,jn as vt,k as yt,kr as bt,kt as xt,ln as St,m as Ct,ma as wt,mn as Tt,na as Et,nn as Dt,on as Ot,or as kt,pn as At,pt as jt,q as Mt,qi as Nt,qt as Pt,r as Ft,sa as It,sn as Lt,ta as Rt,tn as zt,ua as Bt,v as Vt,va as Ht,vi as Ut,vt as Wt,wi as Gt,wn as Kt,wt as qt,x as Jt,xn as Yt,xt as Xt,y as Zt,yn as Qt,yt as $t,zr as en}from"./project-scope-context-hfRzPMZ4.js";import{A as tn,B as j,F as M,H as N,I as P,N as F,P as I,W as L,Z as nn,a as rn,j as R,z}from"./live-protocol-CNUmr-VT.js";import{c as an}from"./dist-CCX8mhHc.js";import{n as on}from"./host-storage-BHtMSWBL.js";function sn(e,t){return e??t}function cn(e,t){let n=sn(e,t);return n===`1`||n===`true`}function ln(e,t,n){return e?.trim()||sn(t,n)||``}var un=class extends Rt{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||dn(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=Et({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),nn.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function dn(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var fn=class extends Ht{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),wt(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&$e(t.mutationKey)!==$e(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??dn();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){nn.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}};function pn(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function mn(e,t,n){let r=e.slice(0);return r[t]=n,r}var hn=class extends Ht{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,nn.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!wt(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(pn(e,n).forEach(e=>{e.destroy()}),pn(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=k(this.#a,t(e))),this.#a}return e}#f(){return this.#r?.combine!==void 0&&this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new o(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=mn(this.#t,n,t),this.#h())}#h(){if(this.hasListeners()){let e=this.#u(this.#t,this.#l),t=this.#f(),n=this.#a,r=t?n:this.#d(e,this.#r?.combine);(t||n!==r)&&nn.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},B=e(t(),1);function gn({queries:e,...t},n){let r=D(n),i=Ke(),a=pe(),s=B.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);s.forEach(e=>{ce(e);let t=r.getQueryCache().get(e.queryHash);oe(e,a,t)}),Nt(a);let[c]=B.useState(()=>new hn(r,s,t)),[l,u,d]=c.getOptimisticResult(s,t.combine),f=!i&&t.subscribed!==!1;B.useSyncExternalStore(B.useCallback(e=>f?c.subscribe(nn.batchCalls(e)):Bt,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),B.useEffect(()=>{c.setQueries(s,t)},[s,t,c]);let ee=l.some((e,t)=>Be(s[t],e))?l.flatMap((e,t)=>{let n=s[t];return n&&Be(n,e)?Ie(n,new o(r,n),a):[]}):[];if(ee.length>0)throw Promise.all(ee);let te=l.find((e,t)=>{let n=s[t];return n&&ge({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(te?.error)throw te.error;return u(d())}function V(e,t){let n=D(t),[r]=B.useState(()=>new fn(n,e));B.useEffect(()=>{r.setOptions(e)},[r,e]);let i=B.useSyncExternalStore(B.useCallback(e=>r.subscribe(nn.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=B.useCallback((e,t)=>{r.mutate(e,t).catch(Bt)},[r]);if(i.error&&ht(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function H(e={}){let t=e.projectId??n(),r=e.cacheScope??(e.boot?`default`:t);return e.hostId===void 0?{projectId:t,cacheScope:r}:{projectId:t,cacheScope:r,hostId:e.hostId}}function U(e,t={}){return{...H(t),runId:e}}function _n(){return cn(void 0,void 0)}function W(e){return!_n()&&e}async function vn(e){return vt(await E.api.v1.health.$get({},h(e)),`/health`)}async function yn(e){return T(await E.api.v1.hosts.$get({},h(e)),`/hosts`,_e)}async function bn(e){return T(await E.api.v1.hosts.projects.$get({},h(e)),`/hosts/projects`,je)}async function xn(e){return T(await E.api.v1.hosts[`runs-index`].$get({query:e?.hostId?{hostId:e.hostId}:{}},h(e)),`/hosts/runs-index`,en)}async function Sn(e,t){return T(await E.api.v1.hosts[`runs-search`].$get({query:{q:e,...t?.limit===void 0?{}:{limit:t.limit}}},h(t)),`/hosts/runs-search`,ee)}async function Cn(e){return vt(await E.api.v1.workspace[`ui-state`].$get({},h(e)),`/workspace/ui-state`)}async function wn(e,t={}){return vt(await E.api.v1.workspace[`ui-state`].$put({json:e},{init:{...an({keepalive:t.keepalive})}}),`/workspace/ui-state`)}j({runs:P(`summary`).optional()});var Tn=L().min(1),En=z().int().positive(),Dn=j({project:Tn,seq:En,run:se,relationships:L().min(1)}),On=j({project:Tn,seq:En,id:L().min(1)}),kn=j({generation:L().min(1),seq:z().int().nonnegative()}),An=j({project:Tn,usage:N(L(),le)});j({runs:F(Ve),referenceStatuses:Le,perProjectLimit:z(),truncated:F(L()),generation:L().min(1),eventSeq:z().int().nonnegative()});function jn(e,t){if(e===`ping`)return{project:null,event:{type:`ping`}};let n;try{n=JSON.parse(t)}catch{return null}switch(e){case`run-summary`:{let e=Dn.safeParse(n);return e.success?{project:e.data.project,event:{type:`run-summary`,summary:e.data.run,seq:e.data.seq,relationships:e.data.relationships}}:null}case`run-deleted`:{let e=On.safeParse(n);return e.success?{project:e.data.project,event:{type:`run-deleted`,id:e.data.id,seq:e.data.seq}}:null}case`usage`:{let e=An.safeParse(n);return e.success?{project:e.data.project,event:{type:`usage`,usage:e.data.usage}}:null}case`ready`:{let e=kn.safeParse(n);return e.success?{project:null,event:{type:`ready`,generation:e.data.generation,seq:e.data.seq}}:null}default:return null}}var Mn=[bt,we,d,v];function Nn(e,t){let n;try{n=JSON.parse(t)}catch{return null}switch(e){case bt:{let e=Ee.safeParse(n);return e.success?{type:`host-run-summary`,hostId:e.data.hostId,project:e.data.project,seq:e.data.seq,summary:e.data.run}:null}case we:{let e=xe.safeParse(n);return e.success?{type:`host-run-deleted`,hostId:e.data.hostId,project:e.data.project,seq:e.data.seq,id:e.data.id}:null}case d:{let e=b.safeParse(n);return e.success?{type:`host-usage`,hostId:e.data.hostId,project:e.data.project,usage:e.data.usage}:null}case v:{let e=ue.safeParse(n);return e.success?{type:`hosts-changed`,...e.data}:null}default:return null}}function Pn(){let e,t;return{ready(n){t=void 0;let r=e!==void 0&&n>e;return e=n,r},frame(n){if(t!==void 0&&n<=t)return!1;let r=e!==void 0&&n!==e+1;return e=n,r},seed(n){t=t===void 0?n:Math.max(t,n),e=e===void 0?n:Math.max(e,n)},reset(){e=void 0,t=void 0}}}function Fn(e,t){if(!e)return;let n=e.findIndex(e=>e.id===t.id);if(n>=0){let r=[...e];return r[n]=t,r}let r=e.findIndex(e=>(e.createdAt??``).localeCompare(t.createdAt)<0),i=[...e];return i.splice(r<0?e.length:r,0,t),i}function In(e,t){if(!e)return;let n=e.filter(e=>e.id!==t);return n.length===e.length?e:n}var Ln=Object.freeze({});function Rn(){let e=Ln,t=new Set;return{subscribe(e){return t.add(e),()=>t.delete(e)},get:()=>e,set(n){e=n;for(let e of t)e()}}}function zn(e){return Ut[p(e).bucket]<=Ut.waiting}function Bn(e,t){let n;for(let r of e)!r.sessionId||r.id===t||(!n||!r.startedAt||!n.startedAt||r.startedAt>=n.startedAt)&&(n=r);return n}function Vn(e,t){return e?.backend??t?.runner??`claude`}function Hn(e,t){let n;for(let r of e)r.removedBackend===void 0&&(t===void 0||r.sessionId!==t)||(!n||!r.startedAt||!n.startedAt||r.startedAt>=n.startedAt)&&(n=r);return n?.removedBackend===void 0?void 0:n}function Un(e){let t=Bn(e.steps),n=Hn(e.steps,t?.sessionId)?void 0:t;return{sessionId:n?.sessionId,backend:Vn(n,e),profileId:n?.profileId}}function Wn(e){return e.command===void 0&&e.kind!==`plugin`}function Gn(e){let t=e.workflowCursor?.mode===`resume`?e.workflowCursor.stepId:void 0;if(t&&e.steps.find(e=>e.id===t)?.status===`failed`)return t;let n=Bn(e.steps);if(n)return n.synthetic===`continuation`&&n.continuesStepId!==void 0?n.continuesStepId:e.steps.find(e=>e.sessionId===n.sessionId)?.id??n.id}function Kn(e,t=!1){if(e.delegation?.role!==`worker`)return;let n=e.workflowDef?.steps;if(!n?.length)return;if(t)return n.find(Wn);let r=Gn(e);return(r?n.find(e=>e.id===r&&Wn(e)):void 0)??[...n].reverse().find(Wn)}var qn=new Set([`queued`,`running`,`waiting`]);function Jn(e){return qn.has(e)}function Yn(e){return A(e)?!1:e.status===`queued`||e.status===`running`||e.status===`waiting`}function Xn(e){return Yn(e)&&e.status!==`queued`}function Zn(e,t,n){return e.archived||!(e.status===`done`||e.status===`failed`||e.status===`cancelled`)||e.delegation?.role===`worker`||n!==void 0&&Re(e)!==n?!1:t===`unpinned`?!e.pinned:t!==`pinned`||e.pinned===!0}var Qn=[`done`,`failed`];function $n(e){return e.archived||A(e)||!Qn.includes(e.status)?!1:e.finishedAt!==void 0}function er(e){let t=e.finishedAt;return t===void 0||!$n(e)?!1:e.seenAt===void 0||e.seenAt<t}var tr=[`Needs you`,`Finished`,`Working`,`Archived`],nr={waiting:0,review:1,running:2,queued:4,done:5,failed:6,cancelled:7},rr=3,ir=e=>A(e)?rr:nr[e.status]??9;function ar(e){let t=e=>Ut[p(e).bucket];return[...e].sort((e,n)=>t(e)-t(n)||ir(e)-ir(n))[0]}function or(e,t){return t===`archived`?`Archived`:Gt(e)?`Needs you`:e.status===`waiting`||e.status===`running`||e.status===`queued`?`Working`:`Finished`}function sr(e){let t=e.titleSummary;return t===void 0||!(e.titleOrigin===`user`||e.titleOrigin===`marker`)&&/[.!?][A-Z]/.test(t)?e.title:t}function cr(e){let t=/^(\d{1,9}): (.+)$/.exec(e),n=t?.[1],r=t?.[2];return n===void 0||r===void 0?{ref:null,rest:e}:{ref:Number(n),rest:r}}function lr(e,t){return t!==void 0&&cr(e).ref===t}var ur=(e,t)=>e<t?-1:+(e>t);function dr(e){let t=e.filter(e=>!e.archived&&e.status===`queued`).sort((e,t)=>ur(e.createdAt,t.createdAt));return new Map(t.map((e,t)=>[e.id,t+1]))}function fr(e,t,n){if(n!==`archived`){let n=Number(!!t.pinned)-Number(!!e.pinned);if(n!==0)return n}let r=ir(e)-ir(t);if(r!==0)return r;if(A(e)&&A(t)){let n=ur(e.autoResumeAt,t.autoResumeAt);if(n!==0)return n}return e.status===`queued`&&t.status===`queued`?ur(e.createdAt,t.createdAt):ur(t.createdAt,e.createdAt)}function pr(e,t){return e.filter(e=>t===`archived`?e.archived:!e.archived).sort((e,n)=>fr(e,n,t))}function G(e){return e.delegation?.role===`worker`}function mr(e,t){if(e==null)return null;let n=t.find(t=>t.id===e);return!n||!G(n)?e:n.delegation?.parentRunId??e}function hr(e,t,n=dr(e)){let r=pr(e,t).filter(e=>!G(e)),i=new Map,a=(e,t)=>{let n=i.get(e);n?n.push(t):i.set(e,[t])};for(let e of r)a(or(e,t),{kind:`run`,run:e,queuePosition:n.get(e.id)??null});return tr.filter(e=>i.has(e)).map(e=>({label:e,rows:i.get(e)}))}function gr(e,t={}){let n=typeof t==`number`?{overall:t}:Je(t),r={"Needs you":`needsYou`,Finished:`finished`,Working:`working`},i=[],a=n.overall===void 0?10:n.overall??1/0;for(let t of e){let e=t.label===`Archived`?1/0:n[r[t.label]]??1/0,o=t.rows.filter(n=>{let r=n.run.pinned;return t.label!==`Archived`&&r?!0:a<=0||e<=0?!1:(--a,--e,!0)});o.length&&i.push({label:t.label,rows:o})}return i}function _r(e,t){if(t.length===0)return[...e];let n=new Set(e.map(e=>e.id)),r=new Set,i=t.filter(e=>n.has(e.id)||r.has(e.id)?!1:(r.add(e.id),!0));return[...e,...i]}function vr(e){let t=0,n=0,r=0;for(let i of e)if(!G(i)){if(i.archived){n+=1;continue}t+=1,Gt(i)&&(r+=1)}return{active:t,archived:n,waiting:r}}function yr(e,t,n){return e.filter(e=>!e.archived&&(!n||Re(e)===(t===`automations`)))}var br={"Needs you":`needs-you`,Finished:`finished`,Working:`working`},xr=Object.keys(br),Sr=`section`;function Cr(e,t,n){let r=`${Sr}=${br[e]}`;return n?`/?origin=${t===`automations`?`automations`:`direct`}&${r}`:`/?${r}`}function wr(e){return xr.find(t=>br[t]===e)??null}function Tr(e,t){let n={active:0,automations:0,activeWaiting:0,automationsWaiting:0};for(let r of e){if(G(r)||r.archived)continue;let e=+!!Gt(r);t&&Re(r)?(n.automations+=1,n.automationsWaiting+=e):(n.active+=1,n.activeWaiting+=e)}return n}var Er=[`done`,`failed`,`cancelled`];function Dr(e){return Er.includes(e)}function Or(e){return!A(e)&&Dr(e.status)&&!er(e)}function kr(e){return e.reduce((e,t)=>G(t)||!er(t)?e:e+1,0)}function Ar(e){return e.status===`failed`?`danger`:`success`}var jr={needsYou:0,failedUnread:0,inMotion:0,finishedUnread:0};function Mr(e){if(e.archived||G(e))return null;if(Gt(e))return`needsYou`;if(p(e).tone===`running`)return`inMotion`;if(er(e)){if(e.status===`failed`)return`failedUnread`;if(e.status===`done`)return`finishedUnread`}return null}function Nr(e,t){return e===t?!0:!e||!t?!1:e.needsYou===t.needsYou&&e.failedUnread===t.failedUnread&&e.inMotion===t.inMotion&&e.finishedUnread===t.finishedUnread}function Pr(e){let t={...jr};for(let n of e){let e=Mr(n);e&&(t[e]+=1)}return t}function Fr(e){let t=new Map;for(let n of e){let e=t.get(n.projectId);e?e.push(n):t.set(n.projectId,[n])}return new Map([...t].map(([e,t])=>[e,Pr(t)]))}function Ir(e,t,n={}){if(n.unknown)return`${e} · activity unknown`;let r=Lr(t).map(e=>e.text);return[e,r.length>0?r.join(` · `):`idle`].join(` · `)}function Lr(e){let{needsYou:t,failedUnread:n,inMotion:r,finishedUnread:i}=e??jr,a=[];return t>0&&a.push({tone:`amber`,text:`${t} needs you`}),n>0&&a.push({tone:`red`,text:`${n} failed`}),r>0&&a.push({tone:`violet`,text:`${r} working`}),i>0&&a.push({tone:`green`,text:`${i} finished`}),a}function Rr(e){let t={...jr};for(let n of e)n&&(t.needsYou+=n.needsYou,t.failedUnread+=n.failedUnread,t.inMotion+=n.inMotion,t.finishedUnread+=n.finishedUnread);return t}function zr(e){let t=e.split(/[-_ .]+/).filter(e=>e!==``);return(t.length>=2?[t[0],t[1]].map(e=>[...e][0]):[...t[0]??``].slice(0,2)).join(``).toLowerCase()}var K=new WeakMap;function Br(){return{needsYou:0,failedUnread:0,inMotion:0,finishedUnread:0}}function Vr(e){return e.needsYou===0&&e.failedUnread===0&&e.inMotion===0&&e.finishedUnread===0}function Hr(e,t,n,r){let i=e.get(t),a=i?{...i}:Br();a[n]=Math.max(0,a[n]+r),Vr(a)?e.delete(t):e.set(t,a)}function Ur(e){let t=new Map;for(let n of e){let e=Mr(n);if(!e)continue;let r=t.get(n.projectId);r||(r=Br(),t.set(n.projectId,r)),r[e]+=1}return t}function Wr(e){let t=new Map;for(let n of e){let e=Mr(n);if(!e)continue;let r=t.get(n.hostId);r||(r=new Map,t.set(n.hostId,r));let i=r.get(n.projectId);i||(i=Br(),r.set(n.projectId,i)),i[e]+=1}return t}function Gr(e,t){if(e===t)return;let n=K.get(e);n&&K.set(t,n)}function Kr(e,t,n){if(e===t)return;let r=K.get(e);if(!r)return;if(n.length===0){K.set(t,r);return}let i=null,a=new Set,o=e=>{if(i||=new Map(r),!a.has(e)){let t=i.get(e),n=t?new Map(t):new Map;return i.set(e,n),a.add(e),n}return i.get(e)};for(let e of n){let t=e.previous?Mr(e.previous):null,n=e.next?Mr(e.next):null;if(t===n)continue;let r=o(e.hostId);t&&Hr(r,e.projectId,t,-1),n&&Hr(r,e.projectId,n,1)}let s=i;if(s)for(let e of a)s.get(e)?.size===0&&s.delete(e);K.set(t,s??r)}function qr(e,t,n,r){if(e===t)return;let i=K.get(e);if(!i)return;let a=new Map(i),o=Ur(r);o.size===0?a.delete(n):a.set(n,o),K.set(t,a)}function Jr(e){let t=K.get(e.runs);t||(t=Wr(e.runs),K.set(e.runs,t));let n=new Map,r=new Set;for(let i of e.hosts){if(i.state!==`connected`||!i.loaded||i.stale)continue;r.add(i.id);let e=t.get(i.id);e&&e.size>0&&n.set(i.id,e)}return{byHost:n,knownHosts:r}}function Yr(e,t){if(e===t)return!0;if(!e||!t||e.knownHosts.size!==t.knownHosts.size||e.byHost.size!==t.byHost.size)return!1;for(let n of e.knownHosts)if(!t.knownHosts.has(n))return!1;for(let[n,r]of e.byHost){let e=t.byHost.get(n);if(!e)return!1;if(r!==e){if(r.size!==e.size)return!1;for(let[t,n]of r)if(!Nr(n,e.get(t)))return!1}}return!0}function Xr(e){return e.type===`run`?e.run.id:e.id}function Zr(e,t){return{...e,runs:t}}function Qr(e,t){let n=0;for(let r of e)t(r)&&r.archived&&(n+=1);return n}var $r=new WeakMap,ei=new WeakMap;function ti(e,t){let n=new Map,r=new Map;for(let i=0;i<e.length;i+=1){let a=e[i],o=t(a),s=n.get(o);if(s||(s=new Map,n.set(o,s)),s.set(a.id,i),a.usage!==void 0){let e=r.get(o);e||(e=new Set,r.set(o,e)),e.add(a.id)}}return $r.set(e,n),ei.set(e,r),{positions:n,liveUsage:r}}var ni=class{runs;copied=!1;positions;liveUsage;liveUsageCopied=!1;scopeOf;constructor(e,t){this.runs=e,this.scopeOf=t;let n=$r.get(e),r=ei.get(e);if(n&&r)this.positions=n,this.liveUsage=r;else{let n=ti(e,t);this.positions=n.positions,this.liveUsage=n.liveUsage}}reindex(){let e=ti(this.runs,this.scopeOf);this.positions=e.positions,this.liveUsage=e.liveUsage,this.liveUsageCopied=!0}mutableLiveUsage(){if(!this.liveUsageCopied){let e=new Map;for(let[t,n]of this.liveUsage)e.set(t,new Set(n));this.liveUsage=e,this.liveUsageCopied=!0,this.copied&&ei.set(this.runs,this.liveUsage)}return this.liveUsage}at(e,t){return this.positions.get(e)?.get(t)??-1}liveUsageIds(e){return this.liveUsage.get(e)}setLiveUsage(e,t,n){let r=this.mutableLiveUsage();if(n){let n=r.get(e);n||(n=new Set,r.set(e,n)),n.add(t)}else{let n=r.get(e);if(!n)return;n.delete(t),n.size===0&&r.delete(e)}}mutable(){return this.copied||(this.runs=[...this.runs],this.copied=!0,$r.set(this.runs,this.positions),ei.set(this.runs,this.liveUsage)),this.runs}replace(e,t){let n=this.runs[e];return this.mutable()[e]=t,n?.usage!==void 0!=(t.usage!==void 0)&&this.setLiveUsage(this.scopeOf(t),t.id,t.usage!==void 0),this.runs}remove(e){return this.mutable().splice(e,1),this.reindex(),this.runs}insert(e){let t=this.runs.findIndex(t=>(t.createdAt??``).localeCompare(e.createdAt)<0);return this.mutable().splice(t<0?this.runs.length:t,0,e),this.reindex(),this.runs}},ri=e=>e.projectId,ii=(e,t)=>`${e}\u0000${t}`,ai=e=>ii(e.hostId,e.projectId);function oi(e,t,n,r){return e.length===0?!1:($r.get(e)??ti(e,ai).positions).get(ii(t,n))?.has(r)??!1}function si(e,t,n){let r=new ni(e.runs,ri),i=e,a=!1;for(let e of t)if(e.type===`usage`)i=gi(i,e.project,e.usage,r);else{let t=fi(i,e.change,n,r);i=t.index,a||=t.reconcile}return{index:i,reconcile:a}}function ci(e,t,n){let r=new ni(e.runs,ai),i=e.runs,a=new Set,o=[],s=!1;for(let c of t){if(c.type===`usage`){i=hi(i,ii(c.hostId,c.project),c.usage,r);continue}let{hostId:t,project:l}=c.change,u=e.hosts.find(e=>e.id===t);if(!u||!u.loaded){a.add(t);continue}let d=n?.(t,l);c.change.type===`run`&&d===!1&&(s=!0);let f=di(i,c.change,{scope:ii(t,l),id:Xr(c.change),inScope:e=>e.hostId===t&&e.projectId===l,truncated:u.truncated.includes(l),perProjectLimit:u.perProjectLimit,isKnownScope:()=>!0,buildRow:e=>({hostId:t,projectId:l,...e}),onDelta:(e,n)=>o.push({hostId:t,projectId:l,previous:e,next:n})},r);i=f.runs,f.reconcile&&a.add(t)}return i!==e.runs&&(o.length===0?Gr(e.runs,i):Kr(e.runs,i,o)),{index:i===e.runs?e:{...e,runs:i},reconcile:!1,reconcileHosts:[...a],refreshProjects:s}}function li(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function ui(e,t,n,r,i,a){return n?(i.onDelta?.(n,void 0),{runs:a.remove(t),reconcile:r}):{runs:e,reconcile:!1}}function di(e,t,n,r){let i=r.at(n.scope,n.id),a=i>=0?e[i]:void 0;if(t.type===`deleted`)return ui(e,i,a,!!(n.truncated&&a?.archived),n,r);let{run:o}=t;if(o.delegation?.role===`worker`)return ui(e,i,a,!1,n,r);if(!a&&!n.isKnownScope())return{runs:e,reconcile:!0};let s=k(a,n.buildRow(o));if(a){if(s===a)return{runs:e,reconcile:!1};n.onDelta?.(a,s);let t=r.replace(i,s);return{runs:t,reconcile:a.archived!==s.archived&&(n.truncated||n.perProjectLimit!==void 0&&Qr(t,n.inScope)>n.perProjectLimit)}}if(n.truncated)return mi(e,s,n.inScope,r,n.onDelta);n.onDelta?.(void 0,s);let c=r.insert(s);return{runs:c,reconcile:s.archived&&n.perProjectLimit!==void 0&&Qr(c,n.inScope)>n.perProjectLimit}}function fi(e,t,n,r){let{project:i}=t,a=di(e.runs,t,{scope:i,id:Xr(t),inScope:e=>e.projectId===i,truncated:e.truncated.includes(i),perProjectLimit:e.perProjectLimit,isKnownScope:()=>li(e,i,n),buildRow:e=>({projectId:i,...e})},r);return{index:a.runs===e.runs?e:Zr(e,a.runs),reconcile:a.reconcile}}function pi(e,t){let n;for(let r of e)t(r)&&r.archived&&(n===void 0||r.createdAt<n)&&(n=r.createdAt);return n}function mi(e,t,n,r,i){let a=pi(e,n),o=a!==void 0&&t.createdAt>a;return t.archived&&!o?{runs:e,reconcile:!1}:(i?.(void 0,t),{runs:r.insert(t),reconcile:t.archived||a===void 0||t.createdAt<a})}function hi(e,t,n,r){let i=!1;for(let[e,a]of Object.entries(n)){let n=r.at(t,e);if(n<0)continue;let o=r.runs[n],s=k(o.usage,a);s!==o.usage&&(r.replace(n,{...o,usage:s}),i=!0)}let a=r.liveUsageIds(t);if(a)for(let e of[...a]){if(Object.prototype.hasOwnProperty.call(n,e))continue;let a=r.at(t,e);if(a<0)continue;let o=r.runs[a];if(o.usage===void 0)continue;let{usage:s,...c}=o;r.replace(a,c),i=!0}return i?r.runs:e}function gi(e,t,n,r){let i=hi(e.runs,t,n,r);return i===e.runs?e:Zr(e,i)}function _i(e,t){let n=e.runs.filter(e=>e.projectId!==t),r=e.truncated.filter(e=>e!==t),i=Object.prototype.hasOwnProperty.call(e.referenceStatuses,t);if(n.length===e.runs.length&&r.length===e.truncated.length&&!i)return e;let a={...e.referenceStatuses};return delete a[t],{...e,runs:n,truncated:r,referenceStatuses:a}}function vi(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function yi(e,t,n){if(e.lastStream===t)e.floor=n===void 0?void 0:Math.max(e.floor??n,n);else{for(let[n,r]of e.changes)r.generation!==t&&e.changes.delete(n);e.floor=n}e.stream=t,e.lastStream=t,e.mismatch=void 0}function bi(e){e.stream=void 0}function xi(e,t){return`hostId`in t?JSON.stringify([e,t.hostId,t.project,Xr(t)]):JSON.stringify([e,t.project,Xr(t)])}function Si(e,t,n=!1){let r=e.stream;if(r===void 0)return!1;(e.floor===void 0||n)&&(e.floor=t.seq-1);let i=xi(r,t),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}var Ci=1e3;function wi(e,t=Ci){if(e.changes.size<=t)return;let n=[...e.changes.entries()].sort((e,t)=>e[1].seq-t[1].seq),r=n.length-t,i;for(let t=0;t<r;t+=1){let[r,a]=n[t];e.changes.delete(r),a.generation===e.lastStream&&(i=i===void 0?a.seq:Math.max(i,a.seq))}i!==void 0&&(e.floor=e.floor===void 0?i:Math.max(e.floor,i))}function Ti(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function Ei(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function Di(e,t,n){if(e.stream!==void 0&&e.stream!==t){let n=e.mismatch!==t;return e.mismatch=t,{mismatch:!0,first:n}}let r=e.lastStream===t&&e.floor!==void 0,i=r&&n<e.floor,a=[...e.changes.entries()].filter(([,e])=>e.generation===t);return{mismatch:!1,covered:r,missed:i,own:a,newer:a.map(([,e])=>e).filter(e=>e.seq>n).sort((e,t)=>e.seq-t.seq)}}function Oi(e,t,n){if(!Ei(t))return{index:t,reconcile:!1};let{generation:r,eventSeq:i}=t,a=Di(e,r,i);if(a.mismatch)return{index:t,reconcile:a.first};let o=si(t,a.newer.map(e=>({type:`change`,change:e})),n);for(let[t,n]of a.own)n.seq<=i&&e.changes.delete(t);return a.covered&&!a.missed&&(e.floor=i),{index:o.index,reconcile:a.missed||o.reconcile}}function ki(e,t,n){if(!Ei(t))return{index:t,reconcile:!1,reconcileHosts:[]};let{generation:r,eventSeq:i}=t,a=Di(e,r,i);if(a.mismatch)return{index:t,reconcile:a.first,reconcileHosts:[]};let o=ci(t,a.newer.map(e=>({type:`change`,change:e})),n);for(let[t,n]of a.own)n.seq<=i&&e.changes.delete(t);return(a.covered&&!a.missed||e.lastStream===r&&e.floor===void 0)&&(e.floor=i),{index:o.index,reconcile:a.missed,reconcileHosts:o.reconcileHosts,refreshProjects:o.refreshProjects}}function Ai(e,t,n){if(e.length===0)return t;let r=$r.get(e)??ti(e,n).positions,i=e.length===t.length,a=!1,o=[];for(let s=0;s<t.length;s+=1){let c=t[s],l=r.get(n(c))?.get(c.id),u=l===void 0?void 0:e[l],d=u===void 0?c:k(u,c);d===u&&(a=!0),i&&d!==e[s]&&(i=!1),o.push(d)}return i?e:a?o:t}function ji(e,t){if(!e||e.generation!==t.generation)return t;let n=Ai(e.runs,t.runs,ri),r=k(e.referenceStatuses,t.referenceStatuses),i=k(e.truncated,t.truncated);return n===e.runs&&r===e.referenceStatuses&&i===e.truncated&&t.perProjectLimit===e.perProjectLimit&&t.eventSeq===e.eventSeq?e:n===t.runs&&r===t.referenceStatuses&&i===t.truncated?t:{...t,runs:n,referenceStatuses:r,truncated:i}}function Mi(e,t){if(!e||e.generation!==t.generation)return t;let n=Ai(e.runs,t.runs,ai),r=k(e.hosts,t.hosts);return n===e.runs&&r===e.hosts&&t.eventSeq===e.eventSeq&&t.warning===e.warning?e:n===t.runs&&r===t.hosts?t:{...t,runs:n,hosts:r}}function Ni(e,t){if(t.length===0)return e;if(e.length===0)return[...t];let n=[],r=0,i=0;for(;r<e.length&&i<t.length;)(e[r].createdAt??``)>=t[i].createdAt?n.push(e[r++]):n.push(t[i++]);for(;r<e.length;)n.push(e[r++]);for(;i<t.length;)n.push(t[i++]);return n}function Pi(e,t,n,r,i){if(t.generation!==e.generation||r.stream!==void 0&&r.stream!==t.generation)return{index:e,fullReconcile:!0,reconcileHosts:[]};let a=[...r.changes.entries()].filter(([,e])=>e.generation===t.generation&&e.hostId===n),o=ci(t,a.map(([,e])=>e).filter(e=>e.seq>t.eventSeq).sort((e,t)=>e.seq-t.seq).map(e=>({type:`change`,change:e})),i);for(let[e,n]of a)n.seq<=t.eventSeq&&r.changes.delete(e);let s=o.index.hosts.find(e=>e.id===n),c=e.hosts.some(e=>e.id===n),l=s?c?e.hosts.map(e=>e.id===n?s:e):[...e.hosts,s]:e.hosts.filter(e=>e.id!==n),u=e.runs.filter(e=>e.hostId!==n),d=o.index.runs.filter(e=>e.hostId===n),f=Ni(u,d);return qr(e.runs,f,n,d),{index:{runs:f,hosts:l,generation:e.generation,eventSeq:e.eventSeq,...t.warning===void 0?{}:{warning:t.warning}},fullReconcile:!1,reconcileHosts:o.reconcileHosts}}var Fi=[`workspace`,`runs-index`],q=[`main`,`hosts`,`runs-index`],Ii=[`workspace`,`projects`],Li=[`main`,`hosts`,`projects`],Ri=6e4,zi=100,Bi=new WeakMap,Vi=new WeakMap;function Hi(e){let t=Bi.get(e);return t||(t=$i(e),Bi.set(e,t)),t}function Ui(e){let t=Vi.get(e);return t||(t=ra(e),Vi.set(e,t)),t}function Wi(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:Hi(t).merge(e)}function Gi(e){let t=e.getQueryData(Ii)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function Ki(e){let t=e.getQueryData(Li)?.hosts;if(!t)return;let n=new Map;for(let e of t)e.projects!==null&&n.set(e.id,new Set(e.projects.map(e=>e.id)));return(e,t)=>n.get(e)?.has(t)}function qi(e,t,n){if(!(!e||typeof e.eventSeq!=`number`||typeof t.eventSeq!=`number`))return e.generation===t.generation?t.eventSeq<e.eventSeq?e:void 0:n!==void 0&&e.generation===n&&t.generation!==n?e:void 0}function Ji(e,t){return t.type===`run-summary`?{type:`run`,project:e,seq:t.seq,run:t.summary}:{type:`deleted`,project:e,seq:t.seq,id:t.id}}function Yi(e){return e.type===`host-run-summary`?{type:`run`,hostId:e.hostId,project:e.project,seq:e.seq,run:e.summary}:{type:`deleted`,hostId:e.hostId,project:e.project,seq:e.seq,id:e.id}}function Xi(e){let t,n,r=-1/0;return{markWrite(){r=Date.now()},cancelPending:()=>{t!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(t),t=void 0,clearTimeout(n),n=void 0},schedule(){if(n!==void 0)return;let i=r+250-Date.now();if(i>0){n=setTimeout(e,i);return}n=setTimeout(e,zi),typeof requestAnimationFrame==`function`&&(t=requestAnimationFrame(e))}}}function Zi(e){let t,n,r=!1,i=()=>{clearTimeout(t),t=void 0;let a=e().catch(()=>void 0).finally(()=>{n===a&&(n=void 0,r&&(r=!1,i()))});return n=a,a};return{isInFlight(){return n!==void 0},reconcile(e={}){return n?(r=!0,n):e.hold?(t??=setTimeout(()=>{i()},400),Promise.resolve()):i()},stop(){clearTimeout(t),t=void 0,r=!1}}}function Qi(e,t){let n=e.getQueryCache().find({queryKey:t,exact:!0});return n!==void 0&&n.state.data===void 0&&n.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:t,exact:!0}).then(()=>e.invalidateQueries({queryKey:t})):e.invalidateQueries({queryKey:t})}function $i(e){let t=vi(),n=[],r=new Set,i=!1,a,o=!1,s=()=>e.getQueryData(Fi),c=Zi(()=>Qi(e,Fi)),l=()=>{if(!i){if(i=!0,a?.()){o=!0;return}c.reconcile({hold:!0})}},u=()=>{d.cancelPending();let t=n;n=[];let i=s();if(!i||t.length===0)return;let a=Gi(e),{index:o,reconcile:l}=si(i,t.filter(e=>e.generation===i.generation?e.type===`usage`?!r.has(e.project):!r.has(e.change.project)&&e.change.seq>i.eventSeq:!1),a);o!==i&&f(o),l&&c.reconcile({hold:!0})},d=Xi(u),f=t=>{d.markWrite(),e.setQueryData(Fi,t)};return{ready(e,n){yi(t,e,n),i=!1,o&&(o=!1,c.reconcile({hold:!0}))},detach(){bi(t)},run(e,i,a=!1){if(r.has(e))return;let o=Ji(e,i);if(!Si(t,o,a)){l();return}n.push({type:`change`,change:o,generation:t.stream}),d.schedule()},usage(e,i){if(!r.has(e)){if(t.stream===void 0){l();return}n.push({type:`usage`,project:e,usage:i,generation:t.stream}),d.schedule()}},dropProject(e){r.add(e),Ti(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let i=s();if(!i)return;let a=_i(i,e);a!==i&&f(a)},setUnknownGenerationHandler(e){a=e},restoreProject(e){r.delete(e)},merge(n){let i=s(),a=Oi(t,n,Gi(e));for(let e of r)a.index=_i(a.index,e);return a.reconcile&&queueMicrotask(()=>{c.reconcile({hold:!0})}),qi(i,n,t.stream)??ji(i,a.index)},reconcile:c.reconcile,flush:u,stop(){d.cancelPending(),c.stop(),n=[]}}}var ea=[1e3,2e3,4e3,8e3,15e3],ta=6e4;function na(e,t){e.setQueryData(q,e=>{if(!e)return e;let n=e.hosts.find(e=>e.id===t);return!n||n.stale?e:{...e,hosts:e.hosts.map(e=>e.id===t?{...e,stale:!0}:e)}})}function ra(e,t=e=>xn({hostId:e}),n=ea,r=ta,i=e=>xn({signal:e})){let a=vi(),o=Pn(),s=new Map,c=new Map,l=new Map,u=0,d,f=[],ee=!1,te,p=!1,ne=!1,re=!1,m,h,g,_=!1,v=0,ie=0,ae=!1,y=new Map,b=()=>e.getQueryData(q),x=()=>e.getQueryCache().find({queryKey:q,exact:!0}),oe=()=>{re||(re=!0,e.invalidateQueries({queryKey:Li,exact:!0}).finally(()=>{re=!1}))},se=e=>{let t=l.get(e);t!==void 0&&(clearTimeout(t),l.delete(e))},ce=()=>{d!==void 0&&(clearTimeout(d),d=void 0),u=0},le=()=>{for(let e of l.values())clearTimeout(e);l.clear(),c.clear(),ce()},S=Zi(()=>x()?(ne=!0,Qi(e,q)):Promise.resolve()),ue=()=>{if(!ee){if(ee=!0,te?.()){p=!0;return}S.reconcile({hold:!0})}},de=()=>{if((x()?.getObserversCount()??0)===0)return;let e=n[u]??r;u+=1,d!==void 0&&clearTimeout(d),d=setTimeout(()=>{d=void 0,S.reconcile()},e)},fe=e=>{if((x()?.getObserversCount()??0)===0)return;let t=c.get(e)??0,i=n[t]??r;c.set(e,t+1),se(e),l.set(e,setTimeout(()=>{l.delete(e),w([e])},i))},pe=t=>{na(e,t),fe(t)},me=(t,n)=>{let r=b();if(!r)return!1;if(n.generation!==r.generation||a.stream!==void 0&&a.stream!==n.generation)return S.reconcile(),!0;let i=s.get(t)??r.eventSeq;if(n.eventSeq<i)return pe(t),!1;let o=Pi(r,n,t,a,Ki(e));if(o.fullReconcile)return S.reconcile(),!0;let l=o.index.hosts.find(e=>e.id===t);l?(s.set(t,n.eventSeq),l.state===`connected`&&l.stale?fe(t):(se(t),c.delete(t))):(se(t),c.delete(t),s.delete(t));let u=Mi(r,o.index);return u!==r&&ve(u),o.reconcileHosts.length>0&&w(o.reconcileHosts,{hold:!0}),!1},he=(t={})=>{let n=x();if(!n)return Promise.resolve();if(n.getObserversCount()===0)return e.invalidateQueries({queryKey:q,exact:!0,refetchType:`none`}),Promise.resolve();if(!b())return S.reconcile(t)},ge=()=>{let t=x();return!t||t.state.fetchStatus!==`fetching`?Promise.resolve():new Promise(n=>{let r=e.getQueryCache().subscribe(e=>{e.query===t&&t.state.fetchStatus!==`fetching`&&(r(),n())})})},C=()=>{clearTimeout(m),m=void 0;let e=v;if(g||_)return(g??Promise.resolve()).then(()=>{if(!(v!==e||y.size===0))return C()});if(h)return h;let n=[...y.entries()];if(y.clear(),ae=!1,n.length===0)return Promise.resolve();let r=he();if(r)return r;let i=e=>{for(let t=e;t<n.length;t+=1){let[e,r]=n[t];y.has(e)||y.set(e,r)}},a=(async()=>{for(let r=0;r<n.length;r+=1){let[a]=n[r];if(v!==e)break;if(_){i(r);break}try{let n=await t(a);if(v!==e)break;if(me(a,n)){i(r+1);break}}catch{if(v===e){if(_){i(r);break}pe(a)}}}})().finally(()=>{h===a&&(h=void 0,!_&&!g&&v===e&&y.size>0&&(ae?C():m??=setTimeout(()=>{C()},400)))});return h=a,a},w=(e,t={})=>{if(e.length===0)return Promise.resolve();let n=he(t);if(n)return n;for(let t of e)y.set(t,++ie);return t.hold||(ae=!0),h||(t.hold&&!ae&&!g&&!_?(m??=setTimeout(()=>{C()},400),Promise.resolve()):C())},_e=()=>{T.cancelPending();let t=f;f=[];let n=b();if(!n||t.length===0)return;let{index:r,reconcileHosts:i,refreshProjects:a}=ci(n,t.filter(e=>{if(e.generation!==n.generation)return!1;if(e.type===`usage`)return!0;let t=s.get(e.change.hostId)??n.eventSeq;return e.change.seq>t}),Ki(e));r!==n&&ve(r),a&&oe(),i.length>0&&w(i,{hold:!0})},T=Xi(_e),ve=t=>{T.markWrite(),e.setQueryData(q,t)},ye=e=>{let t=new Set(e.filter(e=>e.state===`connected`&&e.stale).map(e=>e.id));for(let e of[...l.keys()])t.has(e)||(se(e),c.delete(e));for(let e of[...c.keys()])t.has(e)||c.delete(e);for(let e of t)l.has(e)||fe(e)},be=t=>{let n=b(),r=ki(a,t,Ki(e)),i=qi(n,t,a.stream)??(s.clear(),ye(r.index.hosts),(a.stream===t.generation||a.lastStream===t.generation)&&o.seed(t.eventSeq),Mi(n,r.index)),c=v;return r.refreshProjects&&queueMicrotask(()=>{v===c&&oe()}),r.reconcile?queueMicrotask(()=>{v===c&&S.reconcile({hold:!0})}):r.reconcileHosts.length>0&&queueMicrotask(()=>{v===c&&w(r.reconcileHosts,{hold:!0})}),i};return{ready(e){let t=a.lastStream;yi(a,e),ee=!1;let n=b(),r=t!==void 0&&t!==e||n!==void 0&&n.generation!==e,i=t===void 0&&(n!==void 0||x()?.state.fetchStatus===`fetching`),s=ne&&S.isInFlight();ne=!1,r?o.reset():i&&n&&o.seed(n.eventSeq),(r||p||i)&&!s?(p=!1,S.reconcile({hold:!0})):s&&(p=!1)},detach(){bi(a),o.reset(),ne=!1},run(e){let t=o.frame(e.seq),n=Yi(e);if(!Si(a,n,t)){ue();return}wi(a),f.push({type:`change`,change:n,generation:a.stream}),T.schedule(),t&&S.reconcile({hold:!0})},usage(e,t,n){if(a.stream===void 0){ue();return}f.push({type:`usage`,hostId:e,project:t,usage:n,generation:a.stream}),T.schedule()},setUnknownGenerationHandler(e){te=e},fetchFull:e=>{_=!0,clearTimeout(m),m=void 0;let t=v,n=g,r=h,a=(async()=>{if(n&&await n,r&&await r.catch(()=>void 0),v!==t||e?.aborted)throw e?.reason??new DOMException(`Aborted`,`AbortError`);let a=ie,o;try{o=await i(e)}catch(n){throw v===t&&!e?.aborted&&de(),n}if(v!==t||e?.aborted)throw e?.reason??new DOMException(`Aborted`,`AbortError`);ce();for(let[e,t]of[...y.entries()])t<=a&&y.delete(e);return be(o)})(),o;return o=a.then(()=>ge(),()=>void 0).then(()=>{g===o&&(g=void 0,_=!1,v===t&&y.size>0&&C())}),g=o,a},merge:be,reconcile:S.reconcile,reconcileHosts:w,reconcileFinite(){let t=b();if(!t)return S.reconcile();let n=e.getQueryData(Li)?.hosts??[],r=[...new Set([...t.hosts.map(e=>e.id),...n.map(e=>e.id)])];return r.length===0?S.reconcile():w(r)},flush:_e,stop(){v+=1,_=!1,g=void 0,h=void 0,T.cancelPending(),S.stop(),clearTimeout(m),m=void 0,le(),ae=!1,y.clear(),f=[]}}}var ia=(e,t,n)=>[`host`,e,t,`runs`,`detail`,n],J={get health(){return[n(),`health`]},runs:{get all(){return[n(),`runs`]},relationships:e=>[n(),`runs`,`relationships`,e],list:(e=n())=>[e,`runs`,`list`],archived:e=>[n(),`runs`,`archived`,e],detail:(e,t=n())=>[t,`runs`,`detail`,e],diff:e=>[n(),`runs`,`diff`,e],changes:e=>[n(),`runs`,`changes`,e],file:(e,t)=>[n(),`runs`,`files`,e,t],handoff:e=>[n(),`runs`,`handoff`,e],commits:e=>[n(),`runs`,`commits`,e],commit:(e,t)=>[n(),`runs`,`commit`,e,t]},get workflows(){return[n(),`workflows`]},runnerSkills:(e,t,r=n())=>[r,`runner-skills`,e,t??null],get repo(){return[n(),`repo`]},get repoChanges(){return[n(),`repo`,`changes`]},repoCommit:e=>[n(),`repo`,`commit`,e],get repoBranches(){return[n(),`repo`,`branches`]},get uiState(){return[n(),`ui-state`]},get config(){return[n(),`config`]},get agentConfig(){return[n(),`agent-config`]},agentConfigFile:e=>[n(),`agent-config`,`file`,e],get sessionContext(){return[n(),`session-context`]},sessionContextPreview:(e,t,r=``)=>[n(),`session-context`,`preview`,t,e,r],get worktrees(){return[n(),`worktrees`]},github:(e={})=>[n(),`github`,e.limit??null],githubPages:e=>[n(),`github`,`pages`,e],githubPagesHead:e=>[n(),`github`,`pages-head`,e],githubCommentCounts:(e,t)=>[n(),`github`,`comment-counts`,e,[...t].sort((e,t)=>e-t).join(`,`)],githubChecks:e=>[n(),`github`,`checks`,[...e].sort((e,t)=>e-t).join(`,`)],githubSearch:(e,t)=>[n(),`github`,`search`,e,t],githubRefStatus:(e,t,n,r)=>{let i=[e,`github`,`ref-status`,[...t].sort((e,t)=>e-t).join(`,`),[...n].sort((e,t)=>e-t).join(`,`)];return r===void 0?i:[`host`,r,...i]},githubComments:(e,t)=>[n(),`github`,`comments`,e,t],githubItem:(e,t)=>[n(),`github`,`item`,e,t],githubRefStatusOf:e=>[e,`github`,`ref-status`],githubPrChanges:e=>[n(),`github`,`pr-changes`,e],githubMergeState:e=>[n(),`github`,`merge-state`,e],get openTargets(){return[n(),`open-targets`]}},Y={models:(e,t)=>t&&t!=="default"?[`workspace`,`models`,e,t]:[`workspace`,`models`,e],providerStatus:[`workspace`,`providers`,`status`],projects:[`workspace`,`projects`],githubOwners:[`workspace`,`github-owners`],runsIndex:Fi,runsSearch:e=>[`workspace`,`runs-search`,e],uiState:[`workspace`,`ui-state`],config:[`workspace`,`config`],agentProfiles:[`workspace`,`agent-profiles`],agentAccountStatus:e=>[`workspace`,`agent-profiles`,`status`,e],fsBrowseRoot:[`workspace`,`fs-browse`],fsBrowse:(e,t=!1)=>[...Y.fsBrowseRoot,e,t]},aa=[`workspace`,`runs-index`],oa=e=>[e.cacheScope,`runs`,`list`],X=e=>e.hostId===void 0?[e.cacheScope,`runs`,`detail`,e.runId]:ia(e.hostId,e.projectId,e.runId),Z=e=>typeof e==`function`?e():e;function sa(e){let{seenAt:t,...n}=e;return n}function ca(e,t){let n=sa(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function la(e,t,n){return t?{...e,seenAt:n}:sa(e)}function ua(e,t,n){let r={...e},i=t;for(let e of n)Object.prototype.hasOwnProperty.call(i,e)&&i[e]!==void 0?r[e]=i[e]:delete r[e];return r}function da(e,t){let n=new Set([...Object.keys(e),...Object.keys(t)]),r=[];for(let i of n)Object.is(e[i],t[i])||r.push(i);return r}function fa(e){let t=()=>{e.invalidateQueries({queryKey:aa})};function r(r,i){if(r===`index`)return t();let a=typeof i==`function`?i():i;if(a.hostId!==void 0)return r===`indexed`?void 0:e.invalidateQueries({queryKey:[`host`,a.hostId,a.projectId,`runs`]});if(r===`indexed`){t(),e.invalidateQueries({queryKey:[n(),`runs`]}),e.invalidateQueries({queryKey:[a.projectId,`runs`,`list`]});return}if(r===`runs`)return e.invalidateQueries({queryKey:[a.cacheScope,`runs`]});let o=ct(),s=[a.projectId,a.cacheScope],c=o!==void 0&&s.some(e=>e===o||e==="default")?[o,`default`]:[],l=new Set([...s,...c,n()]);return Promise.all([...l].map(t=>e.invalidateQueries({queryKey:[t,`runs`]}))).then(()=>void 0)}let i=(e,t,n)=>r=>r.id===(e?t:n.id)?la(r,e,n.seenAt):r;async function a(t,n){let r=t.runId,a=new Date().toISOString(),o=e=>e.hostId===t.hostId&&e.projectId===t.projectId&&e.id===r,s=t=>{e.setQueryData(q,e=>e===void 0?e:{...e,runs:e.runs.map(e=>o(e)?t(e):e)})},c=e.getQueryData(X(t)),l=e.getQueryData(q)?.runs.find(o);return e.setQueryData(X(t),e=>e&&la(e,n,a)),s(e=>la(e,n,a)),{id:r,prevList:void 0,prevDetail:c,rollback(){c&&e.setQueryData(X(t),e=>e&&ca(e,c)),l&&s(e=>ca(e,l))},settle(a){let o=i(n,r,a);e.setQueryData(X(t),e=>e?o(e):a),s(o)}}}async function o(n,r){let o=Z(n);if(o.hostId!==void 0)return a(o,r);await e.cancelQueries({queryKey:oa(Z(n))}),await e.cancelQueries({queryKey:X(Z(n))});let s=e.getQueryData(oa(Z(n))),c=e.getQueryData(X(Z(n))),l=Z(n).runId,u=new Date().toISOString();return e.setQueryData(oa(Z(n)),e=>e?.map(e=>e.id===l?la(e,r,u):e)),e.setQueryData(X(Z(n)),e=>e&&la(e,r,u)),{id:l,prevList:s,prevDetail:c,rollback(){if(!r){s&&e.setQueryData(oa(Z(n)),s),c&&e.setQueryData(X(Z(n)),c);return}let t=s?.find(e=>e.id===l);t&&e.setQueryData(oa(Z(n)),e=>e?.map(e=>e.id===l?ca(e,t):e)),c&&e.setQueryData(X(Z(n)),e=>e&&ca(e,c))},settle(a){let o=i(r,l,a);e.setQueryData(oa(Z(n)),e=>e?.map(o));let s={...Z(n),runId:r?l:a.id};e.setQueryData(X(s),e=>e?o(e):a),t()}}}async function s(t,n){if(t.hostId!==void 0){let r=e.getQueryData(q),i=r?.runs.find(e=>e.hostId===t.hostId&&e.projectId===t.projectId&&e.id===t.runId),a=n(),o=i?a(i):void 0,s=i&&o?da(i,o):[];return e.setQueryData(q,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.hostId===t.hostId&&e.projectId===t.projectId&&e.id===t.runId?{...a(e),hostId:e.hostId}:e)}),{previous:r,rollback(){!i||s.length===0||e.setQueryData(q,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.hostId===t.hostId&&e.projectId===t.projectId&&e.id===t.runId?ua(e,i,s):e)})},settle(){}}}await e.cancelQueries({queryKey:aa});let i=e.getQueryData(aa),a=n();return e.setQueryData(aa,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.projectId===t.projectId&&e.id===t.runId?a(e):e)}),{previous:i,rollback(){i&&e.setQueryData(aa,i)},settle(){r(`indexed`,t)}}}return{patchRead:o,patchIndex:s,invalidateAfter:r}}function pa(){let e=D();return(0,B.useMemo)(()=>fa(e),[e])}function ma(e,t){if(!rn(e.path))throw Error(`unsupported shared read`);let n=new URL(e.path,`http://cezar.invalid`);return n.searchParams.sort(),kt({kind:`read`,path:`${n.pathname}${n.search}`,intervalMs:e.intervalMs},{value:t})}function ha(e,t,n,r){let i=D(),a=JSON.stringify(t),o=(0,B.useMemo)(()=>JSON.parse(a),[a]);(0,B.useEffect)(()=>{if(!e||n===!1)return;let t=!0,a=ma({path:e,intervalMs:n},(e,n)=>{n||i.cancelQueries({queryKey:o,exact:!0}).then(()=>{t&&i.setQueryData(o,r?r(e,i):e)})});return()=>{t=!1,a()}},[i,e,o,n,r])}async function ga(e,t=!1){return vt(await Kt.api.v1.p[`:projectId`].runs[`:id`][`worker-destroy`].$post({param:{projectId:n(),id:encodeURIComponent(e)},query:{},json:t?{discardWork:!0}:{}}),u(e,`/worker-destroy`))}function _a(){return O({queryKey:J.openTargets,queryFn:({signal:e})=>Xt({signal:e}),staleTime:5*6e4})}function va(e=!0,t){return O({queryKey:t?J.runs.list(t):J.runs.list(),queryFn:({signal:e})=>Se(H(t?{projectId:t}:void 0),{signal:e}),enabled:e})}function ya(e,t){return f({queryKey:J.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>pt({before:t,limit:200,q:e},{signal:n}),getNextPageParam:e=>e.nextCursor??void 0,placeholderData:(e,t)=>t?.queryKey[0]===n()?e:void 0})}function ba(e){let t=e.trim();return O({queryKey:Y.runsSearch(t),queryFn:({signal:e})=>C(t,{signal:e}),enabled:t.length>=2,placeholderData:It,staleTime:1e4})}function xa(e=!0,t=Ri,n){let r=Hi(D());return ha(`/api/v1/workspace/runs-index`,Y.runsIndex,W(e?t:!1),Wi),O({queryKey:Y.runsIndex,queryFn:({signal:e})=>De({signal:e}).then(r.merge),enabled:e,...n?{select:n}:{},structuralSharing:!1,staleTime:3e4,refetchInterval:!1})}function Sa(e){let t=D();return V({mutationFn:({workerId:e,discardWork:t=!1})=>ga(e,t),onSettled:()=>t.invalidateQueries({queryKey:J.runs.relationships(e)})})}function Ca(e,t={}){return O({queryKey:J.runs.relationships(e),queryFn:({signal:t})=>ve(e,{signal:t}),enabled:t.enabled??!0})}function wa(e){return O({queryKey:J.runs.detail(e??``),queryFn:({signal:t})=>Pe(U(e),{signal:t}),enabled:!!e})}function Ta(e,t,n=!0,r){let i=r?.hostId;return O({queryKey:i===void 0?[e??`default`,`runs`,`detail`,t??``]:ia(i,e??`default`,t??``),queryFn:({signal:n})=>Pe(U(t,{projectId:e,hostId:i}),{signal:n}),enabled:n&&!!e&&!!t,...r?.staleTime===void 0?{}:{staleTime:r.staleTime},...r?.refetchOnMount===void 0?{}:{refetchOnMount:r.refetchOnMount}})}function Ea(e,t){return O({queryKey:t?[t,`runs`,`diff`,e??``]:J.runs.diff(e??``),queryFn:({signal:n})=>g(e,{signal:n,...t?{projectId:t}:{}}),enabled:!!e})}function Da(e,t=!1){return ha(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/changes`:void 0,J.runs.changes(e??``),W(t?4e3:!1)),O({queryKey:J.runs.changes(e??``),queryFn:({signal:t})=>re(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function Oa(e,t){return O({queryKey:J.runs.file(e??``,t??``),queryFn:({signal:n})=>Te(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function ka(e,t){return O({queryKey:[n(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>it(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Aa(e,t){return O({queryKey:[n(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>Ze(e,t,{signal:n}),enabled:t!==null,retry:!1})}function ja(e,t){return O({queryKey:[n(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>Wt(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Ma(e){return O({queryKey:[n(),`runs`,`artifacts`,e],queryFn:({signal:t})=>$t(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function Na(e,t=!1){return ha(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/commits`:void 0,J.runs.commits(e??``),W(t?5e3:!1)),O({queryKey:J.runs.commits(e??``),queryFn:({signal:t})=>ie(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function Pa(e,t){return O({queryKey:J.runs.commit(e??``,t??``),queryFn:({signal:n})=>qt(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function Fa(e,t=!0){return O({queryKey:J.runs.handoff(e??``),queryFn:({signal:t})=>xt(U(e),{signal:t}),enabled:!!e&&t})}function Ia(e,t,n,r){return O({queryKey:r===void 0?e===void 0?J.runs.handoff(t):[e,`runs`,`handoff`,t]:[`host`,r,e??`default`,`runs`,`handoff`,t],queryFn:({signal:n})=>xt(U(t,{projectId:e,hostId:r}),{signal:n}),enabled:n,staleTime:15e3})}function La(e){return typeof e==`object`&&e?{projectId:e.projectId,hostId:e.hostId}:{projectId:e,hostId:void 0}}function Ra(e,t){let r=new Map;for(let t of e){let e=La(t);r.set(JSON.stringify([e.hostId??null,e.projectId??null]),e)}let i=[...r.values()],a=gn({queries:i.map(({projectId:e,hostId:r})=>({queryKey:r===void 0?[e??n(),`automations`,`names`]:[`host`,r,e??n(),`automations`,`names`],queryFn:({signal:t})=>Vt({signal:t,archived:`include`,...e===void 0?{}:{projectId:e},...r===void 0?{}:{hostId:r}}),enabled:t,staleTime:6e4,retry:!1}))}),o=a.map(e=>e.data);return(0,B.useMemo)(()=>{let e=new Map;return o.forEach((t,n)=>{if(!t?.available)return;let r=i[n];for(let n of t.automations)e.set(JSON.stringify([r.hostId??null,r.projectId??null,n.id]),n.name)}),(t,n,r)=>e.get(JSON.stringify([r??null,t??null,n]))},[JSON.stringify([i,a.map(e=>e.dataUpdatedAt)])])}function za(e){let t=D();return V({mutationFn:t=>de(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function Ba(e){let t=D();return V({mutationFn:t=>ze(e,t),onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function Va(e){let t=pa(),n=e?.projectId,r=e?.cacheScope,i=e?.hostId,a=V({mutationFn:e=>me(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),o=(0,B.useCallback)(e=>({...U(e,{projectId:n,cacheScope:r,hostId:i}),id:e}),[n,r,i]),s=(0,B.useCallback)(e=>({onSuccess:(t,n,r,i)=>e?.onSuccess?.(t,n.id,r,i),onError:(t,n,r,i)=>e?.onError?.(t,n.id,r,i),onSettled:(t,n,r,i,a)=>e?.onSettled?.(t,n,r.id,i,a)}),[]),{mutate:c,mutateAsync:l}=a,u=(0,B.useCallback)((e,t)=>c(o(e),s(t)),[c,o,s]),d=(0,B.useCallback)((e,t)=>l(o(e),s(t)),[l,o,s]);return{...a,variables:a.variables?.id,mutate:u,mutateAsync:d}}function Ha(e){let t=pa(),n=e?.projectId,r=e?.cacheScope,i=e?.hostId;return V({mutationFn:e=>me(U(e,{projectId:n,cacheScope:r,hostId:i}),!1),onMutate:e=>t.patchRead(()=>U(e,{projectId:n,cacheScope:r,hostId:i}),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function Ua(e){let t=pa();return V({mutationFn:({id:t,pinned:n})=>S(U(t,e),n),onError:e=>Qe(`Could not update pin. ${Fe(e)} Please retry.`,{tone:`danger`}),onMutate:()=>e??H(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function Wa(e,t,r){let i=pa();return V({...r===void 0?{}:{mutationKey:ia(r,t??n(),e)},mutationFn:n=>Pt(U(e,{projectId:t,hostId:r}),n),onMutate:()=>H({projectId:t,hostId:r}),onSuccess:(e,t,n)=>i.invalidateAfter(`send`,n),onError:(e,t,n)=>{e instanceof ne&&e.status===409&&n&&i.invalidateAfter(`send`,n)}})}function Ga(e,t,r){let i=pa();return V({...r===void 0?{}:{mutationKey:ia(r,t??n(),e)},mutationFn:(n={})=>ot(U(e,{projectId:t,hostId:r}),n),onMutate:()=>H({projectId:t,hostId:r}),onSuccess:(e,t,n)=>i.invalidateAfter(`continue`,n)})}function Ka(e){let t=D();return V({mutationFn:({msgId:t,message:n})=>jt(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function qa(e){let t=D();return V({mutationFn:t=>He(e,t),onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function Ja(e,t=!0,n=!1,r){return O({queryKey:[H({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>Se(H({projectId:e,boot:n}),{signal:t}),enabled:t,...r?{select:r}:{},placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function Ya(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:Y.models(t),refetchType:n})}function Xa(e,t=!0,n){return O({...Za(e,n),enabled:t})}var Za=(e,t)=>({queryKey:Y.models(e,t),queryFn:({signal:n})=>be(e,{signal:n},t),staleTime:300*1e3});function Qa(e,t=!0){let n=gn({queries:e.map(e=>({...Za(e),enabled:t}))});return Object.fromEntries(e.map((e,t)=>[e,n[t]]))}var $a=R([`own`,`provider-spanning`]),eo=j({suggested:F(j({id:L(),label:L(),desc:L()})),retired:F(L())}),to=j({id:R([`settings`,`mcp`,`memory`]),label:L(),note:L().optional(),empty:L().optional(),showsUserMcp:P(!0).optional()}),no=j({label:L(),note:L().optional(),groups:F(to)}),ro=j({runners:F(j({id:Ae,displayName:L(),modelListName:L(),modelIdScope:$a,pickerLabel:L(),pickerDescription:L(),icon:L(),installHint:L(),loginCommand:L(),terminalLogin:I().optional(),browserLogin:I().optional(),managedInstall:P(!0).optional(),accountFolderExample:L().optional(),models:eo,agentConfig:no}))}),io=[`workspace`,`runners`];async function ao(e){return T(await Kt.api.v1.runners.$get({},h(e)),`/runners`,ro)}var oo={queryKey:io,queryFn:({signal:e})=>ao({signal:e}),staleTime:1/0};function so(){return O(oo)}function co(e){return e?.runners??[]}function lo(e){return co(e).map(e=>e.id)}function uo(e,t){if(e!==void 0)return t.includes(e)?e:t[0]}function fo(e){let t=so();return{runner:t.isSuccess?uo(e,lo(t.data))??e:e,ready:!t.isPending}}function po(e,t){return e?.runners.find(e=>e.id===t)}function mo(e,t){return po(e,t)?.displayName??t}function ho(e,t){return po(e,t)?.pickerLabel??t}function go(e,t){return po(e,t)?.modelListName}function _o(e,t,r=!0,i){let a=Ds(i,r),o=gs(),{runner:s,ready:c}=fo(e??a.data?.defaultRunner??`claude`),l=o.data?.capabilities?.localHandoff===!1?null:t,u=i??n(),d=O({queryKey:J.runnerSkills(s,l,u),queryFn:({signal:e})=>_(s,l,{signal:e,projectId:u}),enabled:r&&c&&(e!==void 0||!a.isPending)&&(!t||!o.isPending),retry:!1});return{...d,runner:s,account:l,data:d.data?.skills,list:d.data,unchecked:d.isError||!d.data||d.data.source===`unavailable`}}var vo={draft:{label:`Draft`,hint:`the author has not marked it ready for review`,tone:`neutral`},"review-required":{label:`Waiting for review`,hint:`checks are fine, no one has reviewed it yet`,tone:`info`},"changes-requested":{label:`Changes requested`,hint:`a reviewer asked for edits before this can merge`,tone:`danger`},"checks-pending":{label:`Checks running`,hint:`CI has not finished on the latest commit`,tone:`pending`},"checks-failing":{label:`Checks failing`,hint:`CI is red on the latest commit`,tone:`danger`},ready:{label:`Ready to merge`,hint:`open, checks pass, nothing is waiting on a reviewer`,tone:`success`},merged:{label:`Merged`,hint:`this landed on its base branch`,tone:`merged`},closed:{label:`Closed`,hint:`closed without merging — the work did not land`,tone:`danger`},open:{label:`Open`,hint:`still open on the tracker`,tone:`success`},completed:{label:`Closed as completed`,hint:`the issue was resolved`,tone:`accent`},"not-planned":{label:`Closed as not planned`,hint:`the issue was declined — nothing shipped for it`,tone:`neutral`}},yo={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function bo(e){return typeof e==`string`&&Object.hasOwn(vo,e)}function xo(e){return e!==void 0&&bo(e)?vo[e]:void 0}var So=`cez.reference-statuses.v1`,Co=`cez.reference-conflicts.v1`,Q=new Map(ko()),wo=1e3,$=new Set(Ao()),To=i()??`__local__`;function Eo(){let e=i()??`__local__`;if(To!==e){To=e,clearTimeout(jo),jo=void 0,Q.clear();for(let[e,t]of ko())Q.set(e,t);$.clear();for(let e of Ao())$.add(e)}}function Do(e,t){if(Eo(),Q.get(e)!==t){for(Q.delete(e),Q.set(e,t);Q.size>wo;){let e=Q.keys().next().value;if(e===void 0)break;Q.delete(e)}Mo()}}function Oo(e,t){if(Eo(),$.has(e)!==t){if(t)for($.add(e);$.size>wo;){let e=$.values().next().value;if(e===void 0)break;$.delete(e)}else $.delete(e);Mo()}}function ko(){try{let e=globalThis.sessionStorage?.getItem(on(So));if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>Array.isArray(e)&&e.length===2&&typeof e[0]==`string`&&bo(e[1])):[]}catch{return[]}}function Ao(){try{let e=globalThis.sessionStorage?.getItem(on(Co));if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var jo;function Mo(){if(jo!==void 0)return;let e=on(So),t=on(Co);jo=setTimeout(()=>{jo=void 0;try{globalThis.sessionStorage?.setItem(e,JSON.stringify([...Q])),globalThis.sessionStorage?.setItem(t,JSON.stringify([...$]))}catch{}},250)}var No=e=>e.hostId===void 0?`${e.projectId}\u0000${e.kind}#${e.number}`:`host:${e.hostId}\u0000${e.projectId}\u0000${e.kind}#${e.number}`;function Po(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function Fo(e){let t=e.hostId===void 0?{}:{hostId:e.hostId};return[...e.prs.map(n=>({...t,projectId:e.projectId,kind:`PR`,number:n})),...e.issues.map(n=>({...t,projectId:e.projectId,kind:`Issue`,number:n}))]}function Io(e,t,n,r,i,a){let o=r.prs[n.number]??r.issues[n.number];if(!o){e.set(t,{state:`unknown`,...i?{status:i}:{}});return}let s=r.conflicts?r.conflicts.includes(n.number):void 0;Do(t,o),s!==void 0&&Oo(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function Lo(e,t,n){Eo();let r=No(t),i=Q.get(r),a=$.has(r)?!0:void 0,o=n.data;if(o?.available){Io(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...Po(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...Po(i,a)});return}e.set(r,{state:`loading`,...Po(i,a)})}function Ro(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of Fo(i))Lo(n,e,t)}),n}function zo(e){if(!e)return;let t=e.trim().replace(/\/+$/,``),n=/^(?:https?|ssh|git|git\+ssh):\/\/(?:[^@/]+@)?([^/:]+)(?::\d+)?\/(.+)$/.exec(t),r=n?null:/^(?:[^@/:]+@)?([^:/]+):(.+)$/.exec(t),i=n??r;if(!i)return;let[,a,o]=i;if(!o||a?.toLowerCase()!==`github.com`)return;let s=o.replace(/\.git$/i,``).split(`/`).filter(Boolean),c=s[s.length-2],l=s[s.length-1];return c&&l?`https://github.com/${c}/${l}`:void 0}function Bo(e){let t=new Map;for(let n of e)for(let e of n.tags??[]){let n=e.toLowerCase();t.has(n)||t.set(n,e)}return[...t.values()].sort((e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`}))}function Vo(e,t,n,r=8){let i=n.trim().toLowerCase(),a=new Set(t.map(e=>e.toLowerCase())),o=e.filter(e=>{let t=e.toLowerCase();return a.has(t)?!1:i===``||t.includes(i)&&t!==i});return i===``?o.slice(0,r):o.sort((e,t)=>Number(t.toLowerCase().startsWith(i))-Number(e.toLowerCase().startsWith(i))||e.localeCompare(t,void 0,{sensitivity:`base`})).slice(0,r)}function Ho(e){let t=new Map;for(let n of e){let e=n.trim();if(!e)continue;let r=e.toLowerCase();t.has(r)||t.set(r,e)}return[...t.values()].sort((e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`}))}function Uo(e,t){return kt({kind:`topic`,topic:e},{value:t})}function Wo(){let e=D();return O({queryKey:Y.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(Y.providerStatus),r=await Lt(!1,{signal:t});return y(n,e.getQueryData(Y.providerStatus),r)},staleTime:5*6e4,refetchInterval:W(!1),refetchOnWindowFocus:!0})}function Go(){let e=D();return V({mutationFn:()=>Lt(!0),onMutate:()=>e.getQueryData(Y.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Y.providerStatus,e=>y(r,e,t)),Ya(e)}})}function Ko(){let e=D();return V({mutationFn:({provider:e,authFailureId:t})=>ft(e,t),onMutate:()=>e.getQueryData(Y.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Y.providerStatus,e=>y(r,e,t,n.authFailureId)),Ya(e,n.provider)}})}function qo(e={}){return O({queryKey:Y.projects,queryFn:({signal:e})=>Ot({signal:e}),...e})}function Jo(e,t=!1){return O({queryKey:Y.fsBrowse(e,t),queryFn:({signal:n})=>qe(e??void 0,{signal:n,showHidden:t}),retry:!1})}function Yo(){let e=D();return V({mutationFn:e=>dt(e),onSuccess:()=>e.invalidateQueries({queryKey:Y.projects})})}function Xo(){let e=D();return V({mutationFn:e=>Tt(e),retry:!1,onSuccess:(t,n)=>{e.setQueryData(Y.projects,e=>e&&{...e,projects:e.projects.filter(e=>e.id!==n)}),e.invalidateQueries({queryKey:Y.projects})}})}function Zo(){let e=D();return V({mutationFn:e=>{let{id:t,...n}=e;return Yt(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:Y.projects});let r=e.getQueryData(Y.projects);return e.setQueryData(Y.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?Qo(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(Y.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(Y.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:Y.projects})})}function Qo(e,t){let{maxParallel:n,tags:r,...i}=e,a={...i},o=`maxParallel`in t?t.maxParallel:e.maxParallel;o!=null&&(a.maxParallel=o);let s=`tags`in t&&t.tags!==void 0?t.tags:e.tags,c=s==null?[]:Ho(s);if(c.length>0&&(a.tags=c),`webhook`in t&&t.webhook!==void 0)if(t.webhook===null)delete a.webhook;else{let n=t.webhook.token===void 0?e.webhook?.tokenSet??!1:t.webhook.token!==``;a.webhook={url:t.webhook.url,tokenSet:n}}return a}function $o(e){let t=D();return V({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(Y.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:Y.projects})})}function es(){return $o(e=>{let{projectId:t,...n}=e;return st(t,n)})}function ts(){return $o(e=>{let{projectId:t,webhookId:n,...r}=e;return Ne(t,n,r)})}function ns(){return $o(({projectId:e,webhookId:t})=>gt(e,t))}function rs(){return V({mutationFn:({projectId:e,webhookId:t})=>Qt(e,t),retry:!1})}function is(e){let t=D();return V({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:Y.agentProfiles}),t.invalidateQueries({queryKey:Y.projects}),t.invalidateQueries({predicate:({queryKey:e})=>e[1]===`runner-skills`}),Ya(t)])},onError:()=>{t.invalidateQueries({queryKey:J.health}),t.invalidateQueries({queryKey:Y.agentProfiles,exact:!0})}})}function as(){return is(e=>ke(e))}function os(){return is(e=>{let{id:t,...n}=e;return rt(t,n)})}function ss(){return is(e=>At(e))}function cs(){return is(e=>Xe(e))}function ls(e,t){return O({queryKey:Y.agentAccountStatus(e),queryFn:({signal:t})=>zt(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function us(){let e=D();return V({mutationFn:({provider:e,profileId:t})=>Ye(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:Y.agentProfiles}),e.invalidateQueries({queryKey:Y.providerStatus}),Ya(e,n,`none`)])},onError:()=>{e.invalidateQueries({queryKey:J.health}),e.invalidateQueries({queryKey:Y.agentProfiles,exact:!0})}})}function ds(){let e=D();return V({mutationFn:e=>zt(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(Y.agentAccountStatus(n),t),e.invalidateQueries({queryKey:Y.agentProfiles}),Ya(e,t.status.provider)}})}function fs(){let e=D();return V({mutationFn:e=>We(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Y.projects})})}function ps(){let e=D();return V({mutationFn:e=>c(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Y.projects})})}function ms({enabled:e}){return O({queryKey:Y.githubOwners,queryFn:({signal:e})=>_t({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function hs(){let e=D();(0,B.useEffect)(()=>{let t,n=()=>{let n=e.getQueryData(J.health);n&&(s({bootProject:n.bootProject===void 0?`default`:n.bootProject,apiBase:r()}),t??=Uo(`health`,t=>{e.setQueryData(J.health,t)}))};n();let i=e.getQueryCache().subscribe(n);return()=>{i(),t?.(),tt()}},[e])}function gs(){return O({queryKey:J.health,queryFn:({signal:e})=>et({signal:e})})}function _s(e,t){let n=gs().data,r=qo(t).data?.projects,i=Ft(),a=e??i.projectId,o=a??n?.bootProject??void 0,s=o===void 0?void 0:r?.find(e=>e.id===o);return s?.repoUrl?s.repoUrl:n?.bootProject!==null&&(a===null||a===n?.bootProject)?zo(n?.repo?.remote):void 0}function vs(e=!0){return O({queryKey:Y.uiState,queryFn:({signal:e})=>St({signal:e}),enabled:e})}function ys(){return O({queryKey:Y.config,queryFn:({signal:e})=>at({signal:e})})}function bs(){return O({queryKey:Y.agentProfiles,queryFn:({signal:e})=>Dt({signal:e})})}function xs(){return O({queryKey:J.workflows,queryFn:({signal:e})=>yt({signal:e})})}function Ss(e){return O({queryKey:e?[e,`repo`]:J.repo,queryFn:({signal:t})=>nt({signal:t},e)})}function Cs(e){return O({queryKey:[e,`repo`],queryFn:({signal:t})=>nt({signal:t},e)})}function ws(){return O({queryKey:J.repoBranches,queryFn:({signal:e})=>Jt({signal:e})})}function Ts(){return O({queryKey:J.repoChanges,queryFn:({signal:e})=>Me({signal:e}),retry:!1})}function Es(e){return O({queryKey:J.repoCommit(e??``),queryFn:({signal:t})=>te(e,{signal:t}),enabled:!!e,retry:!1})}function Ds(e,t=!0){return O({queryKey:e?[e,`config`]:J.config,queryFn:({signal:t})=>Zt({signal:t,...e?{projectId:e}:{}}),enabled:t})}function Os(){return O({queryKey:J.worktrees,queryFn:({signal:e})=>l({signal:e})})}function ks(e){return O({queryKey:[e,`worktrees`],queryFn:({signal:t})=>l({signal:t},e),staleTime:0})}function As(e,t=!0,n=!1){return O({queryKey:[H({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>Ce({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:Je(e.sidebarLimits)},enabled:t})}function js(e=!0,t){return As(t??n(),e)}function Ms(){return O({queryKey:J.agentConfig,queryFn:({signal:e})=>Ct({signal:e})})}function Ns(e){return O({queryKey:J.agentConfigFile(e??``),queryFn:({signal:t})=>mt(e,{signal:t}),enabled:e!==null})}function Ps(){return O({queryKey:J.sessionContext,queryFn:({signal:e})=>m({signal:e})})}function Fs(e,t,n=``){return O({queryKey:J.sessionContextPreview(e,t,n),queryFn:({signal:n})=>ye({content:e,role:t},{signal:n}),placeholderData:It,staleTime:0,retry:!1})}function Is(){let e=D();return V({onMutate:()=>({fileKey:J.sessionContext}),mutationFn:e=>w(e),onSuccess:(t,n,r)=>{r&&e.setQueryData(r.fileKey,t)}})}function Ls(e){let t=D(),n=J.agentConfig,r=J.agentConfigFile(e);return V({mutationFn:t=>ae(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}var Rs=R([`passing`,`failing`,`pending`]).nullable(),zs=j({kind:R([`issue`,`pr`]),number:z(),title:L(),author:L(),createdAt:L(),labels:F(L()),body:L().optional(),url:L(),comments:z(),assignees:F(L()).optional(),projectIds:F(L()).optional(),isDraft:I().optional(),additions:z().optional(),deletions:z().optional(),checks:Rs.optional()});M(`available`,[j({available:P(!0),item:zs.nullable(),labelColors:N(L(),L()).optional()}),j({available:P(!1),reason:L()})]),j({kind:R([`issue`,`pr`]),number:tn().int().positive().safe()});var Bs=j({id:L(),title:L(),url:L()});j({available:I(),reason:L().optional(),repo:L().optional(),syncedAt:L().optional(),issues:F(zs),prs:F(zs),labelColors:N(L(),L()).optional(),viewerLogin:L().optional(),projects:F(Bs).optional(),projectsReason:L().optional(),projectsState:R([`refreshing`,`ready`,`unavailable`]).optional(),projectsGeneration:L().optional(),issuesTotal:z().int().nonnegative().optional(),prsTotal:z().int().nonnegative().optional(),issuesNextCursor:L().nullable().optional(),prsNextCursor:L().nullable().optional(),commentsDeferred:P(!0).optional()});var Vs=L().min(1).max(2e3).optional();j({limit:L().optional(),refresh:L().optional(),issuesCursor:Vs,prsCursor:Vs,issuesDone:P(`1`).optional(),prsDone:P(`1`).optional()}).superRefine((e,t)=>{e.issuesDone&&e.issuesCursor&&t.addIssue({code:`custom`,message:`issuesDone and issuesCursor are exclusive`}),e.prsDone&&e.prsCursor&&t.addIssue({code:`custom`,message:`prsDone and prsCursor are exclusive`}),e.issuesDone&&e.prsDone&&t.addIssue({code:`custom`,message:`both sides are done; there is no page to ask for`})}),j({kind:R([`issue`,`pr`]),numbers:L().regex(/^[1-9]\d{0,15}(,[1-9]\d{0,15})*$/).refine(e=>{let t=e.split(`,`);return t.length<=100&&t.every(e=>Number.isSafeInteger(Number(e)))},{message:`at most 100 safe positive integers`}),refresh:P(`1`).optional()}),M(`available`,[j({available:P(!0),counts:N(z(),z().int().nonnegative())}),j({available:P(!1),reason:L()})]),M(`available`,[j({available:P(!0),checks:N(z(),Rs)}),j({available:P(!1),reason:L()})]),j({kind:R([`issue`,`pr`]),q:L().trim().min(1).max(256),limit:tn().int().positive().max(50).optional()}),j({available:I(),projectsReason:L().optional(),reason:L().optional(),items:F(zs),truncated:I().optional(),labelColors:N(L(),L()).optional()});var Hs=z().nullable();M(`available`,[j({available:P(!0),prs:N(z(),ut),issues:N(z(),ut),conflicts:F(z()).optional(),recheckAfterMs:Hs}),j({available:P(!1),reason:L(),recheckAfterMs:Hs})]);var Us=j({id:z(),author:L(),avatarUrl:L().optional(),createdAt:L(),body:L(),kind:R([`comment`,`review`]),reviewState:R([`approved`,`changes_requested`,`commented`,`dismissed`]).optional(),url:L()}),Ws=R([`committed`,`labeled`,`unlabeled`,`assigned`,`unassigned`,`merged`,`closed`,`reopened`,`head_ref_force_pushed`,`cross-referenced`,`renamed`]),Gs=j({id:L(),kind:Ws,actor:L(),avatarUrl:L().optional(),createdAt:L(),url:L().optional(),sha:L().optional(),message:L().optional(),checks:Rs.optional(),label:j({name:L(),color:L().optional()}).optional(),subject:L().optional(),refNumber:z().optional(),refTitle:L().optional(),refIsPr:I().optional()});j({available:I(),reason:L().optional(),comments:F(Us),truncated:I().optional(),events:F(Gs).optional(),detail:j({body:L(),additions:z().int().nonnegative().optional(),deletions:z().int().nonnegative().optional()}).optional()});var Ks=R([`merge`,`squash`,`rebase`]),qs=j({name:L(),state:R([`passing`,`failing`,`pending`,`unknown`]),required:I().nullable(),url:L().optional()}),Js=j({number:z(),title:L(),url:L(),state:R([`open`,`closed`,`merged`]),isDraft:I(),headRef:L(),baseRef:L(),headSha:L(),mergeable:R([`mergeable`,`conflicting`,`unknown`]),reviewDecision:R([`approved`,`changes-requested`,`review-required`,`not-required`,`unknown`]),checks:F(qs),methods:F(Ks),defaultMethod:Ks.nullable(),eligibility:R([`ready`,`blocked`,`pending`,`unauthorized`,`terminal`,`unknown`]),blockers:F(j({code:L(),message:L()})),canMerge:I(),canOverride:I()});M(`available`,[j({available:P(!0),mergeState:Js}),j({available:P(!1),reason:L()})]),j({merged:P(!0),number:z(),url:L(),method:Ks,mergeCommitSha:L().optional()});var Ys=j({path:L(),previousPath:L().optional(),status:R([`added`,`modified`,`removed`,`renamed`,`copied`,`changed`]),additions:z(),deletions:z(),patch:L().optional(),patchUnavailableReason:R([`binary`,`too-large`,`not-provided`]).optional(),truncated:I().optional()});M(`available`,[j({available:P(!0),number:z(),headSha:L(),files:F(Ys),additions:z(),deletions:z(),truncated:I(),reason:L().optional()}),j({available:P(!1),reason:L()})]),j({generation:L().uuid()}),M(`state`,[j({generation:L().uuid(),state:P(`ready`),projects:F(Bs),membership:N(L(),F(L()))}),j({generation:L().uuid(),state:P(`unavailable`),reason:L()})]);function Xs(e){if(!e.available)return;let t=e.issuesNextCursor,n=e.prsNextCursor;if(!(t===void 0&&n===void 0)&&!(!t&&!n))return{...t?{issuesCursor:t}:{issuesDone:!0},...n?{prsCursor:n}:{prsDone:!0}}}function Zs(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function Qs(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function $s(e){let t=e[0];if(!t)return;let n=e[e.length-1],r=[],i=[],a=new Set,o=new Set,s={};for(let t of e){Qs(t.issues,a,r),Qs(t.prs,o,i);for(let[e,n]of Object.entries(t.labelColors??{}))s[e]??=n}let c=e.find(e=>e.projects)?.projects,l=e.map(e=>e.projectsState),u=e.find(e=>e.projectsState===`unavailable`),d=l.includes(`refreshing`)?`refreshing`:u?`unavailable`:l.some(e=>e===`ready`)?`ready`:void 0,{projectsGeneration:f,projectsReason:ee,...te}=t;return{...te,issues:r,prs:i,...Object.keys(s).length>0?{labelColors:s}:{},...c?{projects:c}:{},...d?{projectsState:d}:{},...d===`unavailable`&&u?.projectsReason?{projectsReason:u.projectsReason}:{},...`issuesNextCursor`in n?{issuesNextCursor:n.issuesNextCursor}:{},...`prsNextCursor`in n?{prsNextCursor:n.prsNextCursor}:{}}}var ec=e=>e.map(e=>e.number).join(`,`);function tc(e,t){let n=e[0];if(e.length>1&&n&&(ec(n.issues)!==ec(t.issues)||ec(n.prs)!==ec(t.prs)||n.issuesTotal!==t.issuesTotal||n.prsTotal!==t.prsTotal))return`refetch`;let r=t;if(n&&t.available&&t.projectsState===`refreshing`&&n.repo===t.repo){let e=new Map(n.issues.map(e=>[e.number,e.projectIds]));r={...t,issues:t.issues.map(t=>{let n=e.get(t.number);return t.projectIds===void 0&&n!==void 0?{...t,projectIds:n}:t})}}return[r,...e.slice(1)]}var nc=class extends Error{};function rc(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await x({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new nc(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>Xs(e),retry:(e,t)=>!(t instanceof nc)&&!(t instanceof ne&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function ic(e=50,t=!0){let r=D(),i=J.githubPages(e),a=J.githubPagesHead(e);ha(`/api/v1/p/${n()}/github?limit=${e}`,a,W(t?6e4:!1));let o=f({...rc(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),s=O({queryKey:a,queryFn:({signal:t})=>x({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:c}=o;(0,B.useEffect)(()=>{if(!s.data)return;let e=r.getQueryData(i);if(!e||e.pages.length===0)return;let t=tc(e.pages,s.data);t===`refetch`?c():r.setQueryData(i,{...e,pages:t})},[r,s.dataUpdatedAt,c]);let l=(o.data?.pages??[]).flatMap(e=>e.projectsState===`refreshing`&&e.projectsGeneration?[e.projectsGeneration]:[]),u=gn({queries:l.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>Oe(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,B.useEffect)(()=>{u.forEach((e,t)=>{let n=l[t];!n||!e.data&&!e.error||r.setQueryData(i,t=>{if(!t)return t;let r=!1,i=t.pages.map(t=>{if(t.projectsGeneration!==n||t.projectsState!==`refreshing`)return t;let i=e.data;return i?.generation&&i.generation!==n?t:(r=!0,i?.state===`ready`?{...t,projectsState:`ready`,projects:i.projects,issues:t.issues.map(e=>({...e,projectIds:i.membership?.[e.number]??[]}))}:{...t,projectsState:`unavailable`,projectsReason:i?.reason??`Project boards unavailable. Refresh to try again.`})});return r?{...t,pages:i}:t})})},[r,u.map((e,t)=>e.data||e.error?l[t]:``).join(`,`)]),{pages:o,data:(0,B.useMemo)(()=>$s(o.data?.pages??[]),[o.data])}}function ac(e,t=50,n=!0){let r=f({...rc([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,B.useMemo)(()=>$s(r.data?.pages??[]),[r.data])}}function oc(e,t,n=!0){let r=gn({queries:t.filter(e=>e.length>0).map(t=>({queryKey:J.githubCommentCounts(e,t),queryFn:({signal:n})=>Mt(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,B.useMemo)(()=>{let e={};for(let t of r)t.data?.available&&Object.assign(e,t.data.counts);return e},[r.map(e=>e.dataUpdatedAt).join(`,`)])}function sc(e,t,n,r=!0){return O({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>lt(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function cc(e,t=!0){return O({queryKey:J.githubChecks(e),queryFn:({signal:t})=>he(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function lc(e,t,n=!0){return O({queryKey:J.githubSearch(e,t),queryFn:({signal:n})=>lt(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var uc=100;function dc(e){return[...e].sort((e,t)=>t-e).slice(0,uc).sort((e,t)=>e-t)}function fc(){let e=Ft(),t=gs();return e.projectId??t.data?.bootProject??void 0}function pc(e,t){let n=t===void 0?{}:{hostId:t};for(let[t,r]of Object.entries(e)){for(let[e,i]of Object.entries(r.prs))Do(No({...n,projectId:t,kind:`PR`,number:Number(e)}),i);for(let[e,i]of Object.entries(r.issues))Do(No({...n,projectId:t,kind:`Issue`,number:Number(e)}),i)}}var mc=5*6e4;function hc(e){return e?e.recheckAfterMs:mc}function gc(e,t=!0){let n=(0,B.useMemo)(()=>{let t=new Map;for(let n of e){let e=n.hostId===void 0?n.projectId:`host:${n.hostId}\u0000${n.projectId}`,r=t.get(e)??{...n.hostId===void 0?{}:{hostId:n.hostId},projectId:n.projectId,prs:new Set,issues:new Set};r[n.kind===`PR`?`prs`:`issues`].add(n.number),t.set(e,r)}return[...t.values()].map(e=>({...e.hostId===void 0?{}:{hostId:e.hostId},projectId:e.projectId,prs:dc(e.prs),issues:dc(e.issues)}))},[e.map(No).sort().join(`|`)]),r=gn({queries:n.map(e=>({queryKey:J.githubRefStatus(e.projectId,e.prs,e.issues,e.hostId),queryFn:({signal:t})=>a(e.projectId,{prs:e.prs,issues:e.issues},{signal:t,...e.hostId===void 0?{}:{hostId:e.hostId}}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>hc(e.state.data)??1/0,refetchInterval:e.hostId===void 0?!1:e=>W(t&&!_n()?hc(e.state.data)??!1:!1),refetchOnWindowFocus:!0}))}),i=D(),o=JSON.stringify(n.flatMap((e,t)=>e.hostId===void 0?[{projectId:e.projectId,prs:e.prs,issues:e.issues,interval:hc(r[t]?.data)??!1}]:[]));(0,B.useEffect)(()=>{if(!t||_n())return;let e=!0,n=JSON.parse(o).filter(e=>e.interval!==!1).map(t=>{let n=new URLSearchParams;t.prs.length&&n.set(`prs`,t.prs.join(`,`)),t.issues.length&&n.set(`issues`,t.issues.join(`,`));let r=J.githubRefStatus(t.projectId,t.prs,t.issues);return ma({path:`/api/v1/p/${t.projectId}/github/ref-status?${n}`,intervalMs:t.interval},(t,n)=>{n||i.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&i.setQueryData(r,t)})})});return()=>{e=!1;for(let e of n)e()}},[t,o,i]);let s=(0,B.useMemo)(()=>Ro(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,B.useCallback)(e=>{let t=No(e),n=s.get(t);if(n)return n;let r=Q.get(t);return{state:`idle`,...r?{status:r}:{},...$.has(t)?{conflicting:!0}:{}}},[s])}function _c(e,t,n=!0){return O({queryKey:J.githubComments(e,t),queryFn:({signal:n})=>fe(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function vc(e,t,n=!0){return O({queryKey:J.githubItem(e,t),queryFn:({signal:n})=>Ge(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function yc(e){return O({queryKey:J.githubPrChanges(e??0),queryFn:({signal:t})=>Ue(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{rs as $,Ln as $n,Wa as $t,Os as A,ar as An,Ga as At,gs as B,ir as Bn,Ta as Bt,ws as C,xr as Cn,Xa as Ct,Fs as D,hr as Dn,ja as Dt,Ps as E,fr as En,Aa as Et,as as F,Cr as Fn,Ha as Ft,ds as G,Xn as Gn,Na as Gt,_s as H,$n as Hn,wa as Ht,ps as I,mr as In,za as It,ss as J,Un as Jn,Fa as Jt,Go as K,Zn as Kn,Ea as Kt,es as L,Tr as Ln,_a as Lt,bs as M,dr as Mn,Ka as Mt,fs as N,lr as Nn,ka as Nt,js as O,G as On,Ma as Ot,us as P,sr as Pn,Va as Pt,cs as Q,zn as Qn,ba as Qt,Jo as R,yr as Rn,Ba as Rt,Ss as S,Sr as Sn,Qa as St,Es as T,gr as Tn,ya as Tt,qo as U,Yn as Un,Da as Ut,hs as V,_r as Vn,qa as Vt,Wo as W,Jn as Wn,Pa as Wt,ns as X,Vn as Xn,va as Xt,Xo as Y,Bn as Yn,Ca as Yt,Ko as Z,Kn as Zn,xa as Zt,Cs as _,Rr as _n,V as _r,go as _t,vc as a,Y as an,Nn as ar,Uo as at,Ls as b,Ar as bn,ln as br,so as bt,lc as c,Hi as cn,yn as cr,zo as ct,fc as d,Yr as dn,wn as dr,_o as dt,Ia as en,Mn as er,os as et,gc as f,zr as fn,Sn as fr,uo as ft,Ds as g,Fr as gn,U as gr,lo as gt,Ns as h,Nr as hn,H as hr,po as ht,_c as i,J as in,Pn as ir,vs as it,ls as j,wr as jn,Sa as jt,xs as k,vr as kn,Ra as kt,ac as l,oi as ln,bn as lr,yo as lt,Ms as m,Lr as mn,_n as mr,co as mt,cc as n,pa as nn,Fn as nr,ts as nt,ic as o,q as on,jn as or,Bo as ot,Zs as p,Ir as pn,W as pr,mo as pt,Yo as q,er as qn,Oa as qt,oc as r,ia as rn,Rn as rr,ys as rt,yc as s,Ui as sn,vn as sr,Vo as st,pc as t,ma as tn,In as tr,Zo as tt,sc as u,Jr as un,Cn as ur,xo as ut,As as v,Or as vn,gn as vr,ho as vt,Ts as w,or as wn,Ja as wt,Is as x,tr as xn,Ya as xt,ks as y,kr as yn,un as yr,fo as yt,ms as z,cr as zn,Ua as zt};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Bn as r,Dn as i,En as a,Kn as o,Mn as s,On as c,Pn as l,f as u,kn as d,lt as f,ut as p,wn as m,xn as h}from"./queries-DD_9iITj.js";import{Ai as g,Br as _,Si as v}from"./project-scope-context-DNrHbqd2.js";import{n as ee}from"./chunk-KS7C4IRE-BdLLx37K.js";import{o as y,s as b}from"./dist-CCX8mhHc.js";import{F as x,I as S,N as C,P as w,U as T,_ as E,ct as D,g as O,h as k,m as A,p as j}from"./design-icons-QbNMZniQ.js";import{n as M,r as te,t as ne}from"./popover-BQolmvDR.js";function re(e){if(e.workflow===`(planned)`||e.workflow===`(inbox)`){let t=(e.steps??[]).find(e=>e.kind===`agent`);if(t?.name)return t.name}return e.workflow}var N=e(t(),1),P=[{value:`all`,label:`All`},{value:`direct`,label:`Direct`},{value:`automations`,label:`Automations`}];function ie(e){return e?P:P.filter(e=>e.value!==`automations`)}function ae(e,t){return e===`automations`&&!t?`all`:e}function oe(e){return e===`direct`||e===`automations`?e:`all`}function se(e,t){return t===`all`||_(e)===(t===`automations`)}function ce(e){return e===`all`?void 0:e===`automations`}function F(e,t){let n={all:0,direct:0,automations:0};for(let r of e)c(r)||r.archived!==(t===`archived`)||(n.all+=1,_(r)?n.automations+=1:n.direct+=1);return n}function le(e,t,n,r,i){let a=d(e).archived,o=a>=200;if(n===`all`)return i??(o?`200+`:a);let s=F(t,`archived`)[n];return o&&r!==!1?`${s}+`:s}function ue(e){return e.rows.map(e=>e.run)}function de(e,t){switch(e){case`Needs you`:return`pending`;case`Working`:return`running`;case`Archived`:return`neutral`;case`Finished`:return t.some(e=>v(e).bucket===`error`)?`danger`:`success`}}function fe(e,t,n){return i(e,t,s(n))}var I=(e,t,n)=>n===void 0?`\u0000${e}\u0000${t}`:`${n}\u0000${e}\u0000${t}`,pe=(e,t)=>t===void 0?`\u0000${e}`:`${t}\u0000${e}`;function me(e){let t=new Map;for(let n of e){if(n.archived||n.status!==`queued`)continue;let e=pe(n.projectId,n.hostId),r=t.get(e);r||(r={projectId:n.projectId,hostId:n.hostId,runs:[]},t.set(e,r)),r.runs.push(n)}let n=new Map;for(let{projectId:e,hostId:r,runs:i}of t.values())for(let[t,a]of s(i))n.set(I(e,t,r),a);return n}function he(e){let t=Array.from({length:20},()=>[]);for(let n of e){let e=r(n.run);t[(n.run.pinned?0:10)+e].push(n)}let n=[];for(let e=0;e<t.length;e+=1){let r=t[e];if(r.length===0)continue;let i=e%10;(i===3||i===4)&&r.length>1&&r.sort((e,t)=>a(e.run,t.run,`active`));for(let e of r)n.push(e)}return n}function ge(e,t){let n=t===`archived`,r=[],i,o=!0;for(let t of e)t.run.archived!==n||c(t.run)||(o&&i!==void 0&&t.run.createdAt>i&&(o=!1),i=t.run.createdAt,r.push(t));return n||!o?r.sort((e,n)=>a(e.run,n.run,t)):he(r)}function _e(e,t,n){let r=ge(e,t),i=me(n),a=new Map;for(let e of r){let n=m(e.run,t),r={kind:`run`,run:e,queuePosition:e.run.status===`queued`?i.get(I(e.run.projectId,e.run.id,e.hostId))??null:null},o=a.get(n);o?o.push(r):a.set(n,[r])}return h.filter(e=>a.has(e)).map(e=>({label:e,rows:a.get(e)}))}function L(e){return[e.run]}function ve(e){let t=/\/(\d+)\/?$/.exec(e.trim()),n=t?Number(t[1]):NaN;return Number.isInteger(n)&&n>0?n:null}function ye(e){let t=new Set;for(let n of[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl]){let e=n?ve(n):null;e!==null&&t.add(e)}for(let n of[e.prNumber,e.issueNumber,e.markerRefs?.pr,e.markerRefs?.issue])typeof n==`number`&&Number.isInteger(n)&&n>0&&t.add(n);for(let n of e.pullRequests??[])t.add(n.number);return[...t]}var be=[{id:`title`,kind:`text`,scopes:[`stored`],source:`summary`,texts:e=>[e.title]},{id:`titleSummary`,kind:`text`,scopes:[`stored`],source:`summary`,texts:e=>[e.titleSummary]},{id:`displayTitle`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>[t.displayTitle]},{id:`branch`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.branch]},{id:`workflow`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.workflow]},{id:`workflowLabel`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.workflowLabel]},{id:`automation`,kind:`text`,scopes:[`stored`,`shown`],source:`reader`,texts:(e,t)=>[t.automation],universe:e=>[...e.automationNames?.values()??[]]},{id:`projectName`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>[t.projectName]},{id:`tags`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>t.tags??[]},{id:`id`,kind:`identifier`,scopes:[`stored`],source:`summary`,texts:e=>[e.id]},{id:`urls`,kind:`link`,scopes:[`stored`],source:`summary`,texts:e=>[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl,...(e.pullRequests??[]).map(e=>e.url)]},{id:`heldReferences`,kind:`reference`,scopes:[`stored`],source:`summary`,numbers:ye},{id:`shownReferences`,kind:`reference`,scopes:[`shown`],source:`reader`,numbers:(e,t)=>t.references?.()??[]}];function xe(e){return e.trim().toLowerCase().split(/\s+/).filter(e=>e!==``)}function Se(e,t){return t&&e.automationId!==void 0?t.get(e.automationId)??e.automationId:void 0}function Ce(e,t){let n=t.scope??`stored`,r=t.scope===`shown`?t.extras:{automation:Se(e,t.automationNames)},i=[],a=[],o=[],s={text:i,identifier:a,link:o},c=[];for(let t of be)if(t.scopes.includes(n)){if(t.kind===`reference`){c.push(()=>t.numbers(e,r));continue}for(let n of t.texts(e,r))typeof n==`string`&&s[t.kind].push(n.toLowerCase())}let l;return{prose:i,ids:a,links:o,references:()=>l??=new Set(c.flatMap(e=>e().map(String)))}}function R(e,t,n={}){let r=xe(t);if(r.length===0)return!1;let{prose:i,ids:a,links:o,references:s}=Ce(e,n);return r.every(e=>{if(i.some(t=>t.includes(e)))return!0;let t=e.replace(/^#/,``);return/^\d+$/.test(t)?s().has(String(Number(t)))||a.some(e=>e.startsWith(t)):a.some(t=>t.includes(e))||o.some(t=>t.includes(e))})}var we=new Set([`running`,`waiting`]);function z(e){return e?e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:`${Math.round(e/1024)} kB`:``}function Te(e){return e===void 0?``:`$${e>=10?e.toFixed(0):e.toFixed(2)}`}function Ee(e,t=new Date){if(!g(e))return;let n=new Date(e.autoResumeAt);if(!Number.isFinite(n.getTime()))return;let r=n.toDateString()===t.toDateString(),i=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}).format(n);return{label:r?i:`${new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(n)} ${i}`,title:`Resumes automatically at ${new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(n)}`}}function De(e){return e.steps?re({workflow:e.workflow,steps:e.steps}):e.workflowLabel??e.workflow}function Oe(e,t,n=()=>``){let r=e.filter(e=>!c(e));return t.trim()?r.filter(e=>R(e,t,{scope:`shown`,extras:{displayTitle:l(e),automation:n(e),references:()=>B(e)}})):[...r]}function B(e){return K(e).map(e=>e.number)}function V(e,t){return e.filter(e=>o(e,t)).length}function ke(e){return V(e)}function Ae(e){return H(e)[0]??e.pullRequests?.find(e=>e.url)?.url}function H(e){let t=[];return e.pullRequestUrl&&t.push(e.pullRequestUrl),!(e.markerRefs?.issue!==void 0&&e.markerRefs?.pr===void 0)&&e.referencedPullRequestUrl&&t.push(e.referencedPullRequestUrl),t}function U(e,t){if(e.referencedIssueUrl)return e.referencedIssueUrl;let n=e.issueNumber??e.markerRefs?.issue;if(!(!n||!t))return`${t}/issues/${n}`}function W(e){let t=`${e.kind}#${e.number}`;if(!e.url)return`${t}@project:${e.projectId??`default`}`;try{let n=new URL(e.url),r=n.pathname.split(`/`).filter(Boolean).slice(0,2).join(`/`);return`${t}@${n.host.toLowerCase()}/${r.toLowerCase()}`}catch{return`${t}@${e.url}`}}var G=new WeakMap;function K(e,t,n=e.projectId){let r=G.get(e);if(r&&r.repoBase===t&&r.projectId===n)return r.refs;let i=je(e,t,n);return G.set(e,{repoBase:t,projectId:n,refs:i}),i}function je(e,t,n){let r=H(e),i=e.markerRefs?.pr,a=[...i===void 0||[...r,...(e.pullRequests??[]).flatMap(e=>e.url?[e.url]:[])].some(e=>J(e)===String(i))?[]:[{kind:`PR`,number:i}],...r.map(e=>({kind:`PR`,url:e})),{kind:`PR`,number:e.prNumber},...(e.pullRequests??[]).map(e=>({kind:`PR`,number:e.number,...e.url?{url:e.url}:{},authoritative:!0})),{kind:`Issue`,url:U(e,t)},{kind:`Issue`,number:e.issueNumber}],o=new Set,s=[];for(let e of a){let r=e.url?Number(J(e.url)):e.number;if(!r||!Number.isInteger(r)||!e.url&&!e.authoritative&&s.some(t=>t.url&&t.kind===e.kind&&t.number===r))continue;let i=e.url??Me(e.kind,r,t),a={kind:e.kind,number:r,...i?{url:i}:n===void 0?{}:{projectId:n}},c=W(a);o.has(c)||(o.add(c),s.push(a))}return s}function Me(e,t,n){if(n)return`${n}/${e===`PR`?`pull`:`issues`}/${t}`}function Ne(e){return K(e)[0]}function q(e,t){if(!e.url)return!0;if(!t)return!1;let n=Ie(t);return n!==void 0&&Ie(e.url)===n}var Pe=new WeakMap;function Fe(e,t,n=e.projectId){let r=Pe.get(e);if(r&&r.repoBase===t&&r.projectId===n)return r.refs;let i=K(e,t,n).filter(e=>q(e,t));return Pe.set(e,{repoBase:t,projectId:n,refs:i}),i}function Ie(e){try{let t=new URL(e),[n,r]=t.pathname.split(`/`).filter(Boolean);return n&&r?`${t.host}/${n}/${r}`.toLowerCase():void 0}catch{return}}function Le(e,t){let n=[];for(let r of K(e,t)){if(!q(r,t))continue;let e=r.kind===`PR`?`pr`:`issue`;n.some(t=>t.kind===e&&t.number===r.number)||n.push({kind:e,number:r.number})}return n}function Re(e,t,n,r){if(q(n,r))return`/p/${e}/tasks/${t}/${n.kind===`PR`?`pr`:`issue`}/${n.number}`}function J(e){return/\/(\d+)\/?(?:[?#].*)?$/.exec(e)?.[1]??null}function ze(e,t){let n=we.has(e.status)?t:void 0;if(n)return{cpu:{text:`${n.cpuPct.toFixed(0)}%`,kind:`live`},mem:{text:z(n.rssBytes),kind:`live`}};let r=z(e.peakRssBytes);return{cpu:{text:``,kind:`none`},mem:r?{text:`peak ${r}`,kind:`peak`,title:`peak — run finished${e.peakProcCount?` · ${e.peakProcCount} procs`:``}`}:{text:``,kind:`none`}}}function Be(e,t,n=!1){return n||e.filter(e=>!t(e.label)).some(e=>e.rows.flatMap(L).some(e=>Ne(e)!==void 0))}var Y=n(),Ve=(0,N.createContext)(null);function He({children:e}){let[t,n]=(0,N.useState)(()=>new Map),r=(0,N.useCallback)((e,t)=>{n(n=>{let r=new Map(n);return r.set(e,t),r})},[]),i=(0,N.useCallback)(e=>{n(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),a=u((0,N.useMemo)(()=>[...t.values()].flat(),[t])),o=(0,N.useMemo)(()=>({publish:r,retract:i,lookup:a}),[r,i,a]);return(0,Y.jsx)(Ve.Provider,{value:o,children:e})}var X=(0,N.createContext)(null);function Ue({projectId:e,repoBase:t,requests:n,children:r}){let i=(0,N.useContext)(Ve),a=(0,N.useContext)(X),o=(0,N.useId)();(0,N.useEffect)(()=>{if(i)return i.publish(o,n),()=>i.retract(o)},[i,o,(0,N.useMemo)(()=>n.map(e=>`${e.hostId??``}:${e.projectId} ${e.kind}#${e.number}`).sort().join(`|`),[n])]);let s=u(i?We:n),c=i?.lookup??s,l=t??(a&&a.projectId===e?a.repoBase:void 0),d=(0,N.useMemo)(()=>({lookup:c,projectId:e,repoBase:l}),[c,e,l]);return(0,Y.jsx)(X.Provider,{value:d,children:r})}var We=[];function Z(e,t,n,r){let i=(0,N.useContext)(X),a=n??i?.projectId;return!i||!a||t===void 0?qe:i.lookup({...r===void 0?{}:{hostId:r},projectId:a,kind:e,number:t})}function Ge(e,t,n){let r=(0,N.useContext)(X),i=t??r?.projectId;return!r||!i?[]:e.filter(e=>r.lookup({...n===void 0?{}:{hostId:n},projectId:i,kind:`PR`,number:e}).conflicting===!0)}function Ke(){let e=(0,N.useContext)(X);return{projectId:e?.projectId,repoBase:e?.repoBase}}var qe=Object.freeze({state:`idle`}),Je={success:`border-success/40 text-semantic-green`,danger:`border-danger/40 text-semantic-red`,accent:`border-accent-strong/35 text-accent-text`,merged:`border-merged-strong/35 text-merged-text`,info:`border-info/40 text-semantic-info`,neutral:`border-border text-muted-foreground`,pending:`border-pending-strong/45 text-semantic-amber`,conflict:`border-conflict/45 text-semantic-conflict`},Ye={success:`text-semantic-green`,danger:`text-semantic-red`,accent:`text-merged-text`,merged:`text-merged-text`,info:`text-semantic-info`,neutral:`text-soft-foreground`,pending:`text-semantic-amber`,conflict:`text-semantic-conflict`},Xe={success:`hover:bg-success/10`,danger:`hover:bg-danger/10`,accent:`hover:bg-accent-strong/10`,merged:`hover:bg-merged-strong/10`,info:`hover:bg-info/10`,neutral:`hover:bg-muted`,pending:`hover:bg-pending-strong/10`,conflict:`hover:bg-conflict/10`},Ze={draft:x,"review-required":S,"changes-requested":T,"checks-pending":null,"checks-failing":E,ready:j,merged:C,closed:w,open:A,completed:j,"not-planned":O};function Q(e){return e===`PR`?`pr-chip`:`issue-chip`}function $(e){return e?{"data-conflicting":`true`}:{}}function Qe(e,t,n,r){return!n||r!==void 0&&q({kind:e,number:t??0,url:n},r)}function $e(e,t,n){return e===`PR`&&(t??n)===!0}function et({plain:e,inert:t,conflicting:n,className:r,tone:i}){return e?y(`inline-flex items-center gap-1 rounded-[2px] text-inherit`,n&&`text-conflict font-medium`,!t&&`group/reference focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-link-foreground`,r):y(`inline-flex h-[22px] items-center gap-1 rounded-md border px-1.5 font-mono text-[12px] font-normal`,Je[i],r)}function tt(e,t,n,r){return n&&!r?t?`${e===`PR`?`PR `:``}#${t}`:e:t?`${!r&&e===`Issue`?`Issue `:``}#${t}`:e}function nt(e){return e===`PR`?`pull request`:`issue`}function rt(e,t,n,r){return`Open the ${e}${t?` #${t}`:``} for ${n}${r?` — ${r.label}`:``}`}function it(e,t){return e&&t?Ye[t.tone]:void 0}function at(e,t){return!e&&(!t||!b(t))}function ot({conflicting:e,presentation:t,status:n,plain:r,compact:i,inert:a,kind:o,label:s,glyphClass:c}){return(0,Y.jsxs)(Y.Fragment,{children:[e?(0,Y.jsx)(D,{className:y(`size-2.5 shrink-0`,c),"aria-hidden":`true`}):(0,Y.jsx)(yt,{status:t?n:void 0,className:r?y(`size-2.5`,c):void 0}),r&&i?o===`PR`?(0,Y.jsx)(S,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):(0,Y.jsx)(A,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):null,r?(0,Y.jsx)(`span`,{className:a?void 0:`underline-offset-2 group-hover/reference:underline group-focus-visible/reference:underline`,children:s}):s]})}function st({kind:e,status:t,conflicting:n,chipClass:r,body:i}){return(0,Y.jsx)(`span`,{"data-slot":Q(e),"data-status":t,"data-inert":`true`,...$(n),className:r,children:i})}function ct({kind:e,number:t,tooltip:n,url:r}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`block font-medium`,children:[e===`PR`?`Pull request`:`Issue`,t?` #${t}`:``,` · `,n.headline]}),(0,Y.jsx)(`span`,{className:`block`,children:n.detail}),n.also?(0,Y.jsx)(`span`,{className:`block text-muted-foreground`,children:n.also}):null,r&&b(r)?(0,Y.jsx)(`span`,{className:`block text-muted-foreground`,children:r.replace(/^https?:\/\//,``)}):null]})}function lt({reference:e,taskTitle:t,status:n,conflicting:r,conflictAction:i,projectId:a,hostId:o,repoBase:s,to:c,fullPage:l=!1,className:u,compact:d=!1,plain:m=!1,inert:h=!1}){let{kind:g,number:_,url:v}=e,ee=Ke(),b=Z(g,Qe(g,_,v,s??ee.repoBase)?_:void 0,a,o),x=n??b.status,S=p(x),C=$e(g,r,b.conflicting),w=C?f:S,T=w?.tone??`accent`,E=et({plain:m,inert:h,conflicting:C,className:u,tone:T}),D=gt(b,w,C?S:void 0),O=tt(g,_,m,d),k=nt(g),A=rt(k,_,t,w),j=(0,Y.jsx)(ot,{conflicting:C,presentation:w,status:x,plain:m,compact:d,inert:h,kind:g,label:O,glyphClass:it(m,w)});if(h)return(0,Y.jsx)(st,{kind:g,status:x,conflicting:C,chipClass:E,body:j});let M=at(c,v)?(0,Y.jsx)(`span`,{"data-slot":Q(g),"data-status":x,...$(C),"aria-label":w?`${k} ${O} — ${w.label}`:void 0,className:E,children:j}):(0,Y.jsx)(ut,{to:c,fullPage:l,url:v,"data-slot":Q(g),"data-status":x,...$(C),title:D?void 0:v,"aria-label":A,className:m?E:y(E,Xe[T]),children:j});return D?(0,Y.jsx)(ht,{chip:M,action:C?i:void 0,state:b.state,children:(0,Y.jsx)(ct,{kind:g,number:_,tooltip:D,url:v})}):M}function ut({to:e,fullPage:t,url:n,children:r,...i}){return e?t?(0,Y.jsx)(`a`,{href:e,...i,children:r}):(0,Y.jsx)(ee,{to:e,...i,children:r}):(0,Y.jsx)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,...i,children:r})}var dt=(0,N.createContext)(()=>{});function ft(){return(0,N.useContext)(dt)}var pt=150,mt=120;function ht({chip:e,action:t,state:n,children:r}){let[i,a]=(0,N.useState)(!1),o=(0,N.useRef)(null),s=(0,N.useRef)(null),c=(0,N.useRef)(void 0),l=(0,N.useCallback)((e,t)=>{clearTimeout(c.current),c.current=setTimeout(()=>a(e),t)},[]),u=(0,N.useCallback)(()=>{clearTimeout(c.current),a(!1)},[]);(0,N.useEffect)(()=>()=>clearTimeout(c.current),[]);let d=e=>e instanceof Node&&(s.current?.contains(e)||o.current?.contains(e));return(0,Y.jsxs)(ne,{open:i,onOpenChange:e=>e?a(!0):u(),children:[(0,Y.jsx)(M,{asChild:!0,ref:o,onPointerEnter:e=>{e.pointerType!==`touch`&&l(!0,pt)},onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,mt)},onFocus:()=>a(!0),onBlur:e=>{d(e.relatedTarget)||u()},onKeyDown:e=>{if(e.key===`Escape`)return u();if(e.key!==`Tab`||e.shiftKey||!t)return;let n=s.current?.querySelector(`button:not([disabled]), [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);n&&(e.preventDefault(),n.focus())},...t?{"aria-haspopup":`dialog`,"aria-expanded":i}:{},children:e}),(0,Y.jsxs)(te,{ref:s,side:`top`,role:t?`dialog`:`tooltip`,"data-slot":`reference-status-card`,"data-tooltip-state":n,className:`w-64 space-y-2 p-3 text-xs`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>{e.preventDefault(),d(document.activeElement)&&o.current?.focus()},onPointerEnter:()=>clearTimeout(c.current),onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,mt)},children:[(0,Y.jsx)(`div`,{className:`space-y-0.5`,children:r}),t?(0,Y.jsx)(dt.Provider,{value:u,children:t}):null]})]})}function gt(e,t,n){if(t){let{label:r,hint:i}=t,a=n?`also ${_t(n.label)} — ${n.hint}`:void 0;return e.state===`unavailable`?{headline:r,detail:`last known — GitHub is unreachable${e.reason?` (${e.reason})`:``}`,...a?{also:a}:{}}:{headline:r,detail:i,...a?{also:a}:{}}}switch(e.state){case`loading`:return{headline:`Checking GitHub…`,detail:`the status of this reference is on its way`};case`unavailable`:return{headline:`Status unavailable`,detail:e.reason??`GitHub could not be reached — the chip says nothing rather than guessing`};case`unknown`:return{headline:`Not found on this repository`,detail:`GitHub has no such number here — the reference may point at another repo`};default:return null}}function _t(e){return e.charAt(0).toLowerCase()+e.slice(1)}function vt({kind:e,number:t,className:n}){let r=Z(e,t),i=p(r.status),a=e===`PR`&&r.conflicting===!0,o=a?f:i;if(!o)return null;let s=y(`size-2.5`,Ye[o.tone]);return(0,Y.jsx)(`span`,{"data-slot":`reference-status-glyph`,"data-status":r.status,...a?{"data-conflicting":`true`}:{},"aria-hidden":`true`,className:y(`inline-flex items-center`,n),children:a?(0,Y.jsx)(D,{className:y(`shrink-0`,s),"aria-hidden":`true`}):(0,Y.jsx)(yt,{status:r.status,className:s})})}function yt({status:e,className:t}){if(!e)return null;if(e===`checks-pending`)return(0,Y.jsx)(k,{"data-slot":`status-dot`,"data-tone":`pending`,className:y(`size-3 animate-pulse motion-reduce:animate-none`,t),"aria-hidden":`true`});let n=Ze[e];return n?(0,Y.jsx)(n,{className:y(`size-2.5 shrink-0`,t),"aria-hidden":`true`}):null}export{le as A,L as B,Le as C,ze as D,K as E,de as F,se as I,ce as L,_e as M,ue as N,De as O,fe as P,F as R,Re as S,Ne as T,ie as V,W as _,He as a,V as b,Z as c,Te as d,z as f,Be as g,J as h,Ue as i,ae as j,R as k,Oe as l,Fe as m,vt as n,Ge as o,q as p,ft as r,Ke as s,lt as t,ke as u,Ee as v,Ae as w,U as x,B as y,oe as z};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Bn as r,Dn as i,En as a,Kn as o,Mn as s,On as c,Pn as l,f as u,kn as d,lt as f,ut as p,wn as m,xn as h}from"./queries-ChH9ctc-.js";import{Ci as g,Vr as _,ji as v}from"./project-scope-context-hfRzPMZ4.js";import{n as ee}from"./chunk-KS7C4IRE-BdLLx37K.js";import{o as y,s as b}from"./dist-CCX8mhHc.js";import{F as x,I as S,N as C,P as w,U as T,_ as E,ct as D,g as O,h as k,m as A,p as j}from"./design-icons-QbNMZniQ.js";import{n as M,r as te,t as ne}from"./popover-BQolmvDR.js";function re(e){if(e.workflow===`(planned)`||e.workflow===`(inbox)`){let t=(e.steps??[]).find(e=>e.kind===`agent`);if(t?.name)return t.name}return e.workflow}var N=e(t(),1),P=[{value:`all`,label:`All`},{value:`direct`,label:`Direct`},{value:`automations`,label:`Automations`}];function ie(e){return e?P:P.filter(e=>e.value!==`automations`)}function ae(e,t){return e===`automations`&&!t?`all`:e}function oe(e){return e===`direct`||e===`automations`?e:`all`}function se(e,t){return t===`all`||_(e)===(t===`automations`)}function ce(e){return e===`all`?void 0:e===`automations`}function F(e,t){let n={all:0,direct:0,automations:0};for(let r of e)c(r)||r.archived!==(t===`archived`)||(n.all+=1,_(r)?n.automations+=1:n.direct+=1);return n}function le(e,t,n,r,i){let a=d(e).archived,o=a>=200;if(n===`all`)return i??(o?`200+`:a);let s=F(t,`archived`)[n];return o&&r!==!1?`${s}+`:s}function ue(e){return e.rows.map(e=>e.run)}function de(e,t){switch(e){case`Needs you`:return`pending`;case`Working`:return`running`;case`Archived`:return`neutral`;case`Finished`:return t.some(e=>g(e).bucket===`error`)?`danger`:`success`}}function fe(e,t,n){return i(e,t,s(n))}var I=(e,t,n)=>n===void 0?`\u0000${e}\u0000${t}`:`${n}\u0000${e}\u0000${t}`,pe=(e,t)=>t===void 0?`\u0000${e}`:`${t}\u0000${e}`;function me(e){let t=new Map;for(let n of e){if(n.archived||n.status!==`queued`)continue;let e=pe(n.projectId,n.hostId),r=t.get(e);r||(r={projectId:n.projectId,hostId:n.hostId,runs:[]},t.set(e,r)),r.runs.push(n)}let n=new Map;for(let{projectId:e,hostId:r,runs:i}of t.values())for(let[t,a]of s(i))n.set(I(e,t,r),a);return n}function he(e){let t=Array.from({length:20},()=>[]);for(let n of e){let e=r(n.run);t[(n.run.pinned?0:10)+e].push(n)}let n=[];for(let e=0;e<t.length;e+=1){let r=t[e];if(r.length===0)continue;let i=e%10;(i===3||i===4)&&r.length>1&&r.sort((e,t)=>a(e.run,t.run,`active`));for(let e of r)n.push(e)}return n}function ge(e,t){let n=t===`archived`,r=[],i,o=!0;for(let t of e)t.run.archived!==n||c(t.run)||(o&&i!==void 0&&t.run.createdAt>i&&(o=!1),i=t.run.createdAt,r.push(t));return n||!o?r.sort((e,n)=>a(e.run,n.run,t)):he(r)}function _e(e,t,n){let r=ge(e,t),i=me(n),a=new Map;for(let e of r){let n=m(e.run,t),r={kind:`run`,run:e,queuePosition:e.run.status===`queued`?i.get(I(e.run.projectId,e.run.id,e.hostId))??null:null},o=a.get(n);o?o.push(r):a.set(n,[r])}return h.filter(e=>a.has(e)).map(e=>({label:e,rows:a.get(e)}))}function L(e){return[e.run]}function ve(e){let t=/\/(\d+)\/?$/.exec(e.trim()),n=t?Number(t[1]):NaN;return Number.isInteger(n)&&n>0?n:null}function ye(e){let t=new Set;for(let n of[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl]){let e=n?ve(n):null;e!==null&&t.add(e)}for(let n of[e.prNumber,e.issueNumber,e.markerRefs?.pr,e.markerRefs?.issue])typeof n==`number`&&Number.isInteger(n)&&n>0&&t.add(n);for(let n of e.pullRequests??[])t.add(n.number);return[...t]}var be=[{id:`title`,kind:`text`,scopes:[`stored`],source:`summary`,texts:e=>[e.title]},{id:`titleSummary`,kind:`text`,scopes:[`stored`],source:`summary`,texts:e=>[e.titleSummary]},{id:`displayTitle`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>[t.displayTitle]},{id:`branch`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.branch]},{id:`workflow`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.workflow]},{id:`workflowLabel`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.workflowLabel]},{id:`automation`,kind:`text`,scopes:[`stored`,`shown`],source:`reader`,texts:(e,t)=>[t.automation],universe:e=>[...e.automationNames?.values()??[]]},{id:`projectName`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>[t.projectName]},{id:`tags`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>t.tags??[]},{id:`id`,kind:`identifier`,scopes:[`stored`],source:`summary`,texts:e=>[e.id]},{id:`urls`,kind:`link`,scopes:[`stored`],source:`summary`,texts:e=>[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl,...(e.pullRequests??[]).map(e=>e.url)]},{id:`heldReferences`,kind:`reference`,scopes:[`stored`],source:`summary`,numbers:ye},{id:`shownReferences`,kind:`reference`,scopes:[`shown`],source:`reader`,numbers:(e,t)=>t.references?.()??[]}];function xe(e){return e.trim().toLowerCase().split(/\s+/).filter(e=>e!==``)}function Se(e,t){return t&&e.automationId!==void 0?t.get(e.automationId)??e.automationId:void 0}function Ce(e,t){let n=t.scope??`stored`,r=t.scope===`shown`?t.extras:{automation:Se(e,t.automationNames)},i=[],a=[],o=[],s={text:i,identifier:a,link:o},c=[];for(let t of be)if(t.scopes.includes(n)){if(t.kind===`reference`){c.push(()=>t.numbers(e,r));continue}for(let n of t.texts(e,r))typeof n==`string`&&s[t.kind].push(n.toLowerCase())}let l;return{prose:i,ids:a,links:o,references:()=>l??=new Set(c.flatMap(e=>e().map(String)))}}function R(e,t,n={}){let r=xe(t);if(r.length===0)return!1;let{prose:i,ids:a,links:o,references:s}=Ce(e,n);return r.every(e=>{if(i.some(t=>t.includes(e)))return!0;let t=e.replace(/^#/,``);return/^\d+$/.test(t)?s().has(String(Number(t)))||a.some(e=>e.startsWith(t)):a.some(t=>t.includes(e))||o.some(t=>t.includes(e))})}var we=new Set([`running`,`waiting`]);function z(e){return e?e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:`${Math.round(e/1024)} kB`:``}function Te(e){return e===void 0?``:`$${e>=10?e.toFixed(0):e.toFixed(2)}`}function Ee(e,t=new Date){if(!v(e))return;let n=new Date(e.autoResumeAt);if(!Number.isFinite(n.getTime()))return;let r=n.toDateString()===t.toDateString(),i=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}).format(n);return{label:r?i:`${new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(n)} ${i}`,title:`Resumes automatically at ${new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(n)}`}}function De(e){return e.steps?re({workflow:e.workflow,steps:e.steps}):e.workflowLabel??e.workflow}function Oe(e,t,n=()=>``){let r=e.filter(e=>!c(e));return t.trim()?r.filter(e=>R(e,t,{scope:`shown`,extras:{displayTitle:l(e),automation:n(e),references:()=>B(e)}})):[...r]}function B(e){return K(e).map(e=>e.number)}function V(e,t){return e.filter(e=>o(e,t)).length}function ke(e){return V(e)}function Ae(e){return H(e)[0]??e.pullRequests?.find(e=>e.url)?.url}function H(e){let t=[];return e.pullRequestUrl&&t.push(e.pullRequestUrl),!(e.markerRefs?.issue!==void 0&&e.markerRefs?.pr===void 0)&&e.referencedPullRequestUrl&&t.push(e.referencedPullRequestUrl),t}function U(e,t){if(e.referencedIssueUrl)return e.referencedIssueUrl;let n=e.issueNumber??e.markerRefs?.issue;if(!(!n||!t))return`${t}/issues/${n}`}function W(e){let t=`${e.kind}#${e.number}`;if(!e.url)return`${t}@project:${e.projectId??`default`}`;try{let n=new URL(e.url),r=n.pathname.split(`/`).filter(Boolean).slice(0,2).join(`/`);return`${t}@${n.host.toLowerCase()}/${r.toLowerCase()}`}catch{return`${t}@${e.url}`}}var G=new WeakMap;function K(e,t,n=e.projectId){let r=G.get(e);if(r&&r.repoBase===t&&r.projectId===n)return r.refs;let i=je(e,t,n);return G.set(e,{repoBase:t,projectId:n,refs:i}),i}function je(e,t,n){let r=H(e),i=e.markerRefs?.pr,a=[...i===void 0||[...r,...(e.pullRequests??[]).flatMap(e=>e.url?[e.url]:[])].some(e=>J(e)===String(i))?[]:[{kind:`PR`,number:i}],...r.map(e=>({kind:`PR`,url:e})),{kind:`PR`,number:e.prNumber},...(e.pullRequests??[]).map(e=>({kind:`PR`,number:e.number,...e.url?{url:e.url}:{},authoritative:!0})),{kind:`Issue`,url:U(e,t)},{kind:`Issue`,number:e.issueNumber}],o=new Set,s=[];for(let e of a){let r=e.url?Number(J(e.url)):e.number;if(!r||!Number.isInteger(r)||!e.url&&!e.authoritative&&s.some(t=>t.url&&t.kind===e.kind&&t.number===r))continue;let i=e.url??Me(e.kind,r,t),a={kind:e.kind,number:r,...i?{url:i}:n===void 0?{}:{projectId:n}},c=W(a);o.has(c)||(o.add(c),s.push(a))}return s}function Me(e,t,n){if(n)return`${n}/${e===`PR`?`pull`:`issues`}/${t}`}function Ne(e){return K(e)[0]}function q(e,t){if(!e.url)return!0;if(!t)return!1;let n=Ie(t);return n!==void 0&&Ie(e.url)===n}var Pe=new WeakMap;function Fe(e,t,n=e.projectId){let r=Pe.get(e);if(r&&r.repoBase===t&&r.projectId===n)return r.refs;let i=K(e,t,n).filter(e=>q(e,t));return Pe.set(e,{repoBase:t,projectId:n,refs:i}),i}function Ie(e){try{let t=new URL(e),[n,r]=t.pathname.split(`/`).filter(Boolean);return n&&r?`${t.host}/${n}/${r}`.toLowerCase():void 0}catch{return}}function Le(e,t){let n=[];for(let r of K(e,t)){if(!q(r,t))continue;let e=r.kind===`PR`?`pr`:`issue`;n.some(t=>t.kind===e&&t.number===r.number)||n.push({kind:e,number:r.number})}return n}function Re(e,t,n,r){if(q(n,r))return`/p/${e}/tasks/${t}/${n.kind===`PR`?`pr`:`issue`}/${n.number}`}function J(e){return/\/(\d+)\/?(?:[?#].*)?$/.exec(e)?.[1]??null}function ze(e,t){let n=we.has(e.status)?t:void 0;if(n)return{cpu:{text:`${n.cpuPct.toFixed(0)}%`,kind:`live`},mem:{text:z(n.rssBytes),kind:`live`}};let r=z(e.peakRssBytes);return{cpu:{text:``,kind:`none`},mem:r?{text:`peak ${r}`,kind:`peak`,title:`peak — run finished${e.peakProcCount?` · ${e.peakProcCount} procs`:``}`}:{text:``,kind:`none`}}}function Be(e,t,n=!1){return n||e.filter(e=>!t(e.label)).some(e=>e.rows.flatMap(L).some(e=>Ne(e)!==void 0))}var Y=n(),Ve=(0,N.createContext)(null);function He({children:e}){let[t,n]=(0,N.useState)(()=>new Map),r=(0,N.useCallback)((e,t)=>{n(n=>{let r=new Map(n);return r.set(e,t),r})},[]),i=(0,N.useCallback)(e=>{n(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),a=u((0,N.useMemo)(()=>[...t.values()].flat(),[t])),o=(0,N.useMemo)(()=>({publish:r,retract:i,lookup:a}),[r,i,a]);return(0,Y.jsx)(Ve.Provider,{value:o,children:e})}var X=(0,N.createContext)(null);function Ue({projectId:e,repoBase:t,requests:n,children:r}){let i=(0,N.useContext)(Ve),a=(0,N.useContext)(X),o=(0,N.useId)();(0,N.useEffect)(()=>{if(i)return i.publish(o,n),()=>i.retract(o)},[i,o,(0,N.useMemo)(()=>n.map(e=>`${e.hostId??``}:${e.projectId} ${e.kind}#${e.number}`).sort().join(`|`),[n])]);let s=u(i?We:n),c=i?.lookup??s,l=t??(a&&a.projectId===e?a.repoBase:void 0),d=(0,N.useMemo)(()=>({lookup:c,projectId:e,repoBase:l}),[c,e,l]);return(0,Y.jsx)(X.Provider,{value:d,children:r})}var We=[];function Z(e,t,n,r){let i=(0,N.useContext)(X),a=n??i?.projectId;return!i||!a||t===void 0?qe:i.lookup({...r===void 0?{}:{hostId:r},projectId:a,kind:e,number:t})}function Ge(e,t,n){let r=(0,N.useContext)(X),i=t??r?.projectId;return!r||!i?[]:e.filter(e=>r.lookup({...n===void 0?{}:{hostId:n},projectId:i,kind:`PR`,number:e}).conflicting===!0)}function Ke(){let e=(0,N.useContext)(X);return{projectId:e?.projectId,repoBase:e?.repoBase}}var qe=Object.freeze({state:`idle`}),Je={success:`border-success/40 text-semantic-green`,danger:`border-danger/40 text-semantic-red`,accent:`border-accent-strong/35 text-accent-text`,merged:`border-merged-strong/35 text-merged-text`,info:`border-info/40 text-semantic-info`,neutral:`border-border text-muted-foreground`,pending:`border-pending-strong/45 text-semantic-amber`,conflict:`border-conflict/45 text-semantic-conflict`},Ye={success:`text-semantic-green`,danger:`text-semantic-red`,accent:`text-merged-text`,merged:`text-merged-text`,info:`text-semantic-info`,neutral:`text-soft-foreground`,pending:`text-semantic-amber`,conflict:`text-semantic-conflict`},Xe={success:`hover:bg-success/10`,danger:`hover:bg-danger/10`,accent:`hover:bg-accent-strong/10`,merged:`hover:bg-merged-strong/10`,info:`hover:bg-info/10`,neutral:`hover:bg-muted`,pending:`hover:bg-pending-strong/10`,conflict:`hover:bg-conflict/10`},Ze={draft:x,"review-required":S,"changes-requested":T,"checks-pending":null,"checks-failing":E,ready:j,merged:C,closed:w,open:A,completed:j,"not-planned":O};function Q(e){return e===`PR`?`pr-chip`:`issue-chip`}function $(e){return e?{"data-conflicting":`true`}:{}}function Qe(e,t,n,r){return!n||r!==void 0&&q({kind:e,number:t??0,url:n},r)}function $e(e,t,n){return e===`PR`&&(t??n)===!0}function et({plain:e,inert:t,conflicting:n,className:r,tone:i}){return e?y(`inline-flex items-center gap-1 rounded-[2px] text-inherit`,n&&`text-conflict font-medium`,!t&&`group/reference focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-link-foreground`,r):y(`inline-flex h-[22px] items-center gap-1 rounded-md border px-1.5 font-mono text-[12px] font-normal`,Je[i],r)}function tt(e,t,n,r){return n&&!r?t?`${e===`PR`?`PR `:``}#${t}`:e:t?`${!r&&e===`Issue`?`Issue `:``}#${t}`:e}function nt(e){return e===`PR`?`pull request`:`issue`}function rt(e,t,n,r){return`Open the ${e}${t?` #${t}`:``} for ${n}${r?` — ${r.label}`:``}`}function it(e,t){return e&&t?Ye[t.tone]:void 0}function at(e,t){return!e&&(!t||!b(t))}function ot({conflicting:e,presentation:t,status:n,plain:r,compact:i,inert:a,kind:o,label:s,glyphClass:c}){return(0,Y.jsxs)(Y.Fragment,{children:[e?(0,Y.jsx)(D,{className:y(`size-2.5 shrink-0`,c),"aria-hidden":`true`}):(0,Y.jsx)(yt,{status:t?n:void 0,className:r?y(`size-2.5`,c):void 0}),r&&i?o===`PR`?(0,Y.jsx)(S,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):(0,Y.jsx)(A,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):null,r?(0,Y.jsx)(`span`,{className:a?void 0:`underline-offset-2 group-hover/reference:underline group-focus-visible/reference:underline`,children:s}):s]})}function st({kind:e,status:t,conflicting:n,chipClass:r,body:i}){return(0,Y.jsx)(`span`,{"data-slot":Q(e),"data-status":t,"data-inert":`true`,...$(n),className:r,children:i})}function ct({kind:e,number:t,tooltip:n,url:r}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`block font-medium`,children:[e===`PR`?`Pull request`:`Issue`,t?` #${t}`:``,` · `,n.headline]}),(0,Y.jsx)(`span`,{className:`block`,children:n.detail}),n.also?(0,Y.jsx)(`span`,{className:`block text-muted-foreground`,children:n.also}):null,r&&b(r)?(0,Y.jsx)(`span`,{className:`block text-muted-foreground`,children:r.replace(/^https?:\/\//,``)}):null]})}function lt({reference:e,taskTitle:t,status:n,conflicting:r,conflictAction:i,projectId:a,hostId:o,repoBase:s,to:c,fullPage:l=!1,className:u,compact:d=!1,plain:m=!1,inert:h=!1}){let{kind:g,number:_,url:v}=e,ee=Ke(),b=Z(g,Qe(g,_,v,s??ee.repoBase)?_:void 0,a,o),x=n??b.status,S=p(x),C=$e(g,r,b.conflicting),w=C?f:S,T=w?.tone??`accent`,E=et({plain:m,inert:h,conflicting:C,className:u,tone:T}),D=gt(b,w,C?S:void 0),O=tt(g,_,m,d),k=nt(g),A=rt(k,_,t,w),j=(0,Y.jsx)(ot,{conflicting:C,presentation:w,status:x,plain:m,compact:d,inert:h,kind:g,label:O,glyphClass:it(m,w)});if(h)return(0,Y.jsx)(st,{kind:g,status:x,conflicting:C,chipClass:E,body:j});let M=at(c,v)?(0,Y.jsx)(`span`,{"data-slot":Q(g),"data-status":x,...$(C),"aria-label":w?`${k} ${O} — ${w.label}`:void 0,className:E,children:j}):(0,Y.jsx)(ut,{to:c,fullPage:l,url:v,"data-slot":Q(g),"data-status":x,...$(C),title:D?void 0:v,"aria-label":A,className:m?E:y(E,Xe[T]),children:j});return D?(0,Y.jsx)(ht,{chip:M,action:C?i:void 0,state:b.state,children:(0,Y.jsx)(ct,{kind:g,number:_,tooltip:D,url:v})}):M}function ut({to:e,fullPage:t,url:n,children:r,...i}){return e?t?(0,Y.jsx)(`a`,{href:e,...i,children:r}):(0,Y.jsx)(ee,{to:e,...i,children:r}):(0,Y.jsx)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,...i,children:r})}var dt=(0,N.createContext)(()=>{});function ft(){return(0,N.useContext)(dt)}var pt=150,mt=120;function ht({chip:e,action:t,state:n,children:r}){let[i,a]=(0,N.useState)(!1),o=(0,N.useRef)(null),s=(0,N.useRef)(null),c=(0,N.useRef)(void 0),l=(0,N.useCallback)((e,t)=>{clearTimeout(c.current),c.current=setTimeout(()=>a(e),t)},[]),u=(0,N.useCallback)(()=>{clearTimeout(c.current),a(!1)},[]);(0,N.useEffect)(()=>()=>clearTimeout(c.current),[]);let d=e=>e instanceof Node&&(s.current?.contains(e)||o.current?.contains(e));return(0,Y.jsxs)(ne,{open:i,onOpenChange:e=>e?a(!0):u(),children:[(0,Y.jsx)(M,{asChild:!0,ref:o,onPointerEnter:e=>{e.pointerType!==`touch`&&l(!0,pt)},onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,mt)},onFocus:()=>a(!0),onBlur:e=>{d(e.relatedTarget)||u()},onKeyDown:e=>{if(e.key===`Escape`)return u();if(e.key!==`Tab`||e.shiftKey||!t)return;let n=s.current?.querySelector(`button:not([disabled]), [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);n&&(e.preventDefault(),n.focus())},...t?{"aria-haspopup":`dialog`,"aria-expanded":i}:{},children:e}),(0,Y.jsxs)(te,{ref:s,side:`top`,role:t?`dialog`:`tooltip`,"data-slot":`reference-status-card`,"data-tooltip-state":n,className:`w-64 space-y-2 p-3 text-xs`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>{e.preventDefault(),d(document.activeElement)&&o.current?.focus()},onPointerEnter:()=>clearTimeout(c.current),onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,mt)},children:[(0,Y.jsx)(`div`,{className:`space-y-0.5`,children:r}),t?(0,Y.jsx)(dt.Provider,{value:u,children:t}):null]})]})}function gt(e,t,n){if(t){let{label:r,hint:i}=t,a=n?`also ${_t(n.label)} — ${n.hint}`:void 0;return e.state===`unavailable`?{headline:r,detail:`last known — GitHub is unreachable${e.reason?` (${e.reason})`:``}`,...a?{also:a}:{}}:{headline:r,detail:i,...a?{also:a}:{}}}switch(e.state){case`loading`:return{headline:`Checking GitHub…`,detail:`the status of this reference is on its way`};case`unavailable`:return{headline:`Status unavailable`,detail:e.reason??`GitHub could not be reached — the chip says nothing rather than guessing`};case`unknown`:return{headline:`Not found on this repository`,detail:`GitHub has no such number here — the reference may point at another repo`};default:return null}}function _t(e){return e.charAt(0).toLowerCase()+e.slice(1)}function vt({kind:e,number:t,className:n}){let r=Z(e,t),i=p(r.status),a=e===`PR`&&r.conflicting===!0,o=a?f:i;if(!o)return null;let s=y(`size-2.5`,Ye[o.tone]);return(0,Y.jsx)(`span`,{"data-slot":`reference-status-glyph`,"data-status":r.status,...a?{"data-conflicting":`true`}:{},"aria-hidden":`true`,className:y(`inline-flex items-center`,n),children:a?(0,Y.jsx)(D,{className:y(`shrink-0`,s),"aria-hidden":`true`}):(0,Y.jsx)(yt,{status:r.status,className:s})})}function yt({status:e,className:t}){if(!e)return null;if(e===`checks-pending`)return(0,Y.jsx)(k,{"data-slot":`status-dot`,"data-tone":`pending`,className:y(`size-3 animate-pulse motion-reduce:animate-none`,t),"aria-hidden":`true`});let n=Ze[e];return n?(0,Y.jsx)(n,{className:y(`size-2.5 shrink-0`,t),"aria-hidden":`true`}):null}export{le as A,L as B,Le as C,ze as D,K as E,de as F,se as I,ce as L,_e as M,ue as N,De as O,fe as P,F as R,Re as S,Ne as T,ie as V,W as _,He as a,V as b,Z as c,Te as d,z as f,Be as g,J as h,Ue as i,ae as j,R as k,Oe as l,Fe as m,vt as n,Ge as o,q as p,ft as r,Ke as s,lt as t,ke as u,Ee as v,Ae as w,U as x,B as y,oe as z};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{B as r,an as i,in as a}from"./queries-DD_9iITj.js";import{Zi as o}from"./project-scope-context-DNrHbqd2.js";import{Tn as s}from"./index-C3kap2_j.js";var c=e(t(),1),l=n();function u(){let e=o(),t=(0,c.useCallback)(async()=>{await Promise.all([e.invalidateQueries({queryKey:a.health}),e.invalidateQueries({queryKey:a.agentConfig,exact:!0}),e.invalidateQueries({queryKey:i.agentProfiles,exact:!0})])},[e]);return(0,c.useEffect)(()=>{t()},[t]),t}var d=`${s()} remote-settings enable`;function f({risk:e}){return r().data?.capabilities?.remoteSettingsAdmin===!0?(0,l.jsxs)(`p`,{role:`note`,"data-slot":`remote-settings-notice`,className:`rounded-md border border-pending-strong/40 bg-pending/10 px-3 py-2 text-[13px] text-foreground`,children:[`Remote settings administration is on. `,e,`, and anyone who can open this cockpit can change them. The host operator turns this off with`,` `,(0,l.jsxs)(`code`,{children:[s(),` remote-settings disable`]}),`.`]}):null}export{f as n,u as r,d as t};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{B as r,an as i,in as a}from"./queries-ChH9ctc-.js";import{Qi as o}from"./project-scope-context-hfRzPMZ4.js";import{Tn as s}from"./index-BuR9xHfb.js";var c=e(t(),1),l=n();function u(){let e=o(),t=(0,c.useCallback)(async()=>{await Promise.all([e.invalidateQueries({queryKey:a.health}),e.invalidateQueries({queryKey:a.agentConfig,exact:!0}),e.invalidateQueries({queryKey:i.agentProfiles,exact:!0})])},[e]);return(0,c.useEffect)(()=>{t()},[t]),t}var d=`${s()} remote-settings enable`;function f({risk:e}){return r().data?.capabilities?.remoteSettingsAdmin===!0?(0,l.jsxs)(`p`,{role:`note`,"data-slot":`remote-settings-notice`,className:`rounded-md border border-pending-strong/40 bg-pending/10 px-3 py-2 text-[13px] text-foreground`,children:[`Remote settings administration is on. `,e,`, and anyone who can open this cockpit can change them. The host operator turns this off with`,` `,(0,l.jsxs)(`code`,{children:[s(),` remote-settings disable`]}),`.`]}):null}export{f as n,u as r,d as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{A as r,C as i,H as a,Lt as o,S as s,T as c,Xt as l,_r as u,in as d,ut as f,w as p}from"./queries-DD_9iITj.js";import{h as m}from"./host-context-iTMFRMT5.js";import{B as h,Cn as g,T as _,Zi as v,a as y,f as b,ut as ee,w as x,z as te,zt as ne}from"./project-scope-context-DNrHbqd2.js";import{Z as S}from"./live-protocol-CNUmr-VT.js";import{_ as C,g as w}from"./chunk-KS7C4IRE-BdLLx37K.js";import{c as T,f as E,i as D,t as re}from"./reference-chip-e-fG4-yW.js";import{o as O,s as k}from"./dist-CCX8mhHc.js";import{D as ie,F as A,I as j,M as ae,N as oe,P as se,Q as ce,S as le,X as ue,Z as de,c as fe,ct as M,d as pe,j as me,l as he,n as ge,st as _e,w as ve,y as ye}from"./design-icons-QbNMZniQ.js";import{t as be}from"./createLucideIcon-BHp8sXmF.js";import{n as xe,t as Se}from"./circle-x-7nTlobAF.js";import{_ as Ce}from"./nav-row-styles-CIedRn3A.js";import{i as we,r as Te,t as Ee}from"./git-toolbar-CoKBTzNV.js";import{t as De}from"./info-DA1x_4bz.js";import{t as Oe}from"./loader-circle-CPBhhDbB.js";import{a as ke,i as Ae,n as je,r as Me}from"./diff-controls-CkxtRrbB.js";import{t as N}from"./button-BV_AiLj2.js";import{i as P,l as Ne,p as Pe,r as Fe,t as Ie}from"./dropdown-menu-NJZfnQCU.js";import{a as Le,i as Re,n as ze,o as Be,r as Ve,s as He,t as Ue}from"./dialog-DKr-j9S6.js";import{t as F}from"./project-router-CfEuKuz1.js";import{t as We}from"./status-dot-Da1M54kK.js";import{c as Ge,d as Ke,f as qe,m as I,n as Je,s as L,t as Ye}from"./page-shell-BdjH5hyc.js";import{a as Xe,o as Ze}from"./format-BU7D3IfE.js";import{t as Qe}from"./control-locations-kCPVEtOM.js";import{t as R}from"./centered-state-N8vWM_Hw.js";import{$t as z,A as $e,Bn as et,Bt as tt,Cr as nt,Gt as rt,Ht as it,Jt as at,Kt as ot,Pn as st,Qt as ct,Rn as lt,Rt as ut,Tr as dt,Ut as ft,Vt as pt,Wt as mt,Xt as ht,Yt as gt,Zt as _t,an as B,en as V,gr as vt,in as H,k as yt,lr as U,nn as W,on as G,qt as K,rn as q,tn as J,zn as bt,zt as xt}from"./index-C3kap2_j.js";import{t as St}from"./markdown-BBDDg-4t.js";import{t as Ct}from"./diff-BOF9OXhn.js";import{t as wt}from"./change-counts-BLLRvt46.js";import{t as Tt}from"./code-workbench-B0GIezrD.js";import{t as Et}from"./file-text-nGpo7MVd.js";import{i as Dt,n as Ot,r as kt}from"./commit-list-Jr1_04RS.js";var Y=e(t(),1);function At(e,t){let n=v(t),r=n.getQueryCache();return Y.useSyncExternalStore(Y.useCallback(e=>r.subscribe(S.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var jt=be(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),Mt=be(`git-pull-request-create`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v3`,key:`1jb6z3`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]),X=n();function Nt(){let e=m(),t=s(),n=v(),r=At({queryKey:d.repo})>0,i=t.data?.info?t.data:null,a=ut(e,i,`screen`);return(0,X.jsx)(Ke,{route:`repo-git`,density:i?.info?`full`:`empty`,headerSpacing:`compact`,header:{title:`Git`,secondaryActions:(0,X.jsx)(Ge,{type:`button`,variant:`ghost`,"data-slot":`git-screen-refresh`,"aria-label":`Refresh the repository`,title:`Refresh the repository`,disabled:r,onClick:()=>{n.invalidateQueries({queryKey:d.repo}),n.invalidateQueries({queryKey:d.worktrees})},children:(0,X.jsx)(de,{size:17,"aria-hidden":`true`,className:O(`size-[17px]`,r&&`motion-safe:animate-spin`)})})},children:(0,X.jsxs)(`div`,{"data-slot":`git-screen`,children:[i?.info?(0,X.jsx)(`div`,{className:`mb-[16px]`,children:(0,X.jsx)(pt,{scope:e,repo:i,info:i.info,variant:`screen`},e)}):t.isPending?(0,X.jsx)(`p`,{"data-slot":`git-screen-loading`,role:`status`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Loading the checkout…`}):t.isError?(0,X.jsxs)(`p`,{"data-slot":`git-screen-error`,role:`alert`,className:`mb-[16px] px-[10px] text-[13px] text-danger`,children:[`Could not load the repository: `,t.error.message]}):(0,X.jsx)(`p`,{"data-slot":`git-screen-not-git`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Not a git repository.`}),t.isPending?null:(0,X.jsx)(xt,{branch:i?.info?.branch??null,counts:a,variant:`screen`})]})})}function Pt(e){if(e===``)return null;if(e===`@`)return`A branch cannot be named “@”.`;if(e.startsWith(`-`))return`A branch name cannot start with “-”.`;if(/\s/.test(e))return`A branch name cannot contain spaces.`;if(/[\u0000-\u001f\u007f]/.test(e))return`A branch name cannot contain control characters.`;let t=/[~^:?*[\\]/.exec(e);if(t)return`A branch name cannot contain “${t[0]}”.`;if(e.includes(`..`))return`A branch name cannot contain “..”.`;if(e.includes(`@{`))return`A branch name cannot contain “@{”.`;if(e.startsWith(`/`)||e.endsWith(`/`))return`A branch name cannot start or end with “/”.`;if(e.includes(`//`))return`A branch name cannot contain “//”.`;if(e.endsWith(`.`))return`A branch name cannot end with “.”.`;for(let t of e.split(`/`)){if(t.startsWith(`.`))return`A part of a branch name cannot start with “.”.`;if(t.endsWith(`.lock`))return`A part of a branch name cannot end with “.lock”.`}return null}function Ft({from:e}){let[t,n]=(0,Y.useState)(!1),r=(0,Y.useRef)(null);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Ge,{ref:r,variant:`primary`,"data-action":`new-branch`,disabled:rt(m())&&!t,onClick:()=>n(!0),children:[(0,X.jsx)(ue,{size:16,"aria-hidden":`true`}),`New branch`]}),t?(0,X.jsx)(It,{from:e,returnFocus:r,onClose:()=>n(!1)}):null]})}function It({from:e,returnFocus:t,onClose:n}){let r=mt(m()),i=rt(m()),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(null),l=a.trim(),u=Pt(l),d=u??s;return(0,X.jsx)(Ue,{open:!0,onOpenChange:e=>{!e&&!r.isPending&&n()},children:(0,X.jsx)(Ve,{"data-slot":`new-branch-dialog`,className:`sm:max-w-md`,onCloseAutoFocus:e=>{e.preventDefault(),t.current?.focus()},children:(0,X.jsxs)(`form`,{className:`grid min-w-0 gap-4`,onSubmit:e=>{e.preventDefault(),!(!l||u||i)&&(c(null),r.mutate(l,{onSuccess:n,onError:e=>c(e.message)}))},children:[(0,X.jsxs)(Be,{children:[(0,X.jsx)(He,{children:`New branch`}),(0,X.jsxs)(Re,{"data-slot":`new-branch-base`,children:[`Create from `,(0,X.jsx)(`span`,{className:`font-mono text-foreground`,children:e}),` and switch to it. Switching changes your working tree.`]})]}),(0,X.jsxs)(ze,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,X.jsx)(U,{id:`new-branch-name`,autoComplete:`off`,spellCheck:!1,placeholder:`new-branch-name`,className:`h-11 bg-background font-mono md:text-base placeholder:text-soft-foreground`,value:a,"aria-invalid":d?!0:void 0,"aria-describedby":d?`new-branch-name-hint`:void 0,onChange:e=>{o(e.target.value),c(null)}}),d?(0,X.jsx)(`p`,{id:`new-branch-name-hint`,"data-slot":u?`branch-name-hint`:`branch-create-refusal`,role:`alert`,className:`text-xs text-danger`,children:d}):null]}),(0,X.jsxs)(Le,{children:[(0,X.jsx)(N,{type:`button`,variant:`outline`,disabled:r.isPending,onClick:n,children:`Cancel`}),(0,X.jsx)(N,{type:`submit`,variant:`primary`,"data-action":`create-branch`,disabled:!l||u!==null||i,children:r.isPending?`Creating…`:`Create`})]})]})})})}function Lt({entry:e}){return e.keptReason?(0,X.jsx)(`span`,{"data-slot":`branch-kept-reason`,className:`min-w-0 text-xs text-muted-foreground`,children:e.keptReason}):null}function Rt({repo:e,info:t}){let n=i(),r=new Map((n.data?.branches??[]).map(e=>[e.name,e])),a=n.data?.base??e.baseBranch??t.branch,o=mt(m(),e=>y(e.message,{tone:`danger`})),s=rt(m()),[c,l]=(0,Y.useState)(``),u=c.trim().toLowerCase(),d=Gt(e,n.data?.branches),f=u?d.filter(e=>e.toLowerCase().includes(u)):d;return(0,X.jsx)(`section`,{"data-slot":`repo-branches`,className:`min-w-0`,children:(0,X.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,X.jsx)(`h2`,{className:`sr-only`,children:`Branches`}),(0,X.jsxs)(`label`,{className:`relative block`,children:[(0,X.jsx)(ce,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3 size-4 text-muted-foreground`}),(0,X.jsx)(U,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:c,onChange:e=>l(e.target.value),className:`h-10 rounded-lg border-border bg-card pl-10`})]}),(0,X.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-3.5 flex min-w-0 flex-col divide-y divide-border border-t border-border md:max-h-[40rem] md:overflow-y-auto md:overscroll-contain`,children:[f.map(e=>{let n=e===t.branch,i=r.get(e);return(0,X.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,"data-branch-class":i?.class,className:`flex min-h-[60px] flex-col items-start justify-center gap-1.5 py-2 md:flex-row md:items-center md:justify-start md:gap-2.5`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 max-w-full items-center gap-[8px]`,children:[i?.runId?(0,X.jsx)(F,{to:`/tasks/${i.runId}`,"data-slot":`branch-task-link`,title:i.title?`Open the task ${i.title}`:`Open the task`,className:`min-w-0 truncate rounded-[2px] font-mono text-[12px] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:e}):(0,X.jsx)(`span`,{className:O(`min-w-0 truncate font-mono text-[12px]`,n&&`font-medium`),children:e}),i&&!(n&&i.class===`active`)?(0,X.jsx)(Wt,{entry:i}):null]}),i?(0,X.jsx)(zt,{entry:i,base:a}):null,i?(0,X.jsx)(Lt,{entry:i}):null,e.startsWith(`cez/`)&&!n?null:n?(0,X.jsx)(`span`,{"data-slot":`branch-current`,className:`flex h-8 shrink-0 items-center rounded-md bg-accent-strong/10 px-2.5 text-[12px] font-medium text-accent-text md:ml-auto`,children:`Current`}):(0,X.jsxs)(N,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`md:ml-auto`,disabled:s,onClick:()=>o.mutate(e),children:[(0,X.jsx)(me,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),f.length===0?(0,X.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-muted-foreground`,children:[`No branches match “`,c.trim(),`”.`]}):null]})]})})}function zt({entry:e,base:t}){let n=e.pr?.state===`open`||e.pr?.state===`draft`;return(0,X.jsxs)(`span`,{"data-slot":`branch-facts`,className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:[(0,X.jsxs)(`span`,{"data-slot":`branch-counts`,title:`${Z(e.ahead)} ahead of ${t}, ${Z(e.behind)} behind`,className:`shrink-0 font-mono tabular-nums`,children:[(0,X.jsxs)(`span`,{"aria-hidden":`true`,children:[`↑`,e.ahead,` ↓`,e.behind]}),(0,X.jsxs)(`span`,{className:`sr-only`,children:[Z(e.ahead),` ahead of `,t,`, `,Z(e.behind),` behind`]})]}),e.pr?(0,X.jsx)(Vt,{pr:e.pr}):null,n&&e.pr?.checks?(0,X.jsx)(Ht,{checks:e.pr.checks}):null]})}var Z=e=>`${e} commit${e===1?``:`s`}`,Bt={open:{icon:j,className:`border-success/40 text-semantic-green`},draft:{icon:A,className:`border-border text-muted-foreground`},merged:{icon:oe,className:`border-merged-strong/35 text-merged-text`},closed:{icon:se,className:`border-danger/40 text-semantic-red`}};function Vt({pr:e}){let{icon:t,className:n}=Bt[e.state],r=(0,X.jsxs)(`span`,{className:O(`inline-flex h-6 items-center gap-1 rounded-[4px] border px-1.5 text-xs font-medium group-hover:bg-muted`,n),children:[(0,X.jsx)(t,{size:12,"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,X.jsxs)(`span`,{className:`font-mono`,children:[`#`,e.number]}),(0,X.jsx)(`span`,{children:e.state})]}),i=`inline-flex shrink-0 items-center rounded-[4px] max-md:min-h-11 no-hover:min-h-11`;return k(e.url)?(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`branch-pr`,"data-pr-state":e.state,title:`Open pull request #${e.number}`,className:O(i,`group focus-visible:outline-2 focus-visible:outline-ring`),children:r}):(0,X.jsx)(`span`,{"data-slot":`branch-pr`,"data-pr-state":e.state,className:i,children:r})}function Ht({checks:e}){let t=e===`passing`?xe:e===`failing`?Se:nt;return(0,X.jsxs)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:O(`inline-flex shrink-0 items-center gap-1 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:[(0,X.jsx)(t,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),e]})}var Ut={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function Wt({entry:e}){return(0,X.jsx)(`span`,{"data-slot":`branch-class`,className:O(`shrink-0 rounded-[4px] border px-1.5 py-px text-xs leading-4 font-medium`,e.class===`active`?`border-status-running/40 text-status-running`:e.class===`not-landed`||e.class===`orphan`?`border-inbox-count-foreground/40 text-inbox-count-foreground`:`border-border text-soft-foreground`),children:Ut[e.class]})}function Gt(e,t){let n=new Set(e.branches);for(let e of t??[])n.add(e.name);return[...n].sort((e,t)=>e.localeCompare(t))}function Kt(){let e=p(),t=I(),[n,r]=(0,Y.useState)(`unified`),[i,a]=(0,Y.useState)(!0),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),u=(0,Y.useRef)(null),d=e.isError&&e.error instanceof g&&e.error.status===409,f=e.data?.files??[],m=(0,Y.useMemo)(()=>Te(f),[f]),h=(0,Y.useMemo)(()=>f.some(St),[f]),v=t?n:`unified`;return(0,X.jsx)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:e.isPending?(0,X.jsx)(`p`,{"data-slot":`changes-loading`,className:`py-6 text-center text-xs text-muted-foreground`,children:`Loading changes…`}):e.isError?(0,X.jsx)(R,{icon:d?(0,X.jsx)(ve,{size:16}):(0,X.jsx)(M,{size:16}),tone:d?`neutral`:`danger`,heading:`h2`,title:d?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):f.length===0?(0,X.jsx)(R,{icon:(0,X.jsx)(ve,{size:16}),tone:`neutral`,heading:`h2`,title:`Working tree clean`,subtitle:`No uncommitted changes in the main working tree. Edits show up here as they happen.`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-3 gap-y-2 pb-4 [&_button:not([data-button-size])]:min-h-11`,children:[e.data?(0,X.jsx)(Ee,{stat:e.data.stat}):null,(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[h&&o?(0,X.jsx)(Ae,{}):null,h?(0,X.jsx)(`span`,{className:`max-md:hidden`,children:(0,X.jsx)(ke,{preview:o,onPreviewChange:s})}):null,(0,X.jsx)(Me,{mode:n,wrap:i,onModeChange:r,onWrapChange:a,disabled:h&&o}),(0,X.jsx)(je,{wrap:i,onWrapChange:a,preview:o,onPreviewChange:h?s:void 0,disabled:h&&o})]})]}),(0,X.jsx)(Tt,{className:`gap-5 [--diff-sticky-top:0px] md:gap-0`,treeSlot:`changes-tree-pane`,treeClassName:`overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_2rem)]`,tree:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`h2`,{"data-slot":`changes-tree-heading`,className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,X.jsx)(we,{root:m,selected:c,onSelect:e=>{l(e),u.current?.scrollToPath(e)}})]}),children:(0,X.jsx)(Ct,{files:f,viewRef:u,mode:v,wrap:i,preview:o,loadFileText:e=>Et(()=>_(e)),totals:!1,className:`min-w-0 flex-1`})})]})})}function qt({repo:e,info:t}){let{sha:n}=w(),r=I(),i=e.log,a=(0,Y.useMemo)(()=>ct(i),[i]);if(n&&(!r||i.length===0))return(0,X.jsx)(Qt,{sha:n});let o=at(e,t),s=o&&o.behind>0?(0,X.jsx)(Xt,{info:t,tracking:o}):null;if(i.length===0)return(0,X.jsxs)(X.Fragment,{children:[s?(0,X.jsx)(`div`,{children:s}):null,(0,X.jsx)(R,{icon:(0,X.jsx)(ae,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`})]});let c=(0,X.jsxs)(`div`,{"data-slot":`repo-commits`,className:`flex flex-col gap-4`,children:[s,a.map(e=>(0,X.jsxs)(`section`,{"data-slot":`repo-commit-day`,"aria-label":e.label,className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground`,children:e.label}),(0,X.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.commits.map(e=>(0,X.jsx)(Jt,{commit:e,selected:r&&e.hash===(n??i[0]?.hash),stacked:r},e.hash))})]},e.label))]});return r?(0,X.jsx)(Tt,{className:`flex-none`,treeSlot:`repo-commits-pane`,tree:c,children:(0,X.jsx)(Zt,{sha:n??i[0]?.hash})}):c}function Jt({commit:e,selected:t,stacked:n}){return(0,X.jsxs)(`li`,{"data-selected":t?`true`:void 0,className:O(`flex min-h-[52px] gap-3.5 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,n?`flex-col items-stretch gap-0`:`items-center`,t&&`bg-muted/70`),children:[(0,X.jsxs)(F,{to:`/git/commits/${e.hash}`,"data-slot":`commit-row`,"data-sha":e.hash,"aria-current":t?`true`:void 0,className:`flex min-h-[52px] min-w-0 flex-1 flex-col justify-center gap-0.5 px-4 py-2 focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,X.jsx)(`span`,{"data-slot":`commit-row-subject`,className:`truncate text-[13px] font-medium text-foreground`,children:e.subject}),(0,X.jsxs)(`span`,{"data-slot":`commit-row-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(Ot,{sha:e.hash}),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`}),(0,X.jsxs)(`span`,{className:`truncate`,children:[e.author,` · `,(0,X.jsx)(`span`,{title:_t(e.when,e.at),children:ht(e.when,e.at)})]})]})]}),(0,X.jsx)(Yt,{source:e.source,stacked:n})]})}function Yt({source:e,stacked:t}){let n=O(`hidden shrink-0 items-center gap-[5px] text-xs text-muted-foreground md:flex`,t?`-mt-1.5 max-w-full self-start px-4 pb-2.5`:`max-w-[45%] pr-4`);return e?(0,X.jsxs)(F,{to:`/tasks/${e.runId}`,"data-slot":`commit-source`,"data-source":`task`,"aria-label":`From the task ${e.title}${e.prNumber===null?``:`, pull request #${e.prNumber}`}`,className:O(n,`rounded-[4px] hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`),children:[e.prNumber===null?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(oe,{"aria-hidden":`true`,className:`size-[11px] shrink-0 text-merged-text`}),(0,X.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`PR #`,e.prNumber]})]}),(0,X.jsx)(fe,{"aria-hidden":`true`,className:`size-[12px] shrink-0`}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]}):(0,X.jsx)(`span`,{"data-slot":`commit-source`,"data-source":`unknown`,className:n,children:`no task found`})}function Xt({info:e,tracking:t}){let n=ft(m(),e),r=(0,Y.useRef)(null);return(0,X.jsxs)(`div`,{"data-slot":`git-incoming`,className:`flex min-h-[44px] items-center gap-2.5 rounded-xl border border-border bg-card px-4 py-2`,children:[(0,X.jsx)(jt,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-inbox-count-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 text-[12.5px] text-muted-foreground`,children:[t.behind,` commit`,t.behind===1?``:`s`,` on `,t.ref,` `,t.behind===1?`is`:`are`,` not in your checkout yet`]}),(0,X.jsxs)(`button`,{ref:r,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[28px] shrink-0 items-center gap-[4px] rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 [&>svg]:size-[12px]`,children:[n.pulling?(0,X.jsx)(Oe,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,X.jsx)(ge,{"aria-hidden":`true`}),`Pull`]}),(0,X.jsx)(it,{checkout:n,returnFocus:r})]})}function Zt({sha:e}){return(0,X.jsx)(Dt,{commit:c(e),sha:e,slot:`repo-commit-preview`,loadFileText:t=>Et(()=>x(e,t))})}function Qt({sha:e}){return(0,X.jsx)(kt,{commit:c(e),sha:e,backTo:ot,backLabel:`All recent commits`,slot:`repo-commit`,loadFileText:t=>Et(()=>x(e,t))})}var $t=`Squash-merged branches may show as not landed without GitHub`;function en(e){let t=[],n=[],r=[];for(let i of e)if(i.class===`orphan`)r.push(i);else if(i.class!==`not-landed`)continue;else i.pr&&(i.pr.state===`open`||i.pr.state===`draft`)?n.push(i):t.push(i);return[{key:`no-pr`,title:`No pull request`,note:`nobody sees this work until you act`,rows:t},{key:`pr-open`,title:`Pull request open`,rows:n},{key:`deleted`,title:`Task deleted`,note:`this branch is the only copy of the work`,rows:r}].filter(e=>e.rows.length>0)}function tn(e){return e.filter(e=>e.class===`active`&&e.runId!==null&&e.ahead>0&&(e.runStatus===`done`||e.runStatus===`failed`||e.runStatus===`cancelled`)).length}function nn(){let e=i(),t=l(),n=m(),r=a(),[o,s]=(0,Y.useState)(null);if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`not-landed-loading`,role:`status`,className:`py-5 text-[13px] text-muted-foreground`,children:`Loading branches…`});if(e.isError)return(0,X.jsx)(R,{icon:(0,X.jsx)(M,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let c=en(e.data.branches),u=c.reduce((e,t)=>e+t.rows.length,0),d=tn(e.data.branches),f=d>0?(0,X.jsxs)(`p`,{"data-slot":`not-landed-retained`,className:`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,children:[(0,X.jsx)(De,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,X.jsxs)(`span`,{children:[d,` finished task`,d===1?` still has its`:`s still have their`,` worktree and commits not on the base, so `,d===1?`it is`:`they are`,` not listed here.`,` `,`They show here once the worktree is reclaimed in `,(0,X.jsx)(F,{to:K.cleanup,className:`underline underline-offset-2 hover:text-foreground`,children:`Cleanup`}),`.`]})]}):null,p=new Map((t.data??[]).map(e=>[e.id,e.finishedAt]));return(0,X.jsxs)(D,{projectId:n,repoBase:r,requests:c.flatMap(e=>e.rows).flatMap(e=>e.pr?[{projectId:n,kind:`PR`,number:e.pr.number}]:[]),children:[(0,X.jsxs)(`div`,{"data-slot":`repo-not-landed`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[e.data.prStateKnown?null:(0,X.jsx)(rn,{}),f,c.length===0?(0,X.jsx)(Ye,{icon:(0,X.jsx)(vt,{size:16}),title:d>0?`Nothing else waiting to land`:`Everything landed`,description:d>0?`Every other finished task's commits are on the base branch, or it made none.`:`Every finished task's commits are on the base branch, or it made none.`,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{variant:`outline`,size:`sm`,asChild:!0,children:(0,X.jsx)(F,{to:K.cleanup,children:`Check cleanup`})}),(0,X.jsx)(N,{variant:`outline`,size:`sm`,asChild:!0,children:(0,X.jsx)(F,{to:`/`,children:`View tasks`})})]})}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(`div`,{className:`flex flex-col gap-5`,children:c.map(e=>(0,X.jsxs)(`section`,{"data-slot":`not-landed-group`,"data-group":e.key,"aria-label":e.title,className:`flex flex-col gap-1.5`,children:[(0,X.jsxs)(`h2`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.title}),(0,X.jsx)(`span`,{className:`tabular-nums`,children:e.rows.length}),e.note?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{children:e.note})]}):null]}),(0,X.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.rows.map(e=>(0,X.jsx)(an,{entry:e,finishedAt:e.runId?p.get(e.runId):void 0,onDelete:()=>s(e)},e.name))})]},e.key))}),(0,X.jsxs)(`p`,{"data-slot":`not-landed-note`,className:`flex items-start gap-1.5 px-1 text-xs leading-snug text-muted-foreground`,children:[(0,X.jsx)(De,{"aria-hidden":`true`,className:`mt-px size-3 shrink-0`}),`Delete a branch from its row's … menu. It confirms and names the commits it drops; nothing here is bulk-deleted.`]}),u<=3?(0,X.jsx)(Je,{summary:`${u} ${u===1?`branch`:`branches`} waiting to land. Open a draft PR or inspect worktrees in Cleanup.`,actions:(0,X.jsx)(N,{variant:`outline`,size:`sm`,asChild:!0,children:(0,X.jsx)(F,{to:K.cleanup,children:`Open cleanup`})})}):null]})]}),(0,X.jsx)(un,{entry:o,onClose:()=>s(null)})]})}function rn({className:e}){return(0,X.jsxs)(`p`,{"data-slot":`git-no-forge`,className:O(`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,e),children:[(0,X.jsx)(De,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),$t,`.`]})}function an({entry:e,finishedAt:t,onDelete:n}){return(0,X.jsxs)(`li`,{"data-slot":`not-landed-row`,"data-branch":e.name,"data-branch-class":e.class,className:`flex min-h-[60px] items-center gap-3 px-4 py-3 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,children:[(0,X.jsx)(cn,{entry:e,finishedAt:t}),(0,X.jsx)(on,{entry:e}),(0,X.jsx)(sn,{entry:e,onDelete:n})]})}function on({entry:e}){return(0,X.jsx)(X.Fragment,{children:e.pr?(0,X.jsxs)(`span`,{"data-slot":`not-landed-pr`,className:`hidden shrink-0 items-center gap-1.5 text-xs text-muted-foreground md:flex`,children:[(0,X.jsx)(re,{plain:!0,reference:{kind:`PR`,number:e.pr.number,url:e.pr.url},taskTitle:e.title??e.name,status:e.pr.state===`draft`?`draft`:e.pr.state===`closed`?`closed`:void 0}),(0,X.jsx)(ln,{entry:e})]}):null})}function sn({entry:e,onDelete:t}){let n=v(),r=e.class===`orphan`,i=e.pr&&(e.pr.state===`open`||e.pr.state===`draft`)?e.pr:null,a=!r&&e.runId!==null&&!i,o=u({mutationFn:()=>ee(e.runId),onSuccess:e=>{y(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:d.repoBranches}),n.invalidateQueries({queryKey:d.runs.all})},onError:e=>y(e instanceof g&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),[s,c]=(0,Y.useState)(!1),l=(0,Y.useRef)(null);(0,Y.useEffect)(()=>()=>{l.current!==null&&clearTimeout(l.current)},[]);let f=()=>void navigator.clipboard.writeText(e.name).then(()=>{y(`Copied ${e.name}`),l.current!==null&&clearTimeout(l.current),c(!0),l.current=setTimeout(()=>c(!1),2e3)},()=>y(`Could not copy the branch name`,{tone:`danger`})),p=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-sm px-2.5 text-[12.5px] font-medium text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 [&>svg]:size-[12px]`;return(0,X.jsxs)(X.Fragment,{children:[e.runId?(0,X.jsx)(F,{to:`/tasks/${e.runId}`,"data-action":`not-landed-open`,className:O(p,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:`Open task`}):null,a?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-create-pr`,disabled:o.isPending,onClick:()=>o.mutate(),className:O(p,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[(0,X.jsx)(Mt,{"aria-hidden":`true`}),o.isPending?`Creating…`:`Draft PR`]}):null,r?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,"data-copied":s||void 0,"aria-live":`polite`,onClick:f,className:O(p,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[s?(0,X.jsx)(he,{"aria-hidden":`true`}):(0,X.jsx)(ye,{"aria-hidden":`true`}),s?`Copied`:`Copy branch`]}):null,(0,X.jsxs)(Ie,{children:[(0,X.jsx)(Pe,{"data-action":`not-landed-more`,"aria-label":`More actions for ${e.name}`,className:`flex size-8 shrink-0 items-center justify-center rounded-sm text-soft-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:size-11`,children:(0,X.jsx)(le,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,X.jsxs)(Fe,{align:`end`,className:`w-52`,children:[e.runId?(0,X.jsx)(P,{asChild:!0,className:`md:hidden`,children:(0,X.jsx)(F,{to:`/tasks/${e.runId}`,children:`Open task`})}):null,a?(0,X.jsx)(P,{className:`md:hidden`,disabled:o.isPending,onSelect:()=>o.mutate(),children:`Draft PR`}):null,(0,X.jsx)(P,{className:O(!r&&`md:hidden`),onSelect:f,children:`Copy branch`}),(0,X.jsx)(Ne,{className:`md:hidden`}),(0,X.jsx)(P,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function cn({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=t??e.lastCommit.at,a=Xe(i),o=e.runStatus?st(e.runStatus):void 0,s=n||!o?a:`${o.label}${a?` ${a}`:``}`,c=Number.isFinite(Date.parse(i))?new Date(i).toLocaleString():void 0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`flex size-[12px] shrink-0 items-center justify-center`,children:n?(0,X.jsx)(Ce,{"aria-label":`Task deleted`,className:`size-[12px] text-muted-foreground`}):(0,X.jsx)(We,{tone:o?.tone??`neutral`,shape:o?.shape??`filled`,"aria-label":o?.label})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[e.runId?(0,X.jsx)(F,{to:`/tasks/${e.runId}`,"data-slot":`not-landed-title`,className:`min-w-0 truncate rounded-[2px] text-[13px] font-medium text-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:r}):(0,X.jsx)(`span`,{"data-slot":`not-landed-title`,className:`min-w-0 truncate text-[13px] font-medium text-foreground`,title:r,children:r}),(0,X.jsxs)(`span`,{"data-slot":`not-landed-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),(0,X.jsx)(Q,{}),(0,X.jsxs)(`span`,{className:`shrink-0`,children:[e.ahead,` commit`,e.ahead===1?``:`s`]}),e.diffStat?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(wt,{adds:e.diffStat.additions,dels:e.diffStat.deletions})]}):null,s?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{className:`truncate`,title:c,children:s})]}):null]}),e.parentRunId?(0,X.jsx)(F,{to:`/tasks/${e.parentRunId}`,"data-slot":`not-landed-parent`,className:`w-fit rounded-[2px] text-xs text-muted-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:`Worker of its parent task`}):null,(0,X.jsx)(Lt,{entry:e})]})]})}function Q(){return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`})}function ln({entry:e}){let t=f(T(`PR`,e.pr?.number).status),n=e.pr?.state,r=n===`draft`||n===`closed`?n:t?t.label.toLowerCase():`open`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{"data-slot":`not-landed-pr-state`,children:r})]})}function un({entry:e,onClose:t}){let n=v(),[r,i]=(0,Y.useState)(``),a=(0,Y.useId)(),o=u({mutationFn:e=>b({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;y(e.deleted.length>0?`Deleted ${e.deleted[0]}${t?` and ${t} commit${t===1?``:`s`} with it`:``}`:e.refused[0]?.reason??`Nothing was deleted`),n.invalidateQueries({queryKey:d.repo}),s()},onError:e=>y(e.message,{tone:`danger`})}),s=()=>{i(``),t()},c=e!==null&&r.trim()===e.name,l=e&&`${e.ahead} commit${e.ahead===1?``:`s`}`;return(0,X.jsx)(z,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&s(),children:(0,X.jsxs)(W,{"data-slot":`delete-branch-dialog`,children:[(0,X.jsxs)(B,{children:[(0,X.jsxs)(G,{children:[`Delete `,e?.name,`?`]}),(0,X.jsx)(q,{asChild:!0,children:(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`p`,{children:e?.class===`orphan`?`Its task was deleted, so this branch is the only copy of the work.`:(0,X.jsxs)(X.Fragment,{children:[`This drops the work of `,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:e?.title??e?.name}),`. It is not on the base branch`,e?.pr?``:` and no pull request carries it`,`.`]})}),(0,X.jsxs)(`p`,{"data-slot":`delete-branch-dropped`,children:[l,` will be dropped`,e?.diffStat?` (+${e.diffStat.additions} −${e.diffStat.deletions})`:``,`, the latest “`,e?.lastCommit.subject,`”`,e?.lastCommit.sha?(0,X.jsxs)(X.Fragment,{children:[` (`,(0,X.jsx)(et,{sha:e.lastCommit.sha,variant:`inline`}),`)`]}):null,`.`]})]})})]}),(0,X.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),c&&e&&!o.isPending&&o.mutate(e.name)},className:`flex flex-col gap-[6px]`,children:[(0,X.jsxs)(`label`,{htmlFor:a,className:`text-[12.5px] text-muted-foreground`,children:[`Type `,(0,X.jsx)(`span`,{className:`font-mono text-foreground`,children:e?.name}),` to confirm`]}),(0,X.jsx)(U,{id:a,"data-slot":`delete-branch-confirm`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value),className:`h-11 font-mono`})]}),(0,X.jsxs)(H,{children:[(0,X.jsx)(J,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,X.jsx)(V,{"data-action":`delete-branch-confirm`,className:`h-11 bg-danger text-danger-foreground hover:brightness-[0.96]`,disabled:!c||o.isPending,onClick:t=>{t.preventDefault(),e&&o.mutate(e.name)},children:o.isPending?`Deleting…`:`Delete branch`})]})]})})}function dn({base:e}){let t=i(),n=v(),[r,a]=(0,Y.useState)({merged:!1,empty:!1}),[o,s]=(0,Y.useState)(!1),c=(t.data?.branches??[]).filter(e=>e.class===`merged`),l=(t.data?.branches??[]).filter(e=>e.class===`empty`),f=[...c,...l],p=u({mutationFn:e=>b({names:e}),onSuccess:e=>{let t=e.refused.length;y(`Deleted ${e.deleted.length} branch${e.deleted.length===1?``:`es`}${t?`; kept ${t} that ${t===1?`is`:`are`} no longer safe to delete`:``}`),n.invalidateQueries({queryKey:d.repo})},onError:e=>{n.invalidateQueries({queryKey:d.repo}),y(e.message,{tone:`danger`})}});if(t.isPending)return(0,X.jsx)(`p`,{"data-slot":`cleanup-branches-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading branches…`});if(t.isError)return(0,X.jsxs)(`p`,{"data-slot":`cleanup-branches-error`,className:`text-[13px] text-danger`,children:[`Branches did not load: `,t.error.message]});let m=f.length,h=`branch${m===1?``:`es`}`;return(0,X.jsxs)(`section`,{"data-slot":`cleanup-branches`,"aria-labelledby":`cleanup-branches-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`cleanup-branches-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Branches safe to delete · `,m]}),(0,X.jsxs)(`p`,{className:`text-xs leading-[17px] text-soft-foreground`,children:[`Their work is already on `,e,`, or they have none. Deleting loses nothing.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`cleanup-branches-delete`,disabled:m===0||p.isPending,onClick:()=>s(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(_e,{"aria-hidden":`true`,className:`size-[12px]`}),p.isPending?`Deleting…`:`Delete ${m} ${h}`]})]}),(0,X.jsx)(fn,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:$t.toLowerCase(),rows:c,open:r.merged,onToggle:()=>a(e=>({...e,merged:!e.merged}))}),(0,X.jsx)(fn,{kind:`empty`,title:`Empty`,hint:`no commits beyond the fork point`,rows:l,open:r.empty,onToggle:()=>a(e=>({...e,empty:!e.empty}))}),(0,X.jsx)(z,{open:o,onOpenChange:s,children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(B,{children:[(0,X.jsxs)(G,{children:[`Delete `,m,` `,h,`?`]}),(0,X.jsxs)(q,{children:[c.length,` merged into `,e,` and `,l.length,` empty. Their work is already on `,e,`, or they have none. Anything that stopped being safe since this list loaded is kept.`]})]}),(0,X.jsxs)(H,{children:[(0,X.jsx)(J,{children:`Keep them`}),(0,X.jsxs)(V,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{p.mutate(f.map(e=>e.name)),s(!1)},children:[`Delete `,m,` `,h]})]})]})})]})}function fn({kind:e,title:t,hint:n,rows:r,open:i,onToggle:a}){let o=`cleanup-branches-${e}`;return(0,X.jsxs)(`div`,{"data-slot":`cleanup-branch-group`,"data-group":e,className:`border-b border-border last:border-0`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":o,disabled:r.length===0,onClick:a,className:`flex min-h-[44px] w-full items-center gap-[12px] px-[14px] py-[4px] text-left hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:hover:bg-transparent`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`span`,{className:`truncate text-[12.5px] text-foreground`,children:[t,` · `,r.length]}),(0,X.jsx)(`span`,{className:`truncate text-xs text-soft-foreground`,children:n})]}),r.length>0?(0,X.jsx)(pe,{"aria-hidden":`true`,className:O(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,i&&`rotate-90`)}):null]}),i?(0,X.jsx)(`ul`,{id:o,"aria-label":t,className:`flex flex-col pb-[6px]`,children:r.map(e=>(0,X.jsxs)(`li`,{"data-slot":`cleanup-branch-row`,"data-branch":e.name,className:`flex min-h-[32px] items-center gap-[10px] px-[14px] pl-[26px] text-xs`,children:[(0,X.jsx)(lt,{value:e.name,className:`shrink-0 text-muted-foreground`}),e.runId?(0,X.jsx)(F,{to:`/tasks/${e.runId}`,className:`min-w-0 flex-1 truncate text-soft-foreground underline-offset-2 hover:text-foreground hover:underline`,children:e.title??`Open the task`}):(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-soft-foreground`,children:e.lastCommit.subject}),e.pr?(0,X.jsxs)(`span`,{className:`shrink-0 text-soft-foreground`,children:[`PR #`,e.pr.number]}):null,(0,X.jsx)(bt,{iso:e.lastCommit.at,className:`shrink-0 text-soft-foreground`})]},e.name))}):null]})}function $(e){return e.some(e=>e.sizeBytes===null)?null:e.reduce((e,t)=>e+(t.sizeBytes??0),0)}function pn(e){return e.kind===`dirty`?`${e.uncommittedFiles} uncommitted`:e.kind===`detached-head`?`detached HEAD`:e.kind===`submodules`?`has submodules`:`broken worktree`}function mn(e){if(e.kind===`dirty`){let t=`${e.uncommittedFiles} uncommitted file${e.uncommittedFiles===1?``:`s`}`;return e.detachedHead?`${t} and a detached HEAD on no branch`:t}return e.kind===`detached-head`?`a detached HEAD whose commit is on no branch`:e.kind===`submodules`?`initialized submodules that Git will not remove without force`:`an unregistered or broken Git worktree directory`}function hn(e){let t=e.some(e=>e.reclaimBlocker?.kind===`dirty`),n=e.some(e=>e.reclaimBlocker?.kind===`detached-head`||e.reclaimBlocker?.kind===`dirty`&&e.reclaimBlocker.detachedHead),r=e.some(e=>e.reclaimBlocker?.kind===`submodules`),i=e.some(e=>e.reclaimBlocker?.kind===`invalid`),a=[...t?[`uncommitted work`]:[],...n?[`a detached HEAD`]:[],...r?[`initialized submodules`]:[],...i?[`a broken checkout`]:[]];return a.length<=1?a[0]??`uncommitted work`:`${a.slice(0,-1).join(`, `)} or ${a.at(-1)}`}function gn(e,t,n){let r=Math.max(0,t-e);return e===0?r===0?`Nothing to reclaim — no finished worktrees exceed the keep limit`:n?`Nothing was reclaimed — the worktrees past the keep limit are in use or could not be removed`:`Nothing was reclaimed — the worktrees past the keep limit have uncommitted work or are in use`:`Reclaimed ${e} worktree${e===1?``:`s`} (branch kept)${r>0?` · ${r} kept: ${n?`in use or could not be removed`:`uncommitted work or in use`}`:``}`}function _n(e,t){return e===0?`Reclaim now`:t?`Reclaim ${E(t)} now`:`Reclaim ${e} now`}function vn(e,t,n){let r=t?E(t):String(e);return n?`Discard & reclaim all ${r}`:`Discard & reclaim ${r}`}function yn(e,t){if(!e)return t>0?`No clean worktrees past the keep limit — use Discard & reclaim for blocked worktrees`:`Nothing past the keep limit to reclaim`}function bn(e){return e===0?{prefix:`Retention is unlimited (`,suffix:`), so nothing is reclaimed on its own.`}:{prefix:`Retention keeps the newest ${e} finished checkout${e===1?``:`s`} (`,suffix:`) and reclaims the rest.`}}function xn({blocked:e,discardLabel:t,disabled:n,onDiscard:r}){let i=$(e),a=e.length===1?``:`s`,o=e.length===1?`it has`:`they have`;return(0,X.jsxs)(`div`,{"data-slot":`worktrees-blocked-banner`,className:`flex flex-col gap-[10px] border-b border-border bg-muted/40 px-[14px] py-[10px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`p`,{className:`min-w-0 flex-1 text-[12px] leading-[17px] text-foreground`,children:[e.length,` worktree`,a,` past the keep limit`,i?` (${E(i)})`:``,` `,`cannot be reclaimed automatically because `,o,` `,hn(e),`.`]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`worktrees-discard-reclaim`,disabled:n,onClick:r,className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] border border-danger/40 px-[10px] text-[12px] font-medium text-danger hover:bg-danger/10 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 md:self-center`,children:[(0,X.jsx)(dt,{"aria-hidden":`true`,className:`size-[12px]`}),t]})]})}function Sn({confirmClean:e,onCloseClean:t,cleanCount:n,cleanBytes:r,reclaimLabel:i,onConfirmClean:a,discardBatch:o,onCloseDiscardBatch:s,onConfirmDiscardBatch:c,discardRow:l,onCloseRow:u,onConfirmRow:d}){let f=o?$(o):null,p=o?o.filter(e=>e.reclaimBlocker!==null).length:0,m=o?o.some(e=>!e.reclaimBlocker):!1,h=o?vn(o.length,f,m):``;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(z,{open:e,onOpenChange:e=>{e||t()},children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(B,{children:[(0,X.jsx)(G,{children:`Reclaim old worktrees?`}),(0,X.jsxs)(q,{children:[n,` finished worktree`,n===1?``:`s`,` beyond the keep limit`,r?` (${E(r)})`:``,` `,n===1?`is`:`are`,` reclaimed now, directory only. Their branches are kept, so the work stays recoverable.`]})]}),(0,X.jsxs)(H,{children:[(0,X.jsx)(J,{children:`Keep them`}),(0,X.jsx)(V,{"data-action":`worktrees-confirm`,onClick:a,children:i})]})]})}),(0,X.jsx)(z,{open:o!==null,onOpenChange:e=>{e||s()},children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(B,{children:[(0,X.jsx)(G,{children:`Discard changes and reclaim worktrees?`}),(0,X.jsx)(q,{children:o?(0,X.jsxs)(X.Fragment,{children:[o.length,` finished worktree`,o.length===1?``:`s`,` beyond the keep limit`,f?` (${E(f)})`:``,` will be reclaimed now.`,` `,`Uncommitted files and detached-HEAD commits in `,p,` blocked checkout`,p===1?``:`s`,` will be permanently discarded. Each task’s branch is kept.`]}):null})]}),(0,X.jsxs)(H,{children:[(0,X.jsx)(J,{children:`Keep them`}),(0,X.jsx)(V,{"data-action":`worktrees-discard-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{o&&c(o),s()},children:h})]})]})}),(0,X.jsx)(z,{open:l!==null,onOpenChange:e=>{e||u()},children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(B,{children:[(0,X.jsx)(G,{children:`Discard changes and reclaim worktree?`}),(0,X.jsx)(q,{children:l?.reclaimBlocker?(0,X.jsxs)(X.Fragment,{children:[l.title,` has `,mn(l.reclaimBlocker),`. Reclaiming removes the directory and permanently discards uncommitted or unbranched changes in it. The branch (`,l.branch??l.runId.slice(0,8),`) is kept.`]}):null})]}),(0,X.jsxs)(H,{children:[(0,X.jsx)(J,{children:`Keep it`}),(0,X.jsx)(V,{"data-action":`worktree-discard-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{l&&d(l),u()},children:`Discard & reclaim`})]})]})})]})}function Cn(){let e=r(),t=o().data?.targets.find(e=>e.id===`finder`),n=u({mutationFn:e=>ne(e,t.id),onError:e=>y(e.message,{tone:`danger`})}),i=v(),[a,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(null),m=()=>Promise.all([i.invalidateQueries({queryKey:d.worktrees}),i.invalidateQueries({queryKey:d.repoBranches})]),g=u({mutationFn:({runIds:e})=>h(e?{discardWork:!0,runIds:e}:void 0),onSuccess:(e,{expected:t,runIds:n})=>{m(),y(gn(e.reclaimed.length,t,!!n))},onError:e=>y(e.message,{tone:`danger`})}),_=u({mutationFn:({worktree:e,discardWork:t})=>te(e.runId,t?{discardWork:!0}:void 0),onSuccess:(e,{worktree:t})=>{m(),y(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{m(),y(e.message,{tone:`danger`})}});if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading worktrees…`});if(e.isError)return(0,X.jsxs)(`p`,{"data-slot":`worktrees-error`,className:`text-[13px] text-danger`,children:[`Worktrees did not load: `,e.error.message]});let{worktrees:b,totalBytes:ee,keep:x}=e.data,S=g.isPending||_.isPending,C=b.filter(e=>e.pastKeep),w=C.filter(e=>!e.reclaimBlocker),T=C.filter(e=>e.reclaimBlocker!==null),D=w.length>0,re=$(w),O=$(C),k=_n(w.length,re),ie=vn(C.length,O,D),A=ee?E(ee):null,j=bn(x);return(0,X.jsxs)(`section`,{"data-slot":`worktrees-panel`,"aria-labelledby":`worktrees-panel-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`worktrees-panel-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Worktrees on disk`,A?` · ${A}`:``]}),(0,X.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-xs leading-[17px] text-soft-foreground`,children:[j.prefix,(0,X.jsx)(F,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:Qe(`worktrees`,` › `)}),j.suffix,` `,`Reclaim removes the directory only; the branch stays, so its work stays recoverable.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`worktrees-reclaim-now`,disabled:S||!D,title:yn(D,T.length),onClick:()=>s(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(dt,{"aria-hidden":`true`,className:`size-[12px]`}),k]})]}),T.length>0?(0,X.jsx)(xn,{blocked:T,discardLabel:ie,disabled:S,onDiscard:()=>l(C)}):null,b.length===0?(0,X.jsx)(`p`,{"data-slot":`worktrees-empty`,className:`px-[14px] py-[12px] text-[12.5px] text-soft-foreground`,children:`No task worktrees on disk.`}):(0,X.jsx)(`ul`,{"aria-label":`Task worktrees on disk`,className:`flex flex-col`,children:b.map(e=>(0,X.jsx)(En,{worktree:e,keep:x,disabled:S,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>{e.reclaimBlocker?p(e):_.mutate({worktree:e,discardWork:!1})}},e.runId))}),(0,X.jsx)(Sn,{confirmClean:a,onCloseClean:()=>s(!1),cleanCount:w.length,cleanBytes:re,reclaimLabel:k,onConfirmClean:()=>{g.mutate({expected:w.length}),s(!1)},discardBatch:c,onCloseDiscardBatch:()=>l(null),onConfirmDiscardBatch:e=>{g.mutate({expected:e.length,runIds:e.map(e=>e.runId)})},discardRow:f,onCloseRow:()=>p(null),onConfirmRow:e=>_.mutate({worktree:e,discardWork:!0})})]})}var wn=new Set([`queued`,`running`,`waiting`,`review`]);function Tn(e,t){return wn.has(e.status)||!e.reclaimable?{label:`in use`,tone:`in-use`,state:`in-use`}:e.reclaimBlocker?{label:pn(e.reclaimBlocker),tone:`blocked`,state:`blocked`}:e.pastKeep?{label:`reclaimable`,tone:`plain`,state:`reclaimable`}:{label:t>0?`kept · newest ${t}`:`kept`,tone:`plain`,state:`kept`}}function En({worktree:e,keep:t,disabled:n,onOpen:r,opening:i,onReclaim:a}){let o=Tn(e,t),s=Xe(e.finishedAt??void 0),c=e.status===`review`?`at review`:s?`${e.status} ${Ze(s)}`:e.status,l=o.tone===`in-use`?`text-status-running`:o.tone===`blocked`?`text-danger`:`text-soft-foreground`,u=e.reclaimBlocker?`Cannot auto-reclaim: ${mn(e.reclaimBlocker)}`:void 0,d=(0,X.jsx)(`span`,{"data-slot":`worktree-state`,"data-state":o.state,title:u,className:O(`text-xs`,l),children:o.label}),f=`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:size-11`,p=e.reclaimBlocker?`Discard changes and reclaim the worktree of ${e.title} (branch kept)`:`Reclaim the worktree of ${e.title} (branch kept)`,m=e.reclaimBlocker?`Discard changes and reclaim the directory (branch kept)`:`Reclaim the directory (branch kept)`;return(0,X.jsxs)(`li`,{"data-slot":`worktree-row`,"data-run":e.runId,className:`flex min-h-[44px] items-center gap-[12px] border-b border-border px-[14px] py-[4px] last:border-0`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsx)(`span`,{className:`truncate text-[12.5px] text-foreground`,title:e.title,children:e.title}),(0,X.jsxs)(`span`,{className:`truncate font-mono text-xs text-soft-foreground`,children:[e.branch??e.runId.slice(0,8),` · `,c,(0,X.jsxs)(`span`,{className:`md:hidden`,children:[` · `,o.label]})]})]}),(0,X.jsx)(`span`,{"data-slot":`worktree-size`,className:`shrink-0 text-xs tabular-nums text-muted-foreground`,children:e.sizeBytes===null?`—`:E(e.sizeBytes)||`0 kB`}),(0,X.jsx)(`span`,{className:`hidden shrink-0 md:inline`,children:d}),r?(0,X.jsx)(`button`,{type:`button`,className:f,"aria-label":`Open folder for ${e.title}`,title:`Open folder`,disabled:i,onClick:r,children:(0,X.jsx)(ie,{"aria-hidden":`true`,className:`size-[13px]`})}):null,o.tone===`in-use`?null:(0,X.jsx)(`button`,{type:`button`,"data-action":`worktree-reclaim`,"aria-label":p,title:m,disabled:n,onClick:a,className:O(f,e.reclaimBlocker&&`text-danger hover:text-danger`),children:(0,X.jsx)(dt,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function Dn(e){return e===`main`||e===`changes`?`Split`:`Table`}function On({section:e,index:t=!1}){let n=s(),r=I(),[i]=C(),a=Dn(e);if(t&&!r&&i.get(`view`)!==`repo`)return(0,X.jsx)(Nt,{});if(n.isPending)return(0,X.jsx)(yt,{});if(n.isError)return(0,X.jsx)(L,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,X.jsx)($e,{}),children:(0,X.jsx)(R,{icon:(0,X.jsx)(M,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:n.error.message})});let o=n.data.info;return o?(0,X.jsx)(kn,{repo:n.data,info:o,section:e}):(0,X.jsx)(L,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,X.jsx)($e,{}),children:(0,X.jsx)(R,{icon:(0,X.jsx)(me,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`Squawk is running outside a git repository — start it inside one to browse changes, commits and branches.`})})}function kn({repo:e,info:t,section:n}){let r=Dn(n),a=i(),o=An(n),s=n===`main`?e.log.length:n===`changes`?e.status.length:n===`branches`?Gt(e,a.data?.branches).length:n===`not-landed`?a.data?.branches.filter(e=>e.class===`not-landed`||e.class===`orphan`).length??0:4;return(0,X.jsx)(L,{template:r,route:`repo-git`,density:n===`not-landed`&&a.isPending?`full`:qe(s),rootProps:{"data-git-section":n},beforeHeader:(0,X.jsx)($e,{}),header:{title:o?.title??tt(n,t.branch),headerSlot:`repo-header`,subtitle:o?(0,X.jsxs)(X.Fragment,{children:[`Commit `,o.shortSha,` on `,t.branch]}):(0,X.jsx)(jn,{repo:e,info:t,section:n}),subtitleSlot:`repo-meta`,...n===`branches`?{primaryAction:(0,X.jsx)(Ft,{from:t.branch})}:{}},children:n===`main`?(0,X.jsx)(qt,{repo:e,info:t}):n===`not-landed`?(0,X.jsx)(nn,{}):n===`cleanup`?(0,X.jsxs)(`div`,{"data-slot":`repo-cleanup`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[(0,X.jsx)(Cn,{}),(0,X.jsx)(dn,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,X.jsx)(Rt,{repo:e,info:t}):(0,X.jsx)(Kt,{})})}function An(e){let{sha:t}=w(),n=I(),r=e===`main`&&!n?t:void 0,i=c(r);if(!r)return;let a=r.slice(0,8);return{title:i.data?.subject??`Commit ${a}`,shortSha:a}}function jn({repo:e,info:t,section:n}){let r=e.baseBranch??t.branch;switch(n){case`main`:return(0,X.jsxs)(X.Fragment,{children:[e.log.length===0?`No commits yet`:`Latest ${e.log.length} commit${e.log.length===1?``:`s`} in the main checkout`,e.tracking?` · ${gt(e.tracking)}`:``]});case`not-landed`:return(0,X.jsxs)(X.Fragment,{children:[`Finished tasks whose commits are not on `,r]});case`branches`:return(0,X.jsx)(Mn,{repo:e,info:t});case`changes`:return(0,X.jsxs)(X.Fragment,{children:[e.status.length,` uncommitted file`,e.status.length===1?``:`s`,` in the main checkout`]});case`cleanup`:return(0,X.jsxs)(X.Fragment,{children:[`Nothing here can delete work that is not on `,r]})}}function Mn({repo:e,info:t}){let n=Gt(e,i().data?.branches).length;return(0,X.jsxs)(X.Fragment,{children:[n,` branch`,n===1?``:`es`,` · on `,t.branch]})}export{On as RepoGitRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{A as r,C as i,H as a,Lt as o,S as s,T as c,Xt as l,_r as u,in as d,ut as f,w as p}from"./queries-ChH9ctc-.js";import{g as m}from"./host-context-KsSKxKbI.js";import{B as h,Cn as g,Qi as _,T as v,a as y,f as b,ut as ee,w as x,z as te,zt as ne}from"./project-scope-context-hfRzPMZ4.js";import{Z as S}from"./live-protocol-CNUmr-VT.js";import{_ as C,g as w}from"./chunk-KS7C4IRE-BdLLx37K.js";import{c as T,f as E,i as D,t as re}from"./reference-chip-BPRZm7Kb.js";import{o as O,s as k}from"./dist-CCX8mhHc.js";import{D as ie,F as A,I as j,M as ae,N as oe,P as se,Q as ce,S as le,X as ue,Z as de,c as fe,ct as M,d as pe,j as me,l as he,n as ge,st as _e,w as ve,y as ye}from"./design-icons-QbNMZniQ.js";import{t as be}from"./createLucideIcon-BHp8sXmF.js";import{n as xe,t as Se}from"./circle-x-7nTlobAF.js";import{_ as Ce}from"./nav-row-styles-CIedRn3A.js";import{i as we,r as Te,t as Ee}from"./git-toolbar-BBon1yHh.js";import{t as De}from"./info-DA1x_4bz.js";import{t as Oe}from"./loader-circle-CPBhhDbB.js";import{a as ke,i as Ae,n as je,r as Me}from"./diff-controls-DeMSGYln.js";import{t as N}from"./button-BV_AiLj2.js";import{i as P,l as Ne,p as Pe,r as Fe,t as Ie}from"./dropdown-menu-NJZfnQCU.js";import{a as Le,i as Re,n as ze,o as Be,r as Ve,s as He,t as Ue}from"./dialog-DKr-j9S6.js";import{t as F}from"./project-router-yoWCTDaT.js";import{t as We}from"./status-dot-Fp5SnPHI.js";import{c as Ge,d as Ke,f as qe,m as I,n as Je,s as L,t as Ye}from"./page-shell-BdjH5hyc.js";import{a as Xe,o as Ze}from"./format-BU7D3IfE.js";import{t as Qe}from"./control-locations-kCPVEtOM.js";import{t as R}from"./centered-state-N8vWM_Hw.js";import{$t as z,A as $e,Bn as et,Bt as tt,Cr as nt,Gt as rt,Ht as it,Jt as at,Kt as ot,Pn as st,Qt as ct,Rn as lt,Rt as ut,Tr as dt,Ut as ft,Vt as pt,Wt as mt,Xt as ht,Yt as gt,Zt as _t,an as B,en as V,gr as vt,in as H,k as yt,lr as U,nn as W,on as G,qt as K,rn as q,tn as J,zn as bt,zt as xt}from"./index-BuR9xHfb.js";import{t as St}from"./markdown-BBDDg-4t.js";import{t as Ct}from"./diff-BidPzsVK.js";import{t as wt}from"./change-counts-BLLRvt46.js";import{t as Tt}from"./code-workbench-B0GIezrD.js";import{t as Et}from"./file-text-nGpo7MVd.js";import{i as Dt,n as Ot,r as kt}from"./commit-list-DSw7qvVY.js";var Y=e(t(),1);function At(e,t){let n=_(t),r=n.getQueryCache();return Y.useSyncExternalStore(Y.useCallback(e=>r.subscribe(S.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var jt=be(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),Mt=be(`git-pull-request-create`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v3`,key:`1jb6z3`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]),X=n();function Nt(){let e=m(),t=s(),n=_(),r=At({queryKey:d.repo})>0,i=t.data?.info?t.data:null,a=ut(e,i,`screen`);return(0,X.jsx)(Ke,{route:`repo-git`,density:i?.info?`full`:`empty`,headerSpacing:`compact`,header:{title:`Git`,secondaryActions:(0,X.jsx)(Ge,{type:`button`,variant:`ghost`,"data-slot":`git-screen-refresh`,"aria-label":`Refresh the repository`,title:`Refresh the repository`,disabled:r,onClick:()=>{n.invalidateQueries({queryKey:d.repo}),n.invalidateQueries({queryKey:d.worktrees})},children:(0,X.jsx)(de,{size:17,"aria-hidden":`true`,className:O(`size-[17px]`,r&&`motion-safe:animate-spin`)})})},children:(0,X.jsxs)(`div`,{"data-slot":`git-screen`,children:[i?.info?(0,X.jsx)(`div`,{className:`mb-[16px]`,children:(0,X.jsx)(pt,{scope:e,repo:i,info:i.info,variant:`screen`},e)}):t.isPending?(0,X.jsx)(`p`,{"data-slot":`git-screen-loading`,role:`status`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Loading the checkout…`}):t.isError?(0,X.jsxs)(`p`,{"data-slot":`git-screen-error`,role:`alert`,className:`mb-[16px] px-[10px] text-[13px] text-danger`,children:[`Could not load the repository: `,t.error.message]}):(0,X.jsx)(`p`,{"data-slot":`git-screen-not-git`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Not a git repository.`}),t.isPending?null:(0,X.jsx)(xt,{branch:i?.info?.branch??null,counts:a,variant:`screen`})]})})}function Pt(e){if(e===``)return null;if(e===`@`)return`A branch cannot be named “@”.`;if(e.startsWith(`-`))return`A branch name cannot start with “-”.`;if(/\s/.test(e))return`A branch name cannot contain spaces.`;if(/[\u0000-\u001f\u007f]/.test(e))return`A branch name cannot contain control characters.`;let t=/[~^:?*[\\]/.exec(e);if(t)return`A branch name cannot contain “${t[0]}”.`;if(e.includes(`..`))return`A branch name cannot contain “..”.`;if(e.includes(`@{`))return`A branch name cannot contain “@{”.`;if(e.startsWith(`/`)||e.endsWith(`/`))return`A branch name cannot start or end with “/”.`;if(e.includes(`//`))return`A branch name cannot contain “//”.`;if(e.endsWith(`.`))return`A branch name cannot end with “.”.`;for(let t of e.split(`/`)){if(t.startsWith(`.`))return`A part of a branch name cannot start with “.”.`;if(t.endsWith(`.lock`))return`A part of a branch name cannot end with “.lock”.`}return null}function Ft({from:e}){let[t,n]=(0,Y.useState)(!1),r=(0,Y.useRef)(null);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Ge,{ref:r,variant:`primary`,"data-action":`new-branch`,disabled:rt(m())&&!t,onClick:()=>n(!0),children:[(0,X.jsx)(ue,{size:16,"aria-hidden":`true`}),`New branch`]}),t?(0,X.jsx)(It,{from:e,returnFocus:r,onClose:()=>n(!1)}):null]})}function It({from:e,returnFocus:t,onClose:n}){let r=mt(m()),i=rt(m()),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(null),l=a.trim(),u=Pt(l),d=u??s;return(0,X.jsx)(Ue,{open:!0,onOpenChange:e=>{!e&&!r.isPending&&n()},children:(0,X.jsx)(Ve,{"data-slot":`new-branch-dialog`,className:`sm:max-w-md`,onCloseAutoFocus:e=>{e.preventDefault(),t.current?.focus()},children:(0,X.jsxs)(`form`,{className:`grid min-w-0 gap-4`,onSubmit:e=>{e.preventDefault(),!(!l||u||i)&&(c(null),r.mutate(l,{onSuccess:n,onError:e=>c(e.message)}))},children:[(0,X.jsxs)(Be,{children:[(0,X.jsx)(He,{children:`New branch`}),(0,X.jsxs)(Re,{"data-slot":`new-branch-base`,children:[`Create from `,(0,X.jsx)(`span`,{className:`font-mono text-foreground`,children:e}),` and switch to it. Switching changes your working tree.`]})]}),(0,X.jsxs)(ze,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,X.jsx)(U,{id:`new-branch-name`,autoComplete:`off`,spellCheck:!1,placeholder:`new-branch-name`,className:`h-11 bg-background font-mono md:text-base placeholder:text-soft-foreground`,value:a,"aria-invalid":d?!0:void 0,"aria-describedby":d?`new-branch-name-hint`:void 0,onChange:e=>{o(e.target.value),c(null)}}),d?(0,X.jsx)(`p`,{id:`new-branch-name-hint`,"data-slot":u?`branch-name-hint`:`branch-create-refusal`,role:`alert`,className:`text-xs text-danger`,children:d}):null]}),(0,X.jsxs)(Le,{children:[(0,X.jsx)(N,{type:`button`,variant:`outline`,disabled:r.isPending,onClick:n,children:`Cancel`}),(0,X.jsx)(N,{type:`submit`,variant:`primary`,"data-action":`create-branch`,disabled:!l||u!==null||i,children:r.isPending?`Creating…`:`Create`})]})]})})})}function Lt({entry:e}){return e.keptReason?(0,X.jsx)(`span`,{"data-slot":`branch-kept-reason`,className:`min-w-0 text-xs text-muted-foreground`,children:e.keptReason}):null}function Rt({repo:e,info:t}){let n=i(),r=new Map((n.data?.branches??[]).map(e=>[e.name,e])),a=n.data?.base??e.baseBranch??t.branch,o=mt(m(),e=>y(e.message,{tone:`danger`})),s=rt(m()),[c,l]=(0,Y.useState)(``),u=c.trim().toLowerCase(),d=Gt(e,n.data?.branches),f=u?d.filter(e=>e.toLowerCase().includes(u)):d;return(0,X.jsx)(`section`,{"data-slot":`repo-branches`,className:`min-w-0`,children:(0,X.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,X.jsx)(`h2`,{className:`sr-only`,children:`Branches`}),(0,X.jsxs)(`label`,{className:`relative block`,children:[(0,X.jsx)(ce,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3 size-4 text-muted-foreground`}),(0,X.jsx)(U,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:c,onChange:e=>l(e.target.value),className:`h-10 rounded-lg border-border bg-card pl-10`})]}),(0,X.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-3.5 flex min-w-0 flex-col divide-y divide-border border-t border-border md:max-h-[40rem] md:overflow-y-auto md:overscroll-contain`,children:[f.map(e=>{let n=e===t.branch,i=r.get(e);return(0,X.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,"data-branch-class":i?.class,className:`flex min-h-[60px] flex-col items-start justify-center gap-1.5 py-2 md:flex-row md:items-center md:justify-start md:gap-2.5`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 max-w-full items-center gap-[8px]`,children:[i?.runId?(0,X.jsx)(F,{to:`/tasks/${i.runId}`,"data-slot":`branch-task-link`,title:i.title?`Open the task ${i.title}`:`Open the task`,className:`min-w-0 truncate rounded-[2px] font-mono text-[12px] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:e}):(0,X.jsx)(`span`,{className:O(`min-w-0 truncate font-mono text-[12px]`,n&&`font-medium`),children:e}),i&&!(n&&i.class===`active`)?(0,X.jsx)(Wt,{entry:i}):null]}),i?(0,X.jsx)(zt,{entry:i,base:a}):null,i?(0,X.jsx)(Lt,{entry:i}):null,e.startsWith(`cez/`)&&!n?null:n?(0,X.jsx)(`span`,{"data-slot":`branch-current`,className:`flex h-8 shrink-0 items-center rounded-md bg-accent-strong/10 px-2.5 text-[12px] font-medium text-accent-text md:ml-auto`,children:`Current`}):(0,X.jsxs)(N,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`md:ml-auto`,disabled:s,onClick:()=>o.mutate(e),children:[(0,X.jsx)(me,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),f.length===0?(0,X.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-muted-foreground`,children:[`No branches match “`,c.trim(),`”.`]}):null]})]})})}function zt({entry:e,base:t}){let n=e.pr?.state===`open`||e.pr?.state===`draft`;return(0,X.jsxs)(`span`,{"data-slot":`branch-facts`,className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:[(0,X.jsxs)(`span`,{"data-slot":`branch-counts`,title:`${Z(e.ahead)} ahead of ${t}, ${Z(e.behind)} behind`,className:`shrink-0 font-mono tabular-nums`,children:[(0,X.jsxs)(`span`,{"aria-hidden":`true`,children:[`↑`,e.ahead,` ↓`,e.behind]}),(0,X.jsxs)(`span`,{className:`sr-only`,children:[Z(e.ahead),` ahead of `,t,`, `,Z(e.behind),` behind`]})]}),e.pr?(0,X.jsx)(Vt,{pr:e.pr}):null,n&&e.pr?.checks?(0,X.jsx)(Ht,{checks:e.pr.checks}):null]})}var Z=e=>`${e} commit${e===1?``:`s`}`,Bt={open:{icon:j,className:`border-success/40 text-semantic-green`},draft:{icon:A,className:`border-border text-muted-foreground`},merged:{icon:oe,className:`border-merged-strong/35 text-merged-text`},closed:{icon:se,className:`border-danger/40 text-semantic-red`}};function Vt({pr:e}){let{icon:t,className:n}=Bt[e.state],r=(0,X.jsxs)(`span`,{className:O(`inline-flex h-6 items-center gap-1 rounded-[4px] border px-1.5 text-xs font-medium group-hover:bg-muted`,n),children:[(0,X.jsx)(t,{size:12,"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,X.jsxs)(`span`,{className:`font-mono`,children:[`#`,e.number]}),(0,X.jsx)(`span`,{children:e.state})]}),i=`inline-flex shrink-0 items-center rounded-[4px] max-md:min-h-11 no-hover:min-h-11`;return k(e.url)?(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`branch-pr`,"data-pr-state":e.state,title:`Open pull request #${e.number}`,className:O(i,`group focus-visible:outline-2 focus-visible:outline-ring`),children:r}):(0,X.jsx)(`span`,{"data-slot":`branch-pr`,"data-pr-state":e.state,className:i,children:r})}function Ht({checks:e}){let t=e===`passing`?xe:e===`failing`?Se:nt;return(0,X.jsxs)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:O(`inline-flex shrink-0 items-center gap-1 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:[(0,X.jsx)(t,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),e]})}var Ut={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function Wt({entry:e}){return(0,X.jsx)(`span`,{"data-slot":`branch-class`,className:O(`shrink-0 rounded-[4px] border px-1.5 py-px text-xs leading-4 font-medium`,e.class===`active`?`border-status-running/40 text-status-running`:e.class===`not-landed`||e.class===`orphan`?`border-inbox-count-foreground/40 text-inbox-count-foreground`:`border-border text-soft-foreground`),children:Ut[e.class]})}function Gt(e,t){let n=new Set(e.branches);for(let e of t??[])n.add(e.name);return[...n].sort((e,t)=>e.localeCompare(t))}function Kt(){let e=p(),t=I(),[n,r]=(0,Y.useState)(`unified`),[i,a]=(0,Y.useState)(!0),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),u=(0,Y.useRef)(null),d=e.isError&&e.error instanceof g&&e.error.status===409,f=e.data?.files??[],m=(0,Y.useMemo)(()=>Te(f),[f]),h=(0,Y.useMemo)(()=>f.some(St),[f]),_=t?n:`unified`;return(0,X.jsx)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:e.isPending?(0,X.jsx)(`p`,{"data-slot":`changes-loading`,className:`py-6 text-center text-xs text-muted-foreground`,children:`Loading changes…`}):e.isError?(0,X.jsx)(R,{icon:d?(0,X.jsx)(ve,{size:16}):(0,X.jsx)(M,{size:16}),tone:d?`neutral`:`danger`,heading:`h2`,title:d?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):f.length===0?(0,X.jsx)(R,{icon:(0,X.jsx)(ve,{size:16}),tone:`neutral`,heading:`h2`,title:`Working tree clean`,subtitle:`No uncommitted changes in the main working tree. Edits show up here as they happen.`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-3 gap-y-2 pb-4 [&_button:not([data-button-size])]:min-h-11`,children:[e.data?(0,X.jsx)(Ee,{stat:e.data.stat}):null,(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[h&&o?(0,X.jsx)(Ae,{}):null,h?(0,X.jsx)(`span`,{className:`max-md:hidden`,children:(0,X.jsx)(ke,{preview:o,onPreviewChange:s})}):null,(0,X.jsx)(Me,{mode:n,wrap:i,onModeChange:r,onWrapChange:a,disabled:h&&o}),(0,X.jsx)(je,{wrap:i,onWrapChange:a,preview:o,onPreviewChange:h?s:void 0,disabled:h&&o})]})]}),(0,X.jsx)(Tt,{className:`gap-5 [--diff-sticky-top:0px] md:gap-0`,treeSlot:`changes-tree-pane`,treeClassName:`overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_2rem)]`,tree:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`h2`,{"data-slot":`changes-tree-heading`,className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,X.jsx)(we,{root:m,selected:c,onSelect:e=>{l(e),u.current?.scrollToPath(e)}})]}),children:(0,X.jsx)(Ct,{files:f,viewRef:u,mode:_,wrap:i,preview:o,loadFileText:e=>Et(()=>v(e)),totals:!1,className:`min-w-0 flex-1`})})]})})}function qt({repo:e,info:t}){let{sha:n}=w(),r=I(),i=e.log,a=(0,Y.useMemo)(()=>ct(i),[i]);if(n&&(!r||i.length===0))return(0,X.jsx)(Qt,{sha:n});let o=at(e,t),s=o&&o.behind>0?(0,X.jsx)(Xt,{info:t,tracking:o}):null;if(i.length===0)return(0,X.jsxs)(X.Fragment,{children:[s?(0,X.jsx)(`div`,{children:s}):null,(0,X.jsx)(R,{icon:(0,X.jsx)(ae,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`})]});let c=(0,X.jsxs)(`div`,{"data-slot":`repo-commits`,className:`flex flex-col gap-4`,children:[s,a.map(e=>(0,X.jsxs)(`section`,{"data-slot":`repo-commit-day`,"aria-label":e.label,className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground`,children:e.label}),(0,X.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.commits.map(e=>(0,X.jsx)(Jt,{commit:e,selected:r&&e.hash===(n??i[0]?.hash),stacked:r},e.hash))})]},e.label))]});return r?(0,X.jsx)(Tt,{className:`flex-none`,treeSlot:`repo-commits-pane`,tree:c,children:(0,X.jsx)(Zt,{sha:n??i[0]?.hash})}):c}function Jt({commit:e,selected:t,stacked:n}){return(0,X.jsxs)(`li`,{"data-selected":t?`true`:void 0,className:O(`flex min-h-[52px] gap-3.5 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,n?`flex-col items-stretch gap-0`:`items-center`,t&&`bg-muted/70`),children:[(0,X.jsxs)(F,{to:`/git/commits/${e.hash}`,"data-slot":`commit-row`,"data-sha":e.hash,"aria-current":t?`true`:void 0,className:`flex min-h-[52px] min-w-0 flex-1 flex-col justify-center gap-0.5 px-4 py-2 focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,X.jsx)(`span`,{"data-slot":`commit-row-subject`,className:`truncate text-[13px] font-medium text-foreground`,children:e.subject}),(0,X.jsxs)(`span`,{"data-slot":`commit-row-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(Ot,{sha:e.hash}),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`}),(0,X.jsxs)(`span`,{className:`truncate`,children:[e.author,` · `,(0,X.jsx)(`span`,{title:_t(e.when,e.at),children:ht(e.when,e.at)})]})]})]}),(0,X.jsx)(Yt,{source:e.source,stacked:n})]})}function Yt({source:e,stacked:t}){let n=O(`hidden shrink-0 items-center gap-[5px] text-xs text-muted-foreground md:flex`,t?`-mt-1.5 max-w-full self-start px-4 pb-2.5`:`max-w-[45%] pr-4`);return e?(0,X.jsxs)(F,{to:`/tasks/${e.runId}`,"data-slot":`commit-source`,"data-source":`task`,"aria-label":`From the task ${e.title}${e.prNumber===null?``:`, pull request #${e.prNumber}`}`,className:O(n,`rounded-[4px] hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`),children:[e.prNumber===null?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(oe,{"aria-hidden":`true`,className:`size-[11px] shrink-0 text-merged-text`}),(0,X.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`PR #`,e.prNumber]})]}),(0,X.jsx)(fe,{"aria-hidden":`true`,className:`size-[12px] shrink-0`}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]}):(0,X.jsx)(`span`,{"data-slot":`commit-source`,"data-source":`unknown`,className:n,children:`no task found`})}function Xt({info:e,tracking:t}){let n=ft(m(),e),r=(0,Y.useRef)(null);return(0,X.jsxs)(`div`,{"data-slot":`git-incoming`,className:`flex min-h-[44px] items-center gap-2.5 rounded-xl border border-border bg-card px-4 py-2`,children:[(0,X.jsx)(jt,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-inbox-count-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 text-[12.5px] text-muted-foreground`,children:[t.behind,` commit`,t.behind===1?``:`s`,` on `,t.ref,` `,t.behind===1?`is`:`are`,` not in your checkout yet`]}),(0,X.jsxs)(`button`,{ref:r,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[28px] shrink-0 items-center gap-[4px] rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 [&>svg]:size-[12px]`,children:[n.pulling?(0,X.jsx)(Oe,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,X.jsx)(ge,{"aria-hidden":`true`}),`Pull`]}),(0,X.jsx)(it,{checkout:n,returnFocus:r})]})}function Zt({sha:e}){return(0,X.jsx)(Dt,{commit:c(e),sha:e,slot:`repo-commit-preview`,loadFileText:t=>Et(()=>x(e,t))})}function Qt({sha:e}){return(0,X.jsx)(kt,{commit:c(e),sha:e,backTo:ot,backLabel:`All recent commits`,slot:`repo-commit`,loadFileText:t=>Et(()=>x(e,t))})}var $t=`Squash-merged branches may show as not landed without GitHub`;function en(e){let t=[],n=[],r=[];for(let i of e)if(i.class===`orphan`)r.push(i);else if(i.class!==`not-landed`)continue;else i.pr&&(i.pr.state===`open`||i.pr.state===`draft`)?n.push(i):t.push(i);return[{key:`no-pr`,title:`No pull request`,note:`nobody sees this work until you act`,rows:t},{key:`pr-open`,title:`Pull request open`,rows:n},{key:`deleted`,title:`Task deleted`,note:`this branch is the only copy of the work`,rows:r}].filter(e=>e.rows.length>0)}function tn(e){return e.filter(e=>e.class===`active`&&e.runId!==null&&e.ahead>0&&(e.runStatus===`done`||e.runStatus===`failed`||e.runStatus===`cancelled`)).length}function nn(){let e=i(),t=l(),n=m(),r=a(),[o,s]=(0,Y.useState)(null);if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`not-landed-loading`,role:`status`,className:`py-5 text-[13px] text-muted-foreground`,children:`Loading branches…`});if(e.isError)return(0,X.jsx)(R,{icon:(0,X.jsx)(M,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let c=en(e.data.branches),u=c.reduce((e,t)=>e+t.rows.length,0),d=tn(e.data.branches),f=d>0?(0,X.jsxs)(`p`,{"data-slot":`not-landed-retained`,className:`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,children:[(0,X.jsx)(De,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,X.jsxs)(`span`,{children:[d,` finished task`,d===1?` still has its`:`s still have their`,` worktree and commits not on the base, so `,d===1?`it is`:`they are`,` not listed here.`,` `,`They show here once the worktree is reclaimed in `,(0,X.jsx)(F,{to:K.cleanup,className:`underline underline-offset-2 hover:text-foreground`,children:`Cleanup`}),`.`]})]}):null,p=new Map((t.data??[]).map(e=>[e.id,e.finishedAt]));return(0,X.jsxs)(D,{projectId:n,repoBase:r,requests:c.flatMap(e=>e.rows).flatMap(e=>e.pr?[{projectId:n,kind:`PR`,number:e.pr.number}]:[]),children:[(0,X.jsxs)(`div`,{"data-slot":`repo-not-landed`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[e.data.prStateKnown?null:(0,X.jsx)(rn,{}),f,c.length===0?(0,X.jsx)(Ye,{icon:(0,X.jsx)(vt,{size:16}),title:d>0?`Nothing else waiting to land`:`Everything landed`,description:d>0?`Every other finished task's commits are on the base branch, or it made none.`:`Every finished task's commits are on the base branch, or it made none.`,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{variant:`outline`,size:`sm`,asChild:!0,children:(0,X.jsx)(F,{to:K.cleanup,children:`Check cleanup`})}),(0,X.jsx)(N,{variant:`outline`,size:`sm`,asChild:!0,children:(0,X.jsx)(F,{to:`/`,children:`View tasks`})})]})}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(`div`,{className:`flex flex-col gap-5`,children:c.map(e=>(0,X.jsxs)(`section`,{"data-slot":`not-landed-group`,"data-group":e.key,"aria-label":e.title,className:`flex flex-col gap-1.5`,children:[(0,X.jsxs)(`h2`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.title}),(0,X.jsx)(`span`,{className:`tabular-nums`,children:e.rows.length}),e.note?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{children:e.note})]}):null]}),(0,X.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.rows.map(e=>(0,X.jsx)(an,{entry:e,finishedAt:e.runId?p.get(e.runId):void 0,onDelete:()=>s(e)},e.name))})]},e.key))}),(0,X.jsxs)(`p`,{"data-slot":`not-landed-note`,className:`flex items-start gap-1.5 px-1 text-xs leading-snug text-muted-foreground`,children:[(0,X.jsx)(De,{"aria-hidden":`true`,className:`mt-px size-3 shrink-0`}),`Delete a branch from its row's … menu. It confirms and names the commits it drops; nothing here is bulk-deleted.`]}),u<=3?(0,X.jsx)(Je,{summary:`${u} ${u===1?`branch`:`branches`} waiting to land. Open a draft PR or inspect worktrees in Cleanup.`,actions:(0,X.jsx)(N,{variant:`outline`,size:`sm`,asChild:!0,children:(0,X.jsx)(F,{to:K.cleanup,children:`Open cleanup`})})}):null]})]}),(0,X.jsx)(un,{entry:o,onClose:()=>s(null)})]})}function rn({className:e}){return(0,X.jsxs)(`p`,{"data-slot":`git-no-forge`,className:O(`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,e),children:[(0,X.jsx)(De,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),$t,`.`]})}function an({entry:e,finishedAt:t,onDelete:n}){return(0,X.jsxs)(`li`,{"data-slot":`not-landed-row`,"data-branch":e.name,"data-branch-class":e.class,className:`flex min-h-[60px] items-center gap-3 px-4 py-3 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,children:[(0,X.jsx)(cn,{entry:e,finishedAt:t}),(0,X.jsx)(on,{entry:e}),(0,X.jsx)(sn,{entry:e,onDelete:n})]})}function on({entry:e}){return(0,X.jsx)(X.Fragment,{children:e.pr?(0,X.jsxs)(`span`,{"data-slot":`not-landed-pr`,className:`hidden shrink-0 items-center gap-1.5 text-xs text-muted-foreground md:flex`,children:[(0,X.jsx)(re,{plain:!0,reference:{kind:`PR`,number:e.pr.number,url:e.pr.url},taskTitle:e.title??e.name,status:e.pr.state===`draft`?`draft`:e.pr.state===`closed`?`closed`:void 0}),(0,X.jsx)(ln,{entry:e})]}):null})}function sn({entry:e,onDelete:t}){let n=_(),r=e.class===`orphan`,i=e.pr&&(e.pr.state===`open`||e.pr.state===`draft`)?e.pr:null,a=!r&&e.runId!==null&&!i,o=u({mutationFn:()=>ee(e.runId),onSuccess:e=>{y(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:d.repoBranches}),n.invalidateQueries({queryKey:d.runs.all})},onError:e=>y(e instanceof g&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),[s,c]=(0,Y.useState)(!1),l=(0,Y.useRef)(null);(0,Y.useEffect)(()=>()=>{l.current!==null&&clearTimeout(l.current)},[]);let f=()=>void navigator.clipboard.writeText(e.name).then(()=>{y(`Copied ${e.name}`),l.current!==null&&clearTimeout(l.current),c(!0),l.current=setTimeout(()=>c(!1),2e3)},()=>y(`Could not copy the branch name`,{tone:`danger`})),p=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-sm px-2.5 text-[12.5px] font-medium text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 [&>svg]:size-[12px]`;return(0,X.jsxs)(X.Fragment,{children:[e.runId?(0,X.jsx)(F,{to:`/tasks/${e.runId}`,"data-action":`not-landed-open`,className:O(p,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:`Open task`}):null,a?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-create-pr`,disabled:o.isPending,onClick:()=>o.mutate(),className:O(p,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[(0,X.jsx)(Mt,{"aria-hidden":`true`}),o.isPending?`Creating…`:`Draft PR`]}):null,r?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,"data-copied":s||void 0,"aria-live":`polite`,onClick:f,className:O(p,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[s?(0,X.jsx)(he,{"aria-hidden":`true`}):(0,X.jsx)(ye,{"aria-hidden":`true`}),s?`Copied`:`Copy branch`]}):null,(0,X.jsxs)(Ie,{children:[(0,X.jsx)(Pe,{"data-action":`not-landed-more`,"aria-label":`More actions for ${e.name}`,className:`flex size-8 shrink-0 items-center justify-center rounded-sm text-soft-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:size-11`,children:(0,X.jsx)(le,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,X.jsxs)(Fe,{align:`end`,className:`w-52`,children:[e.runId?(0,X.jsx)(P,{asChild:!0,className:`md:hidden`,children:(0,X.jsx)(F,{to:`/tasks/${e.runId}`,children:`Open task`})}):null,a?(0,X.jsx)(P,{className:`md:hidden`,disabled:o.isPending,onSelect:()=>o.mutate(),children:`Draft PR`}):null,(0,X.jsx)(P,{className:O(!r&&`md:hidden`),onSelect:f,children:`Copy branch`}),(0,X.jsx)(Ne,{className:`md:hidden`}),(0,X.jsx)(P,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function cn({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=t??e.lastCommit.at,a=Xe(i),o=e.runStatus?st(e.runStatus):void 0,s=n||!o?a:`${o.label}${a?` ${a}`:``}`,c=Number.isFinite(Date.parse(i))?new Date(i).toLocaleString():void 0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`flex size-[12px] shrink-0 items-center justify-center`,children:n?(0,X.jsx)(Ce,{"aria-label":`Task deleted`,className:`size-[12px] text-muted-foreground`}):(0,X.jsx)(We,{tone:o?.tone??`neutral`,shape:o?.shape??`filled`,"aria-label":o?.label})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[e.runId?(0,X.jsx)(F,{to:`/tasks/${e.runId}`,"data-slot":`not-landed-title`,className:`min-w-0 truncate rounded-[2px] text-[13px] font-medium text-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:r}):(0,X.jsx)(`span`,{"data-slot":`not-landed-title`,className:`min-w-0 truncate text-[13px] font-medium text-foreground`,title:r,children:r}),(0,X.jsxs)(`span`,{"data-slot":`not-landed-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),(0,X.jsx)(Q,{}),(0,X.jsxs)(`span`,{className:`shrink-0`,children:[e.ahead,` commit`,e.ahead===1?``:`s`]}),e.diffStat?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(wt,{adds:e.diffStat.additions,dels:e.diffStat.deletions})]}):null,s?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{className:`truncate`,title:c,children:s})]}):null]}),e.parentRunId?(0,X.jsx)(F,{to:`/tasks/${e.parentRunId}`,"data-slot":`not-landed-parent`,className:`w-fit rounded-[2px] text-xs text-muted-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:`Worker of its parent task`}):null,(0,X.jsx)(Lt,{entry:e})]})]})}function Q(){return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`})}function ln({entry:e}){let t=f(T(`PR`,e.pr?.number).status),n=e.pr?.state,r=n===`draft`||n===`closed`?n:t?t.label.toLowerCase():`open`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{"data-slot":`not-landed-pr-state`,children:r})]})}function un({entry:e,onClose:t}){let n=_(),[r,i]=(0,Y.useState)(``),a=(0,Y.useId)(),o=u({mutationFn:e=>b({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;y(e.deleted.length>0?`Deleted ${e.deleted[0]}${t?` and ${t} commit${t===1?``:`s`} with it`:``}`:e.refused[0]?.reason??`Nothing was deleted`),n.invalidateQueries({queryKey:d.repo}),s()},onError:e=>y(e.message,{tone:`danger`})}),s=()=>{i(``),t()},c=e!==null&&r.trim()===e.name,l=e&&`${e.ahead} commit${e.ahead===1?``:`s`}`;return(0,X.jsx)(z,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&s(),children:(0,X.jsxs)(W,{"data-slot":`delete-branch-dialog`,children:[(0,X.jsxs)(B,{children:[(0,X.jsxs)(G,{children:[`Delete `,e?.name,`?`]}),(0,X.jsx)(q,{asChild:!0,children:(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`p`,{children:e?.class===`orphan`?`Its task was deleted, so this branch is the only copy of the work.`:(0,X.jsxs)(X.Fragment,{children:[`This drops the work of `,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:e?.title??e?.name}),`. It is not on the base branch`,e?.pr?``:` and no pull request carries it`,`.`]})}),(0,X.jsxs)(`p`,{"data-slot":`delete-branch-dropped`,children:[l,` will be dropped`,e?.diffStat?` (+${e.diffStat.additions} −${e.diffStat.deletions})`:``,`, the latest “`,e?.lastCommit.subject,`”`,e?.lastCommit.sha?(0,X.jsxs)(X.Fragment,{children:[` (`,(0,X.jsx)(et,{sha:e.lastCommit.sha,variant:`inline`}),`)`]}):null,`.`]})]})})]}),(0,X.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),c&&e&&!o.isPending&&o.mutate(e.name)},className:`flex flex-col gap-[6px]`,children:[(0,X.jsxs)(`label`,{htmlFor:a,className:`text-[12.5px] text-muted-foreground`,children:[`Type `,(0,X.jsx)(`span`,{className:`font-mono text-foreground`,children:e?.name}),` to confirm`]}),(0,X.jsx)(U,{id:a,"data-slot":`delete-branch-confirm`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value),className:`h-11 font-mono`})]}),(0,X.jsxs)(H,{children:[(0,X.jsx)(J,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,X.jsx)(V,{"data-action":`delete-branch-confirm`,className:`h-11 bg-danger text-danger-foreground hover:brightness-[0.96]`,disabled:!c||o.isPending,onClick:t=>{t.preventDefault(),e&&o.mutate(e.name)},children:o.isPending?`Deleting…`:`Delete branch`})]})]})})}function dn({base:e}){let t=i(),n=_(),[r,a]=(0,Y.useState)({merged:!1,empty:!1}),[o,s]=(0,Y.useState)(!1),c=(t.data?.branches??[]).filter(e=>e.class===`merged`),l=(t.data?.branches??[]).filter(e=>e.class===`empty`),f=[...c,...l],p=u({mutationFn:e=>b({names:e}),onSuccess:e=>{let t=e.refused.length;y(`Deleted ${e.deleted.length} branch${e.deleted.length===1?``:`es`}${t?`; kept ${t} that ${t===1?`is`:`are`} no longer safe to delete`:``}`),n.invalidateQueries({queryKey:d.repo})},onError:e=>{n.invalidateQueries({queryKey:d.repo}),y(e.message,{tone:`danger`})}});if(t.isPending)return(0,X.jsx)(`p`,{"data-slot":`cleanup-branches-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading branches…`});if(t.isError)return(0,X.jsxs)(`p`,{"data-slot":`cleanup-branches-error`,className:`text-[13px] text-danger`,children:[`Branches did not load: `,t.error.message]});let m=f.length,h=`branch${m===1?``:`es`}`;return(0,X.jsxs)(`section`,{"data-slot":`cleanup-branches`,"aria-labelledby":`cleanup-branches-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`cleanup-branches-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Branches safe to delete · `,m]}),(0,X.jsxs)(`p`,{className:`text-xs leading-[17px] text-soft-foreground`,children:[`Their work is already on `,e,`, or they have none. Deleting loses nothing.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`cleanup-branches-delete`,disabled:m===0||p.isPending,onClick:()=>s(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(_e,{"aria-hidden":`true`,className:`size-[12px]`}),p.isPending?`Deleting…`:`Delete ${m} ${h}`]})]}),(0,X.jsx)(fn,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:$t.toLowerCase(),rows:c,open:r.merged,onToggle:()=>a(e=>({...e,merged:!e.merged}))}),(0,X.jsx)(fn,{kind:`empty`,title:`Empty`,hint:`no commits beyond the fork point`,rows:l,open:r.empty,onToggle:()=>a(e=>({...e,empty:!e.empty}))}),(0,X.jsx)(z,{open:o,onOpenChange:s,children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(B,{children:[(0,X.jsxs)(G,{children:[`Delete `,m,` `,h,`?`]}),(0,X.jsxs)(q,{children:[c.length,` merged into `,e,` and `,l.length,` empty. Their work is already on `,e,`, or they have none. Anything that stopped being safe since this list loaded is kept.`]})]}),(0,X.jsxs)(H,{children:[(0,X.jsx)(J,{children:`Keep them`}),(0,X.jsxs)(V,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{p.mutate(f.map(e=>e.name)),s(!1)},children:[`Delete `,m,` `,h]})]})]})})]})}function fn({kind:e,title:t,hint:n,rows:r,open:i,onToggle:a}){let o=`cleanup-branches-${e}`;return(0,X.jsxs)(`div`,{"data-slot":`cleanup-branch-group`,"data-group":e,className:`border-b border-border last:border-0`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":o,disabled:r.length===0,onClick:a,className:`flex min-h-[44px] w-full items-center gap-[12px] px-[14px] py-[4px] text-left hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:hover:bg-transparent`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`span`,{className:`truncate text-[12.5px] text-foreground`,children:[t,` · `,r.length]}),(0,X.jsx)(`span`,{className:`truncate text-xs text-soft-foreground`,children:n})]}),r.length>0?(0,X.jsx)(pe,{"aria-hidden":`true`,className:O(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,i&&`rotate-90`)}):null]}),i?(0,X.jsx)(`ul`,{id:o,"aria-label":t,className:`flex flex-col pb-[6px]`,children:r.map(e=>(0,X.jsxs)(`li`,{"data-slot":`cleanup-branch-row`,"data-branch":e.name,className:`flex min-h-[32px] items-center gap-[10px] px-[14px] pl-[26px] text-xs`,children:[(0,X.jsx)(lt,{value:e.name,className:`shrink-0 text-muted-foreground`}),e.runId?(0,X.jsx)(F,{to:`/tasks/${e.runId}`,className:`min-w-0 flex-1 truncate text-soft-foreground underline-offset-2 hover:text-foreground hover:underline`,children:e.title??`Open the task`}):(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-soft-foreground`,children:e.lastCommit.subject}),e.pr?(0,X.jsxs)(`span`,{className:`shrink-0 text-soft-foreground`,children:[`PR #`,e.pr.number]}):null,(0,X.jsx)(bt,{iso:e.lastCommit.at,className:`shrink-0 text-soft-foreground`})]},e.name))}):null]})}function $(e){return e.some(e=>e.sizeBytes===null)?null:e.reduce((e,t)=>e+(t.sizeBytes??0),0)}function pn(e){return e.kind===`dirty`?`${e.uncommittedFiles} uncommitted`:e.kind===`detached-head`?`detached HEAD`:e.kind===`submodules`?`has submodules`:`broken worktree`}function mn(e){if(e.kind===`dirty`){let t=`${e.uncommittedFiles} uncommitted file${e.uncommittedFiles===1?``:`s`}`;return e.detachedHead?`${t} and a detached HEAD on no branch`:t}return e.kind===`detached-head`?`a detached HEAD whose commit is on no branch`:e.kind===`submodules`?`initialized submodules that Git will not remove without force`:`an unregistered or broken Git worktree directory`}function hn(e){let t=e.some(e=>e.reclaimBlocker?.kind===`dirty`),n=e.some(e=>e.reclaimBlocker?.kind===`detached-head`||e.reclaimBlocker?.kind===`dirty`&&e.reclaimBlocker.detachedHead),r=e.some(e=>e.reclaimBlocker?.kind===`submodules`),i=e.some(e=>e.reclaimBlocker?.kind===`invalid`),a=[...t?[`uncommitted work`]:[],...n?[`a detached HEAD`]:[],...r?[`initialized submodules`]:[],...i?[`a broken checkout`]:[]];return a.length<=1?a[0]??`uncommitted work`:`${a.slice(0,-1).join(`, `)} or ${a.at(-1)}`}function gn(e,t,n){let r=Math.max(0,t-e);return e===0?r===0?`Nothing to reclaim — no finished worktrees exceed the keep limit`:n?`Nothing was reclaimed — the worktrees past the keep limit are in use or could not be removed`:`Nothing was reclaimed — the worktrees past the keep limit have uncommitted work or are in use`:`Reclaimed ${e} worktree${e===1?``:`s`} (branch kept)${r>0?` · ${r} kept: ${n?`in use or could not be removed`:`uncommitted work or in use`}`:``}`}function _n(e,t){return e===0?`Reclaim now`:t?`Reclaim ${E(t)} now`:`Reclaim ${e} now`}function vn(e,t,n){let r=t?E(t):String(e);return n?`Discard & reclaim all ${r}`:`Discard & reclaim ${r}`}function yn(e,t){if(!e)return t>0?`No clean worktrees past the keep limit — use Discard & reclaim for blocked worktrees`:`Nothing past the keep limit to reclaim`}function bn(e){return e===0?{prefix:`Retention is unlimited (`,suffix:`), so nothing is reclaimed on its own.`}:{prefix:`Retention keeps the newest ${e} finished checkout${e===1?``:`s`} (`,suffix:`) and reclaims the rest.`}}function xn({blocked:e,discardLabel:t,disabled:n,onDiscard:r}){let i=$(e),a=e.length===1?``:`s`,o=e.length===1?`it has`:`they have`;return(0,X.jsxs)(`div`,{"data-slot":`worktrees-blocked-banner`,className:`flex flex-col gap-[10px] border-b border-border bg-muted/40 px-[14px] py-[10px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`p`,{className:`min-w-0 flex-1 text-[12px] leading-[17px] text-foreground`,children:[e.length,` worktree`,a,` past the keep limit`,i?` (${E(i)})`:``,` `,`cannot be reclaimed automatically because `,o,` `,hn(e),`.`]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`worktrees-discard-reclaim`,disabled:n,onClick:r,className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] border border-danger/40 px-[10px] text-[12px] font-medium text-danger hover:bg-danger/10 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 md:self-center`,children:[(0,X.jsx)(dt,{"aria-hidden":`true`,className:`size-[12px]`}),t]})]})}function Sn({confirmClean:e,onCloseClean:t,cleanCount:n,cleanBytes:r,reclaimLabel:i,onConfirmClean:a,discardBatch:o,onCloseDiscardBatch:s,onConfirmDiscardBatch:c,discardRow:l,onCloseRow:u,onConfirmRow:d}){let f=o?$(o):null,p=o?o.filter(e=>e.reclaimBlocker!==null).length:0,m=o?o.some(e=>!e.reclaimBlocker):!1,h=o?vn(o.length,f,m):``;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(z,{open:e,onOpenChange:e=>{e||t()},children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(B,{children:[(0,X.jsx)(G,{children:`Reclaim old worktrees?`}),(0,X.jsxs)(q,{children:[n,` finished worktree`,n===1?``:`s`,` beyond the keep limit`,r?` (${E(r)})`:``,` `,n===1?`is`:`are`,` reclaimed now, directory only. Their branches are kept, so the work stays recoverable.`]})]}),(0,X.jsxs)(H,{children:[(0,X.jsx)(J,{children:`Keep them`}),(0,X.jsx)(V,{"data-action":`worktrees-confirm`,onClick:a,children:i})]})]})}),(0,X.jsx)(z,{open:o!==null,onOpenChange:e=>{e||s()},children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(B,{children:[(0,X.jsx)(G,{children:`Discard changes and reclaim worktrees?`}),(0,X.jsx)(q,{children:o?(0,X.jsxs)(X.Fragment,{children:[o.length,` finished worktree`,o.length===1?``:`s`,` beyond the keep limit`,f?` (${E(f)})`:``,` will be reclaimed now.`,` `,`Uncommitted files and detached-HEAD commits in `,p,` blocked checkout`,p===1?``:`s`,` will be permanently discarded. Each task’s branch is kept.`]}):null})]}),(0,X.jsxs)(H,{children:[(0,X.jsx)(J,{children:`Keep them`}),(0,X.jsx)(V,{"data-action":`worktrees-discard-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{o&&c(o),s()},children:h})]})]})}),(0,X.jsx)(z,{open:l!==null,onOpenChange:e=>{e||u()},children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(B,{children:[(0,X.jsx)(G,{children:`Discard changes and reclaim worktree?`}),(0,X.jsx)(q,{children:l?.reclaimBlocker?(0,X.jsxs)(X.Fragment,{children:[l.title,` has `,mn(l.reclaimBlocker),`. Reclaiming removes the directory and permanently discards uncommitted or unbranched changes in it. The branch (`,l.branch??l.runId.slice(0,8),`) is kept.`]}):null})]}),(0,X.jsxs)(H,{children:[(0,X.jsx)(J,{children:`Keep it`}),(0,X.jsx)(V,{"data-action":`worktree-discard-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{l&&d(l),u()},children:`Discard & reclaim`})]})]})})]})}function Cn(){let e=r(),t=o().data?.targets.find(e=>e.id===`finder`),n=u({mutationFn:e=>ne(e,t.id),onError:e=>y(e.message,{tone:`danger`})}),i=_(),[a,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(null),m=()=>Promise.all([i.invalidateQueries({queryKey:d.worktrees}),i.invalidateQueries({queryKey:d.repoBranches})]),g=u({mutationFn:({runIds:e})=>h(e?{discardWork:!0,runIds:e}:void 0),onSuccess:(e,{expected:t,runIds:n})=>{m(),y(gn(e.reclaimed.length,t,!!n))},onError:e=>y(e.message,{tone:`danger`})}),v=u({mutationFn:({worktree:e,discardWork:t})=>te(e.runId,t?{discardWork:!0}:void 0),onSuccess:(e,{worktree:t})=>{m(),y(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{m(),y(e.message,{tone:`danger`})}});if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading worktrees…`});if(e.isError)return(0,X.jsxs)(`p`,{"data-slot":`worktrees-error`,className:`text-[13px] text-danger`,children:[`Worktrees did not load: `,e.error.message]});let{worktrees:b,totalBytes:ee,keep:x}=e.data,S=g.isPending||v.isPending,C=b.filter(e=>e.pastKeep),w=C.filter(e=>!e.reclaimBlocker),T=C.filter(e=>e.reclaimBlocker!==null),D=w.length>0,re=$(w),O=$(C),k=_n(w.length,re),ie=vn(C.length,O,D),A=ee?E(ee):null,j=bn(x);return(0,X.jsxs)(`section`,{"data-slot":`worktrees-panel`,"aria-labelledby":`worktrees-panel-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`worktrees-panel-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Worktrees on disk`,A?` · ${A}`:``]}),(0,X.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-xs leading-[17px] text-soft-foreground`,children:[j.prefix,(0,X.jsx)(F,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:Qe(`worktrees`,` › `)}),j.suffix,` `,`Reclaim removes the directory only; the branch stays, so its work stays recoverable.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`worktrees-reclaim-now`,disabled:S||!D,title:yn(D,T.length),onClick:()=>s(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(dt,{"aria-hidden":`true`,className:`size-[12px]`}),k]})]}),T.length>0?(0,X.jsx)(xn,{blocked:T,discardLabel:ie,disabled:S,onDiscard:()=>l(C)}):null,b.length===0?(0,X.jsx)(`p`,{"data-slot":`worktrees-empty`,className:`px-[14px] py-[12px] text-[12.5px] text-soft-foreground`,children:`No task worktrees on disk.`}):(0,X.jsx)(`ul`,{"aria-label":`Task worktrees on disk`,className:`flex flex-col`,children:b.map(e=>(0,X.jsx)(En,{worktree:e,keep:x,disabled:S,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>{e.reclaimBlocker?p(e):v.mutate({worktree:e,discardWork:!1})}},e.runId))}),(0,X.jsx)(Sn,{confirmClean:a,onCloseClean:()=>s(!1),cleanCount:w.length,cleanBytes:re,reclaimLabel:k,onConfirmClean:()=>{g.mutate({expected:w.length}),s(!1)},discardBatch:c,onCloseDiscardBatch:()=>l(null),onConfirmDiscardBatch:e=>{g.mutate({expected:e.length,runIds:e.map(e=>e.runId)})},discardRow:f,onCloseRow:()=>p(null),onConfirmRow:e=>v.mutate({worktree:e,discardWork:!0})})]})}var wn=new Set([`queued`,`running`,`waiting`,`review`]);function Tn(e,t){return wn.has(e.status)||!e.reclaimable?{label:`in use`,tone:`in-use`,state:`in-use`}:e.reclaimBlocker?{label:pn(e.reclaimBlocker),tone:`blocked`,state:`blocked`}:e.pastKeep?{label:`reclaimable`,tone:`plain`,state:`reclaimable`}:{label:t>0?`kept · newest ${t}`:`kept`,tone:`plain`,state:`kept`}}function En({worktree:e,keep:t,disabled:n,onOpen:r,opening:i,onReclaim:a}){let o=Tn(e,t),s=Xe(e.finishedAt??void 0),c=e.status===`review`?`at review`:s?`${e.status} ${Ze(s)}`:e.status,l=o.tone===`in-use`?`text-status-running`:o.tone===`blocked`?`text-danger`:`text-soft-foreground`,u=e.reclaimBlocker?`Cannot auto-reclaim: ${mn(e.reclaimBlocker)}`:void 0,d=(0,X.jsx)(`span`,{"data-slot":`worktree-state`,"data-state":o.state,title:u,className:O(`text-xs`,l),children:o.label}),f=`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:size-11`,p=e.reclaimBlocker?`Discard changes and reclaim the worktree of ${e.title} (branch kept)`:`Reclaim the worktree of ${e.title} (branch kept)`,m=e.reclaimBlocker?`Discard changes and reclaim the directory (branch kept)`:`Reclaim the directory (branch kept)`;return(0,X.jsxs)(`li`,{"data-slot":`worktree-row`,"data-run":e.runId,className:`flex min-h-[44px] items-center gap-[12px] border-b border-border px-[14px] py-[4px] last:border-0`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsx)(`span`,{className:`truncate text-[12.5px] text-foreground`,title:e.title,children:e.title}),(0,X.jsxs)(`span`,{className:`truncate font-mono text-xs text-soft-foreground`,children:[e.branch??e.runId.slice(0,8),` · `,c,(0,X.jsxs)(`span`,{className:`md:hidden`,children:[` · `,o.label]})]})]}),(0,X.jsx)(`span`,{"data-slot":`worktree-size`,className:`shrink-0 text-xs tabular-nums text-muted-foreground`,children:e.sizeBytes===null?`—`:E(e.sizeBytes)||`0 kB`}),(0,X.jsx)(`span`,{className:`hidden shrink-0 md:inline`,children:d}),r?(0,X.jsx)(`button`,{type:`button`,className:f,"aria-label":`Open folder for ${e.title}`,title:`Open folder`,disabled:i,onClick:r,children:(0,X.jsx)(ie,{"aria-hidden":`true`,className:`size-[13px]`})}):null,o.tone===`in-use`?null:(0,X.jsx)(`button`,{type:`button`,"data-action":`worktree-reclaim`,"aria-label":p,title:m,disabled:n,onClick:a,className:O(f,e.reclaimBlocker&&`text-danger hover:text-danger`),children:(0,X.jsx)(dt,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function Dn(e){return e===`main`||e===`changes`?`Split`:`Table`}function On({section:e,index:t=!1}){let n=s(),r=I(),[i]=C(),a=Dn(e);if(t&&!r&&i.get(`view`)!==`repo`)return(0,X.jsx)(Nt,{});if(n.isPending)return(0,X.jsx)(yt,{});if(n.isError)return(0,X.jsx)(L,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,X.jsx)($e,{}),children:(0,X.jsx)(R,{icon:(0,X.jsx)(M,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:n.error.message})});let o=n.data.info;return o?(0,X.jsx)(kn,{repo:n.data,info:o,section:e}):(0,X.jsx)(L,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,X.jsx)($e,{}),children:(0,X.jsx)(R,{icon:(0,X.jsx)(me,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`Squawk is running outside a git repository — start it inside one to browse changes, commits and branches.`})})}function kn({repo:e,info:t,section:n}){let r=Dn(n),a=i(),o=An(n),s=n===`main`?e.log.length:n===`changes`?e.status.length:n===`branches`?Gt(e,a.data?.branches).length:n===`not-landed`?a.data?.branches.filter(e=>e.class===`not-landed`||e.class===`orphan`).length??0:4;return(0,X.jsx)(L,{template:r,route:`repo-git`,density:n===`not-landed`&&a.isPending?`full`:qe(s),rootProps:{"data-git-section":n},beforeHeader:(0,X.jsx)($e,{}),header:{title:o?.title??tt(n,t.branch),headerSlot:`repo-header`,subtitle:o?(0,X.jsxs)(X.Fragment,{children:[`Commit `,o.shortSha,` on `,t.branch]}):(0,X.jsx)(jn,{repo:e,info:t,section:n}),subtitleSlot:`repo-meta`,...n===`branches`?{primaryAction:(0,X.jsx)(Ft,{from:t.branch})}:{}},children:n===`main`?(0,X.jsx)(qt,{repo:e,info:t}):n===`not-landed`?(0,X.jsx)(nn,{}):n===`cleanup`?(0,X.jsxs)(`div`,{"data-slot":`repo-cleanup`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[(0,X.jsx)(Cn,{}),(0,X.jsx)(dn,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,X.jsx)(Rt,{repo:e,info:t}):(0,X.jsx)(Kt,{})})}function An(e){let{sha:t}=w(),n=I(),r=e===`main`&&!n?t:void 0,i=c(r);if(!r)return;let a=r.slice(0,8);return{title:i.data?.subject??`Commit ${a}`,shortSha:a}}function jn({repo:e,info:t,section:n}){let r=e.baseBranch??t.branch;switch(n){case`main`:return(0,X.jsxs)(X.Fragment,{children:[e.log.length===0?`No commits yet`:`Latest ${e.log.length} commit${e.log.length===1?``:`s`} in the main checkout`,e.tracking?` · ${gt(e.tracking)}`:``]});case`not-landed`:return(0,X.jsxs)(X.Fragment,{children:[`Finished tasks whose commits are not on `,r]});case`branches`:return(0,X.jsx)(Mn,{repo:e,info:t});case`changes`:return(0,X.jsxs)(X.Fragment,{children:[e.status.length,` uncommitted file`,e.status.length===1?``:`s`,` in the main checkout`]});case`cleanup`:return(0,X.jsxs)(X.Fragment,{children:[`Nothing here can delete work that is not on `,r]})}}function Mn({repo:e,info:t}){let n=Gt(e,i().data?.branches).length;return(0,X.jsxs)(X.Fragment,{children:[n,` branch`,n===1?``:`es`,` · on `,t.branch]})}export{On as RepoGitRoute};