cezarion 0.19.0-dev.8721 → 0.19.0-dev.8731

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/package.json +3 -3
  2. package/web/dist/assets/accounts-section-DVJon113.js +1 -0
  3. package/web/dist/assets/{activity-motion-C8V7jGPP.js → activity-motion-D_Mig_D4.js} +1 -1
  4. package/web/dist/assets/{activity-route-CCOvPI4k.js → activity-route-BvYIEdOs.js} +1 -1
  5. package/web/dist/assets/{agent-config-section-DkJsuQeu.js → agent-config-section-BImy20b0.js} +1 -1
  6. package/web/dist/assets/{agent-defaults-section-BqGJuaw_.js → agent-defaults-section-D30dOTKu.js} +1 -1
  7. package/web/dist/assets/{appearance-BnvyVZZH.js → appearance-CHsrT2VO.js} +1 -1
  8. package/web/dist/assets/{archive-on-merge-field-D7-FuLiL.js → archive-on-merge-field-BT4e_k9f.js} +1 -1
  9. package/web/dist/assets/attention-CGsbqL2t.js +1 -0
  10. package/web/dist/assets/{automations-route-C9Gcx3ov.js → automations-route-BEhmjeVF.js} +2 -2
  11. package/web/dist/assets/{commit-list-DNiFNJqd.js → commit-list-02HM16KN.js} +1 -1
  12. package/web/dist/assets/{diff-B60FGSvK.js → diff-BmDcJsHL.js} +2 -2
  13. package/web/dist/assets/{diff-controls-D6LIYMhn.js → diff-controls-HmgYRhy7.js} +1 -1
  14. package/web/dist/assets/{diff-view-Blyp1vQ3.js → diff-view-CRx2ZNOd.js} +1 -1
  15. package/web/dist/assets/{file-preview-C0EtwJYH.js → file-preview-B361k1Oo.js} +1 -1
  16. package/web/dist/assets/{folder-browser-6stmlyVQ.js → folder-browser-BJ3aXo9k.js} +1 -1
  17. package/web/dist/assets/{git-toolbar-CRj5dZa2.js → git-toolbar-DsNQUL5f.js} +1 -1
  18. package/web/dist/assets/github-DP2REdU5.js +1 -0
  19. package/web/dist/assets/{global-activity-route-Db2_yTAR.js → global-activity-route-Iv0uN7Wy.js} +1 -1
  20. package/web/dist/assets/index-CVz-Ls8s.css +1 -0
  21. package/web/dist/assets/{index-BX94wp6m.js → index-mCjln54E.js} +6 -6
  22. package/web/dist/assets/{label-BKUl84DF.js → label-CH-a6Jyv.js} +1 -1
  23. package/web/dist/assets/{markdown-DK1FZN4x.js → markdown-DiMerfHU.js} +1 -1
  24. package/web/dist/assets/{notifications-section-dI7sOt8i.js → notifications-section-DGH8tp1N.js} +1 -1
  25. package/web/dist/assets/{open-in-menu-N8rXgYSG.js → open-in-menu-CML2QKil.js} +1 -1
  26. package/web/dist/assets/{popover-BPgUYFyu.js → popover-CZV6tz9i.js} +1 -1
  27. package/web/dist/assets/preview-pane-connected-Cl_6DHNm.js +3 -0
  28. package/web/dist/assets/{project-location-CcmuGA5W.js → project-location-CZNz3wYW.js} +1 -1
  29. package/web/dist/assets/{project-router-CT6gVIcC.js → project-router-BvBqllk2.js} +1 -1
  30. package/web/dist/assets/{projects-section-B-eMkZf3.js → projects-section-D3h_nr6-.js} +1 -1
  31. package/web/dist/assets/prompt-templates-section-DelsVm7I.js +1 -0
  32. package/web/dist/assets/{queries-ClkIgWFx.js → queries-CYWRnyM5.js} +1 -1
  33. package/web/dist/assets/{reference-chip-B8bfD56G.js → reference-chip-BdikRjql.js} +1 -1
  34. package/web/dist/assets/{remote-settings-notice-BxFlEKfC.js → remote-settings-notice-D2x0qeKt.js} +1 -1
  35. package/web/dist/assets/repo-git-DKkOxBOJ.js +1 -0
  36. package/web/dist/assets/{report-reader-DT6V1PE1.js → report-reader-D2b9baRm.js} +1 -1
  37. package/web/dist/assets/{report-selection-D9xJZoKb.js → report-selection-D2RvkiGX.js} +1 -1
  38. package/web/dist/assets/{reports-pCaOIoVC.js → reports-CBP54u9k.js} +1 -1
  39. package/web/dist/assets/{resources-section-Dr0YbhlY.js → resources-section-D86nQvrk.js} +1 -1
  40. package/web/dist/assets/review-panel-BcuyfiuF.js +11 -0
  41. package/web/dist/assets/{run-detail-refresh-Bo51TspT.js → run-detail-refresh-BNI7eMgG.js} +1 -1
  42. package/web/dist/assets/run-header-B2AfxeyZ.js +2 -0
  43. package/web/dist/assets/{select-DzxGxxTm.js → select-KMLdkF0Y.js} +1 -1
  44. package/web/dist/assets/{session-context-section-BxrtJ6og.js → session-context-section-Do5bNw8y.js} +2 -2
  45. package/web/dist/assets/{settings-agent-picker-CDt7Ns8e.js → settings-agent-picker-Dtqb26Hz.js} +1 -1
  46. package/web/dist/assets/{settings-shell-B9ladcQ_.js → settings-shell-CWPwhUDh.js} +1 -1
  47. package/web/dist/assets/{sidebar-section-CRUJRrAR.js → sidebar-section-pLjtUKHT.js} +1 -1
  48. package/web/dist/assets/{skills-Co7HupH_.js → skills-CaXsJiUU.js} +1 -1
  49. package/web/dist/assets/{tab-link-BMblA2WK.js → tab-link-B0pNjKxZ.js} +1 -1
  50. package/web/dist/assets/task-changes-oogngDub.js +1 -0
  51. package/web/dist/assets/{task-commits-ISUoukSa.js → task-commits-_Aa8bkJq.js} +1 -1
  52. package/web/dist/assets/task-file-scope-DY0ozMDn.js +1 -0
  53. package/web/dist/assets/task-files-DxFFK3zI.js +1 -0
  54. package/web/dist/assets/{task-github-item-Cg8gVOKX.js → task-github-item-LSzJuoiu.js} +1 -1
  55. package/web/dist/assets/{task-groups-aquji1Kv.js → task-groups-lh9gz7TP.js} +1 -1
  56. package/web/dist/assets/task-thread-BlThx_dR.js +2 -0
  57. package/web/dist/assets/task-thread-PDeU-fL6.css +1 -0
  58. package/web/dist/assets/{tasks-table-BkjZYg2J.js → tasks-table-k18AuMR5.js} +1 -1
  59. package/web/dist/assets/thread-state-DA2aAkKF.js +4 -0
  60. package/web/dist/assets/{toaster-C-xqAWVX.js → toaster-B0kvcFif.js} +1 -1
  61. package/web/dist/assets/{use-hand-to-agent-state-ibAi0h18.js → use-hand-to-agent-state-dgiJEULj.js} +1 -1
  62. package/web/dist/assets/workflows-DNs9e08u.js +7 -0
  63. package/web/dist/assets/{workspace-tools-HU7VkLIs.js → workspace-tools-DHek4GFd.js} +1 -1
  64. package/web/dist/assets/{worktrees-section-uDWkAqqs.js → worktrees-section-fLfqff8U.js} +1 -1
  65. package/web/dist/index.html +15 -15
  66. package/web/dist/assets/accounts-section-BObx1Wc5.js +0 -1
  67. package/web/dist/assets/attention--Y0CyzCN.js +0 -1
  68. package/web/dist/assets/github-DjD-J1Cb.js +0 -1
  69. package/web/dist/assets/index-BtmQDC_G.css +0 -1
  70. package/web/dist/assets/preview-pane-connected-B37RWFUW.js +0 -3
  71. package/web/dist/assets/prompt-templates-section-BNbYFE3y.js +0 -1
  72. package/web/dist/assets/repo-git-CEYHupW1.js +0 -1
  73. package/web/dist/assets/review-panel-wprTeofI.js +0 -8
  74. package/web/dist/assets/run-header-GiajAH1E.js +0 -2
  75. package/web/dist/assets/task-changes-Dwcer1B-.js +0 -1
  76. package/web/dist/assets/task-files-Bek9A4TF.js +0 -1
  77. package/web/dist/assets/task-thread-DbBtpcw3.js +0 -2
  78. package/web/dist/assets/task-thread-DzADOhZd.css +0 -1
  79. package/web/dist/assets/thread-state-CEVwXFWy.js +0 -4
  80. package/web/dist/assets/workflows-Dy_qXVKT.js +0 -7
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{c as n,o as r}from"./utils-DSMR_WLb.js";import{$t as i,At as a,Bn as o,Br as s,C as c,Ct as l,D as u,Di as d,E as f,Et as p,F as m,Fi as h,Fn as g,G as _,Gt as v,In as y,J as ee,Jt as te,K as ne,Kr as re,Kt as ie,Ln as ae,Mi as oe,N as se,Nt as ce,O as le,Q as ue,Qt as de,Rn as fe,Rr as pe,Rt as me,S as he,Si as ge,Sr as _e,St as ve,T as ye,Tt as be,U as xe,Ut as Se,Vn as Ce,Vr as we,Vt as Te,W as Ee,Wt as De,X as Oe,Xt as ke,Yt as Ae,Z as je,Zt as Me,_n as Ne,_r as Pe,_t as Fe,a as Ie,ai as Le,an as Re,b as ze,bt as Be,ci as Ve,di as He,dn as Ue,dt as We,fi as Ge,fn as Ke,gi as qe,gn as Je,gt as Ye,h as Xe,hi as b,ht as Ze,ii as x,in as Qe,j as $e,ji as et,jt as tt,ki as nt,kt as rt,li as it,ln as at,m as ot,mn as st,mt as ct,n as lt,nn as ut,oi as dt,on as ft,ot as pt,pn as mt,q as ht,qr as gt,qt as _t,ri as vt,rn as yt,si as bt,ti as xt,tn as St,ui as Ct,un as wt,v as Tt,vi as Et,vn as Dt,vt as Ot,w as kt,wi as At,wt as jt,x as Mt,xt as Nt,y as Pt,yi as Ft,yn as It,yt as Lt,zn as Rt,zt}from"./toaster-C-xqAWVX.js";import{A as Bt,B as S,F as C,H as w,I as T,N as E,P as D,W as O,Z as k,a as Vt,j as A,z as j}from"./live-protocol-DMhTnCmf.js";function Ht(e,t){return e??t}function Ut(e,t){let n=Ht(e,t);return n===`1`||n===`true`}function Wt(e,t,n){return e?.trim()||Ht(t,n)||``}var Gt=class extends Et{#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||Kt(),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=Ft({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),k.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Kt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var qt=class extends h{#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),et(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&ge(t.mutationKey)!==ge(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??Kt();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){k.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 Jt(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Yt(e,t,n){let r=e.slice(0);return r[t]=n,r}var Xt=class extends h{#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,k.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||!et(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Jt(e,n).forEach(e=>{e.destroy()}),Jt(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=nt(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 qe(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Yt(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)&&k.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},M=e(t(),1);function N({queries:e,...t},n){let r=b(n),i=Ge(),a=He(),o=M.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{Le(e);let t=r.getQueryCache().get(e.queryHash);Ve(e,a,t)}),Ct(a);let[s]=M.useState(()=>new Xt(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),f=!i&&t.subscribed!==!1;M.useSyncExternalStore(M.useCallback(e=>f?s.subscribe(k.batchCalls(e)):d,[s,f]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),M.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let p=c.some((e,t)=>bt(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&bt(n,e)?dt(n,new qe(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=c.find((e,t)=>{let n=o[t];return n&&it({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 P(e,t){let n=b(t),[r]=M.useState(()=>new qt(n,e));M.useEffect(()=>{r.setOptions(e)},[r,e]);let i=M.useSyncExternalStore(M.useCallback(e=>r.subscribe(k.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=M.useCallback((e,t)=>{r.mutate(e,t).catch(d)},[r]);if(i.error&&oe(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function F(e={}){let t=e.projectId??n();return{projectId:t,cacheScope:e.cacheScope??(e.boot?`default`:t)}}function I(e,t={}){return{...F(t),runId:e}}function Zt(e,t=!0,n=!1,r){return x({queryKey:[F({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>a(F({projectId:e,boot:n}),{signal:t}),enabled:t,...r?{select:r}:{},placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function L(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:G.models(t),refetchType:n})}function Qt(e,t=!0,n){return x({...$t(e,n),enabled:t})}var $t=(e,t)=>({queryKey:G.models(e,t),queryFn:({signal:n})=>Ce(e,{signal:n},t),staleTime:300*1e3});function en(e,t=!0){let n=N({queries:e.map(e=>({...$t(e),enabled:t}))});return Object.fromEntries(e.map((e,t)=>[e,n[t]]))}function tn(e,t){return JSON.stringify([e,t])}function nn(e){return e.type===`run`?e.run.id:e.id}function R(e,t){return{...e,runs:t}}function rn(e,t){let n=0;for(let r of e)r.projectId===t&&r.archived&&(n+=1);return n}var an=class{runs;copied=!1;positions=new Map;constructor(e){this.runs=e,this.reindex()}reindex(){this.positions.clear(),this.runs.forEach((e,t)=>this.positions.set(tn(e.projectId,e.id),t))}at(e,t){return this.positions.get(tn(e,t))??-1}mutable(){return this.copied||=(this.runs=[...this.runs],!0),this.runs}replace(e,t){return this.mutable()[e]=t,this.runs}remove(e){return this.mutable().splice(e,1),this.reindex(),this.runs}insert(e){let t=this.runs.findIndex(t=>(t.createdAt??``).localeCompare(e.createdAt)<0);return this.mutable().splice(t<0?this.runs.length:t,0,e),this.reindex(),this.runs}};function on(e,t,n){let r=new an(e.runs),i=e,a=!1;for(let e of t)if(e.type===`usage`)i=fn(i,e.project,e.usage,r);else{let t=ln(i,e.change,n,r);i=t.index,a||=t.reconcile}return{index:i,reconcile:a}}function sn(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function cn(e,t,n){return ln(e,t,n,new an(e.runs))}function ln(e,t,n,r){let{project:i}=t,a=r.at(i,nn(t)),o=a>=0?e.runs[a]:void 0,s=e.truncated.includes(i);if(t.type===`deleted`)return o?{index:R(e,r.remove(a)),reconcile:s&&o.archived}:{index:e,reconcile:!1};let{run:c}=t;if(c.delegation?.role===`worker`)return o?{index:R(e,r.remove(a)),reconcile:!1}:{index:e,reconcile:!1};if(!o&&!sn(e,i,n))return{index:e,reconcile:!0};let l=nt(o,{projectId:i,...c});if(o){if(l===o)return{index:e,reconcile:!1};let t=r.replace(a,l),n=o.archived!==l.archived&&(s||rn(t,i)>e.perProjectLimit);return{index:R(e,t),reconcile:n}}if(s)return dn(e,l,r);let u=r.insert(l);return{index:R(e,u),reconcile:l.archived&&rn(u,i)>e.perProjectLimit}}function un(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 dn(e,t,n){let r=un(e.runs,t.projectId),i=r!==void 0&&t.createdAt>r;return t.archived&&!i?{index:e,reconcile:!1}:{index:R(e,n.insert(t)),reconcile:t.archived||r===void 0||t.createdAt<r}}function fn(e,t,n,r){let i=!1;return e.runs.forEach((e,a)=>{if(e.projectId!==t)return;let o=n[e.id];if(o){let t=nt(e.usage,o);if(t===e.usage)return;r.replace(a,{...e,usage:t})}else{if(e.usage===void 0)return;let{usage:t,...n}=e;r.replace(a,n)}i=!0}),i?R(e,r.runs):e}function pn(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 mn(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function hn(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 gn(e){e.stream=void 0}function _n(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,nn(t)]),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}function vn(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function yn(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function bn(e,t,n){if(!yn(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=cn(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`],xn=[`workspace`,`projects`],Sn=6e4,Cn=100,wn=new WeakMap;function Tn(e){let t=wn.get(e);return t||(t=An(e),wn.set(e,t)),t}function En(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:Tn(t).merge(e)}function Dn(e){let t=e.getQueryData(xn)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function On(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 kn(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 An(e){let t=mn(),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=Dn(e),{index:s,reconcile:c}=on(a,t.filter(e=>e.generation===a.generation?e.type===`usage`?!l.has(e.project):!l.has(e.change.project)&&e.change.seq>a.eventSeq:!1),o);s!==a&&m(s),c&&_({hold:!0})},y=()=>{if(i!==void 0)return;let e=c+250-Date.now();if(e>0){i=setTimeout(v,e);return}i=setTimeout(v,Cn),typeof requestAnimationFrame==`function`&&(r=requestAnimationFrame(v))};return{ready(e,n){hn(t,e,n),u=!1,f&&(f=!1,_({hold:!0}))},detach(){gn(t)},run(e,r,i=!1){if(l.has(e))return;let a=kn(e,r);if(!_n(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),vn(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let r=h();if(!r)return;let i=pn(r,e);i!==r&&m(i)},setUnknownGenerationHandler(e){d=e},restoreProject(e){l.delete(e)},merge(n){let r=h(),i=bn(t,n,Dn(e));for(let e of l)i.index=pn(i.index,e);return i.reconcile&&queueMicrotask(()=>{_({hold:!0})}),On(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 jn=A([`own`,`provider-spanning`]),Mn=S({suggested:E(S({id:O(),label:O(),desc:O()})),retired:E(O())}),Nn=S({id:A([`settings`,`mcp`,`memory`]),label:O(),note:O().optional(),empty:O().optional(),showsUserMcp:T(!0).optional()}),Pn=S({label:O(),note:O().optional(),groups:E(Nn)}),Fn=S({runners:E(S({id:xt,displayName:O(),modelListName:O(),modelIdScope:jn,pickerLabel:O(),pickerDescription:O(),icon:O(),installHint:O(),loginCommand:O(),terminalLogin:D().optional(),browserLogin:D().optional(),managedInstall:T(!0).optional(),accountFolderExample:O().optional(),models:Mn,agentConfig:Pn}))}),In=[`workspace`,`runners`];async function Ln(e){return o(await y.api.v1.runners.$get({},ae(e)),`/runners`,Fn)}var Rn={queryKey:In,queryFn:({signal:e})=>Ln({signal:e}),staleTime:1/0};function zn(){return x(Rn)}function Bn(e){return e?.runners??[]}function Vn(e){return Bn(e).map(e=>e.id)}function Hn(e,t){if(e!==void 0)return t.includes(e)?e:t[0]}function Un(e){let t=zn();return{runner:t.isSuccess?Hn(e,Vn(t.data))??e:e,ready:!t.isPending}}function B(e,t){return e?.runners.find(e=>e.id===t)}function Wn(e,t){return B(e,t)?.displayName??t}function Gn(e,t){return B(e,t)?.pickerLabel??t}function Kn(e,t){return B(e,t)?.modelListName}function qn(e,t,r=!0){let i=Ii(),a=Ur(),{runner:o,ready:s}=Un(e??i.data?.defaultRunner??`claude`),c=a.data?.capabilities?.localHandoff===!1?null:t,l=n(),u=x({queryKey:W.runnerSkills(o,c),queryFn:({signal:e})=>kt(o,c,{signal:e,projectId:l}),enabled:r&&s&&(e!==void 0||!i.isPending)&&(!t||!a.isPending),retry:!1});return{...u,runner:o,account:c,data:u.data?.skills,list:u.data,unchecked:u.isError||!u.data||u.data.source===`unavailable`}}var Jn={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`}},Yn={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function Xn(e){return typeof e==`string`&&Object.hasOwn(Jn,e)}function Zn(e){return e!==void 0&&Xn(e)?Jn[e]:void 0}var Qn=`cez.reference-statuses.v1`,$n=`cez.reference-conflicts.v1`,V=new Map(rr()),er=1e3;function tr(e,t){if(V.get(e)!==t){for(V.delete(e),V.set(e,t);V.size>er;){let e=V.keys().next().value;if(e===void 0)break;V.delete(e)}or()}}var H=new Set(ir());function nr(e,t){if(H.has(e)!==t){if(t)for(H.add(e);H.size>er;){let e=H.values().next().value;if(e===void 0)break;H.delete(e)}else H.delete(e);or()}}function rr(){try{let e=globalThis.sessionStorage?.getItem(Qn);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`&&Xn(e[1])):[]}catch{return[]}}function ir(){try{let e=globalThis.sessionStorage?.getItem($n);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var ar;function or(){ar===void 0&&(ar=setTimeout(()=>{ar=void 0;try{globalThis.sessionStorage?.setItem(Qn,JSON.stringify([...V])),globalThis.sessionStorage?.setItem($n,JSON.stringify([...H]))}catch{}},250))}var U=e=>`${e.projectId}\u0000${e.kind}#${e.number}`;function sr(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function cr(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 lr(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;tr(t,o),s!==void 0&&nr(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function ur(e,t,n){let r=U(t),i=V.get(r),a=H.has(r)?!0:void 0,o=n.data;if(o?.available){lr(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...sr(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...sr(i,a)});return}e.set(r,{state:`loading`,...sr(i,a)})}function dr(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of cr(i))ur(n,e,t)}),n}var W={get health(){return[n(),`health`]},runs:{get all(){return[n(),`runs`]},relationships:e=>[n(),`runs`,`relationships`,e],list:(e=n())=>[e,`runs`,`list`],archived:e=>[n(),`runs`,`archived`,e],detail:(e,t=n())=>[t,`runs`,`detail`,e],diff:e=>[n(),`runs`,`diff`,e],changes:e=>[n(),`runs`,`changes`,e],file:(e,t)=>[n(),`runs`,`files`,e,t],handoff:e=>[n(),`runs`,`handoff`,e],commits:e=>[n(),`runs`,`commits`,e],commit:(e,t)=>[n(),`runs`,`commit`,e,t]},get workflows(){return[n(),`workflows`]},runnerSkills:(e,t)=>[n(),`runner-skills`,e,t??null],get repo(){return[n(),`repo`]},get repoChanges(){return[n(),`repo`,`changes`]},repoCommit:e=>[n(),`repo`,`commit`,e],get repoBranches(){return[n(),`repo`,`branches`]},get uiState(){return[n(),`ui-state`]},get config(){return[n(),`config`]},get agentConfig(){return[n(),`agent-config`]},agentConfigFile:e=>[n(),`agent-config`,`file`,e],get sessionContext(){return[n(),`session-context`]},sessionContextPreview:(e,t,r=``)=>[n(),`session-context`,`preview`,t,e,r],get worktrees(){return[n(),`worktrees`]},github:(e={})=>[n(),`github`,e.limit??null],githubPages:e=>[n(),`github`,`pages`,e],githubPagesHead:e=>[n(),`github`,`pages-head`,e],githubCommentCounts:(e,t)=>[n(),`github`,`comment-counts`,e,[...t].sort((e,t)=>e-t).join(`,`)],githubChecks:e=>[n(),`github`,`checks`,[...e].sort((e,t)=>e-t).join(`,`)],githubSearch:(e,t)=>[n(),`github`,`search`,e,t],githubRefStatus:(e,t,n)=>[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`]}},G={models:(e,t)=>t&&t!=="default"?[`workspace`,`models`,e,t]:[`workspace`,`models`,e],providerStatus:[`workspace`,`providers`,`status`],projects:[`workspace`,`projects`],githubOwners:[`workspace`,`github-owners`],runsIndex:z,runsSearch:e=>[`workspace`,`runs-search`,e],uiState:[`workspace`,`ui-state`],config:[`workspace`,`config`],agentProfiles:[`workspace`,`agent-profiles`],agentAccountStatus:e=>[`workspace`,`agent-profiles`,`status`,e],fsBrowseRoot:[`workspace`,`fs-browse`],fsBrowse:(e,t=!1)=>[...G.fsBrowseRoot,e,t]};function fr(){return Ut(void 0,void 0)}function K(e){return!fr()&&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 mr(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 hr(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 gr(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 _r(e,t){return gt({kind:`topic`,topic:e},{value:t})}function vr(){let e=b();return x({queryKey:G.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(G.providerStatus),r=await Qe(!1,{signal:t});return _e(n,e.getQueryData(G.providerStatus),r)},staleTime:5*6e4,refetchInterval:K(!1),refetchOnWindowFocus:!0})}function yr(){let e=b();return P({mutationFn:()=>Qe(!0),onMutate:()=>e.getQueryData(G.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(G.providerStatus,e=>_e(r,e,t)),L(e)}})}function br(){let e=b();return P({mutationFn:({provider:e,authFailureId:t})=>mt(e,t),onMutate:()=>e.getQueryData(G.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(G.providerStatus,e=>_e(r,e,t,n.authFailureId)),L(e,n.provider)}})}function xr(e={}){return x({queryKey:G.projects,queryFn:({signal:e})=>yt({signal:e}),...e})}function Sr(e,t=!1){return x({queryKey:G.fsBrowse(e,t),queryFn:({signal:n})=>ie(e??void 0,{signal:n,showHidden:t}),retry:!1})}function Cr(){let e=b();return P({mutationFn:e=>at(e),onSuccess:()=>e.invalidateQueries({queryKey:G.projects})})}function wr(){let e=b();return P({mutationFn:e=>Ue(e),retry:!1,onSuccess:()=>{e.invalidateQueries({queryKey:G.projects})}})}function Tr(){let e=b();return P({mutationFn:e=>{let{id:t,...n}=e;return Dt(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:G.projects});let r=e.getQueryData(G.projects);return e.setQueryData(G.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?Er(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(G.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(G.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:G.projects})})}function Er(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?[]:gr(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 Dr(e){let t=b();return P({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(G.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:G.projects})})}function Or(){return Dr(e=>{let{projectId:t,...n}=e;return Me(t,n)})}function kr(){return Dr(e=>{let{projectId:t,webhookId:n,...r}=e;return It(t,n,r)})}function Ar(){return Dr(({projectId:e,webhookId:t})=>Ke(e,t))}function jr(){return P({mutationFn:({projectId:e,webhookId:t})=>Je(e,t),retry:!1})}function q(e){let t=b();return P({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:G.agentProfiles}),t.invalidateQueries({queryKey:G.projects}),t.invalidateQueries({predicate:({queryKey:e})=>e[1]===`runner-skills`}),L(t)])},onError:()=>{t.invalidateQueries({queryKey:W.health}),t.invalidateQueries({queryKey:G.agentProfiles,exact:!0})}})}function Mr(){return q(e=>Ae(e))}function Nr(){return q(e=>{let{id:t,...n}=e;return Ne(t,n)})}function Pr(){return q(e=>wt(e))}function Fr(){return q(e=>st(e))}function Ir(e,t){return x({queryKey:G.agentAccountStatus(e),queryFn:({signal:t})=>de(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function Lr(){let e=b();return P({mutationFn:({provider:e,profileId:t})=>te(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:G.agentProfiles}),e.invalidateQueries({queryKey:G.providerStatus}),L(e,n,`none`)])},onError:()=>{e.invalidateQueries({queryKey:W.health}),e.invalidateQueries({queryKey:G.agentProfiles,exact:!0})}})}function Rr(){let e=b();return P({mutationFn:e=>de(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(G.agentAccountStatus(n),t),e.invalidateQueries({queryKey:G.agentProfiles}),L(e,t.status.provider)}})}function zr(){let e=b();return P({mutationFn:e=>_t(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:G.projects})})}function Br(){let e=b();return P({mutationFn:e=>ke(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:G.projects})})}function Vr({enabled:e}){return x({queryKey:G.githubOwners,queryFn:({signal:e})=>St({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function Hr(){let e=b();(0,M.useEffect)(()=>{let t,n=()=>{let n=e.getQueryData(W.health);n&&(s({bootProject:n.bootProject??`default`,apiBase:r()}),t??=_r(`health`,t=>{e.setQueryData(W.health,t)}))};n();let i=e.getQueryCache().subscribe(n);return()=>{i(),t?.(),re()}},[e])}function Ur(){return x({queryKey:W.health,queryFn:({signal:e})=>ut({signal:e})})}function Wr(e,t){let n=Ur().data,r=xr(t).data?.projects,i=Ie(),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 Gr(){return x({queryKey:G.uiState,queryFn:({signal:e})=>ft({signal:e})})}function Kr(){return x({queryKey:G.config,queryFn:({signal:e})=>Re({signal:e})})}function qr(){return x({queryKey:G.agentProfiles,queryFn:({signal:e})=>i({signal:e})})}var J=[`workspace`,`runs-index`],Y=e=>[e.cacheScope,`runs`,`list`],X=e=>[e.cacheScope,`runs`,`detail`,e.runId],Z=e=>typeof e==`function`?e():e;function Jr(e){let{seenAt:t,...n}=e;return n}function Yr(e,t){let n=Jr(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function Xr(e,t,n){return t?{...e,seenAt:n}:Jr(e)}function Zr(e){let t=()=>{e.invalidateQueries({queryKey:J})};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=we(),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:Y(Z(n))}),await e.cancelQueries({queryKey:X(Z(n))});let i=e.getQueryData(Y(Z(n))),a=e.getQueryData(X(Z(n))),o=Z(n).runId,s=new Date().toISOString();return e.setQueryData(Y(Z(n)),e=>e?.map(e=>e.id===o?Xr(e,r,s):e)),e.setQueryData(X(Z(n)),e=>e&&Xr(e,r,s)),{id:o,prevList:i,prevDetail:a,rollback(){if(!r){i&&e.setQueryData(Y(Z(n)),i),a&&e.setQueryData(X(Z(n)),a);return}let t=i?.find(e=>e.id===o);t&&e.setQueryData(Y(Z(n)),e=>e?.map(e=>e.id===o?Yr(e,t):e)),a&&e.setQueryData(X(Z(n)),e=>e&&Yr(e,a))},settle(i){let a=e=>e.id===(r?o:i.id)?Xr(e,r,i.seenAt):e;e.setQueryData(Y(Z(n)),e=>e?.map(a));let s={...Z(n),runId:r?o:i.id};e.setQueryData(X(s),e=>e?a(e):i),t()}}}async function a(t,n){await e.cancelQueries({queryKey:J});let i=e.getQueryData(J),a=n();return e.setQueryData(J,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(J,i)},settle(){r(`indexed`,t)}}}return{patchRead:i,patchIndex:a,invalidateAfter:r}}function Q(){let e=b();return(0,M.useMemo)(()=>Zr(e),[e])}function Qr(e,t){if(!Vt(e.path))throw Error(`unsupported shared read`);let n=new URL(e.path,`http://cezar.invalid`);return n.searchParams.sort(),gt({kind:`read`,path:`${n.pathname}${n.search}`,intervalMs:e.intervalMs},{value:t})}function $(e,t,n,r){let i=b(),a=JSON.stringify(t),o=(0,M.useMemo)(()=>JSON.parse(a),[a]);(0,M.useEffect)(()=>{if(!e||n===!1)return;let t=!0,a=Qr({path:e,intervalMs:n},(e,n)=>{n||i.cancelQueries({queryKey:o,exact:!0}).then(()=>{t&&i.setQueryData(o,r?r(e,i):e)})});return()=>{t=!1,a()}},[i,e,o,n,r])}async function $r(e,t=!1){return Rt(await y.api.v1.p[`:projectId`].runs[`:id`][`worker-destroy`].$post({param:{projectId:n(),id:encodeURIComponent(e)},query:{},json:t?{discardWork:!0}:{}}),fe(e,`/worker-destroy`))}function ei(){return x({queryKey:W.openTargets,queryFn:({signal:e})=>Lt({signal:e}),staleTime:5*6e4})}function ti(){return x({queryKey:W.runs.list(),queryFn:({signal:e})=>a(F(),{signal:e})})}function ni(e,t){return vt({queryKey:W.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>ct({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 ri(e){let t=e.trim();return x({queryKey:G.runsSearch(t),queryFn:({signal:e})=>Se(t,{signal:e}),enabled:t.length>=2,placeholderData:At,staleTime:1e4})}function ii(e=!0,t=Sn,n){let r=Tn(b());return $(`/api/v1/workspace/runs-index`,G.runsIndex,K(e?t:!1),En),x({queryKey:G.runsIndex,queryFn:({signal:e})=>tt({signal:e}).then(r.merge),enabled:e,...n?{select:n}:{},staleTime:3e4,refetchInterval:!1})}function ai(e){let t=b();return P({mutationFn:({workerId:e,discardWork:t=!1})=>$r(e,t),onSettled:()=>t.invalidateQueries({queryKey:W.runs.relationships(e)})})}function oi(e,t={}){return x({queryKey:W.runs.relationships(e),queryFn:({signal:t})=>rt(e,{signal:t}),enabled:t.enabled??!0})}function si(e){return x({queryKey:W.runs.detail(e??``),queryFn:({signal:t})=>Be(I(e),{signal:t}),enabled:!!e})}function ci(e,t,n=!0,r){return x({queryKey:[e??`default`,`runs`,`detail`,t??``],queryFn:({signal:n})=>Be(I(t,{projectId:e}),{signal:n}),enabled:n&&!!e&&!!t,...r?.staleTime===void 0?{}:{staleTime:r.staleTime},...r?.refetchOnMount===void 0?{}:{refetchOnMount:r.refetchOnMount}})}function li(e,t){return x({queryKey:t?[t,`runs`,`diff`,e??``]:W.runs.diff(e??``),queryFn:({signal:n})=>jt(e,{signal:n,...t?{projectId:t}:{}}),enabled:!!e})}function ui(e,t=!1){return $(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/changes`:void 0,W.runs.changes(e??``),K(t?4e3:!1)),x({queryKey:W.runs.changes(e??``),queryFn:({signal:t})=>Nt(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function di(e,t){return x({queryKey:W.runs.file(e??``,t??``),queryFn:({signal:n})=>be(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function fi(e,t){return x({queryKey:[n(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>Ot(e,t,{signal:n}),enabled:t!==null,retry:!1})}function pi(e,t){return x({queryKey:[n(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>Ze(e,t,{signal:n}),enabled:t!==null,retry:!1})}function mi(e,t){return x({queryKey:[n(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>Ye(e,t,{signal:n}),enabled:t!==null,retry:!1})}function hi(e){return x({queryKey:[n(),`runs`,`artifacts`,e],queryFn:({signal:t})=>Fe(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function gi(e,t=!1){return $(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/commits`:void 0,W.runs.commits(e??``),K(t?5e3:!1)),x({queryKey:W.runs.commits(e??``),queryFn:({signal:t})=>l(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function _i(e,t){return x({queryKey:W.runs.commit(e??``,t??``),queryFn:({signal:n})=>ve(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function vi(e,t=!0){return x({queryKey:W.runs.handoff(e??``),queryFn:({signal:t})=>p(I(e),{signal:t}),enabled:!!e&&t})}function yi(e,t,n){return x({queryKey:e===void 0?W.runs.handoff(t):[e,`runs`,`handoff`,t],queryFn:({signal:n})=>p(I(t,{projectId:e}),{signal:n}),enabled:n,staleTime:15e3})}function bi(e,t){let r=[...new Set(e)],i=N({queries:r.map(e=>({queryKey:[e??n(),`automations`,`names`],queryFn:({signal:t})=>Tt({signal:t,archived:`include`,...e===void 0?{}:{projectId:e}}),enabled:t,staleTime:6e4,retry:!1}))}),a=i.map(e=>e.data);return(0,M.useMemo)(()=>{let e=new Map;return a.forEach((t,n)=>{if(t?.available)for(let i of t.automations)e.set(JSON.stringify([r[n]??null,i.id]),i.name)}),(t,n)=>e.get(JSON.stringify([t??null,n]))},[JSON.stringify([r,i.map(e=>e.dataUpdatedAt)])])}function xi(e){let t=b();return P({mutationFn:t=>ce(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:W.runs.all})})}function Si(e){let t=b();return P({mutationFn:t=>me(e,t),onSuccess:()=>t.invalidateQueries({queryKey:W.runs.all})})}function Ci(e){let t=Q(),n=e?.projectId,r=e?.cacheScope,i=P({mutationFn:e=>v(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),a=(0,M.useCallback)(e=>({...I(e,{projectId:n,cacheScope:r}),id:e}),[n,r]),o=(0,M.useCallback)(e=>({onSuccess:(t,n,r,i)=>e?.onSuccess?.(t,n.id,r,i),onError:(t,n,r,i)=>e?.onError?.(t,n.id,r,i),onSettled:(t,n,r,i,a)=>e?.onSettled?.(t,n,r.id,i,a)}),[]),{mutate:s,mutateAsync:c}=i,l=(0,M.useCallback)((e,t)=>s(a(e),o(t)),[s,a,o]),u=(0,M.useCallback)((e,t)=>c(a(e),o(t)),[c,a,o]);return{...i,variables:i.variables?.id,mutate:l,mutateAsync:u}}function wi(){let e=Q();return P({mutationFn:e=>v(I(e),!1),onMutate:t=>e.patchRead(()=>I(t),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function Ti(e){let t=Q();return P({mutationFn:({id:t,pinned:n})=>zt(I(t,e),n),onError:e=>lt(`Could not update pin. ${e.message} Please retry.`,{tone:`danger`}),onMutate:()=>e??F(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function Ei(e,t){let n=Q();return P({mutationFn:n=>De(I(e,{projectId:t}),n),onMutate:()=>F({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`send`,r),onError:(e,t,r)=>{e instanceof g&&e.status===409&&r&&n.invalidateAfter(`send`,r)}})}function Di(e,t){let n=Q();return P({mutationFn:(n={})=>pt(I(e,{projectId:t}),n),onMutate:()=>F({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`continue`,r)})}function Oi(e){let t=b();return P({mutationFn:({msgId:t,message:n})=>We(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:W.runs.all})})}function ki(e){let t=b();return P({mutationFn:t=>Te(e,t),onSuccess:()=>t.invalidateQueries({queryKey:W.runs.all})})}function Ai(){return x({queryKey:W.workflows,queryFn:({signal:e})=>u({signal:e})})}function ji(e){return x({queryKey:e?[e,`repo`]:W.repo,queryFn:({signal:t})=>ze({signal:t},e)})}function Mi(e){return x({queryKey:[e,`repo`],queryFn:({signal:t})=>ze({signal:t},e)})}function Ni(){return x({queryKey:W.repoBranches,queryFn:({signal:e})=>Mt({signal:e})})}function Pi(){return x({queryKey:W.repoChanges,queryFn:({signal:e})=>he({signal:e}),retry:!1})}function Fi(e){return x({queryKey:W.repoCommit(e??``),queryFn:({signal:t})=>c(e,{signal:t}),enabled:!!e,retry:!1})}function Ii(e){return x({queryKey:e?[e,`config`]:W.config,queryFn:({signal:t})=>Pt({signal:t,...e?{projectId:e}:{}})})}function Li(){return x({queryKey:W.worktrees,queryFn:({signal:e})=>le({signal:e})})}function Ri(e){return x({queryKey:[e,`worktrees`],queryFn:({signal:t})=>le({signal:t},e),staleTime:0})}function zi(e,t=!0,n=!1){return x({queryKey:[F({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>f({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:pe(e.sidebarLimits)},enabled:t})}function Bi(){return zi(n())}function Vi(){return x({queryKey:W.agentConfig,queryFn:({signal:e})=>ot({signal:e})})}function Hi(e){return x({queryKey:W.agentConfigFile(e??``),queryFn:({signal:t})=>Xe(e,{signal:t}),enabled:e!==null})}function Ui(){return x({queryKey:W.sessionContext,queryFn:({signal:e})=>ye({signal:e})})}function Wi(e,t,n=``){return x({queryKey:W.sessionContextPreview(e,t,n),queryFn:({signal:n})=>$e({content:e,role:t},{signal:n}),placeholderData:At,staleTime:0,retry:!1})}function Gi(){let e=b();return P({onMutate:()=>({fileKey:W.sessionContext}),mutationFn:e=>m(e),onSuccess:(t,n,r)=>{r&&e.setQueryData(r.fileKey,t)}})}function Ki(e){let t=b(),n=W.agentConfig,r=W.agentConfigFile(e);return P({mutationFn:t=>se(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}var qi=A([`passing`,`failing`,`pending`]).nullable(),Ji=S({kind:A([`issue`,`pr`]),number:j(),title:O(),author:O(),createdAt:O(),labels:E(O()),body:O().optional(),url:O(),comments:j(),assignees:E(O()).optional(),projectIds:E(O()).optional(),isDraft:D().optional(),additions:j().optional(),deletions:j().optional(),checks:qi.optional()});C(`available`,[S({available:T(!0),item:Ji.nullable(),labelColors:w(O(),O()).optional()}),S({available:T(!1),reason:O()})]),S({kind:A([`issue`,`pr`]),number:Bt().int().positive().safe()});var Yi=S({id:O(),title:O(),url:O()});S({available:D(),reason:O().optional(),repo:O().optional(),syncedAt:O().optional(),issues:E(Ji),prs:E(Ji),labelColors:w(O(),O()).optional(),viewerLogin:O().optional(),projects:E(Yi).optional(),projectsReason:O().optional(),projectsState:A([`refreshing`,`ready`,`unavailable`]).optional(),projectsGeneration:O().optional(),issuesTotal:j().int().nonnegative().optional(),prsTotal:j().int().nonnegative().optional(),issuesNextCursor:O().nullable().optional(),prsNextCursor:O().nullable().optional(),commentsDeferred:T(!0).optional()});var Xi=O().min(1).max(2e3).optional();S({limit:O().optional(),refresh:O().optional(),issuesCursor:Xi,prsCursor:Xi,issuesDone:T(`1`).optional(),prsDone:T(`1`).optional()}).superRefine((e,t)=>{e.issuesDone&&e.issuesCursor&&t.addIssue({code:`custom`,message:`issuesDone and issuesCursor are exclusive`}),e.prsDone&&e.prsCursor&&t.addIssue({code:`custom`,message:`prsDone and prsCursor are exclusive`}),e.issuesDone&&e.prsDone&&t.addIssue({code:`custom`,message:`both sides are done; there is no page to ask for`})}),S({kind:A([`issue`,`pr`]),numbers:O().regex(/^[1-9]\d{0,15}(,[1-9]\d{0,15})*$/).refine(e=>{let t=e.split(`,`);return t.length<=100&&t.every(e=>Number.isSafeInteger(Number(e)))},{message:`at most 100 safe positive integers`}),refresh:T(`1`).optional()}),C(`available`,[S({available:T(!0),counts:w(j(),j().int().nonnegative())}),S({available:T(!1),reason:O()})]),C(`available`,[S({available:T(!0),checks:w(j(),qi)}),S({available:T(!1),reason:O()})]),S({kind:A([`issue`,`pr`]),q:O().trim().min(1).max(256),limit:Bt().int().positive().max(50).optional()}),S({available:D(),projectsReason:O().optional(),reason:O().optional(),items:E(Ji),truncated:D().optional(),labelColors:w(O(),O()).optional()});var Zi=j().nullable();C(`available`,[S({available:T(!0),prs:w(j(),Pe),issues:w(j(),Pe),conflicts:E(j()).optional(),recheckAfterMs:Zi}),S({available:T(!1),reason:O(),recheckAfterMs:Zi})]);var Qi=S({id:j(),author:O(),avatarUrl:O().optional(),createdAt:O(),body:O(),kind:A([`comment`,`review`]),reviewState:A([`approved`,`changes_requested`,`commented`,`dismissed`]).optional(),url:O()}),$i=A([`committed`,`labeled`,`unlabeled`,`assigned`,`unassigned`,`merged`,`closed`,`reopened`,`head_ref_force_pushed`,`cross-referenced`,`renamed`]),ea=S({id:O(),kind:$i,actor:O(),avatarUrl:O().optional(),createdAt:O(),url:O().optional(),sha:O().optional(),message:O().optional(),checks:qi.optional(),label:S({name:O(),color:O().optional()}).optional(),subject:O().optional(),refNumber:j().optional(),refTitle:O().optional(),refIsPr:D().optional()});S({available:D(),reason:O().optional(),comments:E(Qi),truncated:D().optional(),events:E(ea).optional(),detail:S({body:O(),additions:j().int().nonnegative().optional(),deletions:j().int().nonnegative().optional()}).optional()});var ta=A([`merge`,`squash`,`rebase`]),na=S({name:O(),state:A([`passing`,`failing`,`pending`,`unknown`]),required:D().nullable(),url:O().optional()}),ra=S({number:j(),title:O(),url:O(),state:A([`open`,`closed`,`merged`]),isDraft:D(),headRef:O(),baseRef:O(),headSha:O(),mergeable:A([`mergeable`,`conflicting`,`unknown`]),reviewDecision:A([`approved`,`changes-requested`,`review-required`,`not-required`,`unknown`]),checks:E(na),methods:E(ta),defaultMethod:ta.nullable(),eligibility:A([`ready`,`blocked`,`pending`,`unauthorized`,`terminal`,`unknown`]),blockers:E(S({code:O(),message:O()})),canMerge:D(),canOverride:D()});C(`available`,[S({available:T(!0),mergeState:ra}),S({available:T(!1),reason:O()})]),S({merged:T(!0),number:j(),url:O(),method:ta,mergeCommitSha:O().optional()});var ia=S({path:O(),previousPath:O().optional(),status:A([`added`,`modified`,`removed`,`renamed`,`copied`,`changed`]),additions:j(),deletions:j(),patch:O().optional(),patchUnavailableReason:A([`binary`,`too-large`,`not-provided`]).optional(),truncated:D().optional()});C(`available`,[S({available:T(!0),number:j(),headSha:O(),files:E(ia),additions:j(),deletions:j(),truncated:D(),reason:O().optional()}),S({available:T(!1),reason:O()})]),S({generation:O().uuid()}),C(`state`,[S({generation:O().uuid(),state:T(`ready`),projects:E(Yi),membership:w(O(),E(O()))}),S({generation:O().uuid(),state:T(`unavailable`),reason:O()})]);function aa(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 oa(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function sa(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function ca(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){sa(t.issues,a,r),sa(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 la=e=>e.map(e=>e.number).join(`,`);function ua(e,t){let n=e[0];if(e.length>1&&n&&(la(n.issues)!==la(t.issues)||la(n.prs)!==la(t.prs)||n.issuesTotal!==t.issuesTotal||n.prsTotal!==t.prsTotal))return`refetch`;let r=t;if(n&&t.available&&t.projectsState===`refreshing`&&n.repo===t.repo){let e=new Map(n.issues.map(e=>[e.number,e.projectIds]));r={...t,issues:t.issues.map(t=>{let n=e.get(t.number);return t.projectIds===void 0&&n!==void 0?{...t,projectIds:n}:t})}}return[r,...e.slice(1)]}function da(e={},t=!0){let r=b(),i=W.github(e);$(`/api/v1/p/${n()}/github${e.limit===void 0?``:`?limit=${e.limit}`}`,i,K(t?6e4:!1));let a=x({queryKey:W.github(e),queryFn:({signal:t})=>xe({limit:e.limit},{signal:t}),enabled:t,staleTime:6e4,refetchInterval:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0}),o=a.data?.projectsGeneration,s=x({queryKey:[...i,`projects`,o],queryFn:({signal:e})=>Oe(o,{signal:e}),enabled:t&&a.data?.projectsState===`refreshing`&&!!o,staleTime:1/0,retry:!1});return(0,M.useEffect)(()=>{!o||!s.data&&!s.error||r.setQueryData(i,e=>{if(!e||e.projectsGeneration!==o||e.projectsState!==`refreshing`)return e;let t=s.data;return t?.generation&&t.generation!==o?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,o,s.data,s.error,i]),a}var fa=class extends Error{};function pa(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await xe({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new fa(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>aa(e),retry:(e,t)=>!(t instanceof fa)&&!(t instanceof g&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function ma(e=50,t=!0){let r=b(),i=W.githubPages(e),a=W.githubPagesHead(e);$(`/api/v1/p/${n()}/github?limit=${e}`,a,K(t?6e4:!1));let o=vt({...pa(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),s=x({queryKey:a,queryFn:({signal:t})=>xe({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:c}=o;(0,M.useEffect)(()=>{if(!s.data)return;let e=r.getQueryData(i);if(!e||e.pages.length===0)return;let t=ua(e.pages,s.data);t===`refetch`?c():r.setQueryData(i,{...e,pages:t})},[r,s.dataUpdatedAt,c]);let l=(o.data?.pages??[]).flatMap(e=>e.projectsState===`refreshing`&&e.projectsGeneration?[e.projectsGeneration]:[]),u=N({queries:l.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>Oe(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,M.useEffect)(()=>{u.forEach((e,t)=>{let n=l[t];!n||!e.data&&!e.error||r.setQueryData(i,t=>{if(!t)return t;let r=!1,i=t.pages.map(t=>{if(t.projectsGeneration!==n||t.projectsState!==`refreshing`)return t;let i=e.data;return i?.generation&&i.generation!==n?t:(r=!0,i?.state===`ready`?{...t,projectsState:`ready`,projects:i.projects,issues:t.issues.map(e=>({...e,projectIds:i.membership?.[e.number]??[]}))}:{...t,projectsState:`unavailable`,projectsReason:i?.reason??`Project boards unavailable. Refresh to try again.`})});return r?{...t,pages:i}:t})})},[r,u.map((e,t)=>e.data||e.error?l[t]:``).join(`,`)]),{pages:o,data:(0,M.useMemo)(()=>ca(o.data?.pages??[]),[o.data])}}function ha(e,t=50,n=!0){let r=vt({...pa([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,M.useMemo)(()=>ca(r.data?.pages??[]),[r.data])}}function ga(e,t,n=!0){let r=N({queries:t.filter(e=>e.length>0).map(t=>({queryKey:W.githubCommentCounts(e,t),queryFn:({signal:n})=>_(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,M.useMemo)(()=>{let e={};for(let t of r)t.data?.available&&Object.assign(e,t.data.counts);return e},[r.map(e=>e.dataUpdatedAt).join(`,`)])}function _a(e,t,n,r=!0){return x({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>ue(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function va(e,t=!0){return x({queryKey:W.githubChecks(e),queryFn:({signal:t})=>Ee(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function ya(e,t,n=!0){return x({queryKey:W.githubSearch(e,t),queryFn:({signal:n})=>ue(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var ba=100;function xa(e){return[...e].sort((e,t)=>t-e).slice(0,ba).sort((e,t)=>e-t)}function Sa(){let e=Ie(),t=Ur();return e.projectId??t.data?.bootProject}function Ca(e){for(let[t,n]of Object.entries(e)){for(let[e,r]of Object.entries(n.prs))tr(U({projectId:t,kind:`PR`,number:Number(e)}),r);for(let[e,r]of Object.entries(n.issues))tr(U({projectId:t,kind:`Issue`,number:Number(e)}),r)}}var wa=5*6e4;function Ta(e){return e?e.recheckAfterMs:wa}function Ea(e,t=!0){let n=(0,M.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.projectId)??{prs:new Set,issues:new Set};e[n.kind===`PR`?`prs`:`issues`].add(n.number),t.set(n.projectId,e)}return[...t.entries()].map(([e,t])=>({projectId:e,prs:xa(t.prs),issues:xa(t.issues)}))},[e.map(U).sort().join(`|`)]),r=N({queries:n.map(e=>({queryKey:W.githubRefStatus(e.projectId,e.prs,e.issues),queryFn:({signal:t})=>je(e.projectId,{prs:e.prs,issues:e.issues},{signal:t}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>Ta(e.state.data)??1/0,refetchInterval:!1,refetchOnWindowFocus:!0}))}),i=b(),a=JSON.stringify(n.map((e,t)=>({...e,interval:Ta(r[t]?.data)??!1})));(0,M.useEffect)(()=>{if(!t||fr())return;let e=!0,n=JSON.parse(a).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=W.githubRefStatus(t.projectId,t.prs,t.issues);return Qr({path:`/api/v1/p/${t.projectId}/github/ref-status?${n}`,intervalMs:t.interval},(t,n)=>{n||i.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&i.setQueryData(r,t)})})});return()=>{e=!1;for(let e of n)e()}},[t,a,i]);let o=(0,M.useMemo)(()=>dr(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,M.useCallback)(e=>{let t=U(e),n=o.get(t);if(n)return n;let r=V.get(t);return{state:`idle`,...r?{status:r}:{},...H.has(t)?{conflicting:!0}:{}}},[o])}function Da(e,t,n=!0){return x({queryKey:W.githubComments(e,t),queryFn:({signal:n})=>ne(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Oa(e,t,n=!0){return x({queryKey:W.githubItem(e,t),queryFn:({signal:n})=>ht(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function ka(e){return x({queryKey:W.githubPrChanges(e??0),queryFn:({signal:t})=>ee(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{li as $,Vn as $t,Ai as A,br as At,fi as B,hr as Bt,ji as C,vr as Ct,Ui as D,Pr as Dt,Fi as E,Cr as Et,hi as F,kr as Ft,Si as G,G as Gt,wi as H,K as Ht,bi as I,Kr as It,ki as J,qn as Jt,Ti as K,Yn as Kt,Di as L,Gr as Lt,ni as M,jr as Mt,pi as N,Nr as Nt,Wi as O,wr as Ot,mi as P,Tr as Pt,gi as Q,B as Qt,ai as R,_r as Rt,Gi as S,xr as St,Pi as T,yr as Tt,xi as U,fr as Ut,Ci as V,pr as Vt,ei as W,W as Wt,ui as X,Wn as Xt,si as Y,Hn as Yt,_i as Z,Bn as Zt,Ii as _,Sr as _t,Da as a,L as an,ri as at,Ri as b,Hr as bt,ka as c,Zt as cn,Qr as ct,_a as d,P as dn,qr as dt,Kn as en,di as et,Sa as f,N as fn,zr as ft,Hi as g,Or as gt,Vi as h,Br as ht,ga as i,Tn as in,ii as it,Li as j,Fr as jt,Bi as k,Ar as kt,ya as l,F as ln,Q as lt,oa as m,Wt as mn,Mr as mt,da as n,Un as nn,oi as nt,Oa as o,en as on,Ei as ot,Ea as p,Gt as pn,Lr as pt,ci as q,Zn as qt,va as r,zn as rn,ti as rt,ma as s,Qt as sn,yi as st,Ca as t,Gn as tn,vi as tt,ha as u,I as un,Ir as ut,Mi as v,Vr as vt,Ni as w,Rr as wt,Ki as x,Wr as xt,zi as y,Ur as yt,Oi as z,mr as zt};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{c as n,o as r}from"./utils-DSMR_WLb.js";import{$t as i,At as a,Bn as o,Br as s,C as c,Ct as l,D as u,Di as d,E as f,Et as p,F as m,Fi as h,Fn as g,G as _,Gt as v,In as y,J as ee,Jt as te,K as ne,Kr as re,Kt as ie,Ln as ae,Mi as oe,N as se,Nt as ce,O as le,Q as ue,Qt as de,Rn as fe,Rr as pe,Rt as me,S as he,Si as ge,Sr as _e,St as ve,T as ye,Tt as be,U as xe,Ut as Se,Vn as Ce,Vr as we,Vt as Te,W as Ee,Wt as De,X as Oe,Xt as ke,Yt as Ae,Z as je,Zt as Me,_n as Ne,_r as Pe,_t as Fe,a as Ie,ai as Le,an as Re,b as ze,bt as Be,ci as Ve,di as He,dn as Ue,dt as We,fi as Ge,fn as Ke,gi as qe,gn as Je,gt as Ye,h as Xe,hi as b,ht as Ze,ii as x,in as Qe,j as $e,ji as et,jt as tt,ki as nt,kt as rt,li as it,ln as at,m as ot,mn as st,mt as ct,n as lt,nn as ut,oi as dt,on as ft,ot as pt,pn as mt,q as ht,qr as gt,qt as _t,ri as vt,rn as yt,si as bt,ti as xt,tn as St,ui as Ct,un as wt,v as Tt,vi as Et,vn as Dt,vt as Ot,w as kt,wi as At,wt as jt,x as Mt,xt as Nt,y as Pt,yi as Ft,yn as It,yt as Lt,zn as Rt,zt}from"./toaster-B0kvcFif.js";import{A as Bt,B as S,F as C,H as w,I as T,N as E,P as D,W as O,Z as k,a as Vt,j as A,z as j}from"./live-protocol-DMhTnCmf.js";function Ht(e,t){return e??t}function Ut(e,t){let n=Ht(e,t);return n===`1`||n===`true`}function Wt(e,t,n){return e?.trim()||Ht(t,n)||``}var Gt=class extends Et{#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||Kt(),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=Ft({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),k.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Kt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var qt=class extends h{#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),et(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&ge(t.mutationKey)!==ge(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??Kt();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){k.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 Jt(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Yt(e,t,n){let r=e.slice(0);return r[t]=n,r}var Xt=class extends h{#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,k.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||!et(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Jt(e,n).forEach(e=>{e.destroy()}),Jt(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=nt(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 qe(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Yt(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)&&k.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},M=e(t(),1);function N({queries:e,...t},n){let r=b(n),i=Ge(),a=He(),o=M.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{Le(e);let t=r.getQueryCache().get(e.queryHash);Ve(e,a,t)}),Ct(a);let[s]=M.useState(()=>new Xt(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),f=!i&&t.subscribed!==!1;M.useSyncExternalStore(M.useCallback(e=>f?s.subscribe(k.batchCalls(e)):d,[s,f]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),M.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let p=c.some((e,t)=>bt(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&bt(n,e)?dt(n,new qe(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=c.find((e,t)=>{let n=o[t];return n&&it({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 P(e,t){let n=b(t),[r]=M.useState(()=>new qt(n,e));M.useEffect(()=>{r.setOptions(e)},[r,e]);let i=M.useSyncExternalStore(M.useCallback(e=>r.subscribe(k.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=M.useCallback((e,t)=>{r.mutate(e,t).catch(d)},[r]);if(i.error&&oe(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function F(e={}){let t=e.projectId??n();return{projectId:t,cacheScope:e.cacheScope??(e.boot?`default`:t)}}function I(e,t={}){return{...F(t),runId:e}}function Zt(e,t=!0,n=!1,r){return x({queryKey:[F({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>a(F({projectId:e,boot:n}),{signal:t}),enabled:t,...r?{select:r}:{},placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function L(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:G.models(t),refetchType:n})}function Qt(e,t=!0,n){return x({...$t(e,n),enabled:t})}var $t=(e,t)=>({queryKey:G.models(e,t),queryFn:({signal:n})=>Ce(e,{signal:n},t),staleTime:300*1e3});function en(e,t=!0){let n=N({queries:e.map(e=>({...$t(e),enabled:t}))});return Object.fromEntries(e.map((e,t)=>[e,n[t]]))}function tn(e,t){return JSON.stringify([e,t])}function nn(e){return e.type===`run`?e.run.id:e.id}function R(e,t){return{...e,runs:t}}function rn(e,t){let n=0;for(let r of e)r.projectId===t&&r.archived&&(n+=1);return n}var an=class{runs;copied=!1;positions=new Map;constructor(e){this.runs=e,this.reindex()}reindex(){this.positions.clear(),this.runs.forEach((e,t)=>this.positions.set(tn(e.projectId,e.id),t))}at(e,t){return this.positions.get(tn(e,t))??-1}mutable(){return this.copied||=(this.runs=[...this.runs],!0),this.runs}replace(e,t){return this.mutable()[e]=t,this.runs}remove(e){return this.mutable().splice(e,1),this.reindex(),this.runs}insert(e){let t=this.runs.findIndex(t=>(t.createdAt??``).localeCompare(e.createdAt)<0);return this.mutable().splice(t<0?this.runs.length:t,0,e),this.reindex(),this.runs}};function on(e,t,n){let r=new an(e.runs),i=e,a=!1;for(let e of t)if(e.type===`usage`)i=fn(i,e.project,e.usage,r);else{let t=ln(i,e.change,n,r);i=t.index,a||=t.reconcile}return{index:i,reconcile:a}}function sn(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function cn(e,t,n){return ln(e,t,n,new an(e.runs))}function ln(e,t,n,r){let{project:i}=t,a=r.at(i,nn(t)),o=a>=0?e.runs[a]:void 0,s=e.truncated.includes(i);if(t.type===`deleted`)return o?{index:R(e,r.remove(a)),reconcile:s&&o.archived}:{index:e,reconcile:!1};let{run:c}=t;if(c.delegation?.role===`worker`)return o?{index:R(e,r.remove(a)),reconcile:!1}:{index:e,reconcile:!1};if(!o&&!sn(e,i,n))return{index:e,reconcile:!0};let l=nt(o,{projectId:i,...c});if(o){if(l===o)return{index:e,reconcile:!1};let t=r.replace(a,l),n=o.archived!==l.archived&&(s||rn(t,i)>e.perProjectLimit);return{index:R(e,t),reconcile:n}}if(s)return dn(e,l,r);let u=r.insert(l);return{index:R(e,u),reconcile:l.archived&&rn(u,i)>e.perProjectLimit}}function un(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 dn(e,t,n){let r=un(e.runs,t.projectId),i=r!==void 0&&t.createdAt>r;return t.archived&&!i?{index:e,reconcile:!1}:{index:R(e,n.insert(t)),reconcile:t.archived||r===void 0||t.createdAt<r}}function fn(e,t,n,r){let i=!1;return e.runs.forEach((e,a)=>{if(e.projectId!==t)return;let o=n[e.id];if(o){let t=nt(e.usage,o);if(t===e.usage)return;r.replace(a,{...e,usage:t})}else{if(e.usage===void 0)return;let{usage:t,...n}=e;r.replace(a,n)}i=!0}),i?R(e,r.runs):e}function pn(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 mn(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function hn(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 gn(e){e.stream=void 0}function _n(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,nn(t)]),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}function vn(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function yn(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function bn(e,t,n){if(!yn(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=cn(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`],xn=[`workspace`,`projects`],Sn=6e4,Cn=100,wn=new WeakMap;function Tn(e){let t=wn.get(e);return t||(t=An(e),wn.set(e,t)),t}function En(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:Tn(t).merge(e)}function Dn(e){let t=e.getQueryData(xn)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function On(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 kn(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 An(e){let t=mn(),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=Dn(e),{index:s,reconcile:c}=on(a,t.filter(e=>e.generation===a.generation?e.type===`usage`?!l.has(e.project):!l.has(e.change.project)&&e.change.seq>a.eventSeq:!1),o);s!==a&&m(s),c&&_({hold:!0})},y=()=>{if(i!==void 0)return;let e=c+250-Date.now();if(e>0){i=setTimeout(v,e);return}i=setTimeout(v,Cn),typeof requestAnimationFrame==`function`&&(r=requestAnimationFrame(v))};return{ready(e,n){hn(t,e,n),u=!1,f&&(f=!1,_({hold:!0}))},detach(){gn(t)},run(e,r,i=!1){if(l.has(e))return;let a=kn(e,r);if(!_n(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),vn(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let r=h();if(!r)return;let i=pn(r,e);i!==r&&m(i)},setUnknownGenerationHandler(e){d=e},restoreProject(e){l.delete(e)},merge(n){let r=h(),i=bn(t,n,Dn(e));for(let e of l)i.index=pn(i.index,e);return i.reconcile&&queueMicrotask(()=>{_({hold:!0})}),On(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 jn=A([`own`,`provider-spanning`]),Mn=S({suggested:E(S({id:O(),label:O(),desc:O()})),retired:E(O())}),Nn=S({id:A([`settings`,`mcp`,`memory`]),label:O(),note:O().optional(),empty:O().optional(),showsUserMcp:T(!0).optional()}),Pn=S({label:O(),note:O().optional(),groups:E(Nn)}),Fn=S({runners:E(S({id:xt,displayName:O(),modelListName:O(),modelIdScope:jn,pickerLabel:O(),pickerDescription:O(),icon:O(),installHint:O(),loginCommand:O(),terminalLogin:D().optional(),browserLogin:D().optional(),managedInstall:T(!0).optional(),accountFolderExample:O().optional(),models:Mn,agentConfig:Pn}))}),In=[`workspace`,`runners`];async function Ln(e){return o(await y.api.v1.runners.$get({},ae(e)),`/runners`,Fn)}var Rn={queryKey:In,queryFn:({signal:e})=>Ln({signal:e}),staleTime:1/0};function zn(){return x(Rn)}function Bn(e){return e?.runners??[]}function Vn(e){return Bn(e).map(e=>e.id)}function Hn(e,t){if(e!==void 0)return t.includes(e)?e:t[0]}function Un(e){let t=zn();return{runner:t.isSuccess?Hn(e,Vn(t.data))??e:e,ready:!t.isPending}}function B(e,t){return e?.runners.find(e=>e.id===t)}function Wn(e,t){return B(e,t)?.displayName??t}function Gn(e,t){return B(e,t)?.pickerLabel??t}function Kn(e,t){return B(e,t)?.modelListName}function qn(e,t,r=!0){let i=Ii(),a=Ur(),{runner:o,ready:s}=Un(e??i.data?.defaultRunner??`claude`),c=a.data?.capabilities?.localHandoff===!1?null:t,l=n(),u=x({queryKey:W.runnerSkills(o,c),queryFn:({signal:e})=>kt(o,c,{signal:e,projectId:l}),enabled:r&&s&&(e!==void 0||!i.isPending)&&(!t||!a.isPending),retry:!1});return{...u,runner:o,account:c,data:u.data?.skills,list:u.data,unchecked:u.isError||!u.data||u.data.source===`unavailable`}}var Jn={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`}},Yn={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function Xn(e){return typeof e==`string`&&Object.hasOwn(Jn,e)}function Zn(e){return e!==void 0&&Xn(e)?Jn[e]:void 0}var Qn=`cez.reference-statuses.v1`,$n=`cez.reference-conflicts.v1`,V=new Map(rr()),er=1e3;function tr(e,t){if(V.get(e)!==t){for(V.delete(e),V.set(e,t);V.size>er;){let e=V.keys().next().value;if(e===void 0)break;V.delete(e)}or()}}var H=new Set(ir());function nr(e,t){if(H.has(e)!==t){if(t)for(H.add(e);H.size>er;){let e=H.values().next().value;if(e===void 0)break;H.delete(e)}else H.delete(e);or()}}function rr(){try{let e=globalThis.sessionStorage?.getItem(Qn);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`&&Xn(e[1])):[]}catch{return[]}}function ir(){try{let e=globalThis.sessionStorage?.getItem($n);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var ar;function or(){ar===void 0&&(ar=setTimeout(()=>{ar=void 0;try{globalThis.sessionStorage?.setItem(Qn,JSON.stringify([...V])),globalThis.sessionStorage?.setItem($n,JSON.stringify([...H]))}catch{}},250))}var U=e=>`${e.projectId}\u0000${e.kind}#${e.number}`;function sr(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function cr(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 lr(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;tr(t,o),s!==void 0&&nr(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function ur(e,t,n){let r=U(t),i=V.get(r),a=H.has(r)?!0:void 0,o=n.data;if(o?.available){lr(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...sr(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...sr(i,a)});return}e.set(r,{state:`loading`,...sr(i,a)})}function dr(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of cr(i))ur(n,e,t)}),n}var W={get health(){return[n(),`health`]},runs:{get all(){return[n(),`runs`]},relationships:e=>[n(),`runs`,`relationships`,e],list:(e=n())=>[e,`runs`,`list`],archived:e=>[n(),`runs`,`archived`,e],detail:(e,t=n())=>[t,`runs`,`detail`,e],diff:e=>[n(),`runs`,`diff`,e],changes:e=>[n(),`runs`,`changes`,e],file:(e,t)=>[n(),`runs`,`files`,e,t],handoff:e=>[n(),`runs`,`handoff`,e],commits:e=>[n(),`runs`,`commits`,e],commit:(e,t)=>[n(),`runs`,`commit`,e,t]},get workflows(){return[n(),`workflows`]},runnerSkills:(e,t)=>[n(),`runner-skills`,e,t??null],get repo(){return[n(),`repo`]},get repoChanges(){return[n(),`repo`,`changes`]},repoCommit:e=>[n(),`repo`,`commit`,e],get repoBranches(){return[n(),`repo`,`branches`]},get uiState(){return[n(),`ui-state`]},get config(){return[n(),`config`]},get agentConfig(){return[n(),`agent-config`]},agentConfigFile:e=>[n(),`agent-config`,`file`,e],get sessionContext(){return[n(),`session-context`]},sessionContextPreview:(e,t,r=``)=>[n(),`session-context`,`preview`,t,e,r],get worktrees(){return[n(),`worktrees`]},github:(e={})=>[n(),`github`,e.limit??null],githubPages:e=>[n(),`github`,`pages`,e],githubPagesHead:e=>[n(),`github`,`pages-head`,e],githubCommentCounts:(e,t)=>[n(),`github`,`comment-counts`,e,[...t].sort((e,t)=>e-t).join(`,`)],githubChecks:e=>[n(),`github`,`checks`,[...e].sort((e,t)=>e-t).join(`,`)],githubSearch:(e,t)=>[n(),`github`,`search`,e,t],githubRefStatus:(e,t,n)=>[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`]}},G={models:(e,t)=>t&&t!=="default"?[`workspace`,`models`,e,t]:[`workspace`,`models`,e],providerStatus:[`workspace`,`providers`,`status`],projects:[`workspace`,`projects`],githubOwners:[`workspace`,`github-owners`],runsIndex:z,runsSearch:e=>[`workspace`,`runs-search`,e],uiState:[`workspace`,`ui-state`],config:[`workspace`,`config`],agentProfiles:[`workspace`,`agent-profiles`],agentAccountStatus:e=>[`workspace`,`agent-profiles`,`status`,e],fsBrowseRoot:[`workspace`,`fs-browse`],fsBrowse:(e,t=!1)=>[...G.fsBrowseRoot,e,t]};function fr(){return Ut(void 0,void 0)}function K(e){return!fr()&&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 mr(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 hr(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 gr(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 _r(e,t){return gt({kind:`topic`,topic:e},{value:t})}function vr(){let e=b();return x({queryKey:G.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(G.providerStatus),r=await Qe(!1,{signal:t});return _e(n,e.getQueryData(G.providerStatus),r)},staleTime:5*6e4,refetchInterval:K(!1),refetchOnWindowFocus:!0})}function yr(){let e=b();return P({mutationFn:()=>Qe(!0),onMutate:()=>e.getQueryData(G.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(G.providerStatus,e=>_e(r,e,t)),L(e)}})}function br(){let e=b();return P({mutationFn:({provider:e,authFailureId:t})=>mt(e,t),onMutate:()=>e.getQueryData(G.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(G.providerStatus,e=>_e(r,e,t,n.authFailureId)),L(e,n.provider)}})}function xr(e={}){return x({queryKey:G.projects,queryFn:({signal:e})=>yt({signal:e}),...e})}function Sr(e,t=!1){return x({queryKey:G.fsBrowse(e,t),queryFn:({signal:n})=>ie(e??void 0,{signal:n,showHidden:t}),retry:!1})}function Cr(){let e=b();return P({mutationFn:e=>at(e),onSuccess:()=>e.invalidateQueries({queryKey:G.projects})})}function wr(){let e=b();return P({mutationFn:e=>Ue(e),retry:!1,onSuccess:()=>{e.invalidateQueries({queryKey:G.projects})}})}function Tr(){let e=b();return P({mutationFn:e=>{let{id:t,...n}=e;return Dt(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:G.projects});let r=e.getQueryData(G.projects);return e.setQueryData(G.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?Er(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(G.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(G.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:G.projects})})}function Er(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?[]:gr(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 Dr(e){let t=b();return P({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(G.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:G.projects})})}function Or(){return Dr(e=>{let{projectId:t,...n}=e;return Me(t,n)})}function kr(){return Dr(e=>{let{projectId:t,webhookId:n,...r}=e;return It(t,n,r)})}function Ar(){return Dr(({projectId:e,webhookId:t})=>Ke(e,t))}function jr(){return P({mutationFn:({projectId:e,webhookId:t})=>Je(e,t),retry:!1})}function q(e){let t=b();return P({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:G.agentProfiles}),t.invalidateQueries({queryKey:G.projects}),t.invalidateQueries({predicate:({queryKey:e})=>e[1]===`runner-skills`}),L(t)])},onError:()=>{t.invalidateQueries({queryKey:W.health}),t.invalidateQueries({queryKey:G.agentProfiles,exact:!0})}})}function Mr(){return q(e=>Ae(e))}function Nr(){return q(e=>{let{id:t,...n}=e;return Ne(t,n)})}function Pr(){return q(e=>wt(e))}function Fr(){return q(e=>st(e))}function Ir(e,t){return x({queryKey:G.agentAccountStatus(e),queryFn:({signal:t})=>de(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function Lr(){let e=b();return P({mutationFn:({provider:e,profileId:t})=>te(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:G.agentProfiles}),e.invalidateQueries({queryKey:G.providerStatus}),L(e,n,`none`)])},onError:()=>{e.invalidateQueries({queryKey:W.health}),e.invalidateQueries({queryKey:G.agentProfiles,exact:!0})}})}function Rr(){let e=b();return P({mutationFn:e=>de(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(G.agentAccountStatus(n),t),e.invalidateQueries({queryKey:G.agentProfiles}),L(e,t.status.provider)}})}function zr(){let e=b();return P({mutationFn:e=>_t(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:G.projects})})}function Br(){let e=b();return P({mutationFn:e=>ke(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:G.projects})})}function Vr({enabled:e}){return x({queryKey:G.githubOwners,queryFn:({signal:e})=>St({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function Hr(){let e=b();(0,M.useEffect)(()=>{let t,n=()=>{let n=e.getQueryData(W.health);n&&(s({bootProject:n.bootProject??`default`,apiBase:r()}),t??=_r(`health`,t=>{e.setQueryData(W.health,t)}))};n();let i=e.getQueryCache().subscribe(n);return()=>{i(),t?.(),re()}},[e])}function Ur(){return x({queryKey:W.health,queryFn:({signal:e})=>ut({signal:e})})}function Wr(e,t){let n=Ur().data,r=xr(t).data?.projects,i=Ie(),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 Gr(){return x({queryKey:G.uiState,queryFn:({signal:e})=>ft({signal:e})})}function Kr(){return x({queryKey:G.config,queryFn:({signal:e})=>Re({signal:e})})}function qr(){return x({queryKey:G.agentProfiles,queryFn:({signal:e})=>i({signal:e})})}var J=[`workspace`,`runs-index`],Y=e=>[e.cacheScope,`runs`,`list`],X=e=>[e.cacheScope,`runs`,`detail`,e.runId],Z=e=>typeof e==`function`?e():e;function Jr(e){let{seenAt:t,...n}=e;return n}function Yr(e,t){let n=Jr(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function Xr(e,t,n){return t?{...e,seenAt:n}:Jr(e)}function Zr(e){let t=()=>{e.invalidateQueries({queryKey:J})};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=we(),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:Y(Z(n))}),await e.cancelQueries({queryKey:X(Z(n))});let i=e.getQueryData(Y(Z(n))),a=e.getQueryData(X(Z(n))),o=Z(n).runId,s=new Date().toISOString();return e.setQueryData(Y(Z(n)),e=>e?.map(e=>e.id===o?Xr(e,r,s):e)),e.setQueryData(X(Z(n)),e=>e&&Xr(e,r,s)),{id:o,prevList:i,prevDetail:a,rollback(){if(!r){i&&e.setQueryData(Y(Z(n)),i),a&&e.setQueryData(X(Z(n)),a);return}let t=i?.find(e=>e.id===o);t&&e.setQueryData(Y(Z(n)),e=>e?.map(e=>e.id===o?Yr(e,t):e)),a&&e.setQueryData(X(Z(n)),e=>e&&Yr(e,a))},settle(i){let a=e=>e.id===(r?o:i.id)?Xr(e,r,i.seenAt):e;e.setQueryData(Y(Z(n)),e=>e?.map(a));let s={...Z(n),runId:r?o:i.id};e.setQueryData(X(s),e=>e?a(e):i),t()}}}async function a(t,n){await e.cancelQueries({queryKey:J});let i=e.getQueryData(J),a=n();return e.setQueryData(J,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(J,i)},settle(){r(`indexed`,t)}}}return{patchRead:i,patchIndex:a,invalidateAfter:r}}function Q(){let e=b();return(0,M.useMemo)(()=>Zr(e),[e])}function Qr(e,t){if(!Vt(e.path))throw Error(`unsupported shared read`);let n=new URL(e.path,`http://cezar.invalid`);return n.searchParams.sort(),gt({kind:`read`,path:`${n.pathname}${n.search}`,intervalMs:e.intervalMs},{value:t})}function $(e,t,n,r){let i=b(),a=JSON.stringify(t),o=(0,M.useMemo)(()=>JSON.parse(a),[a]);(0,M.useEffect)(()=>{if(!e||n===!1)return;let t=!0,a=Qr({path:e,intervalMs:n},(e,n)=>{n||i.cancelQueries({queryKey:o,exact:!0}).then(()=>{t&&i.setQueryData(o,r?r(e,i):e)})});return()=>{t=!1,a()}},[i,e,o,n,r])}async function $r(e,t=!1){return Rt(await y.api.v1.p[`:projectId`].runs[`:id`][`worker-destroy`].$post({param:{projectId:n(),id:encodeURIComponent(e)},query:{},json:t?{discardWork:!0}:{}}),fe(e,`/worker-destroy`))}function ei(){return x({queryKey:W.openTargets,queryFn:({signal:e})=>Lt({signal:e}),staleTime:5*6e4})}function ti(){return x({queryKey:W.runs.list(),queryFn:({signal:e})=>a(F(),{signal:e})})}function ni(e,t){return vt({queryKey:W.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>ct({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 ri(e){let t=e.trim();return x({queryKey:G.runsSearch(t),queryFn:({signal:e})=>Se(t,{signal:e}),enabled:t.length>=2,placeholderData:At,staleTime:1e4})}function ii(e=!0,t=Sn,n){let r=Tn(b());return $(`/api/v1/workspace/runs-index`,G.runsIndex,K(e?t:!1),En),x({queryKey:G.runsIndex,queryFn:({signal:e})=>tt({signal:e}).then(r.merge),enabled:e,...n?{select:n}:{},staleTime:3e4,refetchInterval:!1})}function ai(e){let t=b();return P({mutationFn:({workerId:e,discardWork:t=!1})=>$r(e,t),onSettled:()=>t.invalidateQueries({queryKey:W.runs.relationships(e)})})}function oi(e,t={}){return x({queryKey:W.runs.relationships(e),queryFn:({signal:t})=>rt(e,{signal:t}),enabled:t.enabled??!0})}function si(e){return x({queryKey:W.runs.detail(e??``),queryFn:({signal:t})=>Be(I(e),{signal:t}),enabled:!!e})}function ci(e,t,n=!0,r){return x({queryKey:[e??`default`,`runs`,`detail`,t??``],queryFn:({signal:n})=>Be(I(t,{projectId:e}),{signal:n}),enabled:n&&!!e&&!!t,...r?.staleTime===void 0?{}:{staleTime:r.staleTime},...r?.refetchOnMount===void 0?{}:{refetchOnMount:r.refetchOnMount}})}function li(e,t){return x({queryKey:t?[t,`runs`,`diff`,e??``]:W.runs.diff(e??``),queryFn:({signal:n})=>jt(e,{signal:n,...t?{projectId:t}:{}}),enabled:!!e})}function ui(e,t=!1){return $(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/changes`:void 0,W.runs.changes(e??``),K(t?4e3:!1)),x({queryKey:W.runs.changes(e??``),queryFn:({signal:t})=>Nt(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function di(e,t){return x({queryKey:W.runs.file(e??``,t??``),queryFn:({signal:n})=>be(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function fi(e,t){return x({queryKey:[n(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>Ot(e,t,{signal:n}),enabled:t!==null,retry:!1})}function pi(e,t){return x({queryKey:[n(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>Ze(e,t,{signal:n}),enabled:t!==null,retry:!1})}function mi(e,t){return x({queryKey:[n(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>Ye(e,t,{signal:n}),enabled:t!==null,retry:!1})}function hi(e){return x({queryKey:[n(),`runs`,`artifacts`,e],queryFn:({signal:t})=>Fe(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function gi(e,t=!1){return $(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/commits`:void 0,W.runs.commits(e??``),K(t?5e3:!1)),x({queryKey:W.runs.commits(e??``),queryFn:({signal:t})=>l(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function _i(e,t){return x({queryKey:W.runs.commit(e??``,t??``),queryFn:({signal:n})=>ve(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function vi(e,t=!0){return x({queryKey:W.runs.handoff(e??``),queryFn:({signal:t})=>p(I(e),{signal:t}),enabled:!!e&&t})}function yi(e,t,n){return x({queryKey:e===void 0?W.runs.handoff(t):[e,`runs`,`handoff`,t],queryFn:({signal:n})=>p(I(t,{projectId:e}),{signal:n}),enabled:n,staleTime:15e3})}function bi(e,t){let r=[...new Set(e)],i=N({queries:r.map(e=>({queryKey:[e??n(),`automations`,`names`],queryFn:({signal:t})=>Tt({signal:t,archived:`include`,...e===void 0?{}:{projectId:e}}),enabled:t,staleTime:6e4,retry:!1}))}),a=i.map(e=>e.data);return(0,M.useMemo)(()=>{let e=new Map;return a.forEach((t,n)=>{if(t?.available)for(let i of t.automations)e.set(JSON.stringify([r[n]??null,i.id]),i.name)}),(t,n)=>e.get(JSON.stringify([t??null,n]))},[JSON.stringify([r,i.map(e=>e.dataUpdatedAt)])])}function xi(e){let t=b();return P({mutationFn:t=>ce(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:W.runs.all})})}function Si(e){let t=b();return P({mutationFn:t=>me(e,t),onSuccess:()=>t.invalidateQueries({queryKey:W.runs.all})})}function Ci(e){let t=Q(),n=e?.projectId,r=e?.cacheScope,i=P({mutationFn:e=>v(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),a=(0,M.useCallback)(e=>({...I(e,{projectId:n,cacheScope:r}),id:e}),[n,r]),o=(0,M.useCallback)(e=>({onSuccess:(t,n,r,i)=>e?.onSuccess?.(t,n.id,r,i),onError:(t,n,r,i)=>e?.onError?.(t,n.id,r,i),onSettled:(t,n,r,i,a)=>e?.onSettled?.(t,n,r.id,i,a)}),[]),{mutate:s,mutateAsync:c}=i,l=(0,M.useCallback)((e,t)=>s(a(e),o(t)),[s,a,o]),u=(0,M.useCallback)((e,t)=>c(a(e),o(t)),[c,a,o]);return{...i,variables:i.variables?.id,mutate:l,mutateAsync:u}}function wi(){let e=Q();return P({mutationFn:e=>v(I(e),!1),onMutate:t=>e.patchRead(()=>I(t),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function Ti(e){let t=Q();return P({mutationFn:({id:t,pinned:n})=>zt(I(t,e),n),onError:e=>lt(`Could not update pin. ${e.message} Please retry.`,{tone:`danger`}),onMutate:()=>e??F(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function Ei(e,t){let n=Q();return P({mutationFn:n=>De(I(e,{projectId:t}),n),onMutate:()=>F({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`send`,r),onError:(e,t,r)=>{e instanceof g&&e.status===409&&r&&n.invalidateAfter(`send`,r)}})}function Di(e,t){let n=Q();return P({mutationFn:(n={})=>pt(I(e,{projectId:t}),n),onMutate:()=>F({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`continue`,r)})}function Oi(e){let t=b();return P({mutationFn:({msgId:t,message:n})=>We(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:W.runs.all})})}function ki(e){let t=b();return P({mutationFn:t=>Te(e,t),onSuccess:()=>t.invalidateQueries({queryKey:W.runs.all})})}function Ai(){return x({queryKey:W.workflows,queryFn:({signal:e})=>u({signal:e})})}function ji(e){return x({queryKey:e?[e,`repo`]:W.repo,queryFn:({signal:t})=>ze({signal:t},e)})}function Mi(e){return x({queryKey:[e,`repo`],queryFn:({signal:t})=>ze({signal:t},e)})}function Ni(){return x({queryKey:W.repoBranches,queryFn:({signal:e})=>Mt({signal:e})})}function Pi(){return x({queryKey:W.repoChanges,queryFn:({signal:e})=>he({signal:e}),retry:!1})}function Fi(e){return x({queryKey:W.repoCommit(e??``),queryFn:({signal:t})=>c(e,{signal:t}),enabled:!!e,retry:!1})}function Ii(e){return x({queryKey:e?[e,`config`]:W.config,queryFn:({signal:t})=>Pt({signal:t,...e?{projectId:e}:{}})})}function Li(){return x({queryKey:W.worktrees,queryFn:({signal:e})=>le({signal:e})})}function Ri(e){return x({queryKey:[e,`worktrees`],queryFn:({signal:t})=>le({signal:t},e),staleTime:0})}function zi(e,t=!0,n=!1){return x({queryKey:[F({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>f({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:pe(e.sidebarLimits)},enabled:t})}function Bi(){return zi(n())}function Vi(){return x({queryKey:W.agentConfig,queryFn:({signal:e})=>ot({signal:e})})}function Hi(e){return x({queryKey:W.agentConfigFile(e??``),queryFn:({signal:t})=>Xe(e,{signal:t}),enabled:e!==null})}function Ui(){return x({queryKey:W.sessionContext,queryFn:({signal:e})=>ye({signal:e})})}function Wi(e,t,n=``){return x({queryKey:W.sessionContextPreview(e,t,n),queryFn:({signal:n})=>$e({content:e,role:t},{signal:n}),placeholderData:At,staleTime:0,retry:!1})}function Gi(){let e=b();return P({onMutate:()=>({fileKey:W.sessionContext}),mutationFn:e=>m(e),onSuccess:(t,n,r)=>{r&&e.setQueryData(r.fileKey,t)}})}function Ki(e){let t=b(),n=W.agentConfig,r=W.agentConfigFile(e);return P({mutationFn:t=>se(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}var qi=A([`passing`,`failing`,`pending`]).nullable(),Ji=S({kind:A([`issue`,`pr`]),number:j(),title:O(),author:O(),createdAt:O(),labels:E(O()),body:O().optional(),url:O(),comments:j(),assignees:E(O()).optional(),projectIds:E(O()).optional(),isDraft:D().optional(),additions:j().optional(),deletions:j().optional(),checks:qi.optional()});C(`available`,[S({available:T(!0),item:Ji.nullable(),labelColors:w(O(),O()).optional()}),S({available:T(!1),reason:O()})]),S({kind:A([`issue`,`pr`]),number:Bt().int().positive().safe()});var Yi=S({id:O(),title:O(),url:O()});S({available:D(),reason:O().optional(),repo:O().optional(),syncedAt:O().optional(),issues:E(Ji),prs:E(Ji),labelColors:w(O(),O()).optional(),viewerLogin:O().optional(),projects:E(Yi).optional(),projectsReason:O().optional(),projectsState:A([`refreshing`,`ready`,`unavailable`]).optional(),projectsGeneration:O().optional(),issuesTotal:j().int().nonnegative().optional(),prsTotal:j().int().nonnegative().optional(),issuesNextCursor:O().nullable().optional(),prsNextCursor:O().nullable().optional(),commentsDeferred:T(!0).optional()});var Xi=O().min(1).max(2e3).optional();S({limit:O().optional(),refresh:O().optional(),issuesCursor:Xi,prsCursor:Xi,issuesDone:T(`1`).optional(),prsDone:T(`1`).optional()}).superRefine((e,t)=>{e.issuesDone&&e.issuesCursor&&t.addIssue({code:`custom`,message:`issuesDone and issuesCursor are exclusive`}),e.prsDone&&e.prsCursor&&t.addIssue({code:`custom`,message:`prsDone and prsCursor are exclusive`}),e.issuesDone&&e.prsDone&&t.addIssue({code:`custom`,message:`both sides are done; there is no page to ask for`})}),S({kind:A([`issue`,`pr`]),numbers:O().regex(/^[1-9]\d{0,15}(,[1-9]\d{0,15})*$/).refine(e=>{let t=e.split(`,`);return t.length<=100&&t.every(e=>Number.isSafeInteger(Number(e)))},{message:`at most 100 safe positive integers`}),refresh:T(`1`).optional()}),C(`available`,[S({available:T(!0),counts:w(j(),j().int().nonnegative())}),S({available:T(!1),reason:O()})]),C(`available`,[S({available:T(!0),checks:w(j(),qi)}),S({available:T(!1),reason:O()})]),S({kind:A([`issue`,`pr`]),q:O().trim().min(1).max(256),limit:Bt().int().positive().max(50).optional()}),S({available:D(),projectsReason:O().optional(),reason:O().optional(),items:E(Ji),truncated:D().optional(),labelColors:w(O(),O()).optional()});var Zi=j().nullable();C(`available`,[S({available:T(!0),prs:w(j(),Pe),issues:w(j(),Pe),conflicts:E(j()).optional(),recheckAfterMs:Zi}),S({available:T(!1),reason:O(),recheckAfterMs:Zi})]);var Qi=S({id:j(),author:O(),avatarUrl:O().optional(),createdAt:O(),body:O(),kind:A([`comment`,`review`]),reviewState:A([`approved`,`changes_requested`,`commented`,`dismissed`]).optional(),url:O()}),$i=A([`committed`,`labeled`,`unlabeled`,`assigned`,`unassigned`,`merged`,`closed`,`reopened`,`head_ref_force_pushed`,`cross-referenced`,`renamed`]),ea=S({id:O(),kind:$i,actor:O(),avatarUrl:O().optional(),createdAt:O(),url:O().optional(),sha:O().optional(),message:O().optional(),checks:qi.optional(),label:S({name:O(),color:O().optional()}).optional(),subject:O().optional(),refNumber:j().optional(),refTitle:O().optional(),refIsPr:D().optional()});S({available:D(),reason:O().optional(),comments:E(Qi),truncated:D().optional(),events:E(ea).optional(),detail:S({body:O(),additions:j().int().nonnegative().optional(),deletions:j().int().nonnegative().optional()}).optional()});var ta=A([`merge`,`squash`,`rebase`]),na=S({name:O(),state:A([`passing`,`failing`,`pending`,`unknown`]),required:D().nullable(),url:O().optional()}),ra=S({number:j(),title:O(),url:O(),state:A([`open`,`closed`,`merged`]),isDraft:D(),headRef:O(),baseRef:O(),headSha:O(),mergeable:A([`mergeable`,`conflicting`,`unknown`]),reviewDecision:A([`approved`,`changes-requested`,`review-required`,`not-required`,`unknown`]),checks:E(na),methods:E(ta),defaultMethod:ta.nullable(),eligibility:A([`ready`,`blocked`,`pending`,`unauthorized`,`terminal`,`unknown`]),blockers:E(S({code:O(),message:O()})),canMerge:D(),canOverride:D()});C(`available`,[S({available:T(!0),mergeState:ra}),S({available:T(!1),reason:O()})]),S({merged:T(!0),number:j(),url:O(),method:ta,mergeCommitSha:O().optional()});var ia=S({path:O(),previousPath:O().optional(),status:A([`added`,`modified`,`removed`,`renamed`,`copied`,`changed`]),additions:j(),deletions:j(),patch:O().optional(),patchUnavailableReason:A([`binary`,`too-large`,`not-provided`]).optional(),truncated:D().optional()});C(`available`,[S({available:T(!0),number:j(),headSha:O(),files:E(ia),additions:j(),deletions:j(),truncated:D(),reason:O().optional()}),S({available:T(!1),reason:O()})]),S({generation:O().uuid()}),C(`state`,[S({generation:O().uuid(),state:T(`ready`),projects:E(Yi),membership:w(O(),E(O()))}),S({generation:O().uuid(),state:T(`unavailable`),reason:O()})]);function aa(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 oa(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function sa(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function ca(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){sa(t.issues,a,r),sa(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 la=e=>e.map(e=>e.number).join(`,`);function ua(e,t){let n=e[0];if(e.length>1&&n&&(la(n.issues)!==la(t.issues)||la(n.prs)!==la(t.prs)||n.issuesTotal!==t.issuesTotal||n.prsTotal!==t.prsTotal))return`refetch`;let r=t;if(n&&t.available&&t.projectsState===`refreshing`&&n.repo===t.repo){let e=new Map(n.issues.map(e=>[e.number,e.projectIds]));r={...t,issues:t.issues.map(t=>{let n=e.get(t.number);return t.projectIds===void 0&&n!==void 0?{...t,projectIds:n}:t})}}return[r,...e.slice(1)]}function da(e={},t=!0){let r=b(),i=W.github(e);$(`/api/v1/p/${n()}/github${e.limit===void 0?``:`?limit=${e.limit}`}`,i,K(t?6e4:!1));let a=x({queryKey:W.github(e),queryFn:({signal:t})=>xe({limit:e.limit},{signal:t}),enabled:t,staleTime:6e4,refetchInterval:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0}),o=a.data?.projectsGeneration,s=x({queryKey:[...i,`projects`,o],queryFn:({signal:e})=>Oe(o,{signal:e}),enabled:t&&a.data?.projectsState===`refreshing`&&!!o,staleTime:1/0,retry:!1});return(0,M.useEffect)(()=>{!o||!s.data&&!s.error||r.setQueryData(i,e=>{if(!e||e.projectsGeneration!==o||e.projectsState!==`refreshing`)return e;let t=s.data;return t?.generation&&t.generation!==o?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,o,s.data,s.error,i]),a}var fa=class extends Error{};function pa(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await xe({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new fa(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>aa(e),retry:(e,t)=>!(t instanceof fa)&&!(t instanceof g&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function ma(e=50,t=!0){let r=b(),i=W.githubPages(e),a=W.githubPagesHead(e);$(`/api/v1/p/${n()}/github?limit=${e}`,a,K(t?6e4:!1));let o=vt({...pa(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),s=x({queryKey:a,queryFn:({signal:t})=>xe({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:c}=o;(0,M.useEffect)(()=>{if(!s.data)return;let e=r.getQueryData(i);if(!e||e.pages.length===0)return;let t=ua(e.pages,s.data);t===`refetch`?c():r.setQueryData(i,{...e,pages:t})},[r,s.dataUpdatedAt,c]);let l=(o.data?.pages??[]).flatMap(e=>e.projectsState===`refreshing`&&e.projectsGeneration?[e.projectsGeneration]:[]),u=N({queries:l.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>Oe(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,M.useEffect)(()=>{u.forEach((e,t)=>{let n=l[t];!n||!e.data&&!e.error||r.setQueryData(i,t=>{if(!t)return t;let r=!1,i=t.pages.map(t=>{if(t.projectsGeneration!==n||t.projectsState!==`refreshing`)return t;let i=e.data;return i?.generation&&i.generation!==n?t:(r=!0,i?.state===`ready`?{...t,projectsState:`ready`,projects:i.projects,issues:t.issues.map(e=>({...e,projectIds:i.membership?.[e.number]??[]}))}:{...t,projectsState:`unavailable`,projectsReason:i?.reason??`Project boards unavailable. Refresh to try again.`})});return r?{...t,pages:i}:t})})},[r,u.map((e,t)=>e.data||e.error?l[t]:``).join(`,`)]),{pages:o,data:(0,M.useMemo)(()=>ca(o.data?.pages??[]),[o.data])}}function ha(e,t=50,n=!0){let r=vt({...pa([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,M.useMemo)(()=>ca(r.data?.pages??[]),[r.data])}}function ga(e,t,n=!0){let r=N({queries:t.filter(e=>e.length>0).map(t=>({queryKey:W.githubCommentCounts(e,t),queryFn:({signal:n})=>_(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,M.useMemo)(()=>{let e={};for(let t of r)t.data?.available&&Object.assign(e,t.data.counts);return e},[r.map(e=>e.dataUpdatedAt).join(`,`)])}function _a(e,t,n,r=!0){return x({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>ue(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function va(e,t=!0){return x({queryKey:W.githubChecks(e),queryFn:({signal:t})=>Ee(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function ya(e,t,n=!0){return x({queryKey:W.githubSearch(e,t),queryFn:({signal:n})=>ue(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var ba=100;function xa(e){return[...e].sort((e,t)=>t-e).slice(0,ba).sort((e,t)=>e-t)}function Sa(){let e=Ie(),t=Ur();return e.projectId??t.data?.bootProject}function Ca(e){for(let[t,n]of Object.entries(e)){for(let[e,r]of Object.entries(n.prs))tr(U({projectId:t,kind:`PR`,number:Number(e)}),r);for(let[e,r]of Object.entries(n.issues))tr(U({projectId:t,kind:`Issue`,number:Number(e)}),r)}}var wa=5*6e4;function Ta(e){return e?e.recheckAfterMs:wa}function Ea(e,t=!0){let n=(0,M.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.projectId)??{prs:new Set,issues:new Set};e[n.kind===`PR`?`prs`:`issues`].add(n.number),t.set(n.projectId,e)}return[...t.entries()].map(([e,t])=>({projectId:e,prs:xa(t.prs),issues:xa(t.issues)}))},[e.map(U).sort().join(`|`)]),r=N({queries:n.map(e=>({queryKey:W.githubRefStatus(e.projectId,e.prs,e.issues),queryFn:({signal:t})=>je(e.projectId,{prs:e.prs,issues:e.issues},{signal:t}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>Ta(e.state.data)??1/0,refetchInterval:!1,refetchOnWindowFocus:!0}))}),i=b(),a=JSON.stringify(n.map((e,t)=>({...e,interval:Ta(r[t]?.data)??!1})));(0,M.useEffect)(()=>{if(!t||fr())return;let e=!0,n=JSON.parse(a).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=W.githubRefStatus(t.projectId,t.prs,t.issues);return Qr({path:`/api/v1/p/${t.projectId}/github/ref-status?${n}`,intervalMs:t.interval},(t,n)=>{n||i.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&i.setQueryData(r,t)})})});return()=>{e=!1;for(let e of n)e()}},[t,a,i]);let o=(0,M.useMemo)(()=>dr(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,M.useCallback)(e=>{let t=U(e),n=o.get(t);if(n)return n;let r=V.get(t);return{state:`idle`,...r?{status:r}:{},...H.has(t)?{conflicting:!0}:{}}},[o])}function Da(e,t,n=!0){return x({queryKey:W.githubComments(e,t),queryFn:({signal:n})=>ne(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Oa(e,t,n=!0){return x({queryKey:W.githubItem(e,t),queryFn:({signal:n})=>ht(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function ka(e){return x({queryKey:W.githubPrChanges(e??0),queryFn:({signal:t})=>ee(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{li as $,Vn as $t,Ai as A,br as At,fi as B,hr as Bt,ji as C,vr as Ct,Ui as D,Pr as Dt,Fi as E,Cr as Et,hi as F,kr as Ft,Si as G,G as Gt,wi as H,K as Ht,bi as I,Kr as It,ki as J,qn as Jt,Ti as K,Yn as Kt,Di as L,Gr as Lt,ni as M,jr as Mt,pi as N,Nr as Nt,Wi as O,wr as Ot,mi as P,Tr as Pt,gi as Q,B as Qt,ai as R,_r as Rt,Gi as S,xr as St,Pi as T,yr as Tt,xi as U,fr as Ut,Ci as V,pr as Vt,ei as W,W as Wt,ui as X,Wn as Xt,si as Y,Hn as Yt,_i as Z,Bn as Zt,Ii as _,Sr as _t,Da as a,L as an,ri as at,Ri as b,Hr as bt,ka as c,Zt as cn,Qr as ct,_a as d,P as dn,qr as dt,Kn as en,di as et,Sa as f,N as fn,zr as ft,Hi as g,Or as gt,Vi as h,Br as ht,ga as i,Tn as in,ii as it,Li as j,Fr as jt,Bi as k,Ar as kt,ya as l,F as ln,Q as lt,oa as m,Wt as mn,Mr as mt,da as n,Un as nn,oi as nt,Oa as o,en as on,Ei as ot,Ea as p,Gt as pn,Lr as pt,ci as q,Zn as qt,va as r,zn as rn,ti as rt,ma as s,Qt as sn,yi as st,Ca as t,Gn as tn,vi as tt,ha as u,I as un,Ir as ut,Mi as v,Vr as vt,Ni as w,Rr as wt,Ki as x,Wr as xt,zi as y,Ur as yt,Oi as z,mr as zt};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{n as r,t as i}from"./utils-DSMR_WLb.js";import{Kt as a,p as o,qt as s}from"./queries-ClkIgWFx.js";import{n as c}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{a as l}from"./tasks-table-BkjZYg2J.js";import{F as u,H as d,M as f,N as p,P as m,f as h,g,h as _,m as v,ot as y,p as b}from"./design-icons-CzEoMH9c.js";import{t as x}from"./createLucideIcon-BHp8sXmF.js";import{n as S,r as C,t as w}from"./popover-BPgUYFyu.js";var T=x(`search-x`,[[`path`,{d:`m13.5 8.5-5 5`,key:`1cs55j`}],[`path`,{d:`m8.5 8.5 5 5`,key:`a8mexj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),E=e(t(),1),D=n(),O=(0,E.createContext)(null);function k({children:e}){let[t,n]=(0,E.useState)(()=>new Map),r=(0,E.useCallback)((e,t)=>{n(n=>{let r=new Map(n);return r.set(e,t),r})},[]),i=(0,E.useCallback)(e=>{n(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),a=o((0,E.useMemo)(()=>[...t.values()].flat(),[t])),s=(0,E.useMemo)(()=>({publish:r,retract:i,lookup:a}),[r,i,a]);return(0,D.jsx)(O.Provider,{value:s,children:e})}var A=(0,E.createContext)(null);function j({projectId:e,repoBase:t,requests:n,children:r}){let i=(0,E.useContext)(O),a=(0,E.useContext)(A),s=(0,E.useId)();(0,E.useEffect)(()=>{if(i)return i.publish(s,n),()=>i.retract(s)},[i,s,n.map(e=>`${e.projectId} ${e.kind}#${e.number}`).sort().join(`|`)]);let c=o(i?M:n),l=i?.lookup??c,u=t??(a&&a.projectId===e?a.repoBase:void 0),d=(0,E.useMemo)(()=>({lookup:l,projectId:e,repoBase:u}),[l,e,u]);return(0,D.jsx)(A.Provider,{value:d,children:r})}var M=[];function N(e,t,n){let r=(0,E.useContext)(A),i=n??r?.projectId;return!r||!i||t===void 0?te:r.lookup({projectId:i,kind:e,number:t})}function ee(e,t){let n=(0,E.useContext)(A),r=t??n?.projectId;return!n||!r?[]:e.filter(e=>n.lookup({projectId:r,kind:`PR`,number:e}).conflicting===!0)}function P(){let e=(0,E.useContext)(A);return{projectId:e?.projectId,repoBase:e?.repoBase}}var te=Object.freeze({state:`idle`}),F={success:`border-success/40 text-semantic-green`,danger:`border-danger/40 text-semantic-red`,accent:`border-accent-strong/35 text-accent-text`,merged:`border-merged-strong/35 text-merged-text`,info:`border-info/40 text-semantic-info`,neutral:`border-border text-muted-foreground`,pending:`border-pending-strong/45 text-semantic-amber`,conflict:`border-conflict/45 text-semantic-conflict`},I={success:`text-semantic-green`,danger:`text-semantic-red`,accent:`text-merged-text`,merged:`text-merged-text`,info:`text-semantic-info`,neutral:`text-soft-foreground`,pending:`text-semantic-amber`,conflict:`text-semantic-conflict`},ne={success:`hover:bg-success/10`,danger:`hover:bg-danger/10`,accent:`hover:bg-accent-strong/10`,merged:`hover:bg-merged-strong/10`,info:`hover:bg-info/10`,neutral:`hover:bg-muted`,pending:`hover:bg-pending-strong/10`,conflict:`hover:bg-conflict/10`},re={draft:m,"review-required":u,"changes-requested":d,"checks-pending":null,"checks-failing":g,ready:h,merged:f,closed:p,open:b,completed:h,"not-planned":_};function L(e){return e===`PR`?`pr-chip`:`issue-chip`}function R(e){return e?{"data-conflicting":`true`}:{}}function z(e,t,n,r){return!n||r!==void 0&&l({kind:e,number:t??0,url:n},r)}function B(e,t,n){return e===`PR`&&(t??n)===!0}function V({plain:e,inert:t,conflicting:n,className:r,tone:a}){return e?i(`inline-flex items-center gap-1 rounded-[2px] text-inherit`,n&&`text-conflict font-medium`,!t&&`group/reference focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-link-foreground`,r):i(`inline-flex h-[22px] items-center gap-1 rounded-md border px-1.5 font-mono text-[12px] font-normal`,F[a],r)}function H(e,t,n,r){return n&&!r?t?`${e===`PR`?`PR `:``}#${t}`:e:t?`${!r&&e===`Issue`?`Issue `:``}#${t}`:e}function U(e){return e===`PR`?`pull request`:`issue`}function W(e,t,n,r){return`Open the ${e}${t?` #${t}`:``} for ${n}${r?` — ${r.label}`:``}`}function G(e,t){return e&&t?I[t.tone]:void 0}function K(e,t){return!e&&(!t||!r(t))}function q({conflicting:e,presentation:t,status:n,plain:r,compact:a,inert:o,kind:s,label:c,glyphClass:l}){return(0,D.jsxs)(D.Fragment,{children:[e?(0,D.jsx)(y,{className:i(`size-2.5 shrink-0`,l),"aria-hidden":`true`}):(0,D.jsx)($,{status:t?n:void 0,className:r?i(`size-2.5`,l):void 0}),r&&a?s===`PR`?(0,D.jsx)(u,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):(0,D.jsx)(b,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):null,r?(0,D.jsx)(`span`,{className:o?void 0:`underline-offset-2 group-hover/reference:underline group-focus-visible/reference:underline`,children:c}):c]})}function J({kind:e,status:t,conflicting:n,chipClass:r,body:i}){return(0,D.jsx)(`span`,{"data-slot":L(e),"data-status":t,"data-inert":`true`,...R(n),className:r,children:i})}function Y({kind:e,number:t,tooltip:n,url:i}){return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`span`,{className:`block font-medium`,children:[e===`PR`?`Pull request`:`Issue`,t?` #${t}`:``,` · `,n.headline]}),(0,D.jsx)(`span`,{className:`block`,children:n.detail}),n.also?(0,D.jsx)(`span`,{className:`block text-muted-foreground`,children:n.also}):null,i&&r(i)?(0,D.jsx)(`span`,{className:`block text-muted-foreground`,children:i.replace(/^https?:\/\//,``)}):null]})}function ie({reference:e,taskTitle:t,status:n,conflicting:r,conflictAction:o,projectId:c,repoBase:l,to:u,className:d,compact:f=!1,plain:p=!1,inert:m=!1}){let{kind:h,number:g,url:_}=e,v=P(),y=N(h,z(h,g,_,l??v.repoBase)?g:void 0,c),b=n??y.status,x=s(b),S=B(h,r,y.conflicting),C=S?a:x,w=C?.tone??`accent`,T=V({plain:p,inert:m,conflicting:S,className:d,tone:w}),E=le(y,C,S?x:void 0),O=H(h,g,p,f),k=U(h),A=W(k,g,t,C),j=(0,D.jsx)(q,{conflicting:S,presentation:C,status:b,plain:p,compact:f,inert:m,kind:h,label:O,glyphClass:G(p,C)});if(m)return(0,D.jsx)(J,{kind:h,status:b,conflicting:S,chipClass:T,body:j});let M=K(u,_)?(0,D.jsx)(`span`,{"data-slot":L(h),"data-status":b,...R(S),"aria-label":C?`${k} ${O} — ${C.label}`:void 0,className:T,children:j}):(0,D.jsx)(ae,{to:u,url:_,"data-slot":L(h),"data-status":b,...R(S),title:E?void 0:_,"aria-label":A,className:p?T:i(T,ne[w]),children:j});return E?(0,D.jsx)(ce,{chip:M,action:S?o:void 0,state:y.state,children:(0,D.jsx)(Y,{kind:h,number:g,tooltip:E,url:_})}):M}function ae({to:e,url:t,children:n,...r}){return e?(0,D.jsx)(c,{to:e,...r,children:n}):(0,D.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,...r,children:n})}var X=(0,E.createContext)(()=>{});function oe(){return(0,E.useContext)(X)}var se=150,Z=120;function ce({chip:e,action:t,state:n,children:r}){let[i,a]=(0,E.useState)(!1),o=(0,E.useRef)(null),s=(0,E.useRef)(null),c=(0,E.useRef)(void 0),l=(0,E.useCallback)((e,t)=>{clearTimeout(c.current),c.current=setTimeout(()=>a(e),t)},[]),u=(0,E.useCallback)(()=>{clearTimeout(c.current),a(!1)},[]);(0,E.useEffect)(()=>()=>clearTimeout(c.current),[]);let d=e=>e instanceof Node&&(s.current?.contains(e)||o.current?.contains(e));return(0,D.jsxs)(w,{open:i,onOpenChange:e=>e?a(!0):u(),children:[(0,D.jsx)(S,{asChild:!0,ref:o,onPointerEnter:e=>{e.pointerType!==`touch`&&l(!0,se)},onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,Z)},onFocus:()=>a(!0),onBlur:e=>{d(e.relatedTarget)||u()},onKeyDown:e=>{if(e.key===`Escape`)return u();if(e.key!==`Tab`||e.shiftKey||!t)return;let n=s.current?.querySelector(`button:not([disabled]), [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);n&&(e.preventDefault(),n.focus())},...t?{"aria-haspopup":`dialog`,"aria-expanded":i}:{},children:e}),(0,D.jsxs)(C,{ref:s,side:`top`,role:t?`dialog`:`tooltip`,"data-slot":`reference-status-card`,"data-tooltip-state":n,className:`w-64 space-y-2 p-3 text-xs`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>{e.preventDefault(),d(document.activeElement)&&o.current?.focus()},onPointerEnter:()=>clearTimeout(c.current),onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,Z)},children:[(0,D.jsx)(`div`,{className:`space-y-0.5`,children:r}),t?(0,D.jsx)(X.Provider,{value:u,children:t}):null]})]})}function le(e,t,n){if(t){let{label:r,hint:i}=t,a=n?`also ${ue(n.label)} — ${n.hint}`:void 0;return e.state===`unavailable`?{headline:r,detail:`last known — GitHub is unreachable${e.reason?` (${e.reason})`:``}`,...a?{also:a}:{}}:{headline:r,detail:i,...a?{also:a}:{}}}switch(e.state){case`loading`:return{headline:`Checking GitHub…`,detail:`the status of this reference is on its way`};case`unavailable`:return{headline:`Status unavailable`,detail:e.reason??`GitHub could not be reached — the chip says nothing rather than guessing`};case`unknown`:return{headline:`Not found on this repository`,detail:`GitHub has no such number here — the reference may point at another repo`};default:return null}}function ue(e){return e.charAt(0).toLowerCase()+e.slice(1)}function Q({kind:e,number:t,className:n}){let r=N(e,t),o=s(r.status),c=e===`PR`&&r.conflicting===!0,l=c?a:o;if(!l)return null;let u=i(`size-2.5`,I[l.tone]);return(0,D.jsx)(`span`,{"data-slot":`reference-status-glyph`,"data-status":r.status,...c?{"data-conflicting":`true`}:{},"aria-hidden":`true`,className:i(`inline-flex items-center`,n),children:c?(0,D.jsx)(y,{className:i(`shrink-0`,u),"aria-hidden":`true`}):(0,D.jsx)($,{status:r.status,className:u})})}function $({status:e,className:t}){if(!e)return null;if(e===`checks-pending`)return(0,D.jsx)(v,{"data-slot":`status-dot`,"data-tone":`pending`,className:i(`size-3 animate-pulse motion-reduce:animate-none`,t),"aria-hidden":`true`});let n=re[e];return n?(0,D.jsx)(n,{className:i(`size-2.5 shrink-0`,t),"aria-hidden":`true`}):null}export{k as a,N as c,j as i,T as l,Q as n,ee as o,oe as r,P as s,ie as t};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{n as r,t as i}from"./utils-DSMR_WLb.js";import{Kt as a,p as o,qt as s}from"./queries-CYWRnyM5.js";import{n as c}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{a as l}from"./tasks-table-k18AuMR5.js";import{F as u,H as d,M as f,N as p,P as m,f as h,g,h as _,m as v,ot as y,p as b}from"./design-icons-CzEoMH9c.js";import{t as x}from"./createLucideIcon-BHp8sXmF.js";import{n as S,r as C,t as w}from"./popover-CZV6tz9i.js";var T=x(`search-x`,[[`path`,{d:`m13.5 8.5-5 5`,key:`1cs55j`}],[`path`,{d:`m8.5 8.5 5 5`,key:`a8mexj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),E=e(t(),1),D=n(),O=(0,E.createContext)(null);function k({children:e}){let[t,n]=(0,E.useState)(()=>new Map),r=(0,E.useCallback)((e,t)=>{n(n=>{let r=new Map(n);return r.set(e,t),r})},[]),i=(0,E.useCallback)(e=>{n(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),a=o((0,E.useMemo)(()=>[...t.values()].flat(),[t])),s=(0,E.useMemo)(()=>({publish:r,retract:i,lookup:a}),[r,i,a]);return(0,D.jsx)(O.Provider,{value:s,children:e})}var A=(0,E.createContext)(null);function j({projectId:e,repoBase:t,requests:n,children:r}){let i=(0,E.useContext)(O),a=(0,E.useContext)(A),s=(0,E.useId)();(0,E.useEffect)(()=>{if(i)return i.publish(s,n),()=>i.retract(s)},[i,s,n.map(e=>`${e.projectId} ${e.kind}#${e.number}`).sort().join(`|`)]);let c=o(i?M:n),l=i?.lookup??c,u=t??(a&&a.projectId===e?a.repoBase:void 0),d=(0,E.useMemo)(()=>({lookup:l,projectId:e,repoBase:u}),[l,e,u]);return(0,D.jsx)(A.Provider,{value:d,children:r})}var M=[];function N(e,t,n){let r=(0,E.useContext)(A),i=n??r?.projectId;return!r||!i||t===void 0?te:r.lookup({projectId:i,kind:e,number:t})}function ee(e,t){let n=(0,E.useContext)(A),r=t??n?.projectId;return!n||!r?[]:e.filter(e=>n.lookup({projectId:r,kind:`PR`,number:e}).conflicting===!0)}function P(){let e=(0,E.useContext)(A);return{projectId:e?.projectId,repoBase:e?.repoBase}}var te=Object.freeze({state:`idle`}),F={success:`border-success/40 text-semantic-green`,danger:`border-danger/40 text-semantic-red`,accent:`border-accent-strong/35 text-accent-text`,merged:`border-merged-strong/35 text-merged-text`,info:`border-info/40 text-semantic-info`,neutral:`border-border text-muted-foreground`,pending:`border-pending-strong/45 text-semantic-amber`,conflict:`border-conflict/45 text-semantic-conflict`},I={success:`text-semantic-green`,danger:`text-semantic-red`,accent:`text-merged-text`,merged:`text-merged-text`,info:`text-semantic-info`,neutral:`text-soft-foreground`,pending:`text-semantic-amber`,conflict:`text-semantic-conflict`},ne={success:`hover:bg-success/10`,danger:`hover:bg-danger/10`,accent:`hover:bg-accent-strong/10`,merged:`hover:bg-merged-strong/10`,info:`hover:bg-info/10`,neutral:`hover:bg-muted`,pending:`hover:bg-pending-strong/10`,conflict:`hover:bg-conflict/10`},re={draft:m,"review-required":u,"changes-requested":d,"checks-pending":null,"checks-failing":g,ready:h,merged:f,closed:p,open:b,completed:h,"not-planned":_};function L(e){return e===`PR`?`pr-chip`:`issue-chip`}function R(e){return e?{"data-conflicting":`true`}:{}}function z(e,t,n,r){return!n||r!==void 0&&l({kind:e,number:t??0,url:n},r)}function B(e,t,n){return e===`PR`&&(t??n)===!0}function V({plain:e,inert:t,conflicting:n,className:r,tone:a}){return e?i(`inline-flex items-center gap-1 rounded-[2px] text-inherit`,n&&`text-conflict font-medium`,!t&&`group/reference focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-link-foreground`,r):i(`inline-flex h-[22px] items-center gap-1 rounded-md border px-1.5 font-mono text-[12px] font-normal`,F[a],r)}function H(e,t,n,r){return n&&!r?t?`${e===`PR`?`PR `:``}#${t}`:e:t?`${!r&&e===`Issue`?`Issue `:``}#${t}`:e}function U(e){return e===`PR`?`pull request`:`issue`}function W(e,t,n,r){return`Open the ${e}${t?` #${t}`:``} for ${n}${r?` — ${r.label}`:``}`}function G(e,t){return e&&t?I[t.tone]:void 0}function K(e,t){return!e&&(!t||!r(t))}function q({conflicting:e,presentation:t,status:n,plain:r,compact:a,inert:o,kind:s,label:c,glyphClass:l}){return(0,D.jsxs)(D.Fragment,{children:[e?(0,D.jsx)(y,{className:i(`size-2.5 shrink-0`,l),"aria-hidden":`true`}):(0,D.jsx)($,{status:t?n:void 0,className:r?i(`size-2.5`,l):void 0}),r&&a?s===`PR`?(0,D.jsx)(u,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):(0,D.jsx)(b,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):null,r?(0,D.jsx)(`span`,{className:o?void 0:`underline-offset-2 group-hover/reference:underline group-focus-visible/reference:underline`,children:c}):c]})}function J({kind:e,status:t,conflicting:n,chipClass:r,body:i}){return(0,D.jsx)(`span`,{"data-slot":L(e),"data-status":t,"data-inert":`true`,...R(n),className:r,children:i})}function Y({kind:e,number:t,tooltip:n,url:i}){return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`span`,{className:`block font-medium`,children:[e===`PR`?`Pull request`:`Issue`,t?` #${t}`:``,` · `,n.headline]}),(0,D.jsx)(`span`,{className:`block`,children:n.detail}),n.also?(0,D.jsx)(`span`,{className:`block text-muted-foreground`,children:n.also}):null,i&&r(i)?(0,D.jsx)(`span`,{className:`block text-muted-foreground`,children:i.replace(/^https?:\/\//,``)}):null]})}function ie({reference:e,taskTitle:t,status:n,conflicting:r,conflictAction:o,projectId:c,repoBase:l,to:u,className:d,compact:f=!1,plain:p=!1,inert:m=!1}){let{kind:h,number:g,url:_}=e,v=P(),y=N(h,z(h,g,_,l??v.repoBase)?g:void 0,c),b=n??y.status,x=s(b),S=B(h,r,y.conflicting),C=S?a:x,w=C?.tone??`accent`,T=V({plain:p,inert:m,conflicting:S,className:d,tone:w}),E=le(y,C,S?x:void 0),O=H(h,g,p,f),k=U(h),A=W(k,g,t,C),j=(0,D.jsx)(q,{conflicting:S,presentation:C,status:b,plain:p,compact:f,inert:m,kind:h,label:O,glyphClass:G(p,C)});if(m)return(0,D.jsx)(J,{kind:h,status:b,conflicting:S,chipClass:T,body:j});let M=K(u,_)?(0,D.jsx)(`span`,{"data-slot":L(h),"data-status":b,...R(S),"aria-label":C?`${k} ${O} — ${C.label}`:void 0,className:T,children:j}):(0,D.jsx)(ae,{to:u,url:_,"data-slot":L(h),"data-status":b,...R(S),title:E?void 0:_,"aria-label":A,className:p?T:i(T,ne[w]),children:j});return E?(0,D.jsx)(ce,{chip:M,action:S?o:void 0,state:y.state,children:(0,D.jsx)(Y,{kind:h,number:g,tooltip:E,url:_})}):M}function ae({to:e,url:t,children:n,...r}){return e?(0,D.jsx)(c,{to:e,...r,children:n}):(0,D.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,...r,children:n})}var X=(0,E.createContext)(()=>{});function oe(){return(0,E.useContext)(X)}var se=150,Z=120;function ce({chip:e,action:t,state:n,children:r}){let[i,a]=(0,E.useState)(!1),o=(0,E.useRef)(null),s=(0,E.useRef)(null),c=(0,E.useRef)(void 0),l=(0,E.useCallback)((e,t)=>{clearTimeout(c.current),c.current=setTimeout(()=>a(e),t)},[]),u=(0,E.useCallback)(()=>{clearTimeout(c.current),a(!1)},[]);(0,E.useEffect)(()=>()=>clearTimeout(c.current),[]);let d=e=>e instanceof Node&&(s.current?.contains(e)||o.current?.contains(e));return(0,D.jsxs)(w,{open:i,onOpenChange:e=>e?a(!0):u(),children:[(0,D.jsx)(S,{asChild:!0,ref:o,onPointerEnter:e=>{e.pointerType!==`touch`&&l(!0,se)},onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,Z)},onFocus:()=>a(!0),onBlur:e=>{d(e.relatedTarget)||u()},onKeyDown:e=>{if(e.key===`Escape`)return u();if(e.key!==`Tab`||e.shiftKey||!t)return;let n=s.current?.querySelector(`button:not([disabled]), [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);n&&(e.preventDefault(),n.focus())},...t?{"aria-haspopup":`dialog`,"aria-expanded":i}:{},children:e}),(0,D.jsxs)(C,{ref:s,side:`top`,role:t?`dialog`:`tooltip`,"data-slot":`reference-status-card`,"data-tooltip-state":n,className:`w-64 space-y-2 p-3 text-xs`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>{e.preventDefault(),d(document.activeElement)&&o.current?.focus()},onPointerEnter:()=>clearTimeout(c.current),onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,Z)},children:[(0,D.jsx)(`div`,{className:`space-y-0.5`,children:r}),t?(0,D.jsx)(X.Provider,{value:u,children:t}):null]})]})}function le(e,t,n){if(t){let{label:r,hint:i}=t,a=n?`also ${ue(n.label)} — ${n.hint}`:void 0;return e.state===`unavailable`?{headline:r,detail:`last known — GitHub is unreachable${e.reason?` (${e.reason})`:``}`,...a?{also:a}:{}}:{headline:r,detail:i,...a?{also:a}:{}}}switch(e.state){case`loading`:return{headline:`Checking GitHub…`,detail:`the status of this reference is on its way`};case`unavailable`:return{headline:`Status unavailable`,detail:e.reason??`GitHub could not be reached — the chip says nothing rather than guessing`};case`unknown`:return{headline:`Not found on this repository`,detail:`GitHub has no such number here — the reference may point at another repo`};default:return null}}function ue(e){return e.charAt(0).toLowerCase()+e.slice(1)}function Q({kind:e,number:t,className:n}){let r=N(e,t),o=s(r.status),c=e===`PR`&&r.conflicting===!0,l=c?a:o;if(!l)return null;let u=i(`size-2.5`,I[l.tone]);return(0,D.jsx)(`span`,{"data-slot":`reference-status-glyph`,"data-status":r.status,...c?{"data-conflicting":`true`}:{},"aria-hidden":`true`,className:i(`inline-flex items-center`,n),children:c?(0,D.jsx)(y,{className:i(`shrink-0`,u),"aria-hidden":`true`}):(0,D.jsx)($,{status:r.status,className:u})})}function $({status:e,className:t}){if(!e)return null;if(e===`checks-pending`)return(0,D.jsx)(v,{"data-slot":`status-dot`,"data-tone":`pending`,className:i(`size-3 animate-pulse motion-reduce:animate-none`,t),"aria-hidden":`true`});let n=re[e];return n?(0,D.jsx)(n,{className:i(`size-2.5 shrink-0`,t),"aria-hidden":`true`}):null}export{k as a,N as c,j as i,T as l,Q as n,ee as o,oe as r,P as s,ie as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Gt as r,Wt as i,yt as a}from"./queries-ClkIgWFx.js";import{hi as o}from"./toaster-C-xqAWVX.js";import{fn as s}from"./index-BX94wp6m.js";var c=e(t(),1),l=n();function u(){let e=o(),t=(0,c.useCallback)(async()=>{await Promise.all([e.invalidateQueries({queryKey:i.health}),e.invalidateQueries({queryKey:i.agentConfig,exact:!0}),e.invalidateQueries({queryKey:r.agentProfiles,exact:!0})])},[e]);return(0,c.useEffect)(()=>{t()},[t]),t}var d=`${s()} remote-settings enable`;function f({risk:e}){return a().data?.capabilities?.remoteSettingsAdmin===!0?(0,l.jsxs)(`p`,{role:`note`,"data-slot":`remote-settings-notice`,className:`rounded-md border border-pending-strong/40 bg-pending/10 px-3 py-2 text-[13px] text-foreground`,children:[`Remote settings administration is on. `,e,`, and anyone who can open this cockpit can change them. The host operator turns this off with`,` `,(0,l.jsxs)(`code`,{children:[s(),` remote-settings disable`]}),`.`]}):null}export{f as n,u as r,d as t};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Gt as r,Wt as i,yt as a}from"./queries-CYWRnyM5.js";import{hi as o}from"./toaster-B0kvcFif.js";import{pn as s}from"./index-mCjln54E.js";var c=e(t(),1),l=n();function u(){let e=o(),t=(0,c.useCallback)(async()=>{await Promise.all([e.invalidateQueries({queryKey:i.health}),e.invalidateQueries({queryKey:i.agentConfig,exact:!0}),e.invalidateQueries({queryKey:r.agentProfiles,exact:!0})])},[e]);return(0,c.useEffect)(()=>{t()},[t]),t}var d=`${s()} remote-settings enable`;function f({risk:e}){return a().data?.capabilities?.remoteSettingsAdmin===!0?(0,l.jsxs)(`p`,{role:`note`,"data-slot":`remote-settings-notice`,className:`rounded-md border border-pending-strong/40 bg-pending/10 px-3 py-2 text-[13px] text-foreground`,children:[`Remote settings administration is on. `,e,`, and anyone who can open this cockpit can change them. The host operator turns this off with`,` `,(0,l.jsxs)(`code`,{children:[s(),` remote-settings disable`]}),`.`]}):null}export{f as n,u as r,d as t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{c as r,n as i,t as a}from"./utils-DSMR_WLb.js";import{C as o,E as s,T as c,W as l,Wt as u,dn as d,j as f,n as p,qt as m,rt as h,w as g,xt as _,yt as ee}from"./queries-CYWRnyM5.js";import{Fn as v,It as te,L as y,R as ne,ct as b,f as x,hi as S,l as C,n as w}from"./toaster-B0kvcFif.js";import{Z as T}from"./live-protocol-DMhTnCmf.js";import{g as E,h as re}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{i as D}from"./tasks-table-k18AuMR5.js";import{A as ie,C as O,E as ae,F as k,J as A,M as oe,X as se,Y as ce,at as le,j as ue,n as de,ot as j,s as fe,u as pe,v as me,x as he}from"./design-icons-CzEoMH9c.js";import{t as ge}from"./createLucideIcon-BHp8sXmF.js";import{n as _e,t as ve}from"./circle-x-7nTlobAF.js";import{_ as ye}from"./nav-row-styles-D5HpOmDZ.js";import{i as be,r as xe,t as Se}from"./git-toolbar-DsNQUL5f.js";import{t as M}from"./info-DA1x_4bz.js";import{t as Ce}from"./loader-circle-CPBhhDbB.js";import{n as we,r as Te}from"./diff-controls-HmgYRhy7.js";import{c as Ee,i as De,t as Oe}from"./reference-chip-BdikRjql.js";import{t as N}from"./button-B7MKxYjT.js";import{i as P,l as ke,p as Ae,r as je,t as Me}from"./dropdown-menu-4e2iKSMT.js";import{t as F}from"./project-router-BvBqllk2.js";import{t as Ne}from"./status-dot-BRzVlF2X.js";import{a as Pe,o as Fe}from"./format-BU7D3IfE.js";import{d as Ie,n as Le,o as Re,s as ze,t as Be,u as Ve}from"./page-shell-7pLJMOgh.js";import{t as I}from"./centered-state-V15AR_qo.js";import{An as He,At as Ue,Bt as We,Dt as Ge,E as Ke,En as qe,Ft as L,Gt as R,Ht as z,It as Je,Jt as B,Kt as V,Lt as Ye,Mn as Xe,Mt as Ze,Nt as Qe,Ot as $e,Pt as et,Rt as tt,T as nt,Ut as H,Vt as U,Wt as W,Xn as G,Xt as K,dn as rt,fr as q,jn as it,jt as at,kt as ot,qt as J,rr as st,ur as ct,zt as lt}from"./index-mCjln54E.js";import{t as ut}from"./markdown-BBDDg-4t.js";import{t as dt}from"./diff-BmDcJsHL.js";import{t as ft}from"./change-counts-npLATh-3.js";import{n as pt,r as mt}from"./commit-list-02HM16KN.js";var Y=e(t(),1);function ht(e,t){let n=S(t),r=n.getQueryCache();return Y.useSyncExternalStore(Y.useCallback(e=>r.subscribe(T.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var gt=ge(`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`}]]),_t=ge(`git-pull-request-create`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v3`,key:`1jb6z3`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]),X=n();function vt(){let e=r(),t=o(),n=S(),i=ht({queryKey:u.repo})>0,s=t.data?.info?t.data:null,c=Ge(e,s,`screen`);return(0,X.jsx)(Ve,{route:`repo-git`,density:s?.info?`full`:`empty`,headerSpacing:`compact`,header:{title:`Git`,secondaryActions:(0,X.jsx)(ze,{type:`button`,variant:`ghost`,"data-slot":`git-screen-refresh`,"aria-label":`Refresh the repository`,title:`Refresh the repository`,disabled:i,onClick:()=>{n.invalidateQueries({queryKey:u.repo}),n.invalidateQueries({queryKey:u.worktrees})},children:(0,X.jsx)(ce,{size:17,"aria-hidden":`true`,className:a(`size-[17px]`,i&&`motion-safe:animate-spin`)})})},children:(0,X.jsxs)(`div`,{"data-slot":`git-screen`,children:[s?.info?(0,X.jsx)(`div`,{className:`mb-[16px]`,children:(0,X.jsx)(Ue,{scope:e,repo:s,info:s.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)($e,{branch:s?.info?.branch??null,counts:c,variant:`screen`})]})})}function yt({entry:e}){return e.keptReason?(0,X.jsx)(`span`,{"data-slot":`branch-kept-reason`,className:`min-w-0 text-xs text-muted-foreground`,children:e.keptReason}):null}function bt({repo:e,info:t}){let n=r(),i=[n,`repo`],o=[n,`health`],s=ee(),c=g(),l=new Map((c.data?.branches??[]).map(e=>[e.name,e])),u=S(),f=d({mutationFn:e=>C({name:e},n),onSuccess:async e=>{w(e.created?`Created and switched to ${e.branch}`:`Switched to ${e.branch}`),await Promise.all([u.invalidateQueries({queryKey:i}),u.invalidateQueries({queryKey:o})]),u.setQueryData(i,t=>t?.info?{...t,info:{...t.info,branch:e.branch}}:t),u.setQueryData(o,t=>Ze(t,n,e.branch))},onError:e=>w(e.message,{tone:`danger`})}),[p,m]=(0,Y.useState)(``),[h,_]=(0,Y.useState)(``),v=h.trim().toLowerCase(),te=Z(e,c.data?.branches),y=v?te.filter(e=>e.toLowerCase().includes(v)):te;return(0,X.jsxs)(`section`,{"data-slot":`repo-branches`,className:`grid min-w-0 grid-cols-1 gap-5 md:grid-cols-[minmax(0,1fr)_290px]`,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)(se,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3 size-4 text-muted-foreground`}),(0,X.jsx)(G,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:h,onChange:e=>_(e.target.value),className:`h-10 rounded-lg border-border bg-card pl-10`})]}),(0,X.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-3.5 flex min-w-0 flex-col divide-y divide-border border-t border-border md:max-h-[40rem] md:overflow-y-auto md:overscroll-contain`,children:[y.map(e=>{let n=e===t.branch,r=l.get(e);return(0,X.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,"data-branch-class":r?.class,className:`flex min-h-[60px] flex-col items-start justify-center gap-1.5 py-2 md:flex-row md:items-center md:justify-start md:gap-2.5`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-[8px]`,children:[r?.runId?(0,X.jsx)(F,{to:`/tasks/${r.runId}`,"data-slot":`branch-task-link`,title:r.title?`Open the task ${r.title}`:`Open the task`,className:`min-w-0 truncate rounded-[2px] font-mono text-[12px] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:e}):(0,X.jsx)(`span`,{className:a(`min-w-0 truncate font-mono text-[12px]`,n&&`font-medium`),children:e}),r&&!(n&&r.class===`active`)?(0,X.jsx)(Tt,{entry:r}):null]}),r?(0,X.jsx)(yt,{entry:r}):null,e.startsWith(`cez/`)&&!n?null:n?(0,X.jsx)(`span`,{"data-slot":`branch-current`,className:`flex h-8 shrink-0 items-center rounded-md bg-accent-strong/10 px-2.5 text-[12px] font-medium text-accent-text md:ml-auto`,children:`Current`}):(0,X.jsxs)(N,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`h-8 max-md:h-11 no-hover:h-11 md:ml-auto`,disabled:f.isPending,onClick:()=>f.mutate(e),children:[(0,X.jsx)(ie,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),y.length===0?(0,X.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-muted-foreground`,children:[`No branches match “`,h.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-5 flex flex-col items-stretch gap-3`,onSubmit:e=>{e.preventDefault();let t=p.trim();t&&f.mutate(t,{onSuccess:()=>m(``)})},children:[(0,X.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,X.jsxs)(`p`,{"data-slot":`branch-create-base`,className:`-mt-1 text-xs text-muted-foreground`,children:[`Create from `,(0,X.jsx)(`span`,{className:`font-mono text-xs text-foreground`,children:t.branch}),`.`]}),(0,X.jsx)(G,{id:`new-branch-name`,"aria-label":`New branch name`,placeholder:`new-branch-name`,className:`h-11 bg-background placeholder:text-soft-foreground`,value:p,onChange:e=>m(e.target.value)}),(0,X.jsxs)(N,{type:`submit`,variant:`primary`,size:`sm`,className:`min-h-11 self-start`,"data-action":`create-branch`,disabled:!p.trim()||f.isPending,children:[(0,X.jsx)(A,{size:16,"aria-hidden":`true`}),`Create branch`]})]}),(0,X.jsx)(`p`,{"data-slot":`branch-create-note`,className:`mt-4 text-xs leading-relaxed text-muted-foreground`,children:`Switching branches changes your working tree. Review uncommitted changes first.`})]}),s.data?.forge?.available?(0,X.jsx)(xt,{}):null]})}function xt(){let e=p({limit:20});return(0,X.jsxs)(`div`,{"data-slot":`repo-prs`,className:`min-w-0 rounded-xl border border-border bg-card p-5 md:col-span-2`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:`Open pull requests`}),e.isPending?(0,X.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`Loading pull requests…`}):e.isError?(0,X.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:e.error.message}):e.data.available?e.data.prs.length===0?(0,X.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`No open pull requests.`}):(0,X.jsx)(`ul`,{className:`mt-3 flex flex-col divide-y divide-border border-t border-border`,children:e.data.prs.map(e=>(0,X.jsx)(St,{pr:e},e.number))}):(0,X.jsx)(`p`,{"data-slot":`repo-prs-unavailable`,className:`mt-3 text-xs text-muted-foreground`,children:e.data.reason??`The forge is unreachable right now.`})]})}function St({pr:e}){let t=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(k,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`shrink-0 font-mono text-xs 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)(Ct,{checks:e.checks}):null]}),n=`flex min-h-11 min-w-0 items-center gap-2 rounded-sm px-1.5 py-2`;return(0,X.jsx)(`li`,{"data-slot":`pr-row`,"data-number":e.number,children:i(e.url)?(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:a(n,`hover:bg-muted`),children:t}):(0,X.jsx)(`span`,{className:n,children:t})})}function Ct({checks:e}){let t=e===`passing`?_e:e===`failing`?ve:ct;return(0,X.jsxs)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:a(`inline-flex shrink-0 items-center gap-1 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:[(0,X.jsx)(t,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),e]})}var wt={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function Tt({entry:e}){return(0,X.jsx)(`span`,{"data-slot":`branch-class`,className:a(`shrink-0 rounded-[4px] border px-1.5 py-px text-xs leading-4 font-medium`,e.class===`active`?`border-status-running/40 text-status-running`:e.class===`not-landed`||e.class===`orphan`?`border-inbox-count-foreground/40 text-inbox-count-foreground`:`border-border text-soft-foreground`),children:wt[e.class]})}function Z(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 Et(){let e=c(),t=K(),[n,r]=(0,Y.useState)(`unified`),[i,a]=(0,Y.useState)(!0),[o,s]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(null),d=(0,Y.useRef)(null),f=e.isError&&e.error instanceof v&&e.error.status===409,p=e.data?.files??[],m=(0,Y.useMemo)(()=>xe(p),[p]),h=(0,Y.useMemo)(()=>p.some(ut),[p]),g=t?n:`unified`;return(0,X.jsx)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:e.isPending?(0,X.jsx)(`p`,{"data-slot":`changes-loading`,className:`py-6 text-center text-xs text-muted-foreground`,children:`Loading changes…`}):e.isError?(0,X.jsx)(I,{icon:f?(0,X.jsx)(O,{size:16}):(0,X.jsx)(j,{size:16}),tone:f?`neutral`:`danger`,heading:`h2`,title:f?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):p.length===0?(0,X.jsx)(I,{icon:(0,X.jsx)(O,{size:16}),tone:`neutral`,heading:`h2`,title:`Working tree clean`,subtitle:`No uncommitted changes in the main working tree. Edits show up here as they happen.`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-3 gap-y-2 pb-4 [&_button]:min-h-11`,children:[e.data?(0,X.jsx)(Se,{stat:e.data.stat}):null,(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[h?(0,X.jsx)(Te,{preview:o,onPreviewChange:s}):null,(0,X.jsx)(`span`,{className:`flex items-center gap-1.5`,children:(0,X.jsx)(we,{mode:n,wrap:i,onModeChange:r,onWrapChange:a})})]})]}),(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 [--diff-sticky-top:1rem] md:flex-row md:items-start`,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-[288px]`,children:[(0,X.jsx)(`h2`,{"data-slot":`changes-tree-heading`,className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,X.jsx)(be,{root:m,selected:l,onSelect:e=>{u(e),d.current?.scrollToPath(e)}})]}),(0,X.jsx)(dt,{files:p,viewRef:d,mode:g,wrap:i,preview:o,totals:!1,className:`min-w-0 flex-1`})]})]})})}function Dt({repo:e,info:t}){let{sha:n}=re(),r=e.log,i=(0,Y.useMemo)(()=>We(r),[r]);if(n)return(0,X.jsx)(At,{sha:n});let a=Je(e,t),o=a&&a.behind>0?(0,X.jsx)(kt,{info:t,tracking:a}):null;return r.length===0?(0,X.jsxs)(X.Fragment,{children:[o?(0,X.jsx)(`div`,{children:o}):null,(0,X.jsx)(I,{icon:(0,X.jsx)(ue,{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-4`,children:[o,i.map(e=>(0,X.jsxs)(`section`,{"data-slot":`repo-commit-day`,"aria-label":e.label,className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground`,children:e.label}),(0,X.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.commits.map(e=>(0,X.jsxs)(`li`,{className:`flex min-h-[52px] items-center gap-3.5 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,children:[(0,X.jsxs)(F,{to:`/git/commits/${e.hash}`,"data-slot":`commit-row`,"data-sha":e.hash,className:`flex min-h-[52px] min-w-0 flex-1 flex-col justify-center gap-0.5 px-4 py-2 focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,X.jsx)(`span`,{"data-slot":`commit-row-subject`,className:`truncate text-[13px] font-medium text-foreground`,children:e.subject}),(0,X.jsxs)(`span`,{"data-slot":`commit-row-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(pt,{sha:e.hash}),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`}),(0,X.jsxs)(`span`,{className:`truncate`,children:[e.author,` · `,(0,X.jsx)(`span`,{title:lt(e.when,e.at),children:tt(e.when,e.at)})]})]})]}),(0,X.jsx)(Ot,{source:e.source})]},e.hash))})]},e.label))]})}function Ot({source:e}){let t=`hidden max-w-[45%] shrink-0 items-center gap-[5px] pr-4 text-xs text-muted-foreground md:flex`;return e?(0,X.jsxs)(F,{to:`/tasks/${e.runId}`,"data-slot":`commit-source`,"data-source":`task`,"aria-label":`From the task ${e.title}${e.prNumber===null?``:`, pull request #${e.prNumber}`}`,className:a(t,`rounded-[4px] hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`),children:[e.prNumber===null?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(oe,{"aria-hidden":`true`,className:`size-[11px] shrink-0 text-merged-text`}),(0,X.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`PR #`,e.prNumber]})]}),(0,X.jsx)(fe,{"aria-hidden":`true`,className:`size-[12px] shrink-0`}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]}):(0,X.jsx)(`span`,{"data-slot":`commit-source`,"data-source":`unknown`,className:t,children:`no task found`})}function kt({info:e,tracking:t}){let n=Qe(r(),e),i=(0,Y.useRef)(null);return(0,X.jsxs)(`div`,{"data-slot":`git-incoming`,className:`flex min-h-[44px] items-center gap-2.5 rounded-xl border border-border bg-card px-4 py-2`,children:[(0,X.jsx)(gt,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-inbox-count-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 text-[12.5px] text-muted-foreground`,children:[t.behind,` commit`,t.behind===1?``:`s`,` on `,t.ref,` `,t.behind===1?`is`:`are`,` not in your checkout yet`]}),(0,X.jsxs)(`button`,{ref:i,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[28px] shrink-0 items-center gap-[4px] rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 [&>svg]:size-[12px]`,children:[n.pulling?(0,X.jsx)(Ce,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,X.jsx)(de,{"aria-hidden":`true`}),`Pull`]}),(0,X.jsx)(at,{checkout:n,returnFocus:i})]})}function At({sha:e}){return(0,X.jsx)(mt,{commit:s(e),sha:e,backTo:K()?`/git`:et,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-9`})}var jt=`Squash-merged branches may show as not landed without GitHub`;function Mt(e){let t=[],n=[],r=[];for(let i of e)if(i.class===`orphan`)r.push(i);else if(i.class!==`not-landed`)continue;else i.pr&&(i.pr.state===`open`||i.pr.state===`draft`)?n.push(i):t.push(i);return[{key:`no-pr`,title:`No pull request`,note:`nobody sees this work until you act`,rows:t},{key:`pr-open`,title:`Pull request open`,rows:n},{key:`deleted`,title:`Task deleted`,note:`this branch is the only copy of the work`,rows:r}].filter(e=>e.rows.length>0)}function Nt(e){return e.filter(e=>e.class===`active`&&e.runId!==null&&e.ahead>0&&(e.runStatus===`done`||e.runStatus===`failed`||e.runStatus===`cancelled`)).length}function Pt(){let e=g(),t=h(),n=r(),i=_(),[a,o]=(0,Y.useState)(null);if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`not-landed-loading`,role:`status`,className:`py-5 text-[13px] text-muted-foreground`,children:`Loading branches…`});if(e.isError)return(0,X.jsx)(I,{icon:(0,X.jsx)(j,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let s=Mt(e.data.branches),c=s.reduce((e,t)=>e+t.rows.length,0),l=Nt(e.data.branches),u=l>0?(0,X.jsxs)(`p`,{"data-slot":`not-landed-retained`,className:`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,children:[(0,X.jsx)(M,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,X.jsxs)(`span`,{children:[l,` finished task`,l===1?` still has its`:`s still have their`,` worktree and commits not on the base, so `,l===1?`it is`:`they are`,` not listed here.`,` `,`They show here once the worktree is reclaimed in `,(0,X.jsx)(F,{to:L.cleanup,className:`underline underline-offset-2 hover:text-foreground`,children:`Cleanup`}),`.`]})]}):null,d=new Map((t.data??[]).map(e=>[e.id,e.finishedAt]));return(0,X.jsxs)(De,{projectId:n,repoBase:i,requests:s.flatMap(e=>e.rows).flatMap(e=>e.pr?[{projectId:n,kind:`PR`,number:e.pr.number}]:[]),children:[(0,X.jsxs)(`div`,{"data-slot":`repo-not-landed`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[e.data.prStateKnown?null:(0,X.jsx)(Ft,{}),u,s.length===0?(0,X.jsx)(Be,{icon:(0,X.jsx)(st,{size:16}),title:l>0?`Nothing else waiting to land`:`Everything landed`,description:l>0?`Every other finished task's commits are on the base branch, or it made none.`:`Every finished task's commits are on the base branch, or it made none.`,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,X.jsx)(F,{to:L.cleanup,children:`Check cleanup`})}),(0,X.jsx)(N,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,X.jsx)(F,{to:`/`,children:`View tasks`})})]})}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(`div`,{className:`flex flex-col gap-5`,children:s.map(e=>(0,X.jsxs)(`section`,{"data-slot":`not-landed-group`,"data-group":e.key,"aria-label":e.title,className:`flex flex-col gap-1.5`,children:[(0,X.jsxs)(`h2`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.title}),(0,X.jsx)(`span`,{className:`tabular-nums`,children:e.rows.length}),e.note?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{children:e.note})]}):null]}),(0,X.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.rows.map(e=>(0,X.jsx)(It,{entry:e,finishedAt:e.runId?d.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-1.5 px-1 text-xs leading-snug text-muted-foreground`,children:[(0,X.jsx)(M,{"aria-hidden":`true`,className:`mt-px size-3 shrink-0`}),`Delete a branch from its row's … menu. It confirms and names the commits it drops; nothing here is bulk-deleted.`]}),c<=3?(0,X.jsx)(Le,{summary:`${c} ${c===1?`branch`:`branches`} waiting to land. Open a draft PR or inspect worktrees in Cleanup.`,actions:(0,X.jsx)(N,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,X.jsx)(F,{to:L.cleanup,children:`Open cleanup`})})}):null]})]}),(0,X.jsx)(Vt,{entry:a,onClose:()=>o(null)})]})}function Ft({className:e}){return(0,X.jsxs)(`p`,{"data-slot":`git-no-forge`,className:a(`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,e),children:[(0,X.jsx)(M,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),jt,`.`]})}function It({entry:e,finishedAt:t,onDelete:n}){return(0,X.jsxs)(`li`,{"data-slot":`not-landed-row`,"data-branch":e.name,"data-branch-class":e.class,className:`flex min-h-[60px] items-center gap-3 px-4 py-3 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,children:[(0,X.jsx)(zt,{entry:e,finishedAt:t}),(0,X.jsx)(Lt,{entry:e}),(0,X.jsx)(Rt,{entry:e,onDelete:n})]})}function Lt({entry:e}){return(0,X.jsx)(X.Fragment,{children:e.pr?(0,X.jsxs)(`span`,{"data-slot":`not-landed-pr`,className:`hidden shrink-0 items-center gap-1.5 text-xs text-muted-foreground md:flex`,children:[(0,X.jsx)(Oe,{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)(Bt,{entry:e})]}):null})}function Rt({entry:e,onDelete:t}){let n=S(),r=e.class===`orphan`,i=e.pr&&(e.pr.state===`open`||e.pr.state===`draft`)?e.pr:null,o=!r&&e.runId!==null&&!i,s=d({mutationFn:()=>b(e.runId),onSuccess:e=>{w(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:u.repoBranches}),n.invalidateQueries({queryKey:u.runs.all})},onError:e=>w(e instanceof v&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),c=()=>void navigator.clipboard.writeText(e.name).then(()=>w(`Copied ${e.name}`),()=>w(`Could not copy the branch name`,{tone:`danger`})),l=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-sm px-2.5 text-[12.5px] font-medium text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 [&>svg]:size-[12px]`;return(0,X.jsxs)(X.Fragment,{children:[e.runId?(0,X.jsx)(F,{to:`/tasks/${e.runId}`,"data-action":`not-landed-open`,className:a(l,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:`Open task`}):null,o?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-create-pr`,disabled:s.isPending,onClick:()=>s.mutate(),className:a(l,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[(0,X.jsx)(_t,{"aria-hidden":`true`}),s.isPending?`Creating…`:`Draft PR`]}):null,r?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,onClick:c,className:a(l,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[(0,X.jsx)(me,{"aria-hidden":`true`}),`Copy branch`]}):null,(0,X.jsxs)(Me,{children:[(0,X.jsx)(Ae,{"data-action":`not-landed-more`,"aria-label":`More actions for ${e.name}`,className:`flex size-8 shrink-0 items-center justify-center rounded-sm text-soft-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:size-11`,children:(0,X.jsx)(he,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,X.jsxs)(je,{align:`end`,className:`w-52`,children:[e.runId?(0,X.jsx)(P,{asChild:!0,className:`md:hidden`,children:(0,X.jsx)(F,{to:`/tasks/${e.runId}`,children:`Open task`})}):null,o?(0,X.jsx)(P,{className:`md:hidden`,disabled:s.isPending,onSelect:()=>s.mutate(),children:`Draft PR`}):null,(0,X.jsx)(P,{className:a(!r&&`md:hidden`),onSelect:c,children:`Copy branch`}),(0,X.jsx)(ke,{className:`md:hidden`}),(0,X.jsx)(P,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function zt({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=t??e.lastCommit.at,a=Pe(i),o=e.runStatus?qe(e.runStatus):void 0,s=n||!o?a:`${o.label}${a?` ${a}`:``}`,c=Number.isFinite(Date.parse(i))?new Date(i).toLocaleString():void 0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`flex size-[12px] shrink-0 items-center justify-center`,children:n?(0,X.jsx)(ye,{"aria-label":`Task deleted`,className:`size-[12px] text-muted-foreground`}):(0,X.jsx)(Ne,{tone:o?.tone??`neutral`,shape:o?.shape??`filled`,"aria-label":o?.label})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[e.runId?(0,X.jsx)(F,{to:`/tasks/${e.runId}`,"data-slot":`not-landed-title`,className:`min-w-0 truncate rounded-[2px] text-[13px] font-medium text-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:r}):(0,X.jsx)(`span`,{"data-slot":`not-landed-title`,className:`min-w-0 truncate text-[13px] font-medium text-foreground`,title:r,children:r}),(0,X.jsxs)(`span`,{"data-slot":`not-landed-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),(0,X.jsx)(Q,{}),(0,X.jsxs)(`span`,{className:`shrink-0`,children:[e.ahead,` commit`,e.ahead===1?``:`s`]}),e.diffStat?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(ft,{adds:e.diffStat.additions,dels:e.diffStat.deletions})]}):null,s?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{className:`truncate`,title:c,children:s})]}):null]}),e.parentRunId?(0,X.jsx)(F,{to:`/tasks/${e.parentRunId}`,"data-slot":`not-landed-parent`,className:`w-fit rounded-[2px] text-xs text-muted-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:`Worker of its parent task`}):null,(0,X.jsx)(yt,{entry:e})]})]})}function Q(){return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`})}function Bt({entry:e}){let t=m(Ee(`PR`,e.pr?.number).status),n=e.pr?.state,r=n===`draft`||n===`closed`?n:t?t.label.toLowerCase():`open`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{"data-slot":`not-landed-pr-state`,children:r})]})}function Vt({entry:e,onClose:t}){let n=S(),[r,i]=(0,Y.useState)(``),a=(0,Y.useId)(),o=d({mutationFn:e=>x({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;w(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:u.repo}),s()},onError:e=>w(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)(U,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&s(),children:(0,X.jsxs)(W,{"data-slot":`delete-branch-dialog`,children:[(0,X.jsxs)(J,{children:[(0,X.jsxs)(B,{children:[`Delete `,e?.name,`?`]}),(0,X.jsx)(R,{asChild:!0,children:(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`p`,{children:e?.class===`orphan`?`Its task was deleted, so this branch is the only copy of the work.`:(0,X.jsxs)(X.Fragment,{children:[`This drops the work of `,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:e?.title??e?.name}),`. It is not on the base branch`,e?.pr?``:` and no pull request carries it`,`.`]})}),(0,X.jsxs)(`p`,{"data-slot":`delete-branch-dropped`,children:[l,` will be dropped`,e?.diffStat?` (+${e.diffStat.additions} −${e.diffStat.deletions})`:``,`, the latest “`,e?.lastCommit.subject,`”`,e?.lastCommit.sha?(0,X.jsxs)(X.Fragment,{children:[` (`,(0,X.jsx)(Xe,{sha:e.lastCommit.sha,variant:`inline`}),`)`]}):null,`.`]})]})})]}),(0,X.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),c&&e&&!o.isPending&&o.mutate(e.name)},className:`flex flex-col gap-[6px]`,children:[(0,X.jsxs)(`label`,{htmlFor:a,className:`text-[12.5px] text-muted-foreground`,children:[`Type `,(0,X.jsx)(`span`,{className:`font-mono text-foreground`,children:e?.name}),` to confirm`]}),(0,X.jsx)(G,{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)(V,{children:[(0,X.jsx)(H,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,X.jsx)(z,{"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 Ht({base:e}){let t=g(),n=S(),[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],f=d({mutationFn:e=>x({names:e}),onSuccess:e=>{let t=e.refused.length;w(`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:u.repo})},onError:e=>{n.invalidateQueries({queryKey:u.repo}),w(e.message,{tone:`danger`})}});if(t.isPending)return(0,X.jsx)(`p`,{"data-slot":`cleanup-branches-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading branches…`});if(t.isError)return(0,X.jsxs)(`p`,{"data-slot":`cleanup-branches-error`,className:`text-[13px] text-danger`,children:[`Branches did not load: `,t.error.message]});let p=l.length,m=`branch${p===1?``:`es`}`;return(0,X.jsxs)(`section`,{"data-slot":`cleanup-branches`,"aria-labelledby":`cleanup-branches-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`cleanup-branches-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Branches safe to delete · `,p]}),(0,X.jsxs)(`p`,{className:`text-xs leading-[17px] text-soft-foreground`,children:[`Their work is already on `,e,`, or they have none. Deleting loses nothing.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`cleanup-branches-delete`,disabled:p===0||f.isPending,onClick:()=>o(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(le,{"aria-hidden":`true`,className:`size-[12px]`}),f.isPending?`Deleting…`:`Delete ${p} ${m}`]})]}),(0,X.jsx)(Ut,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:jt.toLowerCase(),rows:s,open:r.merged,onToggle:()=>i(e=>({...e,merged:!e.merged}))}),(0,X.jsx)(Ut,{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)(U,{open:a,onOpenChange:o,children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(J,{children:[(0,X.jsxs)(B,{children:[`Delete `,p,` `,m,`?`]}),(0,X.jsxs)(R,{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)(V,{children:[(0,X.jsx)(H,{children:`Keep them`}),(0,X.jsxs)(z,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{f.mutate(l.map(e=>e.name)),o(!1)},children:[`Delete `,p,` `,m]})]})]})})]})}function Ut({kind:e,title:t,hint:n,rows:r,open:i,onToggle:o}){let s=`cleanup-branches-${e}`;return(0,X.jsxs)(`div`,{"data-slot":`cleanup-branch-group`,"data-group":e,className:`border-b border-border last:border-0`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":s,disabled:r.length===0,onClick:o,className:`flex min-h-[44px] w-full items-center gap-[12px] px-[14px] py-[4px] text-left hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:hover:bg-transparent`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`span`,{className:`truncate text-[12.5px] text-foreground`,children:[t,` · `,r.length]}),(0,X.jsx)(`span`,{className:`truncate text-xs text-soft-foreground`,children:n})]}),r.length>0?(0,X.jsx)(pe,{"aria-hidden":`true`,className:a(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,i&&`rotate-90`)}):null]}),i?(0,X.jsx)(`ul`,{id:s,"aria-label":t,className:`flex flex-col pb-[6px]`,children:r.map(e=>(0,X.jsxs)(`li`,{"data-slot":`cleanup-branch-row`,"data-branch":e.name,className:`flex min-h-[32px] items-center gap-[10px] px-[14px] pl-[26px] text-xs`,children:[(0,X.jsx)(He,{value:e.name,className:`shrink-0 text-muted-foreground`}),e.runId?(0,X.jsx)(F,{to:`/tasks/${e.runId}`,className:`min-w-0 flex-1 truncate text-soft-foreground underline-offset-2 hover:text-foreground hover:underline`,children:e.title??`Open the task`}):(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-soft-foreground`,children:e.lastCommit.subject}),e.pr?(0,X.jsxs)(`span`,{className:`shrink-0 text-soft-foreground`,children:[`PR #`,e.pr.number]}):null,(0,X.jsx)(it,{iso:e.lastCommit.at,className:`shrink-0 text-soft-foreground`})]},e.name))}):null]})}function $(e){return e.some(e=>e.sizeBytes===null)?null:e.reduce((e,t)=>e+(t.sizeBytes??0),0)}function Wt(e){return e.kind===`dirty`?`${e.uncommittedFiles} uncommitted`:e.kind===`detached-head`?`detached HEAD`:e.kind===`submodules`?`has submodules`:`broken worktree`}function Gt(e){if(e.kind===`dirty`){let t=`${e.uncommittedFiles} uncommitted file${e.uncommittedFiles===1?``:`s`}`;return e.detachedHead?`${t} and a detached HEAD on no branch`:t}return e.kind===`detached-head`?`a detached HEAD whose commit is on no branch`:e.kind===`submodules`?`initialized submodules that Git will not remove without force`:`an unregistered or broken Git worktree directory`}function Kt(e){let t=e.some(e=>e.reclaimBlocker?.kind===`dirty`),n=e.some(e=>e.reclaimBlocker?.kind===`detached-head`||e.reclaimBlocker?.kind===`dirty`&&e.reclaimBlocker.detachedHead),r=e.some(e=>e.reclaimBlocker?.kind===`submodules`),i=e.some(e=>e.reclaimBlocker?.kind===`invalid`),a=[...t?[`uncommitted work`]:[],...n?[`a detached HEAD`]:[],...r?[`initialized submodules`]:[],...i?[`a broken checkout`]:[]];return a.length<=1?a[0]??`uncommitted work`:`${a.slice(0,-1).join(`, `)} or ${a.at(-1)}`}function qt(e,t,n){let r=Math.max(0,t-e);return e===0?r===0?`Nothing to reclaim — no finished worktrees exceed the keep limit`:n?`Nothing was reclaimed — the worktrees past the keep limit are in use or could not be removed`:`Nothing was reclaimed — the worktrees past the keep limit have uncommitted work or are in use`:`Reclaimed ${e} worktree${e===1?``:`s`} (branch kept)${r>0?` · ${r} kept: ${n?`in use or could not be removed`:`uncommitted work or in use`}`:``}`}function Jt(e,t){return e===0?`Reclaim now`:t?`Reclaim ${D(t)} now`:`Reclaim ${e} now`}function Yt(e,t,n){let r=t?D(t):String(e);return n?`Discard & reclaim all ${r}`:`Discard & reclaim ${r}`}function Xt(e,t){if(!e)return t>0?`No clean worktrees past the keep limit — use Discard & reclaim for blocked worktrees`:`Nothing past the keep limit to reclaim`}function Zt(e){return e===0?{prefix:`Retention is unlimited (`,suffix:`), so nothing is reclaimed on its own.`}:{prefix:`Retention keeps the newest ${e} finished checkout${e===1?``:`s`} (`,suffix:`) and reclaims the rest.`}}function Qt({blocked:e,discardLabel:t,disabled:n,onDiscard:r}){let i=$(e),a=e.length===1?``:`s`,o=e.length===1?`it has`:`they have`;return(0,X.jsxs)(`div`,{"data-slot":`worktrees-blocked-banner`,className:`flex flex-col gap-[10px] border-b border-border bg-muted/40 px-[14px] py-[10px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`p`,{className:`min-w-0 flex-1 text-[12px] leading-[17px] text-foreground`,children:[e.length,` worktree`,a,` past the keep limit`,i?` (${D(i)})`:``,` `,`cannot be reclaimed automatically because `,o,` `,Kt(e),`.`]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`worktrees-discard-reclaim`,disabled:n,onClick:r,className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] border border-danger/40 px-[10px] text-[12px] font-medium text-danger hover:bg-danger/10 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 md:self-center`,children:[(0,X.jsx)(q,{"aria-hidden":`true`,className:`size-[12px]`}),t]})]})}function $t({confirmClean:e,onCloseClean:t,cleanCount:n,cleanBytes:r,reclaimLabel:i,onConfirmClean:a,discardBatch:o,onCloseDiscardBatch:s,onConfirmDiscardBatch:c,discardRow:l,onCloseRow:u,onConfirmRow:d}){let f=o?$(o):null,p=o?o.filter(e=>e.reclaimBlocker!==null).length:0,m=o?o.some(e=>!e.reclaimBlocker):!1,h=o?Yt(o.length,f,m):``;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(U,{open:e,onOpenChange:e=>{e||t()},children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(J,{children:[(0,X.jsx)(B,{children:`Reclaim old worktrees?`}),(0,X.jsxs)(R,{children:[n,` finished worktree`,n===1?``:`s`,` beyond the keep limit`,r?` (${D(r)})`:``,` `,n===1?`is`:`are`,` reclaimed now, directory only. Their branches are kept, so the work stays recoverable.`]})]}),(0,X.jsxs)(V,{children:[(0,X.jsx)(H,{children:`Keep them`}),(0,X.jsx)(z,{"data-action":`worktrees-confirm`,onClick:a,children:i})]})]})}),(0,X.jsx)(U,{open:o!==null,onOpenChange:e=>{e||s()},children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(J,{children:[(0,X.jsx)(B,{children:`Discard changes and reclaim worktrees?`}),(0,X.jsx)(R,{children:o?(0,X.jsxs)(X.Fragment,{children:[o.length,` finished worktree`,o.length===1?``:`s`,` beyond the keep limit`,f?` (${D(f)})`:``,` will be reclaimed now.`,` `,`Uncommitted files and detached-HEAD commits in `,p,` blocked checkout`,p===1?``:`s`,` will be permanently discarded. Each task’s branch is kept.`]}):null})]}),(0,X.jsxs)(V,{children:[(0,X.jsx)(H,{children:`Keep them`}),(0,X.jsx)(z,{"data-action":`worktrees-discard-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{o&&c(o),s()},children:h})]})]})}),(0,X.jsx)(U,{open:l!==null,onOpenChange:e=>{e||u()},children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(J,{children:[(0,X.jsx)(B,{children:`Discard changes and reclaim worktree?`}),(0,X.jsx)(R,{children:l?.reclaimBlocker?(0,X.jsxs)(X.Fragment,{children:[l.title,` has `,Gt(l.reclaimBlocker),`. Reclaiming removes the directory and permanently discards uncommitted or unbranched changes in it. The branch (`,l.branch??l.runId.slice(0,8),`) is kept.`]}):null})]}),(0,X.jsxs)(V,{children:[(0,X.jsx)(H,{children:`Keep it`}),(0,X.jsx)(z,{"data-action":`worktree-discard-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{l&&d(l),u()},children:`Discard & reclaim`})]})]})})]})}function en(){let e=f(),t=l().data?.targets.find(e=>e.id===`finder`),n=d({mutationFn:e=>te(e,t.id),onError:e=>w(e.message,{tone:`danger`})}),r=S(),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(null),[c,p]=(0,Y.useState)(null),m=()=>Promise.all([r.invalidateQueries({queryKey:u.worktrees}),r.invalidateQueries({queryKey:u.repoBranches})]),h=d({mutationFn:({runIds:e})=>ne(e?{discardWork:!0,runIds:e}:void 0),onSuccess:(e,{expected:t,runIds:n})=>{m(),w(qt(e.reclaimed.length,t,!!n))},onError:e=>w(e.message,{tone:`danger`})}),g=d({mutationFn:({worktree:e,discardWork:t})=>y(e.runId,t?{discardWork:!0}:void 0),onSuccess:(e,{worktree:t})=>{m(),w(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{m(),w(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:_,totalBytes:ee,keep:v}=e.data,b=h.isPending||g.isPending,x=_.filter(e=>e.pastKeep),C=x.filter(e=>!e.reclaimBlocker),T=x.filter(e=>e.reclaimBlocker!==null),E=C.length>0,re=$(C),ie=$(x),O=Jt(C.length,re),ae=Yt(x.length,ie,E),k=ee?D(ee):null,A=Zt(v);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`,k?` · ${k}`:``]}),(0,X.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-xs leading-[17px] text-soft-foreground`,children:[A.prefix,(0,X.jsx)(F,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:rt(`worktrees`,` › `)}),A.suffix,` `,`Reclaim removes the directory only; the branch stays, so its work stays recoverable.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`worktrees-reclaim-now`,disabled:b||!E,title:Xt(E,T.length),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)(q,{"aria-hidden":`true`,className:`size-[12px]`}),O]})]}),T.length>0?(0,X.jsx)(Qt,{blocked:T,discardLabel:ae,disabled:b,onDiscard:()=>s(x)}):null,_.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:_.map(e=>(0,X.jsx)(rn,{worktree:e,keep:v,disabled:b,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>{e.reclaimBlocker?p(e):g.mutate({worktree:e,discardWork:!1})}},e.runId))}),(0,X.jsx)($t,{confirmClean:i,onCloseClean:()=>a(!1),cleanCount:C.length,cleanBytes:re,reclaimLabel:O,onConfirmClean:()=>{h.mutate({expected:C.length}),a(!1)},discardBatch:o,onCloseDiscardBatch:()=>s(null),onConfirmDiscardBatch:e=>{h.mutate({expected:e.length,runIds:e.map(e=>e.runId)})},discardRow:c,onCloseRow:()=>p(null),onConfirmRow:e=>g.mutate({worktree:e,discardWork:!0})})]})}var tn=new Set([`queued`,`running`,`waiting`,`review`]);function nn(e,t){return tn.has(e.status)||!e.reclaimable?{label:`in use`,tone:`in-use`,state:`in-use`}:e.reclaimBlocker?{label:Wt(e.reclaimBlocker),tone:`blocked`,state:`blocked`}:e.pastKeep?{label:`reclaimable`,tone:`plain`,state:`reclaimable`}:{label:t>0?`kept · newest ${t}`:`kept`,tone:`plain`,state:`kept`}}function rn({worktree:e,keep:t,disabled:n,onOpen:r,opening:i,onReclaim:o}){let s=nn(e,t),c=Pe(e.finishedAt??void 0),l=e.status===`review`?`at review`:c?`${e.status} ${Fe(c)}`:e.status,u=s.tone===`in-use`?`text-status-running`:s.tone===`blocked`?`text-danger`:`text-soft-foreground`,d=e.reclaimBlocker?`Cannot auto-reclaim: ${Gt(e.reclaimBlocker)}`:void 0,f=(0,X.jsx)(`span`,{"data-slot":`worktree-state`,"data-state":s.state,title:d,className:a(`text-xs`,u),children:s.label}),p=`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`,m=e.reclaimBlocker?`Discard changes and reclaim the worktree of ${e.title} (branch kept)`:`Reclaim the worktree of ${e.title} (branch kept)`,h=e.reclaimBlocker?`Discard changes and reclaim the directory (branch kept)`:`Reclaim the directory (branch kept)`;return(0,X.jsxs)(`li`,{"data-slot":`worktree-row`,"data-run":e.runId,className:`flex min-h-[44px] items-center gap-[12px] border-b border-border px-[14px] py-[4px] last:border-0`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsx)(`span`,{className:`truncate text-[12.5px] text-foreground`,title:e.title,children:e.title}),(0,X.jsxs)(`span`,{className:`truncate font-mono text-xs text-soft-foreground`,children:[e.branch??e.runId.slice(0,8),` · `,l,(0,X.jsxs)(`span`,{className:`md:hidden`,children:[` · `,s.label]})]})]}),(0,X.jsx)(`span`,{"data-slot":`worktree-size`,className:`shrink-0 text-xs tabular-nums text-muted-foreground`,children:e.sizeBytes===null?`—`:D(e.sizeBytes)||`0 kB`}),(0,X.jsx)(`span`,{className:`hidden shrink-0 md:inline`,children:f}),r?(0,X.jsx)(`button`,{type:`button`,className:p,"aria-label":`Open folder for ${e.title}`,title:`Open folder`,disabled:i,onClick:r,children:(0,X.jsx)(ae,{"aria-hidden":`true`,className:`size-[13px]`})}):null,s.tone===`in-use`?null:(0,X.jsx)(`button`,{type:`button`,"data-action":`worktree-reclaim`,"aria-label":m,title:h,disabled:n,onClick:o,className:a(p,e.reclaimBlocker&&`text-danger hover:text-danger`),children:(0,X.jsx)(q,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function an(e){return e===`main`||e===`changes`?`Split`:`Table`}function on({section:e,index:t=!1}){let n=o(),r=K(),[i]=E(),a=an(e);if(t&&!r&&i.get(`view`)!==`repo`)return(0,X.jsx)(vt,{});if(n.isPending)return(0,X.jsx)(nt,{});if(n.isError)return(0,X.jsx)(Re,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,X.jsx)(Ke,{}),children:(0,X.jsx)(I,{icon:(0,X.jsx)(j,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:n.error.message})});let s=n.data.info;return s?(0,X.jsx)(sn,{repo:n.data,info:s,section:e}):(0,X.jsx)(Re,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,X.jsx)(Ke,{}),children:(0,X.jsx)(I,{icon:(0,X.jsx)(ie,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`Squawk is running outside a git repository — start it inside one to browse changes, commits and branches.`})})}function sn({repo:e,info:t,section:n}){let r=an(n),i=g(),a=n===`main`?e.log.length:n===`changes`?e.status.length:n===`branches`?Z(e,i.data?.branches).length:n===`not-landed`?i.data?.branches.filter(e=>e.class===`not-landed`||e.class===`orphan`).length??0:4;return(0,X.jsx)(Re,{template:r,route:`repo-git`,density:n===`not-landed`&&i.isPending?`full`:Ie(a),rootProps:{"data-git-section":n},beforeHeader:(0,X.jsx)(Ke,{}),header:{title:ot(n,t.branch),headerSlot:`repo-header`,subtitle:(0,X.jsx)(cn,{repo:e,info:t,section:n}),subtitleSlot:`repo-meta`},children:n===`main`?(0,X.jsx)(Dt,{repo:e,info:t}):n===`not-landed`?(0,X.jsx)(Pt,{}):n===`cleanup`?(0,X.jsxs)(`div`,{"data-slot":`repo-cleanup`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[(0,X.jsx)(en,{}),(0,X.jsx)(Ht,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,X.jsx)(bt,{repo:e,info:t}):(0,X.jsx)(Et,{})})}function cn({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?` · ${Ye(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)(ln,{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 ln({repo:e,info:t}){let n=Z(e,g().data?.branches).length;return(0,X.jsxs)(X.Fragment,{children:[n,` branch`,n===1?``:`es`,` · on `,t.branch]})}export{on as RepoGitRoute};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{B as r,N as i}from"./queries-ClkIgWFx.js";import{Fn as a,nt as o}from"./toaster-C-xqAWVX.js";import{f as s,g as c,h as l,i as u,n as d,p as f}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{ot as p,r as m}from"./design-icons-CzEoMH9c.js";import{a as h,c as g,l as _,s as v,t as y}from"./file-preview-C0EtwJYH.js";import{t as b}from"./button-B7MKxYjT.js";import{t as x}from"./centered-state-V15AR_qo.js";import{_ as S,g as C,h as w}from"./index-BX94wp6m.js";import{r as T}from"./html-report-BX3msvci.js";import{t as E}from"./html-report-frame-uuqkBC0u.js";var D=e(t(),1),O=n();function k(){let e=s(),t=f();return()=>{if(e.key==="default"||window.history.state?.idx===0){t({pathname:e.pathname.replace(/\/report\/?$/,``)},{replace:!0});return}let n=window.navigation,r=A(e.state);n?.canGoBack?n.back():r?t(r,{state:{filesRestoreKey:e.state?.filesRestoreKey}}):t(-1)}}function A(e){let t=e?.readerFrom;return typeof t==`string`&&t.startsWith(`/`)&&!t.startsWith(`//`)?t:null}function j(e){return e?.type===`file`?e:null}function M(){let[e]=c(),t=e.get(`path`),n=e.get(`artifact`);return{path:t,artifactId:n,conflict:e.getAll(`path`).length>1||e.getAll(`artifact`).length>1||t!==null&&n!==null||t===``||n===``}}function N(){let{id:e=``}=l(),t=M(),n=s(),r=k();return(0,O.jsx)(P,{runId:e,selection:t,fragment:n.hash,onBack:r,variant:`route`})}function P({runId:e,selection:t,fragment:n,onBack:r,variant:i,sourceLookup:a}){let{path:o,conflict:c,selected:l,result:d}=I(e,t,a),f=S(w,!0),p=S(C,!1),m=s(),[h,g]=(0,D.useState)(!1),_=j(d.data);if(i===`route`&&L(_))return(0,O.jsx)(u,{replace:!0,to:{pathname:m.pathname.replace(/\/report\/?$/,`/files`),search:m.search,hash:m.hash}});let v=z(_,o),y=i===`pane`&&!p&&!f?`Conversation`:`Back`,b=i===`pane`&&!h&&R(_),x=F(m.pathname,e,t);return(0,O.jsxs)(`div`,{"data-route":`task-report`,"data-variant":i,onKeyDown:e=>{i!==`pane`||e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),e.stopPropagation(),r())},className:i===`route`?`fixed inset-0 z-50 flex flex-col bg-background [padding-block-start:env(safe-area-inset-top)] [padding-inline-end:env(safe-area-inset-right)] [padding-block-end:env(safe-area-inset-bottom)] [padding-inline-start:env(safe-area-inset-left)] md:static md:z-auto md:h-full md:p-0`:`flex h-full min-h-0 flex-col bg-background max-md:[padding-block-start:env(safe-area-inset-top)] max-md:[padding-inline-start:env(safe-area-inset-left)] max-md:[padding-inline-end:env(safe-area-inset-right)]`,children:[(0,O.jsx)(B,{runId:e,file:_,name:v,source:h,onSource:()=>g(e=>!e),onBack:r,backLabel:y,hideDownload:i===`pane`&&p,focusBack:i===`pane`}),(0,O.jsx)(`div`,{"data-slot":`report-body`,className:b?`flex min-h-0 flex-1 flex-col overflow-clip`:`flex min-h-0 flex-1 flex-col overflow-auto`,children:(0,O.jsx)(V,{conflict:c,selected:l,result:d,source:h,name:v,fragment:n,pane:i===`pane`,filesHref:x})})]})}function F(e,t,n){let r=/^\/p\/[^/]+/.exec(e)?.[0]??``,i=n.artifactId?new URLSearchParams({artifact:n.artifactId}):new URLSearchParams({path:n.path??``});return`${r}/tasks/${encodeURIComponent(t)}/files?${i}`}function I(e,t,n){let{path:a=null,artifactId:o=null,conflict:s=!1}=t,c=n?.isPending||n?.isError,l=r(e,o||s||c?null:a),u=i(e,s||c?null:o),d=c&&n?{...n,data:void 0}:o?u:l;return{path:a,conflict:s,selected:a!==null||o!==null,result:d}}function L(e){return e!==null&&(!T(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 u=(0,D.useRef)(null);(0,D.useEffect)(()=>{l&&u.current?.focus({preventScroll:!0})},[l]);let d=t?.artifact;return(0,O.jsxs)(`header`,{"data-slot":`report-bar`,className:`flex min-h-14 shrink-0 items-center gap-2 border-b border-border bg-card px-2 md:px-4`,children:[(0,O.jsxs)(b,{ref:u,variant:`ghost`,className:`min-h-11 min-w-11 gap-1.5 px-2`,onClick:a,"aria-label":s,children:[(0,O.jsx)(m,{size:18,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`max-sm:sr-only`,children:s})]}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`h1`,{className:`truncate text-sm font-medium`,children:n}),t?(0,O.jsxs)(`p`,{className:`truncate text-xs text-soft-foreground`,children:[d?`Published snapshot · ${new Date(d.createdAt).toLocaleString()}`:`Live file`,` · `,h(t.size)]}):null]}),t&&!t.tooLarge&&!t.binary?(0,O.jsx)(b,{variant:`ghost`,className:`min-h-11 px-3 text-accent-text`,onClick:i,children:r?`Preview`:`Source`}):null,d&&!c?(0,O.jsx)(`a`,{className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline focus-visible:ring-2`,href:o(e,d.id,`download`),children:`Download`}):null]})}function V({conflict:e,selected:t,result:n,source:r,name:i,fragment:a,pane:o,filesHref:s}){if(e)return(0,O.jsx)(U,{icon:(0,O.jsx)(v,{}),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 c=n.data;return c.type===`file`?o&&!T(c.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)(d,{to:s,className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:`Open in Files`})}):c.tooLarge?(0,O.jsx)(U,{icon:(0,O.jsx)(_,{}),title:`Too large to preview`,subtitle:`${h(c.size)} is past the 500 kB preview limit. Download it to read it.`}):c.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)(y,{path:c.path,text:c.content??``})}):(0,O.jsx)(E,{html:c.content??``,title:`Report: ${i}`,fragment:a,className:o?`min-h-0 flex-1`:`min-h-[60dvh] flex-1`}):(0,O.jsx)(U,{icon:(0,O.jsx)(v,{}),title:c.type===`unpublished`?`Report not published`:`Report unavailable`,subtitle:c.reason})}function H({result:e}){let t=e.error instanceof a&&e.error.status===404;return(0,O.jsx)(U,{icon:t?(0,O.jsx)(v,{}):(0,O.jsx)(p,{size:16}),tone:t?`neutral`:`danger`,title:t?`Report missing or deleted`:`Could not load this report`,subtitle:e.error?.message??`Try again.`,action:(0,O.jsx)(b,{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)(x,{icon:e,tone:r,heading:`h2`,title:t,subtitle:n}),i]})}export{P as ReportReader,N as TaskReportRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{B as r,N as i}from"./queries-CYWRnyM5.js";import{Fn as a,nt as o}from"./toaster-B0kvcFif.js";import{f as s,g as c,h as l,i as u,n as d,p as f}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{ot as p,r as m}from"./design-icons-CzEoMH9c.js";import{a as h,c as g,l as _,s as v,t as y}from"./file-preview-B361k1Oo.js";import{t as b}from"./button-B7MKxYjT.js";import{t as x}from"./centered-state-V15AR_qo.js";import{_ as S,g as C,v as w}from"./index-mCjln54E.js";import{r as T}from"./html-report-BX3msvci.js";import{t as E}from"./html-report-frame-uuqkBC0u.js";var D=e(t(),1),O=n();function k(){let e=s(),t=f();return()=>{if(e.key==="default"||window.history.state?.idx===0){t({pathname:e.pathname.replace(/\/report\/?$/,``)},{replace:!0});return}let n=window.navigation,r=A(e.state);n?.canGoBack?n.back():r?t(r,{state:{filesRestoreKey:e.state?.filesRestoreKey}}):t(-1)}}function A(e){let t=e?.readerFrom;return typeof t==`string`&&t.startsWith(`/`)&&!t.startsWith(`//`)?t:null}function j(e){return e?.type===`file`?e:null}function M(){let[e]=c(),t=e.get(`path`),n=e.get(`artifact`);return{path:t,artifactId:n,conflict:e.getAll(`path`).length>1||e.getAll(`artifact`).length>1||t!==null&&n!==null||t===``||n===``}}function N(){let{id:e=``}=l(),t=M(),n=s(),r=k();return(0,O.jsx)(P,{runId:e,selection:t,fragment:n.hash,onBack:r,variant:`route`})}function P({runId:e,selection:t,fragment:n,onBack:r,variant:i,sourceLookup:a}){let{path:o,conflict:c,selected:l,result:d}=I(e,t,a),f=w(C,!0),p=w(S,!1),m=s(),[h,g]=(0,D.useState)(!1),_=j(d.data);if(i===`route`&&L(_))return(0,O.jsx)(u,{replace:!0,to:{pathname:m.pathname.replace(/\/report\/?$/,`/files`),search:m.search,hash:m.hash}});let v=z(_,o),y=i===`pane`&&!p&&!f?`Conversation`:`Back`,b=i===`pane`&&!h&&R(_),x=F(m.pathname,e,t);return(0,O.jsxs)(`div`,{"data-route":`task-report`,"data-variant":i,onKeyDown:e=>{i!==`pane`||e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),e.stopPropagation(),r())},className:i===`route`?`fixed inset-0 z-50 flex flex-col bg-background [padding-block-start:env(safe-area-inset-top)] [padding-inline-end:env(safe-area-inset-right)] [padding-block-end:env(safe-area-inset-bottom)] [padding-inline-start:env(safe-area-inset-left)] md:static md:z-auto md:h-full md:p-0`:`flex h-full min-h-0 flex-col bg-background max-md:[padding-block-start:env(safe-area-inset-top)] max-md:[padding-inline-start:env(safe-area-inset-left)] max-md:[padding-inline-end:env(safe-area-inset-right)]`,children:[(0,O.jsx)(B,{runId:e,file:_,name:v,source:h,onSource:()=>g(e=>!e),onBack:r,backLabel:y,hideDownload:i===`pane`&&p,focusBack:i===`pane`}),(0,O.jsx)(`div`,{"data-slot":`report-body`,className:b?`flex min-h-0 flex-1 flex-col overflow-clip`:`flex min-h-0 flex-1 flex-col overflow-auto`,children:(0,O.jsx)(V,{conflict:c,selected:l,result:d,source:h,name:v,fragment:n,pane:i===`pane`,filesHref:x})})]})}function F(e,t,n){let r=/^\/p\/[^/]+/.exec(e)?.[0]??``,i=n.artifactId?new URLSearchParams({artifact:n.artifactId}):new URLSearchParams({path:n.path??``});return`${r}/tasks/${encodeURIComponent(t)}/files?${i}`}function I(e,t,n){let{path:a=null,artifactId:o=null,conflict:s=!1}=t,c=n?.isPending||n?.isError,l=r(e,o||s||c?null:a),u=i(e,s||c?null:o),d=c&&n?{...n,data:void 0}:o?u:l;return{path:a,conflict:s,selected:a!==null||o!==null,result:d}}function L(e){return e!==null&&(!T(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 u=(0,D.useRef)(null);(0,D.useEffect)(()=>{l&&u.current?.focus({preventScroll:!0})},[l]);let d=t?.artifact;return(0,O.jsxs)(`header`,{"data-slot":`report-bar`,className:`flex min-h-14 shrink-0 items-center gap-2 border-b border-border bg-card px-2 md:px-4`,children:[(0,O.jsxs)(b,{ref:u,variant:`ghost`,className:`min-h-11 min-w-11 gap-1.5 px-2`,onClick:a,"aria-label":s,children:[(0,O.jsx)(m,{size:18,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`max-sm:sr-only`,children:s})]}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`h1`,{className:`truncate text-sm font-medium`,children:n}),t?(0,O.jsxs)(`p`,{className:`truncate text-xs text-soft-foreground`,children:[d?`Published snapshot · ${new Date(d.createdAt).toLocaleString()}`:`Live file`,` · `,h(t.size)]}):null]}),t&&!t.tooLarge&&!t.binary?(0,O.jsx)(b,{variant:`ghost`,className:`min-h-11 px-3 text-accent-text`,onClick:i,children:r?`Preview`:`Source`}):null,d&&!c?(0,O.jsx)(`a`,{className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline focus-visible:ring-2`,href:o(e,d.id,`download`),children:`Download`}):null]})}function V({conflict:e,selected:t,result:n,source:r,name:i,fragment:a,pane:o,filesHref:s}){if(e)return(0,O.jsx)(U,{icon:(0,O.jsx)(v,{}),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 c=n.data;return c.type===`file`?o&&!T(c.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)(d,{to:s,className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:`Open in Files`})}):c.tooLarge?(0,O.jsx)(U,{icon:(0,O.jsx)(_,{}),title:`Too large to preview`,subtitle:`${h(c.size)} is past the 500 kB preview limit. Download it to read it.`}):c.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)(y,{path:c.path,text:c.content??``})}):(0,O.jsx)(E,{html:c.content??``,title:`Report: ${i}`,fragment:a,className:o?`min-h-0 flex-1`:`min-h-[60dvh] flex-1`}):(0,O.jsx)(U,{icon:(0,O.jsx)(v,{}),title:c.type===`unpublished`?`Report not published`:`Report unavailable`,subtitle:c.reason})}function H({result:e}){let t=e.error instanceof a&&e.error.status===404;return(0,O.jsx)(U,{icon:t?(0,O.jsx)(v,{}):(0,O.jsx)(p,{size:16}),tone:t?`neutral`:`danger`,title:t?`Report missing or deleted`:`Could not load this report`,subtitle:e.error?.message??`Try again.`,action:(0,O.jsx)(b,{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)(x,{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{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{Ut as i}from"./queries-ClkIgWFx.js";import{f as a,p as o}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{ft as s}from"./design-icons-CzEoMH9c.js";import{a as c,c as l,i as u,n as d,o as f,r as p,s as m,t as h}from"./dist-Da4ckcJG.js";import{t as g}from"./use-search-params-writer-ClMScnNe.js";var _=e(t(),1),v=n();function y({...e}){return(0,v.jsx)(h,{"data-slot":`sheet`,...e})}function b({...e}){return(0,v.jsx)(l,{"data-slot":`sheet-trigger`,...e})}function x({...e}){return(0,v.jsx)(d,{"data-slot":`sheet-close`,...e})}function S({...e}){return(0,v.jsx)(f,{"data-slot":`sheet-portal`,...e})}function C({className:e,...t}){return(0,v.jsx)(c,{"data-slot":`sheet-overlay`,className:r(`fixed inset-0 z-50 bg-black/50 motion-safe:data-[state=closed]:animate-out data-[state=closed]:fade-out-0 motion-safe:data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function w({className:e,children:t,side:n=`right`,showCloseButton:i=!0,overlayClassName:a,...o}){return(0,v.jsxs)(S,{children:[(0,v.jsx)(C,{className:a}),(0,v.jsxs)(p,{"data-slot":`sheet-content`,className:r(`fixed z-50 flex flex-col gap-4 bg-background shadow-modal transition-colors ease-in-out motion-safe:data-[state=closed]:animate-out data-[state=closed]:duration-300 motion-safe:data-[state=open]:animate-in data-[state=open]:duration-500`,n===`right`&&`inset-y-0 end-0 h-full w-3/4 border-s motion-safe:data-[state=closed]:slide-out-to-right motion-safe:data-[state=open]:slide-in-from-right sm:max-w-sm`,n===`left`&&`inset-y-0 start-0 h-full w-3/4 border-e motion-safe:data-[state=closed]:slide-out-to-left motion-safe:data-[state=open]:slide-in-from-left sm:max-w-sm`,n===`top`&&`inset-x-0 inset-bs-0 h-auto border-be motion-safe:data-[state=closed]:slide-out-to-top motion-safe:data-[state=open]:slide-in-from-top`,n===`bottom`&&`inset-x-0 inset-be-0 h-auto border-bs motion-safe:data-[state=closed]:slide-out-to-bottom motion-safe:data-[state=open]:slide-in-from-bottom`,e),...o,children:[t,i&&(0,v.jsxs)(d,{className:`absolute inset-bs-4 end-4 rounded-sm opacity-70 ring-offset-background transition-opacity pointer-hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-secondary`,children:[(0,v.jsx)(s,{className:`size-4`}),(0,v.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function T({className:e,...t}){return(0,v.jsx)(`div`,{"data-slot":`sheet-header`,className:r(`flex flex-col gap-1.5 p-4`,e),...t})}function E({className:e,...t}){return(0,v.jsx)(m,{"data-slot":`sheet-title`,className:r(`font-semibold text-foreground`,e),...t})}function D({className:e,...t}){return(0,v.jsx)(u,{"data-slot":`sheet-description`,className:r(`text-sm text-muted-foreground`,e),...t})}function O(e){let[t,n]=_.useState(()=>Date.now());return _.useEffect(()=>{if(i())return;let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}var k=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function A(e){let t=e.get(`report`);return!t||!k.test(t)||e.getAll(`report`).length!==1||e.getAll(`card`).length>1?null:{artifactId:t,card:e.get(`card`)||null}}var j=(0,_.createContext)(null);function M(e){let t=a(),n=o(),[r,i]=g(),s=A(r),[c,l]=(0,_.useState)(()=>({runId:e,entries:new Map}));c.runId!==e&&l({runId:e,entries:new Map});let u=(0,_.useCallback)((t,n)=>(l(r=>{if(r.runId===e&&r.entries.get(t)===n)return r;let i=new Map(r.runId===e?r.entries:[]);return i.set(t,n),{runId:e,entries:i}}),()=>void 0),[e]),d=(0,_.useRef)({runId:e,callbacks:new Map});d.current.runId!==e&&(d.current={runId:e,callbacks:new Map});let f=(0,_.useCallback)((e,t)=>(d.current.callbacks.set(e,t),()=>{d.current.callbacks.get(e)===t&&d.current.callbacks.delete(e)}),[]),p=(0,_.useMemo)(()=>({register:u,registerOpener:f}),[u,f]),m=(0,_.useRef)(null);return(0,_.useEffect)(()=>{r.has(`report`)&&!s&&i(e=>(e.delete(`report`),e.delete(`card`),e))},[r,s,i]),(0,_.useEffect)(()=>{let n=m.current;!s&&n&&n.runId===e&&n.card&&d.current.callbacks.get(n.card)?.(n.artifactId,n.scrollTop),m.current=s?{...s,runId:e,scrollTop:t.state?.reportScrollTop}:null},[e,s,t.state]),{selection:s,sourceRunId:c.runId===e&&s?c.entries.get(s.artifactId)??(s.card?void 0:e):void 0,registry:p,close:()=>{let e=t.state,r=window.navigation;if(e?.reportReturnKey&&r){r.traverseTo(e.reportReturnKey);return}if(e?.reportReturnTo){n(e.reportReturnTo,{replace:!0});return}i(e=>(e.delete(`report`),e.delete(`card`),e))}}}export{x as a,T as c,y as i,E as l,M as n,w as o,O as r,D as s,j as t,b as u};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{Ut as i}from"./queries-CYWRnyM5.js";import{f as a,p as o}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{ft as s}from"./design-icons-CzEoMH9c.js";import{a as c,c as l,i as u,n as d,o as f,r as p,s as m,t as h}from"./dist-Da4ckcJG.js";import{t as g}from"./use-search-params-writer-ClMScnNe.js";var _=e(t(),1),v=n();function y({...e}){return(0,v.jsx)(h,{"data-slot":`sheet`,...e})}function b({...e}){return(0,v.jsx)(l,{"data-slot":`sheet-trigger`,...e})}function x({...e}){return(0,v.jsx)(d,{"data-slot":`sheet-close`,...e})}function S({...e}){return(0,v.jsx)(f,{"data-slot":`sheet-portal`,...e})}function C({className:e,...t}){return(0,v.jsx)(c,{"data-slot":`sheet-overlay`,className:r(`fixed inset-0 z-50 bg-black/50 motion-safe:data-[state=closed]:animate-out data-[state=closed]:fade-out-0 motion-safe:data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function w({className:e,children:t,side:n=`right`,showCloseButton:i=!0,overlayClassName:a,...o}){return(0,v.jsxs)(S,{children:[(0,v.jsx)(C,{className:a}),(0,v.jsxs)(p,{"data-slot":`sheet-content`,className:r(`fixed z-50 flex flex-col gap-4 bg-background shadow-modal transition-colors ease-in-out motion-safe:data-[state=closed]:animate-out data-[state=closed]:duration-300 motion-safe:data-[state=open]:animate-in data-[state=open]:duration-500`,n===`right`&&`inset-y-0 end-0 h-full w-3/4 border-s motion-safe:data-[state=closed]:slide-out-to-right motion-safe:data-[state=open]:slide-in-from-right sm:max-w-sm`,n===`left`&&`inset-y-0 start-0 h-full w-3/4 border-e motion-safe:data-[state=closed]:slide-out-to-left motion-safe:data-[state=open]:slide-in-from-left sm:max-w-sm`,n===`top`&&`inset-x-0 inset-bs-0 h-auto border-be motion-safe:data-[state=closed]:slide-out-to-top motion-safe:data-[state=open]:slide-in-from-top`,n===`bottom`&&`inset-x-0 inset-be-0 h-auto border-bs motion-safe:data-[state=closed]:slide-out-to-bottom motion-safe:data-[state=open]:slide-in-from-bottom`,e),...o,children:[t,i&&(0,v.jsxs)(d,{className:`absolute inset-bs-4 end-4 rounded-sm opacity-70 ring-offset-background transition-opacity pointer-hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-secondary`,children:[(0,v.jsx)(s,{className:`size-4`}),(0,v.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function T({className:e,...t}){return(0,v.jsx)(`div`,{"data-slot":`sheet-header`,className:r(`flex flex-col gap-1.5 p-4`,e),...t})}function E({className:e,...t}){return(0,v.jsx)(m,{"data-slot":`sheet-title`,className:r(`font-semibold text-foreground`,e),...t})}function D({className:e,...t}){return(0,v.jsx)(u,{"data-slot":`sheet-description`,className:r(`text-sm text-muted-foreground`,e),...t})}function O(e){let[t,n]=_.useState(()=>Date.now());return _.useEffect(()=>{if(i())return;let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}var k=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function A(e){let t=e.get(`report`);return!t||!k.test(t)||e.getAll(`report`).length!==1||e.getAll(`card`).length>1?null:{artifactId:t,card:e.get(`card`)||null}}var j=(0,_.createContext)(null);function M(e){let t=a(),n=o(),[r,i]=g(),s=A(r),[c,l]=(0,_.useState)(()=>({runId:e,entries:new Map}));c.runId!==e&&l({runId:e,entries:new Map});let u=(0,_.useCallback)((t,n)=>(l(r=>{if(r.runId===e&&r.entries.get(t)===n)return r;let i=new Map(r.runId===e?r.entries:[]);return i.set(t,n),{runId:e,entries:i}}),()=>void 0),[e]),d=(0,_.useRef)({runId:e,callbacks:new Map});d.current.runId!==e&&(d.current={runId:e,callbacks:new Map});let f=(0,_.useCallback)((e,t)=>(d.current.callbacks.set(e,t),()=>{d.current.callbacks.get(e)===t&&d.current.callbacks.delete(e)}),[]),p=(0,_.useMemo)(()=>({register:u,registerOpener:f}),[u,f]),m=(0,_.useRef)(null);return(0,_.useEffect)(()=>{r.has(`report`)&&!s&&i(e=>(e.delete(`report`),e.delete(`card`),e))},[r,s,i]),(0,_.useEffect)(()=>{let n=m.current;!s&&n&&n.runId===e&&n.card&&d.current.callbacks.get(n.card)?.(n.artifactId,n.scrollTop),m.current=s?{...s,runId:e,scrollTop:t.state?.reportScrollTop}:null},[e,s,t.state]),{selection:s,sourceRunId:c.runId===e&&s?c.entries.get(s.artifactId)??(s.card?void 0:e):void 0,registry:p,close:()=>{let e=t.state,r=window.navigation;if(e?.reportReturnKey&&r){r.traverseTo(e.reportReturnKey);return}if(e?.reportReturnTo){n(e.reportReturnTo,{replace:!0});return}i(e=>(e.delete(`report`),e.delete(`card`),e))}}}export{x as a,T as c,y as i,E as l,M as n,w as o,O as r,D as s,j as t,b as u};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{c as r,t as i}from"./utils-DSMR_WLb.js";import{N as a,Rt as o,ct as s}from"./queries-ClkIgWFx.js";import{Hr as c,In as l,Ln as u,Wr as d,br as f,hi as p,pi as m,ri as h,zn as g}from"./toaster-C-xqAWVX.js";import{B as _,F as v,I as y,J as b,N as x,W as S,Y as C,z as w}from"./live-protocol-DMhTnCmf.js";import{f as T,m as E}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{X as D}from"./design-icons-CzEoMH9c.js";import{t as O}from"./arrow-up-right-DKGzsMqY.js";import{t as k}from"./chevron-right-BENZ-1ZN.js";import{t as A}from"./eye-B8okNWXU.js";import{t as j}from"./button-B7MKxYjT.js";import{t as M}from"./project-router-CT6gVIcC.js";import{a as ee}from"./format-BU7D3IfE.js";import{d as te,l as ne,n as re,r as N,t as P}from"./page-shell-7pLJMOgh.js";import{t as F}from"./use-search-params-writer-ClMScnNe.js";import{Yn as I,Yt as L,fn as R,ir as z}from"./index-BX94wp6m.js";import{t as B}from"./report-title-D4Mbu2Er.js";import{t as V}from"./html-report-frame-uuqkBC0u.js";var H=e(t(),1),U=1e3,W=S().min(1).max(1024);_({q:S().max(U).optional(),before:W.optional(),limit:S().regex(/^(?:[1-9]|[1-9][0-9]|100)$/).transform(Number).optional()}).strict();var G=_({reports:x(_({id:b(),runId:b(),name:S(),title:S(),createdAt:C(),size:w().int().nonnegative(),taskTitle:S(),taskStatus:f}).strict()),nextCursor:W.nullable(),total:w().int().nonnegative()}).strict(),K=_({epoch:b(),generation:w().int().nonnegative(),metadataGeneration:w().int().nonnegative()}).strict(),q=_({runId:b(),taskTitle:S(),taskStatus:f}).strict(),J=v(`type`,[K.extend({type:y(`snapshot`)}),K.extend({type:y(`content`)}),K.extend({type:y(`metadata`),runs:x(q)})]),Y=new WeakMap;function ie(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 ae=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=ie(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 oe(e,t){let n=Y.get(e);n||(n=new Map,Y.set(e,n));let r=n.get(t);return r||(r=new ae(e,t),n.set(t,r)),r}async function se(e,t){let n=await l.api.v1.p[`:projectId`].reports.state.$get({param:{projectId:e}},u({signal:t}));return K.parse(await g(n,`/reports/state`))}function ce(e){let t=oe(p(),e);return(0,H.useEffect)(()=>{let n=o(`reports:project:${e}`,e=>{let n=J.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;se(e,n).then(e=>{n.aborted||t.receive({type:`snapshot`,...e})}).catch(()=>void 0),r=s({path:`/api/v1/p/${encodeURIComponent(e)}/reports/state`,intervalMs:5e3},(e,n)=>{let r=K.safeParse(e);!n&&r.success&&t.receive({type:`snapshot`,...r.data})})}else c()!==`finite`&&(i?.abort(),r?.(),r=void 0)};a();let l=d(a);return()=>{l(),i?.abort(),r?.(),n()}},[t,e]),t}async function le(e,t,n,r){let i=await l.api.v1.p[`:projectId`].reports.$get({param:{projectId:e},query:{q:t.slice(0,U),...n?{before:n}:{}}},u(r?{signal:r}:void 0));return G.parse(await g(i,`/reports`))}function X(e){let t=r(),n=ce(t);return h({queryKey:[t,`reports`,e],initialPageParam:void 0,queryFn:({pageParam:r,signal:i})=>n.read(e,()=>le(t,e,r,i)),getNextPageParam:e=>e.nextCursor??void 0,staleTime:0,refetchOnWindowFocus:!0})}var Z=n(),Q=new Map;function ue(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(t)}function de(e){let t=L(),[n,r]=(0,H.useState)(!1);return(0,H.useLayoutEffect)(()=>{let n=e.current;if(!n)return;let i=e=>{r(e>0?e>=660:t)};if(i(n.getBoundingClientRect().width),typeof ResizeObserver!=`function`)return;let a=new ResizeObserver(e=>{let t=e[0]?.contentRect.width??n.getBoundingClientRect().width;i(t)});return a.observe(n),()=>a.disconnect()},[e,t]),n}function fe(){let e=T(),t=E(),[n,r]=F(),a=(n.get(`q`)??``).slice(0,U),o=X(a),s=(0,H.useRef)(null),c=(0,H.useRef)(null),l=(0,H.useRef)(``),u=e.pathname+e.search,d=o.data?.pages.flatMap(e=>e.reports)??[],f=e=>{Q.set(u,{scroll:c.current?.scrollTop??0,row:e,pages:o.data?.pages.length??1})},[p,m]=(0,H.useState)(null),h=de(s);(0,H.useLayoutEffect)(()=>{if(!o.data||l.current===u)return;let n=Q.get(u),r=e.state?.filesRestoreKey===u;if(!n||!c.current||t!==`POP`&&!r){l.current=u;return}let i=c.current.querySelector(`[data-report-id="${n.row}"]`);if(o.isFetchNextPageError){l.current=u,c.current.scrollTop=0;return}if((!i||o.data.pages.length<n.pages)&&o.hasNextPage){o.isFetchingNextPage||o.fetchNextPage();return}l.current=u,c.current.scrollTop=i?n.scroll:0,i?.focus({preventScroll:!0})},[u,o.data,o.hasNextPage,o.isFetchingNextPage,o.isFetchNextPageError,o.fetchNextPage,e.state,t]);let g=t=>r(n=>(t?n.set(`q`,t.slice(0,U)):n.delete(`q`),Q.delete(e.pathname+`?`+n.toString()),n)),_=d.find(e=>e.id===p)??d[0]??null,v=o.isPending?`full`:te(d.length);return(0,Z.jsx)(ne,{route:`reports`,density:v,fillHeight:!0,bodyClassName:`gap-4`,header:{title:`Reports`,subtitle:`Published HTML snapshots from tasks in this project.`},children:(0,Z.jsxs)(`div`,{ref:s,"data-slot":`reports-content`,className:`flex min-h-0 min-w-0 flex-1 flex-col gap-4`,children:[(0,Z.jsxs)(`div`,{className:`relative w-full shrink-0`,children:[(0,Z.jsx)(D,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,Z.jsx)(I,{maxLength:U,"aria-label":`Search reports`,placeholder:`Search reports or source tasks…`,value:a,onChange:e=>g(e.target.value),className:`h-10 w-full rounded-lg border-border bg-card pl-9 text-sm max-md:h-11`})]}),o.isPending?(0,Z.jsx)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(`p`,{role:`status`,className:`py-4 text-sm text-muted-foreground`,children:`Loading reports…`})}):o.isError&&d.length===0?(0,Z.jsx)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-3 rounded-xl border border-border bg-card p-5`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Could not load reports`}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o.error.message}),(0,Z.jsx)(j,{variant:`outline`,className:`min-h-11`,onClick:()=>void o.refetch(),children:`Retry`})]})}):d.length===0?(0,Z.jsx)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(P,{icon:(0,Z.jsx)(z,{}),title:a?`No matching reports`:`No published reports yet`,description:a?`Try a different keyword or clear the search filter.`:(0,Z.jsxs)(Z.Fragment,{children:[`Publish an HTML snapshot with`,` `,(0,Z.jsxs)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground`,children:[R(),` artifact publish`]}),` `,`to list it here.`]}),actions:a?(0,Z.jsx)(j,{"data-slot":`reports-clear-search`,variant:`outline`,className:`min-h-11`,onClick:()=>g(``),children:`Clear search`}):(0,Z.jsx)(j,{variant:`outline`,className:`min-h-11`,asChild:!0,children:(0,Z.jsx)(M,{to:`/new`,children:`Start a task`})})})}):(0,Z.jsx)(N,{list:(0,Z.jsxs)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:[(0,Z.jsx)(`ul`,{className:`flex flex-col gap-1.5`,"aria-label":`Reports`,children:d.map(e=>{let t=_?.id===e.id;return(0,Z.jsxs)(`li`,{"data-slot":`report-row`,"data-selected":h&&t?`true`:void 0,className:i(`reports-row flex items-center gap-3 rounded-xl border border-border bg-card px-4 py-3 transition-colors`,h&&t&&`border-accent-strong/60 bg-sidebar-row-selected/40`),children:[(0,Z.jsx)(z,{"aria-hidden":`true`,className:`reports-icon mt-0.5 size-4 shrink-0 self-start text-accent-text`}),(0,Z.jsxs)(`div`,{className:`reports-lines flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Z.jsx)(`h2`,{className:`flex min-w-0 text-[14px] leading-5 font-semibold text-foreground`,title:B(e),children:(0,Z.jsx)(M,{"data-report-id":e.id,className:`reports-open text-foreground no-underline`,to:`/tasks/${e.runId}/report?artifact=${e.id}`,state:{readerFrom:u,filesRestoreKey:u},onClick:()=>f(e.id),children:(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:B(e)})})}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-xs leading-4 text-muted-foreground`,children:[(0,Z.jsx)(M,{className:`reports-task min-w-0 truncate text-xs text-muted-foreground no-underline hover:text-foreground hover:underline`,to:`/tasks/${e.runId}`,children:(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,title:e.taskTitle,children:e.taskTitle})}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`}),(0,Z.jsx)(`time`,{className:`shrink-0 tabular-nums`,dateTime:e.createdAt,title:ue(e.createdAt),children:$(e.createdAt)})]})]}),h?(0,Z.jsx)(`button`,{type:`button`,"data-slot":`report-preview-select`,"aria-label":`Preview ${B(e)}`,"aria-pressed":t,onClick:()=>m(e.id),className:`reports-preview-btn inline-flex min-h-8 min-w-8 shrink-0 items-center justify-center gap-1 rounded-md border border-border bg-background px-2 py-1.5 text-xs text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`,children:(0,Z.jsx)(A,{"aria-hidden":`true`,className:`size-3.5`})}):(0,Z.jsx)(k,{"aria-hidden":`true`,"data-slot":`report-open-cue`,className:`reports-cue size-4 shrink-0 text-muted-foreground`})]},e.id)})}),o.hasNextPage?(0,Z.jsx)(`div`,{className:`mt-4`,children:(0,Z.jsx)(j,{variant:`outline`,className:`min-h-11`,disabled:o.isFetchingNextPage,onClick:()=>void o.fetchNextPage(),children:`Load more reports`})}):null,v===`sparse`?(0,Z.jsx)(re,{summary:`${d.length} published ${d.length===1?`report`:`reports`}. Select a row to open full screen or preview beside the list.`}):null]}),detail:h&&_?(0,Z.jsx)(pe,{report:_,restoreKey:u,onOpenReader:()=>f(_.id)}):null})]})})}function pe({report:e,restoreKey:t,onOpenReader:n}){let r=(0,H.useContext)(m)!==void 0;return(0,Z.jsxs)(`section`,{"data-slot":`reports-preview-pane`,"aria-label":`Preview of ${B(e)}`,className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-border bg-card`,children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h2`,{className:`truncate text-sm font-semibold text-foreground`,children:B(e)}),(0,Z.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-muted-foreground`,children:[e.taskTitle,` · `,$(e.createdAt)]})]}),(0,Z.jsx)(j,{variant:`outline`,size:`sm`,asChild:!0,className:`h-auto min-h-8 shrink-0 py-1.5`,children:(0,Z.jsxs)(M,{"data-slot":`reports-preview-open`,to:`/tasks/${e.runId}/report?artifact=${e.id}`,state:{readerFrom:t,filesRestoreKey:t},onClick:n,children:[`Open reader`,(0,Z.jsx)(O,{"aria-hidden":`true`,className:`size-3.5`})]})})]}),r?(0,Z.jsx)(me,{report:e}):(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-xs text-muted-foreground`,children:`Open reader to view this HTML report.`})]})}function me({report:e}){let t=a(e.runId,e.id);if(t.isPending)return(0,Z.jsx)(`p`,{role:`status`,className:`p-6 text-xs text-muted-foreground`,children:`Loading preview…`});if(t.isError)return(0,Z.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-2 p-6 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`p`,{className:`font-medium text-foreground`,children:`Could not load report preview`}),(0,Z.jsx)(`p`,{children:t.error.message}),(0,Z.jsx)(j,{variant:`outline`,size:`sm`,onClick:()=>void t.refetch(),children:`Retry`})]});let n=t.data;return!n||n.type!==`file`||n.binary||n.content===void 0?(0,Z.jsx)(`p`,{className:`p-6 text-xs text-muted-foreground`,children:`Preview unavailable for this artifact.`}):(0,Z.jsx)(V,{html:n.content,title:B(e),className:`min-h-0 flex-1`})}function $(e){let t=ee(e);return t?t===`just now`?`Published just now`:`Published · ${t}`:``}export{fe as ReportsRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{c as r,t as i}from"./utils-DSMR_WLb.js";import{N as a,Rt as o,ct as s}from"./queries-CYWRnyM5.js";import{Hr as c,In as l,Ln as u,Wr as d,br as f,hi as p,pi as m,ri as h,zn as g}from"./toaster-B0kvcFif.js";import{B as _,F as v,I as y,J as b,N as x,W as S,Y as C,z as w}from"./live-protocol-DMhTnCmf.js";import{f as T,m as E}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{X as D}from"./design-icons-CzEoMH9c.js";import{t as O}from"./arrow-up-right-DKGzsMqY.js";import{t as k}from"./chevron-right-BENZ-1ZN.js";import{t as A}from"./eye-B8okNWXU.js";import{t as j}from"./button-B7MKxYjT.js";import{t as M}from"./project-router-BvBqllk2.js";import{a as ee}from"./format-BU7D3IfE.js";import{d as te,l as ne,n as re,r as N,t as P}from"./page-shell-7pLJMOgh.js";import{t as F}from"./use-search-params-writer-ClMScnNe.js";import{Xn as I,Xt as L,ar as R,pn as z}from"./index-mCjln54E.js";import{t as B}from"./report-title-D4Mbu2Er.js";import{t as V}from"./html-report-frame-uuqkBC0u.js";var H=e(t(),1),U=1e3,W=S().min(1).max(1024);_({q:S().max(U).optional(),before:W.optional(),limit:S().regex(/^(?:[1-9]|[1-9][0-9]|100)$/).transform(Number).optional()}).strict();var G=_({reports:x(_({id:b(),runId:b(),name:S(),title:S(),createdAt:C(),size:w().int().nonnegative(),taskTitle:S(),taskStatus:f}).strict()),nextCursor:W.nullable(),total:w().int().nonnegative()}).strict(),K=_({epoch:b(),generation:w().int().nonnegative(),metadataGeneration:w().int().nonnegative()}).strict(),q=_({runId:b(),taskTitle:S(),taskStatus:f}).strict(),J=v(`type`,[K.extend({type:y(`snapshot`)}),K.extend({type:y(`content`)}),K.extend({type:y(`metadata`),runs:x(q)})]),Y=new WeakMap;function ie(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 ae=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=ie(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 oe(e,t){let n=Y.get(e);n||(n=new Map,Y.set(e,n));let r=n.get(t);return r||(r=new ae(e,t),n.set(t,r)),r}async function se(e,t){let n=await l.api.v1.p[`:projectId`].reports.state.$get({param:{projectId:e}},u({signal:t}));return K.parse(await g(n,`/reports/state`))}function ce(e){let t=oe(p(),e);return(0,H.useEffect)(()=>{let n=o(`reports:project:${e}`,e=>{let n=J.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;se(e,n).then(e=>{n.aborted||t.receive({type:`snapshot`,...e})}).catch(()=>void 0),r=s({path:`/api/v1/p/${encodeURIComponent(e)}/reports/state`,intervalMs:5e3},(e,n)=>{let r=K.safeParse(e);!n&&r.success&&t.receive({type:`snapshot`,...r.data})})}else c()!==`finite`&&(i?.abort(),r?.(),r=void 0)};a();let l=d(a);return()=>{l(),i?.abort(),r?.(),n()}},[t,e]),t}async function le(e,t,n,r){let i=await l.api.v1.p[`:projectId`].reports.$get({param:{projectId:e},query:{q:t.slice(0,U),...n?{before:n}:{}}},u(r?{signal:r}:void 0));return G.parse(await g(i,`/reports`))}function X(e){let t=r(),n=ce(t);return h({queryKey:[t,`reports`,e],initialPageParam:void 0,queryFn:({pageParam:r,signal:i})=>n.read(e,()=>le(t,e,r,i)),getNextPageParam:e=>e.nextCursor??void 0,staleTime:0,refetchOnWindowFocus:!0})}var Z=n(),Q=new Map;function ue(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(t)}function de(e){let t=L(),[n,r]=(0,H.useState)(!1);return(0,H.useLayoutEffect)(()=>{let n=e.current;if(!n)return;let i=e=>{r(e>0?e>=660:t)};if(i(n.getBoundingClientRect().width),typeof ResizeObserver!=`function`)return;let a=new ResizeObserver(e=>{let t=e[0]?.contentRect.width??n.getBoundingClientRect().width;i(t)});return a.observe(n),()=>a.disconnect()},[e,t]),n}function fe(){let e=T(),t=E(),[n,r]=F(),a=(n.get(`q`)??``).slice(0,U),o=X(a),s=(0,H.useRef)(null),c=(0,H.useRef)(null),l=(0,H.useRef)(``),u=e.pathname+e.search,d=o.data?.pages.flatMap(e=>e.reports)??[],f=e=>{Q.set(u,{scroll:c.current?.scrollTop??0,row:e,pages:o.data?.pages.length??1})},[p,m]=(0,H.useState)(null),h=de(s);(0,H.useLayoutEffect)(()=>{if(!o.data||l.current===u)return;let n=Q.get(u),r=e.state?.filesRestoreKey===u;if(!n||!c.current||t!==`POP`&&!r){l.current=u;return}let i=c.current.querySelector(`[data-report-id="${n.row}"]`);if(o.isFetchNextPageError){l.current=u,c.current.scrollTop=0;return}if((!i||o.data.pages.length<n.pages)&&o.hasNextPage){o.isFetchingNextPage||o.fetchNextPage();return}l.current=u,c.current.scrollTop=i?n.scroll:0,i?.focus({preventScroll:!0})},[u,o.data,o.hasNextPage,o.isFetchingNextPage,o.isFetchNextPageError,o.fetchNextPage,e.state,t]);let g=t=>r(n=>(t?n.set(`q`,t.slice(0,U)):n.delete(`q`),Q.delete(e.pathname+`?`+n.toString()),n)),_=d.find(e=>e.id===p)??d[0]??null,v=o.isPending?`full`:te(d.length);return(0,Z.jsx)(ne,{route:`reports`,density:v,fillHeight:!0,bodyClassName:`gap-4`,header:{title:`Reports`,subtitle:`Published HTML snapshots from tasks in this project.`},children:(0,Z.jsxs)(`div`,{ref:s,"data-slot":`reports-content`,className:`flex min-h-0 min-w-0 flex-1 flex-col gap-4`,children:[(0,Z.jsxs)(`div`,{className:`relative w-full shrink-0`,children:[(0,Z.jsx)(D,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,Z.jsx)(I,{maxLength:U,"aria-label":`Search reports`,placeholder:`Search reports or source tasks…`,value:a,onChange:e=>g(e.target.value),className:`h-10 w-full rounded-lg border-border bg-card pl-9 text-sm max-md:h-11`})]}),o.isPending?(0,Z.jsx)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(`p`,{role:`status`,className:`py-4 text-sm text-muted-foreground`,children:`Loading reports…`})}):o.isError&&d.length===0?(0,Z.jsx)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-3 rounded-xl border border-border bg-card p-5`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Could not load reports`}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o.error.message}),(0,Z.jsx)(j,{variant:`outline`,className:`min-h-11`,onClick:()=>void o.refetch(),children:`Retry`})]})}):d.length===0?(0,Z.jsx)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(P,{icon:(0,Z.jsx)(R,{}),title:a?`No matching reports`:`No published reports yet`,description:a?`Try a different keyword or clear the search filter.`:(0,Z.jsxs)(Z.Fragment,{children:[`Publish an HTML snapshot with`,` `,(0,Z.jsxs)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground`,children:[z(),` artifact publish`]}),` `,`to list it here.`]}),actions:a?(0,Z.jsx)(j,{"data-slot":`reports-clear-search`,variant:`outline`,className:`min-h-11`,onClick:()=>g(``),children:`Clear search`}):(0,Z.jsx)(j,{variant:`outline`,className:`min-h-11`,asChild:!0,children:(0,Z.jsx)(M,{to:`/new`,children:`Start a task`})})})}):(0,Z.jsx)(N,{list:(0,Z.jsxs)(`div`,{ref:c,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:[(0,Z.jsx)(`ul`,{className:`flex flex-col gap-1.5`,"aria-label":`Reports`,children:d.map(e=>{let t=_?.id===e.id;return(0,Z.jsxs)(`li`,{"data-slot":`report-row`,"data-selected":h&&t?`true`:void 0,className:i(`reports-row flex items-center gap-3 rounded-xl border border-border bg-card px-4 py-3 transition-colors`,h&&t&&`border-accent-strong/60 bg-sidebar-row-selected/40`),children:[(0,Z.jsx)(R,{"aria-hidden":`true`,className:`reports-icon mt-0.5 size-4 shrink-0 self-start text-accent-text`}),(0,Z.jsxs)(`div`,{className:`reports-lines flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Z.jsx)(`h2`,{className:`flex min-w-0 text-[14px] leading-5 font-semibold text-foreground`,title:B(e),children:(0,Z.jsx)(M,{"data-report-id":e.id,className:`reports-open text-foreground no-underline`,to:`/tasks/${e.runId}/report?artifact=${e.id}`,state:{readerFrom:u,filesRestoreKey:u},onClick:()=>f(e.id),children:(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:B(e)})})}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-xs leading-4 text-muted-foreground`,children:[(0,Z.jsx)(M,{className:`reports-task min-w-0 truncate text-xs text-muted-foreground no-underline hover:text-foreground hover:underline`,to:`/tasks/${e.runId}`,children:(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,title:e.taskTitle,children:e.taskTitle})}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`}),(0,Z.jsx)(`time`,{className:`shrink-0 tabular-nums`,dateTime:e.createdAt,title:ue(e.createdAt),children:$(e.createdAt)})]})]}),h?(0,Z.jsx)(`button`,{type:`button`,"data-slot":`report-preview-select`,"aria-label":`Preview ${B(e)}`,"aria-pressed":t,onClick:()=>m(e.id),className:`reports-preview-btn inline-flex min-h-8 min-w-8 shrink-0 items-center justify-center gap-1 rounded-md border border-border bg-background px-2 py-1.5 text-xs text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`,children:(0,Z.jsx)(A,{"aria-hidden":`true`,className:`size-3.5`})}):(0,Z.jsx)(k,{"aria-hidden":`true`,"data-slot":`report-open-cue`,className:`reports-cue size-4 shrink-0 text-muted-foreground`})]},e.id)})}),o.hasNextPage?(0,Z.jsx)(`div`,{className:`mt-4`,children:(0,Z.jsx)(j,{variant:`outline`,className:`min-h-11`,disabled:o.isFetchingNextPage,onClick:()=>void o.fetchNextPage(),children:`Load more reports`})}):null,v===`sparse`?(0,Z.jsx)(re,{summary:`${d.length} published ${d.length===1?`report`:`reports`}. Select a row to open full screen or preview beside the list.`}):null]}),detail:h&&_?(0,Z.jsx)(pe,{report:_,restoreKey:u,onOpenReader:()=>f(_.id)}):null})]})})}function pe({report:e,restoreKey:t,onOpenReader:n}){let r=(0,H.useContext)(m)!==void 0;return(0,Z.jsxs)(`section`,{"data-slot":`reports-preview-pane`,"aria-label":`Preview of ${B(e)}`,className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-border bg-card`,children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h2`,{className:`truncate text-sm font-semibold text-foreground`,children:B(e)}),(0,Z.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-muted-foreground`,children:[e.taskTitle,` · `,$(e.createdAt)]})]}),(0,Z.jsx)(j,{variant:`outline`,size:`sm`,asChild:!0,className:`h-auto min-h-8 shrink-0 py-1.5`,children:(0,Z.jsxs)(M,{"data-slot":`reports-preview-open`,to:`/tasks/${e.runId}/report?artifact=${e.id}`,state:{readerFrom:t,filesRestoreKey:t},onClick:n,children:[`Open reader`,(0,Z.jsx)(O,{"aria-hidden":`true`,className:`size-3.5`})]})})]}),r?(0,Z.jsx)(me,{report:e}):(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-xs text-muted-foreground`,children:`Open reader to view this HTML report.`})]})}function me({report:e}){let t=a(e.runId,e.id);if(t.isPending)return(0,Z.jsx)(`p`,{role:`status`,className:`p-6 text-xs text-muted-foreground`,children:`Loading preview…`});if(t.isError)return(0,Z.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-2 p-6 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`p`,{className:`font-medium text-foreground`,children:`Could not load report preview`}),(0,Z.jsx)(`p`,{children:t.error.message}),(0,Z.jsx)(j,{variant:`outline`,size:`sm`,onClick:()=>void t.refetch(),children:`Retry`})]});let n=t.data;return!n||n.type!==`file`||n.binary||n.content===void 0?(0,Z.jsx)(`p`,{className:`p-6 text-xs text-muted-foreground`,children:`Preview unavailable for this artifact.`}):(0,Z.jsx)(V,{html:n.content,title:B(e),className:`min-h-0 flex-1`})}function $(e){let t=ee(e);return t?t===`just now`?`Published just now`:`Published · ${t}`:``}export{fe as ReportsRoute};