@hearsay-tools/squawk 0.17.0-dev.5728 → 0.17.0-dev.5734
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.
- package/README.md +19 -19
- package/dist/application-update/discovery.js +19 -11
- package/dist/application-update/discovery.js.map +1 -1
- package/dist/application-update/service.js +2 -2
- package/dist/application-update/service.js.map +1 -1
- package/dist/home/command.js +2 -2
- package/dist/home/command.js.map +1 -1
- package/dist/home/identity.d.ts +38 -14
- package/dist/home/identity.js +18 -8
- package/dist/home/identity.js.map +1 -1
- package/dist/install-as-command.d.ts +1 -1
- package/dist/release/manifests.d.ts +10 -15
- package/dist/release/manifests.js +17 -10
- package/dist/release/manifests.js.map +1 -1
- package/dist/release/snapshot.d.ts +3 -3
- package/dist/release/snapshot.js +3 -4
- package/dist/release/snapshot.js.map +1 -1
- package/dist/self-update/launcher.js +2 -2
- package/dist/self-update/launcher.js.map +1 -1
- package/dist/self-update/layout.d.ts +1 -1
- package/dist/serve-command.js +7 -1
- package/dist/serve-command.js.map +1 -1
- package/dist/server-install/npx-cache.d.ts +5 -1
- package/dist/server-install/npx-cache.js +15 -4
- package/dist/server-install/npx-cache.js.map +1 -1
- package/dist/server-install/platforms/macosx-launchd-files.js +4 -2
- package/dist/server-install/platforms/macosx-launchd-files.js.map +1 -1
- package/dist/server-install/platforms/macosx-ngrok.js +6 -6
- package/dist/server-install/platforms/macosx-ngrok.js.map +1 -1
- package/dist/server-install/platforms/ubuntu-vps.d.ts +5 -4
- package/dist/server-install/platforms/ubuntu-vps.js +11 -11
- package/dist/server-install/platforms/ubuntu-vps.js.map +1 -1
- package/package.json +4 -4
- package/web/dist/assets/{activity-motion-SGth5vR4.js → activity-motion-hhx0e841.js} +1 -1
- package/web/dist/assets/{activity-route-D8otXwOA.js → activity-route-De0BnSrc.js} +1 -1
- package/web/dist/assets/{agent-accounts-6EuZhy-N.js → agent-accounts-BCg-578Q.js} +1 -1
- package/web/dist/assets/{alert-dialog-vFjLgfK4.js → alert-dialog-Dj464rjk.js} +1 -1
- package/web/dist/assets/{button-BEK7XKhS.js → button-CHUAMTHK.js} +1 -1
- package/web/dist/assets/{centered-state-CPgI8cCO.js → centered-state-DGyy0SuA.js} +1 -1
- package/web/dist/assets/{commit-diff-panel-DzyWgn1Z.js → commit-diff-panel-DYtYc_dH.js} +1 -1
- package/web/dist/assets/{control-locations-CexZsd3M.js → control-locations-CA9TMupq.js} +1 -1
- package/web/dist/assets/{diff-controls-DXyB0aDl.js → diff-controls-BR2uqhwG.js} +1 -1
- package/web/dist/assets/{diff-DBDiZl58.js → diff-tVGVhYyc.js} +2 -2
- package/web/dist/assets/{diff-view-DiKAwVMH.js → diff-view-CNM3u77o.js} +1 -1
- package/web/dist/assets/{dropdown-menu-DYflHa4m.js → dropdown-menu-DhrBcVgr.js} +1 -1
- package/web/dist/assets/{es2015-BO600Xfi.js → es2015-D345RR4o.js} +1 -1
- package/web/dist/assets/{file-preview-DTSRkmMo.js → file-preview-C1eTdJLJ.js} +1 -1
- package/web/dist/assets/{git-toolbar-U4s46kUd.js → git-toolbar-Dwz8p8GW.js} +1 -1
- package/web/dist/assets/{github-UaBp2yRF.js → github-BSezqH6f.js} +1 -1
- package/web/dist/assets/{github-sidebar-model-czjLsgVJ.js → github-sidebar-model-Ct0DltOv.js} +1 -1
- package/web/dist/assets/{global-activity-route-B2N2Nz0H.js → global-activity-route-BZiYz-B0.js} +1 -1
- package/web/dist/assets/{image-preview-XPCPclpG.js → image-preview-Cq1vDiEo.js} +1 -1
- package/web/dist/assets/{index-xj-3O89_.js → index-D489J7QW.js} +5 -5
- package/web/dist/assets/{live-refetch-C-Ony2Yr.js → live-refetch-C0kQc3-z.js} +1 -1
- package/web/dist/assets/{markdown-UdZ_toya.js → markdown-D7DUNWcJ.js} +1 -1
- package/web/dist/assets/{nav-row-styles-BE99gD3_.js → nav-row-styles-BZUUavOF.js} +1 -1
- package/web/dist/assets/{popover-CpULuQSm.js → popover-DRcRI46x.js} +1 -1
- package/web/dist/assets/{preview-pane-connected-CgRK7GzB.js → preview-pane-connected-DGkEs_L3.js} +1 -1
- package/web/dist/assets/{project-router-CimAoN1H.js → project-router-1m_VlC22.js} +1 -1
- package/web/dist/assets/{project-scope-context-DMpvJqIm.js → project-scope-context-CaUqlAd7.js} +1 -1
- package/web/dist/assets/{queries-BIOp8jLx.js → queries-DYfIpJ-d.js} +1 -1
- package/web/dist/assets/{repo-git-XkyTfP9G.js → repo-git-CU1S5P-y.js} +1 -1
- package/web/dist/assets/{report-reader-CZjYS5Aw.js → report-reader-DlZol2Ux.js} +1 -1
- package/web/dist/assets/{reports-D_2sFE1y.js → reports-DIGGjk7C.js} +1 -1
- package/web/dist/assets/{run-header-BwPDVPpg.js → run-header-DPjiPKRe.js} +1 -1
- package/web/dist/assets/{skills-BkXe4p4q.js → skills-BMwanop_.js} +1 -1
- package/web/dist/assets/{tab-link-BIweqlIZ.js → tab-link-DCUifQ46.js} +1 -1
- package/web/dist/assets/{task-changes-USNHNm_T.js → task-changes-BZXWvQN3.js} +1 -1
- package/web/dist/assets/{task-commits-kHqlOJe_.js → task-commits-ByI9MSfc.js} +1 -1
- package/web/dist/assets/{task-files-wTWwLR39.js → task-files-LJbenpiH.js} +1 -1
- package/web/dist/assets/{task-github-item-GzaQjkF1.js → task-github-item-B0CU9lGR.js} +1 -1
- package/web/dist/assets/{task-thread-BZX863UN.js → task-thread-CXCN__1a.js} +1 -1
- package/web/dist/assets/{textarea-FAUkHz1K.js → textarea-DlVUfdWG.js} +1 -1
- package/web/dist/assets/{thread-state-CBzx2hmX.js → thread-state-BLaCzqeX.js} +1 -1
- package/web/dist/assets/{toaster-pthKGWiE.js → toaster-B1MyeHiE.js} +1 -1
- package/web/dist/assets/{use-hand-to-agent-state-Bav9eT3b.js → use-hand-to-agent-state-BkmKad8x.js} +1 -1
- package/web/dist/assets/{useInfiniteQuery-CQI4BO4C.js → useInfiniteQuery-qEY8OhKb.js} +1 -1
- package/web/dist/assets/useQuery-DOJQOEBO.js +1 -0
- package/web/dist/assets/{workflows-D871Gx--.js → workflows-Dbxb-d-6.js} +1 -1
- package/web/dist/assets/{ws-DspW9wBH.js → ws-DvGmrP4z.js} +1 -1
- package/web/dist/assets/{zoomable-image-DNc6ORaF.js → zoomable-image-5pOUaPEg.js} +1 -1
- package/web/dist/index.html +21 -21
- package/web/dist/assets/useQuery-Bkq-x4Id.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{A as t,M as n}from"./button-BEK7XKhS.js";import{i as r}from"./react-runtime-CCIEwYL0.js";import{r as i,t as a}from"./live-refetch-C-Ony2Yr.js";import{$ as o,$r as s,An as c,At as l,B as u,Br as d,Ct as f,Dn as p,Er as m,Ft as h,Gr as g,H as _,Hn as v,Hr as y,Ht as ee,I as te,It as ne,Jr as b,Kn as re,Kr as ie,L as ae,Ln as oe,Lt as se,M as ce,Mt as le,N as ue,Nt as de,Ot as fe,Pt as pe,Q as me,R as he,Rt as ge,S as _e,St as ve,Tn as ye,Tr as be,Tt as xe,U as Se,Ur as Ce,Ut as we,V as Te,Vr as Ee,W as De,Wr as Oe,X as ke,Xt as Ae,Y as je,Yr as Me,Yt as Ne,Z as x,_ as Pe,_t as Fe,ai as Ie,ar as S,at as Le,bn as Re,br as C,bt as ze,ci as Be,cn as Ve,ct as He,dn as Ue,dt as We,ei as Ge,en as Ke,et as qe,fi as Je,fn as Ye,ft as Xe,gi as Ze,gn as Qe,gt as $e,h as et,ht as tt,i as nt,jr as rt,jt as it,kn as at,kt as ot,l as st,ln as ct,lt,mt as ut,nt as dt,ot as ft,pi as pt,pt as mt,q as ht,r as gt,ri as _t,rt as vt,st as yt,tt as bt,ui as xt,un as St,ut as Ct,v as wt,vt as Tt,wn as Et,wt as Dt,x as Ot,xn as kt,xt as At,y as jt,yn as Mt,yt as Nt,z as Pt,zr as Ft}from"./project-scope-context-DMpvJqIm.js";import{I as w,L as It,N as Lt,ft as T}from"./live-protocol-BDY7JJpT.js";import{t as Rt}from"./useInfiniteQuery-CQI4BO4C.js";import{t as E}from"./useQuery-Bkq-x4Id.js";import{n as zt,r as D,t as Bt}from"./ws-DspW9wBH.js";import{n as Vt}from"./toaster-pthKGWiE.js";var Ht=class extends s{#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||Ut(),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=Ge({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),T.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Ut(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Wt=class extends Ze{#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),Je(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&_t(t.mutationKey)!==_t(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??Ut();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){T.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 Gt(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Kt(e,t,n){let r=e.slice(0);return r[t]=n,r}var qt=class extends Ze{#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,T.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||!Je(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Gt(e,n).forEach(e=>{e.destroy()}),Gt(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=xt(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 Me(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Kt(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)&&T.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},O=e(r(),1);function k({queries:e,...t},n){let r=b(n),i=ie(),a=g(),o=O.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{Ft(e);let t=r.getQueryCache().get(e.queryHash);y(e,a,t)}),Oe(a);let[s]=O.useState(()=>new qt(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),f=!i&&t.subscribed!==!1;O.useSyncExternalStore(O.useCallback(e=>f?s.subscribe(T.batchCalls(e)):Be,[s,f]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),O.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let p=c.some((e,t)=>Ee(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&Ee(n,e)?d(n,new Me(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=c.find((e,t)=>{let n=o[t];return n&&Ce({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m?.error)throw m.error;return l(u())}function A(e,t){let n=b(t),[r]=O.useState(()=>new Wt(n,e));O.useEffect(()=>{r.setOptions(e)},[r,e]);let i=O.useSyncExternalStore(O.useCallback(e=>r.subscribe(T.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=O.useCallback((e,t)=>{r.mutate(e,t).catch(Be)},[r]);if(i.error&&pt(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function j(e={}){let t=e.projectId??n();return{projectId:t,cacheScope:e.cacheScope??(e.boot?`default`:t)}}function M(e,t={}){return{...j(t),runId:e}}function Jt(e){if(e.workflow===`(planned)`||e.workflow===`(inbox)`){let t=(e.steps??[]).find(e=>e.kind===`agent`);if(t?.name)return t.name}return e.workflow}var N=[`workspace`,`runs-index`],P=e=>[e.cacheScope,`runs`,`list`],F=e=>[e.cacheScope,`runs`,`detail`,e.runId],I=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:N})};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=m(),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:P(I(n))}),await e.cancelQueries({queryKey:F(I(n))});let i=e.getQueryData(P(I(n))),a=e.getQueryData(F(I(n))),o=I(n).runId,s=new Date().toISOString();return e.setQueryData(P(I(n)),e=>e?.map(e=>e.id===o?Zt(e,r,s):e)),e.setQueryData(F(I(n)),e=>e&&Zt(e,r,s)),{id:o,prevList:i,prevDetail:a,rollback(){if(!r){i&&e.setQueryData(P(I(n)),i),a&&e.setQueryData(F(I(n)),a);return}let t=i?.find(e=>e.id===o);t&&e.setQueryData(P(I(n)),e=>e?.map(e=>e.id===o?Xt(e,t):e)),a&&e.setQueryData(F(I(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(P(I(n)),e=>e?.map(a));let s={...I(n),runId:r?o:i.id};e.setQueryData(F(s),e=>e?a(e):i),t()}}}async function a(t,n){await e.cancelQueries({queryKey:N});let i=e.getQueryData(N),a=n();return e.setQueryData(N,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(N,i)},settle(){r(`indexed`,t)}}}return{patchRead:i,patchIndex:a,invalidateAfter:r}}function L(){let e=b();return(0,O.useMemo)(()=>Qt(e),[e])}function $t(e){return e.type===`run`?e.run.id:e.id}function R(e,t){return{...e,runs:t}}function en(e,t){let n=0;for(let r of e)r.projectId===t&&r.archived&&(n+=1);return n}function tn(e,t){let n=e.findIndex(e=>(e.createdAt??``).localeCompare(t.createdAt)<0),r=[...e];return r.splice(n<0?e.length:n,0,t),r}function nn(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function rn(e,t,n){let{project:r}=t,i=$t(t),a=e.runs.findIndex(e=>e.projectId===r&&e.id===i),o=a>=0?e.runs[a]:void 0,s=e.truncated.includes(r);if(t.type===`deleted`)return o?{index:R(e,e.runs.filter((e,t)=>t!==a)),reconcile:s&&o.archived}:{index:e,reconcile:!1};let{run:c}=t;if(c.delegation?.role===`worker`)return o?{index:R(e,e.runs.filter((e,t)=>t!==a)),reconcile:!1}:{index:e,reconcile:!1};if(!o&&!nn(e,r,n))return{index:e,reconcile:!0};let l=xt(o,{projectId:r,...c});if(o){if(l===o)return{index:e,reconcile:!1};let t=[...e.runs];t[a]=l;let n=o.archived!==l.archived&&(s||en(t,r)>e.perProjectLimit);return{index:R(e,t),reconcile:n}}if(s)return on(e,l);let u=tn(e.runs,l);return{index:R(e,u),reconcile:l.archived&&en(u,r)>e.perProjectLimit}}function an(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 on(e,t){let n=an(e.runs,t.projectId),r=n!==void 0&&t.createdAt>n;return t.archived&&!r?{index:e,reconcile:!1}:{index:R(e,tn(e.runs,t)),reconcile:t.archived||n===void 0||t.createdAt<n}}function sn(e,t,n){let r=!1,i=e.runs.map(e=>{if(e.projectId!==t)return e;let i=n[e.id];if(i){let t=xt(e.usage,i);return t===e.usage?e:(r=!0,{...e,usage:t})}if(e.usage===void 0)return e;r=!0;let{usage:a,...o}=e;return o});return r?R(e,i):e}function cn(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 ln(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function un(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 dn(e){e.stream=void 0}function fn(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,$t(t)]),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}function pn(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function mn(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function hn(e,t,n){if(!mn(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=rn(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 z=[`workspace`,`runs-index`],gn=[`workspace`,`projects`],_n=6e4,vn=100,yn=new WeakMap;function B(e){let t=yn.get(e);return t||(t=wn(e),yn.set(e,t)),t}function bn(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:B(t).merge(e)}function xn(e){let t=e.getQueryData(gn)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function Sn(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 Cn(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 wn(e){let t=ln(),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(z,t)},h=()=>e.getQueryData(z),g=()=>{clearTimeout(a),a=void 0;let t=e.getQueryCache().find({queryKey:z,exact:!0}),n=(t!==void 0&&t.state.data===void 0&&t.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:z,exact:!0}).then(()=>e.invalidateQueries({queryKey:z})):e.invalidateQueries({queryKey:z})).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=xn(e),s=a,c=!1;for(let e of t){if(e.generation!==a.generation)continue;if(e.type===`usage`){l.has(e.project)||(s=sn(s,e.project,e.usage));continue}if(l.has(e.change.project)||e.change.seq<=a.eventSeq)continue;let t=rn(s,e.change,o);s=t.index,c||=t.reconcile}s!==a&&m(s),c&&_({hold:!0})},y=()=>{if(i!==void 0)return;let e=c+250-Date.now();if(e>0){i=setTimeout(v,e);return}i=setTimeout(v,vn),typeof requestAnimationFrame==`function`&&(r=requestAnimationFrame(v))};return{ready(e,n){un(t,e,n),u=!1,f&&(f=!1,_({hold:!0}))},detach(){dn(t)},run(e,r,i=!1){if(l.has(e))return;let a=Cn(e,r);if(!fn(t,a,i)){p();return}n.push({type:`change`,change:a,generation:t.stream}),y()},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}),y()}},dropProject(e){l.add(e),pn(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let r=h();if(!r)return;let i=cn(r,e);i!==r&&m(i)},setUnknownGenerationHandler(e){d=e},restoreProject(e){l.delete(e)},merge(n){let r=h(),i=hn(t,n,xn(e));for(let e of l)i.index=cn(i.index,e);return i.reconcile&&queueMicrotask(()=>{_({hold:!0})}),Sn(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 Tn={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`}},En={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function Dn(e){return typeof e==`string`&&Object.hasOwn(Tn,e)}function On(e){return e!==void 0&&Dn(e)?Tn[e]:void 0}var V=new Map(Pn()),kn=1e3;function An(e,t){if(V.get(e)!==t){for(V.delete(e),V.set(e,t);V.size>kn;){let e=V.keys().next().value;if(e===void 0)break;V.delete(e)}Ln()}}var H=new Set(Fn());function jn(e,t){if(H.has(e)!==t){if(t)for(H.add(e);H.size>kn;){let e=H.values().next().value;if(e===void 0)break;H.delete(e)}else H.delete(e);Ln()}}var Mn=`cez.reference-statuses.v1`,Nn=`cez.reference-conflicts.v1`;function Pn(){try{let e=globalThis.sessionStorage?.getItem(Mn);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`&&Dn(e[1])):[]}catch{return[]}}function Fn(){try{let e=globalThis.sessionStorage?.getItem(Nn);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var In;function Ln(){In===void 0&&(In=setTimeout(()=>{In=void 0;try{globalThis.sessionStorage?.setItem(Mn,JSON.stringify([...V])),globalThis.sessionStorage?.setItem(Nn,JSON.stringify([...H]))}catch{}},250))}var U=e=>`${e.projectId}\u0000${e.kind}#${e.number}`;function Rn(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function zn(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 Bn(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;An(t,o),s!==void 0&&jn(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function Vn(e,t,n){let r=U(t),i=V.get(r),a=H.has(r)?!0:void 0,o=n.data;if(o?.available){Bn(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...Rn(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...Rn(i,a)});return}e.set(r,{state:`loading`,...Rn(i,a)})}function Hn(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of zn(i))Vn(n,e,t)}),n}function Un(e){return S(e)?!1:e.status===`queued`||e.status===`running`||e.status===`waiting`}function Wn(e){return Un(e)&&e.status!==`queued`}function Gn(e,t,n){return e.archived||!(e.status===`done`||e.status===`failed`||e.status===`cancelled`)||e.delegation?.role===`worker`||n!==void 0&&re(e)!==n?!1:t===`unpinned`?!e.pinned:t!==`pinned`||e.pinned===!0}var Kn=[`done`,`failed`];function qn(e){return e.archived||S(e)||!Kn.includes(e.status)?!1:e.finishedAt!==void 0}function Jn(e){let t=e.finishedAt;return t===void 0||!qn(e)?!1:e.seenAt===void 0||e.seenAt<t}function Yn(e){let t=/\/(\d+)\/?$/.exec(e.trim()),n=t?Number(t[1]):NaN;return Number.isInteger(n)&&n>0?n:null}function Xn(e){let t=new Set;for(let n of[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl]){let e=n?Yn(n):null;e!==null&&t.add(e)}for(let n of[e.prNumber,e.issueNumber,e.markerRefs?.pr,e.markerRefs?.issue])typeof n==`number`&&Number.isInteger(n)&&n>0&&t.add(n);for(let n of e.pullRequests??[])t.add(n.number);return[...t]}var Zn=[{id:`title`,kind:`text`,scopes:[`stored`],source:`summary`,texts:e=>[e.title]},{id:`titleSummary`,kind:`text`,scopes:[`stored`],source:`summary`,texts:e=>[e.titleSummary]},{id:`displayTitle`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>[t.displayTitle]},{id:`branch`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.branch]},{id:`workflow`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.workflow]},{id:`workflowLabel`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.workflowLabel]},{id:`automation`,kind:`text`,scopes:[`stored`,`shown`],source:`reader`,texts:(e,t)=>[t.automation],universe:e=>[...e.automationNames?.values()??[]]},{id:`projectName`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>[t.projectName]},{id:`tags`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>t.tags??[]},{id:`id`,kind:`identifier`,scopes:[`stored`],source:`summary`,texts:e=>[e.id]},{id:`urls`,kind:`link`,scopes:[`stored`],source:`summary`,texts:e=>[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl,...(e.pullRequests??[]).map(e=>e.url)]},{id:`heldReferences`,kind:`reference`,scopes:[`stored`],source:`summary`,numbers:Xn},{id:`shownReferences`,kind:`reference`,scopes:[`shown`],source:`reader`,numbers:(e,t)=>t.references?.()??[]}];function Qn(e){return e.trim().toLowerCase().split(/\s+/).filter(e=>e!==``)}function $n(e,t){if(t!==`phrase`)return Qn(e);let n=e.trim().toLowerCase();return n===``?[]:[n]}function er(e,t){return t&&e.automationId!==void 0?t.get(e.automationId)??e.automationId:void 0}function tr(e,t){let n=t.scope??`stored`,r=t.scope===`shown`?t.omit??[]:[],i=t.scope===`shown`?t.extras:{automation:er(e,t.automationNames)},a=[],o=[],s=[],c={text:a,identifier:o,link:s},l=[];for(let t of Zn)if(!(!t.scopes.includes(n)||r.includes(t.id))){if(t.kind===`reference`){l.push(()=>t.numbers(e,i));continue}for(let n of t.texts(e,i))typeof n==`string`&&c[t.kind].push(n.toLowerCase())}let u;return{prose:a,ids:o,links:s,references:()=>u??=new Set(l.flatMap(e=>e().map(String)))}}function nr(e,t,n={}){let r=$n(t,n.mode);if(r.length===0)return!1;let{prose:i,ids:a,links:o,references:s}=tr(e,n);return r.every(e=>{if(i.some(t=>t.includes(e)))return!0;let t=e.replace(/^#/,``);return/^\d+$/.test(t)?s().has(String(Number(t)))||a.some(e=>e.startsWith(t)):a.some(t=>t.includes(e))||o.some(t=>t.includes(e))})}var rr=[`Needs you`,`Finished`,`Working`,`Archived`],ir={waiting:0,review:1,running:2,queued:4,done:5,failed:6,cancelled:7},ar=3,W=e=>S(e)?ar:ir[e.status]??9;function or(e){let t=e=>oe[v(e).bucket];return[...e].sort((e,n)=>t(e)-t(n)||W(e)-W(n))[0]}function sr(e,t){return t===`archived`?`Archived`:v(e).bucket===`waiting`?`Needs you`:e.status===`waiting`||e.status===`running`||e.status===`queued`?`Working`:`Finished`}function cr(e){let t=e.titleSummary;return t===void 0||!(e.titleOrigin===`user`||e.titleOrigin===`marker`)&&/[.!?][A-Z]/.test(t)?e.title:t}function lr(e){let t=/^(\d{1,9}): (.+)$/.exec(e),n=t?.[1],r=t?.[2];return n===void 0||r===void 0?{ref:null,rest:e}:{ref:Number(n),rest:r}}function ur(e,t){return t!==void 0&&lr(e).ref===t}function dr(e){let t=e.filter(e=>!e.archived&&e.status===`queued`).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));return new Map(t.map((e,t)=>[e.id,t+1]))}function fr(e,t){return e.filter(e=>t===`archived`?e.archived:!e.archived).sort((e,n)=>{if(t!==`archived`){let t=Number(!!n.pinned)-Number(!!e.pinned);if(t!==0)return t}let r=W(e)-W(n);if(r!==0)return r;if(S(e)&&S(n)){let t=e.autoResumeAt.localeCompare(n.autoResumeAt);if(t!==0)return t}return e.status===`queued`&&n.status===`queued`?e.createdAt.localeCompare(n.createdAt):n.createdAt.localeCompare(e.createdAt)})}function G(e){return e.delegation?.role===`worker`}function pr(e,t){if(e==null)return null;let n=t.find(t=>t.id===e);return!n||!G(n)?e:n.delegation?.parentRunId??e}function mr(e,t,n=dr(e)){let r=fr(e,t).filter(e=>!G(e)),i=new Map,a=(e,t)=>{let n=i.get(e);n?n.push(t):i.set(e,[t])};for(let e of r)a(sr(e,t),{kind:`run`,run:e,queuePosition:n.get(e.id)??null});return rr.filter(e=>i.has(e)).map(e=>({label:e,rows:i.get(e)}))}function hr(e,t={}){let n=typeof t==`number`?{overall:t}:Lt(t),r={"Needs you":`needsYou`,Finished:`finished`,Working:`working`},i=[],a=n.overall===void 0?10:n.overall??1/0;for(let t of e){let e=t.label===`Archived`?1/0:n[r[t.label]]??1/0,o=t.rows.filter(n=>{let r=n.run.pinned;return t.label!==`Archived`&&r?!0:a<=0||e<=0?!1:(--a,--e,!0)});o.length&&i.push({label:t.label,rows:o})}return i}function gr(e,t){if(t.length===0)return[...e];let n=new Set(e.map(e=>e.id)),r=new Set,i=t.filter(e=>n.has(e.id)||r.has(e.id)?!1:(r.add(e.id),!0));return[...e,...i]}function _r(e){let t=0,n=0,r=0;for(let i of e)if(!G(i)){if(i.archived){n+=1;continue}t+=1,v(i).bucket===`waiting`&&(r+=1)}return{active:t,archived:n,waiting:r}}function vr(e,t){let n=t===`automations`;return e.filter(e=>!e.archived&&re(e)===n)}var yr={"Needs you":`needs-you`,Finished:`finished`,Working:`working`},br=Object.keys(yr),xr=`section`;function Sr(e,t){return`/?origin=${t===`automations`?`automations`:`direct`}&${xr}=${yr[e]}`}function Cr(e){return br.find(t=>yr[t]===e)??null}function wr(e){let t={active:0,automations:0,activeWaiting:0,automationsWaiting:0};for(let n of e){if(G(n)||n.archived)continue;let e=+(v(n).bucket===`waiting`);re(n)?(t.automations+=1,t.automationsWaiting+=e):(t.active+=1,t.activeWaiting+=e)}return t}var Tr=new Set([`running`,`waiting`]);function Er(e){return e?e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:`${Math.round(e/1024)} kB`:``}function Dr(e){return e===void 0?``:`$${e>=10?e.toFixed(0):e.toFixed(2)}`}function Or(e,t=new Date){if(!S(e))return;let n=new Date(e.autoResumeAt);if(!Number.isFinite(n.getTime()))return;let r=n.toDateString()===t.toDateString(),i=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}).format(n);return{label:r?i:`${new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(n)} ${i}`,title:`Resumes automatically at ${new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(n)}`}}function kr(e){return e.steps?Jt({workflow:e.workflow,steps:e.steps}):e.workflowLabel??e.workflow}function Ar(e,t,n=()=>``){let r=e.filter(e=>!G(e));return t.trim()?r.filter(e=>nr(e,t,{scope:`shown`,mode:`phrase`,extras:{displayTitle:cr(e),automation:n(e),references:()=>jr(e)}})):[...r]}function jr(e){return K(e).map(e=>e.number)}function Mr(e,t){return e.filter(e=>Gn(e,t)).length}function Nr(e){return Mr(e)}function Pr(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 Fr(e){return Ir(e)[0]??e.pullRequests?.find(e=>e.url)?.url}function Ir(e){let t=[];return e.pullRequestUrl&&t.push(e.pullRequestUrl),!(e.markerRefs?.issue!==void 0&&e.markerRefs?.pr===void 0)&&e.referencedPullRequestUrl&&t.push(e.referencedPullRequestUrl),t}function Lr(e,t){if(e.referencedIssueUrl)return e.referencedIssueUrl;let n=e.issueNumber??e.markerRefs?.issue;if(!(!n||!t))return`${t}/issues/${n}`}function Rr(e){let t=`${e.kind}#${e.number}`;if(!e.url)return`${t}@project:${e.projectId??`default`}`;try{let n=new URL(e.url),r=n.pathname.split(`/`).filter(Boolean).slice(0,2).join(`/`);return`${t}@${n.host.toLowerCase()}/${r.toLowerCase()}`}catch{return`${t}@${e.url}`}}function K(e,t,n=e.projectId){let r=Ir(e),i=e.markerRefs?.pr,a=[...i===void 0||[...r,...(e.pullRequests??[]).flatMap(e=>e.url?[e.url]:[])].some(e=>Gr(e)===String(i))?[]:[{kind:`PR`,number:i}],...r.map(e=>({kind:`PR`,url:e})),{kind:`PR`,number:e.prNumber},...(e.pullRequests??[]).map(e=>({kind:`PR`,number:e.number,...e.url?{url:e.url}:{},authoritative:!0})),{kind:`Issue`,url:Lr(e,t)},{kind:`Issue`,number:e.issueNumber}],o=new Set,s=[];for(let e of a){let r=e.url?Number(Gr(e.url)):e.number;if(!r||!Number.isInteger(r)||!e.url&&!e.authoritative&&s.some(t=>t.url&&t.kind===e.kind&&t.number===r))continue;let i=e.url??zr(e.kind,r,t),a={kind:e.kind,number:r,...i?{url:i}:n===void 0?{}:{projectId:n}},c=Rr(a);o.has(c)||(o.add(c),s.push(a))}return s}function zr(e,t,n){if(n)return`${n}/${e===`PR`?`pull`:`issues`}/${t}`}function Br(e){return K(e)[0]}function Vr(e,t){if(!e.url)return!0;if(!t)return!1;let n=Hr(t);return n!==void 0&&Hr(e.url)===n}function Hr(e){try{let t=new URL(e),[n,r]=t.pathname.split(`/`).filter(Boolean);return n&&r?`${t.host}/${n}/${r}`.toLowerCase():void 0}catch{return}}function Ur(e,t){let n=[];for(let r of K(e,t)){if(!Vr(r,t))continue;let e=r.kind===`PR`?`pr`:`issue`;n.some(t=>t.kind===e&&t.number===r.number)||n.push({kind:e,number:r.number})}return n}function Wr(e,t,n,r){if(Vr(n,r))return`/p/${e}/tasks/${t}/${n.kind===`PR`?`pr`:`issue`}/${n.number}`}function Gr(e){return/\/(\d+)\/?(?:[?#].*)?$/.exec(e)?.[1]??null}function Kr(e,t){let n=Tr.has(e.status)?t:void 0;if(n)return{cpu:{text:`${n.cpuPct.toFixed(0)}%`,kind:`live`},mem:{text:Er(n.rssBytes),kind:`live`}};let r=Er(e.peakRssBytes);return{cpu:{text:``,kind:`none`},mem:r?{text:`peak ${r}`,kind:`peak`,title:`peak — run finished${e.peakProcCount?` · ${e.peakProcCount} procs`:``}`}:{text:``,kind:`none`}}}function qr(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 Jr(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 Yr(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 Xr(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 Zr(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function Qr(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function $r(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){Qr(t.issues,a,r),Qr(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 q=e=>e.map(e=>e.number).join(`,`);function ei(e,t){let n=e[0];if(e.length>1&&n&&(q(n.issues)!==q(t.issues)||q(n.prs)!==q(t.prs)||n.issuesTotal!==t.issuesTotal||n.prsTotal!==t.prsTotal))return`refetch`;let r=t;if(n&&t.available&&t.projectsState===`refreshing`&&n.repo===t.repo){let e=new Map(n.issues.map(e=>[e.number,e.projectIds]));r={...t,issues:t.issues.map(t=>{let n=e.get(t.number);return t.projectIds===void 0&&n!==void 0?{...t,projectIds:n}:t})}}return[r,...e.slice(1)]}var J={get health(){return[n(),`health`]},runs:{get all(){return[n(),`runs`]},relationships:e=>[n(),`runs`,`relationships`,e],list:(e=n())=>[e,`runs`,`list`],archived:e=>[n(),`runs`,`archived`,e],detail:(e,t=n())=>[t,`runs`,`detail`,e],diff:e=>[n(),`runs`,`diff`,e],changes:e=>[n(),`runs`,`changes`,e],file:(e,t)=>[n(),`runs`,`files`,e,t],handoff:e=>[n(),`runs`,`handoff`,e],commits:e=>[n(),`runs`,`commits`,e],commit:(e,t)=>[n(),`runs`,`commit`,e,t]},get workflows(){return[n(),`workflows`]},get skills(){return[n(),`skills`]},get skillsReady(){return[n(),`skills`,`ready`]},get importableSkills(){return[n(),`skills`,`importable`]},get importableSkillsReady(){return[n(),`skills`,`importable`,`ready`]},get launchKey(){return[n(),`launch-key`]},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`]}},Y={models:e=>[`workspace`,`models`,e],providerStatus:[`workspace`,`providers`,`status`],projects:[`workspace`,`projects`],githubOwners:[`workspace`,`github-owners`],runsIndex:z,runsSearch:e=>[`workspace`,`runs-search`,e],uiState:[`workspace`,`ui-state`],config:[`workspace`,`config`],agentProfiles:[`workspace`,`agent-profiles`],agentAccountDetails:e=>[`workspace`,`agent-profiles`,`details`,e],agentAccountStatus:e=>[`workspace`,`agent-profiles`,`status`,e],fsBrowseRoot:[`workspace`,`fs-browse`],fsBrowse:(e,t=!1)=>[...Y.fsBrowseRoot,e,t]};function X(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:Y.models(t),refetchType:n})}function Z(e,t=!0){let n=b();return(0,O.useEffect)(()=>{if(!t||e!==`cursor`)return;let r,i=()=>{let e=n.getQueryData(J.health)?.capabilities?.localHandoff===!0;e&&!r?r=Bt(`models:cursor`,e=>{let t=It.safeParse(e);t.success&&t.data.runner===`cursor`&&(n.cancelQueries({queryKey:Y.models(`cursor`)}),n.setQueryData(Y.models(`cursor`),t.data))}):!e&&r&&(r(),r=void 0)};i();let a=n.getQueryCache().subscribe(i);return()=>{a(),r?.()}},[t,e,n]),E({queryKey:Y.models(e),queryFn:({signal:t})=>w(e)?ot(e,{signal:t}):Promise.reject(Error(`${e} has no host model catalog`)),staleTime:300*1e3,enabled:t&&w(e)})}function ti(e=!0){return{claude:Z(`claude`,e),codex:Z(`codex`,e),opencode:Z(`opencode`,e),pi:Z(`pi`,e),cursor:Z(`cursor`,e),omp:Z(`omp`,e)}}function ni(){let e=b();return E({queryKey:Y.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(Y.providerStatus),r=await ut(!1,{signal:t});return C(n,e.getQueryData(Y.providerStatus),r)},staleTime:5*6e4,refetchInterval:a(!1),refetchOnWindowFocus:!0})}function ri(){let e=b();return A({mutationFn:()=>ut(!0),onMutate:()=>e.getQueryData(Y.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Y.providerStatus,e=>C(r,e,t)),X(e)}})}function ii(){let e=b();return A({mutationFn:({provider:e,authFailureId:t})=>Qe(e,t),onMutate:()=>e.getQueryData(Y.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Y.providerStatus,e=>C(r,e,t,n.authFailureId)),w(n.provider)&&X(e,n.provider)}})}function ai(e={}){return E({queryKey:Y.projects,queryFn:({signal:e})=>mt({signal:e}),...e})}function oi(e,t=!1){return E({queryKey:Y.fsBrowse(e,t),queryFn:({signal:n})=>st(e??void 0,{signal:n,showHidden:t}),retry:!1})}function si(){let e=b();return A({mutationFn:e=>Ve(e),onSuccess:()=>e.invalidateQueries({queryKey:Y.projects})})}function ci(){let e=b();return A({mutationFn:e=>St(e),retry:!1,onSuccess:()=>{e.invalidateQueries({queryKey:Y.projects})}})}function li(){let e=b();return A({mutationFn:e=>{let{id:t,...n}=e;return at(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:Y.projects});let r=e.getQueryData(Y.projects);return e.setQueryData(Y.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?ui(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(Y.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(Y.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:Y.projects})})}function ui(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?[]:Yr(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 di(e){let t=b();return A({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(Y.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:Y.projects})})}function fi(){return di(e=>{let{projectId:t,...n}=e;return _e(t,n)})}function pi(){return di(e=>{let{projectId:t,webhookId:n,...r}=e;return c(t,n,r)})}function mi(){return di(({projectId:e,webhookId:t})=>Ue(e,t))}function hi(){return A({mutationFn:({projectId:e,webhookId:t})=>ye(e,t),retry:!1})}function gi(e){let t=b();return A({mutationFn:t=>ee(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function Q(e){let t=b();return A({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:Y.agentProfiles}),t.invalidateQueries({queryKey:Y.projects})])}})}function _i(){return Q(e=>jt(e))}function vi(){return Q(e=>{let{id:t,...n}=e;return p(t,n)})}function yi(){return Q(e=>ct(e))}function bi(){return Q(e=>Re(e))}function xi(e,t){return E({queryKey:Y.agentAccountDetails(e),queryFn:({signal:t})=>te(e,{signal:t}),enabled:t,staleTime:0,retry:!1})}function Si(e,t){return E({queryKey:Y.agentAccountStatus(e),queryFn:({signal:t})=>ae(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function Ci(){let e=b();return A({mutationFn:({provider:e,profileId:t})=>Pe(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:Y.agentProfiles}),e.invalidateQueries({queryKey:Y.providerStatus}),w(n)?X(e,n,`none`):Promise.resolve()])}})}function wi(){let e=b();return A({mutationFn:e=>ae(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(Y.agentAccountStatus(n),t),e.invalidateQueries({queryKey:Y.agentProfiles}),w(t.status.provider)&&X(e,t.status.provider)}})}function Ti(){return A({mutationFn:e=>{let{routeId:t,...n}=e;return we(t,n)},retry:!1})}function Ei(){let e=b();return A({mutationFn:e=>et(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Y.projects})})}function Di(){let e=b();return A({mutationFn:e=>Ot(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Y.projects})})}function Oi({enabled:e}){return E({queryKey:Y.githubOwners,queryFn:({signal:e})=>dt({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function ki(){let e=b();(0,O.useEffect)(()=>{let n,r=()=>{let r=e.getQueryData(J.health),i=r?.capabilities?.localHandoff===!0;r&&be({local:i,bootProject:r.bootProject??`default`,apiBase:t()}),i&&n===void 0?n=Bt(`health`,t=>{e.setQueryData(J.health,t)}):!i&&n!==void 0&&(n(),n=void 0)};r();let i=e.getQueryCache().subscribe(r);return()=>{i(),n?.(),rt()}},[e])}function $(){return E({queryKey:J.health,queryFn:({signal:e})=>He({signal:e})})}function Ai(e,t){let n=$().data,r=ai(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?Pr(n?.repo?.remote):void 0}function ji(){return E({queryKey:J.openTargets,queryFn:({signal:e})=>Xe({signal:e}),staleTime:5*6e4})}function Mi(){return E({queryKey:J.runs.list(),queryFn:({signal:e})=>l(j(),{signal:e})})}function Ni(e,t){return Rt({queryKey:J.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>Te({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 Pi(e){let t=e.trim();return E({queryKey:Y.runsSearch(t),queryFn:({signal:e})=>Mt(t,{signal:e}),enabled:t.length>=2,placeholderData:Ie,staleTime:1e4})}function Fi(e=!0,t=_n){let n=B(b());return D(`/api/v1/workspace/runs-index`,Y.runsIndex,a(e?t:!1),bn),E({queryKey:Y.runsIndex,queryFn:({signal:e})=>it({signal:e}).then(n.merge),enabled:e,staleTime:3e4,refetchInterval:!1})}function Ii(e,t=!0,n=!1){return E({queryKey:[j({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>l(j({projectId:e,boot:n}),{signal:t}),enabled:t})}function Li(e){let t=b();return A({mutationFn:e=>ce(e),onSettled:()=>t.invalidateQueries({queryKey:J.runs.relationships(e)})})}function Ri(e,t={}){return E({queryKey:J.runs.relationships(e),queryFn:({signal:t})=>fe(e,{signal:t}),enabled:t.enabled??!0})}function zi(e){return E({queryKey:J.runs.detail(e??``),queryFn:({signal:t})=>Nt(M(e),{signal:t}),enabled:!!e})}function Bi(e,t,n=!0){return E({queryKey:[e??`default`,`runs`,`detail`,t??``],queryFn:({signal:n})=>Nt(M(t,{projectId:e}),{signal:n}),enabled:n&&!!e&&!!t})}function Vi(e){return E({queryKey:J.runs.diff(e??``),queryFn:({signal:t})=>f(e,{signal:t}),enabled:!!e})}function Hi(e,t=!1){return D(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/changes`:void 0,J.runs.changes(e??``),a(t?4e3:!1)),E({queryKey:J.runs.changes(e??``),queryFn:({signal:t})=>ze(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function Ui(e,t){return E({queryKey:J.runs.file(e??``,t??``),queryFn:({signal:n})=>Dt(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function Wi(e,t){return E({queryKey:[n(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>ke(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Gi(e,t){return E({queryKey:[n(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>_(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Ki(e,t){return E({queryKey:[n(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>Se(e,t,{signal:n}),enabled:t!==null,retry:!1})}function qi(e){return E({queryKey:[n(),`runs`,`artifacts`,e],queryFn:({signal:t})=>De(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function Ji(e,t=!1){return D(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/commits`:void 0,J.runs.commits(e??``),a(t?5e3:!1)),E({queryKey:J.runs.commits(e??``),queryFn:({signal:t})=>ve(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function Yi(e,t){return E({queryKey:J.runs.commit(e??``,t??``),queryFn:({signal:n})=>At(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function Xi(e,t=!0){return E({queryKey:J.runs.handoff(e??``),queryFn:({signal:t})=>xe(M(e),{signal:t}),enabled:!!e&&t})}function Zi(e,t,n){return E({queryKey:e===void 0?J.runs.handoff(t):[e,`runs`,`handoff`,t],queryFn:({signal:n})=>xe(M(t,{projectId:e}),{signal:n}),enabled:n,staleTime:15e3})}function Qi(e,t){let r=[...new Set(e)],i=k({queries:r.map(e=>({queryKey:[e??n(),`automations`,`names`],queryFn:({signal:t})=>ht({signal:t,archived:`include`,...e===void 0?{}:{projectId:e}}),enabled:t,staleTime:6e4,retry:!1}))}),a=i.map(e=>e.data);return(0,O.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 $i(){return E({queryKey:J.workflows,queryFn:({signal:e})=>h({signal:e})})}function ea(e=!0){let t=b(),n=J.skills,r=n[0],i=E({queryKey:n,queryFn:({signal:e})=>le({signal:e}),enabled:e}),a=E({queryKey:J.skillsReady,queryFn:({signal:e})=>de({signal:e}),enabled:e&&i.isSuccess,staleTime:1/0,retry:!1});return(0,O.useEffect)(()=>{Array.isArray(a.data)&&t.setQueryData([r,`skills`],a.data)},[t,a.data,r]),i}function ta(e=!0){let t=b(),n=J.importableSkills,r=n[0],i=E({queryKey:n,queryFn:({signal:e})=>lt({signal:e}),enabled:e}),a=E({queryKey:J.importableSkillsReady,queryFn:({signal:e})=>Ct({signal:e}),enabled:e&&i.isSuccess,staleTime:1/0,retry:!1});return(0,O.useEffect)(()=>{Array.isArray(a.data)&&t.setQueryData([r,`skills`,`importable`],a.data)},[t,a.data,r]),i}function na(){return E({queryKey:J.launchKey,queryFn:({signal:e})=>We({signal:e}),staleTime:1/0})}function ra(){return E({queryKey:J.repo,queryFn:({signal:e})=>tt({signal:e})})}function ia(e){return E({queryKey:[e,`repo`],queryFn:({signal:t})=>tt({signal:t},e)})}function aa(){return E({queryKey:J.repoBranches,queryFn:({signal:e})=>$e({signal:e})})}function oa(){return E({queryKey:J.repoChanges,queryFn:({signal:e})=>Fe({signal:e}),retry:!1})}function sa(e){return E({queryKey:J.repoCommit(e??``),queryFn:({signal:t})=>Tt(e,{signal:t}),enabled:!!e,retry:!1})}function ca(){return E({queryKey:J.config,queryFn:({signal:e})=>je({signal:e})})}function la(){return E({queryKey:J.worktrees,queryFn:({signal:e})=>ge({signal:e})})}function ua(e){return E({queryKey:[e,`worktrees`],queryFn:({signal:t})=>ge({signal:t},e),staleTime:0})}function da(e,t=!0,n=!1){return E({queryKey:[j({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>pe({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:Lt(e.sidebarLimits)},enabled:t})}function fa(){return da(n())}function pa(){return E({queryKey:J.agentConfig,queryFn:({signal:e})=>he({signal:e})})}function ma(e){return E({queryKey:J.agentConfigFile(e??``),queryFn:({signal:t})=>Pt(e,{signal:t}),enabled:e!==null})}function ha(e){let t=b(),n=J.agentConfig,r=J.agentConfigFile(e);return A({mutationFn:t=>Ke(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}function ga(){return E({queryKey:Y.uiState,queryFn:({signal:e})=>se({signal:e})})}function _a(){return E({queryKey:Y.config,queryFn:({signal:e})=>ne({signal:e})})}function va(){return E({queryKey:Y.agentProfiles,queryFn:({signal:e})=>u({signal:e})})}function ya(e){let t=b();return A({mutationFn:t=>Ne(e,t),onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function ba(e){let t=L(),n=e?.projectId,r=e?.cacheScope,i=A({mutationFn:e=>Et(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),a=(0,O.useCallback)(e=>({...M(e,{projectId:n,cacheScope:r}),id:e}),[n,r]),o=(0,O.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,O.useCallback)((e,t)=>s(a(e),o(t)),[s,a,o]),u=(0,O.useCallback)((e,t)=>c(a(e),o(t)),[c,a,o]);return{...i,variables:i.variables?.id,mutate:l,mutateAsync:u}}function xa(){let e=L();return A({mutationFn:e=>Et(M(e),!1),onMutate:t=>e.patchRead(()=>M(t),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function Sa(e){let t=L();return A({mutationFn:({id:t,pinned:n})=>Ae(M(t,e),n),onError:e=>Vt(`Could not update pin. ${e.message} Please retry.`,{tone:`danger`}),onMutate:()=>e??j(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function Ca(e,t){let n=L();return A({mutationFn:n=>kt(M(e,{projectId:t}),n),onMutate:()=>j({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`send`,r),onError:(e,t,r)=>{e instanceof nt&&e.status===409&&r&&n.invalidateAfter(`send`,r)}})}function wa(e,t){let n=L();return A({mutationFn:(n={})=>wt(M(e,{projectId:t}),n),onMutate:()=>j({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`continue`,r)})}function Ta(e){let t=b();return A({mutationFn:({msgId:t,message:n})=>ue(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function Ea(e){let t=b();return A({mutationFn:t=>Ye(e,t),onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function Da(e={},t=!0){let r=b(),i=J.github(e);D(`/api/v1/p/${n()}/github${e.limit===void 0?``:`?limit=${e.limit}`}`,i,a(t?6e4:!1));let o=E({queryKey:J.github(e),queryFn:({signal:t})=>x({limit:e.limit},{signal:t}),enabled:t,staleTime:6e4,refetchInterval:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0}),s=o.data?.projectsGeneration,c=E({queryKey:[...i,`projects`,s],queryFn:({signal:e})=>Le(s,{signal:e}),enabled:t&&o.data?.projectsState===`refreshing`&&!!s,staleTime:1/0,retry:!1});return(0,O.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 Oa=class extends Error{};function ka(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await x({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new Oa(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>Xr(e),retry:(e,t)=>!(t instanceof Oa)&&!(t instanceof nt&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function Aa(e=50,t=!0){let r=b(),i=J.githubPages(e),o=J.githubPagesHead(e);D(`/api/v1/p/${n()}/github?limit=${e}`,o,a(t?6e4:!1));let s=Rt({...ka(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),c=E({queryKey:o,queryFn:({signal:t})=>x({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:l}=s;(0,O.useEffect)(()=>{if(!c.data)return;let e=r.getQueryData(i);if(!e||e.pages.length===0)return;let t=ei(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=k({queries:u.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>Le(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,O.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,O.useMemo)(()=>$r(s.data?.pages??[]),[s.data])}}function ja(e,t=50,n=!0){let r=Rt({...ka([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,O.useMemo)(()=>$r(r.data?.pages??[]),[r.data])}}function Ma(e,t,n=!0){let r=k({queries:t.filter(e=>e.length>0).map(t=>({queryKey:J.githubCommentCounts(e,t),queryFn:({signal:n})=>o(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,O.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 Na(e,t,n,r=!0){return E({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>yt(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function Pa(e,t=!0){return E({queryKey:J.githubChecks(e),queryFn:({signal:t})=>me(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function Fa(e,t,n=!0){return E({queryKey:J.githubSearch(e,t),queryFn:({signal:n})=>yt(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var Ia=100;function La(e){return[...e].sort((e,t)=>t-e).slice(0,Ia).sort((e,t)=>e-t)}function Ra(){let e=gt(),t=$();return e.projectId??t.data?.bootProject}function za(e){for(let[t,n]of Object.entries(e)){for(let[e,r]of Object.entries(n.prs))An(U({projectId:t,kind:`PR`,number:Number(e)}),r);for(let[e,r]of Object.entries(n.issues))An(U({projectId:t,kind:`Issue`,number:Number(e)}),r)}}var Ba=5*6e4;function Va(e){return e?e.recheckAfterMs:Ba}function Ha(e,t=!0){let n=(0,O.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:La(t.prs),issues:La(t.issues)}))},[e.map(U).sort().join(`|`)]),r=k({queries:n.map(e=>({queryKey:J.githubRefStatus(e.projectId,e.prs,e.issues),queryFn:({signal:t})=>ft(e.projectId,{prs:e.prs,issues:e.issues},{signal:t}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>Va(e.state.data)??1/0,refetchInterval:!1,refetchOnWindowFocus:!0}))}),a=b(),o=JSON.stringify(n.map((e,t)=>({...e,interval:Va(r[t]?.data)??!1})));(0,O.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=J.githubRefStatus(t.projectId,t.prs,t.issues);return zt({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,O.useMemo)(()=>Hn(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,O.useCallback)(e=>{let t=U(e),n=s.get(t);if(n)return n;let r=V.get(t);return{state:`idle`,...r?{status:r}:{},...H.has(t)?{conflicting:!0}:{}}},[s])}function Ua(e,t,n=!0){return E({queryKey:J.githubComments(e,t),queryFn:({signal:n})=>qe(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Wa(e,t,n=!0){return E({queryKey:J.githubItem(e,t),queryFn:({signal:n})=>bt(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Ga(e){return E({queryKey:J.githubPrChanges(e??0),queryFn:({signal:t})=>vt(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{ai as $,Rr as $t,Oi as A,gr as An,Ca as At,gi as B,L as Bn,ga as Bt,Wi as C,cr as Cn,Ri as Ct,Ma as D,vr as Dn,Fi as Dt,Pa as E,wr as En,Mi as Et,ki as F,Gn as Fn,vi as Ft,ja as G,Jr as Gt,ji as H,M as Hn,Y as Ht,ta as I,Jn as In,li as It,Ai as J,Dr as Jt,Na as K,Ar as Kt,na as L,En as Ln,pi as Lt,Ga as M,qn as Mn,Zi as Mt,Fa as N,Un as Nn,hi as Nt,Ua as O,fr as On,Pi as Ot,$ as P,Wn as Pn,fa as Pt,ua as Q,Gr as Qt,ba as R,On as Rn,$i as Rt,Ta as S,ur as Sn,Xi as St,Da as T,pr as Tn,Z as Tt,ya as U,A as Un,Zr as Ut,Ti as V,j as Vn,la as Vt,Sa as W,Ht as Wn,qr as Wt,Ii as X,Pr as Xt,Bi as Y,Er as Yt,da as Z,Vr as Zt,wa as _,G as _n,Hi as _t,Si as a,Ur as an,ri as at,fi as b,Cr as bn,Vi as bt,va as c,K as cn,ci as ct,Ki as d,rr as dn,ra as dt,Or as en,ni as et,qi as f,xr as fn,aa as ft,Ci as g,mr as gn,zi as gt,ca as h,hr as hn,ii as ht,xi as i,Wr as in,Ha as it,Aa as j,nr as jn,ea as jt,Wa as k,lr as kn,bi as kt,Ni as l,Kr as ln,mi as lt,Ei as m,sr as mn,sa as mt,J as n,Mr as nn,wi as nt,pa as o,Fr as on,si as ot,Qi as p,br as pn,oa as pt,ia as q,Nr as qt,za as r,Lr as rn,Ra as rt,ma as s,Br as sn,yi as st,X as t,jr as tn,ha as tt,Gi as u,kr as un,Ea as ut,_i as v,_r as vn,Yi as vt,oi as w,Sr as wn,ti as wt,Li as x,dr as xn,Ui as xt,Di as y,or as yn,Ji as yt,xa as z,B as zn,_a as zt};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{A as t,M as n}from"./button-CHUAMTHK.js";import{i as r}from"./react-runtime-CCIEwYL0.js";import{r as i,t as a}from"./live-refetch-C0kQc3-z.js";import{$ as o,$r as s,An as c,At as l,B as u,Br as d,Ct as f,Dn as p,Er as m,Ft as h,Gr as g,H as _,Hn as v,Hr as y,Ht as ee,I as te,It as ne,Jr as b,Kn as re,Kr as ie,L as ae,Ln as oe,Lt as se,M as ce,Mt as le,N as ue,Nt as de,Ot as fe,Pt as pe,Q as me,R as he,Rt as ge,S as _e,St as ve,Tn as ye,Tr as be,Tt as xe,U as Se,Ur as Ce,Ut as we,V as Te,Vr as Ee,W as De,Wr as Oe,X as ke,Xt as Ae,Y as je,Yr as Me,Yt as Ne,Z as x,_ as Pe,_t as Fe,ai as Ie,ar as S,at as Le,bn as Re,br as C,bt as ze,ci as Be,cn as Ve,ct as He,dn as Ue,dt as We,ei as Ge,en as Ke,et as qe,fi as Je,fn as Ye,ft as Xe,gi as Ze,gn as Qe,gt as $e,h as et,ht as tt,i as nt,jr as rt,jt as it,kn as at,kt as ot,l as st,ln as ct,lt,mt as ut,nt as dt,ot as ft,pi as pt,pt as mt,q as ht,r as gt,ri as _t,rt as vt,st as yt,tt as bt,ui as xt,un as St,ut as Ct,v as wt,vt as Tt,wn as Et,wt as Dt,x as Ot,xn as kt,xt as At,y as jt,yn as Mt,yt as Nt,z as Pt,zr as Ft}from"./project-scope-context-CaUqlAd7.js";import{I as w,L as It,N as Lt,ft as T}from"./live-protocol-BDY7JJpT.js";import{t as Rt}from"./useInfiniteQuery-qEY8OhKb.js";import{t as E}from"./useQuery-DOJQOEBO.js";import{n as zt,r as D,t as Bt}from"./ws-DvGmrP4z.js";import{n as Vt}from"./toaster-B1MyeHiE.js";var Ht=class extends s{#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||Ut(),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=Ge({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),T.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Ut(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Wt=class extends Ze{#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),Je(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&_t(t.mutationKey)!==_t(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??Ut();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){T.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 Gt(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Kt(e,t,n){let r=e.slice(0);return r[t]=n,r}var qt=class extends Ze{#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,T.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||!Je(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Gt(e,n).forEach(e=>{e.destroy()}),Gt(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=xt(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 Me(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Kt(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)&&T.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},O=e(r(),1);function k({queries:e,...t},n){let r=b(n),i=ie(),a=g(),o=O.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{Ft(e);let t=r.getQueryCache().get(e.queryHash);y(e,a,t)}),Oe(a);let[s]=O.useState(()=>new qt(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),f=!i&&t.subscribed!==!1;O.useSyncExternalStore(O.useCallback(e=>f?s.subscribe(T.batchCalls(e)):Be,[s,f]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),O.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let p=c.some((e,t)=>Ee(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&Ee(n,e)?d(n,new Me(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=c.find((e,t)=>{let n=o[t];return n&&Ce({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m?.error)throw m.error;return l(u())}function A(e,t){let n=b(t),[r]=O.useState(()=>new Wt(n,e));O.useEffect(()=>{r.setOptions(e)},[r,e]);let i=O.useSyncExternalStore(O.useCallback(e=>r.subscribe(T.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=O.useCallback((e,t)=>{r.mutate(e,t).catch(Be)},[r]);if(i.error&&pt(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function j(e={}){let t=e.projectId??n();return{projectId:t,cacheScope:e.cacheScope??(e.boot?`default`:t)}}function M(e,t={}){return{...j(t),runId:e}}function Jt(e){if(e.workflow===`(planned)`||e.workflow===`(inbox)`){let t=(e.steps??[]).find(e=>e.kind===`agent`);if(t?.name)return t.name}return e.workflow}var N=[`workspace`,`runs-index`],P=e=>[e.cacheScope,`runs`,`list`],F=e=>[e.cacheScope,`runs`,`detail`,e.runId],I=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:N})};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=m(),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:P(I(n))}),await e.cancelQueries({queryKey:F(I(n))});let i=e.getQueryData(P(I(n))),a=e.getQueryData(F(I(n))),o=I(n).runId,s=new Date().toISOString();return e.setQueryData(P(I(n)),e=>e?.map(e=>e.id===o?Zt(e,r,s):e)),e.setQueryData(F(I(n)),e=>e&&Zt(e,r,s)),{id:o,prevList:i,prevDetail:a,rollback(){if(!r){i&&e.setQueryData(P(I(n)),i),a&&e.setQueryData(F(I(n)),a);return}let t=i?.find(e=>e.id===o);t&&e.setQueryData(P(I(n)),e=>e?.map(e=>e.id===o?Xt(e,t):e)),a&&e.setQueryData(F(I(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(P(I(n)),e=>e?.map(a));let s={...I(n),runId:r?o:i.id};e.setQueryData(F(s),e=>e?a(e):i),t()}}}async function a(t,n){await e.cancelQueries({queryKey:N});let i=e.getQueryData(N),a=n();return e.setQueryData(N,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(N,i)},settle(){r(`indexed`,t)}}}return{patchRead:i,patchIndex:a,invalidateAfter:r}}function L(){let e=b();return(0,O.useMemo)(()=>Qt(e),[e])}function $t(e){return e.type===`run`?e.run.id:e.id}function R(e,t){return{...e,runs:t}}function en(e,t){let n=0;for(let r of e)r.projectId===t&&r.archived&&(n+=1);return n}function tn(e,t){let n=e.findIndex(e=>(e.createdAt??``).localeCompare(t.createdAt)<0),r=[...e];return r.splice(n<0?e.length:n,0,t),r}function nn(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function rn(e,t,n){let{project:r}=t,i=$t(t),a=e.runs.findIndex(e=>e.projectId===r&&e.id===i),o=a>=0?e.runs[a]:void 0,s=e.truncated.includes(r);if(t.type===`deleted`)return o?{index:R(e,e.runs.filter((e,t)=>t!==a)),reconcile:s&&o.archived}:{index:e,reconcile:!1};let{run:c}=t;if(c.delegation?.role===`worker`)return o?{index:R(e,e.runs.filter((e,t)=>t!==a)),reconcile:!1}:{index:e,reconcile:!1};if(!o&&!nn(e,r,n))return{index:e,reconcile:!0};let l=xt(o,{projectId:r,...c});if(o){if(l===o)return{index:e,reconcile:!1};let t=[...e.runs];t[a]=l;let n=o.archived!==l.archived&&(s||en(t,r)>e.perProjectLimit);return{index:R(e,t),reconcile:n}}if(s)return on(e,l);let u=tn(e.runs,l);return{index:R(e,u),reconcile:l.archived&&en(u,r)>e.perProjectLimit}}function an(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 on(e,t){let n=an(e.runs,t.projectId),r=n!==void 0&&t.createdAt>n;return t.archived&&!r?{index:e,reconcile:!1}:{index:R(e,tn(e.runs,t)),reconcile:t.archived||n===void 0||t.createdAt<n}}function sn(e,t,n){let r=!1,i=e.runs.map(e=>{if(e.projectId!==t)return e;let i=n[e.id];if(i){let t=xt(e.usage,i);return t===e.usage?e:(r=!0,{...e,usage:t})}if(e.usage===void 0)return e;r=!0;let{usage:a,...o}=e;return o});return r?R(e,i):e}function cn(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 ln(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function un(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 dn(e){e.stream=void 0}function fn(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,$t(t)]),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}function pn(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function mn(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function hn(e,t,n){if(!mn(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=rn(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 z=[`workspace`,`runs-index`],gn=[`workspace`,`projects`],_n=6e4,vn=100,yn=new WeakMap;function B(e){let t=yn.get(e);return t||(t=wn(e),yn.set(e,t)),t}function bn(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:B(t).merge(e)}function xn(e){let t=e.getQueryData(gn)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function Sn(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 Cn(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 wn(e){let t=ln(),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(z,t)},h=()=>e.getQueryData(z),g=()=>{clearTimeout(a),a=void 0;let t=e.getQueryCache().find({queryKey:z,exact:!0}),n=(t!==void 0&&t.state.data===void 0&&t.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:z,exact:!0}).then(()=>e.invalidateQueries({queryKey:z})):e.invalidateQueries({queryKey:z})).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=xn(e),s=a,c=!1;for(let e of t){if(e.generation!==a.generation)continue;if(e.type===`usage`){l.has(e.project)||(s=sn(s,e.project,e.usage));continue}if(l.has(e.change.project)||e.change.seq<=a.eventSeq)continue;let t=rn(s,e.change,o);s=t.index,c||=t.reconcile}s!==a&&m(s),c&&_({hold:!0})},y=()=>{if(i!==void 0)return;let e=c+250-Date.now();if(e>0){i=setTimeout(v,e);return}i=setTimeout(v,vn),typeof requestAnimationFrame==`function`&&(r=requestAnimationFrame(v))};return{ready(e,n){un(t,e,n),u=!1,f&&(f=!1,_({hold:!0}))},detach(){dn(t)},run(e,r,i=!1){if(l.has(e))return;let a=Cn(e,r);if(!fn(t,a,i)){p();return}n.push({type:`change`,change:a,generation:t.stream}),y()},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}),y()}},dropProject(e){l.add(e),pn(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let r=h();if(!r)return;let i=cn(r,e);i!==r&&m(i)},setUnknownGenerationHandler(e){d=e},restoreProject(e){l.delete(e)},merge(n){let r=h(),i=hn(t,n,xn(e));for(let e of l)i.index=cn(i.index,e);return i.reconcile&&queueMicrotask(()=>{_({hold:!0})}),Sn(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 Tn={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`}},En={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function Dn(e){return typeof e==`string`&&Object.hasOwn(Tn,e)}function On(e){return e!==void 0&&Dn(e)?Tn[e]:void 0}var V=new Map(Pn()),kn=1e3;function An(e,t){if(V.get(e)!==t){for(V.delete(e),V.set(e,t);V.size>kn;){let e=V.keys().next().value;if(e===void 0)break;V.delete(e)}Ln()}}var H=new Set(Fn());function jn(e,t){if(H.has(e)!==t){if(t)for(H.add(e);H.size>kn;){let e=H.values().next().value;if(e===void 0)break;H.delete(e)}else H.delete(e);Ln()}}var Mn=`cez.reference-statuses.v1`,Nn=`cez.reference-conflicts.v1`;function Pn(){try{let e=globalThis.sessionStorage?.getItem(Mn);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`&&Dn(e[1])):[]}catch{return[]}}function Fn(){try{let e=globalThis.sessionStorage?.getItem(Nn);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var In;function Ln(){In===void 0&&(In=setTimeout(()=>{In=void 0;try{globalThis.sessionStorage?.setItem(Mn,JSON.stringify([...V])),globalThis.sessionStorage?.setItem(Nn,JSON.stringify([...H]))}catch{}},250))}var U=e=>`${e.projectId}\u0000${e.kind}#${e.number}`;function Rn(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function zn(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 Bn(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;An(t,o),s!==void 0&&jn(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function Vn(e,t,n){let r=U(t),i=V.get(r),a=H.has(r)?!0:void 0,o=n.data;if(o?.available){Bn(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...Rn(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...Rn(i,a)});return}e.set(r,{state:`loading`,...Rn(i,a)})}function Hn(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of zn(i))Vn(n,e,t)}),n}function Un(e){return S(e)?!1:e.status===`queued`||e.status===`running`||e.status===`waiting`}function Wn(e){return Un(e)&&e.status!==`queued`}function Gn(e,t,n){return e.archived||!(e.status===`done`||e.status===`failed`||e.status===`cancelled`)||e.delegation?.role===`worker`||n!==void 0&&re(e)!==n?!1:t===`unpinned`?!e.pinned:t!==`pinned`||e.pinned===!0}var Kn=[`done`,`failed`];function qn(e){return e.archived||S(e)||!Kn.includes(e.status)?!1:e.finishedAt!==void 0}function Jn(e){let t=e.finishedAt;return t===void 0||!qn(e)?!1:e.seenAt===void 0||e.seenAt<t}function Yn(e){let t=/\/(\d+)\/?$/.exec(e.trim()),n=t?Number(t[1]):NaN;return Number.isInteger(n)&&n>0?n:null}function Xn(e){let t=new Set;for(let n of[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl]){let e=n?Yn(n):null;e!==null&&t.add(e)}for(let n of[e.prNumber,e.issueNumber,e.markerRefs?.pr,e.markerRefs?.issue])typeof n==`number`&&Number.isInteger(n)&&n>0&&t.add(n);for(let n of e.pullRequests??[])t.add(n.number);return[...t]}var Zn=[{id:`title`,kind:`text`,scopes:[`stored`],source:`summary`,texts:e=>[e.title]},{id:`titleSummary`,kind:`text`,scopes:[`stored`],source:`summary`,texts:e=>[e.titleSummary]},{id:`displayTitle`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>[t.displayTitle]},{id:`branch`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.branch]},{id:`workflow`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.workflow]},{id:`workflowLabel`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.workflowLabel]},{id:`automation`,kind:`text`,scopes:[`stored`,`shown`],source:`reader`,texts:(e,t)=>[t.automation],universe:e=>[...e.automationNames?.values()??[]]},{id:`projectName`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>[t.projectName]},{id:`tags`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>t.tags??[]},{id:`id`,kind:`identifier`,scopes:[`stored`],source:`summary`,texts:e=>[e.id]},{id:`urls`,kind:`link`,scopes:[`stored`],source:`summary`,texts:e=>[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl,...(e.pullRequests??[]).map(e=>e.url)]},{id:`heldReferences`,kind:`reference`,scopes:[`stored`],source:`summary`,numbers:Xn},{id:`shownReferences`,kind:`reference`,scopes:[`shown`],source:`reader`,numbers:(e,t)=>t.references?.()??[]}];function Qn(e){return e.trim().toLowerCase().split(/\s+/).filter(e=>e!==``)}function $n(e,t){if(t!==`phrase`)return Qn(e);let n=e.trim().toLowerCase();return n===``?[]:[n]}function er(e,t){return t&&e.automationId!==void 0?t.get(e.automationId)??e.automationId:void 0}function tr(e,t){let n=t.scope??`stored`,r=t.scope===`shown`?t.omit??[]:[],i=t.scope===`shown`?t.extras:{automation:er(e,t.automationNames)},a=[],o=[],s=[],c={text:a,identifier:o,link:s},l=[];for(let t of Zn)if(!(!t.scopes.includes(n)||r.includes(t.id))){if(t.kind===`reference`){l.push(()=>t.numbers(e,i));continue}for(let n of t.texts(e,i))typeof n==`string`&&c[t.kind].push(n.toLowerCase())}let u;return{prose:a,ids:o,links:s,references:()=>u??=new Set(l.flatMap(e=>e().map(String)))}}function nr(e,t,n={}){let r=$n(t,n.mode);if(r.length===0)return!1;let{prose:i,ids:a,links:o,references:s}=tr(e,n);return r.every(e=>{if(i.some(t=>t.includes(e)))return!0;let t=e.replace(/^#/,``);return/^\d+$/.test(t)?s().has(String(Number(t)))||a.some(e=>e.startsWith(t)):a.some(t=>t.includes(e))||o.some(t=>t.includes(e))})}var rr=[`Needs you`,`Finished`,`Working`,`Archived`],ir={waiting:0,review:1,running:2,queued:4,done:5,failed:6,cancelled:7},ar=3,W=e=>S(e)?ar:ir[e.status]??9;function or(e){let t=e=>oe[v(e).bucket];return[...e].sort((e,n)=>t(e)-t(n)||W(e)-W(n))[0]}function sr(e,t){return t===`archived`?`Archived`:v(e).bucket===`waiting`?`Needs you`:e.status===`waiting`||e.status===`running`||e.status===`queued`?`Working`:`Finished`}function cr(e){let t=e.titleSummary;return t===void 0||!(e.titleOrigin===`user`||e.titleOrigin===`marker`)&&/[.!?][A-Z]/.test(t)?e.title:t}function lr(e){let t=/^(\d{1,9}): (.+)$/.exec(e),n=t?.[1],r=t?.[2];return n===void 0||r===void 0?{ref:null,rest:e}:{ref:Number(n),rest:r}}function ur(e,t){return t!==void 0&&lr(e).ref===t}function dr(e){let t=e.filter(e=>!e.archived&&e.status===`queued`).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));return new Map(t.map((e,t)=>[e.id,t+1]))}function fr(e,t){return e.filter(e=>t===`archived`?e.archived:!e.archived).sort((e,n)=>{if(t!==`archived`){let t=Number(!!n.pinned)-Number(!!e.pinned);if(t!==0)return t}let r=W(e)-W(n);if(r!==0)return r;if(S(e)&&S(n)){let t=e.autoResumeAt.localeCompare(n.autoResumeAt);if(t!==0)return t}return e.status===`queued`&&n.status===`queued`?e.createdAt.localeCompare(n.createdAt):n.createdAt.localeCompare(e.createdAt)})}function G(e){return e.delegation?.role===`worker`}function pr(e,t){if(e==null)return null;let n=t.find(t=>t.id===e);return!n||!G(n)?e:n.delegation?.parentRunId??e}function mr(e,t,n=dr(e)){let r=fr(e,t).filter(e=>!G(e)),i=new Map,a=(e,t)=>{let n=i.get(e);n?n.push(t):i.set(e,[t])};for(let e of r)a(sr(e,t),{kind:`run`,run:e,queuePosition:n.get(e.id)??null});return rr.filter(e=>i.has(e)).map(e=>({label:e,rows:i.get(e)}))}function hr(e,t={}){let n=typeof t==`number`?{overall:t}:Lt(t),r={"Needs you":`needsYou`,Finished:`finished`,Working:`working`},i=[],a=n.overall===void 0?10:n.overall??1/0;for(let t of e){let e=t.label===`Archived`?1/0:n[r[t.label]]??1/0,o=t.rows.filter(n=>{let r=n.run.pinned;return t.label!==`Archived`&&r?!0:a<=0||e<=0?!1:(--a,--e,!0)});o.length&&i.push({label:t.label,rows:o})}return i}function gr(e,t){if(t.length===0)return[...e];let n=new Set(e.map(e=>e.id)),r=new Set,i=t.filter(e=>n.has(e.id)||r.has(e.id)?!1:(r.add(e.id),!0));return[...e,...i]}function _r(e){let t=0,n=0,r=0;for(let i of e)if(!G(i)){if(i.archived){n+=1;continue}t+=1,v(i).bucket===`waiting`&&(r+=1)}return{active:t,archived:n,waiting:r}}function vr(e,t){let n=t===`automations`;return e.filter(e=>!e.archived&&re(e)===n)}var yr={"Needs you":`needs-you`,Finished:`finished`,Working:`working`},br=Object.keys(yr),xr=`section`;function Sr(e,t){return`/?origin=${t===`automations`?`automations`:`direct`}&${xr}=${yr[e]}`}function Cr(e){return br.find(t=>yr[t]===e)??null}function wr(e){let t={active:0,automations:0,activeWaiting:0,automationsWaiting:0};for(let n of e){if(G(n)||n.archived)continue;let e=+(v(n).bucket===`waiting`);re(n)?(t.automations+=1,t.automationsWaiting+=e):(t.active+=1,t.activeWaiting+=e)}return t}var Tr=new Set([`running`,`waiting`]);function Er(e){return e?e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:`${Math.round(e/1024)} kB`:``}function Dr(e){return e===void 0?``:`$${e>=10?e.toFixed(0):e.toFixed(2)}`}function Or(e,t=new Date){if(!S(e))return;let n=new Date(e.autoResumeAt);if(!Number.isFinite(n.getTime()))return;let r=n.toDateString()===t.toDateString(),i=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}).format(n);return{label:r?i:`${new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(n)} ${i}`,title:`Resumes automatically at ${new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(n)}`}}function kr(e){return e.steps?Jt({workflow:e.workflow,steps:e.steps}):e.workflowLabel??e.workflow}function Ar(e,t,n=()=>``){let r=e.filter(e=>!G(e));return t.trim()?r.filter(e=>nr(e,t,{scope:`shown`,mode:`phrase`,extras:{displayTitle:cr(e),automation:n(e),references:()=>jr(e)}})):[...r]}function jr(e){return K(e).map(e=>e.number)}function Mr(e,t){return e.filter(e=>Gn(e,t)).length}function Nr(e){return Mr(e)}function Pr(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 Fr(e){return Ir(e)[0]??e.pullRequests?.find(e=>e.url)?.url}function Ir(e){let t=[];return e.pullRequestUrl&&t.push(e.pullRequestUrl),!(e.markerRefs?.issue!==void 0&&e.markerRefs?.pr===void 0)&&e.referencedPullRequestUrl&&t.push(e.referencedPullRequestUrl),t}function Lr(e,t){if(e.referencedIssueUrl)return e.referencedIssueUrl;let n=e.issueNumber??e.markerRefs?.issue;if(!(!n||!t))return`${t}/issues/${n}`}function Rr(e){let t=`${e.kind}#${e.number}`;if(!e.url)return`${t}@project:${e.projectId??`default`}`;try{let n=new URL(e.url),r=n.pathname.split(`/`).filter(Boolean).slice(0,2).join(`/`);return`${t}@${n.host.toLowerCase()}/${r.toLowerCase()}`}catch{return`${t}@${e.url}`}}function K(e,t,n=e.projectId){let r=Ir(e),i=e.markerRefs?.pr,a=[...i===void 0||[...r,...(e.pullRequests??[]).flatMap(e=>e.url?[e.url]:[])].some(e=>Gr(e)===String(i))?[]:[{kind:`PR`,number:i}],...r.map(e=>({kind:`PR`,url:e})),{kind:`PR`,number:e.prNumber},...(e.pullRequests??[]).map(e=>({kind:`PR`,number:e.number,...e.url?{url:e.url}:{},authoritative:!0})),{kind:`Issue`,url:Lr(e,t)},{kind:`Issue`,number:e.issueNumber}],o=new Set,s=[];for(let e of a){let r=e.url?Number(Gr(e.url)):e.number;if(!r||!Number.isInteger(r)||!e.url&&!e.authoritative&&s.some(t=>t.url&&t.kind===e.kind&&t.number===r))continue;let i=e.url??zr(e.kind,r,t),a={kind:e.kind,number:r,...i?{url:i}:n===void 0?{}:{projectId:n}},c=Rr(a);o.has(c)||(o.add(c),s.push(a))}return s}function zr(e,t,n){if(n)return`${n}/${e===`PR`?`pull`:`issues`}/${t}`}function Br(e){return K(e)[0]}function Vr(e,t){if(!e.url)return!0;if(!t)return!1;let n=Hr(t);return n!==void 0&&Hr(e.url)===n}function Hr(e){try{let t=new URL(e),[n,r]=t.pathname.split(`/`).filter(Boolean);return n&&r?`${t.host}/${n}/${r}`.toLowerCase():void 0}catch{return}}function Ur(e,t){let n=[];for(let r of K(e,t)){if(!Vr(r,t))continue;let e=r.kind===`PR`?`pr`:`issue`;n.some(t=>t.kind===e&&t.number===r.number)||n.push({kind:e,number:r.number})}return n}function Wr(e,t,n,r){if(Vr(n,r))return`/p/${e}/tasks/${t}/${n.kind===`PR`?`pr`:`issue`}/${n.number}`}function Gr(e){return/\/(\d+)\/?(?:[?#].*)?$/.exec(e)?.[1]??null}function Kr(e,t){let n=Tr.has(e.status)?t:void 0;if(n)return{cpu:{text:`${n.cpuPct.toFixed(0)}%`,kind:`live`},mem:{text:Er(n.rssBytes),kind:`live`}};let r=Er(e.peakRssBytes);return{cpu:{text:``,kind:`none`},mem:r?{text:`peak ${r}`,kind:`peak`,title:`peak — run finished${e.peakProcCount?` · ${e.peakProcCount} procs`:``}`}:{text:``,kind:`none`}}}function qr(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 Jr(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 Yr(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 Xr(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 Zr(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function Qr(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function $r(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){Qr(t.issues,a,r),Qr(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 q=e=>e.map(e=>e.number).join(`,`);function ei(e,t){let n=e[0];if(e.length>1&&n&&(q(n.issues)!==q(t.issues)||q(n.prs)!==q(t.prs)||n.issuesTotal!==t.issuesTotal||n.prsTotal!==t.prsTotal))return`refetch`;let r=t;if(n&&t.available&&t.projectsState===`refreshing`&&n.repo===t.repo){let e=new Map(n.issues.map(e=>[e.number,e.projectIds]));r={...t,issues:t.issues.map(t=>{let n=e.get(t.number);return t.projectIds===void 0&&n!==void 0?{...t,projectIds:n}:t})}}return[r,...e.slice(1)]}var J={get health(){return[n(),`health`]},runs:{get all(){return[n(),`runs`]},relationships:e=>[n(),`runs`,`relationships`,e],list:(e=n())=>[e,`runs`,`list`],archived:e=>[n(),`runs`,`archived`,e],detail:(e,t=n())=>[t,`runs`,`detail`,e],diff:e=>[n(),`runs`,`diff`,e],changes:e=>[n(),`runs`,`changes`,e],file:(e,t)=>[n(),`runs`,`files`,e,t],handoff:e=>[n(),`runs`,`handoff`,e],commits:e=>[n(),`runs`,`commits`,e],commit:(e,t)=>[n(),`runs`,`commit`,e,t]},get workflows(){return[n(),`workflows`]},get skills(){return[n(),`skills`]},get skillsReady(){return[n(),`skills`,`ready`]},get importableSkills(){return[n(),`skills`,`importable`]},get importableSkillsReady(){return[n(),`skills`,`importable`,`ready`]},get launchKey(){return[n(),`launch-key`]},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`]}},Y={models:e=>[`workspace`,`models`,e],providerStatus:[`workspace`,`providers`,`status`],projects:[`workspace`,`projects`],githubOwners:[`workspace`,`github-owners`],runsIndex:z,runsSearch:e=>[`workspace`,`runs-search`,e],uiState:[`workspace`,`ui-state`],config:[`workspace`,`config`],agentProfiles:[`workspace`,`agent-profiles`],agentAccountDetails:e=>[`workspace`,`agent-profiles`,`details`,e],agentAccountStatus:e=>[`workspace`,`agent-profiles`,`status`,e],fsBrowseRoot:[`workspace`,`fs-browse`],fsBrowse:(e,t=!1)=>[...Y.fsBrowseRoot,e,t]};function X(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:Y.models(t),refetchType:n})}function Z(e,t=!0){let n=b();return(0,O.useEffect)(()=>{if(!t||e!==`cursor`)return;let r,i=()=>{let e=n.getQueryData(J.health)?.capabilities?.localHandoff===!0;e&&!r?r=Bt(`models:cursor`,e=>{let t=It.safeParse(e);t.success&&t.data.runner===`cursor`&&(n.cancelQueries({queryKey:Y.models(`cursor`)}),n.setQueryData(Y.models(`cursor`),t.data))}):!e&&r&&(r(),r=void 0)};i();let a=n.getQueryCache().subscribe(i);return()=>{a(),r?.()}},[t,e,n]),E({queryKey:Y.models(e),queryFn:({signal:t})=>w(e)?ot(e,{signal:t}):Promise.reject(Error(`${e} has no host model catalog`)),staleTime:300*1e3,enabled:t&&w(e)})}function ti(e=!0){return{claude:Z(`claude`,e),codex:Z(`codex`,e),opencode:Z(`opencode`,e),pi:Z(`pi`,e),cursor:Z(`cursor`,e),omp:Z(`omp`,e)}}function ni(){let e=b();return E({queryKey:Y.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(Y.providerStatus),r=await ut(!1,{signal:t});return C(n,e.getQueryData(Y.providerStatus),r)},staleTime:5*6e4,refetchInterval:a(!1),refetchOnWindowFocus:!0})}function ri(){let e=b();return A({mutationFn:()=>ut(!0),onMutate:()=>e.getQueryData(Y.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Y.providerStatus,e=>C(r,e,t)),X(e)}})}function ii(){let e=b();return A({mutationFn:({provider:e,authFailureId:t})=>Qe(e,t),onMutate:()=>e.getQueryData(Y.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(Y.providerStatus,e=>C(r,e,t,n.authFailureId)),w(n.provider)&&X(e,n.provider)}})}function ai(e={}){return E({queryKey:Y.projects,queryFn:({signal:e})=>mt({signal:e}),...e})}function oi(e,t=!1){return E({queryKey:Y.fsBrowse(e,t),queryFn:({signal:n})=>st(e??void 0,{signal:n,showHidden:t}),retry:!1})}function si(){let e=b();return A({mutationFn:e=>Ve(e),onSuccess:()=>e.invalidateQueries({queryKey:Y.projects})})}function ci(){let e=b();return A({mutationFn:e=>St(e),retry:!1,onSuccess:()=>{e.invalidateQueries({queryKey:Y.projects})}})}function li(){let e=b();return A({mutationFn:e=>{let{id:t,...n}=e;return at(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:Y.projects});let r=e.getQueryData(Y.projects);return e.setQueryData(Y.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?ui(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(Y.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(Y.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:Y.projects})})}function ui(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?[]:Yr(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 di(e){let t=b();return A({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(Y.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:Y.projects})})}function fi(){return di(e=>{let{projectId:t,...n}=e;return _e(t,n)})}function pi(){return di(e=>{let{projectId:t,webhookId:n,...r}=e;return c(t,n,r)})}function mi(){return di(({projectId:e,webhookId:t})=>Ue(e,t))}function hi(){return A({mutationFn:({projectId:e,webhookId:t})=>ye(e,t),retry:!1})}function gi(e){let t=b();return A({mutationFn:t=>ee(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function Q(e){let t=b();return A({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:Y.agentProfiles}),t.invalidateQueries({queryKey:Y.projects})])}})}function _i(){return Q(e=>jt(e))}function vi(){return Q(e=>{let{id:t,...n}=e;return p(t,n)})}function yi(){return Q(e=>ct(e))}function bi(){return Q(e=>Re(e))}function xi(e,t){return E({queryKey:Y.agentAccountDetails(e),queryFn:({signal:t})=>te(e,{signal:t}),enabled:t,staleTime:0,retry:!1})}function Si(e,t){return E({queryKey:Y.agentAccountStatus(e),queryFn:({signal:t})=>ae(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function Ci(){let e=b();return A({mutationFn:({provider:e,profileId:t})=>Pe(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:Y.agentProfiles}),e.invalidateQueries({queryKey:Y.providerStatus}),w(n)?X(e,n,`none`):Promise.resolve()])}})}function wi(){let e=b();return A({mutationFn:e=>ae(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(Y.agentAccountStatus(n),t),e.invalidateQueries({queryKey:Y.agentProfiles}),w(t.status.provider)&&X(e,t.status.provider)}})}function Ti(){return A({mutationFn:e=>{let{routeId:t,...n}=e;return we(t,n)},retry:!1})}function Ei(){let e=b();return A({mutationFn:e=>et(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Y.projects})})}function Di(){let e=b();return A({mutationFn:e=>Ot(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:Y.projects})})}function Oi({enabled:e}){return E({queryKey:Y.githubOwners,queryFn:({signal:e})=>dt({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function ki(){let e=b();(0,O.useEffect)(()=>{let n,r=()=>{let r=e.getQueryData(J.health),i=r?.capabilities?.localHandoff===!0;r&&be({local:i,bootProject:r.bootProject??`default`,apiBase:t()}),i&&n===void 0?n=Bt(`health`,t=>{e.setQueryData(J.health,t)}):!i&&n!==void 0&&(n(),n=void 0)};r();let i=e.getQueryCache().subscribe(r);return()=>{i(),n?.(),rt()}},[e])}function $(){return E({queryKey:J.health,queryFn:({signal:e})=>He({signal:e})})}function Ai(e,t){let n=$().data,r=ai(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?Pr(n?.repo?.remote):void 0}function ji(){return E({queryKey:J.openTargets,queryFn:({signal:e})=>Xe({signal:e}),staleTime:5*6e4})}function Mi(){return E({queryKey:J.runs.list(),queryFn:({signal:e})=>l(j(),{signal:e})})}function Ni(e,t){return Rt({queryKey:J.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>Te({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 Pi(e){let t=e.trim();return E({queryKey:Y.runsSearch(t),queryFn:({signal:e})=>Mt(t,{signal:e}),enabled:t.length>=2,placeholderData:Ie,staleTime:1e4})}function Fi(e=!0,t=_n){let n=B(b());return D(`/api/v1/workspace/runs-index`,Y.runsIndex,a(e?t:!1),bn),E({queryKey:Y.runsIndex,queryFn:({signal:e})=>it({signal:e}).then(n.merge),enabled:e,staleTime:3e4,refetchInterval:!1})}function Ii(e,t=!0,n=!1){return E({queryKey:[j({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>l(j({projectId:e,boot:n}),{signal:t}),enabled:t})}function Li(e){let t=b();return A({mutationFn:e=>ce(e),onSettled:()=>t.invalidateQueries({queryKey:J.runs.relationships(e)})})}function Ri(e,t={}){return E({queryKey:J.runs.relationships(e),queryFn:({signal:t})=>fe(e,{signal:t}),enabled:t.enabled??!0})}function zi(e){return E({queryKey:J.runs.detail(e??``),queryFn:({signal:t})=>Nt(M(e),{signal:t}),enabled:!!e})}function Bi(e,t,n=!0){return E({queryKey:[e??`default`,`runs`,`detail`,t??``],queryFn:({signal:n})=>Nt(M(t,{projectId:e}),{signal:n}),enabled:n&&!!e&&!!t})}function Vi(e){return E({queryKey:J.runs.diff(e??``),queryFn:({signal:t})=>f(e,{signal:t}),enabled:!!e})}function Hi(e,t=!1){return D(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/changes`:void 0,J.runs.changes(e??``),a(t?4e3:!1)),E({queryKey:J.runs.changes(e??``),queryFn:({signal:t})=>ze(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function Ui(e,t){return E({queryKey:J.runs.file(e??``,t??``),queryFn:({signal:n})=>Dt(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function Wi(e,t){return E({queryKey:[n(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>ke(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Gi(e,t){return E({queryKey:[n(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>_(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Ki(e,t){return E({queryKey:[n(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>Se(e,t,{signal:n}),enabled:t!==null,retry:!1})}function qi(e){return E({queryKey:[n(),`runs`,`artifacts`,e],queryFn:({signal:t})=>De(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function Ji(e,t=!1){return D(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/commits`:void 0,J.runs.commits(e??``),a(t?5e3:!1)),E({queryKey:J.runs.commits(e??``),queryFn:({signal:t})=>ve(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function Yi(e,t){return E({queryKey:J.runs.commit(e??``,t??``),queryFn:({signal:n})=>At(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function Xi(e,t=!0){return E({queryKey:J.runs.handoff(e??``),queryFn:({signal:t})=>xe(M(e),{signal:t}),enabled:!!e&&t})}function Zi(e,t,n){return E({queryKey:e===void 0?J.runs.handoff(t):[e,`runs`,`handoff`,t],queryFn:({signal:n})=>xe(M(t,{projectId:e}),{signal:n}),enabled:n,staleTime:15e3})}function Qi(e,t){let r=[...new Set(e)],i=k({queries:r.map(e=>({queryKey:[e??n(),`automations`,`names`],queryFn:({signal:t})=>ht({signal:t,archived:`include`,...e===void 0?{}:{projectId:e}}),enabled:t,staleTime:6e4,retry:!1}))}),a=i.map(e=>e.data);return(0,O.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 $i(){return E({queryKey:J.workflows,queryFn:({signal:e})=>h({signal:e})})}function ea(e=!0){let t=b(),n=J.skills,r=n[0],i=E({queryKey:n,queryFn:({signal:e})=>le({signal:e}),enabled:e}),a=E({queryKey:J.skillsReady,queryFn:({signal:e})=>de({signal:e}),enabled:e&&i.isSuccess,staleTime:1/0,retry:!1});return(0,O.useEffect)(()=>{Array.isArray(a.data)&&t.setQueryData([r,`skills`],a.data)},[t,a.data,r]),i}function ta(e=!0){let t=b(),n=J.importableSkills,r=n[0],i=E({queryKey:n,queryFn:({signal:e})=>lt({signal:e}),enabled:e}),a=E({queryKey:J.importableSkillsReady,queryFn:({signal:e})=>Ct({signal:e}),enabled:e&&i.isSuccess,staleTime:1/0,retry:!1});return(0,O.useEffect)(()=>{Array.isArray(a.data)&&t.setQueryData([r,`skills`,`importable`],a.data)},[t,a.data,r]),i}function na(){return E({queryKey:J.launchKey,queryFn:({signal:e})=>We({signal:e}),staleTime:1/0})}function ra(){return E({queryKey:J.repo,queryFn:({signal:e})=>tt({signal:e})})}function ia(e){return E({queryKey:[e,`repo`],queryFn:({signal:t})=>tt({signal:t},e)})}function aa(){return E({queryKey:J.repoBranches,queryFn:({signal:e})=>$e({signal:e})})}function oa(){return E({queryKey:J.repoChanges,queryFn:({signal:e})=>Fe({signal:e}),retry:!1})}function sa(e){return E({queryKey:J.repoCommit(e??``),queryFn:({signal:t})=>Tt(e,{signal:t}),enabled:!!e,retry:!1})}function ca(){return E({queryKey:J.config,queryFn:({signal:e})=>je({signal:e})})}function la(){return E({queryKey:J.worktrees,queryFn:({signal:e})=>ge({signal:e})})}function ua(e){return E({queryKey:[e,`worktrees`],queryFn:({signal:t})=>ge({signal:t},e),staleTime:0})}function da(e,t=!0,n=!1){return E({queryKey:[j({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>pe({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:Lt(e.sidebarLimits)},enabled:t})}function fa(){return da(n())}function pa(){return E({queryKey:J.agentConfig,queryFn:({signal:e})=>he({signal:e})})}function ma(e){return E({queryKey:J.agentConfigFile(e??``),queryFn:({signal:t})=>Pt(e,{signal:t}),enabled:e!==null})}function ha(e){let t=b(),n=J.agentConfig,r=J.agentConfigFile(e);return A({mutationFn:t=>Ke(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}function ga(){return E({queryKey:Y.uiState,queryFn:({signal:e})=>se({signal:e})})}function _a(){return E({queryKey:Y.config,queryFn:({signal:e})=>ne({signal:e})})}function va(){return E({queryKey:Y.agentProfiles,queryFn:({signal:e})=>u({signal:e})})}function ya(e){let t=b();return A({mutationFn:t=>Ne(e,t),onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function ba(e){let t=L(),n=e?.projectId,r=e?.cacheScope,i=A({mutationFn:e=>Et(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),a=(0,O.useCallback)(e=>({...M(e,{projectId:n,cacheScope:r}),id:e}),[n,r]),o=(0,O.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,O.useCallback)((e,t)=>s(a(e),o(t)),[s,a,o]),u=(0,O.useCallback)((e,t)=>c(a(e),o(t)),[c,a,o]);return{...i,variables:i.variables?.id,mutate:l,mutateAsync:u}}function xa(){let e=L();return A({mutationFn:e=>Et(M(e),!1),onMutate:t=>e.patchRead(()=>M(t),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function Sa(e){let t=L();return A({mutationFn:({id:t,pinned:n})=>Ae(M(t,e),n),onError:e=>Vt(`Could not update pin. ${e.message} Please retry.`,{tone:`danger`}),onMutate:()=>e??j(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function Ca(e,t){let n=L();return A({mutationFn:n=>kt(M(e,{projectId:t}),n),onMutate:()=>j({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`send`,r),onError:(e,t,r)=>{e instanceof nt&&e.status===409&&r&&n.invalidateAfter(`send`,r)}})}function wa(e,t){let n=L();return A({mutationFn:(n={})=>wt(M(e,{projectId:t}),n),onMutate:()=>j({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`continue`,r)})}function Ta(e){let t=b();return A({mutationFn:({msgId:t,message:n})=>ue(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function Ea(e){let t=b();return A({mutationFn:t=>Ye(e,t),onSuccess:()=>t.invalidateQueries({queryKey:J.runs.all})})}function Da(e={},t=!0){let r=b(),i=J.github(e);D(`/api/v1/p/${n()}/github${e.limit===void 0?``:`?limit=${e.limit}`}`,i,a(t?6e4:!1));let o=E({queryKey:J.github(e),queryFn:({signal:t})=>x({limit:e.limit},{signal:t}),enabled:t,staleTime:6e4,refetchInterval:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0}),s=o.data?.projectsGeneration,c=E({queryKey:[...i,`projects`,s],queryFn:({signal:e})=>Le(s,{signal:e}),enabled:t&&o.data?.projectsState===`refreshing`&&!!s,staleTime:1/0,retry:!1});return(0,O.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 Oa=class extends Error{};function ka(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await x({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new Oa(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>Xr(e),retry:(e,t)=>!(t instanceof Oa)&&!(t instanceof nt&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function Aa(e=50,t=!0){let r=b(),i=J.githubPages(e),o=J.githubPagesHead(e);D(`/api/v1/p/${n()}/github?limit=${e}`,o,a(t?6e4:!1));let s=Rt({...ka(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),c=E({queryKey:o,queryFn:({signal:t})=>x({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:l}=s;(0,O.useEffect)(()=>{if(!c.data)return;let e=r.getQueryData(i);if(!e||e.pages.length===0)return;let t=ei(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=k({queries:u.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>Le(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,O.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,O.useMemo)(()=>$r(s.data?.pages??[]),[s.data])}}function ja(e,t=50,n=!0){let r=Rt({...ka([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,O.useMemo)(()=>$r(r.data?.pages??[]),[r.data])}}function Ma(e,t,n=!0){let r=k({queries:t.filter(e=>e.length>0).map(t=>({queryKey:J.githubCommentCounts(e,t),queryFn:({signal:n})=>o(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,O.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 Na(e,t,n,r=!0){return E({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>yt(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function Pa(e,t=!0){return E({queryKey:J.githubChecks(e),queryFn:({signal:t})=>me(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function Fa(e,t,n=!0){return E({queryKey:J.githubSearch(e,t),queryFn:({signal:n})=>yt(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var Ia=100;function La(e){return[...e].sort((e,t)=>t-e).slice(0,Ia).sort((e,t)=>e-t)}function Ra(){let e=gt(),t=$();return e.projectId??t.data?.bootProject}function za(e){for(let[t,n]of Object.entries(e)){for(let[e,r]of Object.entries(n.prs))An(U({projectId:t,kind:`PR`,number:Number(e)}),r);for(let[e,r]of Object.entries(n.issues))An(U({projectId:t,kind:`Issue`,number:Number(e)}),r)}}var Ba=5*6e4;function Va(e){return e?e.recheckAfterMs:Ba}function Ha(e,t=!0){let n=(0,O.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:La(t.prs),issues:La(t.issues)}))},[e.map(U).sort().join(`|`)]),r=k({queries:n.map(e=>({queryKey:J.githubRefStatus(e.projectId,e.prs,e.issues),queryFn:({signal:t})=>ft(e.projectId,{prs:e.prs,issues:e.issues},{signal:t}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>Va(e.state.data)??1/0,refetchInterval:!1,refetchOnWindowFocus:!0}))}),a=b(),o=JSON.stringify(n.map((e,t)=>({...e,interval:Va(r[t]?.data)??!1})));(0,O.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=J.githubRefStatus(t.projectId,t.prs,t.issues);return zt({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,O.useMemo)(()=>Hn(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,O.useCallback)(e=>{let t=U(e),n=s.get(t);if(n)return n;let r=V.get(t);return{state:`idle`,...r?{status:r}:{},...H.has(t)?{conflicting:!0}:{}}},[s])}function Ua(e,t,n=!0){return E({queryKey:J.githubComments(e,t),queryFn:({signal:n})=>qe(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Wa(e,t,n=!0){return E({queryKey:J.githubItem(e,t),queryFn:({signal:n})=>bt(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Ga(e){return E({queryKey:J.githubPrChanges(e??0),queryFn:({signal:t})=>vt(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{ai as $,Rr as $t,Oi as A,gr as An,Ca as At,gi as B,L as Bn,ga as Bt,Wi as C,cr as Cn,Ri as Ct,Ma as D,vr as Dn,Fi as Dt,Pa as E,wr as En,Mi as Et,ki as F,Gn as Fn,vi as Ft,ja as G,Jr as Gt,ji as H,M as Hn,Y as Ht,ta as I,Jn as In,li as It,Ai as J,Dr as Jt,Na as K,Ar as Kt,na as L,En as Ln,pi as Lt,Ga as M,qn as Mn,Zi as Mt,Fa as N,Un as Nn,hi as Nt,Ua as O,fr as On,Pi as Ot,$ as P,Wn as Pn,fa as Pt,ua as Q,Gr as Qt,ba as R,On as Rn,$i as Rt,Ta as S,ur as Sn,Xi as St,Da as T,pr as Tn,Z as Tt,ya as U,A as Un,Zr as Ut,Ti as V,j as Vn,la as Vt,Sa as W,Ht as Wn,qr as Wt,Ii as X,Pr as Xt,Bi as Y,Er as Yt,da as Z,Vr as Zt,wa as _,G as _n,Hi as _t,Si as a,Ur as an,ri as at,fi as b,Cr as bn,Vi as bt,va as c,K as cn,ci as ct,Ki as d,rr as dn,ra as dt,Or as en,ni as et,qi as f,xr as fn,aa as ft,Ci as g,mr as gn,zi as gt,ca as h,hr as hn,ii as ht,xi as i,Wr as in,Ha as it,Aa as j,nr as jn,ea as jt,Wa as k,lr as kn,bi as kt,Ni as l,Kr as ln,mi as lt,Ei as m,sr as mn,sa as mt,J as n,Mr as nn,wi as nt,pa as o,Fr as on,si as ot,Qi as p,br as pn,oa as pt,ia as q,Nr as qt,za as r,Lr as rn,Ra as rt,ma as s,Br as sn,yi as st,X as t,jr as tn,ha as tt,Gi as u,kr as un,Ea as ut,_i as v,_r as vn,Yi as vt,oi as w,Sr as wn,ti as wt,Li as x,dr as xn,Ui as xt,Di as y,or as yn,Ji as yt,xa as z,B as zn,_a as zt};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{D as t,E as n,L as r,M as i,d as a,t as o,u as s}from"./button-BEK7XKhS.js";import{i as c,t as l}from"./react-runtime-CCIEwYL0.js";import{C as u,Jr as d,Kt as f,T as p,an as m,i as h,k as g,on as _}from"./project-scope-context-DMpvJqIm.js";import{ft as v}from"./live-protocol-BDY7JJpT.js";import{Et as y,H as ee,J as b,P as x,Rn as te,T as ne,Un as S,Vt as re,Yt as C,dt as w,ft as T,mt as ie,n as E,pt as ae}from"./queries-BIOp8jLx.js";import{n as D}from"./toaster-pthKGWiE.js";import{i as O,l as oe,p as se,r as ce,t as le}from"./dropdown-menu-DYflHa4m.js";import{a as k,c as A,i as j,n as M,o as N,r as P,s as F,t as I}from"./alert-dialog-vFjLgfK4.js";import{D as ue,I as de,M as fe,N as pe,Q as me,S as he,X as ge,Z as _e,c as ve,ct as L,d as ye,j as R,n as be,st as xe,w as z,y as Se}from"./design-icons-DmYTv2r1.js";import{a as B,t as Ce}from"./loader-circle-CZkGEdoI.js";import{t as V}from"./createLucideIcon-BHp8sXmF.js";import{l as we,n as Te,y as Ee}from"./nav-row-styles-BE99gD3_.js";import{n as De,r as Oe}from"./diff-controls-DXyB0aDl.js";import{i as ke,r as Ae,t as je}from"./git-toolbar-U4s46kUd.js";import{t as H}from"./info-DA1x_4bz.js";import{a as Me,l as Ne,n as Pe,t as Fe}from"./control-locations-CexZsd3M.js";import{t as U}from"./project-router-CimAoN1H.js";import{t as W}from"./centered-state-CPgI8cCO.js";import{Et as G,Kt as Ie,Tt as Le,a as Re,c as ze,d as Be,en as K,f as Ve,i as He,l as Ue,m as We,o as Ge,ot as Ke,p as qe,q,r as Je,rn as J,s as Ye,u as Xe}from"./index-xj-3O89_.js";import{t as Ze}from"./markdown-BBDDg-4t.js";import{t as Qe}from"./diff-DBDiZl58.js";import{t as $e}from"./commit-diff-panel-DzyWgn1Z.js";var Y=e(c(),1);function et(e,t){let n=d(t),r=n.getQueryCache();return Y.useSyncExternalStore(Y.useCallback(e=>r.subscribe(v.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var tt=V(`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`}]]),nt=V(`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=l();function rt(){let e=i(),t=w(),n=d(),r=et({queryKey:E.repo})>0,a=t.data?.info?t.data:null,o=Je(e,a,`screen`);return(0,X.jsxs)(`div`,{"data-route":`repo-git`,"data-slot":`git-screen`,className:Te,children:[(0,X.jsxs)(`div`,{className:`mb-[16px] flex items-center gap-[8px]`,children:[(0,X.jsx)(`h1`,{className:s(we,`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:r,onClick:()=>{n.invalidateQueries({queryKey:E.repo}),n.invalidateQueries({queryKey:E.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)(_e,{size:17,"aria-hidden":`true`,className:s(`size-[17px]`,r&&`motion-safe:animate-spin`)})})]}),a?.info?(0,X.jsx)(`div`,{className:`mb-[16px]`,children:(0,X.jsx)(Ge,{scope:e,repo:a,info:a.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)(He,{branch:a?.info?.branch??null,counts:o,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 it({repo:e,info:t}){let n=x(),r=T(),i=new Map((r.data?.branches??[]).map(e=>[e.name,e])),a=d(),c=S({mutationFn:e=>u({name:e}),onSuccess:async e=>{D(e.created?`Created and switched to ${e.branch}`:`Switched to ${e.branch}`),await Promise.all([a.invalidateQueries({queryKey:E.repo}),a.invalidateQueries({queryKey:E.health})]),a.setQueryData(E.repo,t=>t?.info?{...t,info:{...t.info,branch:e.branch}}:t),a.setQueryData(E.health,n=>n?.repo?.root===t.root?{...n,repo:{...n.repo,branch:e.branch}}:n)},onError:e=>D(e.message,{tone:`danger`})}),[l,f]=(0,Y.useState)(``),[p,m]=(0,Y.useState)(``),h=p.trim().toLowerCase(),g=Q(e,r.data?.branches),_=h?g.filter(e=>e.toLowerCase().includes(h)):g;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)(me,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,X.jsx)(J,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:p,onChange:e=>m(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:[_.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)(U,{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:s(`min-w-0 truncate text-[13px]`,n&&`font-normal`),children:e}),r?(0,X.jsx)(lt,{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)(o,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`md:ml-auto h-11`,disabled:c.isPending,onClick:()=>c.mutate(e),children:[(0,X.jsx)(R,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),_.length===0?(0,X.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-soft-foreground`,children:[`No branches match “`,p.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&&c.mutate(t,{onSuccess:()=>f(``)})},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)(J,{id:`new-branch-name`,"aria-label":`New branch name`,placeholder:`new-branch-name`,className:`h-11 bg-background`,value:l,onChange:e=>f(e.target.value)}),(0,X.jsxs)(o,{type:`submit`,variant:`primary`,size:`sm`,className:`min-h-11 self-start`,"data-action":`create-branch`,disabled:!l.trim()||c.isPending,children:[(0,X.jsx)(ge,{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)(at,{}):null]})}function at(){let e=ne({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)(ot,{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 ot({pr:e}){let t=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(de,{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)(st,{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:a(e.url)?(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:s(n,`hover:bg-muted`),children:t}):(0,X.jsx)(`span`,{className:n,children:t})})}function st({checks:e}){return(0,X.jsx)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:s(`shrink-0 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:e})}var ct={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function lt({entry:e}){return(0,X.jsx)(`span`,{"data-slot":`branch-class`,className:s(`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:ct[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 ut(){let e=ae(),t=q(),[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 h&&e.error.status===409,f=e.data?.files??[],p=(0,Y.useMemo)(()=>Ae(f),[f]),m=(0,Y.useMemo)(()=>f.some(Ze),[f]),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)(je,{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)(De,{mode:n,wrap:i,onModeChange:r,onWrapChange:a})}),m?(0,X.jsx)(Oe,{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)(W,{icon:d?(0,X.jsx)(z,{size:16}):(0,X.jsx)(L,{size:16}),tone:d?`neutral`:`danger`,heading:`h2`,title:d?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):f.length===0?(0,X.jsx)(W,{icon:(0,X.jsx)(z,{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)(ke,{root:p,selected:c,onSelect:e=>{l(e),u.current?.scrollToPath(e)}})]}),(0,X.jsx)(Qe,{files:f,viewRef:u,mode:g,wrap:_,preview:o,className:`min-w-0 flex-1`})]})]})}function dt({repo:e,info:t}){let{sha:r}=n(),i=e.log,a=(0,Y.useMemo)(()=>qe(i),[i]);if(r)return(0,X.jsx)(mt,{sha:r});let o=Be(e,t),s=o&&o.behind>0?(0,X.jsx)(pt,{info:t,tracking:o}):null;return i.length===0?(0,X.jsxs)(X.Fragment,{children:[s?(0,X.jsx)(`div`,{className:`px-[8px] pt-[12px] md:px-[20px]`,children:s}):null,(0,X.jsx)(W,{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:[s,a.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)(U,{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,` · `,We(e.when)]})]})]}),(0,X.jsx)(ft,{source:e.source})]},e.hash))})]},e.label))]})}function ft({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)(U,{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:s(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)(pe,{"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)(ve,{"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 pt({info:e,tracking:t}){let n=ze(i(),e),r=(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)(tt,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-inbox-count-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 text-[12.5px] text-muted-foreground`,children:[t.behind,` commit`,t.behind===1?``:`s`,` on `,t.ref,` `,t.behind===1?`is`:`are`,` not in your checkout yet`]}),(0,X.jsxs)(`button`,{ref:r,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[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)(Ce,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,X.jsx)(be,{"aria-hidden":`true`}),`Pull`]}),(0,X.jsx)(Ye,{checkout:n,returnFocus:r})]})}function mt({sha:e}){return(0,X.jsx)($e,{commit:ie(e),sha:e,backTo:q()?`/git`:Ue,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 ht(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 gt(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 _t={done:`success`,failed:`danger`,cancelled:`neutral`};function vt(){let e=T(),t=y(),n=i(),r=b(),[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)(W,{icon:(0,X.jsx)(L,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let s=ht(e.data.branches),c=gt(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)(H,{"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)(U,{to:Xe.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)(Me,{projectId:n,repoBase:r,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)(yt,{}),l,s.length===0?(0,X.jsx)(W,{icon:(0,X.jsx)(Ie,{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)(bt,{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)(H,{"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)(Tt,{entry:a,onClose:()=>o(null)})]})}function yt({className:e}){return(0,X.jsxs)(`p`,{"data-slot":`git-no-forge`,className:s(`flex items-start gap-[6px] px-[10px] pt-[6px] text-[11.5px] leading-[17px] text-soft-foreground`,e),children:[(0,X.jsx)(H,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),$,`.`]})}function bt({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)(Ct,{entry:e,finishedAt:t}),(0,X.jsx)(xt,{entry:e}),(0,X.jsx)(St,{entry:e,onDelete:n})]})}function xt({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)(Pe,{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)(wt,{entry:e})]}):null})}function St({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,a=!r&&e.runId!==null&&!i,o=S({mutationFn:()=>p(e.runId),onSuccess:e=>{D(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:E.repoBranches}),n.invalidateQueries({queryKey:E.runs.all})},onError:e=>D(e instanceof h&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),c=()=>void navigator.clipboard.writeText(e.name).then(()=>D(`Copied ${e.name}`),()=>D(`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)(U,{to:`/tasks/${e.runId}`,"data-action":`not-landed-open`,className:s(l,`hidden border border-border hover:bg-muted md:inline-flex`),children:`Open task`}):null,a?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-create-pr`,disabled:o.isPending,onClick:()=>o.mutate(),className:s(l,`hidden bg-muted hover:brightness-110 md:inline-flex`),children:[(0,X.jsx)(nt,{"aria-hidden":`true`}),o.isPending?`Creating…`:`Create draft PR`]}):null,r?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,onClick:c,className:s(l,`hidden border border-border hover:bg-muted md:inline-flex`),children:[(0,X.jsx)(Se,{"aria-hidden":`true`}),`Copy branch`]}):null,(0,X.jsxs)(le,{children:[(0,X.jsx)(se,{"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)(he,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,X.jsxs)(ce,{align:`end`,className:`w-52`,children:[e.runId?(0,X.jsx)(O,{asChild:!0,className:`md:hidden`,children:(0,X.jsx)(U,{to:`/tasks/${e.runId}`,children:`Open task`})}):null,a?(0,X.jsx)(O,{className:`md:hidden`,disabled:o.isPending,onSelect:()=>o.mutate(),children:`Create draft PR`}):null,(0,X.jsx)(O,{className:s(!r&&`md:hidden`),onSelect:c,children:`Copy branch`}),(0,X.jsx)(oe,{className:`md:hidden`}),(0,X.jsx)(O,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function Ct({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=B(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)(Ee,{"aria-label":`Task deleted`,className:`size-[12px] text-soft-foreground`}):(0,X.jsx)(Ke,{tone:e.runStatus&&_t[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)(U,{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]}),(0,X.jsx)(Z,{entry:e})]})]})}function wt({entry:e}){let t=te(Ne(`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 Tt({entry:e,onClose:t}){let n=d(),[r,i]=(0,Y.useState)(``),a=(0,Y.useId)(),o=S({mutationFn:e=>g({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;D(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:E.repo}),s()},onError:e=>D(e.message,{tone:`danger`})}),s=()=>{i(``),t()},c=e!==null&&r.trim()===e.name,l=e&&`${e.ahead} commit${e.ahead===1?``:`s`}`;return(0,X.jsx)(I,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&s(),children:(0,X.jsxs)(j,{"data-slot":`delete-branch-dialog`,children:[(0,X.jsxs)(F,{children:[(0,X.jsxs)(A,{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:[l,` 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(),c&&e&&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)(J,{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)(N,{children:[(0,X.jsx)(P,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,X.jsx)(M,{"data-action":`delete-branch-confirm`,className:`h-11 bg-danger text-danger-foreground hover:brightness-[0.96]`,disabled:!c||o.isPending,onClick:t=>{t.preventDefault(),e&&o.mutate(e.name)},children:o.isPending?`Deleting…`:`Delete branch`})]})]})})}function Et({base:e}){let t=T(),n=d(),[r,i]=(0,Y.useState)({merged:!1,empty:!1}),[a,o]=(0,Y.useState)(!1),s=(t.data?.branches??[]).filter(e=>e.class===`merged`),c=(t.data?.branches??[]).filter(e=>e.class===`empty`),l=[...s,...c],u=S({mutationFn:e=>g({names:e}),onSuccess:e=>{let t=e.refused.length;D(`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:E.repo})},onError:e=>{n.invalidateQueries({queryKey:E.repo}),D(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 f=l.length,p=`branch${f===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 · `,f]}),(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:f===0||u.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)(xe,{"aria-hidden":`true`,className:`size-[12px]`}),u.isPending?`Deleting…`:`Delete ${f} ${p}`]})]}),(0,X.jsx)(Dt,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:$.toLowerCase(),rows:s,open:r.merged,onToggle:()=>i(e=>({...e,merged:!e.merged}))}),(0,X.jsx)(Dt,{kind:`empty`,title:`Empty`,hint:`no commits beyond the fork point`,rows:c,open:r.empty,onToggle:()=>i(e=>({...e,empty:!e.empty}))}),(0,X.jsx)(I,{open:a,onOpenChange:o,children:(0,X.jsxs)(j,{children:[(0,X.jsxs)(F,{children:[(0,X.jsxs)(A,{children:[`Delete `,f,` `,p,`?`]}),(0,X.jsxs)(k,{children:[s.length,` merged into `,e,` and `,c.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)(N,{children:[(0,X.jsx)(P,{children:`Keep them`}),(0,X.jsxs)(M,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{u.mutate(l.map(e=>e.name)),o(!1)},children:[`Delete `,f,` `,p]})]})]})})]})}function Dt({kind:e,title:t,hint:n,rows:r,open:i,onToggle:a}){let o=`cleanup-branches-${e}`;return(0,X.jsxs)(`div`,{"data-slot":`cleanup-branch-group`,"data-group":e,className:`border-b border-border last:border-0`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":o,disabled:r.length===0,onClick:a,className:`flex min-h-[44px] w-full items-center gap-[12px] px-[14px] py-[4px] text-left hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:hover:bg-transparent`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`span`,{className:`truncate text-[12.5px] text-foreground`,children:[t,` · `,r.length]}),(0,X.jsx)(`span`,{className:`truncate text-[11px] text-soft-foreground`,children:n})]}),r.length>0?(0,X.jsx)(ye,{"aria-hidden":`true`,className:s(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,i&&`rotate-90`)}):null]}),i?(0,X.jsx)(`ul`,{id:o,"aria-label":t,className:`flex flex-col pb-[6px]`,children:r.map(e=>(0,X.jsxs)(`li`,{"data-slot":`cleanup-branch-row`,"data-branch":e.name,className:`flex min-h-[32px] items-center gap-[10px] px-[14px] pl-[26px] text-[11.5px]`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-muted-foreground`,children:e.name}),e.runId?(0,X.jsx)(U,{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:B(e.lastCommit.at)})]},e.name))}):null]})}function Ot(){let e=re(),t=ee().data?.targets.find(e=>e.id===`finder`),n=S({mutationFn:e=>f(e,t.id),onError:e=>D(e.message,{tone:`danger`})}),r=d(),[i,a]=(0,Y.useState)(!1),o=()=>Promise.all([r.invalidateQueries({queryKey:E.worktrees}),r.invalidateQueries({queryKey:E.repoBranches})]),s=S({mutationFn:e=>_(),onSuccess:(e,t)=>{o();let n=e.reclaimed.length,r=Math.max(0,t-n);D(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=>D(e.message,{tone:`danger`})}),c=S({mutationFn:e=>m(e.runId),onSuccess:(e,t)=>{o(),D(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{o(),D(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:l,totalBytes:u,keep:p}=e.data,h=s.isPending||c.isPending,g=l.filter(e=>e.pastKeep),v=g.length>0,y=g.some(e=>e.sizeBytes===null)?null:g.reduce((e,t)=>e+(t.sizeBytes??0),0),b=v?y?`Reclaim ${C(y)} now`:`Reclaim ${g.length} now`:`Reclaim now`,x=u?C(u):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`,x?` · ${x}`:``]}),(0,X.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-[11.5px] leading-[17px] text-soft-foreground`,children:[p===0?`Retention is unlimited (`:`Retention keeps the newest ${p} finished checkout${p===1?``:`s`} (`,(0,X.jsx)(U,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:Fe(`worktrees`,` › `)}),p===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:h||!v,title:v?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)(K,{"aria-hidden":`true`,className:`size-[12px]`}),b]})]}),l.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:l.map(e=>(0,X.jsx)(jt,{worktree:e,keep:p,disabled:h,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>c.mutate(e)},e.runId))}),(0,X.jsx)(I,{open:i,onOpenChange:a,children:(0,X.jsxs)(j,{children:[(0,X.jsxs)(F,{children:[(0,X.jsx)(A,{children:`Reclaim old worktrees?`}),(0,X.jsxs)(k,{children:[g.length,` finished worktree`,g.length===1?``:`s`,` beyond the keep limit`,y?` (${C(y)})`:``,` `,g.length===1?`is`:`are`,` reclaimed now, directory only. Their branches are kept, so the work stays recoverable.`]})]}),(0,X.jsxs)(N,{children:[(0,X.jsx)(P,{children:`Keep them`}),(0,X.jsx)(M,{"data-action":`worktrees-confirm`,onClick:()=>{s.mutate(g.length),a(!1)},children:b})]})]})})]})}var kt=new Set([`queued`,`running`,`waiting`,`review`]);function At(e,t){return kt.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 jt({worktree:e,keep:t,disabled:n,onOpen:r,opening:i,onReclaim:a}){let o=At(e,t),c=B(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":o.tone===`in-use`?`in-use`:e.pastKeep?`reclaimable`:`kept`,className:s(`text-[11.5px]`,o.tone===`in-use`?`text-status-running`:`text-soft-foreground`),children:o.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:[` · `,o.label]})]})]}),(0,X.jsx)(`span`,{"data-slot":`worktree-size`,className:`shrink-0 text-[11.5px] tabular-nums text-muted-foreground`,children:e.sizeBytes===null?`—`:C(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)(ue,{"aria-hidden":`true`,className:`size-[13px]`})}):null,o.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:a,className:d,children:(0,X.jsx)(K,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function Mt({section:e,index:n=!1}){let i=w(),a=q(),[o]=t();if(n&&!a&&o.get(`view`)!==`repo`)return(0,X.jsx)(rt,{});if(i.isPending)return(0,X.jsx)(Le,{});if(i.isError)return(0,X.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(G,{}),(0,X.jsx)(W,{icon:(0,X.jsx)(L,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:i.error.message})]});let s=i.data.info;return s?(0,X.jsx)(Nt,{repo:i.data,info:s,section:e}):(0,X.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(G,{}),(0,X.jsx)(W,{icon:(0,X.jsx)(R,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`${r(`cezar`)} is running outside a git repository — start it inside one to browse changes, commits and branches.`})]})}function Nt({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)(G,{}),(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:Re(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)(Pt,{repo:e,info:t,section:n})})]}),n===`main`?(0,X.jsx)(dt,{repo:e,info:t}):n===`not-landed`?(0,X.jsx)(vt,{}):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)(Ot,{}),(0,X.jsx)(Et,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,X.jsx)(it,{repo:e,info:t}):(0,X.jsx)(ut,{})]})}function Pt({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)(Ft,{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 Ft({repo:e,info:t}){let n=Q(e,T().data?.branches).length;return(0,X.jsxs)(X.Fragment,{children:[n,` branch`,n===1?``:`es`,` · on `,t.branch]})}export{Mt as RepoGitRoute};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{D as t,E as n,L as r,M as i,d as a,t as o,u as s}from"./button-CHUAMTHK.js";import{i as c,t as l}from"./react-runtime-CCIEwYL0.js";import{C as u,Jr as d,Kt as f,T as p,an as m,i as h,k as g,on as _}from"./project-scope-context-CaUqlAd7.js";import{ft as v}from"./live-protocol-BDY7JJpT.js";import{Et as y,H as ee,J as b,P as x,Rn as te,T as ne,Un as S,Vt as re,Yt as C,dt as w,ft as T,mt as ie,n as E,pt as ae}from"./queries-DYfIpJ-d.js";import{n as D}from"./toaster-B1MyeHiE.js";import{i as O,l as oe,p as se,r as ce,t as le}from"./dropdown-menu-DhrBcVgr.js";import{a as k,c as A,i as j,n as M,o as N,r as P,s as F,t as I}from"./alert-dialog-Dj464rjk.js";import{D as ue,I as de,M as fe,N as pe,Q as me,S as he,X as ge,Z as _e,c as ve,ct as L,d as ye,j as R,n as be,st as xe,w as z,y as Se}from"./design-icons-DmYTv2r1.js";import{a as B,t as Ce}from"./loader-circle-CZkGEdoI.js";import{t as V}from"./createLucideIcon-BHp8sXmF.js";import{l as we,n as Te,y as Ee}from"./nav-row-styles-BZUUavOF.js";import{n as De,r as Oe}from"./diff-controls-BR2uqhwG.js";import{i as ke,r as Ae,t as je}from"./git-toolbar-Dwz8p8GW.js";import{t as H}from"./info-DA1x_4bz.js";import{a as Me,l as Ne,n as Pe,t as Fe}from"./control-locations-CA9TMupq.js";import{t as U}from"./project-router-1m_VlC22.js";import{t as W}from"./centered-state-DGyy0SuA.js";import{Et as G,Kt as Ie,Tt as Le,a as Re,c as ze,d as Be,en as K,f as Ve,i as He,l as Ue,m as We,o as Ge,ot as Ke,p as qe,q,r as Je,rn as J,s as Ye,u as Xe}from"./index-D489J7QW.js";import{t as Ze}from"./markdown-BBDDg-4t.js";import{t as Qe}from"./diff-tVGVhYyc.js";import{t as $e}from"./commit-diff-panel-DYtYc_dH.js";var Y=e(c(),1);function et(e,t){let n=d(t),r=n.getQueryCache();return Y.useSyncExternalStore(Y.useCallback(e=>r.subscribe(v.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var tt=V(`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`}]]),nt=V(`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=l();function rt(){let e=i(),t=w(),n=d(),r=et({queryKey:E.repo})>0,a=t.data?.info?t.data:null,o=Je(e,a,`screen`);return(0,X.jsxs)(`div`,{"data-route":`repo-git`,"data-slot":`git-screen`,className:Te,children:[(0,X.jsxs)(`div`,{className:`mb-[16px] flex items-center gap-[8px]`,children:[(0,X.jsx)(`h1`,{className:s(we,`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:r,onClick:()=>{n.invalidateQueries({queryKey:E.repo}),n.invalidateQueries({queryKey:E.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)(_e,{size:17,"aria-hidden":`true`,className:s(`size-[17px]`,r&&`motion-safe:animate-spin`)})})]}),a?.info?(0,X.jsx)(`div`,{className:`mb-[16px]`,children:(0,X.jsx)(Ge,{scope:e,repo:a,info:a.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)(He,{branch:a?.info?.branch??null,counts:o,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 it({repo:e,info:t}){let n=x(),r=T(),i=new Map((r.data?.branches??[]).map(e=>[e.name,e])),a=d(),c=S({mutationFn:e=>u({name:e}),onSuccess:async e=>{D(e.created?`Created and switched to ${e.branch}`:`Switched to ${e.branch}`),await Promise.all([a.invalidateQueries({queryKey:E.repo}),a.invalidateQueries({queryKey:E.health})]),a.setQueryData(E.repo,t=>t?.info?{...t,info:{...t.info,branch:e.branch}}:t),a.setQueryData(E.health,n=>n?.repo?.root===t.root?{...n,repo:{...n.repo,branch:e.branch}}:n)},onError:e=>D(e.message,{tone:`danger`})}),[l,f]=(0,Y.useState)(``),[p,m]=(0,Y.useState)(``),h=p.trim().toLowerCase(),g=Q(e,r.data?.branches),_=h?g.filter(e=>e.toLowerCase().includes(h)):g;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)(me,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,X.jsx)(J,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:p,onChange:e=>m(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:[_.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)(U,{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:s(`min-w-0 truncate text-[13px]`,n&&`font-normal`),children:e}),r?(0,X.jsx)(lt,{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)(o,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`md:ml-auto h-11`,disabled:c.isPending,onClick:()=>c.mutate(e),children:[(0,X.jsx)(R,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),_.length===0?(0,X.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-soft-foreground`,children:[`No branches match “`,p.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&&c.mutate(t,{onSuccess:()=>f(``)})},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)(J,{id:`new-branch-name`,"aria-label":`New branch name`,placeholder:`new-branch-name`,className:`h-11 bg-background`,value:l,onChange:e=>f(e.target.value)}),(0,X.jsxs)(o,{type:`submit`,variant:`primary`,size:`sm`,className:`min-h-11 self-start`,"data-action":`create-branch`,disabled:!l.trim()||c.isPending,children:[(0,X.jsx)(ge,{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)(at,{}):null]})}function at(){let e=ne({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)(ot,{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 ot({pr:e}){let t=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(de,{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)(st,{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:a(e.url)?(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:s(n,`hover:bg-muted`),children:t}):(0,X.jsx)(`span`,{className:n,children:t})})}function st({checks:e}){return(0,X.jsx)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:s(`shrink-0 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:e})}var ct={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function lt({entry:e}){return(0,X.jsx)(`span`,{"data-slot":`branch-class`,className:s(`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:ct[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 ut(){let e=ae(),t=q(),[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 h&&e.error.status===409,f=e.data?.files??[],p=(0,Y.useMemo)(()=>Ae(f),[f]),m=(0,Y.useMemo)(()=>f.some(Ze),[f]),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)(je,{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)(De,{mode:n,wrap:i,onModeChange:r,onWrapChange:a})}),m?(0,X.jsx)(Oe,{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)(W,{icon:d?(0,X.jsx)(z,{size:16}):(0,X.jsx)(L,{size:16}),tone:d?`neutral`:`danger`,heading:`h2`,title:d?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):f.length===0?(0,X.jsx)(W,{icon:(0,X.jsx)(z,{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)(ke,{root:p,selected:c,onSelect:e=>{l(e),u.current?.scrollToPath(e)}})]}),(0,X.jsx)(Qe,{files:f,viewRef:u,mode:g,wrap:_,preview:o,className:`min-w-0 flex-1`})]})]})}function dt({repo:e,info:t}){let{sha:r}=n(),i=e.log,a=(0,Y.useMemo)(()=>qe(i),[i]);if(r)return(0,X.jsx)(mt,{sha:r});let o=Be(e,t),s=o&&o.behind>0?(0,X.jsx)(pt,{info:t,tracking:o}):null;return i.length===0?(0,X.jsxs)(X.Fragment,{children:[s?(0,X.jsx)(`div`,{className:`px-[8px] pt-[12px] md:px-[20px]`,children:s}):null,(0,X.jsx)(W,{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:[s,a.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)(U,{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,` · `,We(e.when)]})]})]}),(0,X.jsx)(ft,{source:e.source})]},e.hash))})]},e.label))]})}function ft({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)(U,{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:s(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)(pe,{"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)(ve,{"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 pt({info:e,tracking:t}){let n=ze(i(),e),r=(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)(tt,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-inbox-count-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 text-[12.5px] text-muted-foreground`,children:[t.behind,` commit`,t.behind===1?``:`s`,` on `,t.ref,` `,t.behind===1?`is`:`are`,` not in your checkout yet`]}),(0,X.jsxs)(`button`,{ref:r,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[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)(Ce,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,X.jsx)(be,{"aria-hidden":`true`}),`Pull`]}),(0,X.jsx)(Ye,{checkout:n,returnFocus:r})]})}function mt({sha:e}){return(0,X.jsx)($e,{commit:ie(e),sha:e,backTo:q()?`/git`:Ue,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 ht(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 gt(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 _t={done:`success`,failed:`danger`,cancelled:`neutral`};function vt(){let e=T(),t=y(),n=i(),r=b(),[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)(W,{icon:(0,X.jsx)(L,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let s=ht(e.data.branches),c=gt(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)(H,{"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)(U,{to:Xe.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)(Me,{projectId:n,repoBase:r,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)(yt,{}),l,s.length===0?(0,X.jsx)(W,{icon:(0,X.jsx)(Ie,{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)(bt,{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)(H,{"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)(Tt,{entry:a,onClose:()=>o(null)})]})}function yt({className:e}){return(0,X.jsxs)(`p`,{"data-slot":`git-no-forge`,className:s(`flex items-start gap-[6px] px-[10px] pt-[6px] text-[11.5px] leading-[17px] text-soft-foreground`,e),children:[(0,X.jsx)(H,{"aria-hidden":`true`,className:`mt-[2.5px] size-[12px] shrink-0`}),$,`.`]})}function bt({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)(Ct,{entry:e,finishedAt:t}),(0,X.jsx)(xt,{entry:e}),(0,X.jsx)(St,{entry:e,onDelete:n})]})}function xt({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)(Pe,{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)(wt,{entry:e})]}):null})}function St({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,a=!r&&e.runId!==null&&!i,o=S({mutationFn:()=>p(e.runId),onSuccess:e=>{D(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:E.repoBranches}),n.invalidateQueries({queryKey:E.runs.all})},onError:e=>D(e instanceof h&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),c=()=>void navigator.clipboard.writeText(e.name).then(()=>D(`Copied ${e.name}`),()=>D(`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)(U,{to:`/tasks/${e.runId}`,"data-action":`not-landed-open`,className:s(l,`hidden border border-border hover:bg-muted md:inline-flex`),children:`Open task`}):null,a?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-create-pr`,disabled:o.isPending,onClick:()=>o.mutate(),className:s(l,`hidden bg-muted hover:brightness-110 md:inline-flex`),children:[(0,X.jsx)(nt,{"aria-hidden":`true`}),o.isPending?`Creating…`:`Create draft PR`]}):null,r?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,onClick:c,className:s(l,`hidden border border-border hover:bg-muted md:inline-flex`),children:[(0,X.jsx)(Se,{"aria-hidden":`true`}),`Copy branch`]}):null,(0,X.jsxs)(le,{children:[(0,X.jsx)(se,{"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)(he,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,X.jsxs)(ce,{align:`end`,className:`w-52`,children:[e.runId?(0,X.jsx)(O,{asChild:!0,className:`md:hidden`,children:(0,X.jsx)(U,{to:`/tasks/${e.runId}`,children:`Open task`})}):null,a?(0,X.jsx)(O,{className:`md:hidden`,disabled:o.isPending,onSelect:()=>o.mutate(),children:`Create draft PR`}):null,(0,X.jsx)(O,{className:s(!r&&`md:hidden`),onSelect:c,children:`Copy branch`}),(0,X.jsx)(oe,{className:`md:hidden`}),(0,X.jsx)(O,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function Ct({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=B(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)(Ee,{"aria-label":`Task deleted`,className:`size-[12px] text-soft-foreground`}):(0,X.jsx)(Ke,{tone:e.runStatus&&_t[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)(U,{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]}),(0,X.jsx)(Z,{entry:e})]})]})}function wt({entry:e}){let t=te(Ne(`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 Tt({entry:e,onClose:t}){let n=d(),[r,i]=(0,Y.useState)(``),a=(0,Y.useId)(),o=S({mutationFn:e=>g({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;D(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:E.repo}),s()},onError:e=>D(e.message,{tone:`danger`})}),s=()=>{i(``),t()},c=e!==null&&r.trim()===e.name,l=e&&`${e.ahead} commit${e.ahead===1?``:`s`}`;return(0,X.jsx)(I,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&s(),children:(0,X.jsxs)(j,{"data-slot":`delete-branch-dialog`,children:[(0,X.jsxs)(F,{children:[(0,X.jsxs)(A,{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:[l,` 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(),c&&e&&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)(J,{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)(N,{children:[(0,X.jsx)(P,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,X.jsx)(M,{"data-action":`delete-branch-confirm`,className:`h-11 bg-danger text-danger-foreground hover:brightness-[0.96]`,disabled:!c||o.isPending,onClick:t=>{t.preventDefault(),e&&o.mutate(e.name)},children:o.isPending?`Deleting…`:`Delete branch`})]})]})})}function Et({base:e}){let t=T(),n=d(),[r,i]=(0,Y.useState)({merged:!1,empty:!1}),[a,o]=(0,Y.useState)(!1),s=(t.data?.branches??[]).filter(e=>e.class===`merged`),c=(t.data?.branches??[]).filter(e=>e.class===`empty`),l=[...s,...c],u=S({mutationFn:e=>g({names:e}),onSuccess:e=>{let t=e.refused.length;D(`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:E.repo})},onError:e=>{n.invalidateQueries({queryKey:E.repo}),D(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 f=l.length,p=`branch${f===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 · `,f]}),(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:f===0||u.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)(xe,{"aria-hidden":`true`,className:`size-[12px]`}),u.isPending?`Deleting…`:`Delete ${f} ${p}`]})]}),(0,X.jsx)(Dt,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:$.toLowerCase(),rows:s,open:r.merged,onToggle:()=>i(e=>({...e,merged:!e.merged}))}),(0,X.jsx)(Dt,{kind:`empty`,title:`Empty`,hint:`no commits beyond the fork point`,rows:c,open:r.empty,onToggle:()=>i(e=>({...e,empty:!e.empty}))}),(0,X.jsx)(I,{open:a,onOpenChange:o,children:(0,X.jsxs)(j,{children:[(0,X.jsxs)(F,{children:[(0,X.jsxs)(A,{children:[`Delete `,f,` `,p,`?`]}),(0,X.jsxs)(k,{children:[s.length,` merged into `,e,` and `,c.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)(N,{children:[(0,X.jsx)(P,{children:`Keep them`}),(0,X.jsxs)(M,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{u.mutate(l.map(e=>e.name)),o(!1)},children:[`Delete `,f,` `,p]})]})]})})]})}function Dt({kind:e,title:t,hint:n,rows:r,open:i,onToggle:a}){let o=`cleanup-branches-${e}`;return(0,X.jsxs)(`div`,{"data-slot":`cleanup-branch-group`,"data-group":e,className:`border-b border-border last:border-0`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":o,disabled:r.length===0,onClick:a,className:`flex min-h-[44px] w-full items-center gap-[12px] px-[14px] py-[4px] text-left hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:hover:bg-transparent`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`span`,{className:`truncate text-[12.5px] text-foreground`,children:[t,` · `,r.length]}),(0,X.jsx)(`span`,{className:`truncate text-[11px] text-soft-foreground`,children:n})]}),r.length>0?(0,X.jsx)(ye,{"aria-hidden":`true`,className:s(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,i&&`rotate-90`)}):null]}),i?(0,X.jsx)(`ul`,{id:o,"aria-label":t,className:`flex flex-col pb-[6px]`,children:r.map(e=>(0,X.jsxs)(`li`,{"data-slot":`cleanup-branch-row`,"data-branch":e.name,className:`flex min-h-[32px] items-center gap-[10px] px-[14px] pl-[26px] text-[11.5px]`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-muted-foreground`,children:e.name}),e.runId?(0,X.jsx)(U,{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:B(e.lastCommit.at)})]},e.name))}):null]})}function Ot(){let e=re(),t=ee().data?.targets.find(e=>e.id===`finder`),n=S({mutationFn:e=>f(e,t.id),onError:e=>D(e.message,{tone:`danger`})}),r=d(),[i,a]=(0,Y.useState)(!1),o=()=>Promise.all([r.invalidateQueries({queryKey:E.worktrees}),r.invalidateQueries({queryKey:E.repoBranches})]),s=S({mutationFn:e=>_(),onSuccess:(e,t)=>{o();let n=e.reclaimed.length,r=Math.max(0,t-n);D(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=>D(e.message,{tone:`danger`})}),c=S({mutationFn:e=>m(e.runId),onSuccess:(e,t)=>{o(),D(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{o(),D(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:l,totalBytes:u,keep:p}=e.data,h=s.isPending||c.isPending,g=l.filter(e=>e.pastKeep),v=g.length>0,y=g.some(e=>e.sizeBytes===null)?null:g.reduce((e,t)=>e+(t.sizeBytes??0),0),b=v?y?`Reclaim ${C(y)} now`:`Reclaim ${g.length} now`:`Reclaim now`,x=u?C(u):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`,x?` · ${x}`:``]}),(0,X.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-[11.5px] leading-[17px] text-soft-foreground`,children:[p===0?`Retention is unlimited (`:`Retention keeps the newest ${p} finished checkout${p===1?``:`s`} (`,(0,X.jsx)(U,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:Fe(`worktrees`,` › `)}),p===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:h||!v,title:v?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)(K,{"aria-hidden":`true`,className:`size-[12px]`}),b]})]}),l.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:l.map(e=>(0,X.jsx)(jt,{worktree:e,keep:p,disabled:h,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>c.mutate(e)},e.runId))}),(0,X.jsx)(I,{open:i,onOpenChange:a,children:(0,X.jsxs)(j,{children:[(0,X.jsxs)(F,{children:[(0,X.jsx)(A,{children:`Reclaim old worktrees?`}),(0,X.jsxs)(k,{children:[g.length,` finished worktree`,g.length===1?``:`s`,` beyond the keep limit`,y?` (${C(y)})`:``,` `,g.length===1?`is`:`are`,` reclaimed now, directory only. Their branches are kept, so the work stays recoverable.`]})]}),(0,X.jsxs)(N,{children:[(0,X.jsx)(P,{children:`Keep them`}),(0,X.jsx)(M,{"data-action":`worktrees-confirm`,onClick:()=>{s.mutate(g.length),a(!1)},children:b})]})]})})]})}var kt=new Set([`queued`,`running`,`waiting`,`review`]);function At(e,t){return kt.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 jt({worktree:e,keep:t,disabled:n,onOpen:r,opening:i,onReclaim:a}){let o=At(e,t),c=B(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":o.tone===`in-use`?`in-use`:e.pastKeep?`reclaimable`:`kept`,className:s(`text-[11.5px]`,o.tone===`in-use`?`text-status-running`:`text-soft-foreground`),children:o.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:[` · `,o.label]})]})]}),(0,X.jsx)(`span`,{"data-slot":`worktree-size`,className:`shrink-0 text-[11.5px] tabular-nums text-muted-foreground`,children:e.sizeBytes===null?`—`:C(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)(ue,{"aria-hidden":`true`,className:`size-[13px]`})}):null,o.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:a,className:d,children:(0,X.jsx)(K,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function Mt({section:e,index:n=!1}){let i=w(),a=q(),[o]=t();if(n&&!a&&o.get(`view`)!==`repo`)return(0,X.jsx)(rt,{});if(i.isPending)return(0,X.jsx)(Le,{});if(i.isError)return(0,X.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(G,{}),(0,X.jsx)(W,{icon:(0,X.jsx)(L,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:i.error.message})]});let s=i.data.info;return s?(0,X.jsx)(Nt,{repo:i.data,info:s,section:e}):(0,X.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,X.jsx)(G,{}),(0,X.jsx)(W,{icon:(0,X.jsx)(R,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`${r(`cezar`)} is running outside a git repository — start it inside one to browse changes, commits and branches.`})]})}function Nt({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)(G,{}),(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:Re(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)(Pt,{repo:e,info:t,section:n})})]}),n===`main`?(0,X.jsx)(dt,{repo:e,info:t}):n===`not-landed`?(0,X.jsx)(vt,{}):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)(Ot,{}),(0,X.jsx)(Et,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,X.jsx)(it,{repo:e,info:t}):(0,X.jsx)(ut,{})]})}function Pt({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)(Ft,{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 Ft({repo:e,info:t}){let n=Q(e,T().data?.branches).length;return(0,X.jsxs)(X.Fragment,{children:[n,` branch`,n===1?``:`es`,` · on `,t.branch]})}export{Mt as RepoGitRoute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{C as t,D as n,E as r,h as i,p as a,t as o,w as s}from"./button-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{C as t,D as n,E as r,h as i,p as a,t as o,w as s}from"./button-CHUAMTHK.js";import{i as c,t as l}from"./react-runtime-CCIEwYL0.js";import{c as u,i as d}from"./project-scope-context-CaUqlAd7.js";import{C as f,u as p}from"./queries-DYfIpJ-d.js";import{ct as m,r as h}from"./design-icons-DmYTv2r1.js";import{c as g,i as _,l as v,o as y,s as b,t as x}from"./file-preview-C1eTdJLJ.js";import{t as S}from"./centered-state-DGyy0SuA.js";import{s as C}from"./markdown-D7DUNWcJ.js";import{gt as w,ht as T,mt as E}from"./index-D489J7QW.js";var D=e(c(),1),O=l();function k(){let e=t(),n=s();return()=>{if(e.key==="default"||window.history.state?.idx===0){n({pathname:e.pathname.replace(/\/report\/?$/,``)},{replace:!0});return}let t=window.navigation,r=A(e.state);t?.canGoBack?t.back():r?n(r,{state:{filesRestoreKey:e.state?.filesRestoreKey}}):n(-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]=n(),t=e.get(`path`),r=e.get(`artifact`);return{path:t,artifactId:r,conflict:e.getAll(`path`).length>1||e.getAll(`artifact`).length>1||t!==null&&r!==null||t===``||r===``}}function N(){let{id:e=``}=r(),n=M(),i=t(),a=k();return(0,O.jsx)(P,{runId:e,selection:n,fragment:i.hash,onBack:a,variant:`route`})}function P({runId:e,selection:n,fragment:r,onBack:a,variant:o,sourceLookup:s}){let{path:c,conflict:l,selected:u,result:d}=I(e,n,s),f=w(E,!0),p=w(T,!1),m=t(),[h,g]=(0,D.useState)(!1),_=j(d.data);if(o===`route`&&L(_))return(0,O.jsx)(i,{replace:!0,to:{pathname:m.pathname.replace(/\/report\/?$/,`/files`),search:m.search,hash:m.hash}});let v=z(_,c),y=o===`pane`&&!p&&!f?`Conversation`:`Back`,b=o===`pane`&&!h&&R(_),x=F(m.pathname,e,n);return(0,O.jsxs)(`div`,{"data-route":`task-report`,"data-variant":o,onKeyDown:e=>{o!==`pane`||e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),e.stopPropagation(),a())},className:o===`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:a,backLabel:y,hideDownload:o===`pane`&&p,focusBack:o===`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:l,selected:u,result:d,source:h,name:v,fragment:r,pane:o===`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:a=!1}=t,o=n?.isPending||n?.isError,s=f(e,i||a||o?null:r),c=p(e,a||o?null:i),l=o&&n?{...n,data:void 0}:i?c:s;return{path:r,conflict:a,selected:r!==null||i!==null,result:l}}function L(e){return e!==null&&(!C(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:i,onBack:a,backLabel:s,hideDownload:c,focusBack:l}){let d=(0,D.useRef)(null);(0,D.useEffect)(()=>{l&&d.current?.focus({preventScroll:!0})},[l]);let f=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)(o,{ref:d,variant:`ghost`,className:`min-h-11 min-w-11 gap-1.5 px-2`,onClick:a,"aria-label":s,children:[(0,O.jsx)(h,{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:[f?`Published snapshot · ${new Date(f.createdAt).toLocaleString()}`:`Live file`,` · `,_(t.size)]}):null]}),t&&!t.tooLarge&&!t.binary?(0,O.jsx)(o,{variant:`ghost`,className:`min-h-11 px-3 text-accent-text`,onClick:i,children:r?`Preview`:`Source`}):null,f&&!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:u(e,f.id,`download`),children:`Download`}):null]})}function V({conflict:e,selected:t,result:n,source:r,name:i,fragment:o,pane:s,filesHref:c}){if(e)return(0,O.jsx)(U,{icon:(0,O.jsx)(b,{}),title:`Invalid report link`,subtitle:`Choose either a path or a published artifact.`});if(!t)return(0,O.jsx)(U,{icon:(0,O.jsx)(g,{}),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 l=n.data;return l.type===`file`?s&&!C(l.path)?(0,O.jsx)(U,{icon:(0,O.jsx)(g,{}),title:`Not an HTML report`,subtitle:`Open this published file in Files.`,action:(0,O.jsx)(a,{to:c,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`})}):l.tooLarge?(0,O.jsx)(U,{icon:(0,O.jsx)(v,{}),title:`Too large to preview`,subtitle:`${_(l.size)} is past the 500 kB preview limit. Download it to read it.`}):l.binary?(0,O.jsx)(U,{icon:(0,O.jsx)(g,{}),title:`Binary file`,subtitle:`This file holds binary data, not readable HTML.`}):r?(0,O.jsx)(`div`,{className:`bg-card`,children:(0,O.jsx)(x,{path:l.path,text:l.content??``})}):(0,O.jsx)(y,{html:l.content??``,title:`Report: ${i}`,fragment:o,className:s?`min-h-0 flex-1`:`min-h-[60dvh] flex-1`}):(0,O.jsx)(U,{icon:(0,O.jsx)(b,{}),title:l.type===`unpublished`?`Report not published`:`Report unavailable`,subtitle:l.reason})}function H({result:e}){let t=e.error instanceof d&&e.error.status===404;return(0,O.jsx)(U,{icon:t?(0,O.jsx)(b,{}):(0,O.jsx)(m,{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)(o,{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 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{C as t,I as n,M as r,T as i,t as a}from"./button-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{C as t,I as n,M as r,T as i,t as a}from"./button-CHUAMTHK.js";import{i as o,t as s}from"./react-runtime-CCIEwYL0.js";import{Dr as c,En as l,Jr as u,Xn as d,kr as f,p,zt as m}from"./project-scope-context-CaUqlAd7.js";import{$ as h,Z as g,dt as _,et as v,nt as y,ot as b,rt as x,ut as S}from"./live-protocol-BDY7JJpT.js";import{t as C}from"./useInfiniteQuery-qEY8OhKb.js";import{n as w,t as T}from"./ws-DvGmrP4z.js";import{t as E}from"./project-router-1m_VlC22.js";import{rn as D,yt as O}from"./index-D489J7QW.js";import{t as k}from"./report-title-D4Mbu2Er.js";var A=e(o(),1),j=1e3,M=b().min(1).max(1024);x({q:b().max(j).optional(),before:M.optional(),limit:b().regex(/^(?:[1-9]|[1-9][0-9]|100)$/).transform(Number).optional()}).strict();var N=x({reports:g(x({id:S(),runId:S(),name:b(),title:b(),createdAt:_(),size:y().int().nonnegative(),taskTitle:b(),taskStatus:d}).strict()),nextCursor:M.nullable(),total:y().int().nonnegative()}).strict(),P=x({epoch:S(),generation:y().int().nonnegative(),metadataGeneration:y().int().nonnegative()}).strict(),F=x({runId:S(),taskTitle:b(),taskStatus:d}).strict(),I=h(`type`,[P.extend({type:v(`snapshot`)}),P.extend({type:v(`content`)}),P.extend({type:v(`metadata`),runs:g(F)})]),L=new WeakMap;function R(e,t){if(!e)return{content:t.type===`content`,metadata:t.type===`metadata`,reset:!1};if(e.epoch!==t.epoch)return{content:!0,metadata:!0,reset:!0};if(!(t.generation<e.generation||t.metadataGeneration<e.metadataGeneration)&&!(e.generation===t.generation&&e.metadataGeneration===t.metadataGeneration))return{content:t.generation!==e.generation,metadata:t.metadataGeneration!==e.metadataGeneration,reset:!1}}var z=class{client;project;state;content=0;metadata=0;patches=new Map;trailing=new Set;flights=new Map;constructor(e,t){this.client=e,this.project=t,e.getQueryCache().subscribe(n=>{if(n.type===`removed`){this.trailing.delete(n.query),this.flights.delete(n.query);return}if(!(n.query.queryKey[0]!==t||n.query.queryKey[1]!==`reports`)){if(n.type===`updated`&&n.action.type===`fetch`&&this.flights.set(n.query,this.metadata),n.query.state.fetchStatus===`idle`&&this.flights.has(n.query)){let e=this.flights.get(n.query);this.flights.delete(n.query),e!==this.metadata&&String(n.query.queryKey[2]??``).trim()===``&&this.client.setQueryData(n.query.queryKey,t=>t&&{...t,pages:t.pages.map(t=>this.patch(t,e))})}!this.trailing.has(n.query)||n.query.state.fetchStatus!==`idle`||(this.trailing.delete(n.query),queueMicrotask(()=>{e.invalidateQueries({queryKey:n.query.queryKey,exact:!0,refetchType:`active`},{cancelRefetch:!1})}))}})}patch(e,t=-1){return{...e,reports:e.reports.map(e=>{let n=this.patches.get(e.runId);return n&&n.version>t?{...e,taskTitle:n.value.taskTitle,taskStatus:n.value.taskStatus}:e})}}async read(e,t){for(;;){let n=this.content,r=this.metadata,i=await t();if(!(n!==this.content||e.trim()!==``&&r!==this.metadata))return e.trim()===``?this.patch(i,r):i}}receive(e,t=!1){let n=this.state;if(!n&&e.type===`snapshot`){this.state=e,this.content++,this.client.getQueryCache().findAll({queryKey:[this.project,`reports`]}).some(e=>e.state.data!==void 0)&&this.invalidate(!0);return}let r=R(n,e);if(!r){t&&e.type===`snapshot`&&(this.content++,this.invalidate(!0));return}let{metadata:i,reset:a}=r,o=r.content||t&&e.type===`snapshot`;this.state=e,a&&this.patches.clear(),i&&this.metadata++,o&&this.content++,e.type===`metadata`&&!a&&this.patchCaches(e);let s=o||i&&e.type!==`metadata`;(s||i)&&this.invalidate(s)}patchCaches(e){for(let t of e.runs)this.patches.set(t.runId,{value:t,version:this.metadata});this.client.setQueriesData({queryKey:[this.project,`reports`],predicate:e=>String(e.queryKey[2]??``).trim()===``},e=>e&&{...e,pages:e.pages.map(e=>this.patch(e,this.metadata-1))})}invalidate(e){let t={queryKey:[this.project,`reports`],refetchType:`active`,...e?{}:{predicate:e=>String(e.queryKey[2]??``).trim()!==``}};for(let e of this.client.getQueryCache().findAll(t))e.state.fetchStatus===`fetching`&&this.trailing.add(e);this.client.invalidateQueries(t,{cancelRefetch:!1})}};function B(e,t){let n=L.get(e);n||(n=new Map,L.set(e,n));let r=n.get(t);return r||(r=new z(e,t),n.set(t,r)),r}async function V(e,t){let n=await p.api.v1.p[`:projectId`].reports.state.$get({param:{projectId:e}},m({signal:t}));return P.parse(await l(n,`/reports/state`))}function H(e){let t=B(u(),e);return(0,A.useEffect)(()=>{let n=T(`reports:project:${e}`,e=>{let n=I.safeParse(e);n.success&&t.receive(n.data,n.data.type===`snapshot`)}),r,i,a=()=>{if(c()===`finite`&&!r){i=new AbortController;let n=i.signal;V(e,n).then(e=>{n.aborted||t.receive({type:`snapshot`,...e})}).catch(()=>void 0),r=w({path:`/api/v1/p/${encodeURIComponent(e)}/reports/state`,intervalMs:5e3},(e,n)=>{let r=P.safeParse(e);!n&&r.success&&t.receive({type:`snapshot`,...r.data})})}else c()!==`finite`&&(i?.abort(),r?.(),r=void 0)};a();let o=f(a);return()=>{o(),i?.abort(),r?.(),n()}},[t,e]),t}async function U(e,t,n,r){let i=await p.api.v1.p[`:projectId`].reports.$get({param:{projectId:e},query:{q:t.slice(0,j),...n?{before:n}:{}}},m(r?{signal:r}:void 0));return N.parse(await l(i,`/reports`))}function W(e){let t=r(),n=H(t);return C({queryKey:[t,`reports`,e],initialPageParam:void 0,queryFn:({pageParam:r,signal:i})=>n.read(e,()=>U(t,e,r,i)),getNextPageParam:e=>e.nextCursor??void 0,staleTime:0,refetchOnWindowFocus:!0})}var G=s(),K=new Map;function q(){let e=t(),r=i(),[o,s]=O(),c=(o.get(`q`)??``).slice(0,j),l=W(c),u=(0,A.useRef)(null),d=(0,A.useRef)(``),f=e.pathname+e.search,p=l.data?.pages.flatMap(e=>e.reports)??[];(0,A.useLayoutEffect)(()=>{if(!l.data||d.current===f)return;let t=K.get(f),n=e.state?.filesRestoreKey===f;if(!t||!u.current||r!==`POP`&&!n){d.current=f;return}let i=u.current.querySelector(`[data-report-id="${t.row}"]`);if(l.isFetchNextPageError){d.current=f,u.current.scrollTop=0;return}if((!i||l.data.pages.length<t.pages)&&l.hasNextPage){l.isFetchingNextPage||l.fetchNextPage();return}d.current=f,u.current.scrollTop=i?t.scroll:0,i?.focus({preventScroll:!0})},[f,l.data,l.hasNextPage,l.isFetchingNextPage,l.isFetchNextPageError,l.fetchNextPage,e.state,r]);let m=t=>s(n=>(t?n.set(`q`,t.slice(0,j)):n.delete(`q`),K.delete(e.pathname+`?`+n.toString()),n));return(0,G.jsxs)(`section`,{"data-route":`reports`,className:`flex h-full min-h-0 flex-col`,children:[(0,G.jsxs)(`header`,{className:`flex shrink-0 flex-col gap-3 border-b border-border p-4`,children:[(0,G.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Reports`}),(0,G.jsx)(D,{maxLength:j,"aria-label":`Search reports`,placeholder:`Search reports or source tasks`,value:c,onChange:e=>m(e.target.value),className:`min-h-11`})]}),(0,G.jsxs)(`div`,{ref:u,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 [scrollbar-gutter:stable]`,children:[l.isPending?(0,G.jsx)(`p`,{role:`status`,children:`Loading reports…`}):l.isError?(0,G.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-3`,children:[(0,G.jsx)(`p`,{children:`Could not load reports`}),(0,G.jsx)(`p`,{className:`text-sm text-soft-foreground`,children:l.error.message}),(0,G.jsx)(a,{className:`min-h-11`,onClick:()=>void l.refetch(),children:`Retry`})]}):p.length===0?(0,G.jsxs)(`div`,{className:`flex flex-col items-start gap-3`,children:[(0,G.jsx)(`h2`,{className:`font-medium`,children:c?`No matching reports`:`No published reports yet`}),c?(0,G.jsx)(a,{"data-slot":`reports-clear-search`,variant:`outline`,className:`min-h-11`,onClick:()=>m(``),children:`Clear search`}):(0,G.jsxs)(`p`,{className:`text-sm text-soft-foreground`,children:[`Publish an HTML snapshot with `,(0,G.jsxs)(`code`,{children:[n(),` artifact publish`]}),` to list it here.`]})]}):(0,G.jsx)(`ul`,{className:`flex flex-col gap-3`,children:p.map(e=>(0,G.jsxs)(`li`,{"data-slot":`report-row`,className:`reports-row rounded-lg border border-border bg-card p-3`,children:[(0,G.jsx)(`h2`,{className:`min-w-0 font-medium [overflow-wrap:anywhere]`,children:(0,G.jsx)(E,{"data-report-id":e.id,className:`reports-open`,to:`/tasks/${e.runId}/report?artifact=${e.id}`,state:{readerFrom:f,filesRestoreKey:f},onClick:()=>K.set(f,{scroll:u.current?.scrollTop??0,row:e.id,pages:l.data?.pages.length??1}),children:k(e)})}),(0,G.jsx)(E,{className:`reports-task text-sm text-accent-text underline [overflow-wrap:anywhere]`,to:`/tasks/${e.runId}`,children:e.taskTitle}),(0,G.jsx)(`time`,{className:`block text-xs text-soft-foreground`,dateTime:e.createdAt,children:new Date(e.createdAt).toLocaleString()})]},e.id))}),l.hasNextPage?(0,G.jsx)(a,{variant:`outline`,className:`min-h-11`,disabled:l.isFetchingNextPage,onClick:()=>void l.fetchNextPage(),children:`Load more reports`}):null]})]})}export{q as ReportsRoute};
|