@wjarka/cezarion 0.17.0-pr2750.4607 → 0.17.0-pr2753.4613

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 (56) hide show
  1. package/dist/ci-wait/controller.d.ts +37 -37
  2. package/dist/delegation/transport.d.ts +62 -62
  3. package/dist/server/activity-routes.d.ts +23 -23
  4. package/dist/server/self-update-routes.d.ts +11 -11
  5. package/dist/server/server.d.ts +1230 -1230
  6. package/package.json +3 -3
  7. package/web/dist/assets/activity-motion-B5fIHwoB.css +1 -0
  8. package/web/dist/assets/activity-motion-Ch0PoZJR.js +2 -0
  9. package/web/dist/assets/activity-route-CQPkXxJ2.js +1 -0
  10. package/web/dist/assets/{agent-accounts-lFFHk56I.js → agent-accounts-ZGHdsjYE.js} +1 -1
  11. package/web/dist/assets/arrow-right-Dh_Lx3um.js +1 -0
  12. package/web/dist/assets/{commit-diff-panel-0_Qu3h0B.js → commit-diff-panel-UwU29VK_.js} +1 -1
  13. package/web/dist/assets/{control-locations-CM5KUQ3d.js → control-locations-SzZ8gyme.js} +1 -1
  14. package/web/dist/assets/{diff-Ca1O4a0T.js → diff-CQdcUei8.js} +2 -2
  15. package/web/dist/assets/{diff-view-Bk5YG0An.js → diff-view-BH7MnYEM.js} +1 -1
  16. package/web/dist/assets/{file-preview-bylLpbji.js → file-preview-BmEFF1nO.js} +1 -1
  17. package/web/dist/assets/{git-toolbar-BhVKNNog.js → git-toolbar-BIctOY7_.js} +1 -1
  18. package/web/dist/assets/github-BtPVrHZu.js +1 -0
  19. package/web/dist/assets/{github-sidebar-model-DeQrUvUi.js → github-sidebar-model-DssVqUad.js} +1 -1
  20. package/web/dist/assets/global-activity-route-BOg5DOZ-.js +1 -0
  21. package/web/dist/assets/hourglass-B0lPAJvT.js +1 -0
  22. package/web/dist/assets/index-B98HIjrF.js +12 -0
  23. package/web/dist/assets/index-DZItIsRv.css +1 -0
  24. package/web/dist/assets/{preview-pane-connected-DY6nOrSu.js → preview-pane-connected-Dfc9BAkc.js} +2 -2
  25. package/web/dist/assets/{project-router-n0p0qOgE.js → project-router-DQWY9FSQ.js} +1 -1
  26. package/web/dist/assets/{project-scope-context-a1Wrxrws.js → project-scope-context-DFjJ4Dzo.js} +3 -3
  27. package/web/dist/assets/queries-Cgys1fiN.js +1 -0
  28. package/web/dist/assets/{repo-git-BlRkTKPh.js → repo-git-BmaBIIo9.js} +1 -1
  29. package/web/dist/assets/{report-reader-BHAqz7cz.js → report-reader-BflKmitB.js} +1 -1
  30. package/web/dist/assets/{reports-CDtBVfcd.js → reports-D0VRvzsA.js} +1 -1
  31. package/web/dist/assets/run-header-p5pX7Js3.js +2 -0
  32. package/web/dist/assets/{skills-DHipK-wn.js → skills-BLI5ZUXe.js} +1 -1
  33. package/web/dist/assets/{tab-link-aLp9SnaN.js → tab-link-SMUzNnZa.js} +1 -1
  34. package/web/dist/assets/{task-changes-QfK-hLrE.js → task-changes-nzP5M4TF.js} +1 -1
  35. package/web/dist/assets/{task-commits-xIQcR_Km.js → task-commits-IDq_lfu-.js} +1 -1
  36. package/web/dist/assets/{task-files-B7oZBfjd.js → task-files-DKCWoClo.js} +1 -1
  37. package/web/dist/assets/{task-github-item-CjDws-2w.js → task-github-item-D-HcRSL8.js} +1 -1
  38. package/web/dist/assets/task-thread-BJuTSmY_.js +9 -0
  39. package/web/dist/assets/{thread-state-BBWH_A_c.js → thread-state-DWNsDveq.js} +1 -1
  40. package/web/dist/assets/{use-hand-to-agent-state-Ce533i9c.js → use-hand-to-agent-state-Ds1bv9Yr.js} +1 -1
  41. package/web/dist/assets/{useInfiniteQuery-BrVyFSZ3.js → useInfiniteQuery-HtyVqdKz.js} +1 -1
  42. package/web/dist/assets/useQuery-BGIo-SEb.js +1 -0
  43. package/web/dist/assets/{workflows-CBpLWh2t.js → workflows-BWyhlz9X.js} +2 -2
  44. package/web/dist/assets/ws-BZNDvStH.js +1 -0
  45. package/web/dist/index.html +11 -11
  46. package/web/dist/assets/activity-route-B1mVzd-G.js +0 -2
  47. package/web/dist/assets/attention-GMrS0SeU.js +0 -1
  48. package/web/dist/assets/github-lnyth9tK.js +0 -1
  49. package/web/dist/assets/global-activity-route-Bw-ScJWc.js +0 -1
  50. package/web/dist/assets/hourglass-DjKAbcdJ.js +0 -1
  51. package/web/dist/assets/index-BS8upD5I.js +0 -12
  52. package/web/dist/assets/index-CRlkK-XH.css +0 -1
  53. package/web/dist/assets/queries-k8gAuGEO.js +0 -1
  54. package/web/dist/assets/run-header-CIroyrry.js +0 -2
  55. package/web/dist/assets/task-thread-Ce9y5t-U.js +0 -9
  56. package/web/dist/assets/useQuery-P6-rXCt0.js +0 -1
@@ -0,0 +1,12 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/preview-pane-connected-Dfc9BAkc.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-runtime-CCIEwYL0.js","assets/button-RJMdCnZw.js","assets/bundle-mjs-BT31bpU6.js","assets/project-scope-context-DFjJ4Dzo.js","assets/live-protocol-ai7TG3jr.js","assets/toaster-BWMQArHJ.js","assets/dropdown-menu-B2Hg08ap.js","assets/es2015-VrVcR1vD.js","assets/design-icons-DmYTv2r1.js","assets/loader-circle-CZkGEdoI.js","assets/createLucideIcon-BHp8sXmF.js","assets/arrow-right-Dh_Lx3um.js","assets/hourglass-B0lPAJvT.js","assets/info-DA1x_4bz.js","assets/thread-state-DWNsDveq.js","assets/app-window-CSHwDX9N.js","assets/project-router-DQWY9FSQ.js","assets/report-reader-BflKmitB.js","assets/queries-Cgys1fiN.js","assets/useInfiniteQuery-HtyVqdKz.js","assets/useQuery-BGIo-SEb.js","assets/ws-BZNDvStH.js","assets/file-preview-BmEFF1nO.js","assets/centered-state-dmABwupF.js","assets/markdown-CYkWwCze.js","assets/alert-dialog-D5mmm9BZ.js","assets/chunk-BO2N2NFS-DE6qKn3r.js","assets/lib-BxQXEXDF.js","assets/task-thread-BJuTSmY_.js","assets/popover-DV9NKc0j.js","assets/textarea-CMbcARwO.js","assets/run-header-p5pX7Js3.js","assets/message-square-B-MD-8rD.js","assets/control-locations-SzZ8gyme.js","assets/tab-link-SMUzNnZa.js","assets/run-header-CC7VUTg9.css","assets/eye-B8okNWXU.js","assets/agent-accounts-ZGHdsjYE.js","assets/lib-BQXq3kEf.js","assets/zoomable-image-DefjK4q5.js","assets/report-title-D4Mbu2Er.js","assets/task-thread-DtQ6uGfQ.css","assets/task-changes-nzP5M4TF.js","assets/git-toolbar-BIctOY7_.js","assets/diff-controls-7vfelV7P.js","assets/markdown-BBDDg-4t.js","assets/diff-CQdcUei8.js","assets/image-preview-BmcpjY75.js","assets/task-files-DKCWoClo.js","assets/task-commits-IDq_lfu-.js","assets/commit-diff-panel-UwU29VK_.js","assets/task-github-item-D-HcRSL8.js","assets/use-hand-to-agent-state-Ds1bv9Yr.js","assets/github-sidebar-model-DssVqUad.js","assets/skills-DFBiAuJG.js","assets/skills-workflows-C21NystW.css","assets/use-hand-to-agent-state-C7esPJ-N.css","assets/repo-git-BmaBIIo9.js","assets/nav-row-styles-D4xk5Osn.js","assets/repo-git-DVXNOJDT.css","assets/github-BtPVrHZu.js","assets/reports-D0VRvzsA.js","assets/reports-B7QAzibP.css","assets/workflows-BWyhlz9X.js","assets/sortable.esm-zp_qkYGV.js","assets/skill-empty-hint-oOtzR3v0.js","assets/activity-route-CQPkXxJ2.js","assets/activity-motion-Ch0PoZJR.js","assets/activity-motion-B5fIHwoB.css","assets/global-activity-route-BOg5DOZ-.js","assets/skills-BLI5ZUXe.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,n,r,t as i}from"./react-runtime-CCIEwYL0.js";import{C as a,D as o,E as s,M as c,O as l,P as u,T as d,_ as f,a as p,b as m,c as h,f as g,g as _,h as v,i as y,j as b,k as x,l as S,m as C,n as w,p as T,r as E,s as D,t as O,u as k,v as A,w as j,x as M,y as N}from"./button-RJMdCnZw.js";import{$n as P,Ar as F,Bn as I,Br as L,Bt as ee,C as te,Cn as ne,Cr as R,Dt as re,E as ie,En as ae,Er as oe,Et as se,Fn as ce,Ft as le,G as ue,Gn as de,Hn as fe,In as pe,J as me,Jn as he,Jr as ge,K as _e,Nn as ve,O as ye,On as be,Ot as xe,Pn as Se,Qr as Ce,Qt as we,Sn as Te,U as Ee,Ur as De,Vr as z,Wn as Oe,Wt as ke,Xn as Ae,Xr as je,Xt as Me,Yn as Ne,Yr as Pe,Yt as Fe,Zr as Ie,Zt as Le,_ as Re,_n as ze,_r as Be,a as Ve,ai as He,b as Ue,ci as We,ct as Ge,d as Ke,dt as qe,ei as Je,gr as Ye,hn as Xe,i as Ze,in as Qe,jn as $e,li as et,lr as tt,m as nt,mn as rt,mr as it,n as at,ni as ot,nn as st,o as ct,or as lt,p as ut,pn as dt,q as ft,qn as pt,r as mt,ri as ht,rn as gt,s as _t,sr as vt,t as yt,ti as bt,tn as xt,tr as St,tt as Ct,ui as wt,ur as Tt,vr as Et,vt as Dt,w as Ot,wn as kt,xt as At,yr as jt,yt as Mt,zn as Nt,zt as Pt}from"./project-scope-context-DFjJ4Dzo.js";import{t as Ft}from"./useInfiniteQuery-HtyVqdKz.js";import{$ as It,$t as Lt,A as Rt,An as zt,At as Bt,Bn as Vt,Bt as Ht,Cn as Ut,Dn as Wt,Dt as Gt,En as Kt,Et as qt,F as Jt,Fn as Yt,Ft as Xt,G as Zt,Gt as Qt,H as $t,Hn as en,Ht as B,It as tn,J as nn,Jt as rn,K as an,Kt as on,L as sn,Lt as cn,Mn as ln,Mt as un,Nt as dn,On as fn,Ot as pn,P as mn,Pn as hn,Pt as gn,Q as _n,R as vn,Rn as yn,Rt as bn,Sn as xn,Tn as Sn,Tt as Cn,V as wn,Vn as V,W as Tn,Wt as En,X as Dn,Xt as On,Y as kn,Yt as An,Z as jn,Zt as Mn,_ as Nn,_n as Pn,a as Fn,an as In,at as Ln,b as Rn,bn as zn,c as Bn,cn as Vn,ct as Hn,dn as Un,dt as Wn,en as Gn,et as Kn,fn as qn,g as Jn,gn as Yn,gt as Xn,h as Zn,hn as Qn,ht as $n,i as er,in as tr,jn as nr,jt as rr,kn as ir,kt as ar,l as or,ln as sr,lt as cr,m as lr,mn as ur,n as H,nn as dr,nt as fr,o as pr,ot as mr,p as hr,pn as gr,q as _r,qt as vr,r as yr,rt as br,s as xr,sn as Sr,st as Cr,t as wr,tn as Tr,tt as Er,un as Dr,v as Or,vn as kr,w as Ar,wn as jr,wt as Mr,xn as Nr,y as Pr,yn as Fr,zn as Ir,zt as Lr}from"./queries-Cgys1fiN.js";import{t as Rr}from"./useQuery-BGIo-SEb.js";import{i as zr}from"./bundle-mjs-BT31bpU6.js";import{$ as Br,I as Vr,L as Hr,M as Ur,N as Wr,Q as Gr,R as Kr,Y as qr,Z as Jr,at as Yr,b as Xr,et as Zr,j as Qr,nt as U,ot as W,rt as G,st as $r,ut as ei}from"./live-protocol-ai7TG3jr.js";import{i as ti,r as ni,t as ri}from"./cez-idle-D3aj_9lp.js";import{n as ii,o as ai,r as oi}from"./ws-BZNDvStH.js";import{n as K,t as si}from"./toaster-BWMQArHJ.js";import{a as ci,c as li,d as ui,f as di,h as fi,i as pi,l as mi,m as hi,n as gi,o as _i,p as q,r as vi,t as yi,u as bi}from"./es2015-VrVcR1vD.js";import{C as xi,_ as Si,a as Ci,b as wi,c as Ti,d as Ei,f as Di,g as Oi,h as ki,i as Ai,l as ji,m as Mi,o as Ni,p as Pi,r as Fi,s as Ii,t as Li,u as Ri,v as zi,w as Bi,x as Vi,y as Hi}from"./dropdown-menu-B2Hg08ap.js";import{a as Ui,c as Wi,d as Gi,f as Ki,g as qi,h as Ji,i as Yi,l as Xi,m as Zi,n as Qi,o as $i,p as ea,r as ta,s as na,t as ra,u as ia}from"./alert-dialog-D5mmm9BZ.js";import{C as aa,S as oa,a as sa,b as ca,c as la,f as ua,h as da,i as fa,l as pa,m as ma,n as ha,o as ga,r as _a,s as va,u as ya,v as ba,w as xa}from"./github-sidebar-model-DssVqUad.js";import{i as Sa,n as Ca,o as wa,r as Ta,s as Ea,t as Da}from"./popover-DV9NKc0j.js";import{$ as Oa,A as ka,B as Aa,D as ja,E as Ma,H as Na,I as Pa,J as Fa,K as Ia,L as La,M as Ra,O as za,Q as Ba,R as Va,S as Ha,V as Ua,W as Wa,X as Ga,Z as Ka,_ as qa,a as Ja,at as Ya,b as Xa,c as Za,ct as Qa,d as $a,et as eo,f as to,ft as no,g as ro,ht as io,it as ao,j as oo,k as so,l as co,m as lo,mt as uo,n as fo,nt as po,ot as mo,pt as ho,q as go,r as _o,rt as vo,s as yo,t as bo,tt as xo,u as So,ut as Co,w as wo,x as To,y as Eo,z as Do}from"./design-icons-DmYTv2r1.js";import{a as Oo,c as ko,i as Ao,n as jo,o as Mo,r as No,s as Po,t as Fo}from"./textarea-CMbcARwO.js";import{a as Io,i as Lo,n as Ro,r as zo,t as Bo}from"./loader-circle-CZkGEdoI.js";import{t as J}from"./createLucideIcon-BHp8sXmF.js";import{_ as Vo,a as Ho,c as Uo,d as Wo,f as Go,g as Ko,h as qo,i as Jo,m as Yo,o as Xo,p as Zo,r as Qo,s as $o,u as es,y as ts}from"./nav-row-styles-D4xk5Osn.js";import{t as ns}from"./eye-B8okNWXU.js";import{a as rs,c as is,i as as,n as os,o as ss,t as cs,u as ls}from"./control-locations-SzZ8gyme.js";import{a as us,c as ds,i as fs,l as ps,n as ms,o as hs,r as gs,s as _s,t as Y,u as vs}from"./project-router-DQWY9FSQ.js";import{n as ys,t as X}from"./centered-state-dmABwupF.js";import{A as bs,D as xs,E as Ss,F as Cs,I as ws,L as Ts,M as Es,N as Ds,O as Os,P as ks,R as As,S as js,T as Ms,V as Ns,_ as Ps,a as Fs,b as Is,c as Ls,d as Rs,f as zs,g as Bs,h as Vs,i as Hs,k as Us,l as Ws,m as Gs,n as Ks,o as qs,p as Js,r as Ys,s as Xs,t as Zs,u as Qs,v as $s,w as ec,x as tc,y as nc,z as rc}from"./agent-accounts-ZGHdsjYE.js";import{c as ic,d as ac,f as oc,i as sc,n as cc,o as lc,r as uc,s as dc,t as fc,u as pc}from"./skills-DFBiAuJG.js";import{f as mc,m as hc,p as gc}from"./markdown-CYkWwCze.js";import{_ as _c,a as vc,c as yc,d as bc,f as xc,g as Sc,i as Cc,l as wc,n as Tc,o as Ec,p as Dc,r as Oc,t as kc,u as Ac,v as jc}from"./sortable.esm-zp_qkYGV.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Mc=class extends wt{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new en({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Nc(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Nc(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Nc(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=Nc(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){Pe.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Je(t,e))}findAll(e={}){return this.getAll().filter(t=>Je(e,t))}notify(e){Pe.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return Pe.batch(()=>Promise.all(e.map(e=>e.continue().catch(ot))))}};function Nc(e){return e.options.scope?.id}var Pc=class extends wt{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??Ce(r,t),a=this.get(i);return a||(a=new De({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){Pe.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>bt(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>bt(e,t)):t}notify(e){Pe.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){Pe.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Pe.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Fc=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Pc,this.#t=e.mutationCache||new Mc,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=et.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=ge.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(He(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=je(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return Pe.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;Pe.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return Pe.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=Pe.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(ot).catch(ot)}invalidateQueries(e,t={}){return Pe.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=Pe.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(ot)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(ot)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(He(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(ot).catch(ot)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(ot).catch(ot)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return ge.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(Ie(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{ht(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(Ie(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{ht(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=Ce(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===We&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Z=e(t(),1),Ic=n(),Lc=class extends EventTarget{readyState=0;release;constructor(e,t){super();let n=()=>queueMicrotask(()=>{this.readyState===0&&(this.readyState=1,this.dispatchEvent(new Event(`open`)))});this.release=oe({kind:`workspace`},{ready:n,reset:()=>{this.readyState!==2&&(this.readyState=0,n())},frame:e=>{if(`data`in e&&e.event===`reconnect`){this.readyState=0,n();return}if(`data`in e&&e.event===`disconnect`){this.readyState===1&&(this.readyState=0,this.dispatchEvent(new Event(`error`)));return}`data`in e&&this.dispatchEvent(new MessageEvent(e.event,{data:e.data}))}})}close(){this.readyState=2,this.release()}};function Rc(e,t){if(e===`ping`)return{project:null,event:{type:`ping`}};let n;try{n=JSON.parse(t)}catch{return null}if(!zc(n))return null;let r=n.project;if(typeof r!=`string`||r===``)return null;switch(e){case`run`:{let{project:e,...t}=n;return Bc(t)?{project:r,event:{type:`run`,run:t}}:null}case`run-deleted`:{let e=n.id;return typeof e==`string`&&e?{project:r,event:{type:`run-deleted`,id:e}}:null}case`usage`:return zc(n.usage)?{project:r,event:{type:`usage`,usage:n.usage}}:null;default:return null}}function zc(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Bc(e){return zc(e)&&typeof e.id==`string`&&e.id!==``}function Vc(e,t){if(!e)return;let n=e.findIndex(e=>e.id===t.id);if(n>=0){let r=[...e];return r[n]=Wc(e[n],t),r}let r=t.createdAt??``,i=e.findIndex(e=>(e.createdAt??``).localeCompare(r)<0),a=[...e];return a.splice(i<0?e.length:i,0,he(t)),a}function Hc(e,t){if(!e)return;let n=e.filter(e=>e.id!==t);return n.length===e.length?e:n}function Uc(e,t){return e?.usage?{...t,usage:e.usage}:t}function Wc(e,t){return he(e?.usage?{...t,usage:e.usage}:t)}var Gc=Object.freeze({});function Kc(){let e=Gc,t=new Set;return{subscribe(e){return t.add(e),()=>t.delete(e)},get:()=>e,set(n){e=n;for(let e of t)e()}}}var Q=i(),qc=x(`/workspace/events`),Jc=2,Yc=3e3,Xc=[`run`,`run-deleted`,`usage`,`ping`],Zc=[`project-added`,`project-removed`,`checkout-progress`,`automation-change`,`project-ready`],Qc=new Set;function $c(e){return Qc.add(e),()=>{Qc.delete(e)}}var el=400;function tl(e){let t,n=()=>{t===void 0&&(t=setTimeout(()=>{t=void 0,e.invalidateQueries({queryKey:B.runsIndex}),e.invalidateQueries({predicate:e=>e.queryKey[1]===`reports`,refetchType:`active`})},el))};return{onEvent(e){(e.type===`run`||e.type===`run-deleted`)&&n()},refresh:n,cancel(){clearTimeout(t),t=void 0}}}function nl(e){return e[1]===`runs`&&e[2]===`list`}function rl(e,t){return e.cancelQueries({queryKey:t}).then(()=>e.invalidateQueries({queryKey:t}))}function il(e){return e.invalidateQueries({predicate:e=>nl(e.queryKey),refetchType:`none`}),e.getQueryCache().findAll({predicate:e=>nl(e.queryKey)&&(e.state.data!==void 0||e.state.fetchStatus!==`idle`)}).map(t=>rl(e,t.queryKey))}var al=1e3,ol=new WeakMap;function sl(e){let t=H.repoBranches,n=ol.get(e);if(n){n.set(JSON.stringify(t),t);return}ol.set(e,new Map([[JSON.stringify(t),t]])),setTimeout(()=>{let t=ol.get(e);ol.delete(e);for(let n of t?.values()??[])e.invalidateQueries({queryKey:n})},al)}function cl(e,t,n=!1){if(t?.aborted)return Promise.resolve();let r=[H.runs.all,B.runsIndex,B.projects,H.health,H.worktrees,H.repoBranches,B.providerStatus,B.models(`cursor`)],i=()=>{for(let t of r)e.cancelQueries({queryKey:t})};return t?.addEventListener(`abort`,i,{once:!0}),ti(()=>{for(let t of e.getQueryCache().findAll({predicate:e=>nl(e.queryKey)}))t.state.data===void 0&&t.state.fetchStatus!==`idle`&&e.cancelQueries({queryKey:t.queryKey,exact:!0});return[e.invalidateQueries({queryKey:H.runs.all,...n?{predicate:e=>[`list`,`detail`,`relationships`,`archived`].includes(String(e.queryKey[2]))}:{}}),e.invalidateQueries({predicate:e=>nl(e.queryKey)}),e.invalidateQueries({queryKey:B.runsIndex}),e.invalidateQueries({queryKey:B.projects}),rl(e,H.health),e.invalidateQueries({queryKey:H.worktrees}),e.invalidateQueries({queryKey:H.repoBranches}),e.invalidateQueries({queryKey:B.providerStatus}),rl(e,B.models(`cursor`)),n?void 0:e.invalidateQueries({predicate:({queryKey:e})=>e.length===3&&e[1]===`github`&&(e[2]===null||typeof e[2]==`number`)})]}).finally(()=>t?.removeEventListener(`abort`,i))}function ll(e){return b()??ul(e)}function ul(e){let t=e.getQueryData(B.projects)?.bootProject;return typeof t==`string`&&t!==``?t:e.getQueryData(H.health)?.bootProject??e.getQueryData([`default`,`health`])?.bootProject}function dl(e,t){return[Ir({projectId:e,boot:e===t}).cacheScope,`runs`,`list`]}function fl(e){let t=new Map,n=new Map,r=t=>{let r=n.get(JSON.stringify(t));if(!r)return;let i=e.getQueryCache().find({queryKey:t,exact:!0}),a=i?.promise;r.phase=`awaiting-fetch`,r.dirty=!1,e.invalidateQueries({queryKey:t,exact:!0}),i?.promise&&i.promise!==a&&(r.phase=`fetching`)},i=e.getQueryCache().subscribe(t=>{if(!n.size||t.type!==`updated`)return;let i=JSON.stringify(t.query.queryKey),a=n.get(i);if(a){if(t.action.type===`setState`){t.query.state.isInvalidated||e.invalidateQueries({queryKey:a.key,exact:!0,refetchType:`none`});return}if(t.action.type===`fetch`){a.phase===`awaiting-fetch`&&(a.phase=`fetching`),a.dirty=!1;return}if(t.action.type===`success`){if(!t.action.manual){a.phase===`fetching`&&!a.dirty?n.delete(i):r(a.key);return}a.phase!==`needs-start`&&(a.phase===`fetching`&&(a.dirty=!0),e.invalidateQueries({queryKey:a.key,exact:!0},{cancelRefetch:!1}))}}}),a=(t,r)=>{let i=JSON.stringify(t),a=e.getQueryCache().find({queryKey:t,exact:!0});if(!a)return;let o=n.get(i);!o&&(a.state.fetchStatus!==`idle`||a.state.isInvalidated)||o&&a.state.fetchStatus===`idle`?(n.set(i,{key:t,phase:`needs-start`,dirty:!1}),a.state.fetchStatus!==`idle`&&e.cancelQueries({queryKey:t,exact:!0}),r.some(e=>JSON.stringify(e)===i)||r.push(t)):o?.phase===`fetching`&&(o.dirty=!0)},o,s,c=(i=!1)=>{s!==void 0&&clearTimeout(s),s=void 0,o!==void 0&&cancelAnimationFrame(o),o=void 0;let c=[];for(let{key:r,baseList:i,baseQuery:o,baseUpdateCount:s,runs:l}of t.values()){let t=e.getQueryCache().find({queryKey:r,exact:!0});if(t!==o||t?.state.dataUpdateCount!==s||t?.state.data!==i){c.push(r),n.set(JSON.stringify(r),{key:r,phase:`needs-start`,dirty:!1}),e.cancelQueries({queryKey:r,exact:!0});continue}a(r,c),e.setQueryData(r,e=>{let t=e;for(let e of l.values())t=Vc(t,e);return t})}if(t.clear(),!i)for(let e of c)r(e);return c},l=t=>{let n=[dl(t,ul(e))],r=[t,`runs`,`list`];return(t===ll(e)||e.getQueryState(r))&&n.push(r),t===ll(e)&&n.push(H.runs.list()),[...new Map(n.map(e=>[JSON.stringify(e),e])).values()]};return{onEvent(i,u){let d=l(i);if(u.type===`run`&&u.run.archived&&d.every(t=>!e.getQueryData(t)?.find(e=>e.id===u.run.id)?.archived)&&u.type===`run`){for(let r of d){let i=JSON.stringify(r),a=n.get(i);a?.phase===`fetching`&&(a.dirty=!0);let o=t.get(i);if(!o){let n=e.getQueryCache().find({queryKey:r,exact:!0});o={key:r,baseList:n?.state.data,baseQuery:n,baseUpdateCount:n?.state.dataUpdateCount,runs:new Map},t.set(i,o)}o.runs.set(u.run.id,u.run)}s===void 0&&(s=setTimeout(()=>{c()},50),typeof requestAnimationFrame==`function`&&(o=requestAnimationFrame(()=>{c()})));return}let f=c(!0);for(let t of d)a(t,f),u.type===`run`?e.setQueryData(t,e=>Vc(e,u.run)):e.setQueryData(t,e=>Hc(e,u.id));for(let e of f)r(e)},flush:c,cancel(){i(),n.clear()}}}function pl(e){let t=new Map;return{refresh(n){let r=H.runs.detail(n);if(!e.getQueryState(r))return;let i=JSON.stringify(r);clearTimeout(t.get(i)),e.cancelQueries({queryKey:r}),t.set(i,setTimeout(()=>{t.delete(i),e.invalidateQueries({queryKey:r})},400))},cancel(){for(let e of t.values())clearTimeout(e);t.clear()}}}var ml=400;function hl(e){return JSON.stringify([e.status,e.currentStepId,e.delegation])}function gl(e){let t=new Map,n=new Map,r=(t,r)=>{if(r&&!e.getQueryState(t))return;let i=JSON.stringify(t);n.has(i)||n.set(i,setTimeout(()=>{n.delete(i),e.invalidateQueries({queryKey:t})},ml))};return{onRun(e){let n=e.delegation?.role===`worker`?e.delegation.parentRunId:void 0,i=hl(e),a=t.get(e.id);t.set(e.id,n===void 0?{shape:i}:{shape:i,parentRunId:n}),a?.shape!==i&&(r(H.runs.relationships(e.id),!0),n!==void 0&&r(H.runs.relationships(n),!0))},onDeleted(n){let i=t.get(n);t.delete(n),e.removeQueries({queryKey:H.runs.relationships(n)}),i?.parentRunId===void 0?r([...H.runs.all,`relationships`],!1):r(H.runs.relationships(i.parentRunId),!0)},cancel(){for(let e of n.values())clearTimeout(e);n.clear(),t.clear()}}}var _l={predicate:e=>e.queryKey[1]===`runs`&&e.queryKey[2]===`archived`};function vl(e,t){if(t.delegation?.role===`worker`)return;let n=!1;for(let r of e.getQueryCache().findAll(_l)){let i=r.state.data;if(i)if(i.pages.some(e=>e.runs.some(e=>e.id===t.id))){let a=he(t);e.setQueryData(r.queryKey,{...i,pages:i.pages.map(e=>({...e,runs:e.runs.map(e=>e.id===t.id?{...a,...e.usage?{usage:e.usage}:{}}:e)}))}),(!t.archived||r.queryKey[3]!==``)&&(n=!0)}else t.archived&&(n=!0)}n&&e.invalidateQueries(_l)}function yl(e,t,n,r,i){switch(n.type){case`run`:{vl(e,n.run),i.onRun(n.run);let t=H.runs.detail(n.run.id);if(e.getQueryData(t)!==void 0&&e.setQueryData(t,e=>Uc(e,n.run)),r(n.run.id),n.run.delegation?.role===`worker`){let t=H.runs.detail(n.run.delegation.parentRunId);e.setQueryData(t,e=>{if(!e)return e;let{finishBlocked:t,...n}=e;return n}),r(n.run.delegation.parentRunId)}let a=H.runs.changes(n.run.id);e.getQueryData(a)!==void 0&&e.invalidateQueries({queryKey:a}),e.invalidateQueries({queryKey:H.worktrees}),sl(e);return}case`run-deleted`:i.onDeleted(n.id),e.removeQueries({queryKey:H.runs.detail(n.id)}),e.removeQueries({queryKey:H.runs.diff(n.id)}),e.setQueriesData(_l,e=>e&&e.pages.some(e=>e.runs.some(e=>e.id===n.id))?{...e,pages:e.pages.map(e=>({...e,runs:e.runs.filter(e=>e.id!==n.id)}))}:e),e.invalidateQueries(_l),e.invalidateQueries({queryKey:H.worktrees}),sl(e);return;case`usage`:t.set(n.usage);return;case`ping`:return}}function bl(e,t=qc){let n=z();(0,Z.useEffect)(()=>{let r=Lc;if(typeof r!=`function`)return;let i=null,a=tl(n),o=pl(n),s=fl(n),c=gl(n),l=!1,u,d=!1,f=!1,p=!1,m=!1,h=()=>{p=!0,m=!1;let e=B.providerStatus;n.cancelQueries({queryKey:e,exact:!0}).then(()=>n.invalidateQueries({queryKey:e,exact:!0,refetchType:`active`})).finally(()=>{if(f||!m){p=!1;return}h()})},g=()=>{f||u!==void 0||(u=setTimeout(()=>{u=void 0,f||_()},Yc))},_=()=>{i?.close(),i=new r(t,{withCredentials:!0}),i.addEventListener(`open`,()=>{if(l=!0,ni(!1),d&&(s.flush(),cl(n)),!d){ti(()=>il(n));for(let e of[H.health,B.models(`cursor`),B.runsIndex])n.cancelQueries({queryKey:e}).then(()=>{f||n.invalidateQueries({queryKey:e})})}d=!0});for(let t of Xc)i.addEventListener(t,r=>{let i=Rc(t,r.data);i&&(i.event.type===`ping`&&l&&(l=!1,ti(()=>il(n)),ni(!0)),a.onEvent(i.event),i.project!==null&&(i.event.type===`run`||i.event.type===`run-deleted`)&&s.onEvent(i.project,i.event),!(i.project!==null&&i.project!==ll(n))&&yl(n,e,i.event,o.refresh,c))});for(let e of Zc)i.addEventListener(e,t=>{let r;try{r=JSON.parse(t.data)}catch{return}e===`project-ready`?a.refresh():e!==`checkout-progress`&&e!==`automation-change`&&n.invalidateQueries({queryKey:B.projects});for(let t of[...Qc])t(e,r)});i.addEventListener(`health`,e=>{let t;try{t=JSON.parse(e.data)}catch{return}let r=F.safeParse(t);r.success&&(n.cancelQueries({queryKey:H.health}),n.setQueryData(H.health,r.data))}),i.addEventListener(`model-catalog`,e=>{let t;try{t=JSON.parse(e.data)}catch{return}let r=Hr.safeParse(t);if(!r.success||r.data.runner!==`cursor`)return;let i=B.models(`cursor`);n.cancelQueries({queryKey:i}),n.setQueryData(i,r.data)}),i.addEventListener(`provider-status`,e=>{let t;try{t=JSON.parse(e.data)}catch{return}let r=Ye(t);if(!r)return;let i=B.providerStatus,a=it(n.getQueryData(i),r);if(a!==void 0){n.setQueryData(i,a);return}if(p){m=!0;return}h()}),i.addEventListener(`error`,()=>{ni(!1),i?.readyState===Jc&&g()})},v=()=>{document.visibilityState===`visible`&&(s.flush(),(!i||i.readyState===Jc)&&(clearTimeout(u),u=void 0,_()))},y=()=>{clearTimeout(u),u=void 0,s.flush()};document.addEventListener(`visibilitychange`,v),window.addEventListener(`pagehide`,y);let b=R((e,t)=>(s.flush(),cl(n,e,t)));return _(),()=>{b(),f=!0,ni(!1),clearTimeout(u),s.flush(),s.cancel(),a.cancel(),o.cancel(),c.cancel(),document.removeEventListener(`visibilitychange`,v),window.removeEventListener(`pagehide`,y),i?.close(),i=null}},[n,e,t])}var xl=(0,Z.createContext)(null);function Sl({children:e}){let[t]=(0,Z.useState)(Kc);return bl(t),Jt(),(0,Q.jsx)(xl.Provider,{value:t,children:e})}function Cl(e){let t=(0,Z.useContext)(xl),n=t?t.get:Tl;return(0,Z.useSyncExternalStore)(t?t.subscribe:wl,()=>e?n()[e]:void 0,()=>void 0)}var wl=()=>()=>void 0,Tl=()=>Gc;function El(){return new Fc({defaultOptions:{queries:{refetchInterval:!1,staleTime:5*6e4,gcTime:30*6e4,refetchOnWindowFocus:!1,refetchOnReconnect:!1,retry:(e,t)=>t instanceof Ze&&t.status>=400&&t.status<500?!1:e<1},mutations:{retry:!1}}})}var Dl=class extends Z.Component{state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:Error(String(e))}}componentDidCatch(e,t){console.error(`cezar cockpit: uncaught render error`,e,t.componentStack)}render(){let{error:e}=this.state;return e?(0,Q.jsxs)(`div`,{"data-slot":`app-error`,role:`alert`,style:{display:`flex`,minHeight:`100dvh`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`12px`,padding:`24px`,textAlign:`center`,font:`14px/1.5 system-ui, sans-serif`},children:[(0,Q.jsx)(`h1`,{style:{fontSize:`20px`,fontWeight:600,margin:0},children:`The cockpit hit an error`}),(0,Q.jsxs)(`p`,{style:{margin:0,maxWidth:`52ch`},children:[`Reload to carry on. Nothing on disk changed — cezar’s state lives in`,` `,(0,Q.jsx)(`code`,{children:`.ai/cezar/`}),`, and this page never wrote to it.`]}),(0,Q.jsx)(`pre`,{"data-slot":`app-error-detail`,style:{margin:0,maxWidth:`100%`,overflowX:`auto`,textAlign:`left`,opacity:.75},children:e.message}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>location.reload(),style:{padding:`6px 14px`,cursor:`pointer`},children:`Reload`})]}):this.props.children}};async function Ol(e){return ae(await ut.api.v1.workspace[`self-update`].$get({},Pt(e)),`/workspace/self-update`)}async function kl(){return ae(await ut.api.v1.workspace[`self-update`].refresh.$post({}),`/workspace/self-update/refresh`)}async function Al(e){return ae(await ut.api.v1.workspace[`self-update`].development.$get({query:e?.refresh?{refresh:`1`}:{}},Pt(e)),`/workspace/self-update/development`)}async function jl(e){return ae(await ut.api.v1.workspace[`self-update`].channel.$put({json:{channel:e}}),`/workspace/self-update/channel`)}async function Ml(e){return ae(await ut.api.v1.workspace[`self-update`].apply.$post({json:{version:e}}),`/workspace/self-update/apply`)}var Nl={status:[`workspace`,`self-update`],development:[`workspace`,`self-update`,`development`]};function Pl(e=!0){return Rr({queryKey:Nl.status,queryFn:({signal:e})=>Ol({signal:e}),enabled:e,refetchInterval:ii(e=>e.state.data?.job?.status===`running`&&1e3)})}function Fl(e=!0){return Rr({queryKey:Nl.development,queryFn:({signal:e})=>Al({signal:e}),enabled:e,staleTime:3e4})}function Il(){let e=z();return V({mutationFn:()=>Al({refresh:!0}),onSuccess:t=>e.setQueryData(Nl.development,t)})}function Ll(){let e=z();return V({mutationFn:()=>kl(),onSuccess:t=>e.setQueryData(Nl.status,t)})}function Rl(){let e=z();return V({mutationFn:e=>jl(e),onSuccess:t=>e.setQueryData(Nl.status,t)})}function zl(){let e=z();return V({mutationFn:e=>Ml(e),onSuccess:t=>e.setQueryData(Nl.status,t)})}var Bl=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),Vl=`VisuallyHidden`,Hl=Z.forwardRef((e,t)=>(0,Q.jsx)(fi.span,{...e,ref:t,style:{...Bl,...e.style}}));Hl.displayName=Vl;var Ul=Hl,Wl=`Collapsible`,[Gl,Kl]=hi(Wl),[ql,Jl]=Gl(Wl),Yl=Z.forwardRef((e,t)=>{let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:o,...s}=e,[c,l]=ui({prop:r,defaultProp:i??!1,onChange:o,caller:Wl});return(0,Q.jsx)(ql,{scope:n,disabled:a,contentId:mi(),open:c,onOpenToggle:Z.useCallback(()=>l(e=>!e),[l]),children:(0,Q.jsx)(fi.div,{"data-state":tu(c),"data-disabled":a?``:void 0,...s,ref:t})})});Yl.displayName=Wl;var Xl=`CollapsibleTrigger`,Zl=Z.forwardRef((e,t)=>{let{__scopeCollapsible:n,...r}=e,i=Jl(Xl,n);return(0,Q.jsx)(fi.button,{type:`button`,"aria-controls":i.open?i.contentId:void 0,"aria-expanded":i.open||!1,"data-state":tu(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:q(e.onClick,i.onOpenToggle)})});Zl.displayName=Xl;var Ql=`CollapsibleContent`,$l=Z.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=Jl(Ql,e.__scopeCollapsible);return(0,Q.jsx)(bi,{present:n||i.open,children:({present:e})=>(0,Q.jsx)(eu,{...r,ref:t,present:e})})});$l.displayName=Ql;var eu=Z.forwardRef((e,t)=>{let{__scopeCollapsible:n,present:r,children:i,...a}=e,o=Jl(Ql,n),[s,c]=Z.useState(r),l=Z.useRef(null),u=D(t,l),d=Z.useRef(0),f=d.current,p=Z.useRef(0),m=p.current,h=o.open||s,g=Z.useRef(h),_=Z.useRef(void 0);return Z.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),di(()=>{let e=l.current;if(e){_.current=_.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();d.current=t.height,p.current=t.width,g.current||(e.style.transitionDuration=_.current.transitionDuration,e.style.animationName=_.current.animationName),c(r)}},[o.open,r]),(0,Q.jsx)(fi.div,{"data-state":tu(o.open),"data-disabled":o.disabled?``:void 0,id:o.contentId,hidden:!h,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:h&&i})});function tu(e){return e?`open`:`closed`}var nu=Yl,ru=`Label`,iu=Z.forwardRef((e,t)=>(0,Q.jsx)(fi.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));iu.displayName=ru;var au=iu;function ou(e,[t,n]){return Math.min(n,Math.max(t,e))}var su=e(r(),1),cu=[` `,`Enter`,`ArrowUp`,`ArrowDown`],lu=[` `,`Enter`],uu=`Select`,[du,fu,pu]=Bi(uu),[mu,hu]=hi(uu,[pu,Vi]),gu=Vi(),[_u,vu]=mu(uu),[yu,bu]=mu(uu),xu=`SelectProvider`;function Su(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m,internal_do_not_use_render:h}=e,g=gu(t),[_,v]=Z.useState(null),[y,b]=Z.useState(null),[x,S]=Z.useState(!1),C=xi(l),[w,T]=ui({prop:r,defaultProp:i??!1,onChange:a,caller:uu}),[E,D]=ui({prop:o,defaultProp:s,onChange:c,caller:uu}),O=Z.useRef(null),k=Z.useRef(E);Z.useEffect(()=>{let e=m?_?.ownerDocument.getElementById(m):_?.form;if(e instanceof HTMLFormElement){let t=()=>D(k.current);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[m,_,D]);let A=!_||!!m||!!_.closest(`form`),[j,M]=Z.useState(new Set),N=mi(),P=Array.from(j).map(e=>e.props.value).join(`;`),F=Z.useCallback(e=>{M(t=>new Set(t).add(e))},[]),I=Z.useCallback(e=>{M(t=>{let n=new Set(t);return n.delete(e),n})},[]),L={required:p,trigger:_,onTriggerChange:v,valueNode:y,onValueNodeChange:b,valueNodeHasChildren:x,onValueNodeHasChildrenChange:S,contentId:N,value:E,onValueChange:D,open:w,onOpenChange:T,dir:C,triggerPointerDownPosRef:O,disabled:f,name:u,autoComplete:d,form:m,nativeOptions:j,nativeSelectKey:P,isFormControl:A};return(0,Q.jsx)(wi,{...g,children:(0,Q.jsx)(_u,{scope:t,...L,children:(0,Q.jsx)(du.Provider,{scope:t,children:(0,Q.jsx)(yu,{scope:t,onNativeOptionAdd:F,onNativeOptionRemove:I,children:Sd(h)?h(L):n})})})})}Su.displayName=xu;var Cu=e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,Q.jsx)(Su,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,Q.jsxs)(Q.Fragment,{children:[n,e?(0,Q.jsx)(xd,{__scopeSelect:t}):null]})})};Cu.displayName=uu;var wu=`SelectTrigger`,Tu=Z.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=gu(n),o=vu(wu,n),s=o.disabled||r,c=D(t,o.onTriggerChange),l=fu(n),u=Z.useRef(`touch`),[d,f,p]=wd(e=>{let t=l().filter(e=>!e.disabled),n=Td(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,Q.jsx)(Si,{asChild:!0,...a,children:(0,Q.jsx)(fi.button,{type:`button`,role:`combobox`,"aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":Cd(o.value)?``:void 0,...i,ref:c,onClick:q(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:q(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:q(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&cu.includes(e.key)&&(m(),e.preventDefault())})})})});Tu.displayName=wu;var Eu=`SelectValue`,Du=Z.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=vu(Eu,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=D(t,c.onValueNodeChange);di(()=>{l(u)},[l,u]);let f=Cd(c.value);return(0,Q.jsx)(fi.span,{...s,asChild:!f&&s.asChild,ref:d,style:{pointerEvents:`none`},children:(0,Q.jsx)(Z.Fragment,{children:f?o:a},f?`placeholder`:`value`)})});Du.displayName=Eu;var Ou=`SelectIcon`,ku=Z.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,Q.jsx)(fi.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});ku.displayName=Ou;var Au=`SelectPortal`,[ju,Mu]=mu(Au,{forceMount:void 0}),Nu=e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,Q.jsx)(ju,{scope:e.__scopeSelect,forceMount:n,children:(0,Q.jsx)(pi,{asChild:!0,...r})})};Nu.displayName=Au;var Pu=`SelectContent`,Fu=Z.forwardRef((e,t)=>{let n=Mu(Pu,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=vu(Pu,e.__scopeSelect),[o,s]=Z.useState();return di(()=>{s(new DocumentFragment)},[]),(0,Q.jsx)(bi,{present:r||a.open,children:({present:e})=>e?(0,Q.jsx)(Hu,{...i,ref:t}):(0,Q.jsx)(Iu,{...i,fragment:o})})});Fu.displayName=Pu;var Iu=Z.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,fragment:i}=e;return i?su.createPortal((0,Q.jsx)(Ru,{scope:n,children:(0,Q.jsx)(du.Slot,{scope:n,children:(0,Q.jsx)(`div`,{ref:t,children:r})})}),i):null});Iu.displayName=`SelectContentFragment`;var Lu=10,[Ru,zu]=mu(Pu),Bu=`SelectContentImpl`,Vu=y(`SelectContent.RemoveScroll`),Hu=Z.forwardRef((e,t)=>{let{__scopeSelect:n}=e,{position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=vu(Pu,n),[y,b]=Z.useState(null),[x,S]=Z.useState(null),C=D(t,b),[w,T]=Z.useState(null),[E,O]=Z.useState(null),k=fu(n),[A,j]=Z.useState(!1),M=Z.useRef(!1);Z.useEffect(()=>{if(y)return yi(y)},[y]),vi();let N=Z.useCallback(e=>{let[t,...n]=k().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[k,x]),P=Z.useCallback(()=>N([w,y]),[N,w,y]);Z.useEffect(()=>{A&&P()},[A,P]);let{onOpenChange:F,triggerPointerDownPosRef:I}=v;Z.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(I.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(I.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(y)||F(!1),document.removeEventListener(`pointermove`,t),I.current=null};return I.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,F,I]),Z.useEffect(()=>{let e=()=>F(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[F]);let[L,ee]=wd(e=>{let t=k().filter(e=>!e.disabled),n=Td(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),te=Z.useCallback((e,t,n)=>{let r=!M.current&&!n;(v.value!==void 0&&v.value===t||r)&&(T(e),r&&(M.current=!0))},[v.value]),ne=Z.useCallback(()=>y?.focus(),[y]),R=Z.useCallback((e,t,n)=>{let r=!M.current&&!n;(v.value!==void 0&&v.value===t||r)&&O(e)},[v.value]),re=r===`popper`?Ku:Wu,ie=re===Ku?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,Q.jsx)(Ru,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:te,selectedItem:w,onItemLeave:ne,itemTextRefCallback:R,focusSelectedItem:P,selectedItemText:E,position:r,isPositioned:A,searchRef:L,children:(0,Q.jsx)(gi,{as:Vu,allowPinchZoom:!0,children:(0,Q.jsx)(ci,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:q(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,Q.jsx)(_i,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,Q.jsx)(re,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...ie,onPlaced:()=>j(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:q(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&ee(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=k().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>N(t)),e.preventDefault()}})})})})})})});Hu.displayName=Bu;var Uu=`SelectItemAlignedPosition`,Wu=Z.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=vu(Pu,n),o=zu(Pu,n),[s,c]=Z.useState(null),[l,u]=Z.useState(null),d=D(t,u),f=fu(n),p=Z.useRef(!1),m=Z.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=Z.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Lu,d=ou(a,[Lu,Math.max(Lu,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Lu,d=ou(a,[Lu,Math.max(Lu,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-Lu*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-Lu,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,j=x-A;if(A<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${Lu}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);di(()=>y(),[y]);let[b,x]=Z.useState();return di(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]),(0,Q.jsx)(qu,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:Z.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]),children:(0,Q.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:b},children:(0,Q.jsx)(fi.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});Wu.displayName=Uu;var Gu=`SelectPopperPosition`,Ku=Z.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=Lu,...a}=e,o=gu(n);return(0,Q.jsx)(Hi,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});Ku.displayName=Gu;var[qu,Ju]=mu(Pu,{}),Yu=`SelectViewport`,Xu=Z.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=zu(Yu,n),o=Ju(Yu,n),s=D(t,a.onViewportChange),c=Z.useRef(0);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,Q.jsx)(du.Slot,{scope:n,children:(0,Q.jsx)(fi.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:q(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-Lu*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});Xu.displayName=Yu;var Zu=`SelectGroup`,[Qu,$u]=mu(Zu),ed=Z.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=mi();return(0,Q.jsx)(Qu,{scope:n,id:i,children:(0,Q.jsx)(fi.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});ed.displayName=Zu;var td=`SelectLabel`,nd=Z.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=$u(td,n);return(0,Q.jsx)(fi.div,{id:i.id,...r,ref:t})});nd.displayName=td;var rd=`SelectItem`,[id,ad]=mu(rd),od=Z.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=vu(rd,n),c=zu(rd,n),l=s.value===r,[u,d]=Z.useState(a??``),[f,p]=Z.useState(!1),m=D(t,li(e=>c.itemRefCallback?.(e,r,i))),h=mi(),g=Z.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};return(0,Q.jsx)(id,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:Z.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,Q.jsx)(du.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,Q.jsx)(fi.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:q(o.onFocus,()=>p(!0)),onBlur:q(o.onBlur,()=>p(!1)),onClick:q(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:q(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:q(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:q(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:q(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:q(o.onKeyDown,e=>{i||e.target!==e.currentTarget||c.searchRef?.current!==``&&e.key===` `||(lu.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});od.displayName=rd;var sd=`SelectItemText`,cd=Z.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=vu(sd,n),s=zu(sd,n),c=ad(sd,n),l=bu(sd,n),[u,d]=Z.useState(null),f=li(e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=D(t,d,c.onItemTextChange,f),m=u?.textContent,h=Z.useMemo(()=>(0,Q.jsx)(`option`,{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:g,onNativeOptionRemove:_}=l;return di(()=>(g(h),()=>_(h)),[g,_,h]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(fi.span,{id:c.textId,...a,ref:p}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!Cd(o.value)?su.createPortal(a.children,o.valueNode):null]})});cd.displayName=sd;var ld=`SelectItemIndicator`,ud=Z.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return ad(ld,n).isSelected?(0,Q.jsx)(fi.span,{"aria-hidden":!0,...r,ref:t}):null});ud.displayName=ld;var dd=`SelectScrollUpButton`,fd=Z.forwardRef((e,t)=>{let n=zu(dd,e.__scopeSelect),r=Ju(dd,e.__scopeSelect),[i,a]=Z.useState(!1),o=D(t,r.onScrollButtonChange);return di(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,Q.jsx)(hd,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});fd.displayName=dd;var pd=`SelectScrollDownButton`,md=Z.forwardRef((e,t)=>{let n=zu(pd,e.__scopeSelect),r=Ju(pd,e.__scopeSelect),[i,a]=Z.useState(!1),o=D(t,r.onScrollButtonChange);return di(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,Q.jsx)(hd,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});md.displayName=pd;var hd=Z.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=zu(`SelectScrollButton`,n),o=Z.useRef(null),s=fu(n),c=Z.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return Z.useEffect(()=>()=>c(),[c]),di(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,Q.jsx)(fi.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:q(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:q(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:q(i.onPointerLeave,()=>{c()})})}),gd=`SelectSeparator`,_d=Z.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,Q.jsx)(fi.div,{"aria-hidden":!0,...r,ref:t})});_d.displayName=gd;var vd=`SelectArrow`,yd=Z.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=gu(n);return zu(vd,n).position===`popper`?(0,Q.jsx)(zi,{...i,...r,ref:t}):null});yd.displayName=vd;var bd=`SelectBubbleInput`,xd=Z.forwardRef(({__scopeSelect:e,...t},n)=>{let r=vu(bd,e),{value:i,onValueChange:a,required:o,disabled:s,name:c,autoComplete:l,form:u}=r,{nativeOptions:d,nativeSelectKey:f}=r,p=Z.useRef(null),m=D(n,p),h=i??``,g=xa(h),_=Array.from(d).some(e=>(e.props.value??``)===``);return Z.useEffect(()=>{let e=p.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(g!==h&&n){let t=new Event(`change`,{bubbles:!0});n.call(e,h),e.dispatchEvent(t)}},[g,h]),(0,Q.jsxs)(fi.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:c,autoComplete:l,disabled:s,form:u,onChange:e=>a(e.target.value),...t,style:{...Bl,...t.style},ref:m,defaultValue:h,children:[Cd(i)&&!_?(0,Q.jsx)(`option`,{value:``}):null,Array.from(d)]},f)});xd.displayName=bd;function Sd(e){return typeof e==`function`}function Cd(e){return e===``||e===void 0}function wd(e){let t=li(e),n=Z.useRef(``),r=Z.useRef(0),i=Z.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=Z.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return Z.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function Td(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Ed(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function Ed(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Dd=`Tabs`,[Od,kd]=hi(Dd,[Oi]),Ad=Oi(),[jd,Md]=Od(Dd),Nd=Z.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=xi(s),[d,f]=ui({prop:r,onChange:i,defaultProp:a??``,caller:Dd});return(0,Q.jsx)(jd,{scope:n,baseId:mi(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,Q.jsx)(fi.div,{dir:u,"data-orientation":o,...l,ref:t})})});Nd.displayName=Dd;var Pd=`TabsList`,Fd=Z.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=Md(Pd,n),o=Ad(n);return(0,Q.jsx)(ki,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,Q.jsx)(fi.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});Fd.displayName=Pd;var Id=`TabsTrigger`,Ld=Z.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=Md(Id,n),s=Ad(n),c=Bd(o.baseId,r),l=Vd(o.baseId,r),u=r===o.value;return(0,Q.jsx)(Mi,{asChild:!0,...s,focusable:!i,active:u,children:(0,Q.jsx)(fi.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:q(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:q(e.onKeyDown,e=>{i||e.target!==e.currentTarget||[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:q(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})});Ld.displayName=Id;var Rd=`TabsContent`,zd=Z.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=Md(Rd,n),c=Bd(s.baseId,r),l=Vd(s.baseId,r),u=r===s.value,d=Z.useRef(u);return Z.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,Q.jsx)(bi,{present:i||u,children:({present:n})=>(0,Q.jsx)(fi.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})});zd.displayName=Rd;function Bd(e,t){return`${e}-trigger-${t}`}function Vd(e,t){return`${e}-content-${t}`}var Hd=Nd,Ud=Fd,Wd=Ld,Gd=zd,[Kd,qd]=hi(`Tooltip`,[Vi]),Jd=Vi(),Yd=`TooltipProvider`,Xd=700,Zd=`tooltip.open`,[Qd,$d]=Kd(Yd),ef=e=>{let{__scopeTooltip:t,delayDuration:n=Xd,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=Z.useRef(!0),s=Z.useRef(!1),c=Z.useRef(0);return Z.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,Q.jsx)(Qd,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:Z.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:Z.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:Z.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};ef.displayName=Yd;var tf=`Tooltip`,[nf,rf]=Kd(tf),af=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=$d(tf,e.__scopeTooltip),l=Jd(t),[u,d]=Z.useState(null),f=mi(),p=Z.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=Z.useRef(!1),[_,v]=ui({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(Zd))):c.onClose(),a?.(e)},caller:tf}),y=Z.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=Z.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=Z.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=Z.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return Z.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,Q.jsx)(wi,{...l,children:(0,Q.jsx)(nf,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:Z.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:Z.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};af.displayName=tf;var of=`TooltipTrigger`,sf=Z.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=rf(of,n),a=$d(of,n),o=Jd(n),s=D(t,Z.useRef(null),i.onTriggerChange),c=Z.useRef(!1),l=Z.useRef(!1),u=Z.useCallback(()=>c.current=!1,[]);return Z.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,Q.jsx)(Si,{asChild:!0,...o,children:(0,Q.jsx)(fi.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:q(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:q(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:q(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:q(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:q(e.onBlur,i.onClose),onClick:q(e.onClick,i.onClose)})})});sf.displayName=of;var cf=`TooltipPortal`,[lf,uf]=Kd(cf,{forceMount:void 0}),df=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=rf(cf,t);return(0,Q.jsx)(lf,{scope:t,forceMount:n,children:(0,Q.jsx)(bi,{present:n||a.open,children:(0,Q.jsx)(pi,{asChild:!0,container:i,children:r})})})};df.displayName=cf;var ff=`TooltipContent`,pf=Z.forwardRef((e,t)=>{let n=uf(ff,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=rf(ff,e.__scopeTooltip);return(0,Q.jsx)(bi,{present:r||o.open,children:o.disableHoverableContent?(0,Q.jsx)(vf,{side:i,...a,ref:t}):(0,Q.jsx)(mf,{side:i,...a,ref:t})})}),mf=Z.forwardRef((e,t)=>{let n=rf(ff,e.__scopeTooltip),r=$d(ff,e.__scopeTooltip),i=Z.useRef(null),a=D(t,i),[o,s]=Z.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=Z.useCallback(()=>{s(null),d(!1)},[d]),p=Z.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=Sf(r,xf(r,n.getBoundingClientRect())),a=Cf(t.getBoundingClientRect()),o=Tf([...i,...a]);s(o),d(!0)},[d]);return Z.useEffect(()=>()=>f(),[f]),Z.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),Z.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!wf(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,Q.jsx)(vf,{...e,ref:a})}),[hf,gf]=Kd(tf,{isInside:!1}),_f=p(`TooltipContent`),vf=Z.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=rf(ff,n),l=Jd(n),{onClose:u}=c;return Z.useEffect(()=>(document.addEventListener(Zd,u),()=>document.removeEventListener(Zd,u)),[u]),Z.useEffect(()=>{if(c.trigger){let e=e=>{e.target instanceof Node&&e.target.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,Q.jsx)(_i,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,Q.jsxs)(Hi,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,Q.jsx)(_f,{children:r}),(0,Q.jsx)(hf,{scope:n,isInside:!0,children:(0,Q.jsx)(Ul,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});pf.displayName=ff;var yf=`TooltipArrow`,bf=Z.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Jd(n);return gf(yf,n).isInside?null:(0,Q.jsx)(zi,{...i,...r,ref:t})});bf.displayName=yf;function xf(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function Sf(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function Cf(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function wf(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function Tf(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),Ef(t)}function Ef(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Df=ef,Of=af,kf=sf,Af=df,jf=pf,Mf=bf,Nf=h(`inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 [&>svg]:pointer-events-none [&>svg]:size-3`,{variants:{variant:{default:`bg-accent-strong text-accent-strong-foreground [a&]:hover:bg-accent-strong/90`,secondary:`bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90`,destructive:`bg-destructive text-destructive-foreground focus-visible:ring-destructive/20 [a&]:hover:bg-destructive/90`,outline:`border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,ghost:`[a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,link:`text-link-foreground underline-offset-4 [a&]:hover:underline`}},defaultVariants:{variant:`default`}});function Pf({className:e,variant:t=`default`,asChild:n=!1,...r}){return(0,Q.jsx)(n?E:`span`,{"data-slot":`badge`,"data-variant":t,className:k(Nf({variant:t}),e),...r})}function Ff({...e}){return(0,Q.jsx)(Cu,{"data-slot":`select`,...e})}function If({...e}){return(0,Q.jsx)(Du,{"data-slot":`select-value`,...e})}function Lf({className:e,size:t=`default`,children:n,...r}){return(0,Q.jsxs)(Tu,{"data-slot":`select-trigger`,"data-size":t,className:k(`flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-[var(--task-brand-bg)] px-3 py-2 text-sm whitespace-nowrap shadow-none transition-[color,box-shadow] outline-hidden focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-11 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 pointer-hover:bg-muted [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,Q.jsx)(ku,{asChild:!0,children:(0,Q.jsx)(So,{className:`size-4 opacity-50`})})]})}function Rf({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,Q.jsx)(Nu,{children:(0,Q.jsxs)(Fu,{"data-slot":`select-content`,className:k(`relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md motion-safe:data-[side=bottom]:slide-in-from-top-2 motion-safe:data-[side=left]:slide-in-from-right-2 motion-safe:data-[side=right]:slide-in-from-left-2 motion-safe:data-[side=top]:slide-in-from-bottom-2 motion-safe:data-[state=closed]:animate-out data-[state=closed]:fade-out-0 motion-safe:data-[state=closed]:zoom-out-95 motion-safe:data-[state=open]:animate-in data-[state=open]:fade-in-0 motion-safe:data-[state=open]:zoom-in-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...i,children:[(0,Q.jsx)(Bf,{}),(0,Q.jsx)(Xu,{className:k(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,Q.jsx)(Vf,{})]})})}function zf({className:e,children:t,...n}){return(0,Q.jsxs)(od,{"data-slot":`select-item`,className:k(`relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pe-8 ps-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,Q.jsx)(`span`,{"data-slot":`select-item-indicator`,className:`absolute end-2 flex size-3.5 items-center justify-center`,children:(0,Q.jsx)(ud,{children:(0,Q.jsx)(co,{className:`size-4`})})}),(0,Q.jsx)(cd,{children:t})]})}function Bf({className:e,...t}){return(0,Q.jsx)(fd,{"data-slot":`select-scroll-up-button`,className:k(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,Q.jsx)(to,{className:`size-4`})})}function Vf({className:e,...t}){return(0,Q.jsx)(md,{"data-slot":`select-scroll-down-button`,className:k(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,Q.jsx)(So,{className:`size-4`})})}function Hf({className:e,type:t,...n}){return(0,Q.jsx)(`input`,{type:t,"data-slot":`input`,className:k(`h-11 w-full min-w-0 rounded-md border border-control-border bg-[var(--task-brand-bg)] px-3 py-1 text-base shadow-none transition-[color,box-shadow] outline-hidden selection:bg-accent-strong selection:text-accent-strong-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-soft-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,`aria-invalid:border-destructive aria-invalid:ring-destructive/20`,e),...n})}function Uf(e){let t=/-pr(\d+)\./.exec(e);return t?Number(t[1]):null}function Wf(e,t){return!t||[e.branch,e.task?.title,e.task?.id,e.commit?.subject,e.worktree,e.pr?`#${e.pr}`:``].filter(Boolean).some(e=>e.toLowerCase().includes(t))}function Gf(e,t,n){return!e.version&&!n?!1:!t||[`#${e.number}`,String(e.number),e.title,e.branch,e.author??``].some(e=>e.toLowerCase().includes(t))}function Kf(e,t){return e.pull&&!e.pull.installed?`Install & restart`:e.needsBuild?`${e.checkout.built?`Rebuild`:`Build`} & ${e.checkout.id===t?`restart`:`switch`}`:`Switch & restart`}function qf(e,t){return e.checkout?e.needsBuild?`${e.checkout.built?`Needs rebuild`:`Not built yet`} — runs npm run build in ${e.checkout.worktree} first (about a minute).`:e.checkout.worktree:e.pull?`Installs ${e.pull.version} from npm.`:t===`worktrees`?`Linked, not copied: a worktree with uncommitted changes, a missing build, or a build older than its last commit is built before the switch.`:`Preview builds CI publishes for green same-repo pull requests.`}function Jf(e,t,n,r){let i=e===`worktrees`?t.find(e=>e.id===r):void 0;return{checkout:i,pull:e===`pulls`?n?.items.find(e=>e.version&&e.version===r):void 0,needsBuild:!!i&&(!i.built||i.stale)}}function Yf(e,{chosenTab:t,needle:n,picked:r,showUnbuilt:i}){let a=(0,Z.useMemo)(()=>e?.checkouts??[],[e]),o=e?.pulls,s=(0,Z.useMemo)(()=>o?.items??[],[o]),c=!e||a.length>0,l=c?t:`pulls`,u=(0,Z.useMemo)(()=>a.filter(e=>Wf(e,n)),[a,n]),d=(0,Z.useMemo)(()=>s.filter(e=>Gf(e,n,i)),[s,n,i]),f=s.filter(e=>!e.version).length;return{pulls:o,tab:l,tabs:[...c?[{value:`worktrees`,label:`Worktrees`,count:a.length}]:[],{value:`pulls`,label:`Pull requests`,count:s.length-f}],shownCheckouts:u,shownPulls:d,unbuilt:f,pick:Jf(l,a,o,r)}}function Xf({data:e,onApply:t,applying:n}){let r=Fl(),i=Il(),[a,o]=(0,Z.useState)(`worktrees`),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(!1),p=s.trim().toLowerCase(),m=Yf(r.data,{chosenTab:a,needle:p,picked:l,showUnbuilt:d}),{tab:h,pick:g}=m,_=e.installed.find(e=>e.active)?.id;return(0,Q.jsxs)(`div`,{"data-slot":`self-update-development`,className:`flex min-w-0 flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(Qf,{tabs:m.tabs,tab:h,showCounts:!!r.data,onTab:e=>{o(e),u(null)}}),(0,Q.jsx)(O,{variant:`ghost`,size:`sm`,onClick:()=>i.mutate(),disabled:i.isPending||r.isFetching,children:i.isPending?`Refreshing…`:`Refresh`})]}),(0,Q.jsx)(Hf,{"aria-label":`Filter`,value:s,onChange:e=>c(e.target.value),placeholder:h===`worktrees`?`Filter by task, branch, commit or #PR`:`Filter by #number, title, branch or author`,className:`h-8 text-[13px]`}),(0,Q.jsx)(`div`,{className:`max-h-72 min-h-24 overflow-y-auto rounded-md border border-border`,children:r.isPending?(0,Q.jsx)(`p`,{className:`px-3 py-3 text-[12.5px] text-muted-foreground`,children:`Looking for worktrees and pull requests…`}):r.error?(0,Q.jsx)(`p`,{className:`px-3 py-3 text-[12.5px] text-danger`,children:r.error.message}):h===`worktrees`?(0,Q.jsx)($f,{checkouts:m.shownCheckouts,activeId:_,picked:l,onPick:u}):(0,Q.jsx)(tp,{pulls:m.pulls,shown:m.shownPulls,filtered:!!p,unbuilt:m.unbuilt,showUnbuilt:d,onToggleUnbuilt:()=>f(e=>!e),activeId:_,picked:l,onPick:u})}),(0,Q.jsx)(Zf,{data:e,pick:g,tab:h,activeId:_,applying:n,onApply:t})]})}function Zf({data:e,pick:t,tab:n,activeId:r,applying:i,onApply:a}){let o=e.job?.status===`running`||e.job?.status===`restarting`,s=t.checkout?.id??t.pull?.version??null,c=!!s&&s===r&&!t.needsBuild;return(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`min-w-0 truncate text-[11.5px] text-muted-foreground`,title:t.checkout?.worktree,children:qf(t,n)}),(0,Q.jsx)(O,{size:`sm`,variant:`contrast`,onClick:()=>s&&a(s),disabled:!s||c||!e.canSelfUpdate||i||o,children:Kf(t,r)})]})}function Qf({tabs:e,tab:t,showCounts:n,onTab:r}){return(0,Q.jsx)(`div`,{role:`tablist`,"aria-label":`Development builds`,className:`flex rounded-md border border-border bg-muted/40 p-0.5`,children:e.map(e=>(0,Q.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.value,onClick:()=>r(e.value),className:k(`rounded-[5px] px-3 py-1 text-[12.5px] font-semibold transition-colors`,t===e.value?`bg-card text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`),children:[e.label,n?(0,Q.jsx)(`span`,{className:`ml-1.5 font-normal text-muted-foreground`,children:e.count}):null]},e.value))})}function $f({checkouts:e,activeId:t,picked:n,onPick:r}){return(0,Q.jsxs)(Q.Fragment,{children:[e.length===0?(0,Q.jsx)(`p`,{className:`px-3 py-3 text-[12.5px] text-muted-foreground`,children:`Nothing matches.`}):null,(0,Q.jsx)(`div`,{role:`listbox`,"aria-label":`Worktrees`,children:e.map(e=>(0,Q.jsx)(rp,{checkout:e,active:e.id===t,selected:n===e.id,onSelect:()=>r(e.id)},e.worktree))})]})}function ep(e,t){return e.items.length===0?`No open pull requests on ${e.repo}.`:t?`Nothing matches.`:`No open pull request has a preview build.`}function tp({pulls:e,shown:t,filtered:n,unbuilt:r,showUnbuilt:i,onToggleUnbuilt:a,activeId:o,picked:s,onPick:c}){return(0,Q.jsxs)(Q.Fragment,{children:[e&&!e.available?(0,Q.jsx)(`p`,{className:`px-3 py-2 text-[12px] text-muted-foreground`,children:e.reason}):null,e?.available&&t.length===0?(0,Q.jsx)(`p`,{className:`px-3 py-3 text-[12.5px] text-muted-foreground`,children:ep(e,n)}):null,(0,Q.jsx)(`div`,{role:`listbox`,"aria-label":`Pull requests`,children:t.map(e=>(0,Q.jsx)(ip,{pull:e,active:!!e.version&&e.version===o,selected:!!e.version&&s===e.version,onSelect:()=>e.version&&c(e.version)},e.number))}),r>0?(0,Q.jsx)(`button`,{type:`button`,onClick:a,className:`w-full border-t border-border px-3 py-2 text-left text-[12px] text-muted-foreground hover:text-foreground`,children:i?`Hide the ${r} without a preview build`:`${r} more without a preview build (forks, CI not green yet) — show`}):null]})}function np({selected:e,disabled:t,onSelect:n,title:r,children:i}){return(0,Q.jsx)(`div`,{role:`option`,"aria-selected":e,"aria-disabled":t,tabIndex:t?-1:0,title:r,onClick:()=>!t&&n(),onKeyDown:e=>{!t&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n())},className:k(`flex min-w-0 flex-col gap-0.5 border-b border-border px-3 py-2 last:border-b-0 outline-none`,t?`cursor-not-allowed opacity-55`:`cursor-pointer hover:bg-muted/50 focus-visible:bg-muted/60`,e&&`bg-accent-strong/10 hover:bg-accent-strong/10`),children:i})}function rp({checkout:e,active:t,selected:n,onSelect:r}){let i=e.task?.title??e.commit?.subject??e.branch;return(0,Q.jsxs)(np,{selected:n,disabled:!e.id,onSelect:r,title:e.worktree,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] font-medium`,children:i}),e.pr?(0,Q.jsxs)(Pf,{variant:`outline`,children:[`#`,e.pr]}):null,t?(0,Q.jsx)(Pf,{variant:`secondary`,children:`current`}):null,e.built?e.stale?(0,Q.jsx)(Pf,{variant:`outline`,children:`needs rebuild`}):null:(0,Q.jsx)(Pf,{variant:`outline`,children:`not built`})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[11.5px] text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`shrink-0 font-mono`,children:e.branch}),e.task?(0,Q.jsxs)(`span`,{className:`shrink-0`,children:[`· `,e.task.status]}):null,e.commit?(0,Q.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`· `,e.commit.sha,` `,e.task?e.commit.subject:``,` · `,Io(e.commit.at),` ago`]}):null,e.builtAt?(0,Q.jsxs)(`span`,{className:`shrink-0`,children:[`· built `,Io(e.builtAt),` ago`]}):null]})]})}function ip({pull:e,active:t,selected:n,onSelect:r}){return(0,Q.jsxs)(np,{selected:n,disabled:!e.version,onSelect:r,title:e.url,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsxs)(`span`,{className:`shrink-0 text-[13px] text-muted-foreground`,children:[`#`,e.number]}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] font-medium`,children:e.title}),e.draft?(0,Q.jsx)(Pf,{variant:`outline`,children:`draft`}):null,t?(0,Q.jsx)(Pf,{variant:`secondary`,children:`current`}):e.version?e.installed?(0,Q.jsx)(Pf,{variant:`outline`,children:`installed`}):null:(0,Q.jsx)(Pf,{variant:`outline`,children:`no build`})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[11.5px] text-muted-foreground`,children:[e.author?(0,Q.jsx)(`span`,{className:`shrink-0`,children:e.author}):null,(0,Q.jsxs)(`span`,{className:`min-w-0 truncate font-mono`,children:[`· `,e.branch]}),(0,Q.jsxs)(`span`,{className:`shrink-0`,children:[`· updated `,Io(e.updatedAt),` ago`]}),e.version?(0,Q.jsxs)(`span`,{className:`shrink-0`,children:[`· build `,e.publishedAt?`${Io(e.publishedAt)} ago`:e.version]}):null]})]})}function ap({open:e,onOpenChange:t,autoApply:n}){let r=Pl(e),i=Ll(),a=Rl(),o=zl(),[s,c]=(0,Z.useState)(``),l=r.data,u=(0,Z.useRef)(null),d=(0,Z.useRef)(!1);return(0,Z.useEffect)(()=>{!n||d.current||!l||!l.canSelfUpdate||l.job||(d.current=!0,!(l.activeRuns>0)&&o.mutate(n))},[n,l,o]),(0,Q.jsx)(jo,{open:e,onOpenChange:e=>{!e&&(o.isPending||l?.job?.status===`running`||l?.job?.status===`restarting`)||t(e)},children:(0,Q.jsxs)(Ao,{"data-slot":`self-update-dialog`,className:`sm:max-w-xl`,ref:u,onOpenAutoFocus:e=>{e.preventDefault(),u.current?.focus()},children:[(0,Q.jsxs)(Po,{children:[(0,Q.jsxs)(ko,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`span`,{children:[`cezar `,l?`v${l.version}`:``]}),(0,Q.jsx)(_p,{data:l})]}),(0,Q.jsx)(Oo,{className:`sr-only`,children:`Update cezar, pick a release channel or switch versions.`})]}),l?(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-5`,children:[(0,Q.jsx)(cp,{data:l,busy:a.isPending,onChange:e=>{c(``),a.mutate(e)}}),(0,Q.jsx)(up,{data:l,checking:i.isPending,onCheck:()=>i.mutate(),onApply:e=>o.mutate(e),applying:o.isPending}),l.channel===`development`?(0,Q.jsx)(Xf,{data:l,onApply:e=>o.mutate(e),applying:o.isPending}):(0,Q.jsx)(gp,{data:l,picked:s,onPick:c,onApply:e=>o.mutate(e),applying:o.isPending}),l.canSelfUpdate?null:(0,Q.jsx)(vp,{data:l}),l.activeRuns>0&&l.canSelfUpdate?(0,Q.jsxs)(`p`,{className:`rounded-md border border-pending/50 bg-pending/10 px-3 py-2 text-[12.5px] text-foreground`,children:[l.activeRuns,` task`,l.activeRuns===1?` is`:`s are`,` running. A restart interrupts them; cezar re-queues or resumes them on the way back up.`]}):null,a.error?(0,Q.jsxs)(`p`,{className:`text-[12.5px] text-danger`,children:[`Could not switch the channel: `,a.error.message,a.variables===`development`?` The running cezar server predates the Development channel — restart cezar to load it.`:null]}):null,o.error?(0,Q.jsx)(`p`,{className:`text-[12.5px] text-danger`,children:o.error.message}):null,l.job?(0,Q.jsx)(yp,{data:l}):null]}):r.error?(0,Q.jsx)(`p`,{className:`text-[13px] text-danger`,children:r.error.message}):null]})})}var op=[{value:`stable`,label:`Stable`},{value:`nightly`,label:`Nightly`},{value:`development`,label:`Development`}],sp={stable:`Tagged releases.`,nightly:`A fresh build of main every night.`,development:`A cezar worktree or an open pull request. Never updates on its own.`};function cp({data:e,busy:t,onChange:n}){return(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`text-[13px] font-semibold`,children:`Release channel`}),(0,Q.jsx)(`div`,{className:`text-[12px] text-muted-foreground`,children:sp[e.channel]})]}),(0,Q.jsx)(`div`,{role:`radiogroup`,"aria-label":`Release channel`,"data-slot":`channel-toggle`,className:`flex shrink-0 rounded-md border border-border bg-muted/40 p-0.5`,children:op.map(r=>{let i=e.channel===r.value;return(0,Q.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":i,disabled:t,onClick:()=>!i&&n(r.value),className:k(`rounded-[5px] px-3 py-1 text-[12.5px] font-semibold transition-colors`,i?`bg-card text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`),children:r.label},r.value)})})]})}var lp=e=>e.job?.status===`running`||e.job?.status===`restarting`;function up(e){let{data:t}=e,n=t.installed.find(e=>e.active),r=n?.source===`registry`?Uf(n.version):null,i=n&&(n.source===`link`||n.source===`local`||r!==null)?n:null;return i||t.channel===`development`?(0,Q.jsx)(dp,{...e,dev:i,pr:r}):(0,Q.jsx)(mp,{...e})}function dp({data:e,checking:t,onCheck:n,onApply:r,applying:i,dev:a,pr:o}){let s=lp(e),c=e.channel===`development`?null:e.latest[e.channel],l=c!==null&&e.installed.some(e=>e.source===`registry`&&e.id===c);return(0,Q.jsxs)(`div`,{"data-slot":`self-update-latest`,className:`flex flex-col gap-2 rounded-md border border-border bg-card px-3 py-2.5`,children:[(0,Q.jsx)(`div`,{className:`min-w-0 text-[13px] break-words`,children:(0,Q.jsx)(fp,{data:e,dev:a,pr:o})}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-2`,children:[(0,Q.jsx)(`div`,{className:`min-w-0 text-[11.5px] break-words text-muted-foreground`,children:(0,Q.jsx)(pp,{data:e,release:c})}),e.channel===`development`?null:(0,Q.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,Q.jsx)(O,{variant:`ghost`,size:`sm`,onClick:n,disabled:t||s,children:t?`Checking…`:`Check again`}),c?(0,Q.jsx)(O,{size:`sm`,"aria-label":l?`Back to v${c}`:`Install v${c} & restart`,onClick:()=>r(c),disabled:!e.canSelfUpdate||i||s,children:l?`Switch back`:`Install & restart`}):null]})]})]})}function fp({data:e,dev:t,pr:n}){return t?.source===`link`?(0,Q.jsxs)(Q.Fragment,{children:[`Running worktree `,(0,Q.jsx)(`span`,{className:`font-mono text-[12.5px] font-semibold`,children:t.branch??t.id}),`, not a release.`]}):t?.source===`local`?(0,Q.jsx)(Q.Fragment,{children:`Running a local build, not a release.`}):n===null?(0,Q.jsxs)(Q.Fragment,{children:[`Running `,(0,Q.jsxs)(`span`,{className:`font-semibold`,children:[`v`,e.version]}),`. Pick a worktree or a pull request below.`]}):(0,Q.jsxs)(Q.Fragment,{children:[`Running the preview build of `,(0,Q.jsxs)(`span`,{className:`font-semibold`,children:[`PR #`,n]}),`, not a release.`]})}function pp({data:e,release:t}){return e.channel===`development`?(0,Q.jsx)(Q.Fragment,{children:`Switch the channel back to Stable or Nightly to follow releases again.`}):e.checkedAt?(0,Q.jsxs)(Q.Fragment,{children:[t?(0,Q.jsxs)(Q.Fragment,{children:[`Newest `,e.channel,`: `,(0,Q.jsxs)(`span`,{className:`font-mono text-foreground`,children:[`v`,t]}),` ·`,` `]}):null,`checked `,new Date(e.checkedAt).toLocaleTimeString()]}):(0,Q.jsx)(Q.Fragment,{children:`The npm registry has not answered yet.`})}function mp({data:e,checking:t,onCheck:n,onApply:r,applying:i}){let a=lp(e),o=e.updateAvailable;return(0,Q.jsxs)(`div`,{"data-slot":`self-update-latest`,className:k(`flex items-center justify-between gap-3 rounded-md border px-3 py-2.5`,o?`border-accent-strong/40 bg-accent-strong/5`:`border-border bg-card`),children:[(0,Q.jsxs)(`div`,{className:`min-w-0 text-[13px]`,children:[(0,Q.jsx)(hp,{data:e,target:o}),e.checkedAt?(0,Q.jsxs)(`div`,{className:`text-[11.5px] text-muted-foreground`,children:[`checked `,new Date(e.checkedAt).toLocaleTimeString()]}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Q.jsx)(O,{variant:`ghost`,size:`sm`,onClick:n,disabled:t||a,children:t?`Checking…`:`Check again`}),o?(0,Q.jsx)(O,{size:`sm`,onClick:()=>r(o),disabled:!e.canSelfUpdate||i||a,children:`Update & restart`}):null]})]})}function hp({data:e,target:t}){return e.checkedAt?t?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`font-semibold`,children:[`v`,t]}),` is available on `,e.channel,`.`]}):(0,Q.jsxs)(Q.Fragment,{children:[`You are on the newest `,e.channel,` version`,e.channel===`nightly`&&e.latest.nightly?` (v${e.latest.nightly})`:``,`.`]}):(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`The npm registry has not answered yet.`})}function gp({data:e,picked:t,onPick:n,onApply:r,applying:i}){let a=e.job?.status===`running`||e.job?.status===`restarting`,o=(0,Z.useMemo)(()=>{let t=e.channel===`stable`?e.installed.filter(e=>e.source===`local`).map(e=>({value:e.id,label:`v${e.version} · local build`,installed:!0,active:e.active})):[],n=e.available.filter(t=>t.channel===e.channel).map(t=>({value:t.version,label:`v${t.version}${t.publishedAt?` · ${t.publishedAt.slice(0,10)}`:``}`,installed:t.installed,active:e.installed.some(e=>e.active&&e.id===t.version)}));return[...t,...n]},[e]),s=o.find(e=>e.value===t);return(0,Q.jsxs)(`div`,{"data-slot":`self-update-picker`,className:`flex min-w-0 flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`text-[13px] font-semibold`,children:[`Pick a version `,(0,Q.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`· `,e.channel]})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsxs)(Ff,{value:t,onValueChange:n,disabled:o.length===0||a,children:[(0,Q.jsx)(Lf,{size:`sm`,"aria-label":`Version`,className:`w-0 min-w-0 flex-1 text-[13px]`,children:(0,Q.jsx)(If,{placeholder:o.length===0?`No versions known`:`Choose a version to install`})}),(0,Q.jsx)(Rf,{className:`max-h-72`,children:o.map(e=>(0,Q.jsx)(zf,{value:e.value,children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e.label,e.active?(0,Q.jsx)(Pf,{variant:`secondary`,children:`current`}):e.installed?(0,Q.jsx)(Pf,{variant:`outline`,children:`installed`}):null]})},e.value))})]}),(0,Q.jsx)(O,{size:`sm`,variant:`contrast`,onClick:()=>s&&r(s.value),disabled:!s||s.active||!e.canSelfUpdate||i||a,children:s?.installed?`Switch & restart`:`Install & restart`})]}),(0,Q.jsx)(`p`,{className:`text-[11.5px] text-muted-foreground`,children:`Any version, older ones included. Installed versions stay on disk, so switching back is instant.`})]})}function _p({data:e}){let t=e?.installed.find(e=>e.active);if(t?.source===`local`)return(0,Q.jsx)(Pf,{variant:`outline`,children:`local build`});if(t?.source===`link`)return(0,Q.jsxs)(Pf,{variant:`outline`,children:[`worktree · `,t.branch??t.id]});let n=t?Uf(t.version):null;return n===null?null:(0,Q.jsxs)(Pf,{variant:`outline`,children:[`PR #`,n,` build`]})}function vp({data:e}){let t=e.installKind===`checkout`?`node packages/cezar/dist/index.js install`:e.installKind===`global-npm`?`cez install`:`npx @wjarka/cezarion install`;return(0,Q.jsxs)(`div`,{"data-slot":`self-update-install-hint`,className:`rounded-md border border-border bg-muted/40 px-3 py-2.5 text-[12.5px]`,children:[(0,Q.jsx)(`p`,{children:e.reason}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-muted-foreground`,children:`Run this once, then start cezar with the plain command:`}),(0,Q.jsx)(`pre`,{className:`mt-1.5 overflow-x-auto rounded bg-background px-2 py-1.5 font-mono text-[12px]`,children:t})]})}function yp({data:e}){let t=e.job,n=z(),r=(0,Z.useRef)(null),[i,a]=(0,Z.useState)(`waiting`);return(0,Z.useEffect)(()=>{r.current?.scrollTo({top:r.current.scrollHeight})},[t.log.length]),(0,Z.useEffect)(()=>{if(t.status!==`restarting`)return;let r=!1,i=Date.now(),o=()=>{a(`back`),n.removeQueries({queryKey:Nl.status}),window.setTimeout(()=>window.location.reload(),400)},s=async()=>{if(!r){try{if((await Ge()).version!==e.version)return o();let t=await Ol().catch(()=>null);if(t&&!t.job)return o()}catch{}if(Date.now()-i>9e4){a(`timeout`);return}window.setTimeout(s,1e3)}};return window.setTimeout(s,1500),()=>{r=!0}},[t.status,e.version,n]),(0,Q.jsxs)(`div`,{"data-slot":`self-update-job`,className:`flex min-w-0 flex-col gap-1.5`,children:[(0,Q.jsx)(`div`,{className:`flex items-center justify-between text-[12.5px]`,children:(0,Q.jsx)(`span`,{className:`font-semibold`,children:t.status===`running`?`Installing ${t.target}…`:t.status===`failed`?`Install of ${t.target} failed`:i===`back`?`Back — reloading`:i===`timeout`?`Restart took too long — reload the page by hand`:`Restarting into ${t.target}…`})}),(0,Q.jsx)(`pre`,{ref:r,className:`max-h-40 min-w-0 overflow-y-auto rounded-md border border-border bg-background px-2 py-1.5 font-mono text-[11px] leading-[1.5] break-all whitespace-pre-wrap text-muted-foreground`,children:t.log.join(`
3
+ `)}),t.error?(0,Q.jsx)(`p`,{className:`text-[12.5px] text-danger`,children:t.error}):null]})}function bp(){return typeof window<`u`&&`__CEZ_DESKTOP__`in window}function xp(){let[e,t]=(0,Z.useState)(!1);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{"data-slot":`desktop-titlebar`,"data-tauri-drag-region":!0,className:`fixed inset-x-0 top-0 z-50 flex h-7 items-center gap-4 border-b border-border bg-background pl-20 text-[11px]`,children:[(0,Q.jsx)(`span`,{"data-tauri-drag-region":!0,children:`Cezarion · Local`}),(0,Q.jsx)(`button`,{type:`button`,className:`rounded px-2 hover:bg-muted`,onClick:()=>t(!0),children:`Versions & updates`})]}),e?(0,Q.jsx)(ap,{open:e,onOpenChange:t}):null]})}var Sp=J(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),Cp=J(`archive-restore`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]),wp=J(`bookmark`,[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]),Tp=J(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),Ep=J(`boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),Dp=J(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),Op=J(`brush`,[[`path`,{d:`m11 10 3 3`,key:`fzmg1i`}],[`path`,{d:`M6.5 21A3.5 3.5 0 1 0 3 17.5a2.62 2.62 0 0 1-.708 1.792A1 1 0 0 0 3 21z`,key:`p4q2r7`}],[`path`,{d:`M9.969 17.031 21.378 5.624a1 1 0 0 0-3.002-3.002L6.967 14.031`,key:`wy6l02`}]]),kp=J(`check-check`,[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]),Ap=J(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),jp=J(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Mp=J(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Np=J(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Pp=J(`chevrons-left`,[[`path`,{d:`m11 17-5-5 5-5`,key:`13zhaf`}],[`path`,{d:`m18 17-5-5 5-5`,key:`h8a8et`}]]),Fp=J(`chevrons-right`,[[`path`,{d:`m6 17 5-5-5-5`,key:`xnjwq`}],[`path`,{d:`m13 17 5-5-5-5`,key:`17xmmf`}]]),Ip=J(`clock-3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6h4`,key:`135r8i`}]]),Lp=J(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Rp=J(`coins`,[[`path`,{d:`M13.744 17.736a6 6 0 1 1-7.48-7.48`,key:`bq4yh3`}],[`path`,{d:`M15 6h1v4`,key:`11y1tn`}],[`path`,{d:`m6.134 14.768.866-.5 2 3.464`,key:`17snzx`}],[`circle`,{cx:`16`,cy:`8`,r:`6`,key:`14bfc9`}]]),zp=J(`compass`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}]]),Bp=J(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Vp=J(`corner-left-up`,[[`path`,{d:`M14 9 9 4 4 9`,key:`1af5af`}],[`path`,{d:`M20 20h-7a4 4 0 0 1-4-4V4`,key:`1blwi3`}]]),Hp=J(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),Up=J(`diamond`,[[`path`,{d:`M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z`,key:`1f1r0c`}]]),Wp=J(`dollar-sign`,[[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`22`,key:`7eqyqh`}],[`path`,{d:`M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6`,key:`1b0p4s`}]]),Gp=J(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),Kp=J(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),qp=J(`feather`,[[`path`,{d:`M12.67 19a2 2 0 0 0 1.416-.588l6.154-6.172a6 6 0 0 0-8.49-8.49L5.586 9.914A2 2 0 0 0 5 11.328V18a1 1 0 0 0 1 1z`,key:`18jl4k`}],[`path`,{d:`M16 8 2 22`,key:`vp34q`}],[`path`,{d:`M17.5 15H9`,key:`1oz8nu`}]]),Jp=J(`file-cog`,[[`path`,{d:`M15 8a1 1 0 0 1-1-1V2a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8z`,key:`1ckgky`}],[`path`,{d:`M20 8v12a2 2 0 0 1-2 2h-4.182`,key:`1726p0`}],[`path`,{d:`m3.305 19.53.923-.382`,key:`ao1pio`}],[`path`,{d:`M4 10.592V4a2 2 0 0 1 2-2h8`,key:`1foop0`}],[`path`,{d:`m4.228 16.852-.924-.383`,key:`1fv9zy`}],[`path`,{d:`m5.852 15.228-.383-.923`,key:`1a9hc2`}],[`path`,{d:`m5.852 20.772-.383.924`,key:`1sh9ke`}],[`path`,{d:`m8.148 15.228.383-.923`,key:`4yu6lf`}],[`path`,{d:`m8.53 21.696-.382-.924`,key:`18b0s9`}],[`path`,{d:`m9.773 16.852.922-.383`,key:`ti6xop`}],[`path`,{d:`m9.773 19.148.922.383`,key:`rws47d`}],[`circle`,{cx:`7`,cy:`18`,r:`3`,key:`lvkj7j`}]]),Yp=J(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Xp=J(`folder-git-2`,[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),Zp=J(`folder-search`,[[`path`,{d:`M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1`,key:`1bw5m7`}],[`path`,{d:`m21 21-1.9-1.9`,key:`1g2n9r`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}]]),Qp=J(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),$p=J(`gem`,[[`path`,{d:`M10.5 3 8 9l4 13 4-13-2.5-6`,key:`b3dvk1`}],[`path`,{d:`M17 3a2 2 0 0 1 1.6.8l3 4a2 2 0 0 1 .013 2.382l-7.99 10.986a2 2 0 0 1-3.247 0l-7.99-10.986A2 2 0 0 1 2.4 7.8l2.998-3.997A2 2 0 0 1 7 3z`,key:`7w4byz`}],[`path`,{d:`M2 9h20`,key:`16fsjt`}]]),em=J(`git-pull-request-arrow`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M5 9v12`,key:`ih889a`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}]]),tm=J(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),nm=J(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),rm=J(`hammer`,[[`path`,{d:`m15 12-9.373 9.373a1 1 0 0 1-3.001-3L12 9`,key:`1hayfq`}],[`path`,{d:`m18 15 4-4`,key:`16gjal`}],[`path`,{d:`m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172v-.344a2 2 0 0 0-.586-1.414l-1.657-1.657A6 6 0 0 0 12.516 3H9l1.243 1.243A6 6 0 0 1 12 8.485V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5`,key:`15ts47`}]]),im=J(`hexagon`,[[`path`,{d:`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`,key:`yt0hxn`}]]),am=J(`id-card`,[[`path`,{d:`M16 10h2`,key:`8sgtl7`}],[`path`,{d:`M16 14h2`,key:`epxaof`}],[`path`,{d:`M6.17 15a3 3 0 0 1 5.66 0`,key:`n6f512`}],[`circle`,{cx:`9`,cy:`11`,r:`2`,key:`yxgjnd`}],[`rect`,{x:`2`,y:`5`,width:`20`,height:`14`,rx:`2`,key:`qneu4z`}]]),om=J(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),sm=J(`link`,[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]),cm=J(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),lm=J(`memory-stick`,[[`path`,{d:`M12 12v-2`,key:`fwoke6`}],[`path`,{d:`M12 18v-2`,key:`qj6yno`}],[`path`,{d:`M16 12v-2`,key:`heuere`}],[`path`,{d:`M16 18v-2`,key:`s1ct0w`}],[`path`,{d:`M2 11h1.5`,key:`15p63e`}],[`path`,{d:`M20 18v-2`,key:`12ehxp`}],[`path`,{d:`M20.5 11H22`,key:`khsy7a`}],[`path`,{d:`M4 18v-2`,key:`1c3oqr`}],[`path`,{d:`M8 12v-2`,key:`1mwtfd`}],[`path`,{d:`M8 18v-2`,key:`qcmpov`}],[`rect`,{x:`2`,y:`6`,width:`20`,height:`10`,rx:`2`,key:`1qcswk`}]]),um=J(`monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),dm=J(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),fm=J(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),pm=J(`panel-left-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]]),mm=J(`panel-left-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]]),hm=J(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),gm=J(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),_m=J(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),vm=J(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),ym=J(`rocket`,[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]]),bm=J(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),xm=J(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Sm=J(`shapes`,[[`path`,{d:`M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z`,key:`1bo67w`}],[`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1bkyp8`}],[`circle`,{cx:`17.5`,cy:`17.5`,r:`3.5`,key:`w3z12y`}]]),Cm=J(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),wm=J(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),Tm=J(`square-terminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),Em=J(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),Dm=J(`waves-horizontal`,[[`path`,{d:`M2 12q2.5 2 5 0t5 0 5 0 5 0`,key:`8ddzzs`}],[`path`,{d:`M2 19q2.5 2 5 0t5 0 5 0 5 0`,key:`1wj4st`}],[`path`,{d:`M2 5q2.5 2 5 0t5 0 5 0 5 0`,key:`69x50u`}]]),Om=J(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),km=J(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),Am=`cez-last-location`;function jm(){try{let e=localStorage.getItem(Am);return e===null?null:JSON.parse(e)}catch{return null}}function Mm(e){try{localStorage.setItem(Am,JSON.stringify(e))}catch{}}var Nm=new Set([`projectId`,`pathname`,`search`,`hash`]);function Pm(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e;if(Object.keys(t).some(e=>!Nm.has(e))||typeof t.projectId!=`string`||t.projectId.length<1||t.projectId.length>64||typeof t.pathname!=`string`||t.pathname.length<1||t.pathname.length>2048||!t.pathname.startsWith(`/p/`)||t.search!==void 0&&(typeof t.search!=`string`||t.search.length>4096||!t.search.startsWith(`?`))||t.hash!==void 0&&(typeof t.hash!=`string`||t.hash.length>2048||!t.hash.startsWith(`#`)))return null;try{if(fs(t.pathname)!==t.projectId)return null}catch{return null}return{projectId:t.projectId,pathname:t.pathname,...t.search===void 0?{}:{search:t.search},...t.hash===void 0?{}:{hash:t.hash}}}function Fm(e,t){let n=t.projects.find(t=>t.id===e);return n!==void 0&&n.status!==`missing`}function Im(e,t){if(t===void 0)return null;let n;try{n=fs(e.pathname)}catch{return null}return n===null||!Fm(n,t)?null:Pm({projectId:n,pathname:e.pathname,...e.search===``?{}:{search:e.search},...e.hash===``?{}:{hash:e.hash}})}function Lm(e,t,n){let r=Pm(e);return r===null||!(t===void 0?n!==void 0&&r.projectId===n:Fm(r.projectId,t))?null:`${r.pathname}${r.search??``}${r.hash??``}`}function Rm(e,t){let n=Pm(e);return n!==null&&n.projectId===t.projectId&&n.pathname===t.pathname&&(n.search??``)===(t.search??``)&&(n.hash??``)===(t.hash??``)}var zm=`cez-project-locations`;function Bm(){try{let e=localStorage.getItem(zm),t=e===null?null:JSON.parse(e);return typeof t==`object`&&t&&!Array.isArray(t)?t:{}}catch{return{}}}function Vm(e){let t=Bm()[e];return t===void 0?null:t}function Hm(e){try{localStorage.setItem(zm,JSON.stringify({...Bm(),[e.projectId]:e}))}catch{}}function Um(e,t,n){let r=Pm(t);return r===null||r.projectId!==e||n===void 0||!Fm(e,n)?null:`${r.pathname}${r.search??``}${r.hash??``}`}function Wm(){return(0,Q.jsxs)(`div`,{"data-route":`activity`,"aria-busy":`true`,className:`min-h-full w-full px-[18px] py-6 md:px-7`,children:[(0,Q.jsx)(`h1`,{className:`text-[18px] font-semibold`,children:`Activity`}),(0,Q.jsx)(`p`,{"data-slot":`activity-loading`,role:`status`,className:`mt-4 text-xs text-muted-foreground`,children:`Loading activity…`})]})}function Gm(){return(0,Q.jsx)(`div`,{"data-route":`github`,className:`flex min-h-full flex-col`,children:(0,Q.jsx)(X,{icon:(0,Q.jsx)(Bo,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:`Loading GitHub…`,subtitle:`Fetching open issues and pull requests.`})})}function Km(){return(0,Q.jsxs)(`div`,{"data-route":`inbox`,className:`task-flow-page flex min-h-full flex-col gap-5`,children:[(0,Q.jsx)(`h1`,{className:`text-[28px] font-medium`,children:`Inbox has been removed`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Agents no longer generate inbox suggestions. Create an ordinary task for work you want to run.`}),(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Existing entries stay in `,(0,Q.jsx)(`code`,{children:`.ai/cezar/todos.json`}),` in the original project. To export them, run this command from that project:`]}),(0,Q.jsx)(`pre`,{className:`overflow-x-auto rounded-xl border border-border bg-card p-4 text-sm`,children:(0,Q.jsx)(`code`,{children:`cp .ai/cezar/todos.json ./cezar-followups-export.json`})}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`If the file is absent, there is nothing to export. Task Notes and Continue still work.`}),(0,Q.jsx)(Y,{to:`/new`,className:w({className:`min-h-11 self-start`}),children:`New task`})]})}function qm(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||e.isContentEditable?!0:e.closest(`[contenteditable=""], [contenteditable="true"]`)!==null}function Jm(e){return e instanceof HTMLElement&&e.closest(`[cmdk-input]`)!==null}function Ym(e,t){return!(typeof e.key!=`string`||e.key.toLowerCase()!==t.toLowerCase()||!e.metaKey&&!e.ctrlKey||e.altKey||e.shiftKey||e.repeat||qm(e.target)&&!Jm(e.target))}function Xm(e,t){let n=Z.useRef(t);Z.useLayoutEffect(()=>{n.current=t}),Z.useEffect(()=>{let t=t=>{Ym(t,e)&&(t.preventDefault(),n.current(t))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e])}function Zm(e,t){return!(typeof e.key!=`string`||e.key.toLowerCase()!==t.toLowerCase()||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||e.repeat||qm(e.target))}function Qm(e,t=typeof navigator>`u`?``:navigator.platform){let n=e.toUpperCase();return/mac|iphone|ipad|ipod/i.test(t)?`⌘${n}`:`Ctrl+${n}`}function $m(e,t){let n=Z.useRef(t);Z.useLayoutEffect(()=>{n.current=t}),Z.useEffect(()=>{let t=t=>{Zm(t,e)&&n.current(t)};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e])}function eh(e){let[t,n]=Z.useState(()=>Date.now());return Z.useEffect(()=>{if(ai())return;let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}var th=`(hover: none) and (pointer: coarse)`;function nh(){return typeof globalThis.matchMedia==`function`&&globalThis.matchMedia(th).matches}function rh(e){return e.key!==`Enter`||e.shiftKey||e.altKey||e.repeat||e.isComposing?!1:e.metaKey||e.ctrlKey?!0:!nh()}function ih(e=typeof navigator>`u`?``:navigator.platform){return/mac|iphone|ipad|ipod/i.test(e)?`⌘↵`:`Ctrl+↵`}var ah={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,svg:`image/svg+xml`,bmp:`image/bmp`,avif:`image/avif`,md:`text/markdown`,markdown:`text/markdown`,txt:`text/plain`,log:`text/plain`,pdf:`application/pdf`};function oh(e){return vt(e.type)?e.type:ah[e.name.split(`.`).pop()?.toLowerCase()??``]??null}async function sh(e){let t=new Uint8Array(await e.arrayBuffer()),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));let r=btoa(n),i=oh(e)??`application/octet-stream`,a=tt(i);return{mediaType:i,data:r,...a?{preview:`data:${i};base64,${r}`}:{},name:e.name||(a?`pasted image`:`pasted.${lt(i)}`),isImage:a}}function ch(e,t){let n=[],r=[],i=t;for(let t of e){let e=t.name||`attachment`;if(oh(t)===null){r.push(`${e} is not a supported attachment (images, PDF and plain-text files such as TXT or MD)`);continue}if(t.size>5242880){r.push(`${e} is too large (max 5 MB)`);continue}if(i>=4){r.push(`${e} skipped — max 4 attachments per message`);continue}n.push(t),i+=1}return{accepted:n,rejected:r}}var lh=new Set([`/`,`@`]);function uh(e,t){for(let n=t-1;n>=0;--n){let r=e[n];if(/\s/.test(r))return null;if(lh.has(r))return n>0&&!/\s/.test(e[n-1])?null:{trigger:r,start:n,query:e.slice(n+1,t)}}return null}function dh(e,t,n,r){let i=`${t.trigger}${r} `;return{text:e.slice(0,t.start)+i+e.slice(n),caret:t.start+i.length}}function fh(){let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition}function ph(e,t){let n=e,r=``;for(let e=t.resultIndex;e<t.results.length;e+=1){let i=t.results[e],a=i[0]?.transcript??``;i.isFinal?n+=a:r+=a}return{finalText:n,interim:r}}function mh(e,t){switch(e){case`aborted`:return null;case`network`:case`service-not-allowed`:return{message:`Dictation couldn't reach this browser's speech service. Some Chromium builds, such as Helium, block it. Use your system dictation instead (macOS: press Fn/Globe twice), or open the cockpit in Chrome or Safari.`,retryable:e===`network`};case`not-allowed`:return{message:`Microphone access is blocked. Allow it in this site's browser settings, then try again.`,retryable:!0};case`audio-capture`:return{message:`No microphone was found. Connect one, then try again.`,retryable:!0};case`language-not-supported`:return{message:`This browser can't recognize speech in ${t}. Use your system dictation instead (macOS: press Fn/Globe twice).`,retryable:!1};case`no-speech`:return{message:`No speech was heard. Check the microphone, then try again.`,retryable:!0};default:return{message:`Dictation failed${e?` — ${e}`:``}`,retryable:!0}}}function hh(e){let[t,n]=Z.useState(null),r=Z.useRef(null),i=Z.useRef(``),a=Z.useRef(!1),o=Z.useRef(()=>{}),[s]=Z.useState(()=>fh()!==void 0),c=Z.useCallback(()=>{let e=r.current;r.current=null,i.current=``,n(null),e&&(e.onresult=null,e.onerror=null,e.onend=null,e.abort())},[]);Z.useEffect(()=>(a.current=!0,()=>{a.current=!1,c()}),[c]);let l=Z.useCallback(()=>o.current(),[]),u=Z.useCallback(()=>{if(!a.current||r.current)return;let t=fh();if(!t)return;let o;try{o=new t,o.lang=navigator.language||`en-US`,o.continuous=!0,o.interimResults=!0;let a=Date.now();o.onresult=e=>{let t=ph(i.current,e);i.current=t.finalText,n({transcript:t.finalText+t.interim,startedAt:a})},o.onerror=t=>{console.warn(`[dictation] recognition error`,t.error,t.message);let n=mh(t.error,o.lang);c(),n&&e(n.message,n.retryable?l:void 0)},o.start(),r.current=o,n({transcript:``,startedAt:a})}catch{e(`Dictation failed — the microphone could not be started`,l),c()}},[e,l,c]);return o.current=u,{supported:s,recording:t,start:u,cancel:Z.useCallback(()=>c(),[c]),finish:Z.useCallback(()=>{let e=r.current,a=(i.current+``).trim()===``?``:i.current,o=t?.transcript??a;return e&&(e.onresult=null,e.onerror=null,e.onend=null,e.stop()),r.current=null,i.current=``,n(null),o.trim()},[t])}}function gh(e,t){let n=Math.max(0,Math.floor((t-e)/1e3));return`${Math.floor(n/60)}:${String(n%60).padStart(2,`0`)}`}var _h=new Map,vh={KeyA:`Yes, approved.`,KeyC:`Continue.`};function yh({onSubmit:e,retainDraftUntilSuccess:t=!1,onStop:n,onFinish:r,finishing:i=!1,secondaryAction:a,stopOnEmpty:o=!1,stopping:s=!1,emptySubmitLabel:c,compactFeedback:l=!1,idleFeedback:u,pendingLabel:d=`Starting task…`,failureHint:f=`Could not confirm submission. Check Tasks before you retry. Your draft is kept.`,clearOnSuccess:p=!0,onPendingChange:m,value:h,onValueChange:g,autoFocus:_=!1,mobileCollapsible:v=!1,mobileDisclosureKey:y,footerStart:b,footerEnd:x,sessionControls:S,executionOptions:C,agentOptions:w,sendAriaLabel:T=`Send`,disabled:E=!1,disabledReason:D=`Session closed — Continue to reopen.`,allowEmptySubmit:A=!1,placeholder:j=`Reply — / for skills, @ for files…`,ariaLabel:M=`Reply to the agent`,autocompleteSkills:N=!0,quickReplies:P=!1,getMentionCandidates:F,voiceProposal:I=!1,ref:L}){let[ee,te]=(0,Z.useState)(``),ne=h??ee,R=(0,Z.useRef)(ne);R.current=ne;let re=(0,Z.useRef)(g);re.current=g;let ie=(0,Z.useCallback)(e=>{let t=typeof e==`function`?e(R.current):e;te(t),re.current?.(t)},[]),[ae,oe]=(0,Z.useState)([]),se=(0,Z.useRef)(ae);se.current=ae;let[ce,le]=(0,Z.useState)(!1),ue=s||ce,de=(0,Z.useRef)(ue);de.current=ue;let fe=ne.trim()!==``||ae.length>0,pe=!fe&&(n!==void 0&&o||ue),me=!fe&&!pe&&r!==void 0,he=pe||me||!fe&&c!==void 0,ge=!fe&&c?c:T,[_e,ve]=(0,Z.useState)(!1),ye=(0,Z.useRef)(!1),be=(0,Z.useRef)(0),xe=(0,Z.useRef)(!0);(0,Z.useEffect)(()=>(xe.current=!0,()=>{xe.current=!1}),[]);let[Se,Ce]=(0,Z.useState)(null),we=ue||t&&_e,Te=()=>de.current||t&&ye.current,[Ee,De]=(0,Z.useState)(null),[Oe,ke]=(0,Z.useState)(``),[Ae,je]=(0,Z.useState)(!1),Me=(0,Z.useRef)(null),Ne=(0,Z.useId)(),Pe=(0,Z.useId)(),Fe=(0,Z.useRef)(new Map),Ie=y===void 0?Fe.current:_h,Le=y??`default`,[,Re]=(0,Z.useReducer)(e=>e+1,0),ze=Ie.get(Le)??!1,Be=v&&!ze,Ve=(0,Z.useRef)(null),He=(0,Z.useRef)(null),Ue=(0,Z.useRef)(null),We=rr(N&&Ae),Ge=gn(),Ke=z(),qe=(0,Z.useRef)(E);qe.current=E;let Je=hh((e,t)=>K(e,{tone:`danger`,...t?{action:{label:`Try again`,onAction:()=>{!qe.current&&!Te()&&t()}}}:{}}));(0,Z.useEffect)(()=>{_&&Me.current?.focus()},[]);let Ye=(0,Z.useCallback)(()=>{let e=Me.current;if(!e||E||Te()){De(null);return}let t=uh(e.value,e.selectionStart??e.value.length);if(t?.trigger===`/`&&!N||t?.trigger===`@`&&F===void 0)return De(null);t?.trigger===`/`&&je(!0),De(t)},[N,E,F,t]),Xe=(0,Z.useMemo)(()=>Ee===null?[]:Ee.trigger===`/`?cc(We.data??[],Ee.query,Ge.data?.skillUsage).map(e=>({value:`${e.name} ${e.path}`,insert:e.name,label:e.name,description:e.description,emphasized:sc(e)})):(F?.()??[]).filter(e=>uc(e,Ee.query)).map(e=>({value:e,insert:e,label:e,emphasized:!1})),[F,We.data,Ee,Ge.data?.skillUsage]),Ze=Xe.some(e=>e.value===Oe)?Oe:Xe[0]?.value,Qe=Ee!==null;(0,Z.useLayoutEffect)(()=>{!Qe||!Ze||[...He.current?.querySelectorAll(`[data-slot="composer-menu-item"]`)??[]].find(e=>e.getAttribute(`data-value`)===Ze)?.scrollIntoView({block:`nearest`})},[Ze,Qe]);let $e=(0,Z.useCallback)(()=>De(null),[]),et=e=>{let t=Me.current;if(!t||Ee===null||Te())return;let n=t.selectionStart??t.value.length,r=dh(t.value,Ee,n,e.insert);Ee.trigger===`/`&&Ge.data!==void 0&&st({skillUsage:fc(Ge.data.skillUsage,e.insert)}).then(()=>Ke.invalidateQueries({queryKey:H.uiState})).catch(()=>{}),ie(r.text),Ue.current=r.caret,De(null),t.focus()};(0,Z.useLayoutEffect)(()=>{let e=Ue.current,t=Me.current;e!==null&&t&&(t.setSelectionRange(e,e),Ue.current=null)},[ne]),(0,Z.useLayoutEffect)(()=>{let e=Me.current;if(!e||typeof CSS<`u`&&CSS.supports(`field-sizing`,`content`))return;let t=()=>{e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,220)}px`};t();let n=e.clientWidth,r=typeof ResizeObserver>`u`?null:new ResizeObserver(()=>{e.clientWidth!==n&&(n=e.clientWidth,t())});r?.observe(e);let i=!1;return document.fonts?.ready.then(()=>{i||t()}),()=>{i=!0,r?.disconnect()}},[ne,ze]);let tt=(0,Z.useCallback)(e=>{if(E||Te())return;let n=be.current,r=ch(e,se.current.length);for(let e of r.rejected)K(e,{tone:`danger`});for(let e of r.accepted)sh(e).then(e=>{!xe.current||t&&ye.current&&!de.current||n!==be.current||oe(t=>t.length>=4?t:[...t,e])},()=>K(`${e.name||`Attachment`} could not be read — try attaching it again`,{tone:`danger`}))},[E,t]),nt=e=>{let t=[...e.clipboardData?.items??[]].filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>e!==null);t.length!==0&&(e.preventDefault(),tt(t))},rt=e=>{let t=[...e.dataTransfer?.files??[]];t.length!==0&&(e.preventDefault(),tt(t))},it=(0,Z.useCallback)((e,t)=>E||s||ye.current||e.trim()===``&&t.length===0&&!A,[E,s,A]),at=(0,Z.useCallback)(async(n,r,i)=>{let a=n.trim();if(!it(n,r)){ye.current=!0,t&&(be.current+=1),ve(!0),Ce(null),m?.(!0),De(null),i&&!t&&(ie(``),oe([]));try{await e(a,r.map(({mediaType:e,data:t})=>({mediaType:e,data:t}))),xe.current&&t&&p&&(R.current===n&&ie(``),se.current===r&&oe([]))}catch(e){if(!xe.current&&t)return;let a=e instanceof Error?e.message:String(e);t?Ce(a):(K(a,{tone:`danger`}),i&&(ie(e=>e===``?n:`${n}\n${e}`),oe(e=>[...r,...e].slice(0,4))))}finally{ye.current=!1,xe.current&&(m?.(!1),ve(!1))}}},[it,e,t,p,m,ie]),ot=(0,Z.useCallback)(()=>it(R.current,se.current)?!1:(at(R.current,se.current,!0),!0),[it,at]);(0,Z.useImperativeHandle)(L,()=>({insertAtCaret:e=>{if(Te())return;let t=Me.current,n=xs(R.current,t?.selectionStart??R.current.length,e);ie(n.text),Ue.current=n.caret,t?.focus()},getDraft:()=>R.current,setDraft:e=>Te()?!1:(ie(e),!0),clearVoiceDraft:e=>R.current===``?!0:ye.current||R.current!==e?!1:(ie(``),!0),submit:ot}),[ie,t,ot]);let ct=async()=>{if(!(!n||s||ye.current)){ye.current=!0,ve(!0),le(!0),Ce(null);try{await n()}catch(e){xe.current&&Ce(e instanceof Error?e.message:String(e))}finally{ye.current=!1,xe.current&&(ve(!1),le(!1))}}},lt=e=>{if(Qe){if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),Xe.length===0)return;let t=Xe.findIndex(e=>e.value===Ze),n=e.key===`ArrowDown`?1:-1,r=Xe[(t+n+Xe.length)%Xe.length];ke(r.value);return}if(e.key===`Escape`){e.preventDefault(),$e();return}if((e.key===`Enter`||e.key===`Tab`)&&!e.shiftKey){let t=Xe.find(e=>e.value===Ze);if(t){e.preventDefault(),et(t);return}$e()}}rh({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.preventDefault(),ot())};(0,Z.useEffect)(()=>{if(!P||E)return;let e=e=>{if(!e.altKey||e.metaKey||e.ctrlKey||e.repeat||qm(e.target))return;let t=vh[e.code];t!==void 0&&(e.preventDefault(),at(t,[],!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[E,P,at]);let ut=e=>{if(E||de.current||ye.current&&(e||t))return;let n=Je.finish();if(n===``)return;let r=ne.trim()===``?n:`${ne.replace(/\s*$/,``)} ${n}`;if(e){t&&ie(r),at(r,ae,!0);return}ie(r),Ue.current=r.length,Me.current?.focus()},dt=Je.recording,ft=Je.supported?(0,Q.jsxs)(O,{type:`button`,variant:`ghost`,size:`sm`,disabled:E||we,"aria-label":`Start dictation`,title:`Dictation`,className:k(`h-11 gap-1.5 px-2.5 text-xs font-medium text-muted-foreground md:h-8`,Be&&`hidden md:inline-flex`),onClick:()=>{Te()||Je.start()},children:[(0,Q.jsx)(Wa,{"aria-hidden":`true`,className:`size-3.5`}),C||S?null:`Dictation`]}):null,pt=me?(0,Q.jsxs)(O,{type:`button`,"data-slot":`composer-finish`,"aria-label":i?`Finishing…`:`Finish`,"aria-busy":i||void 0,title:`Close the session and mark this task done`,disabled:_e||ue||i,className:`h-11 w-auto gap-[7px] px-5 active:opacity-80`,onClick:()=>void r?.(),children:[(0,Q.jsx)(co,{"aria-hidden":`true`}),i?`Finishing…`:`Finish`]}):null,mt=n||ue?(0,Q.jsxs)(O,{type:`button`,variant:`outline`,size:`icon-sm`,"aria-label":ue?`Stopping…`:`Stop`,"aria-busy":ue||void 0,title:ue?`Waiting for execution to stop`:`Stop execution; keep existing work`,disabled:_e||ue,className:k(`h-11 min-w-11 active:opacity-80`,he?`w-auto px-3`:`w-11`),onClick:()=>void ct(),children:[(0,Q.jsx)(ao,{"aria-hidden":`true`,className:`size-3 fill-current`}),he?ue?`Stopping…`:`Stop`:null]}):null,ht=ue||_e||Se!==null||u!=null,gt=(0,Q.jsx)(Q.Fragment,{children:t||n||s?(0,Q.jsx)(`div`,{className:k(`overflow-y-auto text-xs leading-5 text-muted-foreground`,l&&!ht?`h-0`:`px-3 pbe-2 md:px-4`,l?ht&&`min-h-6`:`h-24 md:h-20`),children:(0,Q.jsx)(`div`,{id:`${Ne}-submission`,role:Se===null?`status`:`alert`,"aria-atomic":`true`,tabIndex:Se===null?void 0:0,className:`break-words`,children:ue?`Stopping execution. Your draft is kept.`:_e?d:Se===null?u??null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`font-medium text-foreground`,children:Se}),(0,Q.jsx)(`p`,{children:f})]})})}):null}),_t=(0,Q.jsxs)(`div`,{"data-slot":`composer-submit-row`,className:k(`ms-auto flex min-w-0 flex-wrap items-center justify-end gap-1 md:flex-nowrap`,C&&`new-task-submission`),children:[C||S?null:ft,x?(0,Q.jsx)(`div`,{id:Pe,"data-slot":`composer-footer-end`,className:k(`min-w-0 flex-wrap items-center gap-1.5 md:flex-nowrap`,C&&`me-auto`,v&&`max-md:[&_button]:min-h-11 max-md:[&_button]:min-w-11`,Be?`hidden md:flex`:`flex`),children:(0,Q.jsx)(`div`,{className:`contents`,inert:we||void 0,children:x})}):null,(0,Q.jsxs)(`div`,{className:`flex min-w-[100px] items-center justify-end gap-1`,"data-slot":`composer-actions`,children:[mt??a,pt,!pe&&!me?(0,Q.jsxs)(O,{type:`button`,size:`icon-sm`,"aria-label":ge,"aria-busy":_e&&!ue||void 0,disabled:E||_e||ue||!fe&&!A,className:k(C?`h-12 w-full gap-2 px-6`:S?`h-11 w-auto gap-2 px-5`:`size-11`,!fe&&c&&`w-auto px-3`,`active:opacity-80`),onClick:ot,children:[!S&&!fe&&c?(0,Q.jsx)(_m,{"aria-hidden":`true`}):null,C||S||!fe&&c?ge:null,S||fe||!c?(0,Q.jsx)(Ja,{"aria-hidden":`true`}):null]}):null]})]});return(0,Q.jsxs)(Da,{open:Qe,onOpenChange:e=>e?void 0:$e(),children:[(0,Q.jsx)(Ca,{asChild:!0,children:(0,Q.jsxs)(`div`,{ref:Ve,"data-slot":`composer`,"data-disabled":E||void 0,"data-voice-proposal":I||void 0,onDrop:rt,onDragOver:e=>e.preventDefault(),className:k(C&&`new-task-composer`,S&&`session-composer`,E&&`opacity-80`),children:[(0,Q.jsxs)(`div`,{"data-slot":`composer-editor`,className:k(`rounded-xl border border-[var(--composer-border)] bg-card shadow-none transition-[border-color,box-shadow] focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/15`,C&&`new-task-editor`),children:[ae.length>0?(0,Q.jsx)(`div`,{"data-slot":`composer-thumbs`,className:`flex flex-nowrap items-center gap-2 overflow-x-auto px-4 pbs-3 md:flex-wrap md:overflow-visible`,children:ae.map((e,t)=>(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`Remove ${e.name}`,title:we?`Attachment submitted`:`Click to remove`,disabled:we,className:k(`group relative shrink-0 overflow-hidden rounded-md border border-border`,e.isImage?`size-12`:`flex h-12 min-w-11 max-w-[200px] items-center gap-1.5 bg-muted/40 px-2.5 text-xs text-muted-foreground`),onClick:()=>{Te()||oe(e=>e.filter((e,n)=>n!==t))},children:[e.isImage?(0,Q.jsx)(`img`,{src:e.preview,alt:``,className:`size-full object-cover`}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Fa,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.name})]}),(0,Q.jsx)(`span`,{className:`absolute inset-0 hidden items-center justify-center bg-background/70 group-hover:flex group-focus-visible:flex`,children:(0,Q.jsx)(uo,{"aria-hidden":`true`,className:`size-4`})})]},`${e.name}-${t}`))}):null,(0,Q.jsx)(`label`,{htmlFor:Ne,className:C?`hidden px-5 pbs-5 text-xs text-muted-foreground md:block`:`sr-only`,children:C?`Task description`:M}),(0,Q.jsx)(`textarea`,{ref:Me,id:Ne,autoComplete:`off`,rows:1,value:ne,disabled:E,readOnly:we,"aria-busy":we||void 0,"aria-describedby":t?`${Ne}-submission`:void 0,"aria-label":M,placeholder:E?D:j,className:k(`block field-sizing-content min-h-11 w-full overflow-y-auto resize-none bg-transparent px-3 pbs-2.5 pbe-1 text-base leading-normal outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed md:min-h-[54px] md:px-4 md:pbs-3 md:text-sm`,Be?`max-h-11 md:max-h-[220px]`:`max-h-[220px]`,C&&`md:text-base`),onChange:e=>{Te()||(ie(e.target.value),Ye())},onKeyDown:lt,onSelect:Ye,onPaste:nt}),C?(0,Q.jsxs)(`p`,{"data-slot":`composer-skill-hint`,className:`flex items-center gap-2 px-5 pbs-3 pbe-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(mo,{"aria-hidden":`true`,className:`size-[15px] shrink-0`}),`Type / for a skill or workflow`]}):null,S&&dt?(0,Q.jsx)(`div`,{"data-slot":`session-controls`,inert:we||void 0,children:S}):null,dt?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(xh,{transcript:dt.transcript,startedAt:dt.startedAt,insertionDisabled:we,onCancel:Je.cancel,onInsert:()=>ut(!1),onInsertAndSend:()=>ut(!0)}),mt?(0,Q.jsx)(`div`,{className:`flex justify-end px-2 pbe-2`,children:mt}):null]}):(0,Q.jsxs)(`div`,{"data-slot":`composer-toolbar`,className:`flex flex-wrap items-center gap-1 gap-y-1 px-1.5 pbs-1 pbe-1.5 md:gap-y-1.5 md:px-2 md:pbs-1.5 md:pbe-2`,children:[S?(0,Q.jsx)(`div`,{"data-slot":`session-controls`,inert:we||void 0,children:S}):null,(0,Q.jsxs)(`div`,{"data-slot":`composer-footer-start`,className:k(`flex min-w-0 flex-wrap items-center gap-1`,C&&`w-full`),children:[(0,Q.jsx)(bh,{disabled:E||we,onFiles:tt}),v?(0,Q.jsx)(O,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`size-11 md:hidden`,"aria-label":ze?`Collapse composer`:`Expand composer`,"aria-expanded":ze,"aria-controls":x?`${Ne} ${Pe}`:Ne,onClick:()=>{Ie.set(Le,!ze),Re()},children:(0,Q.jsx)(So,{"aria-hidden":`true`,className:k(`transition-transform motion-reduce:transition-none`,!ze&&`rotate-180`)})}):null,(0,Q.jsx)(`div`,{className:`contents`,inert:we||void 0,children:b}),C||S?(0,Q.jsx)(`div`,{children:ft}):null]}),C?null:_t]}),C?null:gt]}),C?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{"data-slot":`composer-agent-options`,inert:we||void 0,children:w}),(0,Q.jsx)(`div`,{"data-slot":`composer-execution-panel`,inert:we||void 0,children:C}),_t,(0,Q.jsx)(`div`,{"data-slot":`composer-feedback`,children:gt})]}):null]})}),(0,Q.jsx)(Ta,{side:`top`,align:`start`,sideOffset:8,className:`w-80 max-w-[calc(100vw-2rem)] p-0`,onOpenAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>{Ve.current?.contains(e.target)&&e.preventDefault()},children:(0,Q.jsx)(Ds,{shouldFilter:!1,value:Ze??``,onValueChange:ke,children:(0,Q.jsx)(rc,{ref:He,"data-slot":`composer-menu`,"data-trigger":Ee?.trigger,className:`max-h-[min(16rem,var(--radix-popover-content-available-height))] p-1`,children:Xe.length===0?(0,Q.jsx)(`p`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:Ee?.trigger===`@`?`No files seen in this session yet — full file search arrives with the Files tab.`:We.isPending?`Loading skills…`:`No matching skills.`}):Xe.map(e=>(0,Q.jsxs)(As,{value:e.value,"data-slot":`composer-menu-item`,"data-emphasized":e.emphasized||void 0,onSelect:()=>et(e),children:[(0,Q.jsx)(`span`,{className:k(`shrink-0 truncate`,e.emphasized&&`font-semibold`,Ee?.trigger===`@`&&`font-mono text-xs`),children:e.label}),e.description?(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null]},e.value))})})})]})}function bh({disabled:e,onFiles:t}){let n=(0,Z.useRef)(null);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(O,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Attach files`,title:`Attach an image, PDF, TXT or MD file (or paste a screenshot)`,disabled:e,className:`size-11 text-muted-foreground`,onClick:()=>n.current?.click(),children:(0,Q.jsx)(Fa,{"aria-hidden":`true`,className:`size-[15px]`})}),(0,Q.jsx)(`input`,{ref:n,type:`file`,accept:`image/*,application/pdf,text/plain,text/markdown,.pdf,.txt,.md,.markdown,.log`,multiple:!0,className:`hidden`,"aria-hidden":`true`,tabIndex:-1,onChange:e=>{t([...e.target.files??[]]),e.target.value=``}})]})}function xh({transcript:e,startedAt:t,insertionDisabled:n,onCancel:r,onInsert:i,onInsertAndSend:a}){let o=eh(1e3);return(0,Q.jsxs)(`div`,{"data-slot":`dictation-overlay`,role:`status`,"aria-label":`Dictation in progress`,className:`flex items-center gap-2.5 rounded-b-xl border-bs border-border bg-muted/60 px-3 py-2`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 flex-none animate-pulse rounded-full bg-danger motion-reduce:animate-none`}),(0,Q.jsx)(`span`,{"data-slot":`dictation-timer`,className:`text-xs font-medium text-muted-foreground tabular-nums`,children:gh(t,o)}),(0,Q.jsx)(`span`,{"data-slot":`dictation-transcript`,"aria-live":`polite`,className:`min-w-0 flex-1 truncate text-sm text-foreground`,children:e===``?(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Listening…`}):e}),(0,Q.jsx)(O,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Cancel dictation`,className:`size-11 text-muted-foreground md:size-8`,onClick:r,children:(0,Q.jsx)(uo,{"aria-hidden":`true`})}),(0,Q.jsx)(O,{type:`button`,variant:`outline`,size:`icon-sm`,disabled:n,"aria-label":`Insert transcription`,className:`size-11 md:size-8`,onClick:i,children:(0,Q.jsx)(co,{"aria-hidden":`true`})}),(0,Q.jsx)(O,{type:`button`,size:`icon-sm`,disabled:n,"aria-label":`Insert transcription and send`,className:`size-11 md:size-8`,onClick:a,children:(0,Q.jsx)(Ja,{"aria-hidden":`true`})})]})}function Sh(e){try{let t=new URL(e),n=t.pathname===`/`?``:t.pathname.replace(/\/$/,``);return`${t.host}${n}`||e}catch{return e}}function Ch(e){return e?e.webhooks?e.webhooks.filter(e=>e.tasks).map(({id:e,name:t,url:n})=>({id:e,name:t,url:n})):e.webhook?[{id:`task-webhook`,name:`Task webhook`,url:e.webhook.url}]:[]:[]}function wh(e){let t=e.map(e=>e.name);return t.length<=2?t.join(` and `):t.length===3?`${t[0]}, ${t[1]} and ${t[2]}`:`${t[0]}, ${t[1]} and ${t.length-2} more`}function Th(e,t,n){let r=e.skill===``?{source:`workflow`,ref:`quick-task`}:{source:`skill`,ref:e.skill};return Rs({task:e.ref,source:r,model:``,runner:t,defaultRunner:n,images:[]})}function Eh(e,t){return e.kind===`failed`?{message:`Auto-start failed: ${e.message} — review and press Start`,tone:`danger`}:e.kind===`blocked`?{message:`Auto-start blocked (bad key) — review and press Start`,tone:`danger`}:t===``?{message:`Prefilled from link — review and press Start`,tone:`default`}:{message:`Unknown skill "${t}" — prefilled for quick-task; review and press Start`,tone:`danger`}}function Dh(e,t){return`Use the "${e}" skill on: ${t}`}function Oh(e){let t=e.configuredAutonomous===`source-dependent`?e.source===`skill`:e.configuredAutonomous,n=e.interactive!==!0&&void 0;return{autonomous:e.planFirst?!1:e.explicitAutonomous??n??t,worktree:e.hasGit?e.explicitWorktree??n??e.configuredWorktree:!1}}function kh(e){return e.worktree?`Runs in an isolated worktree — review everything before it lands.`:e.hasGit?`Runs in the repo working tree — your checkout is modified directly.`:`Runs in place — no git repository detected, so there is no worktree to isolate in.`}var Ah={text:``,source:null,runner:null,agentProfile:null,model:null,effort:null,retiredVariants:!1,planFirst:!1,worktree:null,autonomous:null,archiveWhenDone:!1,autoMergePr:!1},jh=`cez-new-task-draft`;function Mh(e){return e===null?jh:`${jh}:${e}`}function Nh(e){let t=e&&typeof e==`object`?e:{};return{text:typeof t.text==`string`?t.text:``,source:Ph(t.source)?t.source:null,runner:typeof t.runner==`string`?t.runner:null,agentProfile:typeof t.agentProfile==`string`?t.agentProfile:null,model:typeof t.model==`string`?t.model:null,effort:typeof t.effort==`string`?t.effort:null,retiredVariants:t.retiredVariants===!0||t.variants!==void 0&&t.variants!==1,planFirst:t.planFirst===!0,worktree:typeof t.worktree==`boolean`?t.worktree:null,autonomous:typeof t.autonomous==`boolean`?t.autonomous:null,archiveWhenDone:t.archiveWhenDone===!0,autoMergePr:t.autoMergePr===!0}}function Ph(e){return!!e&&typeof e==`object`&&(e.source===`skill`||e.source===`workflow`)&&typeof e.ref==`string`}var Fh=new Map,Ih=new Map;function Lh(e=null){return Ih.get(Mh(e))??0}function Rh(e=null){let t=Mh(e),n=Fh.get(t);if(n)return{...n};let r;try{let e=localStorage.getItem(t);r=e?Nh(JSON.parse(e)):{...Ah}}catch{r={...Ah}}return Fh.set(t,r),{...r}}function zh(e,t=null){let n=Mh(t);Ih.set(n,Lh(t)+1),Fh.set(n,{...e});try{localStorage.setItem(n,JSON.stringify(e))}catch{}}function Bh(e=null,t){t!==void 0&&Lh(e)!==t||zh({...Rh(e),text:``,source:null},e)}function Vh(e,t,n){return{task:e,steps:[...n.steps],rationale:n.rationale,fallback:n.fallback,images:[...t]}}function Hh(e,t){return!Number.isInteger(t)||t<0||t>=e.length?[...e]:e.filter((e,n)=>n!==t)}function Uh(e,t,n){let r=[...e];if(!Number.isInteger(t)||t<0||t>=r.length)return r;let i=Math.max(0,Math.min(r.length-1,n));if(i===t)return r;let[a]=r.splice(t,1);return r.splice(i,0,a),r}function Wh(e){return e.command??e.prompt??``}function Gh(e,t=120){let n=e.split(`
4
+ `)[0]??``;return n.length>t?`${n.slice(0,t-1)}…`:n}function Kh(e){let{task:t,steps:n,model:r,modelsLocked:i,effort:a,runner:o,runnerExplicit:s,defaultRunner:c,images:l,archiveWhenDone:u,autoMergePr:d}=e;return{task:t,steps:[...n],model:i?void 0:r||void 0,effort:i?void 0:a||void 0,runner:Is(o,c,s),images:l.length>0?[...l]:void 0,...u?{archiveWhenDone:!0}:{},...d?{autoMergePr:!0}:{}}}function qh(e,t){return{...Rh(e),...t.ref===``?{}:{text:t.ref},...t.skill===``?{}:{source:{source:`skill`,ref:t.skill}}}}function Jh(e,t){let[n,r]=(0,Z.useState)(()=>qh(e,t)),i=(0,Z.useRef)(n);(0,Z.useEffect)(()=>{zh(i.current,e)},[e]);let a=(0,Z.useRef)(!1),o=(0,Z.useRef)(!0);return(0,Z.useEffect)(()=>(o.current=!0,()=>{o.current=!1}),[]),{draft:n,update:t=>{if(!o.current||a.current)return;let n={...i.current,...t};i.current=n,zh(n,e),r(n)},submissionPending:a,mounted:o}}function Yh(e,t){let n=bn(),r=rr(),i=r.data,a=t.data?.skillUsage,o=(0,Z.useMemo)(()=>dc(i??[],a),[i,a]),s=n.data?.workflows??[],c=r.data!==void 0&&n.data!==void 0&&!t.isPending,l=nc(e,o,s);return{skillList:o,skillUsage:a,workflowList:s,sourcesReady:c,source:l,selectedSkill:l?.source===`skill`?o.find(e=>e.name===l.ref):void 0}}function Xh(e){let{uiState:t,source:n,sourcesReady:r,draftText:i,submissionPending:a,update:o}=e,s=mn().data?.capabilities.automations===!0,c=t.data?.promptTemplates,l=(0,Z.useMemo)(()=>Es(Us(c),{automations:s}),[c,s]),u=Ss(l,n?.source===`skill`?[n.ref]:[]),d=(0,Z.useRef)(i);d.current=i;let f=(0,Z.useRef)(``);return(0,Z.useEffect)(()=>{if(!r||a.current)return;let e=bs(d.current,f.current,u);f.current=e.applied,e.text!==d.current&&o({text:e.text})},[u,r]),l}function Zh(e,t){let n=Kn(),r=jt(n.data),i=t.data?.defaultRunner,a=i??`claude`,o=r.length>0?$s(e.runner,r,a):null,s=o??a,c=n.isSuccess&&r.length>0,l=Cn(s),u=t.data?.modelsLocked===!0,d=t.data?.defaultModels,f=o===null?[]:Gs(o,l.data,[e.model,d?.[o]]),p=o===null?``:Ps(u?null:e.model,o,d,l.data),m=zs(s,p,l.data);return{providers:n,runners:r,defaultRunner:i,runner:o,displayRunner:s,providersReady:c,catalog:l,modelsLocked:u,models:f,model:p,effortOptions:m,effort:u?``:Bs(e.effort,m)}}function Qh(e,t){let{accounts:n,repoAccount:r}=Ks();return{accountChoices:n,repoAccount:r,agentProfile:n.some(n=>n.provider===e&&n.id===t)?t:null}}function $h(e){let t=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{let n=e&&!t.current;t.current=e,n&&document.activeElement===document.body&&document.querySelector(`textarea[aria-label="Describe a task for the agent"]`)?.focus()},[e])}function eg(e){let t=e.workspaceConfig.data?.composerDefaults;return Oh({hasGit:e.hasGit,planFirst:e.draft.planFirst,explicitAutonomous:e.draft.autonomous,explicitWorktree:e.draft.worktree,interactive:e.selectedSkill?.interactive,configuredAutonomous:t?.autonomous??t?.inheritedAutonomous??`source-dependent`,configuredWorktree:t?.worktree??t?.inheritedWorktree??!0,source:e.source?.source??`workflow`})}function tg(e){let t=It(),n=t.data?.projects??[],r=e??t.data?.bootProject,i=Ch(n.find(e=>e.id===r)),[a,o]=(0,Z.useState)(!1);return{projectList:n,webhookTargets:i,notifyOn:i.length>0&&a,setNotifyChoice:o}}function ng(e,t){let[n,r]=(0,Z.useState)(()=>typeof window<`u`&&window.innerWidth<=767);return(0,Z.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=()=>r(window.innerWidth<=767||t.getBoundingClientRect().width<550);n();let i=typeof ResizeObserver>`u`?null:new ResizeObserver(n);return i?.observe(t),window.addEventListener(`resize`,n),()=>{i?.disconnect(),window.removeEventListener(`resize`,n)}},[t]),n}async function rg(e){let t=Lh(e.draftProjectId),n=``;try{n=(await qe()).key}catch{}if(n===``||e.deepLink.key!==n)return{kind:`blocked`};try{let n=await Ot(Th(e.deepLink,e.runner,e.defaultRunner));return Bh(e.draftProjectId,t),e.queryClient.invalidateQueries({queryKey:H.runs.all}),e.mounted.current&&e.navigate(tc(n)),null}catch(e){return{kind:`failed`,message:e instanceof Error?e.message:String(e)}}}function ig(e){let{deepLink:t}=e,n=ds(),r=z(),[i,a]=(0,Z.useState)(()=>t.auto&&t.ref!==``),[o,s]=(0,Z.useState)(()=>!t.auto&&t.ref!==``?{kind:`prefill`}:null);ag(e.search,n);let{providers:c,providersReady:l,runner:u,defaultRunner:d}=e.engine,f=(0,Z.useRef)(!1);return(0,Z.useEffect)(()=>{if(f.current||!t.auto||t.ref===``||c.isPending)return;let i=!l||u===null;if(!(!i&&e.config.isPending)){if(f.current=!0,i||d===void 0){s({kind:`prefill`}),a(!1);return}rg({deepLink:t,runner:u,defaultRunner:d,draftProjectId:e.draftProjectId,queryClient:r,navigate:n,mounted:e.mounted}).then(e=>{e!==null&&(s(e),a(!1))})}},[e.config.isPending,d,c.isPending,l,u]),og({notice:o,setNotice:s,deepLink:t,sourcesReady:e.sourcesReady,skillList:e.skillList,update:e.update}),i}function ag(e,t){let n=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{n.current||(n.current=!0,e.toString()!==``&&t(`/new`,{replace:!0}))},[])}function og(e){let{notice:t,sourcesReady:n,deepLink:r}=e;(0,Z.useEffect)(()=>{if(t===null||!n)return;e.setNotice(null);let i=r.skill!==``&&!e.skillList.some(e=>e.name===r.skill)?r.skill:``;i!==``&&e.update({text:Dh(r.skill,r.ref),source:null});let{message:a,tone:o}=Eh(t,i);K(a,{tone:o}),document.querySelector(`[data-slot="composer"] button[aria-label="Start task"], [data-slot="composer"] button[aria-label="Plan task"]`)?.focus()},[t,n])}function sg(e){return e.isPending?`Checking agent providers…`:e.isError?`Provider authentication could not be verified.`:`Connect an agent provider before starting a task.`}function cg(e,t,n){st({lastTask:e,...e?{recentSources:Vs(t.data?.recentSources,e)}:{},...e?.source===`skill`&&t.data!==void 0?{skillUsage:fc(t.data.skillUsage,e.ref)}:{}}).then(()=>n.invalidateQueries({queryKey:H.uiState})).catch(()=>{})}function lg(e){let t=ds(),n=z(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),{draft:l,draftProjectId:u,engine:d,mounted:f}=e,{providers:p,providersReady:m,runner:h}=d,g=(e,r)=>{Bh(u,r),n.invalidateQueries({queryKey:H.runs.all}),f.current&&t(tc(e))};return{plan:r,setPlan:i,planning:a,starting:s,submit:async(t,r)=>{let a=Lh(u);if(l.retiredVariants)throw Error(`Parallel variants are removed. Choose Use one task before starting this saved draft.`);if(!m||h===null)throw Error(sg(p));if(!e.sourcesReady)throw Error(`Still loading workflows and skills — try again in a second.`);if(l.planFirst){o(!0);try{let e=await Le(t);f.current&&i(Vh(t,r,e))}finally{o(!1)}return}let s=await Ot(js(Rs({task:t,source:e.source,model:d.model,modelsLocked:d.modelsLocked,effort:d.effort,runner:h,runnerExplicit:l.runner!==null,agentProfile:e.agentProfile,defaultRunner:d.defaultRunner,images:r,worktree:e.runMode.worktree,autonomous:e.runMode.autonomous,archiveWhenDone:l.archiveWhenDone,autoMergePr:l.autoMergePr}),e.notifyOn));cg(e.source,e.uiState,n),g(s,a)},startPlanned:async()=>{if(r===null||r.steps.length===0||s||!m||h===null)return;let t=Lh(u);c(!0);try{let n=await Ot(js(Kh({task:r.task,steps:r.steps,model:d.model,modelsLocked:d.modelsLocked,effort:d.effort,runner:h,runnerExplicit:l.runner!==null,defaultRunner:d.defaultRunner,images:r.images,archiveWhenDone:l.archiveWhenDone,autoMergePr:l.autoMergePr}),e.notifyOn));i(null),g(n,t)}catch(e){K(e instanceof Error?e.message:String(e),{tone:`danger`})}finally{c(!1)}}}}function ug(e){let t=typeof e==`string`?new URLSearchParams(e):e;return{skill:(t.get(`skill`)??``).trim(),ref:(t.get(`ref`)??t.get(`task`)??``).trim(),auto:t.get(`auto`)===`1`,key:t.get(`key`)??``}}function dg({archiveWhenDone:e,autoMergePr:t,onChange:n,disabled:r=!1,embedded:i=!1}){let a=(0,Z.useId)();return(0,Q.jsxs)(`fieldset`,{"data-slot":`completion-controls`,"data-embedded":i||void 0,className:`grid min-w-0 gap-3`,children:[(0,Q.jsx)(`legend`,{className:i?`sr-only`:`text-sm font-medium [margin-block-end:0.5rem]`,children:`After Done`}),(0,Q.jsxs)(`label`,{htmlFor:`${a}-archive`,className:`completion-control flex min-h-11 min-w-0 items-center justify-between gap-3 rounded-md text-sm`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,Q.jsx)(`span`,{id:`${a}-archive-label`,children:`Archive when Done`}),i?(0,Q.jsx)(`span`,{id:`${a}-archive-help`,className:`completion-control-help`,children:`Move to Archived after Done, even without a PR. You can restore it later.`}):null]}),(0,Q.jsx)(oa,{id:`${a}-archive`,className:`completion-switch`,checked:e,disabled:r,"aria-labelledby":`${a}-archive-label`,"aria-describedby":`${a}-archive-help`,onCheckedChange:e=>n({archiveWhenDone:e})})]}),i?null:(0,Q.jsx)(`p`,{id:`${a}-archive-help`,className:`text-xs break-words text-muted-foreground`,children:`Move the task to Archived after it reaches Done. You can restore it later.`}),(0,Q.jsxs)(`label`,{htmlFor:`${a}-merge`,className:`completion-control flex min-h-11 min-w-0 items-center justify-between gap-3 rounded-md text-sm`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,Q.jsx)(`span`,{id:`${a}-merge-label`,children:`Auto-merge PR`}),i?(0,Q.jsx)(`span`,{id:`${a}-merge-help`,className:`completion-control-help`,children:`After Done, mark the PR ready and merge when current-head CI and GitHub rules allow.`}):null]}),(0,Q.jsx)(oa,{id:`${a}-merge`,className:`completion-switch`,checked:t,disabled:r,"aria-labelledby":`${a}-merge-label`,"aria-describedby":`${a}-merge-help`,onCheckedChange:e=>n({autoMergePr:e})})]}),i?null:(0,Q.jsx)(`p`,{id:`${a}-merge-help`,className:`text-xs break-words text-muted-foreground`,children:`After Done, mark a draft PR ready and merge when current-head CI and GitHub rules allow it.`}),!i||e&&t?(0,Q.jsx)(`p`,{className:`completion-order-note text-xs break-words text-muted-foreground`,children:i?`Merge runs before archive when both are on.`:`When both are on, merge comes before archive. Without a PR, Archive when Done still archives the task.`}):null]})}function fg(){return(0,Q.jsxs)(`div`,{"data-route":`new`,className:`relative isolate flex min-h-full flex-col items-center justify-center overflow-x-clip px-6`,children:[(0,Q.jsx)(ys,{}),(0,Q.jsxs)(`div`,{"data-slot":`auto-starting`,role:`status`,className:`text-center`,children:[(0,Q.jsx)(`h1`,{className:`animate-pulse text-lg font-semibold tracking-tight`,children:`Starting task…`}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[14px] text-muted-foreground`,children:`Launched from a bookmarklet — taking you to the run.`})]})]})}function pg(){return(0,Q.jsxs)(`header`,{className:`mb-7 max-md:mb-5`,children:[(0,Q.jsx)(`p`,{"data-slot":`page-eyebrow`,className:`mb-2 text-[11px] font-semibold tracking-[0.16em] text-[var(--accent-text)] uppercase`,children:`NEW TASK`}),(0,Q.jsx)(`h1`,{className:`text-[30px] leading-[normal] font-semibold tracking-[-0.9px] max-md:text-[22px] max-md:leading-[29px] max-md:tracking-[-0.6px]`,children:`What should the agent work on?`}),(0,Q.jsx)(`p`,{"data-slot":`page-description`,className:`mt-2 hidden text-[13px] text-muted-foreground md:block`,children:`Describe the outcome. Configure the run. Review everything before it lands.`})]})}function mg({onUseOneTask:e}){return(0,Q.jsxs)(`section`,{role:`alert`,className:`flex flex-col items-start gap-3 rounded-xl border border-border bg-card p-4`,children:[(0,Q.jsx)(`p`,{children:`Parallel variants are removed. This saved draft requested multiple candidates. Use owned workers to compare approaches, or start one task.`}),(0,Q.jsx)(O,{variant:`outline`,className:`min-h-11`,onClick:e,children:`Use one task`})]})}function hg({groupRef:e,compact:t,engine:n,accounts:r,draftEffort:i,update:a}){let o=n.runners.length>1||n.runners.some(e=>Zs(r.accountChoices,e))?(0,Q.jsx)(gg,{engine:n,accounts:r,update:a},`runner`):null,s=(0,Q.jsx)(_g,{engine:n,draftEffort:i,update:a},`model`),c=(0,Q.jsx)(vg,{engine:n,update:a},`effort`);return(0,Q.jsx)(`div`,{ref:e,"data-slot":`agent-options`,role:`group`,"aria-label":`Agent settings`,className:`new-task-agent-options`,children:(0,Q.jsx)(Hs,{children:t?[o,c,s]:[o,s,c]})})}function gg({engine:e,accounts:t,update:n}){return(0,Q.jsx)(Fs,{icon:(0,Q.jsx)(mo,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:e.runners,value:e.displayRunner,accounts:t.accountChoices,account:t.agentProfile,repoAccount:t.repoAccount,onPick:(t,r)=>n({runner:t,agentProfile:r,...t===e.displayRunner?{}:{model:null}}),disabled:!e.providersReady})}function _g({engine:e,draftEffort:t,update:n}){let{catalog:r,displayRunner:i}=e;return(0,Q.jsx)(Ys,{icon:(0,Q.jsx)(Xa,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`model-pill`,ariaLabel:`Model`,label:e.models.find(t=>t.id===e.model)?.label??`auto`,value:e.model,disabled:!e.providersReady,readOnly:e.modelsLocked,disabledHint:e.modelsLocked?`Model selection is locked to native coding-agent settings.`:void 0,onPick:e=>{let a=zs(i,e,r.data);n({model:e,effort:t===null?null:Bs(t,a)})},options:e.models.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:Js(i,r.data,r.isError,r.isFetching)})}function vg({engine:e,update:t}){return(0,Q.jsx)(Ys,{icon:(0,Q.jsx)(ka,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`effort-pill`,ariaLabel:`Effort`,label:e.effortOptions.find(t=>t.value===e.effort)?.label??`auto`,value:e.effort,disabled:!e.providersReady,readOnly:e.modelsLocked,disabledHint:e.modelsLocked?`Effort selection is locked to native coding-agent settings.`:void 0,onPick:e=>t({effort:e}),options:e.effortOptions.map(e=>({value:e.value,label:e.label,desc:e.desc}))})}function yg({engine:e,draft:t,update:n,repo:r,hasGit:i,runMode:a,webhook:o,interactiveSkill:s,completionDisabled:c}){let{displayRunner:l}=e;return(0,Q.jsxs)(`details`,{"data-slot":`execution-options`,open:!0,className:`group rounded-xl border border-border bg-card xl:self-start`,children:[(0,Q.jsxs)(`summary`,{className:`flex min-h-[44px] cursor-pointer list-none flex-wrap items-center gap-x-2 gap-y-1 px-3 py-2 text-xs text-muted-foreground pointer-hover:bg-muted/50 active:bg-muted/50 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-foreground [&::-webkit-details-marker]:hidden`,children:[(0,Q.jsx)(po,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:`Execution settings`}),(0,Q.jsxs)(`span`,{"data-slot":`execution-summary`,hidden:!0,className:`min-w-0 basis-full truncate pl-5 xl:ml-auto xl:basis-auto xl:pl-0`,children:[Ws.find(e=>e.id===l)?.label??l,` · `,e.models.find(t=>t.id===e.model)?.label??`auto`]}),(0,Q.jsx)(So,{"aria-hidden":`true`,className:`new-task-settings-chevron size-4 shrink-0`})]}),(0,Q.jsxs)(`div`,{className:`new-task-settings-body`,children:[(0,Q.jsx)(`p`,{className:`new-task-settings-description`,children:`Control this run and what happens after Done.`}),(0,Q.jsxs)(`div`,{role:`group`,"aria-label":`Run settings`,className:`new-task-run-settings`,children:[i?(0,Q.jsx)(xg,{on:a.worktree,onChange:e=>n({worktree:e})}):null,(0,Q.jsx)(wg,{repo:r}),(0,Q.jsx)(Sg,{on:a.autonomous,disabled:t.planFirst,onChange:e=>n({autonomous:e})}),o.targets.length>0?(0,Q.jsx)(Cg,{on:o.on,targets:o.targets,onChange:o.onChange}):null,s&&(t.autonomous===null||t.worktree===null)?(0,Q.jsx)(`p`,{className:`basis-full text-xs text-muted-foreground`,"data-slot":`interactive-skill-hint`,children:`This skill recommends an interactive run in the current checkout. You can change either setting.`}):null]}),(0,Q.jsx)(dg,{embedded:!0,archiveWhenDone:t.archiveWhenDone,autoMergePr:t.autoMergePr,onChange:n,disabled:c})]})]})}function bg({showConfigureProviders:e,planFirst:t,planning:n,onModeChange:r}){return(0,Q.jsxs)(Q.Fragment,{children:[e?(0,Q.jsx)(Y,{to:`/settings/agents#providers`,className:`text-xs font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):null,(0,Q.jsx)(Eg,{planFirst:t,planning:n,onModeChange:r}),(0,Q.jsx)(`kbd`,{"aria-hidden":`true`,className:`hidden rounded-[5px] border border-b-2 border-border bg-card px-[5px] py-px font-mono text-[11px] font-medium text-muted-foreground md:inline`,children:ih()})]})}function xg({on:e,disabled:t,disabledReason:n,onChange:r}){return(0,Q.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,disabled:t,"aria-label":`Worktree`,"data-slot":`worktree-toggle`,onClick:()=>r(!e),title:t?n:e?`Runs in an isolated worktree — uncheck to run in the repo working tree`:`Runs in the repo working tree — check to isolate in a worktree`,className:`flex items-center justify-between gap-3 px-0 py-3 text-left`,children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`block text-[13px] font-medium`,children:`Worktree`}),(0,Q.jsx)(`span`,{className:`block text-[12px] text-muted-foreground`,children:e?`Changes stay in a separate working copy.`:`Changes are made in the current working directory.`})]}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:k(`flex h-6 w-10 shrink-0 items-center rounded-full border p-0.5`,e?`border-accent-strong bg-accent-strong`:`border-muted-foreground bg-muted`),children:(0,Q.jsx)(`span`,{className:k(`size-[18px] rounded-full`,e?`ml-auto bg-accent-strong-foreground`:`bg-foreground`)})})]})}function Sg({on:e,disabled:t,onChange:n}){return(0,Q.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,disabled:t,"aria-label":`Autonomous`,"data-slot":`autonomous-toggle`,onClick:()=>n(!e),title:t?`Plan-first runs are interactive — autonomous is unavailable`:e?`Autonomous — the agent runs to completion without pausing for you`:`Runs interactively — check to let the agent finish without pausing for you`,className:`flex items-center justify-between gap-3 px-0 py-3 text-left disabled:opacity-50`,children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`block text-[13px] font-medium`,children:`Autonomous`}),(0,Q.jsx)(`span`,{className:`block text-[12px] text-muted-foreground`,children:`Let the agent proceed without prompts`})]}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:k(`flex h-6 w-10 shrink-0 items-center rounded-full border p-0.5`,e?`border-accent-strong bg-accent-strong`:`border-muted-foreground bg-muted`),children:(0,Q.jsx)(`span`,{className:k(`size-[18px] rounded-full`,e?`ml-auto bg-accent-strong-foreground`:`bg-foreground`)})})]})}function Cg({on:e,targets:t,onChange:n}){return(0,Q.jsxs)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,"aria-label":`Notify webhook`,"data-slot":`notify-webhook-toggle`,onClick:()=>n(!e),title:`${e?`Status changes go to`:`Check to send this task's status changes to`} ${wh(t)} (${t.map(e=>Sh(e.url)).join(`, `)})`,className:`flex min-h-11 items-center justify-between gap-3 px-0 py-3 text-left`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block text-[13px] font-medium`,children:`Notify webhook`}),(0,Q.jsx)(`span`,{"data-slot":`notify-webhook-subtitle`,className:`block truncate text-[12px] text-muted-foreground`,children:`Send status changes`})]}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:k(`flex h-6 w-10 shrink-0 items-center rounded-full border p-0.5`,e?`border-accent-strong bg-accent-strong`:`border-muted-foreground bg-muted`),children:(0,Q.jsx)(`span`,{className:k(`size-[18px] rounded-full`,e?`ml-auto bg-accent-strong-foreground`:`bg-foreground`)})})]})}function wg({repo:e}){return(0,Q.jsxs)(`div`,{"data-slot":`base-branch-row`,className:`new-task-base-branch flex items-center justify-between gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:`Base branch`}),e?(0,Q.jsx)(Tg,{repo:e}):null]})}function Tg({repo:e}){let t=z(),n=V({mutationFn:e=>xt({baseBranch:e}),onSuccess:e=>{t.invalidateQueries({queryKey:H.repo}),K(e.baseBranch?`New tasks will branch off "${e.baseBranch}" (PRs target it too).`:`Base branch cleared — new tasks fork from the checked-out branch.`)},onError:e=>K(e.message,{tone:`danger`})});return e.info?(0,Q.jsx)(Ys,{searchPlaceholder:`Search branches…`,slot:`base-pill`,ariaLabel:`Base branch`,label:(0,Q.jsx)(`span`,{className:`text-[11px]`,children:e.baseBranch??e.info.branch}),value:e.baseBranch??``,onPick:e=>n.mutate(e===``?null:e),options:[{value:``,label:`follow checked-out branch (${e.info.branch})`,desc:`New task worktrees fork from whatever branch is checked out`},...e.branches.map(e=>({value:e,label:e}))]}):null}function Eg({planFirst:e,planning:t,onModeChange:n}){return(0,Q.jsxs)(`div`,{"data-slot":`mode-seg`,role:`radiogroup`,"aria-label":`Run mode`,className:`inline-flex items-center gap-0.5 rounded-lg bg-muted p-[3px]`,children:[(0,Q.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":!e,onClick:()=>n(!1),className:k(`h-6 rounded-md px-2 text-xs transition-colors`,e?`font-medium text-muted-foreground hover:text-foreground`:`bg-card font-semibold text-foreground shadow-xs`),children:[e?null:(0,Q.jsx)(co,{"aria-hidden":`true`,className:`size-3.5`}),`Start`]}),(0,Q.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e,"aria-busy":t||void 0,"data-slot":`mode-plan`,onClick:()=>n(!0),className:k(`h-6 rounded-md px-2 text-xs transition-colors`,e?`bg-contrast font-semibold text-contrast-foreground ring-2 ring-ring/55`:`font-medium text-muted-foreground hover:text-foreground`,t&&`animate-pulse`),children:t?`Planning…`:`Plan first`})]})}function Dg({plan:e,starting:t,startAvailable:n,startUnavailableReason:r,startUnavailableAction:i,onStepsChange:a,onStart:o,onDiscard:s}){let[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),f=(0,Z.useRef)(null),p=(0,Z.useId)();(0,Z.useEffect)(()=>{f.current?.focus({preventScroll:!0});let e=f.current?.closest(`[data-slot="main"]`);e&&(e.scrollTop=0)},[]);let m=()=>{l(null),d(null)},h=(t,n)=>{t.preventDefault(),c!==null&&c!==n&&a(Uh(e.steps,c,n)),m()},g=e.steps.length===0;return(0,Q.jsxs)(`div`,{"data-slot":`plan-page`,children:[(0,Q.jsxs)(`header`,{"data-slot":`plan-page-header`,children:[(0,Q.jsx)(`h1`,{children:`New task / Plan first`}),(0,Q.jsx)(`p`,{children:`Review the proposed chain before launching.`})]}),(0,Q.jsx)(`div`,{"data-slot":`plan-canvas`,children:(0,Q.jsxs)(`section`,{ref:f,tabIndex:-1,"aria-labelledby":p,"data-slot":`plan-review`,className:`flex flex-col outline-none`,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||e.target.closest(`[role="dialog"], [role="alertdialog"]`)||(e.preventDefault(),s())},children:[(0,Q.jsxs)(`header`,{"data-slot":`dialog-header`,className:`flex flex-col gap-1 px-5 pt-4 pb-3.5 text-left`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsx)(`h2`,{id:p,"data-slot":`dialog-title`,className:`text-[11px] font-semibold tracking-[0.08em] text-muted-foreground uppercase`,children:`Proposed chain`}),(0,Q.jsx)(`button`,{type:`button`,onClick:s,"aria-label":`Discard the plan`,className:`-mt-1 -mr-1 rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,Q.jsx)(uo,{"aria-hidden":`true`,className:`size-4`})})]}),(0,Q.jsx)(`p`,{"data-slot":`plan-task`,title:e.task,className:`text-[18px] font-medium text-foreground`,children:Gh(e.task)}),e.fallback?(0,Q.jsx)(`p`,{"data-slot":`plan-fallback`,className:`text-xs text-soft-foreground italic`,children:`planner unavailable — single-step plan`}):e.rationale===``?null:(0,Q.jsx)(`p`,{"data-slot":`plan-rationale`,className:`text-xs text-muted-foreground`,children:e.rationale})]}),(0,Q.jsx)(`ol`,{"data-slot":`plan-steps`,className:`flex-1 space-y-2 overflow-y-auto px-5 py-4`,children:g?(0,Q.jsx)(`li`,{className:`py-6 text-center text-sm text-muted-foreground`,children:`(no steps left — discard and plan again)`}):e.steps.map((t,n)=>(0,Q.jsxs)(`li`,{"data-slot":`plan-step`,"data-step-id":t.id,draggable:!0,onDragStart:()=>l(n),onDragOver:e=>{e.preventDefault(),d(n)},onDragLeave:()=>d(e=>e===n?null:e),onDrop:e=>h(e,n),onDragEnd:m,className:k(`flex items-center gap-2.5 rounded-lg border border-border bg-card-2 px-3 py-2.5`,c===n&&`opacity-50`,u===n&&c!==null&&c!==n&&`border-ring`),children:[(0,Q.jsx)(Va,{"aria-hidden":`true`,className:`size-3.5 shrink-0 cursor-grab text-soft-foreground`}),(0,Q.jsx)(`span`,{className:`w-5 shrink-0 font-mono text-[11px] text-soft-foreground tabular-nums`,children:String(n+1).padStart(2,`0`)}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-[13px] font-medium`,children:t.name??t.id}),t.skill?(0,Q.jsx)(`span`,{"data-slot":`plan-badge-skill`,title:`skill`,className:`shrink-0 rounded-full bg-accent-strong/15 px-1.5 py-px font-mono text-[11px] font-medium text-accent-text`,children:t.skill}):null,t.command?(0,Q.jsx)(`span`,{"data-slot":`plan-badge-check`,className:`shrink-0 rounded-full bg-muted px-1.5 py-px text-[11px] font-medium text-muted-foreground`,children:`check`}):null]}),(0,Q.jsx)(`p`,{className:`mt-3 whitespace-pre-wrap break-words font-mono text-[11px] text-muted-foreground`,children:Wh(t)})]}),(0,Q.jsxs)(`span`,{"data-slot":`plan-step-actions`,className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(O,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-slot":`plan-step-up`,"aria-label":`Move step ${n+1} up`,disabled:n===0,className:`size-7 text-muted-foreground`,onClick:()=>a(Uh(e.steps,n,n-1)),children:`Move up`}),(0,Q.jsx)(O,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-slot":`plan-step-down`,"aria-label":`Move step ${n+1} down`,disabled:n===e.steps.length-1,className:`size-7 text-muted-foreground`,onClick:()=>a(Uh(e.steps,n,n+1)),children:`Move down`}),(0,Q.jsx)(O,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-slot":`plan-step-remove`,"aria-label":`Remove step ${n+1}`,className:`size-7 text-muted-foreground hover:text-danger`,onClick:()=>a(Hh(e.steps,n)),children:`Remove`})]})]},t.id))}),!n&&r?(0,Q.jsxs)(`p`,{id:`plan-start-guidance`,className:`flex flex-wrap items-center gap-1.5 border-t border-border px-5 pt-3 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:r}),i]}):null,(0,Q.jsxs)(`div`,{"data-slot":`plan-actions`,className:`flex flex-wrap items-center gap-3 px-6 pt-3 pb-6`,children:[(0,Q.jsxs)(O,{type:`button`,"data-slot":`plan-start`,disabled:g||t||!n,title:n?void 0:r,"aria-describedby":!n&&r?`plan-start-guidance`:void 0,onClick:o,children:[(0,Q.jsx)(_m,{"aria-hidden":`true`,className:`size-3.5`}),t?`Starting…`:`Start`]}),(0,Q.jsx)(Og,{steps:e.steps,disabled:g}),(0,Q.jsx)(O,{type:`button`,variant:`outline`,onClick:s,children:`Discard`})]}),(0,Q.jsx)(`p`,{className:`px-6 pb-6 text-xs text-muted-foreground`,children:`No steps left? Start is disabled. A planner failure shows a single-step fallback.`})]})})]})}function Og({steps:e,disabled:t}){let n=z(),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),d=async t=>{let r=a.trim();if(!(r===``||l)){u(!0);try{let a=await ie({name:r,steps:e,...t?{overwrite:!0}:{}});K(`Saved — ${a.path.split(`/`).pop()??a.path}`),n.invalidateQueries({queryKey:H.workflows}),c(!1),i(!1),o(``)}catch(e){e instanceof Ze&&e.exists===!0?c(!0):K(e instanceof Error?e.message:String(e),{tone:`danger`})}finally{u(!1)}}};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(O,{type:`button`,variant:`outline`,"data-slot":`plan-save`,disabled:t,onClick:()=>i(!0),children:`Save as chain`}),(0,Q.jsx)(jo,{open:r,onOpenChange:e=>i(!!e),children:(0,Q.jsxs)(Ao,{"data-slot":`plan-save-dialog`,className:`sm:max-w-sm`,showCloseButton:!1,children:[(0,Q.jsxs)(Po,{children:[(0,Q.jsx)(ko,{children:`Save as chain`}),(0,Q.jsx)(Oo,{children:`Saves these steps as a reusable workflow — it joins the picker like any other chain.`})]}),(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),d(!1)},children:[(0,Q.jsx)(`label`,{htmlFor:`plan-chain-name`,className:`mb-2 block text-[11px] text-muted-foreground`,children:`Chain name`}),(0,Q.jsx)(Hf,{id:`plan-chain-name`,value:a,onChange:e=>o(e.target.value),"aria-label":`Chain name`,placeholder:`e.g. fix-and-verify-v2`,maxLength:80,autoFocus:!0}),(0,Q.jsxs)(Mo,{className:`mt-4`,children:[(0,Q.jsx)(O,{type:`button`,variant:`outline`,onClick:()=>i(!1),children:`Cancel`}),(0,Q.jsx)(O,{type:`submit`,disabled:a.trim()===``||l,children:l?`Saving…`:`Save chain`})]})]})]})}),(0,Q.jsx)(ra,{open:s,onOpenChange:e=>e?void 0:c(!1),children:(0,Q.jsxs)(Yi,{"data-slot":`plan-overwrite-dialog`,children:[(0,Q.jsxs)(na,{children:[(0,Q.jsxs)(Wi,{children:[`Overwrite “`,a.trim(),`”?`]}),(0,Q.jsx)(Ui,{children:`A chain with this name already exists. Overwriting replaces its steps with this plan.`})]}),(0,Q.jsxs)($i,{children:[(0,Q.jsx)(ta,{children:`Cancel`}),(0,Q.jsx)(Qi,{onClick:()=>void d(!0),children:`Overwrite chain`})]})]})})]})}var kg={start:{note:`Start immediately with the selected configuration.`,pendingLabel:`Starting task…`,failureHint:void 0,clearOnSuccess:!0,sendAriaLabel:`Start task`},plan:{note:`Review the plan before starting the task.`,pendingLabel:`Planning task…`,failureHint:`Could not create the plan. Your draft is kept. Please retry.`,clearOnSuccess:!1,sendAriaLabel:`Plan task`}};function Ag(){let[e]=o(),t=(0,Z.useRef)(null),n=(0,Z.useRef)(null),r=(0,Z.useRef)(null),{projectId:i}=s(),a=mt().projectId,[c]=(0,Z.useState)(()=>ug(e)),l=Wn(),u=gn(),d=Zn(),f=Lr(),{draft:p,update:m,submissionPending:h,mounted:g}=Jh(a,c),_=Yh(p.source,u),{source:v,sourcesReady:y,skillList:b}=_,x=tg(i),S=Xh({uiState:u,source:v,sourcesReady:y,draftText:p.text,submissionPending:h,update:m}),C=Zh(p,d),w=Qh(C.displayRunner,p.agentProfile);$h(C.providersReady);let T=l.data===void 0||l.data.info!==null,E=eg({hasGit:T,draft:p,selectedSkill:_.selectedSkill,workspaceConfig:f,source:v}),{plan:D,setPlan:O,planning:k,starting:A,submit:j,startPlanned:M}=lg({draft:p,draftProjectId:a,engine:C,agentProfile:w.agentProfile,sourcesReady:y,source:v,runMode:E,notifyOn:x.notifyOn,uiState:u,mounted:g}),N=ig({deepLink:c,search:e,engine:C,config:d,draftProjectId:a,mounted:g,sourcesReady:y,skillList:b,update:m}),P=ng(t,N);if(N)return(0,Q.jsx)(fg,{});let{providers:F,providersReady:I}=C,L=p.planFirst?kg.plan:kg.start,ee=sg(F);return(0,Q.jsxs)(`div`,{"data-route":`new`,"data-plan-review":D===null?void 0:`true`,className:`relative isolate flex min-h-full flex-col overflow-x-clip pb-16`,children:[(0,Q.jsxs)(`div`,{"data-slot":`new-task-layout`,ref:r,style:D===null?void 0:{display:`none`},className:`relative z-[1] mx-auto w-full max-w-none px-11 pt-12 max-md:px-[18px] max-md:pt-[22px]`,children:[(0,Q.jsx)(pg,{}),p.retiredVariants?(0,Q.jsx)(mg,{onUseOneTask:()=>m({retiredVariants:!1})}):null,(0,Q.jsx)(yh,{ref:n,onSubmit:j,retainDraftUntilSuccess:!0,idleFeedback:(0,Q.jsxs)(`div`,{"data-slot":`new-task-mode-note`,className:`flex items-center justify-between gap-3 text-[11px] text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:L.note}),(0,Q.jsx)(`kbd`,{className:`hidden font-sans md:inline`,children:ih()})]}),pendingLabel:L.pendingLabel,failureHint:L.failureHint,clearOnSuccess:L.clearOnSuccess,onPendingChange:e=>{h.current=e},value:p.text,onValueChange:e=>m({text:e}),autoFocus:!0,placeholder:`Describe a task for the agent — / for skills…`,ariaLabel:`Describe a task for the agent`,sendAriaLabel:L.sendAriaLabel,disabled:!I||A,disabledReason:ee,autocompleteSkills:!0,footerStart:(0,Q.jsx)(jg,{projects:x.projectList,urlProjectId:i,templates:S,onInsertTemplate:e=>n.current?.insertAtCaret(e),sources:_,onPickSource:e=>m({source:e})}),agentOptions:(0,Q.jsx)(hg,{groupRef:t,compact:P,engine:C,accounts:w,draftEffort:p.effort,update:m}),executionOptions:(0,Q.jsx)(yg,{engine:C,draft:p,update:m,repo:l.data,hasGit:T,runMode:E,webhook:{targets:x.webhookTargets,on:x.notifyOn,onChange:x.setNotifyChoice},interactiveSkill:_.selectedSkill?.interactive===!0,completionDisabled:A||k}),footerEnd:(0,Q.jsx)(bg,{showConfigureProviders:!I&&!F.isPending,planFirst:p.planFirst,planning:k,onModeChange:e=>m({planFirst:e})})}),(0,Q.jsx)(`p`,{"data-slot":`run-mode-note`,className:`mt-2.5 text-[13px] text-muted-foreground`,children:kh({worktree:E.worktree,hasGit:T})})]}),D===null?null:(0,Q.jsx)(Dg,{plan:D,starting:A,startAvailable:I,startUnavailableReason:ee,startUnavailableAction:F.isPending?void 0:(0,Q.jsx)(Y,{to:`/settings/agents#providers`,children:`Configure providers`}),onStepsChange:e=>O(t=>t&&{...t,steps:e}),onStart:()=>void M(),onDiscard:()=>{O(null),requestAnimationFrame(()=>r.current?.querySelector(`textarea`)?.focus())}})]})}function jg({projects:e,urlProjectId:t,templates:n,onInsertTemplate:r,sources:i,onPickSource:a}){let o=ds();return(0,Q.jsxs)(Q.Fragment,{children:[e.length>1&&t!==void 0?(0,Q.jsx)(Ng,{projects:e,projectId:t,onPick:e=>o(`/p/${encodeURIComponent(e)}/new`,{replace:!0})}):null,(0,Q.jsx)(aa,{label:`Template`,templates:n,onInsert:r}),(0,Q.jsx)(Pg,{source:i.source,ready:i.sourcesReady,skills:i.skillList,skillUsage:i.skillUsage,workflows:i.workflowList,onPick:a})]})}function Mg(e,t){let n=t.trim().toLowerCase();if(n===``)return[...e];let r=e=>{let t=e.name.toLowerCase(),r=e.id.toLowerCase();return t.startsWith(n)||r.startsWith(n)?0:t.includes(n)||r.includes(n)?1:2};return e.map((e,t)=>({project:e,rank:r(e),index:t})).filter(e=>e.rank<2).sort((e,t)=>e.rank-t.rank||e.index-t.index).map(e=>e.project)}function Ng({projects:e,projectId:t,onPick:n}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(``),s=e.find(e=>e.id===t),c=Mg(e,a);return(0,Q.jsxs)(Da,{open:r,onOpenChange:e=>{i(e),e||o(``)},children:[(0,Q.jsx)(Sa,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`project-pill`,"aria-label":`Project`,title:`Which project this task runs in — its skills, workflows, settings and draft`,className:k(Xs,`border-foreground/60 font-semibold text-foreground`),children:[(0,Q.jsx)(ja,{"aria-hidden":`true`,className:`size-3 shrink-0 text-soft-foreground`}),(0,Q.jsx)(`span`,{className:`max-w-40 truncate`,children:s?.name??t}),qs]})}),(0,Q.jsx)(Ta,{align:`start`,sideOffset:8,className:`w-[300px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Q.jsxs)(Ds,{shouldFilter:!1,children:[(0,Q.jsx)(Ts,{placeholder:`search projects…`,value:a,onValueChange:o}),(0,Q.jsxs)(rc,{"data-slot":`project-menu`,className:`max-h-[min(18rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[c.length===0?(0,Q.jsx)(Cs,{children:`Nothing matches.`}):null,c.map(e=>(0,Q.jsxs)(As,{value:e.id,keywords:[e.name],"data-slot":`project-option`,"data-project-id":e.id,disabled:e.status===`missing`,onSelect:()=>{n(e.id),i(!1)},children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium`,children:e.name}),e.status===`missing`?(0,Q.jsx)(`span`,{className:`shrink-0 text-[11px] text-soft-foreground`,children:`folder not found`}):e.branch===void 0?null:(0,Q.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-soft-foreground`,children:e.branch}),e.id===t?(0,Q.jsx)(co,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},e.id))]}),(0,Q.jsx)(`p`,{className:`border-t border-border px-3 py-2 text-[11px] leading-snug text-soft-foreground`,children:`Skills, workflows, settings and the draft re-resolve against the selected project.`})]})})]})}function Pg({source:e,ready:t,skills:n,skillUsage:r,workflows:i,onPick:a}){let[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(null),f=(0,Z.useRef)(null),{mostUsed:p,project:m,global:h,ranked:g}=pc(n,c,r),_=i.find(e=>e.name===Ls),v=ac(i,c).filter(e=>e.name!==Ls),y=i.some(e=>e.name!==Ls),b=ic(`no skill`,`none plain ${Ls} ${_?.description??``}`,c)>0,x=!b&&(g?g.length===0:p.length===0&&m.length===0&&h.length===0)&&v.length===0,S=e=>{a(e),s(!1)},C=t=>S(e?.source===t.source&&e.ref===t.ref?null:t),w=(t,n)=>{let r=e?.source===`skill`&&e.ref===t.name;return(0,Q.jsxs)(As,{value:`skill ${t.name} ${t.path}`,keywords:oc(t.name,t.description),"data-slot":`source-option`,"data-source-kind":`skill`,"data-source-ref":t.name,onSelect:()=>C({source:`skill`,ref:t.name}),children:[(0,Q.jsx)(`span`,{className:k(`shrink-0 font-mono text-xs`,n&&`font-semibold`),children:t.name}),t.description?(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:t.description}):null,(0,Q.jsx)(`button`,{type:`button`,"data-slot":`source-skill-view`,"aria-label":`View skill ${t.name}`,title:`View skill`,onClick:e=>{e.preventDefault(),e.stopPropagation(),d(t)},className:`ml-auto shrink-0 rounded-sm p-0.5 text-soft-foreground transition-colors hover:text-foreground`,children:(0,Q.jsx)(ns,{"aria-hidden":`true`,className:`size-3.5`})}),r?(0,Q.jsx)(co,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},t.path)},T=e===null||e.source===`skill`?vo:no,E=(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`source-pill`,"data-source-kind":e?.source??`none`,"aria-label":`Choose a skill or workflow`,title:e===null?`No skill — the task runs as one plain agent step. Pick a skill or workflow to change that.`:`Runs the ${e.source} "${e.ref}" — pick it again, or press ✕, to run without it`,disabled:!t,onKeyDown:t=>{e===null||t.metaKey||t.ctrlKey||t.altKey||t.key!==`Backspace`&&t.key!==`Delete`||(t.preventDefault(),a(null))},className:k(Xs,`font-mono text-[11px]`,e===null?`text-muted-foreground`:`rounded-r-none border-r-0 border-foreground/60 pr-1.5 font-semibold text-foreground`),children:[(0,Q.jsx)(T,{"aria-hidden":`true`,className:k(`size-3 shrink-0`,e===null?`text-muted-foreground`:`text-accent-icon`)}),(0,Q.jsx)(`span`,{className:`max-w-44 truncate`,children:t?e?.ref??(y?`Skill or workflow`:`Skill`):`…`}),qs]});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ca,{skill:u,onClose:()=>d(null)}),(0,Q.jsxs)(Da,{open:o,onOpenChange:e=>{s(e),e||l(``)},children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center`,children:[(0,Q.jsx)(Sa,{asChild:!0,children:E}),e!==null&&t?(0,Q.jsx)(`button`,{type:`button`,"data-slot":`source-pill-clear`,"aria-label":`Clear the ${e.source} ${e.ref}`,title:`Run without it`,onClick:()=>a(null),className:k(Xs,`rounded-l-none border-foreground/60 pl-1.5 pr-2 text-soft-foreground hover:text-foreground`),children:(0,Q.jsx)(uo,{"aria-hidden":`true`,className:`size-3`})}):null]}),(0,Q.jsx)(Ta,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Q.jsxs)(Ds,{shouldFilter:!1,children:[(0,Q.jsx)(Ts,{placeholder:`search skills & workflows…`,value:c,onValueChange:l,onInput:()=>f.current?.scrollTo(0,0)}),(0,Q.jsxs)(rc,{ref:f,"data-slot":`source-menu`,className:`max-h-[min(18rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[x?(0,Q.jsx)(Cs,{children:`Nothing matches.`}):null,b?(0,Q.jsx)(ws,{children:(0,Q.jsxs)(As,{value:`none no-skill`,keywords:[`none`,`plain`,...oc(Ls)],"data-slot":`source-option`,"data-source-kind":`none`,onSelect:()=>S(null),children:[(0,Q.jsx)(ro,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-soft-foreground`}),(0,Q.jsx)(`span`,{className:`shrink-0 text-xs font-medium`,children:`No skill`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:_?.description??`One agent run on your task — no ceremony.`}),e===null?(0,Q.jsx)(co,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]})}):null,g?g.length>0?(0,Q.jsx)(ws,{children:g.map(e=>w(e,sc(e)))}):null:(0,Q.jsxs)(Q.Fragment,{children:[p.length>0?(0,Q.jsx)(ws,{heading:`Most used`,children:p.map(e=>w(e,sc(e)))}):null,m.length>0?(0,Q.jsx)(ws,{heading:`Project skills`,children:m.map(e=>w(e,!0))}):null]}),v.length>0?(0,Q.jsx)(ws,{heading:`Workflows`,children:v.map(t=>{let n=e?.source===`workflow`&&e.ref===t.name;return(0,Q.jsxs)(As,{value:`workflow ${t.name}`,keywords:oc(t.name,t.description),"data-slot":`source-option`,"data-source-kind":`workflow`,"data-source-ref":t.name,onSelect:()=>C({source:`workflow`,ref:t.name}),children:[(0,Q.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:t.name}),t.description?(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:t.description}):null,n?(0,Q.jsx)(co,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},t.name)})}):null,h.length>0?(0,Q.jsx)(ws,{heading:`Global`,children:h.map(e=>w(e,!1))}):null]})]})})]})]})}function Fg(){return(0,Q.jsx)(`div`,{"data-route":`not-found`,className:`flex min-h-full flex-col`,children:(0,Q.jsx)(X,{icon:(0,Q.jsx)(zp,{}),tone:`neutral`,title:`Page not found`,subtitle:`Nothing lives at this address. The link may be mistyped, or it points at something that is gone.`,actions:(0,Q.jsx)(O,{asChild:!0,variant:`outline`,children:(0,Q.jsx)(Y,{to:`/`,children:`Back to tasks`})})})})}function Ig(){return(0,Q.jsx)(`div`,{className:`px-[18px] pt-2 md:hidden`,children:(0,Q.jsxs)(Y,{to:`/git`,"data-slot":`git-back`,className:`inline-flex min-h-11 items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground`,children:[(0,Q.jsx)(_o,{size:16,"aria-hidden":`true`,className:`size-3.5`}),`Back to Git`]})})}function Lg(){let{pathname:e,search:t}=a();return(0,Q.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[hs(e)!==`/git`||new URLSearchParams(t).get(`view`)===`repo`?(0,Q.jsx)(Ig,{}):null,(0,Q.jsx)(X,{icon:(0,Q.jsx)(Bo,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:`Loading repository…`,subtitle:`Fetching the repo's git state.`})]})}function Rg(){return(0,Q.jsxs)(`div`,{"data-route":`skills`,"aria-busy":`true`,className:`mx-auto min-h-full w-full px-[18px] py-6 md:p-9`,children:[(0,Q.jsx)(`h1`,{className:`text-[30px] font-semibold tracking-tight`,children:`Skills`}),(0,Q.jsx)(`p`,{className:`mt-1 text-[13px] text-muted-foreground`,children:`Markdown playbooks your agents can follow.`}),(0,Q.jsx)(`p`,{"data-slot":`skills-loading`,role:`status`,className:`mt-6 text-xs text-muted-foreground`,children:`Loading skills…`}),(0,Q.jsxs)(`div`,{"aria-hidden":`true`,className:`mt-4 flex flex-col gap-[22px] motion-safe:animate-pulse`,children:[(0,Q.jsx)(`div`,{className:`h-11 rounded-lg border border-border bg-card`}),(0,Q.jsx)(`div`,{className:`h-80 rounded-xl border border-border bg-card`})]})]})}function zg({projectId:e,registry:t}){let n=t.projects.length?t.projects:[{id:t.bootProject,name:t.bootProject}];return(0,Q.jsx)(`div`,{"data-route":`unknown-project`,className:`flex min-h-full flex-col`,children:(0,Q.jsx)(X,{icon:(0,Q.jsx)(Zp,{}),tone:`neutral`,title:`“${e}” isn’t registered here`,subtitle:`This cezar doesn’t serve a project by that id. The link may come from another machine’s workspace — these are the projects registered on this one:`,children:(0,Q.jsx)(`ul`,{"data-slot":`registered-projects`,className:`mx-auto flex w-full max-w-xs flex-col gap-1.5 text-left`,children:n.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(T,{to:`/p/${encodeURIComponent(e.id)}/`,className:`flex items-baseline gap-2 rounded-md border border-border bg-card px-3 py-2 text-sm font-medium text-foreground shadow-xs transition-colors hover:bg-card-2`,children:[e.name||e.id,(0,Q.jsxs)(`span`,{className:`font-mono text-[11px] font-normal text-soft-foreground`,children:[`/p/`,e.id]})]})},e.id))})})})}function Bg(){return(0,Q.jsxs)(`div`,{"data-route":`workflows`,"aria-busy":`true`,className:`mx-auto min-h-full w-full px-[18px] py-6 md:p-9`,children:[(0,Q.jsx)(`h1`,{className:`text-[30px] font-semibold tracking-tight`,children:`Workflows`}),(0,Q.jsx)(`p`,{className:`mt-1 text-[13px] text-muted-foreground`,children:`Portable skill chains. Steps run from top to bottom.`}),(0,Q.jsx)(`p`,{"data-slot":`workflows-loading`,role:`status`,className:`mt-6 text-xs text-muted-foreground`,children:`Loading workflows…`}),(0,Q.jsxs)(`div`,{"aria-hidden":`true`,className:`mt-4 flex flex-col gap-[22px] motion-safe:animate-pulse`,children:[(0,Q.jsx)(`div`,{className:`h-11 rounded-lg border border-border bg-card`}),(0,Q.jsx)(`div`,{className:`h-80 rounded-xl border border-border bg-card`})]})]})}function Vg({tab:e}){return(0,Q.jsx)(`div`,{"data-route":`task-${e}`,className:`flex min-h-full flex-col`,children:(0,Q.jsx)(X,{icon:(0,Q.jsx)(Bo,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:e===`changes`?`Loading changes…`:`Loading files…`,subtitle:`Fetching the run record.`})})}function Hg({tab:e,error:t}){let n=t instanceof Ze&&t.status===404;return(0,Q.jsx)(`div`,{"data-route":`task-${e}`,className:`flex min-h-full flex-col`,children:(0,Q.jsx)(X,{icon:n?(0,Q.jsx)(ls,{}):(0,Q.jsx)(Qa,{size:16}),tone:n?`neutral`:`danger`,title:n?`Task not found`:`Could not load this task`,subtitle:n?`No run has this id. It may have been deleted, or the link is from another machine.`:t.message,actions:(0,Q.jsx)(O,{asChild:!0,variant:`outline`,children:(0,Q.jsx)(Y,{to:`/`,children:`Back to tasks`})})})})}var Ug={issue:`issue`,pr:`pull request`};function Wg({kind:e,number:t,heading:n=`h1`}){let r=(0,Q.jsx)(`div`,{"data-slot":`task-github-loading`,className:`flex min-h-full flex-1 flex-col`,children:(0,Q.jsx)(X,{icon:(0,Q.jsx)(Bo,{className:`motion-safe:animate-spin`}),tone:`neutral`,heading:n,title:`Loading ${Ug[e]}${t===void 0?``:` #${t}`}…`,subtitle:t===void 0?`Fetching the run record.`:`Asking GitHub.`})});return n===`h2`?r:(0,Q.jsx)(`div`,{"data-route":`task-github-item`,className:`flex min-h-full flex-col`,children:r})}function Gg(){return(0,Q.jsx)(`div`,{"data-route":`task-thread`,className:`flex min-h-full flex-col`,children:(0,Q.jsx)(X,{icon:(0,Q.jsx)(Bo,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:`Loading task…`,subtitle:`Fetching the run and its session transcript.`})})}async function Kg(e,t,n,r,i){try{return await e.fetchQuery({queryKey:[t,`runs`,`artifact-metadata`,n,r],queryFn:()=>Ee(n,r,{signal:i}),retry:!1}),!0}catch(e){if(e instanceof Ze&&e.status===404)return!1;throw e}}async function qg(e,t,n,r,i,a){if(await Kg(e,t,n,r,i))return n;i.throwIfAborted();let o=await e.fetchQuery({queryKey:[t,`runs`,`relationships`,n],queryFn:()=>xe(n,{signal:i}),retry:!1}),s=new Set(o.workers.map(e=>e.workerId));a&&s.add(a),s.delete(n);for(let n of s){if(i.aborted)throw i.reason;if(await Kg(e,t,n,r,i))return n}throw new Ze(404,`Report missing or deleted`)}function Jg(e,t,n){let r=z(),i=c();return Rr({queryKey:[i,`runs`,`report-source`,e,t,n],queryFn:({signal:a})=>qg(r,i,e,t,a,n),enabled:!!(e&&t),retry:!1})}function Yg(){let[e]=o(),t=a(),n=j(),r=d(),i=Z.useRef(Math.random()),s=Z.useRef({renderedKey:``,next:e,seq:0,latestSeq:0});return Z.useLayoutEffect(()=>{if(s.current.renderedKey===t.key)return;let n=t.state,a=n?.__writerSession===i.current?n.__writerSeq:void 0;r===`REPLACE`&&a!==void 0&&a<=s.current.latestSeq?(s.current.renderedKey=t.key,a===s.current.latestSeq&&(s.current.next=e)):s.current={renderedKey:t.key,next:e,seq:s.current.seq,latestSeq:0}},[e,t,r]),[e,Z.useCallback(e=>{let t=e(new URLSearchParams(s.current.next));if(t.toString()===s.current.next.toString())return;let r=s.current.seq+1;s.current={...s.current,next:t,seq:r,latestSeq:r},n({search:`?${t}`},{replace:!0,state:{__writerSession:i.current,__writerSeq:r}})},[n])]}var Xg=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Zg(e){let t=e.get(`report`);return!t||!Xg.test(t)||e.getAll(`report`).length!==1||e.getAll(`card`).length>1?null:{artifactId:t,card:e.get(`card`)||null}}var Qg=(0,Z.createContext)(null);function $g(e){let t=a(),n=j(),[r,i]=Yg(),o=Zg(r),[s,c]=(0,Z.useState)(()=>({runId:e,entries:new Map}));s.runId!==e&&c({runId:e,entries:new Map});let l=(0,Z.useCallback)((t,n)=>(c(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]),u=(0,Z.useRef)({runId:e,callbacks:new Map});u.current.runId!==e&&(u.current={runId:e,callbacks:new Map});let d=(0,Z.useCallback)((e,t)=>(u.current.callbacks.set(e,t),()=>{u.current.callbacks.get(e)===t&&u.current.callbacks.delete(e)}),[]),f=(0,Z.useMemo)(()=>({register:l,registerOpener:d}),[l,d]),p=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{r.has(`report`)&&!o&&i(e=>(e.delete(`report`),e.delete(`card`),e))},[r,o,i]),(0,Z.useEffect)(()=>{let n=p.current;!o&&n&&n.runId===e&&n.card&&u.current.callbacks.get(n.card)?.(n.artifactId,n.scrollTop),p.current=o?{...o,runId:e,scrollTop:t.state?.reportScrollTop}:null},[e,o,t.state]),{selection:o,sourceRunId:s.runId===e&&o?s.entries.get(o.artifactId)??(o.card?void 0:e):void 0,registry:f,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))}}}var e_=class extends Z.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e,t){console.error(`cezar cockpit: the preview pane crashed`,e,t.componentStack)}render(){return this.state.failed?(0,Q.jsxs)(`div`,{"data-slot":`preview-pane-error`,role:`alert`,className:`flex h-full flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-semibold text-foreground`,children:`The preview hit an error`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The task is unaffected. Close the preview and open it again.`}),(0,Q.jsx)(O,{variant:`outline`,onClick:this.props.onClose,children:`Close preview`})]}):this.props.children}},t_=`cez-preview-tasks`,n_=`cez.preview.pane-width`,r_=e=>Math.min(75,Math.max(30,Math.round(e)));function i_(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function a_(e){if(!i_(e))return;let{port:t,agent:n,url:r}=e;if(typeof t==`number`&&Number.isInteger(t)&&t>=1&&t<=65535)return{port:t};if(n===!0)return{agent:!0};if(typeof r==`string`&&/^https?:\/\//i.test(r))return{url:r}}function o_(e){if(!i_(e))return;let t=a_(e.target),n=typeof e.percent==`number`&&Number.isFinite(e.percent)?e.percent:void 0;return{open:e.open===!0,...t?{target:t}:{},...n===void 0?{}:{percent:n},at:typeof e.at==`number`?e.at:0}}function s_(){try{let e=localStorage.getItem(t_),t=e===null?null:JSON.parse(e);return i_(t)?t:{}}catch{return{}}}function c_(e){let t=o_(s_()[e]);if(!t)return;let{at:n,...r}=t;return r}function l_(e,t,n=Date.now()){let r=s_(),i={open:!1,...o_(r[e]),...t,at:n};for(let e of Object.keys(i))i[e]===void 0&&delete i[e];r[e]=i;let a=Object.keys(r);if(a.length>100){let e=e=>o_(r[e])?.at??0;for(let t of a.sort((t,n)=>e(t)-e(n)).slice(0,a.length-100))delete r[t]}try{localStorage.setItem(t_,JSON.stringify(r))}catch{}}function u_(){try{let e=Number(localStorage.getItem(n_));return e>0?e:void 0}catch{return}}function d_(e){let t=(e===void 0?void 0:c_(e)?.percent)??u_();return t===void 0?58:r_(t)}function f_(e,t){try{localStorage.setItem(n_,String(t))}catch{}e!==void 0&&l_(e,{percent:t})}var p_=`(min-width: 1180px)`,m_=`(max-width: 767px)`;function h_(e,t){let[n,r]=(0,Z.useState)(()=>window.matchMedia?.(e).matches??t);return(0,Z.useEffect)(()=>{let t=window.matchMedia?.(e);if(!t)return;let n=()=>r(t.matches);return n(),t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},[e]),n}var g_=(0,Z.lazy)(()=>zr(()=>import(`./preview-pane-connected-Dfc9BAkc.js`).then(e=>({default:e.ConnectedPreviewPane})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]))),__=2;function v_(e){let[t,n]=(0,Z.useState)(void 0);return(0,Z.useEffect)(()=>{let t=e.current?.closest(`[data-slot="main"]`);if(!t)return;let r=()=>n(t.clientHeight||void 0);if(r(),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(r);return i.observe(t),()=>i.disconnect()},[e]),t}function y_({run:e,state:t,children:n,report:r}){let i=h_(p_,!0),a=h_(m_,!1),o=(0,Z.useRef)(null),s=v_(o),{percent:c,setPercent:l}=t,u=!!r||t.open&&e!==void 0,d=u&&!i,f=!r&&t.session,p=d&&!f,m=d&&f,h=e=>{let t=o.current?.getBoundingClientRect();!t||t.width===0||l(r_((t.right-e)/t.width*100))},g=e=>{e.currentTarget.setPointerCapture?.(e.pointerId)},_=e=>{e.currentTarget.hasPointerCapture?.(e.pointerId)&&h(e.clientX)},v=e=>{if(e.key===`ArrowLeft`)l(r_(c+__));else if(e.key===`ArrowRight`)l(r_(c-__));else return;e.preventDefault()},y={"--preview-pane":`${c}%`,...s===void 0?{}:{"--preview-h":`${s}px`}};return(0,Q.jsxs)(`div`,{ref:o,"data-slot":`task-split`,"data-pane":u?`open`:`closed`,"data-takeover":p?``:void 0,className:`preview-split flex min-h-full`,style:y,children:[(0,Q.jsx)(`div`,{"data-slot":`task-main`,hidden:p&&a,"data-collapsed":p&&!a?``:void 0,className:`min-w-0 flex-1`,children:n}),u?(0,Q.jsxs)(Q.Fragment,{children:[i?(0,Q.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize preview`,"aria-valuemin":30,"aria-valuemax":75,"aria-valuenow":c,tabIndex:0,"data-slot":`preview-divider`,className:`preview-divider`,onPointerDown:g,onPointerMove:_,onKeyDown:v}):null,(0,Q.jsxs)(`aside`,{"data-slot":`preview-pane`,"data-phone":a?``:void 0,hidden:m,className:`preview-pane`,children:[r,(0,Q.jsx)(`div`,{hidden:!!r,className:`h-full`,children:t.open&&e?(0,Q.jsx)(e_,{onClose:t.closePane,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,className:`p-6 text-sm text-muted-foreground`,children:`Opening the preview…`}),children:(0,Q.jsx)(g_,{run:e,servers:e.previewServers??[],request:t.request,onSession:p?t.showSession:void 0,onTarget:t.setTarget,onLive:t.setLive,onClose:t.closePane},e.id)})}):null})]})]}):null]})}function b_(e){if(!e.worktreePath||e.worktreeReclaimedAt)return!0;let t=e.delegation?.role===`worker`?e.delegation.destroy:void 0;return t!==void 0&&!t.remaining.includes(`worktree`)}function x_(e){let{state:t,server:n}=e,r=Io(e.stateAt);switch(t){case`registered`:return n.answeredAtRegistration?{tone:`neutral`,ring:!1,pulse:!1,text:`was running when registered`}:{tone:`neutral`,ring:!0,pulse:!1,text:`registered · not started`};case`adopted`:return{tone:`neutral`,ring:!1,pulse:!1,text:`was running when registered`};case`starting`:return{tone:`pending`,ring:!1,pulse:!0,text:`starting`};case`up`:return{tone:`success`,ring:!1,pulse:!1,text:r?`up · ${r}`:`up`};case`stalled`:return{tone:`pending`,ring:!1,pulse:!1,text:`stalled · port silent 2 min`};case`exited`:return{tone:`danger`,ring:!1,pulse:!1,text:e.exitCode===void 0?`exited`:`exited · code ${e.exitCode}`};case`stopped`:return{tone:`neutral`,ring:!0,pulse:!1,text:e.reason===`idle`?`stopped after 15 min idle`:`stopped`};case`unavailable`:return{tone:`neutral`,ring:!0,pulse:!1,text:`unavailable`}}}function S_(e){return{kind:`preview-server`,id:`preview-server:${e.port}`,server:e,state:`registered`,stateAt:e.registeredAt}}function C_(e,t){return t?.get(e.port)??S_(e)}function w_(e){return e.state===`registered`?e.server.answeredAtRegistration:e.state===`up`||e.state===`starting`||e.state===`adopted`}function T_(e){return e.split(` -- `)[0].trim()}var E_=(0,Z.createContext)(null);function D_(){return(0,Z.useContext)(E_)}var O_=e=>e&&`port`in e?e.port:void 0;function k_(){return typeof window.matchMedia!=`function`||window.matchMedia(`(min-width: 1180px)`).matches}function A_(e){let t=e===void 0?void 0:c_(e),n=t?.open===!0,r=n?t.target:void 0;return{open:n,target:r,request:n?{...r,restored:!0}:void 0,session:n&&!k_(),percent:d_(e)}}function j_(e,t=!1){let[n]=(0,Z.useState)(()=>A_(e)),[r,i]=(0,Z.useState)(n.open),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(n.target),[l,u]=(0,Z.useState)(n.session),[d,f]=(0,Z.useState)(n.request),[p,m]=(0,Z.useState)(n.percent),[h,g]=(0,Z.useState)(e),_=(0,Z.useRef)(r);if(_.current=r,h!==e){let t=A_(e);g(e),i(t.open),o(!1),c(t.target),u(t.session),f(t.request),m(t.percent)}t&&r&&d?.restored&&(i(!1),c(void 0),f(void 0),u(!1));let v=(0,Z.useCallback)(t=>{e!==void 0&&l_(e,t)},[e]),y=(0,Z.useCallback)(e=>{f({...e});let t=e.port===void 0?e.agent?{agent:!0}:void 0:{port:e.port};u(!1),i(!0),t?(c(t),v({open:!0,target:t})):_.current?v({open:!0}):(c(void 0),v({open:!0,target:void 0}))},[v]),b=(0,Z.useCallback)(()=>{i(!1),o(!1),u(!1),c(void 0),v({open:!1})},[v]),x=(0,Z.useCallback)(e=>{c(e),v({target:e})},[v]),S=(0,Z.useCallback)(t=>{m(t),f_(e,t)},[e]),C=(0,Z.useCallback)(()=>u(!0),[]),w=O_(s);return(0,Z.useMemo)(()=>({open:r,live:a,port:w,target:s,percent:p,request:d,session:l,openPane:y,closePane:b,showSession:C,setLive:o,setTarget:x,setPercent:S}),[r,a,w,s,p,d,l,y,b,C,x,S])}function M_(e,t={}){let[n,r]=(0,Z.useState)([]),{cursor:i,afterSeq:a=0,maxEvents:o,compactAt:s,onCompact:l,onReset:u}=t;return(0,Z.useEffect)(()=>{if(r([]),!e)return;let t=a,n=!1,d=!1,f=c(),p=[],m,h,g=()=>{if(m!==void 0&&globalThis.cancelAnimationFrame?.(m),clearTimeout(h),m=void 0,h=void 0,n||p.length===0)return;let e=p;p=[],r(t=>{let r=[...t,...e];return!d&&s!==void 0&&r.length>=s&&(d=!0,queueMicrotask(()=>{n||l?.()})),o===void 0||r.length<=o?r:r.slice(-o)})},_=()=>{h===void 0&&(h=setTimeout(g,50),typeof globalThis.requestAnimationFrame==`function`&&(m=globalThis.requestAnimationFrame(g)))},v=oe({kind:`run`,projectId:f,runId:e,afterSeq:a,...i?{cursor:i}:{}},{frame:e=>{!(`type`in e)||e.type!==`event`||e.event.seq<=t||(t=e.event.seq,p.push(e.event),_())},reset:async(e,n)=>{g();let r=await u?.(e,n);return r&&(t=Math.max(t,r.afterSeq)),r}});return()=>{n=!0,m!==void 0&&globalThis.cancelAnimationFrame?.(m),clearTimeout(h),v()}},[e,i,a,o,s,l,u]),n}var N_=5,P_=200,F_=5e3;function I_(...e){let t=new Map;for(let n of e)for(let e of n)t.set(e.seq,e);return[...t.values()].sort((e,t)=>e.seq-t.seq)}function L_(e,t,n){e.setQueryData(t,e=>{if(!e)return{pages:[n],pageParams:[void 0]};let t=[...e.pages],r=[...e.pageParams],i=-1;for(let e=0;e<t.length;e+=1)(i===-1||t[e].asOfSeq>t[i].asOfSeq)&&(i=e);if(i>=0&&t[i].asOfSeq>n.asOfSeq)return e;for(i>=0&&t[i].newerCursor===void 0?(t[i]=n,r[i]=void 0):(t.push(n),r.push(void 0));t.length>N_;)t.shift(),r.shift();return{pages:t,pageParams:r}})}function R_(e){let t=c(),n=z(),r=[`run-history`,t,e],i=[`run-history-context`,t,e],a=Ft({queryKey:r,enabled:e!==void 0,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>se(e,t,{signal:n}),getPreviousPageParam:e=>e.olderCursor,getNextPageParam:e=>e.newerCursor,maxPages:N_,staleTime:1/0,retry:1}),o=Rr({queryKey:i,enabled:e!==void 0,queryFn:({signal:t})=>re(e,{signal:t}),retry:1}),s=(0,Z.useCallback)(async(r,i)=>{if(e===void 0)return;let[a,o]=await Promise.all([se(e,void 0,{signal:i}),re(e,{signal:i})]);return i.throwIfAborted(),L_(n,[`run-history`,t,e],a),n.setQueryData([`run-history-context`,t,e],o),{cursor:a.liveCursor,afterSeq:a.asOfSeq}},[n,e,t]),l=a.isError||o.isError,u=M_(l?e:void 0,{onReset:s}),d=a.data?.pages??[],f=d.reduce((e,t)=>t.newerCursor===void 0?t:e??t,void 0),p=(0,Z.useRef)(!1),m=(0,Z.useCallback)(()=>{e===void 0||p.current||(p.current=!0,se(e,void 0).then(r=>L_(n,[`run-history`,t,e],r)).catch(()=>{}).finally(()=>{p.current=!1}))},[n,e,t]),h=e=>e!==void 0&&n.getQueryData([`run-history`,t,e])!==void 0,[g,_]=(0,Z.useState)(()=>({runId:e,pending:h(e)})),v=g.pending;g.runId!==e&&(v=h(e),_({runId:e,pending:v})),(0,Z.useEffect)(()=>{if(!v||e===void 0)return;let r=!1,i=new AbortController;return se(e,void 0,{signal:i.signal}).then(r=>L_(n,[`run-history`,t,e],r)).catch(()=>{}).finally(()=>{r||_({runId:e,pending:!1})}),()=>{r=!0,i.abort()}},[n,v,e,t]);let y=M_(!l&&f&&!v?e:void 0,{cursor:f?.liveCursor,afterSeq:f?.asOfSeq,maxEvents:F_,compactAt:P_,onCompact:m,onReset:s}),b=(0,Z.useRef)(0);b.current=y.length,(0,Z.useEffect)(()=>()=>{b.current>0&&m()},[m]);let x=(0,Z.useMemo)(()=>I_(...d.map(e=>e.events)),[d]),S=(0,Z.useMemo)(()=>l?u:I_(x,y),[l,u,x,y]),C=(0,Z.useMemo)(()=>{if(l)return u;let e=o.data?.contextEvents??[],t=o.data?.asOfSeq??0;return I_(e,S.filter(({seq:e})=>e>t))},[o.data,l,u,S]),w=(0,Z.useCallback)(async()=>{await a.fetchPreviousPage()},[a.fetchPreviousPage]),T=(0,Z.useCallback)(async()=>{l||await n.resetQueries({queryKey:r,exact:!0})},[l,r,n]);return{visibleEvents:S,currentEvents:C,isPending:!l&&a.isPending,contextPending:!l&&o.isPending,fallback:l,hasOlder:!l&&!!a.hasPreviousPage,isFetchingOlder:a.isFetchingPreviousPage,olderError:a.isFetchPreviousPageError?a.error instanceof Error?a.error.message:`Could not load earlier items`:void 0,loadOlder:w,jumpToLatest:T,retainedPages:d.length}}function z_(e){for(let t=e.length-1;t>=0;--t){let n=Tt.safeParse(e[t]);if(n.success)return n.data.state===`connected`}return!1}function B_(e){let{currentEvents:t}=R_(e);return(0,Z.useMemo)(()=>z_(t),[t])}var V_=(0,Z.lazy)(()=>zr(()=>import(`./report-reader-BflKmitB.js`).then(e=>({default:e.ReportReader})),__vite__mapDeps([19,1,2,3,4,5,6,20,21,22,23,7,10,24,12,25,26,27,9,28,29])));function H_(){let{id:e}=s(),t=Xn(e),n=a(),r=mn().data?.capabilities?.preview===!0,i=t.data?b_(t.data):!1,o=j_(e,i),c=$g(e),l=Jg(e,c.selection?.artifactId,c.sourceRunId),u=c.selection?(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,children:`Loading report…`}),children:(0,Q.jsx)(V_,{runId:l.data??e??``,selection:{artifactId:c.selection.artifactId},fragment:n.hash,onBack:c.close,variant:`pane`,sourceLookup:l},`${e}:${c.selection.artifactId}`)}):void 0,d=r?(0,Q.jsx)(U_,{id:e,run:t.data,pane:o,removed:i,report:u,children:(0,Q.jsx)(_,{})}):(0,Q.jsx)(y_,{run:t.data,state:{...o,open:!1},report:u,children:(0,Q.jsx)(_,{})});return(0,Q.jsx)(Qg.Provider,{value:c.registry,children:d})}function U_({id:e,run:t,pane:n,removed:r,children:i,report:a}){let o=B_(e),s=(0,Z.useMemo)(()=>({...n,worktreeRemoved:r,agentLive:o}),[n,r,o]);return(0,Q.jsx)(E_.Provider,{value:s,children:(0,Q.jsx)(y_,{run:t,state:n,report:a,children:i})})}function W_(){let e=Zn();return e.isPending?(0,Q.jsx)(`p`,{role:`status`,children:`Loading task settings…`}):e.isError?(0,Q.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[`Task settings did not load: `,e.error.message]}):(0,Q.jsx)(K_,{config:e.data,scope:`project`})}function G_(){let e=Lr();return e.isPending?(0,Q.jsx)(`p`,{role:`status`,className:`p-4 text-sm`,children:`Loading task settings…`}):e.isError?(0,Q.jsxs)(`p`,{role:`alert`,className:`p-4 text-sm text-danger`,children:[`Task settings did not load: `,e.error.message]}):(0,Q.jsx)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col gap-4 p-4 md:p-6`,children:(0,Q.jsx)(K_,{config:e.data,scope:`global`})})}function K_({config:e,scope:t}){let n=(0,Z.useId)(),r=z(),i=V({mutationFn:async({archiveOnMerge:e,projectKey:n})=>t===`project`?xt({archiveOnMerge:e},n[0]):gt({archiveOnMerge:e}),onSuccess:(e,{projectKey:n})=>{t===`project`?r.setQueryData(n,e):(r.setQueryData(B.config,e),r.invalidateQueries({predicate:e=>e.queryKey.at(-1)===`config`&&e.queryKey!==B.config}))}});return(0,Q.jsxs)(`section`,{"data-slot":`archive-on-merge-field`,className:`flex min-w-0 flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`label`,{htmlFor:n,className:`text-sm font-semibold text-foreground`,children:`Archive tasks after PRs merge`}),(0,Q.jsx)(`p`,{id:`${n}-hint`,className:`text-[13px] text-muted-foreground`,children:`Automatically archive a settled task and its workers once all their associated pull requests merge. History stays available in Archived.`})]}),(0,Q.jsxs)(`select`,{id:n,"aria-describedby":`${n}-hint ${n}-effective`,className:`min-h-11 w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus-visible:outline-2 focus-visible:outline-ring active:bg-muted disabled:opacity-50`,value:e.archiveOnMerge===null?`inherit`:e.archiveOnMerge?`enabled`:`disabled`,disabled:i.isPending,onChange:e=>i.mutate({archiveOnMerge:e.target.value===`inherit`?null:e.target.value===`enabled`,projectKey:H.config}),children:[(0,Q.jsx)(`option`,{value:`inherit`,children:t===`project`?`Inherit global setting`:`Use default`}),(0,Q.jsx)(`option`,{value:`enabled`,children:`Enabled`}),(0,Q.jsx)(`option`,{value:`disabled`,children:`Disabled`})]}),(0,Q.jsxs)(`p`,{id:`${n}-effective`,className:`text-[13px] text-muted-foreground`,children:[`Currently `,e.effectiveArchiveOnMerge?`enabled`:`disabled`,` · `,e.archiveOnMergeSource,` setting.`]}),(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Unarchive restores the task. It stays visible until a later associated PR merges.`}),i.isPending?(0,Q.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Saving…`}):null,i.isError?(0,Q.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[`Could not save: `,i.error.message]}):null]})}var q_=h(`inline-block shrink-0`,{variants:{tone:{success:``,pending:``,danger:``,accent:``,info:``,running:``,neutral:``},shape:{filled:`size-[7px] rounded-full`,ring:`size-[7px] rounded-full border-[1.5px] bg-transparent`,workers:`inline-flex size-[12px] items-center justify-center`},pulse:{true:`animate-pulse motion-reduce:animate-none`,false:``}},compoundVariants:[{shape:`filled`,tone:`success`,className:`bg-success`},{shape:`filled`,tone:`pending`,className:`bg-pending-strong`},{shape:`filled`,tone:`danger`,className:`bg-danger`},{shape:`filled`,tone:`accent`,className:`bg-accent-strong`},{shape:`filled`,tone:`info`,className:`bg-info`},{shape:`filled`,tone:`running`,className:`bg-status-running`},{shape:`filled`,tone:`neutral`,className:`bg-soft-foreground`},{shape:`ring`,tone:`success`,className:`border-success`},{shape:`ring`,tone:`pending`,className:`border-pending-strong`},{shape:`ring`,tone:`danger`,className:`border-danger`},{shape:`ring`,tone:`accent`,className:`border-accent-strong`},{shape:`ring`,tone:`info`,className:`border-info`},{shape:`ring`,tone:`running`,className:`border-status-running`},{shape:`ring`,tone:`neutral`,className:`border-soft-foreground`},{shape:`workers`,tone:`success`,className:`text-success`},{shape:`workers`,tone:`pending`,className:`text-pending-strong`},{shape:`workers`,tone:`danger`,className:`text-danger`},{shape:`workers`,tone:`accent`,className:`text-accent-icon`},{shape:`workers`,tone:`info`,className:`text-info`},{shape:`workers`,tone:`running`,className:`text-status-running`},{shape:`workers`,tone:`neutral`,className:`text-soft-foreground`}],defaultVariants:{tone:`neutral`,shape:`filled`,pulse:!1}});function J_({className:e,tone:t=`neutral`,shape:n=`filled`,pulse:r=!1,...i}){return(0,Q.jsx)(`span`,{"data-slot":`status-dot`,"data-tone":t,"data-shape":n,className:k(q_({tone:t,shape:n,pulse:r,className:e})),...i,children:n===`workers`?(0,Q.jsx)(Tp,{className:`size-[12px]`,"aria-hidden":`true`}):null})}function Y_({className:e,orientation:t=`horizontal`,...n}){return(0,Q.jsx)(Hd,{"data-slot":`tabs`,"data-orientation":t,orientation:t,className:k(`group/tabs flex gap-2 data-[orientation=horizontal]:flex-col`,e),...n})}var X_=h(`group/tabs-list inline-flex w-fit items-center justify-center rounded-md p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function Z_({className:e,variant:t=`default`,...n}){return(0,Q.jsx)(Ud,{"data-slot":`tabs-list`,"data-variant":t,className:k(X_({variant:t}),e),...n})}function Q_({className:e,...t}){return(0,Q.jsx)(Wd,{"data-slot":`tabs-trigger`,className:k(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-sm border border-transparent px-3 py-1 text-[13px] font-medium whitespace-nowrap text-muted-foreground transition-[color,background-color,border-color,box-shadow] group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start pointer-hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-xs group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent`,`data-[state=active]:bg-card data-[state=active]:font-semibold data-[state=active]:text-foreground`,`after:absolute after:bg-accent-strong after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:inset-be-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100`,e),...t})}function $_({className:e,...t}){return(0,Q.jsx)(Gd,{"data-slot":`tabs-content`,className:k(`flex-1 outline-hidden`,e),...t})}var ev={folder:Qp,terminal:Tm,vscode:Lp,cursor:fm,zed:km,windsurf:Dm,sublime:qp,idea:Up,pycharm:im,webstorm:tm,goland:Sm,rubymine:$p,phpstorm:Dp,clion:Hp,rider:Ep,"android-studio":Cm,xcode:rm,warp:ym,claude:Tp,codex:wm,opencode:Tp,pi:Tp,omp:Tp};function tv(e){return e.icon&&ev[e.icon]||Ea}function nv(e){let t=/^cli:(claude|codex|opencode|pi|cursor|omp)$/.exec(e);return t?t[1]:void 0}function rv({choices:e,onPick:t,label:n=`Open in…`,title:r,triggerVariant:i=`ghost`,disabled:a=!1,leading:o,trailing:s,slot:c,className:l}){return(0,Q.jsxs)(Li,{children:[(0,Q.jsx)(Pi,{asChild:!0,children:(0,Q.jsxs)(O,{variant:i,size:`sm`,title:r,disabled:a,"data-slot":c,className:l,children:[(0,Q.jsx)(Ea,{"aria-hidden":`true`}),n]})}),(0,Q.jsxs)(Fi,{align:`end`,children:[o,o&&e.length>0?(0,Q.jsx)(ji,{}):null,e.map(({target:e,suffix:n,title:r})=>{let i=tv(e);return(0,Q.jsxs)(Ai,{"data-target":e.id,title:r,onSelect:()=>t(e.id),children:[(0,Q.jsx)(i,{"aria-hidden":`true`}),e.label,n??``]},e.id)}),s]})]})}function iv(e){return Ws.flatMap(t=>{let n=e.filter(e=>e.provider===t.id);return n.length<2?[{runner:t,account:null,label:t.label,desc:t.desc,missing:!1}]:n.map(e=>({runner:t,account:e.isDefault?null:e.id,label:`${t.label} · ${e.label}`,desc:e.exists?e.configDir:`${e.configDir} — folder not created yet`,missing:!e.exists}))})}var av=e=>e.length>Ws.length;function ov({rows:e,runner:t,accountFor:n,providerStatus:r,disabled:i=!1,accountDisabled:a=!1,onPick:o}){let s=av(e);return(0,Q.jsx)(`div`,{role:`radiogroup`,"aria-label":`Default runner`,"data-slot":`agents-runner`,className:k(`gap-0.5 rounded-md border border-border bg-card p-0.5`,s?`flex max-w-md flex-col`:`inline-flex w-fit`),children:e.map(c=>{let l=Et(r.data,c.runner.id),u=!r.isPending&&!r.isError&&l?.enabled===!0&&l.status===`connected`,d=r.isPending?`Checking provider authentication…`:r.isError?`Provider authentication could not be verified.`:l?.enabled===!1?`This provider is disabled. Enable it above or choose another provider.`:u?void 0:`Connect this provider before selecting it.`,f=e.filter(e=>e.runner.id===c.runner.id).length>1,p=c.runner.id===t&&c.account===n(c.runner.id);return(0,Q.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":p,"data-value":c.runner.id,"data-account":c.account??``,title:d??c.desc,disabled:i||!u||f&&a,onClick:()=>o(c.runner.id,c.account,f),className:k(`rounded-sm px-3 py-1.5 text-left font-mono text-[13px] font-medium transition-colors disabled:opacity-50`,p?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`),children:[c.label,s?(0,Q.jsx)(`span`,{"data-slot":c.missing?`agents-account-missing`:`agents-account-dir`,"data-runner":c.runner.id,className:`ml-2 font-sans text-[11px] text-soft-foreground`,children:c.desc}):null]},`${c.runner.id}:${c.account??``}`)})})}var sv=`x-apple.systempreferences:com.apple.preference.security?Privacy_FilesAndFolders`,cv=`inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-foreground hover:bg-muted`;function lv(e){let t=e.replace(/[\\/]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n<0?null:n===0?t.slice(0,1):t.slice(0,n)}function uv({path:e,selected:t,onSelect:n,onEnter:r,decorate:i,emptyHint:a,showHidden:o=!1}){let s=Ar(e,o),c=s.data?.parent??null;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{"data-slot":`fs-breadcrumb`,className:`truncate font-mono text-[11px] text-soft-foreground`,title:s.data?.path??void 0,children:s.data?.path??(s.isError?``:`Loading…`)}),s.isError?(0,Q.jsx)(dv,{error:s.error,path:e,onEnter:r,onRetry:()=>void s.refetch()}):(0,Q.jsxs)(`ul`,{"data-slot":`fs-listing`,className:`max-h-64 divide-y divide-border/60 overflow-y-auto overscroll-contain rounded-md border border-border`,children:[c===null?null:(0,Q.jsx)(`li`,{className:`flex`,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`fs-up`,onClick:()=>r(c),className:`flex flex-1 items-center gap-2 px-3 py-2 text-left text-[13px] hover:bg-muted`,children:[(0,Q.jsx)(Vp,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),`Up one level`]})}),(s.data?.dirs??[]).map(e=>(0,Q.jsxs)(`li`,{className:`flex items-stretch`,children:[(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`fs-dir`,"aria-pressed":t?.path===e.path,onClick:()=>n(e),onDoubleClick:()=>r(e.path),className:k(`flex min-w-0 flex-1 items-center gap-2 px-3 py-2 text-left text-[13px] hover:bg-muted`,t?.path===e.path&&`bg-muted`),children:[(0,Q.jsx)(Qp,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.name}),i?.(e)]}),(0,Q.jsx)(`button`,{type:`button`,"data-slot":`fs-enter`,"aria-label":`Open ${e.name}`,onClick:()=>r(e.path),className:`flex shrink-0 items-center px-2.5 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,Q.jsx)(Np,{className:`size-3.5`,"aria-hidden":`true`})})]},e.path)),s.data&&s.data.dirs.length===0?(0,Q.jsx)(`li`,{className:`px-3 py-2 text-[13px] text-muted-foreground`,children:a}):null]}),s.data?.truncated?(0,Q.jsx)(`p`,{"data-slot":`fs-truncated`,className:`text-[11px] text-muted-foreground`,children:`Too many folders to list — only the first ones are shown.`}):null]})}function dv({error:e,path:t,onEnter:n,onRetry:r}){let i=e instanceof Ze&&e.status===403,a=t===null?null:lv(t);return(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Q.jsx)(`p`,{"data-slot":`fs-error`,className:`min-w-0 break-words text-[13px] text-danger`,children:e instanceof Error?e.message:`could not list that folder`}),i?(0,Q.jsx)(`p`,{"data-slot":`fs-privacy-hint`,className:`text-[12.5px] text-soft-foreground`,children:`Allow it under Privacy & Security ▸ Files & Folders, then try again.`}):null,(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-[12.5px]`,children:[a===null?null:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`fs-error-back`,onClick:()=>n(a),className:cv,children:[(0,Q.jsx)(Vp,{className:`size-3.5`,"aria-hidden":!0}),`Back`]}),i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`a`,{"data-slot":`fs-privacy-settings`,href:sv,target:`_blank`,rel:`noreferrer`,className:cv,children:`Open Privacy Settings`}),(0,Q.jsx)(`button`,{type:`button`,"data-slot":`fs-retry`,onClick:r,className:cv,children:`Try again`})]}):null]})]})}function fv(e,t,n=!1){let r=Ar(e,n);return t?.path??r.data?.path??null}var pv={claude:`~/.claude-second`,codex:`~/.codex-second`,pi:`~/.pi-second/agent`,omp:`~/.omp/profiles/second`};function mv({open:e,onOpenChange:t,providers:n,initialProvider:r}){let[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(r??n[0]??`claude`),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(!1),g=Or(),_=f.trim();return(0,Q.jsx)(jo,{open:e,onOpenChange:t,children:(0,Q.jsxs)(Ao,{"data-slot":`add-account-dialog`,className:`sm:max-w-lg`,children:[(0,Q.jsxs)(Po,{children:[(0,Q.jsx)(ko,{children:`Add agent account`}),(0,Q.jsx)(Oo,{children:`The config folder this account uses. It does not have to exist yet — Connect signs in and the CLI creates it.`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-[13px]`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Agent`}),(0,Q.jsx)(`select`,{"aria-label":`Agent`,"data-slot":`add-account-provider`,value:c,onChange:e=>l(e.target.value),className:`rounded-md border border-input bg-card px-2 py-1 text-[13px] outline-none focus-visible:border-ring`,children:n.map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))})]}),(0,Q.jsxs)(`label`,{className:`flex min-w-0 flex-1 items-center gap-2 text-[13px]`,children:[(0,Q.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`Name`}),(0,Q.jsx)(`input`,{type:`text`,"aria-label":`Account name`,"data-slot":`add-account-label`,value:u,placeholder:`Work`,onChange:e=>d(e.target.value),className:`min-w-0 flex-1 rounded-md border border-input bg-card px-2 py-1 text-[13px] outline-none focus-visible:border-ring`})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 text-[13px]`,children:[(0,Q.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`Folder`}),(0,Q.jsx)(`input`,{type:`text`,spellCheck:!1,autoComplete:`off`,"aria-label":`Config folder`,"data-slot":`add-account-dir`,value:f,placeholder:pv[c]??`~/.claude-second`,onChange:e=>{p(e.target.value),s(null),g.reset()},className:`min-w-0 flex-1 rounded-md border border-input bg-card px-2 py-1 font-mono text-[13px] outline-none focus-visible:border-ring`}),(0,Q.jsx)(O,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`add-account-browse`,"aria-expanded":m,onClick:()=>h(e=>!e),children:m?`Hide folders`:`Browse…`})]}),(0,Q.jsxs)(`p`,{className:`text-[11px] text-soft-foreground`,children:[`A `,(0,Q.jsx)(`code`,{children:`~`}),` is kept as written and expanded when the agent runs.`]}),c===`omp`?(0,Q.jsxs)(`p`,{"data-slot":`add-account-omp-hint`,className:`text-[11px] text-soft-foreground`,children:[`An omp account is an omp profile: use `,(0,Q.jsx)(`code`,{children:`~/.omp/profiles/<name>`}),`, with a lowercase name. The profile folder may link to a folder elsewhere.`]}):null]}),m?(0,Q.jsx)(uv,{path:i,selected:o,onSelect:e=>{s(e),p(e.path),g.reset()},onEnter:e=>{a(e),s(null),g.reset()},showHidden:!0,emptyHint:`No subfolders here — pick this folder by typing its path above.`}):null,g.isError?(0,Q.jsx)(`p`,{"data-slot":`add-account-error`,className:`min-w-0 break-words text-[13px] text-danger`,children:g.error instanceof Error?g.error.message:`could not add that folder`}):null,(0,Q.jsxs)(Mo,{className:`min-w-0 sm:items-center sm:justify-end`,children:[(0,Q.jsx)(O,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsx)(O,{"data-slot":`add-account-confirm`,disabled:_===``||g.isPending,onClick:()=>{_===``||g.isPending||g.mutate({provider:c,configDir:_,...u.trim()?{label:u.trim()}:{}},{onSuccess:()=>{t(!1),d(``),p(``),s(null),h(!1),K(`Account added — use Connect to sign in`)}})},children:g.isPending?`Adding…`:`Add account`})]})]})})}function hv(e){let t=(0,Z.useRef)(null),n=e.rows.find(t=>t.runner.id===e.runner&&t.account===e.accountFor(t.runner.id));return(0,Q.jsxs)(`details`,{ref:t,className:`settings-agent-picker`,children:[(0,Q.jsxs)(`summary`,{children:[(0,Q.jsx)(mo,{"aria-hidden":`true`,className:`size-4 text-accent-text`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1`,children:(n?.label??e.runner).replace(/^codex/,`Codex`).replace(/^claude/,`Claude Code`)}),(0,Q.jsx)(So,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`})]}),(0,Q.jsx)(ov,{...e,onPick:(...n)=>{e.onPick(...n),t.current&&(t.current.open=!1)}})]})}var gv={claude:`Claude Code`,codex:`Codex`,opencode:`OpenCode`,pi:`pi`,cursor:`Cursor`,omp:`OMP`},_v={claude:`npm i -g @anthropic-ai/claude-code`,codex:`npm i -g @openai/codex`,opencode:`https://opencode.ai`,pi:`https://github.com/badlogic/pi-mono`,cursor:`https://cursor.com/docs/cli/installation`,omp:`https://omp.sh`},vv={connected:{label:`Connected`,tone:`success`},disconnected:{label:`Not connected`,tone:`pending`},"not-installed":{label:`Not installed`,tone:`neutral`},unknown:{label:`Could not verify`,tone:`danger`}};function yv(){let e=Bn();return e.isPending?(0,Q.jsx)(`p`,{"data-slot":`accounts-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading agent accounts…`}):e.isError?(0,Q.jsx)(X,{icon:(0,Q.jsx)(am,{}),tone:`danger`,title:`Agent accounts did not load`,subtitle:e.error.message,heading:`h2`}):(0,Q.jsx)(bv,{data:e.data})}function bv({data:e}){let t=mn(),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(null),o=Cr(),s=[`claude`,`codex`,`opencode`,`pi`,`cursor`,`omp`];return e.editable?(0,Q.jsxs)(`div`,{"data-slot":`accounts-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-5 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,Q.jsx)(`div`,{children:(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Manage runner installations, logins and defaults for new projects.`})}),(0,Q.jsxs)(Y_,{defaultValue:`claude`,children:[(0,Q.jsx)(Z_,{variant:`line`,"data-slot":`accounts-tabs`,children:s.map(e=>(0,Q.jsx)(Q_,{value:e,"data-provider":e,children:gv[e]},e))}),s.map(n=>(0,Q.jsx)($_,{value:n,className:`pt-4`,children:(0,Q.jsx)(xv,{provider:n,check:t.data?.checks?.find(e=>e.name===n),accounts:e.profiles.filter(e=>e.provider===n),canCarryAccounts:e.profileCapableProviders.includes(n),defaultAccountId:e.defaults[n]??null,onAdd:()=>r(n),onRemove:a})},n))]}),(0,Q.jsx)(Sv,{profiles:e}),n===null?null:(0,Q.jsx)(mv,{open:!0,onOpenChange:e=>!e&&r(null),providers:e.profileCapableProviders,initialProvider:n},n),(0,Q.jsx)(ra,{open:i!==null,onOpenChange:e=>!e&&a(null),children:(0,Q.jsxs)(Yi,{"data-slot":`accounts-remove-confirm`,children:[(0,Q.jsxs)(na,{children:[(0,Q.jsxs)(Wi,{children:[`Remove “`,i?.label,`”?`]}),(0,Q.jsxs)(Ui,{children:[`This only forgets the account. Nothing in `,i?.configDir,` is deleted — not your login, not your sessions. Projects using it fall back to the default account, and tasks that ran under it can no longer be resumed from here.`]})]}),(0,Q.jsxs)($i,{children:[(0,Q.jsx)(ta,{children:`Cancel`}),(0,Q.jsx)(Qi,{"data-action":`accounts-remove-confirm`,disabled:o.isPending,onClick:()=>{let e=i;e&&o.mutate(e.id,{onSuccess:()=>{a(null),K(`Removed ${e.label}`)},onError:e=>K(e.message,{tone:`danger`})})},children:`Remove`})]})]})})]}):(0,Q.jsx)(`div`,{"data-slot":`accounts-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-4 p-4 md:p-6`,children:(0,Q.jsx)(`p`,{"data-slot":`accounts-hosted`,className:`text-[13px] text-soft-foreground`,children:`Agent accounts are managed from the machine that owns the checkout — this cockpit runs in hosted mode.`})})}function xv({provider:e,check:t,accounts:n,canCarryAccounts:r,defaultAccountId:i,onAdd:a,onRemove:o}){let s=t?.available===!0,c=n.filter(e=>e.isDefault).length;return(0,Q.jsxs)(`div`,{"data-slot":`accounts-provider`,"data-provider":e,className:`flex flex-col gap-4`,children:[(0,Q.jsx)(`h3`,{className:`settings-account-provider-title`,children:gv[e]}),(0,Q.jsxs)(`div`,{className:`settings-account-installation settings-readout`,children:[t===void 0?(0,Q.jsx)(`span`,{children:`Checking…`}):s?(0,Q.jsx)(`span`,{"data-slot":`agent-installed`,children:`Installed`}):(0,Q.jsxs)(`span`,{"data-slot":`agent-installed`,children:[`Not installed — `,(0,Q.jsx)(`code`,{children:_v[e]})]}),s&&t?.version?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:` · `}),(0,Q.jsx)(`span`,{"data-slot":`agent-version`,children:t.version})]}):null,(0,Q.jsxs)(`span`,{className:`settings-account-count`,children:[n.length,` `,n.length===1?`account`:`accounts`,` (`,c,` discovered, `,n.length-c,` added)`]})]}),(0,Q.jsx)(`ul`,{className:`bg-card`,children:[...n].sort((e,t)=>Number(t.id===i)-Number(e.id===i)).map(e=>(0,Q.jsx)(Cv,{account:e,isMachineDefault:i===e.id||i===null&&e.isDefault,onRemove:()=>o(e)},e.id))}),r?(0,Q.jsx)(`div`,{className:`settings-account-add-row`,children:(0,Q.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,"data-action":`accounts-add`,"data-provider":e,onClick:a,children:`Add account`})}):null,r?null:(0,Q.jsxs)(`p`,{"data-slot":`accounts-single-only`,className:`text-[11px] text-soft-foreground`,children:[gv[e],` can only hold one account here: it keeps its credentials outside its config folder, so a second folder would change settings without changing the login — which would say “work account” while billing the other one.`]})]})}function Sv({profiles:e}){let[t,n]=(0,Z.useState)(null),r=z(),i=Lr(),a=Kn(),o=Mr(),s=ar(),c=V({mutationFn:e=>gt(e),onSuccess:e=>r.setQueryData(B.config,e),onError:e=>K(e.message,{tone:`danger`})});if(i.data===void 0)return null;let l=iv(e.profiles),u=i.data.agentDefaults.runner??`claude`,d=i.data.agentDefaults.models??{};return(0,Q.jsxs)(`section`,{"data-slot":`accounts-defaults`,className:`flex flex-col gap-3 rounded-lg border border-border bg-card/40 p-3.5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-[13px] font-semibold text-foreground`,children:`Defaults for new projects`}),(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`What a project runs when it has not chosen for itself — set once instead of per repository. A project that has chosen keeps its own.`})]}),(0,Q.jsx)(hv,{rows:l,runner:u,accountFor:t=>e.defaults[t]??null,providerStatus:a,disabled:c.isPending,accountDisabled:s.isPending,onPick:(e,t,n)=>{e!==u&&c.mutate({agentDefaults:{runner:e}}),n&&s.mutate({projectId:null,provider:e,profileId:t},{onError:e=>K(e.message,{tone:`danger`})})}}),(0,Q.jsxs)(`div`,{className:`settings-account-models flex flex-col gap-2`,children:[(0,Q.jsxs)(`label`,{className:`settings-model-agent-choice`,children:[(0,Q.jsx)(`span`,{children:`Default model for`}),(0,Q.jsx)(`select`,{"aria-label":`Model agent`,value:t??u,onChange:e=>n(e.target.value),children:Ws.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:gv[e.id]},e.id))})]}),Ws.filter(e=>e.id===(t??u)).map(e=>(0,Q.jsxs)(`label`,{className:`settings-account-model flex items-center gap-3`,children:[(0,Q.jsx)(Xa,{className:`size-4 text-accent-icon shrink-0`}),(0,Q.jsx)(`span`,{className:`w-24 shrink-0 text-xs text-muted-foreground`,children:gv[e.id]}),(0,Q.jsxs)(`select`,{"aria-label":`Default model for ${e.label}`,"data-slot":`accounts-default-model`,"data-runner":e.id,value:d[e.id]??``,disabled:c.isPending,onChange:t=>c.mutate({agentDefaults:{models:{[e.id]:t.target.value||null}}}),className:`block w-full max-w-xs rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[Gs(e.id,o[e.id].data,[d[e.id]]).map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.id===``?`Native default`:e.label},e.id)),Js(e.id,o[e.id].data,o[e.id].isError,o[e.id].isFetching)?(0,Q.jsx)(`option`,{disabled:!0,children:Js(e.id,o[e.id].data,o[e.id].isError,o[e.id].isFetching)}):null]})]},e.id))]})]})}function Cv({account:e,isMachineDefault:t,onRemove:n}){let[r,i]=(0,Z.useState)(!1),a=ec(e),o=Jn(),s=fr(),c=Fn(a,e.status===void 0),l=e.status??c.data?.status,u=l?vv[l.status]:void 0;return(0,Q.jsxs)(`li`,{"data-slot":`account-row`,"data-account":e.id,className:`flex flex-col gap-2 px-3.5 py-3`,children:[(0,Q.jsxs)(`div`,{className:`settings-account-card`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[13px] font-medium text-foreground`,children:e.label}),e.isDefault?(0,Q.jsx)(Pf,{variant:`ghost`,className:`shrink-0 text-[12px] text-muted-foreground`,children:`discovered`}):null]}),t&&(0,Q.jsx)(`p`,{className:`settings-account-default-note`,children:`Default account for new projects. Credentials are not displayed.`}),(0,Q.jsxs)(`div`,{className:`settings-account-readout settings-readout`,children:[(0,Q.jsx)(`p`,{"data-slot":`account-path`,className:`mt-0.5 truncate font-mono text-[11px] text-soft-foreground`,title:e.path,children:e.configDir}),(0,Q.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(J_,{tone:u?.tone??`neutral`,pulse:u===void 0}),(0,Q.jsx)(`span`,{"data-slot":`account-status`,children:u?.label??`Checking…`}),e.exists?e.looksValid?null:(0,Q.jsxs)(`span`,{"data-slot":`account-unrecognised`,children:[`— this folder does not look like `,gv[e.provider],` config yet`]}):(0,Q.jsx)(`span`,{"data-slot":`account-missing`,children:`— folder not created yet; Connect will make it`})]})]})]}),(0,Q.jsxs)(`div`,{className:`settings-account-actions`,children:[l?.status===`connected`?null:(0,Q.jsx)(O,{type:`button`,size:`sm`,"data-action":`account-connect`,disabled:o.isPending,onClick:()=>o.mutate({provider:e.provider,...e.isDefault?{}:{profileId:e.id}},{onSuccess:e=>K(e.opened?`Finish signing in in the terminal, then Check again.`:`This account is already connected.`),onError:e=>K(e instanceof Ze&&e.command?`${e.message} — run: ${e.command}`:e.message,{tone:`danger`})}),children:`Connect`}),(0,Q.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-recheck`,disabled:s.isPending,title:`Re-probe this account's login now, instead of waiting for the cached answer`,onClick:()=>s.mutate(a,{onError:e=>K(e.message,{tone:`danger`})}),children:`Check again`}),(0,Q.jsx)(Tv,{account:e,onRemove:n}),(0,Q.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-details-toggle`,"aria-expanded":r,onClick:()=>i(e=>!e),children:r?`Hide details`:`Show details`})]})]}),r?(0,Q.jsx)(wv,{account:e,routeId:a}):null]})}function wv({account:e,routeId:t}){let n=er(t,!0),r=wn(),i=$t().data?.targets??[],a=i.filter(e=>nv(e.id)===void 0&&e.id!==`terminal`&&e.id!==`finder`).map(e=>({target:e})),o=i.filter(e=>nv(e.id)===void 0).map(e=>({target:e})),s=(e,n,i)=>r.mutate({routeId:t,file:e,...i?{target:i}:{}},{onError:e=>K(e.message,{tone:`danger`}),onSuccess:()=>K(`Opened ${n}`)});return(0,Q.jsxs)(`div`,{"data-slot":`account-details`,className:`rounded-md border border-border/60 bg-muted/30 p-3`,children:[n.isPending?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Reading account details…`}):n.isError?(0,Q.jsx)(`p`,{"data-slot":`account-details-error`,className:`text-xs text-danger`,children:n.error.message}):n.data.available?(0,Q.jsx)(`dl`,{"data-slot":`account-identity`,className:`grid grid-cols-[7rem_minmax(0,1fr)] gap-x-3 gap-y-1 text-xs`,children:n.data.fields.map(e=>(0,Q.jsxs)(Z.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,Q.jsx)(`dd`,{className:`min-w-0 truncate text-foreground`,title:e.value,children:e.value})]},e.label))}):(0,Q.jsx)(`p`,{"data-slot":`account-identity-unavailable`,className:`text-xs text-muted-foreground`,children:n.data.reason??`No account details to show.`}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5 border-t border-border/60 pt-2.5`,children:[(0,Q.jsx)(`span`,{className:`mr-1 text-xs text-muted-foreground`,children:`Config files`}),e.files.map(e=>(0,Q.jsx)(rv,{slot:`account-open-file`,label:e.label,triggerVariant:`outline`,disabled:r.isPending,title:e.exists?e.path:`${e.path} — not created yet`,choices:a,onPick:t=>s(e.id,e.label,t),leading:(0,Q.jsxs)(Ai,{"data-target":`system`,onSelect:()=>s(e.id,e.label),children:[(0,Q.jsx)(Ea,{"aria-hidden":`true`}),`System default`]})},e.id)),(0,Q.jsx)(rv,{slot:`account-open-folder`,label:`Folder`,disabled:r.isPending,title:e.path,choices:o,onPick:e=>s(`folder`,`folder`,e),leading:(0,Q.jsxs)(Ai,{"data-target":`system`,onSelect:()=>s(`folder`,`folder`),children:[(0,Q.jsx)(Ea,{"aria-hidden":`true`}),`System default`]})})]})]})}function Tv({account:e,onRemove:t}){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(e.label),o=Xt();return(0,Q.jsx)(Q.Fragment,{children:e.isDefault?null:(0,Q.jsx)(`div`,{"data-slot":`account-manage`,className:`settings-account-management`,children:n?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`input`,{type:`text`,autoFocus:!0,"aria-label":`Name for ${e.label}`,"data-slot":`account-rename-input`,value:i,onChange:e=>a(e.target.value),className:`w-48 rounded-md border border-input bg-card px-2 py-1 text-xs outline-none focus-visible:border-ring`}),(0,Q.jsx)(O,{type:`button`,size:`sm`,"data-action":`account-rename-save`,disabled:o.isPending||i.trim()===``||i.trim()===e.label,onClick:()=>o.mutate({id:e.id,label:i.trim()},{onSuccess:()=>r(!1),onError:e=>K(e.message,{tone:`danger`})}),children:`Save`}),(0,Q.jsx)(O,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{a(e.label),r(!1)},children:`Cancel`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-rename`,onClick:()=>r(!0),children:`Rename`}),(0,Q.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-remove`,onClick:t,children:`Remove account`}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Renaming changes what cezar calls this account, not its folder.`})]})})})}var Ev=1500;function Dv(e,t){let n=(0,Z.useMemo)(()=>e.split(`
5
+ `).map(e=>[{content:e}]),[e]),r=(0,Z.useMemo)(()=>mc(t),[t]),i=n.length>Ev,[a,o]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{if(r===null||i)return;let t=!1;return gc(e,r).then(n=>{t||o({key:e,tokens:n.tokens})}),()=>{t=!0}},[e,r,i]),r===null||i?n:a?.key===e?a.tokens:hc(e,r)?.tokens??n}var Ov=`code-editor-surface m-0 min-h-full w-full whitespace-pre font-mono text-xs leading-[1.7] px-3 py-2 [tab-size:2]`;function kv({value:e,onChange:t,language:n,readOnly:r,className:i,...a}){let o=Dv(e,n),s=(0,Z.useRef)(null),c=(0,Z.useRef)(null),l=()=>{let e=c.current,t=s.current;!e||!t||(t.scrollTop=e.scrollTop,t.scrollLeft=e.scrollLeft)};return(0,Z.useLayoutEffect)(l,[e]),(0,Q.jsxs)(`div`,{"data-slot":`code-editor`,className:k(`relative overflow-hidden rounded-md border border-input bg-card`,i),children:[(0,Q.jsx)(`pre`,{ref:s,"aria-hidden":`true`,className:k(Ov,`pointer-events-none absolute inset-0 overflow-auto text-soft-foreground`),children:o.map((e,t)=>(0,Q.jsx)(`span`,{className:`block`,children:e.length===0?`
6
+ `:(0,Q.jsxs)(Q.Fragment,{children:[e.map((e,t)=>(0,Q.jsx)(`span`,{style:e.color===void 0?void 0:{color:e.color},children:e.content},t)),`
7
+ `]})},t))}),(0,Q.jsx)(`textarea`,{ref:c,"data-slot":`code-editor-input`,value:e,readOnly:r,onChange:e=>t?.(e.target.value),onScroll:l,spellCheck:!1,autoCorrect:`off`,autoCapitalize:`off`,autoComplete:`off`,wrap:`off`,className:k(Ov,`relative block resize-none overflow-auto bg-transparent text-transparent caret-foreground outline-hidden`,`selection:bg-accent-strong/30 focus-visible:ring-0`,r&&`cursor-default`),...a})]})}var Av=`An editor-plus-commit: a saved change reaches a run after you commit it to the base branch.`;function jv(e){return t=>t.runners.includes(e)}function Mv(e,t,n,r,i){let a=jv(e),o=t===`mcp`?e=>a(e)&&(e.holdsMcp===!0||e.kind===`mcp`):e=>a(e)&&e.kind===t;return{id:t,label:n,note:r,...i?{empty:i}:{},files:o}}var Nv=[{id:`claude`,label:`Claude`,groups:[Mv(`claude`,`settings`,`Settings`),Mv(`claude`,`mcp`,`MCP`,`A dedicated .mcp.json (key: mcpServers), shared via version control.`),Mv(`claude`,`memory`,`Memory & instructions`)]},{id:`codex`,label:`Codex`,note:Av,groups:[Mv(`codex`,`settings`,`Settings`),Mv(`codex`,`mcp`,`MCP`,`Inside config.toml under [mcp_servers.<id>] — the same file as Codex’s settings.`),Mv(`codex`,`memory`,`Memory & instructions`)]},{id:`opencode`,label:`OpenCode`,note:Av,groups:[Mv(`opencode`,`settings`,`Settings`),Mv(`opencode`,`mcp`,`MCP`,`Under the "mcp" key in opencode.json — the same file as OpenCode’s settings.`),Mv(`opencode`,`memory`,`Memory & instructions`)]},{id:`pi`,label:`Pi`,note:Av,groups:[Mv(`pi`,`settings`,`Settings`),Mv(`pi`,`mcp`,`MCP`,`Pi ships no MCP client, so it has no MCP file to edit.`,`Nothing to list: Pi’s README says "No MCP." Give Pi tools as CLI programs with a README (Pi skills), or install a Pi extension that adds MCP support and configure servers there.`),Mv(`pi`,`memory`,`Memory & instructions`)]},{id:`cursor`,label:`Cursor`,note:Av,groups:[Mv(`cursor`,`settings`,`Settings`),Mv(`cursor`,`mcp`,`MCP`,`Cursor CLI uses the editor’s MCP configuration.`),Mv(`cursor`,`memory`,`Memory & instructions`,`Cursor also reads CLAUDE.md and .cursor/rules.`)]},{id:`omp`,label:`OMP`,note:Av,groups:[Mv(`omp`,`settings`,`Settings`),Mv(`omp`,`mcp`,`MCP`,`A dedicated mcp.json (key: mcpServers) at ~/.omp/agent and in the project’s .omp/ folder.`),Mv(`omp`,`memory`,`Memory & instructions`)]}];function Pv(e){let t=Nv.find(t=>t.id===e);if(!t)throw Error(`no agent descriptor for ${e}`);return t}function Fv(){let e=z(),t=(0,Z.useCallback)(async()=>{await Promise.all([e.invalidateQueries({queryKey:H.health}),e.invalidateQueries({queryKey:H.agentConfig,exact:!0})])},[e]);return(0,Z.useEffect)(()=>{t()},[t]),t}var Iv=`cez remote-settings enable`;function Lv({risk:e}){return mn().data?.capabilities?.remoteSettingsAdmin===!0?(0,Q.jsxs)(`p`,{role:`note`,"data-slot":`remote-settings-notice`,className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-[13px] text-foreground`,children:[`Remote settings administration is on. `,e,`, and anyone who can open this cockpit can change them. The host operator turns this off with`,` `,(0,Q.jsx)(`code`,{children:`cez remote-settings disable`}),`.`]}):null}function Rv(e){return e.seeded?`Copied into each run’s worktree — takes effect on your next run.`:e.tracked===`tracked`?`Runs read the committed copy — this edit applies after you commit it.`:e.tracked===`outside-repo`?`Applies to every session on this machine.`:`Personal, git-ignored.`}function zv(){let e=pr();Fv();let t=mn(),n=(0,Z.useMemo)(()=>t.data?Qs(t.data.checks):Nv.map(e=>e.id),[t.data]);return e.isPending?(0,Q.jsx)(`p`,{"data-slot":`agent-config-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading agent config…`}):e.isError?(0,Q.jsx)(X,{icon:(0,Q.jsx)(Jp,{}),tone:`danger`,title:`Agent config did not load`,subtitle:e.error.message,heading:`h2`}):(0,Q.jsx)(Bv,{listing:e.data,installed:n})}function Bv({listing:e,installed:t}){let[n,r]=(0,Z.useState)(`claude`),[i,a]=(0,Z.useState)(null),o=Pv(n),s=e.files.find(e=>e.id===i)??null,c=e=>{r(e),a(null)};return(0,Q.jsxs)(`div`,{"data-slot":`agent-config`,className:`flex flex-col gap-5 p-4 md:p-6`,children:[(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Edit agent instructions and MCP configuration for this project.`}),!e.editable&&(0,Q.jsxs)(`div`,{"data-slot":`agent-config-readonly`,className:`rounded-md border border-border bg-muted/40 px-3 py-2 text-[13px] text-soft-foreground`,children:[`Read-only: this remote cockpit cannot edit agent config. You can still see every file and which one wins. To edit here, the host operator runs `,(0,Q.jsx)(`code`,{children:`cez remote-settings enable`}),`.`]}),(0,Q.jsx)(Lv,{risk:`Agent config can define hooks and MCP servers that run commands on the machine running Cezarion`}),(0,Q.jsx)(`div`,{"data-slot":`agent-config-agents`,role:`tablist`,className:`flex flex-wrap gap-1`,children:Nv.map(e=>(0,Q.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":e.id===o.id,"data-slot":`agent-config-agent`,"data-agent":e.id,"data-selected":e.id===o.id,onClick:()=>c(e.id),className:k(`flex min-w-11 items-center justify-center gap-2 rounded-md px-3 py-1.5 text-[13px] transition-colors`,e.id===o.id?`bg-background font-semibold shadow-sm`:`hover:bg-muted/60`),children:[e.label,!t.includes(e.id)&&(0,Q.jsx)(Pf,{variant:`outline`,className:`text-[12px] text-soft-foreground`,children:`not installed`})]},e.id))}),o.note&&(0,Q.jsx)(`p`,{"data-slot":`agent-config-agent-note`,className:`text-[12px] text-soft-foreground`,children:o.note}),(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-6 lg:grid-cols-[minmax(0,20rem)_minmax(0,1fr)]`,children:[(0,Q.jsx)(`nav`,{"data-slot":`agent-config-nav`,className:`flex min-w-0 flex-col gap-5`,children:(0,Q.jsx)(Vv,{agent:o,listing:e,selectedId:i,onSelect:a})}),(0,Q.jsx)(`div`,{"data-slot":`agent-config-editor-pane`,className:`min-w-0`,children:s?(0,Q.jsx)(Uv,{file:s},s.id):(0,Q.jsx)(`div`,{className:`flex h-full min-h-40 items-center justify-center rounded-md border border-dashed border-border text-[13px] text-soft-foreground`,children:`Select a config file to view or edit it.`})})]})]})}function Vv({agent:e,listing:t,selectedId:n,onSelect:r}){return(0,Q.jsx)(Q.Fragment,{children:e.groups.map(i=>{let a=t.files.filter(i.files),o=e.id===`claude`&&i.id===`mcp`;return a.length===0&&!(o&&t.userMcp)&&!i.empty?null:(0,Q.jsxs)(`section`,{"data-slot":`agent-config-group`,"data-group":i.id,"data-agent":e.id,children:[(0,Q.jsx)(`p`,{className:`mb-1 text-[11px] font-medium uppercase tracking-wide text-soft-foreground`,children:i.label}),i.note&&(0,Q.jsx)(`p`,{className:`mb-2 text-[12px] text-soft-foreground`,children:i.note}),a.length===0&&i.empty&&(0,Q.jsx)(`p`,{"data-slot":`agent-config-group-empty`,className:`rounded-md border border-dashed border-border px-3 py-2 text-[12px] text-soft-foreground`,children:i.empty}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1`,children:a.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`agent-config-file`,"data-selected":e.id===n,onClick:()=>r(e.id),className:k(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[13px] transition-colors`,e.id===n?`bg-accent-strong/15 text-foreground`:`hover:bg-muted/60`),children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[12px]`,children:e.label}),e.seeded&&(0,Q.jsx)(Pf,{variant:`outline`,className:`shrink-0 text-[12px]`,children:`seeded`}),!e.exists&&(0,Q.jsx)(`span`,{className:`shrink-0 text-[11px] text-soft-foreground`,children:`absent`})]})},e.id))}),o&&t.userMcp&&(0,Q.jsx)(Hv,{userMcp:t.userMcp})]},i.id)})})}function Hv({userMcp:e}){return(0,Q.jsxs)(`div`,{"data-slot":`agent-config-user-mcp`,className:`mt-3`,children:[(0,Q.jsx)(`h4`,{className:`mb-1 text-[12px] font-semibold`,children:`User & local scopes`}),(0,Q.jsxs)(`p`,{className:`mb-2 text-[12px] text-soft-foreground`,children:[`Managed by `,(0,Q.jsx)(`code`,{className:`font-mono`,children:`claude mcp add`}),` in `,e.path,` — cezar does not edit Claude’s state file.`]}),e.readable?e.servers.length>0?(0,Q.jsx)(`ul`,{className:`flex flex-wrap gap-1`,children:e.servers.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsx)(Pf,{variant:`outline`,className:`font-mono text-[11px]`,children:e})},e))}):(0,Q.jsx)(`p`,{className:`text-[12px] text-soft-foreground`,children:`No user-scoped MCP servers.`}):(0,Q.jsx)(`p`,{className:`text-[12px] text-soft-foreground`,children:`Could not read the file.`})]})}function Uv({file:e}){let t=xr(e.id),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(null),c=t.data?.version??null,l=n??t.data?.content??``,u=t.data?l!==t.data.content:!1,d=e.writable,{save:f,isSaving:p}=Kv({file:e,content:l,loadedVersion:c,setDraft:r,setConflict:a,setFormatError:s});return(0,Z.useEffect)(()=>{t.data&&(r(t.data.content),a(!1),s(null))},[t.data?.version,t.data]),(0,Q.jsxs)(`div`,{"data-slot":`settings-config-editor`,className:`flex flex-col gap-3`,children:[(0,Q.jsx)(`h3`,{className:`text-sm`,children:`Configuration file`}),(0,Q.jsxs)(`p`,{"data-slot":`agent-config-scope`,title:e.path,className:`text-[12px] text-muted-foreground break-words`,children:[e.scope.charAt(0).toUpperCase()+e.scope.slice(1),` scope · `,e.path]}),(0,Q.jsxs)(`div`,{className:`settings-readout flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`font-mono text-[13px]`,children:e.label}),(0,Q.jsx)(Pf,{variant:`outline`,className:`text-[12px] uppercase`,children:e.format}),(0,Q.jsx)(`a`,{href:e.docsUrl,target:`_blank`,rel:`noreferrer`,className:`text-[12px] text-soft-foreground underline hover:text-foreground`,children:`docs`})]}),(0,Q.jsxs)(`div`,{className:`settings-config-content-heading`,children:[(0,Q.jsx)(`h3`,{children:e.kind===`mcp`||e.holdsMcp?`MCP configuration`:`File contents`}),(e.kind===`mcp`||e.holdsMcp)&&(0,Q.jsx)(`p`,{children:`Review server commands before saving. MCP servers execute locally.`})]}),t.isPending?(0,Q.jsx)(`p`,{className:`text-[13px] text-soft-foreground`,children:`Loading file…`}):t.isError?(0,Q.jsx)(`p`,{className:`text-[13px] text-destructive`,children:t.error.message}):(0,Q.jsx)(kv,{value:l,language:e.format,readOnly:!d,onChange:r,"aria-label":`${e.label} contents`,className:`h-[210px]`}),(0,Q.jsx)(Wv,{formatError:o,conflict:i,onReload:()=>void t.refetch()}),d&&(0,Q.jsxs)(`div`,{className:`settings-form-actions`,children:[(0,Q.jsx)(O,{size:`sm`,onClick:f,disabled:!u||p,children:e.exists?`Save file`:`Create file`}),(0,Q.jsx)(O,{size:`sm`,variant:`outline`,onClick:()=>r(null),disabled:!u||p,children:`Reset`}),u&&(0,Q.jsx)(`span`,{className:`text-[12px] text-soft-foreground`,children:`Unsaved changes`})]}),(0,Q.jsxs)(`div`,{className:`settings-config-save-help`,children:[(0,Q.jsx)(`p`,{"data-slot":`agent-config-precedence`,className:`text-[12px] text-soft-foreground`,children:e.precedence}),(0,Q.jsxs)(`p`,{"data-slot":`agent-config-effect`,className:`text-[12px] text-foreground/80`,children:[Rv(e),e.hotReload?` ${e.hotReload}`:``]}),(0,Q.jsx)(Gv,{reason:e.readOnlyReason})]})]})}function Wv({formatError:e,conflict:t,onReload:n}){return(0,Q.jsxs)(Q.Fragment,{children:[e&&(0,Q.jsx)(`p`,{"data-slot":`agent-config-format-error`,className:`text-[12px] text-destructive`,children:e}),t&&(0,Q.jsxs)(`div`,{"data-slot":`agent-config-conflict`,className:`flex items-center justify-between gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px]`,children:[(0,Q.jsx)(`span`,{children:`The file changed on disk since you opened it.`}),(0,Q.jsx)(O,{size:`sm`,variant:`outline`,onClick:n,children:`Reload from disk`})]})]})}function Gv({reason:e}){return e&&(0,Q.jsx)(`p`,{children:e})}function Kv({file:e,content:t,loadedVersion:n,setDraft:r,setConflict:i,setFormatError:a}){let o=Er(e.id),s=z(),c=Fv();return{save:()=>{a(null),i(!1),o.mutate({content:t,version:n},{onSuccess:()=>{r(null),K(`${e.exists?`Saved`:`Created`} ${e.label}`)},onError:e=>{e instanceof Ze&&e.status===409?c().then(()=>{s.getQueryData(H.health)?.capabilities.settingsAdmin===!1?K(e.message,{tone:`danger`}):i(!0)}):e instanceof Ze&&e.status===400?a(e.message):K(e.message,{tone:`danger`})}})},isSaving:o.isPending}}var qv=[{id:`claude`,label:`Claude Code`,login:`claude auth login`},{id:`codex`,label:`Codex`,login:`codex login`},{id:`opencode`,label:`OpenCode`,login:`opencode auth login`},{id:`pi`,label:`pi`,login:`pi /login`},{id:`cursor`,label:`Cursor`,login:`agent login`},{id:`omp`,label:`OMP`,login:`omp login`}],Jv=e=>({claude:e,codex:e,opencode:e,pi:e,cursor:e,omp:e}),Yv={connected:{label:`Credentials found`,tone:`success`},disconnected:{label:`Not connected`,tone:`pending`},"not-installed":{label:`Not installed`,tone:`neutral`},unknown:{label:`Could not verify`,tone:`danger`}};function Xv(e,t,n){return{providers:e.providers.map(e=>e.provider===t?{...e,enabled:n}:e)}}function Zv(){let e=Kn(),t=Ln(),n=$n(),r=z(),[i,a]=(0,Z.useState)(null),o=(0,Z.useRef)(Promise.resolve()),s=(0,Z.useRef)(Jv(0)),c=(0,Z.useRef)(Jv(0)),l=(0,Z.useRef)(e.data);(0,Z.useEffect)(()=>{i&&Et(e.data,i.provider)?.status===`connected`&&a(null)},[i,e.data]),(0,Z.useEffect)(()=>{if(e.data){if(Object.values(c.current).every(e=>e===0)||!l.current){l.current=e.data;return}l.current={providers:e.data.providers.map(e=>({...e,enabled:c.current[e.provider]>0?Et(l.current,e.provider)?.enabled??e.enabled:e.enabled}))}}},[e.data]);let u=(0,Z.useCallback)((e,t)=>{let n=B.providerStatus,i=r.getQueryData(n);if(!i)return;l.current||=i;let a=Xv(i,e,t);c.current[e]+=1,r.setQueryData(n,a);let u=++s.current[e];o.current=o.current.then(async()=>{try{let i=await ne(e,t),a=Et(i,e)?.enabled;if(a===void 0)return;if(l.current=Xv(l.current??i,e,a),u===s.current[e]){let t=r.getQueryData(n);r.setQueryData(n,t?Xv(t,e,a):i)}}catch(t){if(u===s.current[e]){let i=Et(l.current,e)?.enabled,a=r.getQueryData(n);a&&i!==void 0?r.setQueryData(n,Xv(a,e,i)):l.current?r.setQueryData(n,l.current):r.removeQueries({queryKey:n,exact:!0}),K(t instanceof Error?t.message:String(t),{tone:`danger`})}}finally{--c.current[e]}})},[r]),d=V({mutationFn:e=>Re(e),onSuccess:async(e,t)=>{a(null),K(e.opened?`Finish signing in in the terminal, then check again.`:`Provider is already connected.`),await r.invalidateQueries({queryKey:B.providerStatus}),Vr(t)&&await wr(r,t,`none`)},onError:(e,t)=>{if(e instanceof Ze&&e.command){let n=qv.find(e=>e.id===t)?.label??t;a({provider:t,label:n,message:e.message,command:e.command});return}K(e.message,{tone:`danger`})}}),f=async e=>{try{await navigator.clipboard.writeText(e),K(`Command copied`)}catch{K(`Could not copy the command`,{tone:`danger`})}};return(0,Q.jsxs)(`section`,{id:`providers`,"data-slot":`provider-settings`,className:`scroll-mt-20`,children:[(0,Q.jsxs)(`div`,{className:`mb-2`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Providers`}),(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Connect the coding agents available on this computer.`})]}),e.isError?(0,Q.jsxs)(`div`,{role:`alert`,className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border border-danger/30 bg-danger/5 px-3 py-2.5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[13px] font-medium text-foreground`,children:`Provider status could not be loaded`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.error.message})]}),(0,Q.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,disabled:e.isFetching,onClick:()=>void e.refetch(),children:`Retry`})]}):null,(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:qv.map(r=>{let a=Et(e.data,r.id),o=a?.status,s=o?Yv[o]:e.isPending?{label:`Checking…`,tone:`neutral`}:Yv.unknown,c=d.isPending&&d.variables===r.id,l=o===`disconnected`||o===`unknown`,p=a?.authFailureId;return(0,Q.jsxs)(Z.Fragment,{children:[(0,Q.jsxs)(`div`,{"data-slot":`provider-card`,"data-provider":r.id,className:`rounded-md border border-border bg-card px-3.5 py-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h3`,{className:`text-[13px] font-semibold text-foreground`,children:r.label}),(0,Q.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(J_,{tone:s.tone,pulse:e.isPending}),(0,Q.jsx)(`span`,{children:s.label}),a?.enabled===!1?(0,Q.jsx)(`span`,{children:`Disabled`}):null]}),o===`not-installed`?(0,Q.jsxs)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:[`Install `,r.label,`, then run `,(0,Q.jsx)(`code`,{children:r.login}),`.`]}):o===`unknown`||e.isError&&!o?(0,Q.jsx)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:`Verification failed. Check again when the provider is available.`}):a?.hint?(0,Q.jsx)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:a.hint}):null]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[o===`not-installed`?null:(0,Q.jsx)(oa,{checked:a?.enabled??!0,"aria-label":`Use ${r.label}`,onCheckedChange:e=>u(r.id,e)}),l?(0,Q.jsx)(O,{type:`button`,variant:`ghost`,size:`sm`,disabled:t.isPending,onClick:()=>t.mutate(void 0,{onError:e=>K(e.message,{tone:`danger`})}),children:`Check again`}):null,o===`disconnected`?(0,Q.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,disabled:d.isPending,onClick:()=>d.mutate(r.id),children:c?`Opening…`:`Connect`}):null,p===void 0?null:(0,Q.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,disabled:n.isPending,onClick:()=>n.mutate({provider:r.id,authFailureId:p},{onSuccess:()=>K(`${r.label} can be tried again.`),onError:e=>K(e.message,{tone:`danger`})}),children:`Try again`})]})]}),p===void 0?null:(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`Use this after completing the provider sign-in flow. cezar cannot validate the credential without a task/model request; it will verify it on the next task.`})]}),i?.provider===r.id&&o!==`connected`?(0,Q.jsxs)(`div`,{role:`region`,"aria-label":`${i.label} manual sign-in`,className:`rounded-md border border-pending/40 bg-pending/5 px-3.5 py-3`,children:[(0,Q.jsx)(`p`,{className:`text-[13px] text-foreground`,children:i.message}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`code`,{className:`min-w-0 flex-1 overflow-x-auto rounded-sm bg-muted px-2 py-1.5 text-xs`,children:i.command}),(0,Q.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void f(i.command),children:`Copy command`})]})]}):null]},r.id)})})]})}var Qv=2e4;function $v(){let e=Zn(),t=Mr(),n=Kn();return e.isPending?(0,Q.jsx)(`p`,{"data-slot":`agents-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading agent settings…`}):e.isError?(0,Q.jsx)(X,{icon:(0,Q.jsx)(Za,{}),tone:`danger`,title:`Agent settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,Q.jsx)(ey,{config:e.data,catalogs:t,providerStatus:n})}function ey({config:e,catalogs:t,providerStatus:n}){let r=Wn(),i=z(),a=V({mutationFn:e=>xt(e),onSuccess:e=>{i.setQueryData(H.config,e),i.invalidateQueries({queryKey:H.health}),i.invalidateQueries({queryKey:H.repo})},onError:e=>K(e.message,{tone:`danger`})}),[o,s]=(0,Z.useState)(e.systemPrompt??``),c=o.trim(),l=c===(e.systemPrompt??``),u=c.length>Qv;return(0,Q.jsxs)(`div`,{"data-slot":`agents-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,Q.jsx)(ty,{defaultRunner:e.defaultRunner,providerStatus:n,saving:a.isPending,onPick:e=>a.mutate({defaultRunner:e})}),(0,Q.jsx)(ny,{title:`Default model`,hint:e.modelsLocked?`Models are locked to the defaults configured in the native coding-agent settings.`:`The model preselected in the composer for each runner. Auto lets the runner decide per task.`,children:(0,Q.jsx)(`div`,{className:`flex flex-col gap-4`,children:Ws.map(r=>{let i=Et(n.data,r.id),o=!n.isPending&&!n.isError&&i?.enabled===!0&&i.status===`connected`,s=n.isPending?`Checking provider authentication…`:n.isError?`Provider authentication could not be verified.`:i?.enabled===!1?`This provider is disabled. Enable it above or choose another provider.`:o?void 0:`Connect this provider before selecting it.`,c=t[r.id],l=Js(r.id,c.data,c.isError,c.isFetching),u=Gs(r.id,c.data,[e.defaultModels[r.id]]),d=e.defaultModels[r.id]??``,f=u.find(e=>e.id===d)?.label??d??`auto (default)`;return(0,Q.jsxs)(`label`,{className:`settings-option-row`,children:[(0,Q.jsx)(`div`,{children:(0,Q.jsx)(`h3`,{children:r.label})}),e.modelsLocked?(0,Q.jsx)(`output`,{"aria-label":`Default model for ${r.label}`,"data-slot":`agents-model`,"data-runner":r.id,title:`Model selection is locked to native coding-agent settings.`,className:`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs`,children:f}):(0,Q.jsxs)(`select`,{"aria-label":`Default model for ${r.label}`,"data-slot":`agents-model`,"data-runner":r.id,value:d,title:s??r.desc,disabled:a.isPending||!o,onChange:e=>a.mutate({defaultModels:{[r.id]:e.target.value||null}}),className:`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[u.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.id===``?`Native agent default`:e.label},e.id)),l?(0,Q.jsx)(`option`,{disabled:!0,children:l}):null]})]},r.id)})})}),(0,Q.jsxs)(ny,{title:`System prompt`,hint:`Extra instructions for every run in this project.`,children:[(0,Q.jsx)(Fo,{"aria-label":`System prompt`,"data-slot":`agents-system-prompt`,value:o,onChange:e=>s(e.target.value),placeholder:`Extra rules for every agent run — conventions, tone, review requirements…`,className:`min-h-48 w-full`}),(0,Q.jsxs)(`div`,{className:`settings-form-actions`,children:[(0,Q.jsx)(O,{type:`button`,variant:`primary`,size:`sm`,"data-action":`agents-save-prompt`,disabled:l||u||a.isPending,onClick:()=>a.mutate({systemPrompt:c===``?null:c},{onSuccess:()=>K(c===``?`System prompt cleared`:`System prompt saved`)}),children:`Save prompt`}),u?(0,Q.jsxs)(`p`,{"data-slot":`agents-prompt-limit`,className:`text-[11px] text-danger`,children:[c.length.toLocaleString(),` characters — the limit is`,` `,Qv.toLocaleString(),`.`]}):(0,Q.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:`Leave empty and save to clear. Applied to new runs only.`})]})]}),(0,Q.jsxs)(`section`,{"data-slot":`agents-task-runs`,className:`settings-field flex flex-col gap-5`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Task runs`}),(0,Q.jsx)(ry,{title:`Live title updates`,hint:`Refresh a task's short title through the namer model as the run progresses. A manual rename always wins and stops updates for that task.`,children:(0,Q.jsxs)(`label`,{className:`flex w-fit items-center gap-3`,children:[(0,Q.jsx)(oa,{"aria-label":`Live title updates`,"data-slot":`agents-live-title-updates`,checked:e.liveTitleUpdates??!0,disabled:a.isPending,onCheckedChange:e=>a.mutate({liveTitleUpdates:e},{onSuccess:()=>K(e?`Live title updates on`:`Live title updates off`)})}),(0,Q.jsxs)(`span`,{className:`text-[13px] text-muted-foreground`,children:[e.liveTitleUpdates??!0?`On`:`Off`,e.liveTitleUpdates===null&&` (default)`]})]})}),(0,Q.jsx)(ry,{title:`Review changes before finishing`,hint:`When on, a task with changes pauses so you can Accept, Send back, or open a Draft PR. Autonomous tasks always skip this and finish on their own. Default: off — tasks finish without asking.`,children:(0,Q.jsxs)(`label`,{className:`flex w-fit items-center gap-3`,children:[(0,Q.jsx)(oa,{"aria-label":`Review changes before finishing`,"data-slot":`agents-review-gate`,checked:e.reviewGate??!1,disabled:a.isPending,onCheckedChange:e=>a.mutate({reviewGate:e},{onSuccess:()=>K(e?`Review gate on`:`Review gate off`)})}),(0,Q.jsxs)(`span`,{className:`text-[13px] text-muted-foreground`,children:[e.reviewGate??!1?`On`:`Off`,e.reviewGate===null&&` (default)`]})]})}),(0,Q.jsx)(ry,{title:`Base branch`,hint:`New task worktrees branch from this and draft PRs target it. Also settable from the Git view.`,children:r.data?.info?(0,Q.jsxs)(`select`,{"aria-label":`Base branch`,"data-slot":`agents-base-branch`,value:e.baseBranch??``,disabled:a.isPending,onChange:e=>a.mutate({baseBranch:e.target.value||null}),className:`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[(0,Q.jsx)(`option`,{value:``,children:`follow checked-out branch (default)`}),r.data.branches.map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))]}):(0,Q.jsx)(`p`,{"data-slot":`agents-base-branch-unavailable`,className:`text-[13px] text-soft-foreground`,children:r.isPending?`Loading branches…`:`Not a git repository — tasks run in place, no branching.`})})]}),(0,Q.jsxs)(`details`,{className:`settings-disclosure`,children:[(0,Q.jsx)(`summary`,{children:`Provider connections`}),(0,Q.jsx)(Zv,{})]})]})}function ty({defaultRunner:e,providerStatus:t,saving:n,onPick:r}){let i=Bn(),a=It(),o=mt(),s=Wn(),c=ar(),l=o.projectId??`default`,u=s.data?.info?.root,d=u?i.data?.selections[u]:void 0,f=i.data?.defaults,p=iv(i.data?.profiles??[]),m=av(p);return(0,Q.jsxs)(ny,{title:`Default runner`,hint:`Project defaults. A task can override these choices.`,children:[(0,Q.jsx)(hv,{rows:p,runner:e,accountFor:e=>d?.[e]??f?.[e]??null,providerStatus:t,disabled:n,accountDisabled:c.isPending||a.data===void 0,onPick:(t,n,i)=>{t!==e&&r(t),i&&c.mutate({projectId:l,provider:t,profileId:n},{onError:e=>K(e.message,{tone:`danger`})})}}),!t.isPending&&!t.isError&&Et(t.data,e)?.enabled===!1?(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`This provider is disabled. Enable it above or choose another provider.`}):null,m?(0,Q.jsx)(`p`,{className:`max-w-md text-[13px] text-muted-foreground`,children:`The account is personal and never committed. Tasks already started under another account can’t be resumed here — their sessions live in that account’s folder.`}):null]})}function ny({title:e,hint:t,children:n}){return(0,Q.jsxs)(`section`,{className:`settings-field flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:t})]}),n]})}function ry({title:e,hint:t,children:n}){return(0,Q.jsxs)(`section`,{className:`settings-option-row`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{children:e}),(0,Q.jsx)(`p`,{children:t})]}),n]})}var iy=`cez-accent`,ay=`cez-density`,oy=`cez-width`,sy=`cezarion`,cy=`comfortable`,ly=`narrow`;function uy(e){return sy}function dy(e){return e===`comfortable`||e===`compact`||e===`ultra`?e:cy}function fy(e){return e===`narrow`||e===`wide`?e:ly}function py(e){let t=e&&typeof e==`object`?e:{};return{accent:uy(t.accent),density:dy(t.density),width:fy(t.width)}}function my(){try{return{accent:uy(localStorage.getItem(iy)),density:dy(localStorage.getItem(ay)),width:fy(localStorage.getItem(oy))}}catch{return{accent:sy,density:cy,width:ly}}}function hy(e){try{localStorage.setItem(iy,e.accent),localStorage.setItem(ay,e.density),localStorage.setItem(oy,e.width)}catch{}}function gy(e,t){t.accent===`cezarion`?delete e.dataset.accent:e.dataset.accent=t.accent,t.density===`comfortable`?delete e.dataset.density:e.dataset.density=t.density,t.width===`narrow`?delete e.dataset.width:e.dataset.width=t.width}var _y=Z.createContext(null);function vy({children:e}){let t=z(),n=Ht(),[r,i]=Z.useState(my),a=n.data;Z.useEffect(()=>{if(a===void 0)return;let e=py(a.appearance);i(e),hy(e)},[a]),Z.useLayoutEffect(()=>{gy(document.documentElement,r)},[r]);let o=Z.useCallback(e=>{i(e),hy(e),Qe({appearance:e}).then(e=>t.setQueryData(B.uiState,e)).catch(e=>{K(e instanceof Error?e.message:String(e),{tone:`danger`}),t.invalidateQueries({queryKey:B.uiState})})},[t]),s=Z.useCallback(e=>o({...r,accent:e}),[o,r]),c=Z.useCallback(e=>o({...r,density:e}),[o,r]),l=Z.useCallback(e=>o({...r,width:e}),[o,r]),u=Z.useMemo(()=>({accent:r.accent,density:r.density,width:r.width,setAccent:s,setDensity:c,setWidth:l}),[r,s,c,l]);return(0,Q.jsx)(_y.Provider,{value:u,children:e})}function yy(){let e=Z.useContext(_y);if(!e)throw Error(`cezar: useAppearance() must be called inside <AppearanceProvider>`);return e}var by=`cez-theme`,xy=`(prefers-color-scheme: light)`,Sy=`dark`;function Cy(e){return e===`light`||e===`dark`||e===`system`?e:Sy}function wy(e,t){return e===`light`||e===`system`&&t?`light`:`dark`}function Ty(){try{return Cy(localStorage.getItem(by))}catch{return Sy}}function Ey(e){try{localStorage.setItem(by,e)}catch{}}function Dy(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(xy).matches}function Oy(e,t){e.classList.toggle(`light`,t===`light`),e.style.colorScheme=t}function ky(e){return`/cezarion-mark-${e}.svg`}function Ay(e){let t=document.querySelector(`link[rel="icon"]`);t&&(t.href=ky(e))}var jy=Z.createContext(null);function My({children:e}){let[t,n]=Z.useState(Ty),[r,i]=Z.useState(Dy);Z.useEffect(()=>{let e=window.matchMedia?.(xy);if(!e)return;i(e.matches);let t=e=>i(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let a=wy(t,r);Z.useLayoutEffect(()=>{Oy(document.documentElement,a),Ay(a)},[a]);let o=Z.useCallback(e=>{n(e),Ey(e)},[]),s=Z.useMemo(()=>({theme:t,resolvedTheme:a,setTheme:o}),[t,a,o]);return(0,Q.jsx)(jy.Provider,{value:s,children:e})}function Ny(){let e=Z.useContext(jy);if(!e)throw Error(`cezar: useTheme() must be called inside <ThemeProvider>`);return e}function Py(e){return e<=200}function Fy(e){if(!Array.isArray(e))return[];let t=new Set;for(let n of e){if(typeof n!=`string`)continue;let e=n.trim();if(!(e===``||t.has(e))&&(t.add(e),t.size>=200))break}return[...t]}function Iy(e,t){let n=Fy(t);if(n.length===0)return[...e];let r=new Map(n.map((e,t)=>[e,t])),i=[],a=[];for(let t of e)r.has(t.id)?i.push(t):a.push(t);return i.sort((e,t)=>r.get(e.id)-r.get(t.id)),[...a,...i]}function Ly(e,t,n){return t===n||t<0||n<0||t>=e.length||n>=e.length?[...e]:Tc([...e],t,n)}function Ry(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function zy(){let e=z(),t=Ht(),n=Z.useRef(0),r=Z.useRef(Promise.resolve()),i=Z.useMemo(()=>Fy(t.data?.sidebar?.projectOrder),[t.data?.sidebar?.projectOrder]),a=Z.useCallback(t=>{let i=e.getQueryData(B.uiState);if(i===void 0)return;let{projectOrder:a,...o}=Ry(i.sidebar),s=t===null?o:{...o,projectOrder:t};e.setQueryData(B.uiState,{...i,sidebar:s});let c=++n.current,l=r.current.then(async()=>{let t=await Qe({sidebar:s},{keepalive:!0});c===n.current&&e.setQueryData(B.uiState,t)});r.current=l.catch(t=>{K(t instanceof Error?t.message:String(t),{tone:`danger`}),c===n.current&&e.invalidateQueries({queryKey:B.uiState})})},[e]),o=Z.useCallback(e=>{let t=Fy(e);t.length===0||!Py(e.length)||a(t)},[a]),s=Z.useCallback(()=>a(null),[a]);return{order:i,canReorder:t.data!==void 0,setOrder:o,reset:s}}var By=[{value:`system`,label:`System`,icon:um},{value:`light`,label:`Light`,icon:Em},{value:`dark`,label:`Dark`,icon:dm}],Vy=[{value:`cezarion`,label:`Cezarion`,swatch:`var(--accent-strong)`}],Hy=[{value:`comfortable`,label:`Comfortable`},{value:`compact`,label:`Compact`},{value:`ultra`,label:`Compact for real`}],Uy=[{value:`narrow`,label:`Narrow`},{value:`wide`,label:`Wide`}];function Wy({slot:e,label:t,value:n,options:r,onChange:i}){return(0,Q.jsx)(`div`,{role:`radiogroup`,"aria-label":t,"data-slot":e,className:`inline-flex w-fit gap-0.5 rounded-md border border-border bg-card p-0.5 max-md:max-w-full max-md:flex-wrap`,children:r.map(e=>{let t=e.value===n;return(0,Q.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,"data-value":e.value,onClick:()=>i(e.value),className:k(`flex min-h-11 items-center gap-2 rounded-sm px-3 py-1.5 text-[13px] font-medium transition-colors`,t?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`),children:[e.icon?(0,Q.jsx)(e.icon,{"aria-hidden":`true`,className:`size-3.5`}):null,e.swatch?(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`size-3 rounded-full border border-border`,style:{background:e.swatch}}):null,e.label]},e.value)})})}function Gy({title:e,hint:t,children:n}){return(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:t})]}),n]})}function Ky(){let e=It(),{order:t,canReorder:n,reset:r}=zy();return!((e.data?.projects.length??0)>1)||t.length===0?null:(0,Q.jsx)(Gy,{title:`Project order`,hint:`The project rail is in the order you dragged it into. Reset puts it back in the order the projects were added. Saved with your workspace, so every browser sees it.`,children:(0,Q.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`appearance-project-order-reset`,disabled:!n,onClick:r,className:`w-fit`,children:`Reset order`})})}function qy(){let{theme:e,setTheme:t}=Ny(),{accent:n,density:r,width:i,setAccent:a,setDensity:o,setWidth:s}=yy();return(0,Q.jsxs)(`div`,{"data-slot":`appearance-section`,className:`flex w-full flex-col gap-7 rounded-lg border border-border bg-card p-5`,children:[(0,Q.jsx)(Gy,{title:`Theme`,hint:`System follows your OS preference. Applies to this browser.`,children:(0,Q.jsx)(Wy,{slot:`appearance-theme`,label:`Theme`,value:e,options:By,onChange:t})}),Vy.length>1?(0,Q.jsx)(Gy,{title:`Accent`,hint:`The cockpit brand accent. Saved with your workspace appearance.`,children:(0,Q.jsx)(Wy,{slot:`appearance-accent`,label:`Accent`,value:n,options:Vy,onChange:a})}):null,(0,Q.jsx)(Gy,{title:`Density`,hint:`Compact tightens spacing across the cockpit — text stays the same size.`,children:(0,Q.jsx)(Wy,{slot:`appearance-density`,label:`Density`,value:r,options:Hy,onChange:o})}),(0,Q.jsx)(Gy,{title:`Reading width`,hint:`Wide lets a task's session and commits use more of the screen. Narrow keeps a comfortable reading column. The Changes tab is always full-width.`,children:(0,Q.jsx)(Wy,{slot:`appearance-width`,label:`Reading width`,value:i,options:Uy,onChange:s})}),(0,Q.jsx)(Ky,{}),(0,Q.jsxs)(`div`,{className:`settings-appearance-preview settings-readout`,children:[(0,Q.jsx)(`span`,{className:`text-[12px] text-soft-foreground`,children:`PREVIEW`}),(0,Q.jsx)(`p`,{className:`mt-3 text-base`,children:`Review finalization retries`}),(0,Q.jsxs)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:[`Needs you · cezar · Task `,`#`,`227`]}),(0,Q.jsx)(`span`,{className:`mt-3 inline-flex rounded-md border border-accent-strong/30 bg-accent-strong/10 px-4 py-3 text-xs text-accent-text`,children:`Open task`})]}),(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`Changes apply immediately. Theme is browser-local; density and reading width are saved with your workspace.`})]})}var Jy=`http://localhost:4321`;function Yy(e,t,n,r=Jy,i=null){let a=e=>encodeURIComponent(e).replaceAll(`'`,`%27`),o=`(()=>{const m=location.href.match(/^https:\\/\\/github\\.com\\/([^\\/]+)\\/([^\\/]+)\\/(pull|issues)\\/\\d+/);if(!m){alert('Open a GitHub PR or issue first');return;}const q='${`${e?`skill=${a(e)}&`:``}auto=${t?`1`:`0`}&key=${a(n)}&ref=`}'+encodeURIComponent(location.href);open('${r.replaceAll(`'`,`%27`)}${i===null||i===``?`/new`:`/p/${a(i)}/new`}?'+q,'_blank');})();`;return`javascript:${encodeURIComponent(o)}`}function Xy(){let e=rr();return e.isPending?(0,Q.jsx)(`p`,{"data-slot":`bookmarklets-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading bookmarklets…`}):e.isError?(0,Q.jsx)(X,{icon:(0,Q.jsx)(Qa,{}),tone:`danger`,heading:`h2`,title:`Could not load bookmarklets`,subtitle:e.error.message}):(0,Q.jsx)(`div`,{className:`flex min-h-full flex-1 overflow-y-auto`,children:(0,Q.jsx)(Zy,{skills:lc(e.data??[])})})}function Zy({skills:e}){let t=sn(),n=mn(),r=It(),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(``),c=t.isError?``:t.data?.key||null,l=window.location.origin,u=_s()??n.data?.bootProject??null,d=r.data?.projects.find(e=>e.id===u)?.name??yP(n.data)?.name??null,f=o.trim().toLowerCase(),p=e.filter(e=>e.name.toLowerCase().includes(f));return(0,Q.jsxs)(`div`,{"data-slot":`bookmarklet-panel`,className:`flex w-full min-w-0 flex-col gap-[18px] p-5`,children:[(0,Q.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Run from GitHub`}),(0,Q.jsxs)(`p`,{className:`text-[13px] leading-relaxed text-muted-foreground`,children:[`Drag a launcher to your browser's bookmarks bar. Then open a GitHub PR or issue and click that bookmark. Cezar must be running: `,(0,Q.jsx)(`span`,{className:`font-mono`,children:`npx cezarion`}),`.`]}),(0,Q.jsxs)(`div`,{className:`settings-bookmarklet-project rounded-lg bg-background p-3.5`,children:[(0,Q.jsxs)(`p`,{className:`text-[13px]`,children:[`Project`,d?` · ${d}`:``]}),(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`Launchers target this cockpit and this project. Keep Cezarion running.`})]}),(0,Q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2.5 text-[13px] font-medium`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,"data-slot":`bm-auto`,checked:i,onChange:e=>a(e.target.checked),className:`size-[18px] shrink-0`}),`One-click launch (auto-submit)`]}),(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed text-soft-foreground`,children:`Off by default. Re-drag the launchers after changing this option.`}),c===null||t.isError?(0,Q.jsx)(`p`,{"data-slot":`bm-key-state`,role:t.isError?`alert`:`status`,className:`text-xs leading-relaxed ${t.isError?`text-destructive`:`text-soft-foreground`}`,children:t.isError?`Could not load this project's launch key, so these launchers only prefill the form and auto-start cannot arm: ${t.error.message}`:`Loading this project's launch key…`}):null,(0,Q.jsx)(`div`,{"data-slot":`bm-generic`,className:`rounded-lg border border-border bg-muted/30 p-3.5`,children:(0,Q.jsx)(Qy,{label:d?`cezar (${d}): this PR/issue`:`cezar: this PR/issue`,url:c===null?null:Yy(``,!1,c,l,u),generic:!0,hint:`Prefills the form only—never auto-starts, even when auto-submit is on.`})}),(0,Q.jsx)(Hf,{"data-slot":`bm-filter`,placeholder:`Filter bookmarklet skills…`,"aria-label":`Filter bookmarklet skills`,value:o,onChange:e=>s(e.target.value),className:`h-11 text-[13px]`}),(0,Q.jsx)(`div`,{"data-slot":`bm-list`,className:`flex flex-col divide-y divide-border [&>[data-slot=bm-row]]:py-3.5`,children:p.length>0?p.map(e=>(0,Q.jsx)(Qy,{label:d?`/${e.name} (${d})`:`/${e.name}`,url:c===null?null:Yy(e.name,i,c,l,u)},e.path)):(0,Q.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:e.length>0?`(no skills match)`:`(no skills yet — the generic launcher above still works)`})}),(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed text-soft-foreground`,children:`These are bookmarklet drag sources, not run buttons. Clicking one here explains installation; it does not start a task.`}),(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed text-soft-foreground md:hidden`,children:`No drag-and-drop? Copy the URL for manual bookmark setup where your browser allows it, or install using a desktop browser.`})]})}function Qy({label:e,url:t,hint:n,generic:r=!1}){let i=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{t===null?i.current?.removeAttribute(`href`):i.current?.setAttribute(`href`,t)},[t]);let a=t!==null,o=async()=>{if(t!==null)try{await navigator.clipboard.writeText(t),K(`Bookmarklet URL copied.`)}catch{K(`Copy failed — drag the button instead.`,{tone:`danger`})}};return(0,Q.jsxs)(`div`,{"data-slot":`bm-row`,className:`flex min-w-0 flex-col gap-2.5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`a`,{ref:i,draggable:a,"data-slot":`bm-link`,"data-ready":a,"aria-disabled":!a||void 0,title:a?`Drag me to your bookmarks bar`:`Waiting for the launch key`,"aria-label":`${r?`Drag to bookmarks`:`Drag launcher`}: ${e}`,onClick:e=>{e.preventDefault(),K(a?`Drag me to your bookmarks bar`:`This launcher is not ready: it has no launch key yet.`)},className:`inline-flex aria-disabled:cursor-not-allowed aria-disabled:opacity-60 min-h-11 min-w-0 items-center rounded-md border border-border px-3 text-xs font-medium transition-colors hover:bg-muted ${r?`bg-accent-strong/10 text-accent-text`:`bg-card text-foreground`}`,children:(0,Q.jsx)(`span`,{className:`break-words`,children:e})}),(0,Q.jsx)(`button`,{type:`button`,"data-slot":`bm-copy`,title:`Copy the bookmarklet URL`,disabled:!a,onClick:()=>void o(),className:`min-h-11 disabled:cursor-not-allowed disabled:opacity-60 shrink-0 rounded-md border border-border px-3 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:`Copy URL`})]}),n?(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed text-soft-foreground`,children:n}):null]})}function $y(e){return{enabled:(e&&typeof e==`object`?e:{}).enabled===!0}}function eb(){let e=globalThis.Notification;if(typeof e!=`function`)return`unsupported`;let t=e.permission;return t===`granted`||t===`denied`?t:`default`}function tb(e,t){let n=new Map,r=[];for(let i of t??[]){let t={status:i.status,wantsAttention:oi(i)};n.set(i.id,t);let a=e.get(i.id);a!==void 0&&(a.status===t.status&&a.wantsAttention===t.wantsAttention||t.wantsAttention&&r.push(i))}return{entering:r,statuses:n}}function nb(e){return e.enabled&&e.hidden&&e.permission===`granted`}function rb(e){let t=fe(e).label;return{title:e.titleSummary??e.title,body:`Task ${t}`,tag:`cezar-run-${e.id}`}}function ib(){let e=z(),t=Ht(),[n,r]=Z.useState(!1),[i,a]=Z.useState(eb),o=t.data;Z.useEffect(()=>{o!==void 0&&r($y(o.notifications).enabled)},[o]);let s=Z.useCallback(t=>{r(t),Qe({notifications:{enabled:t}}).then(t=>e.setQueryData(B.uiState,t)).catch(t=>{K(t instanceof Error?t.message:String(t),{tone:`danger`}),e.invalidateQueries({queryKey:B.uiState})})},[e]),c=Z.useCallback(e=>{if(!e){s(!1);return}if(eb()!=="default"){s(!0);return}s(!0),Notification.requestPermission().then(e=>a(e)).catch(()=>a(eb()))},[s]),l=i===`unsupported`;return(0,Q.jsx)(`div`,{"data-slot":`notifications-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:(0,Q.jsx)(`label`,{htmlFor:`notifications-enabled`,children:`Notify when an agent needs you`})}),(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`A browser notification when a task starts waiting, asks for review, or fails — only while this tab is in the background. Off by default.`})]}),(0,Q.jsx)(oa,{id:`notifications-enabled`,"data-slot":`notifications-toggle`,checked:n,disabled:l,onCheckedChange:c})]}),l?null:(0,Q.jsxs)(`p`,{"data-slot":`notifications-permission`,"data-permission":i,className:`mt-4 text-[13px] text-muted-foreground`,children:[`Browser permission · `,i===`granted`?`Allowed`:i===`denied`?`Blocked`:`Not requested`]}),(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Permission is requested only when you enable notifications.`}),l?(0,Q.jsx)(`p`,{"data-slot":`notifications-unsupported`,className:`text-[13px] text-muted-foreground`,children:`This browser does not support notifications, so the toggle is unavailable here.`}):null,!l&&n&&i===`denied`?(0,Q.jsxs)(`div`,{"data-slot":`notifications-denied`,className:`mt-5 flex flex-col gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-sm`,children:`Allow notifications in your browser`}),(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`This browser is blocking notifications. Your preference is saved. Allow notifications in the browser’s site settings to receive them.`}),(0,Q.jsx)(`p`,{className:`settings-readout`,children:`Notifications are blocked for this site.`})]}):null]})})}function ab({open:e,onOpenChange:t}){let[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(null),o=It(),s=mr(),c=j(),l=new Set((o.data?.projects??[]).map(e=>e.root)),u=e=>{r(e),a(null),s.reset()},d=fv(n,i);return(0,Q.jsx)(jo,{open:e,onOpenChange:t,children:(0,Q.jsxs)(Ao,{"data-slot":`add-project-dialog`,className:`sm:max-w-lg`,children:[(0,Q.jsxs)(Po,{children:[(0,Q.jsx)(ko,{children:`Open local folder`}),(0,Q.jsx)(Oo,{children:`Pick the folder cezar should run in. Git repos are marked; any folder works.`})]}),(0,Q.jsxs)(No,{className:`space-y-4`,children:[(0,Q.jsx)(uv,{path:n,selected:i,onSelect:a,onEnter:u,emptyHint:`No subfolders here — “Add project” registers this folder.`,decorate:e=>(0,Q.jsxs)(Q.Fragment,{children:[e.isRepo?(0,Q.jsx)(Pf,{variant:`outline`,className:`shrink-0 text-[12px]`,children:`git`}):null,l.has(e.path)?(0,Q.jsx)(Pf,{variant:`ghost`,className:`shrink-0 text-[12px] text-muted-foreground`,children:`already added`}):null]})}),s.isError?(0,Q.jsx)(`p`,{"data-slot":`add-project-error`,className:`min-w-0 break-words text-[13px] text-danger`,children:s.error instanceof Error?s.error.message:`could not add that folder`}):null]}),(0,Q.jsxs)(Mo,{className:`min-w-0 sm:items-center sm:justify-between`,children:[(0,Q.jsx)(`span`,{"data-slot":`add-project-target`,className:`min-w-0 truncate font-mono text-[11px] text-muted-foreground`,title:d??void 0,children:d??``}),(0,Q.jsxs)(`span`,{className:`flex shrink-0 gap-2`,children:[(0,Q.jsx)(O,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsx)(O,{"data-slot":`add-project-confirm`,disabled:d===null||s.isPending,onClick:()=>{d===null||s.isPending||s.mutate(d,{onSuccess:({project:e})=>{t(!1),c(`/p/${encodeURIComponent(e.id)}/`)}})},children:s.isPending?`Adding…`:`Add project`})]})]})]})})}function ob(){let e=Hn();return{isPending:e.isPending,confirm:(t,n)=>e.mutate(t.id,{onSuccess:()=>{K(`${t.name} removed from the workspace — its files are untouched`),n?.()},onError:e=>K(e.message,{tone:`danger`})})}}function sb({project:e,onOpenChange:t,onConfirm:n}){return(0,Q.jsx)(ra,{open:e!==null,onOpenChange:t,children:(0,Q.jsxs)(Yi,{children:[(0,Q.jsxs)(na,{children:[(0,Q.jsxs)(Wi,{children:[`Remove `,e?.name,` from the workspace?`]}),(0,Q.jsxs)(Ui,{children:[`This only unregisters the project — `,(0,Q.jsx)(`strong`,{children:`nothing on disk is deleted`}),`. The folder, its git history and its task history all stay exactly where they are, and opening it again re-registers it with everything intact.`,(0,Q.jsx)(`span`,{className:`mt-1 block truncate font-mono text-[11px] text-foreground`,title:e?.root,children:e?.root})]})]}),(0,Q.jsxs)($i,{children:[(0,Q.jsx)(ta,{children:`Keep it`}),(0,Q.jsx)(Qi,{"data-action":`projects-confirm-remove`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:n,children:`Remove from list`})]})]})})}function cb({title:e,hint:t,children:n}){return(0,Q.jsxs)(`section`,{className:`settings-field flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:t})]}),n]})}var lb=1,ub={ok:`ok`,"not-git":`no git repo`,missing:`folder not found`};function db(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function fb(){let e=Lr(),t=It();return e.isPending||t.isPending?(0,Q.jsx)(`p`,{"data-slot":`projects-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading projects…`}):e.isError||t.isError?(0,Q.jsx)(X,{icon:(0,Q.jsx)(so,{}),tone:`danger`,title:`Project settings did not load`,subtitle:(e.error??t.error)?.message,heading:`h2`}):(0,Q.jsx)(pb,{config:e.data,registry:t.data})}function pb({config:e,registry:t}){let[n,r]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{"data-slot":`projects-section`,className:`mx-auto flex w-full max-w-4xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,Q.jsx)(mb,{configKey:`browseRoot`,value:e.browseRoot,title:`Default browse folder`,hint:`Where “Open local folder…” starts. The picker cannot navigate above this folder.`,placeholder:`~/`,slot:`browse`,savedLabel:`Browse folder`,footer:`Only affects folder browsing; GitHub checkouts use the separate checkout folder.`}),(0,Q.jsx)(mb,{configKey:`projectsDir`,value:e.projectsDir,title:`Default checkout folder`,hint:`Where “Clone from GitHub” puts new projects: <folder>/<project name>.`,placeholder:`~/cezar/projects`,slot:`checkout`,savedLabel:`Checkout folder`,footer:`Only affects new checkouts; projects already registered keep their location.`,refreshProjects:!0}),(0,Q.jsx)(hb,{registry:t,workspaceMax:e.resources.maxParallel}),(0,Q.jsx)(O,{className:`self-start`,onClick:()=>r(!0),children:`Add project`}),n?(0,Q.jsx)(ab,{open:!0,onOpenChange:r}):null]})}function mb({configKey:e,value:t,title:n,hint:r,placeholder:i,slot:a,savedLabel:o,footer:s,refreshProjects:c=!1}){let l=z(),u=V({mutationFn:t=>gt(e===`browseRoot`?{browseRoot:t}:{projectsDir:t}),onSuccess:t=>{l.setQueryData(B.config,t),e===`browseRoot`?l.invalidateQueries({queryKey:B.fsBrowseRoot}):c&&l.invalidateQueries({queryKey:B.projects})}}),[d,f]=(0,Z.useState)(t),p=d.trim(),m=p===t,h=u.isError?u.error.message:null;return(0,Q.jsxs)(cb,{title:n,hint:`${r} ${e===`browseRoot`?`Choose an existing folder; it is verified writable before saving.`:`The folder is created recursively if needed, then verified writable before saving.`}`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`text`,spellCheck:!1,"aria-label":n,"aria-invalid":h!==null,"data-slot":`projects-${a}-root`,value:d,disabled:u.isPending,placeholder:i,onChange:e=>{f(e.target.value),u.isError&&u.reset()},className:`block w-full max-w-sm rounded-md border border-input bg-card px-3 py-1.5 font-mono text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-danger disabled:opacity-50`}),(0,Q.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,"data-action":`projects-save-${a}-root`,disabled:m||p===``||u.isPending,onClick:()=>u.mutate(p,{onSuccess:()=>K(`${o} set to ${p}`)}),children:`Save`})]}),h===null?(0,Q.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:s}):(0,Q.jsxs)(`p`,{"data-slot":`projects-${a}-root-error`,role:`alert`,className:`text-[11px] text-danger`,children:[h,` — setting unchanged`]})]})}function hb({registry:e,workspaceMax:t}){let[n,r]=(0,Z.useState)(null),i=ob(),a=(0,Z.useMemo)(()=>En(e.projects),[e.projects]);return(0,Q.jsxs)(cb,{title:`Registered projects`,hint:`Connected repositories. Removing a project only unregisters it — no files on disk are deleted.`,children:[e.projects.length===0?(0,Q.jsx)(`p`,{"data-slot":`projects-empty`,className:`text-[13px] text-soft-foreground`,children:`No projects registered yet.`}):(0,Q.jsx)(`div`,{className:`overflow-x-auto rounded-md border border-border`,children:(0,Q.jsxs)(`table`,{className:`w-full border-collapse text-sm`,children:[(0,Q.jsx)(`caption`,{className:`sr-only`,children:`Projects registered in this workspace`}),(0,Q.jsxs)(`colgroup`,{children:[(0,Q.jsx)(`col`,{}),(0,Q.jsx)(`col`,{style:{width:`104px`}}),(0,Q.jsx)(`col`,{style:{width:`260px`}}),(0,Q.jsx)(`col`,{style:{width:`150px`}}),(0,Q.jsx)(`col`,{style:{width:`72px`}}),(0,Q.jsx)(`col`,{style:{width:`92px`}})]}),(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{className:`border-b border-border text-left text-[12px] text-soft-foreground`,children:[(0,Q.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Project`}),(0,Q.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Status`}),(0,Q.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Tags`}),(0,Q.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Max parallel`}),(0,Q.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Added`}),(0,Q.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium text-right`,children:`Actions`})]})}),(0,Q.jsx)(`tbody`,{children:e.projects.map(n=>(0,Q.jsx)(gb,{project:n,isBoot:n.id===e.bootProject,workspaceMax:t,vocabulary:a,disabled:i.isPending,onRemove:()=>r(n)},n.id))})]})}),(0,Q.jsx)(sb,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{if(!n)return;let e=n;r(null),i.confirm(e)}})]})}function gb({project:e,isBoot:t,workspaceMax:n,vocabulary:r,disabled:i,onRemove:a}){return(0,Q.jsxs)(`tr`,{"data-slot":`project-row`,"data-project":e.id,className:`border-b border-border last:border-0`,children:[(0,Q.jsxs)(`th`,{scope:`row`,className:`max-w-0 px-3 py-2 text-left font-normal`,children:[(0,Q.jsx)(`span`,{className:`block truncate text-foreground`,children:e.name}),(0,Q.jsx)(`span`,{className:`block truncate font-mono text-[11px] text-soft-foreground`,title:e.root,children:e.root})]}),(0,Q.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,Q.jsx)(`span`,{"data-slot":`project-status`,className:e.status===`missing`?`text-[12px] text-danger`:`text-[12px] text-soft-foreground`,children:ub[e.status]}),e.status===`missing`?null:(0,Q.jsxs)(`span`,{className:`ml-1 text-[11px] text-soft-foreground`,children:[`· `,e.source]})]}),(0,Q.jsx)(`td`,{className:`px-3 py-2`,children:(0,Q.jsx)(_b,{project:e,vocabulary:r})}),(0,Q.jsx)(`td`,{className:`px-3 py-2`,children:(0,Q.jsx)(vb,{project:e,workspaceMax:n})}),(0,Q.jsx)(`td`,{className:`px-3 py-2 tabular-nums text-soft-foreground`,children:db(e.addedAt)}),(0,Q.jsxs)(`td`,{className:`px-3 py-2 text-right`,children:[e.status===`missing`?null:(0,Q.jsx)(O,{asChild:!0,variant:`outline`,className:`mr-2`,children:(0,Q.jsx)(T,{to:`/p/${encodeURIComponent(e.id)}`,children:`Open`})}),(0,Q.jsx)(O,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`project-remove`,"aria-label":`Remove ${e.name} from the workspace — unregisters it, no files are deleted`,title:t?`cezar is serving this project — it re-registers itself at every start`:void 0,disabled:i||t,onClick:a,children:`Remove`})]})]})}function _b({project:e,vocabulary:t}){let n=tn(),[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(-1),l=(0,Z.useRef)(null),u=e.tags??[],d=Qt(t,u,r),f=a&&d.length>0,p=(t,r)=>{n.mutate({id:e.id,tags:t},{onSuccess:()=>K(r),onError:e=>K(e.message,{tone:`danger`})})},m=t=>{let n=t.trim().slice(0,32);if(c(-1),n){if(u.some(e=>e.toLowerCase()===n.toLowerCase())){i(``);return}if(u.length>=20){K(`${e.name} already has the maximum of 20 tags`,{tone:`danger`});return}i(``),p([...u,n],`${e.name} tagged \u201c${n}\u201d`)}},h=t=>{p(u.filter(e=>e!==t),`\u201c${t}\u201d removed from ${e.name}`)},g=`project-tag-suggestions-${e.id}`;return(0,Q.jsxs)(`div`,{"data-slot":`project-tags`,className:`flex flex-wrap items-center gap-1`,children:[u.map(t=>(0,Q.jsxs)(`span`,{"data-slot":`project-tag`,className:`inline-flex max-w-full items-center gap-1 rounded-full bg-accent-strong/15 py-px pr-1 pl-2 text-[11px] font-medium whitespace-nowrap text-accent-text`,children:[t,(0,Q.jsx)(`button`,{type:`button`,"data-action":`project-tag-remove`,"aria-label":`Remove tag ${t} from ${e.name}`,disabled:n.isPending,onClick:()=>h(t),className:`rounded-full p-0.5 hover:bg-accent-strong/25 disabled:opacity-50`,children:(0,Q.jsx)(uo,{className:`size-3`,"aria-hidden":`true`})})]},t)),(0,Q.jsxs)(Da,{open:f,onOpenChange:o,children:[(0,Q.jsx)(Ca,{asChild:!0,children:(0,Q.jsx)(`input`,{ref:l,type:`text`,"data-slot":`project-tag-input`,"aria-label":`Add a tag to ${e.name}`,role:`combobox`,"aria-expanded":f,"aria-controls":f?g:void 0,"aria-autocomplete":`list`,"aria-activedescendant":f&&s>=0?`${g}-${s}`:void 0,placeholder:u.length===0?`Add tag…`:`+`,value:r,maxLength:32,disabled:n.isPending,onFocus:()=>o(!0),onBlur:()=>o(!1),onChange:e=>{if(o(!0),c(-1),e.target.value.includes(`,`)){i(e.target.value.replace(/,/g,``));return}i(e.target.value)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(d.length===0)return;e.preventDefault(),o(!0);let t=e.key===`ArrowDown`?1:-1,n=s+t;c(n>=d.length?-1:n<-1?d.length-1:n);return}if(e.key===`Escape`&&f){e.preventDefault(),o(!1),c(-1);return}if(e.key===`Enter`||e.key===`,`){e.preventDefault(),m(s>=0?d[s]??r:r);return}if(e.key===`Tab`){o(!1);return}if(e.key===`Backspace`&&r===``&&u.length>0){e.preventDefault();let t=u[u.length-1];t!==void 0&&h(t)}},className:`h-6 w-16 min-w-0 flex-1 rounded-md border border-input bg-card px-1.5 text-[12px] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`})}),(0,Q.jsxs)(Ta,{align:`start`,sideOffset:4,id:g,role:`listbox`,"data-slot":`project-tag-suggestions`,className:`w-56 p-1`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,Q.jsx)(`p`,{className:`px-2 pt-1 pb-1.5 text-[11px] text-soft-foreground`,children:`Tags used in this workspace`}),d.map((e,t)=>(0,Q.jsx)(`button`,{type:`button`,id:`${g}-${t}`,role:`option`,"aria-selected":t===s,"data-slot":`project-tag-suggestion`,onMouseDown:e=>e.preventDefault(),onClick:()=>{m(e),l.current?.focus()},onMouseEnter:()=>c(t),className:k(`flex w-full items-center rounded-sm px-2 py-1 text-left text-[12px] font-medium text-accent-text`,t===s&&`bg-muted`),children:e},e))]})]})]})}function vb({project:e,workspaceMax:t}){let n=tn(),r=e.maxParallel===void 0?``:String(e.maxParallel);return(0,Q.jsxs)(`select`,{"aria-label":`Max parallel tasks for ${e.name}`,"data-slot":`project-max-parallel`,value:r,disabled:n.isPending,onChange:r=>{let i=r.target.value,a=i===``?null:Number(i);n.mutate({id:e.id,maxParallel:a},{onSuccess:()=>K(a===null?`${e.name} inherits the workspace limit (${t})`:`${e.name} runs at most ${a} task${a===1?``:`s`} at a time`),onError:e=>K(e.message,{tone:`danger`})})},className:`block w-44 rounded-md border border-input bg-card px-2 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[(0,Q.jsxs)(`option`,{value:``,children:[`Inherit workspace (`,t,`)`]}),Array.from({length:16},(e,t)=>t+lb).map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))]})}function yb(){let e=gn();return e.isPending?(0,Q.jsx)(`p`,{"data-slot":`prompt-templates-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading prompt templates…`}):e.isError?(0,Q.jsx)(X,{icon:(0,Q.jsx)(Ia,{}),tone:`danger`,title:`Prompt templates did not load`,subtitle:e.error.message,heading:`h2`}):(0,Q.jsx)(bb,{initial:Us(e.data.promptTemplates)})}function bb({initial:e}){let t=z(),n=rr(),r=gn(),[i,a]=(0,Z.useState)(e),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(``),u=V({mutationFn:e=>st({promptTemplates:e}),onSuccess:e=>{t.setQueryData(H.uiState,e),K(`Prompt templates saved`)},onError:e=>K(e.message,{tone:`danger`})}),d=JSON.stringify(i)!==JSON.stringify(e),f=i.some(e=>e.label.trim()===``||e.text.trim()===``),p=(e,t)=>a(n=>n.map(n=>n.id===e?{...n,...t}:n)),m=(e,t)=>a(n=>n.map(n=>{if(n.id!==e)return n;let r=n.skills??[],i=r.includes(t)?r.filter(e=>e!==t):[...r,t],{skills:a,...o}=n;return i.length>0?{...o,skills:i}:o})),h=e=>a(t=>t.filter(t=>t.id!==e));return(0,Q.jsx)(`div`,{"data-slot":`prompt-templates-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:(0,Q.jsxs)(Sb,{title:`Reusable instructions`,hint:`Insert templates from task composers, or apply them automatically with selected skills when the prompt is empty.`,children:[(0,Q.jsx)(`div`,{"data-slot":`prompt-template-list`,className:`flex flex-col gap-3`,children:i.length===0?(0,Q.jsx)(`p`,{"data-slot":`prompt-templates-empty`,className:`text-[13px] text-soft-foreground`,children:`No templates. Add one below, or reset to the built-ins.`}):i.map(e=>(0,Q.jsxs)(`div`,{"data-slot":`prompt-template-row`,"data-template":e.id,className:`flex flex-col gap-1.5 rounded-md border border-border bg-card p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`label`,{htmlFor:`template-label-${e.id}`,className:`text-sm`,children:`Template label`}),(0,Q.jsx)(Hf,{id:`template-label-${e.id}`,"aria-label":`Label for ${e.label||`this template`}`,"data-slot":`prompt-template-label-input`,value:e.label,maxLength:80,onChange:t=>p(e.id,{label:t.target.value}),className:`flex-1`})]}),(0,Q.jsx)(`label`,{htmlFor:`template-text-${e.id}`,className:`text-sm`,children:`Instructions`}),(0,Q.jsx)(Fo,{id:`template-text-${e.id}`,"aria-label":`Text for ${e.label||`this template`}`,"data-slot":`prompt-template-text-input`,value:e.text,maxLength:2e3,onChange:t=>p(e.id,{text:t.target.value}),className:`min-h-14 text-[13px]`}),(0,Q.jsx)(`p`,{className:`mt-3 text-sm`,children:`Apply automatically with skills`}),(0,Q.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5`,children:[(0,Q.jsx)(xb,{label:e.label,skills:n.data??[],skillUsage:r.data?.skillUsage,selected:e.skills??[],onToggle:t=>m(e.id,t)}),(e.skills??[]).map(t=>(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-skill-chip`,"data-skill":t,title:`Stop applying “${e.label}” automatically with ${t}`,onClick:()=>m(e.id,t),className:`inline-flex items-center gap-1 rounded-full border border-border bg-muted px-2 py-px font-mono text-[11px] font-medium text-foreground transition-colors hover:bg-danger/10 hover:text-danger`,children:[t,(0,Q.jsx)(uo,{"aria-hidden":`true`,className:`size-3`})]},t))]}),(0,Q.jsx)(O,{type:`button`,className:`self-start`,variant:`outline`,size:`sm`,"data-action":`prompt-template-remove`,title:`Remove this template`,onClick:()=>h(e.id),children:`Delete template`})]},e.id))}),(0,Q.jsxs)(`div`,{"data-slot":`prompt-template-new`,className:`flex flex-col gap-1.5 rounded-md border border-dashed border-border p-3`,children:[(0,Q.jsx)(`h3`,{className:`text-lg`,children:`New template`}),(0,Q.jsx)(`label`,{htmlFor:`new-template-label`,className:`text-sm`,children:`Label`}),(0,Q.jsx)(Hf,{id:`new-template-label`,"aria-label":`New template label`,"data-slot":`prompt-template-new-label`,placeholder:`e.g. Review security`,value:o,maxLength:80,onChange:e=>s(e.target.value)}),(0,Q.jsx)(`label`,{htmlFor:`new-template-text`,className:`text-sm`,children:`Instructions to insert`}),(0,Q.jsx)(Fo,{id:`new-template-text`,"aria-label":`New template text`,"data-slot":`prompt-template-new-text`,placeholder:`Enter reusable instructions…`,value:c,maxLength:2e3,onChange:e=>l(e.target.value),className:`min-h-14 text-[13px]`}),(0,Q.jsxs)(O,{type:`button`,variant:`outline`,size:`sm`,"data-action":`prompt-template-add`,disabled:!o.trim()||!c.trim(),onClick:()=>{let e=o.trim(),t=c.trim();!e||!t||(a(n=>[...n,{id:Os(),label:e,text:t}]),s(``),l(``))},className:`self-start`,children:[(0,Q.jsx)(Ga,{"aria-hidden":`true`,className:`size-3.5`}),`Add template`]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(O,{type:`button`,variant:`primary`,size:`sm`,"data-action":`prompt-templates-save`,disabled:!d||f||u.isPending,onClick:()=>u.mutate(i),children:`Save`}),(0,Q.jsx)(O,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`prompt-templates-reset`,disabled:u.isPending,onClick:()=>a(Ms.map(e=>({...e}))),children:`Reset to defaults`}),f?(0,Q.jsx)(`p`,{"data-slot":`prompt-templates-invalid`,className:`text-[11px] text-danger`,children:`Every template needs both a label and text.`}):null]})]})})}function xb({label:e,skills:t,skillUsage:n,selected:r,onToggle:i}){let[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(``),l=(0,Z.useRef)(null),{mostUsed:u,project:d,global:f,ranked:p}=pc(t,s,n),m=(e,t)=>{let n=r.includes(e.name);return(0,Q.jsxs)(As,{value:`skill ${e.name} ${e.path}`,keywords:oc(e.name,e.description),"data-slot":`prompt-template-skill-option`,"data-skill":e.name,"data-selected":n?`true`:void 0,onSelect:()=>i(e.name),children:[(0,Q.jsx)(`span`,{className:k(`shrink-0 font-mono text-xs`,t&&`font-semibold`),children:e.name}),e.description?(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,n?(0,Q.jsx)(co,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},e.path)};return(0,Q.jsxs)(Da,{open:a,onOpenChange:e=>{o(e),e||c(``)},children:[(0,Q.jsx)(Sa,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-skills-trigger`,"aria-label":`Apply ${e||`this template`} automatically with a skill`,title:`Pick the skills this template applies itself to`,disabled:t.length===0,className:k(`inline-flex h-[26px] items-center gap-1.5 rounded-full border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-50`,r.length>0&&`border-foreground/60 font-semibold text-foreground`),children:[(0,Q.jsx)(vo,{"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),t.length===0?`no skills found`:`apply with…`,(0,Q.jsx)(So,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,Q.jsx)(Ta,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Q.jsxs)(Ds,{shouldFilter:!1,children:[(0,Q.jsx)(Ts,{placeholder:`search skills…`,value:s,onValueChange:c,onInput:()=>l.current?.scrollTo(0,0)}),(0,Q.jsxs)(rc,{ref:l,"data-slot":`prompt-template-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[(p?p.length===0:u.length===0&&d.length===0&&f.length===0)?(0,Q.jsx)(Cs,{children:`Nothing matches.`}):null,p?p.length>0?(0,Q.jsx)(ws,{children:p.map(e=>m(e,sc(e)))}):null:(0,Q.jsxs)(Q.Fragment,{children:[u.length>0?(0,Q.jsx)(ws,{heading:`Most used`,children:u.map(e=>m(e,sc(e)))}):null,d.length>0?(0,Q.jsx)(ws,{heading:`Project skills`,children:d.map(e=>m(e,!0))}):null,f.length>0?(0,Q.jsx)(ws,{heading:`Global`,children:f.map(e=>m(e,!1))}):null]})]})]})})]})}function Sb({title:e,hint:t,children:n}){return(0,Q.jsxs)(`section`,{className:`settings-field flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:t})]}),n]})}var Cb=1,wb=1,Tb=60,Eb=256;function Db(){let e=Lr();return e.isPending?(0,Q.jsx)(`p`,{"data-slot":`resources-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading resource settings…`}):e.isError?(0,Q.jsx)(X,{icon:(0,Q.jsx)(ka,{}),tone:`danger`,title:`Resource settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,Q.jsx)(Ob,{config:e.data})}function Ob({config:e}){let t=z(),n=V({mutationFn:e=>gt(e),onSuccess:e=>t.setQueryData(B.config,e),onError:e=>K(e.message,{tone:`danger`})}),[r,i]=(0,Z.useState)(e.resources.memoryLimitMb?String(e.resources.memoryLimitMb):``),a=e.resources.monitoringWakeIntervalMinutes??null,[o,s]=(0,Z.useState)(a===null?`park`:`interval`),[c,l]=(0,Z.useState)(String(a??5)),u=Number(c),d=!Number.isInteger(u)||u<wb||u>Tb,f=o===`park`?a===null:!d&&a===u,p=()=>n.mutate({resources:{monitoringWakeIntervalMinutes:o===`park`?null:u}},{onSuccess:()=>K(o===`park`?`Monitoring will stay parked`:`Monitoring will re-check every ${u} minutes`)}),m=e.resources.autoResumeOnUsageLimit??!0,h=e=>n.mutate({resources:{autoResumeOnUsageLimit:e}},{onSuccess:()=>K(e?`Tasks stopped by a usage limit will resume themselves`:`Tasks stopped by a usage limit will stay failed`)}),g=r.trim()===``?0:Number(r),_=r.trim()!==``&&(!Number.isInteger(g)||g<Eb),v=(e.resources.memoryLimitMb??0)===(_?-1:g),y=()=>n.mutate({resources:{memoryLimitMb:g===0?null:g}},{onSuccess:()=>K(g===0?`Memory limit cleared`:`Memory limit set to ${g} MiB`)}),b=e.composerDefaults??{autonomous:null,worktree:null,inheritedAutonomous:`source-dependent`,inheritedWorktree:!0},x=(e,t)=>n.mutate({composerDefaults:{[e]:t===`inherit`?null:t===`on`}});return(0,Q.jsxs)(`div`,{"data-slot":`resources-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,Q.jsxs)(cb,{title:`Max parallel tasks`,hint:`Limit simultaneously running tasks.`,children:[(0,Q.jsx)(`select`,{"aria-label":`Max parallel tasks`,"data-slot":`resources-max-parallel`,value:e.resources.maxParallel,disabled:n.isPending,onChange:e=>n.mutate({resources:{maxParallel:Number(e.target.value)}}),className:`block w-28 rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:Array.from({length:16},(e,t)=>t+Cb).map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))}),(0,Q.jsxs)(`p`,{className:`text-[11px] text-soft-foreground`,children:[`Need a different limit for one project?`,` `,(0,Q.jsx)(T,{to:`/settings/global/projects`,"data-slot":`resources-project-limits-link`,className:`font-medium text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground`,children:`Configure per-project limits`}),`.`]})]}),(0,Q.jsxs)(cb,{title:`Extra monitoring sessions`,hint:`Additional capacity reserved for monitoring.`,children:[(0,Q.jsx)(`select`,{"aria-label":`Extra monitoring sessions`,"data-slot":`resources-max-monitoring`,value:e.resources.maxMonitoringSessions??2,disabled:n.isPending,onChange:e=>n.mutate({resources:{maxMonitoringSessions:Number(e.target.value)}}),className:`block w-28 rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:Array.from({length:17},(e,t)=>(0,Q.jsx)(`option`,{value:t,children:t},t))}),(0,Q.jsxs)(`p`,{className:`text-[11px] text-soft-foreground`,children:[`Capacity: `,e.resources.maxParallel,` active + `,e.resources.maxMonitoringSessions??2,` monitoring. Set 0 to make monitoring share active slots.`]})]}),(0,Q.jsxs)(cb,{title:`Monitoring wake-up`,hint:`Wake monitoring sessions periodically.`,children:[(0,Q.jsxs)(`div`,{className:`settings-resource-controls flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(oa,{"aria-label":`Monitoring wake-up`,"data-slot":`resources-monitoring-wake-mode`,checked:o===`interval`,disabled:n.isPending,onCheckedChange:e=>s(e?`interval`:`park`)}),o===`interval`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`label`,{htmlFor:`monitoring-wake-interval`,className:`w-full text-sm`,children:`Wake interval`}),(0,Q.jsx)(`input`,{id:`monitoring-wake-interval`,type:`number`,min:wb,max:Tb,"aria-label":`Wake interval in minutes`,"data-slot":`resources-monitoring-wake-interval`,value:c,disabled:n.isPending,onChange:e=>l(e.target.value),className:`block w-24 rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`}),(0,Q.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`minutes`})]}):null,(0,Q.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,"data-action":`resources-save-monitoring-wake`,disabled:f||o===`interval`&&d||n.isPending,onClick:p,children:`Save`})]}),o===`interval`&&d?(0,Q.jsx)(`p`,{"data-slot":`resources-monitoring-wake-invalid`,className:`text-[11px] text-danger`,children:`Enter a whole number from 1 to 60 minutes.`}):(0,Q.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:`Applied consistently to Claude, Codex and OpenCode.`})]}),(0,Q.jsxs)(cb,{title:`Auto-resume after a usage limit`,hint:`Resume eligible tasks once the provider usage limit resets.`,children:[(0,Q.jsx)(oa,{"aria-label":`Auto-resume after a usage limit`,"data-slot":`resources-auto-resume`,checked:m,disabled:n.isPending,onCheckedChange:h}),(0,Q.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:`Applies to Claude, Codex and OpenCode — whenever the provider says when the limit lifts.`})]}),(0,Q.jsxs)(cb,{title:`Per-task memory limit`,hint:`Leave blank for no limit.`,children:[(0,Q.jsxs)(`div`,{className:`settings-resource-controls flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`number`,inputMode:`numeric`,min:Eb,step:256,"aria-label":`Per-task memory limit in MiB`,"data-slot":`resources-memory-limit`,value:r,disabled:n.isPending,placeholder:`no limit`,onChange:e=>i(e.target.value),className:`block w-32 rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`}),(0,Q.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`MiB`}),(0,Q.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,"data-action":`resources-save-memory`,disabled:v||_||n.isPending,onClick:y,children:`Save`})]}),_?(0,Q.jsxs)(`p`,{"data-slot":`resources-memory-invalid`,className:`text-[11px] text-danger`,children:[`Enter a whole number of at least `,Eb,` MiB, or leave empty for no limit.`]}):(0,Q.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:`Applies to newly started tasks.`})]}),(0,Q.jsxs)(cb,{title:`New task defaults`,hint:`Apply to new tasks unless overridden.`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,"data-slot":`resources-composer-defaults`,children:[(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:`Autonomous by default`}),(0,Q.jsxs)(`select`,{"aria-label":`Autonomous by default`,value:b.autonomous===null?`inherit`:b.autonomous?`on`:`off`,disabled:n.isPending,onChange:e=>x(`autonomous`,e.target.value),className:`rounded-md border border-input bg-card px-3 py-1.5 shadow-xs outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`,children:[(0,Q.jsx)(`option`,{value:`inherit`,children:`Inherit environment`}),(0,Q.jsx)(`option`,{value:`on`,children:`On`}),(0,Q.jsx)(`option`,{value:`off`,children:`Off`})]}),(0,Q.jsxs)(`span`,{className:`text-[11px] text-soft-foreground`,children:[`Inherited: `,b.inheritedAutonomous===`source-dependent`?`Source-dependent — skills on, workflows off`:b.inheritedAutonomous?`On`:`Off`]})]}),(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:`Use a worktree by default`}),(0,Q.jsxs)(`select`,{"aria-label":`Use a worktree by default`,value:b.worktree===null?`inherit`:b.worktree?`on`:`off`,disabled:n.isPending,onChange:e=>x(`worktree`,e.target.value),className:`rounded-md border border-input bg-card px-3 py-1.5 shadow-xs outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`,children:[(0,Q.jsx)(`option`,{value:`inherit`,children:`Inherit environment`}),(0,Q.jsx)(`option`,{value:`on`,children:`On`}),(0,Q.jsx)(`option`,{value:`off`,children:`Off`})]}),(0,Q.jsxs)(`span`,{className:`text-[11px] text-soft-foreground`,children:[`Inherited: `,b.inheritedWorktree?`On`:`Off`]})]})]}),(0,Q.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:`Interactive skills may recommend both off. Multi-step and parallel runs remain isolated.`})]})]})}var kb=[[`overall`,`Overall`],[`needsYou`,`Needs You`],[`finished`,`Finished`],[`working`,`Working`]];function Ab(){let e=c(),t=jn(e);return t.isPending?(0,Q.jsx)(`p`,{role:`status`,className:`p-4 text-sm text-muted-foreground`,children:`Loading sidebar settings…`}):t.isError?(0,Q.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,Q.jsxs)(`p`,{role:`alert`,children:[`Sidebar settings did not load: `,t.error.message]}),(0,Q.jsx)(O,{className:`min-h-[44px]`,onClick:()=>void t.refetch(),children:`Retry`})]}):(0,Q.jsx)(jb,{scope:e,initial:t.data.sidebarLimits??{}},e)}function jb({scope:e,initial:t}){let n=z(),r=Wr(void 0),i=Mb(t),[a,o]=(0,Z.useState)(()=>({values:i,saved:i,received:i})),{values:s,saved:c}=a,l=e=>o(t=>({...t,values:e})),u=Kr.safeParse(Object.fromEntries(kb.map(([e])=>[e,s[e]===null?null:Number(s[e])]))),d=e=>s[e]!==null&&(s[e].trim()===``||!Number.isSafeInteger(Number(s[e]))||Number(s[e])<=0),f=kb.some(([e])=>s[e]!==c[e]),p=V({onMutate:()=>n.cancelQueries({queryKey:[e,`ui-state`],exact:!0}),mutationFn:t=>st({sidebarLimits:t},e),onSuccess:async t=>{await n.cancelQueries({queryKey:[e,`ui-state`],exact:!0}),n.setQueryData([e,`ui-state`],t);let r=Mb(t.sidebarLimits);o({values:r,saved:r,received:r})}});return!p.isPending&&!Nb(a.received,i)&&o({values:f?s:i,saved:i,received:i}),(0,Q.jsxs)(`form`,{"data-slot":`sidebar-settings`,className:`flex w-full max-w-2xl flex-col gap-5 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6`,onSubmit:e=>{e.preventDefault(),u.success&&!kb.some(([e])=>d(e))&&!p.isPending&&p.mutate(u.data)},children:[(0,Q.jsx)(`p`,{id:`sidebar-limits-help`,className:`text-sm text-muted-foreground`,children:`Limits apply to this project on desktop and mobile. The overall budget is shared in section order: Needs You, Finished, then Working. Each section also respects its own limit. Unlimited removes only that constraint.`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Pinned tasks and groups containing a pin bypass both limits. A task group counts as one row. Archived uses only the overall limit; archived pins are not exempt.`}),kb.map(([e,t])=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`label`,{htmlFor:`sidebar-${e}`,className:`text-sm font-medium`,children:t}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Q.jsx)(`input`,{id:`sidebar-${e}`,type:`number`,inputMode:`numeric`,min:`1`,step:`1`,value:s[e]??``,disabled:s[e]===null||p.isPending,"aria-invalid":d(e),"aria-describedby":d(e)?`sidebar-${e}-error sidebar-limits-help`:`sidebar-limits-help`,onChange:t=>l({...s,[e]:t.target.value}),className:`min-h-[44px] w-28 rounded-md border border-input bg-card px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50`}),(0,Q.jsxs)(`label`,{className:`flex min-h-[44px] cursor-pointer items-center gap-2 text-sm`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,"aria-label":`${t} Unlimited`,checked:s[e]===null,disabled:p.isPending,onChange:t=>l({...s,[e]:t.target.checked?null:String(r[e]??10)}),className:`size-4 accent-[var(--accent-strong)]`}),`Unlimited`]})]}),d(e)&&(0,Q.jsx)(`p`,{id:`sidebar-${e}-error`,className:`text-sm text-danger`,children:`Enter a positive whole number or choose Unlimited.`})]},e)),(0,Q.jsx)(O,{type:`submit`,className:`min-h-[44px] self-start`,variant:`primary`,disabled:!f||!u.success||kb.some(([e])=>d(e))||p.isPending,children:p.isPending?`Saving…`:`Save sidebar limits`}),p.isError&&(0,Q.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[`Could not save sidebar limits: `,p.error.message]}),p.isSuccess&&!f&&(0,Q.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Sidebar limits saved.`})]})}function Mb(e){let t=Wr(e);return Object.fromEntries(kb.map(([e])=>[e,t[e]===null?null:String(t[e])]))}function Nb(e,t){return kb.every(([n])=>e[n]===t[n])}function Pb({savedCommandCount:e,settingsAdmin:t,configPath:n,issue:r,invalid:i,children:a}){return(0,Q.jsxs)(Q.Fragment,{children:[e===0&&r===null?(0,Q.jsx)(`p`,{"data-slot":`worktree-setup-empty`,className:`text-sm text-foreground`,children:`No setup commands configured. No commands will run in new worktrees.`}):null,a,t===!1?(0,Q.jsxs)(`p`,{"data-slot":`worktree-setup-readonly`,className:`text-xs text-foreground`,children:[`Edit `,(0,Q.jsx)(`code`,{children:`worktreeSetup.commands`}),` in`,` `,n===null?(0,Q.jsxs)(Q.Fragment,{children:[`the project’s `,(0,Q.jsx)(`code`,{children:`.ai/cezar/config.json`})]}):(0,Q.jsx)(`code`,{className:`break-all`,children:n}),` `,`on the machine running Cezarion. Valid file edits apply to new worktrees; no restart is needed. To edit here, the host operator runs `,(0,Q.jsx)(`code`,{children:Iv}),`.`]}):null,r===null?null:(0,Q.jsxs)(`p`,{"data-slot":`worktree-setup-issue`,className:`text-[11px] text-danger`,children:[`config.json has an invalid worktreeSetup (`,r,`) — saving replaces it.`]}),i===null?null:(0,Q.jsx)(`p`,{"data-slot":`worktree-setup-invalid`,className:`text-[11px] text-danger`,children:i})]})}function Fb(e,t){let n=e.split(`
8
+ `).map(e=>e.trim()).filter(e=>e!==``),r=Number(t);return{commands:n,timeoutSeconds:r,invalid:n.length>20?`Enter at most 20 commands.`:n.some(e=>e.length>4e3)?`Keep each command under ${Qr.toLocaleString(`en-US`)} characters.`:t.trim()===``||!Number.isInteger(r)||r<1||r>7200?`Enter a whole number of seconds from 1 to ${Ur}.`:null}}function Ib(){let e=_s(),t=It().data;return e===null?null:t?.projects.find(t=>t.id===e)?.root??null}function Lb(e){navigator.clipboard.writeText(e).then(()=>K(`Project folder copied`)).catch(()=>K(e))}function Rb(){let e=Ib();return e===null?null:(0,Q.jsx)(cb,{title:`Project folder`,hint:`Where this project lives on disk. Every task worktree, git command and agent run resolves against it.`,children:(0,Q.jsxs)(`div`,{"data-slot":`project-location`,"data-variant":`field`,className:`flex flex-col gap-3`,children:[(0,Q.jsx)(`span`,{"data-slot":`project-location-path`,className:`w-full min-w-0 rounded-md border border-border bg-background p-3 text-[13px] break-all text-foreground`,children:e}),(0,Q.jsxs)(`div`,{className:`flex w-full flex-wrap items-center gap-2 border-t border-border pt-4`,children:[(0,Q.jsxs)(`button`,{type:`button`,"data-action":`project-location-copy`,title:`Copy the project folder path`,onClick:()=>Lb(e),className:`inline-flex min-h-11 items-center gap-2 rounded-md border border-border bg-card px-3 text-xs text-foreground transition-colors hover:bg-muted`,children:[(0,Q.jsx)(Eo,{"aria-hidden":`true`,className:`size-4`}),`Copy path`]}),(0,Q.jsx)(zb,{root:e})]})]})})}function zb({root:e}){let t=$t(),n=V({mutationFn:e=>ke(e),onError:e=>K(e.message,{tone:`danger`})}),r=(t.data?.targets??[]).filter(e=>nv(e.id)===void 0).map(e=>({target:e}));return r.length===0?null:(0,Q.jsx)(rv,{slot:`project-location-open`,label:`Open with`,triggerVariant:`outline`,title:e,disabled:n.isPending,choices:r,onPick:e=>n.mutate(e,{onSuccess:()=>K(`Opening the project folder in ${r.find(t=>t.target.id===e)?.target.label??e}`)})})}function Bb({config:e}){let t=z(),n=mn(),r=Fv(),i=Ib(),a=i===null?null:`${i.replace(/\/$/,``)}/.ai/cezar/config.json`,o=n.data?.capabilities?.settingsAdmin===!0,s=e.worktreeSetup?.commands??[],c=e.worktreeSetup?.timeoutSeconds??900,[l,u]=(0,Z.useState)(s.join(`
9
+ `)),[d,f]=(0,Z.useState)(String(c)),{commands:p,timeoutSeconds:m,invalid:h}=Fb(l,d),g=e.worktreeSetupIssue===null&&p.length===s.length&&p.every((e,t)=>e===s[t])&&(p.length===0||m===c),_=V({mutationFn:e=>xt(e),onSuccess:e=>{t.setQueryData(H.config,e),u(p.join(`
10
+ `)),K(p.length===0?`Worktree setup cleared`:`Worktree setup saved`)},onError:e=>{K(e.message,{tone:`danger`}),e instanceof Ze&&e.status===409&&r()}}),v=()=>_.mutate({worktreeSetup:p.length===0?null:{commands:p,...m===900?{}:{timeoutSeconds:m}}}),y=`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50 read-only:bg-muted read-only:text-muted-foreground`;return(0,Q.jsxs)(cb,{title:`Prepare new worktrees`,hint:`Runs in every new task and worker worktree before the agent starts, in order, stopping at the first failure. Leave commands empty to skip setup.`,children:[(0,Q.jsx)(Lv,{risk:`These commands run on the machine running Cezarion`}),(0,Q.jsxs)(Pb,{savedCommandCount:s.length,settingsAdmin:n.data?.capabilities?.settingsAdmin,configPath:a,issue:e.worktreeSetupIssue,invalid:h,children:[(0,Q.jsx)(`textarea`,{"data-slot":`worktree-setup-commands`,"aria-label":`Worktree setup commands, one per line`,rows:4,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,value:l,readOnly:!o,disabled:_.isPending,onChange:e=>u(e.target.value),className:`${y} min-h-24 w-full resize-y font-mono text-[13px] leading-relaxed`}),(0,Q.jsxs)(`p`,{className:`text-xs text-soft-foreground`,children:[`Example only: `,(0,Q.jsx)(`code`,{children:`npm ci`}),`. Commands run only after they are saved.`]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-soft-foreground`,children:[(0,Q.jsx)(`span`,{children:`Timeout per command`}),(0,Q.jsx)(`input`,{type:`number`,inputMode:`numeric`,min:1,max:Ur,step:1,"data-slot":`worktree-setup-timeout`,value:d,readOnly:!o,disabled:_.isPending,onChange:e=>f(e.target.value),className:`${y} min-h-11 w-28 md:min-h-0`}),(0,Q.jsx)(`span`,{children:`seconds`})]}),(0,Q.jsx)(O,{type:`button`,variant:`primary`,size:`sm`,className:`min-h-11 self-start md:min-h-0`,"data-action":`worktree-setup-save`,disabled:!o||g||h!==null||_.isPending,onClick:v,children:`Save setup`})]})]})]})}var Vb=0,Hb=1e3;function Ub(){let e=Zn();return e.isPending?(0,Q.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading worktree settings…`}):e.isError?(0,Q.jsx)(X,{icon:(0,Q.jsx)(Xp,{}),tone:`danger`,title:`Worktree settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,Q.jsx)(Wb,{config:e.data})}function Wb({config:e}){let t=z(),n=V({mutationFn:e=>xt(e),onSuccess:e=>t.setQueryData(H.config,e),onError:e=>K(e.message,{tone:`danger`})}),[r,i]=(0,Z.useState)(String(e.worktreeRetention)),a=Number(r),o=r.trim()===``||!Number.isInteger(a)||a<Vb||a>Hb,s=e.worktreeRetention===(o?-1:a);return(0,Q.jsxs)(`div`,{"data-slot":`worktrees-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,Q.jsxs)(cb,{title:`Keep N finished worktrees`,hint:`Older finished worktrees are reclaimed to free disk; their branch is kept so the work stays recoverable. 0 = unlimited. In-review and running tasks are never reclaimed, so the count on disk can exceed this.`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`number`,inputMode:`numeric`,min:Vb,max:Hb,step:1,"aria-label":`Keep last N finished worktrees`,"data-slot":`resources-worktree-retention`,value:r,disabled:n.isPending,onChange:e=>i(e.target.value),className:`block w-32 rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`}),(0,Q.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`worktrees`}),(0,Q.jsx)(O,{type:`button`,variant:`primary`,size:`sm`,className:`self-start`,"data-action":`resources-save-retention`,disabled:s||o||n.isPending,onClick:()=>n.mutate({worktreeRetention:a},{onSuccess:()=>{t.invalidateQueries({queryKey:H.worktrees}),K(a===0?`Keeping all worktrees (unlimited)`:`Keeping the last ${a} finished worktree${a===1?``:`s`}`)}}),children:`Save retention`})]}),o?(0,Q.jsxs)(`p`,{"data-slot":`resources-retention-invalid`,className:`text-[11px] text-danger`,children:[`Enter a whole number from `,Vb,` to `,Hb,` (0 = unlimited).`]}):(0,Q.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:a===0?`Keeping every finished worktree.`:`Keeping the last ${a} finished worktree${a===1?``:`s`} on disk.`})]}),(0,Q.jsx)(Bb,{config:e}),(0,Q.jsxs)(Y,{to:`/git/cleanup`,"data-slot":`worktrees-manage-link`,className:`inline-flex min-h-11 items-center gap-1 self-start text-[13px] font-medium text-link-foreground hover:underline focus-visible:outline-2 focus-visible:outline-ring md:min-h-0`,children:[`Manage worktrees on Git`,(0,Q.jsx)($a,{"aria-hidden":`true`,className:`size-[14px]`})]})]})}function Gb(e,t){return function(){return(0,Q.jsx)(X,{icon:(0,Q.jsx)(t,{}),tone:`neutral`,title:e,subtitle:`This section arrives in a later phase of the redesign.`,heading:`h2`})}}var Kb=[{id:`sidebar`,title:`Sidebar`,description:`Overall and per-section task limits for this project.`,icon:ka,component:Ab,scope:`project`},{id:`agents`,title:`Agents`,description:`Default runner, models and system prompt.`,icon:Za,component:$v,scope:`project`},{id:`agent-config`,title:`Agent config`,description:`Edit the coding agents’ own config files, per scope.`,icon:Jp,component:zv,scope:`project`},{id:`worktrees`,title:`Worktrees`,description:`How many finished task worktrees this project keeps on disk.`,icon:Xp,component:Ub,scope:`project`},{id:`bookmarklets`,title:`Bookmarklets`,description:`Launch skills from a GitHub PR or issue.`,icon:wp,component:Xy,scope:`project`},{id:`prompt-templates`,title:`Prompt templates`,description:`Reusable snippets for follow-up instructions.`,icon:Yp,component:yb,scope:`project`},{id:`appearance`,title:`Appearance`,description:`Theme, accent and density.`,icon:go,component:qy,scope:`global`},{id:`notifications`,title:`Notifications`,description:`Browser notifications when an agent needs you.`,icon:yo,component:ib,scope:`global`},{id:`resources`,title:`Resources`,description:`Parallel tasks and per-task memory limit, across every project.`,icon:ka,component:Db,scope:`global`},{id:`tasks`,title:`Tasks`,description:`Automatic task archiving after pull requests merge.`,icon:Xp,component:G_,scope:`global`},{id:`accounts`,title:`Agent accounts`,description:`Second logins, and the agent and models a project uses when it has chosen none.`,icon:Do,component:yv,scope:`global`},{id:`projects`,title:`Projects`,description:`The workspace registry and where GitHub checkouts land.`,icon:so,component:fb,scope:`global`},{id:`keyboard`,title:`Keyboard`,description:`Shortcuts.`,icon:om,component:Gb(`Keyboard`,om),scope:`global`,hidden:!0}];function qb(e,t){return Kb.filter(n=>!n.hidden&&n.scope===e&&!(t?.singleProject===!0&&n.id===`projects`))}var Jb=[`done`,`failed`,`cancelled`];function Yb(e){return Jb.includes(e)}function Xb(e){return!P(e)&&Yb(e.status)&&!Yt(e)}function Zb(e){return e.reduce((e,t)=>Yn(t)||!Yt(t)?e:e+1,0)}function Qb(e){return e.status===`failed`?`danger`:`success`}var $b={needsYou:0,failedUnread:0,inMotion:0,finishedUnread:0};function ex(e){let t={...$b};for(let n of e){if(n.archived||Yn(n))continue;let e=fe(n);e.bucket===`waiting`?t.needsYou+=1:e.tone===`running`?t.inMotion+=1:Yt(n)&&(n.status===`failed`?t.failedUnread+=1:n.status===`done`&&(t.finishedUnread+=1))}return t}function tx(e){let t=new Map;for(let n of e){let e=t.get(n.projectId);e?e.push(n):t.set(n.projectId,[n])}return new Map([...t].map(([e,t])=>[e,ex(t)]))}function nx(e,t,n={}){if(n.unknown)return`${e} · activity unknown`;let r=rx(t).map(e=>e.text);return[e,r.length>0?r.join(` · `):`idle`].join(` · `)}function rx(e){let{needsYou:t,failedUnread:n,inMotion:r,finishedUnread:i}=e??$b,a=[];return t>0&&a.push({tone:`amber`,text:`${t} needs you`}),n>0&&a.push({tone:`red`,text:`${n} failed`}),r>0&&a.push({tone:`violet`,text:`${r} working`}),i>0&&a.push({tone:`green`,text:`${i} finished`}),a}function ix(e){let t={...$b};for(let n of e)n&&(t.needsYou+=n.needsYou,t.failedUnread+=n.failedUnread,t.inMotion+=n.inMotion,t.finishedUnread+=n.finishedUnread);return t}function ax(e){let t=e.split(/[-_ .]+/).filter(e=>e!==``);return(t.length>=2?[t[0],t[1]].map(e=>[...e][0]):[...t[0]??``].slice(0,2)).join(``).toLowerCase()}var ox=`w-[228px] rounded-[10px] border-border bg-sidebar p-[5px] text-foreground shadow-[0_10px_28px_#00000047] motion-reduce:animate-none`,sx=`h-8 gap-2.5 rounded-[6px] px-[9px] py-0 text-[13px] focus:bg-sidebar-row-hover focus:text-foreground [&_svg]:size-[15px] [&_svg]:text-soft-foreground focus:[&_svg]:text-foreground max-md:min-h-11`;function cx(){let e=_s(),t=mn(),n=It(),r=n.data?.bootProject??t.data?.bootProject,i=e??r??null,a=n.data?.projects.find(e=>e.id===i),o=i===r?t.data?.repo:void 0,s=a?.root??o?.root;return{health:t,registry:n,projectId:i,project:a,root:s,name:a?.name??s?.split(/[\\/]/).filter(Boolean).at(-1),branch:o?.branch??a?.branch}}function lx({onNavigate:e}={}){let t=(0,Z.useRef)(null),n=(0,Z.useRef)(null),[r,i]=(0,Z.useState)(0),{health:a,registry:o,projectId:s,root:c,name:l,branch:u}=cx(),d=a.data?.capabilities.localHandoff===!0,f=l??(o.isPending?`Loading project…`:`Project unavailable`),p=[d?c:void 0,u].filter(Boolean).join(` · `);return(0,Q.jsxs)(`div`,{"data-slot":`project-header`,className:`flex min-w-0 items-center gap-2.5 px-[14px] pt-[14px] pb-2.5`,children:[(0,Q.jsx)(`span`,{ref:t,"aria-hidden":`true`,"data-slot":`project-header-mark`,className:`flex size-7 shrink-0 items-center justify-center rounded-[7px] border border-soft-foreground bg-sidebar-row-selected text-[11px] leading-none font-semibold text-foreground`,children:l?ax(l):`…`}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-px`,children:[(0,Q.jsx)(`div`,{"data-slot":`project-header-name`,className:`truncate text-[14px] font-semibold text-foreground`,title:f,children:f}),(0,Q.jsx)(`div`,{"data-slot":`project-header-detail`,dir:`rtl`,className:`truncate text-left font-mono text-[10.5px] text-soft-foreground`,title:p||void 0,children:(0,Q.jsx)(`bdi`,{dir:`ltr`,children:p||(o.isPending?`Loading…`:`Branch unavailable`)})})]}),(0,Q.jsx)(ux,{projectId:s,onNavigate:e,triggerRef:n,triggerClassName:`size-7 max-md:size-11`,align:`start`,alignOffset:r,onOpenChange:e=>{e&&t.current&&n.current&&i(t.current.getBoundingClientRect().left-n.current.getBoundingClientRect().left)}})]})}function ux({projectId:e,onNavigate:t,triggerRef:n,triggerClassName:r,align:i=`start`,alignOffset:a,side:o,onOpenChange:s}){let c=wj(),l=mn(),u=It(),[d,f]=(0,Z.useState)(!1),p=u.data?.bootProject??l.data?.bootProject,m=Dn(e??`default`,e!==null,e===p),h=vn(Ir({projectId:e??`default`,boot:e===p})),g=(0,Z.useRef)(e);g.current=e;let _=u.data?.projects.find(t=>t.id===e),v=e===p?l.data?.repo:void 0,y=_?.root??v?.root,b=l.data?.capabilities.localHandoff===!0,x=(m.data??[]).filter(e=>!Yn(e)&&Yt(e)),C=m.isError?`Unavailable`:m.data===void 0?`Loading…`:`${x.length} unread`;async function w(){f(!0);let t=0;try{for(let n of x){if(g.current!==e)break;try{await h.mutateAsync(n.id)}catch{t+=1}}t>0&&K(`Could not mark ${t} task${t===1?``:`s`} read. Try again.`,{tone:`danger`})}finally{f(!1)}}async function T(){if(y)try{await navigator.clipboard.writeText(y),K(`Project folder copied`)}catch{K(`Could not copy path: ${y}`,{tone:`danger`})}}return(0,Q.jsxs)(Li,{...S({onOpenChange:s}),children:[(0,Q.jsx)(Pi,{asChild:!0,children:(0,Q.jsx)(`button`,{"data-slot":`project-menu-trigger`,ref:n,type:`button`,"aria-label":`Project menu`,className:k(`flex shrink-0 items-center justify-center rounded-[6px] text-soft-foreground hover:bg-sidebar-row-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring data-[state=open]:bg-sidebar-row-selected data-[state=open]:text-foreground`,r),children:(0,Q.jsx)(Gp,{"aria-hidden":`true`,className:`size-[15px]`})})}),(0,Q.jsxs)(Fi,{align:i,...S({alignOffset:a,side:o}),sideOffset:4,className:ox,children:[(0,Q.jsxs)(Ai,{className:sx,disabled:d||m.isError||m.data===void 0||x.length===0||e===null,onSelect:()=>{w()},children:[(0,Q.jsx)(kp,{"aria-hidden":`true`}),` Mark all read`,(0,Q.jsx)(`span`,{className:`ml-auto text-[11.5px] text-soft-foreground`,children:d?`Marking…`:C})]}),(0,Q.jsx)(ji,{className:`mx-0`}),b&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(dx,{projectId:e??`default`,disabled:!y||_?.status===`missing`}),(0,Q.jsxs)(Ai,{className:sx,disabled:!y,onSelect:()=>{T()},children:[(0,Q.jsx)(Bp,{"aria-hidden":`true`}),` Copy path`]}),(0,Q.jsx)(ji,{className:`mx-0`})]}),(0,Q.jsx)(Ai,{asChild:!0,className:sx,children:(0,Q.jsxs)(Y,{to:`/settings`,onClick:t??c,children:[(0,Q.jsx)(xm,{"aria-hidden":`true`}),` Project settings`]})})]})]})}function dx({disabled:e,projectId:t}){let n=$t(),r=V({mutationFn:e=>ke(e,t),onError:e=>K(e.message,{tone:`danger`}),onSuccess:()=>K(`Opening project folder`)}),i=(n.data?.targets??[]).filter(e=>nv(e.id)===void 0);return(0,Q.jsxs)(Ri,{children:[(0,Q.jsxs)(Di,{className:sx,disabled:e||r.isPending,children:[(0,Q.jsx)(Ea,{"aria-hidden":`true`}),` Open in`]}),(0,Q.jsx)(Ni,{children:(0,Q.jsxs)(Ei,{className:ox,children:[i.map(e=>{let t=tv(e);return(0,Q.jsxs)(Ai,{className:sx,"data-target":e.id,onSelect:()=>r.mutate(e.id),children:[(0,Q.jsx)(t,{"aria-hidden":`true`}),e.label]},e.id)}),i.length===0&&(0,Q.jsx)(Ai,{className:sx,disabled:!0,children:n.isError?`Apps unavailable`:n.isPending?`Loading apps…`:`No apps available`})]})})]})}function fx({...e}){return(0,Q.jsx)(nu,{"data-slot":`collapsible`,...e})}function px({...e}){return(0,Q.jsx)(Zl,{"data-slot":`collapsible-trigger`,...e})}function mx({...e}){return(0,Q.jsx)($l,{"data-slot":`collapsible-content`,...e})}var hx={"needs-you":{label:`Needs you`,hint:`Asks a question, asks for permission, or waits for review`},failed:{label:`Failed`,hint:`Failed, with no scheduled resume`},done:{label:`Done`,hint:`Finished`},cancelled:{label:`Cancelled`,hint:`Was cancelled`},running:{label:`Running`,hint:`Runs an agent turn`},"waiting-workers":{label:`Waiting for agents`,hint:`Waits on its workers or their replies`},"waiting-ci":{label:`Waiting on CI`,hint:`Waits on a pull request's checks`},"waiting-timer":{label:`Waiting`,hint:`Waits on a timer`},"waiting-other":{label:`Any other wait`,hint:`Waits on anything else, including wait types added later`}},gx=(e,t)=>e.length===t.length&&e.every(e=>t.includes(e)),_x={name:``,description:``,url:``,token:``,tasks:!0,triggers:Nt,agent:!1};function vx(e){return{name:e.name,description:e.description??``,url:e.url,token:``,tasks:e.tasks,triggers:e.triggers??Nt,agent:e.agent}}var yx=e=>I.filter(t=>e.includes(t));function bx(e){let t=e.description.trim();return{name:e.name.trim(),url:e.url.trim(),...t?{description:t}:{},...e.token?{token:e.token}:{},tasks:e.tasks,...gx(e.triggers,Nt)?{}:{triggers:yx(e.triggers)},agent:e.agent}}function xx(e,t){let n={},r=e.name.trim(),i=e.description.trim(),a=e.url.trim();return r!==t.name&&(n.name=r),i!==(t.description??``)&&(n.description=i),a!==t.url&&(n.url=a),e.token&&(n.token=e.token),e.tasks!==t.tasks&&(n.tasks=e.tasks),gx(e.triggers,t.triggers??Nt)||(n.triggers=yx(e.triggers)),e.agent!==t.agent&&(n.agent=e.agent),n}var Sx=`flex flex-col gap-1 text-[13px]`,Cx=`text-[11px] text-muted-foreground`;function wx({draft:e,onChange:t,tokenSet:n}){let r=(0,Z.useId)(),i=(0,Z.useId)(),a=(0,Z.useId)(),o=(0,Z.useId)(),s=(0,Z.useId)(),c=(0,Z.useId)(),l=(0,Z.useId)(),u=(0,Z.useId)(),d=(0,Z.useId)(),f=(0,Z.useId)();return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(min(100%,14rem),1fr))] gap-3`,children:[(0,Q.jsxs)(`div`,{className:Sx,children:[(0,Q.jsx)(`label`,{htmlFor:r,className:Cx,children:`Name`}),(0,Q.jsx)(Hf,{id:r,"data-slot":`webhook-name`,autoComplete:`off`,maxLength:80,placeholder:`e.g. Team bot`,value:e.name,onChange:e=>t({name:e.target.value})})]}),(0,Q.jsxs)(`div`,{className:Sx,children:[(0,Q.jsx)(`label`,{htmlFor:o,className:Cx,children:`URL`}),(0,Q.jsx)(Hf,{id:o,"data-slot":`webhook-url`,type:`url`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,maxLength:pe,placeholder:`https://bot.example/hooks/cez`,value:e.url,onChange:e=>t({url:e.target.value})})]})]}),(0,Q.jsxs)(`div`,{className:Sx,children:[(0,Q.jsx)(`label`,{htmlFor:i,className:Cx,children:`Description`}),(0,Q.jsx)(Fo,{id:i,"data-slot":`webhook-description`,"aria-describedby":a,rows:2,maxLength:Se,placeholder:`e.g. Posts to the #releases channel. Use it for release notes.`,value:e.description,onChange:e=>t({description:e.target.value})}),(0,Q.jsx)(`span`,{id:a,className:`text-[11px] text-soft-foreground`,children:`Agents read the name and description to decide when to use this webhook.`})]}),(0,Q.jsxs)(`div`,{className:Sx,children:[(0,Q.jsx)(`label`,{htmlFor:s,className:Cx,children:`Token`}),(0,Q.jsx)(Hf,{id:s,"data-slot":`webhook-token`,type:`password`,autoComplete:`new-password`,spellCheck:!1,maxLength:ce,"aria-describedby":c,placeholder:n?`Token set — type to replace`:`Optional Bearer token`,value:e.token,onChange:e=>t({token:e.target.value})}),(0,Q.jsx)(`span`,{id:c,className:`text-[11px] text-soft-foreground`,children:n?`The token is stored in ~/.cezar and never shown again. Leave it empty to keep it.`:`The token is stored in ~/.cezar, never in the repo. It is sent as a Bearer header.`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3`,children:[(0,Q.jsx)(oa,{id:l,"aria-describedby":u,"data-slot":`webhook-tasks`,checked:e.tasks,onCheckedChange:e=>t({tasks:e})}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col text-[13px]`,children:[(0,Q.jsx)(`label`,{htmlFor:l,className:`font-medium`,children:`Task notifications`}),(0,Q.jsx)(`span`,{id:u,className:`text-[11px] text-soft-foreground`,children:`Tasks you hand off, or start with notify on, send their status here.`})]})]}),e.tasks?(0,Q.jsxs)(`fieldset`,{"data-slot":`webhook-triggers`,className:`flex flex-col gap-1 sm:ps-[3.25rem]`,children:[(0,Q.jsx)(`legend`,{className:`pbe-1 text-[11px] text-muted-foreground`,children:`Send a delivery when a task enters`}),(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(min(100%,15rem),1fr))] gap-x-3`,children:I.map(n=>(0,Q.jsxs)(`label`,{className:`flex min-h-11 items-start gap-2.5 pbs-2 text-[13px]`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,"data-trigger":n,checked:e.triggers.includes(n),onChange:r=>t({triggers:r.target.checked?[...e.triggers,n]:e.triggers.filter(e=>e!==n)}),className:`mbs-0.5 size-[18px] shrink-0`}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:hx[n].label}),(0,Q.jsx)(`span`,{className:`text-[11px] text-soft-foreground`,children:hx[n].hint})]})]},n))}),(0,Q.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:`Handing a task off and Send test always deliver.`})]}):null]}),(0,Q.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3`,children:[(0,Q.jsx)(oa,{id:d,"aria-describedby":f,"data-slot":`webhook-agent`,checked:e.agent,onCheckedChange:e=>t({agent:e})}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col text-[13px]`,children:[(0,Q.jsx)(`label`,{htmlFor:d,className:`font-medium`,children:`Let agents send reports`}),(0,Q.jsx)(`span`,{id:f,className:`text-[11px] text-soft-foreground`,children:`Agents in this project may post a report here when the task calls for it.`})]})]})]})}var Tx=`max-sm:h-11`,Ex=(e,t)=>({tone:`alert`,text:`Not saved: ${e.message}. Fix the field and select ${t} again.`}),Dx=e=>e.dryRun?{tone:`ok`,text:`Dry run: nothing was sent.`}:e.ok?{tone:`ok`,text:`Delivered (HTTP ${e.status??200}).`}:{tone:`danger`,text:`Not delivered: ${e.error??`unknown error`}.`};function Ox({feedback:e}){return e?(0,Q.jsx)(`p`,{"data-slot":e.tone===`alert`?`webhook-error`:`webhook-result`,role:e.tone===`alert`?`alert`:`status`,className:e.tone===`ok`?`text-[13px] text-muted-foreground`:`text-[13px] text-danger`,children:e.text}):null}var kx=`rounded-md border border-border bg-background`,Ax=`flex flex-col gap-3 border-bs border-border p-3`;function jx({projectId:e,webhook:t,defaultOpen:n=!1}){let r=cn(),i=cr(),a=dn(),[o,s]=(0,Z.useState)(n),[c,l]=(0,Z.useState)(()=>vx(t)),[u,d]=(0,Z.useState)(null),f=xx(c,t),p=Object.keys(f).length>0,m=c.name.trim()!==``&&c.url.trim()!==``,h=r.isPending||i.isPending||a.isPending,g={projectId:e,webhookId:t.id},_=e=>r.mutate({...g,...f},{onSuccess:()=>{l(e=>({...e,token:``})),e?e():K(`${c.name.trim()} saved`)},onError:e=>d(Ex(e,`Save`))}),v=()=>a.mutate(g,{onSuccess:e=>d(Dx(e)),onError:e=>d({tone:`danger`,text:e.message})});return(0,Q.jsx)(`li`,{"data-slot":`webhook-card`,"data-webhook-id":t.id,className:kx,children:(0,Q.jsxs)(fx,{open:o,onOpenChange:s,children:[(0,Q.jsx)(px,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-action":`webhook-toggle`,className:`group flex min-h-11 w-full items-center gap-3 rounded-md p-3 text-start focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-foreground pointer-hover:bg-muted/50 active:bg-muted/50`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,Q.jsx)(`span`,{"data-slot":`webhook-card-name`,className:`min-w-0 break-words text-[13px] font-medium`,children:t.name}),t.tasks?(0,Q.jsx)(Pf,{variant:`secondary`,"data-badge":`tasks`,children:`Task notifications`}):null,t.agent?(0,Q.jsx)(Pf,{variant:`secondary`,"data-badge":`agent`,children:`Agents`}):null]}),(0,Q.jsx)(`span`,{"data-slot":`webhook-card-url`,className:`truncate text-[12px] text-muted-foreground`,children:Sh(t.url)})]}),(0,Q.jsx)(So,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground group-data-[state=open]:rotate-180`})]})}),(0,Q.jsx)(mx,{children:(0,Q.jsxs)(`form`,{"data-slot":`webhook-form`,className:Ax,onSubmit:e=>{e.preventDefault(),d(null),m&&p&&_()},children:[(0,Q.jsx)(wx,{draft:c,tokenSet:t.tokenSet,onChange:e=>l(t=>({...t,...e}))}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(O,{type:`submit`,size:`sm`,className:Tx,"data-action":`webhook-save`,disabled:h||!m||!p,children:`Save`}),(0,Q.jsx)(O,{type:`button`,size:`sm`,className:Tx,variant:`outline`,"data-action":`webhook-test`,disabled:h||!m,onClick:()=>{d(null),p?_(v):v()},children:`Send test`}),t.tokenSet?(0,Q.jsx)(O,{type:`button`,size:`sm`,className:Tx,variant:`ghost`,"data-action":`webhook-clear-token`,disabled:h,onClick:()=>r.mutate({...g,token:``},{onSuccess:()=>K(`Webhook token cleared`),onError:e=>d({tone:`danger`,text:`Token not cleared: ${e.message}.`})}),children:`Clear token`}):null,(0,Q.jsx)(O,{type:`button`,size:`sm`,className:Tx,variant:`danger-ghost`,"data-action":`webhook-remove`,"aria-label":`Remove ${t.name}`,disabled:h,onClick:()=>i.mutate(g,{onSuccess:()=>K(`${t.name} removed`),onError:e=>d({tone:`danger`,text:`Not removed: ${e.message}.`})}),children:`Remove`})]}),(0,Q.jsx)(Ox,{feedback:u})]})})]})})}function Mx({projectId:e,onCreated:t,onCancel:n}){let r=Rn(),[i,a]=(0,Z.useState)(_x),[o,s]=(0,Z.useState)(null),c=i.name.trim()!==``&&i.url.trim()!==``;return(0,Q.jsxs)(`li`,{"data-slot":`webhook-card`,"data-draft":``,className:kx,children:[(0,Q.jsx)(`p`,{className:`p-3 text-[13px] font-medium`,children:`New webhook`}),(0,Q.jsxs)(`form`,{"data-slot":`webhook-form`,"aria-label":`New webhook`,className:Ax,onSubmit:n=>{n.preventDefault(),s(null),c&&r.mutate({projectId:e,...bx(i)},{onSuccess:({webhook:e})=>{K(`${e.name} created`),t(e)},onError:e=>s(Ex(e,`Create`))})},children:[(0,Q.jsx)(wx,{draft:i,tokenSet:!1,onChange:e=>a(t=>({...t,...e}))}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(O,{type:`submit`,size:`sm`,className:Tx,"data-action":`webhook-create`,disabled:r.isPending||!c,children:`Create`}),(0,Q.jsx)(O,{type:`button`,size:`sm`,className:Tx,variant:`ghost`,"data-action":`webhook-cancel`,disabled:r.isPending,onClick:n,children:`Cancel`})]}),(0,Q.jsx)(Ox,{feedback:o})]})]})}function Nx({project:e}){let t=e.webhooks??[],[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(null),o=t.length>=16;return(0,Q.jsx)(cb,{title:`Webhooks`,hint:`A webhook gets a POST from cezar. Tasks can send their status to it, and agents can send it reports.`,children:(0,Q.jsxs)(`div`,{"data-slot":`project-webhooks`,className:`flex flex-col gap-3`,children:[t.length===0&&!n?(0,Q.jsx)(`p`,{"data-slot":`webhooks-empty`,className:`text-[13px] text-soft-foreground`,children:`No webhooks yet. Add one to send task updates to a bot, or to let agents post reports.`}):null,t.length>0||n?(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-2`,children:[t.map(t=>(0,Q.jsx)(jx,{projectId:e.id,webhook:t,defaultOpen:t.id===i},t.id)),n?(0,Q.jsx)(Mx,{projectId:e.id,onCancel:()=>r(!1),onCreated:e=>{a(e.id),r(!1)}}):null]}):null,n?null:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(O,{type:`button`,size:`sm`,variant:`outline`,className:`max-sm:h-11`,"data-action":`webhook-add`,disabled:o,onClick:()=>r(!0),children:[(0,Q.jsx)(vm,{"aria-hidden":`true`}),`Add webhook`]}),o?(0,Q.jsxs)(`span`,{className:`text-[11px] text-soft-foreground`,children:[`A project holds at most `,16,` webhooks.`]}):null]})]})})}function Px(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}function Fx({capabilities:e}){let t=_s(),n=It(),r=Lr();if(n.isPending)return(0,Q.jsx)(`p`,{"data-slot":`project-general-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading project…`});if(n.isError)return(0,Q.jsxs)(`p`,{"data-slot":`project-general-error`,className:`text-[13px] text-danger`,children:[`Could not read the project registry — `,n.error.message]});let i=n.data,a=i?.projects.find(e=>e.id===t);if(!i||!a)return null;let o=e?.singleProject!==!0;return(0,Q.jsxs)(`div`,{"data-slot":`project-general`,className:`flex w-full flex-col gap-5`,children:[(0,Q.jsxs)(`section`,{className:`flex flex-col gap-5 rounded-lg border border-border bg-card p-5 [&_select]:min-h-11 [&_select]:w-full`,children:[(0,Q.jsx)(`h2`,{className:`text-lg font-semibold`,children:`General`}),(0,Q.jsx)(Rb,{}),(0,Q.jsx)(Ix,{project:a,canRemove:o}),o?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(cb,{title:`Max parallel tasks`,hint:r.data?`The workspace limit (${r.data.resources.maxParallel}) still applies as an overall ceiling.`:`How many of this project's tasks may run at once. The workspace limit still applies as an overall ceiling.`,children:r.data?(0,Q.jsx)(vb,{project:a,workspaceMax:r.data.resources.maxParallel}):(0,Q.jsx)(`p`,{className:`text-[13px] text-soft-foreground`,children:`Loading the workspace limit…`})}),(0,Q.jsx)(Nx,{project:a},a.id)]}):null]}),o?(0,Q.jsx)(`section`,{className:`rounded-lg border border-border bg-card p-5`,children:(0,Q.jsx)(Lx,{project:a,bootProject:i.bootProject})}):null]})}function Ix({project:e,canRemove:t}){return(0,Q.jsxs)(`dl`,{"data-slot":`project-facts`,className:`grid grid-cols-1 gap-4 text-[13px] sm:grid-cols-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Project`}),(0,Q.jsx)(`dd`,{className:`mt-1 font-medium`,children:e.name})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Branch`}),(0,Q.jsx)(`dd`,{className:`mt-1 break-all`,children:e.branch??`—`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Status`}),(0,Q.jsxs)(`dd`,{"data-slot":`project-general-status`,className:e.status===`missing`?`mt-1 text-danger`:`mt-1`,children:[ub[e.status],e.status===`missing`?t?` — remove it below, or restore the folder`:` — restore the folder at the path above`:null]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Added`}),(0,Q.jsxs)(`dd`,{className:`mt-1`,children:[Px(e.addedAt),(0,Q.jsx)(`span`,{className:`text-soft-foreground`,children:e.source===`checkout`?` · cloned from GitHub`:` · opened locally`})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-[11px] text-muted-foreground`,children:`Last opened`}),(0,Q.jsx)(`dd`,{className:`mt-1`,children:Px(e.lastOpenedAt)})]})]})}function Lx({project:e,bootProject:t}){let[n,r]=(0,Z.useState)(null),i=ob(),a=j(),o=e.id===t;return(0,Q.jsxs)(cb,{title:`Remove from workspace`,hint:`Unregisters this project so it leaves the sidebar and the project list. Nothing on disk is deleted — the folder, its git history and its task history all stay, and opening it again re-registers it.`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(O,{type:`button`,variant:`outline`,size:`sm`,"data-action":`project-general-remove`,"aria-label":`Remove ${e.name} from the workspace — unregisters it, no files are deleted`,title:o?`cezar is serving this project — it re-registers itself at every start`:void 0,disabled:o||i.isPending,onClick:()=>r(e),className:`text-danger`,children:[`Remove `,e.name]}),o?(0,Q.jsx)(`span`,{"data-slot":`project-general-remove-boot`,className:`text-[11px] text-soft-foreground`,children:`cezar is serving this project — it re-registers itself at every start.`}):null]}),(0,Q.jsx)(sb,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{r(null),i.confirm(e,()=>void a(`/p/${encodeURIComponent(t)}`))}})]})}function Rx(e,t){return e===`global`?`/settings/global/${t}`:`/settings/${t}`}var zx=Rx(`global`,`appearance`);function Bx(e){return e===`global`?{Link:T,NavLink:C}:{Link:Y,NavLink:ms}}function Vx({scope:e,title:t,mobileTitle:n}){let r=cx().name;return(0,Q.jsxs)(`header`,{"data-slot":`settings-main-header`,className:`settings-route-header flex shrink-0 flex-col gap-2`,children:[(0,Q.jsxs)(`h1`,{className:`text-[15px] font-semibold tracking-normal max-md:text-[24px] max-md:font-normal`,children:[(0,Q.jsx)(`span`,{className:`md:hidden`,children:n}),(0,Q.jsxs)(`span`,{className:`max-md:hidden`,children:[t,` · `,e===`global`?`every project`:r??`this project`]})]}),e===`global`?(0,Q.jsx)(`span`,{"data-slot":`settings-scope-chip`,className:`sr-only`,children:`Global settings`}):null]})}function Hx({scope:e,activeId:t,capabilities:n}){let{NavLink:r}=Bx(e),i=qb(e,n);return(0,Q.jsxs)(`details`,{className:`settings-section-picker md:hidden`,children:[(0,Q.jsxs)(`summary`,{children:[i.find(e=>e.id===t)?.title??`General`,(0,Q.jsx)(So,{"aria-hidden":`true`,className:`size-5 text-muted-foreground`})]}),(0,Q.jsxs)(`nav`,{"aria-label":`Settings sections`,"data-slot":`settings-nav-mobile`,"data-scope":e,children:[e===`project`?(0,Q.jsx)(r,{to:`/settings`,end:!0,"data-slot":`settings-nav-index`,children:`General`}):null,i.map(t=>(0,Q.jsx)(r,{to:Rx(e,t.id),"data-section":t.id,children:t.title},t.id))]})]},`${e}-${t}`)}function Ux({section:e,scope:t,capabilities:n}){let r=e.component;return(0,Q.jsxs)(`div`,{"data-route":t===`global`?`settings-global-${e.id}`:`settings-${e.id}`,className:`settings-route mx-auto flex min-h-full w-full flex-col`,children:[(0,Q.jsx)(Vx,{scope:t,title:e.title,mobileTitle:t===`global`?`Global settings`:`Project settings`}),(0,Q.jsxs)(`div`,{className:`settings-route-body flex min-w-0 flex-1 flex-col md:flex-row`,children:[(0,Q.jsx)(Hx,{scope:t,activeId:e.id,capabilities:n}),(0,Q.jsxs)(`section`,{className:`settings-panel min-w-0 self-start md:flex-1`,"aria-label":e.title,children:[(0,Q.jsx)(`h2`,{className:`settings-panel-title`,children:e.title}),(0,Q.jsx)(r,{})]})]})]})}function Wx({capabilities:e}){return(0,Q.jsxs)(`div`,{"data-route":`settings`,className:`settings-route mx-auto flex min-h-full w-full flex-col`,children:[(0,Q.jsx)(Vx,{scope:`project`,title:`General`,mobileTitle:`Project settings`}),(0,Q.jsxs)(`div`,{className:`settings-route-body flex min-w-0 flex-1 flex-col md:flex-row`,children:[(0,Q.jsx)(Hx,{scope:`project`,activeId:null,capabilities:e}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-5`,children:[(0,Q.jsx)(Fx,{capabilities:e}),(0,Q.jsx)(`section`,{className:`rounded-lg border border-border bg-card p-5`,children:(0,Q.jsx)(W_,{})}),(0,Q.jsx)(`h2`,{className:`settings-other-title mt-6 rounded-t-lg border border-b-0 border-border bg-card px-5 pt-5 text-base font-semibold md:hidden`,children:`Other project settings`}),(0,Q.jsx)(`ul`,{"data-slot":`settings-index`,className:`mt-7 flex w-full flex-col gap-5 md:hidden`,children:qb(`project`,e).map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(Y,{to:Rx(`project`,e.id),"data-section":e.id,className:`flex items-center gap-3.5 rounded-lg border border-border bg-card p-4 transition-colors hover:bg-card-2`,children:[(0,Q.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center text-accent-text`,children:(0,Q.jsx)(e.icon,{"aria-hidden":`true`,className:`size-4`})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:e.title}),(0,Q.jsx)(`span`,{className:`block text-xs text-soft-foreground`,children:e.description})]}),(0,Q.jsx)($a,{"aria-hidden":`true`,className:`size-4 shrink-0 text-soft-foreground`})]})},e.id))}),(0,Q.jsxs)(`p`,{className:`mt-5 w-full text-[12px] text-soft-foreground`,children:[`Appearance, notifications, host resources and the project registry live in`,` `,(0,Q.jsx)(T,{to:zx,"data-slot":`settings-global-link`,className:`underline underline-offset-2 hover:text-foreground`,children:`Global settings`}),`.`]})]})]})]})}function Gx(e){if(e<1e3)return String(e);let t=[`k`,`M`,`B`,`T`],n=Math.floor(Math.log10(e)/3);return n>t.length?e.toExponential(0).replace(`+`,``):`${Math.floor(e/1e3**n)}${t[n-1]}`}function Kx({stat:e,className:t,compact:n=!1}){let r=`+${e.adds} −${e.dels} across ${e.files} ${e.files===1?`file`:`files`}`,i=e.repointed?`${r} — measured against another branch checked out in this task's worktree, as this task found it`:void 0;return(0,Q.jsxs)(`span`,{"data-slot":`diff-stat`,...i?{"data-repointed":`true`,"aria-label":i}:{},...n&&!i?{"aria-label":r}:{},title:i??r,className:k(`font-mono text-xs font-semibold tabular-nums`,e.repointed&&`cursor-help underline decoration-dotted underline-offset-2`,t),children:[(0,Q.jsxs)(`span`,{className:`text-success`,children:[`+`,n?Gx(e.adds):e.adds.toLocaleString(`en-US`)]}),` `,(0,Q.jsxs)(`span`,{className:`text-danger`,children:[`−`,n?Gx(e.dels):e.dels.toLocaleString(`en-US`)]})]})}function qx(e){return e===void 0?`unknown`:new Intl.NumberFormat().format(e)}function Jx(e,t){return`Input tokens: ${qx(e)}; output tokens: ${qx(t)}`}function Yx(e,t,n=`compact`){let r=e===void 0?`—`:zo(e),i=t===void 0?`—`:zo(t);return n===`table`?`${r} / ${i}`:`IN ${r} · OUT ${i}`}function Xx({inputTokens:e,outputTokens:t,variant:n=`compact`,omitWhenUnknown:r=!0,className:i,title:a}){return r&&e===void 0&&t===void 0?null:(0,Q.jsx)(`span`,{"data-slot":`directional-usage`,"aria-label":Jx(e,t),title:a,className:k(`font-mono tabular-nums`,i),children:Yx(e,t,n)})}function Zx(e,t){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(``),o=(0,Z.useRef)(!1);return{editing:n,draft:i,setDraft:a,begin:()=>{a(e),o.current=!1,r(!0)},commit:()=>{if(o.current)return;o.current=!0,r(!1);let n=i.trim();n.length===0||n===e||t(n)},cancel:()=>{o.current=!0,r(!1)}}}function Qx({editor:e,className:t}){return(0,Q.jsx)(`input`,{"data-slot":`title-input`,"aria-label":`Task title`,autoFocus:!0,value:e.draft,onChange:t=>e.setDraft(t.target.value),onBlur:e.commit,onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),e.commit()):t.key===`Escape`&&(t.preventDefault(),e.cancel())},className:k(`w-full min-w-0 rounded-sm border border-border bg-card px-1.5 py-0.5 outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`,t)})}function $x({className:e,dot:t,shape:n=`filled`,pulse:r=!1,children:i,...a}){return(0,Q.jsxs)(`span`,{"data-slot":`pill`,className:k(`inline-flex items-center gap-1.5 rounded-full bg-muted px-2.5 py-[3px] text-xs font-medium whitespace-nowrap text-muted-foreground`,e),...a,children:[t?(0,Q.jsx)(J_,{tone:t,shape:n,pulse:r}):null,i]})}function eS({pinned:e,onToggle:t,className:n}){return(0,Q.jsx)(`button`,{type:`button`,"data-slot":`pin-toggle`,"data-pinned":e?`true`:void 0,"aria-pressed":e,"aria-label":e?`Unpin task`:`Pin task`,title:e?`Unpin from the top of the list`:`Pin to the top of the list`,onClick:n=>{n.stopPropagation(),t(!e)},className:k(`inline-flex size-5 shrink-0 items-center justify-center rounded-sm text-soft-foreground transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,n,`max-md:min-h-11 max-md:min-w-11 no-hover:min-h-11 no-hover:min-w-11`),children:(0,Q.jsx)(gm,{"data-slot":`pin-icon`,className:`size-[12px]`,fill:e?`currentColor`:`none`,"aria-hidden":`true`})})}function tS(e){let t=e.currentStepId?e.steps.find(t=>t.id===e.currentStepId):void 0;if(t?.backend)return t.backend;if(e.runner)return e.runner;for(let t=e.steps.length-1;t>=0;--t){let n=e.steps[t]?.backend;if(n)return n}return`claude`}var nS={claude:`Claude Code`,codex:`Codex`,opencode:`OpenCode`,pi:`pi`,cursor:`Cursor`,omp:`OMP`};function rS(e){return e.runner??`claude`}function iS(e,t){let n=Et(t,e);return n?.enabled===!1?{provider:e,usable:!1,reason:`${nS[e]} is disabled. Enable it in ${cs(`providers`)}.`}:n?.status===`connected`?{provider:e,usable:!0}:{provider:e,usable:!1,reason:`${nS[e]} credentials are unavailable. Authorize it in ${cs(`providers`)}.`}}function aS(e,t){return iS(tS(e),t)}function oS(e,t){return iS(rS(e),t)}function sS(e){let t=Kn(),n=tS(e);return t.isSuccess&&t.data?aS(e,t.data):{provider:n,usable:!0}}function cS(e){let t=Kn(),n=rS(e);return t.isSuccess&&t.data?oS(e,t.data):t.isError?{provider:n,usable:!1,reason:`Provider authentication could not be verified.`}:{provider:n,usable:!1,reason:`Checking agent providers…`}}function lS(e){return[...e.steps].reverse().find(e=>e.sessionId)?.sessionId}function uS(e){return[...e.steps].reverse().find(e=>e.sessionId)?.backend??e.runner??`claude`}var dS=/^[A-Za-z0-9._][A-Za-z0-9._-]{0,199}$/;function fS(e,t){if(dS.test(t))switch(e){case`codex`:return`codex resume ${t}`;case`cursor`:return;case`opencode`:return`opencode --session ${t}`;case`pi`:return`pi --session ${t}`;case`omp`:return;default:return`claude --resume ${t}`}}function pS(e){if(ln(e))return;let t=lS(e);if(t===void 0||!dS.test(t))return;let n=uS(e),r=n===`cursor`||n===`omp`?e.cliResumeCommand:fS(n,t);if(r!==void 0)return e.worktreePath?`cd ${e.worktreePath} && ${r}`:r}function mS(e,t){let n=nv(t);return!n||ln(e)?!1:n===uS(e)&&lS(e)!==void 0}function hS(e){return(e.status===`failed`||P(e))&&(e.waits?.length??0)>0}function gS(e){return e.status===`cancelled`&&e.startedAt===void 0&&e.workflowDef!==void 0&&e.steps.every(e=>e.status===`pending`&&e.startedAt===void 0&&!e.sessionId)}function _S(e){let t=ln(e),n=lS(e)!==void 0;return{finish:e.status===`waiting`&&t||e.status===`review`,continueRun:!t&&!e.stopping&&e.delegation?.role!==`invalid`&&!(e.delegation?.role===`worker`&&e.delegation.destroy)&&(n||gS(e)),terminal:!t&&n,notes:!0,archive:!t,pin:!e.archived&&!Yn(e),markUnread:nr(e)&&!Yt(e),cancel:t||hS(e),deleteRun:!t}}function vS(e){let t=_S(e);return t.archive&&!t.cancel&&!e.archiveBlocker}function yS(e){return e.status===`waiting`&&e.finishBlocked===null&&fe(e).bucket===`waiting`}function bS(e){return`Merge head branch and resolve conflicts in ${e?`PR number ${e}`:`this pull request`}`}function xS(e){return e===`review`?`Accept the changes without a PR`:`Close the session`}function SS(e,t){let n=e.filter(e=>!e.archived&&e.status===`queued`).sort((e,t)=>e.createdAt.localeCompare(t.createdAt)).findIndex(e=>e.id===t);return n>=0?n+1:void 0}var CS=[50,100,200,400,800,1e3,1e3,1e3,1e3],wS=e=>new Promise(t=>setTimeout(t,e));function TS(e){return e instanceof Ze&&e.status===409&&e.message===`run is still active`}async function ES(e,t=wS){for(let n=0;;n+=1)try{return await e()}catch(e){let r=CS[n];if(!TS(e)||r===void 0)throw e;await t(r)}}function DS(e){return ln(e)?`live`:_S(e).continueRun?`resume`:`unavailable`}function OS(e,t){let n=Bt(e.id,t),r=Nn(e.id,t),i=sS(e),a=cS(e),[o,s]=(0,Z.useState)(void 0),[c,l]=(0,Z.useState)(!1),u=(0,Z.useRef)(!1),d=DS(e),f=d===`resume`?!a.usable:d===`live`&&!i.usable,p=d===`unavailable`?`no-session`:f?`provider`:void 0,m=p===`no-session`?`This session has ended and no agent session was recorded, so the answer cannot be delivered.`:p===`provider`?d===`resume`?a.reason:i.reason:void 0,h=(e,t)=>a.usable?r.mutateAsync({text:e,...t===void 0?{}:{images:t}}):Promise.reject(Error(a.reason??`The run provider is unavailable.`));return{mode:d,blockedBy:p,reason:m,isPending:c||n.isPending||r.isPending,error:o,send:async(t,r)=>{if(p||u.current)return m;u.current=!0,l(!0),s(void 0);try{if(d===`resume`){await ES(()=>h(t,r));return}try{await n.mutateAsync({text:t,...r===void 0?{}:{images:r}})}catch(n){if(n instanceof Ze&&n.status===409&&lS(e)!==void 0){try{await ES(()=>h(t,r))}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Session closed. Retry to reopen the session. ${t}`)}return}throw n}return}catch(e){let t=e instanceof Error?e.message:String(e);return s(t),t}finally{u.current=!1,l(!1)}}}}function kS({run:e,projectId:t,prNumber:n}){let r=OS(e,t),i=as(),[a,o]=(0,Z.useState)(!1),s=a||r.isPending,c=!!r.blockedBy,l=async()=>{if(s||c)return;let e=r.mode===`resume`;o(!0);try{let t=await r.send(bS(n));t?K(t,{tone:`danger`}):(K(`${e?`Task reopened`:`Sent to the task`} — resolving conflicts${n?` in PR #${n}`:``}`),i())}finally{o(!1)}};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(O,{type:`button`,size:`sm`,"data-slot":`reference-conflict-action`,disabled:c||s,onClick:()=>void l(),className:`h-7 w-full text-xs`,children:s?`Sending…`:`Resolve conflicts`}),c&&r.reason?(0,Q.jsx)(`span`,{className:`block opacity-70`,children:r.reason}):null]})}function AS({projectId:e,runId:t,prNumber:n}){let r=kn(e,t);return r.data?(0,Q.jsx)(kS,{run:r.data,projectId:e,prNumber:n}):(0,Q.jsx)(O,{type:`button`,size:`sm`,disabled:!0,className:`h-7 w-full text-xs`,children:r.isError?`Unavailable`:`Loading…`})}function jS({runId:e,prNumber:t}){let{projectId:n}=is();return n===void 0?(0,Q.jsx)(MS,{runId:e,prNumber:t}):(0,Q.jsx)(AS,{projectId:n,runId:e,prNumber:t})}function MS({runId:e,prNumber:t}){let n=Xn(e);return n.data?(0,Q.jsx)(kS,{run:n.data,prNumber:t}):(0,Q.jsx)(O,{type:`button`,size:`sm`,disabled:!0,className:`h-7 w-full text-xs`,children:n.isError?`Unavailable`:`Loading…`})}function NS({run:e,reference:t,className:n,compact:r=!1,plain:i=!1,inert:a=!1}){let{projectId:o,repoBase:s}=is(),c=o!==void 0&&t.number!==void 0?tr(o,e.id,{kind:t.kind,number:t.number,url:t.url},s):void 0;return(0,Q.jsx)(os,{reference:t,taskTitle:xn(e),to:c,conflictAction:Mn({...t,number:t.number??0},s)?(0,Q.jsx)(jS,{runId:e.id,prNumber:t.number}):void 0,className:n,compact:r,plain:i,inert:a})}var PS=[{value:`all`,label:`All`},{value:`direct`,label:`Direct tasks`},{value:`automations`,label:`Automations`}];function FS(e){return e===`direct`||e===`automations`?e:`all`}function IS(e,t){return t===`all`||de(e)===(t===`automations`)}function LS(e){return e===`all`?void 0:e===`automations`}function RS(e,t){let n={all:0,direct:0,automations:0};for(let r of e)Yn(r)||r.archived!==(t===`archived`)||(n.all+=1,de(r)?n.automations+=1:n.direct+=1);return n}function zS(e){return e.rows.map(e=>e.run)}function BS(e,t){switch(e){case`Needs you`:return`pending`;case`Working`:return`running`;case`Archived`:return`neutral`;case`Finished`:return t.some(e=>fe(e).bucket===`error`)?`danger`:`success`}}function VS(e,t,n){return Qn(e,t,zn(n))}var HS=(e,t)=>JSON.stringify([e,t]);function US(e,t,n){let r=new Map,i=e.map(e=>{let{run:t}=e,n=HS(t.projectId,t.id);r.set(n,e);let i=t.delegation;return{...t,id:n,...i&&`parentRunId`in i?{delegation:{...i,parentRunId:HS(t.projectId,i.parentRunId)}}:{}}}),a=new Map;for(let e of n){let t=a.get(e.projectId);t?t.push(e):a.set(e.projectId,[e])}let o=new Map;for(let[e,t]of a)for(let[n,r]of zn(t))o.set(HS(e,n),r);let s=e=>r.get(e.id);return Qn(i,t,o).map(e=>({label:e.label,rows:e.rows.map(e=>({kind:`run`,run:s(e.run),queuePosition:e.queuePosition}))}))}function WS(e){return[e.run]}var GS=/^- \S+ — (?:(?:turn complete|step ".*" complete|step ".*" ended without done|session idle-closed) — |worktree setup (?:done in|failed —|skipped —) )/;function KS(e,t=3){let n=Ne(e,`## Progress log`);if(n<0)return[];let r=[];for(let i of e.slice(Ae(e,n)).split(`
11
+ `)){if(r.length>=t||i.startsWith(`## `))break;let e=i.trim();!e||GS.test(e)||r.push(e.replace(/^[-*] /,``))}return r}function qS({origin:e,counts:t,onChange:n}){return(0,Q.jsx)(`div`,{role:`group`,"aria-label":`Task origin`,"data-slot":`origin-filter`,className:`flex flex-wrap items-center gap-1.5`,children:PS.map(r=>{let i=r.value===e;return(0,Q.jsxs)(`button`,{type:`button`,"data-origin":r.value,"aria-pressed":i,onClick:()=>n(r.value),className:k(`inline-flex min-h-11 items-center gap-1.5 rounded-full border border-border px-3 text-[13px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`,i&&`border-accent-strong bg-accent-strong/10 text-accent-text`),children:[r.label,` `,(0,Q.jsx)(`span`,{className:`tabular-nums`,children:t[r.value]})]},r.value)})})}function JS({onExpand:e,onCollapse:t}){return(0,Q.jsxs)(`div`,{"data-slot":`group-fold-controls`,className:`hidden flex-wrap items-center gap-2 md:ml-auto md:flex`,children:[(0,Q.jsx)(O,{type:`button`,variant:`ghost`,className:`min-h-11`,"data-action":`expand-groups`,onClick:e,children:`Expand groups`}),(0,Q.jsx)(O,{type:`button`,variant:`ghost`,className:`min-h-11`,"data-action":`collapse-groups`,onClick:t,children:`Collapse groups`})]})}function YS({origin:e,counts:t,onChange:n,labels:r,onSetAll:i}){return(0,Q.jsxs)(`div`,{"data-slot":`task-origin-row`,className:`flex flex-wrap items-center gap-2.5`,children:[(0,Q.jsx)(qS,{origin:e,counts:t,onChange:n}),r.length>0?(0,Q.jsx)(JS,{onExpand:()=>i(r,!1),onCollapse:()=>i(r,!0)}):null]})}var XS={pending:`needs you`,running:`working`,success:`finished`,danger:`contains failed tasks`,neutral:`archived`};function ZS({id:e,label:t,count:n,tone:r,folded:i,collapsed:a,onToggle:o,children:s}){let c=a?$a:So;return(0,Q.jsxs)(`section`,{"data-slot":`task-status-group`,"data-bucket":t,"data-folded":i,"data-tone":r,"aria-labelledby":`${e}-heading`,className:`flex flex-col gap-2.5`,children:[(0,Q.jsx)(`h2`,{id:`${e}-heading`,className:`text-[13px] font-semibold text-foreground`,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`status-group-toggle`,"aria-expanded":!a,"aria-controls":`${e}-rows`,"aria-label":`${t} ${n}${r===`danger`?`, contains failed tasks`:``}`,onClick:o,className:`inline-flex min-h-11 items-center gap-2 rounded-md pr-2 hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`,children:[(0,Q.jsx)(c,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,Q.jsx)(J_,{tone:r,role:`img`,"aria-label":XS[r],title:XS[r]}),(0,Q.jsx)(`span`,{children:t}),` `,(0,Q.jsx)(`span`,{className:`font-normal tabular-nums text-muted-foreground`,children:n})]})}),(0,Q.jsx)(`div`,{id:`${e}-rows`,hidden:a,children:a?null:s})]})}function QS({automationId:e,automationName:t,project:n}){let r=e===void 0?`Direct task`:t??e;return(0,Q.jsxs)(`span`,{"data-slot":`task-origin`,"data-origin":e===void 0?`direct`:`automation`,className:`flex min-w-0 flex-wrap items-center gap-x-1.5 text-xs text-muted-foreground`,children:[n?(0,Q.jsxs)(Q.Fragment,{children:[n,(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`·`})]}):null,(0,Q.jsx)(`span`,{className:`min-w-0 break-words`,title:e===void 0?void 0:`Automation ${e}`,children:r})]})}function $S({projectId:e,runId:t,status:n,error:r,open:i}){let a=un(e,t,!0),o=a.data===void 0?[]:KS(a.data);return(0,Q.jsxs)(`div`,{"data-slot":`task-preview`,className:`flex flex-col gap-3 rounded-md bg-muted/50 p-4 text-xs`,children:[(0,Q.jsx)(`p`,{className:`font-medium text-foreground first-letter:uppercase`,children:n}),r?(0,Q.jsx)(`p`,{"data-slot":`task-preview-error`,className:`break-words text-danger`,children:r}):null,a.isPending?(0,Q.jsx)(`p`,{role:`status`,className:`text-muted-foreground`,children:`Loading latest progress…`}):a.isError?(0,Q.jsx)(`p`,{"data-slot":`task-preview-unavailable`,className:`text-muted-foreground`,children:`Latest progress is unavailable.`}):o.length===0?(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:`No progress recorded yet.`}):(0,Q.jsx)(`ul`,{"aria-label":`Latest progress`,className:`flex flex-col gap-1 text-muted-foreground`,children:o.map((e,t)=>(0,Q.jsx)(`li`,{className:`break-words`,children:e},t))}),(0,Q.jsx)(`div`,{children:i})]})}function eC({delayDuration:e=0,...t}){return(0,Q.jsx)(Df,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function tC({...e}){return(0,Q.jsx)(Of,{"data-slot":`tooltip`,...e})}function nC({...e}){return(0,Q.jsx)(kf,{"data-slot":`tooltip-trigger`,...e})}function rC({className:e,sideOffset:t=0,children:n,...r}){return(0,Q.jsx)(Af,{children:(0,Q.jsxs)(jf,{"data-slot":`tooltip-content`,sideOffset:t,className:k(`z-50 w-fit origin-(--radix-tooltip-content-transform-origin) motion-safe:animate-in rounded-md bg-contrast px-3 py-1.5 text-xs text-balance text-contrast-foreground fade-in-0 motion-safe:zoom-in-95 motion-safe:data-[side=bottom]:slide-in-from-top-2 motion-safe:data-[side=left]:slide-in-from-right-2 motion-safe:data-[side=right]:slide-in-from-left-2 motion-safe:data-[side=top]:slide-in-from-bottom-2 motion-safe:data-[state=closed]:animate-out data-[state=closed]:fade-out-0 motion-safe:data-[state=closed]:zoom-out-95`,e),...r,children:[n,(0,Q.jsx)(Mf,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-contrast fill-contrast`})]})})}var iC=[{id:`status`,label:`Status`,canFold:!1,defaultExpanded:!0,align:`left`,width:`120px`},{id:`task`,label:`Task`,canFold:!1,defaultExpanded:!0,align:`left`,width:`320px`},{id:`workflow`,label:`Workflow`,canFold:!0,defaultExpanded:!0,align:`left`,width:`84px`,icon:`workflow`},{id:`branch`,label:`Branch`,canFold:!0,defaultExpanded:!1,align:`left`,width:`120px`,icon:`branch`},{id:`diff`,label:`±`,canFold:!0,defaultExpanded:!0,align:`left`,width:`84px`,icon:`diff`},{id:`reference`,label:`Ref`,canFold:!0,defaultExpanded:!0,align:`left`,width:`104px`,icon:`reference`},{id:`tokens`,label:`IN / OUT`,canFold:!0,defaultExpanded:!0,align:`right`,width:`112px`,icon:`tokens`,capability:`tokens`},{id:`cost`,label:`Cost`,canFold:!0,defaultExpanded:!0,align:`right`,width:`64px`,icon:`cost`,capability:`cost`},{id:`cpu`,label:`CPU`,canFold:!0,defaultExpanded:!0,align:`right`,width:`60px`,icon:`cpu`},{id:`memory`,label:`Mem`,canFold:!0,defaultExpanded:!0,align:`right`,width:`80px`,icon:`memory`},{id:`started`,label:`Started`,canFold:!0,defaultExpanded:!0,align:`right`,width:`68px`,icon:`started`}],aC=new Map(iC.map(e=>[e.id,e]));function oC(e){return typeof e!=`object`||!e||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`boolean`))}function sC(e){let t={};for(let[n,r]of Object.entries(oC(e))){let e=aC.get(n);e?.canFold&&(t[e.id]=r)}return t}function cC(e,t){let n=aC.get(e);return!n||!n.canFold?!0:t[e]??n.defaultExpanded}function lC(e,t){let n=oC(e);return aC.get(t)?.canFold?{...n,[t]:!cC(t,sC(e))}:n}function uC(e){return iC.filter(t=>t.capability===void 0||e[t.capability])}var dC=`cez-sidebar-collapsed`,fC=`cez-sidebar-sections-collapsed`;function pC(e){if(typeof e!=`object`||!e||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))typeof r==`boolean`&&(t[n]=r);return t}function mC(e=dC){try{let t=localStorage.getItem(e);return t===null?{}:pC(JSON.parse(t))}catch{return{}}}function hC(e,t=dC){try{localStorage.setItem(t,JSON.stringify(e))}catch{}}var gC=`cez-task-list-folds`,_C=`cez-task-list-folds-changed`;function vC(e,t,n=new Set){let[r,i]=(0,Z.useState)(()=>mC(gC));(0,Z.useEffect)(()=>{let e=e=>{e instanceof StorageEvent&&e.key!==null&&e.key!==`cez-task-list-folds`||i(e instanceof CustomEvent?e.detail:mC(gC))};return window.addEventListener(`storage`,e),window.addEventListener(_C,e),()=>{window.removeEventListener(`storage`,e),window.removeEventListener(_C,e)}},[]);let a=(0,Z.useCallback)(n=>JSON.stringify([e,t,n]),[e,t]),o=(0,Z.useCallback)(e=>{i(t=>{let n=e(t);return hC(n,gC),queueMicrotask(()=>window.dispatchEvent(new CustomEvent(_C,{detail:n}))),n})},[]),s=e=>r[a(e)]===!0;return{isFolded:s,isCollapsed:e=>s(e)&&!n.has(e),toggle:e=>o(t=>({...t,[a(e)]:t[a(e)]!==!0})),setAll:(e,t)=>o(n=>({...n,...Object.fromEntries(e.map(e=>[a(e),t]))})),only:(0,Z.useCallback)((e,t)=>o(n=>({...n,...Object.fromEntries(t.map(t=>[a(t),t!==e]))})),[o,a])}}function yC(e,t,n,r){let i=vC(e,t,n),a=(0,Z.useRef)(r);a.current=r;let[o,s]=Yg(),c=t===`active`?Fr(o.get(Un)):null,{only:l}=i;return(0,Z.useEffect)(()=>{c!==null&&(l(c,qn),a.current?.(),s(e=>(e.delete(Un),e)))},[c,l,s]),i}function bC(e){let t=e?.capabilities,n=t?.tokenMetrics!==!1;return{tokens:t?.tokenUsageMetrics??n,cost:t?.costMetrics??n}}function xC(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function SC(){let e=z(),t=Ht(),n=Z.useRef(0),r=Z.useRef(0),i=Z.useRef(Promise.resolve()),a=Z.useMemo(()=>sC(t.data?.taskTable?.expandedColumns),[t.data?.taskTable?.expandedColumns]),o=Z.useCallback(t=>{if(!iC.find(e=>e.id===t)?.canFold)return;let a=e.getQueryData(B.uiState);if(a===void 0)return;let o=xC(a?.taskTable),s={...o,expandedColumns:lC(o.expandedColumns,t)};e.setQueryData(B.uiState,{...a,taskTable:s});let c=++n.current;r.current=c;let l=i.current.then(async()=>{let t=await Qe({taskTable:s},{keepalive:!0});c===r.current&&e.setQueryData(B.uiState,t)});i.current=l.catch(t=>{K(t instanceof Error?t.message:String(t),{tone:`danger`}),c===r.current&&e.invalidateQueries({queryKey:B.uiState})})},[e]);return{expandedColumns:a,isExpanded:Z.useCallback(e=>cC(e,a),[a]),toggleColumn:o,isPending:t.isPending}}function CC({runs:e,view:t,onViewChange:n,onArchiveFinished:r,archivePending:i=!1,onMarkAllRead:a,onRename:o,onTogglePin:s,now:c=Date.now(),showTokens:l=!0,showCost:u=!0,expandedColumns:d=sC(void 0),onToggleColumn:f=()=>void 0,columnsPending:p=!1,projectName:m,error:h,onRetry:g,archivedPages:_,archivedTotal:v,onArchivedSearch:y,origin:b,onOriginChange:x,urlQuery:S=``,onQueryChange:C,foldScope:w=`project`,automationName:T=()=>void 0}){let[E,D]=wC(S,C);Z.useEffect(()=>{y?.(E.trim())},[y,E]);let[k,A]=EC(b,x),[j,M]=Z.useState(!1),N=Z.useRef(null),P=DC({all:e??[],view:t,query:E,origin:k,archivedPages:_,archivedTotal:v,automationName:T}),{groups:F,needle:I}=P,L=uC({tokens:l,cost:u}),ee=yC(w,t,new Set(I?F.map(e=>e.label):[]),()=>D(``)),te=t===`archived`?void 0:s;return(0,Q.jsxs)(`div`,{"data-route":`tasks`,"data-presentation":j?`resources`:`summary`,className:`flex min-h-full flex-col gap-[22px] px-[18px] pt-6 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-9`,children:[(0,Q.jsxs)(`header`,{ref:N,className:`flex shrink-0 flex-col gap-[22px]`,children:[(0,Q.jsx)(TC,{projectName:m,detailedTable:j}),(0,Q.jsxs)(`div`,{className:`flex gap-6 border-b border-border`,children:[(0,Q.jsx)(zC,{view:`active`,current:t,onSelect:n,count:P.activeCount,children:`Active`}),(0,Q.jsx)(zC,{view:`archived`,current:t,onSelect:n,count:P.archivedCount,children:`Archived`})]}),(0,Q.jsxs)(`div`,{"data-slot":`tasks-toolbar`,className:`flex flex-wrap items-center gap-2.5`,children:[(0,Q.jsx)(AC,{view:t,unread:P.unread,finished:P.finished,archivePending:i,headerRef:N,onMarkAllRead:()=>a(LS(k)),onArchiveFinished:()=>r(LS(k))}),(0,Q.jsxs)(`div`,{className:`relative order-first w-full md:w-auto md:flex-1`,children:[(0,Q.jsx)(Ba,{className:`pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-soft-foreground`,"aria-hidden":`true`}),(0,Q.jsx)(`input`,{type:`text`,value:E,onChange:e=>D(e.target.value),placeholder:`Search tasks or automations…`,"aria-label":`Search tasks`,className:`h-11 w-full rounded-md border border-input bg-card pr-3 pl-8 text-[13px] text-foreground outline-none placeholder:text-soft-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`})]}),(0,Q.jsx)(jC,{columns:L,expandedColumns:d,columnsPending:p,onToggleColumn:f,detailedTable:j,onToggleDetailed:()=>M(e=>!e)}),(0,Q.jsx)(O,{asChild:!0,"data-slot":`new-task-inline`,className:`min-h-11 inline-flex max-md:hidden`,children:(0,Q.jsxs)(Y,{to:`/new`,children:[(0,Q.jsx)(Ga,{"aria-hidden":`true`}),`New task`]})})]}),(0,Q.jsx)(YS,{origin:k,counts:P.originTotals,onChange:A,labels:F.map(e=>e.label),onSetAll:ee.setAll})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[e===void 0?(0,Q.jsx)(NC,{error:h,onRetry:g}):(0,Q.jsx)(MC,{view:t,query:E,origin:k,onShowAll:()=>{D(``),A(`all`)},caption:kC(P.visibleCount,P.incomplete,I),captionOnPhones:I!==``||P.incomplete,groups:F,folds:ee,grouped:{detailedTable:j,columns:L,expandedColumns:d,onToggleColumn:f,columnsPending:p,onRename:o,onTogglePin:te,now:c,showTokens:l,showCost:u,automationName:T}}),t===`archived`&&_?(0,Q.jsx)(PC,{pages:_}):null]})]})}function wC(e,t){let[n,r]=Z.useState(e),i=Z.useRef(e),a=Z.useRef(e),o=Z.useRef([]);return Z.useEffect(()=>{if(e===i.current)return;i.current=e;let t=o.current.indexOf(e);o.current=t===-1?[]:o.current.slice(t+1),t===-1&&e!==a.current&&r(e)},[e]),Z.useEffect(()=>{a.current=n.trim(),t?.(n,e=>{o.current.push(e)})},[t,n]),[n,r]}function TC({projectName:e,detailedTable:t}){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h1`,{className:`text-[30px] font-semibold tracking-tight`,children:`Project tasks`}),(0,Q.jsxs)(`p`,{className:`text-[13px] text-muted-foreground`,children:[e?`${e} · `:``,t?`Every resource column shown. Fold columns without losing the saved view.`:`Review runs, pull requests and resource usage.`]})]})}function EC(e,t){let[n,r]=Z.useState(`all`);return[e??n,t??r]}function DC({all:e,view:t,query:n,origin:r,archivedPages:i,archivedTotal:a,automationName:o}){let s=n.trim(),c=e=>e.automationId===void 0?``:o(e.automationId)??e.automationId,l=i?.query===s,u=new Set(l?i.runs.map(e=>e.id):[]),d=ir(e,l||s===``?i?.runs??[]:[]).slice(e.length),f=on(e,n,c),p=new Set(f.map(e=>e.id)),m=on(e.filter(e=>u.has(e.id)&&!p.has(e.id)),``),h=e=>IS(e,r),g=VS([...f,...m,...on(d,``)].filter(h),t,e),_=ir(e,i?.query===``?i.runs:[]),v=Pn(e).archived>=200,y=e.filter(h);return{groups:g,needle:s,visibleCount:g.reduce((e,t)=>e+zS(t).length,0),originTotals:RS(_,t),activeCount:RS(e,`active`)[r],archivedCount:OC(e,_,r,i,a),incomplete:t===`archived`&&v&&i?.hasMore!==!1,finished:vr(y),unread:Zb(y)}}function OC(e,t,n,r,i){let a=Pn(e).archived,o=a>=200;if(n===`all`)return i??(o?`200+`:a);let s=RS(t,`archived`)[n];return o&&r?.plainHasMore!==!1?`${s}+`:s}function kC(e,t,n){return`${e} ${e===1?`task`:`tasks`}${t?` loaded`:``}${n?` matching “${n}”`:``}`}function AC({view:e,unread:t,finished:n,archivePending:r,headerRef:i,onMarkAllRead:a,onArchiveFinished:o}){let s=Z.useRef(!1),[c,l]=Z.useState(!1),u=n>0||r;return Z.useEffect(()=>{let e=window.matchMedia?.(`(min-width: 768px)`);if(!e)return;let t=()=>{e.matches&&l(!1)};return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,Q.jsxs)(Q.Fragment,{children:[t>0?(0,Q.jsxs)(O,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`mark-all-read`,className:`hidden md:inline-flex`,onClick:a,children:[(0,Q.jsx)(kp,{className:`size-3.5`,"aria-hidden":`true`}),`Mark all read`,` `,(0,Q.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:t})]}):null,e===`active`&&n>0?(0,Q.jsxs)(O,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`archive-finished`,className:`inline-flex`,disabled:r,"aria-busy":r,onClick:o,children:[(0,Q.jsx)(bo,{className:`size-3.5`,"aria-hidden":`true`}),`Archive finished`,` `,(0,Q.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:n})]}):null,e===`active`&&(u||t>0)?(0,Q.jsxs)(Li,{open:c,onOpenChange:l,children:[(0,Q.jsx)(Pi,{asChild:!0,children:(0,Q.jsx)(O,{type:`button`,variant:`ghost`,size:`icon`,className:`md:hidden`,"aria-label":`Task actions`,"aria-busy":r,children:(0,Q.jsx)(Gp,{"aria-hidden":`true`})})}),(0,Q.jsxs)(Fi,{align:`end`,className:`md:hidden`,onCloseAutoFocus:e=>{(s.current||window.matchMedia?.(`(min-width: 768px)`).matches)&&(e.preventDefault(),s.current=!1,i.current?.querySelector(`[data-view="active"]`)?.focus())},children:[u?(0,Q.jsxs)(Ai,{disabled:r||n===0,onSelect:()=>{s.current=!0,o()},children:[(0,Q.jsx)(bo,{"aria-hidden":`true`}),r?`Archiving…`:`Archive finished (${n})`]}):null,t>0?(0,Q.jsxs)(Ai,{onSelect:a,children:[(0,Q.jsx)(kp,{"aria-hidden":`true`}),`Mark all read (${t})`]}):null]})]}):null]})}function jC({columns:e,expandedColumns:t,columnsPending:n,onToggleColumn:r,detailedTable:i,onToggleDetailed:a}){return(0,Q.jsxs)(Da,{children:[(0,Q.jsx)(Sa,{asChild:!0,children:(0,Q.jsx)(O,{"data-slot":`task-columns-trigger`,variant:`outline`,className:`hidden min-h-11 md:inline-flex`,children:`Columns`})}),(0,Q.jsxs)(Ta,{align:`end`,className:`w-72`,children:[(0,Q.jsx)(`h2`,{className:`mb-2 text-base font-medium`,children:`Visible columns`}),(0,Q.jsx)(`p`,{className:`mb-4 text-xs text-muted-foreground`,children:`Status and Task · Always visible`}),(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:e.filter(e=>e.canFold).map(e=>(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,Q.jsx)(`input`,{"data-column-toggle":e.id,type:`checkbox`,checked:cC(e.id,t),disabled:n,onChange:()=>r(e.id)}),e.id===`diff`?`Diff`:e.id===`reference`?`Reference`:e.id===`memory`?`Memory`:e.label]},e.id))}),(0,Q.jsx)(`p`,{className:`mt-4 text-xs text-muted-foreground`,children:`Saved automatically. Tokens and cost appear only when supported.`}),(0,Q.jsx)(O,{variant:`outline`,className:`mt-4`,onClick:a,children:i?`Summary view`:`Resource columns`})]})]})}function MC({view:e,query:t,origin:n,onShowAll:r,caption:i,captionOnPhones:a,groups:o,folds:s,grouped:c}){return o.length===0?(0,Q.jsx)(FC,{view:e,query:t,origin:n,onShowAll:r}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{"data-slot":`tasks-result-count`,className:k(`mb-3 text-[12px] text-muted-foreground tabular-nums`,!a&&`max-md:hidden`),children:i}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-[22px]`,children:o.map(t=>{let n=zS(t);return(0,Q.jsx)(ZS,{id:`tasks-group-${e}-${t.label.replaceAll(` `,`-`)}`,label:t.label,count:n.length,tone:BS(t.label,n),folded:s.isFolded(t.label),collapsed:s.isCollapsed(t.label),onToggle:()=>s.toggle(t.label),children:(0,Q.jsx)(LC,{group:t,...c})},t.label)})}),(0,Q.jsx)(`p`,{className:`mt-[22px] text-[11px] text-muted-foreground`,children:`Resource details—including tokens, cost, CPU and peak memory—are available when a task row is expanded.`})]})}function NC({error:e,onRetry:t}){return e?(0,Q.jsxs)(`div`,{role:`alert`,className:`rounded-xl border border-border bg-card p-6`,children:[(0,Q.jsx)(`h2`,{className:`text-lg`,children:`Could not load tasks`}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:e}),(0,Q.jsx)(O,{variant:`outline`,className:`mt-4`,onClick:t,children:`Retry`})]}):(0,Q.jsx)(`div`,{role:`status`,"aria-label":`Loading tasks`,className:`rounded-xl border border-border bg-card p-6 text-sm text-muted-foreground`,children:`Loading tasks…`})}function PC({pages:e}){return e.failed?(0,Q.jsxs)(`p`,{role:`alert`,"data-slot":`archived-older-error`,className:`mt-3.5 flex items-center justify-center gap-2.5 text-[13px] text-muted-foreground`,children:[`Could not load older archived tasks.`,(0,Q.jsx)(O,{variant:`outline`,className:`min-h-11`,onClick:e.onLoadMore,children:`Retry`})]}):e.hasMore?(0,Q.jsx)(O,{"data-slot":`archived-older`,variant:`outline`,className:`mt-3.5 min-h-11 self-center`,disabled:e.loading,onClick:e.onLoadMore,children:e.loading?`Loading older archived…`:`Show older archived`}):null}function FC({view:e,query:t,origin:n=`all`,onShowAll:r}){let i=t.trim(),a=i||n!==`all`?`search-miss`:e===`archived`?`archive`:`no-tasks`;return(0,Q.jsx)(`div`,{"data-slot":`tasks-empty`,"data-empty-kind":a,className:`flex flex-1 flex-col`,children:a===`search-miss`?(0,Q.jsx)(X,{heading:`h2`,icon:(0,Q.jsx)(ls,{}),tone:`neutral`,title:`No matching tasks`,subtitle:i?`No tasks match “${i}”.`:n===`automations`?`No automation started a task here.`:`No task here was started directly.`,actions:r?(0,Q.jsx)(O,{variant:`outline`,className:`min-h-11`,"data-action":`clear-task-filters`,onClick:r,children:`Show all tasks`}):void 0}):a===`archive`?(0,Q.jsx)(X,{heading:`h2`,icon:(0,Q.jsx)(bo,{}),tone:`neutral`,title:`Nothing archived yet`,subtitle:`Finished tasks you archive land here.`}):(0,Q.jsx)(X,{heading:`h2`,icon:(0,Q.jsx)(cm,{}),tone:`primary`,backdrop:!0,title:`No tasks yet`,subtitle:`Describe a task to get started.`,actions:(0,Q.jsx)(O,{asChild:!0,children:(0,Q.jsxs)(Y,{to:`/new`,children:[(0,Q.jsx)(Ga,{"aria-hidden":`true`}),`New task`]})})})})}function IC({rows:e,onRename:t,onTogglePin:n,now:r,showTokens:i,showCost:a,automationName:o}){let[s,c]=Z.useState(()=>new Set);return(0,Q.jsx)(`div`,{"data-slot":`tasks-summary`,className:`hidden md:block`,children:(0,Q.jsx)(`div`,{className:`rounded-lg border border-border bg-card p-5`,children:(0,Q.jsxs)(`table`,{className:`w-full table-fixed border-collapse`,children:[(0,Q.jsxs)(`colgroup`,{children:[(0,Q.jsx)(`col`,{}),(0,Q.jsx)(`col`,{className:`w-[136px]`}),(0,Q.jsx)(`col`,{className:`w-[106px]`}),(0,Q.jsx)(`col`,{className:`w-[116px]`}),(0,Q.jsx)(`col`,{className:`w-[70px]`})]}),(0,Q.jsx)(`thead`,{children:(0,Q.jsx)(`tr`,{children:[`Task`,`Workflow`,`Changes`,`Pull request`,`Started`].map(e=>(0,Q.jsx)(`th`,{className:`h-8 border-b border-border text-left text-[12px] font-medium uppercase text-muted-foreground`,children:e},e))})}),(0,Q.jsx)(`tbody`,{children:e.map(({run:e,queuePosition:l})=>{let u=fe(e),d=Gn(e),f=Sr(e),p=s.has(e.id),m=`task-resources-${e.id}`;return(0,Q.jsxs)(Z.Fragment,{children:[(0,Q.jsxs)(`tr`,{"data-status":e.status,"data-slot":`task-summary-row`,className:`group/row border-b border-border last:border-0`,children:[(0,Q.jsxs)(`td`,{className:`py-5 pr-4 align-top`,children:[(0,Q.jsx)(JC,{run:e,to:`/tasks/${e.id}`,onRename:t,onTogglePin:n}),(0,Q.jsx)(`div`,{className:`mt-1`,children:(0,Q.jsx)(KC,{run:e,automationName:o})}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${p?`Hide`:`Show`} resources for ${xn(e)}`,"aria-expanded":p,"aria-controls":m,"aria-describedby":`summary-status-${e.id}`,onClick:()=>c(t=>{let n=new Set(t);return p?n.delete(e.id):n.add(e.id),n}),className:`inline-flex min-h-[26px] items-center gap-1 rounded-md p-0 text-[11px] text-muted-foreground hover:bg-muted focus-visible:outline-2 focus-visible:outline-ring`,children:(0,Q.jsxs)($x,{id:`summary-status-${e.id}`,dot:u.tone,shape:u.shape,pulse:u.pulse,children:[u.label,d?` ${d.label}`:``]})}),e.status===`queued`&&l!==null?(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`#`,l,` in queue`]}):null]})]}),(0,Q.jsx)(`td`,{className:`truncate pr-3 text-xs text-muted-foreground`,title:Dr(e),children:Dr(e)}),(0,Q.jsx)(`td`,{className:`pr-2 text-xs`,children:e.diffStat?(0,Q.jsx)(Kx,{stat:e.diffStat}):(0,Q.jsx)(ew,{})}),(0,Q.jsx)(`td`,{className:`pr-2`,children:f?(0,Q.jsx)(NS,{run:e,reference:f,compact:!0}):(0,Q.jsx)(ew,{})}),(0,Q.jsx)(`td`,{className:`text-xs text-muted-foreground`,children:Io(e.startedAt??e.createdAt,r)})]}),p?(0,Q.jsx)(`tr`,{children:(0,Q.jsx)(`td`,{colSpan:5,className:`border-b border-border pb-5`,children:(0,Q.jsxs)(`div`,{id:m,className:`flex flex-col gap-3`,children:[(0,Q.jsx)($S,{runId:e.id,status:u.label,error:e.error,open:(0,Q.jsx)(O,{asChild:!0,variant:`outline`,className:`min-h-11`,children:(0,Q.jsxs)(Y,{to:`/tasks/${e.id}`,children:[`Open task`,(0,Q.jsxs)(`span`,{className:`sr-only`,children:[`: `,xn(e)]})]})})}),(0,Q.jsx)(`div`,{className:`rounded-md bg-muted/50 p-4`,children:(0,Q.jsx)(RC,{run:e,showTokens:i,showCost:a})})]})})}):null]},e.id)})})]})})})}function LC({group:e,detailedTable:t,columns:n,expandedColumns:r,onToggleColumn:i,columnsPending:a,onRename:o,onTogglePin:s,now:c,showTokens:l,showCost:u,automationName:d}){let f=e.rows.flatMap(e=>WS(e).map(t=>({run:t,queuePosition:t.status===`queued`?e.queuePosition:null})));return(0,Q.jsxs)(Q.Fragment,{children:[t?null:(0,Q.jsx)(IC,{rows:f,onRename:o,onTogglePin:s,now:c,showTokens:l,showCost:u,automationName:d}),(0,Q.jsx)(`div`,{"data-slot":`tasks-table`,hidden:!t,className:k(`hidden overflow-x-auto rounded-lg border border-border bg-card`,t&&`md:block`),children:(0,Q.jsx)(eC,{children:(0,Q.jsxs)(`table`,{className:`w-full table-fixed border-collapse`,children:[(0,Q.jsx)(`colgroup`,{children:n.map(e=>{let t=cC(e.id,r);return(0,Q.jsx)(`col`,{"data-column-id":e.id,"data-expanded":t,style:{width:t?e.width:`42px`}},e.id)})}),(0,Q.jsx)(`thead`,{children:(0,Q.jsx)(`tr`,{children:n.map(e=>(0,Q.jsx)(VC,{column:e,expanded:cC(e.id,r),onToggle:i,disabled:a},e.id))})}),(0,Q.jsx)(`tbody`,{className:`[&>tr:last-child>td]:border-b-0`,children:f.map(({run:e,queuePosition:t})=>(0,Q.jsx)(WC,{run:e,queuePosition:t,onRename:o,onTogglePin:s,now:c,columns:n,expandedColumns:r,automationName:d},e.id))})]})})}),(0,Q.jsx)(`div`,{"data-slot":`task-cards`,className:`flex flex-col rounded-lg border border-border bg-card p-5 md:hidden`,children:f.map(({run:e,queuePosition:t})=>(0,Q.jsx)(QC,{run:e,queuePosition:t,now:c,showTokens:l,showCost:u,onTogglePin:s,automationName:d},e.id))})]})}function RC({run:e,showTokens:t,showCost:n}){let r=sr(e,Cl(e.id));return(0,Q.jsxs)(`dl`,{className:`grid grid-cols-2 gap-4 text-xs md:grid-cols-4`,children:[t?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Tokens in / out`}),(0,Q.jsx)(`dd`,{className:`mt-1`,children:(0,Q.jsx)(Xx,{inputTokens:e.inputTokens,outputTokens:e.outputTokens,omitWhenUnknown:!1})})]}):null,n?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Cost`}),(0,Q.jsx)(`dd`,{className:`mt-1`,children:rn(e.costUsd)||`—`})]}):null,(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`CPU`}),(0,Q.jsx)(`dd`,{className:`mt-1`,title:r.cpu.title,children:r.cpu.text||`—`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Memory`}),(0,Q.jsx)(`dd`,{className:`mt-1`,title:r.mem.title,children:r.mem.text||`—`})]}),e.branch?(0,Q.jsxs)(`div`,{className:`col-span-2`,children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Branch`}),(0,Q.jsx)(`dd`,{className:`mt-1 break-all`,children:e.branch})]}):null]})}function zC({view:e,current:t,onSelect:n,count:r,children:i}){let a=e===t;return(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`overview-tab`,"data-view":e,"aria-pressed":a,onClick:()=>n(e),className:k(`flex min-h-11 items-center justify-center gap-1.5 border-b-2 border-transparent text-[13px] font-medium text-muted-foreground`,a&&`border-accent-strong font-semibold text-accent-text`),children:[i,r===0?null:(0,Q.jsxs)(`span`,{className:`tabular-nums`,children:[` · `,r]})]})}function BC({children:e,right:t=!1,columnId:n,folded:r=!1}){return(0,Q.jsx)(`th`,{scope:`col`,"data-column-id":n,"data-folded":r||void 0,className:k(`h-[38px] border-b border-border px-2.5 text-left text-[11px] font-semibold tracking-[0.05em] whitespace-nowrap text-supporting-foreground uppercase first:pl-4 last:pr-4`,t&&`text-right`,r&&`px-0 first:pl-0 last:pr-0`),children:e})}function VC({column:e,expanded:t,onToggle:n,disabled:r}){if(!e.canFold)return(0,Q.jsx)(BC,{columnId:e.id,right:e.align===`right`,children:e.label});let i=t?`Fold`:`Expand`;return(0,Q.jsx)(BC,{columnId:e.id,right:e.align===`right`,folded:!t,children:(0,Q.jsxs)(tC,{children:[(0,Q.jsx)(nC,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${i} ${e.label} column`,"aria-pressed":t,disabled:r,onClick:()=>n(e.id),className:k(`inline-flex h-8 w-full items-center gap-1 rounded-sm px-0.5 text-inherit outline-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-wait disabled:opacity-60`,e.align===`right`?`justify-end`:`justify-start`,!t&&`justify-center px-0`),children:t?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{children:e.label}),(0,Q.jsx)(Pp,{className:`size-3 opacity-55`,"aria-hidden":`true`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(HC,{icon:e.icon}),(0,Q.jsx)(Fp,{className:`size-3 opacity-70`,"aria-hidden":`true`})]})})}),(0,Q.jsxs)(rC,{side:`top`,children:[e.label,` · `,i,` column`]})]})})}function HC({icon:e}){let t=`size-3.5`;switch(e){case`workflow`:return(0,Q.jsx)(no,{className:t,"aria-hidden":`true`});case`branch`:return(0,Q.jsx)(oo,{className:t,"aria-hidden":`true`});case`diff`:return(0,Q.jsx)(wo,{className:t,"aria-hidden":`true`});case`reference`:return(0,Q.jsx)(sm,{className:t,"aria-hidden":`true`});case`tokens`:return(0,Q.jsx)(Rp,{className:t,"aria-hidden":`true`});case`cost`:return(0,Q.jsx)(Wp,{className:t,"aria-hidden":`true`});case`cpu`:return(0,Q.jsx)(Xa,{className:t,"aria-hidden":`true`});case`memory`:return(0,Q.jsx)(lm,{className:t,"aria-hidden":`true`});case`started`:return(0,Q.jsx)(Ip,{className:t,"aria-hidden":`true`});default:return null}}var UC=`h-[88px] border-b border-border px-2.5 whitespace-nowrap first:pl-4 last:pr-4`;function WC({run:e,queuePosition:t,onRename:n,onTogglePin:r,now:i,columns:a,expandedColumns:o,automationName:s}){let c=ds(),l=fe(e),u=Gn(e),d=`/tasks/${e.id}`,f=rn(e.costUsd),p=Sr(e);return(0,Q.jsx)(`tr`,{"data-slot":`task-table-row`,"data-run-id":e.id,onClick:e=>{e.target.closest(`a, button, input`)||c(d)},className:`group/row cursor-pointer hover:bg-muted`,children:a.map(a=>{if(a.id===`memory`)return null;if(a.id===`cpu`){let n=cC(`cpu`,o),r=cC(`memory`,o);return t!==null&&(n||r)?(0,Q.jsxs)(`td`,{"data-slot":`queue-note`,"data-column-id":`cpu-memory`,colSpan:2,className:k(UC,`text-right font-mono text-[11px] text-supporting-foreground`),children:[`#`,t,` in queue`]},a.id):(0,Q.jsx)(YC,{run:e,cpuExpanded:n,memoryExpanded:r},a.id)}return(0,Q.jsx)(GC,{column:a,expanded:cC(a.id,o),run:e,attention:l,scheduled:u,reference:p,cost:f,to:d,onRename:n,onTogglePin:r,now:i,automationName:s},a.id)})})}function GC({column:e,expanded:t,run:n,attention:r,scheduled:i,reference:a,cost:o,to:s,onRename:c,onTogglePin:l,now:u,automationName:d}){if(!t)return(0,Q.jsx)(qC,{column:e.id});switch(e.id){case`status`:return(0,Q.jsx)(`td`,{"data-column-id":e.id,className:k(UC,`overflow-hidden`),children:(0,Q.jsx)($x,{dot:r.tone,shape:r.shape,pulse:r.pulse,title:i?.title??r.label,className:`w-full max-w-full overflow-hidden`,children:(0,Q.jsxs)(`span`,{className:`min-w-0 truncate`,children:[r.label,i?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(`span`,{className:`tabular-nums`,children:i.label})]}):null]})})});case`task`:return(0,Q.jsxs)(`td`,{"data-column-id":e.id,className:k(UC,`min-w-[320px] max-w-0 whitespace-normal`),children:[(0,Q.jsx)(JC,{run:n,to:s,onRename:c,onTogglePin:l}),(0,Q.jsx)(`div`,{className:`mt-1`,children:(0,Q.jsx)(KC,{run:n,automationName:d})})]});case`workflow`:return(0,Q.jsx)(`td`,{"data-column-id":e.id,className:k(UC,`max-w-0 truncate text-[13px] text-muted-foreground`),children:Dr(n)});case`branch`:return(0,Q.jsx)(`td`,{"data-column-id":e.id,className:k(UC,`max-w-0 overflow-hidden`),children:n.branch?(0,Q.jsx)(tw,{branch:n.branch}):(0,Q.jsx)(ew,{})});case`diff`:return(0,Q.jsx)(`td`,{"data-column-id":e.id,className:k(UC,`overflow-hidden`),children:n.diffStat?(0,Q.jsx)(Kx,{stat:n.diffStat,compact:!0,className:`block max-w-full`}):(0,Q.jsx)(ew,{})});case`reference`:return(0,Q.jsx)(`td`,{"data-column-id":e.id,className:k(UC,`overflow-hidden`),children:a?(0,Q.jsx)(NS,{run:n,reference:a,compact:!0,className:`max-w-full overflow-hidden`}):(0,Q.jsx)(ew,{})});case`tokens`:let t=Jx(n.inputTokens,n.outputTokens);return(0,Q.jsx)(`td`,{"data-column-id":e.id,className:k(UC,`text-right text-xs text-muted-foreground`),children:(0,Q.jsx)(Xx,{inputTokens:n.inputTokens,outputTokens:n.outputTokens,variant:`table`,omitWhenUnknown:!1,title:t,className:`block max-w-full overflow-hidden text-ellipsis`})});case`cost`:return(0,Q.jsx)(`td`,{"data-column-id":e.id,className:k(UC,`text-right font-mono text-xs text-muted-foreground tabular-nums`),children:o?(0,Q.jsx)(ZC,{text:o,accessibleText:`$${n.costUsd}`}):(0,Q.jsx)(ew,{})});case`started`:return(0,Q.jsx)(`td`,{"data-column-id":e.id,className:k(UC,`text-right text-xs text-supporting-foreground tabular-nums`),children:Io(n.startedAt??n.createdAt,u)});default:return null}}function KC({run:e,automationName:t}){return(0,Q.jsx)(QS,{automationId:e.automationId,automationName:e.automationId===void 0?void 0:t(e.automationId)})}function qC({column:e}){return(0,Q.jsx)(`td`,{role:`presentation`,"aria-hidden":`true`,"data-column-id":e,"data-folded":`true`,className:k(UC,`px-0 first:pl-0 last:pr-0`)})}function JC({run:e,to:t,onRename:n,onTogglePin:r}){let i=xn(e),a=Zx(i,t=>n(e.id,t)),o=Yt(e),s=Xb(e);return a.editing?(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,"data-slot":`table-title-editor`,children:[(0,Q.jsx)(Qx,{editor:a,className:`basis-full text-[13px] font-medium`}),(0,Q.jsx)(O,{size:`sm`,"aria-label":`Save title`,onMouseDown:e=>e.preventDefault(),onClick:a.commit,children:`Save`}),(0,Q.jsx)(O,{size:`sm`,variant:`outline`,"aria-label":`Cancel rename`,onMouseDown:e=>e.preventDefault(),onClick:a.cancel,children:`Cancel`})]}):(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.delegation?.role===`worker`?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`Worker`}):null,(0,Q.jsx)(Y,{to:t,title:i,className:k(`line-clamp-2 min-w-0 flex-1 whitespace-normal rounded-sm text-[13px] leading-[18px] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`,o?`font-semibold text-foreground`:s?`font-normal text-foreground`:`font-medium`),children:i}),o?(0,Q.jsx)(J_,{tone:Qb(e),role:`img`,"aria-label":`unread`,title:`Unread — not opened since it finished`,className:`shrink-0`}):null,(0,Q.jsx)(`button`,{type:`button`,"data-slot":`row-rename`,"aria-label":`Rename task`,onClick:a.begin,className:`shrink-0 rounded-sm p-0.5 text-soft-foreground opacity-0 transition-opacity group-hover/row:opacity-100 hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,Q.jsx)(hm,{className:`size-3`,"aria-hidden":`true`})}),r?(0,Q.jsx)(eS,{pinned:!!e.pinned,onToggle:t=>r(e,t),className:`size-[19px] opacity-0 group-hover/row:opacity-100 focus-visible:opacity-100 no-hover:opacity-100 data-[pinned=true]:opacity-100`}):null]})}function YC({run:e,cpuExpanded:t,memoryExpanded:n}){let r=sr(e,Cl(e.id));return(0,Q.jsxs)(Q.Fragment,{children:[t?(0,Q.jsx)(XC,{column:`cpu`,cell:r.cpu}):(0,Q.jsx)(qC,{column:`cpu`}),n?(0,Q.jsx)(XC,{column:`memory`,cell:r.mem}):(0,Q.jsx)(qC,{column:`memory`})]})}function XC({column:e,cell:t}){let n=t.text&&t.title?`${t.text}; ${t.title}`:t.text;return(0,Q.jsx)(`td`,{"data-usage":e===`memory`?`mem`:e,"data-column-id":e,"data-usage-kind":t.kind,className:k(UC,`overflow-hidden`,`text-right font-mono tabular-nums`,t.kind===`live`&&`bg-accent-strong/5 text-xs font-medium text-foreground`,t.kind===`peak`&&`text-[11px] text-supporting-foreground`,t.kind===`none`&&`text-xs text-soft-foreground`),children:(0,Q.jsx)(ZC,{text:t.text||`—`,accessibleText:n||void 0})})}function ZC({text:e,accessibleText:t}){return(0,Q.jsx)(`span`,{"data-slot":`bounded-metric`,...t?{"aria-label":t,title:t}:{},className:`block max-w-full overflow-hidden text-ellipsis`,children:e})}function QC({run:e,queuePosition:t,now:n,showTokens:r,showCost:i,onTogglePin:a,automationName:o}){let s=ds(),[c,l]=Z.useState(!1),u=fe(e),d=Gn(e),f=`/tasks/${e.id}`,p=Sr(e),m=Yt(e),h=Xb(e);return(0,Q.jsxs)(`div`,{"data-slot":`task-card`,"data-status":e.status,"data-run-id":e.id,onClick:e=>{e.target.closest(`a, button`)||s(f)},className:`cursor-pointer border-b border-border py-5 first:pt-0 last:border-0 last:pb-0`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2.5`,children:[(0,Q.jsx)(`button`,{"data-slot":`mobile-resources-toggle`,type:`button`,"aria-controls":`mobile-resources-${e.id}`,"aria-describedby":`mobile-status-${e.id}`,"aria-label":c?`Hide resources`:`Show resources`,title:c?`Hide resources`:`Show resources`,"aria-expanded":c,onClick:()=>l(e=>!e),children:(0,Q.jsxs)($x,{id:`mobile-status-${e.id}`,dot:u.tone,shape:u.shape,pulse:u.pulse,className:`mt-px shrink-0`,title:d?.title,children:[u.label,d?(0,Q.jsx)(`span`,{className:`tabular-nums`,children:d.label}):null]})}),(0,Q.jsxs)(Y,{to:f,className:k(`order-first w-full min-w-0 rounded-sm text-[14px] leading-[1.35] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`,m?`font-semibold text-foreground`:h?`font-normal text-foreground`:`font-medium`),children:[e.delegation?.role===`worker`?(0,Q.jsx)(`span`,{className:`mr-2 text-xs text-muted-foreground`,children:`Worker`}):null,xn(e)]}),m?(0,Q.jsx)(J_,{tone:Qb(e),role:`img`,"aria-label":`unread`,title:`Unread — not opened since it finished`,className:`mt-1.5 shrink-0`}):null,(0,Q.jsx)(`div`,{className:`order-first w-full`,children:(0,Q.jsx)(KC,{run:e,automationName:o})}),a?(0,Q.jsx)(eS,{pinned:!!e.pinned,onToggle:t=>a(e,t),className:`-mr-1 mt-px`}):null]}),(0,Q.jsxs)(`div`,{"data-slot":`mobile-task-meta`,className:`mt-4 grid grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-3 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:Dr(e)}),t===null?e.diffStat?(0,Q.jsx)(Kx,{stat:e.diffStat}):(0,Q.jsx)(ew,{}):(0,Q.jsxs)(`span`,{"data-slot":`queue-note`,children:[`#`,t,` in queue`]}),(0,Q.jsx)(`span`,{children:Io(e.startedAt??e.createdAt,n)})]}),p?(0,Q.jsx)(`div`,{className:`mt-3`,children:(0,Q.jsx)(NS,{run:e,reference:p})}):null,c?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`mt-3`,children:(0,Q.jsx)($S,{runId:e.id,status:u.label,error:e.error,open:(0,Q.jsx)(O,{asChild:!0,variant:`outline`,className:`min-h-11`,children:(0,Q.jsxs)(Y,{to:f,children:[`Open task`,(0,Q.jsxs)(`span`,{className:`sr-only`,children:[`: `,xn(e)]})]})})})}),(0,Q.jsx)($C,{run:e,showTokens:r,showCost:i})]}):null]})}function $C({run:e,showTokens:t,showCost:n}){let r=sr(e,Cl(e.id));return(0,Q.jsxs)(`dl`,{id:`mobile-resources-${e.id}`,className:`mt-3 grid grid-cols-2 gap-3 rounded-md bg-muted p-3 text-xs`,children:[e.branch?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{children:`Branch`}),(0,Q.jsx)(`dd`,{children:e.branch})]}):null,(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{children:`CPU`}),(0,Q.jsx)(`dd`,{children:r.cpu.text||`—`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{children:`Memory`}),(0,Q.jsx)(`dd`,{children:r.mem.text||`—`})]}),t?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{children:`IN / OUT`}),(0,Q.jsx)(`dd`,{children:(0,Q.jsx)(Xx,{inputTokens:e.inputTokens,outputTokens:e.outputTokens})})]}):null,n?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{children:`Cost`}),(0,Q.jsx)(`dd`,{children:rn(e.costUsd)||`—`})]}):null]})}function ew(){return(0,Q.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`—`})}function tw({branch:e}){return(0,Q.jsx)(`span`,{title:e,className:`block truncate rounded-[6px] bg-muted px-1.5 py-0.5 font-mono text-[11px] font-medium text-muted-foreground`,children:e})}function nw(){let e=qt(),t=mn(),n=bC(t.data),{view:r,setView:i,origin:a,setOrigin:o,urlQuery:s,writeQuery:c}=iw(),l=yn(),u=z(),d=sw(e.data,r),f=V({mutationFn:e=>ct(Ir(),void 0,e),onSuccess:()=>l.invalidateAfter(`runs`,()=>Ir()),onError:e=>K(e.message,{tone:`danger`})}),p=V({mutationFn:e=>ee(e),onSuccess:()=>u.invalidateQueries({queryKey:H.runs.all}),onError:e=>K(e.message,{tone:`danger`})}),m=V({mutationFn:({id:e,title:t})=>Fe(e,{title:t}),onSuccess:()=>u.invalidateQueries({queryKey:H.runs.all}),onError:e=>K(e.message,{tone:`danger`})}),h=Tn(),g=eh(3e4),_=SC(),v=br(),y=nn(void 0,{retryOnMount:!1}),b=It({retryOnMount:!1}).data?.projects?.find(e=>e.id===v)?.name,x=[...e.data??[],...d.pages?.runs??[]].some(e=>e.automationId!==void 0),S=hr([void 0],t.data?.capabilities?.automations===!0&&x),C=Z.useCallback(e=>S(void 0,e),[S]);return(0,Q.jsx)(rs,{projectId:v,repoBase:y,requests:Z.useMemo(()=>v===void 0?[]:(e.data??[]).flatMap(e=>{let t=Sr(e);return t?[{projectId:v,kind:t.kind,number:t.number}]:[]}),[e.data,v]),children:(0,Q.jsx)(CC,{runs:e.data,projectName:b,error:e.error?.message,onRetry:()=>void e.refetch(),view:r,onViewChange:i,origin:a,onOriginChange:o,urlQuery:s,onQueryChange:c,foldScope:`project:${v??`default`}`,automationName:C,onArchiveFinished:e=>{f.isPending||f.mutate(e)},archivePending:f.isPending,onMarkAllRead:e=>p.mutate(e),onRename:(e,t)=>m.mutate({id:e,title:t}),onTogglePin:(e,t)=>h.mutate({id:e.id,pinned:t}),now:g,showTokens:n.tokens,showCost:n.cost,expandedColumns:_.expandedColumns,onToggleColumn:_.toggleColumn,columnsPending:_.isPending,archivedPages:d.pages,archivedTotal:d.total,onArchivedSearch:d.search})})}function rw(e,t){return n=>(t===null?n.delete(e):n.set(e,t),n)}function iw(){let[e,t]=Yg(),n=e.get(`archived`)===`1`?`archived`:`active`,r=FS(e.get(`origin`)),[i,a]=Z.useState(n),[o,s]=Z.useState(r);Z.useEffect(()=>a(n),[n]),Z.useEffect(()=>s(r),[r]);let c=e.get(`q`)??``,l=Z.useRef(void 0);return Z.useEffect(()=>{let e=l;return()=>clearTimeout(e.current)},[]),{view:i,setView:e=>{a(e),t(rw(`archived`,e===`archived`?`1`:null))},origin:o,setOrigin:e=>{s(e),t(rw(`origin`,e===`all`?null:e))},urlQuery:c,writeQuery:Z.useCallback((e,n)=>{clearTimeout(l.current);let r=e.trim();l.current=setTimeout(()=>t(e=>{let t=e.get(`q`),i=rw(`q`,r===``?null:r)(e);return i.get(`q`)!==t&&n(r),i}),aw)},[t])}}var aw=250,ow=150;function sw(e,t){yn();let n=z(),[r,i]=Z.useState(``),[a,o]=Z.useState(``);Z.useEffect(()=>{let e=setTimeout(()=>o(r),ow);return()=>clearTimeout(e)},[r]);let s=e!==void 0&&Pn(e).archived>=200,c=or(a,t===`archived`&&(a!==``||s)),l=c.data?.pages,u=Z.useMemo(()=>l||c.isError?{runs:(l??[]).flatMap(e=>e.runs),query:c.isPlaceholderData?null:a,hasMore:c.hasNextPage,loading:c.isFetchingNextPage,onLoadMore:()=>void(l?c.fetchNextPage():c.refetch()),failed:c.isError}:void 0,[l,c]),d=a===``?l:n.getQueryData(H.runs.archived(``))?.pages,f=d===void 0?void 0:d.at(-1)?.nextCursor!=null;return{pages:u&&{...u,plainHasMore:f},total:d?.[0]?.total,search:i}}function cw({slot:e,label:t,options:n,selected:r,onToggle:i,onClear:a,searchPlaceholder:o,emptyLabel:s=`Nothing to filter by`}){let[c,l]=Z.useState(!1),u=r.length>0,d=r.length===1?n.find(e=>e.value===r[0])?.label??r[0]:`${r.length} selected`;return(0,Q.jsxs)(Da,{open:c,onOpenChange:l,children:[(0,Q.jsx)(Sa,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`facet-${e}`,"data-active":u?`true`:void 0,"aria-label":`Filter by ${t.toLowerCase()}`,className:k(`inline-flex h-7 items-center gap-1.5 rounded-full border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,u&&`border-accent-strong/40 bg-accent-strong/10 text-foreground`),children:[(0,Q.jsx)(`span`,{className:k(u&&`text-soft-foreground`),children:t}),u?(0,Q.jsx)(`span`,{className:`max-w-[140px] truncate font-semibold`,children:d}):null,(0,Q.jsx)(Mp,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,Q.jsxs)(Ta,{align:`start`,className:`w-64 p-0`,"data-testid":`facet-${e}-menu`,children:[(0,Q.jsxs)(Ds,{children:[(0,Q.jsx)(Ts,{placeholder:o??`Search ${t.toLowerCase()}…`}),(0,Q.jsxs)(rc,{children:[(0,Q.jsx)(Cs,{children:s}),(0,Q.jsx)(ws,{children:n.map(e=>{let t=r.includes(e.value);return(0,Q.jsxs)(As,{value:e.label,onSelect:()=>i(e.value),"data-slot":`facet-option`,"data-value":e.value,"aria-checked":t,role:`option`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:k(`flex size-4 shrink-0 items-center justify-center rounded-[4px] border`,t?`border-accent-strong bg-accent-strong text-accent-strong-foreground`:`border-input`),children:t?(0,Q.jsx)(Ap,{className:`size-3`}):null}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.count===void 0?null:(0,Q.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-soft-foreground tabular-nums`,children:e.count})]},e.value)})})]})]}),u?(0,Q.jsx)(`div`,{className:`border-t border-border p-1`,children:(0,Q.jsxs)(`button`,{type:`button`,"data-action":`facet-${e}-clear`,onClick:()=>a(),className:`w-full rounded-sm px-2 py-1.5 text-left text-xs font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:[`Clear `,t.toLowerCase()]})}):null]})]})}function lw({label:e,count:t,selected:n,onToggle:r,slot:i,tone:a=`neutral`}){return(0,Q.jsxs)(`button`,{type:`button`,"data-slot":i,"data-selected":n?`true`:void 0,"aria-pressed":n,onClick:r,className:k(`inline-flex h-7 items-center gap-1.5 rounded-full border px-2.5 text-xs font-medium transition-colors`,a===`tag`?`border-accent-strong/25 bg-accent-strong/10 text-accent-text hover:bg-accent-strong/20`:`border-border bg-card text-muted-foreground hover:bg-muted hover:text-foreground`,n&&`border-accent-strong bg-accent-strong text-accent-strong-foreground hover:bg-accent-strong`),children:[e,t===void 0?null:(0,Q.jsx)(`span`,{className:k(`font-mono text-[11px] tabular-nums`,!n&&`text-soft-foreground`),children:t})]})}function uw({slot:e,label:t,value:n,options:r,onChange:i,size:a=`compact`}){return(0,Q.jsx)(`div`,{"data-slot":e,role:`group`,"aria-label":t,className:`inline-flex gap-0.5 rounded-md bg-muted p-[3px]`,children:r.map(e=>{let t=e.value===n;return(0,Q.jsx)(`button`,{type:`button`,"data-value":e.value,"aria-pressed":t,disabled:e.disabled,title:e.title,onClick:()=>i(e.value),className:k(`flex h-6 items-center justify-center rounded-[6px] px-2.5 text-[12px] font-medium text-muted-foreground transition-colors hover:text-foreground disabled:pointer-events-none disabled:opacity-50`,a===`touch`&&`h-11 px-4 text-[13px]`,t&&`bg-card font-semibold text-foreground shadow-xs`),children:e.label},e.value)})})}var dw=220;function fw({references:e,taskTitle:t,visibleCount:n,plain:r=!1,projectId:i,runId:a,repoBase:o}){let[s,c]=Z.useState(!1),l=Z.useRef(!1),u=Z.useRef(!1),d=Z.useRef(null),f=Z.useRef(void 0);Z.useEffect(()=>()=>clearTimeout(f.current),[]);let p=e=>e.pointerType!==`touch`,m=()=>clearTimeout(f.current),h=e=>{p(e)&&(m(),s||(l.current=!0),c(!0))},g=e=>{p(e)&&(m(),f.current=setTimeout(()=>c(!1),dw))},_=e.length-n,v=e.slice(n).map(t=>{let n=e.some(e=>e!==t&&e.kind===t.kind&&e.number===t.number)&&t.url?new URL(t.url).pathname.split(`/`).slice(1,3).join(`/`):``;return`${t.kind} #${t.number}${n?` (${n})`:``}`}).join(`, `);return _<=0?null:(0,Q.jsxs)(Da,{open:s,onOpenChange:c,children:[(0,Q.jsx)(Sa,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`reference-overflow`,title:v,"aria-label":`Show all ${e.length} references for ${t}`,onPointerEnter:h,onPointerLeave:g,onPointerDown:e=>{e.stopPropagation(),u.current=s&&l.current,l.current=!1},onClick:e=>{e.stopPropagation(),s&&(u.current||l.current)&&(e.preventDefault(),m(),d.current?.focus()),u.current=!1,l.current=!1},className:`no-hover:min-h-[44px] no-hover:min-w-[44px] max-md:min-h-[44px] max-md:min-w-[44px] shrink-0 rounded-full px-1 text-[11px] font-medium text-soft-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:[`+`,_]})}),(0,Q.jsxs)(Ta,{ref:d,align:`start`,collisionPadding:8,className:`w-auto min-w-40 max-h-(--radix-popover-content-available-height) overflow-y-auto overscroll-contain p-1.5`,"data-slot":`reference-overflow-list`,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),onPointerEnter:h,onPointerLeave:g,onOpenAutoFocus:e=>{e.preventDefault(),!l.current&&e.target instanceof HTMLElement&&e.target.focus()},onKeyDownCapture:e=>{e.key===`Escape`&&(e.preventDefault(),l.current=!1,c(!1))},onCloseAutoFocus:e=>{l.current&&e.preventDefault()},children:[(0,Q.jsx)(`p`,{className:`px-1 pb-1.5 text-[11px] text-soft-foreground`,children:`References`}),(0,Q.jsx)(`span`,{className:`flex flex-col items-start gap-1`,children:e.map(e=>(0,Q.jsx)(os,{reference:e,taskTitle:t,projectId:i,repoBase:o,to:i===void 0?void 0:tr(i,a,e,o),plain:r,className:`no-hover:min-h-[44px] max-md:min-h-[44px]`,conflictAction:i&&Mn(e,o)?(0,Q.jsx)(AS,{projectId:i,runId:a,prNumber:e.number}):void 0},Lt(e)))})]})]})}function pw({references:e,maxVisible:t,taskTitle:n,projectId:r,runId:i,repoBase:a,plain:o=!1,compact:s=!1,inertInline:c=!1,fitContainer:l=!1,overflowContainer:u}){let d=Z.useRef(null),[f,p]=Z.useState(t),m=Z.useRef(new Map),h=e.map(Lt).join(`|`);Z.useLayoutEffect(()=>{let n=d.current;if(!l||!n?.parentElement){p(t);return}let r=n.parentElement,i=()=>{[...n.querySelectorAll(`:scope > [data-slot="pr-chip"], :scope > [data-slot="issue-chip"]`)].forEach((t,n)=>{let r=t.getBoundingClientRect().width;r&&m.current.set(Lt(e[n]),r)});let i=r.getBoundingClientRect();if(!i.width)return;let a=Math.min(t,e.length);n.dataset.referenceWidth=String(e.slice(0,a).reduce((e,t)=>e+(m.current.get(Lt(t))??48),0)+Math.max(0,a-1)*4);let o=0;for(let e=n.nextElementSibling;e;e=e.nextElementSibling){if(e.getAttribute(`data-slot`)===`task-row-age`||e.getAttribute(`aria-hidden`)===`true`&&e.nextElementSibling?.getAttribute(`data-slot`)===`task-row-age`)continue;let t=getComputedStyle(e);o+=e.getBoundingClientRect().width+(parseFloat(t.marginLeft)||0)+(parseFloat(t.marginRight)||0)}let s=i.right-n.getBoundingClientRect().left-o,l=n.querySelector(`[data-slot="reference-overflow"]`)?.getBoundingClientRect().width||(c?44:26),d=Math.min(t,e.length);for(;d>0&&!(e.slice(0,d).reduce((e,t)=>e+(m.current.get(Lt(t))??48)+4,0)+(u===void 0&&d<e.length?l:0)<=s+(d===e.length?u?.getBoundingClientRect().width??0:0));)d--;p(d)};if(i(),typeof ResizeObserver>`u`)return;let a=new ResizeObserver(i);return a.observe(r),a.observe(n),()=>a.disconnect()},[l,t,h,c,e,u]);let g=Math.min(f,t,e.length),_=(0,Q.jsx)(fw,{references:e,visibleCount:g,taskTitle:n,projectId:r,runId:i,repoBase:a,plain:o});return(0,Q.jsxs)(`span`,{ref:d,"data-slot":`reference-list`,className:`inline-flex max-w-full flex-nowrap items-center gap-1 align-middle`,children:[e.slice(0,g).map(e=>(0,Q.jsx)(os,{reference:e,taskTitle:n,projectId:r,repoBase:a,to:r===void 0?void 0:tr(r,i,e,a),plain:o,compact:s,inert:c,className:`shrink-0`,conflictAction:r&&Mn(e,a)?(0,Q.jsx)(AS,{projectId:r,runId:i,prNumber:e.number}):void 0},Lt(e))),u===void 0?_:u?(0,su.createPortal)(_,u):null]})}var mw=` untagged`,hw=[{value:`project`,label:`Project`},{value:`tag`,label:`Tag`},{value:`status`,label:`Status`},{value:`workflow`,label:`Workflow`}];function gw(e,t){return e===t?`none`:t}var _w={query:``,tags:[],statuses:[],workflows:[]};function vw(e,t){let{origin:n,...r}=e;return t===`all`?r:{...r,origin:t}}function yw(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function bw(e){return(e.projects?.length??0)+e.tags.length+e.statuses.length+e.workflows.length+(e.origin===void 0||e.origin===`all`?0:1)}function xw(e){return e.query.trim()!==``||bw(e)>0}function Sw(e){return bw(e.filters)+(e.filters.query.trim()===``?0:1)+(e.groupBy===`none`?0:1)}function Cw(e){return Sw(e)>0}function ww(e,t){let n=new Map(t.map(e=>[e.id,e]));return e.filter(e=>!Yn(e)).map(e=>{let t=n.get(e.projectId);return{run:e,project:t,projectName:t?.name||e.projectId,tags:t?.tags??[]}})}function Tw(e){let t=new Set;for(let n of e)t.add(n.run.workflow);return[...t].sort((e,t)=>e.localeCompare(t))}function Ew(e){let t=new Set;for(let n of e)t.add(n.run.status);return[...t].sort((e,t)=>e.localeCompare(t))}function Dw(e,t){let n=new Map;for(let r of e)for(let e of t(r))n.set(e,(n.get(e)??0)+1);return n}var Ow=e=>e.tags.length===0?[mw]:e.tags,kw=(e,t)=>e.length===0||t.some(t=>e.includes(t)),Aw=(e,t)=>{if(t.length===0)return!0;let n=Ow(e).map(e=>e.toLowerCase());return t.some(e=>n.includes(e.toLowerCase()))};function jw(e,t){return{displayTitle:xn(e.run),projectName:e.projectName,tags:e.tags,automation:e.run.automationId===void 0?void 0:t(e)??e.run.automationId,references:()=>Tr(e.run)}}function Mw(e,t,n,r=()=>void 0){let i=t.query.trim()!==``;return e.filter(e=>(n===`archived`?!e.run.archived:e.run.archived)||!IS(e.run,t.origin??`all`)||!kw(t.projects??[],[e.run.projectId])||!kw(t.statuses,[e.run.status])||!kw(t.workflows,[e.run.workflow])||!Aw(e,t.tags)?!1:!i||zt(e.run,t.query,{scope:`shown`,omit:[`workflowLabel`],extras:jw(e,r)}))}function Nw(e,t,n,r,i){return Mw(e,r===`origin`?{...t,origin:`all`}:{...t,[r]:[]},n,i)}function Pw(e,t){if(t===`none`)return[{key:`all`,label:``,tasks:[...e]}];let n=new Map,r=(e,t,r)=>{let i=n.get(e);i?i.tasks.push(r):n.set(e,{key:e,label:t,tasks:[r]})};for(let n of e)if(t===`project`)r(n.run.projectId,n.projectName,n);else if(t===`status`)r(n.run.status,n.run.status,n);else if(t===`workflow`)r(n.run.workflow,n.run.workflow,n);else if(n.tags.length===0)r(mw,`Untagged`,n);else for(let e of n.tags)r(e.toLowerCase(),e,n);return[...n.values()].sort((e,t)=>e.key===` untagged`?1:t.key===` untagged`?-1:t.tasks.length-e.tasks.length||e.label.localeCompare(t.label))}function Fw(e,t){let n=new Map(t.map(e=>[e.id,e.name]));return e.map(e=>n.get(e)||e)}var Iw={query:`q`,project:`project`,tag:`tag`,untagged:`untagged`,status:`status`,workflow:`workflow`,groupBy:`group`,archived:`archived`,origin:`origin`},Lw=new Set(hw.map(e=>e.value));function Rw(e){let t=new URLSearchParams,n=e.filters.query.trim();n!==``&&t.set(Iw.query,n);for(let n of e.filters.tags)n===` untagged`?t.set(Iw.untagged,`1`):t.append(Iw.tag,n);for(let n of e.filters.projects??[])t.append(Iw.project,n);for(let n of e.filters.statuses)t.append(Iw.status,n);for(let n of e.filters.workflows)t.append(Iw.workflow,n);return e.groupBy!==`none`&&t.set(Iw.groupBy,e.groupBy),e.view===`archived`&&t.set(Iw.archived,`1`),e.filters.origin!==void 0&&e.filters.origin!==`all`&&t.set(Iw.origin,e.filters.origin),t}function zw(e){let t=e.getAll(Iw.tag).filter(e=>e!==``);e.get(Iw.untagged)===`1`&&t.push(mw);let n=e.get(Iw.groupBy)??``,r=FS(e.get(Iw.origin));return{filters:{query:e.get(Iw.query)??``,...e.has(Iw.project)?{projects:e.getAll(Iw.project).filter(Boolean)}:{},tags:t,statuses:e.getAll(Iw.status).filter(e=>e!==``),workflows:e.getAll(Iw.workflow).filter(e=>e!==``),...r===`all`?{}:{origin:r}},groupBy:Lw.has(n)?n:`none`,view:e.get(Iw.archived)===`1`?`archived`:`active`}}var Bw=15e3,Vw=250,Hw=1,Uw=new Set([`done`,`failed`,`cancelled`]);function Ww(){return Kw({request:({task:e,archived:t})=>_t(Vt(e.run.id,{projectId:e.run.projectId}),t),patch:({archived:e})=>t=>({...t,archived:e})})}function Gw(){return Kw({request:({task:e,read:t})=>kt(Vt(e.run.id,{projectId:e.run.projectId}),t),patch:({read:e})=>t=>{if(e)return{...t,seenAt:new Date().toISOString()};let{seenAt:n,...r}=t;return r}})}function Kw({request:e,patch:t}){let n=yn();return V({mutationFn:e,onMutate:e=>n.patchIndex(Vt(e.task.run.id,{projectId:e.task.run.projectId}),()=>t(e)),onError:(e,t,n)=>{n?.rollback(),K(e.message,{tone:`danger`})},onSettled:(e,t,{task:r},i)=>{i?i.settle():n.invalidateAfter(`indexed`,Vt(r.run.id,{projectId:r.run.projectId}))}})}function qw(){let e=It(),t=mn(),n=bC(t.data),r=Gt(!0,Bw),[i,a]=Yg(),{filters:o,groupBy:s,view:c}=Z.useMemo(()=>zw(i),[i]),l=eh(3e4),u=e=>a(t=>Rw(e(zw(t)))),d=e=>u(t=>({...t,filters:e(t.filters)})),f=e=>u(t=>({...t,groupBy:e})),p=e=>u(t=>({...t,view:e})),[m,h]=Z.useState(s!==`none`||o.tags.length>0),[g,_]=$w(o.query,e=>d(t=>({...t,query:e}))),v=r.data?.referenceStatuses;Z.useEffect(()=>{v&&yr(v)},[v]);let y=Z.useMemo(()=>e.data?.projects??[],[e.data]),b=Z.useMemo(()=>r.data?.runs??[],[r.data]),x=Z.useMemo(()=>ww(b,y),[b,y]),{nameOf:S,visible:C,originTotals:w,statusGroups:E,folds:D}=eT({tasks:x,filters:o,view:c,groupBy:s,index:b,automationsOn:t.data?.capabilities?.automations===!0}),k=Z.useMemo(()=>Pw(C,s),[C,s]),A=o.origin??`all`,j=e=>d(t=>vw(t,e)),M=Z.useMemo(()=>C.flatMap(e=>Vn(e.run,e.project?.repoUrl).filter(t=>Mn(t,e.project?.repoUrl)).map(t=>({projectId:e.run.projectId,kind:t.kind,number:t.number}))),[C]),N=Fw(r.data?.truncated??[],y),P=(e,t)=>d(n=>({...n,[e]:yw(n[e]??[],t)})),F=e=>d(t=>({...t,[e]:[]})),I=Ww(),L=Gw(),ee=r.error??e.error;if(ee)return(0,Q.jsx)(Jw,{groupBy:s,filterDetailsOpen:m,message:ee.message,onRetry:()=>{r.refetch(),e.refetch()}});let te=(0,Q.jsxs)(`div`,{className:`relative w-full`,children:[(0,Q.jsx)(Ba,{className:`pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-soft-foreground`,"aria-hidden":`true`}),(0,Q.jsx)(`input`,{type:`text`,value:g,onChange:e=>_(e.target.value),placeholder:`Search every project…`,"aria-label":`Search tasks across projects`,className:`h-11 w-full rounded-md border border-input bg-card pr-3 pl-8 text-[13px] text-foreground outline-none placeholder:text-soft-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`})]});return(0,Q.jsxs)(`div`,{"data-route":`global-tasks`,"data-presentation":s===`none`?`summary`:`cards`,"data-filter-details":m,className:`flex min-h-full flex-col gap-[22px] px-[18px] pt-6 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-9`,children:[(0,Q.jsxs)(`header`,{className:`flex shrink-0 flex-col gap-[22px]`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h1`,{className:`text-[30px] font-semibold tracking-tight`,children:`All tasks`}),(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:s===`none`?`Every project. One place to review what your agents have shipped.`:`Filter across projects and act on each run without opening the session.`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-6 border-b border-border`,children:[(0,Q.jsx)(tT,{view:`active`,current:c,onSelect:p,children:`Active`}),(0,Q.jsx)(tT,{view:`archived`,current:c,onSelect:p,children:`Archived`}),(0,Q.jsxs)(`span`,{"data-slot":`global-tasks-count`,className:`ml-auto text-[13px] text-soft-foreground tabular-nums`,children:[C.length,` of `,x.length,N.length>0?` loaded`:``]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,Q.jsx)(`div`,{className:`min-w-0 basis-full md:flex-1 md:basis-auto`,children:te}),(0,Q.jsxs)(O,{variant:`outline`,"aria-expanded":m,onClick:()=>h(e=>!e),children:[(0,Q.jsx)(po,{"aria-hidden":`true`}),`Filters`]}),(0,Q.jsx)(O,{asChild:!0,className:`min-h-11`,children:(0,Q.jsxs)(T,{to:us(e.data?.bootProject??`default`,`/new`),children:[(0,Q.jsx)(Ga,{"aria-hidden":`true`}),`New task`]})})]}),(0,Q.jsx)(YS,{origin:A,counts:w,onChange:j,labels:E.map(e=>e.label),onSetAll:D.setAll})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[22px]`,children:[(0,Q.jsx)(nT,{filters:o,onToggle:P,onClearFacet:F,onClearAll:()=>{_(``),u(e=>({...e,filters:_w,groupBy:`none`}))},groupBy:s,onGroupByChange:f,projects:y,tasks:x,view:c,automationName:S}),(0,Q.jsx)(Xw,{projects:N,perProjectLimit:r.data?.perProjectLimit}),r.data===void 0?(0,Q.jsx)(`div`,{role:`status`,className:`rounded-xl border border-border bg-card p-6 text-sm text-muted-foreground`,children:`Loading tasks…`}):(0,Q.jsx)(Yw,{view:c,filtered:xw(o),visibleCount:C.length,referenceRequests:M,lists:{groupBy:s,view:c,statusGroups:E,groups:k,folds:D,row:{now:l,onArchive:(e,t)=>I.mutate({task:e,archived:t}),onSetRead:(e,t)=>L.mutate({task:e,read:t}),busy:I.isPending||L.isPending,showCost:n.cost,automationName:S}}}),(0,Q.jsx)(Zw,{registry:y})]})]})}function Jw({groupBy:e,filterDetailsOpen:t,message:n,onRetry:r}){return(0,Q.jsx)(`div`,{"data-route":`global-tasks`,"data-presentation":e===`none`?`summary`:`cards`,"data-filter-details":t,className:`flex min-h-full flex-col gap-[22px] px-[18px] pt-6 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-9`,children:(0,Q.jsx)(X,{icon:(0,Q.jsx)(Aa,{}),tone:`danger`,title:`Tasks across projects did not load`,subtitle:n,actions:(0,Q.jsx)(O,{variant:`outline`,onClick:r,children:`Retry`})})})}function Yw({view:e,filtered:t,visibleCount:n,referenceRequests:r,lists:i}){return n===0?(0,Q.jsx)(uT,{view:e,filtered:t}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(rs,{requests:r,children:(0,Q.jsx)(Qw,{...i})}),i.groupBy===`none`?(0,Q.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Resource details—including tokens, cost, CPU and peak memory—are available when a task row is expanded.`}):null]})}function Xw({projects:e,perProjectLimit:t}){return e.length===0?null:(0,Q.jsxs)(`p`,{"data-slot":`global-tasks-truncated`,className:`text-[11px] text-soft-foreground`,children:[`Showing every active task and the newest `,t,` archived tasks per project — older archived tasks in`,` `,e.join(`, `),` are in that project’s own Tasks page.`]})}function Zw({registry:e}){return e.length<=1?null:(0,Q.jsxs)(`section`,{"data-slot":`other-projects`,className:`rounded-lg border border-border bg-card p-5`,children:[(0,Q.jsx)(`h2`,{className:`text-base font-semibold`,children:`Other projects`}),(0,Q.jsx)(`div`,{className:`mt-3 flex flex-col divide-y divide-border`,children:e.map(e=>(0,Q.jsxs)(`div`,{className:`flex min-h-14 items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-[13px]`,children:e.name}),(0,Q.jsxs)(T,{to:us(e.id,`/`),className:`inline-flex min-h-11 shrink-0 items-center rounded-md px-3 text-xs text-accent-text hover:bg-accent-strong/10`,children:[`View tasks`,(0,Q.jsxs)(`span`,{className:`sr-only`,children:[` for `,e.name]})]})]},e.id))})]})}function Qw({groupBy:e,view:t,statusGroups:n,groups:r,folds:i,row:a}){return(0,Q.jsx)(Q.Fragment,{children:e===`none`?n.map(e=>{let n=zS(e);return(0,Q.jsx)(ZS,{id:`global-group-${t}-${e.label.replaceAll(` `,`-`)}`,label:e.label,count:n.length,tone:BS(e.label,n.map(e=>e.run)),folded:i.isFolded(e.label),collapsed:i.isCollapsed(e.label),onToggle:()=>i.toggle(e.label),children:(0,Q.jsx)(rT,{tasks:e.rows.flatMap(WS),showProject:!0,...a})},e.label)}):r.map(t=>(0,Q.jsxs)(`section`,{"data-slot":`task-group`,"data-group-key":t.key,children:[(0,Q.jsxs)(`h2`,{className:`mb-1.5 flex items-center gap-2 text-[12px] font-semibold tracking-[0.04em] text-soft-foreground uppercase`,children:[e===`project`?(0,Q.jsx)(T,{to:us(t.key,`/`),"data-slot":`group-project-link`,className:`hover:text-foreground hover:underline`,children:t.label}):t.label,(0,Q.jsx)(`span`,{className:`font-mono text-[11px] font-medium tabular-nums`,children:t.tasks.length})]}),(0,Q.jsx)(rT,{tasks:t.tasks,showProject:e!==`project`,...a})]},t.key))})}function $w(e,t){let[n,r]=Z.useState(e),i=Z.useRef(e);return Z.useEffect(()=>{e!==i.current&&r(e),i.current=e},[e]),Z.useEffect(()=>{if(n===i.current)return;let e=setTimeout(()=>{i.current=n,t(n)},Vw);return()=>clearTimeout(e)},[n]),[n,r]}function eT({tasks:e,filters:t,view:n,groupBy:r,index:i,automationsOn:a}){let o=Z.useMemo(()=>[...new Set(e.filter(e=>e.run.automationId!==void 0).map(e=>e.run.projectId))],[e]),s=hr(o,a&&o.length>0),c=Z.useCallback(e=>e.run.automationId===void 0?void 0:s(e.run.projectId,e.run.automationId),[s]),l=Z.useMemo(()=>Mw(e,t,n,c),[e,t,n,c]),u=RS(Nw(e,t,n,`origin`,c).map(e=>e.run),n),d=r===`none`?US(l,n,i):[];return{nameOf:c,visible:l,originTotals:u,statusGroups:d,folds:vC(`global`,n,new Set(t.query.trim()===``?[]:d.map(e=>e.label)))}}function tT({view:e,current:t,onSelect:n,children:r}){let i=e===t;return(0,Q.jsx)(`button`,{type:`button`,"data-slot":`overview-tab`,"data-view":e,"aria-pressed":i,onClick:()=>n(e),className:k(`flex min-h-11 items-center justify-center border-b-2 border-transparent text-[13px] font-medium text-muted-foreground`,i&&`border-accent-strong font-semibold text-accent-text`),children:r})}function nT({filters:e,onToggle:t,onClearFacet:n,onClearAll:r,groupBy:i,onGroupByChange:a,projects:o,tasks:s,view:c,automationName:l}){let u=Z.useMemo(()=>En(o),[o]),d=Z.useMemo(()=>{let t=(t,n)=>Dw(Nw(s,e,c,t,l),n);return{projects:t(`projects`,e=>[e.run.projectId]),tags:t(`tags`,Ow),statuses:t(`statuses`,e=>[e.run.status]),workflows:t(`workflows`,e=>[e.run.workflow])}},[s,e,c,l]),f=e=>t=>({...t,count:e.get(t.value)??0});return(0,Q.jsxs)(`div`,{"data-slot":`global-tasks-filters`,className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,Q.jsx)(cw,{slot:`project`,label:`Project`,selected:e.projects??[],onToggle:e=>t(`projects`,e),onClear:()=>n(`projects`),options:[...new Map(s.map(e=>[e.run.projectId,e.projectName])).entries()].map(([e,t])=>({value:e,label:t})).map(f(d.projects)),emptyLabel:`No tasks to filter`}),(0,Q.jsx)(cw,{slot:`status`,label:`Status`,selected:e.statuses,onToggle:e=>t(`statuses`,e),onClear:()=>n(`statuses`),options:Ew(s).map(e=>({value:e,label:e})).map(f(d.statuses)),emptyLabel:`No tasks to filter`}),(0,Q.jsx)(cw,{slot:`workflow`,label:`Workflow`,selected:e.workflows,onToggle:e=>t(`workflows`,e),onClear:()=>n(`workflows`),options:Tw(s).map(e=>({value:e,label:e})).map(f(d.workflows)),emptyLabel:`No tasks to filter`}),(0,Q.jsxs)(`div`,{"data-slot":`group-controls`,className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`mx-1 h-5 w-px bg-border`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`text-[11px] font-medium text-soft-foreground`,children:`Group by`}),(0,Q.jsx)(uw,{slot:`group-by`,label:`Group tasks by`,value:i,options:hw,onChange:e=>a(gw(i,e))})]}),Cw({filters:e,groupBy:i})?(0,Q.jsxs)(`button`,{type:`button`,"data-action":`clear-filters`,onClick:r,className:`ml-auto inline-flex h-7 items-center gap-1 rounded-full px-2 text-xs font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,Q.jsx)(uo,{className:`size-3`,"aria-hidden":`true`}),`Clear`,` (${Sw({filters:e,groupBy:i})})`]}):null]}),u.length>0?(0,Q.jsxs)(`div`,{"data-slot":`tag-filters`,className:`flex flex-wrap items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-[11px] font-medium text-soft-foreground`,children:`Tags`}),u.map(n=>(0,Q.jsx)(lw,{slot:`tag-filter`,tone:`tag`,label:n,count:d.tags.get(n)??0,selected:e.tags.some(e=>e.toLowerCase()===n.toLowerCase()),onToggle:()=>t(`tags`,n)},n)),(0,Q.jsx)(lw,{slot:`tag-filter`,label:`Untagged`,count:d.tags.get(` untagged`)??0,selected:e.tags.includes(mw),onToggle:()=>t(`tags`,mw)})]}):(0,Q.jsxs)(`p`,{"data-slot":`no-tags-hint`,className:`text-[11px] text-soft-foreground`,children:[`Tag connected repositories in`,` `,(0,Q.jsx)(T,{to:`/settings/global/projects`,className:`font-medium text-accent-text hover:underline`,children:cs(`projects`)}),` `,`to group their tasks together here.`]})]})}function rT({tasks:e,now:t,showProject:n,onArchive:r,onSetRead:i,busy:a,showCost:o,automationName:s}){return(0,Q.jsxs)(`div`,{"data-slot":`global-tasks-table`,className:`overflow-x-auto rounded-lg border border-border bg-card p-5`,children:[(0,Q.jsx)(`div`,{"data-slot":`global-summary-head`,className:`text-[12px]`,"aria-hidden":`true`,children:[`Task`,`Workflow`,`Changes`,`Pull request`,`Started`].map(e=>(0,Q.jsx)(`span`,{children:e},e))}),(0,Q.jsx)(eC,{children:e.map(e=>(0,Q.jsx)(iT,{task:e,now:t,showProject:n,onArchive:r,onSetRead:i,busy:a,showCost:o,automationName:s(e)},`${e.run.projectId}/${e.run.id}`))})]})}function iT({task:e,now:t,showProject:n,onArchive:r,onSetRead:i,busy:a,showCost:o,automationName:s}){let{run:c}=e,[l,u]=Z.useState(!1),d=fe(c),f=us(c.projectId,`/tasks/${c.id}`),p=Yt(c),m=Xb(c),h=Vn(c,e.project?.repoUrl),g=sr(c,c.usage);return(0,Q.jsxs)(`article`,{"data-status":c.status,"data-expanded":l,"data-slot":`global-task-row`,"data-run-id":c.id,"data-project":c.projectId,className:`hover:bg-muted max-md:flex max-md:flex-wrap max-md:items-center max-md:gap-x-3 max-md:gap-y-2 max-md:border-b max-md:border-border max-md:py-5 max-md:first:pt-0 max-md:last:border-0 max-md:last:pb-0`,children:[(0,Q.jsxs)(`div`,{"data-slot":`global-task-title`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[c.delegation?.role===`worker`?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`Worker`}):null,(0,Q.jsx)(T,{to:f,title:xn(c),className:k(`min-w-0 truncate text-[14px] md:text-[13px]`,p?`font-semibold text-foreground`:m?`font-medium text-muted-foreground`:`font-medium`),children:xn(c)}),p?(0,Q.jsx)(J_,{tone:Qb(c),role:`img`,"aria-label":`unread`,title:`Unread — not opened since it finished`,className:`shrink-0`}):null]}),(0,Q.jsx)(`div`,{className:`mt-1`,children:(0,Q.jsx)(QS,{automationId:c.automationId,automationName:s,project:n?(0,Q.jsx)(T,{to:us(c.projectId,`/`),"data-slot":`task-project`,className:`truncate hover:text-foreground`,children:e.projectName}):void 0})}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,"aria-expanded":l,"aria-label":`${l?`Hide`:`Show`} resources for ${xn(c)}`,onClick:()=>u(e=>!e),"aria-describedby":`global-status-${c.projectId}-${c.id}`,title:`Resources and actions`,className:`min-h-[26px] rounded-md p-0 text-[11px] text-muted-foreground hover:bg-muted`,children:(0,Q.jsx)($x,{id:`global-status-${c.projectId}-${c.id}`,dot:d.tone,shape:d.shape,pulse:d.pulse,children:d.label})}),(0,Q.jsx)(`span`,{children:e.tags.length>0?(0,Q.jsx)(`span`,{className:`flex flex-wrap items-center gap-1`,children:e.tags.map(e=>(0,Q.jsx)(cT,{tag:e},e))}):null})]})]}),(0,Q.jsx)(`div`,{"data-slot":`global-task-references`,children:h.length>0?(0,Q.jsx)(sT,{references:h,run:c,repoBase:e.project?.repoUrl}):(0,Q.jsx)(lT,{})}),(0,Q.jsx)(`div`,{"data-slot":`global-task-workflow`,className:`text-[13px] text-muted-foreground`,children:c.workflow}),(0,Q.jsx)(`div`,{"data-slot":`global-task-diff`,className:`text-xs text-muted-foreground`,children:(0,Q.jsx)(`span`,{title:`Change totals are available in the project task list`,children:`—`})}),(0,Q.jsx)(`div`,{"data-slot":`global-task-age`,className:`text-right text-xs text-soft-foreground tabular-nums`,children:Io(c.startedAt??c.createdAt,t)}),(0,Q.jsx)(`div`,{"data-slot":`global-task-actions`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,Q.jsx)(aT,{task:e,busy:a,onSetRead:i}),(0,Q.jsx)(oT,{task:e,busy:a,onArchive:r}),(0,Q.jsx)(O,{asChild:!0,variant:`outline`,children:(0,Q.jsx)(T,{to:f,children:`Open task`})})]})}),l?(0,Q.jsxs)(`div`,{"data-slot":`global-task-resources`,className:`col-span-full flex flex-col gap-3`,children:[(0,Q.jsx)($S,{projectId:c.projectId,runId:c.id,status:d.label,error:c.error,open:(0,Q.jsx)(O,{asChild:!0,variant:`outline`,className:`min-h-11`,children:(0,Q.jsxs)(T,{to:f,children:[`Open task`,(0,Q.jsxs)(`span`,{className:`sr-only`,children:[`: `,xn(c)]})]})})}),(0,Q.jsxs)(`dl`,{className:`grid grid-cols-2 gap-4 rounded-md bg-muted/50 p-4 text-xs md:grid-cols-3`,children:[o?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Cost`}),(0,Q.jsx)(`dd`,{className:`mt-1`,children:rn(c.costUsd)||`—`})]}):null,(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`CPU`}),(0,Q.jsx)(`dd`,{"data-usage":`cpu`,"data-usage-kind":g.cpu.kind,title:g.cpu.title,className:`mt-1`,children:g.cpu.text||`—`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Memory`}),(0,Q.jsx)(`dd`,{"data-usage":`mem`,"data-usage-kind":g.mem.kind,title:g.mem.title,className:`mt-1`,children:g.mem.text||`—`})]})]})]}):null]})}function aT({task:e,busy:t,onSetRead:n}){if(!nr(e.run))return null;let r=Yt(e.run),i=xn(e.run),a=r?`Mark ${i} read`:`Mark ${i} unread`,o=r?ns:Kp;return(0,Q.jsxs)(tC,{children:[(0,Q.jsx)(nC,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-action":r?`mark-read`:`mark-unread`,"aria-label":a,disabled:t,onClick:()=>n(e,r),className:k(`inline-flex size-11 items-center justify-center md:size-8 rounded-md transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none disabled:cursor-wait disabled:opacity-50`,r?`text-accent-icon`:`text-soft-foreground`),children:[(0,Q.jsx)(o,{className:`size-3.5`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{children:r?`Mark read`:`Mark unread`})]})}),(0,Q.jsx)(rC,{side:`left`,children:r?`Mark read`:`Mark unread`})]})}function oT({task:e,busy:t,onArchive:n}){let r=e.run.archived;if(!r&&!Uw.has(e.run.status))return null;let i=r?`Restore ${xn(e.run)} to the active list`:`Archive ${xn(e.run)}`;return(0,Q.jsxs)(tC,{children:[(0,Q.jsx)(nC,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-action":r?`unarchive-run`:`archive-run`,"aria-label":i,disabled:t,onClick:()=>n(e,!r),className:`inline-flex size-11 items-center justify-center md:size-8 rounded-md text-soft-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none disabled:cursor-wait disabled:opacity-50`,children:[(0,Q.jsx)(r?Cp:bo,{className:`size-3.5`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{children:r?`Unarchive`:`Archive`})]})}),(0,Q.jsx)(rC,{side:`left`,children:r?`Restore`:`Archive`})]})}function sT({references:e,run:t,repoBase:n}){return(0,Q.jsx)(pw,{references:e,maxVisible:Hw,taskTitle:xn(t),projectId:t.projectId,runId:t.id,repoBase:n})}function cT({tag:e,className:t}){return(0,Q.jsx)(`span`,{"data-slot":`project-tag`,className:k(`inline-flex max-w-full items-center truncate rounded-full bg-muted px-1.5 py-px text-[11px] font-medium text-muted-foreground`,t),children:e})}function lT(){return(0,Q.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`—`})}function uT({view:e,filtered:t}){return t?(0,Q.jsx)(X,{heading:`h2`,icon:(0,Q.jsx)(ls,{}),tone:`neutral`,title:`No matching tasks`,subtitle:`No task in any project matches these filters.`}):e===`archived`?(0,Q.jsx)(X,{heading:`h2`,icon:(0,Q.jsx)(bo,{}),tone:`neutral`,title:`Nothing archived yet`,subtitle:`Finished tasks you archive land here, from every project.`}):(0,Q.jsx)(X,{heading:`h2`,icon:(0,Q.jsx)(cm,{}),tone:`neutral`,title:`No tasks yet`,subtitle:`Start a task in any project and it shows up here.`})}var dT=new Map;function fT(e){let t=dT.get(e);return t||(t=new Intl.DateTimeFormat(`en-CA`,{timeZone:e,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`}),dT.set(e,t)),t}function pT(e,t){try{let n=fT(t).formatToParts(new Date(e)),r=e=>Number(n.find(t=>t.type===e)?.value),i=r(`year`),a=r(`month`),o=r(`day`);return{year:i,month:a,day:o,hour:r(`hour`)%24,minute:r(`minute`),second:r(`second`),weekday:mT(i,a,o)}}catch{return null}}function mT(e,t,n){return(new Date(Date.UTC(e,t-1,n)).getUTCDay()+6)%7+1}function hT(e,t){let n=pT(t,e);return n?Date.UTC(n.year,n.month-1,n.day,n.hour,n.minute,n.second)-t:null}function gT(e,t,n,r,i,a){let o=Date.UTC(e,t-1,n,r,i,0,0),s=o;for(let e=0;e<3;e+=1){let e=hT(a,s);if(e===null)return null;let t=o-e;if(Math.abs(t-s)<1e3)return t;s=t}return s}function _T(e){if(!e)return!1;try{return fT(e).format(new Date(0)),!0}catch{return!1}}var vT=[`daily`,`weekdays`,`weekly`,`hours`,`once`],yT=[1,2,3,4,6,8,12],bT=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],xT=[`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`,`Sunday`],ST=43200,CT=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/,wT=[`hour`,`minute`,`day`,`every`],TT=[`at`,`timeZone`,`latestStartMinutes`],ET=`the due time has passed; choose a later time or use Run now`;function DT(e){return`unknown time zone "${e}"; use an IANA name such as Europe/Warsaw`}var OT=G({type:qr(vT),hour:U().int().min(0).max(23).optional(),minute:U().int().min(0).max(59).optional(),day:U().int().min(1).max(7).optional(),every:$r([Zr(1),Zr(2),Zr(3),Zr(4),Zr(6),Zr(8),Zr(12)]).optional(),at:W().regex(CT,`at must be YYYY-MM-DDTHH:MM`).optional(),timeZone:W().optional(),latestStartMinutes:U().int().min(10).max(ST).optional()}).superRefine((e,t)=>{let n=t=>e[t]!==void 0,r=(e,n)=>t.addIssue({code:`custom`,path:[e],message:n});if(e.type!==`once`){for(let e of TT)n(e)&&r(e,`${e} applies only to a once schedule`);return}for(let e of wT)n(e)&&r(e,`${e} does not apply to a once schedule`);e.at===void 0?r(`at`,`a once schedule needs at (YYYY-MM-DDTHH:MM)`):CT.test(e.at)&&!MT(e.at)&&r(`at`,`at is not a real date and time`),e.timeZone===void 0?r(`timeZone`,`a once schedule needs a timeZone`):_T(e.timeZone)||r(`timeZone`,DT(e.timeZone))});function kT(e){return{type:e.type,hour:e.hour??4,minute:e.minute??0,day:e.day??1,every:e.every??6,...e.at===void 0?{}:{at:e.at},...e.timeZone===void 0?{}:{timeZone:e.timeZone},...e.latestStartMinutes===void 0?{}:{latestStartMinutes:e.latestStartMinutes}}}function AT(e){if(e.type!==`once`||!e.at||!e.timeZone)return null;let t=jT(e.at);return t&&gT(t.year,t.month,t.day,t.hour,t.minute,e.timeZone)}function jT(e){let t=CT.exec(e);if(!t)return null;let[n,r,i,a,o]=t.slice(1).map(Number),s=new Date(Date.UTC(n,r,0)).getUTCDate();return r<1||r>12||i<1||i>s||a>23||o>59?null:{year:n,month:r,day:i,hour:a,minute:o}}var MT=e=>jT(e)!==null,NT=e=>String(e).padStart(2,`0`);function PT(e,t=0){return`${NT(e)}:${NT(t)}`}function FT(e){let t=kT(e);switch(t.type){case`once`:return IT(t);case`daily`:return`every day at ${PT(t.hour,t.minute)}`;case`weekdays`:return`weekdays at ${PT(t.hour,t.minute)}`;case`hours`:return t.every===1?`every hour`:`every ${t.every} hours`;case`weekly`:return`${xT[t.day-1]}s at ${PT(t.hour,t.minute)}`}}function IT(e){let t=e.at?jT(e.at):null;if(!t)return`once`;let{year:n,month:r,day:i,hour:a,minute:o}=t;return`once on ${bT[mT(n,r,i)-1]} ${i} ${LT[r-1]} ${n} at ${PT(a,o)} (${e.timeZone??`UTC`})`}var LT=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function RT(e){let t=kT(e);switch(t.type){case`once`:throw Error(`a once schedule has no cron form`);case`daily`:return`${t.minute} ${t.hour} * * *`;case`weekdays`:return`${t.minute} ${t.hour} * * 1-5`;case`hours`:return`0 */${t.every} * * *`;case`weekly`:return`${t.minute} ${t.hour} * * ${t.day%7}`}}function zT(e,t){switch(e.type){case`once`:return[];case`daily`:return[[e.hour,e.minute]];case`weekdays`:return t<=5?[[e.hour,e.minute]]:[];case`weekly`:return t===e.day?[[e.hour,e.minute]]:[];case`hours`:{let t=[];for(let n=0;n<24;n+=e.every)t.push([n,0]);return t}}}function BT(e,t,n,r,i=1e3){if(e.type===`once`){let r=AT(e);return r!==null&&r>=t&&r<n&&i>0?[r]:[]}let a=kT(e),o=pT(t,r);if(!o||n<=t)return[];let s=[],c=Math.ceil((n-t)/864e5)+2;for(let e=-1;e<=c;e+=1){let c=new Date(Date.UTC(o.year,o.month-1,o.day+e)),l=c.getUTCFullYear(),u=c.getUTCMonth()+1,d=c.getUTCDate();for(let[e,o]of zT(a,mT(l,u,d))){let a=gT(l,u,d,e,o,r);if(a===null||a!==s.at(-1)&&a>=t&&a<n&&(s.push(a),s.length>=i))return s}}return s}function VT(e,t){let n=t-e;if(n<=0)return`now`;let r=Math.floor(n/6e4);if(r<1)return`in <1m`;if(r<60)return`in ${r}m`;let i=Math.floor(r/60);return i<24?`in ${i}h`:`in ${Math.floor(i/24)}d`}var HT=new Map;function UT(e,t){if(!Number.isFinite(e))return null;let n=HT.get(t);try{n??=new Intl.DateTimeFormat(`en-GB`,{timeZone:t,weekday:`short`,year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`})}catch{return null}HT.set(t,n);let r={};for(let t of n.formatToParts(e))r[t.type]=t.value;let i=new Date(`${r.month} 1, ${r.year} UTC`).getUTCMonth();return{weekday:r.weekday,day:r.day,month:r.month,hour:r.hour,minute:r.minute,key:`${r.year}-${i}-${r.day}`,dayNumber:Math.floor(Date.UTC(Number(r.year),i,Number(r.day))/864e5)}}function WT(e,t){let n=UT(Date.parse(e),t);return n?`${n.weekday} ${n.hour}:${n.minute}`:e}function GT(e,t,n){let r=UT(Date.parse(e),t),i=UT(n,t);if(!r||!i)return e;let a=`${r.hour}:${r.minute}`,o=i.dayNumber-r.dayNumber;return o===0?`Today ${a}`:o===1?`Yesterday ${a}`:o>1&&o<7?`${r.weekday} ${a}`:`${r.day} ${r.month} ${a}`}var KT=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],qT=e=>String(e).padStart(2,`0`);function JT(e){let t=e?jT(e):null;if(!t)return null;let{year:n,month:r,day:i,hour:a,minute:o}=t;return{date:`${bT[mT(n,r,i)-1]} ${i} ${KT[r-1]} ${n}`,time:`${qT(a)}:${qT(o)}`}}var YT=36e5;function XT(e){let t=AT(e),n=e.timeZone,r=JT(e.at),i=t===null||!n?null:pT(t,n);if(t===null||!n||!r||!i)return null;let a={date:`${bT[mT(i.year,i.month,i.day)-1]} ${i.day} ${KT[i.month-1]} ${i.year}`,time:`${qT(i.hour)}:${qT(i.minute)}`};if(a.date!==r.date||a.time!==r.time)return{...a,note:`${r.time} does not exist on ${r.date} in ${n}.`};let o=e=>{let t=pT(e,n);return!!t&&t.day===i.day&&t.hour===i.hour&&t.minute===i.minute},s=(hT(n,t-12*YT)??0)-(hT(n,t+12*YT)??0);if(s<=0)return a;let c=o(t+s);if(!c&&!o(t-s))return a;let l=(hT(n,t)??0)/6e4,u=`UTC${l<0?`-`:`+`}${qT(Math.floor(Math.abs(l)/60))}:${qT(Math.abs(l)%60)}`;return{...a,note:`${r.time} happens twice that day; it runs at ${c?`the first`:`the second`} (${u}).`}}var ZT=qr([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),QT=G({includeExisting:Gr().optional(),authors:Jr(W()).optional(),assignees:Jr(W()).optional(),requireCurrentLabels:Gr().optional(),allLabels:Jr(W()).optional(),anyLabels:Jr(W()).optional(),excludeLabels:Jr(W()).optional(),changedLabels:Jr(W()).optional(),lookbackDays:U(),maxRecords:U()}),$T=qr([`github`,`schedule`]),eE=Oe.omit({task:!0,images:!0,systemPrompt:!0}).extend({prompt:W(),variants:$r([Zr(1),Zr(2),Zr(3)]).optional(),systemPrompt:W().optional()}),tE=G({at:W(),outcome:qr([`launched`,`cancelled`]),runId:W().optional(),receiptId:W().optional(),trigger:qr([`schedule`,`late`,`manual`,`retry`]).optional()}),nE=qr([`paused`,`waiting`,`failed`,`missed`,`archived`]),rE=G({id:W(),revision:U(),name:W(),description:W().optional(),enabled:Gr(),kind:$T,events:Jr(ZT).optional(),intervalSeconds:U().optional(),filters:QT.optional(),schedule:OT.optional(),task:eE,archived:tE.optional(),createdAt:W(),updatedAt:W()}),iE=G({timestamp:W(),tieBreaker:W().optional()}),aE=G({since:W().datetime(),until:W().datetime(),source:U().int().min(0).max(2),page:U().int().min(1).max(10),item:U().int().min(0).max(100),event:U().int().min(0).max(1e3),cursor:iE.optional()}),oE=G({revision:U().optional(),baselineAt:W().optional(),armedAt:W().optional(),historyScan:aE.optional(),cursor:iE.optional(),frozenHighWatermark:iE.extend({tieBreaker:W()}).optional(),backlogAfter:iE.extend({tieBreaker:W()}).optional(),nextCheckAt:W().optional(),lastSuccessAt:W().optional(),nextRunAt:W().optional(),lastRunAt:W().optional(),etags:Yr(W(),W()).optional(),backoffUntil:W().optional(),consecutiveFailures:U().optional(),onceOutcome:qr([`failed`,`missed`]).optional()}),sE=qr([`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`skipped`,`manual`,`catch-up`,`failed`,`missed`]),cE=G({seq:U(),ts:W(),automationId:W(),revision:U(),event:ZT.optional(),result:sE,reason:W().optional(),durationMs:U().optional(),receiptId:W().optional(),runId:W().optional(),githubNumber:U().optional(),githubTitle:W().optional(),githubUrl:W().optional(),rateLimit:G({bucket:qr([`core`,`search`]),remaining:U().optional(),resetAt:W().optional()}).optional()}),lE=G({matches:U(),launched:U(),duplicates:U(),errors:U()}),uE=rE.extend({state:oE.optional(),latestLog:cE.optional(),counts:lE,nextRunAt:W().optional(),onceStatus:nE.optional()});G({available:Gr(),reason:W().optional(),timeZone:W(),scheduler:G({state:qr([`scheduled`,`idle`]),nextDue:W().optional()}),automations:Jr(uE)}),G({automation:rE}).extend({once:G({dueAt:W(),timeZone:W(),resolvedInstant:W(),note:W()}).optional()}),G({automation:rE,state:oE.optional(),latestLog:cE.optional(),onceStatus:nE.optional()}),G({id:W(),automationId:W(),mode:qr([`preview`,`execute`]),status:qr([`queued`,`running`,`complete`,`error`]),createdAt:W(),completedAt:W().optional(),matches:U().optional(),truncated:Gr().optional(),error:W().optional()}),G({checkId:W()}),G({records:Jr(cE)}),G({receiptId:W(),runId:W()}),G({runId:W()}),rE.omit({id:!0,revision:!0,createdAt:!0,updatedAt:!0,enabled:!0,kind:!0,archived:!0}).extend({kind:$T.optional(),task:eE.extend({variants:pt}),enable:Gr().optional()}).omit({enable:!0}).extend({enabled:Gr().optional(),expectedRevision:U()}),G({archived:qr([`include`,`only`]).optional()}),G({mode:qr([`preview`,`execute`])});function dE({title:e,subtitle:t,action:n,children:r}){return(0,Q.jsxs)(`main`,{"data-route":`automations`,className:`task-flow-page w-full max-w-full min-w-0 max-md:p-4!`,children:[(0,Q.jsxs)(`header`,{className:`mb-6 flex flex-col items-start gap-5 max-md:mb-4 max-md:gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h1`,{className:`mb-2 text-[28px] font-medium max-md:text-[22px]`,children:e}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t})]}),n]}),r]})}function fE({text:e}){return(0,Q.jsx)(`div`,{role:`status`,className:`rounded-xl border bg-card p-6 text-sm text-muted-foreground`,children:e})}var pE={launched:`success`,manual:`success`,"catch-up":`success`,skipped:`neutral`,missed:`neutral`,"no-match":`neutral`,preview:`neutral`,baseline:`neutral`,duplicate:`neutral`,failed:`danger`,error:`danger`,"rate-limited":`danger`},mE={launched:`Launched`,manual:`Manual`,"catch-up":`Catch up`,skipped:`Skipped`,missed:`Missed`,"no-match":`No match`,preview:`Preview`,baseline:`Baseline`,duplicate:`Duplicate`,failed:`Failed`,error:`Error`,"rate-limited":`Rate limited`};function hE(e){let[t,n]=(0,Z.useState)(),[r,i]=(0,Z.useState)(``),a=(0,Z.useCallback)(t=>_e(e,{signal:t}).then(({records:e})=>{t?.aborted||(n(e),i(``))}).catch(e=>{t?.aborted||i(String(e))}),[e]);return(0,Z.useEffect)(()=>{a()},[a]),(0,Z.useEffect)(()=>R(a),[a]),(0,Z.useEffect)(()=>$c((t,n)=>{t===`automation-change`&&n.automationId===e&&a()}),[e,a]),{records:t,error:r,refresh:a}}function gE(e,t){return e.result!==`failed`&&e.result!==`error`||!e.receiptId||e.runId?!1:!t.some(t=>t.receiptId===e.receiptId&&(t.runId||t.seq>e.seq))}function _E({records:e,all:t,timeZone:n,onRetried:r,readOnly:i=!1}){let a=e=>!i&&gE(e,t),[o,s]=(0,Z.useState)(),[c,l]=(0,Z.useState)(),u=Date.now(),d=async e=>{s(e),l(void 0);try{await Xe(e),r()}catch(t){l({receiptId:e,message:t instanceof Error?t.message:String(t)})}finally{s(void 0)}};return(0,Q.jsx)(`ol`,{className:`grid gap-3`,"aria-label":`Automation execution log`,children:e.map(e=>(0,Q.jsxs)(`li`,{className:`min-w-0 rounded-xl border bg-card p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsx)($x,{dot:pE[e.result],children:mE[e.result]}),(0,Q.jsx)(`time`,{className:`text-xs text-muted-foreground`,dateTime:e.ts,title:e.ts,children:GT(e.ts,n,u)})]}),e.reason?(0,Q.jsx)(`p`,{className:`mt-2 text-sm break-words text-muted-foreground`,children:e.reason}):null,e.githubUrl||e.runId||a(e)?(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-sm`,children:[e.githubUrl?(0,Q.jsx)(`a`,{className:`inline-flex min-h-11 items-center underline underline-offset-4 break-all`,href:e.githubUrl,target:`_blank`,rel:`noreferrer`,children:e.githubTitle??`GitHub #${e.githubNumber??``}`}):null,e.runId?(0,Q.jsx)(Y,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`}):null,a(e)?(0,Q.jsx)(O,{variant:`outline`,disabled:o===e.receiptId,onClick:()=>void d(e.receiptId),children:`Retry task`}):null]}):null,c&&c.receiptId===e.receiptId?(0,Q.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm break-words text-destructive`,children:c.message}):null]},e.seq))})}var vE=`all`;function yE({label:e,value:t,onChange:n,options:r}){return(0,Q.jsxs)(Ff,{value:t,onValueChange:n,children:[(0,Q.jsx)(Lf,{"aria-label":e,className:`w-full sm:w-52`,children:(0,Q.jsx)(If,{})}),(0,Q.jsx)(Rf,{children:r.map(e=>(0,Q.jsx)(zf,{value:e.value,children:e.label},e.value))})]})}function bE({automationId:e,automationName:t,timeZone:n,readOnly:r=!1}){let{records:i,error:a,refresh:o}=hE(e),[s,c]=(0,Z.useState)(vE),[l,u]=(0,Z.useState)(vE),d=(0,Z.useMemo)(()=>(i??[]).filter(e=>(s===vE||e.result===s)&&(l===vE||e.event===l)),[i,s,l]),f=(i??[]).some(e=>e.event);return(0,Q.jsx)(dE,{title:`Execution log`,subtitle:t??`Automation activity`,action:(0,Q.jsx)(O,{variant:`outline`,asChild:!0,children:(0,Q.jsx)(Y,{to:`/automations`,children:`Back to automations`})}),children:a&&!i?(0,Q.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,Q.jsx)(fE,{text:a}),(0,Q.jsx)(O,{variant:`outline`,onClick:()=>void o(),children:`Retry`})]}):i?i.length===0?(0,Q.jsx)(fE,{text:`Nothing has run yet.`}):(0,Q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(yE,{label:`Result`,value:s,onChange:c,options:[{value:vE,label:`All results`},...sE.options.map(e=>({value:e,label:mE[e]}))]}),f?(0,Q.jsx)(yE,{label:`Event`,value:l,onChange:u,options:[{value:vE,label:`All events`},...ZT.options.map(e=>({value:e,label:e}))]}):null]}),d.length===0?(0,Q.jsx)(fE,{text:`No rows match these filters.`}):(0,Q.jsx)(_E,{records:d,all:i,timeZone:n,onRetried:()=>void o(),readOnly:r})]}):(0,Q.jsx)(fE,{text:`Loading execution log…`})})}function xE({automationId:e,automationName:t,timeZone:n,showName:r=!1,readOnly:i=!1}){let{records:a,error:o,refresh:s}=hE(e);return(0,Q.jsxs)(`section`,{"data-slot":`automation-inline-log`,className:`mt-4 min-w-0 border-t pt-4`,children:[(0,Q.jsxs)(`h3`,{className:`mb-3 text-sm font-medium`,children:[`Recent activity`,r&&t?` · ${t}`:``]}),o&&!a?(0,Q.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,Q.jsx)(fE,{text:o}),(0,Q.jsx)(O,{variant:`outline`,onClick:()=>void s(),children:`Retry`})]}):a?a.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing has run yet.`}):(0,Q.jsx)(_E,{records:a.slice(0,5),all:a,timeZone:n,onRetried:()=>void s(),readOnly:i}):(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading activity…`})]})}function SE({automation:e,timeZone:t,onDeleted:n}){let r=e.archived,i=e.schedule,a=i?XT(i):null,[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(``),f=(0,Z.useRef)(null),p=(0,Z.useRef)(null),m=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let e=m.current===`keep`?p.current:m.current===`delete`?f.current:null;m.current=null,e?.focus()},[o]);let h=async()=>{l(!0);try{await ye(e.id),n()}catch(e){d(e instanceof Error?e.message:String(e)),l(!1)}},g=[[`Workflow`,e.task.workflow],[`Runner`,e.task.runner],[`Model`,e.task.model],[`Effort`,e.task.effort]];return(0,Q.jsx)(dE,{title:e.name,subtitle:`Archived one-time schedule. It cannot change; delete it when you no longer need the record.`,children:(0,Q.jsxs)(`div`,{className:`grid min-w-0 max-w-3xl gap-5`,children:[(0,Q.jsxs)(`section`,{className:`min-w-0 rounded-xl border bg-card p-4`,children:[(0,Q.jsxs)(`p`,{className:`text-sm break-words`,children:[(0,Q.jsx)(`span`,{children:r.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`}),r.runId?(0,Q.jsxs)(Q.Fragment,{children:[` · `,(0,Q.jsx)(Y,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${r.runId}`,children:`Open task`})]}):null]}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Archived ${WT(r.at,t)} (${t}).`}),a&&i?.timeZone?(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Was due ${a.date} ${a.time} (${i.timeZone}).`}):null]}),(0,Q.jsxs)(`section`,{"aria-labelledby":`archived-inputs`,className:`min-w-0 rounded-xl border bg-card p-4`,children:[(0,Q.jsx)(`h2`,{id:`archived-inputs`,className:`mb-3 text-[15px] font-medium`,children:`What it ran with`}),(0,Q.jsxs)(`dl`,{className:`grid gap-3 text-sm`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-1`,children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Prompt`}),(0,Q.jsx)(`dd`,{className:`break-words whitespace-pre-wrap`,children:e.task.prompt})]}),g.filter(([,e])=>e).map(([e,t])=>(0,Q.jsxs)(`div`,{className:`grid gap-1`,children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,Q.jsx)(`dd`,{className:`break-words`,children:t})]},e))]})]}),(0,Q.jsxs)(`section`,{className:`min-w-0`,children:[(0,Q.jsx)(xE,{automationId:e.id,automationName:e.name,timeZone:t,readOnly:!0}),(0,Q.jsx)(O,{variant:`outline`,asChild:!0,className:`mt-3`,children:(0,Q.jsx)(Y,{to:`/automations/${e.id}/log`,children:`Execution log`})})]}),(0,Q.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[o?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? Its record and log are removed; the task stays.`}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(O,{variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:c,onClick:()=>void h(),children:`Delete schedule`}),(0,Q.jsx)(O,{ref:p,variant:`outline`,disabled:c,onClick:()=>{m.current=`delete`,s(!1)},children:`Keep`})]})]}):(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(O,{ref:f,variant:`outline`,"data-action":`automation-delete`,onClick:()=>{m.current=`keep`,s(!0)},children:`Delete`}),(0,Q.jsx)(O,{variant:`outline`,asChild:!0,children:(0,Q.jsx)(Y,{to:`/automations`,children:`Back to automations`})})]}),u?(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:u}):null]})]})})}function CE({className:e,...t}){return(0,Q.jsx)(au,{"data-slot":`label`,className:k(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var wE=`quick-task`;function TE(e={}){let{prompt:t,workflow:n,runner:r,model:i,autonomous:a,archiveWhenDone:o,autoMergePr:s,variants:c,...l}=e.task??{prompt:``},u=e.task===void 0;return{retiredVariants:c!==void 0&&c!==1,name:e.name??``,description:e.description??``,kind:e.kind??`schedule`,schedule:kT(e.schedule??{type:`daily`}),events:e.events??[`issue.opened`],intervalSeconds:e.intervalSeconds??300,filters:e.filters??{lookbackDays:7,maxRecords:25},prompt:t,...n===void 0?u?{workflow:wE}:{}:{workflow:n},...r===void 0?{}:{runner:r},...i===void 0?{}:{model:i},autonomous:a??!0,archiveWhenDone:o??!1,autoMergePr:s??!1,enabled:e.enabled??e.enable??!1,taskExtra:l}}function EE(e){switch(e.type){case`daily`:case`weekdays`:return{type:e.type,hour:e.hour,minute:e.minute};case`weekly`:return{type:`weekly`,hour:e.hour,minute:e.minute,day:e.day};case`hours`:return{type:`hours`,every:e.every};case`once`:return{type:`once`,at:e.at??``,timeZone:e.timeZone??``,...e.latestStartMinutes===void 0?{}:{latestStartMinutes:e.latestStartMinutes}}}}function DE(e){if(e.retiredVariants)throw Error(`Parallel variants are removed. Choose Use one task before saving this automation.`);return{...e.taskExtra,prompt:e.prompt,...e.workflow?{workflow:e.workflow}:{},...e.runner?{runner:e.runner}:{},...e.model?{model:e.model}:{},autonomous:e.autonomous,...e.archiveWhenDone?{archiveWhenDone:!0}:{},...e.autoMergePr?{autoMergePr:!0}:{}}}function OE(e){return{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},kind:e.kind,...e.kind===`schedule`?{schedule:EE(e.schedule)}:{events:e.events,intervalSeconds:e.intervalSeconds,filters:e.filters},task:DE(e)}}function kE(e){return{...OE(e),enable:e.enabled}}function AE(e,t){return{...OE(e),task:{...DE(e),archiveWhenDone:e.archiveWhenDone,autoMergePr:e.autoMergePr},enabled:e.enabled,expectedRevision:t}}function jE(e){return`'${e.replace(/'/g,`'\\''`)}'`}var ME=new Set([`prompt`,`workflow`,`runner`,`model`,`autonomous`,`worktree`,`archiveWhenDone`,`autoMergePr`]),NE=new Set([`anyLabels`,`authors`,`changedLabels`]);function PE(e){if(e.description!==void 0||!e.name.trim()||!e.task.prompt.trim())return!1;let t=e.task;if(Object.keys(t).some(e=>!ME.has(e))||t.archiveWhenDone===!1||t.autoMergePr===!1||t.worktree!==!0)return!1;if(e.kind===`schedule`)return e.schedule!==void 0;let{events:n,filters:r}=e;return!n?.length||n.some(e=>e.includes(`,`))||!r||r.lookbackDays!==7||r.maxRecords!==25?!1:Object.entries(r).every(([e,t])=>e===`lookbackDays`||e===`maxRecords`||e===`includeExisting`&&t===!0||NE.has(e)&&Array.isArray(t)&&t.length>0)}function FE(e){return e%3600==0?`${e/3600}h`:e%60==0?`${e/60}m`:`${e}s`}function IE(e){return e%1440==0?`${e/1440}d`:e%60==0?`${e/60}h`:`${e}m`}function LE(e,t){return t.startsWith(`-`)?`--${e}=${jE(t)}`:`--${e} ${jE(t)}`}function RE(e){let t=[`cez automation add`,LE(`name`,e.name)];if(e.schedule?.type===`once`)t.push(LE(`at`,e.schedule.at),LE(`tz`,e.schedule.timeZone)),e.schedule.latestStartMinutes!==void 0&&t.push(LE(`latest-start`,IE(e.schedule.latestStartMinutes)));else if(e.kind===`schedule`)t.push(LE(`cron`,RT(e.schedule)));else{t.push(LE(`on`,e.events.join(`,`)),`--every ${FE(e.intervalSeconds??300)}`),e.filters?.includeExisting&&t.push(`--include-existing`);for(let n of e.filters?.anyLabels??[])t.push(LE(`label`,n));for(let n of e.filters?.authors??[])t.push(LE(`author`,n));for(let n of e.filters?.changedLabels??[])t.push(LE(`changed-label`,n))}let{task:n}=e;return n.workflow&&t.push(LE(`workflow`,n.workflow)),n.runner&&t.push(LE(`runner`,n.runner)),n.model&&t.push(LE(`model`,n.model)),n.autonomous===!1&&t.push(`--no-autonomous`),n.archiveWhenDone&&t.push(`--archive-when-done`),n.autoMergePr&&t.push(`--auto-merge-pr`),e.enable===!0&&t.push(`--enable`),t.push(LE(`prompt`,n.prompt)),t.join(` `)}function zE(e,t){let n=kE(e),r=PE(n)?RE(n):`cez automation create --json ${jE(JSON.stringify(n))}`;return t?`CEZ_COCKPIT_URL=${jE(t.origin)} CEZ_PROJECT_ID=${jE(t.projectId)} ${r}`:r}function BE({draft:e}){let t=_s(),n=window.location.origin,r=(0,Z.useMemo)(()=>zE(e,t?{origin:n,projectId:t}:void 0),[e,n,t]),[i,a]=(0,Z.useState)(`idle`),o=(0,Z.useRef)(void 0);(0,Z.useEffect)(()=>()=>clearTimeout(o.current),[]),(0,Z.useEffect)(()=>a(`idle`),[r]);let s=async()=>{clearTimeout(o.current);try{await navigator.clipboard.writeText(r),a(`copied`),o.current=setTimeout(()=>a(`idle`),1600)}catch{a(`failed`)}};return(0,Q.jsxs)(`section`,{"aria-labelledby":`copy-as-cli-heading`,"data-slot":`copy-as-cli`,className:`mbs-4 rounded-xl border bg-card p-4`,children:[(0,Q.jsxs)(`div`,{className:`mbe-2 flex items-center gap-2`,children:[(0,Q.jsx)(`h2`,{id:`copy-as-cli-heading`,className:`text-[15px] font-medium`,children:`Copy as CLI`}),(0,Q.jsxs)(O,{type:`button`,variant:`ghost`,size:`sm`,className:`ms-auto`,onClick:()=>void s(),children:[i===`copied`?(0,Q.jsx)(Ap,{"aria-hidden":`true`}):(0,Q.jsx)(Bp,{"aria-hidden":`true`}),i===`copied`?`Copied`:`Copy`]})]}),(0,Q.jsx)(`pre`,{className:`m-0 rounded-lg border bg-muted px-2.5 py-2 font-mono text-xs/relaxed break-words whitespace-pre-wrap text-muted-foreground`,children:r}),(0,Q.jsx)(`p`,{role:`status`,className:`mbs-2 text-xs break-words text-muted-foreground`,children:i===`failed`?`Could not copy — select the line and copy it by hand.`:(0,Q.jsxs)(Q.Fragment,{children:[`The definition Save would create. `,(0,Q.jsx)(`code`,{children:`cez automation schema`}),` prints its shape.`]})})]})}function VE({pressed:e,onClick:t,disabled:n,children:r}){return(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":e,disabled:n,onClick:t,className:k(Xs,`h-11 px-4 text-[13px]`,e&&`border-transparent bg-accent-strong text-accent-strong-foreground hover:bg-accent-strong hover:text-accent-strong-foreground`),children:r})}var HE=ZT.options,UE=[{seconds:60,label:`1 minute`},{seconds:300,label:`5 minutes`},{seconds:900,label:`15 minutes`},{seconds:1800,label:`30 minutes`},{seconds:3600,label:`1 hour`}],WE=[{key:`authors`,label:`Authors`},{key:`assignees`,label:`Assignees`},{key:`allLabels`,label:`Has all labels`},{key:`anyLabels`,label:`Has any label`},{key:`excludeLabels`,label:`Excludes labels`},{key:`changedLabels`,label:`Changed labels`,hint:`Required for the two label events.`}],GE=e=>(e??[]).join(`, `),KE=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean);function qE(e){return e?`Existing matches within the lookback are eligible on the next check. Previously processed matches will not run again.`:`Enabling starts from a current-time baseline. Existing matches will not launch tasks.`}function JE(e){let t=Math.max(1,Math.round(e.intervalSeconds/60));return`Polls GitHub every ${t} minute${t===1?``:`s`} for ${e.events.join(`, `)||`no events`}. ${qE(e.filters.includeExisting)}`}function YE({draft:e,onChange:t,disabledReason:n}){let r=n=>{t({events:e.events.includes(n)?e.events.filter(e=>e!==n):[...e.events,n]})},i=n=>t({filters:{...e.filters,...n}}),a=(n,r)=>{let i=KE(r),{[n]:a,...o}=e.filters;t({filters:i.length?{...o,[n]:i}:o})},o=UE.some(t=>t.seconds===e.intervalSeconds)?UE:[...UE,{seconds:e.intervalSeconds,label:`${Math.round(e.intervalSeconds/60)} minutes`}].sort((e,t)=>e.seconds-t.seconds);return(0,Q.jsxs)(`div`,{className:`grid gap-4`,children:[n?(0,Q.jsx)(`p`,{className:`text-xs text-pending-strong`,children:`GitHub unavailable · ${n}`}):null,(0,Q.jsx)(`div`,{role:`group`,"aria-label":`GitHub events`,className:`flex flex-wrap gap-2`,children:HE.map(t=>(0,Q.jsx)(VE,{pressed:e.events.includes(t),onClick:()=>r(t),children:t},t))}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(CE,{htmlFor:`automation-interval`,children:`Check every`}),(0,Q.jsxs)(Ff,{value:String(e.intervalSeconds),onValueChange:e=>t({intervalSeconds:Number(e)}),children:[(0,Q.jsx)(Lf,{id:`automation-interval`,className:`w-full sm:w-48`,"aria-label":`Check every`,children:(0,Q.jsx)(If,{})}),(0,Q.jsx)(Rf,{children:o.map(e=>(0,Q.jsx)(zf,{value:String(e.seconds),children:e.label},e.seconds))})]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,Q.jsx)(oa,{"aria-label":`Include existing items`,"aria-describedby":`automation-history-hint`,checked:e.filters.includeExisting??!1,onCheckedChange:e=>i({includeExisting:e})}),(0,Q.jsx)(`span`,{children:`Include existing items`})]}),(0,Q.jsx)(`p`,{id:`automation-history-hint`,className:`text-xs text-muted-foreground`,children:qE(e.filters.includeExisting)})]}),(0,Q.jsxs)(fx,{children:[(0,Q.jsxs)(px,{className:`group flex min-h-11 items-center gap-2 text-sm font-medium`,children:[`Filters`,(0,Q.jsx)(So,{"aria-hidden":`true`,className:`size-4 text-soft-foreground transition-transform motion-reduce:transition-none group-data-[state=open]:rotate-180`})]}),(0,Q.jsx)(mx,{children:(0,Q.jsxs)(`div`,{className:`grid gap-4 pt-2 sm:grid-cols-2`,children:[WE.map(t=>(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,Q.jsx)(CE,{htmlFor:`automation-filter-${t.key}`,children:t.label}),(0,Q.jsx)(Hf,{id:`automation-filter-${t.key}`,placeholder:`comma separated`,value:GE(e.filters[t.key]),onChange:e=>a(t.key,e.target.value)}),t.hint?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.hint}):null]},t.key)),(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,Q.jsx)(CE,{htmlFor:`automation-filter-lookback`,children:`Look back (days)`}),(0,Q.jsx)(Hf,{id:`automation-filter-lookback`,type:`number`,min:1,value:e.filters.lookbackDays,onChange:e=>i({lookbackDays:Math.max(1,Number(e.target.value)||1)})})]}),(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,Q.jsx)(CE,{htmlFor:`automation-filter-max`,children:`Max records per check`}),(0,Q.jsx)(Hf,{id:`automation-filter-max`,type:`number`,min:1,value:e.filters.maxRecords,onChange:e=>i({maxRecords:Math.max(1,Number(e.target.value)||1)})})]})]})})]})]})}var XE=[{minutes:void 0,label:`No limit`},{minutes:30,label:`30 minutes`},{minutes:120,label:`2 hours`},{minutes:360,label:`6 hours`},{minutes:1440,label:`1 day`},{minutes:10080,label:`7 days`}],ZE=`none`,QE=e=>String(e).padStart(2,`0`);function $E(e,t=Date.now()){let n=pT(t,e)??pT(t,`UTC`),r=new Date(Date.UTC(n.year,n.month-1,n.day+1));return`${r.getUTCFullYear()}-${QE(r.getUTCMonth()+1)}-${QE(r.getUTCDate())}T09:00`}function eD(){let e=typeof Intl.supportedValuesOf==`function`?Intl.supportedValuesOf(`timeZone`):[];return e.includes(`UTC`)?e:[`UTC`,...e]}function tD({value:e,stored:t,onChange:n}){let r=t=>n({...e,...t}),i=e.at?jT(e.at):null,a=e.at?.slice(0,10)??``,o=i?.hour??9,s=i?.minute??0,c=(e,t,n)=>r({at:`${e}T${QE(t)}:${QE(n)}`}),l=(0,Z.useRef)(null),u=(0,Z.useId)(),d=AT(e),f=!(t?.type===`once`&&t.at===e.at&&t.timeZone===e.timeZone)&&d!==null&&d<=Date.now();(0,Z.useEffect)(()=>{l.current?.setCustomValidity(f?ET:``)},[f]);let p=XT(e);return(0,Q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-4 gap-y-3`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(CE,{htmlFor:`automation-once-date`,children:`Date`}),(0,Q.jsx)(Hf,{ref:l,id:`automation-once-date`,type:`date`,className:`w-44 max-w-full`,value:a,"aria-invalid":f||void 0,"aria-describedby":f?u:void 0,onChange:e=>{/^\d{4}-\d{2}-\d{2}$/.test(e.target.value)&&c(e.target.value,o,s)},required:!0})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,Q.jsx)(sD,{label:`Hour`,value:o,max:23,onCommit:e=>c(a,e,s)}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,Q.jsx)(sD,{label:`Minute`,value:s,max:59,onCommit:e=>c(a,o,e)})]})]}),f?(0,Q.jsx)(`p`,{id:u,className:`text-xs text-destructive`,children:ET}):null,(0,Q.jsx)(rD,{value:e.timeZone??``,onCommit:e=>r({timeZone:e})}),(0,Q.jsx)(iD,{value:e.latestStartMinutes,onChange:t=>n(nD(e,t))}),p?(0,Q.jsx)(`p`,{className:`text-sm break-words`,children:`Runs once at ${p.time} on ${p.date} (${e.timeZone}). ${p.note?`${p.note} `:``}Cezarion must be running then.`}):null]})}function nD(e,t){let{latestStartMinutes:n,...r}=e;return t===void 0?r:{...r,latestStartMinutes:t}}function rD({value:e,onCommit:t}){let[n,r]=(0,Z.useState)(e),i=(0,Z.useRef)(null),a=(0,Z.useId)(),o=(0,Z.useId)(),[s]=(0,Z.useState)(eD),c=n!==e||!_T(n),l=DT(n);return(0,Z.useEffect)(()=>{i.current?.setCustomValidity(c?l:``)},[c,l]),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(CE,{htmlFor:`automation-once-zone`,children:`Time zone`}),(0,Q.jsx)(Hf,{ref:i,id:`automation-once-zone`,list:a,autoComplete:`off`,spellCheck:!1,className:`w-full sm:w-72`,value:n,"aria-invalid":c||void 0,"aria-describedby":c?o:void 0,onChange:e=>{r(e.target.value),_T(e.target.value)&&t(e.target.value)}}),(0,Q.jsx)(`datalist`,{id:a,children:s.map(e=>(0,Q.jsx)(`option`,{value:e},e))}),c?(0,Q.jsx)(`p`,{id:o,className:`text-xs break-words text-destructive`,children:l}):null]})}function iD({value:e,onChange:t}){let n=XE.some(t=>t.minutes===e)||e===void 0?XE:[...XE,{minutes:e,label:`${e} minutes`}];return(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(CE,{htmlFor:`automation-once-latest`,children:`Latest start`}),(0,Q.jsxs)(Ff,{value:e===void 0?ZE:String(e),onValueChange:e=>t(e===ZE?void 0:Number(e)),children:[(0,Q.jsx)(Lf,{id:`automation-once-latest`,className:`w-full sm:w-48`,"aria-label":`Latest start`,children:(0,Q.jsx)(If,{})}),(0,Q.jsx)(Rf,{children:n.map(e=>(0,Q.jsx)(zf,{value:e.minutes===void 0?ZE:String(e.minutes),children:e.label},e.label))})]}),(0,Q.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`If Cezarion was not running at the time, it still starts the task this long afterwards; later, the schedule is marked missed.`})]})}var aD=[{type:`daily`,label:`Every day`},{type:`weekdays`,label:`Weekdays`},{type:`weekly`,label:`Weekly`},{type:`hours`,label:`Every N hours`},{type:`once`,label:`Once`}],oD=e=>String(e).padStart(2,`0`);function sD({label:e,value:t,max:n,onCommit:r}){let[i,a]=(0,Z.useState)(oD(t)),o=(0,Z.useRef)(null),s=!(/^\d{1,2}$/.test(i)&&Number(i)===t),c=`${e} must be 00–${oD(n)}.`,l=(0,Z.useId)();return(0,Z.useEffect)(()=>{o.current?.setCustomValidity(s?c:``)},[s,c]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Hf,{ref:o,"aria-label":e,"aria-invalid":s||void 0,"aria-describedby":s?l:void 0,inputMode:`numeric`,maxLength:2,className:`w-20 text-center tabular-nums`,value:i,onChange:e=>{a(e.target.value),/^\d{1,2}$/.test(e.target.value)&&Number(e.target.value)<=n&&r(Number(e.target.value))},onBlur:()=>a(oD(t))}),s?(0,Q.jsx)(`p`,{id:l,className:`order-last basis-full text-xs text-destructive`,children:c}):null]})}function cD({value:e,stored:t,onChange:n,timeZone:r}){let i=t=>n({...e,...t}),a=t=>i(t===`once`?{type:t,at:e.at??$E(r),timeZone:e.timeZone??r}:{type:t});return(0,Q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Q.jsx)(`div`,{role:`group`,"aria-label":`Repeat`,className:`flex flex-wrap gap-2`,children:aD.map(t=>(0,Q.jsx)(VE,{pressed:e.type===t.type,onClick:()=>a(t.type),children:t.label},t.type))}),e.type===`once`?(0,Q.jsx)(tD,{value:e,stored:t,onChange:n}):null,e.type===`weekly`?(0,Q.jsx)(`div`,{role:`group`,"aria-label":`Day of the week`,className:`flex flex-wrap gap-2`,children:bT.map((t,n)=>(0,Q.jsx)(VE,{pressed:e.day===n+1,onClick:()=>i({day:n+1}),children:t},t))}):null,e.type===`once`?null:e.type===`hours`?(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(CE,{htmlFor:`automation-every`,children:`Run every`}),(0,Q.jsxs)(Ff,{value:String(e.every),onValueChange:e=>i({every:Number(e)}),children:[(0,Q.jsx)(Lf,{id:`automation-every`,className:`w-full sm:w-48`,"aria-label":`Run every`,children:(0,Q.jsx)(If,{})}),(0,Q.jsx)(Rf,{children:yT.map(e=>(0,Q.jsx)(zf,{value:String(e),children:e===1?`hour`:`${e} hours`},e))})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Counted from midnight, so “every 6 hours” runs at 00:00, 06:00, 12:00 and 18:00.`})]}):(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,Q.jsx)(sD,{label:`Hour`,value:e.hour,max:23,onCommit:e=>i({hour:e})}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,Q.jsx)(sD,{label:`Minute`,value:e.minute,max:59,onCommit:e=>i({minute:e})}),(0,Q.jsx)(`span`,{className:`text-sm break-all text-muted-foreground`,children:r})]}),e.type===`once`?null:(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Cron: `,(0,Q.jsx)(`code`,{className:`font-mono text-foreground`,children:RT(e)})]})]})}var lD=40*864e5,uD=5;function dD({schedule:e,timeZone:t,now:n=Date.now()}){if(e.type===`once`)return(0,Q.jsx)(fD,{schedule:e,now:n});let r=BT(e,n+1,n+lD,t,uD);return(0,Q.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,className:`rounded-xl border bg-card p-4`,children:[(0,Q.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-3 text-[15px] font-medium`,children:`Next 5 runs`}),r.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No runs in the next 40 days.`}):(0,Q.jsx)(`ol`,{"aria-label":`Next 5 runs`,className:`grid gap-1.5 text-sm`,children:r.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-baseline justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`font-medium tabular-nums`,children:WT(new Date(e).toISOString(),t)}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:VT(n,e)})]},e))}),(0,Q.jsxs)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:[`Times are in `,t,`, the zone this cezar runs in.`]})]})}function fD({schedule:e,now:t}){let n=AT(e),r=XT(e);return(0,Q.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,className:`rounded-xl border bg-card p-4`,children:[(0,Q.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-3 text-[15px] font-medium`,children:`Runs once`}),n===null||!r?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Pick a date, a time and a time zone.`}):(0,Q.jsxs)(`p`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium tabular-nums`,children:`${r.date} ${r.time}`}),n>t?(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:VT(t,n)}):null]}),r?.note?(0,Q.jsx)(`p`,{className:`mt-2 text-sm break-words`,children:r.note}):null,n!==null&&n<=t?(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-destructive`,children:`The due time has passed.`}):null,(0,Q.jsx)(`p`,{className:`mt-3 text-xs break-words text-muted-foreground`,children:`Times are in ${e.timeZone??`UTC`}. Cezarion must be running then; afterwards the schedule is archived with its task.`})]})}var pD={schedule:`On a schedule`,github:`When GitHub changes`};function mD(e){return/time zone|due time/i.test(e)?`when`:/placeholder|prompt|workflow|runner|model|task|autonomous/i.test(e)?`run`:/\bname\b/i.test(e)?`name`:/schedule|github|event|filter|label|interval|remote|forge|lookback|records?|hour|minute|poll|kind|archived/i.test(e)?`when`:`form`}function hD({title:e,failure:t,section:n,children:r}){return(0,Q.jsxs)(`fieldset`,{className:`grid min-w-0 gap-4 rounded-xl border p-5 max-md:p-4!`,children:[(0,Q.jsx)(`legend`,{className:`px-0`,children:e}),r,t?.section===n&&!t.conflict?(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:t.message}):null]})}function gD({automation:e,forge:t,timeZone:n,onSaved:r,onReload:i}){let[a,o]=(0,Z.useState)(()=>TE(e)),[s,c]=(0,Z.useState)(e?.revision),[l,u]=(0,Z.useState)(),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(``),y=e=>o(t=>({...t,...e})),b=async t=>{if(t.preventDefault(),d)return;let n=t.currentTarget;if(n instanceof HTMLFormElement&&!n.checkValidity()){n.reportValidity();return}f(!0),u(void 0);let i=`save`;try{if(e&&s!==void 0){let{automation:t}=await be(e.id,AE({...a,enabled:e.enabled},s));c(t.revision),a.enabled!==e.enabled&&(i=`enable`,await Te(e.id,a.enabled))}else await Ue(kE(a));r()}catch(t){let n=t instanceof Error?t.message:String(t);i===`save`&&e&&t instanceof Ze&&t.status===409&&/revision conflict/i.test(n)?u({section:`form`,message:`Edited elsewhere — reload to see the latest version`,conflict:!0}):u({section:i===`enable`?`enable`:mD(n),message:n})}finally{f(!1)}},x=async()=>{if(!(!e||h)){g(!0),v(``);try{await ye(e.id),r()}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(!1)}}},S=e?`Save changes`:a.enabled?`Save and enable`:`Save paused`,C=a.kind===`schedule`;return(0,Q.jsx)(dE,{title:e?`Edit automation`:`New automation`,subtitle:`Define when it runs and the ordinary task it launches.`,children:(0,Q.jsxs)(`form`,{className:`automation-editor grid min-w-0 gap-5 md:grid-cols-[minmax(0,1fr)_320px] md:items-start`,onSubmit:b,children:[(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-5`,children:[a.retiredVariants?(0,Q.jsxs)(`section`,{role:`alert`,className:`flex flex-col items-start gap-3 rounded-xl border border-border bg-card p-4`,children:[(0,Q.jsx)(`p`,{children:`Parallel variants are removed. This automation requests multiple candidates and cannot launch. Use one task, or ask that task to compare approaches with owned workers.`}),(0,Q.jsx)(O,{type:`button`,variant:`outline`,className:`min-h-11`,onClick:()=>y({retiredVariants:!1}),children:`Use one task`})]}):null,(0,Q.jsx)(hD,{title:`Name`,section:`name`,failure:l,children:(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(CE,{htmlFor:`automation-name`,children:`Name`}),(0,Q.jsx)(Hf,{id:`automation-name`,value:a.name,onChange:e=>y({name:e.target.value}),required:!0})]})}),(0,Q.jsxs)(hD,{title:`When`,section:`when`,failure:l,children:[e?(0,Q.jsxs)(`p`,{className:`text-sm`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Trigger · `}),pD[a.kind]]}):(0,Q.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,Q.jsx)(uw,{slot:`automation-kind`,label:`Trigger`,size:`touch`,value:a.kind,onChange:e=>y({kind:e}),options:[{value:`schedule`,label:pD.schedule},{value:`github`,label:pD.github,disabled:!t.available,...t.available?{}:{title:t.reason??`GitHub is unavailable`}}]}),t.available?null:(0,Q.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`GitHub unavailable · ${t.reason??`no GitHub access`}`})]}),C?(0,Q.jsx)(cD,{value:a.schedule,stored:e?.schedule,onChange:e=>y({schedule:e}),timeZone:n}):(0,Q.jsx)(YE,{draft:a,onChange:y,...t.available?{}:{disabledReason:t.reason??`no GitHub access`}})]}),(0,Q.jsxs)(hD,{title:`What to run`,section:`run`,failure:l,children:[(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(CE,{htmlFor:`automation-prompt`,children:`Prompt`}),(0,Q.jsx)(Fo,{id:`automation-prompt`,value:a.prompt,onChange:e=>y({prompt:e.target.value}),rows:4,required:!0}),(0,Q.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:C?(0,Q.jsxs)(Q.Fragment,{children:[`Available: `,`{{date}}`,` `,`{{time}}`,` `,`{{project}}`,` `,`{{automation}}`,`. A run-context block is appended automatically.`]}):(0,Q.jsxs)(Q.Fragment,{children:[`Available: `,`{{github.number}}`,` `,`{{github.title}}`,` `,`{{github.url}}`,` `,`{{github.labels}}`,`. GitHub content is appended as untrusted context.`]})})]}),(0,Q.jsx)(_D,{draft:a,patch:y}),(0,Q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,Q.jsx)(oa,{"aria-label":`Autonomous`,checked:a.autonomous,onCheckedChange:e=>y({autonomous:e})}),(0,Q.jsxs)(`span`,{children:[`Autonomous `,(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`· runs without waiting for answers`})]})]}),(0,Q.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`Each run is an ordinary task in its own worktree, queued behind the parallel cap.`}),(0,Q.jsx)(dg,{archiveWhenDone:a.archiveWhenDone,autoMergePr:a.autoMergePr,onChange:y,disabled:d}),e?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`These settings apply to future tasks. Existing tasks keep their settings.`}):null]}),(0,Q.jsxs)(hD,{title:`Enable`,section:`enable`,failure:l,children:[(0,Q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,Q.jsx)(oa,{"aria-label":e?`Enabled`:`Enable after saving`,checked:a.enabled,onCheckedChange:e=>y({enabled:e})}),(0,Q.jsx)(`span`,{children:e?`Enabled`:`Enable after saving`})]}),(0,Q.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:a.kind===`schedule`&&a.schedule.type===`once`?`It runs once at the time set above, then moves to Archived with its task.`:C?`The first run is the next occurrence shown beside the schedule.`:qE(a.filters.includeExisting)})]}),l?.section===`form`?(0,Q.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-3 text-sm text-destructive`,children:[(0,Q.jsx)(`span`,{className:`break-words`,children:l.message}),l.conflict&&i?(0,Q.jsx)(O,{type:`button`,variant:`outline`,onClick:i,children:`Reload`}):null]}):null,(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(O,{type:`submit`,disabled:d,children:d?`Saving…`:S}),(0,Q.jsx)(O,{type:`button`,variant:`outline`,asChild:!0,children:(0,Q.jsx)(Y,{to:`/automations`,children:`Cancel`})})]}),e?(0,Q.jsxs)(`div`,{className:`grid justify-items-start gap-2 border-t pt-4`,children:[p?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? It will stop running and cannot be restored.`}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(O,{type:`button`,variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:h,onClick:()=>void x(),children:`Delete automation`}),(0,Q.jsx)(O,{type:`button`,variant:`outline`,disabled:h,onClick:()=>{m(!1),v(``)},children:`Keep`})]})]}):(0,Q.jsx)(O,{type:`button`,variant:`outline`,"data-action":`automation-delete`,onClick:()=>m(!0),children:`Delete`}),_?(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:_}):null]}):null]}),(0,Q.jsxs)(`aside`,{className:`min-w-0 md:sticky md:top-4`,children:[C?(0,Q.jsx)(dD,{schedule:a.schedule,timeZone:n}):(0,Q.jsxs)(`section`,{className:`rounded-xl border bg-card p-4`,children:[(0,Q.jsx)(`h2`,{className:`mb-2 text-[15px] font-medium`,children:`How it polls`}),(0,Q.jsx)(`p`,{className:`text-sm break-words text-muted-foreground`,children:JE(a)})]}),a.retiredVariants?null:(0,Q.jsx)(BE,{draft:a})]})]})})}function _D({draft:e,patch:t}){let n=bn(),r=Kn(),i=Zn(),a=e.runner??i.data?.defaultRunner??`claude`,o=Cn(a),s=[...new Set([...(n.data?.workflows??[]).map(e=>e.name),...e.workflow?[e.workflow]:[]])],c=[...new Set([...jt(r.data),...e.runner?[e.runner]:[]])],l=Gs(a,o.data,[e.model]),u=l.find(t=>t.id===(e.model??``))?.label??e.model??`auto`,d=e=>(0,Q.jsx)(e,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`});return(0,Q.jsx)(Hs,{children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(Ys,{slot:`automation-workflow-pill`,icon:d(no),fieldLabel:!0,ariaLabel:`Workflow`,label:e.workflow??`inline steps`,value:e.workflow??``,disabled:e.workflow===void 0,disabledHint:`This automation carries its own steps.`,options:s.map(e=>({value:e,label:e})),onPick:e=>t({workflow:e})}),(0,Q.jsx)(Ys,{slot:`automation-runner-pill`,icon:d(mo),fieldLabel:!0,ariaLabel:`Runner`,label:e.runner??`default`,value:e.runner??``,options:[{value:``,label:`default`,desc:`The project’s default runner`},...c.map(e=>({value:e,label:Ws.find(t=>t.id===e)?.label??e}))],onPick:e=>{t({runner:e||void 0,model:void 0})}}),(0,Q.jsx)(Ys,{slot:`automation-model-pill`,icon:d(Xa),fieldLabel:!0,ariaLabel:`Model`,label:u,value:e.model??``,options:l.map(e=>({value:e.id,label:e.label,desc:e.desc})),onPick:e=>t({model:e||void 0})})]})})}function vD({data:e,error:t,refresh:n,archived:r=!1,onArchivedChange:i}){let[a,o]=(0,Z.useState)({}),[s,c]=(0,Z.useState)({}),l=(e,t)=>o(n=>{let{[e]:r,...i}=n;return t?{...i,[e]:t}:i}),u=async(e,t)=>{c(t=>({...t,[e]:!0}));try{await t()}catch(t){l(e,{text:t instanceof Error?t.message:String(t),tone:`error`})}finally{c(t=>({...t,[e]:!1}))}},d=e=>u(e.id,async()=>{l(e.id,{text:`Starting…`,tone:`info`});let{runId:t}=await ze(e.id);l(e.id,{text:`Started task`,tone:`info`,runId:t}),n()}),f=e=>u(e.id,async()=>{l(e.id,void 0),await Te(e.id,!e.enabled),await n()}),p=e=>u(e.id,async()=>{l(e.id,void 0),await Ke(e.id),await n()}),m=e=>u(e.id,async()=>{l(e.id,{text:`Checking…`,tone:`info`});let{checkId:t}=await nt(e.id,`preview`);for(let r=0;r<60;r+=1){let r=await ue(t);if(r.status===`complete`){l(e.id,{text:`${r.matches??0} filter match${r.matches===1?``:`es`} found; no tasks launched. Counts can include closed items and previously processed events.`,tone:`info`}),n();return}if(r.status===`error`)throw Error(r.error??`Preview failed`);await new Promise(e=>setTimeout(e,500))}throw Error(`Preview is still running`)});return(0,Q.jsx)(dE,{title:`Automations`,subtitle:`Schedules and GitHub checks run while Cezarion is open.`,action:(0,Q.jsx)(O,{asChild:!0,children:(0,Q.jsx)(Y,{to:`/automations/new`,children:`New automation`})}),children:t&&!e?(0,Q.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,Q.jsx)(fE,{text:t}),(0,Q.jsx)(O,{variant:`outline`,onClick:()=>void n(),children:`Retry`})]}):e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(yD,{data:e}),i?(0,Q.jsx)(`div`,{className:`mb-4 flex flex-wrap gap-2`,children:(0,Q.jsx)(VE,{pressed:r,onClick:()=>i(!r),children:`Archived`})}):null,r&&e.automations.length===0?(0,Q.jsx)(fE,{text:`No archived one-time schedules.`}):e.automations.length===0?(0,Q.jsx)(X,{icon:(0,Q.jsx)(io,{}),tone:`neutral`,title:`No automations yet`,subtitle:`Create one paused, preview it, then enable it.`,heading:`h2`,actions:(0,Q.jsx)(O,{asChild:!0,children:(0,Q.jsx)(Y,{to:`/automations/new`,children:`New automation`})})}):(0,Q.jsx)(`ul`,{className:`grid gap-3`,"aria-label":`Automations`,children:e.automations.map(t=>(0,Q.jsx)(SD,{automation:t,timeZone:e.timeZone,note:a[t.id],busy:s[t.id]===!0,onRun:()=>void d(t),onToggle:()=>void f(t),onPreview:()=>void m(t),onCancel:()=>void p(t)},t.id))})]}):(0,Q.jsx)(fE,{text:`Loading automations…`})})}function yD({data:e}){return(0,Q.jsx)(`p`,{"data-slot":`automation-scheduler`,className:k(`mb-4 text-xs break-words`,e.scheduler.state===`scheduled`?`text-success`:`text-muted-foreground`),children:`Scheduler ${e.scheduler.state===`scheduled`?`running`:`idle`} · GitHub ${e.available?`available`:`unavailable`}${e.reason?` · ${e.reason}`:``} · ${e.timeZone}`})}function bD(e){return e.kind===`schedule`&&e.schedule?FT(e.schedule):`on ${(e.events??[]).join(`, `)} · every ${Math.round((e.intervalSeconds??300)/60)} min`}var xD={waiting:{label:`Waiting`,dot:`success`},paused:{label:`Paused`,dot:`neutral`},failed:{label:`Failed`,dot:`danger`},missed:{label:`Missed`,dot:`pending`},archived:{label:`Archived`,dot:`neutral`}};function SD({automation:e,timeZone:t,note:n,busy:r,onRun:i,onToggle:a,onPreview:o,onCancel:s}){let[c,l]=(0,Z.useState)(!1),u=(0,Z.useRef)(null),d=(0,Z.useRef)(null),f=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let e=f.current===`keep`?d.current:f.current===`cancel`?u.current:null;f.current=null,e?.focus()},[c]);let p=()=>{f.current=`keep`,l(!0)},m=()=>{f.current=`cancel`,l(!1)},h=e.kind===`schedule`,g=e.schedule?.type===`once`,_=g?xD[e.onceStatus??(e.enabled?`waiting`:`paused`)]:void 0,v=e.archived,y=h?Ka:La,b=e.enabled&&h?e.nextRunAt:void 0;return(0,Q.jsxs)(`li`,{"data-slot":`automation-card`,"data-kind":e.kind,className:`min-w-0 rounded-xl border bg-card p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`h2`,{className:`flex items-center gap-2 font-semibold break-words`,children:[(0,Q.jsx)(y,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),e.name]}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[13px] break-words text-muted-foreground`,children:bD(e)})]}),_?(0,Q.jsx)($x,{dot:_.dot,children:_.label}):(0,Q.jsx)($x,{dot:e.enabled?`success`:`neutral`,children:e.enabled?`Enabled`:`Paused`})]}),v?(0,Q.jsxs)(`p`,{className:`mt-3 text-sm break-words`,children:[v.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`,v.runId?(0,Q.jsxs)(Q.Fragment,{children:[` · `,(0,Q.jsx)(Y,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${v.runId}`,children:`Open task`})]}):null]}):null,v?(0,Q.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:(0,Q.jsx)(O,{variant:`outline`,asChild:!0,children:(0,Q.jsx)(Y,{to:`/automations/${e.id}`,children:`Details`})})}):null,v?null:(0,Q.jsx)(`p`,{className:`mt-3 text-sm`,children:!h&&e.enabled?(0,Q.jsx)(`span`,{children:`continuous`}):b?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{children:`Next run: ${WT(b,t)}`}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:` · ${VT(Date.now(),Date.parse(b))}`})]}):(0,Q.jsx)(`span`,{children:`Next run: —`})}),v?null:(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,Q.jsx)(O,{variant:`outline`,asChild:!0,children:(0,Q.jsx)(Y,{to:`/automations/${e.id}`,children:`Edit`})}),(0,Q.jsx)(O,{variant:`outline`,asChild:!0,children:(0,Q.jsx)(Y,{to:`/automations/${e.id}/log`,children:`Execution log`})}),(0,Q.jsx)(O,{variant:`outline`,"data-action":`automation-toggle`,disabled:r,onClick:a,children:e.enabled?`Pause`:`Enable`}),h?(0,Q.jsx)(O,{variant:`outline`,"data-action":`automation-run`,disabled:r,onClick:i,children:`Run now`}):(0,Q.jsx)(O,{variant:`outline`,"data-action":`automation-preview`,disabled:r,onClick:o,children:`Test filter`}),g&&!c?(0,Q.jsx)(O,{variant:`outline`,ref:u,"data-action":`automation-cancel`,disabled:r,onClick:p,children:`Cancel`}):null]}),g&&!v&&c?(0,Q.jsxs)(`div`,{className:`mt-3 grid justify-items-start gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-sm break-words`,children:`Cancel “${e.name}”? It will never run, and it moves to Archived.`}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(O,{variant:`danger-ghost`,"data-action":`automation-cancel-confirm`,disabled:r,onClick:()=>{l(!1),s()},children:`Cancel schedule`}),(0,Q.jsx)(O,{ref:d,variant:`outline`,disabled:r,onClick:m,children:`Keep`})]})]}):null,n?(0,Q.jsxs)(`p`,{role:n.tone===`error`?`alert`:`status`,className:k(`mt-3 text-sm break-words`,n.tone===`error`?`text-destructive`:`text-muted-foreground`),children:[n.text,n.runId?(0,Q.jsxs)(Q.Fragment,{children:[` · `,(0,Q.jsx)(Y,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${n.runId}`,children:`Open task`})]}):null]}):null,(0,Q.jsx)(xE,{automationId:e.id,automationName:e.name,timeZone:t})]})}function CD(e){let t=_s(),n=mn(),r=n.data!==void 0,i=r&&n.data.capabilities?.automations!==!0,[a,o]=(0,Z.useState)(),[s,c]=(0,Z.useState)(``),l=(0,Z.useCallback)(t=>ft({signal:t,...e?{archived:e}:{}}).then(e=>{t?.aborted||(o(e),c(``))}).catch(e=>{t?.aborted||c(String(e))}),[e]);return(0,Z.useEffect)(()=>{r&&!i&&l()},[r,i,l]),(0,Z.useEffect)(()=>R(async e=>{r&&!i&&await l(e)}),[r,i,l]),(0,Z.useEffect)(()=>$c((e,n)=>{if(e!==`automation-change`)return;let r=n;typeof r.project==`string`&&(t===null||r.project===t)&&l()}),[t,l]),{data:a,error:s,refresh:l}}function wD({mode:e=`list`}){let{automationId:t}=s(),n=ds(),[r,i]=(0,Z.useState)(!1),{data:a,error:o,refresh:c}=CD(e===`list`?r?`only`:void 0:`include`),[l,u]=(0,Z.useState)(0),d=mn(),f=d.data!==void 0,p=f&&d.data.capabilities?.automations!==!0;if(!f)return(0,Q.jsx)(`div`,{"data-route":`automations`,className:`task-flow-page flex min-h-full flex-col`,children:(0,Q.jsx)(fE,{text:`Loading automations…`})});if(p)return(0,Q.jsx)(`div`,{"data-route":`automations`,className:`task-flow-page flex min-h-full flex-col`,children:(0,Q.jsx)(X,{icon:(0,Q.jsx)(io,{}),tone:`neutral`,title:`Automations are off`,subtitle:`This server does not run schedules, poll GitHub or launch tasks from them. Set CEZ_AUTOMATIONS=1 and restart cezar to turn automations on.`,heading:`h2`})});let m=()=>{n(`/automations`),c()},h=a?.automations.find(e=>e.id===t);if(e===`list`)return(0,Q.jsx)(vD,{data:a,error:o,refresh:c,archived:r,onArchivedChange:i});if(!a)return o?(0,Q.jsx)(dE,{title:`Automations`,subtitle:`Could not load automations.`,children:(0,Q.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,Q.jsx)(fE,{text:o}),(0,Q.jsx)(O,{variant:`outline`,onClick:()=>void c(),children:`Retry`})]})}):(0,Q.jsx)(`div`,{"data-route":`automations`,className:`task-flow-page flex min-h-full flex-col`,children:(0,Q.jsx)(fE,{text:`Loading automations…`})});let g={available:a.available,...a.reason?{reason:a.reason}:{}};return e===`new`?(0,Q.jsx)(gD,{forge:g,timeZone:a.timeZone,onSaved:m}):e===`edit`?h?h.archived?(0,Q.jsx)(SE,{automation:h,timeZone:a.timeZone,onDeleted:m}):(0,Q.jsx)(gD,{automation:h,forge:g,timeZone:a.timeZone,onSaved:m,onReload:()=>void c().then(()=>u(e=>e+1))},`${h.id}:${l}`):(0,Q.jsx)(dE,{title:`Automation not found`,subtitle:`This automation may have been removed.`,children:(0,Q.jsx)(O,{asChild:!0,variant:`outline`,children:(0,Q.jsx)(Y,{to:`/automations`,children:`Back to automations`})})}):t?(0,Q.jsx)(bE,{automationId:t,automationName:h?.name,timeZone:a.timeZone,readOnly:!!h?.archived}):(0,Q.jsx)(fE,{text:`Automation not found.`})}function TD(e,t){let[n,r]=(0,Z.useState)(null),i=(0,Z.useMemo)(()=>`${e}${Math.random().toString(36).slice(2)}-${Date.now().toString(36)}`,[]),a=(0,Z.useRef)(i);return a.current=i,(0,Z.useEffect)(()=>$c((e,t)=>{if(e!==`checkout-progress`)return;let n=t;n?.checkoutId===a.current&&(n.phase===`cloning`&&n.line?r(n.line):n.phase!==`cloning`&&r(null))}),[]),(0,Z.useEffect)(()=>R(async e=>{if(!t)return;let n=await me(i,{signal:e}).catch(()=>null);if(!n)return;let{progress:o}=n;e.aborted||o?.checkoutId!==a.current||r(o?.phase===`cloning`?o.line??null:null)}),[t,i]),{checkoutId:i,progress:n,setProgress:r}}function ED(e){return e instanceof Error?e.message.match(/https:\/\/github\.com\/orgs\/[A-Za-z0-9._-]+\/sso\?authorization_request=[A-Za-z0-9._~-]+(?![^\s'"<>])/)?.[0]??null:null}function DD({open:e,onOpenChange:t}){let[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(!1),l=It(),u=lr(),{mutate:d,isPending:f}=u,p=j(),m=ED(u.error),{checkoutId:h,progress:g,setProgress:_}=TD(`co-`,f),v=(0,Z.useMemo)(()=>{let e=n.trim().replace(/\/+$/,``).replace(/\.git$/,``).split(`/`).pop()??``;return e.includes(`:`)?e.split(`:`).pop()??``:e},[n]),y=i.trim()===``?v:i.trim(),b=l.data?.projectsDir??``,x=y===``?``:`${b.replace(/\/+$/,``)}/${y}`,S=(0,Z.useCallback)(()=>{n.trim()===``||f||(c.current=!1,s(!1),_(null),d({url:n.trim(),checkoutId:h,...i.trim()===``?{}:{name:i.trim()}},{onSuccess:({project:e})=>{t(!1),p(`/p/${encodeURIComponent(e.id)}/`)}}))},[d,f,h,i,p,t,n]);return(0,Z.useEffect)(()=>{if(!o)return;let e=()=>{c.current&&(c.current=!1,s(!1),S())},t=()=>{document.visibilityState===`visible`&&e()};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,t)}},[o,S]),(0,Q.jsx)(jo,{open:e,onOpenChange:e=>u.isPending?void 0:t(e),children:(0,Q.jsxs)(Ao,{"data-slot":`clone-project-dialog`,className:`min-w-0 max-h-[calc(100dvh-2rem)] overflow-x-hidden overflow-y-auto sm:max-w-lg`,children:[(0,Q.jsxs)(Po,{children:[(0,Q.jsx)(ko,{children:`Clone from GitHub`}),(0,Q.jsxs)(Oo,{children:[`cezar clones with `,(0,Q.jsx)(`code`,{children:`gh`}),` into your checkout root and adds the result as a project.`]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Q.jsx)(CE,{htmlFor:`clone-url`,children:`Repository`}),(0,Q.jsx)(Hf,{id:`clone-url`,"data-slot":`clone-url`,autoFocus:!0,placeholder:`owner/repo or https://github.com/owner/repo`,value:n,disabled:u.isPending,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&S()}})]}),(0,Q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Q.jsx)(CE,{htmlFor:`clone-name`,children:`Folder name`}),(0,Q.jsx)(Hf,{id:`clone-name`,"data-slot":`clone-name`,placeholder:v===``?`repo`:v,value:i,disabled:u.isPending,onChange:e=>a(e.target.value)}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,Q.jsx)(`p`,{"data-slot":`clone-target`,className:`min-w-0 flex-1 truncate font-mono text-[11px] text-soft-foreground`,title:x,children:x}),u.isPending?(0,Q.jsx)(O,{"data-slot":`clone-root-settings`,variant:`ghost`,size:`icon-sm`,className:`size-7`,"aria-label":`Edit checkout root`,title:`Edit checkout root`,disabled:!0,children:(0,Q.jsx)(eo,{className:`size-3.5`,"aria-hidden":`true`})}):(0,Q.jsx)(O,{asChild:!0,variant:`ghost`,size:`icon-sm`,className:`size-7`,children:(0,Q.jsx)(T,{to:`/settings/global/projects`,"data-slot":`clone-root-settings`,"aria-label":`Edit checkout root`,title:`Edit checkout root`,children:(0,Q.jsx)(eo,{className:`size-3.5`,"aria-hidden":`true`})})})]})]}),u.isPending?(0,Q.jsx)(`p`,{"data-slot":`clone-progress`,className:`truncate font-mono text-[11px] text-muted-foreground`,children:g??`Starting the clone…`}):null,u.isError?(0,Q.jsx)(`div`,{"data-slot":`clone-error`,className:`grid min-w-0 gap-1.5 text-[13px] text-danger`,children:m?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{children:`GitHub requires SAML authorization for this organization.`}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`a`,{"data-slot":`clone-sso-link`,className:`inline-flex min-h-11 items-center font-medium underline underline-offset-2`,href:m,target:`_blank`,rel:`noreferrer`,onClick:()=>{c.current=!0,s(!0)},children:`Authorize this GitHub organization`}),o?` — return here after authorizing, or choose Retry clone.`:` — return to this tab to retry, or choose Retry clone.`]}),(0,Q.jsxs)(`details`,{className:`min-w-0`,children:[(0,Q.jsx)(`summary`,{className:`min-h-11 content-center`,children:`Error details`}),(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap break-all`,children:u.error instanceof Error?u.error.message:null})]})]}):(0,Q.jsx)(`p`,{className:`min-w-0 whitespace-pre-wrap break-all`,children:u.error instanceof Error?u.error.message:`could not clone that repository`})}):null,(0,Q.jsxs)(Mo,{children:[(0,Q.jsx)(O,{variant:`outline`,disabled:u.isPending,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsx)(O,{"data-slot":`clone-confirm`,disabled:n.trim()===``||y===``||u.isPending,onClick:S,children:u.isPending?`Cloning…`:u.isError?`Retry clone`:`Clone`})]})]})})}var OD=[{slug:`github/codespaces-nextjs`,label:`Next.js`,description:`Minimal Next.js app (GitHub)`},{slug:`vercel/chatbot`,label:`Next.js AI chatbot`,description:`Full-featured AI chat app (Vercel)`},{slug:`vercel/nextjs-postgres-nextauth-tailwindcss-template`,label:`Next.js admin dashboard`,description:`Postgres, Auth.js and Tailwind (Vercel)`},{slug:`github/codespaces-react`,label:`React + Vite`,description:`React single-page app (GitHub)`},{slug:`antfu-collective/vitesse`,label:`Vue + Vite`,description:`Opinionated Vue starter (Vitesse)`},{slug:`nuxt-ui-templates/starter-vue`,label:`Vue + Nuxt UI`,description:`Vue + Vite with Nuxt UI (Nuxt)`},{slug:`mugnavo/cove`,label:`Vite+`,description:`TanStack Start on Vite+ (vp), Better Auth`},{slug:`w3cj/hono-open-api-starter`,label:`Hono`,description:`Type-safe JSON API with OpenAPI docs`},{slug:`github/codespaces-express`,label:`Express`,description:`Node.js web server (GitHub)`},{slug:`andrewmcodes/obsidian-beginner-vault-template`,label:`Obsidian vault`,description:`Your own knowledge base in Markdown`},{slug:`chibat/chrome-extension-typescript-starter`,label:`Chrome extension`,description:`TypeScript extension starter`},{slug:`actions/typescript-action`,label:`GitHub Action`,description:`TypeScript action with tests (GitHub)`},{slug:`microsoft/python-package-template`,label:`Python package`,description:`Packaging, tests and CI (Microsoft)`},{slug:`github/codespaces-flask`,label:`Flask`,description:`Python web app (GitHub)`},{slug:`github/codespaces-django`,label:`Django`,description:`Python web framework (GitHub)`},{slug:`github/codespaces-rails`,label:`Ruby on Rails`,description:`Rails app (GitHub)`},{slug:`github/codespaces-jupyter`,label:`Jupyter notebooks`,description:`Data science and ML (GitHub)`}];function kD(e){let t=e.trim().toLowerCase();return t===``||OD.some(e=>e.slug.toLowerCase()===t)?OD:OD.filter(e=>[e.label,e.slug,e.description].some(e=>e.toLowerCase().includes(t)))}function AD({value:e,onChange:t,disabled:n,id:r}){let i=(0,Z.useId)(),a=kD(e),[o,s]=(0,Z.useState)(-1),c=(0,Z.useRef)(null);(0,Z.useEffect)(()=>s(-1),[e]),(0,Z.useEffect)(()=>{o<0||c.current?.querySelector(`[data-index="${o}"]`)?.scrollIntoView?.({block:`nearest`})},[o]);let l=e=>`${i}-option-${e}`;return(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-1.5`,children:[(0,Q.jsx)(Hf,{id:r,"data-slot":`create-project-template`,role:`combobox`,"aria-expanded":`true`,"aria-controls":i,"aria-autocomplete":`list`,"aria-activedescendant":o>=0?l(o):void 0,autoComplete:`off`,spellCheck:!1,placeholder:`owner/repo or https://github.com/owner/repo`,value:e,disabled:n,onChange:e=>t(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),a.length===0)return;let t=e.key===`ArrowDown`;s(e=>e<0?t?0:a.length-1:(e+(t?1:-1)+a.length)%a.length)}else if(e.key===`Enter`&&o>=0){e.preventDefault(),e.stopPropagation();let n=a[o];n&&t(n.slug)}}}),(0,Q.jsx)(`ul`,{ref:c,id:i,role:`listbox`,"aria-label":`Suggested templates`,"data-slot":`create-project-template-list`,className:`max-h-48 min-h-0 overflow-y-auto overscroll-contain rounded-md border border-border`,children:a.length===0?(0,Q.jsx)(`li`,{className:`px-3 py-2 text-xs text-muted-foreground`,role:`presentation`,children:`No suggestion matches — any GitHub template repository works.`}):a.map((r,i)=>{let a=r.slug.toLowerCase()===e.trim().toLowerCase();return(0,Q.jsxs)(`li`,{id:l(i),role:`option`,"aria-selected":a,"data-index":i,"data-slot":`create-project-template-option`,onMouseDown:e=>e.preventDefault(),onClick:()=>{n||t(r.slug)},className:k(`grid min-h-11 cursor-pointer content-center gap-0.5 px-3 py-1.5 text-start`,`pointer-hover:hover:bg-accent`,i===o&&`bg-accent`,a&&`font-medium`),children:[(0,Q.jsxs)(`span`,{className:`truncate text-[13px]`,children:[r.label,` `,(0,Q.jsx)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:r.slug})]}),(0,Q.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:r.description})]},r.slug)})})]})}function jD({open:e,onOpenChange:t}){let[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(`empty`),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(null),m=It(),h=Rt({enabled:e}),g=Pr(),{mutate:_,isPending:v}=g,y=j(),b=(0,Z.useId)(),x=(0,Z.useRef)(!1),{checkoutId:S,progress:C,setProgress:w}=TD(`np-`,v),T=h.data?.available?h.data.owners:null,E=h.isError?`GitHub is unavailable: ${h.error instanceof Error?h.error.message:`could not ask gh`}`:h.data&&!h.data.available?h.data.reason:null,D=i&&T!==null&&T.length>0,k=o??T?.[0]?.login??null,A=D?c:`empty`,M=n.trim(),N=ve.test(M),P=(m.data?.projectsDir??``).replace(/\/+$/,``),F=N&&!v&&f===null&&(!D||k!==null&&(A===`empty`||u.trim()!==``)),I=(0,Z.useCallback)(()=>{!F||x.current||(x.current=!0,w(null),_({name:M,checkoutId:S,...D&&k?{github:{owner:k,...A===`template`?{template:u.trim()}:{}}}:{}},{onSettled:()=>{x.current=!1},onSuccess:({project:e,warning:n})=>{if(n){p({projectId:e.id,warning:n});return}t(!1),y(`/p/${encodeURIComponent(e.id)}/`)}}))},[F,_,M,S,D,k,A,u,t,y]),L=()=>{f&&(t(!1),y(`/p/${encodeURIComponent(f.projectId)}/`))},ee=`${b}-name-hint`;return(0,Q.jsx)(jo,{open:e,onOpenChange:e=>v?void 0:t(e),children:(0,Q.jsxs)(Ao,{"data-slot":`create-project-dialog`,className:`flex min-w-0 flex-col overflow-y-clip overflow-x-clip sm:max-w-2xl`,children:[(0,Q.jsxs)(Po,{className:`flex-none`,children:[(0,Q.jsx)(ko,{children:`New project`}),(0,Q.jsx)(Oo,{children:`cezar creates a git repository with one empty commit in your checkout root and adds it as a project.`})]}),f?(0,Q.jsxs)(`div`,{"data-slot":`create-project-warning`,role:`status`,className:`flex min-h-0 flex-1 gap-3 overflow-y-auto overscroll-contain rounded-md border border-border bg-muted p-4 text-[13px]`,children:[(0,Q.jsx)(Qa,{"aria-hidden":`true`,className:`mbs-0.5 size-5 shrink-0 text-warning`}),(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,Q.jsx)(`p`,{className:`font-medium`,children:`The project was created, but its GitHub repository is not finished.`}),(0,Q.jsx)(`p`,{className:`min-w-0 whitespace-pre-wrap break-words font-mono text-xs`,children:f.warning})]})]}):(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-wrap gap-6 overflow-y-auto overscroll-contain`,children:[(0,Q.jsxs)(`div`,{className:`grid min-w-[50%] grow-[999] basis-0 content-start gap-5`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Q.jsx)(CE,{htmlFor:`${b}-name`,children:`Name`}),(0,Q.jsx)(Hf,{id:`${b}-name`,"data-slot":`create-project-name`,autoFocus:!0,autoComplete:`off`,spellCheck:!1,placeholder:`my-project`,value:n,disabled:v,"aria-invalid":M!==``&&!N,"aria-describedby":M!==``&&!N?ee:void 0,onChange:e=>r(e.target.value.replace(/\s/g,`-`)),onKeyDown:e=>{e.key===`Enter`&&I()}}),M!==``&&!N?(0,Q.jsx)(`p`,{id:ee,"data-slot":`create-project-name-hint`,className:`text-xs text-danger`,children:`Use letters, digits, “.”, “-” and “_” only, starting with a letter or digit — it names the folder and the repository.`}):null,(0,Q.jsx)(`p`,{"data-slot":`create-project-path`,className:`min-w-0 truncate font-mono text-[11px] text-soft-foreground`,title:`${P}/${M}`,children:M===``?`${P}/…`:`${P}/${M}`})]}),(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(oa,{id:`${b}-github`,"data-slot":`create-project-github`,checked:D,disabled:v||T===null||T.length===0,onCheckedChange:a,className:`mbs-0.5`}),(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-0.5`,children:[(0,Q.jsx)(CE,{htmlFor:`${b}-github`,children:`Also create a private GitHub repository`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Under the account you choose. You can change its visibility on GitHub later.`})]})]}),(0,Q.jsxs)(`fieldset`,{className:`grid gap-2`,disabled:v,children:[(0,Q.jsx)(`legend`,{className:`mbe-2 text-sm font-medium`,children:`Start with`}),(0,Q.jsx)(MD,{slot:`create-project-start-empty`,name:`${b}-start`,checked:A===`empty`,disabled:v,onChange:()=>l(`empty`),title:`Empty repository`,detail:`One empty first commit, no files.`}),(0,Q.jsx)(MD,{slot:`create-project-start-template`,name:`${b}-start`,checked:A===`template`,disabled:v||!D,onChange:()=>l(`template`),title:`From a template`,detail:D?`GitHub generates the repository from a template.`:`Needs the GitHub repository.`})]}),A===`template`?(0,Q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Q.jsx)(CE,{htmlFor:`${b}-template`,children:`Template`}),(0,Q.jsx)(AD,{id:`${b}-template`,value:u,onChange:d,disabled:v})]}):null]}),(0,Q.jsx)(ND,{owners:T,unavailableReason:E,enabled:D&&!v,chosen:k,onChoose:s,groupName:`${b}-owner`})]}),v?(0,Q.jsx)(`p`,{"data-slot":`create-project-progress`,className:`flex-none truncate font-mono text-[11px] text-muted-foreground`,children:C??`Starting…`}):null,g.isError?(0,Q.jsx)(`p`,{"data-slot":`create-project-error`,role:`alert`,className:`flex-none min-w-0 whitespace-pre-wrap break-words text-[13px] text-danger`,children:g.error instanceof Error?g.error.message:`could not create the project`}):null,(0,Q.jsx)(Mo,{className:`flex-none`,children:f?(0,Q.jsx)(O,{"data-slot":`create-project-open`,onClick:L,children:`Go to project`}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(O,{variant:`outline`,disabled:v,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsx)(O,{"data-slot":`create-project-submit`,disabled:!F,onClick:I,children:v?`Creating…`:g.isError?`Try again`:`Create project`})]})})]})})}function MD({slot:e,name:t,checked:n,disabled:r,onChange:i,title:a,detail:o}){return(0,Q.jsxs)(`label`,{className:k(`flex min-h-11 items-start gap-3 rounded-md border border-border p-3`,`has-[:checked]:border-accent-strong has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-ring`,r?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,Q.jsx)(`input`,{type:`radio`,"data-slot":e,name:t,checked:n,disabled:r,onChange:i,className:`mbs-0.5 size-4 accent-[var(--color-accent-strong)]`}),(0,Q.jsxs)(`span`,{className:`grid min-w-0 gap-0.5`,children:[(0,Q.jsx)(`span`,{className:`text-[13px] font-medium`,children:a}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:o})]})]})}function ND({owners:e,unavailableReason:t,enabled:n,chosen:r,onChoose:i,groupName:a}){return(0,Q.jsxs)(`fieldset`,{"data-slot":`create-project-owners`,disabled:!n,className:`grid min-w-0 grow basis-56 content-start gap-2`,children:[(0,Q.jsx)(`legend`,{className:`mbe-2 text-sm font-medium`,children:`Repository owner`}),t===null?e===null?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ba,{className:`h-14 w-full`}),(0,Q.jsx)(ba,{className:`h-14 w-full`})]}):e.map(e=>(0,Q.jsxs)(`label`,{"data-slot":`create-project-owner`,className:k(`flex min-h-11 min-w-0 items-center gap-3 rounded-md border border-border p-2.5`,`has-[:checked]:border-accent-strong has-[:checked]:bg-accent`,`has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-ring`,n?`cursor-pointer pointer-hover:hover:bg-accent`:`cursor-not-allowed opacity-60`),children:[(0,Q.jsx)(`input`,{type:`radio`,name:a,value:e.login,checked:r===e.login,disabled:!n,onChange:()=>i(e.login),className:`sr-only`}),e.avatarUrl?(0,Q.jsx)(`img`,{src:e.avatarUrl,alt:``,className:`size-8 shrink-0 rounded-full object-cover`}):(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-8 shrink-0 place-items-center rounded-full bg-muted text-xs font-medium uppercase`,children:e.login.slice(0,1)}),(0,Q.jsxs)(`span`,{className:`grid min-w-0`,children:[(0,Q.jsx)(`span`,{className:`truncate text-[13px] font-medium`,children:e.login}),(0,Q.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.personal?`Personal account`:e.description??`Organization`})]})]},e.login)):(0,Q.jsxs)(`p`,{"data-slot":`create-project-github-unavailable`,className:`rounded-md border border-border bg-muted p-3 text-xs text-muted-foreground break-words`,children:[t,`. Local projects still work.`]})]})}var PD=e=>e.available?`success`:`danger`,FD=e=>e.available?`Installed`:`Not installed`,ID=e=>e.available?null:e.hint??null,LD=`/settings/agents`,RD=`inline-flex items-center rounded-sm text-xs font-medium text-foreground hover:underline focus-visible:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring max-md:min-h-11 no-hover:min-h-11`;function zD(){let e=mn(),t=It(),n=On(e.data?.repo?.remote),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!1),s=async()=>{if(!(!e.data||a)){o(!0);try{await navigator.clipboard.writeText(JSON.stringify({version:e.data.version,checks:e.data.checks},null,2)),K(`Diagnostics copied`)}catch{K(`Could not copy diagnostics. Please try again.`,{tone:`danger`})}finally{o(!1)}}};return(0,Q.jsxs)(`div`,{"data-route":`workspace-tools`,className:`w-full space-y-[22px] px-9 py-9 max-md:px-[18px] max-md:py-6`,children:[(0,Q.jsx)(`h1`,{className:`text-[28px] font-normal leading-[1.5] max-md:text-[24px]`,children:`Workspace tools`}),e.data?.capabilities.singleProject===!0?null:(0,Q.jsxs)(`section`,{className:`space-y-4 rounded-xl border border-border bg-card p-6 max-md:p-4`,"aria-labelledby":`add-project-heading`,children:[(0,Q.jsx)(`h2`,{id:`add-project-heading`,className:`text-lg font-normal leading-[1.5]`,children:`Add project`}),(0,Q.jsx)(`p`,{className:`text-[13px] leading-[1.5] text-muted-foreground`,children:`Start a new repository, open an existing local folder, or clone a GitHub repository.`}),(0,Q.jsxs)(`dl`,{className:`space-y-4 text-[13px] leading-[1.5] text-muted-foreground`,children:[e.data?.repoRoot?(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-x-3`,children:[(0,Q.jsx)(`dt`,{children:`Local folder`}),(0,Q.jsx)(`dd`,{className:`min-w-0 break-all`,children:e.data.repo?.root??e.data.repoRoot})]}):null,n?(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-x-3`,children:[(0,Q.jsx)(`dt`,{children:`Repository`}),(0,Q.jsx)(`dd`,{className:`min-w-0 break-all`,children:n.replace(/^https:\/\//,``)})]}):null,t.data?.projectsDir?(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-x-3`,children:[(0,Q.jsx)(`dt`,{children:`Checkout folder`}),(0,Q.jsx)(`dd`,{className:`min-w-0 break-all`,children:t.data.projectsDir})]}):null]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,Q.jsx)(O,{variant:`outline`,className:`h-10 rounded-lg px-[15px] text-xs font-normal leading-[18px]`,"data-action":`new-project`,onClick:()=>i(`new`),children:`New project`}),(0,Q.jsx)(O,{variant:`outline`,className:`h-10 rounded-lg px-[15px] text-xs font-normal leading-[18px]`,onClick:()=>i(`local`),children:`Open local folder`}),(0,Q.jsx)(O,{variant:`outline`,className:`h-10 rounded-lg px-[15px] text-xs font-normal leading-[18px]`,onClick:()=>i(`clone`),children:`Clone from GitHub`})]})]}),(0,Q.jsxs)(`section`,{className:`space-y-4 rounded-xl border border-border bg-card p-6 max-md:p-4`,"aria-labelledby":`tools-heading`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`h2`,{id:`tools-heading`,className:`text-lg font-normal leading-[1.5]`,children:`Tools diagnostics`}),(0,Q.jsx)(Y,{to:LD,"data-slot":`tools-settings`,className:RD,children:`Tool settings ›`})]}),(0,Q.jsx)(`p`,{className:`text-[13px] leading-[1.5] text-muted-foreground`,children:`Check the tools available to this local workspace.`}),e.isError?(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:`Could not refresh tool diagnostics. Recheck to retry.`}):null,!e.data&&!e.isError?(0,Q.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Checking installed tools…`}):null,e.data?(0,Q.jsx)(`dl`,{className:`space-y-4 text-[13px] leading-[1.5] text-muted-foreground`,children:e.data.checks.map(e=>{let t=ID(e);return(0,Q.jsxs)(`div`,{"data-slot":`tool-row`,"data-tool":e.name,"data-available":e.available,className:`flex flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,Q.jsxs)(`dt`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(J_,{tone:PD(e)}),(0,Q.jsx)(`span`,{className:`font-mono text-[13px] font-medium text-foreground`,children:e.name})]}),(0,Q.jsxs)(`dd`,{className:`flex min-w-0 flex-1 items-center gap-x-3 text-muted-foreground`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 break-words`,children:[FD(e),e.version?` · ${e.version}`:``]}),e.available?null:(0,Q.jsx)(Y,{to:LD,"data-slot":`tool-setup`,className:`${RD} ml-auto`,children:`Set up ›`})]}),t?(0,Q.jsx)(`dd`,{"data-slot":`tool-hint`,className:`basis-full min-w-0 break-words pl-[15px] text-xs leading-snug text-muted-foreground`,children:t}):null]},e.name)})}):null,e.data?.checks.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No tool diagnostics reported by this server.`}):null,(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,Q.jsx)(O,{variant:`outline`,className:`h-10 rounded-lg px-[15px] text-xs font-normal leading-[18px]`,disabled:e.isFetching,onClick:()=>void e.refetch(),children:e.isFetching?`Checking tools…`:`Recheck tools`}),(0,Q.jsx)(O,{variant:`outline`,className:`h-10 rounded-lg px-[15px] text-xs font-normal leading-[18px]`,disabled:!e.data||a,onClick:()=>void s(),children:a?`Copying…`:`Copy diagnostics`})]})]}),r===`new`?(0,Q.jsx)(jD,{open:!0,onOpenChange:e=>{e||i(null)}}):null,r===`local`?(0,Q.jsx)(ab,{open:!0,onOpenChange:e=>{e||i(null)}}):null,r===`clone`?(0,Q.jsx)(DD,{open:!0,onOpenChange:e=>{e||i(null)}}):null]})}var BD=(0,Z.lazy)(()=>zr(()=>import(`./task-thread-BJuTSmY_.js`).then(e=>({default:e.TaskThreadRoute})),__vite__mapDeps([30,1,2,3,4,5,6,20,21,22,23,7,31,9,8,10,12,32,27,11,33,17,15,34,35,18,26,28,29,36,37,38,16,25,39,40,41,42,43]))),VD=(0,Z.lazy)(()=>zr(()=>import(`./task-changes-nzP5M4TF.js`).then(e=>({default:e.TaskChangesRoute})),__vite__mapDeps([44,1,2,3,4,5,6,20,21,22,23,7,10,32,27,9,33,8,31,12,11,17,15,34,35,18,26,28,29,36,37,45,46,38,25,47,48,49,41]))),HD=(0,Z.lazy)(()=>zr(()=>import(`./task-files-DKCWoClo.js`).then(e=>({default:e.TaskFilesRoute})),__vite__mapDeps([50,1,2,3,4,5,6,20,21,22,23,7,10,12,33,8,9,27,31,32,11,17,15,34,35,18,26,28,29,36,37,24,25]))),UD=(0,Z.lazy)(async()=>{let{TaskReportRoute:e}=await zr(async()=>{let{TaskReportRoute:e}=await import(`./report-reader-BflKmitB.js`);return{TaskReportRoute:e}},__vite__mapDeps([19,1,2,3,4,5,6,20,21,22,23,7,10,24,12,25,26,27,9,28,29]));return{default:e}}),WD=(0,Z.lazy)(()=>zr(()=>import(`./task-commits-IDq_lfu-.js`).then(e=>({default:e.TaskCommitsRoute})),__vite__mapDeps([51,1,2,3,4,5,6,20,21,22,23,7,10,33,8,9,27,31,12,32,11,17,15,34,35,18,26,28,29,36,37,25,40,52,46,38,48,49,41]))),GD=(0,Z.lazy)(()=>zr(()=>import(`./task-github-item-D-HcRSL8.js`).then(e=>({default:e.TaskGithubItemRoute})),__vite__mapDeps([53,2,1,3,4,5,6,20,21,22,23,7,31,9,8,10,12,33,27,32,11,17,15,34,35,18,26,28,29,36,37,25,54,55,39,56,57,38,48,49,41,58]))),KD=(0,Z.lazy)(()=>zr(()=>import(`./repo-git-BmaBIIo9.js`).then(e=>({default:e.RepoGitRoute})),__vite__mapDeps([59,1,2,3,4,5,6,20,21,22,23,7,8,9,10,27,11,12,60,46,38,45,31,15,35,18,25,47,48,49,41,52,61]))),qD=(0,Z.lazy)(()=>zr(()=>import(`./github-BtPVrHZu.js`).then(e=>({default:e.GithubRoute})),__vite__mapDeps([62,1,2,3,4,5,6,20,21,22,23,7,55,9,8,10,31,12,32,27,18,39,56,26,28,29,57,11,60,25,40,54,38,34,48,49,41,36,58]))),JD=(0,Z.lazy)(()=>zr(()=>import(`./reports-D0VRvzsA.js`).then(e=>({default:e.ReportsRoute})),__vite__mapDeps([63,1,2,3,4,5,6,21,18,42,64]))),YD=(0,Z.lazy)(()=>zr(()=>import(`./workflows-BWyhlz9X.js`).then(e=>({default:e.WorkflowsRoute})),__vite__mapDeps([65,1,2,3,4,5,6,20,21,22,23,7,8,9,10,27,32,25,56,66,67,57]))),XD=(0,Z.lazy)(()=>zr(()=>import(`./activity-route-CQPkXxJ2.js`).then(e=>({default:e.ProjectActivityRoute})),__vite__mapDeps([68,1,2,3,4,13,12,69,5,6,22,23,14,38,34,18,70]))),ZD=(0,Z.lazy)(()=>zr(()=>import(`./global-activity-route-BOg5DOZ-.js`).then(e=>({default:e.GlobalActivityRoute})),__vite__mapDeps([71,1,2,3,4,20,5,6,21,22,23,7,69,12,14,38,34,18,70]))),QD=(0,Z.lazy)(()=>zr(()=>import(`./skills-BLI5ZUXe.js`).then(e=>({default:e.SkillsRoute})),__vite__mapDeps([72,1,2,3,4,5,6,20,21,22,23,7,55,9,8,10,31,12,32,27,18,39,56,26,28,29,57,25,67])));function $D(){let e=a();return(0,Q.jsx)(gs,{to:{pathname:`/skills`,search:e.search,hash:e.hash},replace:!0})}function eO({sectionId:e}){let t=a();return(0,Q.jsx)(v,{to:{pathname:Rx(`global`,e),search:t.search,hash:t.hash},replace:!0})}function tO(){return(0,Q.jsx)(`div`,{"data-route":`scope-resolving`,className:`flex min-h-full flex-col`,children:(0,Q.jsx)(`p`,{className:`px-4 py-6 text-center text-xs text-soft-foreground`,children:`Loading…`})})}function nO(){let{projectId:e=``}=s(),t=a(),n=It(),r=mn();if(e==="default"){let e=n.data?.bootProject??(n.isError?r.data?.bootProject:void 0);if(e!==void 0){let n=t.pathname.replace(/^\/p\/default(?=\/|$)/,``);return(0,Q.jsx)(v,{to:`/p/${encodeURIComponent(e)}${n||`/`}${t.search}${t.hash}`,replace:!0})}if(!n.isError)return(0,Q.jsx)(tO,{})}if(n.data){if(!(n.data.bootProject===e||n.data.projects.some(t=>t.id===e)))return(0,Q.jsx)(zg,{projectId:e,registry:n.data})}else if(!n.isError)return(0,Q.jsx)(tO,{});return(0,Q.jsx)(at,{projectId:n.data?.bootProject===e?null:e,children:(0,Q.jsx)(_,{},e)})}function rO(){let{projectId:e=``}=s();return(0,Q.jsx)(Ag,{},e)}var iO=/^\/tasks\/([0-9a-f-]{36})(?=\/|$)/i;function aO(){let e=a(),t=mn(),n=It(),r=iO.exec(e.pathname)?.[1]??null,i=Gt(r!==null),o=i.data!==void 0||i.isError,s=i.data!==void 0&&!i.data.runs.some(e=>e.id===r),c=pn(r!==null&&s?r:``),l=t.data?.bootProject??n.data?.bootProject,u=(t.data!==void 0||t.isError)&&(n.data!==void 0||n.isError);if(l===void 0&&!u)return(0,Q.jsx)(tO,{});let d=l??`default`;if(e.pathname===`/`&&e.search===``&&e.hash===``){if(n.data===void 0&&!n.isError)return(0,Q.jsx)(tO,{});let e=Lm(jm(),n.data,l);if(e!==null)return(0,Q.jsx)(v,{to:e,replace:!0})}let f=d;if(r!==null){if(!o)return(0,Q.jsx)(tO,{});let e=i.data?.runs.find(e=>e.id===r)?.projectId;if(e!==void 0)f=e;else if(s){if(c.data===void 0&&!c.isError)return(0,Q.jsx)(tO,{});f=c.data?.runs.find(e=>e.id===r)?.projectId??d}}let p=e.pathname===`/p`||e.pathname===`/p/`?`/`:e.pathname;return(0,Q.jsx)(v,{to:`/p/${encodeURIComponent(f)}${p}${e.search}${e.hash}`,replace:!0})}var oO=[{pattern:`/`,pageLabel:`Tasks`},{pattern:`/tasks`,pageLabel:`All tasks`},{pattern:`/tools`,pageLabel:`Workspace tools`},{pattern:`/new`,pageLabel:`New task`},{pattern:`/activity`,pageLabel:`Activity`},{pattern:`/git/*`,pageLabel:`Git`},{pattern:`/github/*`,pageLabel:`GitHub`},{pattern:`/automations/*`,pageLabel:`Automations`},{pattern:`/skills`,pageLabel:`Skills`},{pattern:`/inbox`,pageLabel:`Inbox`},{pattern:`/reports`,pageLabel:`Reports`},{pattern:`/workflows/*`,pageLabel:`Workflows`},{pattern:`/settings/*`,pageLabel:`Settings`}];function sO(e){let t=hs(e),n=m({path:`/tasks/:id/*`,end:!0},t);return n?{pageLabel:null,taskId:n.params.id??null}:{pageLabel:oO.find(({pattern:e})=>m({path:e,end:!0},t))?.pageLabel??null,taskId:null}}function cO(e){return(0,Q.jsxs)(f,{path:`/p/:projectId`,element:(0,Q.jsx)(nO,{}),children:[(0,Q.jsx)(f,{index:!0,element:(0,Q.jsx)(nw,{})}),(0,Q.jsx)(f,{path:`new`,element:(0,Q.jsx)(rO,{})}),(0,Q.jsx)(f,{path:`activity`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Wm,{}),children:(0,Q.jsx)(XD,{})})}),(0,Q.jsxs)(f,{path:`tasks/:id`,element:(0,Q.jsx)(H_,{}),children:[(0,Q.jsx)(f,{index:!0,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Gg,{}),children:(0,Q.jsx)(BD,{})})}),(0,Q.jsx)(f,{path:`changes`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Vg,{tab:`changes`}),children:(0,Q.jsx)(VD,{})})}),(0,Q.jsx)(f,{path:`files`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Vg,{tab:`files`}),children:(0,Q.jsx)(HD,{})})}),(0,Q.jsx)(f,{path:`report`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{"data-route":`task-report`,children:(0,Q.jsx)(`h1`,{className:`p-4 text-sm text-soft-foreground`,children:`Loading report…`})}),children:(0,Q.jsx)(UD,{})})}),(0,Q.jsx)(f,{path:`commits`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Vg,{tab:`changes`}),children:(0,Q.jsx)(WD,{})})}),(0,Q.jsx)(f,{path:`commits/:sha`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Vg,{tab:`changes`}),children:(0,Q.jsx)(WD,{})})}),(0,Q.jsx)(f,{path:`issue/:n`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Wg,{kind:`issue`}),children:(0,Q.jsx)(GD,{kind:`issue`})})}),(0,Q.jsx)(f,{path:`pr/:n`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Wg,{kind:`pr`}),children:(0,Q.jsx)(GD,{kind:`pr`})})})]}),(0,Q.jsx)(f,{path:`compare/:groupId`,element:(0,Q.jsx)(gs,{to:`/`,replace:!0})}),(0,Q.jsx)(f,{path:`git`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lg,{}),children:(0,Q.jsx)(KD,{section:`main`,index:!0})})}),(0,Q.jsx)(f,{path:`git/commits`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lg,{}),children:(0,Q.jsx)(KD,{section:`main`})})}),(0,Q.jsx)(f,{path:`git/commits/:sha`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lg,{}),children:(0,Q.jsx)(KD,{section:`main`})})}),(0,Q.jsx)(f,{path:`git/not-landed`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lg,{}),children:(0,Q.jsx)(KD,{section:`not-landed`})})}),(0,Q.jsx)(f,{path:`git/cleanup`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lg,{}),children:(0,Q.jsx)(KD,{section:`cleanup`})})}),(0,Q.jsx)(f,{path:`git/branches`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lg,{}),children:(0,Q.jsx)(KD,{section:`branches`})})}),(0,Q.jsx)(f,{path:`git/changes`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Lg,{}),children:(0,Q.jsx)(KD,{section:`changes`})})}),(0,Q.jsx)(f,{path:`github`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Gm,{}),children:(0,Q.jsx)(qD,{view:`issues`,index:!0})})}),(0,Q.jsx)(f,{path:`github/prs`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Gm,{}),children:(0,Q.jsx)(qD,{view:`prs`})})}),(0,Q.jsx)(f,{path:`github/issues/:n`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Gm,{}),children:(0,Q.jsx)(qD,{view:`issues`})})}),(0,Q.jsx)(f,{path:`github/prs/:n`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Gm,{}),children:(0,Q.jsx)(qD,{view:`prs`})})}),(0,Q.jsx)(f,{path:`github/prs/:n/changes`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Gm,{}),children:(0,Q.jsx)(qD,{view:`prs`,changes:!0})})}),(0,Q.jsx)(f,{path:`automations`,element:(0,Q.jsx)(wD,{})}),(0,Q.jsx)(f,{path:`automations/new`,element:(0,Q.jsx)(wD,{mode:`new`})}),(0,Q.jsx)(f,{path:`automations/:automationId`,element:(0,Q.jsx)(wD,{mode:`edit`})}),(0,Q.jsx)(f,{path:`automations/:automationId/log`,element:(0,Q.jsx)(wD,{mode:`log`})}),(0,Q.jsx)(f,{path:`skills`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Rg,{}),children:(0,Q.jsx)(QD,{})})}),(0,Q.jsx)(f,{path:`inbox`,element:(0,Q.jsx)(Km,{})}),(0,Q.jsx)(f,{path:`reports`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,children:`Loading reports…`}),children:(0,Q.jsx)(JD,{})})}),(0,Q.jsx)(f,{path:`workflows`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Bg,{}),children:(0,Q.jsx)(YD,{})})}),(0,Q.jsx)(f,{path:`workflows/:name`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Bg,{}),children:(0,Q.jsx)(YD,{})})}),(0,Q.jsx)(f,{path:`settings`,element:(0,Q.jsx)(Wx,{capabilities:e})}),(0,Q.jsx)(f,{path:`settings/skills`,element:(0,Q.jsx)($D,{})}),qb(`project`,e).map(t=>(0,Q.jsx)(f,{path:`settings/${t.id}`,element:(0,Q.jsx)(Ux,{section:t,scope:`project`,capabilities:e})},t.id)),qb(`global`,e).map(e=>(0,Q.jsx)(f,{path:`settings/${e.id}`,element:(0,Q.jsx)(eO,{sectionId:e.id})},e.id)),(0,Q.jsx)(f,{path:`*`,element:(0,Q.jsx)(Fg,{})})]})}function lO(e,t){let n=M(N(cO(t)),e),r=n?.at(-1);return!n||!r||r.route.path===`*`?null:{pattern:`/${n.slice(1).map(e=>e.route.path).filter(e=>e!==void 0).join(`/`)}`.replace(/\/$/,``)||`/`,params:r.params}}function uO(){let e=mn().data?.capabilities;return(0,Q.jsxs)(A,{children:[cO(e),(0,Q.jsx)(f,{path:`/tasks`,element:(0,Q.jsx)(qw,{})}),(0,Q.jsx)(f,{path:`/tools`,element:(0,Q.jsx)(zD,{})}),(0,Q.jsx)(f,{path:`/activity`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Wm,{}),children:(0,Q.jsx)(ZD,{})})}),(0,Q.jsx)(f,{path:`/settings/global`,element:(0,Q.jsx)(v,{to:zx,replace:!0})}),(0,Q.jsx)(f,{path:`/settings/global/skills`,element:(0,Q.jsx)(v,{to:`/skills`,replace:!0})}),qb(`global`,e).map(t=>(0,Q.jsx)(f,{path:Rx(`global`,t.id),element:(0,Q.jsx)(Ux,{section:t,scope:`global`,capabilities:e})},t.id)),(0,Q.jsx)(f,{path:`*`,element:(0,Q.jsx)(aO,{})})]})}var dO=2500,fO=e=>String(us(e,`/`));function pO(e,t,n){let r={href:fO(e),verify:!1},i=Um(e,t,n.registry);if(i===null)return r;try{let e=lO(i.replace(/[?#].*$/,``),n.capabilities);return e===null?r:{href:i,verify:Object.keys(e.params).some(e=>e!==`projectId`)}}catch{return r}}var mO=e=>Mt(Vt(e.params.id??``,{projectId:e.opts.projectId}),{signal:e.opts.signal});function hO(e){let t=Number(e);return Number.isSafeInteger(t)&&t>=1?t:null}async function gO(e,t,n){let r=await Ct(e,t,{},n.opts);return r.available?r.item!==null:null}var _O=async e=>(await mO(e),!0),vO=async e=>(await mO(e),await At(e.params.id??``,e.params.sha??``,e.opts),!0);async function yO(e,t){let n=await mO(e),r=hO(e.params.n);return r===null?!1:In(n,e.repoBase).some(e=>e.kind===t&&e.number===r)?gO(t,r,e):e.repoBase===void 0&&null}var bO=async e=>(await Dt(e.params.sha??``,e.opts),!0);async function xO(e,t){let n=hO(e.params.n);return n!==null&&gO(t,n,e)}var SO=[{matches:e=>e===`/tasks/:id/commits/:sha`,check:vO},{matches:e=>e===`/tasks/:id/issue/:n`,check:e=>yO(e,`issue`)},{matches:e=>e===`/tasks/:id/pr/:n`,check:e=>yO(e,`pr`)},{matches:e=>e.startsWith(`/tasks/:id`),check:_O},{matches:e=>e===`/git/commits/:sha`,check:bO},{matches:e=>e===`/github/issues/:n`,check:e=>xO(e,`issue`)},{matches:e=>e.startsWith(`/github/prs/:n`),check:e=>xO(e,`pr`)},{matches:e=>e===`/workflows/:name`,check:async e=>{let{workflows:t,issues:n}=await le(e.opts);return t.some(t=>t.name===e.params.name)?!0:n.length>0&&null}},{matches:e=>e.startsWith(`/automations/:automationId`),check:async e=>{let t=await ft(e.opts);return t.available?t.automations.some(t=>t.id===e.params.automationId):null}}];async function CO(e,t,n,r,i){let a=``;try{let o=lO(t,n);if(o===null)return!1;a=o.pattern;let s=SO.find(e=>e.matches(o.pattern));return s===void 0?null:await s.check({projectId:e,pattern:a,params:o.params,repoBase:i,opts:{projectId:e,signal:r}})}catch(e){return!TO(e,a)&&null}}var wO=/unknown revision|bad object|bad revision|unknown commit|not a commit hash|needed a single revision/i;function TO(e,t){return e instanceof Ze?e.status===404||(t===`/git/commits/:sha`||t===`/tasks/:id/commits/:sha`)&&e.status===409&&wO.test(e.message):!1}async function EO(e,t,n){let r=pO(e,t,n);if(!r.verify)return r.href;let i=new AbortController,a=setTimeout(()=>i.abort(),dO);try{return await CO(e,r.href.replace(/[?#].*$/,``),n.capabilities,i.signal,n.repoBaseOf?.(e))===!1?fO(e):r.href}finally{clearTimeout(a)}}var DO={key:``,navigate:null,ticket:0};function OO(e,t){e!==DO.key&&DO.ticket++,DO.key=e,DO.navigate=t}function kO(){DO.ticket++}async function AO(e,t,n){let r=++DO.ticket,i=DO.key,a=await EO(e,t,n);r===DO.ticket&&i===DO.key&&DO.navigate?.(a)}function jO(){let e=j(),t=a();Z.useLayoutEffect(()=>{OO(`${t.key}|${t.pathname}${t.search}${t.hash}`,e)},[e,t.key,t.pathname,t.search,t.hash])}function MO(){let e=It().data,t=mn().data,n=t?.capabilities,r=Z.useCallback(n=>e?.projects.find(e=>e.id===n)?.repoUrl??(n===(t?.bootProject??e?.bootProject)?On(t?.repo?.remote):void 0),[e,t]);jO();let{pathname:i,search:o,hash:s}=a(),c=fs(i),l=`${i}${o}${s}`;return{target:Z.useCallback(t=>t===c?{href:l,verify:!1}:pO(t,Vm(t),{registry:e,capabilities:n}),[e,n,c,l]),go:Z.useCallback(async t=>{if(t===c)return kO();await AO(t,Vm(t),{registry:e,capabilities:n,repoBaseOf:r})},[e,n,r,c])}}var NO=[{to:`/`,label:`Tasks`,icon:Ua,match:[`/`,`/tasks`],badge:`tasks-unread`},{to:`/activity`,label:`Activity`,icon:Sp,match:[`/activity`]},{to:`/git`,label:`Git`,icon:oo,match:[`/git`]},{to:`/github`,label:`GitHub`,icon:La,match:[`/github`],forge:!0},{to:`/automations`,label:`Automations`,icon:io,match:[`/automations`],automations:!0},{to:`/skills`,label:`Skills`,icon:vo,match:[`/skills`]},{to:`/workflows`,label:`Workflows`,icon:no,match:[`/workflows`]},{to:`/reports`,label:`Reports`,icon:Yp,match:[`/reports`]},{to:`/settings`,label:`Settings`,icon:eo,match:[`/settings`]}];function PO({forge:e=!1,automations:t=!1}={}){return NO.filter(n=>(!n.forge||e)&&(!n.automations||t))}function FO(e,t){return t===`/`?e===`/`:e===t||e.startsWith(t+`/`)}function IO(e){let t=null;for(let n of NO)for(let r of n.match)FO(e,r)&&(t===null||r.length>t.length)&&(t={to:n.to,length:r.length});return t?.to??null}function LO(e){let t=IO(e);return NO.find(e=>e.to===t)??null}function RO(e){return/^\/tasks\/[^/]+(?:\/|$)/.test(hs(e))}function zO(e,t){let n=hs(e);return/^\/git\/?$/.test(n)?new URLSearchParams(t).get(`view`)===`repo`:n.startsWith(`/git/`)}var BO=[`/`,`/activity`,`/github`],VO=[`/git`,`/skills`,`/workflows`,`/reports`,`/settings`,`/automations`],HO={light:`dark`,dark:`system`,system:`light`},UO={light:`light`,dark:`dark`,system:`system`};function WO({className:e,showLabel:t=!1,labelClassName:n}){let{theme:r,setTheme:i}=Ny(),a=HO[r],o=Ya;return(0,Q.jsxs)(O,{type:`button`,variant:`ghost`,size:`icon-sm`,className:e,"data-slot":`theme-toggle`,"data-theme-pref":r,title:`Theme: ${UO[r]}`,"aria-label":`Theme: ${UO[r]}. Switch to ${UO[a]}.`,onClick:()=>i(a),children:[(0,Q.jsx)(o,{"aria-hidden":`true`}),t?(0,Q.jsxs)(`span`,{className:n,children:[`Theme · `,r.charAt(0).toUpperCase()+r.slice(1)]}):null]})}var GO,KO,qO,JO=new Map,YO=new Map,XO=new Map,ZO=new Set,QO=(e,t)=>`${e}\u0000${t}`,$O=()=>ZO.forEach(e=>e()),ek=e=>JO.get(QO(e.runId,e.askRequestId));function tk(e){e.kind===`answer`?(KO&&ek(e)?.restore(KO),KO=void 0):YO.get(e.runId)?.clearVoiceDraft(e.text)}function nk(e,t){let n=new Map;for(let r of[...e,...t])n.set(r.question,r);return[...n.values()].sort((e,t)=>e.question-t.question)}function rk(e){let t=GO;if(e.kind===`answer`){let n=ek(e);if(!n)return{ok:!1,reason:`no-card`};if(t?.kind===`answer`&&t.askRequestId===e.askRequestId&&t.runId===e.runId){let r={...e,answers:nk(t.answers,e.answers)};return GO=r,qO=void 0,n.apply(r.answers),$O(),{ok:!0,replaced:t.decisionId}}return t&&tk(t),KO=n.read(),GO=e,qO=void 0,n.apply(e.answers),$O(),t?{ok:!0,replaced:t.decisionId}:{ok:!0}}let n=YO.get(e.runId);if(!n)return{ok:!1,reason:`no-card`};let r=n.getDraft(),i=t?.kind===`tell`&&t.runId===e.runId&&r===t.text;return r.trim()!==``&&!i?{ok:!1,reason:`draft-not-empty`}:n.setDraft(e.text)?(t&&!(t.kind===`tell`&&t.runId===e.runId)&&tk(t),GO=e,qO=void 0,$O(),t?{ok:!0,replaced:t.decisionId}:{ok:!0}):{ok:!1,reason:`busy`}}function ik(){let e=GO;if(!e)return{ok:!1,reason:`no-target`};if(e.kind===`answer`){let t=ek(e);if(!t)return{ok:!1,reason:`no-target`};let n=t.unanswered();if(n.length>0)return{ok:!1,unanswered:n.map(e=>({index:e,header:t.headers[e]??``}))};if(!t.send())return{ok:!1,reason:`busy`};KO=void 0}else{let t=YO.get(e.runId);if(!t)return{ok:!1,reason:`no-target`};if(!t.submit())return{ok:!1,reason:`busy`}}return GO=void 0,$O(),{ok:!0}}function ak(){let e=GO;e&&(tk(e),GO=void 0,$O())}function ok(e){GO=void 0,KO=void 0,qO=e,$O()}var sk=e=>GO?.kind===`answer`&&GO.runId===e?GO:void 0,$={getProposal:()=>GO,propose:rk,confirm:ik,cancel:ak,lastDrop:()=>qO,headersFor:(e,t)=>JO.get(QO(e,t))?.headers,registerAskCard(e){let t=QO(e.runId,e.requestId);return JO.set(t,e),GO?.kind===`answer`&&QO(GO.runId,GO.askRequestId)===t&&e.apply(GO.answers,{reveal:!1}),()=>{JO.get(t)===e&&JO.delete(t)}},syncPendingAsk(e,t){let n=sk(e);n&&n.askRequestId!==t&&ok(`question-closed`);let r=t??null;XO.get(e)!==r&&(XO.set(e,r),$O())},leaveTask(e){sk(e)&&ok(`task-closed`),XO.delete(e)&&$O()},pendingAskFor(e){return XO.get(e)},registerComposer(e){return YO.set(e.runId,e),()=>{YO.get(e.runId)===e&&(YO.delete(e.runId),GO?.kind===`tell`&&GO.runId===e.runId&&(e.clearVoiceDraft(GO.text),ok(`task-closed`)))}},subscribe(e){return ZO.add(e),()=>{ZO.delete(e)}}};function ck(){return(0,Z.useSyncExternalStore)($.subscribe,$.getProposal,$.getProposal)}function lk(e){let t=()=>e===void 0?void 0:$.pendingAskFor(e);return(0,Z.useSyncExternalStore)($.subscribe,t,t)}var uk=Z.createContext(null);function dk({children:e}){let[t,n]=Z.useState(`active`),r=Z.useMemo(()=>[t,n],[t]);return(0,Q.jsx)(uk.Provider,{value:r,children:e})}function fk(){let e=Z.useContext(uk);if(!e)throw Error(`useListView must be used inside a <ListViewProvider>`);return e}var pk=[`one`,`two`,`three`,`four`,`five`,`six`,`seven`,`eight`,`nine`,`ten`],mk=[`first`,`second`,`third`,`fourth`,`fifth`,`sixth`,`seventh`,`eighth`,`ninth`,`tenth`],hk=RegExp(`^(?:the\\s+)?(?:number\\s+)?(\\d{1,2}|${[...pk,...mk].join(`|`)})(?:\\s+one)?$`);function gk(e,t){let n=hk.exec(e.toLowerCase().trim().replace(/[.!?]$/,``).trim())?.[1];if(n===void 0)return null;let r=/^\d+$/.test(n)?Number(n):Math.max(pk.indexOf(n),mk.indexOf(n))+1;return r>=1&&r<=Math.min(10,t)?r-1:null}var _k={"needs-permission":`needs-permission`,failed:`failed`,"needs-you":null,"needs-review":`needs-review`,running:`running`,"usage-limit":`scheduled`,"waiting-on-workers":`waiting-on-workers`,"waiting-on-subagents":`waiting-on-workers`,"waiting-for-ci":`waiting-for-ci`,"waiting-for-merge":null,"waiting-for-command":null,monitoring:`monitoring`,"waiting-for-capacity":`waiting-for-capacity`,queued:`queued`,done:`done`,cancelled:`cancelled`,unseen:null};function vk(e,t){switch(e){case`needs-you`:return gr(t,`active`)===`Needs you`;case`working`:return gr(t,`active`)===`Working`;case`finished`:return gr(t,`active`)===`Finished`;case`archived`:return t.archived===!0;case`needs-permission`:return fe(t).bucket===`permission`;case`failed`:return fe(t).bucket===`error`;case`needs-review`:case`running`:case`waiting-for-ci`:case`monitoring`:case`waiting-for-capacity`:case`queued`:case`scheduled`:case`waiting-on-workers`:return _k[fe(t).rung]===e;case`done`:case`cancelled`:return t.status===e;case`unread`:return Yt(t)}}function yk(e,t,n){return n===`archived`?Wt(e,`archived`).filter(e=>!Yn(e)).slice(0,200).map(e=>({kind:`run`,run:e,queuePosition:null})):Qn(Kt(e,t),`active`).flatMap(e=>e.rows)}var bk=(e,t)=>vk(t,e.run),xk=(e,t)=>e.run.id===t,Sk=e=>e===void 0?{kind:`past-end`}:{kind:`run`,runId:e.run.id};function Ck(e){let{runs:t,sidebarView:n,openRunId:r,status:i,position:a}=e,o=yk(t,n,i).filter(e=>bk(e,i));if(o.length===0)return{kind:`empty`};if(typeof a==`number`)return Sk(o[a-1]);if(a===`last`)return Sk(o[o.length-1]);let s=jr(r,t),c=s===null?-1:o.findIndex(e=>xk(e,s));return Sk(a===`next`?o[c+1]:c===-1?o[o.length-1]:o[c-1])}var wk=[[`/tasks`,`task`],[`/new`,`new-task`],[`/github`,`github`],[`/git`,`git`],[`/automations`,`automations`],[`/inbox`,`inbox`],[`/settings`,`settings`]];function Tk(e){for(let[t,n]of wk)if(e===t||e.startsWith(`${t}/`))return n;return`other`}var Ek=qr([`needs-you`,`working`,`finished`,`archived`,`needs-review`,`needs-permission`,`failed`,`running`,`waiting-for-ci`,`monitoring`,`waiting-for-capacity`,`queued`,`scheduled`,`waiting-on-workers`,`done`,`cancelled`,`unread`]),Dk=$r([qr([`next`,`previous`,`last`]),U().int().min(1).max(10)]),Ok=qr([`active`,`automations`]),kk=qr([`task`,`new-task`,`github`,`git`,`automations`,`inbox`,`settings`,`other`]);G({text:W().trim().min(1).max(500),sidebarView:Ok,openRunId:Xr.shape.id.optional(),view:kk.optional(),askRequestId:W().min(1).max(200).nullable().optional(),proposal:G({decisionId:ei(),action:qr([`answer`,`tell`])}).strict().optional()}).strict();var Ak=Br(`kind`,[G({question:U().int().min(0).max(3),kind:Zr(`option`),labels:Jr(W()).min(1).max(4)}),G({question:U().int().min(0).max(3),kind:Zr(`other`),text:W().min(1).max(500)})]),jk=ei(),Mk=U().min(0).max(1);Br(`action`,[G({action:Zr(`open`),decisionId:jk,status:Ek,position:Dk,confidence:Mk,alternatives:Jr(G({status:Ek,position:Dk})).max(3).optional()}),G({action:Zr(`answer`),decisionId:jk,runId:Xr.shape.id,askRequestId:W(),answers:Jr(Ak).min(1).max(4),confidence:Mk}),G({action:Zr(`tell`),decisionId:jk,runId:Xr.shape.id,text:W().min(1).max(500),confidence:Mk}),G({action:Zr(`confirm`),decisionId:jk}),G({action:Zr(`cancel`),decisionId:jk}),G({action:Zr(`none`),decisionId:jk,reason:qr([`not-a-command`,`no-open-task`,`no-open-question`,`unclear`,`ambiguous`,`stale-context`,`unsupported`])})]);var Nk=qr([`executed`,`confirmed`,`cancelled`,`replaced`,`abandoned`]);G({decisionId:ei(),outcome:Nk}).strict(),G({ok:Zr(!0)});var Pk=[`first`,`second`,`third`,`fourth`,`fifth`,`sixth`,`seventh`,`eighth`,`ninth`,`tenth`];function Fk(e){return typeof e==`number`?Pk[e-1]??String(e):e}function Ik(e){return e.split(`-`).map(e=>e===`ci`?`CI`:e).join(` `)}function Lk(e,t,n){return`Open “${e}” — ${Fk(n)} ${Ik(t)}`}var Rk=e=>`No ${Ik(e)} tasks.`,zk=(e,t)=>`No ${Fk(t)} ${Ik(e)} task.`;function Bk(e,t,n){return`Answer ${n?`“${n}”: `:``}${Vk(e,t).join(`; `)}`}function Vk(e,t){return e.map(e=>`${t?.[e.question]||`question ${e.question+1}`}: ${e.kind===`option`?e.labels.join(`, `):e.text}`)}function Hk(e,t){return e===`answer`?t?`Answer “${t}”`:`Answer the question`:t?`Send to “${t}”`:`Send to this task`}var Uk=(e,t)=>t?`Tell “${t}”: ${e}`:`Tell it: ${e}`,Wk=`voice-will-do`,Gk=3e3,Kk={timedOut:`Voice decision timed out.`,unavailable:`Voice decision unavailable.`,noCard:`This question is not open here.`,draftNotEmpty:`The message box already has text.`,busy:`The task is busy. Try again in a moment.`,noOpenTask:`Open a task first.`,noOpenQuestion:`This task has no open question.`,unclear:`Not sure what to do. Try again.`,questionClosed:`The question was answered or closed elsewhere.`,taskClosed:`The task is no longer open.`,scrollToQuestion:`Scroll to the question, then confirm.`,ambiguous:`Which question? Name it, for example “to question two”.`,staleContext:`The screen changed. Try again.`,unsupported:`Voice cannot do that yet.`},qk={"no-open-task":Kk.noOpenTask,"no-open-question":Kk.noOpenQuestion,unclear:Kk.unclear,ambiguous:Kk.ambiguous,"stale-context":Kk.staleContext,unsupported:Kk.unsupported};function Jk(e){return e.trim().split(/\s+/).length>=2}var Yk=e=>Jk(e)&&e.length<=500,Xk=e=>/^(?:no|cancel)$/.test(e.toLowerCase().replace(/[.!?]+$/,``).trim()),Zk=(e,t)=>e.text===t.text&&e.projectId===t.projectId&&e.view===t.view&&e.openRunId===t.openRunId&&e.askRequestId===t.askRequestId&&e.proposalId===t.proposalId;function Qk(e,t){let n=e=>{let n=t.runs.find(t=>t.id===e.runId);return n?xn(n):e.runId},r=(e,n)=>Ck({...t,status:e,position:n}),i=r(e.status,e.position),a=[],o=new Set;for(let t of[{status:e.status,position:e.position},...e.alternatives??[]]){let e=r(t.status,t.position);if(e.kind!==`run`)continue;let i=`run:${e.runId}`;o.has(i)||(o.add(i),a.push({target:e,text:Lk(n(e),t.status,t.position)}))}return{primary:i,choices:e.alternatives?.length?a:a.slice(0,1)}}function $k(e,t){let n=e.find(e=>e.id===t);return n?xn(n):void 0}function eA(e,t){let n=Hk(e.kind,$k(t,e.runId));return e.kind===`answer`?{heading:n,lines:Vk(e.answers,$.headersFor(e.runId,e.askRequestId))}:{heading:n,lines:[e.text]}}function tA(){document.querySelector(`[cmdk-item]:not([data-slot^="voice-"]):not([data-disabled="true"])`)?.click()}var nA={row:void 0,confirm:void 0,mode:`idle`,onEnter:()=>!1,onClose:()=>{},onSelect:()=>{},onConfirm:()=>{}};function rA(e){let{enabled:t}=e,n=qt().data,[r]=fk(),i=ps(`/tasks/:id/*`)?.params.id??null,a=_s(),o=Tk(vs()),s=lk(i??void 0),c=ds(),l=ck(),u=e.text.trim(),d=Z.useMemo(()=>({text:u,projectId:a,view:o,openRunId:i,askRequestId:s,proposalId:l?.decisionId??null}),[u,a,o,i,s,l?.decisionId]),[f,p]=Z.useState(),[m,h]=Z.useState(),[g,_]=Z.useState(),v=g!==void 0&&g.projectId===a&&g.view===o&&g.openRunId===i&&g.sidebarView===r?g:void 0,y=v?gk(u,v.choices.length):null,b=v!==void 0&&!(Yk(u)&&y===null)?v:void 0,x=Z.useRef({...e,key:d,runs:n??[],sidebarView:r,openRunId:i,navigate:c,settled:f,choosing:b});x.current={...e,key:d,runs:n??[],sidebarView:r,openRunId:i,navigate:c,settled:f,choosing:b};let S=Z.useRef(void 0),C=Z.useRef(void 0),w=Z.useRef(!1),T=Z.useRef(new Set),E=Z.useRef(new Set),D=Z.useCallback((e,t)=>{E.current.has(e)||(E.current.add(e),dt(e,t))},[]),O=Z.useCallback(e=>h({text:e,forText:x.current.key.text}),[]),k=Z.useCallback(e=>h({text:e,forText:x.current.key.text,forKey:x.current.key}),[]),A=Z.useCallback(e=>{let t=S.current;if(t&&Zk(t.key,e)&&!t.failed)return t;t?.controller.abort();let n=new AbortController,r=$.getProposal(),i={key:e,controller:n,failed:!1,result:$e({text:e.text,sidebarView:x.current.sidebarView,view:e.view,...e.openRunId===null?{}:{openRunId:e.openRunId},...e.askRequestId===void 0?{}:{askRequestId:e.askRequestId},...r&&r.decisionId===e.proposalId?{proposal:{decisionId:r.decisionId,action:r.kind}}:{}},n.signal).then(e=>n.signal.aborted?{kind:`aborted`}:{kind:`decision`,decision:e},()=>n.signal.aborted?{kind:`aborted`}:{kind:`failed`})};return i.result.then(t=>{t.kind===`failed`&&(i.failed=!0),t.kind!==`aborted`&&w.current&&S.current===i&&p({key:e,result:t})}),S.current=i,i},[]),j=Z.useCallback((e,t)=>{D(e,`executed`);let n=$.getProposal();n&&($.cancel(),D(n.decisionId,`abandoned`)),_(void 0),x.current.close(),x.current.navigate(`/tasks/${t.runId}`)},[D]),M=Z.useCallback(()=>{let e=$.getProposal();if(!e)return;let t=$.confirm();if(t.ok)D(e.decisionId,`confirmed`),x.current.close();else if(`unanswered`in t){let e=t.unanswered[0];e&&O(`Question ${e.index+1} (${e.header}) still needs an answer.`)}else t.reason===`busy`?O(Kk.busy):e.kind===`answer`?O(Kk.scrollToQuestion):($.cancel(),D(e.decisionId,`abandoned`),O(Kk.taskClosed))},[D,O]),N=Z.useCallback((e,t)=>{T.current.add(e.decisionId);let{clearText:n,runs:r,sidebarView:i,openRunId:a}=x.current;switch(e.action){case`open`:{let{primary:o,choices:s}=Qk(e,{runs:r,sidebarView:i,openRunId:a});if(s.length>=2){_({decisionId:e.decisionId,choices:s,projectId:t.key.projectId,view:t.key.view,openRunId:a,sidebarView:i}),n();return}let c=s[0];return c?j(e.decisionId,c.target):k(o.kind===`empty`?Rk(e.status):zk(e.status,e.position))}case`answer`:case`tell`:{if(e.runId!==a)return;let t=$.propose(e.action===`answer`?{kind:`answer`,decisionId:e.decisionId,runId:e.runId,askRequestId:e.askRequestId,answers:e.answers}:{kind:`tell`,decisionId:e.decisionId,runId:e.runId,text:e.text});if(t.ok){t.replaced&&D(t.replaced,`replaced`),_(void 0),n();return}return k(t.reason===`no-card`?Kk.noCard:t.reason===`draft-not-empty`?Kk.draftNotEmpty:Kk.busy)}case`confirm`:case`cancel`:{let r=$.getProposal();if(t.key.proposalId===null||r?.decisionId!==t.key.proposalId)return k(Kk.unclear);if(e.action===`confirm`)return M();$.cancel(),D(r.decisionId,`cancelled`),n();return}case`none`:return e.reason===`not-a-command`?tA():k(qk[e.reason])}},[M,j,D,k]),P=Z.useCallback(async()=>{let e=x.current.key,t=A(e);if(C.current===t)return;C.current=t;let n,r=new Promise(e=>{n=setTimeout(()=>e(`timeout`),Gk)}),i=await Promise.race([t.result,r]);clearTimeout(n);let a=C.current===t;if(a&&(C.current=void 0),!(!a||!w.current)&&Zk(x.current.key,e)){if(i===`timeout`)return t.controller.abort(),S.current===t&&(S.current=void 0),k(Kk.timedOut),tA();if(i.kind!==`aborted`){if(i.kind===`failed`)return k(Kk.unavailable),tA();N(i.decision,t)}}},[N,A,k]),F=Z.useCallback(e=>{let t=x.current;if(t.choosing){let n=t.choosing.choices[e];n&&j(t.choosing.decisionId,n.target);return}let n=t.settled;if(!n||!Zk(n.key,t.key)||!Yk(t.key.text)||n.result.kind!==`decision`||n.result.decision.action!==`open`)return;let{decision:r}=n.result,i=Qk(r,t).choices[e];i&&(T.current.add(r.decisionId),j(r.decisionId,i.target))},[j]),{selected:I}=e;Z.useEffect(()=>{I!==`voice-will-do`&&(C.current=void 0)},[I]),Z.useEffect(()=>{let e=S.current;if(e&&!Zk(e.key,d)&&(e.controller.abort(),S.current=void 0),!t||!Yk(d.text)||y!==null||S.current)return;let n=setTimeout(()=>A(d),300);return()=>clearTimeout(n)},[t,d,y,A]);let L=g!==void 0&&b===void 0;Z.useEffect(()=>{h(e=>e&&e.forText!==u?void 0:e)},[u]),Z.useEffect(()=>{L&&_(void 0)},[L]),Z.useEffect(()=>{let e=$.getProposal();return $.subscribe(()=>{let t=$.getProposal(),n=$.lastDrop();e&&!t&&n&&x.current.enabled&&(D(e.decisionId,`abandoned`),O(n===`question-closed`?Kk.questionClosed:Kk.taskClosed)),e=t})},[D,O]);let ee=Z.useCallback(()=>{let e=x.current;if(!e.enabled)return;S.current?.controller.abort();let t=$.getProposal();t&&($.cancel(),D(t.decisionId,`cancelled`));let n=e.settled;if(n&&Zk(n.key,e.key)&&n.result.kind===`decision`){let{decision:e}=n.result;e.action!==`none`&&!T.current.has(e.decisionId)&&D(e.decisionId,`abandoned`)}e.choosing&&D(e.choosing.decisionId,`abandoned`)},[D]);Z.useEffect(()=>(w.current=!0,()=>{w.current=!1,ee()}),[ee]);let te=Z.useCallback(e=>{let t=x.current;if(!t.enabled)return!1;let n=t.key.text,r=()=>(e.preventDefault(),!0);if(e.repeat)return Yk(n)||$.getProposal()?r():!1;if(t.choosing){let e=gk(n,t.choosing.choices.length);if(e!==null)return F(e),r()}let i=$.getProposal();return i&&Xk(n)?($.cancel(),D(i.decisionId,`cancelled`),t.clearText(),r()):n===``&&i&&!t.choosing?(M(),r()):Yk(n)&&t.selected===`voice-will-do`?(P(),r()):!1},[F,P,M,D]),ne=Z.useCallback(e=>{if(e!==void 0)return F(e);Yk(x.current.key.text)&&P()},[F,P]);if(!t)return nA;let R;m&&m.forText===u&&(m.forKey===void 0||Zk(m.forKey,d))?R={kind:`notice`,text:m.text}:b?R={kind:`will-do`,text:`Which one?`,choices:b.choices.map(e=>e.text)}:f&&Zk(f.key,d)&&Yk(u)?R=iA(f.result,f.key,{runs:n??[],sidebarView:r,openRunId:i}):Yk(u)&&y===null&&(R={kind:`will-do`,text:`Reading…`,pending:!0});let re=l&&u===``&&!b?eA(l,n??[]):void 0,ie=b?`choosing`:l?`proposal`:Yk(u)?`preview`:`idle`;return{row:R,confirm:re,mode:ie,onEnter:te,onClose:ee,onSelect:ne,onConfirm:M}}function iA(e,t,n){if(e.kind===`aborted`)return;if(e.kind===`failed`)return{kind:`notice`,text:Kk.unavailable};let{decision:r}=e;switch(r.action){case`open`:{let{primary:e,choices:t}=Qk(r,n);if(t.length>=2)return{kind:`will-do`,text:`Which one?`,choices:t.map(e=>e.text)};let i=t[0];return i?{kind:`will-do`,text:i.text}:{kind:`notice`,text:e.kind===`empty`?Rk(r.status):zk(r.status,r.position)}}case`answer`:return r.runId===n.openRunId?{kind:`will-do`,text:Bk(r.answers,$.headersFor(r.runId,r.askRequestId),$k(n.runs,r.runId))}:void 0;case`tell`:return r.runId===n.openRunId?{kind:`will-do`,text:Uk(r.text,$k(n.runs,r.runId))}:void 0;case`confirm`:case`cancel`:return t.proposalId===null?{kind:`notice`,text:Kk.unclear}:{kind:`will-do`,text:r.action===`confirm`?`Send it`:`Drop it`};case`none`:return r.reason===`not-a-command`?void 0:{kind:`notice`,text:qk[r.reason]}}}function aA({row:e,committable:t,onSelect:n}){return e?(0,Q.jsxs)(ws,{forceMount:!0,"data-slot":`voice-rows`,children:[(0,Q.jsxs)(As,{forceMount:!0,value:Wk,"data-slot":`voice-row`,"data-voice-kind":e.kind,disabled:e.kind===`notice`||e.choices!==void 0||!t,onSelect:()=>n(),className:`data-[disabled=true]:opacity-100`,children:[e.kind===`will-do`?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-soft-foreground`,children:`Will do`}):null,(0,Q.jsx)(`span`,{role:e.kind===`notice`?`status`:void 0,className:e.pending?`min-w-0 flex-1 truncate text-muted-foreground`:`min-w-0 flex-1 truncate`,children:e.text})]}),e.choices?.map((e,t)=>(0,Q.jsxs)(As,{forceMount:!0,value:`voice-choice-${t+1}`,"data-slot":`voice-choice`,onSelect:()=>n(t),children:[(0,Q.jsx)(`span`,{className:`w-4 shrink-0 text-center text-xs text-soft-foreground tabular-nums`,children:t+1}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e})]},t))]}):null}var oA=`Say “yes, confirmed” or press Return to send…`;function sA({confirm:e,notice:t,onConfirm:n}){return(0,Q.jsxs)(ws,{forceMount:!0,"data-slot":`voice-confirm-panel`,children:[t?(0,Q.jsx)(`p`,{role:`status`,className:`px-2 py-1.5 text-sm text-foreground`,children:t}):null,(0,Q.jsxs)(As,{forceMount:!0,value:`voice-confirm`,"data-slot":`voice-confirm`,onSelect:n,className:`flex-col items-start gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:e.heading}),e.lines.map((e,t)=>(0,Q.jsx)(`span`,{className:`w-full whitespace-pre-wrap break-words`,children:e},t))]}),(0,Q.jsxs)(`div`,{"data-slot":`voice-confirm-hints`,className:`flex gap-4 px-2 pt-2 pb-1 text-xs text-muted-foreground`,children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`kbd`,{className:`font-sans text-soft-foreground`,children:`↵`}),` Send`]}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`kbd`,{className:`font-sans text-soft-foreground`,children:`Esc`}),` Cancel`]})]})]})}var cA=`cezar:open-command-palette`;function lA(){window.dispatchEvent(new Event(cA))}function uA(e){return[...e].sort((e,t)=>Date.parse(t.createdAt)-Date.parse(e.createdAt))}function dA(e,t,n){let r=t.trim().toLowerCase();if(r===``)return 1;let i=(n?.length?`${e} ${n.join(` `)}`:e).toLowerCase(),a=r.split(/\s+/),o=0;for(let e of a){let t=i.indexOf(e);if(t===-1)return 0;let n=t===0||!/[a-z0-9]/.test(i[t-1]??``);o+=(n?1:.5)/(1+t/48)}return o/a.length}function fA(e,t){if(t.trim()===``)return e;let n=e=>e.rows.reduce((e,n)=>Math.max(e,dA(n.value,t,n.keywords)),0);return e.map(e=>({group:e,score:n(e)})).sort((e,t)=>t.score-e.score).map(({group:e})=>e)}function pA(e,t){return{value:`task ${xn(e)} ${e.id}`,keywords:[...t?[t]:[],...bA(e),...[e.branch,e.workflow,e.workflowLabel,e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl].filter(e=>!!e)]}}var mA=e=>({value:`view ${e}`}),hA=e=>({value:`project ${e.name} ${e.id}`,keywords:[e.root]}),gA=e=>({value:`skill ${e.name} ${e.path}`,...S({keywords:e.description?[e.description]:void 0})}),_A={value:`action toggle theme`},vA=150;function yA(e,t,n,r=[]){let i=uA(e.filter(e=>!Yn(e))).map(e=>({...e,projectId:t})),a=new Set(i.map(xA)),o=[...n??[],...r].filter(e=>Yn(e)||a.has(xA(e))?!1:(a.add(xA(e)),!0)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return[...i,...o]}function bA(e){let t=new Set;for(let n of[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl]){let e=n?/\/(\d+)\/?$/.exec(n):null;e&&t.add(Number(e[1]))}for(let n of[e.prNumber,e.issueNumber,e.markerRefs?.pr,e.markerRefs?.issue])typeof n==`number`&&Number.isInteger(n)&&n>0&&t.add(n);return[...t].flatMap(e=>[String(e),`#${e}`])}var xA=e=>`${e.projectId??``}/${e.id}`;function SA(e){let t=e.filter(e=>Yt(e)).sort((e,t)=>(t.finishedAt??``).localeCompare(e.finishedAt??``)),n=new Set(t.map(xA));return{recentlyFinished:t,otherTasks:e.filter(e=>!n.has(xA(e)))}}function CA(e,t,n=[]){let r=Iy(e,n);return[...r.filter(e=>e.id!==t),...r.filter(e=>e.id===t)]}function wA(){let[e,t]=Z.useState(!1),[n,r]=Z.useState(``);Z.useEffect(()=>{e||r(``)},[e]);let i=ds();Xm(`k`,()=>t(e=>!e));let a=Z.useCallback(()=>{t(!1),i(`/new`)},[i]);Xm(`n`,a),$m(`c`,a),Z.useEffect(()=>{let e=()=>t(!0);return window.addEventListener(cA,e),()=>window.removeEventListener(cA,e)},[]);let o=ck(),s=e&&o!==void 0;return(0,Q.jsx)(ks,{open:e,onOpenChange:t,title:`Command palette`,description:`Search projects, tasks, views, actions, and skills`,showCloseButton:!1,filter:dA,value:n,onValueChange:r,className:`${s?o?.kind===`tell`?`top-[2vh]`:`top-auto bottom-[2vh]`:`top-[10vh]`} translate-y-0 sm:max-w-2xl lg:max-w-3xl xl:max-w-4xl`,overlayClassName:s?`bg-transparent`:void 0,contentProps:s?{"data-voice-proposal":`true`}:void 0,children:(0,Q.jsx)(EA,{open:e,docked:s,selected:n,close:()=>t(!1)})})}function TA({task:e,projectName:t,showProject:n,now:r,onSelect:i}){let a=fe(e),o=xn(e);return(0,Q.jsxs)(As,{...pA(e,t),"data-slot":`palette-task`,"data-run-id":e.id,"data-project-id":e.projectId??void 0,onSelect:()=>i(e),children:[(0,Q.jsx)(J_,{tone:a.tone,shape:a.shape,pulse:a.pulse,"aria-label":a.label,role:`img`}),e.delegation?.role===`worker`?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`Worker`}):null,(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:o}),n&&t?(0,Q.jsx)(`span`,{"data-slot":`palette-task-project`,className:`shrink-0 truncate text-xs text-soft-foreground`,children:t}):null,(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-soft-foreground tabular-nums`,children:Io(e.finishedAt??e.createdAt,r)})]})}function EA({open:e,docked:t,selected:n,close:r}){let i=ds(),a=j(),[o,s]=Z.useState(``),c=o.trim()!==``,l=_s(),{theme:u,setTheme:d}=Ny(),f=qt(),p=rr(),m=It(),h=gn(),g=mn(),_=Date.now(),v=rA({enabled:g.data?.capabilities.voice===!0,text:o,selected:n,close:r,clearText:()=>s(``)}),{onClose:y}=v;Z.useEffect(()=>{e||y()},[e,y]);let b=m.data,x=b!==void 0&&b.projects.length>1,S=Gt(x),{order:C}=zy(),w=Z.useMemo(()=>x?CA(b.projects,l,C):[],[x,b,l,C]),T=Z.useMemo(()=>new Map((b?.projects??[]).map(e=>[e.id,e.name])),[b]),E=l??b?.bootProject??null,[D,O]=Z.useState(``);Z.useEffect(()=>{let e=setTimeout(()=>O(o),vA);return()=>clearTimeout(e)},[o]);let k=pn(D),A=c?k.data?.runs:void 0,M=c&&!k.isPlaceholderData?(k.data?.truncated??[]).map(e=>T.get(e)??e):[],N=Z.useMemo(()=>yA(f.data??[],E,S.data?.runs,A),[f.data,E,S.data,A]),P=Z.useMemo(()=>SA(N),[N]),F=c?[]:P.recentlyFinished,I=c?N:P.otherTasks,L=x,ee=e=>e.projectId===null?null:T.get(e.projectId)??null,te=h.data?.skillUsage,ne=Z.useMemo(()=>dc(p.data??[],te),[p.data,te]),R=e=>{r(),i(e)},re=e=>{r(),a(e)},ie=MO(),ae=e=>{r(),ie.go(e)},oe=e=>{r(),i(e.projectId===null?`/tasks/${e.id}`:us(e.projectId,`/tasks/${e.id}`))},se=HO[u],ce=[...x?[{label:`All tasks`,to:`/tasks`,icon:Aa,global:!0}]:[],...PO({forge:g.data?.forge?.available===!0,automations:g.data?.capabilities.automations===!0}).map(e=>({label:e.label,to:e.to,icon:e.icon,global:!1}))],le=[{rows:ce.map(e=>mA(e.label)),node:(0,Q.jsx)(ws,{heading:`Views`,children:ce.map(e=>{let t=e.icon;return(0,Q.jsxs)(As,{...mA(e.label),"data-slot":`palette-view`,"data-nav-to":e.to,onSelect:()=>e.global?re(e.to):R(e.to),children:[(0,Q.jsx)(t,{"aria-hidden":`true`}),e.label]},e.to)})},`views`)}];return w.length>0&&le.push({rows:w.map(hA),node:(0,Q.jsx)(ws,{heading:`Projects`,children:w.map(e=>{let t=e.id===l,n=e.status===`missing`;return(0,Q.jsxs)(As,{...hA(e),"data-slot":`palette-project`,"data-project-id":e.id,disabled:n,onSelect:()=>ae(e.id),children:[(0,Q.jsx)(ja,{"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),n?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-soft-foreground`,children:`folder not found`}):e.branch===void 0?null:(0,Q.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-soft-foreground`,children:e.branch}),t?(0,Q.jsx)(co,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},e.id)})},`projects`)}),I.length>0&&le.push({rows:c?I.map(e=>pA(e,ee(e))):[],node:(0,Q.jsx)(ws,{heading:`Tasks`,children:I.map(e=>(0,Q.jsx)(TA,{task:e,projectName:ee(e),showProject:L,now:_,onSelect:oe},xA(e)))},`tasks`)}),le.push({rows:[_A],node:(0,Q.jsx)(ws,{heading:`Actions`,children:(0,Q.jsxs)(As,{..._A,"data-slot":`palette-action`,"data-action":`toggle-theme`,onSelect:()=>{d(se),r()},children:[(0,Q.jsx)(Ya,{"aria-hidden":`true`}),`Toggle theme`,(0,Q.jsxs)(Ns,{className:`tracking-normal`,children:[u,` → `,se]})]})},`actions`)}),ne.length>0&&le.push({rows:ne.map(gA),node:(0,Q.jsx)(ws,{heading:`Skills`,children:ne.map(e=>(0,Q.jsxs)(As,{...gA(e),"data-slot":`palette-skill`,"data-skill":e.name,onSelect:()=>R(`/new?skill=${encodeURIComponent(e.name)}`),children:[(0,Q.jsx)(`span`,{className:`shrink-0 font-medium`,children:e.name}),e.description?(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null]},e.path))},`skills`)}),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ts,{placeholder:v.confirm?oA:`Search projects, tasks, views, actions, skills…`,value:o,onValueChange:s,onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&v.onEnter(e)}}),(0,Q.jsx)(rc,{className:t?`max-h-[28vh]`:`max-h-[55vh] min-h-[14rem] sm:max-h-[60vh] lg:max-h-[68vh]`,children:v.confirm?(0,Q.jsx)(sA,{confirm:v.confirm,notice:v.row?.kind===`notice`?v.row.text:void 0,onConfirm:v.onConfirm}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(aA,{row:v.row,committable:o.trim()!==``,onSelect:v.onSelect}),v.row?null:(0,Q.jsx)(Cs,{children:`Nothing matches.`}),(0,Q.jsx)(ws,{children:(0,Q.jsxs)(As,{value:`new task`,"data-slot":`palette-view`,"data-nav-to":`/new`,onSelect:()=>R(`/new`),children:[(0,Q.jsx)(Ga,{"aria-hidden":`true`}),`New task`,(0,Q.jsx)(Ns,{children:`C`})]})}),!c&&F.length>0?(0,Q.jsx)(ws,{heading:`Recently finished`,children:F.map(e=>(0,Q.jsx)(TA,{task:e,projectName:ee(e),showProject:L,now:_,onSelect:oe},xA(e)))}):null,fA(le,o).map(e=>e.node)]})}),M.length>0?(0,Q.jsxs)(`p`,{"data-slot":`palette-search-truncated`,role:`status`,className:`border-t border-border px-3 py-2 text-[11px] text-soft-foreground`,children:[`More matches in `,M.join(`, `),`. Type more to narrow them.`]}):null]})}function DA({triggerClassName:e,icon:t=za,iconClassName:n=`size-4`,side:r,origin:i,label:a,iconFrameClassName:o}={}){let[s,c]=Z.useState(!1),[l,u]=Z.useState(!1),[d,f]=Z.useState(!1);return(0,Q.jsxs)(Li,{children:[(0,Q.jsx)(Pi,{asChild:!0,children:(0,Q.jsxs)(O,{variant:`ghost`,"aria-label":`Add project`,title:`Add project`,"data-origin":i,className:k(`size-9 p-0 text-muted-foreground`,e),children:[o?(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:o,children:(0,Q.jsx)(t,{className:n,"aria-hidden":`true`})}):(0,Q.jsx)(t,{className:n,"aria-hidden":`true`}),a?(0,Q.jsx)(`span`,{children:a}):(0,Q.jsx)(`span`,{className:`sr-only`,children:`Add project`})]})}),(0,Q.jsxs)(Fi,{align:`start`,...S({side:r}),className:`w-56`,children:[(0,Q.jsx)(Ci,{className:`text-xs text-soft-foreground`,children:`Add project`}),(0,Q.jsxs)(Ai,{"data-slot":`add-project-new`,onSelect:()=>f(!0),children:[(0,Q.jsx)(za,{"aria-hidden":`true`}),`New project…`]}),(0,Q.jsxs)(Ai,{"data-slot":`add-project-local`,onSelect:()=>c(!0),children:[(0,Q.jsx)(Ma,{"aria-hidden":`true`}),`Open local folder…`]}),(0,Q.jsxs)(Ai,{"data-slot":`add-project-clone`,onSelect:()=>u(!0),children:[(0,Q.jsx)(La,{"aria-hidden":`true`}),`Clone from GitHub…`]})]}),s?(0,Q.jsx)(ab,{open:!0,onOpenChange:c}):null,l?(0,Q.jsx)(DD,{open:!0,onOpenChange:u}):null,d?(0,Q.jsx)(jD,{open:!0,onOpenChange:f}):null]})}function OA(e,t){let n=e=>e.split(`.`).slice(0,3).map(e=>Number.parseInt(e,10)||0),r=n(e),i=n(t);for(let e=0;e<3;e++){let t=(r[e]??0)-(i[e]??0);if(t!==0)return t>0}return!1}function kA({version:e,latestVersion:t,state:n,onApplyUpdate:r,onRestart:i}){let a=n?.status===`ready`,o=n?.status===`preparing`,s=n?.status===`restarting`,c=!!(e&&t&&OA(t,e));return{preparing:o,restarting:s,canRestart:n?.supported&&a&&!!i,canApply:n?.supported&&c&&!!r,ready:a}}function AA(e){let{version:t,latestVersion:n,state:r,busy:i=!1}=e,{preparing:a,restarting:o,canRestart:s,canApply:c,ready:l}=kA(e),u=r?.supported?l||o?`restart`:a||c?`update`:null:null;return{preparing:a,restarting:o,canRestart:s,canApply:c,action:u,actionBusy:i||a||o,tooltip:u===`restart`?`Restart required`:a?`Preparing update`:`Update from v${t} to v${n}`}}function jA({version:e,latestVersion:t,state:n,onApplyUpdate:r,onRestart:i,busy:a=!1,offline:o=!1}){let[s,c]=Z.useState(!1),[l,u]=Z.useState(!1),d=Z.useRef(null),f=Z.useRef(!1),{preparing:p,restarting:m,canRestart:h,canApply:g,action:_,actionBusy:v,tooltip:y}=AA({version:e,latestVersion:t,state:n,onApplyUpdate:r,onRestart:i,busy:a});return _?(0,Q.jsxs)(ra,{open:s,onOpenChange:c,children:[(0,Q.jsx)(`div`,{"data-slot":`application-update-action`,className:`flex size-11 shrink-0 items-center justify-center`,children:_?(0,Q.jsx)(eC,{children:(0,Q.jsxs)(tC,{open:l,onOpenChange:u,children:[(0,Q.jsx)(nC,{asChild:!0,onKeyDown:e=>{e.key===`Tab`&&u(!1)},children:_===`update`?(0,Q.jsx)(O,{variant:`ghost`,size:`icon`,className:`size-11 motion-safe:transition-transform motion-safe:duration-[var(--app-duration-1)] motion-safe:active:scale-[0.97]`,"aria-label":p?`Preparing update`:`Update application`,"aria-busy":v,disabled:!g||v||o,title:y,onClick:()=>{!g||v||o||f.current||(f.current=!0,r?.().finally(()=>{f.current=!1}))},children:(0,Q.jsx)(To,{"aria-hidden":`true`,className:`size-[18px]`})}):(0,Q.jsx)(O,{ref:d,variant:`ghost`,size:`icon`,className:`size-11 motion-safe:transition-transform motion-safe:duration-[var(--app-duration-1)] motion-safe:active:scale-[0.97]`,"aria-label":m?`Reconnecting after restart`:`Restart application`,"aria-busy":v,disabled:!h||v||o,title:y,onClick:()=>c(!0),children:(0,Q.jsx)(Ka,{"aria-hidden":`true`,className:`size-[18px]`})})}),(0,Q.jsx)(rC,{side:`bottom`,children:y})]})}):null}),(0,Q.jsxs)(Yi,{onCloseAutoFocus:e=>{e.preventDefault(),d.current?.focus()},children:[(0,Q.jsxs)(na,{children:[(0,Q.jsx)(Wi,{children:`Restart Cezarion?`}),(0,Q.jsx)(Ui,{children:`Running tasks will be recovered after restart. The cockpit will reconnect when the new version is ready.`})]}),(0,Q.jsxs)($i,{children:[(0,Q.jsx)(ta,{children:`Restart Later`}),(0,Q.jsx)(Qi,{onClick:()=>{!h||v||o||f.current||(f.current=!0,c(!1),i?.().finally(()=>{f.current=!1}))},children:`Restart Now`})]})]})]}):null}function MA({version:e,latestVersion:t,state:n,error:r,offline:i=!1,busy:a=!1}){let o=r??(n?.status===`error`?n.message??`Update failed.`:null),s=n&&!n.supported&&e&&t&&OA(t,e),c=n?.message&&n.message!==`Update this installation manually.`?n.message:`Install the newer release using your original installation method, then restart Cezarion.`,l=o?null:i?`Connection lost. Reconnect to continue.`:n?.status===`preparing`||a&&n?.status!==`ready`?`Preparing update.`:n?.status===`restarting`?`Restarting. Reconnecting to the cockpit.`:a&&n?.status===`ready`?`Checking update status.`:s?`In-app updates are unavailable for this installation. ${c}`:null;return!o&&!l?null:(0,Q.jsx)(`div`,{"data-slot":`application-update-feedback`,className:`px-4 pb-2 text-[11px] leading-4 text-muted-foreground`,children:o?(0,Q.jsxs)(`p`,{role:`status`,children:[(0,Q.jsx)(`span`,{className:`block truncate`,title:o,children:o}),(0,Q.jsx)(`span`,{className:`block`,children:`Retry or update manually.`})]}):l?(0,Q.jsx)(`p`,{role:`status`,title:l,children:l}):null})}var NA={amber:`text-signal-word-amber`,red:`text-signal-word-red`,violet:`text-status-running`,green:`text-success`};function PA({signal:e,known:t,current:n,maxParts:r,slot:i,className:a}){let o=rx(e).slice(0,r);return(0,Q.jsx)(`span`,{"data-slot":i,className:k(`flex min-w-0 items-center font-medium`,n?`text-muted-foreground`:`text-soft-foreground`,a),children:t?o.length===0?`idle`:o.map((e,t)=>(0,Q.jsxs)(`span`,{className:`flex items-center gap-x-[inherit]`,children:[t>0?(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}):null,(0,Q.jsx)(`span`,{"data-tone":e.tone,className:NA[e.tone],children:e.text})]},e.tone)):`activity unknown`})}var FA={amber:`bg-pending text-signal-ink-amber`,red:`bg-danger text-signal-ink`,violet:`bg-status-running text-signal-ink`,green:`bg-success text-signal-ink`};function IA(e,t,n){return e>9&&!(n&&t>1)?22:t===1?18:14}function LA({position:e,segments:t,className:n,compact:r=!1}){let i=t.filter(e=>e.count>0);return i.length===0?null:(0,Q.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`rail-pill-${e}`,className:k(`pointer-events-none absolute -right-[4px] box-border flex h-[17px] overflow-hidden rounded-[9px] border-2 border-background`,e===`top`?`-top-[6px]`:`top-[25px]`,n),children:i.map(({tone:e,count:t})=>(0,Q.jsx)(`span`,{"data-segment":e,"data-count":t,style:{width:IA(t,i.length,r)},className:k(`flex items-center justify-center text-[10px] leading-[13px] font-bold tabular-nums`,FA[e]),children:t>9?`9+`:t},e))})}function RA(e){return{top:[{tone:`amber`,count:e?.needsYou??0},{tone:`red`,count:e?.failedUnread??0}],bottom:[{tone:`violet`,count:e?.inMotion??0},{tone:`green`,count:e?.finishedUnread??0}]}}function zA({...e}){return(0,Q.jsx)(Xi,{"data-slot":`sheet`,...e})}function BA({...e}){return(0,Q.jsx)(qi,{"data-slot":`sheet-trigger`,...e})}function VA({...e}){return(0,Q.jsx)(ia,{"data-slot":`sheet-close`,...e})}function HA({...e}){return(0,Q.jsx)(Zi,{"data-slot":`sheet-portal`,...e})}function UA({className:e,...t}){return(0,Q.jsx)(ea,{"data-slot":`sheet-overlay`,className:k(`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 WA({className:e,children:t,side:n=`right`,showCloseButton:r=!0,overlayClassName:i,...a}){return(0,Q.jsxs)(HA,{children:[(0,Q.jsx)(UA,{className:i}),(0,Q.jsxs)(Gi,{"data-slot":`sheet-content`,className:k(`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),...a,children:[t,r&&(0,Q.jsxs)(ia,{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,Q.jsx)(uo,{className:`size-4`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function GA({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`sheet-header`,className:k(`flex flex-col gap-1.5 p-4`,e),...t})}function KA({className:e,...t}){return(0,Q.jsx)(Ji,{"data-slot":`sheet-title`,className:k(`font-semibold text-foreground`,e),...t})}function qA({className:e,...t}){return(0,Q.jsx)(Ki,{"data-slot":`sheet-description`,className:k(`text-sm text-muted-foreground`,e),...t})}function JA(e,t){if(!e?.signals)return null;let n=e.signals;return ix(e.projects.filter(e=>e.id!==t).map(e=>n.get(e.id)))}function YA(e){let t=rx(e??void 0).map(e=>e.text);return t.length>0?`Open projects. Elsewhere: ${t.join(`, `)}`:`Open projects`}function XA({elsewhere:e}){if(!e)return null;let{top:t,bottom:n}=RA(e),r=`right-[2px] border-card`;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(LA,{position:`top`,segments:t,compact:!0,className:k(r,`top-[3px]`)}),(0,Q.jsx)(LA,{position:`bottom`,segments:n,compact:!0,className:k(r,`top-[24px]`)})]})}function ZA({version:e}){let{resolvedTheme:t}=Ny();return(0,Q.jsxs)(`div`,{"data-slot":`drawer-identity`,className:`flex shrink-0 items-center gap-[12px] border-b border-border pt-[env(safe-area-inset-top)] pr-[14px] pb-[14px] pl-[18px]`,children:[(0,Q.jsx)(`img`,{src:`/cezarion-mark-${t}.svg`,alt:``,"aria-hidden":`true`,className:`mt-[14px] size-[32px] rounded-lg`}),(0,Q.jsx)(`span`,{className:`mt-[14px] text-[18px] leading-none font-bold tracking-[-0.02em] text-foreground`,children:`Cezarion`}),e?(0,Q.jsxs)(`span`,{"data-slot":`drawer-version`,title:`v${e}`,className:`mt-[14px] min-w-0 truncate text-[11px] leading-none text-soft-foreground`,children:[`v`,e]}):null,(0,Q.jsx)(VA,{asChild:!0,children:(0,Q.jsx)(O,{variant:`ghost`,size:`icon`,"aria-label":`Close menu`,className:`mt-[14px] ml-auto size-[44px] text-foreground`,children:(0,Q.jsx)(uo,{className:`size-[19px]`,"aria-hidden":`true`})})})]})}function QA({version:e,latestVersion:t,...n}){let r=n.state?.status===`ready`||n.state?.status===`preparing`||n.state?.status===`restarting`;if(!(e&&t&&OA(t,e))&&!r)return null;let i=n.state?.status,a=i===`preparing`?`Preparing update…`:i===`ready`||i===`restarting`?`Restart to finish updating`:`Update available · v${t}`;return(0,Q.jsxs)(`div`,{"data-slot":`drawer-update`,className:`shrink-0 border-b border-border px-[18px] py-[6px]`,children:[(0,Q.jsxs)(`div`,{className:`flex min-h-[44px] items-center gap-[8px]`,children:[(0,Q.jsx)(J_,{tone:`pending`,className:`size-[6px] shrink-0`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] font-medium text-foreground`,children:a}),(0,Q.jsx)(jA,{version:e,latestVersion:t,...n})]}),(0,Q.jsx)(MA,{version:e,latestVersion:t,state:n.state,error:n.error,offline:n.offline,busy:n.busy})]})}function $A({project:e,signal:t,known:n,current:r,onNavigate:i}){let{top:a,bottom:o}=RA(t),s=r?`border-sidebar-row-selected`:`border-sidebar`,c=`right-[-4px]`,l=(0,Q.jsxs)(T,{to:us(e.id,`/`),onClick:i,"data-slot":`drawer-project`,"data-project-id":e.id,"aria-current":r?`page`:void 0,className:k(`flex h-[64px] min-w-0 items-center gap-[12px] rounded-[10px] px-[10px] text-foreground hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,r&&`flex-1 hover:bg-sidebar-row-selected`),children:[(0,Q.jsxs)(`span`,{"aria-hidden":`true`,className:k(`relative flex size-[40px] shrink-0 items-center justify-center rounded-[10px] border text-[13px] leading-none font-semibold`,r?`border-soft-foreground bg-sidebar text-foreground`:`border-transparent bg-muted text-muted-foreground`),children:[ax(e.name),(0,Q.jsx)(LA,{position:`top`,segments:a,className:k(c,s)}),(0,Q.jsx)(LA,{position:`bottom`,segments:o,className:k(c,s,`top-[29px]`)})]}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,Q.jsx)(`span`,{className:`truncate text-[14.5px] leading-tight font-semibold`,children:e.name}),(0,Q.jsx)(PA,{signal:t,known:n,current:r,slot:`drawer-project-state`,className:`flex-wrap gap-x-[6px] text-[11.5px] leading-tight`})]}),r?(0,Q.jsx)(co,{"aria-hidden":`true`,className:`size-[16px] shrink-0 text-foreground`}):null]});return r?(0,Q.jsxs)(`div`,{"data-slot":`drawer-project-current`,className:`flex items-center rounded-[10px] bg-sidebar-row-selected pr-[4px]`,children:[l,(0,Q.jsx)(ux,{projectId:e.id,onNavigate:i,triggerClassName:`size-[44px]`,align:`end`})]}):l}var ej=`flex h-[48px] w-full items-center gap-[12px] rounded-[10px] px-[10px] text-[14.5px] font-normal text-foreground hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring [&_svg]:size-[18px] [&_svg]:shrink-0 [&_svg]:text-soft-foreground`;function tj({nav:e,currentProjectId:t,onNavigate:n}){return(0,Q.jsxs)(`div`,{"data-slot":`drawer-projects`,className:`shrink-0`,children:[(0,Q.jsx)(`div`,{className:`px-[18px] pt-[14px] pb-[6px] text-[12px] font-medium text-soft-foreground`,id:`drawer-projects-label`,children:`Projects`}),(0,Q.jsx)(`div`,{role:`group`,"data-slot":`drawer-projects-group`,"aria-labelledby":`drawer-projects-label`,className:`flex flex-col gap-[2px] px-[8px] pb-[8px]`,children:e.projects.map(r=>(0,Q.jsx)($A,{project:r,signal:e.signals?.get(r.id),known:e.signals!==null,current:r.id===t,onNavigate:n},r.id))}),e.singleProject?null:(0,Q.jsxs)(`div`,{"data-slot":`drawer-workspace`,className:`flex flex-col gap-[2px] border-t border-border px-[8px] py-[8px]`,children:[(0,Q.jsxs)(T,{to:`/tasks`,onClick:n,"data-slot":`drawer-all-projects`,className:ej,children:[(0,Q.jsx)(Aa,{"aria-hidden":`true`}),`All projects · task overview`]}),(0,Q.jsx)(DA,{origin:`mobile`,icon:za,iconClassName:`size-[18px]`,label:`Add project`,triggerClassName:k(ej,`h-[48px] justify-start p-0 px-[10px] text-foreground`)})]})]})}function nj({onNavigate:e,tools:t}){let{theme:n,setTheme:r}=Ny(),i=HO[n],a=n.charAt(0).toUpperCase()+n.slice(1);return(0,Q.jsxs)(`div`,{"data-slot":`drawer-global`,className:`flex shrink-0 flex-col gap-[2px] border-t border-border px-[8px] pt-[8px] pb-[max(8px,env(safe-area-inset-bottom))]`,children:[t?(0,Q.jsxs)(T,{to:`/tools`,onClick:e,"data-slot":`drawer-tools`,"aria-label":t.blocked?`Tools, needs setup`:void 0,"aria-describedby":t.blocked&&t.note?`drawer-tools-note`:void 0,className:k(ej,t.note&&`h-auto min-h-[48px] py-[6px]`),children:[(0,Q.jsxs)(`span`,{className:`relative flex shrink-0`,children:[(0,Q.jsx)(ho,{"aria-hidden":`true`}),t.blocked?(0,Q.jsx)(J_,{tone:`pending`,"data-slot":`drawer-tools-dot`,className:`absolute -top-[2px] -right-[3px] ring-[1.5px] ring-sidebar`}):null]}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsx)(`span`,{children:`Tools`}),t.note?(0,Q.jsx)(`span`,{id:`drawer-tools-note`,"data-slot":`drawer-tools-note`,className:`text-[11.5px] leading-tight text-soft-foreground`,children:t.note}):null]})]}):null,(0,Q.jsxs)(T,{to:`/settings/global/appearance`,onClick:e,"data-slot":`drawer-global-settings`,className:ej,children:[(0,Q.jsx)(Oa,{"aria-hidden":`true`}),`Global settings`]}),(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`theme-toggle`,"data-theme-pref":n,"aria-label":`Theme: ${n.toLowerCase()}. Switch to ${i}.`,onClick:()=>r(i),className:ej,children:[(0,Q.jsx)(Ya,{"aria-hidden":`true`}),`Theme · `,a]})]})}var rj=Z.createContext(null);function ij(){return Z.useContext(rj)}function aj({slot:e,children:t}){return(0,su.createPortal)(t,e)}var oj=`(min-width: 768px)`;function sj(){let[e,t]=Z.useState(()=>window.matchMedia?.(oj).matches??!0);return Z.useEffect(()=>{let e=window.matchMedia?.(oj);if(!e)return;let n=()=>t(e.matches);return n(),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var cj=[`/git`,`/automations`,`/workflows`,`/reports`];function lj({items:e,activeTo:t,needsYou:n=!1,onNavigate:r}){let[i,a]=(0,Z.useState)(!1),o=(0,Z.useRef)(null),s=e.filter(e=>cj.includes(e.to)),c=e.filter(e=>!s.includes(e)),l=s.some(e=>e.to===t);return(0,Q.jsx)(eC,{children:(0,Q.jsxs)(`nav`,{ref:o,"aria-label":`Main`,"data-slot":`view-tabs`,onKeyDown:e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;let t=Array.from(o.current?.querySelectorAll(`[data-view-tab]`)??[]),n=t.indexOf(document.activeElement);n<0||(e.preventDefault(),t[e.key===`Home`?0:e.key===`End`?t.length-1:(n+(e.key===`ArrowRight`?1:-1)+t.length)%t.length]?.focus())},className:`flex shrink-0 items-center justify-between max-md:justify-start max-md:gap-1 max-md:overflow-x-auto border-b border-border px-3 pt-2.5 pb-2`,children:[c.map(e=>{let i=e.to===t,a=e.icon,o=e.to===`/`&&n&&!i;return(0,Q.jsxs)(tC,{children:[(0,Q.jsx)(nC,{asChild:!0,children:(0,Q.jsxs)(Y,{to:e.to,onClick:r,"data-view-tab":!0,"aria-label":e.label,"aria-current":i?`page`:void 0,className:k(`relative flex h-[30px] min-w-0 items-center justify-center rounded-[7px] text-soft-foreground hover:bg-sidebar-row-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11 max-md:min-w-11`,i?`shrink-0 gap-1.5 bg-sidebar-row-selected px-[9px] text-[12px] font-semibold text-foreground`:`w-7 shrink-0`),children:[(0,Q.jsxs)(`span`,{className:`relative`,children:[(0,Q.jsx)(a,{className:`size-[15px] shrink-0`,"aria-hidden":`true`}),o?(0,Q.jsx)(`span`,{"aria-label":`Tasks need you`,"data-slot":`nav-needs-you-dot`,className:`absolute -top-1 -right-1 size-[7px] rounded-full border-[1.5px] border-sidebar bg-pending-strong`}):null]}),i?(0,Q.jsx)(`span`,{className:`truncate`,children:e.label}):null]})}),(0,Q.jsx)(rC,{side:`bottom`,sideOffset:6,style:{pointerEvents:`none`},children:e.label})]},e.to)}),s.length?(0,Q.jsxs)(Li,{open:i,onOpenChange:a,children:[(0,Q.jsxs)(tC,{children:[(0,Q.jsx)(nC,{asChild:!0,children:(0,Q.jsx)(Pi,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,"data-view-tab":!0,"aria-label":`More views`,"data-active":l?`true`:void 0,className:k(`relative flex h-[30px] w-7 shrink-0 items-center justify-center rounded-[7px] text-soft-foreground hover:bg-sidebar-row-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11 max-md:min-w-11`,(i||l)&&`bg-sidebar-row-selected text-foreground`),children:(0,Q.jsx)(Gp,{className:`size-[15px]`,"aria-hidden":`true`})})})}),(0,Q.jsx)(rC,{side:`bottom`,sideOffset:6,style:{pointerEvents:`none`},children:`More views`})]}),(0,Q.jsx)(Fi,{align:`end`,sideOffset:4,className:`w-48 rounded-[10px] border-border bg-sidebar p-[5px] shadow-[0_10px_28px_#00000047]`,children:s.map(e=>{let n=e.icon,i=e.to===t;return(0,Q.jsx)(Ai,{asChild:!0,className:k(`h-8 max-md:min-h-11 gap-2.5 rounded-md px-[9px] text-[13px] text-foreground focus:bg-sidebar-row-hover`,i&&`bg-sidebar-row-selected font-medium`),children:(0,Q.jsxs)(Y,{to:e.to,onClick:r,"aria-current":i?`page`:void 0,children:[(0,Q.jsx)(n,{className:`size-[15px] text-soft-foreground`}),e.label]})},e.to)})})]}):null]})})}function uj(e,t,n){let r=hs(e),i=r===`/new`,a=RO(e);return{activeTo:i?`/new`:IO(r),current:LO(r),currentProjectId:fs(e),newTask:i,pushed:a,showTabBar:!a&&!zO(e,t)&&!n,gitRepositoryView:r===`/git`&&new URLSearchParams(t).get(`view`)===`repo`}}var dj=[{to:`/git`,label:`Git`},{to:`/skills`,label:`Skills`},{to:`/workflows`,label:`Workflows`},{to:`/reports`,label:`Reports`},{to:`/settings`,label:`Project settings`}],fj=[`/automations`],pj=`flex h-[50px] min-h-11 w-full items-center gap-[14px] rounded-[10px] px-[10px] text-[14.5px] text-foreground hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:outline-ring [&_svg]:size-[18px] [&_svg]:shrink-0 [&_svg]:text-muted-foreground`;function mj({open:e,onOpenChange:t,onCloseAutoFocus:n,projectName:r,items:i,activeTo:a}){let o=new Map(i.map(e=>[e.to,e])),s=dj.flatMap(({to:e,label:t})=>{let n=o.get(e);return n?[{to:e,label:t,icon:n.icon}]:[]}),c=fj.flatMap(e=>{let t=o.get(e);return t?[{to:e,label:t.label,icon:t.icon}]:[]}),l=()=>t(!1),u=({to:e,label:t,icon:n})=>{let r=e===a;return(0,Q.jsxs)(Y,{to:e,onClick:l,"data-slot":`more-row`,"data-more-row":e,"aria-current":r?`page`:void 0,className:k(pj,r&&`bg-sidebar-row-selected hover:bg-sidebar-row-selected`),children:[(0,Q.jsx)(n,{"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t}),(0,Q.jsx)($a,{"aria-hidden":`true`,className:`!size-[15px]`})]},e)};return(0,Q.jsx)(zA,{open:e,onOpenChange:t,children:(0,Q.jsxs)(WA,{side:`bottom`,"data-slot":`more-sheet`,showCloseButton:!1,onCloseAutoFocus:n,"aria-describedby":void 0,className:`gap-0 rounded-t-[20px] border-border bg-sidebar px-[14px] pt-[10px] pb-[max(14px,env(safe-area-inset-bottom))] md:hidden`,children:[(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:`mx-auto mb-[14px] h-[5px] w-[36px] rounded-[3px] bg-border`}),(0,Q.jsxs)(`div`,{className:`flex items-baseline gap-[10px] px-[10px] pb-[6px]`,children:[(0,Q.jsx)(KA,{className:`text-[17px] leading-tight font-bold`,children:`More`}),r?(0,Q.jsx)(`span`,{"data-slot":`more-project`,className:`min-w-0 truncate text-[12.5px] text-soft-foreground`,children:r}):null]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-[2px]`,children:s.map(u)}),c.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{role:`separator`,className:`mx-[10px] mt-[8px] border-t border-border`}),(0,Q.jsx)(`div`,{className:`px-[10px] pt-[12px] pb-[4px] text-[12px] font-medium text-soft-foreground`,children:`Shown when their flag is on`}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-[2px]`,children:c.map(u)})]}):null]})})}var hj=`(min-width: 768px)`;function gj({items:e,activeTo:t,signal:n,projectName:r,showNewTask:i=!0}){let[o,s]=Z.useState(!1),c=Z.useRef(null),{pathname:l}=a();Z.useEffect(()=>{s(!1)},[l]),Z.useEffect(()=>{let e=window.matchMedia?.(hj);if(!e)return;e.matches&&s(!1);let t=e=>{e.matches&&s(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let u=e.filter(e=>BO.includes(e.to)),d=t!==null&&VO.includes(t),{top:f}=RA(n),p=f.some(e=>e.count>0),m=e=>k(`relative flex h-full min-h-11 min-w-11 flex-1 flex-col items-center justify-center gap-[3px] text-[10.5px] leading-none focus-visible:outline-2 focus-visible:outline-ring`,e?`font-semibold text-foreground`:`font-medium text-soft-foreground`);return(0,Q.jsxs)(Q.Fragment,{children:[i?(0,Q.jsxs)(Y,{to:`/new`,"data-slot":`mobile-new-task`,className:`absolute right-4 bottom-full z-30 mb-4 flex h-12 items-center gap-2 rounded-[24px] bg-foreground px-[18px] text-[14px] font-semibold text-background shadow-[0_8px_24px_#00000055] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:[(0,Q.jsx)(Ga,{"aria-hidden":`true`,className:`size-[18px]`}),`New task`]}):null,(0,Q.jsxs)(`nav`,{"aria-label":`Views`,"data-slot":`mobile-tab-bar`,className:`flex h-[54px] items-stretch`,children:[u.map(e=>{let n=e.to===t,r=e.icon,i=e.to===`/`&&p;return(0,Q.jsxs)(Y,{to:e.to,"data-tab":e.to,"aria-current":n?`page`:void 0,className:m(n),children:[(0,Q.jsxs)(`span`,{className:`relative`,children:[(0,Q.jsx)(r,{"aria-hidden":`true`,className:`size-[21px]`}),i?(0,Q.jsx)(LA,{position:`top`,segments:f,className:`-top-[6px] -right-[10px] border-sidebar`}):null]}),e.label]},e.to)}),(0,Q.jsxs)(`button`,{ref:c,type:`button`,"data-tab":`more`,"aria-haspopup":`dialog`,"aria-expanded":o,"data-active":d?`true`:void 0,onClick:()=>s(!0),className:m(d),children:[(0,Q.jsx)(`span`,{className:`relative`,children:(0,Q.jsx)(Ha,{"aria-hidden":`true`,className:`size-[21px]`})}),`More`]})]}),(0,Q.jsx)(mj,{open:o,onOpenChange:s,onCloseAutoFocus:e=>{c.current?.isConnected&&(e.preventDefault(),c.current.focus())},projectName:r,items:e,activeTo:t})]})}var _j=`cez-sidebar-width`;function vj(e){let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?Math.min(420,Math.max(264,Math.round(t))):264}function yj(){try{let e=localStorage.getItem(_j);return e===null?264:vj(e)}catch{return 264}}function bj(e){try{localStorage.setItem(_j,String(vj(e)))}catch{}}var xj=`(min-width: 768px)`,Sj=Z.createContext(264),Cj=Z.createContext(void 0);function wj(){return Z.useContext(Cj)}function Tj(e){return m({path:`/tasks/:id`,end:!0},hs(e))!==null}function Ej(e){let t=hs(e);return t===`/github`||t.startsWith(`/github/`)}function Dj({children:e,breadcrumb:t,repo:n=null,version:r=null,latestVersion:i=null,applicationUpdate:o,onApplyUpdate:s,onRestart:c,applicationUpdateError:l,applicationUpdateBusy:u,applicationUpdateOffline:f,sidebarList:p,taskQuickList:m,sessionScope:h,toolsMenu:g,forgeAvailable:_=!0,automationsAvailable:v=!0,banner:y,mobileProjects:b,projectHeader:x,sidebarProjectId:S,needsYou:C,projectRail:w,toolsStatus:T}){let{pathname:E,search:D}=a(),{activeTo:O,current:A,currentProjectId:j,newTask:M,pushed:N,showTabBar:P,gitRepositoryView:F}=uj(E,D,wa()),[I,L]=Z.useState(!1),[ee,te]=Z.useState(null),ne=Z.useRef(null),R=Z.useRef(null),re=Z.useRef(null),ie=Tj(E);Z.useLayoutEffect(()=>{let e=re.current;if(re.current=E,ie||e!==null&&fs(e)===fs(E)&&Ej(e)&&Ej(E))return;let t=R.current;t&&(t.scrollTop=0)},[E,ie,F]);let ae=d(),oe=Z.useRef(E);Z.useEffect(()=>{let e=oe.current;oe.current=E,e!==E&&(ae===`REPLACE`&&Pj(e,E)||L(!1))},[E,ae]),Z.useEffect(()=>{let e=window.matchMedia?.(xj);if(!e)return;e.matches&&L(!1);let t=e=>{e.matches&&L(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let se=PO({forge:_,automations:v}),ce={version:r,latestVersion:i,state:o,onApplyUpdate:s,onRestart:c,error:l,busy:u,offline:f};return(0,Q.jsxs)(zA,{open:I,onOpenChange:L,children:[bp()?(0,Q.jsx)(xp,{}):null,(0,Q.jsxs)(`div`,{"data-slot":`app-shell`,style:bp()?{paddingTop:28}:void 0,className:`flex h-dvh overflow-hidden bg-background text-foreground pl-[env(safe-area-inset-left)] pr-[env(safe-area-inset-right)]`,children:[(0,Q.jsx)(Aj,{projectRail:w,activeTo:O,items:se,repo:n,update:ce,sidebarList:p,taskQuickList:m,sessionScope:h,toolsMenu:g,projectHeader:x,sidebarProjectId:S,needsYou:C}),(0,Q.jsx)(Nj,{update:ce,taskQuickList:m,sidebarProjectId:S,mobileProjects:b,currentProjectId:j,toolsStatus:T,onNavigate:()=>L(!1),onCloseAutoFocus:e=>{ne.current?.isConnected&&(e.preventDefault(),ne.current.focus())}}),(0,Q.jsxs)(`div`,{className:`grid min-w-0 flex-1 grid-rows-[auto_auto_1fr_auto] overflow-hidden`,children:[(0,Q.jsx)(Bj,{title:A?.label??`cezar`,pushed:N?{onSlot:te}:null,repo:n,elsewhere:JA(b,j),onTrigger:e=>{ne.current=e}}),(0,Q.jsx)(Oj,{breadcrumb:t,repo:n,label:A?.label,newTask:M}),y?(0,Q.jsx)(`div`,{"data-slot":`banner-slot`,className:`row-start-2`,children:y}):null,(0,Q.jsx)(`main`,{ref:R,"data-slot":`main`,className:k(`row-start-3 min-h-0 overflow-y-auto overscroll-contain`,P&&!M&&`max-md:pb-20`),children:(0,Q.jsx)(rj.Provider,{value:N?ee:null,children:e})}),(0,Q.jsx)(kj,{showTabBar:P,items:se,activeTo:O,mobileProjects:b,currentProjectId:j,repo:n,newTask:M})]})]})]})}function Oj({breadcrumb:e,repo:t,label:n,newTask:r}){let i=e?.project??t?.name,a=e?.branch??t?.branch;return(0,Q.jsxs)(`header`,{"data-slot":`desktop-breadcrumb`,className:k(`row-start-1 hidden min-w-0 items-center gap-3 border-b border-border text-[13px] text-muted-foreground md:flex`,r?`h-[72px] px-11`:`h-16 px-9`),children:[(0,Q.jsx)(Ma,{"aria-hidden":`true`,className:`size-4 shrink-0`}),i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`truncate font-medium text-foreground`,children:i}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`/`})]}):null,(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:e?.page??n??`Cezarion`}),a?(0,Q.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 text-[11px]`,children:[(0,Q.jsx)(xo,{"aria-hidden":`true`,className:`size-4 text-accent-text`}),a]}):null]})}function kj({showTabBar:e,items:t,activeTo:n,mobileProjects:r,currentProjectId:i,repo:a,newTask:o}){let s=i===null?void 0:r?.signals?.get(i);return(0,Q.jsx)(`div`,{"data-slot":`composer`,className:k(`row-start-4 pb-[max(env(safe-area-inset-bottom),var(--kb,0px))]`,e&&`relative max-md:border-t max-md:border-border max-md:bg-sidebar`),children:e?(0,Q.jsx)(`div`,{className:`md:hidden`,children:(0,Q.jsx)(gj,{items:t,activeTo:n,signal:s,projectName:r?.projects.find(e=>e.id===i)?.name??a?.name??null,showNewTask:!o})}):null})}function Aj({projectRail:e,...t}){let[n,r]=Z.useState(yj),i=Z.useCallback(e=>{let t=vj(e);r(t),bj(t)},[]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Sj.Provider,{value:n,children:e}),(0,Q.jsx)(jj,{...t,width:n,onWidthChange:i})]})}function jj({width:e,onWidthChange:t,...n}){return(0,Q.jsxs)(`aside`,{"data-slot":`sidebar`,style:{width:e},className:`relative hidden shrink-0 flex-col border-r border-border bg-sidebar md:flex`,children:[(0,Q.jsx)(Ij,{...n}),(0,Q.jsx)(Mj,{width:e,onWidthChange:t})]})}function Mj({width:e,onWidthChange:t}){let n=Z.useRef(null),r=t=>{t.button===0&&(n.current={x:t.clientX,width:e},t.currentTarget.setPointerCapture(t.pointerId),t.preventDefault(),t.currentTarget.focus())},i=e=>{let r=n.current;r&&t(vj(r.width+(e.clientX-r.x)))},a=e=>{n.current&&(n.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))};return(0,Q.jsx)(`div`,{"data-slot":`sidebar-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the sidebar`,"aria-valuenow":e,"aria-valuemin":264,"aria-valuemax":420,tabIndex:0,onPointerDown:r,onPointerMove:i,onPointerUp:a,onPointerCancel:a,onKeyDown:n=>{let r=n.key===`ArrowLeft`?e-16:n.key===`ArrowRight`?e+16:n.key===`Home`?264:n.key===`End`?420:null;r!==null&&(n.preventDefault(),t(vj(r)))},onDoubleClick:()=>t(264),title:`Drag to resize the sidebar — double-click to reset`,className:`absolute inset-y-0 -right-[2px] z-20 w-[5px] cursor-col-resize touch-none bg-transparent transition-colors hover:bg-[var(--composer-border)] focus-visible:bg-[var(--composer-border)] focus-visible:outline-none`})}function Nj({onNavigate:e,onCloseAutoFocus:t,mobileProjects:n,currentProjectId:r,toolsStatus:i,update:a,taskQuickList:o,sidebarProjectId:s}){return(0,Q.jsxs)(WA,{side:`left`,"data-slot":`mobile-nav-drawer`,onCloseAutoFocus:t,overlayClassName:`bg-[var(--nav-scrim)]`,showCloseButton:!1,className:`w-[calc(100%-68px)] max-w-[334px] gap-0 border-border bg-sidebar p-0 sm:max-w-[334px] md:hidden`,"aria-describedby":void 0,children:[(0,Q.jsx)(KA,{className:`sr-only`,children:`Navigation`}),(0,Q.jsx)(ZA,{version:a.version}),(0,Q.jsx)(QA,{...a}),(0,Q.jsxs)(`div`,{"data-slot":`drawer-scroll`,className:`flex min-h-0 flex-1 flex-col overflow-y-auto overscroll-contain`,children:[n?(0,Q.jsx)(tj,{nav:n,currentProjectId:r,onNavigate:e}):null,o?(0,Q.jsx)(Fj,{projectId:s,onNavigate:e,children:(0,Q.jsx)(`div`,{"data-slot":`drawer-tasks`,className:`border-t border-border px-[8px] py-[8px]`,children:o})}):null]}),(0,Q.jsx)(nj,{onNavigate:e,tools:i})]})}function Pj(e,t){return fs(e)==="default"&&fs(t)!==null&&fs(t)!=="default"&&hs(e)===hs(t)}function Fj({projectId:e,onNavigate:t,children:n}){let r=mt(),i=e===void 0?r:{projectId:e,apiBase:`${l}/p/${encodeURIComponent(e)}`};return(0,Q.jsx)(yt.Provider,{value:i,children:(0,Q.jsx)(Cj.Provider,{value:t,children:n})})}function Ij({activeTo:e,items:t,repo:n,update:r,sidebarList:i,taskQuickList:a,sessionScope:o,toolsMenu:s,projectHeader:c,sidebarProjectId:l,needsYou:u,onNavigate:d}){return(0,Q.jsx)(Fj,{projectId:l,onNavigate:d,children:(0,Q.jsxs)(`div`,{"data-slot":`sidebar-content`,className:`@container/sidebar flex min-h-0 flex-1 flex-col pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)]`,children:[(0,Q.jsx)(`div`,{"data-slot":`sidebar-header`,className:`shrink-0`,children:c??(n?(0,Q.jsxs)(`div`,{className:`px-[14px] pt-[14px] pb-2.5`,children:[(0,Q.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:n.name}),(0,Q.jsx)(`div`,{className:`truncate font-mono text-[10.5px] text-soft-foreground`,children:n.branch})]}):null)}),(0,Q.jsxs)(`div`,{"data-slot":`sidebar-actions`,className:`flex flex-col gap-2 px-3`,children:[(0,Q.jsx)(Rj,{}),(0,Q.jsx)(O,{asChild:!0,variant:`ghost`,className:k(`relative h-[32px] max-md:min-h-11 rounded-[7px] bg-muted w-full min-w-0 justify-start gap-2 px-2.5 text-[12.5px] font-medium text-foreground hover:bg-sidebar-row-hover hover:text-foreground`,e===`/new`&&`bg-sidebar-row-selected text-foreground font-medium hover:bg-sidebar-row-selected`),children:(0,Q.jsxs)(Y,{to:`/new`,onClick:d,"data-sidebar-item":`new-task`,"aria-current":e===`/new`?`page`:void 0,children:[(0,Q.jsx)(Ga,{className:`size-[15px]`,"aria-hidden":`true`}),`New task`,(0,Q.jsx)(`kbd`,{"aria-hidden":`true`,className:`sr-only`,children:`C`})]})})]}),o?(0,Q.jsx)(`div`,{className:`shrink-0 px-3 pt-2`,children:o}):null,(0,Q.jsx)(lj,{items:t,activeTo:e,needsYou:u,onNavigate:d}),(0,Q.jsx)(`div`,{"data-slot":`project-task-navigation`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-3`,children:(0,Q.jsx)(Cj.Provider,{value:d,children:i??(0,Q.jsx)(`div`,{"data-slot":`task-quick-list`,children:a})})}),(0,Q.jsx)(Lj,{toolsMenu:s,update:r})]})})}function Lj({toolsMenu:e,update:t}){return(0,Q.jsxs)(`div`,{"data-slot":`sidebar-footer`,className:`shrink-0`,children:[(0,Q.jsxs)(`div`,{"data-slot":`sidebar-footer-controls`,className:`flex h-11 items-center justify-between gap-1 border-t border-border px-3`,children:[(0,Q.jsx)(`div`,{"data-slot":`tools-menu`,className:`shrink-0`,children:e}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,"data-slot":`version-action`,children:[t.version?(0,Q.jsx)(zj,{version:t.version,latestVersion:t.latestVersion}):null,(0,Q.jsx)(jA,{...t})]})]}),(0,Q.jsx)(MA,{...t})]})}function Rj(){return(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`command-palette-hint`,title:`Search — command palette (⌘K / Ctrl+K)`,onClick:()=>lA(),className:`flex h-[32px] max-md:min-h-11 w-full items-center gap-2 rounded-[7px] border border-border bg-background px-2.5 text-left text-[12.5px] font-normal text-soft-foreground transition-colors hover:border-border hover:text-foreground`,children:[(0,Q.jsx)(Ba,{className:`size-[14px] shrink-0`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`truncate`,children:`Search…`}),(0,Q.jsx)(`kbd`,{"aria-hidden":`true`,className:`ml-auto shrink-0 font-sans text-[11px] font-normal text-soft-foreground`,children:Qm(`k`)})]})}function zj({version:e,latestVersion:t}){let n=!!(t&&OA(t,e));return(0,Q.jsxs)(`span`,{"data-slot":`version-chip`,"data-update-available":n?`true`:void 0,title:n?`v${e} — update available: v${t}`:`v${e}`,className:`flex min-w-0 items-center gap-1 font-mono text-[11px] text-soft-foreground`,children:[n?(0,Q.jsx)(J_,{tone:`pending`,className:`size-[5px] shrink-0`}):null,(0,Q.jsxs)(`span`,{className:`truncate`,children:[`v`,e]})]})}function Bj({title:e,pushed:t,repo:n,elsewhere:r,onTrigger:i}){return t?(0,Q.jsx)(Vj,{onSlot:t.onSlot}):(0,Q.jsx)(`header`,{"data-slot":`mobile-top-bar`,className:`row-start-1 min-w-0 border-b border-border bg-card pt-[env(safe-area-inset-top)] md:hidden`,children:(0,Q.jsxs)(`div`,{className:`flex h-[56px] min-w-0 items-center gap-[8px] px-[8px]`,children:[(0,Q.jsx)(BA,{asChild:!0,children:(0,Q.jsxs)(O,{variant:`ghost`,"aria-label":YA(r),onClick:e=>i(e.currentTarget),className:`relative h-[44px] w-[64px] shrink-0 justify-start rounded-md p-0 pl-[10px] text-foreground`,children:[(0,Q.jsx)(Na,{className:`size-[20px]`,"aria-hidden":`true`}),(0,Q.jsx)(XA,{elsewhere:r})]})}),n?(0,Q.jsx)(BA,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`mobile-project-picker`,"aria-label":`Switch project: ${n.name}`,onClick:e=>i(e.currentTarget),className:`flex h-[44px] min-w-0 flex-1 items-center justify-start gap-[10px] rounded-md text-left focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`flex size-[28px] shrink-0 items-center justify-center rounded-[8px] border border-soft-foreground bg-sidebar-row-selected text-[11px] leading-none font-semibold text-foreground`,children:ax(n.name)}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsx)(`span`,{className:`truncate text-[15px] leading-tight font-semibold text-foreground`,children:n.name}),n.branch?(0,Q.jsx)(`span`,{className:`truncate font-mono text-[10.5px] leading-tight text-soft-foreground`,children:n.branch}):null]}),(0,Q.jsx)(So,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-soft-foreground`})]})}):null,e===`cezar`?n?null:(0,Q.jsx)(`span`,{className:`flex-1`}):(0,Q.jsx)(`span`,{"data-slot":`mobile-route-title`,className:k(`truncate text-[15px] font-semibold text-foreground`,n?`sr-only`:`min-w-0 flex-1 pl-[8px]`),children:e}),(0,Q.jsx)(O,{variant:`ghost`,"aria-label":`Search`,"data-slot":`mobile-search`,onClick:()=>lA(),className:`ml-auto size-[44px] shrink-0 p-0 text-foreground`,children:(0,Q.jsx)(Ba,{className:`size-[19px]`,"aria-hidden":`true`})})]})})}function Vj({onSlot:e}){let t=ds();return(0,Q.jsx)(`header`,{"data-slot":`mobile-top-bar`,"data-mode":`task`,className:`row-start-1 min-w-0 border-b border-border bg-card pt-[env(safe-area-inset-top)] md:hidden`,children:(0,Q.jsxs)(`div`,{className:`flex h-[56px] min-w-0 items-center gap-[4px] px-[8px]`,children:[(0,Q.jsx)(O,{variant:`ghost`,"aria-label":`Back`,"data-slot":`mobile-back`,onClick:()=>{let e=window.history.state?.idx;t(typeof e==`number`&&e>0?-1:`/`)},className:`size-[44px] shrink-0 p-0 text-foreground`,children:(0,Q.jsx)(jp,{className:`size-[22px]`,"aria-hidden":`true`})}),(0,Q.jsx)(`div`,{"data-slot":`mobile-run-bar`,ref:e,className:`flex min-w-0 flex-1 items-center gap-[4px]`})]})})}var Hj=`cez:application-restart-from`,Uj=24e4,Wj=3e4,Gj=`The response was lost; update status is unknown. Reconnect or check the current state before retrying.`;function Kj(e,t){let n=t?.applicationUpdate;return!!(n&&(n.status===`error`||e.kind===`apply`&&n.status===`ready`||e.kind===`restart`&&(n.status===`restarting`||n.status===`idle`&&e.initialVersion&&t.version!==e.initialVersion)))}function qj(e,t=()=>window.location.reload()){let n=z(),r=Z.useRef(null),i=Z.useRef(e);i.current=e;let[a,o]=Z.useState(!1),[s,c]=Z.useState(null),[l,u]=Z.useState(()=>!navigator.onLine),d=Z.useRef(e?.version??null),f=Z.useRef(!1),[p,m]=Z.useState(()=>{try{return window.sessionStorage.getItem(Hj)}catch{return null}});Z.useEffect(()=>{let e=()=>u(!navigator.onLine);return window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}},[]),Z.useEffect(()=>{(e?.applicationUpdate?.status===`ready`||e?.applicationUpdate?.status===`restarting`)&&c(null)},[e?.applicationUpdate?.status]),Z.useEffect(()=>{if(!e?.version)return;d.current||=e.version;let n=d.current!==e.version,r=!!(p&&e.version!==p);if(n||r||p&&e.applicationUpdate?.status===`error`){try{window.sessionStorage.removeItem(Hj)}catch{}m(null)}(n||r)&&!f.current&&(f.current=!0,t())},[e?.version,e?.applicationUpdate?.status,p,t]);let h=Z.useCallback(e=>{n.setQueryData(H.health,t=>t&&{...t,applicationUpdate:e})},[n]),g=Z.useCallback((e,t)=>{if(r.current===e){if(e.reconciledRestart&&(t.source===`timeout`||t.source===`failure`&&t.cause instanceof Ze&&t.cause.status===0)&&(t={source:`health`,state:e.reconciledRestart}),r.current=null,clearTimeout(e.timer),t.source!==`response`&&e.controller.abort(),o(!1),t.source===`response`&&t.state&&h(t.state),t.source===`timeout`?c(Gj):t.source===`failure`?c(t.cause instanceof Error?t.cause.message:`The request failed.`):c(null),t.source===`failure`&&e.kind===`restart`){try{window.sessionStorage.removeItem(Hj)}catch{}m(null)}(t.source===`timeout`||t.source===`failure`)&&n.invalidateQueries({queryKey:H.health}),e.resolve(t.state)}},[n,h]);Z.useEffect(()=>{let t=r.current,n=e?.applicationUpdate;if(t&&!(n===t.initialState&&e?.version===t.initialVersion||!Kj(t,e))){if(t.kind===`restart`&&n?.status===`restarting`){t.reconciledRestart=n,o(!1),c(null),t.resolve(n);return}g(t,{source:`health`,state:n})}},[e?.applicationUpdate,e?.version,g]),Z.useEffect(()=>()=>{let e=r.current;e&&(r.current=null,clearTimeout(e.timer),e.controller.abort(),e.resolve(void 0))},[]);let _=Z.useCallback((e,t)=>{if(r.current)return Promise.resolve(void 0);let a=new AbortController,s=i.current?.applicationUpdate,l=i.current?.version,u=n.getQueryData(H.health)?.applicationUpdate;return o(!0),c(null),new Promise(o=>{let c={controller:a,initialState:s,initialCacheState:u,initialVersion:l,kind:e,resolve:o,timer:setTimeout(()=>g(c,{source:`timeout`}),e===`apply`?Uj:Wj)};r.current=c,t(a.signal).then(e=>{if(r.current!==c)return;let t=n.getQueryData(H.health),a=i.current,o=t?.applicationUpdate!==u&&Kj(c,t)?t.applicationUpdate:a?.applicationUpdate!==s&&Kj(c,a)?a.applicationUpdate:void 0;g(c,o?{source:`health`,state:o}:{source:`response`,state:e.state})},e=>g(c,{source:`failure`,cause:e}))})},[g,n]);return{apply:Z.useCallback(async()=>{await _(`apply`,Ve)},[_]),restart:Z.useCallback(async()=>{if(r.current)return;let e=i.current?.version,t=await _(`restart`,rt);if(e&&t?.status===`restarting`){try{window.sessionStorage.setItem(Hj,e)}catch{}m(e)}},[_]),busy:a,error:s,offline:l}}var Jj=[`claude`,`codex`,`opencode`,`pi`,`cursor`,`omp`],Yj={claude:`Claude Code`,codex:`Codex`,opencode:`OpenCode`,pi:`pi`,cursor:`Cursor`,omp:`OMP`};function Xj(e){if(typeof e!=`object`||!e||Array.isArray(e))return{};let t=e,n={};for(let e of Jj){let r=t[e];typeof r==`string`&&r.length>0&&r.length<=128&&(n[e]=r)}return n}function Zj(e,t){if(!e)return[];let n=new Map(e.providers.map(e=>[e.provider,e]));return Jj.flatMap(e=>{let r=n.get(e);return r?.status!==`disconnected`||!r.authFailureId||t[e]===r.authFailureId?[]:[{provider:e,label:Yj[e],authFailureId:r.authFailureId}]})}function Qj(e,t){return{...e,...Object.fromEntries(t.map(({provider:e,authFailureId:t})=>[e,t]))}}function $j({status:e,pending:t,error:n,dismissals:r,onDismissAuthFailures:i}){if(t||!e)return null;let a;try{a=Be(e)}catch{return null}let o=Zj(a,r);if(o.length>0)return(0,Q.jsxs)(`div`,{"data-slot":`provider-banner`,role:`alert`,className:`flex min-h-9 items-center gap-2 border-b border-border bg-destructive/10 px-4 text-sm text-foreground`,children:[(0,Q.jsx)(J_,{tone:`danger`}),(0,Q.jsxs)(`span`,{children:[`Provider authentication failed during a task:`,` `,o.map(({label:e})=>e).join(`, `),`.`]}),(0,Q.jsx)(Y,{to:`/settings/agents#providers`,className:`ml-auto shrink-0 font-medium underline underline-offset-4 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:`Open agent settings`}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Dismiss provider authentication alert`,onClick:()=>i(o),className:`shrink-0 rounded-sm p-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:(0,Q.jsx)(Om,{className:`size-4`,"aria-hidden":`true`})})]});if(n||a.providers.some(e=>e.enabled&&e.status===`connected`))return null;let s=a.providers.some(e=>e.status===`connected`),c=a.providers.some(e=>e.status===`unknown`);return(0,Q.jsxs)(`div`,{"data-slot":`provider-banner`,role:`status`,className:`flex min-h-9 items-center gap-2 border-b border-border bg-muted/50 px-4 text-sm text-muted-foreground`,children:[(0,Q.jsx)(J_,{tone:c?`danger`:`pending`}),(0,Q.jsx)(`span`,{children:s?`No agent provider is enabled.`:c?`No connected provider could be verified.`:`No agent provider credentials were found.`}),(0,Q.jsx)(Y,{to:`/settings/agents#providers`,className:`ml-auto shrink-0 font-medium text-foreground underline underline-offset-4 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:`Configure providers`})]})}function eM(e){if(!(typeof e!=`object`||!e||Array.isArray(e)))return e}function tM(){let e=Kn(),t=Ht(),n=z(),r=(0,Z.useRef)(Promise.resolve()),i=(0,Z.useRef)(0),a=(0,Z.useRef)(0),o=(0,Z.useRef)(eM(t.data));(0,Z.useEffect)(()=>{a.current===0&&(o.current=eM(t.data))},[t.data]);let s=(0,Z.useCallback)(e=>{let t=B.uiState,s=eM(n.getQueryData(t)),c=Qj(Xj(s?.dismissedProviderAuthFailures),e),l={...s,dismissedProviderAuthFailures:c};a.current+=1,n.setQueryData(t,l);let u=++i.current;r.current=r.current.then(async()=>{try{let e=await Qe({dismissedProviderAuthFailures:c});o.current=eM(e),u===i.current&&n.setQueryData(t,e)}catch(e){u===i.current&&(o.current===void 0?n.removeQueries({queryKey:t,exact:!0}):n.setQueryData(t,o.current),n.invalidateQueries({queryKey:t}),K(e instanceof Error?e.message:String(e),{tone:`danger`}))}finally{--a.current}})},[n]);return(0,Q.jsx)($j,{status:e.data,pending:e.isPending,error:e.isError,dismissals:Xj(eM(t.data)?.dismissedProviderAuthFailures),onDismissAuthFailures:s})}var nM=`cez-project-rail-expanded`;function rM(e,t){return e-232-t>=640}function iM(){try{return localStorage.getItem(nM)===`1`}catch{return!1}}function aM(e){try{localStorage.setItem(nM,e?`1`:`0`)}catch{}}function oM(e){if(e!==void 0)return e.isDragging?`relative z-10 opacity-40 [-webkit-touch-callout:none]`:`[-webkit-touch-callout:none]`}function sM({project:e,signal:t,known:n,current:r,target:i,onSwitchProject:a,onSelectProject:o,sort:s}){let c=nx(e.name,t,{unknown:!n});return(0,Q.jsxs)(`div`,{ref:s?.setNodeRef,style:s?.style,...s?.listeners,"data-slot":`rail-project`,"data-project-id":e.id,"data-dragging":s?.isDragging?``:void 0,className:k(`relative flex h-[52px] w-full shrink-0 items-center justify-center`,oM(s)),children:[r?(0,Q.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`rail-current-bar`,className:`absolute top-1/2 left-0 h-5 w-[3px] -translate-y-1/2 rounded-r-[2px] bg-foreground`}):null,(0,Q.jsxs)(`div`,{className:`relative size-9`,children:[(0,Q.jsx)(T,{ref:s?.setActivatorNodeRef,"aria-describedby":s?.attributes[`aria-describedby`],to:i.href,onClick:t=>{t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(o?.(e.id),i.verify&&a&&(t.preventDefault(),a(e.id)))},"aria-label":c,title:c,"aria-current":r?`page`:void 0,className:k(`flex size-full items-center justify-center rounded-[9px] border text-[12px] leading-none font-semibold focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,r?`border-soft-foreground bg-sidebar-row-selected text-foreground`:`border-transparent bg-muted text-muted-foreground hover:text-foreground`),children:ax(e.name)}),(0,Q.jsx)(LA,{position:`top`,segments:RA(t).top}),(0,Q.jsx)(LA,{position:`bottom`,segments:RA(t).bottom})]})]})}var cM=`motion-safe:rail-text-in`;function lM({project:e,signal:t,known:n,current:r,target:i,onSwitchProject:a,onSelectProject:o,sort:s}){let c=nx(e.name,t,{unknown:!n}),{top:l,bottom:u}=RA(t),d=r?`border-sidebar-row-selected`:`border-background group-hover:border-sidebar-row-hover`;return(0,Q.jsxs)(`div`,{ref:s?.setNodeRef,style:s?.style,...s?.listeners,"data-slot":`rail-project`,"data-project-id":e.id,"data-dragging":s?.isDragging?``:void 0,className:k(`group/row relative w-full shrink-0`,oM(s)),children:[(0,Q.jsxs)(T,{to:i.href,onClick:t=>{t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(o?.(e.id),i.verify&&a&&(t.preventDefault(),a(e.id)))},"aria-label":c,"aria-current":r?`page`:void 0,className:k(`group flex h-[52px] w-full items-center gap-[10px] rounded-[8px] px-[6px] pr-6 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,r?`bg-sidebar-row-selected`:`hover:bg-sidebar-row-hover`),children:[(0,Q.jsxs)(`span`,{"aria-hidden":`true`,"data-slot":`rail-mark`,className:k(`relative flex size-9 shrink-0 items-center justify-center rounded-[9px] border text-[12px] leading-none font-semibold`,r?`border-soft-foreground bg-sidebar text-foreground`:`border-transparent bg-muted text-muted-foreground`),children:[ax(e.name),(0,Q.jsx)(LA,{position:`top`,segments:l,className:d}),(0,Q.jsx)(LA,{position:`bottom`,segments:u,className:d})]}),(0,Q.jsxs)(`span`,{className:k(`flex min-w-0 flex-1 flex-col gap-px`,cM),children:[(0,Q.jsx)(`span`,{"data-slot":`rail-project-name`,className:k(`truncate text-[13.5px] leading-[18px] font-semibold`,r?`text-foreground`:`text-muted-foreground`),children:e.name}),(0,Q.jsx)(PA,{signal:t,known:n,current:r,maxParts:2,slot:`rail-project-state`,className:`h-4 gap-x-[4px] overflow-hidden text-[11px] leading-4 whitespace-nowrap`})]})]}),s?(0,Q.jsx)(uM,{name:e.name,sort:s}):null]})}function uM({name:e,sort:t}){return(0,Q.jsx)(`button`,{type:`button`,ref:t.setActivatorNodeRef,"data-slot":`rail-project-grip`,...t.attributes,"aria-label":`Reorder ${e}, position ${t.position} of ${t.total}`,className:k(`absolute top-1/2 right-0.5 flex h-10 w-5 -translate-y-1/2 cursor-grab touch-none items-center justify-center rounded text-soft-foreground opacity-0 outline-none transition-opacity hover:text-foreground motion-reduce:transition-none`,`focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50`,`group-hover/row:opacity-100 group-focus-within/row:opacity-100 [@media(hover:none)]:opacity-100`),children:(0,Q.jsx)(nm,{"aria-hidden":`true`,className:`size-3.5`})})}function dM({expanded:e,position:t,total:n,sortable:r,...i}){let{attributes:a,listeners:o,setNodeRef:s,setActivatorNodeRef:c,transform:l,transition:u,isDragging:d}=Cc({id:i.project.id,disabled:!r}),f=r?{setNodeRef:s,setActivatorNodeRef:c,style:{transform:jc.Translate.toString(l),transition:u},listeners:o,attributes:a,isDragging:d,position:t,total:n}:void 0;return e?(0,Q.jsx)(lM,{...i,sort:f}):(0,Q.jsx)(sM,{...i,sort:f})}var fM=({transform:e})=>({...e,x:0}),pM=class extends bc{static activators=[{eventName:`onPointerDown`,handler:({nativeEvent:e},t)=>e.pointerType!==`touch`&&bc.activators[0].handler({nativeEvent:e},t)}]},mM={delay:250,tolerance:5},hM={start:[yc.Space],cancel:[yc.Esc],end:[yc.Space,yc.Enter,yc.Tab]},gM={droppable:{strategy:Ac.Always}},_M={draggable:`To reorder projects, press Space to pick this project up. Use the up and down arrow keys to move it, Space to drop it, or Escape to cancel.`};function vM(e,t){let[n,r]=Z.useState(null),i=Z.useMemo(()=>{if(n===null||n.base!==e)return e;let t=new Map(e.map(e=>[e.id,e]));return n.ids.flatMap(e=>t.get(e)??[])},[n,e]),a=Z.useMemo(()=>i.map(e=>e.id),[i]),o=_c(Sc(pM,{activationConstraint:{distance:6}}),Sc(xc,{activationConstraint:mM}),Sc(wc,{coordinateGetter:Oc,keyboardCodes:hM})),s=Z.useRef(null),c=Z.useCallback(()=>{s.current?.();let e=e=>e.preventDefault();window.addEventListener(`click`,e,!0),s.current=()=>{window.removeEventListener(`click`,e,!0),s.current=null}},[]),l=Z.useCallback(()=>{let e=s.current;window.setTimeout(()=>e?.(),0)},[]);Z.useEffect(()=>()=>s.current?.(),[]);let u=Z.useCallback(n=>{l();let{active:i,over:o}=n;if(!t||o===null||o.id===i.id)return;let s=Ly(a,a.indexOf(String(i.id)),a.indexOf(String(o.id)));s.some((e,t)=>e!==a[t])&&(r({base:e,ids:s}),t(s))},[l,e,a,t]);return{projects:i,ids:a,sensors:o,announcements:Z.useMemo(()=>{let e=e=>{let t=a.indexOf(String(e));return{name:i[t]?.name??String(e),position:`position ${t+1} of ${a.length}`}};return{onDragStart:({active:t})=>`Picked up ${e(t.id).name}, ${e(t.id).position}.`,onDragOver:({active:t,over:n})=>n?`${e(t.id).name} moved to ${e(n.id).position}.`:`${e(t.id).name} is not over a drop position.`,onDragEnd:({active:t,over:n})=>n?`${e(t.id).name} dropped at ${e(n.id).position}.`:`${e(t.id).name} dropped. The order is unchanged.`,onDragCancel:({active:t})=>`Reordering cancelled. ${e(t.id).name} returned to ${e(t.id).position}.`}},[a,i]),onDragStart:c,onDragEnd:u,onDragCancel:l}}function yM(e){return k(`flex shrink-0 items-center rounded-[8px] text-soft-foreground hover:bg-sidebar-row-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,e?`size-auto h-9 w-full justify-start gap-3 px-2.5 text-[13px] font-normal`:`size-9 justify-center`)}var bM=k(`truncate text-muted-foreground group-hover:text-foreground`,cM);function xM({to:e,label:t,slot:n,active:r,expanded:i,children:a}){return(0,Q.jsxs)(T,{to:e,"data-slot":n,"aria-label":t,title:i?void 0:t,"aria-current":r?`page`:void 0,className:k(`group`,yM(i),r&&`bg-sidebar-row-selected text-foreground hover:bg-sidebar-row-selected`),children:[a,i?(0,Q.jsx)(`span`,{className:bM,children:t}):null]})}function SM(e){let[t,n]=Z.useState(()=>window.innerWidth);return Z.useEffect(()=>{let e=()=>n(window.innerWidth);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),rM(t,e)}function CM(){let e=SM(Z.useContext(Sj));return(0,Q.jsx)(`div`,{"aria-hidden":`true`,"data-slot":`project-rail-placeholder`,style:{width:iM()&&e?232:60},className:`hidden shrink-0 border-r border-border bg-background md:block`})}var wM=e=>({href:String(us(e,`/`)),verify:!1});function TM({projects:e,signals:t,version:n,singleProject:r,projectTarget:i=wM,onSwitchProject:o,onSelectProject:s,canReorder:c=!1,onReorder:l}){let{pathname:u}=a(),{resolvedTheme:d}=Ny(),f=Z.useContext(Sj),[p,m]=Z.useState(iM),h=SM(f),g=p&&h,_=()=>{let e=!g;m(e),aM(e)},v=fs(u),y=u===`/tasks`,b=u===`/settings/global`||u.startsWith(`/settings/global/`),x=n?`Cezarion v${n}`:`Cezarion`,S=Z.useId(),C=vM(e,l),w=c&&l!==void 0&&e.length>1;return(0,Q.jsxs)(`nav`,{id:S,"aria-label":`Projects`,"data-slot":`project-rail`,"data-expanded":g?`true`:`false`,style:{width:g?232:60},className:k(`hidden shrink-0 flex-col overflow-hidden border-r border-border bg-background pt-3 pb-3.5 transition-[width] duration-[160ms] ease-out motion-reduce:transition-none md:flex`,g?`items-stretch px-2.5`:`items-center`),children:[g?(0,Q.jsxs)(`div`,{"data-slot":`rail-identity`,className:`flex shrink-0 flex-col gap-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex h-[34px] items-center gap-[10px] px-0.5`,children:[(0,Q.jsx)(`img`,{src:`/cezarion-mark-${d}.svg`,alt:``,"aria-hidden":`true`,"data-slot":`rail-app-mark`,className:`size-[34px] shrink-0 rounded-[8px]`}),(0,Q.jsxs)(`span`,{className:k(`flex min-w-0 items-baseline gap-[10px] whitespace-nowrap`,cM),"aria-label":x,children:[(0,Q.jsx)(`span`,{className:`text-[15px] leading-none font-bold text-foreground`,children:`Cezarion`}),n?(0,Q.jsxs)(`span`,{"data-slot":`rail-version`,title:`v${n}`,className:`min-w-0 truncate text-[11px] leading-none text-soft-foreground`,children:[`v`,n]}):null]})]}),(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:`h-px w-full bg-border`}),(0,Q.jsx)(`div`,{className:k(`px-1 pt-2.5 pb-1 text-[11px] font-medium text-soft-foreground`,cM),children:`Projects`})]}):(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-col items-center gap-0.5`,children:[(0,Q.jsx)(`img`,{src:`/cezarion-mark-${d}.svg`,alt:x,title:x,"data-slot":`rail-app-mark`,className:`size-[34px] rounded-[9px]`}),(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:`mt-0.5 mb-1.5 h-px w-6 bg-border`})]}),(0,Q.jsxs)(`div`,{"data-slot":`rail-projects`,className:k(`flex min-h-0 w-full flex-1 flex-col gap-0.5 overflow-y-auto overscroll-contain [scrollbar-width:none]`,g?`items-stretch`:`items-center`),children:[(0,Q.jsx)(Ec,{sensors:C.sensors,collisionDetection:Dc,measuring:gM,modifiers:[fM],accessibility:{announcements:C.announcements,screenReaderInstructions:_M},onDragStart:C.onDragStart,onDragEnd:C.onDragEnd,onDragCancel:C.onDragCancel,children:(0,Q.jsx)(kc,{items:C.ids,strategy:vc,disabled:!w,children:C.projects.map((e,n)=>(0,Q.jsx)(dM,{expanded:g,sortable:w,position:n+1,total:C.projects.length,project:e,signal:t?.get(e.id),known:t!==null,current:e.id===v,target:i(e.id),onSwitchProject:o,onSelectProject:s},e.id))})}),r?null:g?(0,Q.jsx)(DA,{origin:`rail`,icon:Ga,iconClassName:`size-[15px] text-soft-foreground`,iconFrameClassName:`flex size-9 shrink-0 items-center justify-center rounded-[9px] border border-border`,label:`Add project`,side:`right`,triggerClassName:k(`h-[44px] w-full shrink-0 justify-start gap-[10px] rounded-[8px] px-[6px] text-[13px] font-normal text-muted-foreground hover:bg-sidebar-row-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring motion-safe:[&>span:last-child]:rail-text-in`)}):(0,Q.jsx)(DA,{origin:`rail`,icon:Ga,iconClassName:`size-[15px]`,side:`right`,triggerClassName:`shrink-0 rounded-[9px] border border-border text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`})]}),(0,Q.jsxs)(`div`,{"data-slot":`rail-bottom`,className:k(`flex shrink-0 flex-col gap-0.5 pt-2`,g?`items-stretch`:`items-center`),children:[h?(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`rail-expand-toggle`,"aria-expanded":g,"aria-controls":S,"aria-label":g?`Collapse projects`:`Expand projects`,title:g?void 0:`Expand projects`,onClick:_,className:k(`group`,yM(g)),children:[g?(0,Q.jsx)(pm,{className:`size-4 shrink-0`,"aria-hidden":`true`}):(0,Q.jsx)(mm,{className:`size-4 shrink-0`,"aria-hidden":`true`}),g?(0,Q.jsx)(`span`,{className:bM,children:`Collapse`}):null]}):null,r?null:(0,Q.jsx)(xM,{to:`/tasks`,label:`All projects`,slot:`rail-all-projects`,active:y,expanded:g,children:(0,Q.jsx)(Aa,{className:`size-4 shrink-0`,"aria-hidden":`true`})}),(0,Q.jsx)(xM,{to:`/settings/global/appearance`,label:`Global settings`,slot:`rail-global-settings`,active:b,expanded:g,children:(0,Q.jsx)(Oa,{className:`size-4 shrink-0`,"aria-hidden":`true`})}),(0,Q.jsx)(WO,{showLabel:g,labelClassName:bM,className:k(`group`,yM(g),`[&_svg]:size-4`)})]})]})}function EM(){let e=z(),t=It().data?.projects,{order:n,canReorder:r,setOrder:i}=zy(),a=r&&t!==void 0&&Py(t.length),o=Z.useMemo(()=>t?Iy(t,n):void 0,[t,n]),s=Gt().data,c=mn().data?.capabilities.singleProject===!0,l=Z.useMemo(()=>s?tx(s.runs):null,[s]),u=t?.map(e=>e.id).sort().join(`
12
+ `),d=Z.useRef(void 0);return Z.useEffect(()=>{u!==void 0&&(d.current!==void 0&&d.current!==u&&e.invalidateQueries({queryKey:B.runsIndex}),d.current=u)},[e,u]),Z.useMemo(()=>o?{projects:o,signals:l,singleProject:c,canReorder:a,onReorder:i}:null,[o,l,c,a,i])}var DM=60;function OM(e){return`title`in e?`Archived "${e.title.length>DM?`${e.title.slice(0,DM-1)}…`:e.title}"`:`Archived ${e.count} ${e.count===1?`task`:`tasks`}`}async function kM(e,t,n){let r=new Set(n),i=(await Promise.allSettled(t.map(async t=>{await _t(Vt(t,{projectId:e}),!1),r.has(t)&&await Me(Vt(t,{projectId:e}),!0)}))).find(e=>e.status===`rejected`);i&&K(i.reason instanceof Error?i.reason.message:`Could not undo the archive.`,{tone:`danger`})}function AM(){let e=document.activeElement;return!e||e===document.body||!e.isConnected}function jM(e,t){if(!e.isConnected)return t();let n=new MutationObserver(()=>{e.isConnected||(n.disconnect(),clearTimeout(r),t())}),r=setTimeout(()=>n.disconnect(),5e3);n.observe(document.body,{childList:!0,subtree:!0})}function MM(e,t){if(!AM())return;let n=e?.isConnected?e:t?.isConnected?t:null;n instanceof HTMLElement&&(n.tabIndex<0&&!n.hasAttribute(`tabindex`)&&(n.tabIndex=-1),n.focus({preventScroll:!0}))}function NM(e,t,n){if(!e)return()=>{};let r=t(e);return()=>jM(e,()=>MM(r,n))}function PM(e){let t=document.activeElement?.closest(`[data-slot="task-row"]`);return t?.getAttribute(`data-run-id`)===e?t:Array.from(document.querySelectorAll(`[data-slot="task-row"]`)).find(t=>t.getAttribute(`data-run-id`)===e)??null}var FM=e=>e?.querySelector(`a`)??null;function IM(e,t){let n=e?.projectId,r=e?.cacheScope,i=yn(),[a,o]=Z.useState(null),s=e=>i.invalidateAfter(`runs`,Ir({projectId:n,cacheScope:e})),l=(e,t,r,i)=>K(e,{action:{label:`Undo`,onAction:()=>void kM(n,r,i).finally(()=>void s(t))}}),u=Z.useRef(new Map);return{archiveOne:e=>{let i=u.current.get(e.id);if(i)return i;let a=r??c(),o=!!e.pinned,d=PM(e.id),f=NM(d,e=>{let t=Array.from(e.closest(`[data-slot="quick-list-bucket"]`)?.querySelectorAll(`[data-slot="task-row"]`)??[]),n=t.indexOf(e);return FM(t[n+1]??t[n-1])},d?.closest(`[data-slot="quick-list-bucket"]`)?.parentElement??null),p=_t(Vt(e.id,{projectId:n}),!0).then(()=>(s(a),l(OM({title:xn(e)}),a,[e.id],o?[e.id]:[]),f(),t?.(),!0),e=>(K(e.message,{tone:`danger`}),!1)).finally(()=>u.current.delete(e.id));return u.current.set(e.id,p),p},sweep:(e,i)=>{let a=r??c();o(e);let u=document.activeElement,d=u?.matches(`[data-action="archive-group"]`)?u:null,f=NM(d,e=>FM(e.closest(`[data-slot="quick-list-bucket"]`)?.nextElementSibling?.querySelector(`[data-slot="task-row"]`)??void 0),d?.closest(`[data-slot="quick-list-bucket"]`)?.parentElement??null);ct(Ir({projectId:n}),e,i).then(({ids:e,pinnedIds:n})=>{s(a),e.length>0&&l(OM({count:e.length}),a,e,n),f(),e.length>0&&t?.()},e=>K(e.message,{tone:`danger`})).finally(()=>o(null))},sweeping:a}}var LM=.6,RM=300,zM=100,BM={offset:0,phase:`idle`,past:!1},VM=null;function HM(e,t){VM&&VM.id!==e&&VM.close(),VM={id:e,close:t}}function UM(e){VM?.id===e&&(VM=null)}function WM(){if(!(typeof navigator>`u`||typeof navigator.vibrate!=`function`))try{navigator.vibrate(10)}catch{}}function GM({id:e,enabled:t,onArchive:n}){let[r,i]=Z.useState(BM),a=Z.useRef(null),o=Z.useRef(null),s=Z.useRef(!1),c=Z.useRef(!1),l=Z.useRef(void 0),u=()=>{c.current=!0,clearTimeout(l.current),l.current=void 0},d=()=>{c.current&&(clearTimeout(l.current),l.current=setTimeout(()=>{c.current=!1},RM))};Z.useEffect(()=>()=>clearTimeout(l.current),[]);let f=Z.useRef(r);f.current=r;let p=Z.useRef(n);p.current=n;let m=Z.useCallback(()=>{o.current=null,s.current=!1,UM(e),i(BM)},[e]);Z.useEffect(()=>{!t&&f.current.phase!==`committing`&&m()},[t,m]),Z.useEffect(()=>()=>UM(e),[e]);let h=r.phase===`open`;Z.useEffect(()=>{if(!h)return;let e=()=>m(),t=e=>{let t=a.current;t&&e.target instanceof Node&&t.contains(e.target)||m()};return document.addEventListener(`scroll`,e,{capture:!0,passive:!0}),document.addEventListener(`pointerdown`,t,!0),()=>{document.removeEventListener(`scroll`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,!0)}},[h,m]);let g=t=>{UM(e),i({offset:-t,phase:`committing`,past:!0});let n=e=>{e===!1&&m()};try{let e=p.current();e&&typeof e.then==`function`&&e.then(n,m)}catch{m()}};return{offset:r.offset,phase:r.phase,past:r.past,surfaceRef:a,bind:{onPointerDown:e=>{if(c.current=!1,!t||f.current.phase===`committing`||e.pointerType===`mouse`&&e.button!==0)return;let n=(a.current??e.currentTarget).getBoundingClientRect();o.current={pointerId:e.pointerId,x0:e.clientX,y0:e.clientY,base:f.current.phase===`open`?-88:0,width:n.width>0?n.width:320,axis:null,wasOpen:f.current.phase===`open`,samples:[{x:e.clientX,t:Date.now()}]}},onPointerMove:t=>{let n=o.current;if(!n||t.pointerId!==n.pointerId)return;let r=t.clientX-n.x0,a=t.clientY-n.y0;if(n.axis===null){if(Math.max(Math.abs(r),Math.abs(a))<10||(n.axis=Math.abs(r)>Math.abs(a)?`x`:`y`,n.axis===`y`))return;try{t.currentTarget.setPointerCapture?.(t.pointerId)}catch{}HM(e,m),u()}if(n.axis!==`x`)return;let c=Math.min(0,Math.max(-n.width,n.base+r)),l=-c>=LM*n.width;l&&!s.current&&WM(),s.current=l,n.samples.push({x:t.clientX,t:Date.now()}),n.samples.length>8&&n.samples.shift(),i({offset:c,phase:`dragging`,past:l})},onPointerUp:t=>{let n=o.current;if(!n||t.pointerId!==n.pointerId)return;if(o.current=null,n.axis!==`x`){n.axis===null&&n.wasOpen&&(u(),d(),m());return}d();let r=f.current.offset,a=Date.now(),c={x:t.clientX,t:a},l=n.samples.find(e=>a-e.t<=zM&&e.t<a),p=l?(c.x-l.x)/(c.t-l.t):0;s.current=!1,f.current.past||p<=-1&&-r>=40?g(n.width):p<1&&-r>=40?(HM(e,m),i({offset:-88,phase:`open`,past:!1})):m()},onPointerCancel:e=>{let t=o.current;!t||e.pointerId!==t.pointerId||(o.current=null,d(),t.axis===`x`&&m())},onClickCapture:e=>{c.current&&(c.current=!1,e.preventDefault(),e.stopPropagation())},onKeyDownCapture:()=>{c.current=!1}},close:m}}var KM=`opacity-0 group-hover/task-row:opacity-100 focus-visible:opacity-100 group-has-[:focus-visible]/task-row:opacity-100 no-hover:opacity-100`,qM=`opacity-0 group-hover/task-row:opacity-100 focus-visible:opacity-100 group-has-[:focus-visible]/task-row:opacity-100`,JM=`transition-opacity motion-reduce:transition-none group-hover/task-row:opacity-0 group-has-[:focus-visible]/task-row:opacity-0 max-md:absolute max-md:top-1/2 max-md:left-0 max-md:-translate-y-1/2 max-md:opacity-100 no-hover:absolute no-hover:top-1/2 no-hover:left-0 no-hover:-translate-y-1/2 no-hover:opacity-100`;function YM({run:e,title:t,unread:n,inertReferences:r,onTogglePin:i,onArchiveRun:a}){return(0,Q.jsxs)(`span`,{"data-slot":`task-row-trailing`,className:`relative flex h-[19px] w-[16px] shrink-0 items-center justify-center max-md:h-auto max-md:w-11 max-md:self-stretch no-hover:h-auto no-hover:w-11 no-hover:self-stretch`,children:[n?(0,Q.jsx)(J_,{tone:Qb(e),role:`img`,"aria-label":`unread`,title:`Unread — not opened since it finished`,"data-slot":`unread-marker`,className:i?JM:void 0}):null,i?(0,Q.jsx)(eS,{pinned:!!e.pinned,onToggle:t=>i(e,t),className:k(`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2`,KM)}):null,a&&!r&&hn(e)?(0,Q.jsx)(`button`,{type:`button`,"data-action":`archive-run`,"aria-label":`Archive ${t}`,title:`Archive task`,onClick:t=>{t.stopPropagation(),a(e)},className:k(`absolute top-[19.5px] left-1/2 inline-flex size-5 -translate-x-1/2 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none motion-reduce:transition-none`,qM),children:(0,Q.jsx)(bo,{className:`size-[12px] -translate-y-[2.5px]`,"aria-hidden":`true`})}):null]})}function XM({inertReferences:e,swipeable:t,swipe:n,title:r,onArchive:i,children:a}){return e?(0,Q.jsxs)(`div`,{ref:n.surfaceRef,"data-slot":`task-row-swipe`,"data-swipe":t?`on`:void 0,className:k(`relative rounded-[6px]`,t&&`touch-pan-y touch-pinch-zoom overflow-hidden`),children:[n.offset<0?(0,Q.jsx)(ZM,{width:-n.offset,past:n.past,title:r,onArchive:i}):null,a]}):a}function ZM({width:e,past:t,title:n,onArchive:r}){return(0,Q.jsx)(`div`,{"data-slot":`task-row-swipe-action`,"data-past":t?`true`:void 0,"aria-hidden":`true`,style:{width:e},className:k(`absolute inset-y-0 right-0 flex items-stretch justify-end overflow-hidden rounded-[6px]`,t?`bg-info text-signal-ink`:`bg-muted text-foreground`),children:t?(0,Q.jsxs)(`span`,{className:`flex w-full items-center justify-center gap-2 text-[12px] font-semibold whitespace-nowrap`,children:[(0,Q.jsx)(bo,{className:`size-[16px] shrink-0`,"aria-hidden":`true`}),`Release to archive`]}):(0,Q.jsxs)(`button`,{type:`button`,tabIndex:-1,"aria-label":`Archive ${n}`,onClick:e=>{e.stopPropagation(),r()},className:`flex w-[88px] shrink-0 flex-col items-center justify-center gap-1 text-[12px] font-semibold`,children:[(0,Q.jsx)(bo,{className:`size-[16px]`,"aria-hidden":`true`}),`Archive`]})})}var QM=`[&>[data-ellipsis-hidden]]:pointer-events-none`,$M=`data-ellipsis-hidden`,eN=new Map;function tN(e){let t=getComputedStyle(e),n=`${t.fontStyle} ${t.fontWeight} ${t.fontSize} ${t.fontFamily} ${t.letterSpacing}`,r=eN.get(n);if(r!==void 0)return r;let i=document.createElement(`span`);i.textContent=`…`,i.setAttribute(`aria-hidden`,`true`),Object.assign(i.style,{position:`absolute`,visibility:`hidden`,whiteSpace:`pre`,fontStyle:t.fontStyle,fontWeight:t.fontWeight,fontSize:t.fontSize,fontFamily:t.fontFamily,letterSpacing:t.letterSpacing}),document.body.appendChild(i);let a=i.getBoundingClientRect().width;i.remove();let o=a||parseFloat(t.fontSize)||12;return a&&(!document.fonts||document.fonts.status===`loaded`)&&eN.set(n,o),o}function nN(e,t){if(e.scrollWidth<=e.clientWidth)return[];let n=e.getBoundingClientRect(),r=parseFloat(getComputedStyle(e).paddingRight)||0,i=n.left+e.clientLeft+e.clientWidth-r-t+.5;return Array.from(e.children).filter(e=>e.getBoundingClientRect().right>i)}function rN(e,t,n){Z.useLayoutEffect(()=>{let n=e.current;if(!t||!n||typeof ResizeObserver>`u`)return;let r=!0,i=()=>{if(!r)return;let e=new Set(nN(n,tN(n)));for(let t of Array.from(n.children))t.hasAttribute($M)!==e.has(t)&&t.toggleAttribute($M,e.has(t))},a=new ResizeObserver(i),o=new Set,s=()=>{for(let e of Array.from(n.children))o.has(e)||(o.add(e),a.observe(e))};a.observe(n),s(),i();let c=typeof MutationObserver>`u`?null:new MutationObserver(()=>{s(),i()});return c?.observe(n,{childList:!0}),document.fonts&&document.fonts.status!==`loaded`&&document.fonts.ready.then(i),()=>{r=!1,a.disconnect(),c?.disconnect();for(let e of Array.from(n.children))e.removeAttribute($M)}},[e,t,n])}var iN=`(hover: none)`;function aN(){let[e,t]=(0,Z.useState)(()=>typeof window.matchMedia==`function`&&window.matchMedia(iN).matches);return(0,Z.useEffect)(()=>{if(typeof window.matchMedia!=`function`)return;let e=window.matchMedia(iN);t(e.matches);let n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function oN(){let[e,t]=(0,Z.useState)(()=>typeof window.matchMedia!=`function`||window.matchMedia(`(min-width: 768px)`).matches);return(0,Z.useEffect)(()=>{if(typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(min-width: 768px)`),n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var sN={"needs-permission":`label`,failed:`label`,"needs-you":`none`,"needs-review":`label`,running:`label`,"usage-limit":`resume`,"waiting-on-workers":`label`,"waiting-on-subagents":`label`,"waiting-for-ci":`label`,"waiting-for-merge":`label`,"waiting-for-command":`until`,monitoring:`next-check`,"waiting-for-capacity":`label`,queued:`queue-position`,done:`none`,cancelled:`none`,unseen:`label`};function cN(e,t,n,r){let{label:i}=e;switch(sN[e.rung]){case`none`:return;case`queue-position`:return t===null?i:`queued #${t}`;case`resume`:{let e=Lo(n.autoResumeAt,r);return e===`scheduled`?i:`${i}, ${e}`}case`next-check`:{let e=St(n),t=e?.kind===`timer`?new Date(e.at):void 0;return t&&Number.isFinite(t.getTime())?`${i}, next check ${Ro(t,new Date(r))}`:i}case`until`:{let e=St(n),t=e?.kind===`process`?new Date(e.deadline):void 0;return t&&Number.isFinite(t.getTime())?`${i}, until ${Ro(t,new Date(r))}`:i}case`label`:return i}}function lN({run:e,attention:t,queuePosition:n,inWorkingGroup:r,scope:i,now:a}){let o=Vn(e,void 0,i??void 0),s=n===null?Io(e.finishedAt??e.createdAt,a):``,c=r&&t.rung===`running`?void 0:cN(t,n,e,a);return{stateWord:c,references:o,age:s,key:`${s}|${c??``}|${o.map(e=>`${e.kind}-${e.number}-${e.url}`).join(`,`)}|${+!!e.notify}`}}function uN(e){let t=xn(e);return{title:t,displayTitle:Nr(t,Sr(e)?.number)?fn(t).rest:t}}var dN=`cez-sidebar-sections-changed`;function fN(e){let[t,n]=(0,Z.useState)(()=>mC(fC)),[r,i]=(0,Z.useState)({}),a=(0,Z.useRef)(t);(0,Z.useEffect)(()=>{let e=e=>{if(e instanceof StorageEvent&&e.key!==null&&e.key!==`cez-sidebar-sections-collapsed`)return;let t=e instanceof CustomEvent?e.detail:mC(fC);a.current=t,n(t)};return window.addEventListener(`storage`,e),window.addEventListener(dN,e),()=>{window.removeEventListener(`storage`,e),window.removeEventListener(dN,e)}},[]),(0,Z.useEffect)(()=>{if(e===null||Object.keys(r).length===0)return;let t={...a.current};for(let[n,i]of Object.entries(r))t[JSON.stringify([e,n])]=i;i({}),a.current=t,n(t),hC(t,fC),window.dispatchEvent(new CustomEvent(dN,{detail:t}))},[e,r]);let o=t=>JSON.stringify([e,t]);return{isCollapsed:e=>e!==`Archived`&&(r[e]??t[o(e)])===!0,toggle:t=>{if(e===null){i(e=>({...e,[t]:e[t]!==!0}));return}let r=o(t),s={...a.current,[r]:a.current[r]!==!0};a.current=s,n(s),hC(s,fC),window.dispatchEvent(new CustomEvent(dN,{detail:s}))}}}function pN({runs:e,view:t,onViewChange:n,currentRunId:r=null,now:i=Date.now(),onTogglePin:a,onArchiveRun:o,onSweep:s,sweeping:c=null,showViewControls:l=!0,rowLimit:u,sidebarLimits:d,projectId:f=null}){let p=wj(),m=Sn(e),h=Kt(e,t),g=Qn(h,`active`),_=ur(g,d??u??{overall:null}),v=s?mN(h):void 0;return(0,Q.jsxs)(`div`,{"data-slot":`quick-list`,children:[(0,Q.jsxs)(`div`,{"data-slot":`quick-list-header`,className:`flex min-h-11 items-center gap-1.5 pr-[6px] pl-[10px] md:min-h-[26px]`,children:[(0,Q.jsx)(`h2`,{className:`text-[13px] font-semibold text-foreground`,children:`Tasks`}),(0,Q.jsx)(`span`,{className:`text-[11.5px] text-soft-foreground`,children:m[t]}),(0,Q.jsxs)(Y,{to:`/`,onClick:p,className:`ml-auto flex min-h-11 items-center gap-0.5 text-[12px] text-soft-foreground hover:text-foreground md:min-h-[26px]`,children:[`All`,(0,Q.jsx)($a,{className:`size-[13px]`,"aria-hidden":`true`})]})]}),l?(0,Q.jsx)(`div`,{className:`sticky top-0 z-10 bg-sidebar pt-2 pb-1`,children:(0,Q.jsx)(`div`,{className:`inline-flex w-full gap-0.5 rounded-md bg-muted p-[2px]`,children:(0,Q.jsx)(ON,{view:t,onSelect:n,counts:m})})}):null,g.length===0?(0,Q.jsx)(`p`,{className:`px-3 py-3.5 text-xs text-soft-foreground`,children:t===`automations`?`No automation tasks.`:`No tasks yet — describe one.`}):(0,Q.jsx)(hN,{buckets:_,allBuckets:g,sectionProjectId:f,currentRunId:jr(r,e),now:i,onTogglePin:a,onArchiveRun:o,onSweep:s,sweeping:c,sweepCounts:v,view:t})]})}function mN(e){return{unpinned:dr(e,`unpinned`),pinned:dr(e,`pinned`)}}function hN({buckets:e,currentRunId:t=null,now:n=Date.now(),scope:r=null,onTogglePin:i,onArchiveRun:a,onSweep:o,sweeping:s=null,sweepCounts:c,projectName:l,allBuckets:u=e,sectionProjectId:d=r,view:f=`active`}){let p=Z.useId(),m=fN(d),h=Z.useRef(null),g=Z.useRef(null);Z.useLayoutEffect(()=>{let e=g.current;if(!e||e.element.isConnected||(g.current=null,document.activeElement!==document.body))return;let t=u.find(t=>t.rows.some(t=>t.run.id===e.id));if(!t)return;let n=Array.from(h.current?.children??[]).find(e=>e.dataset.bucket===t.label);(Array.from(n?.querySelectorAll(`[data-slot="task-row"]`)??[]).find(t=>t.dataset.runId===e.id)?.querySelector(`a`)??n?.querySelector(`[data-slot="section-toggle"]`))?.focus({preventScroll:!0})});let _=(e,o=!1)=>(0,Q.jsx)(CN,{inWorkingGroup:o,run:e.run,queuePosition:e.queuePosition,currentRunId:t,now:n,scope:r,onTogglePin:i,onArchiveRun:a});return(0,Q.jsx)(`div`,{ref:h,className:`flex flex-col gap-3`,onFocusCapture:e=>{let t=e.target.closest(`[data-slot="task-row"]`);g.current=t?.dataset.runId?{id:t.dataset.runId,element:e.target}:null},onBlurCapture:e=>{e.currentTarget.contains(e.relatedTarget)||(g.current=null)},children:u.map(t=>{let n=t.label===`Archived`,i=m.isCollapsed(t.label),a=e.find(({label:e})=>e===t.label)?.rows??[],u=t.rows.length,d=!n&&!i&&a.length<u,h=`${p}-${t.label.replaceAll(` `,`-`)}`;return(0,Q.jsxs)(`div`,{"data-slot":`quick-list-bucket`,"data-bucket":t.label,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 pr-[6px]`,children:[(0,Q.jsx)(_N,{id:h,bucket:t,collapsed:i,cut:d,onToggle:m.toggle}),d?(0,Q.jsx)(gN,{section:t.label,shown:a.length,total:u,scope:r,view:f}):null,o&&c?(0,Q.jsx)(EN,{label:t.label,headingId:h,projectName:l,counts:c,onSweep:o,sweeping:s}):null]}),(0,Q.jsx)(`div`,{id:`${h}-rows`,hidden:i,children:!i&&a.map(e=>(0,Q.jsx)(`div`,{children:_(e,t.label===`Working`)},e.run.id))})]},t.label)})})}function gN({section:e,shown:t,total:n,scope:r,view:i}){let a=wj();return(0,Q.jsxs)(Y,{to:us(r,Ut(e,i)),onClick:a,"data-slot":`section-cut-link`,"aria-label":`${e}: showing ${t} of ${n}, see all`,title:`The sidebar shows ${t} of ${n} ${e} tasks. Click to see all of them. Change the limit in ${cs(`sidebar`)}.`,className:`mr-auto -ml-1 flex min-h-[44px] min-w-[44px] shrink-0 items-center rounded-[4px] px-1 text-[11px] font-normal text-soft-foreground tabular-nums underline decoration-dotted underline-offset-[3px] hover:text-foreground focus-visible:outline-2 focus-visible:outline-link-foreground md:min-h-[26px] md:min-w-0 no-hover:min-h-[44px] no-hover:min-w-[44px]`,children:[t,` of `,n]})}function _N({id:e,bucket:t,collapsed:n,cut:r,onToggle:i}){let a=t.rows.length;if(t.label===`Archived`)return(0,Q.jsx)(`h2`,{id:e,className:`min-w-0 flex-1 text-[11px] font-medium text-soft-foreground`,children:(0,Q.jsxs)(`span`,{className:`px-[10px] pt-[2px] pb-[4px]`,children:[t.label,` `,a]})});let o=t.label,s=t.rows.map(e=>e.run),c=s.length?fe(kr(s)):null,l=s.some(Yt),u=n?$a:So;return(0,Q.jsx)(`h2`,{id:e,className:k(`min-w-0 text-[11px] font-medium text-soft-foreground`,r?`shrink-0`:`flex-1`),children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`section-toggle`,"aria-expanded":!n,"aria-controls":`${e}-rows`,"aria-label":`${o} ${a}`,onClick:()=>i(o),className:k(`flex min-h-[44px] items-center gap-1.5 rounded-[4px] px-[10px] text-left hover:bg-sidebar-row-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-link-foreground md:min-h-[26px] no-hover:min-h-[44px]`,r?`pr-[4px]`:`w-full`),children:[(0,Q.jsx)(u,{className:`size-[12px] shrink-0`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{children:o}),r?null:(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(`span`,{className:`font-normal tabular-nums`,children:a})]}),c&&(o===`Needs you`||n)?(0,Q.jsx)(J_,{tone:c.tone,shape:c.shape,pulse:c.pulse,role:`img`,"aria-label":c.label,title:c.label}):null,n&&l?(0,Q.jsx)(`span`,{role:`img`,"aria-label":`unread`,title:`Unread tasks`,className:`size-[5px] shrink-0 rounded-full bg-foreground`}):null]})})}function vN({view:e,current:t,onSelect:n,count:r,children:i}){let a=e===t;return(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`view-tab`,"data-view":e,"aria-pressed":a,onClick:()=>n(e),className:k(`flex min-h-11 min-w-0 flex-1 items-center justify-center gap-1.5 rounded-[7px] text-[11px] font-medium text-muted-foreground md:min-h-[22px]`,a&&`bg-card font-semibold text-foreground shadow-xs`),children:[i,r>0?(0,Q.jsx)(`span`,{className:`font-mono text-[11px] tabular-nums`,children:r}):null]})}function yN(){let e=aN(),t=oN();return e||!t}function bN(e){let t=document.createRange();t.selectNodeContents(e);let n=t.getBoundingClientRect?.().width,r=e.querySelector(`[data-reference-width]`),i=r?Math.max(0,Number(r.dataset.referenceWidth)-r.getBoundingClientRect().width):0;return Math.ceil((n||e.scrollWidth)+i)}function xN(e,t,n){let[r,i]=Z.useState(!1),[a,o]=Z.useState(0),s=Z.useRef(!1),c=Z.useRef(!1),l=Z.useRef(null),u=Z.useCallback(e=>{s.current=e,i(e)},[]);return Z.useLayoutEffect(()=>{let r=e.current;if(!t||!r||typeof ResizeObserver>`u`){l.current=null,u(!1);return}let i=!0,a=()=>{if(i){if(l.current?.key!==n){if(s.current){u(!1),o(e=>e+1);return}l.current={key:n,width:bN(r)}}u(l.current.width>r.clientWidth)}};a();let d=new ResizeObserver(a);d.observe(r);let f=new WeakMap,p=new ResizeObserver(e=>{let t=!1;for(let n of e??[]){let e=n.borderBoxSize?.[0]?.inlineSize??n.contentRect.width,r=f.get(n.target);f.set(n.target,e),r!==void 0&&r!==e&&(t=!0)}!t||!i||(l.current=null,a())}),m=new Set,h=()=>{let e=!1;for(let t of[...r.children,...r.querySelectorAll(`[data-slot="reference-list"] [data-slot="pr-chip"], [data-slot="reference-list"] [data-slot="issue-chip"]`)]){let{slot:n}=t.dataset;n===`task-row-age`||t.getAttribute(`aria-hidden`)===`true`||m.has(t)||(m.add(t),f.set(t,t.getBoundingClientRect().width),p.observe(t),e=!0)}return e};h();let g=typeof MutationObserver>`u`?null:new MutationObserver(()=>{!h()||!i||(l.current=null,a())});return g?.observe(r,{childList:!0,subtree:!0}),document.fonts&&document.fonts.status!==`loaded`&&!c.current&&document.fonts.ready.then(()=>{c.current=!0,i&&(l.current=null,a())}),()=>{i=!1,d.disconnect(),p.disconnect(),g?.disconnect()}},[e,t,n,a,u]),t&&r}function SN(){return(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:` · `})}function CN({run:e,queuePosition:t,currentRunId:n,now:r,scope:i,inWorkingGroup:a=!1,onTogglePin:o,onArchiveRun:s}){let c=ds(),l=wj(),u=yN(),d=!!s&&u&&hn(e),f=GM({id:e.id,enabled:d,onArchive:()=>s?.(e)}),p=us(i,`/tasks/${e.id}`),m=fe(e),h=e.id===n,{title:g,displayTitle:_}=uN(e),v=Yt(e),y=lN({run:e,attention:m,queuePosition:t,inWorkingGroup:a,scope:i,now:r}),[b,x]=Z.useState(null);return(0,Q.jsx)(XM,{inertReferences:u,swipeable:d,swipe:f,title:g,onArchive:()=>void s?.(e),children:(0,Q.jsxs)(`div`,{"data-slot":`task-row`,"data-run-id":e.id,"data-active":h?`true`:void 0,onClick:e=>{e.currentTarget.contains(e.target)&&(e.target.closest(`a, button, input`)||(c(p),l?.()))},...d?f.bind:{},style:f.offset?{transform:`translateX(${f.offset}px)`}:void 0,className:k(`selection-row group/task-row flex cursor-pointer items-start gap-2.5 rounded-[6px] py-1.5 pr-2 pl-2.5 hover:bg-sidebar-row-hover`,d&&`select-none`,d&&f.phase!==`dragging`&&`motion-safe:transition-transform motion-safe:duration-200 motion-safe:ease-out`,h&&`bg-sidebar-row-selected hover:bg-sidebar-row-selected`),children:[(0,Q.jsx)(`span`,{"data-slot":`task-row-dot`,className:`flex h-[19px] w-[12px] shrink-0 items-center justify-center`,children:(0,Q.jsx)(J_,{tone:m.tone,shape:m.shape,pulse:m.pulse,"aria-label":m.label,title:m.label,role:`img`})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Q.jsx)(wN,{run:e,to:p,title:g,displayTitle:_,isActive:h,unread:v,swipeable:d,onNavigate:l}),(0,Q.jsx)(TN,{run:e,meta:y,title:g,scope:i,isActive:h,inertReferences:u,overflowContainer:b})]}),y.references.length?(0,Q.jsx)(`span`,{ref:x,"data-slot":`protected-reference-overflow`,className:k(`shrink-0 self-end`,u&&`-my-1.5 self-center`)}):null,e.delegation?.role===`worker`?(0,Q.jsxs)(`span`,{className:`sr-only`,children:[`Worker · `,m.label]}):null,(0,Q.jsx)(YM,{run:e,title:g,unread:v,inertReferences:u,onTogglePin:o,onArchiveRun:s})]})})}function wN({run:e,to:t,title:n,displayTitle:r,isActive:i,unread:a,swipeable:o,onNavigate:s}){return(0,Q.jsxs)(Y,{to:t,onClick:s,title:n,"aria-current":i?`page`:void 0,draggable:!o&&void 0,className:`flex h-[19px] min-w-0 items-center gap-2 rounded-[2px] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`,children:[(0,Q.jsx)(`span`,{"data-slot":`task-row-title`,className:k(`min-w-[7rem] flex-1 truncate text-[13px] leading-[1.45] font-medium text-muted-foreground`,a&&`font-semibold text-foreground`,i&&`text-foreground`),children:r}),e.diffStat?(0,Q.jsx)(Kx,{stat:e.diffStat,className:`hidden shrink-0 text-[12px] @min-[23rem]/sidebar:inline`}):null]})}function TN({run:e,meta:t,title:n,scope:r,isActive:i,inertReferences:a,overflowContainer:o}){let{stateWord:s,references:c,age:l,key:u}=t,d=is(),f=Z.useRef(null),p=xN(f,!!l,u);rN(f,!a&&c.length>0,`${u}|${+!!p}`);let m=[];return s&&m.push((0,Q.jsx)(`span`,{"data-slot":`task-row-state`,children:s},`state`)),c.length&&m.push((0,Q.jsx)(pw,{references:c,maxVisible:2,taskTitle:n,projectId:r??d.projectId,repoBase:d.repoBase,runId:e.id,plain:!0,compact:!0,inertInline:a,fitContainer:!0,overflowContainer:o},`references`)),l&&!p&&m.push((0,Q.jsx)(`span`,{"data-slot":`task-row-age`,className:`tabular-nums`,children:l},`age`)),(0,Q.jsxs)(`div`,{ref:f,"data-slot":`task-row-meta`,className:k(`h-[16px] min-w-0 truncate text-[11.5px] leading-[1.4] font-normal text-soft-foreground`,QM,i&&`text-muted-foreground`),children:[e.notify===!0?(0,Q.jsx)(`span`,{"data-slot":`task-row-notify`,role:`img`,"aria-label":`Notifying the task webhook`,title:`Notifying the task webhook`,className:`mr-[4px] inline-block shrink-0 align-[-1px]`,children:(0,Q.jsx)(bm,{"aria-hidden":`true`,className:`size-[10px]`})}):null,m.length?m.flatMap((e,t)=>t?[(0,Q.jsx)(SN,{},`sep-${t}`),e]:[e]):e.notify===!0?null:`\xA0`]})}function EN({label:e,headingId:t,projectName:n,counts:r,onSweep:i,sweeping:a}){let o=e===`Finished`?`unpinned`:null;if(!o||r[o]===0)return null;let s=a===o,c=`Archive all`;return(0,Q.jsxs)(`button`,{type:`button`,"data-action":`archive-group`,"data-scope":o,disabled:s,"aria-busy":s?`true`:void 0,"aria-label":n?`${c}, ${n}`:void 0,"aria-describedby":t,onClick:()=>i(o),className:`relative inline-flex shrink-0 items-center gap-1 rounded-[4px] px-1.5 py-0.5 font-sans text-[11px] leading-[1.4] text-muted-foreground hover:bg-sidebar-row-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-link-foreground disabled:opacity-60 max-md:before:absolute max-md:before:top-1/2 max-md:before:left-0 max-md:before:h-11 max-md:before:w-full max-md:before:-translate-y-1/2 max-md:before:content-[''] no-hover:before:absolute no-hover:before:top-1/2 no-hover:before:left-0 no-hover:before:h-11 no-hover:before:w-full no-hover:before:-translate-y-1/2 no-hover:before:content-['']`,children:[(0,Q.jsx)(bo,{className:`size-[11px]`,"aria-hidden":`true`}),c]})}function DN({showViewControls:e=!0,projectId:t,boot:n=!1}){let r=wj(),i=t??c(),a=Dn(i,!0,n),o=jn(i,!0,n).data?.sidebarLimits??{},s=Tn(Ir({projectId:i,boot:n})),l=IM(Ir({projectId:i,boot:n}),r),u=mn(),[d,f]=fk(),p=ps(`/tasks/:id/*`),m=ps(`/tasks/:id`),h=eh(3e4),g=br(),_=t??g,v=nn(_),y=ur(Qn(Kt(a.data??[],d),`active`),o),b=_===void 0?[]:y.flatMap(e=>e.rows.flatMap(({run:e})=>Vn(e,v).filter(e=>Mn(e,v)).map(e=>({projectId:_,kind:e.kind,number:e.number}))));return a.data?(0,Q.jsx)(rs,{projectId:_,repoBase:v,requests:b,children:(0,Q.jsx)(pN,{showViewControls:e,sidebarLimits:o,projectId:_==="default"?u.data?.bootProject??null:_??null,runs:a.data,view:d,onViewChange:f,currentRunId:p?.params.id??m?.params.id??null,now:h,onTogglePin:(e,t)=>s.mutate({id:e.id,pinned:t}),onArchiveRun:l.archiveOne,onSweep:e=>l.sweep(e,d===`automations`),sweeping:l.sweeping})}):null}function ON({view:e,onSelect:t,counts:n}){let r=(0,Q.jsx)(J_,{tone:`pending`,pulse:!0,"data-slot":`waiting-dot`,"aria-label":`needs you`});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(vN,{view:`active`,current:e,onSelect:t,count:n.active,children:[`Active`,n.activeWaiting>0&&e!==`active`?r:null]}),(0,Q.jsxs)(vN,{view:`automations`,current:e,onSelect:t,count:n.automations,children:[`Automations`,n.automationsWaiting>0&&e!==`automations`?r:null]})]})}var kN={claude:!0,codex:!0,opencode:!0,pi:!0,cursor:!0,omp:!0},AN=e=>Object.hasOwn(kN,e.name);function jN(e){let t=e.checks.filter(AN);if(t.length&&!t.some(e=>e.available))return`no agent CLI found — install one to run tasks`;let n=t.find(t=>t.name===e.defaultRunner);return n&&!n.available?`default runner (${e.defaultRunner}) not found`:null}function MN(e){let t=`cezar v${e.version}`,n=jN(e);if(n)return`${t} · ${n}`;let r=e.checks.filter(e=>!e.available).map(e=>e.name);return r.length?`${t} · optional: ${r.join(`, `)} not installed`:t}function NN(e){return e.forge?.available?null:e.forge?`GitHub is unreachable — ${e.forge.reason??`unknown reason`}. The GitHub tab is hidden until it comes back.`:`No GitHub remote detected — the GitHub tab is hidden. Every plain-git feature still works.`}function PN({health:e,sessionScope:t}){if(!e)return null;let n=jN(e);return(0,Q.jsxs)(Li,{children:[(0,Q.jsx)(Pi,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`tools-menu-trigger`,"aria-label":`Tools`,title:MN(e),className:`relative flex items-center gap-1.5 rounded-[6px] px-2 py-1.5 text-[12px] font-normal text-soft-foreground transition-colors hover:bg-sidebar-row-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring data-[state=open]:bg-sidebar-row-selected data-[state=open]:text-foreground`,children:[(0,Q.jsx)(ho,{className:`size-[15px]`,"aria-hidden":`true`}),n?(0,Q.jsx)(J_,{tone:`pending`,className:`absolute top-1 left-5 size-1.5`}):null,`Tools`]})}),(0,Q.jsxs)(Fi,{side:`top`,align:`start`,"data-slot":`tools-menu-content`,className:`w-[240px]`,children:[t?(0,Q.jsx)(`div`,{className:`px-2 py-2`,children:t}):null,(0,Q.jsx)(Ci,{className:`text-[11px] font-semibold tracking-[.04em] text-soft-foreground uppercase`,children:`Installed tools`}),e.checks.map(e=>e.available?(0,Q.jsx)(FN,{check:e},e.name):(0,Q.jsx)(IN,{check:e},e.name)),NN(e)?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ji,{}),(0,Q.jsx)(`p`,{"data-slot":`forge-note`,className:`px-2 py-1.5 text-[11px] leading-snug text-muted-foreground`,children:NN(e)})]}):null,(0,Q.jsx)(ji,{}),(0,Q.jsx)(Ai,{asChild:!0,children:(0,Q.jsx)(T,{to:`/tools`,children:`Tools diagnostics`})}),(0,Q.jsx)(Ai,{asChild:!0,children:(0,Q.jsxs)(Y,{to:LD,"data-slot":`tools-settings`,className:`gap-2 text-[13px] text-muted-foreground`,children:[(0,Q.jsx)(eo,{className:`size-3.5`,"aria-hidden":`true`}),`Tool settings`]})})]})]})}function FN({check:e}){return(0,Q.jsxs)(`div`,{"data-slot":`tool-row`,"data-tool":e.name,"data-available":`true`,className:`flex items-center gap-2 rounded-sm px-2 py-1.5`,children:[(0,Q.jsx)(J_,{tone:PD(e)}),(0,Q.jsx)(`span`,{className:`font-mono text-[13px] font-medium`,children:e.name}),(0,Q.jsx)(`span`,{"data-slot":`tool-version`,className:`ml-auto font-mono text-[11px] font-medium text-muted-foreground tabular-nums`,children:e.version??`not found`})]})}function IN({check:e}){let t=ID(e);return(0,Q.jsx)(Ai,{asChild:!0,children:(0,Q.jsxs)(Y,{to:LD,"data-slot":`tool-row`,"data-tool":e.name,"data-available":`false`,className:`flex-col items-stretch gap-1`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(J_,{tone:PD(e)}),(0,Q.jsx)(`span`,{className:`font-mono text-[13px] font-medium`,children:e.name}),(0,Q.jsx)(`span`,{"data-slot":`tool-version`,className:`ml-auto font-mono text-[11px] font-medium text-muted-foreground`,children:`not found`})]}),(0,Q.jsxs)(`span`,{className:`flex items-end justify-between gap-3 pl-[15px]`,children:[t?(0,Q.jsx)(`span`,{"data-slot":`tool-hint`,className:`min-w-0 text-[11px] leading-snug text-muted-foreground`,children:t}):null,(0,Q.jsx)(`span`,{"data-slot":`tool-setup`,className:`ml-auto shrink-0 text-[11px] font-semibold text-accent-text`,children:`Set up →`})]})]})})}function LN(e){return e?.trim()||null}function RN({projectName:e,pageLabel:t}){let n=LN(e),r=LN(t);return n&&r?`${n} — ${r} · cezar`:n?`${n} · cezar`:r?`${r} · cezar`:`cezar`}function zN(e){let t=RN(e);(0,Z.useEffect)(()=>{document.title=t},[t])}function BN(e){let t=hs(e);return/^\/git\/branches(?:\/|$)/.test(t)?`branches`:/^\/git\/not-landed(?:\/|$)/.test(t)?`not-landed`:/^\/git\/cleanup(?:\/|$)/.test(t)?`cleanup`:/^\/git\/changes(?:\/|$)/.test(t)?`changes`:/^\/git(?:\/commits(?:\/[^/]+)?)?\/?$/.test(t)?`main`:null}var VN={main:`/git`,"not-landed":`/git/not-landed`,cleanup:`/git/cleanup`,branches:`/git/branches`,changes:`/git/changes`},HN=`/git?view=repo`,UN={second:`s`,minute:`m`,hour:`h`,day:`d`,week:`w`,month:`mo`,year:`y`};function WN(e){let t=/^(\d+) (second|minute|hour|day|week|month|year)s? ago$/.exec(e.trim());return t?`${t[1]}${UN[t[2]]}`:e}function GN(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}var KN=new Intl.DateTimeFormat(`en-US`,{weekday:`short`,month:`short`,day:`numeric`}),qN=new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,year:`numeric`});function JN(e,t){let n=Date.parse(e);if(Number.isNaN(n))return`Earlier`;let r=GN(t);if(n>=r)return`Today`;if(n>=GN(r-1))return`Yesterday`;let i=new Date(n);return(i.getFullYear()===new Date(t).getFullYear()?KN:qN).format(i)}function YN(e,t=Date.now()){let n=[];for(let r of e){let e=JN(r.at,t),i=n.at(-1);i?.label===e?i.commits.push(r):n.push({label:e,commits:[r]})}return n}function XN(e,t=Date.now()){return e.filter(e=>JN(e.at,t)===`Today`).length}function ZN(e,t){return(e.baseBranch??t.branch)===t.branch?e.tracking:null}function QN(e,t=Date.now()){let n=e.fetchedAt?Io(e.fetchedAt,t):``;return n?`fetched ${n} ago`:`never fetched`}function $N(e,t){let n=z(),r=[e,`repo`],i=[e,`health`],[a,o]=(0,Z.useState)(null),s=e=>K(e.message,{tone:`danger`}),c=()=>Promise.all([n.invalidateQueries({queryKey:r}),n.invalidateQueries({queryKey:i}),n.invalidateQueries({queryKey:B.projects})]),l=V({mutationFn:t=>we(t,e)}),u=async(e=!1)=>{let n=a?.branch??t.branch;try{let t=await l.mutateAsync(e?{branch:n,confirm:!0}:{branch:n});if(`risks`in t){o(t);return}o(null),K(t.summary),await c()}catch(e){o(null),K(e instanceof Error?e.message:String(e),{tone:`danger`}),await c()}},d=V({mutationFn:t=>te({name:t},e),onSuccess:async e=>{K(e.created?`Created and switched to ${e.branch}`:`Switched to ${e.branch}`),await c(),n.setQueryData(r,t=>t?.info?{...t,info:{...t.info,branch:e.branch}}:t),n.setQueryData(i,n=>n?.repo?.root===t.root?{...n,repo:{...n.repo,branch:e.branch}}:n)},onError:s}),f=V({mutationFn:t=>xt({baseBranch:t},e),onSuccess:t=>{K(t.baseBranch?`New tasks now start from ${t.baseBranch}`:`New tasks now start from the checked-out branch`),n.invalidateQueries({queryKey:r}),n.invalidateQueries({queryKey:[e,`config`]})},onError:s});return{hasRemote:!!t.remote,pull:u,pulling:l.isPending,confirmation:a,dismissConfirmation:()=>{l.isPending||o(null)},switchBranch:d,setBase:f}}var eP={sidebar:{card:`gap-[8px] rounded-[8px] p-[10px]`,branchRow:`gap-[6px]`,branchIcon:`size-[14px]`,branch:`text-[12.5px]`,chevron:`size-[12px]`,pull:`h-[24px] gap-[4px] rounded-[6px] px-[8px] text-[11.5px] [&>svg]:size-[12px]`,line:`text-[11px]`,lineChevron:`size-[11px]`,dirty:`gap-[6px] pt-[6px] text-[11px] [&>svg]:size-[12px]`},screen:{card:`gap-[10px] rounded-[10px] p-[12px]`,branchRow:`gap-[8px]`,branchIcon:`size-[16px]`,branch:`text-[14px]`,chevron:`size-[14px]`,pull:`h-[36px] gap-[6px] rounded-[8px] px-[14px] text-[13px] [&>svg]:size-[14px]`,line:`text-[12px]`,lineChevron:`size-[12px]`,dirty:`h-[40px] gap-[8px] pt-[4px] text-[13px] [&>svg:first-child]:size-[14px] [&>svg:last-child]:size-[15px]`}};function tP({scope:e,repo:t,info:n,variant:r,onNavigate:i}){let a=eP[r],o=$N(e,n),s=t.baseBranch??n.branch,c=t.status.length,l=ZN(t,n),u=o.switchBranch.isPending,d=(0,Z.useRef)(null);return(0,Q.jsxs)(`section`,{"aria-label":`Checkout`,"data-slot":`git-checkout`,"data-variant":r,className:k(`flex flex-col border border-border`,a.card),children:[(0,Q.jsxs)(`div`,{className:k(`flex min-w-0 items-center`,a.branchRow),children:[(0,Q.jsxs)(Li,{children:[(0,Q.jsxs)(Pi,{"data-slot":`git-branch-menu`,"aria-label":`Branch ${n.branch}. Switch branch`,disabled:u,className:k(`group flex min-w-0 flex-1 items-center rounded-[4px] text-left outline-none focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-60`,a.branchRow,r===`screen`&&`min-h-11`),children:[(0,Q.jsx)(oo,{"aria-hidden":`true`,className:k(`shrink-0 text-muted-foreground`,a.branchIcon)}),(0,Q.jsx)(`span`,{"data-slot":`git-checkout-branch`,className:k(`min-w-0 flex-1 truncate font-mono font-semibold text-foreground`,a.branch),children:n.branch}),(0,Q.jsx)(So,{"aria-hidden":`true`,className:k(`shrink-0 text-soft-foreground group-hover:text-foreground`,a.chevron)})]}),(0,Q.jsxs)(Fi,{align:`start`,className:`w-64`,children:[(0,Q.jsx)(Ci,{className:`text-xs text-soft-foreground`,children:`Switch branch`}),(0,Q.jsx)(Ii,{value:n.branch,onValueChange:e=>{e!==n.branch&&o.switchBranch.mutate(e)},children:t.branches.map(e=>(0,Q.jsx)(Ti,{value:e,"data-branch":e,className:`font-mono text-[12.5px]`,children:(0,Q.jsx)(`span`,{className:`truncate`,children:e})},e))}),(0,Q.jsx)(ji,{}),(0,Q.jsx)(Ai,{asChild:!0,children:(0,Q.jsx)(Y,{to:VN.branches,"data-slot":`git-branch-menu-all`,onClick:i,children:`Create or find a branch…`})})]})]}),(0,Q.jsxs)(`button`,{ref:d,type:`button`,"data-action":`repo-pull`,disabled:!o.hasRemote||o.pulling,title:o.hasRemote?`Pull ${n.branch}`:`No remote configured. Add a Git remote before pulling.`,onClick:()=>void o.pull(),className:k(`inline-flex shrink-0 items-center bg-muted font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100`,a.pull),children:[o.pulling?(0,Q.jsx)(Bo,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,Q.jsx)(fo,{"aria-hidden":`true`}),`Pull`]})]}),l?(0,Q.jsx)(nP,{tracking:l,className:a.line}):null,(0,Q.jsxs)(Li,{children:[(0,Q.jsxs)(Pi,{"data-slot":`base-branch-picker`,"aria-label":`New tasks start from ${s}. Change the base branch`,disabled:o.setBase.isPending,className:k(`group flex min-w-0 items-center gap-[4px] self-start rounded-[4px] text-soft-foreground outline-none hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-60`,a.line,r===`screen`&&`min-h-[32px]`),children:[(0,Q.jsx)(`span`,{className:`shrink-0`,children:`New tasks start from`}),(0,Q.jsx)(`span`,{"data-slot":`base-branch`,className:`min-w-0 truncate font-mono text-muted-foreground group-hover:text-foreground`,children:s}),(0,Q.jsx)(So,{"aria-hidden":`true`,className:k(`shrink-0`,a.lineChevron)})]}),(0,Q.jsxs)(Fi,{align:`start`,className:`w-64`,children:[(0,Q.jsx)(Ci,{className:`text-xs text-soft-foreground`,children:`New tasks start from`}),(0,Q.jsxs)(Ii,{value:t.baseBranch??``,onValueChange:e=>o.setBase.mutate(e===``?null:e),children:[(0,Q.jsx)(Ti,{value:``,"data-branch":``,className:`text-[12.5px]`,children:`The checked-out branch (default)`}),t.branches.map(e=>(0,Q.jsx)(Ti,{value:e,"data-branch":e,className:`font-mono text-[12.5px]`,children:(0,Q.jsx)(`span`,{className:`truncate`,children:e})},e))]})]})]}),c>0?(0,Q.jsxs)(Y,{to:VN.changes,"data-slot":`git-uncommitted`,onClick:i,className:k(`flex min-w-0 items-center border-t border-border text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`,a.dirty),children:[(0,Q.jsx)(Qa,{"aria-hidden":`true`,className:`shrink-0 text-inbox-count-foreground`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[c,` uncommitted file`,c===1?``:`s`]}),(0,Q.jsx)($a,{"aria-hidden":`true`,className:`shrink-0 text-soft-foreground`})]}):null,(0,Q.jsx)(rP,{checkout:o,returnFocus:d})]})}function nP({tracking:e,className:t}){let n=e.ref.split(`/`)[0]||e.ref,r=QN(e);return(0,Q.jsx)(`p`,{"data-slot":`git-freshness`,className:k(`flex min-w-0 items-center gap-[4px] text-soft-foreground`,t),children:e.behind>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{"data-slot":`git-behind`,className:`shrink-0 font-medium text-inbox-count-foreground`,children:[e.behind,` behind `,n]}),(0,Q.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`· `,r]})]}):(0,Q.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`up to date · `,r]})})}function rP({checkout:e,returnFocus:t}){return(0,Q.jsx)(ra,{open:e.confirmation!==null,onOpenChange:t=>!t&&e.dismissConfirmation(),children:(0,Q.jsxs)(Yi,{onCloseAutoFocus:e=>{e.preventDefault(),t.current?.focus()},children:[(0,Q.jsxs)(na,{children:[(0,Q.jsxs)(Wi,{children:[`Pull `,e.confirmation?.branch,` anyway?`]}),(0,Q.jsx)(Ui,{asChild:!0,children:(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[e.confirmation?.risks.includes(`active_runs`)?(0,Q.jsx)(`p`,{children:`An active session is using this repository. Pulling can change files while it works.`}):null,e.confirmation?.risks.includes(`dirty_tree`)?(0,Q.jsx)(`p`,{children:`The checkout has dirty files. Git may refuse the pull to protect them.`}):null]})})]}),(0,Q.jsxs)($i,{children:[(0,Q.jsx)(ta,{className:`h-11`,disabled:e.pulling,children:`Cancel`}),(0,Q.jsx)(Qi,{className:`h-11`,disabled:e.pulling||e.confirmation===null,onClick:t=>{t.preventDefault(),e.pull(!0)},children:e.pulling?`Pulling…`:`Pull anyway`})]})]})})}var iP={main:Ra,"not-landed":em,cleanup:Op,branches:oo};function aP(e,t){switch(e){case`main`:return t?`Recently on ${t}`:`Recent commits`;case`not-landed`:return`Not landed`;case`cleanup`:return`Cleanup`;case`branches`:return`All branches`;case`changes`:return`Uncommitted changes`}}var oP=[`main`,`not-landed`,`cleanup`,`branches`];function sP({branch:e,counts:t,variant:n,active:r,onNavigate:i}){let a=n===`screen`;return(0,Q.jsx)(`nav`,{"aria-label":`Git sections`,"data-slot":`git-sections`,className:a?Ho:Vo,children:oP.map(n=>{let o=iP[n],s=!a&&r===n,c=t[n];return(0,Q.jsxs)(Y,{to:a&&n===`main`?HN:VN[n],"data-git-section":n,"aria-current":s?`page`:void 0,onClick:i,className:k(a?Uo:k(qo,`text-[12.5px]`),Ko,s&&`bg-sidebar-row-selected text-foreground font-medium hover:bg-sidebar-row-selected`),children:[(0,Q.jsx)(o,{"aria-hidden":`true`,className:a?$o:Yo}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:aP(n,e)}),c?(0,Q.jsx)(`span`,{"data-slot":`git-section-count`,className:a?Jo:Wo,children:c}):null,a?(0,Q.jsx)($a,{"aria-hidden":`true`,className:Qo}):null]},n)})})}async function cP(e,t){return ae(await ut.api.v1.p[`:projectId`].repo.branches.counts.$get({param:{projectId:t??c()}},Pt(e)),`/repo/branches/counts`)}function lP(e){return Rr({queryKey:[e,`repo`,`branches`,`counts`],queryFn:({signal:t})=>cP({signal:t},e)})}function uP(e,t,n){let r=_n(e),i=lP(e),a=r.data?.totalBytes??null,o=i.data?.counts??null,s=t&&n===`screen`?XN(t.log):0;return{main:s>0?`${s} today`:null,"not-landed":o?.notLanded?String(o.notLanded):null,cleanup:a?An(a):r.data&&a===null&&o?.cleanup?String(o.cleanup):null,branches:t?String(i.data?.allBranches??t.branches.length):null}}function dP({scope:e}){let t=_r(e),{pathname:n}=a(),r=wj(),i=t.data?.info?t.data:null,o=uP(e,i,`sidebar`);return(0,Q.jsxs)(`div`,{"data-slot":`git-sidebar`,role:`region`,"aria-label":`Git`,className:es,children:[i?.info?(0,Q.jsx)(tP,{scope:e,repo:i,info:i.info,variant:`sidebar`,onNavigate:r},e):t.isPending?(0,Q.jsx)(`div`,{"data-slot":`git-checkout-placeholder`,"aria-hidden":`true`,className:`h-[94px] rounded-[8px] border border-border`}):null,t.isPending?null:(0,Q.jsx)(sP,{branch:i?.info?.branch??null,counts:o,variant:`sidebar`,active:BN(n),onNavigate:r})]})}var fP={assigned:Co,"no-task":ts,"has-task":Za,all:lo,review:ns,mine:Pa,failing:qa,"all-prs":lo};function pP(e,t){return e===`assigned`||e===`mine`?t.identity:e===`no-task`||e===`has-task`?t.tasks:null}function mP({model:e,variant:t,activeId:n,onNavigate:r}){let i=t===`screen`;return(0,Q.jsx)(Q.Fragment,{children:[{key:`issues`,label:`Issues`,rows:_a},{key:`prs`,label:`Pull requests`,rows:fa}].map(t=>(0,Q.jsxs)(`nav`,{"aria-label":t.label,"data-slot":`github-filter-group`,"data-group":t.key,className:i?Ho:k(Go,t.key===`prs`&&`pt-[6px]`),children:[(0,Q.jsx)(`h3`,{className:i?Xo:Zo,children:t.label}),t.rows.map(({id:t,label:a})=>{let o=fP[t],s=n===t,c=pP(t,e.blocked),l=e.counts[t],u=pa(l),d=k(i?Uo:k(qo,`text-[12.5px]`),c?`cursor-not-allowed opacity-60`:Ko,s&&`bg-sidebar-row-selected text-foreground font-medium hover:bg-sidebar-row-selected`),f=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(o,{"aria-hidden":`true`,className:i?$o:Yo}),(0,Q.jsx)(`span`,{className:`truncate`,children:a}),u?(0,Q.jsx)(`span`,{"data-slot":`gh-filter-count`,title:ga(t,l),className:i?Jo:Wo,children:u}):null,i?(0,Q.jsx)($a,{"aria-hidden":`true`,className:k(Qo,!u&&`ml-auto`)}):null]});if(c)return(0,Q.jsxs)(`div`,{"data-gh-filter":t,"aria-disabled":`true`,title:c,className:d,children:[f,(0,Q.jsx)(`span`,{className:`sr-only`,children:c})]},t);let{view:p,filter:m}=la(t);return(0,Q.jsx)(Y,{to:ya(p,m),"data-gh-filter":t,"aria-current":s?`page`:void 0,onClick:r,className:d,children:f},t)})]},t.key))})}function hP(e){let t=Zt(e,50).data,n=t?.available===!0,r=Dn(e,!0,e==="default"),i=an(e,`pr`,sa,n),a=an(e,`pr`,ha,n),o=(0,Z.useMemo)(()=>r.data?ua(r.data,t?.repo,e):null,[r.data,t?.repo,e]);return{gh:t,counts:(0,Z.useMemo)(()=>va({gh:t,tasks:o,review:i.data,failing:a.data}),[t,o,i.data,a.data]),blocked:{identity:t?.available===!0&&!t.viewerLogin?`GitHub login unavailable.`:null,tasks:r.isError&&!r.data?`Task list unavailable.`:null}}}function gP(e){return/^\/github\/prs(?:\/|$)/.test(hs(e))?`prs`:`issues`}function _P({scope:e}){let t=hP(e),{pathname:n}=a(),[r]=o(),i=wj(),s=gP(n);return(0,Q.jsx)(`div`,{"data-slot":`github-sidebar`,role:`region`,"aria-label":`GitHub`,className:es,children:(0,Q.jsx)(mP,{model:t,variant:`sidebar`,activeId:da(s,ma(s,r.get(`filter`))),onNavigate:i})})}function vP({projectId:e,projectName:t,capabilities:n}){return(0,Q.jsx)(`div`,{"data-slot":`settings-sidebar`,className:es,children:[`project`,`global`].map(r=>{let i=r===`project`?`This project${t?` · ${t}`:``}`:`Global · every project`,a=r===`project`?`/p/${encodeURIComponent(e)}/settings`:`/settings/global`,o=qb(r,n).map(e=>({id:e.id,title:e.title,icon:e.icon,to:`${a}/${e.id}`})),s=r===`project`?[{id:`general`,title:`General`,icon:eo,to:a},...o]:o;return(0,Q.jsxs)(`nav`,{"aria-label":i,"data-slot":`settings-nav`,"data-scope":r,className:k(`flex flex-col gap-px`,r===`global`&&`pt-[6px]`),children:[(0,Q.jsx)(`h3`,{title:i,className:Zo,children:i}),s.map(({id:e,title:t,icon:n,to:r})=>(0,Q.jsxs)(C,{to:r,end:!0,"data-section":e,className:({isActive:e})=>k(qo,Ko,e&&`bg-sidebar-row-selected text-foreground font-medium hover:bg-sidebar-row-selected`),children:[(0,Q.jsx)(n,{"aria-hidden":`true`,className:Yo}),(0,Q.jsx)(`span`,{className:`truncate`,children:t})]},e))]},r)})})}function yP(e){let t=e?.repo;if(!t)return null;let n=t.root.replace(/[\\/]+$/,``).split(/[\\/]/).pop();return n?{name:n,branch:t.branch}:null}function bP({children:e}){let{pathname:t}=a(),n=_s(),r=mn(),i=(0,Z.useRef)(void 0);r.data&&(i.current=r.data);let o=r.data??i.current,s=qj(o),c=o?.capabilities.automations===!0,l=It(),u=l.data,d=EM(),f=MO(),p=sO(t),m=u?.bootProject??r.data?.bootProject??null,h=n??m??`default`,g=h===m,_=Dn(h,!0,g),v=n!==null&&n===m,y=u?.projects.find(e=>e.id===n),b=Dn(n??``,y!==void 0&&p.taskId!==null,u?.bootProject===n).data,x=t===`/tools`||t===`/settings/global`||t.startsWith(`/settings/global/`),S=x?null:y?.name??(v?yP(r.data)?.name??null:null),C=p.taskId?b?.find(e=>e.id===p.taskId):void 0,w=C?xn(C):p.pageLabel;zN({projectName:S,pageLabel:w});let T=y?y.forge===`github`:r.data?.forge?.available===!0,E=hs(t),D=/^\/settings(?:\/|$)/.test(E)?(0,Q.jsx)(vP,{projectId:h,projectName:u?.projects.find(e=>e.id===h)?.name??(g?yP(r.data)?.name??null:null),capabilities:r.data?.capabilities}):/^\/github(?:\/|$)/.test(E)&&T?(0,Q.jsx)(_P,{scope:Ir({projectId:h,boot:g}).cacheScope}):/^\/git(?:\/|$)/.test(E)?(0,Q.jsx)(dP,{scope:Ir({projectId:h,boot:g}).cacheScope}):void 0;return(0,Q.jsxs)(dk,{children:[(0,Q.jsx)(Dj,{repo:t===`/tools`?yP(r.data):x?null:y?{name:y.name,branch:y.id===m?r.data?.repo?.branch??``:``}:yP(r.data),breadcrumb:{project:t===`/tools`?`Workspace`:S,page:C?`Tasks / ${w}`:w??`Cezarion`,branch:C?.worktreePath?`Isolated worktree`:void 0},version:o?.version??null,latestVersion:o?.latestVersion??null,applicationUpdate:o?.applicationUpdate,onApplyUpdate:s.apply,onRestart:s.restart,applicationUpdateError:s.error,applicationUpdateBusy:s.busy,applicationUpdateOffline:s.offline||r.isError,forgeAvailable:T,automationsAvailable:c,banner:(0,Q.jsx)(tM,{}),sidebarList:D,taskQuickList:(0,Q.jsx)(DN,{projectId:h,boot:g}),sidebarProjectId:h,projectHeader:(0,Q.jsx)(lx,{}),mobileProjects:d,needsYou:Pn(_.data??[]).waiting>0,toolsMenu:(0,Q.jsx)(PN,{health:r.data}),toolsStatus:r.data?{blocked:jN(r.data)!==null,note:NN(r.data)}:null,projectRail:d?(0,Q.jsx)(TM,{...d,projectTarget:f.target,onSwitchProject:e=>void f.go(e),version:o?.version??null}):l.isPending?(0,Q.jsx)(CM,{}):null,children:e}),(0,Q.jsx)(wA,{})]})}function xP(){let e=a(),t=It();return jO(),(0,Z.useEffect)(()=>{let n=Im(e,t.data);n!==null&&(Rm(jm(),n)||Mm(n),Rm(Vm(n.projectId),n)||Hm(n))},[e.hash,e.pathname,e.search,t.data]),null}function SP(){let e=z(),t=$y(Ht().data?.notifications).enabled,n=(0,Z.useRef)(t);return n.current=t,(0,Z.useEffect)(()=>{let t=e.getQueryCache(),r=new Map,i=new Map,a=new Map,o=new Set,s=new Map,c=0,l=e=>e.length===3&&typeof e[0]==`string`&&e[1]===`runs`&&e[2]===`list`,u=()=>{let e=new Set([...r.values()].flatMap(e=>[...e.keys()]));for(let t of i.keys())e.has(t)||(i.delete(t),a.delete(t),o.delete(t))},d=(e,t,s=!1,l=1/0)=>{let d=r.get(e),{statuses:f}=tb(new Map,t),p=t.filter(e=>{if((a.get(e.id)??0)>l)return!1;let t=d?.get(e.id),n=f.get(e.id),r=l===1/0?t:i.get(e.id);return t!==void 0&&r!==void 0&&(r.status!==n.status||r.wantsAttention!==n.wantsAttention)}),{entering:m,statuses:h}=tb(i,p);for(let[e,t]of f)!d?.has(e)&&!o.has(e)&&(a.get(e)??0)<=l&&(i.set(e,t),a.set(e,++c));for(let[e,t]of h){let n=i.get(e);n?.status===t.status&&n.wantsAttention===t.wantsAttention||(i.set(e,t),a.set(e,++c),o.add(e))}if(r.set(e,f),u(),!s&&m.length!==0&&nb({enabled:n.current,hidden:document.visibilityState===`hidden`,permission:eb()}))for(let e of m)CP(e)};for(let e of t.getAll().sort((e,t)=>e.state.dataUpdatedAt-t.state.dataUpdatedAt))l(e.queryKey)&&Array.isArray(e.state.data)&&d(e.queryHash,e.state.data,!0);return t.subscribe(e=>{if(l(e.query.queryKey)){if(e.type===`removed`)r.delete(e.query.queryHash),s.delete(e.query.queryHash),u();else if(e.type===`updated`&&(e.action.type===`fetch`&&s.set(e.query.queryHash,c),e.action.type===`success`&&Array.isArray(e.query.state.data))){let t=e.action.manual?1/0:s.get(e.query.queryHash)??0;d(e.query.queryHash,e.query.state.data,!1,t),e.action.manual||s.delete(e.query.queryHash)}}})},[e]),null}function CP(e){let t=globalThis.Notification;if(typeof t!=`function`)return;let n=rb(e);try{new t(n.title,{body:n.body,tag:n.tag})}catch{}}function wP(){let[e]=(0,Z.useState)(El);return(0,Z.useEffect)(()=>ri(e),[e]),(0,Q.jsx)(Dl,{children:(0,Q.jsx)(L,{client:e,children:(0,Q.jsxs)(Sl,{children:[(0,Q.jsx)(SP,{}),(0,Q.jsx)(My,{children:(0,Q.jsx)(vy,{children:(0,Q.jsxs)(g,{children:[(0,Q.jsx)(xP,{}),(0,Q.jsx)(ss,{children:(0,Q.jsx)(bP,{children:(0,Q.jsx)(uO,{})})}),(0,Q.jsx)(si,{})]})})})]})})})}function TP(){return(document.querySelector(`meta[name="cez-api-base"]`)?.getAttribute(`content`))?.trim()||``}u(TP());var EP=document.getElementById(`root`);if(!EP)throw Error(`cezar: #root container is missing from index.html`);(0,Ic.createRoot)(EP).render((0,Q.jsx)(Z.StrictMode,{children:(0,Q.jsx)(wP,{})}));export{Zy as $,Op as $t,eC as A,rh as At,yS as B,hm as Bt,KA as C,Bg as Ct,bC as D,Sh as Dt,VT as E,Ch as Et,mS as F,Om as Ft,$x as G,em as Gt,pS as H,um as Ht,xS as I,Tm as It,Xx as J,Bp as Jt,Qx as K,Yp as Kt,gS as L,Cm as Lt,kS as M,eh as Mt,OS as N,Gm as Nt,tC as O,wh as Ot,vS as P,Wm as Pt,px as Q,Ap as Qt,uS as R,bm as Rt,GA as S,Vg as St,$ as T,Ig as Tt,_S as U,sm as Ut,SS as V,dm as Vt,sS as W,tm as Wt,fx as X,Mp as Xt,Kx as Y,Np as Yt,mx as Z,jp as Zt,sj as _,Qg as _t,aP as a,J_ as at,WA as b,Wg as bt,$N as c,C_ as ct,ZN as d,x_ as dt,Tp as en,zy as et,QN as f,D_ as ft,aj as g,e_ as gt,oN as h,h_ as ht,sP as i,tv as it,nC as j,ih as jt,rC as k,yh as kt,HN as l,w_ as lt,WN as m,m_ as mt,mP as n,Hf as nn,rv as nt,tP as o,B_ as ot,YN as p,p_ as pt,Zx as q,Gp as qt,uP as r,nv as rt,rP as s,R_ as st,hP as t,Cp as tn,Iy as tt,VN as u,T_ as ut,ij as v,Yg as vt,ck as w,Lg as wt,qA as x,Hg as xt,zA as y,Gg as yt,lS as z,_m as zt};