@wjarka/cezarion 0.18.0-dev.8037 → 0.18.0-dev.8044

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 (62) hide show
  1. package/package.json +2 -2
  2. package/web/dist/assets/{accounts-section-B-zlsH7k.js → accounts-section-D3P_Z-Nu.js} +1 -1
  3. package/web/dist/assets/{activity-motion-psm6jyeg.js → activity-motion-BW-0k8s7.js} +1 -1
  4. package/web/dist/assets/{activity-route-DeK0riM9.js → activity-route-Bpgblioe.js} +1 -1
  5. package/web/dist/assets/{agent-config-section-BvmWn_h-.js → agent-config-section-Cj3w7UIn.js} +1 -1
  6. package/web/dist/assets/{agent-defaults-section-DsuYOQpY.js → agent-defaults-section-BJ4poe9c.js} +1 -1
  7. package/web/dist/assets/{appearance-DNMXL1v0.js → appearance-BUsUTPF0.js} +1 -1
  8. package/web/dist/assets/{archive-on-merge-field-BovFB0t7.js → archive-on-merge-field-D_kgBFNv.js} +1 -1
  9. package/web/dist/assets/attention-lvUYNNvV.js +1 -0
  10. package/web/dist/assets/{automations-route-DyiKOd25.js → automations-route-CZaUrmDs.js} +1 -1
  11. package/web/dist/assets/{commit-diff-panel-DawdFJ6E.js → commit-diff-panel-xwLW6Ydr.js} +1 -1
  12. package/web/dist/assets/{diff-CfoXwmnl.js → diff-BB8SoL-s.js} +2 -2
  13. package/web/dist/assets/{diff-view-5xkdG47g.js → diff-view-O8lx1ztb.js} +1 -1
  14. package/web/dist/assets/{file-preview-DIVTxup4.js → file-preview-BS6M2tBo.js} +1 -1
  15. package/web/dist/assets/{folder-browser-BzVWaANT.js → folder-browser-Dsqz0Z1z.js} +1 -1
  16. package/web/dist/assets/{git-toolbar-BUViNmxj.js → git-toolbar-DoPFA36c.js} +1 -1
  17. package/web/dist/assets/{github-COe1nsmn.js → github-Bjy3WBvf.js} +1 -1
  18. package/web/dist/assets/{global-activity-route-B-cJo1pg.js → global-activity-route-BXBZKz_9.js} +1 -1
  19. package/web/dist/assets/{index-BZiixXpY.js → index-CmadQXcg.js} +5 -5
  20. package/web/dist/assets/{label-DVUPtyTI.js → label-CZp8t0zE.js} +1 -1
  21. package/web/dist/assets/{markdown-bvY77s5D.js → markdown-KHcncamw.js} +1 -1
  22. package/web/dist/assets/{notifications-section-Cet1mmEc.js → notifications-section-DD21Sd79.js} +1 -1
  23. package/web/dist/assets/{open-in-menu-BpSp2CJF.js → open-in-menu-DdKs6X5r.js} +1 -1
  24. package/web/dist/assets/{preview-pane-connected-BCrpsIIn.js → preview-pane-connected-BvTZv2SQ.js} +1 -1
  25. package/web/dist/assets/{project-location-ClZPnbBZ.js → project-location-B3LBvkz2.js} +1 -1
  26. package/web/dist/assets/{project-router-BYrAO9Ws.js → project-router-CIKODSHW.js} +1 -1
  27. package/web/dist/assets/project-scope-context-D1bpJixc.js +4 -0
  28. package/web/dist/assets/{projects-section-CdUdrEPd.js → projects-section-C0k8kyb-.js} +1 -1
  29. package/web/dist/assets/{prompt-templates-section-D3ojaPZw.js → prompt-templates-section-DNkosCni.js} +1 -1
  30. package/web/dist/assets/{queries--x5yVcip.js → queries-dHXhD3Hc.js} +1 -1
  31. package/web/dist/assets/{reference-chip-013dL8dQ.js → reference-chip-BWViAFIN.js} +1 -1
  32. package/web/dist/assets/{remote-settings-notice-BbBWWAm8.js → remote-settings-notice-DPCENbhz.js} +1 -1
  33. package/web/dist/assets/{repo-git-1hSBzyJQ.js → repo-git-jKOnO3ba.js} +1 -1
  34. package/web/dist/assets/{report-reader-BNtgxtSI.js → report-reader-DXYiKNcg.js} +1 -1
  35. package/web/dist/assets/{reports-C64cW2KP.js → reports-DEE0bHNv.js} +1 -1
  36. package/web/dist/assets/{resources-section-xAUouGNM.js → resources-section-lqXgYTrv.js} +1 -1
  37. package/web/dist/assets/{run-header-75eMWFhM.js → run-header-CXlUbvDO.js} +1 -1
  38. package/web/dist/assets/{runners-C4-xD5Cz.js → runners-CGQjSsir.js} +1 -1
  39. package/web/dist/assets/{settings-agent-picker-4P5j_ZP8.js → settings-agent-picker-BRvZn4kM.js} +1 -1
  40. package/web/dist/assets/{settings-shell-CME_R4D1.js → settings-shell-DTtd-vIa.js} +1 -1
  41. package/web/dist/assets/{sidebar-section-BQSB_KxK.js → sidebar-section-BFW4ZfBR.js} +1 -1
  42. package/web/dist/assets/{skills-RUJCWIve.js → skills-AImMlT1T.js} +1 -1
  43. package/web/dist/assets/{tab-link-DnbdjF4r.js → tab-link-CM6SDBtV.js} +1 -1
  44. package/web/dist/assets/{task-changes-Boec_UFj.js → task-changes-01Z_ppIw.js} +1 -1
  45. package/web/dist/assets/{task-commits-B6k-DdnE.js → task-commits-DRNIum3J.js} +1 -1
  46. package/web/dist/assets/{task-files-T731cz4q.js → task-files-Crz7Fo3C.js} +1 -1
  47. package/web/dist/assets/{task-github-item-iQd_C1Y4.js → task-github-item-psG2V47c.js} +1 -1
  48. package/web/dist/assets/{task-groups-BTMFLRHJ.js → task-groups-DF0XoB6U.js} +1 -1
  49. package/web/dist/assets/{task-thread-BaPz3rdA.js → task-thread-Bqg91ZVZ.js} +2 -2
  50. package/web/dist/assets/{tasks-table-BCuA9Kx7.js → tasks-table-DHTEGteC.js} +1 -1
  51. package/web/dist/assets/{thread-state-B3Ichxx9.js → thread-state-BWJ2YyXo.js} +1 -1
  52. package/web/dist/assets/{use-hand-to-agent-state-DIIBuX3r.js → use-hand-to-agent-state-DNROQerR.js} +1 -1
  53. package/web/dist/assets/{useInfiniteQuery-BxpPo6z-.js → useInfiniteQuery-qJeCNhM7.js} +1 -1
  54. package/web/dist/assets/useQuery-C3CQhXsT.js +1 -0
  55. package/web/dist/assets/{workflows-8HhOvPhw.js → workflows-Cx9lgrEo.js} +2 -2
  56. package/web/dist/assets/{workspace-tools-D6C2Yjat.js → workspace-tools-CVitt3kE.js} +1 -1
  57. package/web/dist/assets/{worktrees-section-Cm4JH128.js → worktrees-section-DxUg4l9n.js} +1 -1
  58. package/web/dist/assets/{ws-Iixb-QFR.js → ws-BisMp6U5.js} +1 -1
  59. package/web/dist/index.html +15 -15
  60. package/web/dist/assets/attention-DaLkUl4h.js +0 -1
  61. package/web/dist/assets/project-scope-context-BDU1qGx3.js +0 -4
  62. package/web/dist/assets/useQuery-DcVi2Spi.js +0 -1
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{c as n,o as r}from"./utils-DSMR_WLb.js";import{n as i,t as a}from"./live-refetch-CZb2VOyu.js";import{$ as o,$r as s,$t as c,Ai as l,At as u,B as d,Bt as f,Ct as p,Di as m,Dt as h,Ei as g,Et as _,F as v,Fr as ee,Gt as te,I as ne,In as re,Ir as ie,J as ae,K as oe,L as se,Nr as ce,Ot as le,P as ue,Pt as de,Q as fe,Qt as pe,R as me,Si as he,St as ge,Tt as _e,V as ve,Vr as ye,Vt as be,W as xe,X as Se,Y as Ce,Z as we,_ as Te,_i as Ee,_n as De,_r as Oe,_t as ke,ai as Ae,at as je,b as Me,bn as Ne,c as Pe,ci as y,cn as Fe,ct as Ie,dt as Le,ei as Re,en as ze,et as Be,f as Ve,fr as He,ft as Ue,g as We,gt as Ge,hn as Ke,ht as qe,i as Je,ii as Ye,in as Xe,it as Ze,j as Qe,kt as $e,li as et,ln as tt,lt as nt,m as rt,mi as it,mn as at,mt as ot,ni as st,nn as ct,nt as lt,oi as ut,ot as dt,pi as ft,pn as pt,pt as mt,q as ht,r as gt,ri as _t,rt as vt,sn as yt,st as bt,ti as xt,tn as St,un as Ct,ut as wt,v as Tt,vt as Et,wi as Dt,wt as Ot,x as kt,yi as At,yn as jt,yt as Mt,z as Nt}from"./project-scope-context-BDU1qGx3.js";import{B as b,H as x,L as S,M as C,N as w,O as Pt,P as T,R as E,Y as D,j as O,k}from"./live-protocol-D9ji1YCl.js";import{t as Ft}from"./useInfiniteQuery-BxpPo6z-.js";import{t as A}from"./useQuery-DcVi2Spi.js";import{n as It,r as j,t as Lt}from"./ws-Iixb-QFR.js";import{n as Rt}from"./toaster-Bo5vCbz-.js";var zt=class extends ft{#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||Bt(),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=it({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),D.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Bt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Vt=class extends l{#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),g(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&Ee(t.mutationKey)!==Ee(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??Bt();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){D.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 Ht(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Ut(e,t,n){let r=e.slice(0);return r[t]=n,r}var Wt=class extends l{#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,D.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||!g(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Ht(e,n).forEach(e=>{e.destroy()}),Ht(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=Dt(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 et(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Ut(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)&&D.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},M=e(t(),1);function N({queries:e,...t},n){let r=y(n),i=ut(),a=Ae(),o=M.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{s(e);let t=r.getQueryCache().get(e.queryHash);st(e,a,t)}),Ye(a);let[c]=M.useState(()=>new Wt(r,o,t)),[l,u,d]=c.getOptimisticResult(o,t.combine),f=!i&&t.subscribed!==!1;M.useSyncExternalStore(M.useCallback(e=>f?c.subscribe(D.batchCalls(e)):he,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),M.useEffect(()=>{c.setQueries(o,t)},[o,t,c]);let p=l.some((e,t)=>xt(o[t],e))?l.flatMap((e,t)=>{let n=o[t];return n&&xt(n,e)?Re(n,new et(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=l.find((e,t)=>{let n=o[t];return n&&_t({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m?.error)throw m.error;return u(d())}function P(e,t){let n=y(t),[r]=M.useState(()=>new Vt(n,e));M.useEffect(()=>{r.setOptions(e)},[r,e]);let i=M.useSyncExternalStore(M.useCallback(e=>r.subscribe(D.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=M.useCallback((e,t)=>{r.mutate(e,t).catch(he)},[r]);if(i.error&&m(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function F(e={}){let t=e.projectId??n();return{projectId:t,cacheScope:e.cacheScope??(e.boot?`default`:t)}}function I(e,t={}){return{...F(t),runId:e}}function Gt(e,t=!0,n=!1,r){return A({queryKey:[F({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>Ot(F({projectId:e,boot:n}),{signal:t}),enabled:t,...r?{select:r}:{},placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function L(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:Z.models(t),refetchType:n})}function Kt(e,t=!0,n){return A({...qt(e,n),enabled:t})}var qt=(e,t)=>({queryKey:Z.models(e,t),queryFn:({signal:n})=>re(e,{signal:n},t),staleTime:300*1e3});function Jt(e,t=!0){let n=N({queries:e.map(e=>({...qt(e),enabled:t}))});return Object.fromEntries(e.map((e,t)=>[e,n[t]]))}var R=[`workspace`,`runs-index`],z=e=>[e.cacheScope,`runs`,`list`],B=e=>[e.cacheScope,`runs`,`detail`,e.runId],V=e=>typeof e==`function`?e():e;function Yt(e){let{seenAt:t,...n}=e;return n}function Xt(e,t){let n=Yt(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function Zt(e,t,n){return t?{...e,seenAt:n}:Yt(e)}function Qt(e){let t=()=>{e.invalidateQueries({queryKey:R})};function r(r,i){if(r===`index`)return t();let a=typeof i==`function`?i():i;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=ie(),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)}async function i(n,r){await e.cancelQueries({queryKey:z(V(n))}),await e.cancelQueries({queryKey:B(V(n))});let i=e.getQueryData(z(V(n))),a=e.getQueryData(B(V(n))),o=V(n).runId,s=new Date().toISOString();return e.setQueryData(z(V(n)),e=>e?.map(e=>e.id===o?Zt(e,r,s):e)),e.setQueryData(B(V(n)),e=>e&&Zt(e,r,s)),{id:o,prevList:i,prevDetail:a,rollback(){if(!r){i&&e.setQueryData(z(V(n)),i),a&&e.setQueryData(B(V(n)),a);return}let t=i?.find(e=>e.id===o);t&&e.setQueryData(z(V(n)),e=>e?.map(e=>e.id===o?Xt(e,t):e)),a&&e.setQueryData(B(V(n)),e=>e&&Xt(e,a))},settle(i){let a=e=>e.id===(r?o:i.id)?Zt(e,r,i.seenAt):e;e.setQueryData(z(V(n)),e=>e?.map(a));let s={...V(n),runId:r?o:i.id};e.setQueryData(B(s),e=>e?a(e):i),t()}}}async function a(t,n){await e.cancelQueries({queryKey:R});let i=e.getQueryData(R),a=n();return e.setQueryData(R,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(R,i)},settle(){r(`indexed`,t)}}}return{patchRead:i,patchIndex:a,invalidateAfter:r}}function H(){let e=y();return(0,M.useMemo)(()=>Qt(e),[e])}function $t(e,t){return JSON.stringify([e,t])}function en(e){return e.type===`run`?e.run.id:e.id}function U(e,t){return{...e,runs:t}}function tn(e,t){let n=0;for(let r of e)r.projectId===t&&r.archived&&(n+=1);return n}var nn=class{runs;copied=!1;positions=new Map;constructor(e){this.runs=e,this.reindex()}reindex(){this.positions.clear(),this.runs.forEach((e,t)=>this.positions.set($t(e.projectId,e.id),t))}at(e,t){return this.positions.get($t(e,t))??-1}mutable(){return this.copied||=(this.runs=[...this.runs],!0),this.runs}replace(e,t){return this.mutable()[e]=t,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}};function rn(e,t,n){let r=new nn(e.runs),i=e,a=!1;for(let e of t)if(e.type===`usage`)i=un(i,e.project,e.usage,r);else{let t=sn(i,e.change,n,r);i=t.index,a||=t.reconcile}return{index:i,reconcile:a}}function an(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function on(e,t,n){return sn(e,t,n,new nn(e.runs))}function sn(e,t,n,r){let{project:i}=t,a=r.at(i,en(t)),o=a>=0?e.runs[a]:void 0,s=e.truncated.includes(i);if(t.type===`deleted`)return o?{index:U(e,r.remove(a)),reconcile:s&&o.archived}:{index:e,reconcile:!1};let{run:c}=t;if(c.delegation?.role===`worker`)return o?{index:U(e,r.remove(a)),reconcile:!1}:{index:e,reconcile:!1};if(!o&&!an(e,i,n))return{index:e,reconcile:!0};let l=Dt(o,{projectId:i,...c});if(o){if(l===o)return{index:e,reconcile:!1};let t=r.replace(a,l),n=o.archived!==l.archived&&(s||tn(t,i)>e.perProjectLimit);return{index:U(e,t),reconcile:n}}if(s)return ln(e,l,r);let u=r.insert(l);return{index:U(e,u),reconcile:l.archived&&tn(u,i)>e.perProjectLimit}}function cn(e,t){let n;for(let r of e)r.projectId===t&&r.archived&&(n===void 0||r.createdAt<n)&&(n=r.createdAt);return n}function ln(e,t,n){let r=cn(e.runs,t.projectId),i=r!==void 0&&t.createdAt>r;return t.archived&&!i?{index:e,reconcile:!1}:{index:U(e,n.insert(t)),reconcile:t.archived||r===void 0||t.createdAt<r}}function un(e,t,n,r){let i=!1;return e.runs.forEach((e,a)=>{if(e.projectId!==t)return;let o=n[e.id];if(o){let t=Dt(e.usage,o);if(t===e.usage)return;r.replace(a,{...e,usage:t})}else{if(e.usage===void 0)return;let{usage:t,...n}=e;r.replace(a,n)}i=!0}),i?U(e,r.runs):e}function dn(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 fn(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function pn(e,t,n){if(e.lastStream===t)e.floor=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 mn(e){e.stream=void 0}function hn(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=JSON.stringify([r,t.project,en(t)]),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}function gn(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function _n(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function vn(e,t,n){if(!_n(t))return{index:t,reconcile:!1};let{generation:r,eventSeq:i}=t;if(e.stream!==void 0&&e.stream!==r){let n=e.mismatch!==r;return e.mismatch=r,{index:t,reconcile:n}}let a=e.lastStream===r&&e.floor!==void 0,o=a&&i<e.floor,s=t,c=o,l=[...e.changes.entries()].filter(([,e])=>e.generation===r),u=l.map(([,e])=>e).filter(e=>e.seq>i).sort((e,t)=>e.seq-t.seq);for(let e of u){let t=on(s,e,n);s=t.index,c||=t.reconcile}for(let[t,n]of l)n.seq<=i&&e.changes.delete(t);return a&&!o&&(e.floor=i),{index:s,reconcile:c}}var W=[`workspace`,`runs-index`],yn=[`workspace`,`projects`],bn=6e4,xn=100,Sn=new WeakMap;function Cn(e){let t=Sn.get(e);return t||(t=On(e),Sn.set(e,t)),t}function wn(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:Cn(t).merge(e)}function Tn(e){let t=e.getQueryData(yn)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function En(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 Dn(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 On(e){let t=fn(),n=[],r,i,a,o,s=!1,c=-1/0,l=new Set,u=!1,d,f=!1,p=()=>{if(!u){if(u=!0,d?.()){f=!0;return}_({hold:!0})}},m=t=>{c=Date.now(),e.setQueryData(W,t)},h=()=>e.getQueryData(W),g=()=>{clearTimeout(a),a=void 0;let t=e.getQueryCache().find({queryKey:W,exact:!0}),n=(t!==void 0&&t.state.data===void 0&&t.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:W,exact:!0}).then(()=>e.invalidateQueries({queryKey:W})):e.invalidateQueries({queryKey:W})).catch(()=>void 0).finally(()=>{o===n&&(o=void 0,s&&(s=!1,g()))});return o=n,n},_=(e={})=>o?(s=!0,o):e.hold?(a??=setTimeout(()=>{g()},400),Promise.resolve()):g(),v=()=>{r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0;let t=n;n=[];let a=h();if(!a||t.length===0)return;let o=Tn(e),{index:s,reconcile:c}=rn(a,t.filter(e=>e.generation===a.generation?e.type===`usage`?!l.has(e.project):!l.has(e.change.project)&&e.change.seq>a.eventSeq:!1),o);s!==a&&m(s),c&&_({hold:!0})},ee=()=>{if(i!==void 0)return;let e=c+250-Date.now();if(e>0){i=setTimeout(v,e);return}i=setTimeout(v,xn),typeof requestAnimationFrame==`function`&&(r=requestAnimationFrame(v))};return{ready(e,n){pn(t,e,n),u=!1,f&&(f=!1,_({hold:!0}))},detach(){mn(t)},run(e,r,i=!1){if(l.has(e))return;let a=Dn(e,r);if(!hn(t,a,i)){p();return}n.push({type:`change`,change:a,generation:t.stream}),ee()},usage(e,r){if(!l.has(e)){if(t.stream===void 0){p();return}n.push({type:`usage`,project:e,usage:r,generation:t.stream}),ee()}},dropProject(e){l.add(e),gn(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let r=h();if(!r)return;let i=dn(r,e);i!==r&&m(i)},setUnknownGenerationHandler(e){d=e},restoreProject(e){l.delete(e)},merge(n){let r=h(),i=vn(t,n,Tn(e));for(let e of l)i.index=dn(i.index,e);return i.reconcile&&queueMicrotask(()=>{_({hold:!0})}),En(r,n,t.stream)??i.index},reconcile:_,flush:v,stop(){r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0,clearTimeout(a),a=void 0,n=[],s=!1}}}var kn={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`}},An={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function jn(e){return typeof e==`string`&&Object.hasOwn(kn,e)}function Mn(e){return e!==void 0&&jn(e)?kn[e]:void 0}var Nn=`cez.reference-statuses.v1`,Pn=`cez.reference-conflicts.v1`,G=new Map(Rn()),Fn=1e3;function In(e,t){if(G.get(e)!==t){for(G.delete(e),G.set(e,t);G.size>Fn;){let e=G.keys().next().value;if(e===void 0)break;G.delete(e)}Vn()}}var K=new Set(zn());function Ln(e,t){if(K.has(e)!==t){if(t)for(K.add(e);K.size>Fn;){let e=K.values().next().value;if(e===void 0)break;K.delete(e)}else K.delete(e);Vn()}}function Rn(){try{let e=globalThis.sessionStorage?.getItem(Nn);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`&&jn(e[1])):[]}catch{return[]}}function zn(){try{let e=globalThis.sessionStorage?.getItem(Pn);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var Bn;function Vn(){Bn===void 0&&(Bn=setTimeout(()=>{Bn=void 0;try{globalThis.sessionStorage?.setItem(Nn,JSON.stringify([...G])),globalThis.sessionStorage?.setItem(Pn,JSON.stringify([...K]))}catch{}},250))}var q=e=>`${e.projectId}\u0000${e.kind}#${e.number}`;function Hn(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function Un(e){return[...e.prs.map(t=>({projectId:e.projectId,kind:`PR`,number:t})),...e.issues.map(t=>({projectId:e.projectId,kind:`Issue`,number:t}))]}function Wn(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;In(t,o),s!==void 0&&Ln(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function Gn(e,t,n){let r=q(t),i=G.get(r),a=K.has(r)?!0:void 0,o=n.data;if(o?.available){Wn(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...Hn(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...Hn(i,a)});return}e.set(r,{state:`loading`,...Hn(i,a)})}function Kn(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of Un(i))Gn(n,e,t)}),n}async function qn(e,t=!1){return Ke(await Ve.api.v1.p[`:projectId`].runs[`:id`][`worker-destroy`].$post({param:{projectId:n(),id:encodeURIComponent(e)},query:{},json:t?{discardWork:!0}:{}}),yt(e,`/worker-destroy`))}var Jn=k([`passing`,`failing`,`pending`]).nullable(),J=E({kind:k([`issue`,`pr`]),number:S(),title:x(),author:x(),createdAt:x(),labels:O(x()),body:x().optional(),url:x(),comments:S(),assignees:O(x()).optional(),projectIds:O(x()).optional(),isDraft:C().optional(),additions:S().optional(),deletions:S().optional(),checks:Jn.optional()});w(`available`,[E({available:T(!0),item:J.nullable(),labelColors:b(x(),x()).optional()}),E({available:T(!1),reason:x()})]),E({kind:k([`issue`,`pr`]),number:Pt().int().positive().safe()});var Yn=E({id:x(),title:x(),url:x()});E({available:C(),reason:x().optional(),repo:x().optional(),syncedAt:x().optional(),issues:O(J),prs:O(J),labelColors:b(x(),x()).optional(),viewerLogin:x().optional(),projects:O(Yn).optional(),projectsReason:x().optional(),projectsState:k([`refreshing`,`ready`,`unavailable`]).optional(),projectsGeneration:x().optional(),issuesTotal:S().int().nonnegative().optional(),prsTotal:S().int().nonnegative().optional(),issuesNextCursor:x().nullable().optional(),prsNextCursor:x().nullable().optional(),commentsDeferred:T(!0).optional()});var Xn=x().min(1).max(2e3).optional();E({limit:x().optional(),refresh:x().optional(),issuesCursor:Xn,prsCursor:Xn,issuesDone:T(`1`).optional(),prsDone:T(`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`})}),E({kind:k([`issue`,`pr`]),numbers:x().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:T(`1`).optional()}),w(`available`,[E({available:T(!0),counts:b(S(),S().int().nonnegative())}),E({available:T(!1),reason:x()})]),w(`available`,[E({available:T(!0),checks:b(S(),Jn)}),E({available:T(!1),reason:x()})]),E({kind:k([`issue`,`pr`]),q:x().trim().min(1).max(256),limit:Pt().int().positive().max(50).optional()}),E({available:C(),projectsReason:x().optional(),reason:x().optional(),items:O(J),truncated:C().optional(),labelColors:b(x(),x()).optional()});var Zn=S().nullable();w(`available`,[E({available:T(!0),prs:b(S(),He),issues:b(S(),He),conflicts:O(S()).optional(),recheckAfterMs:Zn}),E({available:T(!1),reason:x(),recheckAfterMs:Zn})]);var Qn=E({id:S(),author:x(),avatarUrl:x().optional(),createdAt:x(),body:x(),kind:k([`comment`,`review`]),reviewState:k([`approved`,`changes_requested`,`commented`,`dismissed`]).optional(),url:x()}),$n=k([`committed`,`labeled`,`unlabeled`,`assigned`,`unassigned`,`merged`,`closed`,`reopened`,`head_ref_force_pushed`,`cross-referenced`,`renamed`]),er=E({id:x(),kind:$n,actor:x(),avatarUrl:x().optional(),createdAt:x(),url:x().optional(),sha:x().optional(),message:x().optional(),checks:Jn.optional(),label:E({name:x(),color:x().optional()}).optional(),subject:x().optional(),refNumber:S().optional(),refTitle:x().optional(),refIsPr:C().optional()});E({available:C(),reason:x().optional(),comments:O(Qn),truncated:C().optional(),events:O(er).optional(),detail:E({body:x(),additions:S().int().nonnegative().optional(),deletions:S().int().nonnegative().optional()}).optional()});var tr=k([`merge`,`squash`,`rebase`]),nr=E({name:x(),state:k([`passing`,`failing`,`pending`,`unknown`]),required:C().nullable(),url:x().optional()}),rr=E({number:S(),title:x(),url:x(),state:k([`open`,`closed`,`merged`]),isDraft:C(),headRef:x(),baseRef:x(),headSha:x(),mergeable:k([`mergeable`,`conflicting`,`unknown`]),reviewDecision:k([`approved`,`changes-requested`,`review-required`,`not-required`,`unknown`]),checks:O(nr),methods:O(tr),defaultMethod:tr.nullable(),eligibility:k([`ready`,`blocked`,`pending`,`unauthorized`,`terminal`,`unknown`]),blockers:O(E({code:x(),message:x()})),canMerge:C(),canOverride:C()});w(`available`,[E({available:T(!0),mergeState:rr}),E({available:T(!1),reason:x()})]),E({merged:T(!0),number:S(),url:x(),method:tr,mergeCommitSha:x().optional()});var ir=E({path:x(),previousPath:x().optional(),status:k([`added`,`modified`,`removed`,`renamed`,`copied`,`changed`]),additions:S(),deletions:S(),patch:x().optional(),patchUnavailableReason:k([`binary`,`too-large`,`not-provided`]).optional(),truncated:C().optional()});w(`available`,[E({available:T(!0),number:S(),headSha:x(),files:O(ir),additions:S(),deletions:S(),truncated:C(),reason:x().optional()}),E({available:T(!1),reason:x()})]),E({generation:x().uuid()}),w(`state`,[E({generation:x().uuid(),state:T(`ready`),projects:O(Yn),membership:b(x(),O(x()))}),E({generation:x().uuid(),state:T(`unavailable`),reason:x()})]);function ar(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 or(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 sr(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 cr(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 lr(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 ur(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function dr(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function fr(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){dr(t.issues,a,r),dr(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:p,...m}=t;return{...m,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 Y=e=>e.map(e=>e.number).join(`,`);function pr(e,t){let n=e[0];if(e.length>1&&n&&(Y(n.issues)!==Y(t.issues)||Y(n.prs)!==Y(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)]}function mr(e,t,r=!0){let i=hi(),a=$(),o=e??i.data?.defaultRunner??`claude`,s=a.data?.capabilities?.localHandoff===!1?null:t,c=n(),l=A({queryKey:X.runnerSkills(o,s),queryFn:({signal:e})=>p(o,s,{signal:e,projectId:c}),enabled:r&&(e!==void 0||!i.isPending)&&(!t||!a.isPending),retry:!1});return{...l,runner:o,account:s,data:l.data?.skills,list:l.data,unchecked:l.isError||!l.data||l.data.source===`unavailable`}}var X={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)=>[n(),`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 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)=>[e,`github`,`ref-status`,[...t].sort((e,t)=>e-t).join(`,`),[...n].sort((e,t)=>e-t).join(`,`)],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`]}},Z={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:W,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)=>[...Z.fsBrowseRoot,e,t]};function hr(){let e=y();return A({queryKey:Z.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(Z.providerStatus),r=await Ie(!1,{signal:t});return Oe(n,e.getQueryData(Z.providerStatus),r)},staleTime:5*6e4,refetchInterval:a(!1),refetchOnWindowFocus:!0})}function gr(){let e=y();return P({mutationFn:()=>Ie(!0),onMutate:()=>e.getQueryData(Z.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Z.providerStatus,e=>Oe(r,e,t)),L(e)}})}function _r(){let e=y();return P({mutationFn:({provider:e,authFailureId:t})=>Xe(e,t),onMutate:()=>e.getQueryData(Z.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Z.providerStatus,e=>Oe(r,e,t,n.authFailureId)),L(e,n.provider)}})}function vr(e={}){return A({queryKey:Z.projects,queryFn:({signal:e})=>bt({signal:e}),...e})}function yr(e,t=!1){return A({queryKey:Z.fsBrowse(e,t),queryFn:({signal:n})=>Pe(e??void 0,{signal:n,showHidden:t}),retry:!1})}function br(){let e=y();return P({mutationFn:e=>pe(e),onSuccess:()=>e.invalidateQueries({queryKey:Z.projects})})}function xr(){let e=y();return P({mutationFn:e=>ze(e),retry:!1,onSuccess:()=>{e.invalidateQueries({queryKey:Z.projects})}})}function Sr(){let e=y();return P({mutationFn:e=>{let{id:t,...n}=e;return jt(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:Z.projects});let r=e.getQueryData(Z.projects);return e.setQueryData(Z.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?Cr(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(Z.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(Z.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:Z.projects})})}function Cr(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?[]:cr(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 wr(e){let t=y();return P({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(Z.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:Z.projects})})}function Tr(){return wr(e=>{let{projectId:t,...n}=e;return kt(t,n)})}function Er(){return wr(e=>{let{projectId:t,webhookId:n,...r}=e;return Ne(t,n,r)})}function Dr(){return wr(({projectId:e,webhookId:t})=>St(e,t))}function Or(){return P({mutationFn:({projectId:e,webhookId:t})=>at(e,t),retry:!1})}function kr(e){let t=y();return P({mutationFn:t=>de(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:X.runs.all})})}function Q(e){let t=y();return P({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:Z.agentProfiles}),t.invalidateQueries({queryKey:Z.projects}),t.invalidateQueries({predicate:({queryKey:e})=>e[1]===`runner-skills`}),L(t)])}})}function Ar(){return Q(e=>Tt(e))}function jr(){return Q(e=>{let{id:t,...n}=e;return De(t,n)})}function Mr(){return Q(e=>c(e))}function Nr(){return Q(e=>tt(e))}function Pr(e,t){return A({queryKey:Z.agentAccountStatus(e),queryFn:({signal:t})=>ue(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function Fr(){let e=y();return P({mutationFn:({provider:e,profileId:t})=>We(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:Z.agentProfiles}),e.invalidateQueries({queryKey:Z.providerStatus}),L(e,n,`none`)])}})}function Ir(){let e=y();return P({mutationFn:e=>ue(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(Z.agentAccountStatus(n),t),e.invalidateQueries({queryKey:Z.agentProfiles}),L(e,t.status.provider)}})}function Lr(){let e=y();return P({mutationFn:e=>rt(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Z.projects})})}function Rr(){let e=y();return P({mutationFn:e=>Me(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Z.projects})})}function zr({enabled:e}){return A({queryKey:Z.githubOwners,queryFn:({signal:e})=>o({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function Br(){let e=y();(0,M.useEffect)(()=>{let t,n=()=>{let n=e.getQueryData(X.health);n&&(ee({bootProject:n.bootProject??`default`,apiBase:r()}),t??=Lt(`health`,t=>{e.setQueryData(X.health,t)}))};n();let i=e.getQueryCache().subscribe(n);return()=>{i(),t?.(),ye()}},[e])}function $(){return A({queryKey:X.health,queryFn:({signal:e})=>je({signal:e})})}function Vr(e,t){let n=$().data,r=vr(t).data?.projects,i=gt(),a=e??i.projectId,o=a??n?.bootProject,s=o===void 0?void 0:r?.find(e=>e.id===o);return s?.repoUrl?s.repoUrl:a===null||a===n?.bootProject?ar(n?.repo?.remote):void 0}function Hr(){return A({queryKey:X.openTargets,queryFn:({signal:e})=>dt({signal:e}),staleTime:5*6e4})}function Ur(){return A({queryKey:X.runs.list(),queryFn:({signal:e})=>Ot(F(),{signal:e})})}function Wr(e,t){return Ft({queryKey:X.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>me({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 Gr(e){let t=e.trim();return A({queryKey:Z.runsSearch(t),queryFn:({signal:e})=>Fe(t,{signal:e}),enabled:t.length>=2,placeholderData:At,staleTime:1e4})}function Kr(e=!0,t=bn,n){let r=Cn(y());return j(`/api/v1/workspace/runs-index`,Z.runsIndex,a(e?t:!1),wn),A({queryKey:Z.runsIndex,queryFn:({signal:e})=>_e({signal:e}).then(r.merge),enabled:e,...n?{select:n}:{},staleTime:3e4,refetchInterval:!1})}function qr(e){let t=y();return P({mutationFn:({workerId:e,discardWork:t=!1})=>qn(e,t),onSettled:()=>t.invalidateQueries({queryKey:X.runs.relationships(e)})})}function Jr(e,t={}){return A({queryKey:X.runs.relationships(e),queryFn:({signal:t})=>ge(e,{signal:t}),enabled:t.enabled??!0})}function Yr(e){return A({queryKey:X.runs.detail(e??``),queryFn:({signal:t})=>mt(I(e),{signal:t}),enabled:!!e})}function Xr(e,t,n=!0){return A({queryKey:[e??`default`,`runs`,`detail`,t??``],queryFn:({signal:n})=>mt(I(t,{projectId:e}),{signal:n}),enabled:n&&!!e&&!!t})}function Zr(e){return A({queryKey:X.runs.diff(e??``),queryFn:({signal:t})=>ke(e,{signal:t}),enabled:!!e})}function Qr(e,t=!1){return j(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/changes`:void 0,X.runs.changes(e??``),a(t?4e3:!1)),A({queryKey:X.runs.changes(e??``),queryFn:({signal:t})=>ot(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function $r(e,t){return A({queryKey:X.runs.file(e??``,t??``),queryFn:({signal:n})=>Et(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function ei(e,t){return A({queryKey:[n(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>ht(e,t,{signal:n}),enabled:t!==null,retry:!1})}function ti(e,t){return A({queryKey:[n(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>Nt(e,t,{signal:n}),enabled:t!==null,retry:!1})}function ni(e,t){return A({queryKey:[n(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>d(e,t,{signal:n}),enabled:t!==null,retry:!1})}function ri(e){return A({queryKey:[n(),`runs`,`artifacts`,e],queryFn:({signal:t})=>ve(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function ii(e,t=!1){return j(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/commits`:void 0,X.runs.commits(e??``),a(t?5e3:!1)),A({queryKey:X.runs.commits(e??``),queryFn:({signal:t})=>Ge(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function ai(e,t){return A({queryKey:X.runs.commit(e??``,t??``),queryFn:({signal:n})=>qe(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function oi(e,t=!0){return A({queryKey:X.runs.handoff(e??``),queryFn:({signal:t})=>Mt(I(e),{signal:t}),enabled:!!e&&t})}function si(e,t,n){return A({queryKey:e===void 0?X.runs.handoff(t):[e,`runs`,`handoff`,t],queryFn:({signal:n})=>Mt(I(t,{projectId:e}),{signal:n}),enabled:n,staleTime:15e3})}function ci(e,t){let r=[...new Set(e)],i=N({queries:r.map(e=>({queryKey:[e??n(),`automations`,`names`],queryFn:({signal:t})=>xe({signal:t,archived:`include`,...e===void 0?{}:{projectId:e}}),enabled:t,staleTime:6e4,retry:!1}))}),a=i.map(e=>e.data);return(0,M.useMemo)(()=>{let e=new Map;return a.forEach((t,n)=>{if(t?.available)for(let i of t.automations)e.set(JSON.stringify([r[n]??null,i.id]),i.name)}),(t,n)=>e.get(JSON.stringify([t??null,n]))},[JSON.stringify([r,i.map(e=>e.dataUpdatedAt)])])}function li(){return A({queryKey:X.workflows,queryFn:({signal:e})=>h({signal:e})})}function ui(){return A({queryKey:X.repo,queryFn:({signal:e})=>nt({signal:e})})}function di(e){return A({queryKey:[e,`repo`],queryFn:({signal:t})=>nt({signal:t},e)})}function fi(){return A({queryKey:X.repoBranches,queryFn:({signal:e})=>wt({signal:e})})}function pi(){return A({queryKey:X.repoChanges,queryFn:({signal:e})=>Le({signal:e}),retry:!1})}function mi(e){return A({queryKey:X.repoCommit(e??``),queryFn:({signal:t})=>Ue(e,{signal:t}),enabled:!!e,retry:!1})}function hi(){return A({queryKey:X.config,queryFn:({signal:e})=>oe({signal:e})})}function gi(){return A({queryKey:X.worktrees,queryFn:({signal:e})=>u({signal:e})})}function _i(e){return A({queryKey:[e,`worktrees`],queryFn:({signal:t})=>u({signal:t},e),staleTime:0})}function vi(e,t=!0,n=!1){return A({queryKey:[F({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>_({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:ce(e.sidebarLimits)},enabled:t})}function yi(){return vi(n())}function bi(){return A({queryKey:X.agentConfig,queryFn:({signal:e})=>v({signal:e})})}function xi(e){return A({queryKey:X.agentConfigFile(e??``),queryFn:({signal:t})=>ne(e,{signal:t}),enabled:e!==null})}function Si(e){let t=y(),n=X.agentConfig,r=X.agentConfigFile(e);return P({mutationFn:t=>te(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}function Ci(){return A({queryKey:Z.uiState,queryFn:({signal:e})=>$e({signal:e})})}function wi(){return A({queryKey:Z.config,queryFn:({signal:e})=>le({signal:e})})}function Ti(){return A({queryKey:Z.agentProfiles,queryFn:({signal:e})=>se({signal:e})})}function Ei(e){let t=y();return P({mutationFn:t=>f(e,t),onSuccess:()=>t.invalidateQueries({queryKey:X.runs.all})})}function Di(e){let t=H(),n=e?.projectId,r=e?.cacheScope,i=P({mutationFn:e=>pt(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),a=(0,M.useCallback)(e=>({...I(e,{projectId:n,cacheScope:r}),id:e}),[n,r]),o=(0,M.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:s,mutateAsync:c}=i,l=(0,M.useCallback)((e,t)=>s(a(e),o(t)),[s,a,o]),u=(0,M.useCallback)((e,t)=>c(a(e),o(t)),[c,a,o]);return{...i,variables:i.variables?.id,mutate:l,mutateAsync:u}}function Oi(){let e=H();return P({mutationFn:e=>pt(I(e),!1),onMutate:t=>e.patchRead(()=>I(t),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function ki(e){let t=H();return P({mutationFn:({id:t,pinned:n})=>be(I(t,e),n),onError:e=>Rt(`Could not update pin. ${e.message} Please retry.`,{tone:`danger`}),onMutate:()=>e??F(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function Ai(e,t){let n=H();return P({mutationFn:n=>Ct(I(e,{projectId:t}),n),onMutate:()=>F({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`send`,r),onError:(e,t,r)=>{e instanceof Je&&e.status===409&&r&&n.invalidateAfter(`send`,r)}})}function ji(e,t){let n=H();return P({mutationFn:(n={})=>Te(I(e,{projectId:t}),n),onMutate:()=>F({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`continue`,r)})}function Mi(e){let t=y();return P({mutationFn:({msgId:t,message:n})=>Qe(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:X.runs.all})})}function Ni(e){let t=y();return P({mutationFn:t=>ct(e,t),onSuccess:()=>t.invalidateQueries({queryKey:X.runs.all})})}function Pi(e={},t=!0){let r=y(),i=X.github(e);j(`/api/v1/p/${n()}/github${e.limit===void 0?``:`?limit=${e.limit}`}`,i,a(t?6e4:!1));let o=A({queryKey:X.github(e),queryFn:({signal:t})=>ae({limit:e.limit},{signal:t}),enabled:t,staleTime:6e4,refetchInterval:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0}),s=o.data?.projectsGeneration,c=A({queryKey:[...i,`projects`,s],queryFn:({signal:e})=>lt(s,{signal:e}),enabled:t&&o.data?.projectsState===`refreshing`&&!!s,staleTime:1/0,retry:!1});return(0,M.useEffect)(()=>{!s||!c.data&&!c.error||r.setQueryData(i,e=>{if(!e||e.projectsGeneration!==s||e.projectsState!==`refreshing`)return e;let t=c.data;return t?.generation&&t.generation!==s?e:t?.state===`ready`?{...e,projectsState:`ready`,projects:t.projects,issues:e.issues.map(e=>({...e,projectIds:t.membership?.[e.number]??[]}))}:{...e,projectsState:`unavailable`,projectsReason:t?.reason??`Project boards unavailable. Refresh to try again.`}})},[r,s,c.data,c.error,i]),o}var Fi=class extends Error{};function Ii(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await ae({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new Fi(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>lr(e),retry:(e,t)=>!(t instanceof Fi)&&!(t instanceof Je&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function Li(e=50,t=!0){let r=y(),i=X.githubPages(e),o=X.githubPagesHead(e);j(`/api/v1/p/${n()}/github?limit=${e}`,o,a(t?6e4:!1));let s=Ft({...Ii(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),c=A({queryKey:o,queryFn:({signal:t})=>ae({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:l}=s;(0,M.useEffect)(()=>{if(!c.data)return;let e=r.getQueryData(i);if(!e||e.pages.length===0)return;let t=pr(e.pages,c.data);t===`refetch`?l():r.setQueryData(i,{...e,pages:t})},[r,c.dataUpdatedAt,l]);let u=(s.data?.pages??[]).flatMap(e=>e.projectsState===`refreshing`&&e.projectsGeneration?[e.projectsGeneration]:[]),d=N({queries:u.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>lt(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,M.useEffect)(()=>{d.forEach((e,t)=>{let n=u[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,d.map((e,t)=>e.data||e.error?u[t]:``).join(`,`)]),{pages:s,data:(0,M.useMemo)(()=>fr(s.data?.pages??[]),[s.data])}}function Ri(e,t=50,n=!0){let r=Ft({...Ii([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,M.useMemo)(()=>fr(r.data?.pages??[]),[r.data])}}function zi(e,t,n=!0){let r=N({queries:t.filter(e=>e.length>0).map(t=>({queryKey:X.githubCommentCounts(e,t),queryFn:({signal:n})=>Se(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,M.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 Bi(e,t,n,r=!0){return A({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>Ze(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function Vi(e,t=!0){return A({queryKey:X.githubChecks(e),queryFn:({signal:t})=>Ce(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function Hi(e,t,n=!0){return A({queryKey:X.githubSearch(e,t),queryFn:({signal:n})=>Ze(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var Ui=100;function Wi(e){return[...e].sort((e,t)=>t-e).slice(0,Ui).sort((e,t)=>e-t)}function Gi(){let e=gt(),t=$();return e.projectId??t.data?.bootProject}function Ki(e){for(let[t,n]of Object.entries(e)){for(let[e,r]of Object.entries(n.prs))In(q({projectId:t,kind:`PR`,number:Number(e)}),r);for(let[e,r]of Object.entries(n.issues))In(q({projectId:t,kind:`Issue`,number:Number(e)}),r)}}var qi=5*6e4;function Ji(e){return e?e.recheckAfterMs:qi}function Yi(e,t=!0){let n=(0,M.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.projectId)??{prs:new Set,issues:new Set};e[n.kind===`PR`?`prs`:`issues`].add(n.number),t.set(n.projectId,e)}return[...t.entries()].map(([e,t])=>({projectId:e,prs:Wi(t.prs),issues:Wi(t.issues)}))},[e.map(q).sort().join(`|`)]),r=N({queries:n.map(e=>({queryKey:X.githubRefStatus(e.projectId,e.prs,e.issues),queryFn:({signal:t})=>vt(e.projectId,{prs:e.prs,issues:e.issues},{signal:t}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>Ji(e.state.data)??1/0,refetchInterval:!1,refetchOnWindowFocus:!0}))}),a=y(),o=JSON.stringify(n.map((e,t)=>({...e,interval:Ji(r[t]?.data)??!1})));(0,M.useEffect)(()=>{if(!t||i())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=X.githubRefStatus(t.projectId,t.prs,t.issues);return It({path:`/api/v1/p/${t.projectId}/github/ref-status?${n}`,intervalMs:t.interval},(t,n)=>{n||a.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&a.setQueryData(r,t)})})});return()=>{e=!1;for(let e of n)e()}},[t,o,a]);let s=(0,M.useMemo)(()=>Kn(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,M.useCallback)(e=>{let t=q(e),n=s.get(t);if(n)return n;let r=G.get(t);return{state:`idle`,...r?{status:r}:{},...K.has(t)?{conflicting:!0}:{}}},[s])}function Xi(e,t,n=!0){return A({queryKey:X.githubComments(e,t),queryFn:({signal:n})=>we(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Zi(e,t,n=!0){return A({queryKey:X.githubItem(e,t),queryFn:({signal:n})=>fe(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Qi(e){return A({queryKey:X.githubPrChanges(e??0),queryFn:({signal:t})=>Be(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{gr as $,Qi as A,wi as At,Ri as B,Mn as Bt,Pi as C,si as Ct,Zi as D,Sr as Dt,Xi as E,jr as Et,Oi as F,ur as Ft,vi as G,Kt as Gt,di as H,H as Ht,kr as I,or as It,hr as J,I as Jt,_i as K,Gt as Kt,Hr as L,sr as Lt,$ as M,gi as Mt,Br as N,Z as Nt,zr as O,Er as Ot,Di as P,mr as Pt,Yi as Q,Ei as R,ar as Rt,yr as S,Ai as St,zi as T,yi as Tt,Vr as U,L as Ut,Bi as V,Cn as Vt,Xr as W,Jt as Wt,Ir as X,N as Xt,Si as Y,P as Yt,Gi as Z,zt as Zt,Rr as _,Jr as _t,xi as a,ui as at,Mi as b,Gr as bt,ti as c,mi as ct,ci as d,Qr as dt,br as et,Lr as f,ai as ft,Ar as g,oi as gt,ji as h,$r as ht,bi as i,Ni as it,Hi as j,Ci as jt,Li as k,li as kt,ni as l,_r as lt,Fr as m,Zr as mt,Ki as n,xr as nt,Ti as o,fi as ot,hi as p,ii as pt,vr as q,F as qt,Pr as r,Dr as rt,Wr as s,pi as st,X as t,Mr as tt,ri as u,Yr as ut,Tr as v,Ur as vt,Vi as w,Or as wt,ei as x,Nr as xt,qr as y,Kr as yt,ki as z,An as zt};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{c as n,o as r}from"./utils-DSMR_WLb.js";import{n as i,t as a}from"./live-refetch-CZb2VOyu.js";import{$ as o,$r as s,$t as c,Ai as l,At as u,B as d,Bt as f,Ct as p,Di as m,Dt as h,Ei as g,Et as _,F as v,Fr as ee,Gt as te,I as ne,In as re,Ir as ie,J as ae,K as oe,L as se,Nr as ce,Ot as le,P as ue,Pt as de,Q as fe,Qt as pe,R as me,Si as he,St as ge,Tt as _e,V as ve,Vr as ye,Vt as be,W as xe,X as Se,Y as Ce,Z as we,_ as Te,_i as Ee,_n as De,_r as Oe,_t as ke,ai as Ae,at as je,b as Me,bn as Ne,c as Pe,ci as y,cn as Fe,ct as Ie,dt as Le,ei as Re,en as ze,et as Be,f as Ve,fr as He,ft as Ue,g as We,gt as Ge,hn as Ke,ht as qe,i as Je,ii as Ye,in as Xe,it as Ze,j as Qe,kt as $e,li as et,ln as tt,lt as nt,m as rt,mi as it,mn as at,mt as ot,ni as st,nn as ct,nt as lt,oi as ut,ot as dt,pi as ft,pn as pt,pt as mt,q as ht,r as gt,ri as _t,rt as vt,sn as yt,st as bt,ti as xt,tn as St,un as Ct,ut as wt,v as Tt,vt as Et,wi as Dt,wt as Ot,x as kt,yi as At,yn as jt,yt as Mt,z as Nt}from"./project-scope-context-D1bpJixc.js";import{B as b,H as x,L as S,M as C,N as w,O as Pt,P as T,R as E,Y as D,j as O,k}from"./live-protocol-D9ji1YCl.js";import{t as Ft}from"./useInfiniteQuery-qJeCNhM7.js";import{t as A}from"./useQuery-C3CQhXsT.js";import{n as It,r as j,t as Lt}from"./ws-BisMp6U5.js";import{n as Rt}from"./toaster-Bo5vCbz-.js";var zt=class extends ft{#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||Bt(),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=it({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),D.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Bt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Vt=class extends l{#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),g(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&Ee(t.mutationKey)!==Ee(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??Bt();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){D.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 Ht(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Ut(e,t,n){let r=e.slice(0);return r[t]=n,r}var Wt=class extends l{#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,D.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||!g(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Ht(e,n).forEach(e=>{e.destroy()}),Ht(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=Dt(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 et(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Ut(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)&&D.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},M=e(t(),1);function N({queries:e,...t},n){let r=y(n),i=ut(),a=Ae(),o=M.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{s(e);let t=r.getQueryCache().get(e.queryHash);st(e,a,t)}),Ye(a);let[c]=M.useState(()=>new Wt(r,o,t)),[l,u,d]=c.getOptimisticResult(o,t.combine),f=!i&&t.subscribed!==!1;M.useSyncExternalStore(M.useCallback(e=>f?c.subscribe(D.batchCalls(e)):he,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),M.useEffect(()=>{c.setQueries(o,t)},[o,t,c]);let p=l.some((e,t)=>xt(o[t],e))?l.flatMap((e,t)=>{let n=o[t];return n&&xt(n,e)?Re(n,new et(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=l.find((e,t)=>{let n=o[t];return n&&_t({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m?.error)throw m.error;return u(d())}function P(e,t){let n=y(t),[r]=M.useState(()=>new Vt(n,e));M.useEffect(()=>{r.setOptions(e)},[r,e]);let i=M.useSyncExternalStore(M.useCallback(e=>r.subscribe(D.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=M.useCallback((e,t)=>{r.mutate(e,t).catch(he)},[r]);if(i.error&&m(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function F(e={}){let t=e.projectId??n();return{projectId:t,cacheScope:e.cacheScope??(e.boot?`default`:t)}}function I(e,t={}){return{...F(t),runId:e}}function Gt(e,t=!0,n=!1,r){return A({queryKey:[F({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>Ot(F({projectId:e,boot:n}),{signal:t}),enabled:t,...r?{select:r}:{},placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function L(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:Z.models(t),refetchType:n})}function Kt(e,t=!0,n){return A({...qt(e,n),enabled:t})}var qt=(e,t)=>({queryKey:Z.models(e,t),queryFn:({signal:n})=>re(e,{signal:n},t),staleTime:300*1e3});function Jt(e,t=!0){let n=N({queries:e.map(e=>({...qt(e),enabled:t}))});return Object.fromEntries(e.map((e,t)=>[e,n[t]]))}var R=[`workspace`,`runs-index`],z=e=>[e.cacheScope,`runs`,`list`],B=e=>[e.cacheScope,`runs`,`detail`,e.runId],V=e=>typeof e==`function`?e():e;function Yt(e){let{seenAt:t,...n}=e;return n}function Xt(e,t){let n=Yt(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function Zt(e,t,n){return t?{...e,seenAt:n}:Yt(e)}function Qt(e){let t=()=>{e.invalidateQueries({queryKey:R})};function r(r,i){if(r===`index`)return t();let a=typeof i==`function`?i():i;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=ie(),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)}async function i(n,r){await e.cancelQueries({queryKey:z(V(n))}),await e.cancelQueries({queryKey:B(V(n))});let i=e.getQueryData(z(V(n))),a=e.getQueryData(B(V(n))),o=V(n).runId,s=new Date().toISOString();return e.setQueryData(z(V(n)),e=>e?.map(e=>e.id===o?Zt(e,r,s):e)),e.setQueryData(B(V(n)),e=>e&&Zt(e,r,s)),{id:o,prevList:i,prevDetail:a,rollback(){if(!r){i&&e.setQueryData(z(V(n)),i),a&&e.setQueryData(B(V(n)),a);return}let t=i?.find(e=>e.id===o);t&&e.setQueryData(z(V(n)),e=>e?.map(e=>e.id===o?Xt(e,t):e)),a&&e.setQueryData(B(V(n)),e=>e&&Xt(e,a))},settle(i){let a=e=>e.id===(r?o:i.id)?Zt(e,r,i.seenAt):e;e.setQueryData(z(V(n)),e=>e?.map(a));let s={...V(n),runId:r?o:i.id};e.setQueryData(B(s),e=>e?a(e):i),t()}}}async function a(t,n){await e.cancelQueries({queryKey:R});let i=e.getQueryData(R),a=n();return e.setQueryData(R,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(R,i)},settle(){r(`indexed`,t)}}}return{patchRead:i,patchIndex:a,invalidateAfter:r}}function H(){let e=y();return(0,M.useMemo)(()=>Qt(e),[e])}function $t(e,t){return JSON.stringify([e,t])}function en(e){return e.type===`run`?e.run.id:e.id}function U(e,t){return{...e,runs:t}}function tn(e,t){let n=0;for(let r of e)r.projectId===t&&r.archived&&(n+=1);return n}var nn=class{runs;copied=!1;positions=new Map;constructor(e){this.runs=e,this.reindex()}reindex(){this.positions.clear(),this.runs.forEach((e,t)=>this.positions.set($t(e.projectId,e.id),t))}at(e,t){return this.positions.get($t(e,t))??-1}mutable(){return this.copied||=(this.runs=[...this.runs],!0),this.runs}replace(e,t){return this.mutable()[e]=t,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}};function rn(e,t,n){let r=new nn(e.runs),i=e,a=!1;for(let e of t)if(e.type===`usage`)i=un(i,e.project,e.usage,r);else{let t=sn(i,e.change,n,r);i=t.index,a||=t.reconcile}return{index:i,reconcile:a}}function an(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function on(e,t,n){return sn(e,t,n,new nn(e.runs))}function sn(e,t,n,r){let{project:i}=t,a=r.at(i,en(t)),o=a>=0?e.runs[a]:void 0,s=e.truncated.includes(i);if(t.type===`deleted`)return o?{index:U(e,r.remove(a)),reconcile:s&&o.archived}:{index:e,reconcile:!1};let{run:c}=t;if(c.delegation?.role===`worker`)return o?{index:U(e,r.remove(a)),reconcile:!1}:{index:e,reconcile:!1};if(!o&&!an(e,i,n))return{index:e,reconcile:!0};let l=Dt(o,{projectId:i,...c});if(o){if(l===o)return{index:e,reconcile:!1};let t=r.replace(a,l),n=o.archived!==l.archived&&(s||tn(t,i)>e.perProjectLimit);return{index:U(e,t),reconcile:n}}if(s)return ln(e,l,r);let u=r.insert(l);return{index:U(e,u),reconcile:l.archived&&tn(u,i)>e.perProjectLimit}}function cn(e,t){let n;for(let r of e)r.projectId===t&&r.archived&&(n===void 0||r.createdAt<n)&&(n=r.createdAt);return n}function ln(e,t,n){let r=cn(e.runs,t.projectId),i=r!==void 0&&t.createdAt>r;return t.archived&&!i?{index:e,reconcile:!1}:{index:U(e,n.insert(t)),reconcile:t.archived||r===void 0||t.createdAt<r}}function un(e,t,n,r){let i=!1;return e.runs.forEach((e,a)=>{if(e.projectId!==t)return;let o=n[e.id];if(o){let t=Dt(e.usage,o);if(t===e.usage)return;r.replace(a,{...e,usage:t})}else{if(e.usage===void 0)return;let{usage:t,...n}=e;r.replace(a,n)}i=!0}),i?U(e,r.runs):e}function dn(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 fn(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function pn(e,t,n){if(e.lastStream===t)e.floor=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 mn(e){e.stream=void 0}function hn(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=JSON.stringify([r,t.project,en(t)]),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}function gn(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function _n(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function vn(e,t,n){if(!_n(t))return{index:t,reconcile:!1};let{generation:r,eventSeq:i}=t;if(e.stream!==void 0&&e.stream!==r){let n=e.mismatch!==r;return e.mismatch=r,{index:t,reconcile:n}}let a=e.lastStream===r&&e.floor!==void 0,o=a&&i<e.floor,s=t,c=o,l=[...e.changes.entries()].filter(([,e])=>e.generation===r),u=l.map(([,e])=>e).filter(e=>e.seq>i).sort((e,t)=>e.seq-t.seq);for(let e of u){let t=on(s,e,n);s=t.index,c||=t.reconcile}for(let[t,n]of l)n.seq<=i&&e.changes.delete(t);return a&&!o&&(e.floor=i),{index:s,reconcile:c}}var W=[`workspace`,`runs-index`],yn=[`workspace`,`projects`],bn=6e4,xn=100,Sn=new WeakMap;function Cn(e){let t=Sn.get(e);return t||(t=On(e),Sn.set(e,t)),t}function wn(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:Cn(t).merge(e)}function Tn(e){let t=e.getQueryData(yn)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function En(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 Dn(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 On(e){let t=fn(),n=[],r,i,a,o,s=!1,c=-1/0,l=new Set,u=!1,d,f=!1,p=()=>{if(!u){if(u=!0,d?.()){f=!0;return}_({hold:!0})}},m=t=>{c=Date.now(),e.setQueryData(W,t)},h=()=>e.getQueryData(W),g=()=>{clearTimeout(a),a=void 0;let t=e.getQueryCache().find({queryKey:W,exact:!0}),n=(t!==void 0&&t.state.data===void 0&&t.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:W,exact:!0}).then(()=>e.invalidateQueries({queryKey:W})):e.invalidateQueries({queryKey:W})).catch(()=>void 0).finally(()=>{o===n&&(o=void 0,s&&(s=!1,g()))});return o=n,n},_=(e={})=>o?(s=!0,o):e.hold?(a??=setTimeout(()=>{g()},400),Promise.resolve()):g(),v=()=>{r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0;let t=n;n=[];let a=h();if(!a||t.length===0)return;let o=Tn(e),{index:s,reconcile:c}=rn(a,t.filter(e=>e.generation===a.generation?e.type===`usage`?!l.has(e.project):!l.has(e.change.project)&&e.change.seq>a.eventSeq:!1),o);s!==a&&m(s),c&&_({hold:!0})},ee=()=>{if(i!==void 0)return;let e=c+250-Date.now();if(e>0){i=setTimeout(v,e);return}i=setTimeout(v,xn),typeof requestAnimationFrame==`function`&&(r=requestAnimationFrame(v))};return{ready(e,n){pn(t,e,n),u=!1,f&&(f=!1,_({hold:!0}))},detach(){mn(t)},run(e,r,i=!1){if(l.has(e))return;let a=Dn(e,r);if(!hn(t,a,i)){p();return}n.push({type:`change`,change:a,generation:t.stream}),ee()},usage(e,r){if(!l.has(e)){if(t.stream===void 0){p();return}n.push({type:`usage`,project:e,usage:r,generation:t.stream}),ee()}},dropProject(e){l.add(e),gn(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let r=h();if(!r)return;let i=dn(r,e);i!==r&&m(i)},setUnknownGenerationHandler(e){d=e},restoreProject(e){l.delete(e)},merge(n){let r=h(),i=vn(t,n,Tn(e));for(let e of l)i.index=dn(i.index,e);return i.reconcile&&queueMicrotask(()=>{_({hold:!0})}),En(r,n,t.stream)??i.index},reconcile:_,flush:v,stop(){r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0,clearTimeout(a),a=void 0,n=[],s=!1}}}var kn={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`}},An={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function jn(e){return typeof e==`string`&&Object.hasOwn(kn,e)}function Mn(e){return e!==void 0&&jn(e)?kn[e]:void 0}var Nn=`cez.reference-statuses.v1`,Pn=`cez.reference-conflicts.v1`,G=new Map(Rn()),Fn=1e3;function In(e,t){if(G.get(e)!==t){for(G.delete(e),G.set(e,t);G.size>Fn;){let e=G.keys().next().value;if(e===void 0)break;G.delete(e)}Vn()}}var K=new Set(zn());function Ln(e,t){if(K.has(e)!==t){if(t)for(K.add(e);K.size>Fn;){let e=K.values().next().value;if(e===void 0)break;K.delete(e)}else K.delete(e);Vn()}}function Rn(){try{let e=globalThis.sessionStorage?.getItem(Nn);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`&&jn(e[1])):[]}catch{return[]}}function zn(){try{let e=globalThis.sessionStorage?.getItem(Pn);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var Bn;function Vn(){Bn===void 0&&(Bn=setTimeout(()=>{Bn=void 0;try{globalThis.sessionStorage?.setItem(Nn,JSON.stringify([...G])),globalThis.sessionStorage?.setItem(Pn,JSON.stringify([...K]))}catch{}},250))}var q=e=>`${e.projectId}\u0000${e.kind}#${e.number}`;function Hn(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function Un(e){return[...e.prs.map(t=>({projectId:e.projectId,kind:`PR`,number:t})),...e.issues.map(t=>({projectId:e.projectId,kind:`Issue`,number:t}))]}function Wn(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;In(t,o),s!==void 0&&Ln(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function Gn(e,t,n){let r=q(t),i=G.get(r),a=K.has(r)?!0:void 0,o=n.data;if(o?.available){Wn(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...Hn(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...Hn(i,a)});return}e.set(r,{state:`loading`,...Hn(i,a)})}function Kn(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of Un(i))Gn(n,e,t)}),n}async function qn(e,t=!1){return Ke(await Ve.api.v1.p[`:projectId`].runs[`:id`][`worker-destroy`].$post({param:{projectId:n(),id:encodeURIComponent(e)},query:{},json:t?{discardWork:!0}:{}}),yt(e,`/worker-destroy`))}var Jn=k([`passing`,`failing`,`pending`]).nullable(),J=E({kind:k([`issue`,`pr`]),number:S(),title:x(),author:x(),createdAt:x(),labels:O(x()),body:x().optional(),url:x(),comments:S(),assignees:O(x()).optional(),projectIds:O(x()).optional(),isDraft:C().optional(),additions:S().optional(),deletions:S().optional(),checks:Jn.optional()});w(`available`,[E({available:T(!0),item:J.nullable(),labelColors:b(x(),x()).optional()}),E({available:T(!1),reason:x()})]),E({kind:k([`issue`,`pr`]),number:Pt().int().positive().safe()});var Yn=E({id:x(),title:x(),url:x()});E({available:C(),reason:x().optional(),repo:x().optional(),syncedAt:x().optional(),issues:O(J),prs:O(J),labelColors:b(x(),x()).optional(),viewerLogin:x().optional(),projects:O(Yn).optional(),projectsReason:x().optional(),projectsState:k([`refreshing`,`ready`,`unavailable`]).optional(),projectsGeneration:x().optional(),issuesTotal:S().int().nonnegative().optional(),prsTotal:S().int().nonnegative().optional(),issuesNextCursor:x().nullable().optional(),prsNextCursor:x().nullable().optional(),commentsDeferred:T(!0).optional()});var Xn=x().min(1).max(2e3).optional();E({limit:x().optional(),refresh:x().optional(),issuesCursor:Xn,prsCursor:Xn,issuesDone:T(`1`).optional(),prsDone:T(`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`})}),E({kind:k([`issue`,`pr`]),numbers:x().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:T(`1`).optional()}),w(`available`,[E({available:T(!0),counts:b(S(),S().int().nonnegative())}),E({available:T(!1),reason:x()})]),w(`available`,[E({available:T(!0),checks:b(S(),Jn)}),E({available:T(!1),reason:x()})]),E({kind:k([`issue`,`pr`]),q:x().trim().min(1).max(256),limit:Pt().int().positive().max(50).optional()}),E({available:C(),projectsReason:x().optional(),reason:x().optional(),items:O(J),truncated:C().optional(),labelColors:b(x(),x()).optional()});var Zn=S().nullable();w(`available`,[E({available:T(!0),prs:b(S(),He),issues:b(S(),He),conflicts:O(S()).optional(),recheckAfterMs:Zn}),E({available:T(!1),reason:x(),recheckAfterMs:Zn})]);var Qn=E({id:S(),author:x(),avatarUrl:x().optional(),createdAt:x(),body:x(),kind:k([`comment`,`review`]),reviewState:k([`approved`,`changes_requested`,`commented`,`dismissed`]).optional(),url:x()}),$n=k([`committed`,`labeled`,`unlabeled`,`assigned`,`unassigned`,`merged`,`closed`,`reopened`,`head_ref_force_pushed`,`cross-referenced`,`renamed`]),er=E({id:x(),kind:$n,actor:x(),avatarUrl:x().optional(),createdAt:x(),url:x().optional(),sha:x().optional(),message:x().optional(),checks:Jn.optional(),label:E({name:x(),color:x().optional()}).optional(),subject:x().optional(),refNumber:S().optional(),refTitle:x().optional(),refIsPr:C().optional()});E({available:C(),reason:x().optional(),comments:O(Qn),truncated:C().optional(),events:O(er).optional(),detail:E({body:x(),additions:S().int().nonnegative().optional(),deletions:S().int().nonnegative().optional()}).optional()});var tr=k([`merge`,`squash`,`rebase`]),nr=E({name:x(),state:k([`passing`,`failing`,`pending`,`unknown`]),required:C().nullable(),url:x().optional()}),rr=E({number:S(),title:x(),url:x(),state:k([`open`,`closed`,`merged`]),isDraft:C(),headRef:x(),baseRef:x(),headSha:x(),mergeable:k([`mergeable`,`conflicting`,`unknown`]),reviewDecision:k([`approved`,`changes-requested`,`review-required`,`not-required`,`unknown`]),checks:O(nr),methods:O(tr),defaultMethod:tr.nullable(),eligibility:k([`ready`,`blocked`,`pending`,`unauthorized`,`terminal`,`unknown`]),blockers:O(E({code:x(),message:x()})),canMerge:C(),canOverride:C()});w(`available`,[E({available:T(!0),mergeState:rr}),E({available:T(!1),reason:x()})]),E({merged:T(!0),number:S(),url:x(),method:tr,mergeCommitSha:x().optional()});var ir=E({path:x(),previousPath:x().optional(),status:k([`added`,`modified`,`removed`,`renamed`,`copied`,`changed`]),additions:S(),deletions:S(),patch:x().optional(),patchUnavailableReason:k([`binary`,`too-large`,`not-provided`]).optional(),truncated:C().optional()});w(`available`,[E({available:T(!0),number:S(),headSha:x(),files:O(ir),additions:S(),deletions:S(),truncated:C(),reason:x().optional()}),E({available:T(!1),reason:x()})]),E({generation:x().uuid()}),w(`state`,[E({generation:x().uuid(),state:T(`ready`),projects:O(Yn),membership:b(x(),O(x()))}),E({generation:x().uuid(),state:T(`unavailable`),reason:x()})]);function ar(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 or(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 sr(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 cr(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 lr(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 ur(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function dr(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function fr(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){dr(t.issues,a,r),dr(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:p,...m}=t;return{...m,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 Y=e=>e.map(e=>e.number).join(`,`);function pr(e,t){let n=e[0];if(e.length>1&&n&&(Y(n.issues)!==Y(t.issues)||Y(n.prs)!==Y(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)]}function mr(e,t,r=!0){let i=hi(),a=$(),o=e??i.data?.defaultRunner??`claude`,s=a.data?.capabilities?.localHandoff===!1?null:t,c=n(),l=A({queryKey:X.runnerSkills(o,s),queryFn:({signal:e})=>p(o,s,{signal:e,projectId:c}),enabled:r&&(e!==void 0||!i.isPending)&&(!t||!a.isPending),retry:!1});return{...l,runner:o,account:s,data:l.data?.skills,list:l.data,unchecked:l.isError||!l.data||l.data.source===`unavailable`}}var X={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)=>[n(),`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 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)=>[e,`github`,`ref-status`,[...t].sort((e,t)=>e-t).join(`,`),[...n].sort((e,t)=>e-t).join(`,`)],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`]}},Z={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:W,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)=>[...Z.fsBrowseRoot,e,t]};function hr(){let e=y();return A({queryKey:Z.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(Z.providerStatus),r=await Ie(!1,{signal:t});return Oe(n,e.getQueryData(Z.providerStatus),r)},staleTime:5*6e4,refetchInterval:a(!1),refetchOnWindowFocus:!0})}function gr(){let e=y();return P({mutationFn:()=>Ie(!0),onMutate:()=>e.getQueryData(Z.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Z.providerStatus,e=>Oe(r,e,t)),L(e)}})}function _r(){let e=y();return P({mutationFn:({provider:e,authFailureId:t})=>Xe(e,t),onMutate:()=>e.getQueryData(Z.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Z.providerStatus,e=>Oe(r,e,t,n.authFailureId)),L(e,n.provider)}})}function vr(e={}){return A({queryKey:Z.projects,queryFn:({signal:e})=>bt({signal:e}),...e})}function yr(e,t=!1){return A({queryKey:Z.fsBrowse(e,t),queryFn:({signal:n})=>Pe(e??void 0,{signal:n,showHidden:t}),retry:!1})}function br(){let e=y();return P({mutationFn:e=>pe(e),onSuccess:()=>e.invalidateQueries({queryKey:Z.projects})})}function xr(){let e=y();return P({mutationFn:e=>ze(e),retry:!1,onSuccess:()=>{e.invalidateQueries({queryKey:Z.projects})}})}function Sr(){let e=y();return P({mutationFn:e=>{let{id:t,...n}=e;return jt(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:Z.projects});let r=e.getQueryData(Z.projects);return e.setQueryData(Z.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?Cr(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(Z.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(Z.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:Z.projects})})}function Cr(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?[]:cr(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 wr(e){let t=y();return P({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(Z.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:Z.projects})})}function Tr(){return wr(e=>{let{projectId:t,...n}=e;return kt(t,n)})}function Er(){return wr(e=>{let{projectId:t,webhookId:n,...r}=e;return Ne(t,n,r)})}function Dr(){return wr(({projectId:e,webhookId:t})=>St(e,t))}function Or(){return P({mutationFn:({projectId:e,webhookId:t})=>at(e,t),retry:!1})}function kr(e){let t=y();return P({mutationFn:t=>de(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:X.runs.all})})}function Q(e){let t=y();return P({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:Z.agentProfiles}),t.invalidateQueries({queryKey:Z.projects}),t.invalidateQueries({predicate:({queryKey:e})=>e[1]===`runner-skills`}),L(t)])}})}function Ar(){return Q(e=>Tt(e))}function jr(){return Q(e=>{let{id:t,...n}=e;return De(t,n)})}function Mr(){return Q(e=>c(e))}function Nr(){return Q(e=>tt(e))}function Pr(e,t){return A({queryKey:Z.agentAccountStatus(e),queryFn:({signal:t})=>ue(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function Fr(){let e=y();return P({mutationFn:({provider:e,profileId:t})=>We(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:Z.agentProfiles}),e.invalidateQueries({queryKey:Z.providerStatus}),L(e,n,`none`)])}})}function Ir(){let e=y();return P({mutationFn:e=>ue(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(Z.agentAccountStatus(n),t),e.invalidateQueries({queryKey:Z.agentProfiles}),L(e,t.status.provider)}})}function Lr(){let e=y();return P({mutationFn:e=>rt(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Z.projects})})}function Rr(){let e=y();return P({mutationFn:e=>Me(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Z.projects})})}function zr({enabled:e}){return A({queryKey:Z.githubOwners,queryFn:({signal:e})=>o({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function Br(){let e=y();(0,M.useEffect)(()=>{let t,n=()=>{let n=e.getQueryData(X.health);n&&(ee({bootProject:n.bootProject??`default`,apiBase:r()}),t??=Lt(`health`,t=>{e.setQueryData(X.health,t)}))};n();let i=e.getQueryCache().subscribe(n);return()=>{i(),t?.(),ye()}},[e])}function $(){return A({queryKey:X.health,queryFn:({signal:e})=>je({signal:e})})}function Vr(e,t){let n=$().data,r=vr(t).data?.projects,i=gt(),a=e??i.projectId,o=a??n?.bootProject,s=o===void 0?void 0:r?.find(e=>e.id===o);return s?.repoUrl?s.repoUrl:a===null||a===n?.bootProject?ar(n?.repo?.remote):void 0}function Hr(){return A({queryKey:X.openTargets,queryFn:({signal:e})=>dt({signal:e}),staleTime:5*6e4})}function Ur(){return A({queryKey:X.runs.list(),queryFn:({signal:e})=>Ot(F(),{signal:e})})}function Wr(e,t){return Ft({queryKey:X.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>me({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 Gr(e){let t=e.trim();return A({queryKey:Z.runsSearch(t),queryFn:({signal:e})=>Fe(t,{signal:e}),enabled:t.length>=2,placeholderData:At,staleTime:1e4})}function Kr(e=!0,t=bn,n){let r=Cn(y());return j(`/api/v1/workspace/runs-index`,Z.runsIndex,a(e?t:!1),wn),A({queryKey:Z.runsIndex,queryFn:({signal:e})=>_e({signal:e}).then(r.merge),enabled:e,...n?{select:n}:{},staleTime:3e4,refetchInterval:!1})}function qr(e){let t=y();return P({mutationFn:({workerId:e,discardWork:t=!1})=>qn(e,t),onSettled:()=>t.invalidateQueries({queryKey:X.runs.relationships(e)})})}function Jr(e,t={}){return A({queryKey:X.runs.relationships(e),queryFn:({signal:t})=>ge(e,{signal:t}),enabled:t.enabled??!0})}function Yr(e){return A({queryKey:X.runs.detail(e??``),queryFn:({signal:t})=>mt(I(e),{signal:t}),enabled:!!e})}function Xr(e,t,n=!0){return A({queryKey:[e??`default`,`runs`,`detail`,t??``],queryFn:({signal:n})=>mt(I(t,{projectId:e}),{signal:n}),enabled:n&&!!e&&!!t})}function Zr(e){return A({queryKey:X.runs.diff(e??``),queryFn:({signal:t})=>ke(e,{signal:t}),enabled:!!e})}function Qr(e,t=!1){return j(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/changes`:void 0,X.runs.changes(e??``),a(t?4e3:!1)),A({queryKey:X.runs.changes(e??``),queryFn:({signal:t})=>ot(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function $r(e,t){return A({queryKey:X.runs.file(e??``,t??``),queryFn:({signal:n})=>Et(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function ei(e,t){return A({queryKey:[n(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>ht(e,t,{signal:n}),enabled:t!==null,retry:!1})}function ti(e,t){return A({queryKey:[n(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>Nt(e,t,{signal:n}),enabled:t!==null,retry:!1})}function ni(e,t){return A({queryKey:[n(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>d(e,t,{signal:n}),enabled:t!==null,retry:!1})}function ri(e){return A({queryKey:[n(),`runs`,`artifacts`,e],queryFn:({signal:t})=>ve(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function ii(e,t=!1){return j(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/commits`:void 0,X.runs.commits(e??``),a(t?5e3:!1)),A({queryKey:X.runs.commits(e??``),queryFn:({signal:t})=>Ge(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function ai(e,t){return A({queryKey:X.runs.commit(e??``,t??``),queryFn:({signal:n})=>qe(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function oi(e,t=!0){return A({queryKey:X.runs.handoff(e??``),queryFn:({signal:t})=>Mt(I(e),{signal:t}),enabled:!!e&&t})}function si(e,t,n){return A({queryKey:e===void 0?X.runs.handoff(t):[e,`runs`,`handoff`,t],queryFn:({signal:n})=>Mt(I(t,{projectId:e}),{signal:n}),enabled:n,staleTime:15e3})}function ci(e,t){let r=[...new Set(e)],i=N({queries:r.map(e=>({queryKey:[e??n(),`automations`,`names`],queryFn:({signal:t})=>xe({signal:t,archived:`include`,...e===void 0?{}:{projectId:e}}),enabled:t,staleTime:6e4,retry:!1}))}),a=i.map(e=>e.data);return(0,M.useMemo)(()=>{let e=new Map;return a.forEach((t,n)=>{if(t?.available)for(let i of t.automations)e.set(JSON.stringify([r[n]??null,i.id]),i.name)}),(t,n)=>e.get(JSON.stringify([t??null,n]))},[JSON.stringify([r,i.map(e=>e.dataUpdatedAt)])])}function li(){return A({queryKey:X.workflows,queryFn:({signal:e})=>h({signal:e})})}function ui(){return A({queryKey:X.repo,queryFn:({signal:e})=>nt({signal:e})})}function di(e){return A({queryKey:[e,`repo`],queryFn:({signal:t})=>nt({signal:t},e)})}function fi(){return A({queryKey:X.repoBranches,queryFn:({signal:e})=>wt({signal:e})})}function pi(){return A({queryKey:X.repoChanges,queryFn:({signal:e})=>Le({signal:e}),retry:!1})}function mi(e){return A({queryKey:X.repoCommit(e??``),queryFn:({signal:t})=>Ue(e,{signal:t}),enabled:!!e,retry:!1})}function hi(){return A({queryKey:X.config,queryFn:({signal:e})=>oe({signal:e})})}function gi(){return A({queryKey:X.worktrees,queryFn:({signal:e})=>u({signal:e})})}function _i(e){return A({queryKey:[e,`worktrees`],queryFn:({signal:t})=>u({signal:t},e),staleTime:0})}function vi(e,t=!0,n=!1){return A({queryKey:[F({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>_({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:ce(e.sidebarLimits)},enabled:t})}function yi(){return vi(n())}function bi(){return A({queryKey:X.agentConfig,queryFn:({signal:e})=>v({signal:e})})}function xi(e){return A({queryKey:X.agentConfigFile(e??``),queryFn:({signal:t})=>ne(e,{signal:t}),enabled:e!==null})}function Si(e){let t=y(),n=X.agentConfig,r=X.agentConfigFile(e);return P({mutationFn:t=>te(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}function Ci(){return A({queryKey:Z.uiState,queryFn:({signal:e})=>$e({signal:e})})}function wi(){return A({queryKey:Z.config,queryFn:({signal:e})=>le({signal:e})})}function Ti(){return A({queryKey:Z.agentProfiles,queryFn:({signal:e})=>se({signal:e})})}function Ei(e){let t=y();return P({mutationFn:t=>f(e,t),onSuccess:()=>t.invalidateQueries({queryKey:X.runs.all})})}function Di(e){let t=H(),n=e?.projectId,r=e?.cacheScope,i=P({mutationFn:e=>pt(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),a=(0,M.useCallback)(e=>({...I(e,{projectId:n,cacheScope:r}),id:e}),[n,r]),o=(0,M.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:s,mutateAsync:c}=i,l=(0,M.useCallback)((e,t)=>s(a(e),o(t)),[s,a,o]),u=(0,M.useCallback)((e,t)=>c(a(e),o(t)),[c,a,o]);return{...i,variables:i.variables?.id,mutate:l,mutateAsync:u}}function Oi(){let e=H();return P({mutationFn:e=>pt(I(e),!1),onMutate:t=>e.patchRead(()=>I(t),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function ki(e){let t=H();return P({mutationFn:({id:t,pinned:n})=>be(I(t,e),n),onError:e=>Rt(`Could not update pin. ${e.message} Please retry.`,{tone:`danger`}),onMutate:()=>e??F(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function Ai(e,t){let n=H();return P({mutationFn:n=>Ct(I(e,{projectId:t}),n),onMutate:()=>F({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`send`,r),onError:(e,t,r)=>{e instanceof Je&&e.status===409&&r&&n.invalidateAfter(`send`,r)}})}function ji(e,t){let n=H();return P({mutationFn:(n={})=>Te(I(e,{projectId:t}),n),onMutate:()=>F({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`continue`,r)})}function Mi(e){let t=y();return P({mutationFn:({msgId:t,message:n})=>Qe(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:X.runs.all})})}function Ni(e){let t=y();return P({mutationFn:t=>ct(e,t),onSuccess:()=>t.invalidateQueries({queryKey:X.runs.all})})}function Pi(e={},t=!0){let r=y(),i=X.github(e);j(`/api/v1/p/${n()}/github${e.limit===void 0?``:`?limit=${e.limit}`}`,i,a(t?6e4:!1));let o=A({queryKey:X.github(e),queryFn:({signal:t})=>ae({limit:e.limit},{signal:t}),enabled:t,staleTime:6e4,refetchInterval:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0}),s=o.data?.projectsGeneration,c=A({queryKey:[...i,`projects`,s],queryFn:({signal:e})=>lt(s,{signal:e}),enabled:t&&o.data?.projectsState===`refreshing`&&!!s,staleTime:1/0,retry:!1});return(0,M.useEffect)(()=>{!s||!c.data&&!c.error||r.setQueryData(i,e=>{if(!e||e.projectsGeneration!==s||e.projectsState!==`refreshing`)return e;let t=c.data;return t?.generation&&t.generation!==s?e:t?.state===`ready`?{...e,projectsState:`ready`,projects:t.projects,issues:e.issues.map(e=>({...e,projectIds:t.membership?.[e.number]??[]}))}:{...e,projectsState:`unavailable`,projectsReason:t?.reason??`Project boards unavailable. Refresh to try again.`}})},[r,s,c.data,c.error,i]),o}var Fi=class extends Error{};function Ii(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await ae({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new Fi(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>lr(e),retry:(e,t)=>!(t instanceof Fi)&&!(t instanceof Je&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function Li(e=50,t=!0){let r=y(),i=X.githubPages(e),o=X.githubPagesHead(e);j(`/api/v1/p/${n()}/github?limit=${e}`,o,a(t?6e4:!1));let s=Ft({...Ii(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),c=A({queryKey:o,queryFn:({signal:t})=>ae({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:l}=s;(0,M.useEffect)(()=>{if(!c.data)return;let e=r.getQueryData(i);if(!e||e.pages.length===0)return;let t=pr(e.pages,c.data);t===`refetch`?l():r.setQueryData(i,{...e,pages:t})},[r,c.dataUpdatedAt,l]);let u=(s.data?.pages??[]).flatMap(e=>e.projectsState===`refreshing`&&e.projectsGeneration?[e.projectsGeneration]:[]),d=N({queries:u.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>lt(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,M.useEffect)(()=>{d.forEach((e,t)=>{let n=u[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,d.map((e,t)=>e.data||e.error?u[t]:``).join(`,`)]),{pages:s,data:(0,M.useMemo)(()=>fr(s.data?.pages??[]),[s.data])}}function Ri(e,t=50,n=!0){let r=Ft({...Ii([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,M.useMemo)(()=>fr(r.data?.pages??[]),[r.data])}}function zi(e,t,n=!0){let r=N({queries:t.filter(e=>e.length>0).map(t=>({queryKey:X.githubCommentCounts(e,t),queryFn:({signal:n})=>Se(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,M.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 Bi(e,t,n,r=!0){return A({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>Ze(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function Vi(e,t=!0){return A({queryKey:X.githubChecks(e),queryFn:({signal:t})=>Ce(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function Hi(e,t,n=!0){return A({queryKey:X.githubSearch(e,t),queryFn:({signal:n})=>Ze(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var Ui=100;function Wi(e){return[...e].sort((e,t)=>t-e).slice(0,Ui).sort((e,t)=>e-t)}function Gi(){let e=gt(),t=$();return e.projectId??t.data?.bootProject}function Ki(e){for(let[t,n]of Object.entries(e)){for(let[e,r]of Object.entries(n.prs))In(q({projectId:t,kind:`PR`,number:Number(e)}),r);for(let[e,r]of Object.entries(n.issues))In(q({projectId:t,kind:`Issue`,number:Number(e)}),r)}}var qi=5*6e4;function Ji(e){return e?e.recheckAfterMs:qi}function Yi(e,t=!0){let n=(0,M.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.projectId)??{prs:new Set,issues:new Set};e[n.kind===`PR`?`prs`:`issues`].add(n.number),t.set(n.projectId,e)}return[...t.entries()].map(([e,t])=>({projectId:e,prs:Wi(t.prs),issues:Wi(t.issues)}))},[e.map(q).sort().join(`|`)]),r=N({queries:n.map(e=>({queryKey:X.githubRefStatus(e.projectId,e.prs,e.issues),queryFn:({signal:t})=>vt(e.projectId,{prs:e.prs,issues:e.issues},{signal:t}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>Ji(e.state.data)??1/0,refetchInterval:!1,refetchOnWindowFocus:!0}))}),a=y(),o=JSON.stringify(n.map((e,t)=>({...e,interval:Ji(r[t]?.data)??!1})));(0,M.useEffect)(()=>{if(!t||i())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=X.githubRefStatus(t.projectId,t.prs,t.issues);return It({path:`/api/v1/p/${t.projectId}/github/ref-status?${n}`,intervalMs:t.interval},(t,n)=>{n||a.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&a.setQueryData(r,t)})})});return()=>{e=!1;for(let e of n)e()}},[t,o,a]);let s=(0,M.useMemo)(()=>Kn(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,M.useCallback)(e=>{let t=q(e),n=s.get(t);if(n)return n;let r=G.get(t);return{state:`idle`,...r?{status:r}:{},...K.has(t)?{conflicting:!0}:{}}},[s])}function Xi(e,t,n=!0){return A({queryKey:X.githubComments(e,t),queryFn:({signal:n})=>we(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Zi(e,t,n=!0){return A({queryKey:X.githubItem(e,t),queryFn:({signal:n})=>fe(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Qi(e){return A({queryKey:X.githubPrChanges(e??0),queryFn:({signal:t})=>Be(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{gr as $,Qi as A,wi as At,Ri as B,Mn as Bt,Pi as C,si as Ct,Zi as D,Sr as Dt,Xi as E,jr as Et,Oi as F,ur as Ft,vi as G,Kt as Gt,di as H,H as Ht,kr as I,or as It,hr as J,I as Jt,_i as K,Gt as Kt,Hr as L,sr as Lt,$ as M,gi as Mt,Br as N,Z as Nt,zr as O,Er as Ot,Di as P,mr as Pt,Yi as Q,Ei as R,ar as Rt,yr as S,Ai as St,zi as T,yi as Tt,Vr as U,L as Ut,Bi as V,Cn as Vt,Xr as W,Jt as Wt,Ir as X,N as Xt,Si as Y,P as Yt,Gi as Z,zt as Zt,Rr as _,Jr as _t,xi as a,ui as at,Mi as b,Gr as bt,ti as c,mi as ct,ci as d,Qr as dt,br as et,Lr as f,ai as ft,Ar as g,oi as gt,ji as h,$r as ht,bi as i,Ni as it,Hi as j,Ci as jt,Li as k,li as kt,ni as l,_r as lt,Fr as m,Zr as mt,Ki as n,xr as nt,Ti as o,fi as ot,hi as p,ii as pt,vr as q,F as qt,Pr as r,Dr as rt,Wr as s,pi as st,X as t,Mr as tt,ri as u,Yr as ut,Tr as v,Ur as vt,Vi as w,Or as wt,ei as x,Nr as xt,qr as y,Kr as yt,ki as z,An 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{n as r,t as i}from"./utils-DSMR_WLb.js";import{Bt as a,Q as o,zt as s}from"./queries--x5yVcip.js";import{n as c}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{a as l}from"./tasks-table-BCuA9Kx7.js";import{F as u,H as d,M as f,N as p,P as m,f as h,g,h as _,m as v,ot as y,p as b}from"./design-icons-CzEoMH9c.js";import{t as x}from"./createLucideIcon-BHp8sXmF.js";import{n as S,r as C,t as w}from"./popover-BPgUYFyu.js";var T=x(`search-x`,[[`path`,{d:`m13.5 8.5-5 5`,key:`1cs55j`}],[`path`,{d:`m8.5 8.5 5 5`,key:`a8mexj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),E={general:[`Settings`,`General`],webhooks:[`Settings`,`General`,`Webhooks`],providers:[`Settings`,`Agent defaults`,`Providers`],projects:[`Settings`,`Projects`],worktrees:[`Settings`,`Worktrees`],sidebar:[`Settings`,`Sidebar`]};function D(e,t=` → `){return E[e].join(t)}var O=e(t(),1),k=n(),A=(0,O.createContext)(null);function j({children:e}){let[t,n]=(0,O.useState)(()=>new Map),r=(0,O.useCallback)((e,t)=>{n(n=>{let r=new Map(n);return r.set(e,t),r})},[]),i=(0,O.useCallback)(e=>{n(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),a=o((0,O.useMemo)(()=>[...t.values()].flat(),[t])),s=(0,O.useMemo)(()=>({publish:r,retract:i,lookup:a}),[r,i,a]);return(0,k.jsx)(A.Provider,{value:s,children:e})}var M=(0,O.createContext)(null);function ee({projectId:e,repoBase:t,requests:n,children:r}){let i=(0,O.useContext)(A),a=(0,O.useContext)(M),s=(0,O.useId)();(0,O.useEffect)(()=>{if(i)return i.publish(s,n),()=>i.retract(s)},[i,s,n.map(e=>`${e.projectId} ${e.kind}#${e.number}`).sort().join(`|`)]);let c=o(i?N:n),l=i?.lookup??c,u=t??(a&&a.projectId===e?a.repoBase:void 0),d=(0,O.useMemo)(()=>({lookup:l,projectId:e,repoBase:u}),[l,e,u]);return(0,k.jsx)(M.Provider,{value:d,children:r})}var N=[];function P(e,t,n){let r=(0,O.useContext)(M),i=n??r?.projectId;return!r||!i||t===void 0?te:r.lookup({projectId:i,kind:e,number:t})}function F(e,t){let n=(0,O.useContext)(M),r=t??n?.projectId;return!n||!r?[]:e.filter(e=>n.lookup({projectId:r,kind:`PR`,number:e}).conflicting===!0)}function I(){let e=(0,O.useContext)(M);return{projectId:e?.projectId,repoBase:e?.repoBase}}var te=Object.freeze({state:`idle`}),ne={success:`border-success/40 text-success`,danger:`border-danger/40 text-danger`,accent:`border-accent-strong/35 text-accent-text`,merged:`border-merged-strong/35 text-merged-text`,info:`border-info/40 text-info`,neutral:`border-border text-muted-foreground`,pending:`border-pending-strong/45 text-pending-strong`,conflict:`border-conflict/45 text-conflict`},L={success:`text-success`,danger:`text-danger`,accent:`text-merged-text`,merged:`text-merged-text`,info:`text-info`,neutral:`text-soft-foreground`,pending:`text-pending-strong`,conflict:`text-conflict`},re={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`},R={draft:m,"review-required":u,"changes-requested":d,"checks-pending":null,"checks-failing":g,ready:h,merged:f,closed:p,open:b,completed:h,"not-planned":_};function z(e){return e===`PR`?`pr-chip`:`issue-chip`}function B(e){return e?{"data-conflicting":`true`}:{}}function V(e,t,n,r){return!n||r!==void 0&&l({kind:e,number:t??0,url:n},r)}function H(e,t,n){return e===`PR`&&(t??n)===!0}function U({plain:e,inert:t,conflicting:n,className:r,tone:a}){return e?i(`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):i(`inline-flex h-[22px] items-center gap-1 rounded-md border px-1.5 font-mono text-[12px] font-normal`,ne[a],r)}function W(e,t,n,r){return n&&!r?t?`${e===`PR`?`PR `:``}#${t}`:e:t?`${!r&&e===`Issue`?`Issue `:``}#${t}`:e}function G(e){return e===`PR`?`pull request`:`issue`}function K(e,t,n,r){return`Open the ${e}${t?` #${t}`:``} for ${n}${r?` — ${r.label}`:``}`}function q(e,t){return e&&t?L[t.tone]:void 0}function J(e,t){return!e&&(!t||!r(t))}function Y({conflicting:e,presentation:t,status:n,plain:r,compact:a,inert:o,kind:s,label:c,glyphClass:l}){return(0,k.jsxs)(k.Fragment,{children:[e?(0,k.jsx)(y,{className:i(`size-2.5 shrink-0`,l),"aria-hidden":`true`}):(0,k.jsx)($,{status:t?n:void 0,className:r?i(`size-2.5`,l):void 0}),r&&a?s===`PR`?(0,k.jsx)(u,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):(0,k.jsx)(b,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):null,r?(0,k.jsx)(`span`,{className:o?void 0:`underline-offset-2 group-hover/reference:underline group-focus-visible/reference:underline`,children:c}):c]})}function ie({kind:e,status:t,conflicting:n,chipClass:r,body:i}){return(0,k.jsx)(`span`,{"data-slot":z(e),"data-status":t,"data-inert":`true`,...B(n),className:r,children:i})}function ae({kind:e,number:t,tooltip:n,url:i}){return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`span`,{className:`block font-medium`,children:[e===`PR`?`Pull request`:`Issue`,t?` #${t}`:``,` · `,n.headline]}),(0,k.jsx)(`span`,{className:`block`,children:n.detail}),n.also?(0,k.jsx)(`span`,{className:`block opacity-70`,children:n.also}):null,i&&r(i)?(0,k.jsx)(`span`,{className:`block opacity-70`,children:i.replace(/^https?:\/\//,``)}):null]})}function oe({reference:e,taskTitle:t,status:n,conflicting:r,conflictAction:o,projectId:c,repoBase:l,to:u,className:d,compact:f=!1,plain:p=!1,inert:m=!1}){let{kind:h,number:g,url:_}=e,v=I(),y=P(h,V(h,g,_,l??v.repoBase)?g:void 0,c),b=n??y.status,x=a(b),S=H(h,r,y.conflicting),C=S?s:x,w=C?.tone??`accent`,T=U({plain:p,inert:m,conflicting:S,className:d,tone:w}),E=ue(y,C,S?x:void 0),D=W(h,g,p,f),O=G(h),A=K(O,g,t,C),j=(0,k.jsx)(Y,{conflicting:S,presentation:C,status:b,plain:p,compact:f,inert:m,kind:h,label:D,glyphClass:q(p,C)});if(m)return(0,k.jsx)(ie,{kind:h,status:b,conflicting:S,chipClass:T,body:j});let M=J(u,_)?(0,k.jsx)(`span`,{"data-slot":z(h),"data-status":b,...B(S),"aria-label":C?`${O} ${D} — ${C.label}`:void 0,className:T,children:j}):(0,k.jsx)(se,{to:u,url:_,"data-slot":z(h),"data-status":b,...B(S),title:E?void 0:_,"aria-label":A,className:p?T:i(T,re[w]),children:j});return E?(0,k.jsx)(le,{chip:M,action:S?o:void 0,state:y.state,children:(0,k.jsx)(ae,{kind:h,number:g,tooltip:E,url:_})}):M}function se({to:e,url:t,children:n,...r}){return e?(0,k.jsx)(c,{to:e,...r,children:n}):(0,k.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,...r,children:n})}var X=(0,O.createContext)(()=>{});function ce(){return(0,O.useContext)(X)}var Z=150,Q=120;function le({chip:e,action:t,state:n,children:r}){let[i,a]=(0,O.useState)(!1),o=(0,O.useRef)(null),s=(0,O.useRef)(null),c=(0,O.useRef)(void 0),l=(0,O.useCallback)((e,t)=>{clearTimeout(c.current),c.current=setTimeout(()=>a(e),t)},[]),u=(0,O.useCallback)(()=>{clearTimeout(c.current),a(!1)},[]);(0,O.useEffect)(()=>()=>clearTimeout(c.current),[]);let d=e=>e instanceof Node&&(s.current?.contains(e)||o.current?.contains(e));return(0,k.jsxs)(w,{open:i,onOpenChange:e=>e?a(!0):u(),children:[(0,k.jsx)(S,{asChild:!0,ref:o,onPointerEnter:e=>{e.pointerType!==`touch`&&l(!0,Z)},onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,Q)},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,k.jsxs)(C,{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,Q)},children:[(0,k.jsx)(`div`,{className:`space-y-0.5`,children:r}),t?(0,k.jsx)(X.Provider,{value:u,children:t}):null]})]})}function ue(e,t,n){if(t){let{label:r,hint:i}=t,a=n?`also ${de(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 de(e){return e.charAt(0).toLowerCase()+e.slice(1)}function fe({kind:e,number:t,className:n}){let r=P(e,t),o=a(r.status),c=e===`PR`&&r.conflicting===!0,l=c?s:o;if(!l)return null;let u=i(`size-2.5`,L[l.tone]);return(0,k.jsx)(`span`,{"data-slot":`reference-status-glyph`,"data-status":r.status,...c?{"data-conflicting":`true`}:{},"aria-hidden":`true`,className:i(`inline-flex items-center`,n),children:c?(0,k.jsx)(y,{className:i(`shrink-0`,u),"aria-hidden":`true`}):(0,k.jsx)($,{status:r.status,className:u})})}function $({status:e,className:t}){if(!e)return null;if(e===`checks-pending`)return(0,k.jsx)(v,{"data-slot":`status-dot`,"data-tone":`pending`,className:i(`size-3 animate-pulse motion-reduce:animate-none`,t),"aria-hidden":`true`});let n=R[e];return n?(0,k.jsx)(n,{className:i(`size-2.5 shrink-0`,t),"aria-hidden":`true`}):null}export{j as a,P as c,ee as i,D as l,fe as n,F as o,ce as r,I as s,oe as t,T as u};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{n as r,t as i}from"./utils-DSMR_WLb.js";import{Bt as a,Q as o,zt as s}from"./queries-dHXhD3Hc.js";import{n as c}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{a as l}from"./tasks-table-DHTEGteC.js";import{F as u,H as d,M as f,N as p,P as m,f as h,g,h as _,m as v,ot as y,p as b}from"./design-icons-CzEoMH9c.js";import{t as x}from"./createLucideIcon-BHp8sXmF.js";import{n as S,r as C,t as w}from"./popover-BPgUYFyu.js";var T=x(`search-x`,[[`path`,{d:`m13.5 8.5-5 5`,key:`1cs55j`}],[`path`,{d:`m8.5 8.5 5 5`,key:`a8mexj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),E={general:[`Settings`,`General`],webhooks:[`Settings`,`General`,`Webhooks`],providers:[`Settings`,`Agent defaults`,`Providers`],projects:[`Settings`,`Projects`],worktrees:[`Settings`,`Worktrees`],sidebar:[`Settings`,`Sidebar`]};function D(e,t=` → `){return E[e].join(t)}var O=e(t(),1),k=n(),A=(0,O.createContext)(null);function j({children:e}){let[t,n]=(0,O.useState)(()=>new Map),r=(0,O.useCallback)((e,t)=>{n(n=>{let r=new Map(n);return r.set(e,t),r})},[]),i=(0,O.useCallback)(e=>{n(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),a=o((0,O.useMemo)(()=>[...t.values()].flat(),[t])),s=(0,O.useMemo)(()=>({publish:r,retract:i,lookup:a}),[r,i,a]);return(0,k.jsx)(A.Provider,{value:s,children:e})}var M=(0,O.createContext)(null);function ee({projectId:e,repoBase:t,requests:n,children:r}){let i=(0,O.useContext)(A),a=(0,O.useContext)(M),s=(0,O.useId)();(0,O.useEffect)(()=>{if(i)return i.publish(s,n),()=>i.retract(s)},[i,s,n.map(e=>`${e.projectId} ${e.kind}#${e.number}`).sort().join(`|`)]);let c=o(i?N:n),l=i?.lookup??c,u=t??(a&&a.projectId===e?a.repoBase:void 0),d=(0,O.useMemo)(()=>({lookup:l,projectId:e,repoBase:u}),[l,e,u]);return(0,k.jsx)(M.Provider,{value:d,children:r})}var N=[];function P(e,t,n){let r=(0,O.useContext)(M),i=n??r?.projectId;return!r||!i||t===void 0?te:r.lookup({projectId:i,kind:e,number:t})}function F(e,t){let n=(0,O.useContext)(M),r=t??n?.projectId;return!n||!r?[]:e.filter(e=>n.lookup({projectId:r,kind:`PR`,number:e}).conflicting===!0)}function I(){let e=(0,O.useContext)(M);return{projectId:e?.projectId,repoBase:e?.repoBase}}var te=Object.freeze({state:`idle`}),ne={success:`border-success/40 text-success`,danger:`border-danger/40 text-danger`,accent:`border-accent-strong/35 text-accent-text`,merged:`border-merged-strong/35 text-merged-text`,info:`border-info/40 text-info`,neutral:`border-border text-muted-foreground`,pending:`border-pending-strong/45 text-pending-strong`,conflict:`border-conflict/45 text-conflict`},L={success:`text-success`,danger:`text-danger`,accent:`text-merged-text`,merged:`text-merged-text`,info:`text-info`,neutral:`text-soft-foreground`,pending:`text-pending-strong`,conflict:`text-conflict`},re={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`},R={draft:m,"review-required":u,"changes-requested":d,"checks-pending":null,"checks-failing":g,ready:h,merged:f,closed:p,open:b,completed:h,"not-planned":_};function z(e){return e===`PR`?`pr-chip`:`issue-chip`}function B(e){return e?{"data-conflicting":`true`}:{}}function V(e,t,n,r){return!n||r!==void 0&&l({kind:e,number:t??0,url:n},r)}function H(e,t,n){return e===`PR`&&(t??n)===!0}function U({plain:e,inert:t,conflicting:n,className:r,tone:a}){return e?i(`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):i(`inline-flex h-[22px] items-center gap-1 rounded-md border px-1.5 font-mono text-[12px] font-normal`,ne[a],r)}function W(e,t,n,r){return n&&!r?t?`${e===`PR`?`PR `:``}#${t}`:e:t?`${!r&&e===`Issue`?`Issue `:``}#${t}`:e}function G(e){return e===`PR`?`pull request`:`issue`}function K(e,t,n,r){return`Open the ${e}${t?` #${t}`:``} for ${n}${r?` — ${r.label}`:``}`}function q(e,t){return e&&t?L[t.tone]:void 0}function J(e,t){return!e&&(!t||!r(t))}function Y({conflicting:e,presentation:t,status:n,plain:r,compact:a,inert:o,kind:s,label:c,glyphClass:l}){return(0,k.jsxs)(k.Fragment,{children:[e?(0,k.jsx)(y,{className:i(`size-2.5 shrink-0`,l),"aria-hidden":`true`}):(0,k.jsx)($,{status:t?n:void 0,className:r?i(`size-2.5`,l):void 0}),r&&a?s===`PR`?(0,k.jsx)(u,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):(0,k.jsx)(b,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):null,r?(0,k.jsx)(`span`,{className:o?void 0:`underline-offset-2 group-hover/reference:underline group-focus-visible/reference:underline`,children:c}):c]})}function ie({kind:e,status:t,conflicting:n,chipClass:r,body:i}){return(0,k.jsx)(`span`,{"data-slot":z(e),"data-status":t,"data-inert":`true`,...B(n),className:r,children:i})}function ae({kind:e,number:t,tooltip:n,url:i}){return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`span`,{className:`block font-medium`,children:[e===`PR`?`Pull request`:`Issue`,t?` #${t}`:``,` · `,n.headline]}),(0,k.jsx)(`span`,{className:`block`,children:n.detail}),n.also?(0,k.jsx)(`span`,{className:`block opacity-70`,children:n.also}):null,i&&r(i)?(0,k.jsx)(`span`,{className:`block opacity-70`,children:i.replace(/^https?:\/\//,``)}):null]})}function oe({reference:e,taskTitle:t,status:n,conflicting:r,conflictAction:o,projectId:c,repoBase:l,to:u,className:d,compact:f=!1,plain:p=!1,inert:m=!1}){let{kind:h,number:g,url:_}=e,v=I(),y=P(h,V(h,g,_,l??v.repoBase)?g:void 0,c),b=n??y.status,x=a(b),S=H(h,r,y.conflicting),C=S?s:x,w=C?.tone??`accent`,T=U({plain:p,inert:m,conflicting:S,className:d,tone:w}),E=ue(y,C,S?x:void 0),D=W(h,g,p,f),O=G(h),A=K(O,g,t,C),j=(0,k.jsx)(Y,{conflicting:S,presentation:C,status:b,plain:p,compact:f,inert:m,kind:h,label:D,glyphClass:q(p,C)});if(m)return(0,k.jsx)(ie,{kind:h,status:b,conflicting:S,chipClass:T,body:j});let M=J(u,_)?(0,k.jsx)(`span`,{"data-slot":z(h),"data-status":b,...B(S),"aria-label":C?`${O} ${D} — ${C.label}`:void 0,className:T,children:j}):(0,k.jsx)(se,{to:u,url:_,"data-slot":z(h),"data-status":b,...B(S),title:E?void 0:_,"aria-label":A,className:p?T:i(T,re[w]),children:j});return E?(0,k.jsx)(le,{chip:M,action:S?o:void 0,state:y.state,children:(0,k.jsx)(ae,{kind:h,number:g,tooltip:E,url:_})}):M}function se({to:e,url:t,children:n,...r}){return e?(0,k.jsx)(c,{to:e,...r,children:n}):(0,k.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,...r,children:n})}var X=(0,O.createContext)(()=>{});function ce(){return(0,O.useContext)(X)}var Z=150,Q=120;function le({chip:e,action:t,state:n,children:r}){let[i,a]=(0,O.useState)(!1),o=(0,O.useRef)(null),s=(0,O.useRef)(null),c=(0,O.useRef)(void 0),l=(0,O.useCallback)((e,t)=>{clearTimeout(c.current),c.current=setTimeout(()=>a(e),t)},[]),u=(0,O.useCallback)(()=>{clearTimeout(c.current),a(!1)},[]);(0,O.useEffect)(()=>()=>clearTimeout(c.current),[]);let d=e=>e instanceof Node&&(s.current?.contains(e)||o.current?.contains(e));return(0,k.jsxs)(w,{open:i,onOpenChange:e=>e?a(!0):u(),children:[(0,k.jsx)(S,{asChild:!0,ref:o,onPointerEnter:e=>{e.pointerType!==`touch`&&l(!0,Z)},onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,Q)},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,k.jsxs)(C,{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,Q)},children:[(0,k.jsx)(`div`,{className:`space-y-0.5`,children:r}),t?(0,k.jsx)(X.Provider,{value:u,children:t}):null]})]})}function ue(e,t,n){if(t){let{label:r,hint:i}=t,a=n?`also ${de(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 de(e){return e.charAt(0).toLowerCase()+e.slice(1)}function fe({kind:e,number:t,className:n}){let r=P(e,t),o=a(r.status),c=e===`PR`&&r.conflicting===!0,l=c?s:o;if(!l)return null;let u=i(`size-2.5`,L[l.tone]);return(0,k.jsx)(`span`,{"data-slot":`reference-status-glyph`,"data-status":r.status,...c?{"data-conflicting":`true`}:{},"aria-hidden":`true`,className:i(`inline-flex items-center`,n),children:c?(0,k.jsx)(y,{className:i(`shrink-0`,u),"aria-hidden":`true`}):(0,k.jsx)($,{status:r.status,className:u})})}function $({status:e,className:t}){if(!e)return null;if(e===`checks-pending`)return(0,k.jsx)(v,{"data-slot":`status-dot`,"data-tone":`pending`,className:i(`size-3 animate-pulse motion-reduce:animate-none`,t),"aria-hidden":`true`});let n=R[e];return n?(0,k.jsx)(n,{className:i(`size-2.5 shrink-0`,t),"aria-hidden":`true`}):null}export{j as a,P as c,ee as i,D as l,fe as n,F as o,ce as r,I as s,oe as t,T as u};
@@ -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{ci as r}from"./project-scope-context-BDU1qGx3.js";import{M as i,t as a}from"./queries--x5yVcip.js";import{gn as o}from"./index-BZiixXpY.js";var s=e(t(),1),c=n();function l(){let e=r(),t=(0,s.useCallback)(async()=>{await Promise.all([e.invalidateQueries({queryKey:a.health}),e.invalidateQueries({queryKey:a.agentConfig,exact:!0})])},[e]);return(0,s.useEffect)(()=>{t()},[t]),t}var u=`${o()} remote-settings enable`;function d({risk:e}){return i().data?.capabilities?.remoteSettingsAdmin===!0?(0,c.jsxs)(`p`,{role:`note`,"data-slot":`remote-settings-notice`,className:`rounded-md border border-warning/40 bg-warning/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,c.jsxs)(`code`,{children:[o(),` remote-settings disable`]}),`.`]}):null}export{d as n,l as r,u 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{ci as r}from"./project-scope-context-D1bpJixc.js";import{M as i,t as a}from"./queries-dHXhD3Hc.js";import{gn as o}from"./index-CmadQXcg.js";var s=e(t(),1),c=n();function l(){let e=r(),t=(0,s.useCallback)(async()=>{await Promise.all([e.invalidateQueries({queryKey:a.health}),e.invalidateQueries({queryKey:a.agentConfig,exact:!0})])},[e]);return(0,s.useEffect)(()=>{t()},[t]),t}var u=`${o()} remote-settings enable`;function d({risk:e}){return i().data?.capabilities?.remoteSettingsAdmin===!0?(0,c.jsxs)(`p`,{role:`note`,"data-slot":`remote-settings-notice`,className:`rounded-md border border-warning/40 bg-warning/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,c.jsxs)(`code`,{children:[o(),` remote-settings disable`]}),`.`]}):null}export{d as n,l as r,u 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{c as r,n as i,t as a}from"./utils-DSMR_WLb.js";import{Lt as o,O as s,S as c,Xt as l,Zt as u,ci as d,i as f,w as p}from"./project-scope-context-BDU1qGx3.js";import{Y as m}from"./live-protocol-D9ji1YCl.js";import{Bt as h,C as g,L as _,M as v,Mt as ee,U as y,Yt as b,at as x,ct as S,ot as C,st as te,t as w,vt as ne}from"./queries--x5yVcip.js";import{g as re,h as ie}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{i as T}from"./tasks-table-BCuA9Kx7.js";import{n as E}from"./toaster-Bo5vCbz-.js";import{A as D,C as O,E as ae,F as oe,J as se,M as ce,X as le,Y as ue,at as de,j as fe,n as pe,ot as k,s as me,u as he,v as ge,x as _e}from"./design-icons-CzEoMH9c.js";import{t as A}from"./createLucideIcon-BHp8sXmF.js";import{l as ve,n as ye,y as be}from"./nav-row-styles-DqKjMToI.js";import{n as xe,r as Se}from"./diff-controls-BSWICnsb.js";import{i as Ce,r as we,t as Te}from"./git-toolbar-BUViNmxj.js";import{t as j}from"./info-DA1x_4bz.js";import{a as Ee,i as M}from"./format-BNCkW110.js";import{c as De,i as Oe,l as ke,t as Ae}from"./reference-chip-013dL8dQ.js";import{t as N}from"./button-BQ2y4XRB.js";import{i as P,l as je,p as Me,r as Ne,t as Pe}from"./dropdown-menu-4e2iKSMT.js";import{t as F}from"./project-router-BYrAO9Ws.js";import{t as Fe}from"./status-dot-DtAOFiIi.js";import{t as I}from"./centered-state-V15AR_qo.js";import{$t as L,At as Ie,Bt as R,D as z,E as Le,Ft as Re,Gt as B,Hn as V,Ht as H,It as ze,Jn as Be,Kt as U,Lt as Ve,Mt as He,Nt as Ue,Ot as We,Pt as Ge,Rt as Ke,Ut as W,Vt as G,Wt as K,jt as qe,kt as Je,qt as q,tr as J,zt as Ye}from"./index-BZiixXpY.js";import{t as Xe}from"./markdown-BBDDg-4t.js";import{t as Ze}from"./diff-CfoXwmnl.js";import{t as Qe}from"./commit-diff-panel-DawdFJ6E.js";var Y=e(t(),1);function $e(e,t){let n=d(t),r=n.getQueryCache();return Y.useSyncExternalStore(Y.useCallback(e=>r.subscribe(m.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var et=A(`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`}]]),tt=A(`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=r(),t=x(),n=d(),i=$e({queryKey:w.repo})>0,o=t.data?.info?t.data:null,s=We(e,o,`screen`);return(0,X.jsxs)(`div`,{"data-route":`repo-git`,"data-slot":`git-screen`,className:ye,children:[(0,X.jsxs)(`div`,{className:`mb-[16px] flex items-center gap-[8px]`,children:[(0,X.jsx)(`h1`,{className:a(ve,`min-w-0 flex-1`),children:`Git`}),(0,X.jsx)(`button`,{type:`button`,"data-slot":`git-screen-refresh`,"aria-label":`Refresh the repository`,title:`Refresh the repository`,disabled:i,onClick:()=>{n.invalidateQueries({queryKey:w.repo}),n.invalidateQueries({queryKey:w.worktrees})},className:`-my-2 -mr-[10px] flex size-11 shrink-0 items-center justify-center rounded-md text-soft-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-60`,children:(0,X.jsx)(ue,{size:17,"aria-hidden":`true`,className:a(`size-[17px]`,i&&`motion-safe:animate-spin`)})})]}),o?.info?(0,X.jsx)(`div`,{className:`mb-[16px]`,children:(0,X.jsx)(qe,{scope:e,repo:o,info:o.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)(Je,{branch:o?.info?.branch??null,counts:s,variant:`screen`})]})}function Z({entry:e}){return e.keptReason?(0,X.jsx)(`span`,{"data-slot":`branch-kept-reason`,className:`min-w-0 text-[11px] text-soft-foreground`,children:e.keptReason}):null}function rt({repo:e,info:t}){let n=v(),r=C(),i=new Map((r.data?.branches??[]).map(e=>[e.name,e])),o=d(),s=b({mutationFn:e=>c({name:e}),onSuccess:async e=>{E(e.created?`Created and switched to ${e.branch}`:`Switched to ${e.branch}`),await Promise.all([o.invalidateQueries({queryKey:w.repo}),o.invalidateQueries({queryKey:w.health})]),o.setQueryData(w.repo,t=>t?.info?{...t,info:{...t.info,branch:e.branch}}:t),o.setQueryData(w.health,n=>n?.repo?.root===t.root?{...n,repo:{...n.repo,branch:e.branch}}:n)},onError:e=>E(e.message,{tone:`danger`})}),[l,u]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(``),m=f.trim().toLowerCase(),h=Q(e,r.data?.branches),g=m?h.filter(e=>e.toLowerCase().includes(m)):h;return(0,X.jsxs)(`section`,{"data-slot":`repo-branches`,className:`grid min-w-0 grid-cols-1 gap-5 px-[18px] py-[22px] md:grid-cols-[minmax(0,1fr)_290px] md:px-9`,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)(le,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,X.jsx)(V,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:f,onChange:e=>p(e.target.value),className:`h-11 pl-10`})]}),(0,X.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-4 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:[g.map(e=>{let n=e===t.branch,r=i.get(e);return(0,X.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,"data-branch-class":r?.class,className:`flex min-h-20 flex-col items-start justify-center gap-2 py-3 md:flex-row md:items-center md:justify-start md:py-2.5`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-[8px]`,children:[r?.runId?(0,X.jsx)(F,{to:`/tasks/${r.runId}`,"data-slot":`branch-task-link`,title:r.title?`Open the task ${r.title}`:`Open the task`,className:`min-w-0 truncate rounded-[2px] text-[13px] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:e}):(0,X.jsx)(`span`,{className:a(`min-w-0 truncate text-[13px]`,n&&`font-normal`),children:e}),r?(0,X.jsx)(ct,{entry:r}):null]}),r?(0,X.jsx)(Z,{entry:r}):null,e.startsWith(`cez/`)&&!n?null:n?(0,X.jsx)(`span`,{"data-slot":`branch-current`,className:`md:ml-auto flex shrink-0 items-center rounded-md bg-accent-strong/10 px-2 py-1.5 text-[12px] font-medium text-accent-text`,children:`Current`}):(0,X.jsxs)(N,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`md:ml-auto h-11`,disabled:s.isPending,onClick:()=>s.mutate(e),children:[(0,X.jsx)(D,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),g.length===0?(0,X.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-soft-foreground`,children:[`No branches match “`,f.trim(),`”.`]}):null]})]}),(0,X.jsxs)(`div`,{className:`min-w-0 self-start rounded-xl border border-border bg-card p-5`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:`Create a branch`}),(0,X.jsxs)(`form`,{"data-slot":`branch-create`,className:`mt-7 flex flex-col items-stretch gap-3`,onSubmit:e=>{e.preventDefault();let t=l.trim();t&&s.mutate(t,{onSuccess:()=>u(``)})},children:[(0,X.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,X.jsx)(`p`,{className:`-mt-1 text-xs text-muted-foreground`,children:`Create from the selected base.`}),(0,X.jsx)(V,{id:`new-branch-name`,"aria-label":`New branch name`,placeholder:`new-branch-name`,className:`h-11 bg-background`,value:l,onChange:e=>u(e.target.value)}),(0,X.jsxs)(N,{type:`submit`,variant:`primary`,size:`sm`,className:`min-h-11 self-start`,"data-action":`create-branch`,disabled:!l.trim()||s.isPending,children:[(0,X.jsx)(se,{size:16,"aria-hidden":`true`}),`Create branch`]})]}),(0,X.jsx)(`p`,{className:`mt-3 border-t border-border pt-4 text-xs leading-relaxed text-muted-foreground`,children:`Switching branches changes your working tree. Review uncommitted changes first.`})]}),n.data?.forge?.available?(0,X.jsx)(it,{}):null]})}function it(){let e=g({limit:20});return(0,X.jsxs)(`div`,{"data-slot":`repo-prs`,className:`max-w-xl`,children:[(0,X.jsx)(`h2`,{className:`text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Open pull requests`}),e.isPending?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`Loading pull requests…`}):e.isError?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:e.error.message}):e.data.available?e.data.prs.length===0?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`No open pull requests.`}):(0,X.jsx)(`ul`,{className:`mt-2 flex flex-col divide-y divide-border`,children:e.data.prs.map(e=>(0,X.jsx)(at,{pr:e},e.number))}):(0,X.jsx)(`p`,{"data-slot":`repo-prs-unavailable`,className:`mt-2 text-xs text-soft-foreground`,children:e.data.reason??`The forge is unreachable right now.`})]})}function at({pr:e}){let t=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(oe,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:[`#`,e.number]}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.title}),e.checks?(0,X.jsx)(ot,{checks:e.checks}):null]}),n=`flex min-w-0 items-center gap-2 rounded-sm px-1.5 py-2`;return(0,X.jsx)(`li`,{"data-slot":`pr-row`,"data-number":e.number,children:i(e.url)?(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:a(n,`hover:bg-muted`),children:t}):(0,X.jsx)(`span`,{className:n,children:t})})}function ot({checks:e}){return(0,X.jsx)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:a(`shrink-0 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:e})}var st={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function ct({entry:e}){return(0,X.jsx)(`span`,{"data-slot":`branch-class`,className:a(`shrink-0 rounded-[4px] border px-[5px] py-[1px] text-[10.5px] leading-[14px]`,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:st[e.class]})}function Q(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 lt(){let e=te(),t=L(),[n,r]=(0,Y.useState)(`unified`),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),u=(0,Y.useRef)(null),d=e.isError&&e.error instanceof f&&e.error.status===409,p=e.data?.files??[],m=(0,Y.useMemo)(()=>we(p),[p]),h=(0,Y.useMemo)(()=>p.some(Xe),[p]),g=t?n:`unified`,_=!t||i;return(0,X.jsxs)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,X.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 px-[18px] py-[22px] md:px-9`,children:[(0,X.jsx)(`span`,{className:`text-sm`,children:e.data?`${e.data.stat.files} files changed ·`:`Uncommitted changes`}),e.data?(0,X.jsx)(Te,{stat:e.data.stat}):null,(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`hidden items-center gap-1 md:flex`,children:(0,X.jsx)(xe,{mode:n,wrap:i,onModeChange:r,onWrapChange:a})}),h?(0,X.jsx)(Se,{preview:o,onPreviewChange:s}):null]})]}),e.isPending?(0,X.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading changes…`}):e.isError?(0,X.jsx)(I,{icon:d?(0,X.jsx)(O,{size:16}):(0,X.jsx)(k,{size:16}),tone:d?`neutral`:`danger`,heading:`h2`,title:d?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):p.length===0?(0,X.jsx)(I,{icon:(0,X.jsx)(O,{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)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 md:flex-row md:items-start px-[18px] pb-9 pt-0 [--diff-sticky-top:1rem] md:px-9`,children:[(0,X.jsxs)(`aside`,{"data-slot":`changes-tree-pane`,className:`md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] w-full md:w-60 shrink-0 overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 lg:w-[250px]`,children:[(0,X.jsx)(`h2`,{className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,X.jsx)(Ce,{root:m,selected:c,onSelect:e=>{l(e),u.current?.scrollToPath(e)}})]}),(0,X.jsx)(Ze,{files:p,viewRef:u,mode:g,wrap:_,preview:o,className:`min-w-0 flex-1`})]})]})}function ut({repo:e,info:t}){let{sha:n}=ie(),r=e.log,i=(0,Y.useMemo)(()=>Ke(r),[r]);if(n)return(0,X.jsx)(pt,{sha:n});let a=ze(e,t),o=a&&a.behind>0?(0,X.jsx)(ft,{info:t,tracking:a}):null;return r.length===0?(0,X.jsxs)(X.Fragment,{children:[o?(0,X.jsx)(`div`,{className:`px-[8px] pt-[12px] md:px-[20px]`,children:o}):null,(0,X.jsx)(I,{icon:(0,X.jsx)(fe,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`})]}):(0,X.jsxs)(`div`,{"data-slot":`repo-commits`,className:`flex flex-col gap-[2px] px-[8px] pt-[12px] pb-[20px] md:px-[20px]`,children:[o,i.map(e=>(0,X.jsxs)(`section`,{"data-slot":`repo-commit-day`,"aria-label":e.label,className:`flex flex-col`,children:[(0,X.jsx)(`h2`,{className:`px-[10px] pt-[14px] pb-[4px] text-[11px] font-medium text-soft-foreground`,children:e.label}),(0,X.jsx)(`ul`,{className:`flex flex-col`,children:e.commits.map(e=>(0,X.jsxs)(`li`,{className:`flex min-h-[52px] items-center gap-[14px] rounded-[6px] hover:bg-sidebar-row-hover`,children:[(0,X.jsxs)(F,{to:`/git/commits/${e.hash}`,"data-slot":`commit-row`,"data-sha":e.hash,className:`flex min-h-[52px] min-w-0 flex-1 flex-col justify-center gap-[3px] rounded-[6px] px-[10px] py-[6px] focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,X.jsx)(`span`,{"data-slot":`commit-row-subject`,className:`truncate text-[13px] text-foreground`,children:e.subject}),(0,X.jsxs)(`span`,{"data-slot":`commit-row-meta`,className:`flex min-w-0 items-center gap-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono`,children:e.hash}),(0,X.jsxs)(`span`,{className:`truncate`,children:[`· `,e.author,` · `,Ye(e.when)]})]})]}),(0,X.jsx)(dt,{source:e.source})]},e.hash))})]},e.label))]})}function dt({source:e}){let t=`hidden max-w-[45%] shrink-0 items-center gap-[5px] pr-[10px] text-[11.5px] text-soft-foreground md:flex`;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:a(t,`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)(ce,{"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)(me,{"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:t,children:`no task found`})}function ft({info:e,tracking:t}){let n=Ue(r(),e),i=(0,Y.useRef)(null);return(0,X.jsxs)(`div`,{"data-slot":`git-incoming`,className:`mb-[4px] flex min-h-[40px] items-center gap-[8px] rounded-[8px] border border-border px-[10px] py-[6px]`,children:[(0,X.jsx)(et,{"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:i,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[26px] 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)(Ee,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,X.jsx)(pe,{"aria-hidden":`true`}),`Pull`]}),(0,X.jsx)(He,{checkout:n,returnFocus:i})]})}function pt({sha:e}){return(0,X.jsx)(Qe,{commit:S(e),sha:e,backTo:L()?`/git`:Ge,backLabel:`All recent commits`,slot:`repo-commit`,className:`flex min-h-0 flex-1 flex-col`,diffClassName:`px-4 py-4 [--diff-sticky-top:1rem] md:px-6`})}var $=`Squash-merged branches may show as not landed without GitHub`;function mt(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 ht(e){return e.filter(e=>e.class===`active`&&e.runId!==null&&e.ahead>0&&(e.runStatus===`done`||e.runStatus===`failed`||e.runStatus===`cancelled`)).length}var gt={done:`success`,failed:`danger`,cancelled:`neutral`};function _t(){let e=C(),t=ne(),n=r(),i=y(),[a,o]=(0,Y.useState)(null);if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`not-landed-loading`,role:`status`,className:`px-[28px] py-[20px] text-[13px] text-soft-foreground`,children:`Loading branches…`});if(e.isError)return(0,X.jsx)(I,{icon:(0,X.jsx)(k,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let s=mt(e.data.branches),c=ht(e.data.branches),l=c>0?(0,X.jsxs)(`p`,{"data-slot":`not-landed-retained`,className:`flex items-start gap-[6px] px-[10px] pt-[6px] text-[11.5px] leading-[17px] text-soft-foreground`,children:[(0,X.jsx)(j,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),(0,X.jsxs)(`span`,{children:[c,` finished task`,c===1?` still has its`:`s still have their`,` worktree and commits not on the base, so `,c===1?`it is`:`they are`,` not listed here.`,` `,`They show here once the worktree is reclaimed in `,(0,X.jsx)(F,{to:Re.cleanup,className:`underline underline-offset-2 hover:text-foreground`,children:`Cleanup`}),`.`]})]}):null,u=new Map((t.data??[]).map(e=>[e.id,e.finishedAt]));return(0,X.jsxs)(Oe,{projectId:n,repoBase:i,requests:s.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-[2px] px-[8px] pt-[12px] pb-[calc(90px+env(safe-area-inset-bottom))] md:px-[20px] md:pb-[20px]`,children:[e.data.prStateKnown?null:(0,X.jsx)(vt,{}),l,s.length===0?(0,X.jsx)(I,{icon:(0,X.jsx)(Be,{size:16}),tone:`neutral`,heading:`h2`,title:c>0?`Nothing else waiting to land`:`Everything landed`,subtitle:c>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.`}):(0,X.jsxs)(X.Fragment,{children:[s.map(e=>(0,X.jsxs)(`section`,{"data-slot":`not-landed-group`,"data-group":e.key,"aria-label":e.title,className:`flex flex-col`,children:[(0,X.jsxs)(`h2`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-[6px] px-[10px] pt-[14px] pb-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,X.jsx)(`span`,{children:e.rows.length}),e.note?(0,X.jsxs)(`span`,{children:[`· `,e.note]}):null]}),(0,X.jsx)(`ul`,{className:`flex flex-col`,children:e.rows.map(e=>(0,X.jsx)(yt,{entry:e,finishedAt:e.runId?u.get(e.runId):void 0,onDelete:()=>o(e)},e.name))})]},e.key)),(0,X.jsxs)(`p`,{"data-slot":`not-landed-note`,className:`flex items-start gap-[6px] px-[10px] pt-[14px] text-[11.5px] leading-[17px] text-soft-foreground`,children:[(0,X.jsx)(j,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),`Delete branch is in each row's … menu. It confirms and names the commits it drops. Nothing on this list can be bulk-deleted.`]})]})]}),(0,X.jsx)(wt,{entry:a,onClose:()=>o(null)})]})}function vt({className:e}){return(0,X.jsxs)(`p`,{"data-slot":`git-no-forge`,className:a(`flex items-start gap-[6px] px-[10px] pt-[6px] text-[11.5px] leading-[17px] text-soft-foreground`,e),children:[(0,X.jsx)(j,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),$,`.`]})}function yt({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-[56px] items-center gap-[12px] rounded-[6px] px-[10px] py-[6px] hover:bg-sidebar-row-hover`,children:[(0,X.jsx)(St,{entry:e,finishedAt:t}),(0,X.jsx)(bt,{entry:e}),(0,X.jsx)(xt,{entry:e,onDelete:n})]})}function bt({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-[4px] text-[11.5px] text-muted-foreground md:flex`,children:[(0,X.jsx)(Ae,{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)(Ct,{entry:e})]}):null})}function xt({entry:e,onDelete:t}){let n=d(),r=e.class===`orphan`,i=e.pr&&(e.pr.state===`open`||e.pr.state===`draft`)?e.pr:null,o=!r&&e.runId!==null&&!i,s=b({mutationFn:()=>p(e.runId),onSuccess:e=>{E(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:w.repoBranches}),n.invalidateQueries({queryKey:w.runs.all})},onError:e=>E(e instanceof f&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),c=()=>void navigator.clipboard.writeText(e.name).then(()=>E(`Copied ${e.name}`),()=>E(`Could not copy the branch name`,{tone:`danger`})),l=`inline-flex h-[28px] shrink-0 items-center gap-[5px] rounded-[6px] px-[10px] text-[12px] 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:a(l,`hidden border border-border hover:bg-muted md:inline-flex`),children:`Open task`}):null,o?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-create-pr`,disabled:s.isPending,onClick:()=>s.mutate(),className:a(l,`hidden bg-muted hover:brightness-110 md:inline-flex`),children:[(0,X.jsx)(tt,{"aria-hidden":`true`}),s.isPending?`Creating…`:`Create draft PR`]}):null,r?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,onClick:c,className:a(l,`hidden border border-border hover:bg-muted md:inline-flex`),children:[(0,X.jsx)(ge,{"aria-hidden":`true`}),`Copy branch`]}):null,(0,X.jsxs)(Pe,{children:[(0,X.jsx)(Me,{"data-action":`not-landed-more`,"aria-label":`More actions for ${e.name}`,className:`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] 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)(_e,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,X.jsxs)(Ne,{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,o?(0,X.jsx)(P,{className:`md:hidden`,disabled:s.isPending,onSelect:()=>s.mutate(),children:`Create draft PR`}):null,(0,X.jsx)(P,{className:a(!r&&`md:hidden`),onSelect:c,children:`Copy branch`}),(0,X.jsx)(je,{className:`md:hidden`}),(0,X.jsx)(P,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function St({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=M(t??e.lastCommit.at),a=n||!e.runStatus?i?`${i} ago`:``:`${e.runStatus}${i?` ${i} ago`:``}`;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)(be,{"aria-label":`Task deleted`,className:`size-[12px] text-soft-foreground`}):(0,X.jsx)(Fe,{tone:e.runStatus&&gt[e.runStatus]||`neutral`,"aria-label":e.runStatus??void 0})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[3px]`,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] 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] text-muted-foreground`,title:r,children:r}),(0,X.jsxs)(`span`,{"data-slot":`not-landed-meta`,className:`flex min-w-0 items-center gap-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-muted-foreground`,children:e.name}),(0,X.jsxs)(`span`,{className:`shrink-0`,children:[`· `,e.ahead,` commit`,e.ahead===1?``:`s`]}),e.diffStat?(0,X.jsxs)(`span`,{className:`flex shrink-0 gap-[4px] tabular-nums`,children:[(0,X.jsxs)(`span`,{className:`text-success`,children:[`+`,e.diffStat.additions]}),(0,X.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.diffStat.deletions]})]}):null,a?(0,X.jsxs)(`span`,{className:`truncate`,children:[`· `,a]}):null]}),e.parentRunId?(0,X.jsx)(F,{to:`/tasks/${e.parentRunId}`,"data-slot":`not-landed-parent`,className:`w-fit rounded-[2px] text-[11px] text-soft-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:`Worker of its parent task`}):null,(0,X.jsx)(Z,{entry:e})]})]})}function Ct({entry:e}){let t=h(De(`PR`,e.pr?.number).status),n=e.pr?.state;return(0,X.jsxs)(`span`,{"data-slot":`not-landed-pr-state`,children:[`· `,n===`draft`||n===`closed`?n:t?t.label.toLowerCase():`open`]})}function wt({entry:e,onClose:t}){let n=d(),[r,i]=(0,Y.useState)(``),a=(0,Y.useId)(),o=b({mutationFn:e=>s({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;E(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:w.repo}),c()},onError:e=>E(e.message,{tone:`danger`})}),c=()=>{i(``),t()},l=e!==null&&r.trim()===e.name,u=e&&`${e.ahead} commit${e.ahead===1?``:`s`}`;return(0,X.jsx)(R,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&c(),children:(0,X.jsxs)(W,{"data-slot":`delete-branch-dialog`,children:[(0,X.jsxs)(U,{children:[(0,X.jsxs)(q,{children:[`Delete `,e?.name,`?`]}),(0,X.jsx)(K,{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:[u,` will be dropped`,e?.diffStat?` (+${e.diffStat.additions} −${e.diffStat.deletions})`:``,`, the latest “`,e?.lastCommit.subject,`”`,` `,`(`,(0,X.jsx)(`span`,{className:`font-mono`,children:e?.lastCommit.sha.slice(0,7)}),`).`]})]})})]}),(0,X.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),l&&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)(V,{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)(B,{children:[(0,X.jsx)(H,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,X.jsx)(G,{"data-action":`delete-branch-confirm`,className:`h-11 bg-danger text-danger-foreground hover:brightness-[0.96]`,disabled:!l||o.isPending,onClick:t=>{t.preventDefault(),e&&o.mutate(e.name)},children:o.isPending?`Deleting…`:`Delete branch`})]})]})})}function Tt({base:e}){let t=C(),n=d(),[r,i]=(0,Y.useState)({merged:!1,empty:!1}),[a,o]=(0,Y.useState)(!1),c=(t.data?.branches??[]).filter(e=>e.class===`merged`),l=(t.data?.branches??[]).filter(e=>e.class===`empty`),u=[...c,...l],f=b({mutationFn:e=>s({names:e}),onSuccess:e=>{let t=e.refused.length;E(`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:w.repo})},onError:e=>{n.invalidateQueries({queryKey:w.repo}),E(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 p=u.length,m=`branch${p===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 · `,p]}),(0,X.jsxs)(`p`,{className:`text-[11.5px] 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:p===0||f.isPending,onClick:()=>o(!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)(de,{"aria-hidden":`true`,className:`size-[12px]`}),f.isPending?`Deleting…`:`Delete ${p} ${m}`]})]}),(0,X.jsx)(Et,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:$.toLowerCase(),rows:c,open:r.merged,onToggle:()=>i(e=>({...e,merged:!e.merged}))}),(0,X.jsx)(Et,{kind:`empty`,title:`Empty`,hint:`no commits beyond the fork point`,rows:l,open:r.empty,onToggle:()=>i(e=>({...e,empty:!e.empty}))}),(0,X.jsx)(R,{open:a,onOpenChange:o,children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(U,{children:[(0,X.jsxs)(q,{children:[`Delete `,p,` `,m,`?`]}),(0,X.jsxs)(K,{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)(B,{children:[(0,X.jsx)(H,{children:`Keep them`}),(0,X.jsxs)(G,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{f.mutate(u.map(e=>e.name)),o(!1)},children:[`Delete `,p,` `,m]})]})]})})]})}function Et({kind:e,title:t,hint:n,rows:r,open:i,onToggle:o}){let s=`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":s,disabled:r.length===0,onClick:o,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-[11px] text-soft-foreground`,children:n})]}),r.length>0?(0,X.jsx)(he,{"aria-hidden":`true`,className:a(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,i&&`rotate-90`)}):null]}),i?(0,X.jsx)(`ul`,{id:s,"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-[11.5px]`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-muted-foreground`,children:e.name}),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)(`span`,{className:`shrink-0 tabular-nums text-soft-foreground`,children:M(e.lastCommit.at)})]},e.name))}):null]})}function Dt(){let e=ee(),t=_().data?.targets.find(e=>e.id===`finder`),n=b({mutationFn:e=>o(e,t.id),onError:e=>E(e.message,{tone:`danger`})}),r=d(),[i,a]=(0,Y.useState)(!1),s=()=>Promise.all([r.invalidateQueries({queryKey:w.worktrees}),r.invalidateQueries({queryKey:w.repoBranches})]),c=b({mutationFn:e=>u(),onSuccess:(e,t)=>{s();let n=e.reclaimed.length,r=Math.max(0,t-n);E(n===0?r>0?`Nothing was reclaimed — the worktrees past the keep limit have uncommitted work or are in use`:`Nothing to reclaim — no finished worktrees exceed the keep limit`:`Reclaimed ${n} worktree${n===1?``:`s`} (branch kept)${r>0?` · ${r} kept: uncommitted work or in use`:``}`)},onError:e=>E(e.message,{tone:`danger`})}),f=b({mutationFn:e=>l(e.runId),onSuccess:(e,t)=>{s(),E(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{s(),E(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:p,totalBytes:m,keep:h}=e.data,g=c.isPending||f.isPending,v=p.filter(e=>e.pastKeep),y=v.length>0,x=v.some(e=>e.sizeBytes===null)?null:v.reduce((e,t)=>e+(t.sizeBytes??0),0),S=y?x?`Reclaim ${T(x)} now`:`Reclaim ${v.length} now`:`Reclaim now`,C=m?T(m):null;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`,C?` · ${C}`:``]}),(0,X.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-[11.5px] leading-[17px] text-soft-foreground`,children:[h===0?`Retention is unlimited (`:`Retention keeps the newest ${h} finished checkout${h===1?``:`s`} (`,(0,X.jsx)(F,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:ke(`worktrees`,` › `)}),h===0?`), so nothing is reclaimed on its own.`:`) and reclaims the rest.`,` `,`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:g||!y,title:y?void 0:`Nothing past the keep limit to reclaim`,onClick:()=>a(!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)(J,{"aria-hidden":`true`,className:`size-[12px]`}),S]})]}),p.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:p.map(e=>(0,X.jsx)(At,{worktree:e,keep:h,disabled:g,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>f.mutate(e)},e.runId))}),(0,X.jsx)(R,{open:i,onOpenChange:a,children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(U,{children:[(0,X.jsx)(q,{children:`Reclaim old worktrees?`}),(0,X.jsxs)(K,{children:[v.length,` finished worktree`,v.length===1?``:`s`,` beyond the keep limit`,x?` (${T(x)})`:``,` `,v.length===1?`is`:`are`,` reclaimed now, directory only. Their branches are kept, so the work stays recoverable.`]})]}),(0,X.jsxs)(B,{children:[(0,X.jsx)(H,{children:`Keep them`}),(0,X.jsx)(G,{"data-action":`worktrees-confirm`,onClick:()=>{c.mutate(v.length),a(!1)},children:S})]})]})})]})}var Ot=new Set([`queued`,`running`,`waiting`,`review`]);function kt(e,t){return Ot.has(e.status)||!e.reclaimable?{label:`in use`,tone:`in-use`}:e.pastKeep?{label:`reclaimable`,tone:`plain`}:{label:t>0?`kept · newest ${t}`:`kept`,tone:`plain`}}function At({worktree:e,keep:t,disabled:n,onOpen:r,opening:i,onReclaim:o}){let s=kt(e,t),c=M(e.finishedAt??void 0),l=e.status===`review`?`at review`:c?`${e.status} ${c} ago`:e.status,u=(0,X.jsx)(`span`,{"data-slot":`worktree-state`,"data-state":s.tone===`in-use`?`in-use`:e.pastKeep?`reclaimable`:`kept`,className:a(`text-[11.5px]`,s.tone===`in-use`?`text-status-running`:`text-soft-foreground`),children:s.label}),d=`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`;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-[10.5px] text-soft-foreground`,children:[e.branch??e.runId.slice(0,8),` · `,l,(0,X.jsxs)(`span`,{className:`md:hidden`,children:[` · `,s.label]})]})]}),(0,X.jsx)(`span`,{"data-slot":`worktree-size`,className:`shrink-0 text-[11.5px] tabular-nums text-muted-foreground`,children:e.sizeBytes===null?`—`:T(e.sizeBytes)||`0 kB`}),(0,X.jsx)(`span`,{className:`hidden shrink-0 md:inline`,children:u}),r?(0,X.jsx)(`button`,{type:`button`,className:d,"aria-label":`Open folder for ${e.title}`,title:`Open folder`,disabled:i,onClick:r,children:(0,X.jsx)(ae,{"aria-hidden":`true`,className:`size-[13px]`})}):null,s.tone===`in-use`?null:(0,X.jsx)(`button`,{type:`button`,"data-action":`worktree-reclaim`,"aria-label":`Reclaim the worktree of ${e.title} (branch kept)`,title:`Reclaim the directory (branch kept)`,disabled:n,onClick:o,className:d,children:(0,X.jsx)(J,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function jt({section:e,index:t=!1}){let n=x(),r=L(),[i]=re();if(t&&!r&&i.get(`view`)!==`repo`)return(0,X.jsx)(nt,{});if(n.isPending)return(0,X.jsx)(Le,{});if(n.isError)return(0,X.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(z,{}),(0,X.jsx)(I,{icon:(0,X.jsx)(k,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:n.error.message})]});let a=n.data.info;return a?(0,X.jsx)(Mt,{repo:n.data,info:a,section:e}):(0,X.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(z,{}),(0,X.jsx)(I,{icon:(0,X.jsx)(D,{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 Mt({repo:e,info:t,section:n}){return(0,X.jsxs)(`div`,{"data-route":`repo-git`,"data-git-section":n,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(z,{}),(0,X.jsxs)(`header`,{"data-slot":`repo-header`,className:`flex flex-col gap-1 px-[18px] pt-[18px] md:min-h-[61px] md:flex-row md:items-center md:gap-[10px] md:border-b md:border-border md:px-7 md:py-4`,children:[(0,X.jsx)(`h1`,{className:`min-w-0 flex-1 truncate text-2xl font-semibold tracking-tight md:text-[15px] md:tracking-normal`,children:Ie(n,t.branch)}),(0,X.jsx)(`p`,{"data-slot":`repo-meta`,className:`min-w-0 truncate text-[12px] text-soft-foreground md:text-[11.5px]`,children:(0,X.jsx)(Nt,{repo:e,info:t,section:n})})]}),n===`main`?(0,X.jsx)(ut,{repo:e,info:t}):n===`not-landed`?(0,X.jsx)(_t,{}):n===`cleanup`?(0,X.jsxs)(`div`,{"data-slot":`repo-cleanup`,className:`flex flex-col gap-[16px] px-[18px] pt-[12px] pb-[calc(90px+env(safe-area-inset-bottom))] md:px-[20px] md:pb-[20px]`,children:[(0,X.jsx)(Dt,{}),(0,X.jsx)(Tt,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,X.jsx)(rt,{repo:e,info:t}):(0,X.jsx)(lt,{})]})}function Nt({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?` · ${Ve(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)(Pt,{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 Pt({repo:e,info:t}){let n=Q(e,C().data?.branches).length;return(0,X.jsxs)(X.Fragment,{children:[n,` branch`,n===1?``:`es`,` · on `,t.branch]})}export{jt 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{c as r,n as i,t as a}from"./utils-DSMR_WLb.js";import{Lt as o,O as s,S as c,Xt as l,Zt as u,ci as d,i as f,w as p}from"./project-scope-context-D1bpJixc.js";import{Y as m}from"./live-protocol-D9ji1YCl.js";import{Bt as h,C as g,L as _,M as v,Mt as ee,U as y,Yt as b,at as x,ct as S,ot as C,st as te,t as w,vt as ne}from"./queries-dHXhD3Hc.js";import{g as re,h as ie}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{i as T}from"./tasks-table-DHTEGteC.js";import{n as E}from"./toaster-Bo5vCbz-.js";import{A as D,C as O,E as ae,F as oe,J as se,M as ce,X as le,Y as ue,at as de,j as fe,n as pe,ot as k,s as me,u as he,v as ge,x as _e}from"./design-icons-CzEoMH9c.js";import{t as A}from"./createLucideIcon-BHp8sXmF.js";import{l as ve,n as ye,y as be}from"./nav-row-styles-DqKjMToI.js";import{n as xe,r as Se}from"./diff-controls-BSWICnsb.js";import{i as Ce,r as we,t as Te}from"./git-toolbar-DoPFA36c.js";import{t as j}from"./info-DA1x_4bz.js";import{a as Ee,i as M}from"./format-BNCkW110.js";import{c as De,i as Oe,l as ke,t as Ae}from"./reference-chip-BWViAFIN.js";import{t as N}from"./button-BQ2y4XRB.js";import{i as P,l as je,p as Me,r as Ne,t as Pe}from"./dropdown-menu-4e2iKSMT.js";import{t as F}from"./project-router-CIKODSHW.js";import{t as Fe}from"./status-dot-DtAOFiIi.js";import{t as I}from"./centered-state-V15AR_qo.js";import{$t as L,At as Ie,Bt as R,D as z,E as Le,Ft as Re,Gt as B,Hn as V,Ht as H,It as ze,Jn as Be,Kt as U,Lt as Ve,Mt as He,Nt as Ue,Ot as We,Pt as Ge,Rt as Ke,Ut as W,Vt as G,Wt as K,jt as qe,kt as Je,qt as q,tr as J,zt as Ye}from"./index-CmadQXcg.js";import{t as Xe}from"./markdown-BBDDg-4t.js";import{t as Ze}from"./diff-BB8SoL-s.js";import{t as Qe}from"./commit-diff-panel-xwLW6Ydr.js";var Y=e(t(),1);function $e(e,t){let n=d(t),r=n.getQueryCache();return Y.useSyncExternalStore(Y.useCallback(e=>r.subscribe(m.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var et=A(`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`}]]),tt=A(`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=r(),t=x(),n=d(),i=$e({queryKey:w.repo})>0,o=t.data?.info?t.data:null,s=We(e,o,`screen`);return(0,X.jsxs)(`div`,{"data-route":`repo-git`,"data-slot":`git-screen`,className:ye,children:[(0,X.jsxs)(`div`,{className:`mb-[16px] flex items-center gap-[8px]`,children:[(0,X.jsx)(`h1`,{className:a(ve,`min-w-0 flex-1`),children:`Git`}),(0,X.jsx)(`button`,{type:`button`,"data-slot":`git-screen-refresh`,"aria-label":`Refresh the repository`,title:`Refresh the repository`,disabled:i,onClick:()=>{n.invalidateQueries({queryKey:w.repo}),n.invalidateQueries({queryKey:w.worktrees})},className:`-my-2 -mr-[10px] flex size-11 shrink-0 items-center justify-center rounded-md text-soft-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-60`,children:(0,X.jsx)(ue,{size:17,"aria-hidden":`true`,className:a(`size-[17px]`,i&&`motion-safe:animate-spin`)})})]}),o?.info?(0,X.jsx)(`div`,{className:`mb-[16px]`,children:(0,X.jsx)(qe,{scope:e,repo:o,info:o.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)(Je,{branch:o?.info?.branch??null,counts:s,variant:`screen`})]})}function Z({entry:e}){return e.keptReason?(0,X.jsx)(`span`,{"data-slot":`branch-kept-reason`,className:`min-w-0 text-[11px] text-soft-foreground`,children:e.keptReason}):null}function rt({repo:e,info:t}){let n=v(),r=C(),i=new Map((r.data?.branches??[]).map(e=>[e.name,e])),o=d(),s=b({mutationFn:e=>c({name:e}),onSuccess:async e=>{E(e.created?`Created and switched to ${e.branch}`:`Switched to ${e.branch}`),await Promise.all([o.invalidateQueries({queryKey:w.repo}),o.invalidateQueries({queryKey:w.health})]),o.setQueryData(w.repo,t=>t?.info?{...t,info:{...t.info,branch:e.branch}}:t),o.setQueryData(w.health,n=>n?.repo?.root===t.root?{...n,repo:{...n.repo,branch:e.branch}}:n)},onError:e=>E(e.message,{tone:`danger`})}),[l,u]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(``),m=f.trim().toLowerCase(),h=Q(e,r.data?.branches),g=m?h.filter(e=>e.toLowerCase().includes(m)):h;return(0,X.jsxs)(`section`,{"data-slot":`repo-branches`,className:`grid min-w-0 grid-cols-1 gap-5 px-[18px] py-[22px] md:grid-cols-[minmax(0,1fr)_290px] md:px-9`,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)(le,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,X.jsx)(V,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:f,onChange:e=>p(e.target.value),className:`h-11 pl-10`})]}),(0,X.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-4 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:[g.map(e=>{let n=e===t.branch,r=i.get(e);return(0,X.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,"data-branch-class":r?.class,className:`flex min-h-20 flex-col items-start justify-center gap-2 py-3 md:flex-row md:items-center md:justify-start md:py-2.5`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-[8px]`,children:[r?.runId?(0,X.jsx)(F,{to:`/tasks/${r.runId}`,"data-slot":`branch-task-link`,title:r.title?`Open the task ${r.title}`:`Open the task`,className:`min-w-0 truncate rounded-[2px] text-[13px] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:e}):(0,X.jsx)(`span`,{className:a(`min-w-0 truncate text-[13px]`,n&&`font-normal`),children:e}),r?(0,X.jsx)(ct,{entry:r}):null]}),r?(0,X.jsx)(Z,{entry:r}):null,e.startsWith(`cez/`)&&!n?null:n?(0,X.jsx)(`span`,{"data-slot":`branch-current`,className:`md:ml-auto flex shrink-0 items-center rounded-md bg-accent-strong/10 px-2 py-1.5 text-[12px] font-medium text-accent-text`,children:`Current`}):(0,X.jsxs)(N,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`md:ml-auto h-11`,disabled:s.isPending,onClick:()=>s.mutate(e),children:[(0,X.jsx)(D,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),g.length===0?(0,X.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-soft-foreground`,children:[`No branches match “`,f.trim(),`”.`]}):null]})]}),(0,X.jsxs)(`div`,{className:`min-w-0 self-start rounded-xl border border-border bg-card p-5`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:`Create a branch`}),(0,X.jsxs)(`form`,{"data-slot":`branch-create`,className:`mt-7 flex flex-col items-stretch gap-3`,onSubmit:e=>{e.preventDefault();let t=l.trim();t&&s.mutate(t,{onSuccess:()=>u(``)})},children:[(0,X.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,X.jsx)(`p`,{className:`-mt-1 text-xs text-muted-foreground`,children:`Create from the selected base.`}),(0,X.jsx)(V,{id:`new-branch-name`,"aria-label":`New branch name`,placeholder:`new-branch-name`,className:`h-11 bg-background`,value:l,onChange:e=>u(e.target.value)}),(0,X.jsxs)(N,{type:`submit`,variant:`primary`,size:`sm`,className:`min-h-11 self-start`,"data-action":`create-branch`,disabled:!l.trim()||s.isPending,children:[(0,X.jsx)(se,{size:16,"aria-hidden":`true`}),`Create branch`]})]}),(0,X.jsx)(`p`,{className:`mt-3 border-t border-border pt-4 text-xs leading-relaxed text-muted-foreground`,children:`Switching branches changes your working tree. Review uncommitted changes first.`})]}),n.data?.forge?.available?(0,X.jsx)(it,{}):null]})}function it(){let e=g({limit:20});return(0,X.jsxs)(`div`,{"data-slot":`repo-prs`,className:`max-w-xl`,children:[(0,X.jsx)(`h2`,{className:`text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Open pull requests`}),e.isPending?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`Loading pull requests…`}):e.isError?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:e.error.message}):e.data.available?e.data.prs.length===0?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`No open pull requests.`}):(0,X.jsx)(`ul`,{className:`mt-2 flex flex-col divide-y divide-border`,children:e.data.prs.map(e=>(0,X.jsx)(at,{pr:e},e.number))}):(0,X.jsx)(`p`,{"data-slot":`repo-prs-unavailable`,className:`mt-2 text-xs text-soft-foreground`,children:e.data.reason??`The forge is unreachable right now.`})]})}function at({pr:e}){let t=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(oe,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:[`#`,e.number]}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.title}),e.checks?(0,X.jsx)(ot,{checks:e.checks}):null]}),n=`flex min-w-0 items-center gap-2 rounded-sm px-1.5 py-2`;return(0,X.jsx)(`li`,{"data-slot":`pr-row`,"data-number":e.number,children:i(e.url)?(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:a(n,`hover:bg-muted`),children:t}):(0,X.jsx)(`span`,{className:n,children:t})})}function ot({checks:e}){return(0,X.jsx)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:a(`shrink-0 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:e})}var st={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function ct({entry:e}){return(0,X.jsx)(`span`,{"data-slot":`branch-class`,className:a(`shrink-0 rounded-[4px] border px-[5px] py-[1px] text-[10.5px] leading-[14px]`,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:st[e.class]})}function Q(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 lt(){let e=te(),t=L(),[n,r]=(0,Y.useState)(`unified`),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),u=(0,Y.useRef)(null),d=e.isError&&e.error instanceof f&&e.error.status===409,p=e.data?.files??[],m=(0,Y.useMemo)(()=>we(p),[p]),h=(0,Y.useMemo)(()=>p.some(Xe),[p]),g=t?n:`unified`,_=!t||i;return(0,X.jsxs)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,X.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 px-[18px] py-[22px] md:px-9`,children:[(0,X.jsx)(`span`,{className:`text-sm`,children:e.data?`${e.data.stat.files} files changed ·`:`Uncommitted changes`}),e.data?(0,X.jsx)(Te,{stat:e.data.stat}):null,(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`hidden items-center gap-1 md:flex`,children:(0,X.jsx)(xe,{mode:n,wrap:i,onModeChange:r,onWrapChange:a})}),h?(0,X.jsx)(Se,{preview:o,onPreviewChange:s}):null]})]}),e.isPending?(0,X.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading changes…`}):e.isError?(0,X.jsx)(I,{icon:d?(0,X.jsx)(O,{size:16}):(0,X.jsx)(k,{size:16}),tone:d?`neutral`:`danger`,heading:`h2`,title:d?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):p.length===0?(0,X.jsx)(I,{icon:(0,X.jsx)(O,{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)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 md:flex-row md:items-start px-[18px] pb-9 pt-0 [--diff-sticky-top:1rem] md:px-9`,children:[(0,X.jsxs)(`aside`,{"data-slot":`changes-tree-pane`,className:`md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] w-full md:w-60 shrink-0 overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 lg:w-[250px]`,children:[(0,X.jsx)(`h2`,{className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,X.jsx)(Ce,{root:m,selected:c,onSelect:e=>{l(e),u.current?.scrollToPath(e)}})]}),(0,X.jsx)(Ze,{files:p,viewRef:u,mode:g,wrap:_,preview:o,className:`min-w-0 flex-1`})]})]})}function ut({repo:e,info:t}){let{sha:n}=ie(),r=e.log,i=(0,Y.useMemo)(()=>Ke(r),[r]);if(n)return(0,X.jsx)(pt,{sha:n});let a=ze(e,t),o=a&&a.behind>0?(0,X.jsx)(ft,{info:t,tracking:a}):null;return r.length===0?(0,X.jsxs)(X.Fragment,{children:[o?(0,X.jsx)(`div`,{className:`px-[8px] pt-[12px] md:px-[20px]`,children:o}):null,(0,X.jsx)(I,{icon:(0,X.jsx)(fe,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`})]}):(0,X.jsxs)(`div`,{"data-slot":`repo-commits`,className:`flex flex-col gap-[2px] px-[8px] pt-[12px] pb-[20px] md:px-[20px]`,children:[o,i.map(e=>(0,X.jsxs)(`section`,{"data-slot":`repo-commit-day`,"aria-label":e.label,className:`flex flex-col`,children:[(0,X.jsx)(`h2`,{className:`px-[10px] pt-[14px] pb-[4px] text-[11px] font-medium text-soft-foreground`,children:e.label}),(0,X.jsx)(`ul`,{className:`flex flex-col`,children:e.commits.map(e=>(0,X.jsxs)(`li`,{className:`flex min-h-[52px] items-center gap-[14px] rounded-[6px] hover:bg-sidebar-row-hover`,children:[(0,X.jsxs)(F,{to:`/git/commits/${e.hash}`,"data-slot":`commit-row`,"data-sha":e.hash,className:`flex min-h-[52px] min-w-0 flex-1 flex-col justify-center gap-[3px] rounded-[6px] px-[10px] py-[6px] focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,X.jsx)(`span`,{"data-slot":`commit-row-subject`,className:`truncate text-[13px] text-foreground`,children:e.subject}),(0,X.jsxs)(`span`,{"data-slot":`commit-row-meta`,className:`flex min-w-0 items-center gap-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono`,children:e.hash}),(0,X.jsxs)(`span`,{className:`truncate`,children:[`· `,e.author,` · `,Ye(e.when)]})]})]}),(0,X.jsx)(dt,{source:e.source})]},e.hash))})]},e.label))]})}function dt({source:e}){let t=`hidden max-w-[45%] shrink-0 items-center gap-[5px] pr-[10px] text-[11.5px] text-soft-foreground md:flex`;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:a(t,`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)(ce,{"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)(me,{"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:t,children:`no task found`})}function ft({info:e,tracking:t}){let n=Ue(r(),e),i=(0,Y.useRef)(null);return(0,X.jsxs)(`div`,{"data-slot":`git-incoming`,className:`mb-[4px] flex min-h-[40px] items-center gap-[8px] rounded-[8px] border border-border px-[10px] py-[6px]`,children:[(0,X.jsx)(et,{"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:i,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[26px] 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)(Ee,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,X.jsx)(pe,{"aria-hidden":`true`}),`Pull`]}),(0,X.jsx)(He,{checkout:n,returnFocus:i})]})}function pt({sha:e}){return(0,X.jsx)(Qe,{commit:S(e),sha:e,backTo:L()?`/git`:Ge,backLabel:`All recent commits`,slot:`repo-commit`,className:`flex min-h-0 flex-1 flex-col`,diffClassName:`px-4 py-4 [--diff-sticky-top:1rem] md:px-6`})}var $=`Squash-merged branches may show as not landed without GitHub`;function mt(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 ht(e){return e.filter(e=>e.class===`active`&&e.runId!==null&&e.ahead>0&&(e.runStatus===`done`||e.runStatus===`failed`||e.runStatus===`cancelled`)).length}var gt={done:`success`,failed:`danger`,cancelled:`neutral`};function _t(){let e=C(),t=ne(),n=r(),i=y(),[a,o]=(0,Y.useState)(null);if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`not-landed-loading`,role:`status`,className:`px-[28px] py-[20px] text-[13px] text-soft-foreground`,children:`Loading branches…`});if(e.isError)return(0,X.jsx)(I,{icon:(0,X.jsx)(k,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let s=mt(e.data.branches),c=ht(e.data.branches),l=c>0?(0,X.jsxs)(`p`,{"data-slot":`not-landed-retained`,className:`flex items-start gap-[6px] px-[10px] pt-[6px] text-[11.5px] leading-[17px] text-soft-foreground`,children:[(0,X.jsx)(j,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),(0,X.jsxs)(`span`,{children:[c,` finished task`,c===1?` still has its`:`s still have their`,` worktree and commits not on the base, so `,c===1?`it is`:`they are`,` not listed here.`,` `,`They show here once the worktree is reclaimed in `,(0,X.jsx)(F,{to:Re.cleanup,className:`underline underline-offset-2 hover:text-foreground`,children:`Cleanup`}),`.`]})]}):null,u=new Map((t.data??[]).map(e=>[e.id,e.finishedAt]));return(0,X.jsxs)(Oe,{projectId:n,repoBase:i,requests:s.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-[2px] px-[8px] pt-[12px] pb-[calc(90px+env(safe-area-inset-bottom))] md:px-[20px] md:pb-[20px]`,children:[e.data.prStateKnown?null:(0,X.jsx)(vt,{}),l,s.length===0?(0,X.jsx)(I,{icon:(0,X.jsx)(Be,{size:16}),tone:`neutral`,heading:`h2`,title:c>0?`Nothing else waiting to land`:`Everything landed`,subtitle:c>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.`}):(0,X.jsxs)(X.Fragment,{children:[s.map(e=>(0,X.jsxs)(`section`,{"data-slot":`not-landed-group`,"data-group":e.key,"aria-label":e.title,className:`flex flex-col`,children:[(0,X.jsxs)(`h2`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-[6px] px-[10px] pt-[14px] pb-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,X.jsx)(`span`,{children:e.rows.length}),e.note?(0,X.jsxs)(`span`,{children:[`· `,e.note]}):null]}),(0,X.jsx)(`ul`,{className:`flex flex-col`,children:e.rows.map(e=>(0,X.jsx)(yt,{entry:e,finishedAt:e.runId?u.get(e.runId):void 0,onDelete:()=>o(e)},e.name))})]},e.key)),(0,X.jsxs)(`p`,{"data-slot":`not-landed-note`,className:`flex items-start gap-[6px] px-[10px] pt-[14px] text-[11.5px] leading-[17px] text-soft-foreground`,children:[(0,X.jsx)(j,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),`Delete branch is in each row's … menu. It confirms and names the commits it drops. Nothing on this list can be bulk-deleted.`]})]})]}),(0,X.jsx)(wt,{entry:a,onClose:()=>o(null)})]})}function vt({className:e}){return(0,X.jsxs)(`p`,{"data-slot":`git-no-forge`,className:a(`flex items-start gap-[6px] px-[10px] pt-[6px] text-[11.5px] leading-[17px] text-soft-foreground`,e),children:[(0,X.jsx)(j,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),$,`.`]})}function yt({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-[56px] items-center gap-[12px] rounded-[6px] px-[10px] py-[6px] hover:bg-sidebar-row-hover`,children:[(0,X.jsx)(St,{entry:e,finishedAt:t}),(0,X.jsx)(bt,{entry:e}),(0,X.jsx)(xt,{entry:e,onDelete:n})]})}function bt({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-[4px] text-[11.5px] text-muted-foreground md:flex`,children:[(0,X.jsx)(Ae,{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)(Ct,{entry:e})]}):null})}function xt({entry:e,onDelete:t}){let n=d(),r=e.class===`orphan`,i=e.pr&&(e.pr.state===`open`||e.pr.state===`draft`)?e.pr:null,o=!r&&e.runId!==null&&!i,s=b({mutationFn:()=>p(e.runId),onSuccess:e=>{E(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:w.repoBranches}),n.invalidateQueries({queryKey:w.runs.all})},onError:e=>E(e instanceof f&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),c=()=>void navigator.clipboard.writeText(e.name).then(()=>E(`Copied ${e.name}`),()=>E(`Could not copy the branch name`,{tone:`danger`})),l=`inline-flex h-[28px] shrink-0 items-center gap-[5px] rounded-[6px] px-[10px] text-[12px] 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:a(l,`hidden border border-border hover:bg-muted md:inline-flex`),children:`Open task`}):null,o?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-create-pr`,disabled:s.isPending,onClick:()=>s.mutate(),className:a(l,`hidden bg-muted hover:brightness-110 md:inline-flex`),children:[(0,X.jsx)(tt,{"aria-hidden":`true`}),s.isPending?`Creating…`:`Create draft PR`]}):null,r?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,onClick:c,className:a(l,`hidden border border-border hover:bg-muted md:inline-flex`),children:[(0,X.jsx)(ge,{"aria-hidden":`true`}),`Copy branch`]}):null,(0,X.jsxs)(Pe,{children:[(0,X.jsx)(Me,{"data-action":`not-landed-more`,"aria-label":`More actions for ${e.name}`,className:`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] 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)(_e,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,X.jsxs)(Ne,{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,o?(0,X.jsx)(P,{className:`md:hidden`,disabled:s.isPending,onSelect:()=>s.mutate(),children:`Create draft PR`}):null,(0,X.jsx)(P,{className:a(!r&&`md:hidden`),onSelect:c,children:`Copy branch`}),(0,X.jsx)(je,{className:`md:hidden`}),(0,X.jsx)(P,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function St({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=M(t??e.lastCommit.at),a=n||!e.runStatus?i?`${i} ago`:``:`${e.runStatus}${i?` ${i} ago`:``}`;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)(be,{"aria-label":`Task deleted`,className:`size-[12px] text-soft-foreground`}):(0,X.jsx)(Fe,{tone:e.runStatus&&gt[e.runStatus]||`neutral`,"aria-label":e.runStatus??void 0})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[3px]`,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] 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] text-muted-foreground`,title:r,children:r}),(0,X.jsxs)(`span`,{"data-slot":`not-landed-meta`,className:`flex min-w-0 items-center gap-[6px] text-[11px] text-soft-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-muted-foreground`,children:e.name}),(0,X.jsxs)(`span`,{className:`shrink-0`,children:[`· `,e.ahead,` commit`,e.ahead===1?``:`s`]}),e.diffStat?(0,X.jsxs)(`span`,{className:`flex shrink-0 gap-[4px] tabular-nums`,children:[(0,X.jsxs)(`span`,{className:`text-success`,children:[`+`,e.diffStat.additions]}),(0,X.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.diffStat.deletions]})]}):null,a?(0,X.jsxs)(`span`,{className:`truncate`,children:[`· `,a]}):null]}),e.parentRunId?(0,X.jsx)(F,{to:`/tasks/${e.parentRunId}`,"data-slot":`not-landed-parent`,className:`w-fit rounded-[2px] text-[11px] text-soft-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:`Worker of its parent task`}):null,(0,X.jsx)(Z,{entry:e})]})]})}function Ct({entry:e}){let t=h(De(`PR`,e.pr?.number).status),n=e.pr?.state;return(0,X.jsxs)(`span`,{"data-slot":`not-landed-pr-state`,children:[`· `,n===`draft`||n===`closed`?n:t?t.label.toLowerCase():`open`]})}function wt({entry:e,onClose:t}){let n=d(),[r,i]=(0,Y.useState)(``),a=(0,Y.useId)(),o=b({mutationFn:e=>s({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;E(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:w.repo}),c()},onError:e=>E(e.message,{tone:`danger`})}),c=()=>{i(``),t()},l=e!==null&&r.trim()===e.name,u=e&&`${e.ahead} commit${e.ahead===1?``:`s`}`;return(0,X.jsx)(R,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&c(),children:(0,X.jsxs)(W,{"data-slot":`delete-branch-dialog`,children:[(0,X.jsxs)(U,{children:[(0,X.jsxs)(q,{children:[`Delete `,e?.name,`?`]}),(0,X.jsx)(K,{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:[u,` will be dropped`,e?.diffStat?` (+${e.diffStat.additions} −${e.diffStat.deletions})`:``,`, the latest “`,e?.lastCommit.subject,`”`,` `,`(`,(0,X.jsx)(`span`,{className:`font-mono`,children:e?.lastCommit.sha.slice(0,7)}),`).`]})]})})]}),(0,X.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),l&&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)(V,{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)(B,{children:[(0,X.jsx)(H,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,X.jsx)(G,{"data-action":`delete-branch-confirm`,className:`h-11 bg-danger text-danger-foreground hover:brightness-[0.96]`,disabled:!l||o.isPending,onClick:t=>{t.preventDefault(),e&&o.mutate(e.name)},children:o.isPending?`Deleting…`:`Delete branch`})]})]})})}function Tt({base:e}){let t=C(),n=d(),[r,i]=(0,Y.useState)({merged:!1,empty:!1}),[a,o]=(0,Y.useState)(!1),c=(t.data?.branches??[]).filter(e=>e.class===`merged`),l=(t.data?.branches??[]).filter(e=>e.class===`empty`),u=[...c,...l],f=b({mutationFn:e=>s({names:e}),onSuccess:e=>{let t=e.refused.length;E(`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:w.repo})},onError:e=>{n.invalidateQueries({queryKey:w.repo}),E(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 p=u.length,m=`branch${p===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 · `,p]}),(0,X.jsxs)(`p`,{className:`text-[11.5px] 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:p===0||f.isPending,onClick:()=>o(!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)(de,{"aria-hidden":`true`,className:`size-[12px]`}),f.isPending?`Deleting…`:`Delete ${p} ${m}`]})]}),(0,X.jsx)(Et,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:$.toLowerCase(),rows:c,open:r.merged,onToggle:()=>i(e=>({...e,merged:!e.merged}))}),(0,X.jsx)(Et,{kind:`empty`,title:`Empty`,hint:`no commits beyond the fork point`,rows:l,open:r.empty,onToggle:()=>i(e=>({...e,empty:!e.empty}))}),(0,X.jsx)(R,{open:a,onOpenChange:o,children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(U,{children:[(0,X.jsxs)(q,{children:[`Delete `,p,` `,m,`?`]}),(0,X.jsxs)(K,{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)(B,{children:[(0,X.jsx)(H,{children:`Keep them`}),(0,X.jsxs)(G,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{f.mutate(u.map(e=>e.name)),o(!1)},children:[`Delete `,p,` `,m]})]})]})})]})}function Et({kind:e,title:t,hint:n,rows:r,open:i,onToggle:o}){let s=`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":s,disabled:r.length===0,onClick:o,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-[11px] text-soft-foreground`,children:n})]}),r.length>0?(0,X.jsx)(he,{"aria-hidden":`true`,className:a(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,i&&`rotate-90`)}):null]}),i?(0,X.jsx)(`ul`,{id:s,"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-[11.5px]`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-muted-foreground`,children:e.name}),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)(`span`,{className:`shrink-0 tabular-nums text-soft-foreground`,children:M(e.lastCommit.at)})]},e.name))}):null]})}function Dt(){let e=ee(),t=_().data?.targets.find(e=>e.id===`finder`),n=b({mutationFn:e=>o(e,t.id),onError:e=>E(e.message,{tone:`danger`})}),r=d(),[i,a]=(0,Y.useState)(!1),s=()=>Promise.all([r.invalidateQueries({queryKey:w.worktrees}),r.invalidateQueries({queryKey:w.repoBranches})]),c=b({mutationFn:e=>u(),onSuccess:(e,t)=>{s();let n=e.reclaimed.length,r=Math.max(0,t-n);E(n===0?r>0?`Nothing was reclaimed — the worktrees past the keep limit have uncommitted work or are in use`:`Nothing to reclaim — no finished worktrees exceed the keep limit`:`Reclaimed ${n} worktree${n===1?``:`s`} (branch kept)${r>0?` · ${r} kept: uncommitted work or in use`:``}`)},onError:e=>E(e.message,{tone:`danger`})}),f=b({mutationFn:e=>l(e.runId),onSuccess:(e,t)=>{s(),E(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{s(),E(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:p,totalBytes:m,keep:h}=e.data,g=c.isPending||f.isPending,v=p.filter(e=>e.pastKeep),y=v.length>0,x=v.some(e=>e.sizeBytes===null)?null:v.reduce((e,t)=>e+(t.sizeBytes??0),0),S=y?x?`Reclaim ${T(x)} now`:`Reclaim ${v.length} now`:`Reclaim now`,C=m?T(m):null;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`,C?` · ${C}`:``]}),(0,X.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-[11.5px] leading-[17px] text-soft-foreground`,children:[h===0?`Retention is unlimited (`:`Retention keeps the newest ${h} finished checkout${h===1?``:`s`} (`,(0,X.jsx)(F,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:ke(`worktrees`,` › `)}),h===0?`), so nothing is reclaimed on its own.`:`) and reclaims the rest.`,` `,`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:g||!y,title:y?void 0:`Nothing past the keep limit to reclaim`,onClick:()=>a(!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)(J,{"aria-hidden":`true`,className:`size-[12px]`}),S]})]}),p.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:p.map(e=>(0,X.jsx)(At,{worktree:e,keep:h,disabled:g,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>f.mutate(e)},e.runId))}),(0,X.jsx)(R,{open:i,onOpenChange:a,children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(U,{children:[(0,X.jsx)(q,{children:`Reclaim old worktrees?`}),(0,X.jsxs)(K,{children:[v.length,` finished worktree`,v.length===1?``:`s`,` beyond the keep limit`,x?` (${T(x)})`:``,` `,v.length===1?`is`:`are`,` reclaimed now, directory only. Their branches are kept, so the work stays recoverable.`]})]}),(0,X.jsxs)(B,{children:[(0,X.jsx)(H,{children:`Keep them`}),(0,X.jsx)(G,{"data-action":`worktrees-confirm`,onClick:()=>{c.mutate(v.length),a(!1)},children:S})]})]})})]})}var Ot=new Set([`queued`,`running`,`waiting`,`review`]);function kt(e,t){return Ot.has(e.status)||!e.reclaimable?{label:`in use`,tone:`in-use`}:e.pastKeep?{label:`reclaimable`,tone:`plain`}:{label:t>0?`kept · newest ${t}`:`kept`,tone:`plain`}}function At({worktree:e,keep:t,disabled:n,onOpen:r,opening:i,onReclaim:o}){let s=kt(e,t),c=M(e.finishedAt??void 0),l=e.status===`review`?`at review`:c?`${e.status} ${c} ago`:e.status,u=(0,X.jsx)(`span`,{"data-slot":`worktree-state`,"data-state":s.tone===`in-use`?`in-use`:e.pastKeep?`reclaimable`:`kept`,className:a(`text-[11.5px]`,s.tone===`in-use`?`text-status-running`:`text-soft-foreground`),children:s.label}),d=`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`;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-[10.5px] text-soft-foreground`,children:[e.branch??e.runId.slice(0,8),` · `,l,(0,X.jsxs)(`span`,{className:`md:hidden`,children:[` · `,s.label]})]})]}),(0,X.jsx)(`span`,{"data-slot":`worktree-size`,className:`shrink-0 text-[11.5px] tabular-nums text-muted-foreground`,children:e.sizeBytes===null?`—`:T(e.sizeBytes)||`0 kB`}),(0,X.jsx)(`span`,{className:`hidden shrink-0 md:inline`,children:u}),r?(0,X.jsx)(`button`,{type:`button`,className:d,"aria-label":`Open folder for ${e.title}`,title:`Open folder`,disabled:i,onClick:r,children:(0,X.jsx)(ae,{"aria-hidden":`true`,className:`size-[13px]`})}):null,s.tone===`in-use`?null:(0,X.jsx)(`button`,{type:`button`,"data-action":`worktree-reclaim`,"aria-label":`Reclaim the worktree of ${e.title} (branch kept)`,title:`Reclaim the directory (branch kept)`,disabled:n,onClick:o,className:d,children:(0,X.jsx)(J,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function jt({section:e,index:t=!1}){let n=x(),r=L(),[i]=re();if(t&&!r&&i.get(`view`)!==`repo`)return(0,X.jsx)(nt,{});if(n.isPending)return(0,X.jsx)(Le,{});if(n.isError)return(0,X.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(z,{}),(0,X.jsx)(I,{icon:(0,X.jsx)(k,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:n.error.message})]});let a=n.data.info;return a?(0,X.jsx)(Mt,{repo:n.data,info:a,section:e}):(0,X.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(z,{}),(0,X.jsx)(I,{icon:(0,X.jsx)(D,{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 Mt({repo:e,info:t,section:n}){return(0,X.jsxs)(`div`,{"data-route":`repo-git`,"data-git-section":n,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(z,{}),(0,X.jsxs)(`header`,{"data-slot":`repo-header`,className:`flex flex-col gap-1 px-[18px] pt-[18px] md:min-h-[61px] md:flex-row md:items-center md:gap-[10px] md:border-b md:border-border md:px-7 md:py-4`,children:[(0,X.jsx)(`h1`,{className:`min-w-0 flex-1 truncate text-2xl font-semibold tracking-tight md:text-[15px] md:tracking-normal`,children:Ie(n,t.branch)}),(0,X.jsx)(`p`,{"data-slot":`repo-meta`,className:`min-w-0 truncate text-[12px] text-soft-foreground md:text-[11.5px]`,children:(0,X.jsx)(Nt,{repo:e,info:t,section:n})})]}),n===`main`?(0,X.jsx)(ut,{repo:e,info:t}):n===`not-landed`?(0,X.jsx)(_t,{}):n===`cleanup`?(0,X.jsxs)(`div`,{"data-slot":`repo-cleanup`,className:`flex flex-col gap-[16px] px-[18px] pt-[12px] pb-[calc(90px+env(safe-area-inset-bottom))] md:px-[20px] md:pb-[20px]`,children:[(0,X.jsx)(Dt,{}),(0,X.jsx)(Tt,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,X.jsx)(rt,{repo:e,info:t}):(0,X.jsx)(lt,{})]})}function Nt({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?` · ${Ve(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)(Pt,{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 Pt({repo:e,info:t}){let n=Q(e,C().data?.branches).length;return(0,X.jsxs)(X.Fragment,{children:[n,` branch`,n===1?``:`es`,` · on `,t.branch]})}export{jt as RepoGitRoute};
@@ -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{i as r,s as i}from"./project-scope-context-BDU1qGx3.js";import{c as a,x as o}from"./queries--x5yVcip.js";import{f as s,g as c,h as l,i as u,n as d,p as f}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{ot as p,r as m}from"./design-icons-CzEoMH9c.js";import{c as h,i as g,l as _,o as v,s as y,t as b}from"./file-preview-DIVTxup4.js";import{t as x}from"./button-BQ2y4XRB.js";import{t as S}from"./centered-state-V15AR_qo.js";import{_ as C,g as w,h as T}from"./index-BZiixXpY.js";import{s as E}from"./markdown-bvY77s5D.js";var D=e(t(),1),O=n();function k(){let e=s(),t=f();return()=>{if(e.key==="default"||window.history.state?.idx===0){t({pathname:e.pathname.replace(/\/report\/?$/,``)},{replace:!0});return}let n=window.navigation,r=A(e.state);n?.canGoBack?n.back():r?t(r,{state:{filesRestoreKey:e.state?.filesRestoreKey}}):t(-1)}}function A(e){let t=e?.readerFrom;return typeof t==`string`&&t.startsWith(`/`)&&!t.startsWith(`//`)?t:null}function j(e){return e?.type===`file`?e:null}function M(){let[e]=c(),t=e.get(`path`),n=e.get(`artifact`);return{path:t,artifactId:n,conflict:e.getAll(`path`).length>1||e.getAll(`artifact`).length>1||t!==null&&n!==null||t===``||n===``}}function N(){let{id:e=``}=l(),t=M(),n=s(),r=k();return(0,O.jsx)(P,{runId:e,selection:t,fragment:n.hash,onBack:r,variant:`route`})}function P({runId:e,selection:t,fragment:n,onBack:r,variant:i,sourceLookup:a}){let{path:o,conflict:c,selected:l,result:d}=I(e,t,a),f=C(T,!0),p=C(w,!1),m=s(),[h,g]=(0,D.useState)(!1),_=j(d.data);if(i===`route`&&L(_))return(0,O.jsx)(u,{replace:!0,to:{pathname:m.pathname.replace(/\/report\/?$/,`/files`),search:m.search,hash:m.hash}});let v=z(_,o),y=i===`pane`&&!p&&!f?`Conversation`:`Back`,b=i===`pane`&&!h&&R(_),x=F(m.pathname,e,t);return(0,O.jsxs)(`div`,{"data-route":`task-report`,"data-variant":i,onKeyDown:e=>{i!==`pane`||e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),e.stopPropagation(),r())},className:i===`route`?`fixed inset-0 z-50 flex flex-col bg-background [padding-block-start:env(safe-area-inset-top)] [padding-inline-end:env(safe-area-inset-right)] [padding-block-end:env(safe-area-inset-bottom)] [padding-inline-start:env(safe-area-inset-left)] md:static md:z-auto md:h-full md:p-0`:`flex h-full min-h-0 flex-col bg-background max-md:[padding-block-start:env(safe-area-inset-top)] max-md:[padding-inline-start:env(safe-area-inset-left)] max-md:[padding-inline-end:env(safe-area-inset-right)]`,children:[(0,O.jsx)(B,{runId:e,file:_,name:v,source:h,onSource:()=>g(e=>!e),onBack:r,backLabel:y,hideDownload:i===`pane`&&p,focusBack:i===`pane`}),(0,O.jsx)(`div`,{"data-slot":`report-body`,className:b?`flex min-h-0 flex-1 flex-col overflow-clip`:`flex min-h-0 flex-1 flex-col overflow-auto`,children:(0,O.jsx)(V,{conflict:c,selected:l,result:d,source:h,name:v,fragment:n,pane:i===`pane`,filesHref:x})})]})}function F(e,t,n){let r=/^\/p\/[^/]+/.exec(e)?.[0]??``,i=n.artifactId?new URLSearchParams({artifact:n.artifactId}):new URLSearchParams({path:n.path??``});return`${r}/tasks/${encodeURIComponent(t)}/files?${i}`}function I(e,t,n){let{path:r=null,artifactId:i=null,conflict:s=!1}=t,c=n?.isPending||n?.isError,l=o(e,i||s||c?null:r),u=a(e,s||c?null:i),d=c&&n?{...n,data:void 0}:i?u:l;return{path:r,conflict:s,selected:r!==null||i!==null,result:d}}function L(e){return e!==null&&(!E(e.path)||!e.artifact&&(e.tooLarge||e.binary))}function R(e){return e!==null&&!e.tooLarge&&!e.binary}function z(e,t){return e?e.artifact?.name??e.path.split(/[\\/]/).at(-1)??e.path:t??`Report`}function B({runId:e,file:t,name:n,source:r,onSource:a,onBack:o,backLabel:s,hideDownload:c,focusBack:l}){let u=(0,D.useRef)(null);(0,D.useEffect)(()=>{l&&u.current?.focus({preventScroll:!0})},[l]);let d=t?.artifact;return(0,O.jsxs)(`header`,{"data-slot":`report-bar`,className:`flex min-h-14 shrink-0 items-center gap-2 border-b border-border bg-card px-2 md:px-4`,children:[(0,O.jsxs)(x,{ref:u,variant:`ghost`,className:`min-h-11 min-w-11 gap-1.5 px-2`,onClick:o,"aria-label":s,children:[(0,O.jsx)(m,{size:18,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`max-sm:sr-only`,children:s})]}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`h1`,{className:`truncate text-sm font-medium`,children:n}),t?(0,O.jsxs)(`p`,{className:`truncate text-xs text-soft-foreground`,children:[d?`Published snapshot · ${new Date(d.createdAt).toLocaleString()}`:`Live file`,` · `,g(t.size)]}):null]}),t&&!t.tooLarge&&!t.binary?(0,O.jsx)(x,{variant:`ghost`,className:`min-h-11 px-3 text-accent-text`,onClick:a,children:r?`Preview`:`Source`}):null,d&&!c?(0,O.jsx)(`a`,{className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline focus-visible:ring-2`,href:i(e,d.id,`download`),children:`Download`}):null]})}function V({conflict:e,selected:t,result:n,source:r,name:i,fragment:a,pane:o,filesHref:s}){if(e)return(0,O.jsx)(U,{icon:(0,O.jsx)(y,{}),title:`Invalid report link`,subtitle:`Choose either a path or a published artifact.`});if(!t)return(0,O.jsx)(U,{icon:(0,O.jsx)(h,{}),title:`No report selected`,subtitle:`Open a report from a link in the conversation or from Files.`});if(n.isPending)return(0,O.jsx)(`p`,{role:`status`,"data-slot":`report-loading`,className:`px-4 py-6 text-center text-sm text-soft-foreground`,children:`Loading report…`});if(n.isError)return(0,O.jsx)(H,{result:n});let c=n.data;return c.type===`file`?o&&!E(c.path)?(0,O.jsx)(U,{icon:(0,O.jsx)(h,{}),title:`Not an HTML report`,subtitle:`Open this published file in Files.`,action:(0,O.jsx)(d,{to:s,className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:`Open in Files`})}):c.tooLarge?(0,O.jsx)(U,{icon:(0,O.jsx)(_,{}),title:`Too large to preview`,subtitle:`${g(c.size)} is past the 500 kB preview limit. Download it to read it.`}):c.binary?(0,O.jsx)(U,{icon:(0,O.jsx)(h,{}),title:`Binary file`,subtitle:`This file holds binary data, not readable HTML.`}):r?(0,O.jsx)(`div`,{className:`bg-card`,children:(0,O.jsx)(b,{path:c.path,text:c.content??``})}):(0,O.jsx)(v,{html:c.content??``,title:`Report: ${i}`,fragment:a,className:o?`min-h-0 flex-1`:`min-h-[60dvh] flex-1`}):(0,O.jsx)(U,{icon:(0,O.jsx)(y,{}),title:c.type===`unpublished`?`Report not published`:`Report unavailable`,subtitle:c.reason})}function H({result:e}){let t=e.error instanceof r&&e.error.status===404;return(0,O.jsx)(U,{icon:t?(0,O.jsx)(y,{}):(0,O.jsx)(p,{size:16}),tone:t?`neutral`:`danger`,title:t?`Report missing or deleted`:`Could not load this report`,subtitle:e.error?.message??`Try again.`,action:(0,O.jsx)(x,{variant:`outline`,className:`min-h-11`,onClick:()=>void e.refetch(),children:`Retry`})})}function U({icon:e,title:t,subtitle:n,tone:r=`neutral`,action:i}){return(0,O.jsxs)(`div`,{"data-slot":`report-state`,className:`flex flex-col items-center gap-3 p-6`,children:[(0,O.jsx)(S,{icon:e,tone:r,heading:`h2`,title:t,subtitle:n}),i]})}export{P as ReportReader,N as TaskReportRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{i as r,s as i}from"./project-scope-context-D1bpJixc.js";import{c as a,x as o}from"./queries-dHXhD3Hc.js";import{f as s,g as c,h as l,i as u,n as d,p as f}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{ot as p,r as m}from"./design-icons-CzEoMH9c.js";import{c as h,i as g,l as _,o as v,s as y,t as b}from"./file-preview-BS6M2tBo.js";import{t as x}from"./button-BQ2y4XRB.js";import{t as S}from"./centered-state-V15AR_qo.js";import{_ as C,g as w,h as T}from"./index-CmadQXcg.js";import{s as E}from"./markdown-KHcncamw.js";var D=e(t(),1),O=n();function k(){let e=s(),t=f();return()=>{if(e.key==="default"||window.history.state?.idx===0){t({pathname:e.pathname.replace(/\/report\/?$/,``)},{replace:!0});return}let n=window.navigation,r=A(e.state);n?.canGoBack?n.back():r?t(r,{state:{filesRestoreKey:e.state?.filesRestoreKey}}):t(-1)}}function A(e){let t=e?.readerFrom;return typeof t==`string`&&t.startsWith(`/`)&&!t.startsWith(`//`)?t:null}function j(e){return e?.type===`file`?e:null}function M(){let[e]=c(),t=e.get(`path`),n=e.get(`artifact`);return{path:t,artifactId:n,conflict:e.getAll(`path`).length>1||e.getAll(`artifact`).length>1||t!==null&&n!==null||t===``||n===``}}function N(){let{id:e=``}=l(),t=M(),n=s(),r=k();return(0,O.jsx)(P,{runId:e,selection:t,fragment:n.hash,onBack:r,variant:`route`})}function P({runId:e,selection:t,fragment:n,onBack:r,variant:i,sourceLookup:a}){let{path:o,conflict:c,selected:l,result:d}=I(e,t,a),f=C(T,!0),p=C(w,!1),m=s(),[h,g]=(0,D.useState)(!1),_=j(d.data);if(i===`route`&&L(_))return(0,O.jsx)(u,{replace:!0,to:{pathname:m.pathname.replace(/\/report\/?$/,`/files`),search:m.search,hash:m.hash}});let v=z(_,o),y=i===`pane`&&!p&&!f?`Conversation`:`Back`,b=i===`pane`&&!h&&R(_),x=F(m.pathname,e,t);return(0,O.jsxs)(`div`,{"data-route":`task-report`,"data-variant":i,onKeyDown:e=>{i!==`pane`||e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),e.stopPropagation(),r())},className:i===`route`?`fixed inset-0 z-50 flex flex-col bg-background [padding-block-start:env(safe-area-inset-top)] [padding-inline-end:env(safe-area-inset-right)] [padding-block-end:env(safe-area-inset-bottom)] [padding-inline-start:env(safe-area-inset-left)] md:static md:z-auto md:h-full md:p-0`:`flex h-full min-h-0 flex-col bg-background max-md:[padding-block-start:env(safe-area-inset-top)] max-md:[padding-inline-start:env(safe-area-inset-left)] max-md:[padding-inline-end:env(safe-area-inset-right)]`,children:[(0,O.jsx)(B,{runId:e,file:_,name:v,source:h,onSource:()=>g(e=>!e),onBack:r,backLabel:y,hideDownload:i===`pane`&&p,focusBack:i===`pane`}),(0,O.jsx)(`div`,{"data-slot":`report-body`,className:b?`flex min-h-0 flex-1 flex-col overflow-clip`:`flex min-h-0 flex-1 flex-col overflow-auto`,children:(0,O.jsx)(V,{conflict:c,selected:l,result:d,source:h,name:v,fragment:n,pane:i===`pane`,filesHref:x})})]})}function F(e,t,n){let r=/^\/p\/[^/]+/.exec(e)?.[0]??``,i=n.artifactId?new URLSearchParams({artifact:n.artifactId}):new URLSearchParams({path:n.path??``});return`${r}/tasks/${encodeURIComponent(t)}/files?${i}`}function I(e,t,n){let{path:r=null,artifactId:i=null,conflict:s=!1}=t,c=n?.isPending||n?.isError,l=o(e,i||s||c?null:r),u=a(e,s||c?null:i),d=c&&n?{...n,data:void 0}:i?u:l;return{path:r,conflict:s,selected:r!==null||i!==null,result:d}}function L(e){return e!==null&&(!E(e.path)||!e.artifact&&(e.tooLarge||e.binary))}function R(e){return e!==null&&!e.tooLarge&&!e.binary}function z(e,t){return e?e.artifact?.name??e.path.split(/[\\/]/).at(-1)??e.path:t??`Report`}function B({runId:e,file:t,name:n,source:r,onSource:a,onBack:o,backLabel:s,hideDownload:c,focusBack:l}){let u=(0,D.useRef)(null);(0,D.useEffect)(()=>{l&&u.current?.focus({preventScroll:!0})},[l]);let d=t?.artifact;return(0,O.jsxs)(`header`,{"data-slot":`report-bar`,className:`flex min-h-14 shrink-0 items-center gap-2 border-b border-border bg-card px-2 md:px-4`,children:[(0,O.jsxs)(x,{ref:u,variant:`ghost`,className:`min-h-11 min-w-11 gap-1.5 px-2`,onClick:o,"aria-label":s,children:[(0,O.jsx)(m,{size:18,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`max-sm:sr-only`,children:s})]}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`h1`,{className:`truncate text-sm font-medium`,children:n}),t?(0,O.jsxs)(`p`,{className:`truncate text-xs text-soft-foreground`,children:[d?`Published snapshot · ${new Date(d.createdAt).toLocaleString()}`:`Live file`,` · `,g(t.size)]}):null]}),t&&!t.tooLarge&&!t.binary?(0,O.jsx)(x,{variant:`ghost`,className:`min-h-11 px-3 text-accent-text`,onClick:a,children:r?`Preview`:`Source`}):null,d&&!c?(0,O.jsx)(`a`,{className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline focus-visible:ring-2`,href:i(e,d.id,`download`),children:`Download`}):null]})}function V({conflict:e,selected:t,result:n,source:r,name:i,fragment:a,pane:o,filesHref:s}){if(e)return(0,O.jsx)(U,{icon:(0,O.jsx)(y,{}),title:`Invalid report link`,subtitle:`Choose either a path or a published artifact.`});if(!t)return(0,O.jsx)(U,{icon:(0,O.jsx)(h,{}),title:`No report selected`,subtitle:`Open a report from a link in the conversation or from Files.`});if(n.isPending)return(0,O.jsx)(`p`,{role:`status`,"data-slot":`report-loading`,className:`px-4 py-6 text-center text-sm text-soft-foreground`,children:`Loading report…`});if(n.isError)return(0,O.jsx)(H,{result:n});let c=n.data;return c.type===`file`?o&&!E(c.path)?(0,O.jsx)(U,{icon:(0,O.jsx)(h,{}),title:`Not an HTML report`,subtitle:`Open this published file in Files.`,action:(0,O.jsx)(d,{to:s,className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:`Open in Files`})}):c.tooLarge?(0,O.jsx)(U,{icon:(0,O.jsx)(_,{}),title:`Too large to preview`,subtitle:`${g(c.size)} is past the 500 kB preview limit. Download it to read it.`}):c.binary?(0,O.jsx)(U,{icon:(0,O.jsx)(h,{}),title:`Binary file`,subtitle:`This file holds binary data, not readable HTML.`}):r?(0,O.jsx)(`div`,{className:`bg-card`,children:(0,O.jsx)(b,{path:c.path,text:c.content??``})}):(0,O.jsx)(v,{html:c.content??``,title:`Report: ${i}`,fragment:a,className:o?`min-h-0 flex-1`:`min-h-[60dvh] flex-1`}):(0,O.jsx)(U,{icon:(0,O.jsx)(y,{}),title:c.type===`unpublished`?`Report not published`:`Report unavailable`,subtitle:c.reason})}function H({result:e}){let t=e.error instanceof r&&e.error.status===404;return(0,O.jsx)(U,{icon:t?(0,O.jsx)(y,{}):(0,O.jsx)(p,{size:16}),tone:t?`neutral`:`danger`,title:t?`Report missing or deleted`:`Could not load this report`,subtitle:e.error?.message??`Try again.`,action:(0,O.jsx)(x,{variant:`outline`,className:`min-h-11`,onClick:()=>void e.refetch(),children:`Retry`})})}function U({icon:e,title:t,subtitle:n,tone:r=`neutral`,action:i}){return(0,O.jsxs)(`div`,{"data-slot":`report-state`,className:`flex flex-col items-center gap-3 p-6`,children:[(0,O.jsx)(S,{icon:e,tone:r,heading:`h2`,title:t,subtitle:n}),i]})}export{P as ReportReader,N as TaskReportRoute};